skir-converter 0.1.4 → 0.1.5
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var SkirFormatConverter=function(e){"use strict";const t=1024;let n=0,i=class{constructor(e,t){this.from=e,this.to=t}};class s{constructor(e={}){this.id=n++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof e&&(e=a.match(e)),t=>{let n=e(t);return void 0===n?null:[this,n]}}}s.closedBy=new s({deserialize:e=>e.split(" ")}),s.openedBy=new s({deserialize:e=>e.split(" ")}),s.group=new s({deserialize:e=>e.split(" ")}),s.isolate=new s({deserialize:e=>{if(e&&"rtl"!=e&&"ltr"!=e&&"auto"!=e)throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}}),s.contextHash=new s({perNode:!0}),s.lookAhead=new s({perNode:!0}),s.mounted=new s({perNode:!0});class r{constructor(e,t,n,i=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=i}static get(e){return e&&e.props&&e.props[s.mounted.id]}}const o=Object.create(null);class a{constructor(e,t,n,i=0){this.name=e,this.props=t,this.id=n,this.flags=i}static define(e){let t=e.props&&e.props.length?Object.create(null):o,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(null==e.name?8:0),i=new a(e.name||"",t,e.id,n);if(e.props)for(let n of e.props)if(Array.isArray(n)||(n=n(i)),n){if(n[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[n[0].id]=n[1]}return i}prop(e){return this.props[e.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(e){if("string"==typeof e){if(this.name==e)return!0;let t=this.prop(s.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let i of n.split(" "))t[i]=e[n];return e=>{for(let n=e.prop(s.group),i=-1;i<(n?n.length:0);i++){let s=t[i<0?e.name:n[i]];if(s)return s}}}}a.none=new a("",Object.create(null),0,8);class l{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let n of this.types){let i=null;for(let t of e){let e=t(n);if(e){i||(i=Object.assign({},n.props));let t=e[1],s=e[0];s.combine&&s.id in i&&(t=s.combine(i[s.id],t)),i[s.id]=t}}t.push(i?new a(n.name,i,n.id,n.flags):n)}return new l(t)}}const c=new WeakMap,h=new WeakMap;var u;!function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays",e[e.EnterBracketed=16]="EnterBracketed"}(u||(u={}));class d{constructor(e,t,n,i,s){if(this.type=e,this.children=t,this.positions=n,this.length=i,this.props=null,s&&s.length){this.props=Object.create(null);for(let[e,t]of s)this.props["number"==typeof e?e:e.id]=t}}toString(){let e=r.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let e of this.children){let n=e.toString();n&&(t&&(t+=","),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new A(this.topNode,e)}cursorAt(e,t=0,n=0){let i=c.get(this)||this.topNode,s=new A(i);return s.moveTo(e,t),c.set(this,s._tree),s}get topNode(){return new v(this,0,0,null)}resolve(e,t=0){let n=g(c.get(this)||this.topNode,e,t,!1);return c.set(this,n),n}resolveInner(e,t=0){let n=g(h.get(this)||this.topNode,e,t,!0);return h.set(this,n),n}resolveStack(e,t=0){return function(e,t,n){let i=e.resolveInner(t,n),s=null;for(let e=i instanceof v?i:i.context.parent;e;e=e.parent)if(e.index<0){let r=e.parent;(s||(s=[i])).push(r.resolve(t,n)),e=r}else{let o=r.get(e.tree);if(o&&o.overlay&&o.overlay[0].from<=t&&o.overlay[o.overlay.length-1].to>=t){let r=new v(o.tree,o.overlay[0].from+e.from,-1,e);(s||(s=[i])).push(g(r,t,n,!1))}}return s?S(s):i}(this,e,t)}iterate(e){let{enter:t,leave:n,from:i=0,to:s=this.length}=e,r=e.mode||0,o=(r&u.IncludeAnonymous)>0;for(let e=this.cursor(r|u.IncludeAnonymous);;){let r=!1;if(e.from<=s&&e.to>=i&&(!o&&e.type.isAnonymous||!1!==t(e))){if(e.firstChild())continue;r=!0}for(;r&&n&&(o||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;r=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:E(a.none,this.children,this.positions,0,this.children.length,0,this.length,(e,t,n)=>new d(this.type,e,t,n,this.propValues),e.makeTree||((e,t,n)=>new d(a.none,e,t,n)))}static build(e){return function(e){var n;let{buffer:i,nodeSet:r,maxBufferLength:o=t,reused:a=[],minRepeatType:l=r.types.length}=e,c=Array.isArray(i)?new f(i,i.length):i,h=r.types,u=0,m=0;function g(e,t,n,i,s,d){let{id:f,start:S,end:C,size:A}=c,T=m,O=u;if(A<0){if(c.next(),-1==A){let t=a[f];return n.push(t),void i.push(S-e)}if(-3==A)return void(u=f);if(-4==A)return void(m=f);throw new RangeError(`Unrecognized record size: ${A}`)}let M,N,D=h[f],_=S-e;if(C-S<=o&&(N=k(c.pos-t,s))){let t=new Uint16Array(N.size-N.skip),n=c.pos-N.size,i=t.length;for(;c.pos>n;)i=x(N.start,t,i);M=new p(t,C-N.start,r),_=N.start-e}else{let e=c.pos-A;c.next();let t=[],n=[],i=f>=l?f:-1,s=0,r=C;for(;c.pos>e;)i>=0&&c.id==i&&c.size>=0?(c.end<=r-o&&(b(t,n,S,s,c.end,r,i,T,O),s=t.length,r=c.end),c.next()):d>2500?y(S,e,t,n):g(S,e,t,n,i,d+1);if(i>=0&&s>0&&s<t.length&&b(t,n,S,s,S,r,i,T,O),t.reverse(),n.reverse(),i>-1&&s>0){let e=v(D,O);M=E(D,t,n,0,t.length,0,C-S,e,e)}else M=w(D,t,n,C-S,T-C,O)}n.push(M),i.push(_)}function y(e,t,n,i){let s=[],a=0,l=-1;for(;c.pos>t;){let{id:e,start:t,end:n,size:i}=c;if(i>4)c.next();else{if(l>-1&&t<l)break;l<0&&(l=n-o),s.push(e,t,n),a++,c.next()}}if(a){let t=new Uint16Array(4*a),o=s[s.length-2];for(let e=s.length-3,n=0;e>=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-o,t[n++]=s[e+2]-o,t[n++]=n;n.push(new p(t,s[2]-o,r)),i.push(o-e)}}function v(e,t){return(n,i,r)=>{let o,a,l=0,c=n.length-1;if(c>=0&&(o=n[c])instanceof d){if(!c&&o.type==e&&o.length==r)return o;(a=o.prop(s.lookAhead))&&(l=i[c]+o.length+a)}return w(e,n,i,r,l,t)}}function b(e,t,n,i,s,o,a,l,c){let h=[],u=[];for(;e.length>i;)h.push(e.pop()),u.push(t.pop()+n-s);e.push(w(r.types[a],h,u,o-s,l-o,c)),t.push(s-n)}function w(e,t,n,i,r,o,a){if(o){let e=[s.contextHash,o];a=a?[e].concat(a):[e]}if(r>25){let e=[s.lookAhead,r];a=a?[e].concat(a):[e]}return new d(e,t,n,i,a)}function k(e,t){let n=c.fork(),i=0,s=0,r=0,a=n.end-o,h={size:0,start:0,skip:0};e:for(let o=n.pos-e;n.pos>o;){let e=n.size;if(n.id==t&&e>=0){h.size=i,h.start=s,h.skip=r,r+=4,i+=4,n.next();continue}let c=n.pos-e;if(e<0||c<o||n.start<a)break;let u=n.id>=l?4:0,d=n.start;for(n.next();n.pos>c;){if(n.size<0){if(-3!=n.size&&-4!=n.size)break e;u+=4}else n.id>=l&&(u+=4);n.next()}s=d,i+=e,r+=u}return(t<0||i==e)&&(h.size=i,h.start=s,h.skip=r),h.size>4?h:void 0}function x(e,t,n){let{id:i,start:s,end:r,size:o}=c;if(c.next(),o>=0&&i<l){let a=n;if(o>4){let i=c.pos-(o-4);for(;c.pos>i;)n=x(e,t,n)}t[--n]=a,t[--n]=r-e,t[--n]=s-e,t[--n]=i}else-3==o?u=i:-4==o&&(m=i);return n}let S=[],C=[];for(;c.pos>0;)g(e.start||0,e.bufferStart||0,S,C,-1,0);let A=null!==(n=e.length)&&void 0!==n?n:S.length?C[0]+S[0].length:0;return new d(h[e.topID],S.reverse(),C.reverse(),A)}(e)}}d.empty=new d(a.none,[],[],0);class f{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new f(this.buffer,this.index)}}class p{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return a.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],n=this.buffer[e+3],i=this.set.types[t],s=i.name;if(/\W/.test(s)&&!i.isError&&(s=JSON.stringify(s)),n==(e+=4))return s;let r=[];for(;e<n;)r.push(this.childString(e)),e=this.buffer[e+3];return s+"("+r.join(",")+")"}findChild(e,t,n,i,s){let{buffer:r}=this,o=-1;for(let a=e;a!=t&&!(m(s,i,r[a+1],r[a+2])&&(o=a,n>0));a=r[a+3]);return o}slice(e,t,n){let i=this.buffer,s=new Uint16Array(t-e),r=0;for(let o=e,a=0;o<t;){s[a++]=i[o++],s[a++]=i[o++]-n;let t=s[a++]=i[o++]-n;s[a++]=i[o++]-e,r=Math.max(r,t)}return new p(s,r,this.set)}}function m(e,t,n,i){switch(e){case-2:return n<t;case-1:return i>=t&&n<t;case 0:return n<t&&i>t;case 1:return n<=t&&i>t;case 2:return i>t;case 4:return!0}}function g(e,t,n,i){for(var s;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!i&&e instanceof v&&e.index<0?null:e.parent;if(!t)return e;e=t}let r=i?0:u.IgnoreOverlays;if(i)for(let i=e,o=i.parent;o;i=o,o=i.parent)i instanceof v&&i.index<0&&(null===(s=o.enter(t,n,r))||void 0===s?void 0:s.from)!=i.from&&(e=o);for(;;){let i=e.enter(t,n,r);if(!i)return e;e=i}}class y{cursor(e=0){return new A(this,e)}getChild(e,t=null,n=null){let i=b(this,e,t,n);return i.length?i[0]:null}getChildren(e,t=null,n=null){return b(this,e,t,n)}resolve(e,t=0){return g(this,e,t,!1)}resolveInner(e,t=0){return g(this,e,t,!0)}matchContext(e){return w(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}}class v extends y{constructor(e,t,n,i){super(),this._tree=e,this.from=t,this.index=n,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,n,i,s=0){for(let o=this;;){for(let{children:a,positions:l}=o._tree,c=t>0?a.length:-1;e!=c;e+=t){let c,h=a[e],f=l[e]+o.from;if(s&u.EnterBracketed&&h instanceof d&&(c=r.get(h))&&!c.overlay&&c.bracketed&&n>=f&&n<=f+h.length||m(i,n,f,f+h.length))if(h instanceof p){if(s&u.ExcludeBuffers)continue;let r=h.findChild(0,h.buffer.length,t,n-f,i);if(r>-1)return new x(new k(o,h,e,f),null,r)}else if(s&u.IncludeAnonymous||!h.type.isAnonymous||T(h)){let a;if(!(s&u.IgnoreMounts)&&(a=r.get(h))&&!a.overlay)return new v(a.tree,f,e,o);let l=new v(h,f,e,o);return s&u.IncludeAnonymous||!l.type.isAnonymous?l:l.nextChild(t<0?h.children.length-1:0,t,n,i,s)}}if(s&u.IncludeAnonymous||!o.type.isAnonymous)return null;if(e=o.index>=0?o.index+t:t<0?-1:o._parent._tree.children.length,o=o._parent,!o)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,n=0){let i;if(!(n&u.IgnoreOverlays)&&(i=r.get(this._tree))&&i.overlay){let s=e-this.from,r=n&u.EnterBracketed&&i.bracketed;for(let{from:e,to:n}of i.overlay)if((t>0||r?e<=s:e<s)&&(t<0||r?n>=s:n>s))return new v(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function b(e,t,n,i){let s=e.cursor(),r=[];if(!s.firstChild())return r;if(null!=n)for(let e=!1;!e;)if(e=s.type.is(n),!s.nextSibling())return r;for(;;){if(null!=i&&s.type.is(i))return r;if(s.type.is(t)&&r.push(s.node),!s.nextSibling())return null==i?r:[]}}function w(e,t,n=t.length-1){for(let i=e;n>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(t[n]&&t[n]!=i.name)return!1;n--}}return!0}class k{constructor(e,t,n,i){this.parent=e,this.buffer=t,this.index=n,this.start=i}}class x extends y{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.context.start,n);return s<0?null:new x(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,n=0){if(n&u.ExcludeBuffers)return null;let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new x(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new x(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new x(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,i=this.index+4,s=n.buffer[this.index+3];if(s>i){let r=n.buffer[this.index+1];e.push(n.slice(i,s,r)),t.push(0)}return new d(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function S(e){if(!e.length)return null;let t=0,n=e[0];for(let i=1;i<e.length;i++){let s=e[i];(s.from>n.from||s.to<n.to)&&(n=s,t=i)}let i=n instanceof v&&n.index<0?null:n.parent,s=e.slice();return i?s[t]=i:s.splice(t,1),new C(s,n)}class C{constructor(e,t){this.heads=e,this.node=t}get next(){return S(this.heads)}}class A{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~u.EnterBracketed,e instanceof v)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return!!e&&(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0)}yieldBuf(e,t){this.index=e;let{start:n,buffer:i}=this.buffer;return this.type=t||i.set.types[i.buffer[e]],this.from=n+i.buffer[e+1],this.to=n+i.buffer[e+2],!0}yield(e){return!!e&&(e instanceof v?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:i}=this.buffer,s=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.buffer.start,n);return!(s<0)&&(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?!(n&u.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&u.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&u.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode));let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:i}=this;if(i){if(e>0){if(this.index<i.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(i.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=i)}else({index:t,_parent:n}=this._tree);for(;n;({index:t,_parent:n}=n))if(t>-1)for(let i=t+e,s=e<0?-1:n._tree.children.length;i!=s;i+=e){let e=n._tree.children[i];if(this.mode&u.IncludeAnonymous||e instanceof p||!e.type.isAnonymous||T(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)e:for(let i=this.index,s=this.stack.length;s>=0;){for(let r=e;r;r=r._parent)if(r.index==i){if(i==this.index)return r;t=r,n=s+1;break e}i=this.stack[--s]}for(let e=n;e<this.stack.length;e++)t=new x(this.buffer,t,this.stack[e]);return this.bufferNode=new x(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let i=!1;if(this.type.isAnonymous||!1!==e(this)){if(this.firstChild()){n++;continue}this.type.isAnonymous||(i=!0)}for(;;){if(i&&t&&t(this),i=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,i=!0}}}matchContext(e){if(!this.buffer)return w(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let i=e.length-1,s=this.stack.length-1;i>=0;s--){if(s<0)return w(this._tree,e,i);let r=n[t.buffer[this.stack[s]]];if(!r.isAnonymous){if(e[i]&&e[i]!=r.name)return!1;i--}}return!0}}function T(e){return e.children.some(e=>e instanceof p||!e.type.isAnonymous||T(e))}const O=new WeakMap;function M(e,t){if(!e.isAnonymous||t instanceof p||t.type!=e)return 1;let n=O.get(t);if(null==n){n=1;for(let i of t.children){if(i.type!=e||!(i instanceof d)){n=1;break}n+=M(e,i)}O.set(t,n)}return n}function E(e,t,n,i,s,r,o,a,l){let c=0;for(let n=i;n<s;n++)c+=M(e,t[n]);let h=Math.ceil(1.5*c/8),u=[],d=[];return function t(n,i,s,o,a){for(let c=s;c<o;){let s=c,f=i[c],p=M(e,n[c]);for(c++;c<o;c++){let t=M(e,n[c]);if(p+t>=h)break;p+=t}if(c==s+1){if(p>h){let e=n[s];t(e.children,e.positions,0,e.children.length,i[s]+a);continue}u.push(n[s])}else{let t=i[c-1]+n[c-1].length-f;u.push(E(e,n,i,s,c,f,t,null,l))}d.push(f+a-r)}}(t,n,i,s,0),(a||l)(u,d,o)}class N{constructor(e,t,n,i,s=!1,r=!1){this.from=e,this.to=t,this.tree=n,this.offset=i,this.open=(s?1:0)|(r?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e,t=[],n=!1){let i=[new N(0,e.length,e,0,!1,n)];for(let n of t)n.to>e.length&&i.push(n);return i}static applyChanges(e,t,n=128){if(!t.length)return e;let i=[],s=1,r=e.length?e[0]:null;for(let o=0,a=0,l=0;;o++){let c=o<t.length?t[o]:null,h=c?c.fromA:1e9;if(h-a>=n)for(;r&&r.from<h;){let t=r;if(a>=t.from||h<=t.to||l){let e=Math.max(t.from,a)-l,n=Math.min(t.to,h)-l;t=e>=n?null:new N(e,n,t.tree,t.offset+l,o>0,!!c)}if(t&&i.push(t),r.to>h)break;r=s<e.length?e[s++]:null}if(!c)break;a=c.toA,l=c.toA-c.toB}return i}}let D=class{startParse(e,t,n){return"string"==typeof e&&(e=new _(e)),n=n?n.length?n.map(e=>new i(e.from,e.to)):[new i(0,0)]:[new i(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let i=this.startParse(e,t,n);for(;;){let e=i.advance();if(e)return e}}};class _{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new s({perNode:!0});class P{constructor(e,t,n,i,s,r,o,a,l,c=0,h){this.p=e,this.stack=t,this.state=n,this.reducePos=i,this.pos=s,this.score=r,this.buffer=o,this.bufferBase=a,this.curContext=l,this.lookAhead=c,this.parent=h}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,n=0){let i=e.parser.context;return new P(e,[],t,n,n,0,[],0,i?new I(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let n=e>>19,i=65535&e,{parser:s}=this.p,r=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),o=s.dynamicPrecedence(i);if(o&&(this.score+=o),0==n)return this.pushState(s.getGoto(this.state,i,!0),this.reducePos),i<s.minRepeatTerm&&this.storeNode(i,this.reducePos,this.reducePos,r?8:4,!0),void this.reduceContext(i,this.reducePos);let a=this.stack.length-3*(n-1)-(262144&e?6:0),l=a?this.stack[a-2]:this.p.ranges[0].from,c=this.reducePos-l;c>=2e3&&!(null===(t=this.p.parser.nodeSet.types[i])||void 0===t?void 0:t.isAnonymous)&&(l==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=l,this.p.lastBigReductionSize=c));let h=a?this.stack[a-1]:0,u=this.bufferBase+this.buffer.length-h;if(i<s.minRepeatTerm||131072&e){let e=s.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(i,l,e,u+4,!0)}if(262144&e)this.state=this.stack[a];else{let e=this.stack[a-3];this.state=s.getGoto(e,i,!0)}for(;this.stack.length>a;)this.stack.pop();this.reduceContext(i,l)}storeNode(e,t,n,i=4,s=!1){if(0==e&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let e=this,i=this.buffer.length;if(0==i&&e.parent&&(i=e.bufferBase-e.parent.bufferBase,e=e.parent),i>0&&0==e.buffer[i-4]&&e.buffer[i-1]>-1){if(t==n)return;if(e.buffer[i-2]>=t)return void(e.buffer[i-2]=n)}}if(s&&this.pos!=n){let s=this.buffer.length;if(s>0&&(0!=this.buffer[s-4]||this.buffer[s-1]<0)){let e=!1;for(let t=s;t>0&&this.buffer[t-2]>n;t-=4)if(this.buffer[t-1]>=0){e=!0;break}if(e)for(;s>0&&this.buffer[s-2]>n;)this.buffer[s]=this.buffer[s-4],this.buffer[s+1]=this.buffer[s-3],this.buffer[s+2]=this.buffer[s-2],this.buffer[s+3]=this.buffer[s-1],s-=4,i>4&&(i-=4)}this.buffer[s]=e,this.buffer[s+1]=t,this.buffer[s+2]=n,this.buffer[s+3]=i}else this.buffer.push(e,t,n,i)}shift(e,t,n,i){if(131072&e)this.pushState(65535&e,this.pos);else if(262144&e)this.pos=i,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,i,4);else{let s=e,{parser:r}=this.p;this.pos=i;let o=r.stateFlag(s,1);!o&&(i>n||t<=r.maxNode)&&(this.reducePos=i),this.pushState(s,o?n:Math.min(n,this.reducePos)),this.shiftContext(t,n),t<=r.maxNode&&this.buffer.push(t,n,i,4)}}apply(e,t,n,i){65536&e?this.reduce(e):this.shift(e,t,n,i)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let i=this.pos;this.reducePos=this.pos=i+e.length,this.pushState(t,i),this.buffer.push(n,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let n=e.buffer.slice(t),i=e.bufferBase+t;for(;e&&i==e.bufferBase;)e=e.parent;return new P(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,n,i,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new R(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(0==n)return!1;if(!(65536&n))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let n=[];for(let i,s=0;s<t.length;s+=2)(i=t[s+1])!=this.state&&this.p.parser.hasAction(i,e)&&n.push(t[s],i);if(this.stack.length<120)for(let e=0;n.length<8&&e<t.length;e+=2){let i=t[e+1];n.some((e,t)=>1&t&&e==i)||n.push(t[e],i)}t=n}let n=[];for(let e=0;e<t.length&&n.length<4;e+=2){let i=t[e+1];if(i==this.state)continue;let s=this.split();s.pushState(i,this.pos),s.storeNode(0,s.pos,s.pos,4,!0),s.shiftContext(t[e],this.pos),s.reducePos=this.pos,s.score-=200,n.push(s)}return n}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(65536&t))return!1;if(!e.validAction(this.state,t)){let n=t>>19,i=65535&t,s=this.stack.length-3*n;if(s<0||e.getGoto(this.stack[s],i,!1)<0){let e=this.findForcedReduction();if(null==e)return!1;t=e}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(i,s)=>{if(!t.includes(i))return t.push(i),e.allActions(i,t=>{if(393216&t);else if(65536&t){let n=(t>>19)-s;if(n>1){let i=65535&t,s=this.stack.length-3*n;if(s>=0&&e.getGoto(this.stack[s],i,!1)>=0)return n<<19|65536|i}}else{let e=n(t,s+1);if(null!=e)return e}})};return n(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:e}=this.p;return 65535==e.data[e.stateSlot(this.state,1)]&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||-3!=this.buffer[e])&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||-4!=this.buffer[e])&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new I(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){return!(e<=this.lookAhead)&&(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class I{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class R{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=65535&e,n=e>>19;0==n?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=3*(n-1);let i=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=i}}class ${constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,0==this.index&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new $(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;null!=e&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,0==this.index&&this.maybeNext()}fork(){return new $(this.stack,this.pos,this.index)}}function B(e,t=Uint16Array){if("string"!=typeof e)return e;let n=null;for(let i=0,s=0;i<e.length;){let r=0;for(;;){let t=e.charCodeAt(i++),n=!1;if(126==t){r=65535;break}t>=92&&t--,t>=34&&t--;let s=t-32;if(s>=46&&(s-=46,n=!0),r+=s,n)break;r*=46}n?n[s++]=r:n=new t(r)}return n}class L{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const z=new L;let j=class{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=z,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,i=this.rangeIndex,s=this.pos+e;for(;s<n.from;){if(!i)return null;let e=this.ranges[--i];s-=n.from-e.to,n=e}for(;t<0?s>n.to:s>=n.to;){if(i==this.ranges.length-1)return null;let e=this.ranges[++i];s+=e.from-n.to,n=e}return s}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t,n,i=this.chunkOff+e;if(i>=0&&i<this.chunk.length)t=this.pos+e,n=this.chunk.charCodeAt(i);else{let i=this.resolveOffset(e,1);if(null==i)return-1;if(t=i,t>=this.chunk2Pos&&t<this.chunk2Pos+this.chunk2.length)n=this.chunk2.charCodeAt(t-this.chunk2Pos);else{let e=this.rangeIndex,i=this.range;for(;i.to<=t;)i=this.ranges[++e];this.chunk2=this.input.chunk(this.chunk2Pos=t),t+this.chunk2.length>i.to&&(this.chunk2=this.chunk2.slice(0,i.to-t)),n=this.chunk2.charCodeAt(0)}}return t>=this.token.lookAhead&&(this.token.lookAhead=t+1),n}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(null==n||n<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=n}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=z,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n="";for(let i of this.ranges){if(i.from>=t)break;i.to>e&&(n+=this.input.read(Math.max(i.from,e),Math.min(i.to,t)))}return n}};class W{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;!function(e,t,n,i,s,r){let o=0,a=1<<i,{dialect:l}=n.p.parser;e:for(;0!=(a&e[o]);){let n=e[o+1];for(let i=o+3;i<n;i+=2)if((e[i+1]&a)>0){let n=e[i];if(l.allows(n)&&(-1==t.token.value||t.token.value==n||F(n,t.token.value,s,r))){t.acceptToken(n);break}}let i=t.next,c=0,h=e[o+2];if(!(t.next<0&&h>c&&65535==e[n+3*h-3])){for(;c<h;){let s=c+h>>1,r=n+s+(s<<1),a=e[r],l=e[r+1]||65536;if(i<a)h=s;else{if(!(i>=l)){o=e[r+2],t.advance();continue e}c=s+1}}break}o=e[n+3*h-1]}}(this.data,e,t,this.id,n.data,n.tokenPrecTable)}}function U(e,t,n){for(let i,s=t;65535!=(i=e[s]);s++)if(i==n)return s-t;return-1}function F(e,t,n,i){let s=U(n,i,t);return s<0||U(n,i,e)<s}W.prototype.contextual=W.prototype.fallback=W.prototype.extend=!1,W.prototype.fallback=W.prototype.extend=!1;const V="undefined"!=typeof process&&process.env&&/\bparse\b/.test(process.env.LOG);let H=null;function q(e,t,n){let i=e.cursor(u.IncludeAnonymous);for(i.moveTo(t);;)if(!(n<0?i.childBefore(t):i.childAfter(t)))for(;;){if((n<0?i.to<t:i.from>t)&&!i.type.isError)return n<0?Math.max(0,Math.min(i.to-1,t-25)):Math.min(e.length,Math.max(i.from+1,t+25));if(n<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return n<0?0:e.length}}class K{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?q(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?q(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let n=this.trees[t],i=this.index[t];if(i==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let r=n.children[i],o=this.start[t]+n.positions[i];if(o>e)return this.nextStart=o,null;if(r instanceof d){if(o==e){if(o<this.safeFrom)return null;let e=o+r.length;if(e<=this.safeTo){let t=r.prop(s.lookAhead);if(!t||e+t<this.fragment.to)return r}}this.index[t]++,o+r.length>=Math.max(this.safeFrom,e)&&(this.trees.push(r),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+r.length}}}class J{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(e=>new L)}getActions(e){let t=0,n=null,{parser:i}=e.p,{tokenizers:s}=i,r=i.stateSlot(e.state,3),o=e.curContext?e.curContext.hash:0,a=0;for(let i=0;i<s.length;i++){if(!(1<<i&r))continue;let l=s[i],c=this.tokens[i];if((!n||l.fallback)&&((l.contextual||c.start!=e.pos||c.mask!=r||c.context!=o)&&(this.updateCachedToken(c,l,e),c.mask=r,c.context=o),c.lookAhead>c.end+25&&(a=Math.max(c.lookAhead,a)),0!=c.value)){let i=t;if(c.extended>-1&&(t=this.addActions(e,c.extended,c.end,t)),t=this.addActions(e,c.value,c.end,t),!l.extend&&(n=c,t>i))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),n||e.pos!=this.stream.end||(n=new L,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new L,{pos:n,p:i}=e;return t.start=n,t.end=Math.min(n+1,i.stream.end),t.value=n==i.stream.end?i.parser.eofTerm:0,t}updateCachedToken(e,t,n){let i=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(i,e),n),e.value>-1){let{parser:t}=n.p;for(let i=0;i<t.specialized.length;i++)if(t.specialized[i]==e.value){let s=t.specializers[i](this.stream.read(e.start,e.end),n);if(s>=0&&n.p.parser.dialect.allows(s>>1)){1&s?e.extended=s>>1:e.value=s>>1;break}}}else e.value=0,e.end=this.stream.clipPos(i+1)}putAction(e,t,n,i){for(let t=0;t<i;t+=3)if(this.actions[t]==e)return i;return this.actions[i++]=e,this.actions[i++]=t,this.actions[i++]=n,i}addActions(e,t,n,i){let{state:s}=e,{parser:r}=e.p,{data:o}=r;for(let e=0;e<2;e++)for(let a=r.stateSlot(s,e?2:1);;a+=3){if(65535==o[a]){if(1!=o[a+1]){0==i&&2==o[a+1]&&(i=this.putAction(X(o,a+2),t,n,i));break}a=X(o,a+2)}o[a]==t&&(i=this.putAction(X(o,a+1),t,n,i))}return i}}class Z{constructor(e,t,n,i){this.parser=e,this.input=t,this.ranges=i,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 j(t,i),this.tokens=new J(e,this.stream),this.topTerm=e.top[1];let{from:s}=i[0];this.stacks=[P.start(this,e.top[0],s)],this.fragments=n.length&&this.stream.end-s>4*e.bufferLength?new K(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e,t,n=this.stacks,i=this.minStackPos,s=this.stacks=[];if(this.bigReductionCount>300&&1==n.length){let[e]=n;for(;e.forceReduce()&&e.stack.length&&e.stack[e.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let r=0;r<n.length;r++){let o=n[r];for(;;){if(this.tokens.mainToken=null,o.pos>i)s.push(o);else{if(this.advanceStack(o,s,n))continue;{e||(e=[],t=[]),e.push(o);let n=this.tokens.getMainToken(o);t.push(n.value,n.end)}}break}}if(!s.length){let t=e&&function(e){let t=null;for(let n of e){let e=n.p.stoppedAt;(n.pos==n.p.stream.end||null!=e&&n.pos>e)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.score<n.score)&&(t=n)}return t}(e);if(t)return V&&console.log("Finish with "+this.stackID(t)),this.stackToTree(t);if(this.parser.strict)throw V&&e&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+i);this.recovering||(this.recovering=5)}if(this.recovering&&e){let n=null!=this.stoppedAt&&e[0].pos>this.stoppedAt?e[0]:this.runRecovery(e,t,s);if(n)return V&&console.log("Force-finish "+this.stackID(n)),this.stackToTree(n.forceAll())}if(this.recovering){let e=1==this.recovering?1:3*this.recovering;if(s.length>e)for(s.sort((e,t)=>t.score-e.score);s.length>e;)s.pop();s.some(e=>e.reducePos>i)&&this.recovering--}else if(s.length>1){e:for(let e=0;e<s.length-1;e++){let t=s[e];for(let n=e+1;n<s.length;n++){let i=s[n];if(t.sameState(i)||t.buffer.length>500&&i.buffer.length>500){if(!((t.score-i.score||t.buffer.length-i.buffer.length)>0)){s.splice(e--,1);continue e}s.splice(n--,1)}}}s.length>12&&(s.sort((e,t)=>t.score-e.score),s.splice(12,s.length-12))}this.minStackPos=s[0].pos;for(let e=1;e<s.length;e++)s[e].pos<this.minStackPos&&(this.minStackPos=s[e].pos);return null}stopAt(e){if(null!=this.stoppedAt&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,n){let i=e.pos,{parser:r}=this,o=V?this.stackID(e)+" -> ":"";if(null!=this.stoppedAt&&i>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let t=e.curContext&&e.curContext.tracker.strict,n=t?e.curContext.hash:0;for(let a=this.fragments.nodeAt(i);a;){let i=this.parser.nodeSet.types[a.type.id]==a.type?r.getGoto(e.state,a.type.id):-1;if(i>-1&&a.length&&(!t||(a.prop(s.contextHash)||0)==n))return e.useNode(a,i),V&&console.log(o+this.stackID(e)+` (via reuse of ${r.getName(a.type.id)})`),!0;if(!(a instanceof d)||0==a.children.length||a.positions[0]>0)break;let l=a.children[0];if(!(l instanceof d&&0==a.positions[0]))break;a=l}}let a=r.stateSlot(e.state,4);if(a>0)return e.reduce(a),V&&console.log(o+this.stackID(e)+` (via always-reduce ${r.getName(65535&a)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let s=0;s<l.length;){let a=l[s++],c=l[s++],h=l[s++],u=s==l.length||!n,d=u?e:e.split(),f=this.tokens.mainToken;if(d.apply(a,c,f?f.start:d.pos,h),V&&console.log(o+this.stackID(d)+` (via ${65536&a?`reduce of ${r.getName(65535&a)}`:"shift"} for ${r.getName(c)} @ ${i}${d==e?"":", split"})`),u)return!0;d.pos>i?t.push(d):n.push(d)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return Y(e,t),!0}}runRecovery(e,t,n){let i=null,s=!1;for(let r=0;r<e.length;r++){let o=e[r],a=t[r<<1],l=t[1+(r<<1)],c=V?this.stackID(o)+" -> ":"";if(o.deadEnd){if(s)continue;if(s=!0,o.restart(),V&&console.log(c+this.stackID(o)+" (restarted)"),this.advanceFully(o,n))continue}let h=o.split(),u=c;for(let e=0;e<10&&h.forceReduce();e++){if(V&&console.log(u+this.stackID(h)+" (via force-reduce)"),this.advanceFully(h,n))break;V&&(u=this.stackID(h)+" -> ")}for(let e of o.recoverByInsert(a))V&&console.log(c+this.stackID(e)+" (via recover-insert)"),this.advanceFully(e,n);this.stream.end>o.pos?(l==o.pos&&(l++,a=0),o.recoverByDelete(a,l),V&&console.log(c+this.stackID(o)+` (via recover-delete ${this.parser.getName(a)})`),Y(o,n)):(!i||i.score<h.score)&&(i=h)}return i}stackToTree(e){return e.close(),d.build({buffer:$.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(H||(H=new WeakMap)).get(e);return t||H.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function Y(e,t){for(let n=0;n<t.length;n++){let i=t[n];if(i.pos==e.pos&&i.sameState(e))return void(t[n].score<e.score&&(t[n]=e))}t.push(e)}class G{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||0==this.disabled[e]}}class Q extends D{constructor(e){if(super(),this.wrappers=[],14!=e.version)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let n=e.nodeNames.split(" ");this.minRepeatTerm=n.length;for(let t=0;t<e.repeatNodeCount;t++)n.push("");let i=Object.keys(e.topRules).map(t=>e.topRules[t][1]),r=[];for(let e=0;e<n.length;e++)r.push([]);function o(e,t,n){r[e].push([t,t.deserialize(String(n))])}if(e.nodeProps)for(let t of e.nodeProps){let e=t[0];"string"==typeof e&&(e=s[e]);for(let n=1;n<t.length;){let i=t[n++];if(i>=0)o(i,e,t[n++]);else{let s=t[n+-i];for(let r=-i;r>0;r--)o(t[n++],e,s);n++}}}this.nodeSet=new l(n.map((t,n)=>a.define({name:n>=this.minRepeatTerm?void 0:t,id:n,props:r[n],top:i.indexOf(n)>-1,error:0==n,skipped:e.skippedNodes&&e.skippedNodes.indexOf(n)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=t;let c=B(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let e=0;e<this.specializerSpecs.length;e++)this.specialized[e]=this.specializerSpecs[e].term;this.specializers=this.specializerSpecs.map(ee),this.states=B(e.states,Uint32Array),this.data=B(e.stateData),this.goto=B(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(e=>"number"==typeof e?new W(c,e):e),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let i=new Z(this,e,t,n);for(let s of this.wrappers)i=s(i,e,t,n);return i}getGoto(e,t,n=!1){let i=this.goto;if(t>=i[0])return-1;for(let s=i[t+1];;){let t=i[s++],r=1&t,o=i[s++];if(r&&n)return o;for(let n=s+(t>>1);s<n;s++)if(i[s]==e)return o;if(r)return-1}}hasAction(e,t){let n=this.data;for(let i=0;i<2;i++)for(let s,r=this.stateSlot(e,i?2:1);;r+=3){if(65535==(s=n[r])){if(1!=n[r+1]){if(2==n[r+1])return X(n,r+2);break}s=n[r=X(n,r+2)]}if(s==t||0==s)return X(n,r+1)}return 0}stateSlot(e,t){return this.states[6*e+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,e=>e==t||null)}allActions(e,t){let n=this.stateSlot(e,4),i=n?t(n):void 0;for(let n=this.stateSlot(e,1);null==i;n+=3){if(65535==this.data[n]){if(1!=this.data[n+1])break;n=X(this.data,n+2)}i=t(X(this.data,n+1))}return i}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(65535==this.data[n]){if(1!=this.data[n+1])break;n=X(this.data,n+2)}if(!(1&this.data[n+2])){let e=this.data[n+1];t.some((t,n)=>1&n&&t==e)||t.push(this.data[n],e)}}return t}configure(e){let t=Object.assign(Object.create(Q.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let n=this.topRules[e.top];if(!n)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=n}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(t=>{let n=e.tokenizers.find(e=>e.from==t);return n?n.to:t})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((n,i)=>{let s=e.specializers.find(e=>e.from==n.external);if(!s)return n;let r=Object.assign(Object.assign({},n),{external:s.to});return t.specializers[i]=ee(r),r})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),null!=e.strict&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),null!=e.bufferLength&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return null==t?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let i of e.split(" ")){let e=t.indexOf(i);e>=0&&(n[e]=!0)}let i=null;for(let e=0;e<t.length;e++)if(!n[e])for(let n,s=this.dialects[t[e]];65535!=(n=this.data[s++]);)(i||(i=new Uint8Array(this.maxTerm+1)))[n]=1;return new G(e,n,i)}static deserialize(e){return new Q(e)}}function X(e,t){return e[t]|e[t+1]<<16}function ee(e){if(e.external){let t=e.extend?1:0;return(n,i)=>e.external(n,i)<<1|t}return e.get}let te=0;class ne{constructor(e,t,n,i){this.name=e,this.set=t,this.base=n,this.modified=i,this.id=te++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let n="string"==typeof e?e:"?";if(e instanceof ne&&(t=e),null==t?void 0:t.base)throw new Error("Can not derive from a modified tag");let i=new ne(n,[],null,[]);if(i.set.push(i),t)for(let e of t.set)i.set.push(e);return i}static defineModifier(e){let t=new se(e);return e=>e.modified.indexOf(t)>-1?e:se.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}}let ie=0;class se{constructor(e){this.name=e,this.instances=[],this.id=ie++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(n=>n.base==e&&function(e,t){return e.length==t.length&&e.every((e,n)=>e==t[n])}(t,n.modified));if(n)return n;let i=[],s=new ne(e.name,i,e,t);for(let e of t)e.instances.push(s);let r=function(e){let t=[[]];for(let n=0;n<e.length;n++)for(let i=0,s=t.length;i<s;i++)t.push(t[i].concat(e[n]));return t.sort((e,t)=>t.length-e.length)}(t);for(let t of e.set)if(!t.modified.length)for(let e of r)i.push(se.get(t,e));return s}}function re(e){let t=Object.create(null);for(let n in e){let i=e[n];Array.isArray(i)||(i=[i]);for(let e of n.split(" "))if(e){let n=[],s=2,r=e;for(let t=0;;){if("..."==r&&t>0&&t+3==e.length){s=1;break}let i=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(r);if(!i)throw new RangeError("Invalid path: "+e);if(n.push("*"==i[0]?"":'"'==i[0][0]?JSON.parse(i[0]):i[0]),t+=i[0].length,t==e.length)break;let o=e[t++];if(t==e.length&&"!"==o){s=0;break}if("/"!=o)throw new RangeError("Invalid path: "+e);r=e.slice(t)}let o=n.length-1,a=n[o];if(!a)throw new RangeError("Invalid path: "+e);let l=new ae(i,s,o>0?n.slice(0,o):null);t[a]=l.sort(t[a])}}return oe.add(t)}const oe=new s({combine(e,t){let n,i,s;for(;e||t;){if(!e||t&&e.depth>=t.depth?(s=t,t=t.next):(s=e,e=e.next),n&&n.mode==s.mode&&!s.context&&!n.context)continue;let r=new ae(s.tags,s.mode,s.context);n?n.next=r:i=r,n=r}return i}});class ae{constructor(e,t,n,i){this.tags=e,this.mode=t,this.context=n,this.next=i}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}function le(e,t){let n=Object.create(null);for(let t of e)if(Array.isArray(t.tag))for(let e of t.tag)n[e.id]=t.class;else n[t.tag.id]=t.class;let{scope:i,all:s=null}=t||{};return{style:e=>{let t=s;for(let i of e)for(let e of i.set){let i=n[e.id];if(i){t=t?t+" "+i:i;break}}return t},scope:i}}function ce(e,t,n,i=0,s=e.length){let r=new he(i,Array.isArray(t)?t:[t],n);r.highlightRange(e.cursor(),i,s,"",r.highlighters),r.flush(s)}ae.empty=new ae([],2,null);class he{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,i,r){let{type:o,from:a,to:l}=e;if(a>=n||l<=t)return;o.isTop&&(r=this.highlighters.filter(e=>!e.scope||e.scope(o)));let c=i,h=function(e){let t=e.type.prop(oe);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}(e)||ae.empty,u=function(e,t){let n=null;for(let i of e){let e=i.style(t);e&&(n=n?n+" "+e:e)}return n}(r,h.tags);if(u&&(c&&(c+=" "),c+=u,1==h.mode&&(i+=(i?" ":"")+u)),this.startSpan(Math.max(t,a),c),h.opaque)return;let d=e.tree&&e.tree.prop(s.mounted);if(d&&d.overlay){let s=e.node.enter(d.overlay[0].from+a,1),o=this.highlighters.filter(e=>!e.scope||e.scope(d.tree.type)),h=e.firstChild();for(let u=0,f=a;;u++){let p=u<d.overlay.length?d.overlay[u]:null,m=p?p.from+a:l,g=Math.max(t,f),y=Math.min(n,m);if(g<y&&h)for(;e.from<y&&(this.highlightRange(e,g,y,i,r),this.startSpan(Math.min(y,e.to),c),!(e.to>=m)&&e.nextSibling()););if(!p||m>n)break;f=p.to+a,f>t&&(this.highlightRange(s.cursor(),Math.max(t,p.from+a),Math.min(n,f),"",o),this.startSpan(Math.min(n,f),c))}h&&e.parent()}else if(e.firstChild()){d&&(i="");do{if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,i,r),this.startSpan(Math.min(n,e.to),c)}}while(e.nextSibling());e.parent()}}}const ue=ne.define,de=ue(),fe=ue(),pe=ue(fe),me=ue(fe),ge=ue(),ye=ue(ge),ve=ue(ge),be=ue(),we=ue(be),ke=ue(),xe=ue(),Se=ue(),Ce=ue(Se),Ae=ue(),Te={comment:de,lineComment:ue(de),blockComment:ue(de),docComment:ue(de),name:fe,variableName:ue(fe),typeName:pe,tagName:ue(pe),propertyName:me,attributeName:ue(me),className:ue(fe),labelName:ue(fe),namespace:ue(fe),macroName:ue(fe),literal:ge,string:ye,docString:ue(ye),character:ue(ye),attributeValue:ue(ye),number:ve,integer:ue(ve),float:ue(ve),bool:ue(ge),regexp:ue(ge),escape:ue(ge),color:ue(ge),url:ue(ge),keyword:ke,self:ue(ke),null:ue(ke),atom:ue(ke),unit:ue(ke),modifier:ue(ke),operatorKeyword:ue(ke),controlKeyword:ue(ke),definitionKeyword:ue(ke),moduleKeyword:ue(ke),operator:xe,derefOperator:ue(xe),arithmeticOperator:ue(xe),logicOperator:ue(xe),bitwiseOperator:ue(xe),compareOperator:ue(xe),updateOperator:ue(xe),definitionOperator:ue(xe),typeOperator:ue(xe),controlOperator:ue(xe),punctuation:Se,separator:ue(Se),bracket:Ce,angleBracket:ue(Ce),squareBracket:ue(Ce),paren:ue(Ce),brace:ue(Ce),content:be,heading:we,heading1:ue(we),heading2:ue(we),heading3:ue(we),heading4:ue(we),heading5:ue(we),heading6:ue(we),contentSeparator:ue(be),list:ue(be),quote:ue(be),emphasis:ue(be),strong:ue(be),link:ue(be),monospace:ue(be),strikethrough:ue(be),inserted:ue(),deleted:ue(),changed:ue(),invalid:ue(),meta:Ae,documentMeta:ue(Ae),annotation:ue(Ae),processingInstruction:ue(Ae),definition:ne.defineModifier("definition"),constant:ne.defineModifier("constant"),function:ne.defineModifier("function"),standard:ne.defineModifier("standard"),local:ne.defineModifier("local"),special:ne.defineModifier("special")};for(let e in Te){let t=Te[e];t instanceof ne&&(t.name=e)}le([{tag:Te.link,class:"tok-link"},{tag:Te.heading,class:"tok-heading"},{tag:Te.emphasis,class:"tok-emphasis"},{tag:Te.strong,class:"tok-strong"},{tag:Te.keyword,class:"tok-keyword"},{tag:Te.atom,class:"tok-atom"},{tag:Te.bool,class:"tok-bool"},{tag:Te.url,class:"tok-url"},{tag:Te.labelName,class:"tok-labelName"},{tag:Te.inserted,class:"tok-inserted"},{tag:Te.deleted,class:"tok-deleted"},{tag:Te.literal,class:"tok-literal"},{tag:Te.string,class:"tok-string"},{tag:Te.number,class:"tok-number"},{tag:[Te.regexp,Te.escape,Te.special(Te.string)],class:"tok-string2"},{tag:Te.variableName,class:"tok-variableName"},{tag:Te.local(Te.variableName),class:"tok-variableName tok-local"},{tag:Te.definition(Te.variableName),class:"tok-variableName tok-definition"},{tag:Te.special(Te.variableName),class:"tok-variableName2"},{tag:Te.definition(Te.propertyName),class:"tok-propertyName tok-definition"},{tag:Te.typeName,class:"tok-typeName"},{tag:Te.namespace,class:"tok-namespace"},{tag:Te.className,class:"tok-className"},{tag:Te.macroName,class:"tok-macroName"},{tag:Te.propertyName,class:"tok-propertyName"},{tag:Te.operator,class:"tok-operator"},{tag:Te.comment,class:"tok-comment"},{tag:Te.meta,class:"tok-meta"},{tag:Te.invalid,class:"tok-invalid"},{tag:Te.punctuation,class:"tok-punctuation"}]);const Oe=re({String:Te.string,Number:Te.number,"True False":Te.bool,PropertyName:Te.propertyName,Null:Te.null,", :":Te.separator,"[ ]":Te.squareBracket,"{ }":Te.brace}),Me=Q.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:[Oe],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});let Ee=[],Ne=[];function De(e){if(e<768)return!1;for(let t=0,n=Ee.length;;){let i=t+n>>1;if(e<Ee[i])n=i;else{if(!(e>=Ne[i]))return!0;t=i+1}if(t==n)return!1}}function _e(e){return e>=127462&&e<=127487}(()=>{let e="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?Ne:Ee).push(n+=e[t])})();function Pe(e,t,n=!0,i=!0){return(n?Ie:Re)(e,t,i)}function Ie(e,t,n){if(t==e.length)return t;t&&Be(e.charCodeAt(t))&&Le(e.charCodeAt(t-1))&&t--;let i=$e(e,t);for(t+=ze(i);t<e.length;){let s=$e(e,t);if(8205==i||8205==s||n&&De(s))t+=ze(s),i=s;else{if(!_e(s))break;{let n=0,i=t-2;for(;i>=0&&_e($e(e,i));)n++,i-=2;if(n%2==0)break;t+=2}}}return t}function Re(e,t,n){for(;t>0;){let i=Ie(e,t-2,n);if(i<t)return i;t--}return 0}function $e(e,t){let n=e.charCodeAt(t);if(!Le(n)||t+1==e.length)return n;let i=e.charCodeAt(t+1);return Be(i)?i-56320+(n-55296<<10)+65536:n}function Be(e){return e>=56320&&e<57344}function Le(e){return e>=55296&&e<56320}function ze(e){return e<65536?1:2}class je{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=Ze(this,e,t);let i=[];return this.decompose(0,e,i,2),n.length&&n.decompose(0,n.length,i,3),this.decompose(t,this.length,i,1),Ue.from(i,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Ze(this,e,t);let n=[];return this.decompose(e,t,n,0),Ue.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),i=new He(this),s=new He(e);for(let e=t,r=t;;){if(i.next(e),s.next(e),e=0,i.lineBreak!=s.lineBreak||i.done!=s.done||i.value!=s.value)return!1;if(r+=i.value.length,i.done||r>=n)return!0}}iter(e=1){return new He(this,e)}iterRange(e,t=this.length){return new qe(this,e,t)}iterLines(e,t){let n;if(null==e)n=this.iter();else{null==t&&(t=this.lines+1);let i=this.line(e).from;n=this.iterRange(i,Math.max(i,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Ke(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(0==e.length)throw new RangeError("A document must have at least one line");return 1!=e.length||e[0]?e.length<=32?new We(e):Ue.from(We.split(e,[])):je.empty}}class We extends je{constructor(e,t=function(e){let t=-1;for(let n of e)t+=n.length+1;return t}(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,i){for(let s=0;;s++){let r=this.text[s],o=i+r.length;if((t?n:o)>=e)return new Je(i,o,n,r);i=o+1,n++}}decompose(e,t,n,i){let s=e<=0&&t>=this.length?this:new We(Ve(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(1&i){let e=n.pop(),t=Fe(s.text,e.text.slice(),0,s.length);if(t.length<=32)n.push(new We(t,e.length+s.length));else{let e=t.length>>1;n.push(new We(t.slice(0,e)),new We(t.slice(e)))}}else n.push(s)}replace(e,t,n){if(!(n instanceof We))return super.replace(e,t,n);[e,t]=Ze(this,e,t);let i=Fe(this.text,Fe(n.text,Ve(this.text,0,e)),t),s=this.length+n.length-(t-e);return i.length<=32?new We(i,s):Ue.from(We.split(i,[]),s)}sliceString(e,t=this.length,n="\n"){[e,t]=Ze(this,e,t);let i="";for(let s=0,r=0;s<=t&&r<this.text.length;r++){let o=this.text[r],a=s+o.length;s>e&&r&&(i+=n),e<a&&t>s&&(i+=o.slice(Math.max(0,e-s),t-s)),s=a+1}return i}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],i=-1;for(let s of e)n.push(s),i+=s.length+1,32==n.length&&(t.push(new We(n,i)),n=[],i=-1);return i>-1&&t.push(new We(n,i)),t}}class Ue extends je{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,i){for(let s=0;;s++){let r=this.children[s],o=i+r.length,a=n+r.lines-1;if((t?a:o)>=e)return r.lineInner(e,t,n,i);i=o+1,n=a+1}}decompose(e,t,n,i){for(let s=0,r=0;r<=t&&s<this.children.length;s++){let o=this.children[s],a=r+o.length;if(e<=a&&t>=r){let s=i&((r<=e?1:0)|(a>=t?2:0));r>=e&&a<=t&&!s?n.push(o):o.decompose(e-r,t-r,n,s)}r=a+1}}replace(e,t,n){if([e,t]=Ze(this,e,t),n.lines<this.lines)for(let i=0,s=0;i<this.children.length;i++){let r=this.children[i],o=s+r.length;if(e>=s&&t<=o){let a=r.replace(e-s,t-s,n),l=this.lines-r.lines+a.lines;if(a.lines<l>>4&&a.lines>l>>6){let s=this.children.slice();return s[i]=a,new Ue(s,this.length-(t-e)+n.length)}return super.replace(s,o,a)}s=o+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n="\n"){[e,t]=Ze(this,e,t);let i="";for(let s=0,r=0;s<this.children.length&&r<=t;s++){let o=this.children[s],a=r+o.length;r>e&&s&&(i+=n),e<a&&t>r&&(i+=o.sliceString(e-r,t-r,n)),r=a+1}return i}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof Ue))return 0;let n=0,[i,s,r,o]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=t,s+=t){if(i==r||s==o)return n;let a=this.children[i],l=e.children[s];if(a!=l)return n+a.scanIdentical(l,t);n+=a.length+1}}static from(e,t=e.reduce((e,t)=>e+t.length+1,-1)){let n=0;for(let t of e)n+=t.lines;if(n<32){let n=[];for(let t of e)t.flatten(n);return new We(n,t)}let i=Math.max(32,n>>5),s=i<<1,r=i>>1,o=[],a=0,l=-1,c=[];function h(e){let t;if(e.lines>s&&e instanceof Ue)for(let t of e.children)h(t);else e.lines>r&&(a>r||!a)?(u(),o.push(e)):e instanceof We&&a&&(t=c[c.length-1])instanceof We&&e.lines+t.lines<=32?(a+=e.lines,l+=e.length+1,c[c.length-1]=new We(t.text.concat(e.text),t.length+1+e.length)):(a+e.lines>i&&u(),a+=e.lines,l+=e.length+1,c.push(e))}function u(){0!=a&&(o.push(1==c.length?c[0]:Ue.from(c,l)),l=-1,a=c.length=0)}for(let t of e)h(t);return u(),1==o.length?o[0]:new Ue(o,t)}}function Fe(e,t,n=0,i=1e9){for(let s=0,r=0,o=!0;r<e.length&&s<=i;r++){let a=e[r],l=s+a.length;l>=n&&(l>i&&(a=a.slice(0,i-s)),s<n&&(a=a.slice(n-s)),o?(t[t.length-1]+=a,o=!1):t.push(a)),s=l+1}return t}function Ve(e,t,n){return Fe(e,[""],t,n)}je.empty=new We([""],0);class He{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof We?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,i=this.nodes[n],s=this.offsets[n],r=s>>1,o=i instanceof We?i.text.length:i.children.length;if(r==(t>0?o:0)){if(0==n)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&s)==(t>0?0:1)){if(this.offsets[n]+=t,0==e)return this.lineBreak=!0,this.value="\n",this;e--}else if(i instanceof We){let s=i.text[r+(t<0?-1:0)];if(this.offsets[n]+=t,s.length>Math.max(0,e))return this.value=0==e?s:t>0?s.slice(e):s.slice(0,s.length-e),this;e-=s.length}else{let s=i.children[r+(t<0?-1:0)];e>s.length?(e-=s.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(s),this.offsets.push(t>0?1:(s instanceof We?s.text.length:s.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class qe{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new He(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:i}=this.cursor.next(e);return this.pos+=(i.length+e)*t,this.value=i.length<=n?i:t<0?i.slice(i.length-n):i.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class Ke{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:i}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(je.prototype[Symbol.iterator]=function(){return this.iter()},He.prototype[Symbol.iterator]=qe.prototype[Symbol.iterator]=Ke.prototype[Symbol.iterator]=function(){return this});class Je{constructor(e,t,n,i){this.from=e,this.to=t,this.number=n,this.text=i}get length(){return this.to-this.from}}function Ze(e,t,n){return[t=Math.max(0,Math.min(e.length,t)),Math.max(t,Math.min(e.length,n))]}function Ye(e,t,n=!0,i=!0){return Pe(e,t,n,i)}function Ge(e,t){let n=e.charCodeAt(t);if(!(i=n,i>=55296&&i<56320&&t+1!=e.length))return n;var i;let s=e.charCodeAt(t+1);return function(e){return e>=56320&&e<57344}(s)?s-56320+(n-55296<<10)+65536:n}function Qe(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10),56320+(1023&e)))}function Xe(e){return e<65536?1:2}const et=/\r\n?|\n/;var tt=function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e}(tt||(tt={}));class nt{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,i=0;t<this.sections.length;){let s=this.sections[t++],r=this.sections[t++];r<0?(e(n,i,s),i+=s):i+=r,n+=s}}iterChangedRanges(e,t=!1){ot(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let n=this.sections[t++],i=this.sections[t++];i<0?e.push(n,i):e.push(i,n)}return new nt(e)}composeDesc(e){return this.empty?e:e.empty?this:lt(this,e)}mapDesc(e,t=!1){return e.empty?this:at(this,e,t)}mapPos(e,t=-1,n=tt.Simple){let i=0,s=0;for(let r=0;r<this.sections.length;){let o=this.sections[r++],a=this.sections[r++],l=i+o;if(a<0){if(l>e)return s+(e-i);s+=o}else{if(n!=tt.Simple&&l>=e&&(n==tt.TrackDel&&i<e&&l>e||n==tt.TrackBefore&&i<e||n==tt.TrackAfter&&l>e))return null;if(l>e||l==e&&t<0&&!o)return e==i||t<0?s:s+a;s+=a}i=l}if(e>i)throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);return s}touchesRange(e,t=e){for(let n=0,i=0;n<this.sections.length&&i<=t;){let s=i+this.sections[n++];if(this.sections[n++]>=0&&i<=t&&s>=e)return!(i<e&&s>t)||"cover";i=s}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let n=this.sections[t++],i=this.sections[t++];e+=(e?" ":"")+n+(i>=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(e=>"number"!=typeof e))throw new RangeError("Invalid JSON representation of ChangeDesc");return new nt(e)}static create(e){return new nt(e)}}class it extends nt{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return ot(this,(t,n,i,s,r)=>e=e.replace(i,i+(n-t),r),!1),e}mapDesc(e,t=!1){return at(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let i=0,s=0;i<t.length;i+=2){let r=t[i],o=t[i+1];if(o>=0){t[i]=o,t[i+1]=r;let a=i>>1;for(;n.length<a;)n.push(je.empty);n.push(r?e.slice(s,s+r):je.empty)}s+=r}return new it(t,n)}compose(e){return this.empty?e:e.empty?this:lt(this,e,!0)}map(e,t=!1){return e.empty?this:at(this,e,t,!0)}iterChanges(e,t=!1){ot(this,e,t)}get desc(){return nt.create(this.sections)}filter(e){let t=[],n=[],i=[],s=new ct(this);e:for(let r=0,o=0;;){let a=r==e.length?1e9:e[r++];for(;o<a||o==a&&0==s.len;){if(s.done)break e;let e=Math.min(s.len,a-o);st(i,e,-1);let r=-1==s.ins?-1:0==s.off?s.ins:0;st(t,e,r),r>0&&rt(n,t,s.text),s.forward(e),o+=e}let l=e[r++];for(;o<l;){if(s.done)break e;let e=Math.min(s.len,l-o);st(t,e,-1),st(i,e,-1==s.ins?-1:0==s.off?s.ins:0),s.forward(e),o+=e}}return{changes:new it(t,n),filtered:nt.create(i)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],i=this.sections[t+1];i<0?e.push(n):0==i?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let i=[],s=[],r=0,o=null;function a(e=!1){if(!e&&!i.length)return;r<t&&st(i,t-r,-1);let n=new it(i,s);o=o?o.compose(n.map(o)):n,i=[],s=[],r=0}return function e(l){if(Array.isArray(l))for(let t of l)e(t);else if(l instanceof it){if(l.length!=t)throw new RangeError(`Mismatched change set length (got ${l.length}, expected ${t})`);a(),o=o?o.compose(l.map(o)):l}else{let{from:e,to:o=e,insert:c}=l;if(e>o||e<0||o>t)throw new RangeError(`Invalid change range ${e} to ${o} (in doc of length ${t})`);let h=c?"string"==typeof c?je.of(c.split(n||et)):c:je.empty,u=h.length;if(e==o&&0==u)return;e<r&&a(),e>r&&st(i,e-r,-1),st(i,o-e,u),rt(s,i,h),r=o}}(e),a(!o),o}static empty(e){return new it(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let i=0;i<e.length;i++){let s=e[i];if("number"==typeof s)t.push(s,-1);else{if(!Array.isArray(s)||"number"!=typeof s[0]||s.some((e,t)=>t&&"string"!=typeof e))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==s.length)t.push(s[0],0);else{for(;n.length<i;)n.push(je.empty);n[i]=je.of(s.slice(1)),t.push(s[0],n[i].length)}}}return new it(t,n)}static createSet(e,t){return new it(e,t)}}function st(e,t,n,i=!1){if(0==t&&n<=0)return;let s=e.length-2;s>=0&&n<=0&&n==e[s+1]?e[s]+=t:s>=0&&0==t&&0==e[s]?e[s+1]+=n:i?(e[s]+=t,e[s+1]+=n):e.push(t,n)}function rt(e,t,n){if(0==n.length)return;let i=t.length-2>>1;if(i<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<i;)e.push(je.empty);e.push(n)}}function ot(e,t,n){let i=e.inserted;for(let s=0,r=0,o=0;o<e.sections.length;){let a=e.sections[o++],l=e.sections[o++];if(l<0)s+=a,r+=a;else{let c=s,h=r,u=je.empty;for(;c+=a,h+=l,l&&i&&(u=u.append(i[o-2>>1])),!(n||o==e.sections.length||e.sections[o+1]<0);)a=e.sections[o++],l=e.sections[o++];t(s,c,r,h,u),s=c,r=h}}}function at(e,t,n,i=!1){let s=[],r=i?[]:null,o=new ct(e),a=new ct(t);for(let e=-1;;){if(o.done&&a.len||a.done&&o.len)throw new Error("Mismatched change set lengths");if(-1==o.ins&&-1==a.ins){let e=Math.min(o.len,a.len);st(s,e,-1),o.forward(e),a.forward(e)}else if(a.ins>=0&&(o.ins<0||e==o.i||0==o.off&&(a.len<o.len||a.len==o.len&&!n))){let t=a.len;for(st(s,a.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(st(s,0,o.ins),r&&rt(r,s,o.text),e=o.i),o.forward(n),t-=n}a.next()}else{if(!(o.ins>=0)){if(o.done&&a.done)return r?it.createSet(s,r):nt.create(s);throw new Error("Mismatched change set lengths")}{let t=0,n=o.len;for(;n;)if(-1==a.ins){let e=Math.min(n,a.len);t+=e,n-=e,a.forward(e)}else{if(!(0==a.ins&&a.len<n))break;n-=a.len,a.next()}st(s,t,e<o.i?o.ins:0),r&&e<o.i&&rt(r,s,o.text),e=o.i,o.forward(o.len-n)}}}}function lt(e,t,n=!1){let i=[],s=n?[]:null,r=new ct(e),o=new ct(t);for(let e=!1;;){if(r.done&&o.done)return s?it.createSet(i,s):nt.create(i);if(0==r.ins)st(i,r.len,0,e),r.next();else if(0!=o.len||o.done){if(r.done||o.done)throw new Error("Mismatched change set lengths");{let t=Math.min(r.len2,o.len),n=i.length;if(-1==r.ins){let n=-1==o.ins?-1:o.off?0:o.ins;st(i,t,n,e),s&&n&&rt(s,i,o.text)}else-1==o.ins?(st(i,r.off?0:r.len,t,e),s&&rt(s,i,r.textBit(t))):(st(i,r.off?0:r.len,o.off?0:o.ins,e),s&&!o.off&&rt(s,i,o.text));e=(r.ins>t||o.ins>=0&&o.len>t)&&(e||i.length>n),r.forward2(t),o.forward(t)}}else st(i,0,o.ins,e),s&&rt(s,i,o.text),o.next()}}class ct{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return-2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?je.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?je.empty:t[n].slice(this.off,null==e?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){-1==this.ins?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class ht{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let e=7&this.flags;return 7==e?null:e}get goalColumn(){let e=this.flags>>6;return 16777215==e?void 0:e}map(e,t=-1){let n,i;return this.empty?n=i=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),i=e.mapPos(this.to,-1)),n==this.from&&i==this.to?this:new ht(n,i,this.flags)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return ut.range(e,t,void 0,void 0,n);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return ut.range(this.anchor,i,void 0,void 0,n)}eq(e,t=!1){return!(this.anchor!=e.anchor||this.head!=e.head||this.goalColumn!=e.goalColumn||t&&this.empty&&this.assoc!=e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||"number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid JSON representation for SelectionRange");return ut.range(e.anchor,e.head)}static create(e,t,n){return new ht(e,t,n)}}class ut{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:ut.create(this.ranges.map(n=>n.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new ut([this.main],0)}addRange(e,t=!0){return ut.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,ut.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||"number"!=typeof e.main||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ut(e.ranges.map(e=>ht.fromJSON(e)),e.main)}static single(e,t=e){return new ut([ut.range(e,t)],0)}static create(e,t=0){if(0==e.length)throw new RangeError("A selection needs at least one range");for(let n=0,i=0;i<e.length;i++){let s=e[i];if(s.empty?s.from<=n:s.from<n)return ut.normalized(e.slice(),t);n=s.to}return new ut(e,t)}static cursor(e,t=0,n,i){return ht.create(e,e,(0==t?0:t<0?8:16)|(null==n?7:Math.min(6,n))|(null!=i?i:16777215)<<6)}static range(e,t,n,i,s){let r=(null!=n?n:16777215)<<6|(null==i?7:Math.min(6,i));return s||e==t||(s=t<e?1:-1),t<e?ht.create(t,e,48|r):ht.create(e,t,(s?s<0?8:16:0)|r)}static normalized(e,t=0){let n=e[t];e.sort((e,t)=>e.from-t.from),t=e.indexOf(n);for(let n=1;n<e.length;n++){let i=e[n],s=e[n-1];if(i.empty?i.from<=s.to:i.from<s.to){let r=s.from,o=Math.max(i.to,s.to);n<=t&&t--,e.splice(--n,2,i.anchor>i.head?ut.range(o,r):ut.range(r,o))}}return new ut(e,t)}}function dt(e,t){for(let n of e.ranges)if(n.to>t)throw new RangeError("Selection points outside of document")}let ft=0;class pt{constructor(e,t,n,i,s){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=i,this.id=ft++,this.default=e([]),this.extensions="function"==typeof s?s(this):s}get reader(){return this}static define(e={}){return new pt(e.combine||(e=>e),e.compareInput||((e,t)=>e===t),e.compare||(e.combine?(e,t)=>e===t:mt),!!e.static,e.enables)}of(e){return new gt([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new gt(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new gt(e,this,2,t)}from(e,t){return t||(t=e=>e),this.compute([e],n=>t(n.field(e)))}}function mt(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}class gt{constructor(e,t,n,i){this.dependencies=e,this.facet=t,this.type=n,this.value=i,this.id=ft++}dynamicSlot(e){var t;let n=this.value,i=this.facet.compareInput,s=this.id,r=e[s]>>1,o=2==this.type,a=!1,l=!1,c=[];for(let n of this.dependencies)"doc"==n?a=!0:"selection"==n?l=!0:1&(null!==(t=e[n.id])&&void 0!==t?t:1)||c.push(e[n.id]);return{create:e=>(e.values[r]=n(e),1),update(e,t){if(a&&t.docChanged||l&&(t.docChanged||t.selection)||vt(e,c)){let t=n(e);if(o?!yt(t,e.values[r],i):!i(t,e.values[r]))return e.values[r]=t,1}return 0},reconfigure:(e,t)=>{let a,l=t.config.address[s];if(null!=l){let s=Pt(t,l);if(this.dependencies.every(n=>n instanceof pt?t.facet(n)===e.facet(n):!(n instanceof kt)||t.field(n,!1)==e.field(n,!1))||(o?yt(a=n(e),s,i):i(a=n(e),s)))return e.values[r]=s,0}else a=n(e);return e.values[r]=a,1}}}}function yt(e,t,n){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++)if(!n(e[i],t[i]))return!1;return!0}function vt(e,t){let n=!1;for(let i of t)1&_t(e,i)&&(n=!0);return n}function bt(e,t,n){let i=n.map(t=>e[t.id]),s=n.map(e=>e.type),r=i.filter(e=>!(1&e)),o=e[t.id]>>1;function a(e){let n=[];for(let t=0;t<i.length;t++){let r=Pt(e,i[t]);if(2==s[t])for(let e of r)n.push(e);else n.push(r)}return t.combine(n)}return{create(e){for(let t of i)_t(e,t);return e.values[o]=a(e),1},update(e,n){if(!vt(e,r))return 0;let i=a(e);return t.compare(i,e.values[o])?0:(e.values[o]=i,1)},reconfigure(e,s){let r=vt(e,i),l=s.config.facets[t.id],c=s.facet(t);if(l&&!r&&mt(n,l))return e.values[o]=c,0;let h=a(e);return t.compare(h,c)?(e.values[o]=c,0):(e.values[o]=h,1)}}}const wt=pt.define({static:!0});class kt{constructor(e,t,n,i,s){this.id=e,this.createF=t,this.updateF=n,this.compareF=i,this.spec=s,this.provides=void 0}static define(e){let t=new kt(ft++,e.create,e.update,e.compare||((e,t)=>e===t),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(wt).find(e=>e.field==this);return((null==t?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let i=e.values[t],s=this.updateF(i,n);return this.compareF(i,s)?0:(e.values[t]=s,1)},reconfigure:(e,n)=>{let i,s=e.facet(wt),r=n.facet(wt);return(i=s.find(e=>e.field==this))&&i!=r.find(e=>e.field==this)?(e.values[t]=i.create(e),1):null!=n.config.address[this.id]?(e.values[t]=n.field(this),0):(e.values[t]=this.create(e),1)}}}init(e){return[this,wt.of({field:this,create:e})]}get extension(){return this}}const xt=4,St=3,Ct=2,At=1;function Tt(e){return t=>new Mt(t,e)}const Ot={highest:Tt(0),high:Tt(At),default:Tt(Ct),low:Tt(St),lowest:Tt(xt)};class Mt{constructor(e,t){this.inner=e,this.prec=t}}class Et{of(e){return new Nt(this,e)}reconfigure(e){return Et.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Nt{constructor(e,t){this.compartment=e,this.inner=t}}class Dt{constructor(e,t,n,i,s,r){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=i,this.staticValues=s,this.facets=r,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return null==t?e.default:this.staticValues[t>>1]}static resolve(e,t,n){let i=[],s=Object.create(null),r=new Map;for(let n of function(e,t,n){let i=[[],[],[],[],[]],s=new Map;function r(e,o){let a=s.get(e);if(null!=a){if(a<=o)return;let t=i[a].indexOf(e);t>-1&&i[a].splice(t,1),e instanceof Nt&&n.delete(e.compartment)}if(s.set(e,o),Array.isArray(e))for(let t of e)r(t,o);else if(e instanceof Nt){if(n.has(e.compartment))throw new RangeError("Duplicate use of compartment in extensions");let i=t.get(e.compartment)||e.inner;n.set(e.compartment,i),r(i,o)}else if(e instanceof Mt)r(e.inner,e.prec);else if(e instanceof kt)i[o].push(e),e.provides&&r(e.provides,o);else if(e instanceof gt)i[o].push(e),e.facet.extensions&&r(e.facet.extensions,Ct);else{let t=e.extension;if(!t)throw new Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(t,o)}}return r(e,Ct),i.reduce((e,t)=>e.concat(t))}(e,t,r))n instanceof kt?i.push(n):(s[n.facet.id]||(s[n.facet.id]=[])).push(n);let o=Object.create(null),a=[],l=[];for(let e of i)o[e.id]=l.length<<1,l.push(t=>e.slot(t));let c=null==n?void 0:n.config.facets;for(let e in s){let t=s[e],i=t[0].facet,r=c&&c[e]||[];if(t.every(e=>0==e.type))if(o[i.id]=a.length<<1|1,mt(r,t))a.push(n.facet(i));else{let e=i.combine(t.map(e=>e.value));a.push(n&&i.compare(e,n.facet(i))?n.facet(i):e)}else{for(let e of t)0==e.type?(o[e.id]=a.length<<1|1,a.push(e.value)):(o[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));o[i.id]=l.length<<1,l.push(e=>bt(e,i,t))}}let h=l.map(e=>e(o));return new Dt(e,r,h,o,a,s)}}function _t(e,t){if(1&t)return 2;let n=t>>1,i=e.status[n];if(4==i)throw new Error("Cyclic dependency between fields and/or facets");if(2&i)return i;e.status[n]=4;let s=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|s}function Pt(e,t){return 1&t?e.config.staticValues[t>>1]:e.values[t>>1]}const It=pt.define(),Rt=pt.define({combine:e=>e.some(e=>e),static:!0}),$t=pt.define({combine:e=>e.length?e[0]:void 0,static:!0}),Bt=pt.define(),Lt=pt.define(),zt=pt.define(),jt=pt.define({combine:e=>!!e.length&&e[0]});class Wt{constructor(e,t){this.type=e,this.value=t}static define(){return new Ut}}class Ut{of(e){return new Wt(this,e)}}class Ft{constructor(e){this.map=e}of(e){return new Vt(this,e)}}class Vt{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return void 0===t?void 0:t==this.value?this:new Vt(this.type,t)}is(e){return this.type==e}static define(e={}){return new Ft(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let i of e){let e=i.map(t);e&&n.push(e)}return n}}Vt.reconfigure=Vt.define(),Vt.appendConfig=Vt.define();class Ht{constructor(e,t,n,i,s,r){this.startState=e,this.changes=t,this.selection=n,this.effects=i,this.annotations=s,this.scrollIntoView=r,this._doc=null,this._state=null,n&&dt(n,t.newLength),s.some(e=>e.type==Ht.time)||(this.annotations=s.concat(Ht.time.of(Date.now())))}static create(e,t,n,i,s,r){return new Ht(e,t,n,i,s,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(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(Ht.userEvent);return!(!t||!(t==e||t.length>e.length&&t.slice(0,e.length)==e&&"."==t[e.length]))}}function qt(e,t){let n=[];for(let i=0,s=0;;){let r,o;if(i<e.length&&(s==t.length||t[s]>=e[i]))r=e[i++],o=e[i++];else{if(!(s<t.length))return n;r=t[s++],o=t[s++]}!n.length||n[n.length-1]<r?n.push(r,o):n[n.length-1]<o&&(n[n.length-1]=o)}}function Kt(e,t,n){var i;let s,r,o;return n?(s=t.changes,r=it.empty(t.changes.length),o=e.changes.compose(t.changes)):(s=t.changes.map(e.changes),r=e.changes.mapDesc(t.changes,!0),o=e.changes.compose(s)),{changes:o,selection:t.selection?t.selection.map(r):null===(i=e.selection)||void 0===i?void 0:i.map(s),effects:Vt.mapEffects(e.effects,s).concat(Vt.mapEffects(t.effects,r)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function Jt(e,t,n){let i=t.selection,s=Gt(t.annotations);return t.userEvent&&(s=s.concat(Ht.userEvent.of(t.userEvent))),{changes:t.changes instanceof it?t.changes:it.of(t.changes||[],n,e.facet($t)),selection:i&&(i instanceof ut?i:ut.single(i.anchor,i.head)),effects:Gt(t.effects),annotations:s,scrollIntoView:!!t.scrollIntoView}}function Zt(e,t,n){let i=Jt(e,t.length?t[0]:{},e.doc.length);t.length&&!1===t[0].filter&&(n=!1);for(let s=1;s<t.length;s++){!1===t[s].filter&&(n=!1);let r=!!t[s].sequential;i=Kt(i,Jt(e,t[s],r?i.changes.newLength:e.doc.length),r)}let s=Ht.create(e,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return function(e){let t=e.startState,n=t.facet(zt),i=e;for(let s=n.length-1;s>=0;s--){let r=n[s](e);r&&Object.keys(r).length&&(i=Kt(i,Jt(t,r,e.changes.newLength),!0))}return i==e?e:Ht.create(t,e.changes,e.selection,i.effects,i.annotations,i.scrollIntoView)}(n?function(e){let t=e.startState,n=!0;for(let i of t.facet(Bt)){let t=i(e);if(!1===t){n=!1;break}Array.isArray(t)&&(n=!0===n?t:qt(n,t))}if(!0!==n){let i,s;if(!1===n)s=e.changes.invertedDesc,i=it.empty(t.doc.length);else{let t=e.changes.filter(n);i=t.changes,s=t.filtered.mapDesc(t.changes).invertedDesc}e=Ht.create(t,i,e.selection&&e.selection.map(s),Vt.mapEffects(e.effects,s),e.annotations,e.scrollIntoView)}let i=t.facet(Lt);for(let n=i.length-1;n>=0;n--){let s=i[n](e);e=s instanceof Ht?s:Array.isArray(s)&&1==s.length&&s[0]instanceof Ht?s[0]:Zt(t,Gt(s),!1)}return e}(s):s)}Ht.time=Wt.define(),Ht.userEvent=Wt.define(),Ht.addToHistory=Wt.define(),Ht.remote=Wt.define();const Yt=[];function Gt(e){return null==e?Yt:Array.isArray(e)?e:[e]}var Qt=function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(Qt||(Qt={}));const Xt=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let en;try{en=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(wm){}function tn(e){return t=>{if(!/\S/.test(t))return Qt.Space;if(function(e){if(en)return en.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>""&&(n.toUpperCase()!=n.toLowerCase()||Xt.test(n)))return!0}return!1}(t))return Qt.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return Qt.Word;return Qt.Other}}class nn{constructor(e,t,n,i,s,r){this.config=e,this.doc=t,this.selection=n,this.values=i,this.status=e.statusTemplate.slice(),this.computeSlot=s,r&&(r._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)_t(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(null!=n)return _t(this,n),Pt(this,n);if(t)throw new RangeError("Field is not present in this state")}update(...e){return Zt(this,e,!0)}applyTransaction(e){let t,n=this.config,{base:i,compartments:s}=n;for(let t of e.effects)t.is(Et.reconfigure)?(n&&(s=new Map,n.compartments.forEach((e,t)=>s.set(t,e)),n=null),s.set(t.value.compartment,t.value.extension)):t.is(Vt.reconfigure)?(n=null,i=t.value):t.is(Vt.appendConfig)&&(n=null,i=Gt(i).concat(t.value));if(n)t=e.startState.values.slice();else{n=Dt.resolve(i,s,this),t=new nn(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values}let r=e.startState.facet(Rt)?e.newSelection:e.newSelection.asSingle();new nn(n,e.newDoc,r,t,(t,n)=>n.update(t,e),e)}replaceSelection(e){return"string"==typeof e&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:ut.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),i=this.changes(n.changes),s=[n.range],r=Gt(n.effects);for(let n=1;n<t.ranges.length;n++){let o=e(t.ranges[n]),a=this.changes(o.changes),l=a.map(i);for(let e=0;e<n;e++)s[e]=s[e].map(l);let c=i.mapDesc(a,!0);s.push(o.range.map(c)),i=i.compose(l),r=Vt.mapEffects(r,l).concat(Vt.mapEffects(Gt(o.effects),c))}return{changes:i,selection:ut.create(s,t.mainIndex),effects:r}}changes(e=[]){return e instanceof it?e:it.of(e,this.doc.length,this.facet(nn.lineSeparator))}toText(e){return je.of(e.split(this.facet(nn.lineSeparator)||et))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return null==t?e.default:(_t(this,t),Pt(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let i=e[n];i instanceof kt&&null!=this.config.address[i.id]&&(t[n]=i.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e,t={},n){if(!e||"string"!=typeof e.doc)throw new RangeError("Invalid JSON representation for EditorState");let i=[];if(n)for(let t in n)if(Object.prototype.hasOwnProperty.call(e,t)){let s=n[t],r=e[t];i.push(s.init(e=>s.spec.fromJSON(r,e)))}return nn.create({doc:e.doc,selection:ut.fromJSON(e.selection),extensions:t.extensions?i.concat([t.extensions]):i})}static create(e={}){let t=Dt.resolve(e.extensions||[],new Map),n=e.doc instanceof je?e.doc:je.of((e.doc||"").split(t.staticFacet(nn.lineSeparator)||et)),i=e.selection?e.selection instanceof ut?e.selection:ut.single(e.selection.anchor,e.selection.head):ut.single(0);return dt(i,n.length),t.staticFacet(Rt)||(i=i.asSingle()),new nn(t,n,i,t.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(nn.tabSize)}get lineBreak(){return this.facet(nn.lineSeparator)||"\n"}get readOnly(){return this.facet(jt)}phrase(e,...t){for(let t of this.facet(nn.phrases))if(Object.prototype.hasOwnProperty.call(t,e)){e=t[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(e,n)=>{if("$"==n)return"$";let i=+(n||1);return!i||i>t.length?e:t[i-1]})),e}languageDataAt(e,t,n=-1){let i=[];for(let s of this.facet(It))for(let r of s(this,t,n))Object.prototype.hasOwnProperty.call(r,e)&&i.push(r[e]);return i}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return tn(t.length?t[0]:"")}wordAt(e){let{text:t,from:n,length:i}=this.doc.lineAt(e),s=this.charCategorizer(e),r=e-n,o=e-n;for(;r>0;){let e=Ye(t,r,!1);if(s(t.slice(e,r))!=Qt.Word)break;r=e}for(;o<i;){let e=Ye(t,o);if(s(t.slice(o,e))!=Qt.Word)break;o=e}return r==o?null:ut.range(r+n,o+n)}}function sn(e,t,n={}){let i={};for(let t of e)for(let e of Object.keys(t)){let s=t[e],r=i[e];if(void 0===r)i[e]=s;else if(r===s||void 0===s);else{if(!Object.hasOwnProperty.call(n,e))throw new Error("Config merge conflict for field "+e);i[e]=n[e](r,s)}}for(let e in t)void 0===i[e]&&(i[e]=t[e]);return i}nn.allowMultipleSelections=Rt,nn.tabSize=pt.define({combine:e=>e.length?e[0]:4}),nn.lineSeparator=$t,nn.readOnly=jt,nn.phrases=pt.define({compare(e,t){let n=Object.keys(e),i=Object.keys(t);return n.length==i.length&&n.every(n=>e[n]==t[n])}}),nn.languageData=It,nn.changeFilter=Bt,nn.transactionFilter=Lt,nn.transactionExtender=zt,Et.reconfigure=Vt.define();class rn{eq(e){return this==e}range(e,t=e){return an.create(e,t,this)}}function on(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}rn.prototype.startSide=rn.prototype.endSide=0,rn.prototype.point=!1,rn.prototype.mapMode=tt.TrackDel;class an{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new an(e,t,n)}}function ln(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}class cn{constructor(e,t,n,i){this.from=e,this.to=t,this.value=n,this.maxPoint=i}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,i=0){let s=n?this.to:this.from;for(let r=i,o=s.length;;){if(r==o)return r;let i=r+o>>1,a=s[i]-e||(n?this.value[i].endSide:this.value[i].startSide)-t;if(i==r)return a>=0?r:o;a>=0?o=i:r=i+1}}between(e,t,n,i){for(let s=this.findIndex(t,-1e9,!0),r=this.findIndex(n,1e9,!1,s);s<r;s++)if(!1===i(this.from[s]+e,this.to[s]+e,this.value[s]))return!1}map(e,t){let n=[],i=[],s=[],r=-1,o=-1;for(let a=0;a<this.value.length;a++){let l,c,h=this.value[a],u=this.from[a]+e,d=this.to[a]+e;if(u==d){let e=t.mapPos(u,h.startSide,h.mapMode);if(null==e)continue;if(l=c=e,h.startSide!=h.endSide&&(c=t.mapPos(u,h.endSide),c<l))continue}else if(l=t.mapPos(u,h.startSide),c=t.mapPos(d,h.endSide),l>c||l==c&&h.startSide>0&&h.endSide<=0)continue;(c-l||h.endSide-h.startSide)<0||(r<0&&(r=l),h.point&&(o=Math.max(o,c-l)),n.push(h),i.push(l-r),s.push(c-r))}return{mapped:n.length?new cn(i,s,n,o):null,pos:r}}}class hn{constructor(e,t,n,i){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=i}static create(e,t,n,i){return new hn(e,t,n,i)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:n=!1,filterFrom:i=0,filterTo:s=this.length}=e,r=e.filter;if(0==t.length&&!r)return this;if(n&&(t=t.slice().sort(ln)),this.isEmpty)return t.length?hn.of(t):this;let o=new fn(this,null,-1).goto(0),a=0,l=[],c=new un;for(;o.value||a<t.length;)if(a<t.length&&(o.from-t[a].from||o.startSide-t[a].value.startSide)>=0){let e=t[a++];c.addInner(e.from,e.to,e.value)||l.push(e)}else 1==o.rangeIndex&&o.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(o.chunkIndex)<t[a].from)&&(!r||i>this.chunkEnd(o.chunkIndex)||s<this.chunkPos[o.chunkIndex])&&c.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!r||i>o.to||s<o.from||r(o.from,o.to,o.value))&&(c.addInner(o.from,o.to,o.value)||l.push(an.create(o.from,o.to,o.value))),o.next());return c.finishInner(this.nextLayer.isEmpty&&!l.length?hn.empty:this.nextLayer.update({add:l,filter:r,filterFrom:i,filterTo:s}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],n=[],i=-1;for(let s=0;s<this.chunk.length;s++){let r=this.chunkPos[s],o=this.chunk[s],a=e.touchesRange(r,r+o.length);if(!1===a)i=Math.max(i,o.maxPoint),t.push(o),n.push(e.mapPos(r));else if(!0===a){let{mapped:s,pos:a}=o.map(r,e);s&&(i=Math.max(i,s.maxPoint),t.push(s),n.push(a))}}let s=this.nextLayer.map(e);return 0==t.length?s:new hn(n,t,s||hn.empty,i)}between(e,t,n){if(!this.isEmpty){for(let i=0;i<this.chunk.length;i++){let s=this.chunkPos[i],r=this.chunk[i];if(t>=s&&e<=s+r.length&&!1===r.between(s,e-s,t-s,n))return}this.nextLayer.between(e,t,n)}}iter(e=0){return pn.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return pn.from(e).goto(t)}static compare(e,t,n,i,s=-1){let r=e.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=s),o=t.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=s),a=dn(r,o,n),l=new gn(r,a,s),c=new gn(o,a,s);n.iterGaps((e,t,n)=>yn(l,e,c,t,n,i)),n.empty&&0==n.length&&yn(l,0,c,0,0,i)}static eq(e,t,n=0,i){null==i&&(i=999999999);let s=e.filter(e=>!e.isEmpty&&t.indexOf(e)<0),r=t.filter(t=>!t.isEmpty&&e.indexOf(t)<0);if(s.length!=r.length)return!1;if(!s.length)return!0;let o=dn(s,r),a=new gn(s,o,0).goto(n),l=new gn(r,o,0).goto(n);for(;;){if(a.to!=l.to||!vn(a.active,l.active)||a.point&&(!l.point||!on(a.point,l.point)))return!1;if(a.to>i)return!0;a.next(),l.next()}}static spans(e,t,n,i,s=-1){let r=new gn(e,null,s).goto(t),o=t,a=r.openStart;for(;;){let e=Math.min(r.to,n);if(r.point){let n=r.activeForPoint(r.to),s=r.pointFrom<t?n.length+1:r.point.startSide<0?n.length:Math.min(n.length,a);i.point(o,e,r.point,n,s,r.pointRank),a=Math.min(r.openEnd(e),n.length)}else e>o&&(i.span(o,e,r.active,a),a=r.openEnd(e));if(r.to>n)return a+(r.point&&r.to>n?1:0);o=r.to,r.next()}}static of(e,t=!1){let n=new un;for(let i of e instanceof an?[e]:t?function(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let i=e[n];if(ln(t,i)>0)return e.slice().sort(ln);t=i}return e}(e):e)n.add(i.from,i.to,i.value);return n.finish()}static join(e){if(!e.length)return hn.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let i=e[n];i!=hn.empty;i=i.nextLayer)t=new hn(i.chunkPos,i.chunk,t,Math.max(i.maxPoint,t.maxPoint));return t}}hn.empty=new hn([],[],null,-1),hn.empty.nextLayer=hn.empty;class un{finishChunk(e){this.chunks.push(new cn(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new un)).add(e,t,n)}addInner(e,t,n){let i=e-this.lastTo||n.startSide-this.last.endSide;if(i<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(i<0)&&(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(hn.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return e;let t=hn.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function dn(e,t,n){let i=new Map;for(let t of e)for(let e=0;e<t.chunk.length;e++)t.chunk[e].maxPoint<=0&&i.set(t.chunk[e],t.chunkPos[e]);let s=new Set;for(let e of t)for(let t=0;t<e.chunk.length;t++){let r=i.get(e.chunk[t]);null==r||(n?n.mapPos(r):r)!=e.chunkPos[t]||(null==n?void 0:n.touchesRange(r,r+e.chunk[t].length))||s.add(e.chunk[t])}return s}class fn{constructor(e,t,n,i=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=i}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let t=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(t)||this.layer.chunkEnd(this.chunkIndex)<e||t.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let i=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<i)&&this.setRangeIndex(i)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class pn{constructor(e){this.heap=e}static from(e,t=null,n=-1){let i=[];for(let s=0;s<e.length;s++)for(let r=e[s];!r.isEmpty;r=r.nextLayer)r.maxPoint>=n&&i.push(new fn(r,t,n,s));return 1==i.length?i[0]:new pn(i)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let e=this.heap.length>>1;e>=0;e--)mn(this.heap,e);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)mn(this.heap,e);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),mn(this.heap,0)}}}function mn(e,t){for(let n=e[t];;){let i=1+(t<<1);if(i>=e.length)break;let s=e[i];if(i+1<e.length&&s.compare(e[i+1])>=0&&(s=e[i+1],i++),n.compare(s)<0)break;e[i]=n,e[t]=s,t=i}}class gn{constructor(e,t,n){this.minPoint=n,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=pn.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){bn(this.active,e),bn(this.activeTo,e),bn(this.activeRank,e),this.minActive=kn(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:i,rank:s}=this.cursor;for(;t<this.activeRank.length&&(s-this.activeRank[t]||i-this.activeTo[t])>0;)t++;wn(this.active,t,n),wn(this.activeTo,t,i),wn(this.activeRank,t,s),e&&wn(e,t,this.cursor.from),this.minActive=kn(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let i=this.minActive;if(i>-1&&(this.activeTo[i]-this.cursor.from||this.active[i].endSide-this.cursor.startSide)<0){if(this.activeTo[i]>e){this.to=this.activeTo[i],this.endSide=this.active[i].endSide;break}this.removeActive(i),n&&bn(n,i)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}{let e=this.cursor.value;if(e.point){if(!(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=e,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=e.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(n),this.cursor.next()}}}if(n){this.openStart=0;for(let t=n.length-1;t>=0&&n[t]<e;t--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}}function yn(e,t,n,i,s,r){e.goto(t),n.goto(i);let o=i+s,a=i,l=i-t,c=!!r.boundChange;for(let t=!1;;){let i=e.to+l-n.to,s=i||e.endSide-n.endSide,h=s<0?e.to+l:n.to,u=Math.min(h,o);if(e.point||n.point?(e.point&&n.point&&on(e.point,n.point)&&vn(e.activeForPoint(e.to),n.activeForPoint(n.to))||r.comparePoint(a,u,e.point,n.point),t=!1):(t&&r.boundChange(a),u>a&&!vn(e.active,n.active)&&r.compareRange(a,u,e.active,n.active),c&&u<o&&(i||e.openEnd(h)!=n.openEnd(h))&&(t=!0)),h>o)break;a=h,s<=0&&e.next(),s>=0&&n.next()}}function vn(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!on(e[n],t[n]))return!1;return!0}function bn(e,t){for(let n=t,i=e.length-1;n<i;n++)e[n]=e[n+1];e.pop()}function wn(e,t,n){for(let n=e.length-1;n>=t;n--)e[n+1]=e[n];e[t]=n}function kn(e,t){let n=-1,i=1e9;for(let s=0;s<t.length;s++)(t[s]-i||e[s].endSide-e[n].endSide)<0&&(n=s,i=t[s]);return n}function xn(e,t,n=e.length){let i=0;for(let s=0;s<n&&s<e.length;)9==e.charCodeAt(s)?(i+=t-i%t,s++):(i++,s=Ye(e,s));return i}function Sn(e,t,n,i){for(let i=0,s=0;;){if(s>=t)return i;if(i==e.length)break;s+=9==e.charCodeAt(i)?n-s%n:1,i=Ye(e,i)}return!0===i?-1:e.length}const Cn="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),An="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),Tn="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class On{constructor(e,t){this.rules=[];let{finish:n}=t||{};function i(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function s(e,t,r,o){let a=[],l=/^@(\w+)\b/.exec(e[0]),c=l&&"keyframes"==l[1];if(l&&null==t)return r.push(e[0]+";");for(let n in t){let o=t[n];if(/&/.test(n))s(n.split(/,\s*/).map(t=>e.map(e=>t.replace(/&/,e))).reduce((e,t)=>e.concat(t)),o,r);else if(o&&"object"==typeof o){if(!l)throw new RangeError("The value of a property ("+n+") should be a primitive value.");s(i(n),o,a,c)}else null!=o&&a.push(n.replace(/_.*/,"").replace(/[A-Z]/g,e=>"-"+e.toLowerCase())+": "+o+";")}(a.length||c)&&r.push((!n||l||o?e:e.map(n)).join(", ")+" {"+a.join(" ")+"}")}for(let t in e)s(i(t),e[t],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let e=Tn[Cn]||1;return Tn[Cn]=e+1,"ͼ"+e.toString(36)}static mount(e,t,n){let i=e[An],s=n&&n.nonce;i?s&&i.setNonce(s):i=new En(e,s),i.mount(Array.isArray(t)?t:[t],e)}}let Mn=new Map;class En{constructor(e,t){let n=e.ownerDocument||e,i=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&i.CSSStyleSheet){let t=Mn.get(n);if(t)return e[An]=t;this.sheet=new i.CSSStyleSheet,Mn.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[An]=this}mount(e,t){let n=this.sheet,i=0,s=0;for(let t=0;t<e.length;t++){let r=e[t],o=this.modules.indexOf(r);if(o<s&&o>-1&&(this.modules.splice(o,1),s--,o=-1),-1==o){if(this.modules.splice(s++,0,r),n)for(let e=0;e<r.rules.length;e++)n.insertRule(r.rules[e],i++)}else{for(;s<o;)i+=this.modules[s++].rules.length;i+=r.rules.length,s++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let e="";for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+"\n";this.styleTag.textContent=e;let n=t.head||t;this.styleTag.parentNode!=n&&n.insertBefore(this.styleTag,n.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}for(var Nn={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:"'"},Dn={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},_n="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Pn="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),In=0;In<10;In++)Nn[48+In]=Nn[96+In]=String(In);for(In=1;In<=24;In++)Nn[In+111]="F"+In;for(In=65;In<=90;In++)Nn[In]=String.fromCharCode(In+32),Dn[In]=String.fromCharCode(In);for(var Rn in Nn)Dn.hasOwnProperty(Rn)||(Dn[Rn]=Nn[Rn]);function $n(){var e=arguments[0];"string"==typeof e&&(e=document.createElement(e));var t=1,n=arguments[1];if(n&&"object"==typeof n&&null==n.nodeType&&!Array.isArray(n)){for(var i in n)if(Object.prototype.hasOwnProperty.call(n,i)){var s=n[i];"string"==typeof s?e.setAttribute(i,s):null!=s&&(e[i]=s)}t++}for(;t<arguments.length;t++)Bn(e,arguments[t]);return e}function Bn(e,t){if("string"==typeof t)e.appendChild(document.createTextNode(t));else if(null==t);else if(null!=t.nodeType)e.appendChild(t);else{if(!Array.isArray(t))throw new RangeError("Unsupported child node: "+t);for(var n=0;n<t.length;n++)Bn(e,t[n])}}let Ln="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},zn="undefined"!=typeof document?document:{documentElement:{style:{}}};const jn=/Edge\/(\d+)/.exec(Ln.userAgent),Wn=/MSIE \d/.test(Ln.userAgent),Un=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ln.userAgent),Fn=!!(Wn||Un||jn),Vn=!Fn&&/gecko\/(\d+)/i.test(Ln.userAgent),Hn=!Fn&&/Chrome\/(\d+)/.exec(Ln.userAgent),qn="webkitFontSmoothing"in zn.documentElement.style,Kn=!Fn&&/Apple Computer/.test(Ln.vendor),Jn=Kn&&(/Mobile\/\w+/.test(Ln.userAgent)||Ln.maxTouchPoints>2);var Zn={mac:Jn||/Mac/.test(Ln.platform),windows:/Win/.test(Ln.platform),linux:/Linux|X11/.test(Ln.platform),ie:Fn,ie_version:Wn?zn.documentMode||6:Un?+Un[1]:jn?+jn[1]:0,gecko:Vn,gecko_version:Vn?+(/Firefox\/(\d+)/.exec(Ln.userAgent)||[0,0])[1]:0,chrome:!!Hn,chrome_version:Hn?+Hn[1]:0,ios:Jn,android:/Android\b/.test(Ln.userAgent),webkit_version:qn?+(/\bAppleWebKit\/(\d+)/.exec(Ln.userAgent)||[0,0])[1]:0,safari:Kn,safari_version:Kn?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Ln.userAgent)||[0,0])[1]:0,tabSize:null!=zn.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};function Yn(e,t){for(let n in e)"class"==n&&t.class?t.class+=" "+e.class:"style"==n&&t.style?t.style+=";"+e.style:t[n]=e[n];return t}const Gn=Object.create(null);function Qn(e,t,n){if(e==t)return!0;e||(e=Gn),t||(t=Gn);let i=Object.keys(e),s=Object.keys(t);if(i.length-0!=s.length-0)return!1;for(let r of i)if(r!=n&&(-1==s.indexOf(r)||e[r]!==t[r]))return!1;return!0}function Xn(e,t,n){let i=!1;if(t)for(let s in t)n&&s in n||(i=!0,"style"==s?e.style.cssText="":e.removeAttribute(s));if(n)for(let s in n)t&&t[s]==n[s]||(i=!0,"style"==s?e.style.cssText=n[s]:e.setAttribute(s,n[s]));return i}function ei(e){let t=Object.create(null);for(let n=0;n<e.attributes.length;n++){let i=e.attributes[n];t[i.name]=i.value}return t}class ti{eq(e){return!1}updateDOM(e,t,n){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var ni=function(e){return e[e.Text=0]="Text",e[e.WidgetBefore=1]="WidgetBefore",e[e.WidgetAfter=2]="WidgetAfter",e[e.WidgetRange=3]="WidgetRange",e}(ni||(ni={}));class ii extends rn{constructor(e,t,n,i){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=i}get heightRelevant(){return!1}static mark(e){return new si(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new oi(e,t,t,n,e.widget||null,!1)}static replace(e){let t,n,i=!!e.block;if(e.isBlockGap)t=-5e8,n=4e8;else{let{start:s,end:r}=ai(e,i);t=(s?i?-3e8:-1:5e8)-1,n=1+(r?i?2e8:1:-6e8)}return new oi(e,t,n,i,e.widget||null,!0)}static line(e){return new ri(e)}static set(e,t=!1){return hn.of(e,t)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}ii.none=hn.empty;class si extends ii{constructor(e){let{start:t,end:n}=ai(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Yn(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Gn}eq(e){return this==e||e instanceof si&&this.tagName==e.tagName&&Qn(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}si.prototype.point=!1;class ri extends ii{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof ri&&this.spec.class==e.spec.class&&Qn(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}ri.prototype.mapMode=tt.TrackBefore,ri.prototype.point=!0;class oi extends ii{constructor(e,t,n,i,s,r){super(t,n,s,e),this.block=i,this.isReplace=r,this.mapMode=i?t<=0?tt.TrackBefore:tt.TrackAfter:tt.TrackDel}get type(){return this.startSide!=this.endSide?ni.WidgetRange:this.startSide<=0?ni.WidgetBefore:ni.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof oi&&function(e,t){return e==t||!!(e&&t&&e.compare(t))}(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}function ai(e,t=!1){let{inclusiveStart:n,inclusiveEnd:i}=e;return null==n&&(n=e.inclusive),null==i&&(i=e.inclusive),{start:null!=n?n:t,end:null!=i?i:t}}function li(e,t,n,i=0){let s=n.length-1;s>=0&&n[s]+i>=e?n[s]=Math.max(n[s],t):n.push(e,t)}oi.prototype.point=!0;class ci extends rn{constructor(e,t){super(),this.tagName=e,this.attributes=t}eq(e){return e==this||e instanceof ci&&this.tagName==e.tagName&&Qn(this.attributes,e.attributes)}static create(e){return new ci(e.tagName,e.attributes||Gn)}static set(e,t=!1){return hn.of(e,t)}}function hi(e){let t;return t=11==e.nodeType?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function ui(e,t){return!!t&&(e==t||e.contains(1!=t.nodeType?t.parentNode:t))}function di(e,t){if(!t.anchorNode)return!1;try{return ui(e,t.anchorNode)}catch(e){return!1}}function fi(e){return 3==e.nodeType?Oi(e,0,e.nodeValue.length).getClientRects():1==e.nodeType?e.getClientRects():[]}function pi(e,t,n,i){return!!n&&(yi(e,t,n,i,-1)||yi(e,t,n,i,1))}function mi(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t}function gi(e){return 1==e.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function yi(e,t,n,i,s){for(;;){if(e==n&&t==i)return!0;if(t==(s<0?0:vi(e))){if("DIV"==e.nodeName)return!1;let n=e.parentNode;if(!n||1!=n.nodeType)return!1;t=mi(e)+(s<0?0:1),e=n}else{if(1!=e.nodeType)return!1;if(1==(e=e.childNodes[t+(s<0?-1:0)]).nodeType&&"false"==e.contentEditable)return!1;t=s<0?vi(e):0}}}function vi(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function bi(e,t){let n=t?e.left:e.right;return{left:n,right:n,top:e.top,bottom:e.bottom}}function wi(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function ki(e,t){let n=t.width/e.offsetWidth,i=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.width-e.offsetWidth)<1)&&(n=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(t.height-e.offsetHeight)<1)&&(i=1),{scaleX:n,scaleY:i}}function xi(e,t=!0){let n=e.ownerDocument,i=null,s=null;for(let r=e.parentNode;r&&(r!=n.body&&(t&&!i||!s));)if(1==r.nodeType)!s&&r.scrollHeight>r.clientHeight&&(s=r),t&&!i&&r.scrollWidth>r.clientWidth&&(i=r),r=r.assignedSlot||r.parentNode;else{if(11!=r.nodeType)break;r=r.host}return{x:i,y:s}}ci.prototype.startSide=ci.prototype.endSide=-1;class Si{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?vi(t):0),n,Math.min(e.focusOffset,n?vi(n):0))}set(e,t,n,i){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=i}}let Ci,Ai=null;function Ti(e){if(e.setActive)return e.setActive();if(Ai)return e.focus(Ai);let t=[];for(let n=e;n&&(t.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(e.focus(null==Ai?{get preventScroll(){return Ai={preventScroll:!0},!0}}:void 0),!Ai){Ai=!1;for(let e=0;e<t.length;){let n=t[e++],i=t[e++],s=t[e++];n.scrollTop!=i&&(n.scrollTop=i),n.scrollLeft!=s&&(n.scrollLeft=s)}}}function Oi(e,t,n=t){let i=Ci||(Ci=document.createRange());return i.setEnd(e,n),i.setStart(e,t),i}function Mi(e,t,n,i){let s={key:t,code:t,keyCode:n,which:n,cancelable:!0};i&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=i);let r=new KeyboardEvent("keydown",s);r.synthetic=!0,e.dispatchEvent(r);let o=new KeyboardEvent("keyup",s);return o.synthetic=!0,e.dispatchEvent(o),r.defaultPrevented||o.defaultPrevented}function Ei(e){return e instanceof Window?e.pageYOffset>Math.max(0,e.document.documentElement.scrollHeight-e.innerHeight-4):e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function Ni(e,t){for(let n=e,i=t;;){if(3==n.nodeType&&i>0)return{node:n,offset:i};if(1==n.nodeType&&i>0){if("false"==n.contentEditable)return null;n=n.childNodes[i-1],i=vi(n)}else{if(!n.parentNode||gi(n))return null;i=mi(n),n=n.parentNode}}}function Di(e,t){for(let n=e,i=t;;){if(3==n.nodeType&&i<n.nodeValue.length)return{node:n,offset:i};if(1==n.nodeType&&i<n.childNodes.length){if("false"==n.contentEditable)return null;n=n.childNodes[i],i=0}else{if(!n.parentNode||gi(n))return null;i=mi(n)+1,n=n.parentNode}}}Zn.safari&&Zn.safari_version>=26&&(Ai=!1);class _i{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(e,t){return new _i(e.parentNode,mi(e),t)}static after(e,t){return new _i(e.parentNode,mi(e)+1,t)}}var Pi=function(e){return e[e.LTR=0]="LTR",e[e.RTL=1]="RTL",e}(Pi||(Pi={}));const Ii=Pi.LTR,Ri=Pi.RTL;function $i(e){let t=[];for(let n=0;n<e.length;n++)t.push(1<<+e[n]);return t}const Bi=$i("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Li=$i("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),zi=Object.create(null),ji=[];for(let e of["()","[]","{}"]){let t=e.charCodeAt(0),n=e.charCodeAt(1);zi[t]=n,zi[n]=-t}function Wi(e){return e<=247?Bi[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?Li[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}const Ui=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Fi{get dir(){return this.level%2?Ri:Ii}constructor(e,t,n){this.from=e,this.to=t,this.level=n}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,i){let s=-1;for(let r=0;r<e.length;r++){let o=e[r];if(o.from<=t&&o.to>=t){if(o.level==n)return r;(s<0||(0!=i?i<0?o.from<t:o.to>t:e[s].level>o.level))&&(s=r)}}if(s<0)throw new RangeError("Index out of range");return s}}function Vi(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let i=e[n],s=t[n];if(i.from!=s.from||i.to!=s.to||i.direction!=s.direction||!Vi(i.inner,s.inner))return!1}return!0}const Hi=[];function qi(e,t,n,i,s,r,o){let a=i%2?2:1;if(i%2==s%2)for(let l=t,c=0;l<n;){let t=!0,h=!1;if(c==r.length||l<r[c].from){let e=Hi[l];e!=a&&(t=!1,h=16==e)}let u=t||1!=a?null:[],d=t?i:i+1,f=l;e:for(;;)if(c<r.length&&f==r[c].from){if(h)break e;let p=r[c];if(!t)for(let e=p.to,t=c+1;;){if(e==n)break e;if(!(t<r.length&&r[t].from==e)){if(Hi[e]==a)break e;break}e=r[t++].to}if(c++,u)u.push(p);else{p.from>l&&o.push(new Fi(l,p.from,d)),Ki(e,p.direction==Ii!=!(d%2)?i+1:i,s,p.inner,p.from,p.to,o),l=p.to}f=p.to}else{if(f==n||(t?Hi[f]!=a:Hi[f]==a))break;f++}u?qi(e,l,f,i+1,s,u,o):l<f&&o.push(new Fi(l,f,d)),l=f}else for(let l=n,c=r.length;l>t;){let n=!0,h=!1;if(!c||l>r[c-1].to){let e=Hi[l-1];e!=a&&(n=!1,h=16==e)}let u=n||1!=a?null:[],d=n?i:i+1,f=l;e:for(;;)if(c&&f==r[c-1].to){if(h)break e;let p=r[--c];if(!n)for(let e=p.from,n=c;;){if(e==t)break e;if(!n||r[n-1].to!=e){if(Hi[e-1]==a)break e;break}e=r[--n].from}if(u)u.push(p);else{p.to<l&&o.push(new Fi(p.to,l,d)),Ki(e,p.direction==Ii!=!(d%2)?i+1:i,s,p.inner,p.from,p.to,o),l=p.from}f=p.from}else{if(f==t||(n?Hi[f-1]!=a:Hi[f-1]==a))break;f--}u?qi(e,f,l,i+1,s,u,o):f<l&&o.push(new Fi(f,l,d)),l=f}}function Ki(e,t,n,i,s,r,o){let a=t%2?2:1;!function(e,t,n,i,s){for(let r=0;r<=i.length;r++){let o=r?i[r-1].to:t,a=r<i.length?i[r].from:n,l=r?256:s;for(let t=o,n=l,i=l;t<a;t++){let s=Wi(e.charCodeAt(t));512==s?s=n:8==s&&4==i&&(s=16),Hi[t]=4==s?2:s,7&s&&(i=s),n=s}for(let e=o,t=l,i=l;e<a;e++){let s=Hi[e];if(128==s)e<a-1&&t==Hi[e+1]&&24&t?s=Hi[e]=t:Hi[e]=256;else if(64==s){let s=e+1;for(;s<a&&64==Hi[s];)s++;let r=e&&8==t||s<n&&8==Hi[s]?1==i?1:8:256;for(let t=e;t<s;t++)Hi[t]=r;e=s-1}else 8==s&&1==i&&(Hi[e]=1);t=s,7&s&&(i=s)}}}(e,s,r,i,a),function(e,t,n,i,s){let r=1==s?2:1;for(let o=0,a=0,l=0;o<=i.length;o++){let c=o?i[o-1].to:t,h=o<i.length?i[o].from:n;for(let t,n,i,o=c;o<h;o++)if(n=zi[t=e.charCodeAt(o)])if(n<0){for(let e=a-3;e>=0;e-=3)if(ji[e+1]==-n){let t=ji[e+2],n=2&t?s:4&t?1&t?r:s:0;n&&(Hi[o]=Hi[ji[e]]=n),a=e;break}}else{if(189==ji.length)break;ji[a++]=o,ji[a++]=t,ji[a++]=l}else if(2==(i=Hi[o])||1==i){let e=i==s;l=e?0:1;for(let t=a-3;t>=0;t-=3){let n=ji[t+2];if(2&n)break;if(e)ji[t+2]|=2;else{if(4&n)break;ji[t+2]|=4}}}}}(e,s,r,i,a),function(e,t,n,i){for(let s=0,r=i;s<=n.length;s++){let o=s?n[s-1].to:e,a=s<n.length?n[s].from:t;for(let l=o;l<a;){let o=Hi[l];if(256==o){let o=l+1;for(;;)if(o==a){if(s==n.length)break;o=n[s++].to,a=s<n.length?n[s].from:t}else{if(256!=Hi[o])break;o++}let c=1==r,h=c==(1==(o<t?Hi[o]:i))?c?1:2:i;for(let t=o,i=s,r=i?n[i-1].to:e;t>l;)t==r&&(t=n[--i].from,r=i?n[i-1].to:e),Hi[--t]=h;l=o}else r=o,l++}}}(s,r,i,a),qi(e,s,r,t,n,i,o)}function Ji(e){return[new Fi(0,e,0)]}let Zi="";function Yi(e,t,n,i,s){var r;let o=i.head-e.from,a=Fi.find(t,o,null!==(r=i.bidiLevel)&&void 0!==r?r:-1,i.assoc),l=t[a],c=l.side(s,n);if(o==c){let e=a+=s?1:-1;if(e<0||e>=t.length)return null;l=t[a=e],o=l.side(!s,n),c=l.side(s,n)}let h=Ye(e.text,o,l.forward(s,n));(h<l.from||h>l.to)&&(h=c),Zi=e.text.slice(Math.min(o,h),Math.max(o,h));let u=a==(s?t.length-1:0)?null:t[a+(s?1:-1)];return u&&h==c&&u.level+(s?0:1)<l.level?ut.cursor(u.side(!s,n)+e.from,u.forward(s,n)?1:-1,u.level):ut.cursor(h+e.from,l.forward(s,n)?-1:1,l.level)}function Gi(e,t,n){for(let i=t;i<n;i++){let t=Wi(e.charCodeAt(i));if(1==t)return Ii;if(2==t||4==t)return Ri}return Ii}const Qi=pt.define(),Xi=pt.define(),es=pt.define(),ts=pt.define(),ns=pt.define(),is=pt.define(),ss=pt.define(),rs=pt.define(),os=pt.define(),as=pt.define({combine:e=>e.some(e=>e)}),ls=pt.define({combine:e=>e.some(e=>e)}),cs=pt.define();class hs{constructor(e,t="nearest",n="nearest",i=5,s=5,r=!1){this.range=e,this.y=t,this.x=n,this.yMargin=i,this.xMargin=s,this.isSnapshot=r}map(e){return e.empty?this:new hs(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new hs(ut.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const us=Vt.define({map:(e,t)=>e.map(t)}),ds=Vt.define();function fs(e,t,n){let i=e.facet(ts);i.length?i[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)||(n?console.error(n+":",t):console.error(t))}const ps=pt.define({combine:e=>!e.length||e[0]});let ms=0;const gs=pt.define({combine:e=>e.filter((t,n)=>{for(let i=0;i<n;i++)if(e[i].plugin==t.plugin)return!1;return!0})});class ys{constructor(e,t,n,i,s){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=i,this.baseExtensions=s(this),this.extension=this.baseExtensions.concat(gs.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(gs.of({plugin:this,arg:e}))}static define(e,t){const{eventHandlers:n,eventObservers:i,provide:s,decorations:r}=t||{};return new ys(ms++,e,n,i,e=>{let t=[];return r&&t.push(ks.of(t=>{let n=t.plugin(e);return n?r(n):ii.none})),s&&t.push(s(e)),t})}static fromClass(e,t){return ys.define((t,n)=>new e(t,n),t)}}class vs{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(fs(e.state,t,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(e){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){fs(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(null===(t=this.value)||void 0===t?void 0:t.destroy)try{this.value.destroy()}catch(t){fs(e.state,t,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const bs=pt.define(),ws=pt.define(),ks=pt.define(),xs=pt.define(),Ss=pt.define(),Cs=pt.define(),As=pt.define();function Ts(e,t){let n=e.state.facet(As);if(!n.length)return n;let i=n.map(t=>t instanceof Function?t(e):t),s=[];return hn.spans(i,t.from,t.to,{point(){},span(e,n,i,r){let o=e-t.from,a=n-t.from,l=s;for(let e=i.length-1;e>=0;e--,r--){let n,s=i[e].spec.bidiIsolate;if(null==s&&(s=Gi(t.text,o,a)),r>0&&l.length&&(n=l[l.length-1]).to==o&&n.direction==s)n.to=a,l=n.inner;else{let e={from:o,to:a,direction:s,inner:[]};l.push(e),l=e.inner}}}}),s}const Os=pt.define();function Ms(e){let t=0,n=0,i=0,s=0;for(let r of e.state.facet(Os)){let o=r(e);o&&(null!=o.left&&(t=Math.max(t,o.left)),null!=o.right&&(n=Math.max(n,o.right)),null!=o.top&&(i=Math.max(i,o.top)),null!=o.bottom&&(s=Math.max(s,o.bottom)))}return{left:t,right:n,top:i,bottom:s}}const Es=pt.define();class Ns{constructor(e,t,n,i){this.fromA=e,this.toA=t,this.fromB=n,this.toB=i}join(e){return new Ns(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let i=e[t-1];if(!(i.fromA>n.toA)){if(i.toA<n.fromA)break;n=n.join(i),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(e,t){if(0==t.length)return e;let n=[];for(let i=0,s=0,r=0;;){let o=i<e.length?e[i].fromB:1e9,a=s<t.length?t[s]:1e9,l=Math.min(o,a);if(1e9==l)break;let c=l+r,h=l,u=c;for(;;)if(s<t.length&&t[s]<=h){let n=t[s+1];s+=2,h=Math.max(h,n);for(let t=i;t<e.length&&e[t].fromB<=h;t++)r=e[t].toA-e[t].toB;u=Math.max(u,n+r)}else{if(!(i<e.length&&e[i].fromB<=h))break;{let t=e[i++];h=Math.max(h,t.toB),u=Math.max(u,t.toA),r=t.toA-t.toB}}n.push(new Ns(c,u,l,h))}return n}}class Ds{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=it.empty(this.startState.doc.length);for(let e of n)this.changes=this.changes.compose(e.changes);let i=[];this.changes.iterChangedRanges((e,t,n,s)=>i.push(new Ns(e,t,n,s))),this.changedRanges=i}static create(e,t,n){return new Ds(e,t,n)}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(e=>e.selection)}get empty(){return 0==this.flags&&0==this.transactions.length}}const _s=[];class Ps{constructor(e,t,n=0){this.dom=e,this.length=t,this.flags=n,this.parent=null,e.cmTile=this}get breakAfter(){return 1&this.flags}get children(){return _s}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,4&this.flags){this.flags&=-5;let e=this.domAttrs;e&&function(e,t){for(let n=e.attributes.length-1;n>=0;n--){let i=e.attributes[n].name;null==t[i]&&e.removeAttribute(i)}for(let n in t){let i=t[n];"style"==n?e.style.cssText=i:e.getAttribute(n)!=i&&e.setAttribute(n,i)}}(this.dom,e)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let n=t;for(let t of this.children){if(t==e)return n;n+=t.length+t.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t){return null}domPosFor(e,t){let n=mi(this.dom),i=this.length?e>0:t>0;return new _i(this.parent.dom,n+(i?1:0),0==e||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&2&this.parent.flags&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof $s)return e;return null}static get(e){return e.cmTile}}class Is extends Ps{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(2&this.flags)return;super.sync(e);let t,n=this.dom,i=null,s=(null==e?void 0:e.node)==n?e:null,r=0;for(let o of this.children){if(o.sync(e),r+=o.length+o.breakAfter,t=i?i.nextSibling:n.firstChild,s&&t!=o.dom&&(s.written=!0),o.dom.parentNode==n)for(;t&&t!=o.dom;)t=Rs(t);else n.insertBefore(o.dom,t);i=o.dom}for(t=i?i.nextSibling:n.firstChild,s&&t&&(s.written=!0);t;)t=Rs(t);this.length=r}}function Rs(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class $s extends Is{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=Ps.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],n=this,i=0,s=0;;)if(i==n.children.length){if(!t.length)return;n=n.parent,n.breakAfter&&s++,i=t.pop()}else{let r=n.children[i++];if(r instanceof Bs)t.push(i),n=r,i=0;else{let t=s+r.length,n=e(r,s);if(void 0!==n)return n;s=t+r.breakAfter}}}resolveBlock(e,t){let n,i,s=-1,r=-1;if(this.blockTiles((o,a)=>{let l=a+o.length;if(e>=a&&e<=l){if(o.isWidget()&&t>=-1&&t<=1){if(32&o.flags)return!0;16&o.flags&&(n=void 0)}(a<e||e==l&&(t<-1?o.length:o.covers(1)))&&(!n||!o.isWidget()&&n.isWidget())&&(n=o,s=e-a),(l>e||e==a&&(t>1?o.length:o.covers(-1)))&&(!i||!o.isWidget()&&i.isWidget())&&(i=o,r=e-a)}}),!n&&!i)throw new Error("No tile at position "+e);return n&&t<0||!i?{tile:n,offset:s}:{tile:i,offset:r}}}class Bs extends Is{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return!!this.children.length&&(e<0?this.children[0].covers(-1):this.lastChild.covers(1))}get domAttrs(){return this.wrapper.attributes}static of(e,t){let n=new Bs(t||document.createElement(e.tagName),e);return t||(n.flags|=4),n}}class Ls extends Is{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,n){let i=new Ls(t||document.createElement("div"),e);return t&&n||(i.flags|=4),i}get domAttrs(){return this.attrs}resolveInline(e,t,n){let i=null,s=-1,r=null,o=-1;!function e(a,l){for(let c=0,h=0;c<a.children.length&&h<=l;c++){let u=a.children[c],d=h+u.length;d>=l&&(u.isComposite()?e(u,l-h):(!r||r.isHidden&&(t>0||n&&zs(r,u)))&&(d>l||32&u.flags)?(r=u,o=l-h):(h<l||16&u.flags&&!u.isHidden)&&(i=u,s=l-h)),h=d}}(this,e);let a=(t<0?i:r)||i||r;return a?{tile:a,offset:a==i?s:o}:null}coordsIn(e,t){let n=this.resolveInline(e,t,!0);return n?n.tile.coordsIn(Math.max(0,n.offset),t):function(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=fi(t);return n[n.length-1]||null}(this)}domIn(e,t){let n=this.resolveInline(e,t);if(n){let{tile:e,offset:i}=n;if(this.dom.contains(e.dom))return e.isText()?new _i(e.dom,Math.min(e.dom.nodeValue.length,i)):e.domPosFor(i,16&e.flags?1:32&e.flags?-1:t);let s=n.tile.parent,r=!1;for(let e of s.children){if(r)return new _i(e.dom,0);e==n.tile&&(r=!0)}}return new _i(this.dom,0)}}function zs(e,t){let n=e.coordsIn(0,1),i=t.coordsIn(0,1);return n&&i&&i.top<n.bottom}class js extends Is{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(e,t){let n=new js(t||document.createElement(e.tagName),e);return t||(n.flags|=4),n}}class Ws extends Ps{constructor(e,t){super(e,t.length),this.text=t}sync(e){2&this.flags||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t){let n=this.dom.nodeValue.length;e>n&&(e=n);let i=e,s=e,r=0;0==e&&t<0||e==n&&t>=0?Zn.chrome||Zn.gecko||(e?(i--,r=1):s<n&&(s++,r=-1)):t<0?i--:s<n&&s++;let o=Oi(this.dom,i,s).getClientRects();if(!o.length)return null;let a=o[(r?r<0:t>=0)?0:o.length-1];return Zn.safari&&!r&&0==a.width&&(a=Array.prototype.find.call(o,e=>e.width)||a),r?bi(a,r<0):a||null}static of(e,t){let n=new Ws(t||document.createTextNode(e),e);return t||(n.flags|=2),n}}class Us extends Ps{constructor(e,t,n,i){super(e,t,i),this.widget=n}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return!(48&this.flags)&&(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,n){let i=this.widget.coordsAt(this.dom,e,t);if(i)return i;if(n)return bi(this.dom.getBoundingClientRect(),this.length?0==e:t<=0);{let t=this.dom.getClientRects(),n=null;if(!t.length)return null;let i=!!(16&this.flags)||!(32&this.flags)&&e>0;for(let s=i?t.length-1:0;n=t[s],!(e>0?0==s:s==t.length-1||n.top<n.bottom);s+=i?-1:1);return bi(n,!i)}}get overrideDOMText(){if(!this.length)return je.empty;let{root:e}=this;if(!e)return je.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,t,n,i,s){return s||(s=e.toDOM(t),e.editable||(s.contentEditable="false")),new Us(s,n,e,i)}}class Fs extends Ps{constructor(e){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return je.empty}coordsIn(e){return this.dom.getBoundingClientRect()}}class Vs{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,n){let{tile:i,index:s,beforeBreak:r,parents:o}=this;for(;e||t>0;)if(i.isComposite())if(r){if(!e)break;n&&n.break(),e--,r=!1}else if(s==i.children.length){if(!e&&!o.length)break;n&&n.leave(i),r=!!i.breakAfter,({tile:i,index:s}=o.pop()),s++}else{let a=i.children[s],l=a.breakAfter;!(t>0?a.length<=e:a.length<e)||n&&!1===n.skip(a,0,a.length)&&a.isComposite?(o.push({tile:i,index:s}),i=a,s=0,n&&a.isComposite()&&n.enter(a)):(r=!!l,s++,e-=a.length)}else if(s==i.length)r=!!i.breakAfter,({tile:i,index:s}=o.pop()),s++;else{if(!e)break;{let t=Math.min(e,i.length-s);n&&n.skip(i,s,s+t),e-=t,s+=t}}return this.tile=i,this.index=s,this.beforeBreak=r,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class Hs{constructor(e,t,n,i){this.from=e,this.to=t,this.wrapper=n,this.rank=i}}class qs{constructor(e,t,n){this.cache=e,this.root=t,this.blockWrappers=n,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,n,i){var s;this.flushBuffer();let r=this.ensureMarks(t,n),o=r.lastChild;if(o&&o.isText()&&!(8&o.flags)&&o.length+e.length<512){this.cache.reused.set(o,2),(r.children[r.children.length-1]=new Ws(o.dom,o.text+e)).parent=r}else r.append(i||Ws.of(e,null===(s=this.cache.find(Ws))||void 0===s?void 0:s.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let n=this.curLine;n.dom!=t.line.dom&&(n.setDOM(this.cache.reused.has(t.line)?Xs(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let i=n;for(let e=t.marks.length-1;e>=0;e--){let n=t.marks[e],s=i.lastChild;if(s instanceof js&&s.mark.eq(n.mark))s.dom!=n.dom&&s.setDOM(Xs(n.dom)),i=s;else{if(this.cache.reused.get(n)){let e=Ps.get(n.dom);e&&e.setDOM(Xs(n.dom))}let e=js.of(n.mark,n.dom);i.append(e),i=e}this.cache.reused.set(n,2)}let s=Ps.get(e.text);s&&this.cache.reused.set(s,2);let r=new Ws(e.text,e.text.nodeValue);r.flags|=8,i.append(r)}addInlineWidget(e,t,n){let i=this.afterWidget&&48&e.flags&&(48&this.afterWidget.flags)==(48&e.flags);i||this.flushBuffer();let s=this.ensureMarks(t,n);i||16&e.flags||s.append(this.getBuffer(1)),s.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,n){this.flushBuffer(),this.ensureMarks(t,n).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){(this.afterWidget||this.lastBlock).length+=e,this.pos+=e}addLineStart(e,t){var n;e||(e=Qs);let i=Ls.start(e,t||(null===(n=this.cache.find(Ls))||void 0===n?void 0:n.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=i)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var n;let i=this.curLine;for(let s=e.length-1;s>=0;s--){let r,o=e[s];if(t>0&&(r=i.lastChild)&&r instanceof js&&r.mark.eq(o))i=r,t--;else{let e=js.of(o,null===(n=this.cache.find(js,e=>e.mark.eq(o)))||void 0===n?void 0:n.dom);i.append(e),i=e,t=0}}return i}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;e&&Gs(this.curLine,!1)&&("BR"==e.dom.nodeName||!e.isWidget()||Zn.ios&&Gs(this.curLine,!0))||this.curLine.append(this.cache.findWidget(tr,0,32)||new Us(tr.toDOM(),0,tr,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=new Hs(e.from,e.to,e.value,e.rank),n=this.wrappers.length;for(;n>0&&(this.wrappers[n-1].rank-t.rank||this.wrappers[n-1].to-t.to)<0;)n--;this.wrappers.splice(n,0,t)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let n of this.wrappers){let i=t.lastChild;if(n.from<this.pos&&i instanceof Bs&&i.wrapper.eq(n.wrapper))t=i;else{let i=Bs.of(n.wrapper,null===(e=this.cache.find(Bs,e=>e.wrapper.eq(n.wrapper)))||void 0===e?void 0:e.dom);t.append(i),t=i}}return t}blockPosCovered(){let e=this.lastBlock;return null!=e&&!e.breakAfter&&(!e.isWidget()||(160&e.flags)>0)}getBuffer(e){let t=2|(e<0?16:32),n=this.cache.find(Fs,void 0,1);return n&&(n.flags=t),n||new Fs(t)}flushBuffer(){!this.afterWidget||32&this.afterWidget.flags||(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class Ks{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:t,lineBreak:n,done:i}=this.cursor.next(this.skipCount);if(this.skipCount=0,i)throw new Error("Ran out of text content when drawing inline views");this.text=t;let s=this.textOff=Math.min(e,t.length);return n?null:t.slice(0,s)}let t=Math.min(this.text.length,this.textOff+e),n=this.text.slice(this.textOff,t);return this.textOff=t,n}}const Js=[Us,Ls,Ws,js,Fs,Bs,$s];for(let e=0;e<Js.length;e++)Js[e].bucket=e;class Zs{constructor(e){this.view=e,this.buckets=Js.map(()=>[]),this.index=Js.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,n=this.buckets[t];n.length<6?n.push(e):n[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,n=2){let i=e.bucket,s=this.buckets[i],r=this.index[i];for(let e=s.length-1;e>=0;e--){let o=(e+r)%s.length,a=s[o];if((!t||t(a))&&!this.reused.has(a))return s.splice(o,1),o<r&&this.index[i]--,this.reused.set(a,n),a}return null}findWidget(e,t,n){let i=this.buckets[0];if(i.length)for(let s=0,r=0;;s++){if(s==i.length){if(r)return null;r=1,s=0}let o=i[s];if(!this.reused.has(o)&&(0==r?o.widget.compare(e):o.widget.constructor==e.constructor&&e.updateDOM(o.dom,this.view,o.widget)))return i.splice(s,1),s<this.index[0]&&this.index[0]--,o.widget==e&&o.length==t&&(497&o.flags)==n?(this.reused.set(o,1),o):(this.reused.set(o,2),new Us(o.dom,t,e,-498&o.flags|n))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}}class Ys{constructor(e,t,n,i,s){this.view=e,this.decorations=i,this.disallowBlockEffectsFor=s,this.openWidget=!1,this.openMarks=0,this.cache=new Zs(e),this.text=new Ks(e.state.doc),this.builder=new qs(this.cache,new $s(e,e.contentDOM),hn.iter(n)),this.cache.reused.set(t,2),this.old=new Vs(t),this.reuseWalker={skip:(e,t,n)=>{if(this.cache.add(e),e.isComposite())return!1},enter:e=>this.cache.add(e),leave:()=>{},break:()=>{}}}run(e,t){let n=t&&this.getCompositionContext(t.text);for(let i=0,s=0,r=0;;){let o=r<e.length?e[r++]:null,a=o?o.fromA:this.old.root.length;if(a>i){let e=a-i;this.preserve(e,!r,!o),i=a,s+=e}if(!o)break;t&&o.fromA<=t.range.fromA&&o.toA>=t.range.toA?(this.forward(o.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(s,t.range.fromB),this.cache.clear(),this.builder.addComposition(t,n),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,o.toA),this.emit(t.range.toB,o.toB)):(this.forward(o.fromA,o.toA),this.emit(s,o.toB)),s=o.toB,i=o.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,n){let i=function(e){let t=[];for(let n=e.parents.length;n>1;n--){let i=n==e.parents.length?e.tile:e.parents[n].tile;i instanceof js&&t.push(i.mark)}return t}(this.old),s=this.openMarks;this.old.advance(e,n?1:-1,{skip:(e,t,n)=>{if(e.isWidget())if(this.openWidget)this.builder.continueWidget(n-t);else{let r=n>0||t<e.length?Us.of(e.widget,this.view,n-t,496&e.flags,this.cache.maybeReuse(e)):this.cache.reuse(e);256&r.flags?(r.flags&=-2,this.builder.addBlockWidget(r)):(this.builder.ensureLine(null),this.builder.addInlineWidget(r,i,s),s=i.length)}else if(e.isText())this.builder.ensureLine(null),t||n!=e.length||this.cache.reused.has(e)?(this.cache.add(e),this.builder.addText(e.text.slice(t,n),i,s)):this.builder.addText(e.text,i,s,this.cache.reuse(e)),s=i.length;else if(e.isLine())e.flags&=-2,this.cache.reused.set(e,1),this.builder.addLine(e);else if(e instanceof Fs)this.cache.add(e);else{if(!(e instanceof js))return!1;this.builder.ensureLine(null),this.builder.addMark(e,i,s),this.cache.reused.set(e,1),s=i.length}this.openWidget=!1},enter:e=>{e.isLine()?this.builder.addLineStart(e.attrs,this.cache.maybeReuse(e)):(this.cache.add(e),e instanceof js&&i.unshift(e.mark)),this.openWidget=!1},leave:e=>{e.isLine()?i.length&&(i.length=s=0):e instanceof js&&(i.shift(),s=Math.min(s,i.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let n=null,i=this.builder,s=0,r=hn.spans(this.decorations,e,t,{point:(e,t,r,o,a,l)=>{if(r instanceof oi){if(this.disallowBlockEffectsFor[l]){if(r.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.view.state.doc.lineAt(e).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(s=o.length,a>o.length)i.continueWidget(t-e);else{let s=r.widget||(r.block?er.block:er.inline),l=function(e){let t=e.isReplace?(e.startSide<0?64:0)|(e.endSide>0?128:0):e.startSide>0?32:16;e.block&&(t|=256);return t}(r),c=this.cache.findWidget(s,t-e,l)||Us.of(s,this.view,t-e,l);r.block?(r.startSide>0&&i.addLineStartIfNotCovered(n),i.addBlockWidget(c)):(i.ensureLine(n),i.addInlineWidget(c,o,a))}n=null}else n=function(e,t){let n=t.spec.attributes,i=t.spec.class;if(!n&&!i)return e;e||(e={class:"cm-line"});n&&Yn(n,e);i&&(e.class+=" "+i);return e}(n,r);t>e&&this.text.skip(t-e)},span:(e,t,s,r)=>{for(let o=e;o<t;){let a=this.text.next(Math.min(512,t-o));null==a?(i.addLineStartIfNotCovered(n),i.addBreak(),o++):(i.ensureLine(n),i.addText(a,s,o==e?r:s.length),o+=a.length),n=null}}});i.addLineStartIfNotCovered(n),this.openWidget=r>s,this.openMarks=r}forward(e,t,n=1){t-e<=10?this.old.advance(t-e,n,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,n,this.reuseWalker))}getCompositionContext(e){let t=[],n=null;for(let i=e.parentNode;;i=i.parentNode){let e=Ps.get(i);if(i==this.view.contentDOM)break;e instanceof js?t.push(e):(null==e?void 0:e.isLine())?n=e:e instanceof Bs||("DIV"!=i.nodeName||n||i==this.view.contentDOM?n||t.push(js.of(new si({tagName:i.nodeName.toLowerCase(),attributes:ei(i)}),i)):n=new Ls(i,Qs))}return{line:n,marks:t}}}function Gs(e,t){let n=e=>{for(let i of e.children)if((t?i.isText():i.length)||n(i))return!0;return!1};return n(e)}const Qs={class:"cm-line"};function Xs(e){let t=Ps.get(e);return t&&t.setDOM(e.cloneNode()),e}class er extends ti{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}er.inline=new er("span"),er.block=new er("div");const tr=new class extends ti{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class nr{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=ii.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 $s(e,e.contentDOM),this.updateInner([new Ns(0,0,0,e.state.doc.length)],null)}update(e){var t;let n=e.changedRanges;this.minWidth>0&&n.length&&(n.every(({fromA:e,toA:t})=>t<this.minWidthFrom||e>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let i=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&((null===(t=this.domChanged)||void 0===t?void 0:t.newSel)?i=this.domChanged.newSel.head:function(e,t){let n=!1;t&&e.iterChangedRanges((e,i)=>{e<t.to&&i>t.from&&(n=!0)});return n}(e.changes,this.hasComposition)||e.selectionSet||(i=e.state.selection.main.head));let s=i>-1?function(e,t,n){let i=sr(e,n);if(!i)return null;let{node:s,from:r,to:o}=i,a=s.nodeValue;if(/[\n\r]/.test(a))return null;if(e.state.doc.sliceString(i.from,i.to)!=a)return null;let l=t.invertedDesc;return{range:new Ns(l.mapPos(r),l.mapPos(o),r,o),text:s}}(this.view,e.changes,i):null;if(this.domChanged=null,this.hasComposition){let{from:t,to:i}=this.hasComposition;n=new Ns(t,i,e.changes.mapPos(t,-1),e.changes.mapPos(i,1)).addToSet(n.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(Zn.ie||Zn.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let r=this.decorations,o=this.blockWrappers;this.updateDeco();let a=function(e,t,n){let i=new rr;return hn.compare(e,t,n,i),i.changes}(r,this.decorations,e.changes);a.length&&(n=Ns.extendWithRanges(n,a));let l=function(e,t,n){let i=new or;return hn.compare(e,t,n,i),i.changes}(o,this.blockWrappers,e.changes);return l.length&&(n=Ns.extendWithRanges(n,l)),s&&!n.some(e=>e.fromA<=s.range.fromA&&e.toA>=s.range.toA)&&(n=s.range.addToSet(n.slice())),!(2&this.tile.flags&&0==n.length)&&(this.updateInner(n,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:n}=this.view;n.ignore(()=>{if(t||e.length){let n=this.tile,i=new Ys(this.view,n,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&Ps.get(t.text)&&i.cache.reused.set(Ps.get(t.text),2),this.tile=i.run(e,t),ir(n,i.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 i=Zn.chrome||Zn.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(i),!i||!i.written&&n.selectionRange.focusNode==i.node&&this.tile.dom.contains(i.node)||(this.forceSelection=!0),this.tile.dom.style.height=""});let i=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let e of this.tile.children)e.isWidget()&&e.widget instanceof ar&&i.push(e.dom);n.updateGaps(i)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let e of t.effects)e.is(ds)&&(this.editContextFormatting=e.value)}updateSelection(e=!1,t=!1){!e&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let{dom:n}=this.tile,i=this.view.root.activeElement,s=i==n,r=!s&&!(this.view.state.facet(ps)||n.tabIndex>-1)&&di(n,this.view.observer.selectionRange)&&!(i&&n.contains(i));if(!(s||t||r))return;let o=this.forceSelection;this.forceSelection=!1;let a,l,c=this.view.state.selection.main;if(c.empty?l=a=this.inlineDOMNearPos(c.anchor,c.assoc||1):(l=this.inlineDOMNearPos(c.head,c.head==c.from?1:-1),a=this.inlineDOMNearPos(c.anchor,c.anchor==c.from?1:-1)),Zn.gecko&&c.empty&&!this.hasComposition&&(1==(h=a).node.nodeType&&h.node.firstChild&&(0==h.offset||"false"==h.node.childNodes[h.offset-1].contentEditable)&&(h.offset==h.node.childNodes.length||"false"==h.node.childNodes[h.offset].contentEditable))){let e=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(e,a.node.childNodes[a.offset]||null)),a=l=new _i(e,0),o=!0}var h;let u=this.view.observer.selectionRange;!o&&u.focusNode&&(pi(a.node,a.offset,u.anchorNode,u.anchorOffset)&&pi(l.node,l.offset,u.focusNode,u.focusOffset)||this.suppressWidgetCursorChange(u,c))||(this.view.observer.ignore(()=>{Zn.android&&Zn.chrome&&n.contains(u.focusNode)&&function(e,t){for(let n=e;n&&n!=t;n=n.assignedSlot||n.parentNode)if(1==n.nodeType&&"false"==n.contentEditable)return!0;return!1}(u.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let e=hi(this.view.root);if(e)if(c.empty){if(Zn.gecko){let e=(t=a.node,s=a.offset,1!=t.nodeType?0:(s&&"false"==t.childNodes[s-1].contentEditable?1:0)|(s<t.childNodes.length&&"false"==t.childNodes[s].contentEditable?2:0));if(e&&3!=e){let t=(1==e?Ni:Di)(a.node,a.offset);t&&(a=new _i(t.node,t.offset))}}e.collapse(a.node,a.offset),null!=c.bidiLevel&&void 0!==e.caretBidiLevel&&(e.caretBidiLevel=c.bidiLevel)}else if(e.extend){e.collapse(a.node,a.offset);try{e.extend(l.node,l.offset)}catch(e){}}else{let t=document.createRange();c.anchor>c.head&&([a,l]=[l,a]),t.setEnd(l.node,l.offset),t.setStart(a.node,a.offset),e.removeAllRanges(),e.addRange(t)}else;var t,s;r&&this.view.root.activeElement==n&&(n.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(a,l)),this.impreciseAnchor=a.precise?null:new _i(u.anchorNode,u.anchorOffset),this.impreciseHead=l.precise?null:new _i(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&pi(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=hi(e.root),{anchorNode:i,anchorOffset:s}=e.observer.selectionRange;if(!(n&&t.empty&&t.assoc&&n.modify))return;let r=this.lineAt(t.head,t.assoc);if(!r)return;let o=r.posAtStart;if(t.head==o||t.head==o+r.length)return;let a=this.coordsAt(t.head,-1),l=this.coordsAt(t.head,1);if(!a||!l||a.bottom>l.top)return;let c=this.domAtPos(t.head+t.assoc,t.assoc);n.collapse(c.node,c.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let h=e.observer.selectionRange;e.docView.posFromDOM(h.anchorNode,h.anchorOffset)!=t.from&&n.collapse(i,s)}posFromDOM(e,t){let n=this.tile.nearest(e);if(!n)return 2&this.tile.dom.compareDocumentPosition(e)?0:this.view.state.doc.length;let i=n.posAtStart;if(!n.isComposite())return n.isText()?e==n.dom?i+t:i+(t?n.length:0):i;{let s;if(e==n.dom)s=n.dom.childNodes[t];else{let i=0==vi(e)?0:0==t?-1:1;for(;;){let t=e.parentNode;if(t==n.dom)break;0==i&&t.firstChild!=t.lastChild&&(i=e==t.firstChild?-1:1),e=t}s=i<0?e:e.nextSibling}if(s==n.dom.firstChild)return i;for(;s&&!Ps.get(s);)s=s.nextSibling;if(!s)return i+n.length;for(let e=0,t=i;;e++){let i=n.children[e];if(i.dom==s)return t;t+=i.length+i.breakAfter}}}domAtPos(e,t){let{tile:n,offset:i}=this.tile.resolveBlock(e,t);return n.isWidget()?n.domPosFor(e,t):n.domIn(i,t)}inlineDOMNearPos(e,t){let n,i,s=-1,r=!1,o=-1,a=!1;return this.tile.blockTiles((t,l)=>{if(t.isWidget()){if(32&t.flags&&l>=e)return!0;16&t.flags&&(r=!0)}else{let c=l+t.length;if(l<=e&&(n=t,s=e-l,r=c<e),c>=e&&!i&&(i=t,o=e-l,a=l>e),l>e&&i)return!0}}),n||i?(r&&i?n=null:a&&n&&(i=null),n&&t<0||!i?n.domIn(s,t):i.domIn(o,t)):this.domAtPos(e,t)}coordsAt(e,t){let{tile:n,offset:i}=this.tile.resolveBlock(e,t);return n.isWidget()?n.widget instanceof ar?null:n.coordsInWidget(i,t,!0):n.coordsIn(i,t)}lineAt(e,t){let{tile:n}=this.tile.resolveBlock(e,t);return n.isLine()?n:null}coordsForChar(e){let{tile:t,offset:n}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;return function e(t,n){if(t.isComposite())for(let i of t.children){if(i.length>=n){let t=e(i,n);if(t)return t}if((n-=i.length)<0)break}else if(t.isText()&&n<t.length){let e=Ye(t.text,n);if(e==n)return null;let i=Oi(t.dom,n,e).getClientRects();for(let e=0;e<i.length;e++){let t=i[e];if(e==i.length-1||t.top<t.bottom&&t.left<t.right)return t}}return null}(t,n)}measureVisibleLineHeights(e){let t=[],{from:n,to:i}=e,s=this.view.contentDOM.clientWidth,r=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,a=this.view.textDirection==Pi.LTR,l=0,c=(e,h,u)=>{for(let d=0;d<e.children.length&&!(h>i);d++){let i=e.children[d],f=h+i.length,p=i.dom.getBoundingClientRect(),{height:m}=p;if(u&&!d&&(l+=p.top-u.top),i instanceof Bs)f>n&&c(i,h,p);else if(h>=n&&(l>0&&t.push(-l),t.push(m+l),l=0,r)){let e=i.dom.lastChild,t=e?fi(e):[];if(t.length){let e=t[t.length-1],n=a?e.right-p.left:p.right-e.left;n>o&&(o=n,this.minWidth=s,this.minWidthFrom=h,this.minWidthTo=f)}}u&&d==e.children.length-1&&(l+=u.bottom-p.bottom),h=f+i.breakAfter}};return c(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return"rtl"==getComputedStyle(t.dom).direction?Pi.RTL:Pi.LTR}measureTextSize(){let e=this.tile.blockTiles(e=>{if(e.isLine()&&e.children.length&&e.length<=20){let t,n=0;for(let i of e.children){if(!i.isText()||/[^ -~]/.test(i.text))return;let e=fi(i.dom);if(1!=e.length)return;n+=e[0].width,t=e[0].height}if(n)return{lineHeight:e.dom.getBoundingClientRect().height,charWidth:n/e.length,textHeight:t}}});if(e)return e;let t,n,i,s=document.createElement("div");return s.className="cm-line",s.style.width="99999px",s.style.position="absolute",s.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(s);let e=fi(s.firstChild)[0];t=s.getBoundingClientRect().height,n=e&&e.width?e.width/27:7,i=e&&e.height?e.height:t,s.remove()}),{lineHeight:t,charWidth:n,textHeight:i}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,i=0;;i++){let s=i==t.viewports.length?null:t.viewports[i],r=s?s.from-1:this.view.state.doc.length;if(r>n){let i=(t.lineBlockAt(r).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(ii.replace({widget:new ar(i),block:!0,inclusive:!0,isBlockGap:!0}).range(n,r))}if(!s)break;n=s.to+1}return ii.set(e)}updateDeco(){let e=1,t=this.view.state.facet(ks).map(t=>(this.dynamicDecorationMap[e++]="function"==typeof t)?t(this.view):t),n=!1,i=this.view.state.facet(Ss).map((e,t)=>{let i="function"==typeof e;return i&&(n=!0),i?e(this.view):e});for(i.length&&(this.dynamicDecorationMap[e++]=n,t.push(hn.join(i))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(xs).map(e=>"function"==typeof e?e(this.view):e)}scrollIntoView(e){var t;if(e.isSnapshot){let t=this.view.viewState.lineBlockAt(e.range.head);return this.view.scrollDOM.scrollTop=t.top-e.yMargin,void(this.view.scrollDOM.scrollLeft=e.xMargin)}for(let t of this.view.state.facet(cs))try{if(t(this.view,e.range,e))return!0}catch(e){fs(this.view.state,e,"scroll handler")}let n,{range:i}=e,s=this.coordsAt(i.head,null!==(t=i.assoc)&&void 0!==t?t:i.empty?0:i.head>i.anchor?-1:1);if(!s)return;!i.empty&&(n=this.coordsAt(i.anchor,i.anchor>i.head?-1:1))&&(s={left:Math.min(s.left,n.left),top:Math.min(s.top,n.top),right:Math.max(s.right,n.right),bottom:Math.max(s.bottom,n.bottom)});let r=Ms(this.view),o={left:s.left-r.left,top:s.top-r.top,right:s.right+r.right,bottom:s.bottom+r.bottom},{offsetWidth:a,offsetHeight:l}=this.view.scrollDOM;if(function(e,t,n,i,s,r,o,a){let l=e.ownerDocument,c=l.defaultView||window;for(let h=e,u=!1;h&&!u;)if(1==h.nodeType){let e,d=h==l.body,f=1,p=1;if(d)e=wi(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(h).position)&&(u=!0),h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.assignedSlot||h.parentNode;continue}let t=h.getBoundingClientRect();({scaleX:f,scaleY:p}=ki(h,t)),e={left:t.left,right:t.left+h.clientWidth*f,top:t.top,bottom:t.top+h.clientHeight*p}}let m=0,g=0;if("nearest"==s)t.top<e.top?(g=t.top-(e.top+o),n>0&&t.bottom>e.bottom+g&&(g=t.bottom-e.bottom+o)):t.bottom>e.bottom&&(g=t.bottom-e.bottom+o,n<0&&t.top-g<e.top&&(g=t.top-(e.top+o)));else{let i=t.bottom-t.top,r=e.bottom-e.top;g=("center"==s&&i<=r?t.top+i/2-r/2:"start"==s||"center"==s&&n<0?t.top-o:t.bottom-r+o)-e.top}if("nearest"==i?t.left<e.left?(m=t.left-(e.left+r),n>0&&t.right>e.right+m&&(m=t.right-e.right+r)):t.right>e.right&&(m=t.right-e.right+r,n<0&&t.left<e.left+m&&(m=t.left-(e.left+r))):m=("center"==i?t.left+(t.right-t.left)/2-(e.right-e.left)/2:"start"==i==a?t.left-r:t.right-(e.right-e.left)+r)-e.left,m||g)if(d)c.scrollBy(m,g);else{let e=0,n=0;if(g){let e=h.scrollTop;h.scrollTop+=g/p,n=(h.scrollTop-e)*p}if(m){let t=h.scrollLeft;h.scrollLeft+=m/f,e=(h.scrollLeft-t)*f}t={left:t.left-e,top:t.top-n,right:t.right-e,bottom:t.bottom-n},e&&Math.abs(e-m)<1&&(i="nearest"),n&&Math.abs(n-g)<1&&(s="nearest")}if(d)break;(t.top<e.top||t.bottom>e.bottom||t.left<e.left||t.right>e.right)&&(t={left:Math.max(t.left,e.left),right:Math.min(t.right,e.right),top:Math.max(t.top,e.top),bottom:Math.min(t.bottom,e.bottom)}),h=h.assignedSlot||h.parentNode}else{if(11!=h.nodeType)break;h=h.host}}(this.view.scrollDOM,o,i.head<i.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,a),-a),Math.max(Math.min(e.yMargin,l),-l),this.view.textDirection==Pi.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(s.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||s.bottom<window.pageYOffset+window.visualViewport.offsetTop)){let e=this.view.docView.lineAt(i.head,1);e&&e.dom.scrollIntoView({block:"nearest"})}}lineHasWidget(e){let t=e=>e.isWidget()||e.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){ir(this.tile)}}function ir(e,t){let n=null==t?void 0:t.get(e);if(1!=n){null==n&&e.destroy();for(let n of e.children)ir(n,t)}}function sr(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let i=Ni(n.focusNode,n.focusOffset),s=Di(n.focusNode,n.focusOffset),r=i||s;if(s&&i&&s.node!=i.node){let t=Ps.get(s.node);if(!t||t.isText()&&t.text!=s.node.nodeValue)r=s;else if(e.docView.lastCompositionAfterCursor){let e=Ps.get(i.node);!e||e.isText()&&e.text!=i.node.nodeValue||(r=s)}}if(e.docView.lastCompositionAfterCursor=r!=i,!r)return null;let o=t-r.offset;return{from:o,to:o+r.node.nodeValue.length,node:r.node}}let rr=class{constructor(){this.changes=[]}compareRange(e,t){li(e,t,this.changes)}comparePoint(e,t){li(e,t,this.changes)}boundChange(e){li(e,e,this.changes)}};class or{constructor(){this.changes=[]}compareRange(e,t){li(e,t,this.changes)}comparePoint(){}boundChange(e){li(e,e,this.changes)}}class ar extends ti{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function lr(e,t,n){let i=e.lineBlockAt(t);if(Array.isArray(i.type)){let e;for(let s of i.type){if(s.from>t)break;if(!(s.to<t)){if(s.from<t&&s.to>t)return s;e&&(s.type!=ni.Text||e.type==s.type&&!(n<0?s.from<t:s.to>t))||(e=s)}}return e||i}return i}function cr(e,t,n,i){let s=e.state.doc.lineAt(t.head),r=e.bidiSpans(s),o=e.textDirectionAt(s.from);for(let a=t,l=null;;){let t=Yi(s,r,o,a,n),c=Zi;if(!t){if(s.number==(n?e.state.doc.lines:1))return a;c="\n",s=e.state.doc.line(s.number+(n?1:-1)),r=e.bidiSpans(s),t=e.visualLineSide(s,!n)}if(l){if(!l(c))return a}else{if(!i)return t;l=i(c)}a=t}}function hr(e,t,n){for(;;){let i=0;for(let s of e)s.between(t-1,t+1,(e,s,r)=>{if(t>e&&t<s){let r=i||n||(t-e<s-t?-1:1);t=r<0?e:s,i=r}});if(!i)return t}}function ur(e,t){let n=null;for(let i=0;i<t.ranges.length;i++){let s=t.ranges[i],r=null;if(s.empty){let t=hr(e,s.from,0);t!=s.from&&(r=ut.cursor(t,-1))}else{let t=hr(e,s.from,-1),n=hr(e,s.to,1);t==s.from&&n==s.to||(r=ut.range(s.from==s.anchor?t:n,s.from==s.head?t:n))}r&&(n||(n=t.ranges.slice()),n[i]=r)}return n?ut.create(n,t.mainIndex):t}function dr(e,t,n){let i=hr(e.state.facet(Cs).map(t=>t(e)),n.from,t.head>n.from?-1:1);return i==n.from?n:ut.cursor(i,i<n.from?1:-1)}class fr{constructor(e,t){this.pos=e,this.assoc=t}}function pr(e,t,n,i){let s,r=e.contentDOM.getBoundingClientRect(),o=r.top+e.viewState.paddingTop,{x:a,y:l}=t,c=l-o;for(;;){if(c<0)return new fr(0,1);if(c>e.viewState.docHeight)return new fr(e.state.doc.length,-1);if(s=e.elementAtHeight(c),null==i)break;if(s.type==ni.Text){if(i<0?s.to<e.viewport.from:s.from>e.viewport.to)break;let t=e.docView.coordsAt(i<0?s.from:s.to,i>0?-1:1);if(t&&(i<0?t.top<=c+o:t.bottom>=c+o))break}let t=e.viewState.heightOracle.textHeight/2;c=i>0?s.bottom+t:s.top-t}if(e.viewport.from>=s.to||e.viewport.to<=s.from){if(n)return null;if(s.type==ni.Text){let t=function(e,t,n,i,s){let r=Math.round((i-t.left)*e.defaultCharacterWidth);if(e.lineWrapping&&n.height>1.5*e.defaultLineHeight){let t=e.viewState.heightOracle.textHeight;r+=Math.floor((s-n.top-.5*(e.defaultLineHeight-t))/t)*e.viewState.heightOracle.lineLength}let o=e.state.sliceDoc(n.from,n.to);return n.from+Sn(o,r,e.state.tabSize)}(e,r,s,a,l);return new fr(t,t==s.from?1:-1)}}if(s.type!=ni.Text)return c<(s.top+s.bottom)/2?new fr(s.from,1):new fr(s.to,-1);let h=e.docView.lineAt(s.from,2);return h&&h.length==s.length||(h=e.docView.lineAt(s.from,-2)),new mr(e,a,l,e.textDirectionAt(s.from)).scanTile(h,s.from)}class mr{constructor(e,t,n,i){this.view=e,this.x=t,this.y=n,this.baseDir=i,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,t){let{line:n,spans:i}=this.bidiSpansAt(e);return i[Fi.find(i,e-n.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:n,spans:i}=this.bidiSpansAt(e);return i[Fi.find(i,e-n.from,-1,t)].dir}bidiIn(e,t){let{spans:n,line:i}=this.bidiSpansAt(e);return n.length>1||n.length&&(n[0].level!=this.baseDir||n[0].to+i.from<t)}scan(e,t){let n,i,s,r=0,o=e.length-1,a=new Set,l=this.bidiIn(e[0],e[o]),c=-1,h=1e9;e:for(;r<o;){let u=o-r,d=r+o>>1;t:if(a.has(d)){let e=r+Math.floor(Math.random()*u);for(let t=0;t<u;t++){if(!a.has(e)){d=e;break t}e++,e==o&&(e=r)}break e}a.add(d);let f=t(d);if(f)for(let t=0;t<f.length;t++){let a=f[t],u=0;if(!(0==a.width&&f.length>1)){if(a.bottom<this.y)(!n||n.bottom<a.bottom)&&(n=a),u=1;else if(a.top>this.y)(!i||i.top>a.top)&&(i=a),u=-1;else{let e=a.left>this.x?this.x-a.left:a.right<this.x?this.x-a.right:0,t=Math.abs(e);t<h&&(c=d,h=t,s=a),e&&(u=e<0==(this.baseDir==Pi.LTR)?-1:1)}-1!=u||l&&!this.baseDirAt(e[d],1)?1!=u||l&&!this.baseDirAt(e[d+1],-1)||(r=d+1):o=d}}}if(!s){let s=n&&(!i||this.y-n.bottom<i.top-this.y)?n:i;return this.y=(s.top+s.bottom)/2,this.scan(e,t)}let u=(l?this.dirAt(e[c],1):this.baseDir)==Pi.LTR;return{i:c,after:this.x>(s.left+s.right)/2==u}}scanText(e,t){let n=[];for(let i=0;i<e.length;i=Ye(e.text,i))n.push(t+i);n.push(t+e.length);let i=this.scan(n,i=>{let s=n[i]-t,r=n[i+1]-t;return Oi(e.dom,s,r).getClientRects()});return i.after?new fr(n[i.i+1],-1):new fr(n[i.i],1)}scanTile(e,t){if(!e.length)return new fr(t,1);if(1==e.children.length){let n=e.children[0];if(n.isText())return this.scanText(n,t);if(n.isComposite())return this.scanTile(n,t)}let n=[t];for(let i=0,s=t;i<e.children.length;i++)n.push(s+=e.children[i].length);let i=this.scan(n,t=>{let n=e.children[t];return 48&n.flags?null:(1==n.dom.nodeType?n.dom:Oi(n.dom,0,n.length)).getClientRects()}),s=e.children[i.i],r=n[i.i];return s.isText()?this.scanText(s,r):s.isComposite()?this.scanTile(s,r):i.after?new fr(n[i.i+1],-1):new fr(r,1)}}const gr="";class yr{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(nn.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=gr}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let i=e;;){this.findPointBefore(n,i);let e=this.text.length;this.readNode(i);let s=Ps.get(i),r=i.nextSibling;if(r==t){(null==s?void 0:s.breakAfter)&&!r&&n!=this.view.contentDOM&&this.lineBreak();break}let o=Ps.get(r);(s&&o?s.breakAfter:(s?s.breakAfter:gi(i))||gi(r)&&("BR"!=i.nodeName||(null==s?void 0:s.isWidget()))&&this.text.length>e)&&!br(r,t)&&this.lineBreak(),i=r}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,i=this.lineSeparator?null:/\r\n?|\n/g;;){let s,r=-1,o=1;if(this.lineSeparator?(r=t.indexOf(this.lineSeparator,n),o=this.lineSeparator.length):(s=i.exec(t))&&(r=s.index,o=s[0].length),this.append(t.slice(n,r<0?t.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=o-1);n=r+o}}readNode(e){let t=Ps.get(e),n=t&&t.overrideDOMText;if(null!=n){this.findPointInside(e,n.length);for(let e=n.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else 3==e.nodeType?this.readTextNode(e):"BR"==e.nodeName?e.nextSibling&&this.lineBreak():1==e.nodeType&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(3==e.nodeType?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(vr(e,n.node,n.offset)?t:0))}}function vr(e,t,n){for(;;){if(!t||n<vi(t))return!1;if(t==e)return!0;n=mi(t)+1,t=t.parentNode}}function br(e,t){let n;for(;e!=t&&e;e=e.nextSibling){let t=Ps.get(e);if(!(null==t?void 0:t.isWidget()))return!1;t&&(n||(n=[])).push(t)}if(n)for(let e of n){let t=e.overrideDOMText;if(null==t?void 0:t.length)return!1}return!0}class wr{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class kr{constructor(e,t,n,i){this.typeOver=i,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:s,impreciseAnchor:r}=e.docView,o=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=xr(e.docView.tile,t,n,0))){let t=s||r?[]:function(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:i,focusNode:s,focusOffset:r}=e.observer.selectionRange;n&&(t.push(new wr(n,i)),s==n&&r==i||t.push(new wr(s,r)));return t}(e),n=new yr(t,e);n.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=n.text,this.newSel=function(e,t){if(0==e.length)return null;let n=e[0].pos,i=2==e.length?e[1].pos:n;return n>-1&&i>-1?ut.single(n+t,i+t):null}(t,this.bounds.from)}else{let t=e.observer.selectionRange,n=s&&s.node==t.focusNode&&s.offset==t.focusOffset||!ui(e.contentDOM,t.focusNode)?o.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),i=r&&r.node==t.anchorNode&&r.offset==t.anchorOffset||!ui(e.contentDOM,t.anchorNode)?o.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),a=e.viewport;if((Zn.ios||Zn.chrome)&&o.main.empty&&n!=i&&(a.from>0||a.to<e.state.doc.length)){let t=Math.min(n,i),s=Math.max(n,i),r=a.from-t,o=a.to-s;0!=r&&1!=r&&0!=t||0!=o&&-1!=o&&s!=e.state.doc.length||(n=0,i=e.state.doc.length)}if(e.inputState.composing>-1&&o.ranges.length>1)this.newSel=o.replaceRange(ut.range(i,n));else if(e.lineWrapping&&i==n&&(!o.main.empty||o.main.head!=n)&&e.inputState.lastTouchTime>Date.now()-100){let t=e.coordsAtPos(n,-1),i=0;t&&(i=e.inputState.lastTouchY<=t.bottom?-1:1),this.newSel=ut.create([ut.cursor(n,i)])}else this.newSel=ut.single(i,n)}}}function xr(e,t,n,i){if(e.isComposite()){let s=-1,r=-1,o=-1,a=-1;for(let l=0,c=i,h=i;l<e.children.length;l++){let i=e.children[l],u=c+i.length;if(c<t&&u>n)return xr(i,t,n,c);if(u>=t&&-1==s&&(s=l,r=c),c>n&&i.dom.parentNode==e.dom){o=l,a=h;break}h=u,c=u+i.breakAfter}return{from:r,to:a<0?i+e.length:a,startDOM:(s?e.children[s-1].dom.nextSibling:null)||e.dom.firstChild,endDOM:o<e.children.length&&o>=0?e.children[o].dom:null}}return e.isText()?{from:i,to:i+e.length,startDOM:e.dom,endDOM:e.dom.nextSibling}:null}function Sr(e,t){let n,{newSel:i}=t,{state:s}=e,r=s.selection.main,o=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:e,to:i}=t.bounds,a=r.from,l=null;(8===o||Zn.android&&t.text.length<i-e)&&(a=r.to,l="end");let c,h,u=s.doc.sliceString(e,i,gr);!r.empty&&r.from>=e&&r.to<=i&&(t.typeOver||u!=t.text)&&u.slice(0,r.from-e)==t.text.slice(0,r.from-e)&&u.slice(r.to-e)==t.text.slice(c=t.text.length-(u.length-(r.to-e)))?n={from:r.from,to:r.to,insert:je.of(t.text.slice(r.from-e,c).split(gr))}:(h=Ar(u,t.text,a-e,l))&&(Zn.chrome&&13==o&&h.toB==h.from+2&&t.text.slice(h.from,h.toB)==gr+gr&&h.toB--,n={from:e+h.from,to:e+h.toA,insert:je.of(t.text.slice(h.from,h.toB).split(gr))})}else i&&(!e.hasFocus&&s.facet(ps)||Tr(i,r))&&(i=null);if(!n&&!i)return!1;if((Zn.mac||Zn.android)&&n&&n.from==n.to&&n.from==r.head-1&&/^\. ?$/.test(n.insert.toString())&&"off"==e.contentDOM.getAttribute("autocorrect")?(i&&2==n.insert.length&&(i=ut.single(i.main.anchor-1,i.main.head-1)),n={from:n.from,to:n.to,insert:je.of([n.insert.toString().replace("."," ")])}):s.doc.lineAt(r.from).to<r.to&&e.docView.lineHasWidget(r.to)&&e.inputState.insertingTextAt>Date.now()-50?n={from:r.from,to:r.to,insert:s.toText(e.inputState.insertingText)}:Zn.chrome&&n&&n.from==n.to&&n.from==r.head&&"\n "==n.insert.toString()&&e.lineWrapping&&(i&&(i=ut.single(i.main.anchor-1,i.main.head-1)),n={from:r.from,to:r.to,insert:je.of([" "])}),n)return Cr(e,n,i,o);if(i&&!Tr(i,r)){let t=!1,n="select";return e.inputState.lastSelectionTime>Date.now()-50&&("select"==e.inputState.lastSelectionOrigin&&(t=!0),n=e.inputState.lastSelectionOrigin,"select.pointer"==n&&(i=ur(s.facet(Cs).map(t=>t(e)),i))),e.dispatch({selection:i,scrollIntoView:t,userEvent:n}),!0}return!1}function Cr(e,t,n,i=-1){if(Zn.ios&&e.inputState.flushIOSKey(t))return!0;let s=e.state.selection.main;if(Zn.android&&(t.to==s.to&&(t.from==s.from||t.from==s.from-1&&" "==e.state.sliceDoc(t.from,s.from))&&1==t.insert.length&&2==t.insert.lines&&Mi(e.contentDOM,"Enter",13)||(t.from==s.from-1&&t.to==s.to&&0==t.insert.length||8==i&&t.insert.length<t.to-t.from&&t.to>s.head)&&Mi(e.contentDOM,"Backspace",8)||t.from==s.from&&t.to==s.to+1&&0==t.insert.length&&Mi(e.contentDOM,"Delete",46)))return!0;let r,o=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let a=()=>r||(r=function(e,t,n){let i,s=e.state,r=s.selection.main,o=-1;if(t.from==t.to&&t.from<r.from||t.from>r.to){let n=t.from<r.from?-1:1,i=n<0?r.from:r.to,a=hr(s.facet(Cs).map(t=>t(e)),i,n);t.from==a&&(o=a)}if(o>-1)i={changes:t,selection:ut.cursor(t.from+t.insert.length,-1)};else if(t.from>=r.from&&t.to<=r.to&&t.to-t.from>=(r.to-r.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let n=r.from<t.from?s.sliceDoc(r.from,t.from):"",o=r.to>t.to?s.sliceDoc(t.to,r.to):"";i=s.replaceSelection(e.state.toText(n+t.insert.sliceString(0,void 0,e.state.lineBreak)+o))}else{let o=s.changes(t),a=n&&n.main.to<=o.newLength?n.main:void 0;if(s.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=r.to+10&&t.to>=r.to-10){let l,c=e.state.sliceDoc(t.from,t.to),h=n&&sr(e,n.main.head);if(h){let e=t.insert.length-(t.to-t.from);l={from:h.from,to:h.to-e}}else l=e.state.doc.lineAt(r.head);let u=r.to-t.to;i=s.changeByRange(n=>{if(n.from==r.from&&n.to==r.to)return{changes:o,range:a||n.map(o)};let i=n.to-u,h=i-c.length;if(e.state.sliceDoc(h,i)!=c||i>=l.from&&h<=l.to)return{range:n};let d=s.changes({from:h,to:i,insert:t.insert}),f=n.to-r.to;return{changes:d,range:a?ut.range(Math.max(0,a.anchor+f),Math.max(0,a.head+f)):n.map(d)}})}else i={changes:o,selection:a&&s.selection.replaceRange(a)}}let a="input.type";(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,a+=".compose",e.inputState.compositionFirstChange&&(a+=".start",e.inputState.compositionFirstChange=!1));return s.update(i,{userEvent:a,scrollIntoView:!0})}(e,t,n));return e.state.facet(is).some(n=>n(e,t.from,t.to,o,a))||e.dispatch(a()),!0}function Ar(e,t,n,i){let s=Math.min(e.length,t.length),r=0;for(;r<s&&e.charCodeAt(r)==t.charCodeAt(r);)r++;if(r==s&&e.length==t.length)return null;let o=e.length,a=t.length;for(;o>0&&a>0&&e.charCodeAt(o-1)==t.charCodeAt(a-1);)o--,a--;if("end"==i){n-=o+Math.max(0,r-Math.min(o,a))-r}if(o<r&&e.length<t.length){r-=n<=r&&n>=o?r-n:0,a=r+(a-o),o=r}else if(a<r){r-=n<=r&&n>=a?r-n:0,o=r+(o-a),a=r}return{from:r,toA:o,toB:a}}function Tr(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}class Or{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Zn.safari&&e.contentDOM.addEventListener("input",()=>null),Zn.gecko&&function(e){Gr.has(e)||(Gr.add(e),e.addEventListener("copy",()=>{}),e.addEventListener("cut",()=>{}))}(e.contentDOM.ownerDocument)}handleEvent(e){(function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n,i=t.target;i!=e.contentDOM;i=i.parentNode)if(!i||11==i.nodeType||(n=Ps.get(i))&&n.isWidget()&&!n.isHidden&&n.widget.ignoreEvent(t))return!1;return!0})(this.view,e)&&!this.ignoreDuringComposition(e)&&("keydown"==e.type&&this.keydown(e)||(0!=this.view.updateState?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e)))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let e of n.observers)e(this.view,t);for(let e of n.handlers){if(t.defaultPrevented)break;if(e(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=Er(e),n=this.handlers,i=this.view.contentDOM;for(let e in t)if("scroll"!=e){let s=!t[e].handlers.length,r=n[e];r&&s!=!r.handlers.length&&(i.removeEventListener(e,this.handleEvent),r=null),r||i.addEventListener(e,this.handleEvent,{passive:s})}for(let e in n)"scroll"==e||t[e]||i.removeEventListener(e,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),9==e.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&27!=e.keyCode&&_r.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Zn.android&&Zn.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return!Zn.ios||e.synthetic||e.altKey||e.metaKey||e.shiftKey||!((t=Nr.find(t=>t.keyCode==e.keyCode))&&!e.ctrlKey||Dr.indexOf(e.key)>-1&&e.ctrlKey)?(229!=e.keyCode&&this.view.observer.forceFlush(),!1):(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0)}flushIOSKey(e){let t=this.pendingIOSKey;return!!t&&(!("Enter"==t.key&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString()))&&(this.pendingIOSKey=void 0,Mi(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0)))}ignoreDuringComposition(e){return!(!/^key/.test(e.type)||e.synthetic)&&(this.composing>0||!!(Zn.safari&&!Zn.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function Mr(e,t){return(n,i)=>{try{return t.call(e,i,n)}catch(e){fs(n.state,e)}}}function Er(e){let t=Object.create(null);function n(e){return t[e]||(t[e]={observers:[],handlers:[]})}for(let t of e){let e=t.spec,i=e&&e.plugin.domEventHandlers,s=e&&e.plugin.domEventObservers;if(i)for(let e in i){let s=i[e];s&&n(e).handlers.push(Mr(t.value,s))}if(s)for(let e in s){let i=s[e];i&&n(e).observers.push(Mr(t.value,i))}}for(let e in Rr)n(e).handlers.push(Rr[e]);for(let e in $r)n(e).observers.push($r[e]);return t}const Nr=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Dr="dthko",_r=[16,17,18,20,91,92,224,225];function Pr(e){return.7*Math.max(0,e)+8}class Ir{constructor(e,t,n,i){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=i,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=xi(e.contentDOM),this.atoms=e.state.facet(Cs).map(t=>t(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(nn.allowMultipleSelections)&&function(e,t){let n=e.state.facet(Qi);return n.length?n[0](t):Zn.mac?t.metaKey:t.ctrlKey}(e,t),this.dragging=!(!function(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let i=hi(e.root);if(!i||0==i.rangeCount)return!0;let s=i.getRangeAt(0).getClientRects();for(let e=0;e<s.length;e++){let n=s[e];if(n.left<=t.clientX&&n.right>=t.clientX&&n.top<=t.clientY&&n.bottom>=t.clientY)return!0}return!1}(e,t)||1!=Hr(t))&&null}start(e){!1===this.dragging&&this.select(e)}move(e){if(0==e.buttons)return this.destroy();if(this.dragging||null==this.dragging&&function(e,t){return Math.max(Math.abs(e.clientX-t.clientX),Math.abs(e.clientY-t.clientY))}(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,n=0,i=0,s=0,r=this.view.win.innerWidth,o=this.view.win.innerHeight;this.scrollParents.x&&({left:i,right:r}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:o}=this.scrollParents.y.getBoundingClientRect());let a=Ms(this.view);e.clientX-a.left<=i+6?t=-Pr(i-e.clientX):e.clientX+a.right>=r-6&&(t=Pr(e.clientX-r)),e.clientY-a.top<=s+6?n=-Pr(s-e.clientY):e.clientY+a.bottom>=o-6&&(n=Pr(e.clientY-o)),this.setScrollSpeed(t,n)}up(e){null==this.dragging&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),!1===this.dragging&&this.select(this.lastEvent)}select(e){let{view:t}=this,n=ur(this.atoms,this.style.get(e,this.extend,this.multiple));!this.mustSelect&&n.eq(t.state.selection,!1===this.dragging)||this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(e=>e.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}const Rr=Object.create(null),$r=Object.create(null),Br=Zn.ie&&Zn.ie_version<15||Zn.ios&&Zn.webkit_version<604;function Lr(e,t,n){for(let i of e.facet(t))n=i(n,e);return n}function zr(e,t){t=Lr(e.state,rs,t);let n,{state:i}=e,s=1,r=i.toText(t),o=r.lines==i.selection.ranges.length,a=null!=Kr&&i.selection.ranges.every(e=>e.empty)&&Kr==r.toString();if(a){let e=-1;n=i.changeByRange(n=>{let a=i.doc.lineAt(n.from);if(a.from==e)return{range:n};e=a.from;let l=i.toText((o?r.line(s++).text:t)+i.lineBreak);return{changes:{from:a.from,insert:l},range:ut.cursor(n.from+l.length)}})}else n=o?i.changeByRange(e=>{let t=r.line(s++);return{changes:{from:e.from,to:e.to,insert:t.text},range:ut.cursor(e.from+t.length)}}):i.replaceSelection(r);e.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}function jr(e,t,n,i){if(1==i)return ut.cursor(t,n);if(2==i)return function(e,t,n=1){let i=e.charCategorizer(t),s=e.doc.lineAt(t),r=t-s.from;if(0==s.length)return ut.cursor(t);0==r?n=1:r==s.length&&(n=-1);let o=r,a=r;n<0?o=Ye(s.text,r,!1):a=Ye(s.text,r);let l=i(s.text.slice(o,a));for(;o>0;){let e=Ye(s.text,o,!1);if(i(s.text.slice(e,o))!=l)break;o=e}for(;a<s.length;){let e=Ye(s.text,a);if(i(s.text.slice(a,e))!=l)break;a=e}return ut.range(o+s.from,a+s.from)}(e.state,t,n);{let i=e.docView.lineAt(t,n),s=e.state.doc.lineAt(i?i.posAtEnd:t),r=i?i.posAtStart:s.from,o=i?i.posAtEnd:s.to;return o<e.state.doc.length&&o==s.to&&o++,ut.range(r,o)}}$r.scroll=e=>{e.inputState.lastScrollTop=e.scrollDOM.scrollTop,e.inputState.lastScrollLeft=e.scrollDOM.scrollLeft},$r.wheel=$r.mousewheel=e=>{e.inputState.lastWheelEvent=Date.now()},Rr.keydown=(e,t)=>(e.inputState.setSelectionOrigin("select"),27==t.keyCode&&0!=e.inputState.tabFocusMode&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),$r.touchstart=(e,t)=>{let n=e.inputState,i=t.targetTouches[0];n.lastTouchTime=Date.now(),i&&(n.lastTouchX=i.clientX,n.lastTouchY=i.clientY),n.setSelectionOrigin("select.pointer")},$r.touchmove=e=>{e.inputState.setSelectionOrigin("select.pointer")},Rr.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let i of e.state.facet(es))if(n=i(e,t),n)break;if(n||0!=t.button||(n=function(e,t){let n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),i=Hr(t),s=e.state.selection;return{update(e){e.docChanged&&(n.pos=e.changes.mapPos(n.pos),s=s.map(e.changes))},get(t,r,o){let a,l=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),c=jr(e,l.pos,l.assoc,i);if(n.pos!=l.pos&&!r){let t=jr(e,n.pos,n.assoc,i),s=Math.min(t.from,c.from),r=Math.max(t.to,c.to);c=s<c.from?ut.range(s,r,c.assoc):ut.range(r,s,c.assoc)}return r?s.replaceRange(s.main.extend(c.from,c.to,c.assoc)):o&&1==i&&s.ranges.length>1&&(a=function(e,t){for(let n=0;n<e.ranges.length;n++){let{from:i,to:s}=e.ranges[n];if(i<=t&&s>=t)return ut.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-(e.mainIndex>n?1:0))}return null}(s,l.pos))?a:o?s.addRange(c):ut.create([c])}}}(e,t)),n){let i=!e.hasFocus;e.inputState.startMouseSelection(new Ir(e,t,n,i)),i&&e.observer.ignore(()=>{Ti(e.contentDOM);let t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()});let s=e.inputState.mouseSelection;if(s)return s.start(t),!1===s.dragging}else e.inputState.setSelectionOrigin("select.pointer");return!1};const Wr=Zn.ie&&Zn.ie_version<=11;let Ur=null,Fr=0,Vr=0;function Hr(e){if(!Wr)return e.detail;let t=Ur,n=Vr;return Ur=e,Vr=Date.now(),Fr=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(Fr+1)%3:1}function qr(e,t,n,i){if(!(n=Lr(e.state,rs,n)))return;let s=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:r}=e.inputState,o=i&&r&&function(e,t){let n=e.state.facet(Xi);return n.length?n[0](t):Zn.mac?!t.altKey:!t.ctrlKey}(e,t)?{from:r.from,to:r.to}:null,a={from:s,insert:n},l=e.state.changes(o?[o,a]:a);e.focus(),e.dispatch({changes:l,selection:{anchor:l.mapPos(s,-1),head:l.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"}),e.inputState.draggedContent=null}Rr.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let i=e.docView.tile.nearest(t.target);if(i&&i.isWidget()){let e=i.posAtStart,t=e+i.length;(e>=n.to||t<=n.from)&&(n=ut.range(e,t))}}let{inputState:i}=e;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData("Text",Lr(e.state,os,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed="copyMove"),!1},Rr.dragend=e=>(e.inputState.draggedContent=null,!1),Rr.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let i=Array(n.length),s=0,r=()=>{++s==n.length&&qr(e,t,i.filter(e=>null!=e).join(e.state.lineBreak),!1)};for(let e=0;e<n.length;e++){let t=new FileReader;t.onerror=r,t.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(i[e]=t.result),r()},t.readAsText(n[e])}return!0}{let n=t.dataTransfer.getData("Text");if(n)return qr(e,t,n,!0),!0}return!1},Rr.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=Br?null:t.clipboardData;return n?(zr(e,n.getData("text/plain")||n.getData("text/uri-list")),!0):(function(e){let t=e.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{e.focus(),n.remove(),zr(e,n.value)},50)}(e),!1)};let Kr=null;Rr.copy=Rr.cut=(e,t)=>{if(!di(e.contentDOM,e.observer.selectionRange))return!1;let{text:n,ranges:i,linewise:s}=function(e){let t=[],n=[],i=!1;for(let i of e.selection.ranges)i.empty||(t.push(e.sliceDoc(i.from,i.to)),n.push(i));if(!t.length){let s=-1;for(let{from:i}of e.selection.ranges){let r=e.doc.lineAt(i);r.number>s&&(t.push(r.text),n.push({from:r.from,to:Math.min(e.doc.length,r.to+1)})),s=r.number}i=!0}return{text:Lr(e,os,t.join(e.lineBreak)),ranges:n,linewise:i}}(e.state);if(!n&&!s)return!1;Kr=s?n:null,"cut"!=t.type||e.state.readOnly||e.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let r=Br?null:t.clipboardData;return r?(r.clearData(),r.setData("text/plain",n),!0):(function(e,t){let n=e.dom.parentNode;if(!n)return;let i=n.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=t,i.focus(),i.selectionEnd=t.length,i.selectionStart=0,setTimeout(()=>{i.remove(),e.focus()},50)}(e,n),!1)};const Jr=Wt.define();function Zr(e,t){let n=[];for(let i of e.facet(ss)){let s=i(e,t);s&&n.push(s)}return n.length?e.update({effects:n,annotations:Jr.of(!0)}):null}function Yr(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=Zr(e.state,t);n?e.dispatch(n):e.update([])}},10)}$r.focus=e=>{e.inputState.lastFocusTime=Date.now(),e.scrollDOM.scrollTop||!e.inputState.lastScrollTop&&!e.inputState.lastScrollLeft||(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),Yr(e)},$r.blur=e=>{e.observer.clearSelectionRange(),Yr(e)},$r.compositionstart=$r.compositionupdate=e=>{e.observer.editContext||(null==e.inputState.compositionFirstChange&&(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))},$r.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,Zn.chrome&&Zn.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))},$r.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},Rr.beforeinput=(e,t)=>{var n,i;if("insertText"!=t.inputType&&"insertCompositionText"!=t.inputType||(e.inputState.insertingText=t.data,e.inputState.insertingTextAt=Date.now()),"insertReplacementText"==t.inputType&&e.observer.editContext){let i=null===(n=t.dataTransfer)||void 0===n?void 0:n.getData("text/plain"),s=t.getTargetRanges();if(i&&s.length){let t=s[0],n=e.posAtDOM(t.startContainer,t.startOffset),r=e.posAtDOM(t.endContainer,t.endOffset);return Cr(e,{from:n,to:r,insert:e.state.toText(i)},null),!0}}let s;if(Zn.chrome&&Zn.android&&(s=Nr.find(e=>e.inputType==t.inputType))&&(e.observer.delayAndroidKey(s.key,s.keyCode),"Backspace"==s.key||"Delete"==s.key)){let t=(null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0;setTimeout(()=>{var n;((null===(n=window.visualViewport)||void 0===n?void 0:n.height)||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return Zn.ios&&"deleteContentForward"==t.inputType&&e.observer.flushSoon(),Zn.safari&&"insertText"==t.inputType&&e.inputState.composing>=0&&setTimeout(()=>$r.compositionend(e,t),20),!1};const Gr=new Set;const Qr=["pre-wrap","normal","pre-line","break-spaces"];let Xr=!1;function eo(){Xr=!1}class to{constructor(e){this.lineWrapping=e,this.doc=je.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Qr.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let i=e[n];i<0?n++:this.heightSamples[Math.floor(10*i)]||(t=!0,this.heightSamples[Math.floor(10*i)]=!0)}return t}refresh(e,t,n,i,s,r){let o=Qr.indexOf(e)>-1,a=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=o||Math.abs(n-this.charWidth)>.1;if(this.lineWrapping=o,this.lineHeight=t,this.charWidth=n,this.textHeight=i,this.lineLength=s,a){this.heightSamples={};for(let e=0;e<r.length;e++){let t=r[e];t<0?e++:this.heightSamples[Math.floor(10*t)]=!0}}return a}}class no{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class io{constructor(e,t,n,i,s){this.from=e,this.length=t,this.top=n,this.height=i,this._content=s}get type(){return"number"==typeof this._content?ni.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 oi?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new io(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var so=function(e){return e[e.ByPos=0]="ByPos",e[e.ByHeight=1]="ByHeight",e[e.ByPosNoHeight=2]="ByPosNoHeight",e}(so||(so={}));const ro=.001;class oo{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(2&this.flags)>0}set outdated(e){this.flags=(e?2:0)|-3&this.flags}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>ro&&(Xr=!0),this.height=e)}replace(e,t,n){return oo.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,i){let s=this,r=n.doc;for(let o=i.length-1;o>=0;o--){let{fromA:a,toA:l,fromB:c,toB:h}=i[o],u=s.lineAt(a,so.ByPosNoHeight,n.setDoc(t),0,0),d=u.to>=l?u:s.lineAt(l,so.ByPosNoHeight,n,0,0);for(h+=d.to-l,l=d.to;o>0&&u.from<=i[o-1].toA;)a=i[o-1].fromA,c=i[o-1].fromB,o--,a<u.from&&(u=s.lineAt(a,so.ByPosNoHeight,n,0,0));c+=u.from-a,a=u.from;let f=mo.build(n.setDoc(r),e,c,h);s=ao(s,s.replace(a,l,f))}return s.updateHeight(n,0)}static empty(){return new ho(0,0,0)}static of(e){if(1==e.length)return e[0];let t=0,n=e.length,i=0,s=0;for(;;)if(t==n)if(i>2*s){let s=e[t-1];s.break?e.splice(--t,1,s.left,null,s.right):e.splice(--t,1,s.left,s.right),n+=1+s.break,i-=s.size}else{if(!(s>2*i))break;{let t=e[n];t.break?e.splice(n,1,t.left,null,t.right):e.splice(n,1,t.left,t.right),n+=2+t.break,s-=t.size}}else if(i<s){let n=e[t++];n&&(i+=n.size)}else{let t=e[--n];t&&(s+=t.size)}let r=0;return null==e[t-1]?(r=1,t--):null==e[t]&&(r=1,n++),new fo(oo.of(e.slice(0,t)),r,oo.of(e.slice(n)))}}function ao(e,t){return e==t?e:(e.constructor!=t.constructor&&(Xr=!0),t)}oo.prototype.size=1;const lo=ii.replace({});class co extends oo{constructor(e,t,n){super(e,t),this.deco=n,this.spaceAbove=0}mainBlock(e,t){return new io(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,n,i){return this.spaceAbove&&e<n+this.spaceAbove?new io(i,0,n,this.spaceAbove,lo):this.mainBlock(n,i)}lineAt(e,t,n,i,s){let r=this.mainBlock(i,s);return this.spaceAbove?this.blockAt(0,n,i,s).join(r):r}forEachLine(e,t,n,i,s,r){e<=s+this.length&&t>=s&&r(this.lineAt(0,so.ByPos,n,i,s))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,n=!1,i){return i&&i.from<=t&&i.more&&this.setMeasuredHeight(i),this.outdated=!1,this}toString(){return`block(${this.length})`}}class ho extends co{constructor(e,t,n){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=n}mainBlock(e,t){return new io(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,n){let i=n[0];return 1==n.length&&(i instanceof ho||i instanceof uo&&4&i.flags)&&Math.abs(this.length-i.length)<10?(i instanceof uo?i=new ho(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):oo.of(n)}updateHeight(e,t=0,n=!1,i){return i&&i.from<=t&&i.more?this.setMeasuredHeight(i):(n||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class uo extends oo{constructor(e){super(e,0)}heightMetrics(e,t){let n,i=e.doc.lineAt(t).number,s=e.doc.lineAt(t+this.length).number,r=s-i+1,o=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*r);n=t/r,this.length>r+1&&(o=(this.height-t)/(this.length-r-1))}else n=this.height/r;return{firstLine:i,lastLine:s,perLine:n,perChar:o}}blockAt(e,t,n,i){let{firstLine:s,lastLine:r,perLine:o,perChar:a}=this.heightMetrics(t,i);if(t.lineWrapping){let s=i+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),r=t.doc.lineAt(s),l=o+r.length*a,c=Math.max(n,e-l/2);return new io(r.from,r.length,c,l,0)}{let i=Math.max(0,Math.min(r-s,Math.floor((e-n)/o))),{from:a,length:l}=t.doc.line(s+i);return new io(a,l,n+o*i,o,0)}}lineAt(e,t,n,i,s){if(t==so.ByHeight)return this.blockAt(e,n,i,s);if(t==so.ByPosNoHeight){let{from:t,to:i}=n.doc.lineAt(e);return new io(t,i-t,0,0,0)}let{firstLine:r,perLine:o,perChar:a}=this.heightMetrics(n,s),l=n.doc.lineAt(e),c=o+l.length*a,h=l.number-r,u=i+o*h+a*(l.from-s-h);return new io(l.from,l.length,Math.max(i,Math.min(u,i+this.height-c)),c,0)}forEachLine(e,t,n,i,s,r){e=Math.max(e,s),t=Math.min(t,s+this.length);let{firstLine:o,perLine:a,perChar:l}=this.heightMetrics(n,s);for(let c=e,h=i;c<=t;){let t=n.doc.lineAt(c);if(c==e){let n=t.number-o;h+=a*n+l*(e-s-n)}let i=a+l*t.length;r(new io(t.from,t.length,h,i,0)),h+=i,c=t.to+1}}replace(e,t,n){let i=this.length-t;if(i>0){let e=n[n.length-1];e instanceof uo?n[n.length-1]=new uo(e.length+i):n.push(null,new uo(i-1))}if(e>0){let t=n[0];t instanceof uo?n[0]=new uo(e+t.length):n.unshift(new uo(e-1),null)}return oo.of(n)}decomposeLeft(e,t){t.push(new uo(e-1),null)}decomposeRight(e,t){t.push(null,new uo(this.length-e-1))}updateHeight(e,t=0,n=!1,i){let s=t+this.length;if(i&&i.from<=t+this.length&&i.more){let n=[],r=Math.max(t,i.from),o=-1;for(i.from>t&&n.push(new uo(i.from-t-1).updateHeight(e,t));r<=s&&i.more;){let t=e.doc.lineAt(r).length;n.length&&n.push(null);let s=i.heights[i.index++],a=0;s<0&&(a=-s,s=i.heights[i.index++]),-1==o?o=s:Math.abs(s-o)>=ro&&(o=-2);let l=new ho(t,s,a);l.outdated=!1,n.push(l),r+=t+1}r<=s&&n.push(null,new uo(s-r).updateHeight(e,r));let a=oo.of(n);return(o<0||Math.abs(a.height-this.height)>=ro||Math.abs(o-this.heightMetrics(e,t).perLine)>=ro)&&(Xr=!0),ao(this,a)}return(n||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class fo extends oo{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return 1&this.flags}blockAt(e,t,n,i){let s=n+this.left.height;return e<s?this.left.blockAt(e,t,n,i):this.right.blockAt(e,t,s,i+this.left.length+this.break)}lineAt(e,t,n,i,s){let r=i+this.left.height,o=s+this.left.length+this.break,a=t==so.ByHeight?e<r:e<o,l=a?this.left.lineAt(e,t,n,i,s):this.right.lineAt(e,t,n,r,o);if(this.break||(a?l.to<o:l.from>o))return l;let c=t==so.ByPosNoHeight?so.ByPosNoHeight:so.ByPos;return a?l.join(this.right.lineAt(o,c,n,r,o)):this.left.lineAt(o,c,n,i,s).join(l)}forEachLine(e,t,n,i,s,r){let o=i+this.left.height,a=s+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,n,i,s,r),t>=a&&this.right.forEachLine(e,t,n,o,a,r);else{let l=this.lineAt(a,so.ByPos,n,i,s);e<l.from&&this.left.forEachLine(e,l.from-1,n,i,s,r),l.to>=e&&l.from<=t&&r(l),t>l.to&&this.right.forEachLine(l.to+1,t,n,o,a,r)}}replace(e,t,n){let i=this.left.length+this.break;if(t<i)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-i,t-i,n));let s=[];e>0&&this.decomposeLeft(e,s);let r=s.length;for(let e of n)s.push(e);if(e>0&&po(s,r-1),t<this.length){let e=s.length;this.decomposeRight(t,s),po(s,e)}return oo.of(s)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,i=n+this.break;if(e>=i)return this.right.decomposeRight(e-i,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<i&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?oo.of(this.break?[e,null,t]:[e,t]):(this.left=ao(this.left,e),this.right=ao(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,i){let{left:s,right:r}=this,o=t+s.length+this.break,a=null;return i&&i.from<=t+s.length&&i.more?a=s=s.updateHeight(e,t,n,i):s.updateHeight(e,t,n),i&&i.from<=o+r.length&&i.more?a=r=r.updateHeight(e,o,n,i):r.updateHeight(e,o,n),a?this.balanced(s,r):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function po(e,t){let n,i;null==e[t]&&(n=e[t-1])instanceof uo&&(i=e[t+1])instanceof uo&&e.splice(t-1,3,new uo(n.length+1+i.length))}class mo{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let e=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof ho?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new ho(e-this.pos,-1,0)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let i=n.widget?n.widget.estimatedHeight:0,s=n.widget?n.widget.lineBreaks:0;i<0&&(i=this.oracle.lineHeight);let r=t-e;n.block?this.addBlock(new co(r,i,n)):(r||s||i>=5)&&this.addLineDeco(i,s,r)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new ho(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let n=new uo(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof ho)return e;let t=new ho(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let i=this.ensureLine();i.length+=n,i.collapsed+=n,i.widgetHeight=Math.max(i.widgetHeight,e),i.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||t instanceof ho||this.isCovered?(this.writtenTo<this.pos||null==t)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new ho(0,-1,0));let n=e;for(let e of this.nodes)e instanceof ho&&e.updateHeight(this.oracle,n),n+=e?e.length:1;return this.nodes}static build(e,t,n,i){let s=new mo(n,e);return hn.spans(t,n,i,s,0),s.finish(n)}}class go{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,i){(e<t||n&&n.heightRelevant||i&&i.heightRelevant)&&li(e,t,this.changes,5)}}function yo(e,t){let n=e.getBoundingClientRect(),i=e.ownerDocument,s=i.defaultView||window,r=Math.max(0,n.left),o=Math.min(s.innerWidth,n.right),a=Math.max(0,n.top),l=Math.min(s.innerHeight,n.bottom);for(let t=e.parentNode;t&&t!=i.body;)if(1==t.nodeType){let n=t,i=window.getComputedStyle(n);if((n.scrollHeight>n.clientHeight||n.scrollWidth>n.clientWidth)&&"visible"!=i.overflow){let i=n.getBoundingClientRect();r=Math.max(r,i.left),o=Math.min(o,i.right),a=Math.max(a,i.top),l=Math.min(t==e.parentNode?s.innerHeight:l,i.bottom)}t="absolute"==i.position||"fixed"==i.position?n.offsetParent:n.parentNode}else{if(11!=t.nodeType)break;t=t.host}return{left:r-n.left,right:Math.max(r,o)-n.left,top:a-(n.top+t),bottom:Math.max(a,l)-(n.top+t)}}function vo(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}class bo{constructor(e,t,n,i){this.from=e,this.to=t,this.size=n,this.displaySize=i}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let i=e[n],s=t[n];if(i.from!=s.from||i.to!=s.to||i.size!=s.size)return!1}return!0}draw(e,t){return ii.replace({widget:new wo(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class wo extends ti{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class ko{constructor(e,t){this.view=e,this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=Ao,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Pi.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let n=t.facet(ws).some(e=>"function"!=typeof e&&"cm-lineWrapping"==e.class);this.heightOracle=new to(n),this.stateDeco=To(t),this.heightMap=oo.empty().applyChanges(this.stateDeco,je.empty,this.heightOracle.setDoc(t.doc),[new Ns(0,0,0,t.doc.length)]);for(let e=0;e<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());e++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ii.set(this.lineGaps.map(e=>e.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let i=n?t.head:t.anchor;if(!e.some(({from:e,to:t})=>i>=e&&i<=t)){let{from:t,to:n}=this.lineBlockAt(i);e.push(new xo(t,n))}}return this.viewports=e.sort((e,t)=>e.from-t.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Ao:new Oo(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Mo(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=To(this.state);let i=e.changedRanges,s=Ns.extendWithRanges(i,function(e,t,n){let i=new go;return hn.compare(e,t,n,i,0),i.changes}(n,this.stateDeco,e?e.changes:it.empty(this.state.doc.length))),r=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);eo(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=r||Xr)&&(e.flags|=2),o?(this.scrollAnchorPos=e.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=r);let a=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let l=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(l||!e.changes.empty||2&e.flags)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(ls)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,n=window.getComputedStyle(t),i=this.heightOracle,s=n.whiteSpace;this.defaultTextDirection="rtl"==n.direction?Pi.RTL:Pi.LTR;let r=this.heightOracle.mustRefreshForWrapping(s)||"refresh"===this.mustMeasureContent,o=t.getBoundingClientRect(),a=r||this.mustMeasureContent||this.contentDOMHeight!=o.height;this.contentDOMHeight=o.height,this.mustMeasureContent=!1;let l=0,c=0;if(o.width&&o.height){let{scaleX:e,scaleY:n}=ki(t,o);(e>.005&&Math.abs(this.scaleX-e)>.005||n>.005&&Math.abs(this.scaleY-n)>.005)&&(this.scaleX=e,this.scaleY=n,l|=16,r=a=!0)}let h=(parseInt(n.paddingTop)||0)*this.scaleY,u=(parseInt(n.paddingBottom)||0)*this.scaleY;this.paddingTop==h&&this.paddingBottom==u||(this.paddingTop=h,this.paddingBottom=u,l|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(i.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,l|=16);let d=xi(this.view.contentDOM,!1).y;d!=this.scrollParent&&(this.scrollParent=d,this.scrollAnchorHeight=-1,this.scrollOffset=0);let f=this.getScrollOffset();this.scrollOffset!=f&&(this.scrollAnchorHeight=-1,this.scrollOffset=f),this.scrolledToBottom=Ei(this.scrollParent||e.win);let p=(this.printing?vo:yo)(t,this.paddingTop),m=p.top-this.pixelViewport.top,g=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let y=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(y!=this.inView&&(this.inView=y,y&&(a=!0)),!this.inView&&!this.scrollTarget&&!function(e){let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView||window;return t.left<n.innerWidth&&t.right>0&&t.top<n.innerHeight&&t.bottom>0}(e.dom))return 0;let v=o.width;if(this.contentDOMWidth==v&&this.editorHeight==e.scrollDOM.clientHeight||(this.contentDOMWidth=o.width,this.editorHeight=e.scrollDOM.clientHeight,l|=16),a){let t=e.docView.measureVisibleLineHeights(this.viewport);if(i.mustRefreshForHeights(t)&&(r=!0),r||i.lineWrapping&&Math.abs(v-this.contentDOMWidth)>i.charWidth){let{lineHeight:n,charWidth:o,textHeight:a}=e.docView.measureTextSize();r=n>0&&i.refresh(s,n,o,a,Math.max(5,v/o),t),r&&(e.docView.minWidth=0,l|=16)}m>0&&g>0?c=Math.max(m,g):m<0&&g<0&&(c=Math.min(m,g)),eo();for(let n of this.viewports){let s=n.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(n);this.heightMap=(r?oo.empty().applyChanges(this.stateDeco,je.empty,this.heightOracle,[new Ns(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(i,0,r,new no(n.from,s))}Xr&&(l|=2)}let b=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return b&&(2&l&&(l|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),l|=this.updateForViewport()),(2&l||b)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(r?[]:this.lineGaps,e)),l|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),l}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),i=this.heightMap,s=this.heightOracle,{visibleTop:r,visibleBottom:o}=this,a=new xo(i.lineAt(r-1e3*n,so.ByHeight,s,0,0).from,i.lineAt(o+1e3*(1-n),so.ByHeight,s,0,0).to);if(t){let{head:e}=t.range;if(e<a.from||e>a.to){let n,r=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),o=i.lineAt(e,so.ByPos,s,0,0);n="center"==t.y?(o.top+o.bottom)/2-r/2:"start"==t.y||"nearest"==t.y&&e<a.from?o.top:o.bottom-r,a=new xo(i.lineAt(n-500,so.ByHeight,s,0,0).from,i.lineAt(n+r+500,so.ByHeight,s,0,0).to)}}return a}mapViewport(e,t){let n=t.mapPos(e.from,-1),i=t.mapPos(e.to,1);return new xo(this.heightMap.lineAt(n,so.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(i,so.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:i}=this.heightMap.lineAt(e,so.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(t,so.ByPos,this.heightOracle,0,0),{visibleTop:r,visibleBottom:o}=this;return(0==e||i<=r-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||s>=o+Math.max(10,Math.min(n,250)))&&i>r-2e3&&s<o+2e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let i of e)t.touchesRange(i.from,i.to)||n.push(new bo(t.mapPos(i.from),t.mapPos(i.to),i.size,i.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,i=n?1e4:2e3,s=i>>1,r=i<<1;if(this.defaultTextDirection!=Pi.LTR&&!n)return[];let o=[],a=(i,r,l,c)=>{if(r-i<s)return;let h=this.state.selection.main,u=[h.from];h.empty||u.push(h.to);for(let e of u)if(e>i&&e<r)return a(i,e-10,l,c),void a(e+10,r,l,c);let d=function(e,t){for(let n of e)if(t(n))return n;return}(e,e=>e.from>=l.from&&e.to<=l.to&&Math.abs(e.from-i)<s&&Math.abs(e.to-r)<s&&!u.some(t=>e.from<t&&e.to>t));if(!d){if(r<l.to&&t&&n&&t.visibleRanges.some(e=>e.from<=r&&e.to>=r)){let e=t.moveToLineBoundary(ut.cursor(r),!1,!0).head;e>i&&(r=e)}let e=this.gapSize(l,i,r,c);d=new bo(i,r,e,n||e<2e6?e:2e6)}o.push(d)},l=t=>{if(t.length<r||t.type!=ni.Text)return;let s=function(e,t,n){let i=[],s=e,r=0;hn.spans(n,e,t,{span(){},point(e,t){e>s&&(i.push({from:s,to:e}),r+=e-s),s=t}},20),s<t&&(i.push({from:s,to:t}),r+=t-s);return{total:r,ranges:i}}(t.from,t.to,this.stateDeco);if(s.total<r)return;let o,l,c=this.scrollTarget?this.scrollTarget.range.head:null;if(n){let e,n,r=i/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=c){let i=Co(s,c),o=((this.visibleBottom-this.visibleTop)/2+r)/t.height;e=i-o,n=i+o}else e=(this.visibleTop-t.top-r)/t.height,n=(this.visibleBottom-t.top+r)/t.height;o=So(s,e),l=So(s,n)}else{let n=s.total*this.heightOracle.charWidth,r=i*this.heightOracle.charWidth,a=0;if(n>2e6)for(let n of e)n.from>=t.from&&n.from<t.to&&n.size!=n.displaySize&&n.from*this.heightOracle.charWidth+a<this.pixelViewport.left&&(a=n.size-n.displaySize);let h,u,d=this.pixelViewport.left+a,f=this.pixelViewport.right+a;if(null!=c){let e=Co(s,c),t=((f-d)/2+r)/n;h=e-t,u=e+t}else h=(d-r)/n,u=(f+r)/n;o=So(s,h),l=So(s,u)}o>t.from&&a(t.from,o,t,s),l<t.to&&a(l,t.to,t,s)};for(let e of this.viewportLines)Array.isArray(e.type)?e.type.forEach(l):l(e);return o}gapSize(e,t,n,i){let s=Co(i,n)-Co(i,t);return this.heightOracle.lineWrapping?e.height*s:i.total*this.heightOracle.charWidth*s}updateLineGaps(e){bo.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=ii.set(e.map(e=>e.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];hn.spans(t,this.viewport.from,this.viewport.to,{span(e,t){n.push({from:e,to:t})},point(){}},20);let i=0;if(n.length!=this.visibleRanges.length)i=12;else for(let t=0;t<n.length&&!(8&i);t++){let s=this.visibleRanges[t],r=n[t];s.from==r.from&&s.to==r.to||(i|=4,e&&e.mapPos(s.from,-1)==r.from&&e.mapPos(s.to,1)==r.to||(i|=8))}return this.visibleRanges=n,i}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||Mo(this.heightMap.lineAt(e,so.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||Mo(this.heightMap.lineAt(this.scaler.fromDOM(e),so.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return Mo(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class xo{constructor(e,t){this.from=e,this.to=t}}function So({total:e,ranges:t},n){if(n<=0)return t[0].from;if(n>=1)return t[t.length-1].to;let i=Math.floor(e*n);for(let e=0;;e++){let{from:n,to:s}=t[e],r=s-n;if(i<=r)return n+i;i-=r}}function Co(e,t){let n=0;for(let{from:i,to:s}of e.ranges){if(t<=s){n+=t-i;break}n+=s-i}return n/e.total}const Ao={toDOM:e=>e,fromDOM:e=>e,scale:1,eq(e){return e==this}};function To(e){let t=e.facet(ks).filter(e=>"function"!=typeof e),n=e.facet(Ss).filter(e=>"function"!=typeof e);return n.length&&t.push(hn.join(n)),t}class Oo{constructor(e,t,n){let i=0,s=0,r=0;this.viewports=n.map(({from:n,to:s})=>{let r=t.lineAt(n,so.ByPos,e,0,0).top,o=t.lineAt(s,so.ByPos,e,0,0).bottom;return i+=o-r,{from:n,to:s,top:r,bottom:o,domTop:0,domBottom:0}}),this.scale=(7e6-i)/(t.height-i);for(let e of this.viewports)e.domTop=r+(e.top-s)*this.scale,r=e.domBottom=e.domTop+(e.bottom-e.top),s=e.bottom}toDOM(e){for(let t=0,n=0,i=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.top)return i+(e-n)*this.scale;if(e<=s.bottom)return s.domTop+(e-s.top);n=s.bottom,i=s.domBottom}}fromDOM(e){for(let t=0,n=0,i=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.domTop)return n+(e-i)/this.scale;if(e<=s.domBottom)return s.top+(e-s.domTop);n=s.bottom,i=s.domBottom}}eq(e){return e instanceof Oo&&(this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,n)=>t.from==e.viewports[n].from&&t.to==e.viewports[n].to))}}function Mo(e,t){if(1==t.scale)return e;let n=t.toDOM(e.top),i=t.toDOM(e.bottom);return new io(e.from,e.length,n,i-n,Array.isArray(e._content)?e._content.map(e=>Mo(e,t)):e._content)}const Eo=pt.define({combine:e=>e.join(" ")}),No=pt.define({combine:e=>e.indexOf(!0)>-1}),Do=On.newName(),_o=On.newName(),Po=On.newName(),Io={"&light":"."+_o,"&dark":"."+Po};function Ro(e,t,n){return new On(t,{finish:t=>/&/.test(t)?t.replace(/&\w*/,t=>{if("&"==t)return e;if(!n||!n[t])throw new RangeError(`Unsupported selector: ${t}`);return n[t]}):e+" "+t})}const $o=Ro("."+Do,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Io),Bo={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Lo=Zn.ie&&Zn.ie_version<=11;class zo{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Si,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let e of t)this.queue.push(e);(Zn.ie&&Zn.ie_version<=11||Zn.ios&&e.composing)&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),!window.EditContext||!Zn.android||!1===e.constructor.EDIT_CONTEXT||Zn.chrome&&Zn.chrome_version<126||(this.editContext=new Uo(e),e.state.facet(ps)&&(e.contentDOM.editContext=this.editContext.editContext)),Lo&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.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 e;(null===(e=this.view.docView)||void 0===e?void 0:e.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver(e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.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(e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){("change"!=e.type&&e.type||e.matches)&&(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,i=this.selectionRange;if(n.state.facet(ps)?n.root.activeElement!=this.dom:!di(this.dom,i))return;let s=i.anchorNode&&n.docView.tile.nearest(i.anchorNode);s&&s.isWidget()&&s.widget.ignoreEvent(e)?t||(this.selectionChanged=!1):(Zn.ie&&Zn.ie_version<=11||Zn.android&&Zn.chrome)&&!n.state.selection.main.empty&&i.focusNode&&pi(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=hi(e.root);if(!t)return!1;let n=Zn.safari&&11==e.root.nodeType&&e.root.activeElement==this.dom&&function(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return Wo(e,n)}let n=null;function i(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.contentDOM.addEventListener("beforeinput",i,!0),e.dom.ownerDocument.execCommand("indent"),e.contentDOM.removeEventListener("beforeinput",i,!0),n?Wo(e,n):null}(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let i=di(this.dom,n);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&function(e,t){let n=t.focusNode,i=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=i)return!1;for(i=Math.min(i,vi(n));;)if(i){if(1!=n.nodeType)return!1;let e=n.childNodes[i-1];"false"==e.contentEditable?i--:(n=e,i=vi(n))}else{if(n==e)return!0;i=mi(n),n=n.parentNode}}(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),i&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(1==n.nodeType)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(n),n=n.assignedSlot||n.parentNode;else{if(11!=n.nodeType)break;n=n.host}if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let e of this.scrollTargets)e.removeEventListener("scroll",this.onScroll);for(let e of this.scrollTargets=t)e.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,Bo),Lo&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Lo&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var n;if(!this.delayedAndroidKey){let e=()=>{let e=this.delayedAndroidKey;if(e){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&Mi(this.dom,e.key,e.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(e)}this.delayedAndroidKey&&"Enter"!=e||(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(null===(n=this.delayedAndroidKey)||void 0===n?void 0:n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,i=!1;for(let s of e){let e=this.readMutation(s);e&&(e.typeOver&&(i=!0),-1==t?({from:t,to:n}=e):(t=Math.min(e.from,t),n=Math.max(e.to,n)))}return{from:t,to:n,typeOver:i}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),i=this.selectionChanged&&di(this.dom,this.selectionRange);if(e<0&&!i)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new kr(this.view,e,t,n);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,i=Sr(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!Tr(this.view.state.selection,t.newSel.main))&&this.view.update([]),i}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty("attributes"==e.type),"childList"==e.type){let n=jo(t,e.previousSibling||e.target.previousSibling,-1),i=jo(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:i?t.posBefore(i):t.posAtEnd,typeOver:!1}}return"characterData"==e.type?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(ps)!=e.state.facet(ps)&&(e.view.contentDOM.editContext=e.state.facet(ps)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),null===(e=this.intersection)||void 0===e||e.disconnect(),null===(t=this.gapIntersection)||void 0===t||t.disconnect(),null===(n=this.resizeScroll)||void 0===n||n.disconnect();for(let e of this.scrollTargets)e.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 jo(e,t,n){for(;t;){let i=Ps.get(t);if(i&&i.parent==e)return i;let s=t.parentNode;t=s!=e.dom?s:n>0?t.nextSibling:t.previousSibling}return null}function Wo(e,t){let n=t.startContainer,i=t.startOffset,s=t.endContainer,r=t.endOffset,o=e.docView.domAtPos(e.state.selection.main.anchor,1);return pi(o.node,o.offset,s,r)&&([n,i,s,r]=[s,r,n,i]),{anchorNode:n,anchorOffset:i,focusNode:s,focusOffset:r}}class Uo{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let i=e.state.selection.main,{anchor:s,head:r}=i,o=this.toEditorPos(n.updateRangeStart),a=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:o,drifted:!1});let l=a-o>n.text.length;o==this.from&&s<this.from?o=s:a==this.to&&s>this.to&&(a=s);let c=Ar(e.state.sliceDoc(o,a),n.text,(l?i.from:i.to)-o,l?"end":null);if(!c){let t=ut.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));return void(Tr(t,i)||e.dispatch({selection:t,userEvent:"select"}))}let h={from:c.from+o,to:c.toA+o,insert:je.of(n.text.slice(c.from,c.toB).split("\n"))};if((Zn.mac||Zn.android)&&h.from==r-1&&/^\. ?$/.test(n.text)&&"off"==e.contentDOM.getAttribute("autocorrect")&&(h={from:o,to:a,insert:je.of([n.text.replace("."," ")])}),this.pendingContextChange=h,!e.state.readOnly){let t=this.to-this.from+(h.to-h.from+h.insert.length);Cr(e,h,ut.single(this.toEditorPos(n.selectionStart,t),this.toEditorPos(n.selectionEnd,t)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),h.from<h.to&&!h.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let i=[],s=null;for(let t=this.toEditorPos(n.rangeStart),r=this.toEditorPos(n.rangeEnd);t<r;t++){let n=e.coordsForChar(t);s=n&&new DOMRect(n.left,n.top,n.right-n.left,n.bottom-n.top)||s||new DOMRect,i.push(s)}t.updateCharacterBounds(n.rangeStart,i)},this.handlers.textformatupdate=t=>{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,i=e.underlineThickness;if(!/none/i.test(t)&&!/none/i.test(i)){let s=this.toEditorPos(e.rangeStart),r=this.toEditorPos(e.rangeEnd);if(s<r){let e=`text-decoration: underline ${/^[a-z]/.test(t)?t+" ":"Dashed"==t?"dashed ":"Squiggle"==t?"wavy ":""}${/thin/i.test(i)?1:2}px`;n.push(ii.mark({attributes:{style:e}}).range(s,r))}}}e.dispatch({effects:ds.of(ii.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:t}=this.composing;this.composing=null,t&&this.reset(e.state)}};for(let e in this.handlers)t.addEventListener(e,this.handlers[e]);this.measureReq={read:e=>{this.editContext.updateControlBounds(e.contentDOM.getBoundingClientRect());let t=hi(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,i=this.pendingContextChange;return e.changes.iterChanges((s,r,o,a,l)=>{if(n)return;let c=l.length-(r-s);if(i&&r>=i.to){if(i.from==s&&i.to==r&&i.insert.eq(l))return i=this.pendingContextChange=null,t+=c,void(this.to+=c);i=null,this.revertPending(e.state)}if(s+=t,(r+=t)<=this.from)this.from+=c,this.to+=c;else if(s<this.to){if(s<this.from||r>this.to||this.to-this.from+l.length>3e4)return void(n=!0);this.editContext.updateText(this.toContextPos(s),this.toContextPos(r),l.toString()),this.to+=c}t+=c}),i&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(e=>!e.isUserEvent("input.type")&&e.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):this.applyEdits(e)&&this.rangeIsValid(e.state)?(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state):(this.pendingContextChange=null,this.reset(e.state)),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),i=this.toContextPos(t.head);this.editContext.selectionStart==n&&this.editContext.selectionEnd==i||this.editContext.updateSelection(n,i)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>3e4)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Fo{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;this.dispatchTransactions=e.dispatchTransactions||n&&(e=>e.forEach(e=>n(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||function(e){for(;e;){if(e&&(9==e.nodeType||11==e.nodeType&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}(e.parent)||document,this.viewState=new ko(this,e.state||nn.create(e)),e.scrollTo&&e.scrollTo.is(us)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(gs).map(e=>new vs(e));for(let e of this.plugins)e.update(this);this.observer=new zo(this),this.inputState=new Or(this),this.inputState.ensureHandlers(this.plugins),this.docView=new nr(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),(null===(t=document.fonts)||void 0===t?void 0:t.ready)&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=1==e.length&&e[0]instanceof Ht?e:1==e.length&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t,n=!1,i=!1,s=this.state;for(let t of e){if(t.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=t.state}if(this.destroyed)return void(this.viewState.state=s);let r=this.hasFocus,o=0,a=null;e.some(e=>e.annotation(Jr))?(this.inputState.notifiedFocused=r,o=1):r!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=r,a=Zr(s,r),a||(o=1));let l=this.observer.delayedAndroidKey,c=null;if(l?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(c=null)):this.observer.clear(),s.facet(nn.phrases)!=this.state.facet(nn.phrases))return this.setState(s);t=Ds.create(this,s,e),t.flags|=o;let h=this.viewState.scrollTarget;try{this.updateState=2;for(let t of e){if(h&&(h=h.map(t.changes)),t.scrollIntoView){let{main:e}=t.state.selection;h=new hs(e.empty?e:ut.cursor(e.head,e.head>e.anchor?-1:1))}for(let e of t.effects)e.is(us)&&(h=e.value.clip(this.state))}this.viewState.update(t,h),this.bidiCache=qo.update(this.bidiCache,t.changes),t.empty||(this.updatePlugins(t),this.inputState.update(t)),n=this.docView.update(t),this.state.facet(Es)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(e=>e.isUserEvent("select.pointer")))}finally{this.updateState=0}if(t.startState.facet(Eo)!=t.state.facet(Eo)&&(this.viewState.mustMeasureContent=!0),(n||i||h||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!t.empty)for(let e of this.state.facet(ns))try{e(t)}catch(e){fs(this.state,e,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!Sr(this,c)&&l.force&&Mi(this.contentDOM,l.key,l.keyCode)})}setState(e){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=e);this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);this.viewState=new ko(this,e),this.plugins=e.facet(gs).map(e=>new vs(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new nr(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(gs),n=e.state.facet(gs);if(t!=n){let i=[];for(let s of n){let n=t.indexOf(s);if(n<0)i.push(new vs(s));else{let t=this.plugins[n];t.mustUpdate=e,i.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=i,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e<this.plugins.length;e++)this.plugins[e].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(e){fs(this.state,e,"doc view update listener")}}}measure(e=!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,e&&this.observer.forceFlush();let t=null,n=this.viewState.scrollParent,i=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:r}=this.viewState;Math.abs(i-this.viewState.scrollOffset)>1&&(r=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(r<0)if(Ei(n||this.win))s=-1,r=this.viewState.heightMap.height;else{let e=this.viewState.scrollAnchorAt(i);s=e.from,r=e.top}this.updateState=1;let o=this.viewState.measure();if(!o&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(e>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let a=[];4&o||([this.measureRequests,a]=[a,this.measureRequests]);let l=a.map(e=>{try{return e.read(this)}catch(e){return fs(this.state,e),Ho}}),c=Ds.create(this,this.state,[]),h=!1;c.flags|=o,t?t.flags|=o:t=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),h=this.docView.update(c),h&&this.docViewUpdate());for(let e=0;e<a.length;e++)if(l[e]!=Ho)try{let t=a[e];t.write&&t.write(l[e],this)}catch(e){fs(this.state,e)}if(h&&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 e=((s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-r)/this.scaleY;if((e>1||e<-1)&&(n==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){i+=e,n?n.scrollTop+=e:this.win.scrollBy(0,e),r=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(ns))e(t)}get themeClasses(){return Do+" "+(this.state.facet(No)?Po:_o)+" "+this.state.facet(Eo)}updateAttrs(){let e=Ko(this,bs,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(ps)?"true":"false",class:"cm-content",style:`${Zn.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Ko(this,ws,t);let n=this.observer.ignore(()=>{let n=Xn(this.contentDOM,this.contentAttrs,t),i=Xn(this.dom,this.editorAttrs,e);return n||i});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let e of n.effects)if(e.is(Fo.announce)){t&&(this.announceDOM.textContent=""),t=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=e.value}}mountStyles(){this.styleModules=this.state.facet(Es);let e=this.state.facet(Fo.cspNonce);On.mount(this.root,this.styleModules.concat($o).reverse(),e?{nonce:e}: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(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(null!=e.key)for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key)return void(this.measureRequests[t]=e);this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(void 0===t||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(t=>t.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return dr(this,e,cr(this,e,t,n))}moveByGroup(e,t){return dr(this,e,cr(this,e,t,t=>function(e,t,n){let i=e.state.charCategorizer(t),s=i(n);return e=>{let t=i(e);return s==Qt.Space&&(s=t),s==t}}(this,e.head,t)))}visualLineSide(e,t){let n=this.bidiSpans(e),i=this.textDirectionAt(e.from),s=n[t?n.length-1:0];return ut.cursor(s.side(t,i)+e.from,s.forward(!t,i)?1:-1)}moveToLineBoundary(e,t,n=!0){return function(e,t,n,i){let s=lr(e,t.head,t.assoc||-1),r=i&&s.type==ni.Text&&(e.lineWrapping||s.widgetLineBreaks)?e.coordsAtPos(t.assoc<0&&t.head>s.from?t.head-1:t.head):null;if(r){let t=e.dom.getBoundingClientRect(),i=e.textDirectionAt(s.from),o=e.posAtCoords({x:n==(i==Pi.LTR)?t.right-1:t.left+1,y:(r.top+r.bottom)/2});if(null!=o)return ut.cursor(o,n?-1:1)}return ut.cursor(n?s.to:s.from,n?-1:1)}(this,e,t,n)}moveVertically(e,t,n){return dr(this,e,function(e,t,n,i){let s=t.head,r=n?1:-1;if(s==(n?e.state.doc.length:0))return ut.cursor(s,t.assoc);let o,a=t.goalColumn,l=e.contentDOM.getBoundingClientRect(),c=e.coordsAtPos(s,t.assoc||((t.empty?n:t.head==t.from)?1:-1)),h=e.documentTop;if(c)null==a&&(a=c.left-l.left),o=r<0?c.top:c.bottom;else{let t=e.viewState.lineBlockAt(s);null==a&&(a=Math.min(l.right-l.left,e.defaultCharacterWidth*(s-t.from))),o=(r<0?t.top:t.bottom)+h}let u=l.left+a,d=e.viewState.heightOracle.textHeight>>1,f=null!=i?i:d;for(let t=0;;t+=d){let i=o+(f+t)*r,s=pr(e,{x:u,y:i},!1,r);if(n?i>l.bottom:i<l.top)return ut.cursor(s.pos,s.assoc);let c=e.coordsAtPos(s.pos,s.assoc),h=c?(c.top+c.bottom)/2:0;if(!c||(n?h>o:h<o))return ut.cursor(s.pos,s.assoc,void 0,a)}}(this,e,t,n))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let n=pr(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),pr(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let i=this.state.doc.lineAt(e),s=this.bidiSpans(i);return bi(n,s[Fi.find(s,e-i.from,-1,t)].dir==Pi.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(as)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Vo)return Ji(e.length);let t,n=this.textDirectionAt(e.from);for(let i of this.bidiCache)if(i.from==e.from&&i.dir==n&&(i.fresh||Vi(i.isolates,t=Ts(this,e))))return i.order;t||(t=Ts(this,e));let i=function(e,t,n){if(!e)return[new Fi(0,0,t==Ri?1:0)];if(t==Ii&&!n.length&&!Ui.test(e))return Ji(e.length);if(n.length)for(;e.length>Hi.length;)Hi[Hi.length]=256;let i=[],s=t==Ii?0:1;return Ki(e,s,s,n,0,e.length,i),i}(e.text,n,t);return this.bidiCache.push(new qo(e.from,e.to,n,t,!0,i)),i}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Zn.safari&&(null===(e=this.inputState)||void 0===e?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Ti(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((9==e.nodeType?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return us.of(new hs("number"==typeof e?ut.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return us.of(new hs(ut.cursor(n.from),"start","start",n.top-e,t,!0))}setTabFocusMode(e){null==e?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof e?this.inputState.tabFocusMode=e?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return ys.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return ys.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=On.newName(),i=[Eo.of(n),Es.of(Ro(`.${n}`,e))];return t&&t.dark&&i.push(No.of(!0)),i}static baseTheme(e){return Ot.lowest(Es.of(Ro("."+Do,e,Io)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),i=n&&Ps.get(n)||Ps.get(e);return(null===(t=null==i?void 0:i.root)||void 0===t?void 0:t.view)||null}}Fo.styleModule=Es,Fo.inputHandler=is,Fo.clipboardInputFilter=rs,Fo.clipboardOutputFilter=os,Fo.scrollHandler=cs,Fo.focusChangeEffect=ss,Fo.perLineTextDirection=as,Fo.exceptionSink=ts,Fo.updateListener=ns,Fo.editable=ps,Fo.mouseSelectionStyle=es,Fo.dragMovesSelection=Xi,Fo.clickAddsSelectionRange=Qi,Fo.decorations=ks,Fo.blockWrappers=xs,Fo.outerDecorations=Ss,Fo.atomicRanges=Cs,Fo.bidiIsolatedRanges=As,Fo.scrollMargins=Os,Fo.darkTheme=No,Fo.cspNonce=pt.define({combine:e=>e.length?e[0]:""}),Fo.contentAttributes=ws,Fo.editorAttributes=bs,Fo.lineWrapping=Fo.contentAttributes.of({class:"cm-lineWrapping"}),Fo.announce=Vt.define();const Vo=4096,Ho={};class qo{constructor(e,t,n,i,s,r){this.from=e,this.to=t,this.dir=n,this.isolates=i,this.fresh=s,this.order=r}static update(e,t){if(t.empty&&!e.some(e=>e.fresh))return e;let n=[],i=e.length?e[e.length-1].dir:Pi.LTR;for(let s=Math.max(0,e.length-10);s<e.length;s++){let r=e[s];r.dir!=i||t.touchesRange(r.from,r.to)||n.push(new qo(t.mapPos(r.from,1),t.mapPos(r.to,-1),r.dir,r.isolates,!1,r.order))}return n}}function Ko(e,t,n){for(let i=e.state.facet(t),s=i.length-1;s>=0;s--){let t=i[s],r="function"==typeof t?t(e):t;r&&Yn(r,n)}return n}const Jo=Zn.mac?"mac":Zn.windows?"win":Zn.linux?"linux":"key";function Zo(e,t,n){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),!1!==n&&t.shiftKey&&(e="Shift-"+e),e}const Yo=Ot.default(Fo.domEventHandlers({keydown:(e,t)=>ia(Xo(t.state),e,t,"editor")})),Go=pt.define({enables:Yo}),Qo=new WeakMap;function Xo(e){let t=e.facet(Go),n=Qo.get(t);return n||Qo.set(t,n=function(e,t=Jo){let n=Object.create(null),i=Object.create(null),s=(e,t)=>{let n=i[e];if(null==n)i[e]=t;else if(n!=t)throw new Error("Key binding "+e+" is used both as a regular binding and as a multi-stroke prefix")},r=(e,i,r,o,a)=>{var l,c;let h=n[e]||(n[e]=Object.create(null)),u=i.split(/ (?!$)/).map(e=>function(e,t){const n=e.split(/-(?!$)/);let i,s,r,o,a=n[n.length-1];"Space"==a&&(a=" ");for(let e=0;e<n.length-1;++e){const a=n[e];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))i=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))r=!0;else{if(!/^mod$/i.test(a))throw new Error("Unrecognized modifier name: "+a);"mac"==t?o=!0:s=!0}}return i&&(a="Alt-"+a),s&&(a="Ctrl-"+a),o&&(a="Meta-"+a),r&&(a="Shift-"+a),a}(e,t));for(let t=1;t<u.length;t++){let n=u.slice(0,t).join(" ");s(n,!0),h[n]||(h[n]={preventDefault:!0,stopPropagation:!1,run:[t=>{let i=ea={view:t,prefix:n,scope:e};return setTimeout(()=>{ea==i&&(ea=null)},ta),!0}]})}let d=u.join(" ");s(d,!1);let f=h[d]||(h[d]={preventDefault:!1,stopPropagation:!1,run:(null===(c=null===(l=h._any)||void 0===l?void 0:l.run)||void 0===c?void 0:c.slice())||[]});r&&f.run.push(r),o&&(f.preventDefault=!0),a&&(f.stopPropagation=!0)};for(let i of e){let e=i.scope?i.scope.split(" "):["editor"];if(i.any)for(let t of e){let e=n[t]||(n[t]=Object.create(null));e._any||(e._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:s}=i;for(let t in e)e[t].run.push(e=>s(e,na))}let s=i[t]||i.key;if(s)for(let t of e)r(t,s,i.run,i.preventDefault,i.stopPropagation),i.shift&&r(t,"Shift-"+s,i.shift,i.preventDefault,i.stopPropagation)}return n}(t.reduce((e,t)=>e.concat(t),[]))),n}let ea=null;const ta=4e3;let na=null;function ia(e,t,n,i){na=t;let s=function(e){var t=!(_n&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Pn&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?Dn:Nn)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}(t),r=Xe(Ge(s,0))==s.length&&" "!=s,o="",a=!1,l=!1,c=!1;ea&&ea.view==n&&ea.scope==i&&(o=ea.prefix+" ",_r.indexOf(t.keyCode)<0&&(l=!0,ea=null));let h,u,d=new Set,f=e=>{if(e){for(let t of e.run)if(!d.has(t)&&(d.add(t),t(n)))return e.stopPropagation&&(c=!0),!0;e.preventDefault&&(e.stopPropagation&&(c=!0),l=!0)}return!1},p=e[i];return p&&(f(p[o+Zo(s,t,!r)])?a=!0:!r||!(t.altKey||t.metaKey||t.ctrlKey)||Zn.windows&&t.ctrlKey&&t.altKey||Zn.mac&&t.altKey&&!t.ctrlKey&&!t.metaKey||!(h=Nn[t.keyCode])||h==s?r&&t.shiftKey&&f(p[o+Zo(s,t,!0)])&&(a=!0):(f(p[o+Zo(h,t,!0)])||t.shiftKey&&(u=Dn[t.keyCode])!=s&&u!=h&&f(p[o+Zo(u,t,!1)]))&&(a=!0),!a&&f(p._any)&&(a=!0)),l&&(a=!0),a&&c&&t.stopPropagation(),na=null,a}class sa{constructor(e,t,n,i,s){this.className=e,this.left=t,this.top=n,this.width=i,this.height=s}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className==this.className&&(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",null!=this.width&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,n){if(n.empty){let i=e.coordsAtPos(n.head,n.assoc||1);if(!i)return[];let s=ra(e);return[new sa(t,i.left-s.left,i.top-s.top,null,i.bottom-i.top)]}return function(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let i=Math.max(n.from,e.viewport.from),s=Math.min(n.to,e.viewport.to),r=e.textDirection==Pi.LTR,o=e.contentDOM,a=o.getBoundingClientRect(),l=ra(e),c=o.querySelector(".cm-line"),h=c&&window.getComputedStyle(c),u=a.left+(h?parseInt(h.paddingLeft)+Math.min(0,parseInt(h.textIndent)):0),d=a.right-(h?parseInt(h.paddingRight):0),f=lr(e,i,1),p=lr(e,s,-1),m=f.type==ni.Text?f:null,g=p.type==ni.Text?p:null;m&&(e.lineWrapping||f.widgetLineBreaks)&&(m=oa(e,i,1,m));g&&(e.lineWrapping||p.widgetLineBreaks)&&(g=oa(e,s,-1,g));if(m&&g&&m.from==g.from&&m.to==g.to)return v(b(n.from,n.to,m));{let t=m?b(n.from,null,m):w(f,!1),i=g?b(null,n.to,g):w(p,!0),s=[];return(m||f).to<(g||p).from-(m&&g?1:0)||f.widgetLineBreaks>1&&t.bottom+e.defaultLineHeight/2<i.top?s.push(y(u,t.bottom,d,i.top)):t.bottom<i.top&&e.elementAtHeight((t.bottom+i.top)/2).type==ni.Text&&(t.bottom=i.top=(t.bottom+i.top)/2),v(t).concat(s).concat(v(i))}function y(e,n,i,s){return new sa(t,e-l.left,n-l.top,Math.max(0,i-e),s-n)}function v({top:e,bottom:t,horizontal:n}){let i=[];for(let s=0;s<n.length;s+=2)i.push(y(n[s],e,n[s+1],t));return i}function b(t,n,i){let s=1e9,o=-1e9,a=[];function l(t,n,l,c,h){let f=e.coordsAtPos(t,t==i.to?-2:2),p=e.coordsAtPos(l,l==i.from?2:-2);f&&p&&(s=Math.min(f.top,p.top,s),o=Math.max(f.bottom,p.bottom,o),h==Pi.LTR?a.push(r&&n?u:f.left,r&&c?d:p.right):a.push(!r&&c?u:p.left,!r&&n?d:f.right))}let c=null!=t?t:i.from,h=null!=n?n:i.to;for(let i of e.visibleRanges)if(i.to>c&&i.from<h)for(let s=Math.max(i.from,c),r=Math.min(i.to,h);;){let i=e.state.doc.lineAt(s);for(let o of e.bidiSpans(i)){let e=o.from+i.from,a=o.to+i.from;if(e>=r)break;a>s&&l(Math.max(e,s),null==t&&e<=c,Math.min(a,r),null==n&&a>=h,o.dir)}if(s=i.to+1,s>=r)break}return 0==a.length&&l(c,null==t,h,null==n,e.textDirection),{top:s,bottom:o,horizontal:a}}function w(e,t){let n=a.top+(t?e.top:e.bottom);return{top:n,bottom:n,horizontal:[]}}}(e,t,n)}}function ra(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==Pi.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function oa(e,t,n,i){let s=e.coordsAtPos(t,2*n);if(!s)return i;let r=e.dom.getBoundingClientRect(),o=(s.top+s.bottom)/2,a=e.posAtCoords({x:r.left+1,y:o}),l=e.posAtCoords({x:r.right-1,y:o});return null==a||null==l?i:{from:Math.max(i.from,Math.min(a,l)),to:Math.min(i.to,Math.max(a,l))}}class aa{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(la)!=e.state.facet(la)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){!1!==this.layer.updateOnDocViewUpdate&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(la);for(;t<n.length&&n[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;e==this.scaleX&&t==this.scaleY||(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((e,t)=>!function(e,t){return e.constructor==t.constructor&&e.eq(t)}(e,this.drawn[t]))){let t=this.dom.firstChild,n=0;for(let i of e)i.update&&t&&i.constructor&&this.drawn[n].constructor&&i.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(i.draw(),t);for(;t;){let e=t.nextSibling;t.remove(),t=e}this.drawn=e,Zn.safari&&Zn.safari_version>=26&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const la=pt.define();function ca(e){return[ys.define(t=>new aa(t,e)),la.of(e)]}const ha=pt.define({combine:e=>sn(e,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})});function ua(e={}){return[ha.of(e),fa,ma,ga,ls.of(!0)]}function da(e){return e.startState.facet(ha)!=e.state.facet(ha)}const fa=ca({above:!0,markers(e){let{state:t}=e,n=t.facet(ha),i=[];for(let s of t.selection.ranges){let r=s==t.selection.main;if(s.empty||n.drawRangeCursor&&!(r&&Zn.ios&&n.iosSelectionHandles)){let t=r?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",n=s.empty?s:ut.cursor(s.head,s.assoc);for(let s of sa.forRange(e,t,n))i.push(s)}}return i},update(e,t){e.transactions.some(e=>e.selection)&&(t.style.animationName="cm-blink"==t.style.animationName?"cm-blink2":"cm-blink");let n=da(e);return n&&pa(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){pa(t.state,e)},class:"cm-cursorLayer"});function pa(e,t){t.style.animationDuration=e.facet(ha).cursorBlinkRate+"ms"}const ma=ca({above:!1,markers(e){let t=[],{main:n,ranges:i}=e.state.selection;for(let n of i)if(!n.empty)for(let i of sa.forRange(e,"cm-selectionBackground",n))t.push(i);if(Zn.ios&&!n.empty&&e.state.facet(ha).iosSelectionHandles){for(let i of sa.forRange(e,"cm-selectionHandle cm-selectionHandle-start",ut.cursor(n.from,1)))t.push(i);for(let i of sa.forRange(e,"cm-selectionHandle cm-selectionHandle-end",ut.cursor(n.to,1)))t.push(i)}return t},update:(e,t)=>e.docChanged||e.selectionSet||e.viewportChanged||da(e),class:"cm-selectionLayer"}),ga=Ot.highest(Fo.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),ya=Vt.define({map:(e,t)=>null==e?null:t.mapPos(e)}),va=kt.define({create:()=>null,update:(e,t)=>(null!=e&&(e=t.changes.mapPos(e)),t.effects.reduce((e,t)=>t.is(ya)?t.value:e,e))}),ba=ys.fromClass(class{constructor(e){this.view=e,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(e){var t;let n=e.state.field(va);null==n?null!=this.cursor&&(null===(t=this.cursor)||void 0===t||t.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(e.startState.field(va)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(va),n=null!=t&&e.coordsAtPos(t);if(!n)return null;let i=e.scrollDOM.getBoundingClientRect();return{left:n.left-i.left+e.scrollDOM.scrollLeft*e.scaleX,top:n.top-i.top+e.scrollDOM.scrollTop*e.scaleY,height:n.bottom-n.top}}drawCursor(e){if(this.cursor){let{scaleX:t,scaleY:n}=this.view;e?(this.cursor.style.left=e.left/t+"px",this.cursor.style.top=e.top/n+"px",this.cursor.style.height=e.height/n+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(e){this.view.state.field(va)!=e&&this.view.dispatch({effects:ya.of(e)})}},{eventObservers:{dragover(e){this.setDropPos(this.view.posAtCoords({x:e.clientX,y:e.clientY}))},dragleave(e){e.target!=this.view.contentDOM&&this.view.contentDOM.contains(e.relatedTarget)||this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function wa(e,t,n,i,s){t.lastIndex=0;for(let r,o=e.iterRange(n,i),a=n;!o.next().done;a+=o.value.length)if(!o.lineBreak)for(;r=t.exec(o.value);)s(a+r.index,r)}class ka{constructor(e){const{regexp:t,decoration:n,decorate:i,boundary:s,maxLength:r=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,i)this.addMatch=(e,t,n,s)=>i(s,n,n+e[0].length,e,t);else if("function"==typeof n)this.addMatch=(e,t,i,s)=>{let r=n(e,t,i);r&&s(i,i+e[0].length,r)};else{if(!n)throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.addMatch=(e,t,i,s)=>s(i,i+e[0].length,n)}this.boundary=s,this.maxLength=r}createDeco(e){let t=new un,n=t.add.bind(t);for(let{from:t,to:i}of function(e,t){let n=e.visibleRanges;if(1==n.length&&n[0].from==e.viewport.from&&n[0].to==e.viewport.to)return n;let i=[];for(let{from:s,to:r}of n)s=Math.max(e.state.doc.lineAt(s).from,s-t),r=Math.min(e.state.doc.lineAt(r).to,r+t),i.length&&i[i.length-1].to>=s?i[i.length-1].to=r:i.push({from:s,to:r});return i}(e,this.maxLength))wa(e.state.doc,this.regexp,t,i,(t,i)=>this.addMatch(i,e,t,n));return t.finish()}updateDeco(e,t){let n=1e9,i=-1;return e.docChanged&&e.changes.iterChanges((t,s,r,o)=>{o>=e.view.viewport.from&&r<=e.view.viewport.to&&(n=Math.min(r,n),i=Math.max(o,i))}),e.viewportMoved||i-n>1e3?this.createDeco(e.view):i>-1?this.updateRange(e.view,t.map(e.changes),n,i):t}updateRange(e,t,n,i){for(let s of e.visibleRanges){let r=Math.max(s.from,n),o=Math.min(s.to,i);if(o>=r){let n=e.state.doc.lineAt(r),i=n.to<o?e.state.doc.lineAt(o):n,a=Math.max(s.from,n.from),l=Math.min(s.to,i.to);if(this.boundary){for(;r>n.from;r--)if(this.boundary.test(n.text[r-1-n.from])){a=r;break}for(;o<i.to;o++)if(this.boundary.test(i.text[o-i.from])){l=o;break}}let c,h=[],u=(e,t,n)=>h.push(n.range(e,t));if(n==i)for(this.regexp.lastIndex=a-n.from;(c=this.regexp.exec(n.text))&&c.index<l-n.from;)this.addMatch(c,e,c.index+n.from,u);else wa(e.state.doc,this.regexp,a,l,(t,n)=>this.addMatch(n,e,t,u));t=t.update({filterFrom:a,filterTo:l,filter:(e,t)=>e<a||t>l,add:h})}}return t}}const xa=null!=/x/.unicode?"gu":"g",Sa=new RegExp("[\0-\b\n--\u2028\u2029\ufeff-]",xa),Ca={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 Aa=null;const Ta=pt.define({combine(e){let t=sn(e,{render:null,specialChars:Sa,addSpecialChars:null});return(t.replaceTabs=!function(){var e;if(null==Aa&&"undefined"!=typeof document&&document.body){let t=document.body.style;Aa=null!=(null!==(e=t.tabSize)&&void 0!==e?e:t.MozTabSize)}return Aa||!1}())&&(t.specialChars=new RegExp("\t|"+t.specialChars.source,xa)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,xa)),t}});function Oa(e={}){return[Ta.of(e),Ma||(Ma=ys.fromClass(class{constructor(e){this.view=e,this.decorations=ii.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(Ta)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new ka({regexp:e.specialChars,decoration:(t,n,i)=>{let{doc:s}=n.state,r=Ge(t[0],0);if(9==r){let e=s.lineAt(i),t=n.state.tabSize,r=xn(e.text,t,i-e.from);return ii.replace({widget:new Na((t-r%t)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[r]||(this.decorationCache[r]=ii.replace({widget:new Ea(e,r)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(Ta);e.startState.facet(Ta)!=t?(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(e.view)):this.decorations=this.decorator.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}))]}let Ma=null;class Ea extends ti{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=function(e){return e>=32?"•":10==e?"":String.fromCharCode(9216+e)}(this.code),n=e.state.phrase("Control character")+" "+(Ca[this.code]||"0x"+this.code.toString(16)),i=this.options.render&&this.options.render(this.code,n,t);if(i)return i;let s=document.createElement("span");return s.textContent=t,s.title=n,s.setAttribute("aria-label",n),s.className="cm-specialChar",s}ignoreEvent(){return!1}}class Na extends ti{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent="\t",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}const Da=ii.line({class:"cm-activeLine"}),_a=ys.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,n=[];for(let i of e.state.selection.ranges){let s=e.lineBlockAt(i.head);s.from>t&&(n.push(Da.range(s.from)),t=s.from)}return ii.set(n)}},{decorations:e=>e.decorations}),Pa=2e3;function Ia(e,t){let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1),i=e.state.doc.lineAt(n),s=n-i.from,r=s>Pa?-1:s==i.length?function(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}(e,t.clientX):xn(i.text,e.state.tabSize,n-i.from);return{line:i.number,col:r,off:s}}function Ra(e,t){let n=Ia(e,t),i=e.state.selection;return n?{update(e){if(e.docChanged){let t=e.changes.mapPos(e.startState.doc.line(n.line).from),s=e.state.doc.lineAt(t);n={line:s.number,col:n.col,off:Math.min(n.off,s.length)},i=i.map(e.changes)}},get(t,s,r){let o=Ia(e,t);if(!o)return i;let a=function(e,t,n){let i=Math.min(t.line,n.line),s=Math.max(t.line,n.line),r=[];if(t.off>Pa||n.off>Pa||t.col<0||n.col<0){let o=Math.min(t.off,n.off),a=Math.max(t.off,n.off);for(let t=i;t<=s;t++){let n=e.doc.line(t);n.length<=a&&r.push(ut.range(n.from+o,n.to+a))}}else{let o=Math.min(t.col,n.col),a=Math.max(t.col,n.col);for(let t=i;t<=s;t++){let n=e.doc.line(t),i=Sn(n.text,o,e.tabSize,!0);if(i<0)r.push(ut.cursor(n.to));else{let t=Sn(n.text,a,e.tabSize);r.push(ut.range(n.from+i,n.from+t))}}}return r}(e.state,n,o);return a.length?r?ut.create(a.concat(i.ranges)):ut.create(a):i}}:null}const $a={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},Ba={style:"cursor: crosshair"};function La(e={}){let[t,n]=$a[e.key||"Alt"],i=ys.fromClass(class{constructor(e){this.view=e,this.isDown=!1}set(e){this.isDown!=e&&(this.isDown=e,this.view.update([]))}},{eventObservers:{keydown(e){this.set(e.keyCode==t||n(e))},keyup(e){e.keyCode!=t&&n(e)||this.set(!1)},mousemove(e){this.set(n(e))}}});return[i,Fo.contentAttributes.of(e=>{var t;return(null===(t=e.plugin(i))||void 0===t?void 0:t.isDown)?Ba:null})]}const za="-10000px";class ja{constructor(e,t,n,i){this.facet=t,this.createTooltipView=n,this.removeTooltipView=i,this.input=e.state.facet(t),this.tooltips=this.input.filter(e=>e);let s=null;this.tooltipViews=this.tooltips.map(e=>s=n(e,s))}update(e,t){var n;let i=e.state.facet(this.facet),s=i.filter(e=>e);if(i===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let r=[],o=t?[]:null;for(let n=0;n<s.length;n++){let i=s[n],a=-1;if(i){for(let e=0;e<this.tooltips.length;e++){let t=this.tooltips[e];t&&t.create==i.create&&(a=e)}if(a<0)r[n]=this.createTooltipView(i,n?r[n-1]:null),o&&(o[n]=!!i.above);else{let i=r[n]=this.tooltipViews[a];o&&(o[n]=t[a]),i.update&&i.update(e)}}}for(let e of this.tooltipViews)r.indexOf(e)<0&&(this.removeTooltipView(e),null===(n=e.destroy)||void 0===n||n.call(e));return t&&(o.forEach((e,n)=>t[n]=e),t.length=o.length),this.input=i,this.tooltips=s,this.tooltipViews=r,!0}}function Wa(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const Ua=pt.define({combine:e=>{var t,n,i;return{position:Zn.ios?"absolute":(null===(t=e.find(e=>e.position))||void 0===t?void 0:t.position)||"fixed",parent:(null===(n=e.find(e=>e.parent))||void 0===n?void 0:n.parent)||null,tooltipSpace:(null===(i=e.find(e=>e.tooltipSpace))||void 0===i?void 0:i.tooltipSpace)||Wa}}}),Fa=new WeakMap,Va=ys.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(Ua);this.position=t.position,this.parent=t.parent,this.classes=e.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 ja(e,Ja,(e,t)=>this.createTooltip(e,t),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver="function"==typeof IntersectionObserver?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.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 e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,i=e.state.facet(Ua);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let e of this.manager.tooltipViews)e.dom.style.position=this.position;n=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let e of this.manager.tooltipViews)this.container.appendChild(e.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),i=t?t.dom:null;if(n.dom.classList.add("cm-tooltip"),e.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let e=document.createElement("div");e.className="cm-tooltip-arrow",n.dom.appendChild(e)}return n.dom.style.position=this.position,n.dom.style.top=za,n.dom.style.left="0px",this.container.insertBefore(n.dom,i),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),null===(e=t.destroy)||void 0===e||e.call(t);this.parent&&this.container.remove(),null===(t=this.resizeObserver)||void 0===t||t.disconnect(),null===(n=this.intersectionObserver)||void 0===n||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if("fixed"==this.position&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(Zn.safari){let t=e.getBoundingClientRect();n=Math.abs(t.top+1e4)>1||Math.abs(t.left)>1}else n=!!e.offsetParent&&e.offsetParent!=this.container.ownerDocument.body}if(n||"absolute"==this.position)if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(e=n.width/this.parent.offsetWidth,t=n.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);let i=this.view.scrollDOM.getBoundingClientRect(),s=Ms(this.view);return{visible:{left:i.left+s.left,top:i.top+s.top,right:i.right-s.right,bottom:i.bottom-s.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((e,t)=>{let n=this.manager.tooltipViews[t];return n.getCoords?n.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(Ua).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){var t;if(e.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let e of this.manager.tooltipViews)e.dom.style.position="absolute"}let{visible:n,space:i,scaleX:s,scaleY:r}=e,o=[];for(let a=0;a<this.manager.tooltips.length;a++){let l=this.manager.tooltips[a],c=this.manager.tooltipViews[a],{dom:h}=c,u=e.pos[a],d=e.size[a];if(!u||!1!==l.clip&&(u.bottom<=Math.max(n.top,i.top)||u.top>=Math.min(n.bottom,i.bottom)||u.right<Math.max(n.left,i.left)-.1||u.left>Math.min(n.right,i.right)+.1)){h.style.top=za;continue}let f=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=f?7:0,m=d.right-d.left,g=null!==(t=Fa.get(c))&&void 0!==t?t:d.bottom-d.top,y=c.offset||Ka,v=this.view.textDirection==Pi.LTR,b=d.width>i.right-i.left?v?i.left:i.right-d.width:v?Math.max(i.left,Math.min(u.left-(f?14:0)+y.x,i.right-m)):Math.min(Math.max(i.left,u.left-m+(f?14:0)-y.x),i.right-m),w=this.above[a];!l.strictSide&&(w?u.top-g-p-y.y<i.top:u.bottom+g+p+y.y>i.bottom)&&w==i.bottom-u.bottom>u.top-i.top&&(w=this.above[a]=!w);let k=(w?u.top-i.top:i.bottom-u.bottom)-p;if(k<g&&!1!==c.resize){if(k<this.view.defaultLineHeight){h.style.top=za;continue}Fa.set(c,g),h.style.height=(g=k)/r+"px"}else h.style.height&&(h.style.height="");let x=w?u.top-g-p-y.y:u.bottom+p+y.y,S=b+m;if(!0!==c.overlap)for(let e of o)e.left<S&&e.right>b&&e.top<x+g&&e.bottom>x&&(x=w?e.top-g-2-p:e.bottom+p+2);if("absolute"==this.position?(h.style.top=(x-e.parent.top)/r+"px",Ha(h,(b-e.parent.left)/s)):(h.style.top=x/r+"px",Ha(h,b/s)),f){let e=u.left+(v?y.x:-y.x)-(b+14-7);f.style.left=e/s+"px"}!0!==c.overlap&&o.push({left:b,top:x,right:S,bottom:x+g}),h.classList.toggle("cm-tooltip-above",w),h.classList.toggle("cm-tooltip-below",!w),c.positioned&&c.positioned(e.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 e of this.manager.tooltipViews)e.dom.style.top=za}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Ha(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}const qa=Fo.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"}}}),Ka={x:0,y:0},Ja=pt.define({enables:[Va,qa]}),Za=pt.define({combine:e=>e.reduce((e,t)=>e.concat(t),[])});class Ya{static create(e){return new Ya(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new ja(e,Za,(e,t)=>this.createHostedView(e,t),e=>e.dom.remove())}createHostedView(e,t){let n=e.create(this.view);return n.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(n.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)null===(e=t.destroy)||void 0===e||e.call(t)}passProp(e){let t;for(let n of this.manager.tooltipViews){let i=n[e];if(void 0!==i)if(void 0===t)t=i;else if(t!==i)return}return t}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 Ga=Ja.compute([Za],e=>{let t=e.facet(Za);return 0===t.length?null:{pos:Math.min(...t.map(e=>e.pos)),end:Math.max(...t.map(e=>{var t;return null!==(t=e.end)&&void 0!==t?t:e.pos})),create:Ya.create,above:t[0].above,arrow:t.some(e=>e.arrow)}});class Qa{constructor(e,t,n,i,s){this.view=e,this.source=t,this.field=n,this.setHover=i,this.hoverTime=s,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,n=e.docView.tile.nearest(t.target);if(!n)return;let i,s=1;if(n.isWidget())i=n.posAtStart;else{if(i=e.posAtCoords(t),null==i)return;let n=e.coordsAtPos(i);if(!n||t.y<n.top||t.y>n.bottom||t.x<n.left-e.defaultCharacterWidth||t.x>n.right+e.defaultCharacterWidth)return;let r=e.bidiSpans(e.state.doc.lineAt(i)).find(e=>e.from<=i&&e.to>=i),o=r&&r.dir==Pi.RTL?-1:1;s=t.x<n.left?-o:o}let r=this.source(e,i,s);if(null==r?void 0:r.then){let t=this.pending={pos:i};r.then(n=>{this.pending==t&&(this.pending=null,!n||Array.isArray(n)&&!n.length||e.dispatch({effects:this.setHover.of(Array.isArray(n)?n:[n])}))},t=>fs(e.state,t,"hover tooltip"))}else!r||Array.isArray(r)&&!r.length||e.dispatch({effects:this.setHover.of(Array.isArray(r)?r:[r])})}get tooltip(){let e=this.view.plugin(Va),t=e?e.manager.tooltips.findIndex(e=>e.create==Ya.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,n;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:s}=this;if(i.length&&s&&!function(e,t){let n,{left:i,right:s,top:r,bottom:o}=e.getBoundingClientRect();if(n=e.querySelector(".cm-tooltip-arrow")){let e=n.getBoundingClientRect();r=Math.min(e.top,r),o=Math.max(e.bottom,o)}return t.clientX>=i-Xa&&t.clientX<=s+Xa&&t.clientY>=r-Xa&&t.clientY<=o+Xa}(s.dom,e)||this.pending){let{pos:s}=i[0]||this.pending,r=null!==(n=null===(t=i[0])||void 0===t?void 0:t.end)&&void 0!==n?n:s;(s==r?this.view.posAtCoords(this.lastMove)==s:function(e,t,n,i,s){let r=e.scrollDOM.getBoundingClientRect(),o=e.documentTop+e.documentPadding.top+e.contentHeight;if(r.left>i||r.right<i||r.top>s||Math.min(r.bottom,o)<s)return!1;let a=e.posAtCoords({x:i,y:s},!1);return a>=t&&a<=n}(this.view,s,r,e.clientX,e.clientY))||(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length){let{tooltip:t}=this;t&&t.dom.contains(e.relatedTarget)?this.watchTooltipLeave(t.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=n=>{e.removeEventListener("mouseleave",t),this.active.length&&!this.view.dom.contains(n.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const Xa=4;function el(e,t={}){let n=Vt.define(),i=kt.define({create:()=>[],update(e,i){if(e.length&&(t.hideOnChange&&(i.docChanged||i.selection)?e=[]:t.hideOn&&(e=e.filter(e=>!t.hideOn(i,e))),i.docChanged)){let t=[];for(let n of e){let e=i.changes.mapPos(n.pos,-1,tt.TrackDel);if(null!=e){let s=Object.assign(Object.create(null),n);s.pos=e,null!=s.end&&(s.end=i.changes.mapPos(s.end)),t.push(s)}}e=t}for(let t of i.effects)t.is(n)&&(e=t.value),t.is(nl)&&(e=[]);return e},provide:e=>Za.from(e)});return{active:i,extension:[i,ys.define(s=>new Qa(s,e,i,n,t.hoverTime||300)),Ga]}}function tl(e,t){let n=e.plugin(Va);if(!n)return null;let i=n.manager.tooltips.indexOf(t);return i<0?null:n.manager.tooltipViews[i]}const nl=Vt.define(),il=pt.define({combine(e){let t,n;for(let i of e)t=t||i.topContainer,n=n||i.bottomContainer;return{topContainer:t,bottomContainer:n}}});function sl(e,t){let n=e.plugin(rl),i=n?n.specs.indexOf(t):-1;return i>-1?n.panels[i]:null}const rl=ys.fromClass(class{constructor(e){this.input=e.state.facet(ll),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(il);this.top=new ol(e,!0,t.topContainer),this.bottom=new ol(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top));for(let e of this.panels)e.dom.classList.add("cm-panel"),e.mount&&e.mount()}update(e){let t=e.state.facet(il);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new ol(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new ol(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(ll);if(n!=this.input){let t=n.filter(e=>e),i=[],s=[],r=[],o=[];for(let n of t){let t,a=this.specs.indexOf(n);a<0?(t=n(e.view),o.push(t)):(t=this.panels[a],t.update&&t.update(e)),i.push(t),(t.top?s:r).push(t)}this.specs=t,this.panels=i,this.top.sync(s),this.bottom.sync(r);for(let e of o)e.dom.classList.add("cm-panel"),e.mount&&e.mount()}else for(let t of this.panels)t.update&&t.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>Fo.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class ol{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(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",this.dom.style[this.top?"top":"bottom"]="0";let e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=al(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=al(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(this.container&&this.classes!=this.view.themeClasses){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function al(e){let t=e.nextSibling;return e.remove(),t}const ll=pt.define({enables:rl});function cl(e,t){let n,i=new Promise(e=>n=e),s=e=>function(e,t,n){let i=t.content?t.content(e,()=>o(null)):null;if(!i){if(i=$n("form"),t.input){let e=$n("input",t.input);/^(text|password|number|email|tel|url)$/.test(e.type)&&e.classList.add("cm-textfield"),e.name||(e.name="input"),i.appendChild($n("label",(t.label||"")+": ",e))}else i.appendChild(document.createTextNode(t.label||""));i.appendChild(document.createTextNode(" ")),i.appendChild($n("button",{class:"cm-button",type:"submit"},t.submitLabel||"OK"))}let s="FORM"==i.nodeName?[i]:i.querySelectorAll("form");for(let e=0;e<s.length;e++){let t=s[e];t.addEventListener("keydown",e=>{27==e.keyCode?(e.preventDefault(),o(null)):13==e.keyCode&&(e.preventDefault(),o(t))}),t.addEventListener("submit",e=>{e.preventDefault(),o(t)})}let r=$n("div",i,$n("button",{onclick:()=>o(null),"aria-label":e.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));t.class&&(r.className=t.class);function o(t){r.contains(r.ownerDocument.activeElement)&&e.focus(),n(t)}return r.classList.add("cm-dialog"),{dom:r,top:t.top,mount:()=>{if(t.focus){let e;e="string"==typeof t.focus?i.querySelector(t.focus):i.querySelector("input")||i.querySelector("button"),e&&"select"in e?e.select():e&&"focus"in e&&e.focus()}}}}(e,t,n);e.state.field(hl,!1)?e.dispatch({effects:ul.of(s)}):e.dispatch({effects:Vt.appendConfig.of(hl.init(()=>[s]))});let r=dl.of(s);return{close:r,result:i.then(t=>{let n=e.win.queueMicrotask||(t=>e.win.setTimeout(t,10));return n(()=>{e.state.field(hl).indexOf(s)>-1&&e.dispatch({effects:r})}),t})}}const hl=kt.define({create:()=>[],update(e,t){for(let n of t.effects)n.is(ul)?e=[n.value].concat(e):n.is(dl)&&(e=e.filter(e=>e!=n.value));return e},provide:e=>ll.computeN([e],t=>t.field(e))}),ul=Vt.define(),dl=Vt.define();class fl extends rn{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}fl.prototype.elementClass="",fl.prototype.toDOM=void 0,fl.prototype.mapMode=tt.TrackBefore,fl.prototype.startSide=fl.prototype.endSide=-1,fl.prototype.point=!0;const pl=pt.define(),ml=pt.define(),gl={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>hn.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},yl=pt.define();function vl(e){return[wl(),yl.of({...gl,...e})]}const bl=pt.define({combine:e=>e.some(e=>e)});function wl(e){return[kl]}const kl=ys.fromClass(class{constructor(e){this.view=e,this.domAfter=null,this.prevViewport=e.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=e.state.facet(yl).map(t=>new Al(e,t)),this.fixed=!e.state.facet(bl);for(let e of this.gutters)"after"==e.config.side?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.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(e){if(this.updateGutters(e)){let t=this.prevViewport,n=e.view.viewport,i=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(i<.8*(n.to-n.from))}if(e.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(bl)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=hn.iter(this.view.state.facet(pl),this.view.viewport.from),i=[],s=this.gutters.map(e=>new Cl(e,this.view.viewport,-this.view.documentPadding.top));for(let e of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(e.type)){let t=!0;for(let r of e.type)if(r.type==ni.Text&&t){Sl(n,i,r.from);for(let e of s)e.line(this.view,r,i);t=!1}else if(r.widget)for(let e of s)e.widget(this.view,r)}else if(e.type==ni.Text){Sl(n,i,e.from);for(let t of s)t.line(this.view,e,i)}else if(e.widget)for(let t of s)t.widget(this.view,e);for(let e of s)e.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(yl),n=e.state.facet(yl),i=e.docChanged||e.heightChanged||e.viewportChanged||!hn.eq(e.startState.facet(pl),e.state.facet(pl),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let t of this.gutters)t.update(e)&&(i=!0);else{i=!0;let s=[];for(let i of n){let n=t.indexOf(i);n<0?s.push(new Al(this.view,i)):(this.gutters[n].update(e),s.push(this.gutters[n]))}for(let e of this.gutters)e.dom.remove(),s.indexOf(e)<0&&e.destroy();for(let e of s)"after"==e.config.side?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.gutters=s}return i}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:e=>Fo.scrollMargins.of(t=>{let n=t.plugin(e);if(!n||0==n.gutters.length||!n.fixed)return null;let i=n.dom.offsetWidth*t.scaleX,s=n.domAfter?n.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==Pi.LTR?{left:i,right:s}:{right:i,left:s}})});function xl(e){return Array.isArray(e)?e:[e]}function Sl(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class Cl{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=hn.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:i}=this,s=(t.top-this.height)/e.scaleY,r=t.height/e.scaleY;if(this.i==i.elements.length){let t=new Tl(e,r,s,n);i.elements.push(t),i.dom.appendChild(t.dom)}else i.elements[this.i].update(e,r,s,n);this.height=t.bottom,this.i++}line(e,t,n){let i=[];Sl(this.cursor,i,t.from),n.length&&(i=i.concat(n));let s=this.gutter.config.lineMarker(e,t,i);s&&i.unshift(s);let r=this.gutter;(0!=i.length||r.config.renderEmptyElements)&&this.addElement(e,t,i)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),i=n?[n]:null;for(let n of e.state.facet(ml)){let s=n(e,t.widget,t);s&&(i||(i=[])).push(s)}i&&this.addElement(e,t,i)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class Al{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let n in t.domEventHandlers)this.dom.addEventListener(n,i=>{let s,r=i.target;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let e=r.getBoundingClientRect();s=(e.top+e.bottom)/2}else s=i.clientY;let o=e.lineBlockAtHeight(s-e.documentTop);t.domEventHandlers[n](e,o,i)&&i.preventDefault()});this.markers=xl(t.markers(e)),t.initialSpacer&&(this.spacer=new Tl(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=xl(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let t=this.config.updateSpacer(this.spacer.markers[0],e);t!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[t])}let n=e.view.viewport;return!hn.eq(this.markers,t,n.from,n.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(e)}destroy(){for(let e of this.elements)e.destroy()}}class Tl{constructor(e,t,n,i){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,n,i)}update(e,t,n,i){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),function(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].compare(t[n]))return!1;return!0}(this.markers,i)||this.setMarkers(e,i)}setMarkers(e,t){let n="cm-gutterElement",i=this.dom.firstChild;for(let s=0,r=0;;){let o=r,a=s<t.length?t[s++]:null,l=!1;if(a){let e=a.elementClass;e&&(n+=" "+e);for(let e=r;e<this.markers.length;e++)if(this.markers[e].compare(a)){o=e,l=!0;break}}else o=this.markers.length;for(;r<o;){let e=this.markers[r++];if(e.toDOM){e.destroy(i);let t=i.nextSibling;i.remove(),i=t}}if(!a)break;a.toDOM&&(l?i=i.nextSibling:this.dom.insertBefore(a.toDOM(e),i)),l&&r++}this.dom.className=n,this.markers=t}destroy(){this.setMarkers(null,[])}}const Ol=pt.define(),Ml=pt.define(),El=pt.define({combine:e=>sn(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let n=Object.assign({},e);for(let e in t){let i=n[e],s=t[e];n[e]=i?(e,t,n)=>i(e,t,n)||s(e,t,n):s}return n}})});class Nl extends fl{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Dl(e,t){return e.state.facet(El).formatNumber(t,e.state)}const _l=yl.compute([El],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:e=>e.state.facet(Ol),lineMarker:(e,t,n)=>n.some(e=>e.toDOM)?null:new Nl(Dl(e,e.state.doc.lineAt(t.from).number)),widgetMarker:(e,t,n)=>{for(let i of e.state.facet(Ml)){let s=i(e,t,n);if(s)return s}return null},lineMarkerChange:e=>e.startState.facet(El)!=e.state.facet(El),initialSpacer:e=>new Nl(Dl(e,Il(e.state.doc.lines))),updateSpacer(e,t){let n=Dl(t.view,Il(t.view.state.doc.lines));return n==e.number?e:new Nl(n)},domEventHandlers:e.facet(El).domEventHandlers,side:"before"}));function Pl(e={}){return[El.of(e),wl(),_l]}function Il(e){let t=9;for(;t<e;)t=10*t+9;return t}const Rl=new class extends fl{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},$l=pl.compute(["selection"],e=>{let t=[],n=-1;for(let i of e.selection.ranges){let s=e.doc.lineAt(i.head).from;s>n&&(n=s,t.push(Rl.range(s)))}return hn.of(t)});var Bl;const Ll=new s;const zl=new s;class jl{constructor(e,t,n=[],i=""){this.data=e,this.name=i,nn.prototype.hasOwnProperty("tree")||Object.defineProperty(nn.prototype,"tree",{get(){return Fl(this)}}),this.parser=t,this.extension=[Ql.of(this),nn.languageData.of((e,t,n)=>{let i=Wl(e,t,n),s=i.type.prop(Ll);if(!s)return[];let r=e.facet(s),o=i.type.prop(zl);if(o){let s=i.resolve(t-i.from,n);for(let t of o)if(t.test(s,e)){let n=e.facet(t.facet);return"replace"==t.type?n:n.concat(r)}}return r})].concat(n)}isActiveAt(e,t,n=-1){return Wl(e,t,n).type.prop(Ll)==this.data}findRegions(e){let t=e.facet(Ql);if((null==t?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],i=(e,t)=>{if(e.prop(Ll)==this.data)return void n.push({from:t,to:t+e.length});let r=e.prop(s.mounted);if(r){if(r.tree.prop(Ll)==this.data){if(r.overlay)for(let e of r.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}if(r.overlay){let e=n.length;if(i(r.tree,r.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let s=e.children[n];s instanceof d&&i(s,e.positions[n]+t)}};return i(Fl(e),0),n}get allowsNesting(){return!0}}function Wl(e,t,n){let i=e.facet(Ql),s=Fl(e).topNode;if(!i||i.allowsNesting)for(let e=s;e;e=e.enter(t,n,u.ExcludeBuffers|u.EnterBracketed))e.type.isTop&&(s=e);return s}jl.setState=Vt.define();class Ul extends jl{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(e){let t=(n=e.languageData,pt.define({combine:n?e=>e.concat(n):void 0}));var n;return new Ul(t,e.parser.configure({props:[Ll.add(e=>e.isTop?t:void 0)]}),e.name)}configure(e,t){return new Ul(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Fl(e){let t=e.field(jl.state,!1);return t?t.tree:d.empty}class Vl{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}}let Hl=null;class ql{constructor(e,t,n=[],i,s,r,o,a){this.parser=e,this.state=t,this.fragments=n,this.tree=i,this.treeLen=s,this.viewport=r,this.skipped=o,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new ql(e,t,[],d.empty,0,n,[],null)}startParse(){return this.parser.startParse(new Vl(this.state.doc),this.fragments)}work(e,t){return null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=d.empty&&this.isDone(null!=t?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if("number"==typeof e){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||(this.parse=this.startParse()),null!=t&&(null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let i=this.parse.advance();if(i){if(this.fragments=this.withoutTempSkipped(N.addTree(i,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(n=this.parse.stoppedAt)&&void 0!==n?n:this.state.doc.length,this.tree=i,this.parse=null,!(this.treeLen<(null!=t?t:this.state.doc.length)))return!0;this.parse=this.startParse()}if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(N.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Hl;Hl=this;try{return e()}finally{Hl=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Kl(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:i,treeLen:s,viewport:r,skipped:o}=this;if(this.takeTree(),!e.empty){let t=[];if(e.iterChangedRanges((e,n,i,s)=>t.push({fromA:e,toA:n,fromB:i,toB:s})),n=N.applyChanges(n,t),i=d.empty,s=0,r={from:e.mapPos(r.from,-1),to:e.mapPos(r.to,1)},this.skipped.length){o=[];for(let t of this.skipped){let n=e.mapPos(t.from,1),i=e.mapPos(t.to,-1);n<i&&o.push({from:n,to:i})}}}return new ql(this.parser,t,n,i,s,r,o,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let t=0;t<this.skipped.length;t++){let{from:n,to:i}=this.skipped[t];n<e.to&&i>e.from&&(this.fragments=Kl(this.fragments,n,i),this.skipped.splice(t--,1))}return!(this.skipped.length>=t)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends D{createParse(t,n,i){let s=i[0].from,r=i[i.length-1].to,o={parsedPos:s,advance(){let t=Hl;if(t){for(let e of i)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=r,new d(a.none,[],[],r-s)},stoppedAt:null,stopAt(){}};return o}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&0==t[0].from&&t[0].to>=e}static get(){return Hl}}function Kl(e,t,n){return N.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class Jl{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new Jl(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=ql.create(e.facet(Ql).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new Jl(n)}}jl.state=kt.define({create:Jl.init,update(e,t){for(let e of t.effects)if(e.is(jl.setState))return e.value;return t.startState.facet(Ql)!=t.state.facet(Ql)?Jl.init(t.state):e.apply(t)}});let Zl=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};"undefined"!=typeof requestIdleCallback&&(Zl=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const Yl="undefined"!=typeof navigator&&(null===(Bl=navigator.scheduling)||void 0===Bl?void 0:Bl.isInputPending)?()=>navigator.scheduling.isInputPending():null,Gl=ys.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(jl.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(jl.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=Zl(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:i}}=this.view,s=n.field(jl.state);if(s.tree==s.context.tree&&s.context.isDone(i+1e5))return;let r=Date.now()+Math.min(this.chunkBudget,100,e&&!Yl?Math.max(25,e.timeRemaining()-5):1e9),o=s.context.treeLen<i&&n.doc.length>i+1e3,a=s.context.work(()=>Yl&&Yl()||Date.now()>r,i+(o?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:jl.setState.of(new Jl(s.context))})),this.chunkBudget>0&&(!a||o)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>fs(this.view.state,e)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Ql=pt.define({combine:e=>e.length?e[0]:null,enables:e=>[jl.state,Gl,Fo.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});class Xl{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const ec=pt.define(),tc=pt.define({combine:e=>{if(!e.length)return" ";let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return t}});function nc(e){let t=e.facet(tc);return 9==t.charCodeAt(0)?e.tabSize*t.length:t.length}function ic(e,t){let n="",i=e.tabSize,s=e.facet(tc)[0];if("\t"==s){for(;t>=i;)n+="\t",t-=i;s=" "}for(let e=0;e<t;e++)n+=s;return n}function sc(e,t){e instanceof nn&&(e=new rc(e));for(let n of e.state.facet(ec)){let i=n(e,t);if(void 0!==i)return i}let n=Fl(e.state);return n.length>=t?function(e,t,n){let i=t.resolveStack(n),s=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(s!=i.node){let e=[];for(let t=s;t&&!(t.from<i.node.from||t.to>i.node.to||t.from==i.node.from&&t.type==i.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)i={node:e[t],next:i}}return ac(i,e,n)}(e,n,t):null}class rc{constructor(e,t={}){this.state=e,this.options=t,this.unit=nc(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:i,simulateDoubleBreak:s}=this.options;return null!=i&&i>=n.from&&i<=n.to?s&&i==e?{text:"",from:e}:(t<0?i<e:i<=e)?{text:n.text.slice(i-n.from),from:i}:{text:n.text.slice(0,i-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:i}=this.lineAt(e,t);return n.slice(e-i,Math.min(n.length,e+100-i))}column(e,t=1){let{text:n,from:i}=this.lineAt(e,t),s=this.countColumn(n,e-i),r=this.options.overrideIndentation?this.options.overrideIndentation(i):-1;return r>-1&&(s+=r-this.countColumn(n,n.search(/\S|$/))),s}countColumn(e,t=e.length){return xn(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:i}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let e=s(i);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const oc=new s;function ac(e,t,n){for(let i=e;i;i=i.next){let e=lc(i.node);if(e)return e(hc.create(t,n,i))}return 0}function lc(e){let t=e.type.prop(oc);if(t)return t;let n,i=e.firstChild;if(i&&(n=i.type.prop(s.closedBy))){let t=e.lastChild,i=t&&n.indexOf(t.name)>-1;return e=>function(e,t,n,i,s){let r=e.textAfter,o=r.match(/^\s*/)[0].length,a=i&&r.slice(o,o+i.length)==i||s==e.pos+o,l=function(e){let t=e.node,n=t.childAfter(t.from),i=t.lastChild;if(!n)return null;let s=e.options.simulateBreak,r=e.state.doc.lineAt(n.from),o=null==s||s<=r.from?r.to:Math.min(r.to,s);for(let e=n.to;;){let s=t.childAfter(e);if(!s||s==i)return null;if(!s.type.isSkipped){if(s.from>=o)return null;let e=/^ */.exec(r.text.slice(n.to-r.from))[0].length;return{from:n.from,to:n.to+e}}e=s.to}}(e);return l?a?e.column(l.from):e.column(l.to):e.baseIndent+(a?0:e.unit*n)}(e,0,1,void 0,i&&!function(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}(e)?t.from:void 0)}return null==e.parent?cc:null}function cc(){return 0}class hc extends rc{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(e,t,n){return new hc(e,t,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(uc(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return ac(this.context.next,this.base,this.pos)}}function uc(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function dc({except:e,units:t=1}={}){return n=>{let i=e&&e.test(n.textAfter);return n.baseIndent+(i?0:t*n.unit)}}const fc=pt.define(),pc=new s;function mc(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function gc(e,t,n){for(let i of e.facet(fc)){let s=i(e,t,n);if(s)return s}return function(e,t,n){let i=Fl(e);if(i.length<n)return null;let s=null;for(let r=i.resolveStack(n,1);r;r=r.next){let o=r.node;if(o.to<=n||o.from>n)continue;if(s&&o.from<t)break;let a=o.type.prop(pc);if(a&&(o.to<i.length-50||i.length==e.doc.length||!mc(o))){let i=a(o,e);i&&i.from<=n&&i.from>=t&&i.to>n&&(s=i)}}return s}(e,t,n)}function yc(e,t){let n=t.mapPos(e.from,1),i=t.mapPos(e.to,-1);return n>=i?void 0:{from:n,to:i}}const vc=Vt.define({map:yc}),bc=Vt.define({map:yc});function wc(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(e=>e.from<=n&&e.to>=n)||t.push(e.lineBlockAt(n));return t}const kc=kt.define({create:()=>ii.none,update(e,t){t.isUserEvent("delete")&&t.changes.iterChangedRanges((t,n)=>e=xc(e,t,n)),e=e.map(t.changes);for(let n of t.effects)if(n.is(vc)&&!Cc(e,n.value.from,n.value.to)){let{preparePlaceholder:i}=t.state.facet(Ec),s=i?ii.replace({widget:new Pc(i(t.state,n.value))}):_c;e=e.update({add:[s.range(n.value.from,n.value.to)]})}else n.is(bc)&&(e=e.update({filter:(e,t)=>n.value.from!=e||n.value.to!=t,filterFrom:n.value.from,filterTo:n.value.to}));return t.selection&&(e=xc(e,t.selection.main.head)),e},provide:e=>Fo.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(e,t)=>{n.push(e,t)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw new RangeError("Invalid JSON for fold state");let t=[];for(let n=0;n<e.length;){let i=e[n++],s=e[n++];if("number"!=typeof i||"number"!=typeof s)throw new RangeError("Invalid JSON for fold state");t.push(_c.range(i,s))}return ii.set(t,!0)}});function xc(e,t,n=t){let i=!1;return e.between(t,n,(e,s)=>{e<n&&s>t&&(i=!0)}),i?e.update({filterFrom:t,filterTo:n,filter:(e,i)=>e>=n||i<=t}):e}function Sc(e,t,n){var i;let s=null;return null===(i=e.field(kc,!1))||void 0===i||i.between(t,n,(e,t)=>{(!s||s.from>e)&&(s={from:e,to:t})}),s}function Cc(e,t,n){let i=!1;return e.between(t,t,(e,s)=>{e==t&&s==n&&(i=!0)}),i}function Ac(e,t){return e.field(kc,!1)?t:t.concat(Vt.appendConfig.of(Nc()))}function Tc(e,t,n=!0){let i=e.state.doc.lineAt(t.from).number,s=e.state.doc.lineAt(t.to).number;return Fo.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${i} ${e.state.phrase("to")} ${s}.`)}const Oc=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:e=>{for(let t of wc(e)){let n=gc(e.state,t.from,t.to);if(n)return e.dispatch({effects:Ac(e.state,[vc.of(n),Tc(e,n)])}),!0}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:e=>{if(!e.state.field(kc,!1))return!1;let t=[];for(let n of wc(e)){let i=Sc(e.state,n.from,n.to);i&&t.push(bc.of(i),Tc(e,i,!1))}return t.length&&e.dispatch({effects:t}),t.length>0}},{key:"Ctrl-Alt-[",run:e=>{let{state:t}=e,n=[];for(let i=0;i<t.doc.length;){let s=e.lineBlockAt(i),r=gc(t,s.from,s.to);r&&n.push(vc.of(r)),i=(r?e.lineBlockAt(r.to):s).to+1}return n.length&&e.dispatch({effects:Ac(e.state,n)}),!!n.length}},{key:"Ctrl-Alt-]",run:e=>{let t=e.state.field(kc,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(e,t)=>{n.push(bc.of({from:e,to:t}))}),e.dispatch({effects:n}),!0}}],Mc={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Ec=pt.define({combine:e=>sn(e,Mc)});function Nc(e){return[kc,Bc]}function Dc(e,t){let{state:n}=e,i=n.facet(Ec),s=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),i=Sc(e.state,n.from,n.to);i&&e.dispatch({effects:bc.of(i)}),t.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(e,s,t);let r=document.createElement("span");return r.textContent=i.placeholderText,r.setAttribute("aria-label",n.phrase("folded code")),r.title=n.phrase("unfold"),r.className="cm-foldPlaceholder",r.onclick=s,r}const _c=ii.replace({widget:new class extends ti{toDOM(e){return Dc(e,null)}}});class Pc extends ti{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return Dc(e,this.value)}}const Ic={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class Rc extends fl{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function $c(e={}){let t={...Ic,...e},n=new Rc(t,!0),i=new Rc(t,!1),s=ys.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(Ql)!=e.state.facet(Ql)||e.startState.field(kc,!1)!=e.state.field(kc,!1)||Fl(e.startState)!=Fl(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new un;for(let s of e.viewportLineBlocks){let r=Sc(e.state,s.from,s.to)?i:gc(e.state,s.from,s.to)?n:null;r&&t.add(s.from,s.from,r)}return t.finish()}}),{domEventHandlers:r}=t;return[s,vl({class:"cm-foldGutter",markers(e){var t;return(null===(t=e.plugin(s))||void 0===t?void 0:t.markers)||hn.empty},initialSpacer:()=>new Rc(t,!1),domEventHandlers:{...r,click:(e,t,n)=>{if(r.click&&r.click(e,t,n))return!0;let i=Sc(e.state,t.from,t.to);if(i)return e.dispatch({effects:bc.of(i)}),!0;let s=gc(e.state,t.from,t.to);return!!s&&(e.dispatch({effects:vc.of(s)}),!0)}}}),Nc()]}const Bc=Fo.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 Lc{constructor(e,t){let n;function i(e){let t=On.newName();return(n||(n=Object.create(null)))["."+t]=e,t}this.specs=e;const s="string"==typeof t.all?t.all:t.all?i(t.all):void 0,r=t.scope;this.scope=r instanceof jl?e=>e.prop(Ll)==r.data:r?e=>e==r:void 0,this.style=le(e.map(e=>({tag:e.tag,class:e.class||i(Object.assign({},e,{tag:null}))})),{all:s}).style,this.module=n?new On(n):null,this.themeType=t.themeType}static define(e,t){return new Lc(e,t||{})}}const zc=pt.define(),jc=pt.define({combine:e=>e.length?[e[0]]:null});function Wc(e){let t=e.facet(zc);return t.length?t:e.facet(jc)}function Uc(e,t){let n,i=[Vc];return e instanceof Lc&&(e.module&&i.push(Fo.styleModule.of(e.module)),n=e.themeType),(null==t?void 0:t.fallback)?i.push(jc.of(e)):n?i.push(zc.computeN([Fo.darkTheme],t=>t.facet(Fo.darkTheme)==("dark"==n)?[e]:[])):i.push(zc.of(e)),i}class Fc{constructor(e){this.markCache=Object.create(null),this.tree=Fl(e.state),this.decorations=this.buildDeco(e,Wc(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=Fl(e.state),n=Wc(e.state),i=n!=Wc(e.startState),{viewport:s}=e.view,r=e.changes.mapPos(this.decoratedTo,1);t.length<s.to&&!i&&t.type==this.tree.type&&r>=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=r):(t!=this.tree||e.viewportChanged||i)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=s.to)}buildDeco(e,t){if(!t||!this.tree.length)return ii.none;let n=new un;for(let{from:i,to:s}of e.visibleRanges)ce(this.tree,t,(e,t,i)=>{n.add(e,t,this.markCache[i]||(this.markCache[i]=ii.mark({class:i})))},i,s);return n.finish()}}const Vc=Ot.high(ys.fromClass(Fc,{decorations:e=>e.decorations})),Hc=Lc.define([{tag:Te.meta,color:"#404740"},{tag:Te.link,textDecoration:"underline"},{tag:Te.heading,textDecoration:"underline",fontWeight:"bold"},{tag:Te.emphasis,fontStyle:"italic"},{tag:Te.strong,fontWeight:"bold"},{tag:Te.strikethrough,textDecoration:"line-through"},{tag:Te.keyword,color:"#708"},{tag:[Te.atom,Te.bool,Te.url,Te.contentSeparator,Te.labelName],color:"#219"},{tag:[Te.literal,Te.inserted],color:"#164"},{tag:[Te.string,Te.deleted],color:"#a11"},{tag:[Te.regexp,Te.escape,Te.special(Te.string)],color:"#e40"},{tag:Te.definition(Te.variableName),color:"#00f"},{tag:Te.local(Te.variableName),color:"#30a"},{tag:[Te.typeName,Te.namespace],color:"#085"},{tag:Te.className,color:"#167"},{tag:[Te.special(Te.variableName),Te.macroName],color:"#256"},{tag:Te.definition(Te.propertyName),color:"#00c"},{tag:Te.comment,color:"#940"},{tag:Te.invalid,color:"#f00"}]),qc=Fo.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Kc="()[]{}",Jc=pt.define({combine:e=>sn(e,{afterCursor:!0,brackets:Kc,maxScanDistance:1e4,renderMatch:Gc})}),Zc=ii.mark({class:"cm-matchingBracket"}),Yc=ii.mark({class:"cm-nonmatchingBracket"});function Gc(e){let t=[],n=e.matched?Zc:Yc;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}function Qc(e){let t=[],n=e.facet(Jc);for(let i of e.selection.ranges){if(!i.empty)continue;let s=rh(e,i.head,-1,n)||i.head>0&&rh(e,i.head-1,1,n)||n.afterCursor&&(rh(e,i.head,1,n)||i.head<e.doc.length&&rh(e,i.head+1,-1,n));s&&(t=t.concat(n.renderMatch(s,e)))}return ii.set(t,!0)}const Xc=ys.fromClass(class{constructor(e){this.paused=!1,this.decorations=Qc(e.state)}update(e){(e.docChanged||e.selectionSet||this.paused)&&(e.view.composing?(this.decorations=this.decorations.map(e.changes),this.paused=!0):(this.decorations=Qc(e.state),this.paused=!1))}},{decorations:e=>e.decorations}),eh=[Xc,qc];function th(e={}){return[Jc.of(e),eh]}const nh=new s;function ih(e,t,n){let i=e.prop(t<0?s.openedBy:s.closedBy);if(i)return i;if(1==e.name.length){let i=n.indexOf(e.name);if(i>-1&&i%2==(t<0?1:0))return[n[i+t]]}return null}function sh(e){let t=e.type.prop(nh);return t?t(e.node):e}function rh(e,t,n,i={}){let s=i.maxScanDistance||1e4,r=i.brackets||Kc,o=Fl(e),a=o.resolveInner(t,n);for(let i=a;i;i=i.parent){let s=ih(i.type,n,r);if(s&&i.from<i.to){let o=sh(i);if(o&&(n>0?t>=o.from&&t<o.to:t>o.from&&t<=o.to))return oh(e,t,n,i,o,s,r)}}return function(e,t,n,i,s,r,o){if(n<0?!t:t==e.doc.length)return null;let a=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),l=o.indexOf(a);if(l<0||l%2==0!=n>0)return null;let c={from:n<0?t-1:t,to:n>0?t+1:t},h=e.doc.iterRange(t,n>0?e.doc.length:0),u=0;for(let e=0;!h.next().done&&e<=r;){let r=h.value;n<0&&(e+=r.length);let a=t+e*n;for(let e=n>0?0:r.length-1,t=n>0?r.length:-1;e!=t;e+=n){let t=o.indexOf(r[e]);if(!(t<0||i.resolveInner(a+e,1).type!=s))if(t%2==0==n>0)u++;else{if(1==u)return{start:c,end:{from:a+e,to:a+e+1},matched:t>>1==l>>1};u--}}n>0&&(e+=r.length)}return h.done?{start:c,matched:!1}:null}(e,t,n,o,a.type,s,r)}function oh(e,t,n,i,s,r,o){let a=i.parent,l={from:s.from,to:s.to},c=0,h=null==a?void 0:a.cursor();if(h&&(n<0?h.childBefore(i.from):h.childAfter(i.to)))do{if(n<0?h.to<=i.from:h.from>=i.to){if(0==c&&r.indexOf(h.type.name)>-1&&h.from<h.to){let e=sh(h);return{start:l,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}if(ih(h.type,n,o))c++;else if(ih(h.type,-n,o)){if(0==c){let e=sh(h);return{start:l,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}c--}}}while(n<0?h.prevSibling():h.nextSibling());return{start:l,matched:!1}}const ah=Object.create(null),lh=[a.none],ch=[],hh=Object.create(null),uh=Object.create(null);for(let[e,t]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"]])uh[e]=fh(ah,t);function dh(e,t){ch.indexOf(e)>-1||(ch.push(e),console.warn(t))}function fh(e,t){let n=[];for(let i of t.split(" ")){let t=[];for(let n of i.split(".")){let i=e[n]||Te[n];i?"function"==typeof i?t.length?t=t.map(i):dh(n,`Modifier ${n} used at start of tag`):t.length?dh(n,`Tag ${n} used as modifier`):t=Array.isArray(i)?i:[i]:dh(n,`Unknown highlighting tag ${n}`)}for(let e of t)n.push(e)}if(!n.length)return 0;let i=t.replace(/ /g,"_"),s=i+" "+n.map(e=>e.id),r=hh[s];if(r)return r.id;let o=hh[s]=a.define({id:lh.length,name:i,props:[re({[i]:n})]});return lh.push(o),o.id}Pi.RTL,Pi.LTR;const ph=Ul.define({name:"json",parser:Me.configure({props:[oc.add({Object:dc({except:/^\s*\}/}),Array:dc({except:/^\s*\]/})}),pc.add({"Object Array":function(e){let t=e.firstChild,n=e.lastChild;return t&&t.to<n.from?{from:t.to,to:n.type.isError?e.to:n.from}:null}})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function mh(){return new Xl(ph)}function gh(e,t){return({state:n,dispatch:i})=>{if(n.readOnly)return!1;let s=e(t,n);return!!s&&(i(n.update(s)),!0)}}const yh=gh(Sh,0),vh=gh(xh,0),bh=gh((e,t)=>xh(e,t,function(e){let t=[];for(let n of e.selection.ranges){let i=e.doc.lineAt(n.from),s=n.to<=i.to?i:e.doc.lineAt(n.to);s.from>i.from&&s.from==n.to&&(s=n.to==i.to+1?i:e.doc.lineAt(n.to-1));let r=t.length-1;r>=0&&t[r].to>i.from?t[r].to=s.to:t.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:s.to})}return t}(t)),0);function wh(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}const kh=50;function xh(e,t,n=t.selection.ranges){let i=n.map(e=>wh(t,e.from).block);if(!i.every(e=>e))return null;let s=n.map((e,n)=>function(e,{open:t,close:n},i,s){let r,o,a=e.sliceDoc(i-kh,i),l=e.sliceDoc(s,s+kh),c=/\s*$/.exec(a)[0].length,h=/^\s*/.exec(l)[0].length,u=a.length-c;if(a.slice(u-t.length,u)==t&&l.slice(h,h+n.length)==n)return{open:{pos:i-c,margin:c&&1},close:{pos:s+h,margin:h&&1}};s-i<=2*kh?r=o=e.sliceDoc(i,s):(r=e.sliceDoc(i,i+kh),o=e.sliceDoc(s-kh,s));let d=/^\s*/.exec(r)[0].length,f=/\s*$/.exec(o)[0].length,p=o.length-f-n.length;return r.slice(d,d+t.length)==t&&o.slice(p,p+n.length)==n?{open:{pos:i+d+t.length,margin:/\s/.test(r.charAt(d+t.length))?1:0},close:{pos:s-f-n.length,margin:/\s/.test(o.charAt(p-1))?1:0}}:null}(t,i[n],e.from,e.to));if(2!=e&&!s.every(e=>e))return{changes:t.changes(n.map((e,t)=>s[t]?[]:[{from:e.from,insert:i[t].open+" "},{from:e.to,insert:" "+i[t].close}]))};if(1!=e&&s.some(e=>e)){let e=[];for(let t,n=0;n<s.length;n++)if(t=s[n]){let s=i[n],{open:r,close:o}=t;e.push({from:r.pos-s.open.length,to:r.pos+r.margin},{from:o.pos-o.margin,to:o.pos+s.close.length})}return{changes:e}}return null}function Sh(e,t,n=t.selection.ranges){let i=[],s=-1;e:for(let{from:e,to:r}of n){let n,o=i.length,a=1e9;for(let o=e;o<=r;){let l=t.doc.lineAt(o);if(null==n&&(n=wh(t,l.from).line,!n))continue e;if(l.from>s&&(e==r||r>l.from)){s=l.from;let e=/^\s*/.exec(l.text)[0].length,t=e==l.length,r=l.text.slice(e,e+n.length)==n?e:-1;e<l.text.length&&e<a&&(a=e),i.push({line:l,comment:r,token:n,indent:e,empty:t,single:!1})}o=l.to+1}if(a<1e9)for(let e=o;e<i.length;e++)i[e].indent<i[e].line.text.length&&(i[e].indent=a);i.length==o+1&&(i[o].single=!0)}if(2!=e&&i.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:s,empty:r,single:o}of i)!o&&r||e.push({from:t.from+s,insert:n+" "});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(1!=e&&i.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:s}of i)if(n>=0){let i=t.from+n,r=i+s.length;" "==t.text[r-t.from]&&r++,e.push({from:i,to:r})}return{changes:e}}return null}const Ch=Wt.define(),Ah=Wt.define(),Th=pt.define(),Oh=pt.define({combine:e=>sn(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,i)=>e(n,i)||t(n,i)})}),Mh=kt.define({create:()=>Hh.empty,update(e,t){let n=t.state.facet(Oh),i=t.annotation(Ch);if(i){let s=Rh.fromTransaction(t,i.selection),r=i.side,o=0==r?e.undone:e.done;return o=s?$h(o,o.length,n.minDepth,s):jh(o,t.startState.selection),new Hh(0==r?i.rest:o,0==r?o:i.rest)}let s=t.annotation(Ah);if("full"!=s&&"before"!=s||(e=e.isolate()),!1===t.annotation(Ht.addToHistory))return t.changes.empty?e:e.addMapping(t.changes.desc);let r=Rh.fromTransaction(t),o=t.annotation(Ht.time),a=t.annotation(Ht.userEvent);return r?e=e.addChanges(r,o,a,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,a,n.newGroupDelay)),"full"!=s&&"after"!=s||(e=e.isolate()),e},toJSON:e=>({done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}),fromJSON:e=>new Hh(e.done.map(Rh.fromJSON),e.undone.map(Rh.fromJSON))});function Eh(e={}){return[Mh,Oh.of(e),Fo.domEventHandlers({beforeinput(e,t){let n="historyUndo"==e.inputType?Dh:"historyRedo"==e.inputType?_h:null;return!!n&&(e.preventDefault(),n(t))}})]}function Nh(e,t){return function({state:n,dispatch:i}){if(!t&&n.readOnly)return!1;let s=n.field(Mh,!1);if(!s)return!1;let r=s.pop(e,n,t);return!!r&&(i(r),!0)}}const Dh=Nh(0,!1),_h=Nh(1,!1),Ph=Nh(0,!0),Ih=Nh(1,!0);class Rh{constructor(e,t,n,i,s){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=i,this.selectionsAfter=s}setSelAfter(e){return new Rh(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:null===(e=this.changes)||void 0===e?void 0:e.toJSON(),mapped:null===(t=this.mapped)||void 0===t?void 0:t.toJSON(),startSelection:null===(n=this.startSelection)||void 0===n?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(e){return new Rh(e.changes&&it.fromJSON(e.changes),[],e.mapped&&nt.fromJSON(e.mapped),e.startSelection&&ut.fromJSON(e.startSelection),e.selectionsAfter.map(ut.fromJSON))}static fromTransaction(e,t){let n=Lh;for(let t of e.startState.facet(Th)){let i=t(e);i.length&&(n=n.concat(i))}return!n.length&&e.changes.empty?null:new Rh(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,Lh)}static selection(e){return new Rh(void 0,Lh,void 0,void 0,e)}}function $h(e,t,n,i){let s=t+1>n+20?t-n-1:0,r=e.slice(s,t);return r.push(i),r}function Bh(e,t){return e.length?t.length?e.concat(t):e:t}const Lh=[],zh=200;function jh(e,t){if(e.length){let n=e[e.length-1],i=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-zh));return i.length&&i[i.length-1].eq(t)?e:(i.push(t),$h(e,e.length-1,1e9,n.setSelAfter(i)))}return[Rh.selection([t])]}function Wh(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function Uh(e,t){if(!e.length)return e;let n=e.length,i=Lh;for(;n;){let s=Fh(e[n-1],t,i);if(s.changes&&!s.changes.empty||s.effects.length){let t=e.slice(0,n);return t[n-1]=s,t}t=s.mapped,n--,i=s.selectionsAfter}return i.length?[Rh.selection(i)]:Lh}function Fh(e,t,n){let i=Bh(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):Lh,n);if(!e.changes)return Rh.selection(i);let s=e.changes.map(t),r=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(r):r;return new Rh(s,Vt.mapEffects(e.effects,t),o,e.startSelection.map(r),i)}const Vh=/^(input\.type|delete)($|\.)/;class Hh{constructor(e,t,n=0,i=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=i}isolate(){return this.prevTime?new Hh(this.done,this.undone):this}addChanges(e,t,n,i,s){let r=this.done,o=r[r.length-1];return r=o&&o.changes&&!o.changes.empty&&e.changes&&(!n||Vh.test(n))&&(!o.selectionsAfter.length&&t-this.prevTime<i.newGroupDelay&&i.joinToEvent(s,function(e,t){let n=[],i=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,s,r)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];r>=t&&s<=o&&(i=!0)}}),i}(o.changes,e.changes))||"input.type.compose"==n)?$h(r,r.length-1,i.minDepth,new Rh(e.changes.compose(o.changes),Bh(Vt.mapEffects(e.effects,o.changes),o.effects),o.mapped,o.startSelection,Lh)):$h(r,r.length,i.minDepth,e),new Hh(r,Lh,t,n)}addSelection(e,t,n,i){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:Lh;return s.length>0&&t-this.prevTime<i&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&function(e,t){return e.ranges.length==t.ranges.length&&0===e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length}(s[s.length-1],e)?this:new Hh(jh(this.done,e),this.undone,t,n)}addMapping(e){return new Hh(Uh(this.done,e),Uh(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let i=0==e?this.done:this.undone;if(0==i.length)return null;let s=i[i.length-1],r=s.selectionsAfter[0]||(s.startSelection?s.startSelection.map(s.changes.invertedDesc,1):t.selection);if(n&&s.selectionsAfter.length)return t.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:Ch.of({side:e,rest:Wh(i),selection:r}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let n=1==i.length?Lh:i.slice(0,i.length-1);return s.mapped&&(n=Uh(n,s.mapped)),t.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:Ch.of({side:e,rest:n,selection:r}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}return null}}Hh.empty=new Hh(Lh,Lh);const qh=[{key:"Mod-z",run:Dh,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:_h,preventDefault:!0},{linux:"Ctrl-Shift-z",run:_h,preventDefault:!0},{key:"Mod-u",run:Ph,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Ih,preventDefault:!0}];function Kh(e,t){return ut.create(e.ranges.map(t),e.mainIndex)}function Jh(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function Zh({state:e,dispatch:t},n){let i=Kh(e.selection,n);return!i.eq(e.selection,!0)&&(t(Jh(e,i)),!0)}function Yh(e,t){return ut.cursor(t?e.to:e.from)}function Gh(e,t){return Zh(e,n=>n.empty?e.moveByChar(n,t):Yh(n,t))}function Qh(e){return e.textDirectionAt(e.state.selection.main.head)==Pi.LTR}const Xh=e=>Gh(e,!Qh(e)),eu=e=>Gh(e,Qh(e));function tu(e,t){return Zh(e,n=>n.empty?e.moveByGroup(n,t):Yh(n,t))}function nu(e,t,n){if(t.type.prop(n))return!0;let i=t.to-t.from;return i&&(i>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function iu(e,t,n){let i,r,o=Fl(e).resolveInner(t.head),a=n?s.closedBy:s.openedBy;for(let i=t.head;;){let t=n?o.childAfter(i):o.childBefore(i);if(!t)break;nu(e,t,a)?o=t:i=n?t.to:t.from}return r=o.type.prop(a)&&(i=n?rh(e,o.from,1):rh(e,o.to,-1))&&i.matched?n?i.end.to:i.end.from:n?o.to:o.from,ut.cursor(r,n?-1:1)}function su(e,t){return Zh(e,n=>{if(!n.empty)return Yh(n,t);let i=e.moveVertically(n,t);return i.head!=n.head?i:e.moveToLineBoundary(n,t)})}const ru=e=>su(e,!1),ou=e=>su(e,!0);function au(e){let t,n=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,i=0,s=0;if(n){for(let t of e.state.facet(Fo.scrollMargins)){let n=t(e);(null==n?void 0:n.top)&&(i=Math.max(null==n?void 0:n.top,i)),(null==n?void 0:n.bottom)&&(s=Math.max(null==n?void 0:n.bottom,s))}t=e.scrollDOM.clientHeight-i-s}else t=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:i,marginBottom:s,selfScroll:n,height:Math.max(e.defaultLineHeight,t-5)}}function lu(e,t){let n,i=au(e),{state:s}=e,r=Kh(s.selection,n=>n.empty?e.moveVertically(n,t,i.height):Yh(n,t));if(r.eq(s.selection))return!1;if(i.selfScroll){let t=e.coordsAtPos(s.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),a=o.top+i.marginTop,l=o.bottom-i.marginBottom;t&&t.top>a&&t.bottom<l&&(n=Fo.scrollIntoView(r.main.head,{y:"start",yMargin:t.top-a}))}return e.dispatch(Jh(s,r),{effects:n}),!0}const cu=e=>lu(e,!1),hu=e=>lu(e,!0);function uu(e,t,n){let i=e.lineBlockAt(t.head),s=e.moveToLineBoundary(t,n);if(s.head==t.head&&s.head!=(n?i.to:i.from)&&(s=e.moveToLineBoundary(t,n,!1)),!n&&s.head==i.from&&i.length){let n=/^\s*/.exec(e.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;n&&t.head!=i.from+n&&(s=ut.cursor(i.from+n))}return s}function du(e,t){let n=Kh(e.state.selection,e=>{let n=t(e);return ut.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return!n.eq(e.state.selection)&&(e.dispatch(Jh(e.state,n)),!0)}function fu(e,t){return du(e,n=>e.moveByChar(n,t))}const pu=e=>fu(e,!Qh(e)),mu=e=>fu(e,Qh(e));function gu(e,t){return du(e,n=>e.moveByGroup(n,t))}function yu(e,t){return du(e,n=>e.moveVertically(n,t))}const vu=e=>yu(e,!1),bu=e=>yu(e,!0);function wu(e,t){return du(e,n=>e.moveVertically(n,t,au(e).height))}const ku=e=>wu(e,!1),xu=e=>wu(e,!0),Su=({state:e,dispatch:t})=>(t(Jh(e,{anchor:0})),!0),Cu=({state:e,dispatch:t})=>(t(Jh(e,{anchor:e.doc.length})),!0),Au=({state:e,dispatch:t})=>(t(Jh(e,{anchor:e.selection.main.anchor,head:0})),!0),Tu=({state:e,dispatch:t})=>(t(Jh(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0);function Ou(e,t){let{state:n}=e,i=n.selection,s=n.selection.ranges.slice();for(let i of n.selection.ranges){let r=n.doc.lineAt(i.head);if(t?r.to<e.state.doc.length:r.from>0)for(let n=i;;){let i=e.moveVertically(n,t);if(i.head<r.from||i.head>r.to){s.some(e=>e.head==i.head)||s.push(i);break}if(i.head==n.head)break;n=i}}return s.length!=i.ranges.length&&(e.dispatch(Jh(n,ut.create(s,s.length-1))),!0)}function Mu(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:i}=e,s=i.changeByRange(i=>{let{from:s,to:r}=i;if(s==r){let o=t(i);o<s?(n="delete.backward",o=Eu(e,o,!1)):o>s&&(n="delete.forward",o=Eu(e,o,!0)),s=Math.min(s,o),r=Math.max(r,o)}else s=Eu(e,s,!1),r=Eu(e,r,!0);return s==r?{range:i}:{changes:{from:s,to:r},range:ut.cursor(s,s<i.head?-1:1)}});return!s.changes.empty&&(e.dispatch(i.update(s,{scrollIntoView:!0,userEvent:n,effects:"delete.selection"==n?Fo.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function Eu(e,t,n){if(e instanceof Fo)for(let i of e.state.facet(Fo.atomicRanges).map(t=>t(e)))i.between(t,t,(e,i)=>{e<t&&i>t&&(t=n?i:e)});return t}const Nu=(e,t,n)=>Mu(e,i=>{let s,r,o=i.from,{state:a}=e,l=a.doc.lineAt(o);if(n&&!t&&o>l.from&&o<l.from+200&&!/[^ \t]/.test(s=l.text.slice(0,o-l.from))){if("\t"==s[s.length-1])return o-1;let e=xn(s,a.tabSize)%nc(a)||nc(a);for(let t=0;t<e&&" "==s[s.length-1-t];t++)o--;r=o}else r=Ye(l.text,o-l.from,t,t)+l.from,r==o&&l.number!=(t?a.doc.lines:1)?r+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(l.text.slice(r-l.from,o-l.from))&&(r=Ye(l.text,r-l.from,!1,!1)+l.from);return r}),Du=e=>Nu(e,!1,!0),_u=e=>Nu(e,!0,!1),Pu=(e,t)=>Mu(e,n=>{let i=n.head,{state:s}=e,r=s.doc.lineAt(i),o=s.charCategorizer(i);for(let e=null;;){if(i==(t?r.to:r.from)){i==n.head&&r.number!=(t?s.doc.lines:1)&&(i+=t?1:-1);break}let a=Ye(r.text,i-r.from,t)+r.from,l=r.text.slice(Math.min(i,a)-r.from,Math.max(i,a)-r.from),c=o(l);if(null!=e&&c!=e)break;" "==l&&i==n.head||(e=c),i=a}return i}),Iu=e=>Pu(e,!1);function Ru(e){let t=[],n=-1;for(let i of e.selection.ranges){let s=e.doc.lineAt(i.from),r=e.doc.lineAt(i.to);if(i.empty||i.to!=r.from||(r=e.doc.lineAt(i.to-1)),n>=s.number){let e=t[t.length-1];e.to=r.to,e.ranges.push(i)}else t.push({from:s.from,to:r.to,ranges:[i]});n=r.number+1}return t}function $u(e,t,n){if(e.readOnly)return!1;let i=[],s=[];for(let t of Ru(e)){if(n?t.to==e.doc.length:0==t.from)continue;let r=e.doc.lineAt(n?t.to+1:t.from-1),o=r.length+1;if(n){i.push({from:t.to,to:r.to},{from:t.from,insert:r.text+e.lineBreak});for(let n of t.ranges)s.push(ut.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{i.push({from:r.from,to:t.from},{from:t.to,insert:e.lineBreak+r.text});for(let e of t.ranges)s.push(ut.range(e.anchor-o,e.head-o))}}return!!i.length&&(t(e.update({changes:i,scrollIntoView:!0,selection:ut.create(s,e.selection.mainIndex),userEvent:"move.line"})),!0)}function Bu(e,t,n){if(e.readOnly)return!1;let i=[];for(let t of Ru(e))n?i.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):i.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let s=e.changes(i);return t(e.update({changes:s,selection:e.selection.map(s,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Lu=ju(!1),zu=ju(!0);function ju(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let i=t.changeByRange(n=>{let{from:i,to:r}=n,o=t.doc.lineAt(i),a=!e&&i==r&&function(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n,i=Fl(e).resolveInner(t),r=i.childBefore(t),o=i.childAfter(t);return r&&o&&r.to<=t&&o.from>=t&&(n=r.type.prop(s.closedBy))&&n.indexOf(o.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(o.from).from&&!/\S/.test(e.sliceDoc(r.to,o.from))?{from:r.to,to:o.from}:null}(t,i);e&&(i=r=(r<=o.to?o:t.doc.lineAt(r)).to);let l=new rc(t,{simulateBreak:i,simulateDoubleBreak:!!a}),c=sc(l,i);for(null==c&&(c=xn(/^\s*/.exec(t.doc.lineAt(i).text)[0],t.tabSize));r<o.to&&/\s/.test(o.text[r-o.from]);)r++;a?({from:i,to:r}=a):i>o.from&&i<o.from+100&&!/\S/.test(o.text.slice(0,i))&&(i=o.from);let h=["",ic(t,c)];return a&&h.push(ic(t,l.lineIndent(o.from,-1))),{changes:{from:i,to:r,insert:je.of(h)},range:ut.cursor(i+1+h[1].length)}});return n(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function Wu(e,t){let n=-1;return e.changeByRange(i=>{let s=[];for(let r=i.from;r<=i.to;){let o=e.doc.lineAt(r);o.number>n&&(i.empty||i.to>o.from)&&(t(o,s,i),n=o.number),r=o.to+1}let r=e.changes(s);return{changes:s,range:ut.range(r.mapPos(i.anchor,1),r.mapPos(i.head,1))}})}const Uu=[{key:"ArrowLeft",run:Xh,shift:pu,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:e=>tu(e,!Qh(e)),shift:e=>gu(e,!Qh(e)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:e=>Zh(e,t=>uu(e,t,!Qh(e))),shift:e=>du(e,t=>uu(e,t,!Qh(e))),preventDefault:!0},{key:"ArrowRight",run:eu,shift:mu,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:e=>tu(e,Qh(e)),shift:e=>gu(e,Qh(e)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:e=>Zh(e,t=>uu(e,t,Qh(e))),shift:e=>du(e,t=>uu(e,t,Qh(e))),preventDefault:!0},{key:"ArrowUp",run:ru,shift:vu,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Su,shift:Au},{mac:"Ctrl-ArrowUp",run:cu,shift:ku},{key:"ArrowDown",run:ou,shift:bu,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Cu,shift:Tu},{mac:"Ctrl-ArrowDown",run:hu,shift:xu},{key:"PageUp",run:cu,shift:ku},{key:"PageDown",run:hu,shift:xu},{key:"Home",run:e=>Zh(e,t=>uu(e,t,!1)),shift:e=>du(e,t=>uu(e,t,!1)),preventDefault:!0},{key:"Mod-Home",run:Su,shift:Au},{key:"End",run:e=>Zh(e,t=>uu(e,t,!0)),shift:e=>du(e,t=>uu(e,t,!0)),preventDefault:!0},{key:"Mod-End",run:Cu,shift:Tu},{key:"Enter",run:Lu,shift:Lu},{key:"Mod-a",run:({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:Du,shift:Du,preventDefault:!0},{key:"Delete",run:_u,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Iu,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:e=>Pu(e,!0),preventDefault:!0},{mac:"Mod-Backspace",run:e=>Mu(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),preventDefault:!0},{mac:"Mod-Delete",run:e=>Mu(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),preventDefault:!0}].concat([{key:"Ctrl-b",run:Xh,shift:pu,preventDefault:!0},{key:"Ctrl-f",run:eu,shift:mu},{key:"Ctrl-p",run:ru,shift:vu},{key:"Ctrl-n",run:ou,shift:bu},{key:"Ctrl-a",run:e=>Zh(e,t=>ut.cursor(e.lineBlockAt(t.head).from,1)),shift:e=>du(e,t=>ut.cursor(e.lineBlockAt(t.head).from))},{key:"Ctrl-e",run:e=>Zh(e,t=>ut.cursor(e.lineBlockAt(t.head).to,-1)),shift:e=>du(e,t=>ut.cursor(e.lineBlockAt(t.head).to))},{key:"Ctrl-d",run:_u},{key:"Ctrl-h",run:Du},{key:"Ctrl-k",run:e=>Mu(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)})},{key:"Ctrl-Alt-h",run:Iu},{key:"Ctrl-o",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:je.of(["",""])},range:ut.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||0==t.from||t.from==e.doc.length)return{range:t};let n=t.from,i=e.doc.lineAt(n),s=n==i.from?n-1:Ye(i.text,n-i.from,!1)+i.from,r=n==i.to?n+1:Ye(i.text,n-i.from,!0)+i.from;return{changes:{from:s,to:r,insert:e.doc.slice(n,r).append(e.doc.slice(s,n))},range:ut.cursor(r)}});return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:hu}].map(e=>({mac:e.key,run:e.run,shift:e.shift}))),Fu=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:e=>Zh(e,t=>iu(e.state,t,!Qh(e))),shift:e=>du(e,t=>iu(e.state,t,!Qh(e)))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e=>Zh(e,t=>iu(e.state,t,Qh(e))),shift:e=>du(e,t=>iu(e.state,t,Qh(e)))},{key:"Alt-ArrowUp",run:({state:e,dispatch:t})=>$u(e,t,!1)},{key:"Shift-Alt-ArrowUp",run:({state:e,dispatch:t})=>Bu(e,t,!1)},{key:"Alt-ArrowDown",run:({state:e,dispatch:t})=>$u(e,t,!0)},{key:"Shift-Alt-ArrowDown",run:({state:e,dispatch:t})=>Bu(e,t,!0)},{key:"Mod-Alt-ArrowUp",run:e=>Ou(e,!1)},{key:"Mod-Alt-ArrowDown",run:e=>Ou(e,!0)},{key:"Escape",run:({state:e,dispatch:t})=>{let n=e.selection,i=null;return n.ranges.length>1?i=ut.create([n.main]):n.main.empty||(i=ut.create([ut.cursor(n.main.head)])),!!i&&(t(Jh(e,i)),!0)}},{key:"Mod-Enter",run:zu},{key:"Alt-l",mac:"Ctrl-l",run:({state:e,dispatch:t})=>{let n=Ru(e).map(({from:t,to:n})=>ut.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:ut.create(n),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:e,dispatch:t})=>{let n=Kh(e.selection,t=>{let n=Fl(e),i=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=i.node.from&&e.node.to<=i.node.to&&(i=e)}for(let e=i;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return ut.range(n.to,n.from)}return t});return!n.eq(e.selection)&&(t(Jh(e,n)),!0)},preventDefault:!0},{key:"Mod-[",run:({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(Wu(e,(t,n)=>{let i=/^\s*/.exec(t.text)[0];if(!i)return;let s=xn(i,e.tabSize),r=0,o=ic(e,Math.max(0,s-nc(e)));for(;r<i.length&&r<o.length&&i.charCodeAt(r)==o.charCodeAt(r);)r++;n.push({from:t.from+r,to:t.from+i.length,insert:o.slice(r)})}),{userEvent:"delete.dedent"})),!0)},{key:"Mod-]",run:({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(Wu(e,(t,n)=>{n.push({from:t.from,insert:e.facet(tc)})}),{userEvent:"input.indent"})),!0)},{key:"Mod-Alt-\\",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),i=new rc(e,{overrideIndentation:e=>{let t=n[e];return null==t?-1:t}}),s=Wu(e,(t,s,r)=>{let o=sc(i,t.from);if(null==o)return;/\S/.test(t.text)||(o=0);let a=/^\s*/.exec(t.text)[0],l=ic(e,o);(a!=l||r.from<t.from+a.length)&&(n[t.from]=o,s.push({from:t.from,to:t.from+a.length,insert:l}))});return s.changes.empty||t(e.update(s,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(Ru(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),i=Kh(t.selection,t=>{let n;if(e.lineWrapping){let i=e.lineBlockAt(t.head),s=e.coordsAtPos(t.head,t.assoc||1);s&&(n=i.bottom+e.documentTop-s.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:e,dispatch:t})=>function(e,t){let n=!1,i=Kh(e.selection,t=>{let i=rh(e,t.head,-1)||rh(e,t.head,1)||t.head>0&&rh(e,t.head-1,1)||t.head<e.doc.length&&rh(e,t.head+1,-1);if(!i||!i.end)return t;n=!0;let s=i.start.from==t.head?i.end.to:i.end.from;return ut.cursor(s)});return!!n&&(t(Jh(e,i)),!0)}(e,t)},{key:"Mod-/",run:e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),i=wh(e.state,n.from);return i.line?yh(e):!!i.block&&bh(e)}},{key:"Alt-A",run:vh},{key:"Ctrl-m",mac:"Shift-Alt-m",run:e=>(e.setTabFocusMode(),!0)}].concat(Uu),Vu="function"==typeof String.prototype.normalize?e=>e.normalize("NFKD"):e=>e;class Hu{constructor(e,t,n=0,i=e.length,s,r){this.test=r,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,i),this.bufferStart=n,this.normalize=s?e=>s(Vu(e)):Vu,this.query=this.normalize(t)}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 Ge(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=Qe(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=Xe(e);let i=this.normalize(t);if(i.length)for(let e=0,s=n;;e++){let r=i.charCodeAt(e),o=this.match(r,s,this.bufferPos+this.bufferStart);if(e==i.length-1){if(o)return this.value=o,this;break}s==n&&e<t.length&&t.charCodeAt(e)==r&&s++}}}match(e,t,n){let i=null;for(let t=0;t<this.matches.length;t+=2){let s=this.matches[t],r=!1;this.query.charCodeAt(s)==e&&(s==this.query.length-1?i={from:this.matches[t+1],to:n}:(this.matches[t]++,r=!0)),r||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(1==this.query.length?i={from:t,to:n}:this.matches.push(1,t)),i&&this.test&&!this.test(i.from,i.to,this.buffer,this.bufferStart)&&(i=null),i}}"undefined"!=typeof Symbol&&(Hu.prototype[Symbol.iterator]=function(){return this});const qu={from:-1,to:-1,match:/.*/.exec("")},Ku="gm"+(null==/x/.unicode?"":"u");class Ju{constructor(e,t,n,i=0,s=e.length){if(this.text=e,this.to=s,this.curLine="",this.done=!1,this.value=qu,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new Gu(e,t,n,i,s);this.re=new RegExp(t,Ku+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.iter=e.iter();let r=e.lineAt(i);this.curLineStart=r.from,this.matchPos=Qu(e,i),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),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 e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,i=n+t[0].length;if(this.matchPos=Qu(this.text,i+(n==i?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<i||n>this.value.to)&&(!this.test||this.test(n,i,t)))return this.value={from:n,to:i,match:t},this;e=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),e=0}}}}const Zu=new WeakMap;class Yu{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,n){let i=Zu.get(e);if(!i||i.from>=n||i.to<=t){let i=new Yu(t,e.sliceString(t,n));return Zu.set(e,i),i}if(i.from==t&&i.to==n)return i;let{text:s,from:r}=i;return r>t&&(s=e.sliceString(t,r)+s,r=t),i.to<n&&(s+=e.sliceString(i.to,n)),Zu.set(e,new Yu(r,s)),new Yu(t,s.slice(t-r,n-r))}}class Gu{constructor(e,t,n,i,s){this.text=e,this.to=s,this.done=!1,this.value=qu,this.matchPos=Qu(e,i),this.re=new RegExp(t,Ku+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.flat=Yu.get(e,i,this.chunkEnd(i+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=Qu(this.text,n+(e==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Yu.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function Qu(e,t){if(t>=e.length)return t;let n,i=e.lineAt(t);for(;t<i.to&&(n=i.text.charCodeAt(t-i.from))>=56320&&n<57344;)t++;return t}"undefined"!=typeof Symbol&&(Ju.prototype[Symbol.iterator]=Gu.prototype[Symbol.iterator]=function(){return this});const Xu={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},ed=pt.define({combine:e=>sn(e,Xu,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})});const td=ii.mark({class:"cm-selectionMatch"}),nd=ii.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function id(e,t,n,i){return!(0!=n&&e(t.sliceDoc(n-1,n))==Qt.Word||i!=t.doc.length&&e(t.sliceDoc(i,i+1))==Qt.Word)}const sd=ys.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(ed),{state:n}=e,i=n.selection;if(i.ranges.length>1)return ii.none;let s,r=i.main,o=null;if(r.empty){if(!t.highlightWordAroundCursor)return ii.none;let e=n.wordAt(r.head);if(!e)return ii.none;o=n.charCategorizer(r.head),s=n.sliceDoc(e.from,e.to)}else{let e=r.to-r.from;if(e<t.minSelectionLength||e>200)return ii.none;if(t.wholeWords){if(s=n.sliceDoc(r.from,r.to),o=n.charCategorizer(r.head),!id(o,n,r.from,r.to)||!function(e,t,n,i){return e(t.sliceDoc(n,n+1))==Qt.Word&&e(t.sliceDoc(i-1,i))==Qt.Word}(o,n,r.from,r.to))return ii.none}else if(s=n.sliceDoc(r.from,r.to),!s)return ii.none}let a=[];for(let i of e.visibleRanges){let e=new Hu(n.doc,s,i.from,i.to);for(;!e.next().done;){let{from:i,to:s}=e.value;if((!o||id(o,n,i,s))&&(r.empty&&i<=r.from&&s>=r.to?a.push(nd.range(i,s)):(i>=r.to||s<=r.from)&&a.push(td.range(i,s)),a.length>t.maxMatches))return ii.none}}return ii.set(a)}},{decorations:e=>e.decorations}),rd=Fo.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}});const od=pt.define({combine:e=>sn(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Rd(e),scrollToMatch:e=>Fo.scrollIntoView(e)})});class ad{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||function(e){try{return new RegExp(e,Ku),!0}catch(e){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>"n"==t?"\n":"r"==t?"\r":"t"==t?"\t":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new pd(this):new hd(this)}getCursor(e,t=0,n){let i=e.doc?e:nn.create({doc:e});return null==n&&(n=i.doc.length),this.regexp?ud(this,i,t,n):cd(this,i,t,n)}}class ld{constructor(e){this.spec=e}}function cd(e,t,n,i){let s;return e.wholeWord&&(s=function(e,t){return(n,i,s,r)=>((r>n||r+s.length<i)&&(r=Math.max(0,n-2),s=e.sliceString(r,Math.min(e.length,i+2))),!(t(dd(s,n-r))==Qt.Word&&t(fd(s,n-r))==Qt.Word||t(fd(s,i-r))==Qt.Word&&t(dd(s,i-r))==Qt.Word))}(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(s=function(e,t,n){return(i,s,r,o)=>{if(n&&!n(i,s,r,o))return!1;let a=i>=o&&s<=o+r.length?r.slice(i-o,s-o):t.doc.sliceString(i,s);return e(a,t,i,s)}}(e.test,t,s)),new Hu(t.doc,e.unquoted,n,i,e.caseSensitive?void 0:e=>e.toLowerCase(),s)}class hd extends ld{constructor(e){super(e)}nextMatch(e,t,n){let i=cd(this.spec,e,n,e.doc.length).nextOverlapping();if(i.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);i=cd(this.spec,e,0,n).nextOverlapping()}return i.done||i.value.from==t&&i.value.to==n?null:i.value}prevMatchInRange(e,t,n){for(let i=n;;){let n=Math.max(t,i-1e4-this.spec.unquoted.length),s=cd(this.spec,e,n,i),r=null;for(;!s.nextOverlapping().done;)r=s.value;if(r)return r;if(n==t)return null;i-=1e4}}prevMatch(e,t,n){let i=this.prevMatchInRange(e,0,t);return i||(i=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length)),!i||i.from==t&&i.to==n?null:i}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=cd(this.spec,e,0,e.doc.length),i=[];for(;!n.next().done;){if(i.length>=t)return null;i.push(n.value)}return i}highlight(e,t,n,i){let s=cd(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!s.next().done;)i(s.value.from,s.value.to)}}function ud(e,t,n,i){let s;var r;return e.wholeWord&&(r=t.charCategorizer(t.selection.main.head),s=(e,t,n)=>!n[0].length||(r(dd(n.input,n.index))!=Qt.Word||r(fd(n.input,n.index))!=Qt.Word)&&(r(fd(n.input,n.index+n[0].length))!=Qt.Word||r(dd(n.input,n.index+n[0].length))!=Qt.Word)),e.test&&(s=function(e,t,n){return(i,s,r)=>(!n||n(i,s,r))&&e(r[0],t,i,s)}(e.test,t,s)),new Ju(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:s},n,i)}function dd(e,t){return e.slice(Ye(e,t,!1),t)}function fd(e,t){return e.slice(t,Ye(e,t))}class pd extends ld{nextMatch(e,t,n){let i=ud(this.spec,e,n,e.doc.length).next();return i.done&&(i=ud(this.spec,e,0,t).next()),i.done?null:i.value}prevMatchInRange(e,t,n){for(let i=1;;i++){let s=Math.max(t,n-1e4*i),r=ud(this.spec,e,s,n),o=null;for(;!r.next().done;)o=r.value;if(o&&(s==t||o.from>s+10))return o;if(s==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if("&"==n)return e.match[0];if("$"==n)return"$";for(let t=n.length;t>0;t--){let i=+n.slice(0,t);if(i>0&&i<e.match.length)return e.match[i]+n.slice(t)}return t})}matchAll(e,t){let n=ud(this.spec,e,0,e.doc.length),i=[];for(;!n.next().done;){if(i.length>=t)return null;i.push(n.value)}return i}highlight(e,t,n,i){let s=ud(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!s.next().done;)i(s.value.from,s.value.to)}}const md=Vt.define(),gd=Vt.define(),yd=kt.define({create:e=>new vd(Ed(e).create(),null),update(e,t){for(let n of t.effects)n.is(md)?e=new vd(n.value.create(),e.panel):n.is(gd)&&(e=new vd(e.query,n.value?Md:null));return e},provide:e=>ll.from(e,e=>e.panel)});class vd{constructor(e,t){this.query=e,this.panel=t}}const bd=ii.mark({class:"cm-searchMatch"}),wd=ii.mark({class:"cm-searchMatch cm-searchMatch-selected"}),kd=ys.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(yd))}update(e){let t=e.state.field(yd);(t!=e.startState.field(yd)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return ii.none;let{view:n}=this,i=new un;for(let t=0,s=n.visibleRanges,r=s.length;t<r;t++){let{from:o,to:a}=s[t];for(;t<r-1&&a>s[t+1].from-500;)a=s[++t].to;e.highlight(n.state,o,a,(e,t)=>{let s=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);i.add(e,t,s?wd:bd)})}return i.finish()}},{decorations:e=>e.decorations});function xd(e){return t=>{let n=t.state.field(yd,!1);return n&&n.query.spec.valid?e(t,n):_d(t)}}const Sd=xd((e,{query:t})=>{let{to:n}=e.state.selection.main,i=t.nextMatch(e.state,n,n);if(!i)return!1;let s=ut.single(i.from,i.to),r=e.state.facet(od);return e.dispatch({selection:s,effects:[zd(e,i),r.scrollToMatch(s.main,e)],userEvent:"select.search"}),Dd(e),!0}),Cd=xd((e,{query:t})=>{let{state:n}=e,{from:i}=n.selection.main,s=t.prevMatch(n,i,i);if(!s)return!1;let r=ut.single(s.from,s.to),o=e.state.facet(od);return e.dispatch({selection:r,effects:[zd(e,s),o.scrollToMatch(r.main,e)],userEvent:"select.search"}),Dd(e),!0}),Ad=xd((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!(!n||!n.length)&&(e.dispatch({selection:ut.create(n.map(e=>ut.range(e.from,e.to))),userEvent:"select.search.matches"}),!0)}),Td=xd((e,{query:t})=>{let{state:n}=e,{from:i,to:s}=n.selection.main;if(n.readOnly)return!1;let r=t.nextMatch(n,i,i);if(!r)return!1;let o,a,l=r,c=[],h=[];l.from==i&&l.to==s&&(a=n.toText(t.getReplacement(l)),c.push({from:l.from,to:l.to,insert:a}),l=t.nextMatch(n,l.from,l.to),h.push(Fo.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(i).number)+".")));let u=e.state.changes(c);return l&&(o=ut.single(l.from,l.to).map(u),h.push(zd(e,l)),h.push(n.facet(od).scrollToMatch(o.main,e))),e.dispatch({changes:u,selection:o,effects:h,userEvent:"input.replace"}),!0}),Od=xd((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map(e=>{let{from:n,to:i}=e;return{from:n,to:i,insert:t.getReplacement(e)}});if(!n.length)return!1;let i=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:Fo.announce.of(i),userEvent:"input.replace.all"}),!0});function Md(e){return e.state.facet(od).createPanel(e)}function Ed(e,t){var n,i,s,r,o;let a=e.selection.main,l=a.empty||a.to>a.from+100?"":e.sliceDoc(a.from,a.to);if(t&&!l)return t;let c=e.facet(od);return new ad({search:(null!==(n=null==t?void 0:t.literal)&&void 0!==n?n:c.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:null!==(i=null==t?void 0:t.caseSensitive)&&void 0!==i?i:c.caseSensitive,literal:null!==(s=null==t?void 0:t.literal)&&void 0!==s?s:c.literal,regexp:null!==(r=null==t?void 0:t.regexp)&&void 0!==r?r:c.regexp,wholeWord:null!==(o=null==t?void 0:t.wholeWord)&&void 0!==o?o:c.wholeWord})}function Nd(e){let t=sl(e,Md);return t&&t.dom.querySelector("[main-field]")}function Dd(e){let t=Nd(e);t&&t==e.root.activeElement&&t.select()}const _d=e=>{let t=e.state.field(yd,!1);if(t&&t.panel){let n=Nd(e);if(n&&n!=e.root.activeElement){let i=Ed(e.state,t.query.spec);i.valid&&e.dispatch({effects:md.of(i)}),n.focus(),n.select()}}else e.dispatch({effects:[gd.of(!0),t?md.of(Ed(e.state,t.query.spec)):Vt.appendConfig.of(Wd)]});return!0},Pd=e=>{let t=e.state.field(yd,!1);if(!t||!t.panel)return!1;let n=sl(e,Md);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:gd.of(!1)}),!0},Id=[{key:"Mod-f",run:_d,scope:"editor search-panel"},{key:"F3",run:Sd,shift:Cd,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Sd,shift:Cd,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Pd,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:i,to:s}=n.main,r=[],o=0;for(let t=new Hu(e.doc,e.sliceDoc(i,s));!t.next().done;){if(r.length>1e3)return!1;t.value.from==i&&(o=r.length),r.push(ut.range(t.value.from,t.value.to))}return t(e.update({selection:ut.create(r,o),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:i,result:s}=cl(e,{label:t.phrase("Go to line"),input:{type:"text",name:"line",value:n},focus:!0,submitLabel:t.phrase("go")});return s.then(n=>{let s=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!s)return void e.dispatch({effects:i});let r=t.doc.lineAt(t.selection.main.head),[,o,a,l,c]=s,h=l?+l.slice(1):0,u=a?+a:r.number;if(a&&c){let e=u/100;o&&(e=e*("-"==o?-1:1)+r.number/t.doc.lines),u=Math.round(t.doc.lines*e)}else a&&o&&(u=u*("-"==o?-1:1)+r.number);let d=t.doc.line(Math.max(1,Math.min(t.doc.lines,u))),f=ut.cursor(d.from+Math.max(0,Math.min(h,d.length)));e.dispatch({effects:[i,Fo.scrollIntoView(f.from,{y:"center"})],selection:f})}),!0}},{key:"Mod-d",run:({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return(({state:e,dispatch:t})=>{let{selection:n}=e,i=ut.create(n.ranges.map(t=>e.wordAt(t.head)||ut.cursor(t.head)),n.mainIndex);return!i.eq(n)&&(t(e.update({selection:i})),!0)})({state:e,dispatch:t});let i=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=i))return!1;let s=function(e,t){let{main:n,ranges:i}=e.selection,s=e.wordAt(n.head),r=s&&s.from==n.from&&s.to==n.to;for(let n=!1,s=new Hu(e.doc,t,i[i.length-1].to);;){if(s.next(),!s.done){if(n&&i.some(e=>e.from==s.value.from))continue;if(r){let t=e.wordAt(s.value.from);if(!t||t.from!=s.value.from||t.to!=s.value.to)continue}return s.value}if(n)return null;s=new Hu(e.doc,t,0,Math.max(0,i[i.length-1].from-1)),n=!0}}(e,i);return!!s&&(t(e.update({selection:e.selection.addRange(ut.range(s.from,s.to),!1),effects:Fo.scrollIntoView(s.to)})),!0)},preventDefault:!0}];class Rd{constructor(e){this.view=e;let t=this.query=e.state.field(yd).query.spec;function n(e,t,n){return $n("button",{class:"cm-button",name:e,onclick:t,type:"button"},n)}this.commit=this.commit.bind(this),this.searchField=$n("input",{value:t.search,placeholder:$d(e,"Find"),"aria-label":$d(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=$n("input",{value:t.replace,placeholder:$d(e,"Replace"),"aria-label":$d(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=$n("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=$n("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=$n("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit}),this.dom=$n("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,n("next",()=>Sd(e),[$d(e,"next")]),n("prev",()=>Cd(e),[$d(e,"previous")]),n("select",()=>Ad(e),[$d(e,"all")]),$n("label",null,[this.caseField,$d(e,"match case")]),$n("label",null,[this.reField,$d(e,"regexp")]),$n("label",null,[this.wordField,$d(e,"by word")]),...e.state.readOnly?[]:[$n("br"),this.replaceField,n("replace",()=>Td(e),[$d(e,"replace")]),n("replaceAll",()=>Od(e),[$d(e,"replace all")])],$n("button",{name:"close",onclick:()=>Pd(e),"aria-label":$d(e,"close"),type:"button"},["×"])])}commit(){let e=new ad({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:md.of(e)}))}keydown(e){var t,n,i;t=this.view,n=e,i="search-panel",ia(Xo(t.state),n,t,i)?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Cd:Sd)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),Td(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(md)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(od).top}}function $d(e,t){return e.state.phrase(t)}const Bd=30,Ld=/[\s\.,:;?!]/;function zd(e,{from:t,to:n}){let i=e.state.doc.lineAt(t),s=e.state.doc.lineAt(n).to,r=Math.max(i.from,t-Bd),o=Math.min(s,n+Bd),a=e.state.sliceDoc(r,o);if(r!=i.from)for(let e=0;e<Bd;e++)if(!Ld.test(a[e+1])&&Ld.test(a[e])){a=a.slice(e);break}if(o!=s)for(let e=a.length-1;e>a.length-Bd;e--)if(!Ld.test(a[e-1])&&Ld.test(a[e])){a=a.slice(0,e);break}return Fo.announce.of(`${e.state.phrase("current match")}. ${a} ${e.state.phrase("on line")} ${i.number}.`)}const jd=Fo.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"}}),Wd=[yd,Ot.low(kd),jd];class Ud{constructor(e,t,n,i){this.state=e,this.pos=t,this.explicit=n,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=Fl(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),i=t.text.slice(n-t.from,this.pos-t.from),s=i.search(Kd(e,!1));return s<0?null:{from:n+s,to:this.pos,text:i.slice(s)}}get aborted(){return null==this.abortListeners}addEventListener(e,t,n){"abort"==e&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}}function Fd(e){let t=Object.keys(e).join(""),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,"")),`[${n?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function Vd(e){let t=e.map(e=>"string"==typeof e?{label:e}:e),[n,i]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:function(e){let t=Object.create(null),n=Object.create(null);for(let{label:i}of e){t[i[0]]=!0;for(let e=1;e<i.length;e++)n[i[e]]=!0}let i=Fd(t)+Fd(n)+"*$";return[new RegExp("^"+i),new RegExp(i)]}(t);return e=>{let s=e.matchBefore(i);return s||e.explicit?{from:s?s.from:e.pos,options:t,validFor:n}:null}}class Hd{constructor(e,t,n,i){this.completion=e,this.source=t,this.match=n,this.score=i}}function qd(e){return e.selection.main.from}function Kd(e,t){var n;let{source:i}=e,s=t&&"^"!=i[0],r="$"!=i[i.length-1];return s||r?new RegExp(`${s?"^":""}(?:${i})${r?"$":""}`,null!==(n=e.flags)&&void 0!==n?n:e.ignoreCase?"i":""):e}const Jd=Wt.define();function Zd(e,t,n,i){let{main:s}=e.selection,r=n-s.from,o=i-s.from;return{...e.changeByRange(a=>{if(a!=s&&n!=i&&e.sliceDoc(a.from+r,a.from+o)!=e.sliceDoc(n,i))return{range:a};let l=e.toText(t);return{changes:{from:a.from+r,to:i==s.from?a.to:a.from+o,insert:l},range:ut.cursor(a.from+r+l.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const Yd=new WeakMap;function Gd(e){if(!Array.isArray(e))return e;let t=Yd.get(e);return t||Yd.set(e,t=Vd(e)),t}const Qd=Vt.define(),Xd=Vt.define();class ef{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=Ge(e,t),i=Xe(n);this.chars.push(n);let s=e.slice(t,t+i),r=s.toUpperCase();this.folded.push(Ge(r==s?s.toLowerCase():r,0)),t+=i}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(0==this.pattern.length)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:i,precise:s,byWord:r}=this;if(1==t.length){let i=Ge(e,0),s=Xe(i),r=s==e.length?0:-100;if(i==t[0]);else{if(i!=n[0])return null;r+=-200}return this.ret(r,[0,s])}let o=e.indexOf(this.pattern);if(0==o)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=t.length,l=0;if(o<0){for(let s=0,r=Math.min(e.length,200);s<r&&l<a;){let r=Ge(e,s);r!=t[l]&&r!=n[l]||(i[l++]=s),s+=Xe(r)}if(l<a)return null}let c=0,h=0,u=!1,d=0,f=-1,p=-1,m=/[a-z]/.test(e),g=!0;for(let i=0,l=Math.min(e.length,200),y=0;i<l&&h<a;){let l=Ge(e,i);o<0&&(c<a&&l==t[c]&&(s[c++]=i),d<a&&(l==t[d]||l==n[d]?(0==d&&(f=i),p=i+1,d++):d=0));let v,b=l<255?l>=48&&l<=57||l>=97&&l<=122?2:l>=65&&l<=90?1:0:(v=Qe(l))!=v.toLowerCase()?1:v!=v.toUpperCase()?2:0;(!i||1==b&&m||0==y&&0!=b)&&(t[h]==l||n[h]==l&&(u=!0)?r[h++]=i:r.length&&(g=!1)),y=b,i+=Xe(l)}return h==a&&0==r[0]&&g?this.result((u?-200:0)-100,r,e):d==a&&0==f?this.ret(-200-e.length+(p==e.length?0:-100),[0,p]):o>-1?this.ret(-700-e.length,[o,o+this.pattern.length]):d==a?this.ret(-900-e.length,[f,p]):h==a?this.result((u?-200:0)-100-700+(g?0:-1100),r,e):2==t.length?null:this.result((i[0]?-700:0)-200-1100,i,e)}result(e,t,n){let i=[],s=0;for(let e of t){let t=e+(this.astral?Xe(Ge(n,e)):1);s&&i[s-1]==e?i[s-1]=t:(i[s++]=e,i[s++]=t)}return this.ret(e-n.length,i)}}class tf{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return null==n?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}}const nf=pt.define({combine:e=>sn(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:rf,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>sf(e(n),t(n)),optionClass:(e,t)=>n=>sf(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})});function sf(e,t){return e?t?e+" "+t:e:t}function rf(e,t,n,i,s,r){let o,a,l=e.textDirection==Pi.RTL,c=l,h=!1,u="top",d=t.left-s.left,f=s.right-t.right,p=i.right-i.left,m=i.bottom-i.top;if(c&&d<Math.min(p,f)?c=!1:!c&&f<Math.min(p,d)&&(c=!0),p<=(c?d:f))o=Math.max(s.top,Math.min(n.top,s.bottom-m))-t.top,a=Math.min(400,c?d:f);else{h=!0,a=Math.min(400,(l?t.right:s.right-t.left)-30);let e=s.bottom-t.bottom;e>=m||e>t.top?o=n.bottom-t.top:(u="bottom",o=t.bottom-n.top)}return{style:`${u}: ${o/((t.bottom-t.top)/r.offsetHeight)}px; max-width: ${a/((t.right-t.left)/r.offsetWidth)}px`,class:"cm-completionInfo-"+(h?l?"left-narrow":"right-narrow":c?"left":"right")}}const of=Vt.define();function af(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let i=Math.floor((e-t)/n);return{from:e-(i+1)*n,to:e-i*n}}class lf{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass="";let i=e.state.field(t),{options:s,selected:r}=i.open,o=e.state.facet(nf);this.optionContent=function(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement("div");return t.classList.add("cm-completionIcon"),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>"cm-completionIcon-"+e)),t.setAttribute("aria-hidden","true"),t},position:20}),t.push({render(e,t,n,i){let s=document.createElement("span");s.className="cm-completionLabel";let r=e.displayLabel||e.label,o=0;for(let e=0;e<i.length;){let t=i[e++],n=i[e++];t>o&&s.appendChild(document.createTextNode(r.slice(o,t)));let a=s.appendChild(document.createElement("span"));a.appendChild(document.createTextNode(r.slice(t,n))),a.className="cm-completionMatchedText",o=n}return o<r.length&&s.appendChild(document.createTextNode(r.slice(o))),s},position:50},{render(e){if(!e.detail)return null;let t=document.createElement("span");return t.className="cm-completionDetail",t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=af(s.length,r,o.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",n=>{let{options:i}=e.state.field(t).open;for(let t,s=n.target;s&&s!=this.dom;s=s.parentNode)if("LI"==s.nodeName&&(t=/-(\d+)$/.exec(s.id))&&+t[1]<i.length)return this.applyCompletion(e,i[+t[1]]),void n.preventDefault();if(n.target==this.list){let t=this.list.classList.contains("cm-completionListIncompleteTop")&&n.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&n.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;null!=t&&(e.dispatch({effects:of.of(t)}),n.preventDefault())}}),this.dom.addEventListener("focusout",t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(nf).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:Xd.of(null)})}),this.showOptions(s,i.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let n=e.state.field(this.stateField),i=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),n!=i){let{options:s,selected:r,disabled:o}=n.open;i.open&&i.open.options==s||(this.range=af(s.length,r,e.state.facet(nf).maxRenderedOptions),this.showOptions(s,n.id)),this.updateSel(),o!=(null===(t=i.open)||void 0===t?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!o)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(" "))e&&this.dom.classList.remove(e);for(let e of t.split(" "))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=af(t.options.length,t.selected,this.view.state.facet(nf).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:i}=t.options[t.selected],{info:s}=i;if(!s)return;let r="string"==typeof s?document.createTextNode(s):s(i);if(!r)return;"then"in r?r.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,i)}).catch(e=>fs(this.view.state,e,"completion info")):(this.addInfoPane(r,i),n.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",n.id="cm-completionInfo-"+Math.floor(65535*Math.random()).toString(16),null!=e.nodeType)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:i}=e;n.appendChild(t),this.infoDestroy=i||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,i=this.range.from;n;n=n.nextSibling,i++)"LI"==n.nodeName&&n.id?i==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),t=n):n.hasAttribute("aria-selected")&&(n.removeAttribute("aria-selected"),n.removeAttribute("aria-describedby")):i--;return t&&function(e,t){let n=e.getBoundingClientRect(),i=t.getBoundingClientRect(),s=n.height/e.offsetHeight;i.top<n.top?e.scrollTop-=(n.top-i.top)/s:i.bottom>n.bottom&&(e.scrollTop+=(i.bottom-n.bottom)/s)}(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),i=e.getBoundingClientRect(),s=this.space;if(!s){let e=this.dom.ownerDocument.documentElement;s={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return i.top>Math.min(s.bottom,t.bottom)-10||i.bottom<Math.max(s.top,t.top)+10?null:this.view.state.facet(nf).positionInfo(this.view,t,i,n,s,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,n){const i=document.createElement("ul");i.id=t,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions")),i.addEventListener("mousedown",e=>{e.target==i&&e.preventDefault()});let s=null;for(let r=n.from;r<n.to;r++){let{completion:o,match:a}=e[r],{section:l}=o;if(l){let e="string"==typeof l?l:l.name;if(e!=s&&(r>n.from||0==n.from))if(s=e,"string"!=typeof l&&l.header)i.appendChild(l.header(l));else{i.appendChild(document.createElement("completion-section")).textContent=e}}const c=i.appendChild(document.createElement("li"));c.id=t+"-"+r,c.setAttribute("role","option");let h=this.optionClass(o);h&&(c.className=h);for(let e of this.optionContent){let t=e(o,this.view.state,this.view,a);t&&c.appendChild(t)}}return n.from&&i.classList.add("cm-completionListIncompleteTop"),n.to<e.length&&i.classList.add("cm-completionListIncompleteBottom"),i}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function cf(e,t){return n=>new lf(n,e,t)}function hf(e){return 100*(e.boost||0)+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}class uf{constructor(e,t,n,i,s,r){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=i,this.selected=s,this.disabled=r}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new uf(this.options,mf(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,i,s,r){if(i&&!r&&e.some(e=>e.isPending))return i.setDisabled();let o=function(e,t){let n=[],i=null,s=null,r=e=>{n.push(e);let{section:t}=e.completion;if(t){i||(i=[]);let e="string"==typeof t?t:t.name;i.some(t=>t.name==e)||i.push("string"==typeof t?{name:e}:t)}},o=t.facet(nf);for(let i of e)if(i.hasResult()){let e=i.result.getMatch;if(!1===i.result.filter)for(let t of i.result.options)r(new Hd(t,i.source,e?e(t):[],1e9-n.length));else{let n,a=t.sliceDoc(i.from,i.to),l=o.filterStrict?new tf(a):new ef(a);for(let t of i.result.options)if(n=l.match(t.label)){let o=t.displayLabel?e?e(t,n.matched):[]:n.matched,a=n.score+(t.boost||0);if(r(new Hd(t,i.source,o,a)),"object"==typeof t.section&&"dynamic"===t.section.rank){let{name:e}=t.section;s||(s=Object.create(null)),s[e]=Math.max(a,s[e]||-1e9)}}}}if(i){let e=Object.create(null),t=0,r=(e,t)=>("dynamic"===e.rank&&"dynamic"===t.rank?s[t.name]-s[e.name]:0)||("number"==typeof e.rank?e.rank:1e9)-("number"==typeof t.rank?t.rank:1e9)||(e.name<t.name?-1:1);for(let n of i.sort(r))t-=1e5,e[n.name]=t;for(let t of n){let{section:n}=t.completion;n&&(t.score+=e["string"==typeof n?n:n.name])}}let a=[],l=null,c=o.compareCompletions;for(let e of n.sort((e,t)=>t.score-e.score||c(e.completion,t.completion))){let t=e.completion;!l||l.label!=t.label||l.detail!=t.detail||null!=l.type&&null!=t.type&&l.type!=t.type||l.apply!=t.apply||l.boost!=t.boost?a.push(e):hf(e.completion)>hf(l)&&(a[a.length-1]=e),l=e.completion}return a}(e,t);if(!o.length)return i&&e.some(e=>e.isPending)?i.setDisabled():null;let a=t.facet(nf).selectOnOpen?0:-1;if(i&&i.selected!=a&&-1!=i.selected){let e=i.options[i.selected].completion;for(let t=0;t<o.length;t++)if(o[t].completion==e){a=t;break}}return new uf(o,mf(n,a),{pos:e.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:Sf,above:s.aboveCursor},i?i.timestamp:Date.now(),a,!1)}map(e){return new uf(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new uf(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class df{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new df(gf,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(e){let{state:t}=e,n=t.facet(nf),i=(n.override||t.languageDataAt("autocomplete",qd(t)).map(Gd)).map(t=>{let i=this.active.find(e=>e.source==t)||new vf(t,this.active.some(e=>0!=e.state)?1:0);return i.update(e,n)});i.length==this.active.length&&i.every((e,t)=>e==this.active[t])&&(i=this.active);let s=this.open,r=e.effects.some(e=>e.is(wf));s&&e.docChanged&&(s=s.map(e.changes)),e.selection||i.some(t=>t.hasResult()&&e.changes.touchesRange(t.from,t.to))||!function(e,t){if(e==t)return!0;for(let n=0,i=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;i<t.length&&!t[i].hasResult();)i++;let s=n==e.length,r=i==t.length;if(s||r)return s==r;if(e[n++].result!=t[i++].result)return!1}}(i,this.active)||r?s=uf.build(i,t,this.id,s,n,r):s&&s.disabled&&!i.some(e=>e.isPending)&&(s=null),!s&&i.every(e=>!e.isPending)&&i.some(e=>e.hasResult())&&(i=i.map(e=>e.hasResult()?new vf(e.source,0):e));for(let t of e.effects)t.is(of)&&(s=s&&s.setSelected(t.value,this.id));return i==this.active&&s==this.open?this:new df(i,this.id,s)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?ff:pf}}const ff={"aria-autocomplete":"list"},pf={};function mf(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const gf=[];function yf(e,t){if(e.isUserEvent("input.complete")){let n=e.annotation(Jd);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent("input.type");return n&&t.activateOnTyping?5:n?1:e.isUserEvent("delete.backward")?2:e.selection?8:e.docChanged?16:0}class vf{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return 1==this.state}update(e,t){let n=yf(e,t),i=this;(8&n||16&n&&this.touches(e))&&(i=new vf(i.source,0)),4&n&&0==i.state&&(i=new vf(this.source,1)),i=i.updateFor(e,n);for(let t of e.effects)if(t.is(Qd))i=new vf(i.source,1,t.value);else if(t.is(Xd))i=new vf(i.source,0);else if(t.is(wf))for(let e of t.value)e.source==i.source&&(i=e);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(qd(e.state))}}class bf extends vf{constructor(e,t,n,i,s,r){super(e,3,t),this.limit=n,this.result=i,this.from=s,this.to=r}hasResult(){return!0}updateFor(e,t){var n;if(!(3&t))return this.map(e.changes);let i=this.result;i.map&&!e.changes.empty&&(i=i.map(i,e.changes));let s=e.changes.mapPos(this.from),r=e.changes.mapPos(this.to,1),o=qd(e.state);if(o>r||!i||2&t&&(qd(e.startState)==this.from||o<this.limit))return new vf(this.source,4&t?1:0);let a=e.changes.mapPos(this.limit);return function(e,t,n,i){if(!e)return!1;let s=t.sliceDoc(n,i);return"function"==typeof e?e(s,n,i,t):Kd(e,!0).test(s)}(i.validFor,e.state,s,r)?new bf(this.source,this.explicit,a,i,s,r):i.update&&(i=i.update(i,s,r,new Ud(e.state,o,!1)))?new bf(this.source,this.explicit,a,i,i.from,null!==(n=i.to)&&void 0!==n?n:qd(e.state)):new vf(this.source,1,this.explicit)}map(e){if(e.empty)return this;return(this.result.map?this.result.map(this.result,e):this.result)?new bf(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new vf(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}const wf=Vt.define({map:(e,t)=>e.map(e=>e.map(t))}),kf=kt.define({create:()=>df.start(),update:(e,t)=>e.update(t),provide:e=>[Ja.from(e,e=>e.tooltip),Fo.contentAttributes.from(e,e=>e.attrs)]});function xf(e,t){const n=t.completion.apply||t.completion.label;let i=e.state.field(kf).active.find(e=>e.source==t.source);return i instanceof bf&&("string"==typeof n?e.dispatch({...Zd(e.state,n,i.from,i.to),annotations:Jd.of(t.completion)}):n(e,t.completion,i.from,i.to),!0)}const Sf=cf(kf,xf);function Cf(e,t="option"){return n=>{let i=n.state.field(kf,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<n.state.facet(nf).interactionDelay)return!1;let s,r=1;"page"==t&&(s=tl(n,i.open.tooltip))&&(r=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:o}=i.open.options,a=i.open.selected>-1?i.open.selected+r*(e?1:-1):e?0:o-1;return a<0?a="page"==t?0:o-1:a>=o&&(a="page"==t?o-1:0),n.dispatch({effects:of.of(a)}),!0}}const Af=e=>!!e.state.field(kf,!1)&&(e.dispatch({effects:Qd.of(!0)}),!0);class Tf{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const Of=ys.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(kf).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(kf),n=e.state.facet(nf);if(!e.selectionSet&&!e.docChanged&&e.startState.field(kf)==t)return;let i=e.transactions.some(e=>{let t=yf(e,n);return 8&t||(e.selection||e.docChanged)&&!(3&t)});for(let t=0;t<this.running.length;t++){let n=this.running[t];if(i||n.context.abortOnDocChange&&e.docChanged||n.updates.length+e.transactions.length>50&&Date.now()-n.time>1e3){for(let e of n.context.abortListeners)try{e()}catch(e){fs(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(Qd)))&&(this.pendingStart=!0);let s=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),s):-1,0!=this.composing)for(let t of e.transactions)t.isUserEvent("input.type")?this.composing=2:2==this.composing&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(kf);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(nf).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=qd(t),i=new Ud(t,n,e.explicit,this.view),s=new Tf(e,i);this.running.push(s),Promise.resolve(e.source(i)).then(e=>{s.context.aborted||(s.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:Xd.of(null)}),fs(this.view.state,e)})}scheduleAccept(){this.running.every(e=>void 0!==e.done)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(nf).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(nf),i=this.view.state.field(kf);for(let s=0;s<this.running.length;s++){let r=this.running[s];if(void 0===r.done)continue;if(this.running.splice(s--,1),r.done){let i=qd(r.updates.length?r.updates[0].startState:this.view.state),s=Math.min(i,r.done.from+(r.active.explicit?0:1)),o=new bf(r.active.source,r.active.explicit,s,r.done,r.done.from,null!==(e=r.done.to)&&void 0!==e?e:i);for(let e of r.updates)o=o.update(e,n);if(o.hasResult()){t.push(o);continue}}let o=i.active.find(e=>e.source==r.active.source);if(o&&o.isPending)if(null==r.done){let e=new vf(r.active.source,0);for(let t of r.updates)e=e.update(t,n);e.isPending||t.push(e)}else this.startQuery(o)}(t.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:wf.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(kf,!1);if(t&&t.tooltip&&this.view.state.facet(nf).closeOnBlur){let n=t.open&&tl(this.view,t.open.tooltip);n&&n.dom.contains(e.relatedTarget)||setTimeout(()=>this.view.dispatch({effects:Xd.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout(()=>this.view.dispatch({effects:Qd.of(!1)}),20),this.composing=0}}}),Mf="object"==typeof navigator&&/Win/.test(navigator.platform),Ef=Ot.highest(Fo.domEventHandlers({keydown(e,t){let n=t.state.field(kf,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&(!Mf||!e.altKey)||e.metaKey)return!1;let i=n.open.options[n.open.selected],s=n.active.find(e=>e.source==i.source),r=i.completion.commitCharacters||s.result.commitCharacters;return r&&r.indexOf(e.key)>-1&&xf(t,i),!1}})),Nf=Fo.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"},".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"}}}),Df={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},_f=Vt.define({map(e,t){let n=t.mapPos(e,-1,tt.TrackAfter);return null==n?void 0:n}}),Pf=new class extends rn{};Pf.startSide=1,Pf.endSide=-1;const If=kt.define({create:()=>hn.empty,update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:e=>e>=n.from&&e<=n.to})}for(let n of t.effects)n.is(_f)&&(e=e.update({add:[Pf.range(n.value,n.value+1)]}));return e}});function Rf(){return[jf,If]}const $f="()[]{}<>«»»«[]{}";function Bf(e){for(let t=0;t<16;t+=2)if($f.charCodeAt(t)==e)return $f.charAt(t+1);return Qe(e<128?e:e+1)}function Lf(e,t){return e.languageDataAt("closeBrackets",t)[0]||Df}const zf="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),jf=Fo.inputHandler.of((e,t,n,i)=>{if((zf?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let s=e.state.selection.main;if(i.length>2||2==i.length&&1==Xe(Ge(i,0))||t!=s.from||n!=s.to)return!1;let r=function(e,t){let n=Lf(e,e.selection.main.head),i=n.brackets||Df.brackets;for(let s of i){let r=Bf(Ge(s,0));if(t==s)return r==s?qf(e,s,i.indexOf(s+s+s)>-1,n):Vf(e,s,r,n.before||Df.before);if(t==r&&Uf(e,e.selection.main.from))return Hf(e,s,r)}return null}(e.state,i);return!!r&&(e.dispatch(r),!0)}),Wf=[{key:"Backspace",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Lf(e,e.selection.main.head).brackets||Df.brackets,i=null,s=e.changeByRange(t=>{if(t.empty){let i=function(e,t){let n=e.sliceString(t-2,t);return Xe(Ge(n,0))==n.length?n:n.slice(1)}(e.doc,t.head);for(let s of n)if(s==i&&Ff(e.doc,t.head)==Bf(Ge(s,0)))return{changes:{from:t.head-s.length,to:t.head+s.length},range:ut.cursor(t.head-s.length)}}return{range:i=t}});return i||t(e.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!i}}];function Uf(e,t){let n=!1;return e.field(If).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function Ff(e,t){let n=e.sliceString(t,t+2);return n.slice(0,Xe(Ge(n,0)))}function Vf(e,t,n,i){let s=null,r=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:n,from:r.to}],effects:_f.of(r.to+t.length),range:ut.range(r.anchor+t.length,r.head+t.length)};let o=Ff(e.doc,r.head);return!o||/\s/.test(o)||i.indexOf(o)>-1?{changes:{insert:t+n,from:r.head},effects:_f.of(r.head+t.length),range:ut.cursor(r.head+t.length)}:{range:s=r}});return s?null:e.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function Hf(e,t,n){let i=null,s=e.changeByRange(t=>t.empty&&Ff(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:ut.cursor(t.head+n.length)}:i={range:t});return i?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function qf(e,t,n,i){let s=i.stringPrefixes||Df.stringPrefixes,r=null,o=e.changeByRange(i=>{if(!i.empty)return{changes:[{insert:t,from:i.from},{insert:t,from:i.to}],effects:_f.of(i.to+t.length),range:ut.range(i.anchor+t.length,i.head+t.length)};let o,a=i.head,l=Ff(e.doc,a);if(l==t){if(Kf(e,a))return{changes:{insert:t+t,from:a},effects:_f.of(a+t.length),range:ut.cursor(a+t.length)};if(Uf(e,a)){let i=n&&e.sliceDoc(a,a+3*t.length)==t+t+t?t+t+t:t;return{changes:{from:a,to:a+i.length,insert:i},range:ut.cursor(a+i.length)}}}else{if(n&&e.sliceDoc(a-2*t.length,a)==t+t&&(o=Jf(e,a-2*t.length,s))>-1&&Kf(e,o))return{changes:{insert:t+t+t+t,from:a},effects:_f.of(a+t.length),range:ut.cursor(a+t.length)};if(e.charCategorizer(a)(l)!=Qt.Word&&Jf(e,a,s)>-1&&!function(e,t,n,i){let s=Fl(e).resolveInner(t,-1),r=i.reduce((e,t)=>Math.max(e,t.length),0);for(let o=0;o<5;o++){let o=e.sliceDoc(s.from,Math.min(s.to,s.from+n.length+r)),a=o.indexOf(n);if(!a||a>-1&&i.indexOf(o.slice(0,a))>-1){let t=s.firstChild;for(;t&&t.from==s.from&&t.to-t.from>n.length+a;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let l=s.to==t&&s.parent;if(!l)break;s=l}return!1}(e,a,t,s))return{changes:{insert:t+t,from:a},effects:_f.of(a+t.length),range:ut.cursor(a+t.length)}}return{range:r=i}});return r?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function Kf(e,t){let n=Fl(e).resolveInner(t+1);return n.parent&&n.from==t}function Jf(e,t,n){let i=e.charCategorizer(t);if(i(e.sliceDoc(t-1,t))!=Qt.Word)return t;for(let s of n){let n=t-s.length;if(e.sliceDoc(n,t)==s&&i(e.sliceDoc(n-1,n))!=Qt.Word)return n}return-1}function Zf(e={}){return[Ef,kf,nf.of(e),Of,Gf,Nf]}const Yf=[{key:"Ctrl-Space",run:Af},{mac:"Alt-`",run:Af},{mac:"Alt-i",run:Af},{key:"Escape",run:e=>{let t=e.state.field(kf,!1);return!(!t||!t.active.some(e=>0!=e.state))&&(e.dispatch({effects:Xd.of(null)}),!0)}},{key:"ArrowDown",run:Cf(!0)},{key:"ArrowUp",run:Cf(!1)},{key:"PageDown",run:Cf(!0,"page")},{key:"PageUp",run:Cf(!1,"page")},{key:"Enter",run:e=>{let t=e.state.field(kf,!1);return!(e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(nf).interactionDelay)&&xf(e,t.open.options[t.open.selected])}}],Gf=Ot.highest(Go.computeN([nf],e=>e.facet(nf).defaultKeymap?[Yf]:[]));class Qf{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}}class Xf{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let i=n.facet(fp).markerFilter;i&&(e=i(e,n));let s=e.slice().sort((e,t)=>e.from-t.from||e.to-t.to),r=new un,o=[],a=0,l=n.doc.iter(),c=0,h=n.doc.length;for(let e=0;;){let t,n,i=e==s.length?null:s[e];if(!i&&!o.length)break;if(o.length)t=a,n=o.reduce((e,t)=>Math.min(e,t.to),i&&i.from>t?i.from:1e8);else{if(t=i.from,t>h)break;n=i.to,o.push(i),e++}for(;e<s.length;){let i=s[e];if(i.from!=t||!(i.to>i.from||i.to==t)){n=Math.min(i.from,n);break}o.push(i),e++,n=Math.min(i.to,n)}n=Math.min(n,h);let u=!1;if(o.some(e=>e.from==t&&(e.to==n||n==h))&&(u=t==n,!u&&n-t<10)){let e=t-(c+l.value.length);e>0&&(l.next(e),c=t);for(let e=t;;){if(e>=n){u=!0;break}if(!l.lineBreak&&c+l.value.length>e)break;e=c+l.value.length,c+=l.value.length,l.next()}}let d=Ap(o);if(u)r.add(t,t,ii.widget({widget:new vp(d),diagnostics:o.slice()}));else{let e=o.reduce((e,t)=>t.markClass?e+" "+t.markClass:e,"");r.add(t,n,ii.mark({class:"cm-lintRange cm-lintRange-"+d+e,diagnostics:o.slice(),inclusiveEnd:o.some(e=>e.to>n)}))}if(a=n,a==h)break;for(let e=0;e<o.length;e++)o[e].to<=a&&o.splice(e--,1)}let u=r.finish();return new Xf(u,t,ep(u))}}function ep(e,t=null,n=0){let i=null;return e.between(n,1e9,(e,n,{spec:s})=>{if(!(t&&s.diagnostics.indexOf(t)<0))if(i){if(s.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new Qf(i.from,n,i.diagnostic)}else i=new Qf(e,n,t||s.diagnostics[0])}),i}function tp(e,t){let n=t.pos,i=t.end||n,s=e.state.facet(fp).hideOn(e,n,i);if(null!=s)return s;let r=e.startState.doc.lineAt(t.pos);return!(!e.effects.some(e=>e.is(ip))&&!e.changes.touchesRange(r.from,Math.max(r.to,i)))}function np(e,t){return e.field(op,!1)?t:t.concat(Vt.appendConfig.of(Pp))}const ip=Vt.define(),sp=Vt.define(),rp=Vt.define(),op=kt.define({create:()=>new Xf(ii.none,null,null),update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),i=null,s=e.panel;if(e.selected){let s=t.changes.mapPos(e.selected.from,1);i=ep(n,e.selected.diagnostic,s)||ep(n,null,s)}!n.size&&s&&t.state.facet(fp).autoPanel&&(s=null),e=new Xf(n,s,i)}for(let n of t.effects)if(n.is(ip)){let i=t.state.facet(fp).autoPanel?n.value.length?wp.open:null:e.panel;e=Xf.init(n.value,i,t.state)}else n.is(sp)?e=new Xf(e.diagnostics,n.value?wp.open:null,e.selected):n.is(rp)&&(e=new Xf(e.diagnostics,e.panel,n.value));return e},provide:e=>[ll.from(e,e=>e.panel),Fo.decorations.from(e,e=>e.diagnostics)]}),ap=ii.mark({class:"cm-lintRange cm-lintRange-active"});function lp(e,t,n){let i,{diagnostics:s}=e.state.field(op),r=-1,o=-1;s.between(t-(n<0?1:0),t+(n>0?1:0),(e,s,{spec:a})=>{if(t>=e&&t<=s&&(e==s||(t>e||n>0)&&(t<s||n<0)))return i=a.diagnostics,r=e,o=s,!1});let a=e.state.facet(fp).tooltipFilter;return i&&a&&(i=a(i,e.state)),i?{pos:r,end:o,above:e.state.doc.lineAt(r).to<o,create:()=>({dom:cp(e,i)})}:null}function cp(e,t){return $n("ul",{class:"cm-tooltip-lint"},t.map(t=>yp(e,t,!1)))}const hp=e=>{let t=e.state.field(op,!1);return!(!t||!t.panel)&&(e.dispatch({effects:sp.of(!1)}),!0)},up=[{key:"Mod-Shift-m",run:e=>{let t=e.state.field(op,!1);t&&t.panel||e.dispatch({effects:np(e.state,[sp.of(!0)])});let n=sl(e,wp.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:e=>{let t=e.state.field(op,!1);if(!t)return!1;let n=e.state.selection.main,i=ep(t.diagnostics,null,n.to+1);return!(!i&&(i=ep(t.diagnostics,null,0),!i||i.from==n.from&&i.to==n.to))&&(e.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)}}],dp=ys.fromClass(class{constructor(e){this.view=e,this.timeout=-1,this.set=!0;let{delay:t}=e.state.facet(fp);this.lintTime=Date.now()+t,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,t)}run(){clearTimeout(this.timeout);let e=Date.now();if(e<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-e);else{this.set=!1;let{state:e}=this.view,{sources:t}=e.facet(fp);t.length&&function(e,t,n){let i=[],s=-1;for(let r of e)r.then(n=>{i.push(n),clearTimeout(s),i.length==e.length?t(i):s=setTimeout(()=>t(i),200)},n)}(t.map(e=>Promise.resolve(e(this.view))),t=>{this.view.state.doc==e.doc&&this.view.dispatch(function(e,t){return{effects:np(e,[ip.of(t)])}}(this.view.state,t.reduce((e,t)=>e.concat(t))))},e=>{fs(this.view.state,e)})}}update(e){let t=e.state.facet(fp);(e.docChanged||t!=e.startState.facet(fp)||t.needsRefresh&&t.needsRefresh(e))&&(this.lintTime=Date.now()+t.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,t.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});const fp=pt.define({combine:e=>({sources:e.map(e=>e.source).filter(e=>null!=e),...sn(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:pp,tooltipFilter:pp,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,i,s)=>e(n,i,s)||t(n,i,s):e:t,autoPanel:(e,t)=>e||t})})});function pp(e,t){return e?t?(n,i)=>t(e(n,i),i):e:t}function mp(e,t={}){return[fp.of({source:e,config:t}),dp,Pp]}function gp(e){let t=[];if(e)e:for(let{name:n}of e){for(let e=0;e<n.length;e++){let i=n[e];if(/[a-zA-Z]/.test(i)&&!t.some(e=>e.toLowerCase()==i.toLowerCase())){t.push(i);continue e}}t.push("")}return t}function yp(e,t,n){var i;let s=n?gp(t.actions):[];return $n("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},$n("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(e):t.message),null===(i=t.actions)||void 0===i?void 0:i.map((n,i)=>{let r=!1,o=i=>{if(i.preventDefault(),r)return;r=!0;let s=ep(e.state.field(op).diagnostics,t);s&&n.apply(e,s.from,s.to)},{name:a}=n,l=s[i]?a.indexOf(s[i]):-1,c=l<0?a:[a.slice(0,l),$n("u",a.slice(l,l+1)),a.slice(l+1)];return $n("button",{type:"button",class:"cm-diagnosticAction"+(n.markClass?" "+n.markClass:""),onclick:o,onmousedown:o,"aria-label":` Action: ${a}${l<0?"":` (access key "${s[i]})"`}.`},c)}),t.source&&$n("div",{class:"cm-diagnosticSource"},t.source))}class vp extends ti{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return $n("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class bp{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=yp(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class wp{constructor(e){this.view=e,this.items=[];this.list=$n("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(27==t.keyCode)hp(this.view),this.view.focus();else if(38==t.keyCode||33==t.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==t.keyCode||34==t.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==t.keyCode)this.moveSelection(0);else if(35==t.keyCode)this.moveSelection(this.items.length-1);else if(13==t.keyCode)this.view.focus();else{if(!(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0))return;{let{diagnostic:n}=this.items[this.selectedIndex],i=gp(n.actions);for(let s=0;s<i.length;s++)if(i[s].toUpperCase().charCodeAt(0)==t.keyCode){let t=ep(this.view.state.field(op).diagnostics,n);t&&n.actions[s].apply(e,t.from,t.to)}}}t.preventDefault()}},onclick:e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)}}),this.dom=$n("div",{class:"cm-panel-lint"},this.list,$n("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>hp(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(op).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(op),n=0,i=!1,s=null,r=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:a})=>{for(let e of a.diagnostics){if(r.has(e))continue;r.add(e);let o,a=-1;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){a=t;break}a<0?(o=new bp(this.view,e),this.items.splice(n,0,o),i=!0):(o=this.items[a],a>n&&(this.items.splice(n,a-n),i=!0)),t&&o.diagnostic==t.diagnostic?o.dom.hasAttribute("aria-selected")||(o.dom.setAttribute("aria-selected","true"),s=o):o.dom.hasAttribute("aria-selected")&&o.dom.removeAttribute("aria-selected"),n++}});n<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)i=!0,this.items.pop();0==this.items.length&&(this.items.push(new bp(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),i=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:()=>({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=ep(this.view.state.field(op).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:rp.of(t)})}static open(e){return new wp(e)}}function kp(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function xp(e){return kp(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Sp=Fo.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:xp("#d11")},".cm-lintRange-warning":{backgroundImage:xp("orange")},".cm-lintRange-info":{backgroundImage:xp("#999")},".cm-lintRange-hint":{backgroundImage:xp("#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 Cp(e){return"error"==e?4:"warning"==e?3:"info"==e?2:1}function Ap(e){let t="hint",n=1;for(let i of e){let e=Cp(i.severity);e>n&&(n=e,t=i.severity)}return t}class Tp extends fl{constructor(e){super(),this.diagnostics=e,this.severity=Ap(e)}toDOM(e){let t=document.createElement("div");t.className="cm-lint-marker cm-lint-marker-"+this.severity;let n=this.diagnostics,i=e.state.facet(Ip).tooltipFilter;return i&&(n=i(n,e.state)),n.length&&(t.onmouseover=()=>function(e,t,n){function i(){let i=e.elementAtHeight(t.getBoundingClientRect().top+5-e.documentTop);e.coordsAtPos(i.from)&&e.dispatch({effects:Np.of({pos:i.from,above:!1,clip:!1,create:()=>({dom:cp(e,n),getCoords:()=>t.getBoundingClientRect()})})}),t.onmouseout=t.onmousemove=null,function(e,t){let n=i=>{let s=t.getBoundingClientRect();if(!(i.clientX>s.left-10&&i.clientX<s.right+10&&i.clientY>s.top-10&&i.clientY<s.bottom+10)){for(let e=i.target;e;e=e.parentNode)if(1==e.nodeType&&e.classList.contains("cm-tooltip-lint"))return;window.removeEventListener("mousemove",n),e.state.field(Dp)&&e.dispatch({effects:Np.of(null)})}};window.addEventListener("mousemove",n)}(e,t)}let{hoverTime:s}=e.state.facet(Ip),r=setTimeout(i,s);t.onmouseout=()=>{clearTimeout(r),t.onmouseout=t.onmousemove=null},t.onmousemove=()=>{clearTimeout(r),r=setTimeout(i,s)}}(e,t,n)),t}}function Op(e,t){let n=Object.create(null);for(let i of t){let t=e.lineAt(i.from);(n[t.from]||(n[t.from]=[])).push(i)}let i=[];for(let e in n)i.push(new Tp(n[e]).range(+e));return hn.of(i,!0)}const Mp=vl({class:"cm-gutter-lint",markers:e=>e.state.field(Ep),widgetMarker:(e,t,n)=>{let i=[];return e.state.field(Ep).between(n.from,n.to,(e,t,s)=>{e>n.from&&e<n.to&&i.push(...s.diagnostics)}),i.length?new Tp(i):null}}),Ep=kt.define({create:()=>hn.empty,update(e,t){e=e.map(t.changes);let n=t.state.facet(Ip).markerFilter;for(let i of t.effects)if(i.is(ip)){let s=i.value;n&&(s=n(s||[],t.state)),e=Op(t.state.doc,s.slice(0))}return e}}),Np=Vt.define(),Dp=kt.define({create:()=>null,update:(e,t)=>(e&&t.docChanged&&(e=tp(t,e)?null:{...e,pos:t.changes.mapPos(e.pos)}),t.effects.reduce((e,t)=>t.is(Np)?t.value:e,e)),provide:e=>Ja.from(e)}),_p=Fo.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:kp('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:kp('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:kp('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),Pp=[op,Fo.decorations.compute([op],e=>{let{selected:t,panel:n}=e.field(op);return t&&n&&t.from!=t.to?ii.set([ap.range(t.from,t.to)]):ii.none}),el(lp,{hideOn:tp}),Sp],Ip=pt.define({combine:e=>sn(e,{hoverTime:300,markerFilter:null,tooltipFilter:null})});function Rp(e={}){return[Ip.of(e),Ep,Mp,_p,Dp]}const $p=(()=>[Pl(),$l,Oa(),Eh(),$c(),ua(),[va,ba],nn.allowMultipleSelections.of(!0),nn.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:i}=e.newSelection.main,s=n.lineAt(i);if(i>s.from+200)return e;let r=n.sliceString(s.from,i);if(!t.some(e=>e.test(r)))return e;let{state:o}=e,a=-1,l=[];for(let{head:e}of o.selection.ranges){let t=o.doc.lineAt(e);if(t.from==a)continue;a=t.from;let n=sc(o,t.from);if(null==n)continue;let i=/^\s*/.exec(t.text)[0],s=ic(o,n);i!=s&&l.push({from:t.from,to:t.from+i.length,insert:s})}return l.length?[e,{changes:l,sequential:!0}]:e}),Uc(Hc,{fallback:!0}),th(),Rf(),Zf(),Fo.mouseSelectionStyle.of((e,t)=>(e=>e.altKey&&0==e.button)(t)?Ra(e,t):null),La(),_a,[rd,sd],Go.of([...Wf,...Fu,...Id,...qh,...Oc,...Yf,...up])])(),Bp=(()=>[Oa(),Eh(),ua(),Uc(Hc,{fallback:!0}),Go.of([...Fu,...qh])])(),Lp=globalThis,zp=Lp.ShadowRoot&&(void 0===Lp.ShadyCSS||Lp.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,jp=Symbol(),Wp=new WeakMap;let Up=class{constructor(e,t,n){if(this._$cssResult$=!0,n!==jp)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(zp&&void 0===e){const n=void 0!==t&&1===t.length;n&&(e=Wp.get(t)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&Wp.set(t,e))}return e}toString(){return this.cssText}};const Fp=(e,...t)=>{const n=1===e.length?e[0]:t.reduce((t,n,i)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if("number"==typeof e)return e;throw Error("Value passed to 'css' function must be a 'css' function result: "+e+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+e[i+1],e[0]);return new Up(n,e,jp)},Vp=zp?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const n of e.cssRules)t+=n.cssText;return(e=>new Up("string"==typeof e?e:e+"",void 0,jp))(t)})(e):e,{is:Hp,defineProperty:qp,getOwnPropertyDescriptor:Kp,getOwnPropertyNames:Jp,getOwnPropertySymbols:Zp,getPrototypeOf:Yp}=Object,Gp=globalThis,Qp=Gp.trustedTypes,Xp=Qp?Qp.emptyScript:"",em=Gp.reactiveElementPolyfillSupport,tm=(e,t)=>e,nm={toAttribute(e,t){switch(t){case Boolean:e=e?Xp:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=null!==e;break;case Number:n=null===e?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch(e){n=null}}return n}},im=(e,t)=>!Hp(e,t),sm={attribute:!0,type:String,converter:nm,reflect:!1,useDefault:!1,hasChanged:im};
|
|
1
|
+
var SkirFormatConverter=function(e){"use strict";const t=1024;let n=0,i=class{constructor(e,t){this.from=e,this.to=t}};class s{constructor(e={}){this.id=n++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof e&&(e=a.match(e)),t=>{let n=e(t);return void 0===n?null:[this,n]}}}s.closedBy=new s({deserialize:e=>e.split(" ")}),s.openedBy=new s({deserialize:e=>e.split(" ")}),s.group=new s({deserialize:e=>e.split(" ")}),s.isolate=new s({deserialize:e=>{if(e&&"rtl"!=e&&"ltr"!=e&&"auto"!=e)throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}}),s.contextHash=new s({perNode:!0}),s.lookAhead=new s({perNode:!0}),s.mounted=new s({perNode:!0});class r{constructor(e,t,n,i=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=i}static get(e){return e&&e.props&&e.props[s.mounted.id]}}const o=Object.create(null);class a{constructor(e,t,n,i=0){this.name=e,this.props=t,this.id=n,this.flags=i}static define(e){let t=e.props&&e.props.length?Object.create(null):o,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(null==e.name?8:0),i=new a(e.name||"",t,e.id,n);if(e.props)for(let n of e.props)if(Array.isArray(n)||(n=n(i)),n){if(n[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[n[0].id]=n[1]}return i}prop(e){return this.props[e.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(e){if("string"==typeof e){if(this.name==e)return!0;let t=this.prop(s.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let i of n.split(" "))t[i]=e[n];return e=>{for(let n=e.prop(s.group),i=-1;i<(n?n.length:0);i++){let s=t[i<0?e.name:n[i]];if(s)return s}}}}a.none=new a("",Object.create(null),0,8);class l{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let n of this.types){let i=null;for(let t of e){let e=t(n);if(e){i||(i=Object.assign({},n.props));let t=e[1],s=e[0];s.combine&&s.id in i&&(t=s.combine(i[s.id],t)),i[s.id]=t}}t.push(i?new a(n.name,i,n.id,n.flags):n)}return new l(t)}}const c=new WeakMap,h=new WeakMap;var u;!function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays",e[e.EnterBracketed=16]="EnterBracketed"}(u||(u={}));class d{constructor(e,t,n,i,s){if(this.type=e,this.children=t,this.positions=n,this.length=i,this.props=null,s&&s.length){this.props=Object.create(null);for(let[e,t]of s)this.props["number"==typeof e?e:e.id]=t}}toString(){let e=r.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let e of this.children){let n=e.toString();n&&(t&&(t+=","),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new A(this.topNode,e)}cursorAt(e,t=0,n=0){let i=c.get(this)||this.topNode,s=new A(i);return s.moveTo(e,t),c.set(this,s._tree),s}get topNode(){return new y(this,0,0,null)}resolve(e,t=0){let n=g(c.get(this)||this.topNode,e,t,!1);return c.set(this,n),n}resolveInner(e,t=0){let n=g(h.get(this)||this.topNode,e,t,!0);return h.set(this,n),n}resolveStack(e,t=0){return function(e,t,n){let i=e.resolveInner(t,n),s=null;for(let e=i instanceof y?i:i.context.parent;e;e=e.parent)if(e.index<0){let r=e.parent;(s||(s=[i])).push(r.resolve(t,n)),e=r}else{let o=r.get(e.tree);if(o&&o.overlay&&o.overlay[0].from<=t&&o.overlay[o.overlay.length-1].to>=t){let r=new y(o.tree,o.overlay[0].from+e.from,-1,e);(s||(s=[i])).push(g(r,t,n,!1))}}return s?S(s):i}(this,e,t)}iterate(e){let{enter:t,leave:n,from:i=0,to:s=this.length}=e,r=e.mode||0,o=(r&u.IncludeAnonymous)>0;for(let e=this.cursor(r|u.IncludeAnonymous);;){let r=!1;if(e.from<=s&&e.to>=i&&(!o&&e.type.isAnonymous||!1!==t(e))){if(e.firstChild())continue;r=!0}for(;r&&n&&(o||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;r=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:M(a.none,this.children,this.positions,0,this.children.length,0,this.length,(e,t,n)=>new d(this.type,e,t,n,this.propValues),e.makeTree||((e,t,n)=>new d(a.none,e,t,n)))}static build(e){return function(e){var n;let{buffer:i,nodeSet:r,maxBufferLength:o=t,reused:a=[],minRepeatType:l=r.types.length}=e,c=Array.isArray(i)?new f(i,i.length):i,h=r.types,u=0,m=0;function g(e,t,n,i,s,d){let{id:f,start:S,end:C,size:A}=c,T=m,N=u;if(A<0){if(c.next(),-1==A){let t=a[f];return n.push(t),void i.push(S-e)}if(-3==A)return void(u=f);if(-4==A)return void(m=f);throw new RangeError(`Unrecognized record size: ${A}`)}let O,E,D=h[f],_=S-e;if(C-S<=o&&(E=w(c.pos-t,s))){let t=new Uint16Array(E.size-E.skip),n=c.pos-E.size,i=t.length;for(;c.pos>n;)i=x(E.start,t,i);O=new p(t,C-E.start,r),_=E.start-e}else{let e=c.pos-A;c.next();let t=[],n=[],i=f>=l?f:-1,s=0,r=C;for(;c.pos>e;)i>=0&&c.id==i&&c.size>=0?(c.end<=r-o&&(v(t,n,S,s,c.end,r,i,T,N),s=t.length,r=c.end),c.next()):d>2500?b(S,e,t,n):g(S,e,t,n,i,d+1);if(i>=0&&s>0&&s<t.length&&v(t,n,S,s,S,r,i,T,N),t.reverse(),n.reverse(),i>-1&&s>0){let e=y(D,N);O=M(D,t,n,0,t.length,0,C-S,e,e)}else O=k(D,t,n,C-S,T-C,N)}n.push(O),i.push(_)}function b(e,t,n,i){let s=[],a=0,l=-1;for(;c.pos>t;){let{id:e,start:t,end:n,size:i}=c;if(i>4)c.next();else{if(l>-1&&t<l)break;l<0&&(l=n-o),s.push(e,t,n),a++,c.next()}}if(a){let t=new Uint16Array(4*a),o=s[s.length-2];for(let e=s.length-3,n=0;e>=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-o,t[n++]=s[e+2]-o,t[n++]=n;n.push(new p(t,s[2]-o,r)),i.push(o-e)}}function y(e,t){return(n,i,r)=>{let o,a,l=0,c=n.length-1;if(c>=0&&(o=n[c])instanceof d){if(!c&&o.type==e&&o.length==r)return o;(a=o.prop(s.lookAhead))&&(l=i[c]+o.length+a)}return k(e,n,i,r,l,t)}}function v(e,t,n,i,s,o,a,l,c){let h=[],u=[];for(;e.length>i;)h.push(e.pop()),u.push(t.pop()+n-s);e.push(k(r.types[a],h,u,o-s,l-o,c)),t.push(s-n)}function k(e,t,n,i,r,o,a){if(o){let e=[s.contextHash,o];a=a?[e].concat(a):[e]}if(r>25){let e=[s.lookAhead,r];a=a?[e].concat(a):[e]}return new d(e,t,n,i,a)}function w(e,t){let n=c.fork(),i=0,s=0,r=0,a=n.end-o,h={size:0,start:0,skip:0};e:for(let o=n.pos-e;n.pos>o;){let e=n.size;if(n.id==t&&e>=0){h.size=i,h.start=s,h.skip=r,r+=4,i+=4,n.next();continue}let c=n.pos-e;if(e<0||c<o||n.start<a)break;let u=n.id>=l?4:0,d=n.start;for(n.next();n.pos>c;){if(n.size<0){if(-3!=n.size&&-4!=n.size)break e;u+=4}else n.id>=l&&(u+=4);n.next()}s=d,i+=e,r+=u}return(t<0||i==e)&&(h.size=i,h.start=s,h.skip=r),h.size>4?h:void 0}function x(e,t,n){let{id:i,start:s,end:r,size:o}=c;if(c.next(),o>=0&&i<l){let a=n;if(o>4){let i=c.pos-(o-4);for(;c.pos>i;)n=x(e,t,n)}t[--n]=a,t[--n]=r-e,t[--n]=s-e,t[--n]=i}else-3==o?u=i:-4==o&&(m=i);return n}let S=[],C=[];for(;c.pos>0;)g(e.start||0,e.bufferStart||0,S,C,-1,0);let A=null!==(n=e.length)&&void 0!==n?n:S.length?C[0]+S[0].length:0;return new d(h[e.topID],S.reverse(),C.reverse(),A)}(e)}}d.empty=new d(a.none,[],[],0);class f{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new f(this.buffer,this.index)}}class p{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return a.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],n=this.buffer[e+3],i=this.set.types[t],s=i.name;if(/\W/.test(s)&&!i.isError&&(s=JSON.stringify(s)),n==(e+=4))return s;let r=[];for(;e<n;)r.push(this.childString(e)),e=this.buffer[e+3];return s+"("+r.join(",")+")"}findChild(e,t,n,i,s){let{buffer:r}=this,o=-1;for(let a=e;a!=t&&!(m(s,i,r[a+1],r[a+2])&&(o=a,n>0));a=r[a+3]);return o}slice(e,t,n){let i=this.buffer,s=new Uint16Array(t-e),r=0;for(let o=e,a=0;o<t;){s[a++]=i[o++],s[a++]=i[o++]-n;let t=s[a++]=i[o++]-n;s[a++]=i[o++]-e,r=Math.max(r,t)}return new p(s,r,this.set)}}function m(e,t,n,i){switch(e){case-2:return n<t;case-1:return i>=t&&n<t;case 0:return n<t&&i>t;case 1:return n<=t&&i>t;case 2:return i>t;case 4:return!0}}function g(e,t,n,i){for(var s;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!i&&e instanceof y&&e.index<0?null:e.parent;if(!t)return e;e=t}let r=i?0:u.IgnoreOverlays;if(i)for(let i=e,o=i.parent;o;i=o,o=i.parent)i instanceof y&&i.index<0&&(null===(s=o.enter(t,n,r))||void 0===s?void 0:s.from)!=i.from&&(e=o);for(;;){let i=e.enter(t,n,r);if(!i)return e;e=i}}class b{cursor(e=0){return new A(this,e)}getChild(e,t=null,n=null){let i=v(this,e,t,n);return i.length?i[0]:null}getChildren(e,t=null,n=null){return v(this,e,t,n)}resolve(e,t=0){return g(this,e,t,!1)}resolveInner(e,t=0){return g(this,e,t,!0)}matchContext(e){return k(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}}class y extends b{constructor(e,t,n,i){super(),this._tree=e,this.from=t,this.index=n,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,n,i,s=0){for(let o=this;;){for(let{children:a,positions:l}=o._tree,c=t>0?a.length:-1;e!=c;e+=t){let c,h=a[e],f=l[e]+o.from;if(s&u.EnterBracketed&&h instanceof d&&(c=r.get(h))&&!c.overlay&&c.bracketed&&n>=f&&n<=f+h.length||m(i,n,f,f+h.length))if(h instanceof p){if(s&u.ExcludeBuffers)continue;let r=h.findChild(0,h.buffer.length,t,n-f,i);if(r>-1)return new x(new w(o,h,e,f),null,r)}else if(s&u.IncludeAnonymous||!h.type.isAnonymous||T(h)){let a;if(!(s&u.IgnoreMounts)&&(a=r.get(h))&&!a.overlay)return new y(a.tree,f,e,o);let l=new y(h,f,e,o);return s&u.IncludeAnonymous||!l.type.isAnonymous?l:l.nextChild(t<0?h.children.length-1:0,t,n,i,s)}}if(s&u.IncludeAnonymous||!o.type.isAnonymous)return null;if(e=o.index>=0?o.index+t:t<0?-1:o._parent._tree.children.length,o=o._parent,!o)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,n=0){let i;if(!(n&u.IgnoreOverlays)&&(i=r.get(this._tree))&&i.overlay){let s=e-this.from,r=n&u.EnterBracketed&&i.bracketed;for(let{from:e,to:n}of i.overlay)if((t>0||r?e<=s:e<s)&&(t<0||r?n>=s:n>s))return new y(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function v(e,t,n,i){let s=e.cursor(),r=[];if(!s.firstChild())return r;if(null!=n)for(let e=!1;!e;)if(e=s.type.is(n),!s.nextSibling())return r;for(;;){if(null!=i&&s.type.is(i))return r;if(s.type.is(t)&&r.push(s.node),!s.nextSibling())return null==i?r:[]}}function k(e,t,n=t.length-1){for(let i=e;n>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(t[n]&&t[n]!=i.name)return!1;n--}}return!0}class w{constructor(e,t,n,i){this.parent=e,this.buffer=t,this.index=n,this.start=i}}class x 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(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.context.start,n);return s<0?null:new x(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,n=0){if(n&u.ExcludeBuffers)return null;let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new x(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new x(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new x(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,i=this.index+4,s=n.buffer[this.index+3];if(s>i){let r=n.buffer[this.index+1];e.push(n.slice(i,s,r)),t.push(0)}return new d(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function S(e){if(!e.length)return null;let t=0,n=e[0];for(let i=1;i<e.length;i++){let s=e[i];(s.from>n.from||s.to<n.to)&&(n=s,t=i)}let i=n instanceof y&&n.index<0?null:n.parent,s=e.slice();return i?s[t]=i:s.splice(t,1),new C(s,n)}class C{constructor(e,t){this.heads=e,this.node=t}get next(){return S(this.heads)}}class A{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~u.EnterBracketed,e instanceof y)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return!!e&&(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0)}yieldBuf(e,t){this.index=e;let{start:n,buffer:i}=this.buffer;return this.type=t||i.set.types[i.buffer[e]],this.from=n+i.buffer[e+1],this.to=n+i.buffer[e+2],!0}yield(e){return!!e&&(e instanceof y?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:i}=this.buffer,s=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.buffer.start,n);return!(s<0)&&(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?!(n&u.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&u.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&u.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode));let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:i}=this;if(i){if(e>0){if(this.index<i.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(i.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=i)}else({index:t,_parent:n}=this._tree);for(;n;({index:t,_parent:n}=n))if(t>-1)for(let i=t+e,s=e<0?-1:n._tree.children.length;i!=s;i+=e){let e=n._tree.children[i];if(this.mode&u.IncludeAnonymous||e instanceof p||!e.type.isAnonymous||T(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)e:for(let i=this.index,s=this.stack.length;s>=0;){for(let r=e;r;r=r._parent)if(r.index==i){if(i==this.index)return r;t=r,n=s+1;break e}i=this.stack[--s]}for(let e=n;e<this.stack.length;e++)t=new x(this.buffer,t,this.stack[e]);return this.bufferNode=new x(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let i=!1;if(this.type.isAnonymous||!1!==e(this)){if(this.firstChild()){n++;continue}this.type.isAnonymous||(i=!0)}for(;;){if(i&&t&&t(this),i=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,i=!0}}}matchContext(e){if(!this.buffer)return k(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let i=e.length-1,s=this.stack.length-1;i>=0;s--){if(s<0)return k(this._tree,e,i);let r=n[t.buffer[this.stack[s]]];if(!r.isAnonymous){if(e[i]&&e[i]!=r.name)return!1;i--}}return!0}}function T(e){return e.children.some(e=>e instanceof p||!e.type.isAnonymous||T(e))}const N=new WeakMap;function O(e,t){if(!e.isAnonymous||t instanceof p||t.type!=e)return 1;let n=N.get(t);if(null==n){n=1;for(let i of t.children){if(i.type!=e||!(i instanceof d)){n=1;break}n+=O(e,i)}N.set(t,n)}return n}function M(e,t,n,i,s,r,o,a,l){let c=0;for(let n=i;n<s;n++)c+=O(e,t[n]);let h=Math.ceil(1.5*c/8),u=[],d=[];return function t(n,i,s,o,a){for(let c=s;c<o;){let s=c,f=i[c],p=O(e,n[c]);for(c++;c<o;c++){let t=O(e,n[c]);if(p+t>=h)break;p+=t}if(c==s+1){if(p>h){let e=n[s];t(e.children,e.positions,0,e.children.length,i[s]+a);continue}u.push(n[s])}else{let t=i[c-1]+n[c-1].length-f;u.push(M(e,n,i,s,c,f,t,null,l))}d.push(f+a-r)}}(t,n,i,s,0),(a||l)(u,d,o)}class E{constructor(e,t,n,i,s=!1,r=!1){this.from=e,this.to=t,this.tree=n,this.offset=i,this.open=(s?1:0)|(r?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e,t=[],n=!1){let i=[new E(0,e.length,e,0,!1,n)];for(let n of t)n.to>e.length&&i.push(n);return i}static applyChanges(e,t,n=128){if(!t.length)return e;let i=[],s=1,r=e.length?e[0]:null;for(let o=0,a=0,l=0;;o++){let c=o<t.length?t[o]:null,h=c?c.fromA:1e9;if(h-a>=n)for(;r&&r.from<h;){let t=r;if(a>=t.from||h<=t.to||l){let e=Math.max(t.from,a)-l,n=Math.min(t.to,h)-l;t=e>=n?null:new E(e,n,t.tree,t.offset+l,o>0,!!c)}if(t&&i.push(t),r.to>h)break;r=s<e.length?e[s++]:null}if(!c)break;a=c.toA,l=c.toA-c.toB}return i}}let D=class{startParse(e,t,n){return"string"==typeof e&&(e=new _(e)),n=n?n.length?n.map(e=>new i(e.from,e.to)):[new i(0,0)]:[new i(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let i=this.startParse(e,t,n);for(;;){let e=i.advance();if(e)return e}}};class _{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new s({perNode:!0});class I{constructor(e,t,n,i,s,r,o,a,l,c=0,h){this.p=e,this.stack=t,this.state=n,this.reducePos=i,this.pos=s,this.score=r,this.buffer=o,this.bufferBase=a,this.curContext=l,this.lookAhead=c,this.parent=h}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,n=0){let i=e.parser.context;return new I(e,[],t,n,n,0,[],0,i?new B(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let n=e>>19,i=65535&e,{parser:s}=this.p,r=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),o=s.dynamicPrecedence(i);if(o&&(this.score+=o),0==n)return this.pushState(s.getGoto(this.state,i,!0),this.reducePos),i<s.minRepeatTerm&&this.storeNode(i,this.reducePos,this.reducePos,r?8:4,!0),void this.reduceContext(i,this.reducePos);let a=this.stack.length-3*(n-1)-(262144&e?6:0),l=a?this.stack[a-2]:this.p.ranges[0].from,c=this.reducePos-l;c>=2e3&&!(null===(t=this.p.parser.nodeSet.types[i])||void 0===t?void 0:t.isAnonymous)&&(l==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=l,this.p.lastBigReductionSize=c));let h=a?this.stack[a-1]:0,u=this.bufferBase+this.buffer.length-h;if(i<s.minRepeatTerm||131072&e){let e=s.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(i,l,e,u+4,!0)}if(262144&e)this.state=this.stack[a];else{let e=this.stack[a-3];this.state=s.getGoto(e,i,!0)}for(;this.stack.length>a;)this.stack.pop();this.reduceContext(i,l)}storeNode(e,t,n,i=4,s=!1){if(0==e&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let e=this,i=this.buffer.length;if(0==i&&e.parent&&(i=e.bufferBase-e.parent.bufferBase,e=e.parent),i>0&&0==e.buffer[i-4]&&e.buffer[i-1]>-1){if(t==n)return;if(e.buffer[i-2]>=t)return void(e.buffer[i-2]=n)}}if(s&&this.pos!=n){let s=this.buffer.length;if(s>0&&(0!=this.buffer[s-4]||this.buffer[s-1]<0)){let e=!1;for(let t=s;t>0&&this.buffer[t-2]>n;t-=4)if(this.buffer[t-1]>=0){e=!0;break}if(e)for(;s>0&&this.buffer[s-2]>n;)this.buffer[s]=this.buffer[s-4],this.buffer[s+1]=this.buffer[s-3],this.buffer[s+2]=this.buffer[s-2],this.buffer[s+3]=this.buffer[s-1],s-=4,i>4&&(i-=4)}this.buffer[s]=e,this.buffer[s+1]=t,this.buffer[s+2]=n,this.buffer[s+3]=i}else this.buffer.push(e,t,n,i)}shift(e,t,n,i){if(131072&e)this.pushState(65535&e,this.pos);else if(262144&e)this.pos=i,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,i,4);else{let s=e,{parser:r}=this.p;this.pos=i;let o=r.stateFlag(s,1);!o&&(i>n||t<=r.maxNode)&&(this.reducePos=i),this.pushState(s,o?n:Math.min(n,this.reducePos)),this.shiftContext(t,n),t<=r.maxNode&&this.buffer.push(t,n,i,4)}}apply(e,t,n,i){65536&e?this.reduce(e):this.shift(e,t,n,i)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let i=this.pos;this.reducePos=this.pos=i+e.length,this.pushState(t,i),this.buffer.push(n,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let n=e.buffer.slice(t),i=e.bufferBase+t;for(;e&&i==e.bufferBase;)e=e.parent;return new I(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,n,i,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new P(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(0==n)return!1;if(!(65536&n))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let n=[];for(let i,s=0;s<t.length;s+=2)(i=t[s+1])!=this.state&&this.p.parser.hasAction(i,e)&&n.push(t[s],i);if(this.stack.length<120)for(let e=0;n.length<8&&e<t.length;e+=2){let i=t[e+1];n.some((e,t)=>1&t&&e==i)||n.push(t[e],i)}t=n}let n=[];for(let e=0;e<t.length&&n.length<4;e+=2){let i=t[e+1];if(i==this.state)continue;let s=this.split();s.pushState(i,this.pos),s.storeNode(0,s.pos,s.pos,4,!0),s.shiftContext(t[e],this.pos),s.reducePos=this.pos,s.score-=200,n.push(s)}return n}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(65536&t))return!1;if(!e.validAction(this.state,t)){let n=t>>19,i=65535&t,s=this.stack.length-3*n;if(s<0||e.getGoto(this.stack[s],i,!1)<0){let e=this.findForcedReduction();if(null==e)return!1;t=e}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(i,s)=>{if(!t.includes(i))return t.push(i),e.allActions(i,t=>{if(393216&t);else if(65536&t){let n=(t>>19)-s;if(n>1){let i=65535&t,s=this.stack.length-3*n;if(s>=0&&e.getGoto(this.stack[s],i,!1)>=0)return n<<19|65536|i}}else{let e=n(t,s+1);if(null!=e)return e}})};return n(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:e}=this.p;return 65535==e.data[e.stateSlot(this.state,1)]&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||-3!=this.buffer[e])&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||-4!=this.buffer[e])&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new B(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){return!(e<=this.lookAhead)&&(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class B{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class P{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=65535&e,n=e>>19;0==n?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=3*(n-1);let i=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=i}}class R{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,0==this.index&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new R(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;null!=e&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,0==this.index&&this.maybeNext()}fork(){return new R(this.stack,this.pos,this.index)}}function $(e,t=Uint16Array){if("string"!=typeof e)return e;let n=null;for(let i=0,s=0;i<e.length;){let r=0;for(;;){let t=e.charCodeAt(i++),n=!1;if(126==t){r=65535;break}t>=92&&t--,t>=34&&t--;let s=t-32;if(s>=46&&(s-=46,n=!0),r+=s,n)break;r*=46}n?n[s++]=r:n=new t(r)}return n}class L{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const z=new L;let F=class{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=z,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,i=this.rangeIndex,s=this.pos+e;for(;s<n.from;){if(!i)return null;let e=this.ranges[--i];s-=n.from-e.to,n=e}for(;t<0?s>n.to:s>=n.to;){if(i==this.ranges.length-1)return null;let e=this.ranges[++i];s+=e.from-n.to,n=e}return s}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t,n,i=this.chunkOff+e;if(i>=0&&i<this.chunk.length)t=this.pos+e,n=this.chunk.charCodeAt(i);else{let i=this.resolveOffset(e,1);if(null==i)return-1;if(t=i,t>=this.chunk2Pos&&t<this.chunk2Pos+this.chunk2.length)n=this.chunk2.charCodeAt(t-this.chunk2Pos);else{let e=this.rangeIndex,i=this.range;for(;i.to<=t;)i=this.ranges[++e];this.chunk2=this.input.chunk(this.chunk2Pos=t),t+this.chunk2.length>i.to&&(this.chunk2=this.chunk2.slice(0,i.to-t)),n=this.chunk2.charCodeAt(0)}}return t>=this.token.lookAhead&&(this.token.lookAhead=t+1),n}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(null==n||n<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=n}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=z,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n="";for(let i of this.ranges){if(i.from>=t)break;i.to>e&&(n+=this.input.read(Math.max(i.from,e),Math.min(i.to,t)))}return n}};class j{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;!function(e,t,n,i,s,r){let o=0,a=1<<i,{dialect:l}=n.p.parser;e:for(;0!=(a&e[o]);){let n=e[o+1];for(let i=o+3;i<n;i+=2)if((e[i+1]&a)>0){let n=e[i];if(l.allows(n)&&(-1==t.token.value||t.token.value==n||U(n,t.token.value,s,r))){t.acceptToken(n);break}}let i=t.next,c=0,h=e[o+2];if(!(t.next<0&&h>c&&65535==e[n+3*h-3])){for(;c<h;){let s=c+h>>1,r=n+s+(s<<1),a=e[r],l=e[r+1]||65536;if(i<a)h=s;else{if(!(i>=l)){o=e[r+2],t.advance();continue e}c=s+1}}break}o=e[n+3*h-1]}}(this.data,e,t,this.id,n.data,n.tokenPrecTable)}}function W(e,t,n){for(let i,s=t;65535!=(i=e[s]);s++)if(i==n)return s-t;return-1}function U(e,t,n,i){let s=W(n,i,t);return s<0||W(n,i,e)<s}j.prototype.contextual=j.prototype.fallback=j.prototype.extend=!1,j.prototype.fallback=j.prototype.extend=!1;const V="undefined"!=typeof process&&process.env&&/\bparse\b/.test(process.env.LOG);let H=null;function q(e,t,n){let i=e.cursor(u.IncludeAnonymous);for(i.moveTo(t);;)if(!(n<0?i.childBefore(t):i.childAfter(t)))for(;;){if((n<0?i.to<t:i.from>t)&&!i.type.isError)return n<0?Math.max(0,Math.min(i.to-1,t-25)):Math.min(e.length,Math.max(i.from+1,t+25));if(n<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return n<0?0:e.length}}class K{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?q(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?q(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let n=this.trees[t],i=this.index[t];if(i==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let r=n.children[i],o=this.start[t]+n.positions[i];if(o>e)return this.nextStart=o,null;if(r instanceof d){if(o==e){if(o<this.safeFrom)return null;let e=o+r.length;if(e<=this.safeTo){let t=r.prop(s.lookAhead);if(!t||e+t<this.fragment.to)return r}}this.index[t]++,o+r.length>=Math.max(this.safeFrom,e)&&(this.trees.push(r),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+r.length}}}class J{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(e=>new L)}getActions(e){let t=0,n=null,{parser:i}=e.p,{tokenizers:s}=i,r=i.stateSlot(e.state,3),o=e.curContext?e.curContext.hash:0,a=0;for(let i=0;i<s.length;i++){if(!(1<<i&r))continue;let l=s[i],c=this.tokens[i];if((!n||l.fallback)&&((l.contextual||c.start!=e.pos||c.mask!=r||c.context!=o)&&(this.updateCachedToken(c,l,e),c.mask=r,c.context=o),c.lookAhead>c.end+25&&(a=Math.max(c.lookAhead,a)),0!=c.value)){let i=t;if(c.extended>-1&&(t=this.addActions(e,c.extended,c.end,t)),t=this.addActions(e,c.value,c.end,t),!l.extend&&(n=c,t>i))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),n||e.pos!=this.stream.end||(n=new L,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new L,{pos:n,p:i}=e;return t.start=n,t.end=Math.min(n+1,i.stream.end),t.value=n==i.stream.end?i.parser.eofTerm:0,t}updateCachedToken(e,t,n){let i=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(i,e),n),e.value>-1){let{parser:t}=n.p;for(let i=0;i<t.specialized.length;i++)if(t.specialized[i]==e.value){let s=t.specializers[i](this.stream.read(e.start,e.end),n);if(s>=0&&n.p.parser.dialect.allows(s>>1)){1&s?e.extended=s>>1:e.value=s>>1;break}}}else e.value=0,e.end=this.stream.clipPos(i+1)}putAction(e,t,n,i){for(let t=0;t<i;t+=3)if(this.actions[t]==e)return i;return this.actions[i++]=e,this.actions[i++]=t,this.actions[i++]=n,i}addActions(e,t,n,i){let{state:s}=e,{parser:r}=e.p,{data:o}=r;for(let e=0;e<2;e++)for(let a=r.stateSlot(s,e?2:1);;a+=3){if(65535==o[a]){if(1!=o[a+1]){0==i&&2==o[a+1]&&(i=this.putAction(X(o,a+2),t,n,i));break}a=X(o,a+2)}o[a]==t&&(i=this.putAction(X(o,a+1),t,n,i))}return i}}class Z{constructor(e,t,n,i){this.parser=e,this.input=t,this.ranges=i,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 F(t,i),this.tokens=new J(e,this.stream),this.topTerm=e.top[1];let{from:s}=i[0];this.stacks=[I.start(this,e.top[0],s)],this.fragments=n.length&&this.stream.end-s>4*e.bufferLength?new K(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e,t,n=this.stacks,i=this.minStackPos,s=this.stacks=[];if(this.bigReductionCount>300&&1==n.length){let[e]=n;for(;e.forceReduce()&&e.stack.length&&e.stack[e.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let r=0;r<n.length;r++){let o=n[r];for(;;){if(this.tokens.mainToken=null,o.pos>i)s.push(o);else{if(this.advanceStack(o,s,n))continue;{e||(e=[],t=[]),e.push(o);let n=this.tokens.getMainToken(o);t.push(n.value,n.end)}}break}}if(!s.length){let t=e&&function(e){let t=null;for(let n of e){let e=n.p.stoppedAt;(n.pos==n.p.stream.end||null!=e&&n.pos>e)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.score<n.score)&&(t=n)}return t}(e);if(t)return V&&console.log("Finish with "+this.stackID(t)),this.stackToTree(t);if(this.parser.strict)throw V&&e&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+i);this.recovering||(this.recovering=5)}if(this.recovering&&e){let n=null!=this.stoppedAt&&e[0].pos>this.stoppedAt?e[0]:this.runRecovery(e,t,s);if(n)return V&&console.log("Force-finish "+this.stackID(n)),this.stackToTree(n.forceAll())}if(this.recovering){let e=1==this.recovering?1:3*this.recovering;if(s.length>e)for(s.sort((e,t)=>t.score-e.score);s.length>e;)s.pop();s.some(e=>e.reducePos>i)&&this.recovering--}else if(s.length>1){e:for(let e=0;e<s.length-1;e++){let t=s[e];for(let n=e+1;n<s.length;n++){let i=s[n];if(t.sameState(i)||t.buffer.length>500&&i.buffer.length>500){if(!((t.score-i.score||t.buffer.length-i.buffer.length)>0)){s.splice(e--,1);continue e}s.splice(n--,1)}}}s.length>12&&(s.sort((e,t)=>t.score-e.score),s.splice(12,s.length-12))}this.minStackPos=s[0].pos;for(let e=1;e<s.length;e++)s[e].pos<this.minStackPos&&(this.minStackPos=s[e].pos);return null}stopAt(e){if(null!=this.stoppedAt&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,n){let i=e.pos,{parser:r}=this,o=V?this.stackID(e)+" -> ":"";if(null!=this.stoppedAt&&i>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let t=e.curContext&&e.curContext.tracker.strict,n=t?e.curContext.hash:0;for(let a=this.fragments.nodeAt(i);a;){let i=this.parser.nodeSet.types[a.type.id]==a.type?r.getGoto(e.state,a.type.id):-1;if(i>-1&&a.length&&(!t||(a.prop(s.contextHash)||0)==n))return e.useNode(a,i),V&&console.log(o+this.stackID(e)+` (via reuse of ${r.getName(a.type.id)})`),!0;if(!(a instanceof d)||0==a.children.length||a.positions[0]>0)break;let l=a.children[0];if(!(l instanceof d&&0==a.positions[0]))break;a=l}}let a=r.stateSlot(e.state,4);if(a>0)return e.reduce(a),V&&console.log(o+this.stackID(e)+` (via always-reduce ${r.getName(65535&a)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let s=0;s<l.length;){let a=l[s++],c=l[s++],h=l[s++],u=s==l.length||!n,d=u?e:e.split(),f=this.tokens.mainToken;if(d.apply(a,c,f?f.start:d.pos,h),V&&console.log(o+this.stackID(d)+` (via ${65536&a?`reduce of ${r.getName(65535&a)}`:"shift"} for ${r.getName(c)} @ ${i}${d==e?"":", split"})`),u)return!0;d.pos>i?t.push(d):n.push(d)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return Y(e,t),!0}}runRecovery(e,t,n){let i=null,s=!1;for(let r=0;r<e.length;r++){let o=e[r],a=t[r<<1],l=t[1+(r<<1)],c=V?this.stackID(o)+" -> ":"";if(o.deadEnd){if(s)continue;if(s=!0,o.restart(),V&&console.log(c+this.stackID(o)+" (restarted)"),this.advanceFully(o,n))continue}let h=o.split(),u=c;for(let e=0;e<10&&h.forceReduce();e++){if(V&&console.log(u+this.stackID(h)+" (via force-reduce)"),this.advanceFully(h,n))break;V&&(u=this.stackID(h)+" -> ")}for(let e of o.recoverByInsert(a))V&&console.log(c+this.stackID(e)+" (via recover-insert)"),this.advanceFully(e,n);this.stream.end>o.pos?(l==o.pos&&(l++,a=0),o.recoverByDelete(a,l),V&&console.log(c+this.stackID(o)+` (via recover-delete ${this.parser.getName(a)})`),Y(o,n)):(!i||i.score<h.score)&&(i=h)}return i}stackToTree(e){return e.close(),d.build({buffer:R.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(H||(H=new WeakMap)).get(e);return t||H.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function Y(e,t){for(let n=0;n<t.length;n++){let i=t[n];if(i.pos==e.pos&&i.sameState(e))return void(t[n].score<e.score&&(t[n]=e))}t.push(e)}class G{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||0==this.disabled[e]}}class Q extends D{constructor(e){if(super(),this.wrappers=[],14!=e.version)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let n=e.nodeNames.split(" ");this.minRepeatTerm=n.length;for(let t=0;t<e.repeatNodeCount;t++)n.push("");let i=Object.keys(e.topRules).map(t=>e.topRules[t][1]),r=[];for(let e=0;e<n.length;e++)r.push([]);function o(e,t,n){r[e].push([t,t.deserialize(String(n))])}if(e.nodeProps)for(let t of e.nodeProps){let e=t[0];"string"==typeof e&&(e=s[e]);for(let n=1;n<t.length;){let i=t[n++];if(i>=0)o(i,e,t[n++]);else{let s=t[n+-i];for(let r=-i;r>0;r--)o(t[n++],e,s);n++}}}this.nodeSet=new l(n.map((t,n)=>a.define({name:n>=this.minRepeatTerm?void 0:t,id:n,props:r[n],top:i.indexOf(n)>-1,error:0==n,skipped:e.skippedNodes&&e.skippedNodes.indexOf(n)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=t;let c=$(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let e=0;e<this.specializerSpecs.length;e++)this.specialized[e]=this.specializerSpecs[e].term;this.specializers=this.specializerSpecs.map(ee),this.states=$(e.states,Uint32Array),this.data=$(e.stateData),this.goto=$(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(e=>"number"==typeof e?new j(c,e):e),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let i=new Z(this,e,t,n);for(let s of this.wrappers)i=s(i,e,t,n);return i}getGoto(e,t,n=!1){let i=this.goto;if(t>=i[0])return-1;for(let s=i[t+1];;){let t=i[s++],r=1&t,o=i[s++];if(r&&n)return o;for(let n=s+(t>>1);s<n;s++)if(i[s]==e)return o;if(r)return-1}}hasAction(e,t){let n=this.data;for(let i=0;i<2;i++)for(let s,r=this.stateSlot(e,i?2:1);;r+=3){if(65535==(s=n[r])){if(1!=n[r+1]){if(2==n[r+1])return X(n,r+2);break}s=n[r=X(n,r+2)]}if(s==t||0==s)return X(n,r+1)}return 0}stateSlot(e,t){return this.states[6*e+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,e=>e==t||null)}allActions(e,t){let n=this.stateSlot(e,4),i=n?t(n):void 0;for(let n=this.stateSlot(e,1);null==i;n+=3){if(65535==this.data[n]){if(1!=this.data[n+1])break;n=X(this.data,n+2)}i=t(X(this.data,n+1))}return i}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(65535==this.data[n]){if(1!=this.data[n+1])break;n=X(this.data,n+2)}if(!(1&this.data[n+2])){let e=this.data[n+1];t.some((t,n)=>1&n&&t==e)||t.push(this.data[n],e)}}return t}configure(e){let t=Object.assign(Object.create(Q.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let n=this.topRules[e.top];if(!n)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=n}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(t=>{let n=e.tokenizers.find(e=>e.from==t);return n?n.to:t})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((n,i)=>{let s=e.specializers.find(e=>e.from==n.external);if(!s)return n;let r=Object.assign(Object.assign({},n),{external:s.to});return t.specializers[i]=ee(r),r})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),null!=e.strict&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),null!=e.bufferLength&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return null==t?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let i of e.split(" ")){let e=t.indexOf(i);e>=0&&(n[e]=!0)}let i=null;for(let e=0;e<t.length;e++)if(!n[e])for(let n,s=this.dialects[t[e]];65535!=(n=this.data[s++]);)(i||(i=new Uint8Array(this.maxTerm+1)))[n]=1;return new G(e,n,i)}static deserialize(e){return new Q(e)}}function X(e,t){return e[t]|e[t+1]<<16}function ee(e){if(e.external){let t=e.extend?1:0;return(n,i)=>e.external(n,i)<<1|t}return e.get}let te=0;class ne{constructor(e,t,n,i){this.name=e,this.set=t,this.base=n,this.modified=i,this.id=te++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let n="string"==typeof e?e:"?";if(e instanceof ne&&(t=e),null==t?void 0:t.base)throw new Error("Can not derive from a modified tag");let i=new ne(n,[],null,[]);if(i.set.push(i),t)for(let e of t.set)i.set.push(e);return i}static defineModifier(e){let t=new se(e);return e=>e.modified.indexOf(t)>-1?e:se.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}}let ie=0;class se{constructor(e){this.name=e,this.instances=[],this.id=ie++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(n=>n.base==e&&function(e,t){return e.length==t.length&&e.every((e,n)=>e==t[n])}(t,n.modified));if(n)return n;let i=[],s=new ne(e.name,i,e,t);for(let e of t)e.instances.push(s);let r=function(e){let t=[[]];for(let n=0;n<e.length;n++)for(let i=0,s=t.length;i<s;i++)t.push(t[i].concat(e[n]));return t.sort((e,t)=>t.length-e.length)}(t);for(let t of e.set)if(!t.modified.length)for(let e of r)i.push(se.get(t,e));return s}}function re(e){let t=Object.create(null);for(let n in e){let i=e[n];Array.isArray(i)||(i=[i]);for(let e of n.split(" "))if(e){let n=[],s=2,r=e;for(let t=0;;){if("..."==r&&t>0&&t+3==e.length){s=1;break}let i=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(r);if(!i)throw new RangeError("Invalid path: "+e);if(n.push("*"==i[0]?"":'"'==i[0][0]?JSON.parse(i[0]):i[0]),t+=i[0].length,t==e.length)break;let o=e[t++];if(t==e.length&&"!"==o){s=0;break}if("/"!=o)throw new RangeError("Invalid path: "+e);r=e.slice(t)}let o=n.length-1,a=n[o];if(!a)throw new RangeError("Invalid path: "+e);let l=new ae(i,s,o>0?n.slice(0,o):null);t[a]=l.sort(t[a])}}return oe.add(t)}const oe=new s({combine(e,t){let n,i,s;for(;e||t;){if(!e||t&&e.depth>=t.depth?(s=t,t=t.next):(s=e,e=e.next),n&&n.mode==s.mode&&!s.context&&!n.context)continue;let r=new ae(s.tags,s.mode,s.context);n?n.next=r:i=r,n=r}return i}});class ae{constructor(e,t,n,i){this.tags=e,this.mode=t,this.context=n,this.next=i}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}function le(e,t){let n=Object.create(null);for(let t of e)if(Array.isArray(t.tag))for(let e of t.tag)n[e.id]=t.class;else n[t.tag.id]=t.class;let{scope:i,all:s=null}=t||{};return{style:e=>{let t=s;for(let i of e)for(let e of i.set){let i=n[e.id];if(i){t=t?t+" "+i:i;break}}return t},scope:i}}function ce(e,t,n,i=0,s=e.length){let r=new he(i,Array.isArray(t)?t:[t],n);r.highlightRange(e.cursor(),i,s,"",r.highlighters),r.flush(s)}ae.empty=new ae([],2,null);class he{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,i,r){let{type:o,from:a,to:l}=e;if(a>=n||l<=t)return;o.isTop&&(r=this.highlighters.filter(e=>!e.scope||e.scope(o)));let c=i,h=function(e){let t=e.type.prop(oe);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}(e)||ae.empty,u=function(e,t){let n=null;for(let i of e){let e=i.style(t);e&&(n=n?n+" "+e:e)}return n}(r,h.tags);if(u&&(c&&(c+=" "),c+=u,1==h.mode&&(i+=(i?" ":"")+u)),this.startSpan(Math.max(t,a),c),h.opaque)return;let d=e.tree&&e.tree.prop(s.mounted);if(d&&d.overlay){let s=e.node.enter(d.overlay[0].from+a,1),o=this.highlighters.filter(e=>!e.scope||e.scope(d.tree.type)),h=e.firstChild();for(let u=0,f=a;;u++){let p=u<d.overlay.length?d.overlay[u]:null,m=p?p.from+a:l,g=Math.max(t,f),b=Math.min(n,m);if(g<b&&h)for(;e.from<b&&(this.highlightRange(e,g,b,i,r),this.startSpan(Math.min(b,e.to),c),!(e.to>=m)&&e.nextSibling()););if(!p||m>n)break;f=p.to+a,f>t&&(this.highlightRange(s.cursor(),Math.max(t,p.from+a),Math.min(n,f),"",o),this.startSpan(Math.min(n,f),c))}h&&e.parent()}else if(e.firstChild()){d&&(i="");do{if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,i,r),this.startSpan(Math.min(n,e.to),c)}}while(e.nextSibling());e.parent()}}}const ue=ne.define,de=ue(),fe=ue(),pe=ue(fe),me=ue(fe),ge=ue(),be=ue(ge),ye=ue(ge),ve=ue(),ke=ue(ve),we=ue(),xe=ue(),Se=ue(),Ce=ue(Se),Ae=ue(),Te={comment:de,lineComment:ue(de),blockComment:ue(de),docComment:ue(de),name:fe,variableName:ue(fe),typeName:pe,tagName:ue(pe),propertyName:me,attributeName:ue(me),className:ue(fe),labelName:ue(fe),namespace:ue(fe),macroName:ue(fe),literal:ge,string:be,docString:ue(be),character:ue(be),attributeValue:ue(be),number:ye,integer:ue(ye),float:ue(ye),bool:ue(ge),regexp:ue(ge),escape:ue(ge),color:ue(ge),url:ue(ge),keyword:we,self:ue(we),null:ue(we),atom:ue(we),unit:ue(we),modifier:ue(we),operatorKeyword:ue(we),controlKeyword:ue(we),definitionKeyword:ue(we),moduleKeyword:ue(we),operator:xe,derefOperator:ue(xe),arithmeticOperator:ue(xe),logicOperator:ue(xe),bitwiseOperator:ue(xe),compareOperator:ue(xe),updateOperator:ue(xe),definitionOperator:ue(xe),typeOperator:ue(xe),controlOperator:ue(xe),punctuation:Se,separator:ue(Se),bracket:Ce,angleBracket:ue(Ce),squareBracket:ue(Ce),paren:ue(Ce),brace:ue(Ce),content:ve,heading:ke,heading1:ue(ke),heading2:ue(ke),heading3:ue(ke),heading4:ue(ke),heading5:ue(ke),heading6:ue(ke),contentSeparator:ue(ve),list:ue(ve),quote:ue(ve),emphasis:ue(ve),strong:ue(ve),link:ue(ve),monospace:ue(ve),strikethrough:ue(ve),inserted:ue(),deleted:ue(),changed:ue(),invalid:ue(),meta:Ae,documentMeta:ue(Ae),annotation:ue(Ae),processingInstruction:ue(Ae),definition:ne.defineModifier("definition"),constant:ne.defineModifier("constant"),function:ne.defineModifier("function"),standard:ne.defineModifier("standard"),local:ne.defineModifier("local"),special:ne.defineModifier("special")};for(let e in Te){let t=Te[e];t instanceof ne&&(t.name=e)}le([{tag:Te.link,class:"tok-link"},{tag:Te.heading,class:"tok-heading"},{tag:Te.emphasis,class:"tok-emphasis"},{tag:Te.strong,class:"tok-strong"},{tag:Te.keyword,class:"tok-keyword"},{tag:Te.atom,class:"tok-atom"},{tag:Te.bool,class:"tok-bool"},{tag:Te.url,class:"tok-url"},{tag:Te.labelName,class:"tok-labelName"},{tag:Te.inserted,class:"tok-inserted"},{tag:Te.deleted,class:"tok-deleted"},{tag:Te.literal,class:"tok-literal"},{tag:Te.string,class:"tok-string"},{tag:Te.number,class:"tok-number"},{tag:[Te.regexp,Te.escape,Te.special(Te.string)],class:"tok-string2"},{tag:Te.variableName,class:"tok-variableName"},{tag:Te.local(Te.variableName),class:"tok-variableName tok-local"},{tag:Te.definition(Te.variableName),class:"tok-variableName tok-definition"},{tag:Te.special(Te.variableName),class:"tok-variableName2"},{tag:Te.definition(Te.propertyName),class:"tok-propertyName tok-definition"},{tag:Te.typeName,class:"tok-typeName"},{tag:Te.namespace,class:"tok-namespace"},{tag:Te.className,class:"tok-className"},{tag:Te.macroName,class:"tok-macroName"},{tag:Te.propertyName,class:"tok-propertyName"},{tag:Te.operator,class:"tok-operator"},{tag:Te.comment,class:"tok-comment"},{tag:Te.meta,class:"tok-meta"},{tag:Te.invalid,class:"tok-invalid"},{tag:Te.punctuation,class:"tok-punctuation"}]);const Ne=re({String:Te.string,Number:Te.number,"True False":Te.bool,PropertyName:Te.propertyName,Null:Te.null,", :":Te.separator,"[ ]":Te.squareBracket,"{ }":Te.brace}),Oe=Q.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:[Ne],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});let Me=[],Ee=[];function De(e){if(e<768)return!1;for(let t=0,n=Me.length;;){let i=t+n>>1;if(e<Me[i])n=i;else{if(!(e>=Ee[i]))return!0;t=i+1}if(t==n)return!1}}function _e(e){return e>=127462&&e<=127487}(()=>{let e="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?Ee:Me).push(n+=e[t])})();function Ie(e,t,n=!0,i=!0){return(n?Be:Pe)(e,t,i)}function Be(e,t,n){if(t==e.length)return t;t&&$e(e.charCodeAt(t))&&Le(e.charCodeAt(t-1))&&t--;let i=Re(e,t);for(t+=ze(i);t<e.length;){let s=Re(e,t);if(8205==i||8205==s||n&&De(s))t+=ze(s),i=s;else{if(!_e(s))break;{let n=0,i=t-2;for(;i>=0&&_e(Re(e,i));)n++,i-=2;if(n%2==0)break;t+=2}}}return t}function Pe(e,t,n){for(;t>0;){let i=Be(e,t-2,n);if(i<t)return i;t--}return 0}function Re(e,t){let n=e.charCodeAt(t);if(!Le(n)||t+1==e.length)return n;let i=e.charCodeAt(t+1);return $e(i)?i-56320+(n-55296<<10)+65536:n}function $e(e){return e>=56320&&e<57344}function Le(e){return e>=55296&&e<56320}function ze(e){return e<65536?1:2}class Fe{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=Ze(this,e,t);let i=[];return this.decompose(0,e,i,2),n.length&&n.decompose(0,n.length,i,3),this.decompose(t,this.length,i,1),We.from(i,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Ze(this,e,t);let n=[];return this.decompose(e,t,n,0),We.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),i=new He(this),s=new He(e);for(let e=t,r=t;;){if(i.next(e),s.next(e),e=0,i.lineBreak!=s.lineBreak||i.done!=s.done||i.value!=s.value)return!1;if(r+=i.value.length,i.done||r>=n)return!0}}iter(e=1){return new He(this,e)}iterRange(e,t=this.length){return new qe(this,e,t)}iterLines(e,t){let n;if(null==e)n=this.iter();else{null==t&&(t=this.lines+1);let i=this.line(e).from;n=this.iterRange(i,Math.max(i,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Ke(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(0==e.length)throw new RangeError("A document must have at least one line");return 1!=e.length||e[0]?e.length<=32?new je(e):We.from(je.split(e,[])):Fe.empty}}class je extends Fe{constructor(e,t=function(e){let t=-1;for(let n of e)t+=n.length+1;return t}(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,i){for(let s=0;;s++){let r=this.text[s],o=i+r.length;if((t?n:o)>=e)return new Je(i,o,n,r);i=o+1,n++}}decompose(e,t,n,i){let s=e<=0&&t>=this.length?this:new je(Ve(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(1&i){let e=n.pop(),t=Ue(s.text,e.text.slice(),0,s.length);if(t.length<=32)n.push(new je(t,e.length+s.length));else{let e=t.length>>1;n.push(new je(t.slice(0,e)),new je(t.slice(e)))}}else n.push(s)}replace(e,t,n){if(!(n instanceof je))return super.replace(e,t,n);[e,t]=Ze(this,e,t);let i=Ue(this.text,Ue(n.text,Ve(this.text,0,e)),t),s=this.length+n.length-(t-e);return i.length<=32?new je(i,s):We.from(je.split(i,[]),s)}sliceString(e,t=this.length,n="\n"){[e,t]=Ze(this,e,t);let i="";for(let s=0,r=0;s<=t&&r<this.text.length;r++){let o=this.text[r],a=s+o.length;s>e&&r&&(i+=n),e<a&&t>s&&(i+=o.slice(Math.max(0,e-s),t-s)),s=a+1}return i}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],i=-1;for(let s of e)n.push(s),i+=s.length+1,32==n.length&&(t.push(new je(n,i)),n=[],i=-1);return i>-1&&t.push(new je(n,i)),t}}class We extends Fe{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,i){for(let s=0;;s++){let r=this.children[s],o=i+r.length,a=n+r.lines-1;if((t?a:o)>=e)return r.lineInner(e,t,n,i);i=o+1,n=a+1}}decompose(e,t,n,i){for(let s=0,r=0;r<=t&&s<this.children.length;s++){let o=this.children[s],a=r+o.length;if(e<=a&&t>=r){let s=i&((r<=e?1:0)|(a>=t?2:0));r>=e&&a<=t&&!s?n.push(o):o.decompose(e-r,t-r,n,s)}r=a+1}}replace(e,t,n){if([e,t]=Ze(this,e,t),n.lines<this.lines)for(let i=0,s=0;i<this.children.length;i++){let r=this.children[i],o=s+r.length;if(e>=s&&t<=o){let a=r.replace(e-s,t-s,n),l=this.lines-r.lines+a.lines;if(a.lines<l>>4&&a.lines>l>>6){let s=this.children.slice();return s[i]=a,new We(s,this.length-(t-e)+n.length)}return super.replace(s,o,a)}s=o+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n="\n"){[e,t]=Ze(this,e,t);let i="";for(let s=0,r=0;s<this.children.length&&r<=t;s++){let o=this.children[s],a=r+o.length;r>e&&s&&(i+=n),e<a&&t>r&&(i+=o.sliceString(e-r,t-r,n)),r=a+1}return i}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof We))return 0;let n=0,[i,s,r,o]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=t,s+=t){if(i==r||s==o)return n;let a=this.children[i],l=e.children[s];if(a!=l)return n+a.scanIdentical(l,t);n+=a.length+1}}static from(e,t=e.reduce((e,t)=>e+t.length+1,-1)){let n=0;for(let t of e)n+=t.lines;if(n<32){let n=[];for(let t of e)t.flatten(n);return new je(n,t)}let i=Math.max(32,n>>5),s=i<<1,r=i>>1,o=[],a=0,l=-1,c=[];function h(e){let t;if(e.lines>s&&e instanceof We)for(let t of e.children)h(t);else e.lines>r&&(a>r||!a)?(u(),o.push(e)):e instanceof je&&a&&(t=c[c.length-1])instanceof je&&e.lines+t.lines<=32?(a+=e.lines,l+=e.length+1,c[c.length-1]=new je(t.text.concat(e.text),t.length+1+e.length)):(a+e.lines>i&&u(),a+=e.lines,l+=e.length+1,c.push(e))}function u(){0!=a&&(o.push(1==c.length?c[0]:We.from(c,l)),l=-1,a=c.length=0)}for(let t of e)h(t);return u(),1==o.length?o[0]:new We(o,t)}}function Ue(e,t,n=0,i=1e9){for(let s=0,r=0,o=!0;r<e.length&&s<=i;r++){let a=e[r],l=s+a.length;l>=n&&(l>i&&(a=a.slice(0,i-s)),s<n&&(a=a.slice(n-s)),o?(t[t.length-1]+=a,o=!1):t.push(a)),s=l+1}return t}function Ve(e,t,n){return Ue(e,[""],t,n)}Fe.empty=new je([""],0);class He{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof je?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,i=this.nodes[n],s=this.offsets[n],r=s>>1,o=i instanceof je?i.text.length:i.children.length;if(r==(t>0?o:0)){if(0==n)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&s)==(t>0?0:1)){if(this.offsets[n]+=t,0==e)return this.lineBreak=!0,this.value="\n",this;e--}else if(i instanceof je){let s=i.text[r+(t<0?-1:0)];if(this.offsets[n]+=t,s.length>Math.max(0,e))return this.value=0==e?s:t>0?s.slice(e):s.slice(0,s.length-e),this;e-=s.length}else{let s=i.children[r+(t<0?-1:0)];e>s.length?(e-=s.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(s),this.offsets.push(t>0?1:(s instanceof je?s.text.length:s.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class qe{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new He(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:i}=this.cursor.next(e);return this.pos+=(i.length+e)*t,this.value=i.length<=n?i:t<0?i.slice(i.length-n):i.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class Ke{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:i}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(Fe.prototype[Symbol.iterator]=function(){return this.iter()},He.prototype[Symbol.iterator]=qe.prototype[Symbol.iterator]=Ke.prototype[Symbol.iterator]=function(){return this});class Je{constructor(e,t,n,i){this.from=e,this.to=t,this.number=n,this.text=i}get length(){return this.to-this.from}}function Ze(e,t,n){return[t=Math.max(0,Math.min(e.length,t)),Math.max(t,Math.min(e.length,n))]}function Ye(e,t,n=!0,i=!0){return Ie(e,t,n,i)}function Ge(e,t){let n=e.charCodeAt(t);if(!(i=n,i>=55296&&i<56320&&t+1!=e.length))return n;var i;let s=e.charCodeAt(t+1);return function(e){return e>=56320&&e<57344}(s)?s-56320+(n-55296<<10)+65536:n}function Qe(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10),56320+(1023&e)))}function Xe(e){return e<65536?1:2}const et=/\r\n?|\n/;var tt=function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e}(tt||(tt={}));class nt{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,i=0;t<this.sections.length;){let s=this.sections[t++],r=this.sections[t++];r<0?(e(n,i,s),i+=s):i+=r,n+=s}}iterChangedRanges(e,t=!1){ot(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let n=this.sections[t++],i=this.sections[t++];i<0?e.push(n,i):e.push(i,n)}return new nt(e)}composeDesc(e){return this.empty?e:e.empty?this:lt(this,e)}mapDesc(e,t=!1){return e.empty?this:at(this,e,t)}mapPos(e,t=-1,n=tt.Simple){let i=0,s=0;for(let r=0;r<this.sections.length;){let o=this.sections[r++],a=this.sections[r++],l=i+o;if(a<0){if(l>e)return s+(e-i);s+=o}else{if(n!=tt.Simple&&l>=e&&(n==tt.TrackDel&&i<e&&l>e||n==tt.TrackBefore&&i<e||n==tt.TrackAfter&&l>e))return null;if(l>e||l==e&&t<0&&!o)return e==i||t<0?s:s+a;s+=a}i=l}if(e>i)throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);return s}touchesRange(e,t=e){for(let n=0,i=0;n<this.sections.length&&i<=t;){let s=i+this.sections[n++];if(this.sections[n++]>=0&&i<=t&&s>=e)return!(i<e&&s>t)||"cover";i=s}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let n=this.sections[t++],i=this.sections[t++];e+=(e?" ":"")+n+(i>=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(e=>"number"!=typeof e))throw new RangeError("Invalid JSON representation of ChangeDesc");return new nt(e)}static create(e){return new nt(e)}}class it extends nt{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return ot(this,(t,n,i,s,r)=>e=e.replace(i,i+(n-t),r),!1),e}mapDesc(e,t=!1){return at(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let i=0,s=0;i<t.length;i+=2){let r=t[i],o=t[i+1];if(o>=0){t[i]=o,t[i+1]=r;let a=i>>1;for(;n.length<a;)n.push(Fe.empty);n.push(r?e.slice(s,s+r):Fe.empty)}s+=r}return new it(t,n)}compose(e){return this.empty?e:e.empty?this:lt(this,e,!0)}map(e,t=!1){return e.empty?this:at(this,e,t,!0)}iterChanges(e,t=!1){ot(this,e,t)}get desc(){return nt.create(this.sections)}filter(e){let t=[],n=[],i=[],s=new ct(this);e:for(let r=0,o=0;;){let a=r==e.length?1e9:e[r++];for(;o<a||o==a&&0==s.len;){if(s.done)break e;let e=Math.min(s.len,a-o);st(i,e,-1);let r=-1==s.ins?-1:0==s.off?s.ins:0;st(t,e,r),r>0&&rt(n,t,s.text),s.forward(e),o+=e}let l=e[r++];for(;o<l;){if(s.done)break e;let e=Math.min(s.len,l-o);st(t,e,-1),st(i,e,-1==s.ins?-1:0==s.off?s.ins:0),s.forward(e),o+=e}}return{changes:new it(t,n),filtered:nt.create(i)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],i=this.sections[t+1];i<0?e.push(n):0==i?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let i=[],s=[],r=0,o=null;function a(e=!1){if(!e&&!i.length)return;r<t&&st(i,t-r,-1);let n=new it(i,s);o=o?o.compose(n.map(o)):n,i=[],s=[],r=0}return function e(l){if(Array.isArray(l))for(let t of l)e(t);else if(l instanceof it){if(l.length!=t)throw new RangeError(`Mismatched change set length (got ${l.length}, expected ${t})`);a(),o=o?o.compose(l.map(o)):l}else{let{from:e,to:o=e,insert:c}=l;if(e>o||e<0||o>t)throw new RangeError(`Invalid change range ${e} to ${o} (in doc of length ${t})`);let h=c?"string"==typeof c?Fe.of(c.split(n||et)):c:Fe.empty,u=h.length;if(e==o&&0==u)return;e<r&&a(),e>r&&st(i,e-r,-1),st(i,o-e,u),rt(s,i,h),r=o}}(e),a(!o),o}static empty(e){return new it(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let i=0;i<e.length;i++){let s=e[i];if("number"==typeof s)t.push(s,-1);else{if(!Array.isArray(s)||"number"!=typeof s[0]||s.some((e,t)=>t&&"string"!=typeof e))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==s.length)t.push(s[0],0);else{for(;n.length<i;)n.push(Fe.empty);n[i]=Fe.of(s.slice(1)),t.push(s[0],n[i].length)}}}return new it(t,n)}static createSet(e,t){return new it(e,t)}}function st(e,t,n,i=!1){if(0==t&&n<=0)return;let s=e.length-2;s>=0&&n<=0&&n==e[s+1]?e[s]+=t:s>=0&&0==t&&0==e[s]?e[s+1]+=n:i?(e[s]+=t,e[s+1]+=n):e.push(t,n)}function rt(e,t,n){if(0==n.length)return;let i=t.length-2>>1;if(i<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<i;)e.push(Fe.empty);e.push(n)}}function ot(e,t,n){let i=e.inserted;for(let s=0,r=0,o=0;o<e.sections.length;){let a=e.sections[o++],l=e.sections[o++];if(l<0)s+=a,r+=a;else{let c=s,h=r,u=Fe.empty;for(;c+=a,h+=l,l&&i&&(u=u.append(i[o-2>>1])),!(n||o==e.sections.length||e.sections[o+1]<0);)a=e.sections[o++],l=e.sections[o++];t(s,c,r,h,u),s=c,r=h}}}function at(e,t,n,i=!1){let s=[],r=i?[]:null,o=new ct(e),a=new ct(t);for(let e=-1;;){if(o.done&&a.len||a.done&&o.len)throw new Error("Mismatched change set lengths");if(-1==o.ins&&-1==a.ins){let e=Math.min(o.len,a.len);st(s,e,-1),o.forward(e),a.forward(e)}else if(a.ins>=0&&(o.ins<0||e==o.i||0==o.off&&(a.len<o.len||a.len==o.len&&!n))){let t=a.len;for(st(s,a.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(st(s,0,o.ins),r&&rt(r,s,o.text),e=o.i),o.forward(n),t-=n}a.next()}else{if(!(o.ins>=0)){if(o.done&&a.done)return r?it.createSet(s,r):nt.create(s);throw new Error("Mismatched change set lengths")}{let t=0,n=o.len;for(;n;)if(-1==a.ins){let e=Math.min(n,a.len);t+=e,n-=e,a.forward(e)}else{if(!(0==a.ins&&a.len<n))break;n-=a.len,a.next()}st(s,t,e<o.i?o.ins:0),r&&e<o.i&&rt(r,s,o.text),e=o.i,o.forward(o.len-n)}}}}function lt(e,t,n=!1){let i=[],s=n?[]:null,r=new ct(e),o=new ct(t);for(let e=!1;;){if(r.done&&o.done)return s?it.createSet(i,s):nt.create(i);if(0==r.ins)st(i,r.len,0,e),r.next();else if(0!=o.len||o.done){if(r.done||o.done)throw new Error("Mismatched change set lengths");{let t=Math.min(r.len2,o.len),n=i.length;if(-1==r.ins){let n=-1==o.ins?-1:o.off?0:o.ins;st(i,t,n,e),s&&n&&rt(s,i,o.text)}else-1==o.ins?(st(i,r.off?0:r.len,t,e),s&&rt(s,i,r.textBit(t))):(st(i,r.off?0:r.len,o.off?0:o.ins,e),s&&!o.off&&rt(s,i,o.text));e=(r.ins>t||o.ins>=0&&o.len>t)&&(e||i.length>n),r.forward2(t),o.forward(t)}}else st(i,0,o.ins,e),s&&rt(s,i,o.text),o.next()}}class ct{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return-2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?Fe.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?Fe.empty:t[n].slice(this.off,null==e?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){-1==this.ins?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class ht{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let e=7&this.flags;return 7==e?null:e}get goalColumn(){let e=this.flags>>6;return 16777215==e?void 0:e}map(e,t=-1){let n,i;return this.empty?n=i=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),i=e.mapPos(this.to,-1)),n==this.from&&i==this.to?this:new ht(n,i,this.flags)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return ut.range(e,t,void 0,void 0,n);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return ut.range(this.anchor,i,void 0,void 0,n)}eq(e,t=!1){return!(this.anchor!=e.anchor||this.head!=e.head||this.goalColumn!=e.goalColumn||t&&this.empty&&this.assoc!=e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||"number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid JSON representation for SelectionRange");return ut.range(e.anchor,e.head)}static create(e,t,n){return new ht(e,t,n)}}class ut{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:ut.create(this.ranges.map(n=>n.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new ut([this.main],0)}addRange(e,t=!0){return ut.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,ut.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||"number"!=typeof e.main||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ut(e.ranges.map(e=>ht.fromJSON(e)),e.main)}static single(e,t=e){return new ut([ut.range(e,t)],0)}static create(e,t=0){if(0==e.length)throw new RangeError("A selection needs at least one range");for(let n=0,i=0;i<e.length;i++){let s=e[i];if(s.empty?s.from<=n:s.from<n)return ut.normalized(e.slice(),t);n=s.to}return new ut(e,t)}static cursor(e,t=0,n,i){return ht.create(e,e,(0==t?0:t<0?8:16)|(null==n?7:Math.min(6,n))|(null!=i?i:16777215)<<6)}static range(e,t,n,i,s){let r=(null!=n?n:16777215)<<6|(null==i?7:Math.min(6,i));return s||e==t||(s=t<e?1:-1),t<e?ht.create(t,e,48|r):ht.create(e,t,(s?s<0?8:16:0)|r)}static normalized(e,t=0){let n=e[t];e.sort((e,t)=>e.from-t.from),t=e.indexOf(n);for(let n=1;n<e.length;n++){let i=e[n],s=e[n-1];if(i.empty?i.from<=s.to:i.from<s.to){let r=s.from,o=Math.max(i.to,s.to);n<=t&&t--,e.splice(--n,2,i.anchor>i.head?ut.range(o,r):ut.range(r,o))}}return new ut(e,t)}}function dt(e,t){for(let n of e.ranges)if(n.to>t)throw new RangeError("Selection points outside of document")}let ft=0;class pt{constructor(e,t,n,i,s){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=i,this.id=ft++,this.default=e([]),this.extensions="function"==typeof s?s(this):s}get reader(){return this}static define(e={}){return new pt(e.combine||(e=>e),e.compareInput||((e,t)=>e===t),e.compare||(e.combine?(e,t)=>e===t:mt),!!e.static,e.enables)}of(e){return new gt([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new gt(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new gt(e,this,2,t)}from(e,t){return t||(t=e=>e),this.compute([e],n=>t(n.field(e)))}}function mt(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}class gt{constructor(e,t,n,i){this.dependencies=e,this.facet=t,this.type=n,this.value=i,this.id=ft++}dynamicSlot(e){var t;let n=this.value,i=this.facet.compareInput,s=this.id,r=e[s]>>1,o=2==this.type,a=!1,l=!1,c=[];for(let n of this.dependencies)"doc"==n?a=!0:"selection"==n?l=!0:1&(null!==(t=e[n.id])&&void 0!==t?t:1)||c.push(e[n.id]);return{create:e=>(e.values[r]=n(e),1),update(e,t){if(a&&t.docChanged||l&&(t.docChanged||t.selection)||yt(e,c)){let t=n(e);if(o?!bt(t,e.values[r],i):!i(t,e.values[r]))return e.values[r]=t,1}return 0},reconfigure:(e,t)=>{let a,l=t.config.address[s];if(null!=l){let s=It(t,l);if(this.dependencies.every(n=>n instanceof pt?t.facet(n)===e.facet(n):!(n instanceof wt)||t.field(n,!1)==e.field(n,!1))||(o?bt(a=n(e),s,i):i(a=n(e),s)))return e.values[r]=s,0}else a=n(e);return e.values[r]=a,1}}}}function bt(e,t,n){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++)if(!n(e[i],t[i]))return!1;return!0}function yt(e,t){let n=!1;for(let i of t)1&_t(e,i)&&(n=!0);return n}function vt(e,t,n){let i=n.map(t=>e[t.id]),s=n.map(e=>e.type),r=i.filter(e=>!(1&e)),o=e[t.id]>>1;function a(e){let n=[];for(let t=0;t<i.length;t++){let r=It(e,i[t]);if(2==s[t])for(let e of r)n.push(e);else n.push(r)}return t.combine(n)}return{create(e){for(let t of i)_t(e,t);return e.values[o]=a(e),1},update(e,n){if(!yt(e,r))return 0;let i=a(e);return t.compare(i,e.values[o])?0:(e.values[o]=i,1)},reconfigure(e,s){let r=yt(e,i),l=s.config.facets[t.id],c=s.facet(t);if(l&&!r&&mt(n,l))return e.values[o]=c,0;let h=a(e);return t.compare(h,c)?(e.values[o]=c,0):(e.values[o]=h,1)}}}const kt=pt.define({static:!0});class wt{constructor(e,t,n,i,s){this.id=e,this.createF=t,this.updateF=n,this.compareF=i,this.spec=s,this.provides=void 0}static define(e){let t=new wt(ft++,e.create,e.update,e.compare||((e,t)=>e===t),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(kt).find(e=>e.field==this);return((null==t?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let i=e.values[t],s=this.updateF(i,n);return this.compareF(i,s)?0:(e.values[t]=s,1)},reconfigure:(e,n)=>{let i,s=e.facet(kt),r=n.facet(kt);return(i=s.find(e=>e.field==this))&&i!=r.find(e=>e.field==this)?(e.values[t]=i.create(e),1):null!=n.config.address[this.id]?(e.values[t]=n.field(this),0):(e.values[t]=this.create(e),1)}}}init(e){return[this,kt.of({field:this,create:e})]}get extension(){return this}}const xt=4,St=3,Ct=2,At=1;function Tt(e){return t=>new Ot(t,e)}const Nt={highest:Tt(0),high:Tt(At),default:Tt(Ct),low:Tt(St),lowest:Tt(xt)};class Ot{constructor(e,t){this.inner=e,this.prec=t}}class Mt{of(e){return new Et(this,e)}reconfigure(e){return Mt.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Et{constructor(e,t){this.compartment=e,this.inner=t}}class Dt{constructor(e,t,n,i,s,r){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=i,this.staticValues=s,this.facets=r,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return null==t?e.default:this.staticValues[t>>1]}static resolve(e,t,n){let i=[],s=Object.create(null),r=new Map;for(let n of function(e,t,n){let i=[[],[],[],[],[]],s=new Map;function r(e,o){let a=s.get(e);if(null!=a){if(a<=o)return;let t=i[a].indexOf(e);t>-1&&i[a].splice(t,1),e instanceof Et&&n.delete(e.compartment)}if(s.set(e,o),Array.isArray(e))for(let t of e)r(t,o);else if(e instanceof Et){if(n.has(e.compartment))throw new RangeError("Duplicate use of compartment in extensions");let i=t.get(e.compartment)||e.inner;n.set(e.compartment,i),r(i,o)}else if(e instanceof Ot)r(e.inner,e.prec);else if(e instanceof wt)i[o].push(e),e.provides&&r(e.provides,o);else if(e instanceof gt)i[o].push(e),e.facet.extensions&&r(e.facet.extensions,Ct);else{let t=e.extension;if(!t)throw new Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(t,o)}}return r(e,Ct),i.reduce((e,t)=>e.concat(t))}(e,t,r))n instanceof wt?i.push(n):(s[n.facet.id]||(s[n.facet.id]=[])).push(n);let o=Object.create(null),a=[],l=[];for(let e of i)o[e.id]=l.length<<1,l.push(t=>e.slot(t));let c=null==n?void 0:n.config.facets;for(let e in s){let t=s[e],i=t[0].facet,r=c&&c[e]||[];if(t.every(e=>0==e.type))if(o[i.id]=a.length<<1|1,mt(r,t))a.push(n.facet(i));else{let e=i.combine(t.map(e=>e.value));a.push(n&&i.compare(e,n.facet(i))?n.facet(i):e)}else{for(let e of t)0==e.type?(o[e.id]=a.length<<1|1,a.push(e.value)):(o[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));o[i.id]=l.length<<1,l.push(e=>vt(e,i,t))}}let h=l.map(e=>e(o));return new Dt(e,r,h,o,a,s)}}function _t(e,t){if(1&t)return 2;let n=t>>1,i=e.status[n];if(4==i)throw new Error("Cyclic dependency between fields and/or facets");if(2&i)return i;e.status[n]=4;let s=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|s}function It(e,t){return 1&t?e.config.staticValues[t>>1]:e.values[t>>1]}const Bt=pt.define(),Pt=pt.define({combine:e=>e.some(e=>e),static:!0}),Rt=pt.define({combine:e=>e.length?e[0]:void 0,static:!0}),$t=pt.define(),Lt=pt.define(),zt=pt.define(),Ft=pt.define({combine:e=>!!e.length&&e[0]});class jt{constructor(e,t){this.type=e,this.value=t}static define(){return new Wt}}class Wt{of(e){return new jt(this,e)}}class Ut{constructor(e){this.map=e}of(e){return new Vt(this,e)}}class Vt{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return void 0===t?void 0:t==this.value?this:new Vt(this.type,t)}is(e){return this.type==e}static define(e={}){return new Ut(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let i of e){let e=i.map(t);e&&n.push(e)}return n}}Vt.reconfigure=Vt.define(),Vt.appendConfig=Vt.define();class Ht{constructor(e,t,n,i,s,r){this.startState=e,this.changes=t,this.selection=n,this.effects=i,this.annotations=s,this.scrollIntoView=r,this._doc=null,this._state=null,n&&dt(n,t.newLength),s.some(e=>e.type==Ht.time)||(this.annotations=s.concat(Ht.time.of(Date.now())))}static create(e,t,n,i,s,r){return new Ht(e,t,n,i,s,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(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(Ht.userEvent);return!(!t||!(t==e||t.length>e.length&&t.slice(0,e.length)==e&&"."==t[e.length]))}}function qt(e,t){let n=[];for(let i=0,s=0;;){let r,o;if(i<e.length&&(s==t.length||t[s]>=e[i]))r=e[i++],o=e[i++];else{if(!(s<t.length))return n;r=t[s++],o=t[s++]}!n.length||n[n.length-1]<r?n.push(r,o):n[n.length-1]<o&&(n[n.length-1]=o)}}function Kt(e,t,n){var i;let s,r,o;return n?(s=t.changes,r=it.empty(t.changes.length),o=e.changes.compose(t.changes)):(s=t.changes.map(e.changes),r=e.changes.mapDesc(t.changes,!0),o=e.changes.compose(s)),{changes:o,selection:t.selection?t.selection.map(r):null===(i=e.selection)||void 0===i?void 0:i.map(s),effects:Vt.mapEffects(e.effects,s).concat(Vt.mapEffects(t.effects,r)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function Jt(e,t,n){let i=t.selection,s=Gt(t.annotations);return t.userEvent&&(s=s.concat(Ht.userEvent.of(t.userEvent))),{changes:t.changes instanceof it?t.changes:it.of(t.changes||[],n,e.facet(Rt)),selection:i&&(i instanceof ut?i:ut.single(i.anchor,i.head)),effects:Gt(t.effects),annotations:s,scrollIntoView:!!t.scrollIntoView}}function Zt(e,t,n){let i=Jt(e,t.length?t[0]:{},e.doc.length);t.length&&!1===t[0].filter&&(n=!1);for(let s=1;s<t.length;s++){!1===t[s].filter&&(n=!1);let r=!!t[s].sequential;i=Kt(i,Jt(e,t[s],r?i.changes.newLength:e.doc.length),r)}let s=Ht.create(e,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return function(e){let t=e.startState,n=t.facet(zt),i=e;for(let s=n.length-1;s>=0;s--){let r=n[s](e);r&&Object.keys(r).length&&(i=Kt(i,Jt(t,r,e.changes.newLength),!0))}return i==e?e:Ht.create(t,e.changes,e.selection,i.effects,i.annotations,i.scrollIntoView)}(n?function(e){let t=e.startState,n=!0;for(let i of t.facet($t)){let t=i(e);if(!1===t){n=!1;break}Array.isArray(t)&&(n=!0===n?t:qt(n,t))}if(!0!==n){let i,s;if(!1===n)s=e.changes.invertedDesc,i=it.empty(t.doc.length);else{let t=e.changes.filter(n);i=t.changes,s=t.filtered.mapDesc(t.changes).invertedDesc}e=Ht.create(t,i,e.selection&&e.selection.map(s),Vt.mapEffects(e.effects,s),e.annotations,e.scrollIntoView)}let i=t.facet(Lt);for(let n=i.length-1;n>=0;n--){let s=i[n](e);e=s instanceof Ht?s:Array.isArray(s)&&1==s.length&&s[0]instanceof Ht?s[0]:Zt(t,Gt(s),!1)}return e}(s):s)}Ht.time=jt.define(),Ht.userEvent=jt.define(),Ht.addToHistory=jt.define(),Ht.remote=jt.define();const Yt=[];function Gt(e){return null==e?Yt:Array.isArray(e)?e:[e]}var Qt=function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(Qt||(Qt={}));const Xt=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let en;try{en=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(km){}function tn(e){return t=>{if(!/\S/.test(t))return Qt.Space;if(function(e){if(en)return en.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>""&&(n.toUpperCase()!=n.toLowerCase()||Xt.test(n)))return!0}return!1}(t))return Qt.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return Qt.Word;return Qt.Other}}class nn{constructor(e,t,n,i,s,r){this.config=e,this.doc=t,this.selection=n,this.values=i,this.status=e.statusTemplate.slice(),this.computeSlot=s,r&&(r._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)_t(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(null!=n)return _t(this,n),It(this,n);if(t)throw new RangeError("Field is not present in this state")}update(...e){return Zt(this,e,!0)}applyTransaction(e){let t,n=this.config,{base:i,compartments:s}=n;for(let t of e.effects)t.is(Mt.reconfigure)?(n&&(s=new Map,n.compartments.forEach((e,t)=>s.set(t,e)),n=null),s.set(t.value.compartment,t.value.extension)):t.is(Vt.reconfigure)?(n=null,i=t.value):t.is(Vt.appendConfig)&&(n=null,i=Gt(i).concat(t.value));if(n)t=e.startState.values.slice();else{n=Dt.resolve(i,s,this),t=new nn(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values}let r=e.startState.facet(Pt)?e.newSelection:e.newSelection.asSingle();new nn(n,e.newDoc,r,t,(t,n)=>n.update(t,e),e)}replaceSelection(e){return"string"==typeof e&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:ut.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),i=this.changes(n.changes),s=[n.range],r=Gt(n.effects);for(let n=1;n<t.ranges.length;n++){let o=e(t.ranges[n]),a=this.changes(o.changes),l=a.map(i);for(let e=0;e<n;e++)s[e]=s[e].map(l);let c=i.mapDesc(a,!0);s.push(o.range.map(c)),i=i.compose(l),r=Vt.mapEffects(r,l).concat(Vt.mapEffects(Gt(o.effects),c))}return{changes:i,selection:ut.create(s,t.mainIndex),effects:r}}changes(e=[]){return e instanceof it?e:it.of(e,this.doc.length,this.facet(nn.lineSeparator))}toText(e){return Fe.of(e.split(this.facet(nn.lineSeparator)||et))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return null==t?e.default:(_t(this,t),It(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let i=e[n];i instanceof wt&&null!=this.config.address[i.id]&&(t[n]=i.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e,t={},n){if(!e||"string"!=typeof e.doc)throw new RangeError("Invalid JSON representation for EditorState");let i=[];if(n)for(let t in n)if(Object.prototype.hasOwnProperty.call(e,t)){let s=n[t],r=e[t];i.push(s.init(e=>s.spec.fromJSON(r,e)))}return nn.create({doc:e.doc,selection:ut.fromJSON(e.selection),extensions:t.extensions?i.concat([t.extensions]):i})}static create(e={}){let t=Dt.resolve(e.extensions||[],new Map),n=e.doc instanceof Fe?e.doc:Fe.of((e.doc||"").split(t.staticFacet(nn.lineSeparator)||et)),i=e.selection?e.selection instanceof ut?e.selection:ut.single(e.selection.anchor,e.selection.head):ut.single(0);return dt(i,n.length),t.staticFacet(Pt)||(i=i.asSingle()),new nn(t,n,i,t.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(nn.tabSize)}get lineBreak(){return this.facet(nn.lineSeparator)||"\n"}get readOnly(){return this.facet(Ft)}phrase(e,...t){for(let t of this.facet(nn.phrases))if(Object.prototype.hasOwnProperty.call(t,e)){e=t[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(e,n)=>{if("$"==n)return"$";let i=+(n||1);return!i||i>t.length?e:t[i-1]})),e}languageDataAt(e,t,n=-1){let i=[];for(let s of this.facet(Bt))for(let r of s(this,t,n))Object.prototype.hasOwnProperty.call(r,e)&&i.push(r[e]);return i}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return tn(t.length?t[0]:"")}wordAt(e){let{text:t,from:n,length:i}=this.doc.lineAt(e),s=this.charCategorizer(e),r=e-n,o=e-n;for(;r>0;){let e=Ye(t,r,!1);if(s(t.slice(e,r))!=Qt.Word)break;r=e}for(;o<i;){let e=Ye(t,o);if(s(t.slice(o,e))!=Qt.Word)break;o=e}return r==o?null:ut.range(r+n,o+n)}}function sn(e,t,n={}){let i={};for(let t of e)for(let e of Object.keys(t)){let s=t[e],r=i[e];if(void 0===r)i[e]=s;else if(r===s||void 0===s);else{if(!Object.hasOwnProperty.call(n,e))throw new Error("Config merge conflict for field "+e);i[e]=n[e](r,s)}}for(let e in t)void 0===i[e]&&(i[e]=t[e]);return i}nn.allowMultipleSelections=Pt,nn.tabSize=pt.define({combine:e=>e.length?e[0]:4}),nn.lineSeparator=Rt,nn.readOnly=Ft,nn.phrases=pt.define({compare(e,t){let n=Object.keys(e),i=Object.keys(t);return n.length==i.length&&n.every(n=>e[n]==t[n])}}),nn.languageData=Bt,nn.changeFilter=$t,nn.transactionFilter=Lt,nn.transactionExtender=zt,Mt.reconfigure=Vt.define();class rn{eq(e){return this==e}range(e,t=e){return an.create(e,t,this)}}function on(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}rn.prototype.startSide=rn.prototype.endSide=0,rn.prototype.point=!1,rn.prototype.mapMode=tt.TrackDel;class an{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new an(e,t,n)}}function ln(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}class cn{constructor(e,t,n,i){this.from=e,this.to=t,this.value=n,this.maxPoint=i}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,i=0){let s=n?this.to:this.from;for(let r=i,o=s.length;;){if(r==o)return r;let i=r+o>>1,a=s[i]-e||(n?this.value[i].endSide:this.value[i].startSide)-t;if(i==r)return a>=0?r:o;a>=0?o=i:r=i+1}}between(e,t,n,i){for(let s=this.findIndex(t,-1e9,!0),r=this.findIndex(n,1e9,!1,s);s<r;s++)if(!1===i(this.from[s]+e,this.to[s]+e,this.value[s]))return!1}map(e,t){let n=[],i=[],s=[],r=-1,o=-1;for(let a=0;a<this.value.length;a++){let l,c,h=this.value[a],u=this.from[a]+e,d=this.to[a]+e;if(u==d){let e=t.mapPos(u,h.startSide,h.mapMode);if(null==e)continue;if(l=c=e,h.startSide!=h.endSide&&(c=t.mapPos(u,h.endSide),c<l))continue}else if(l=t.mapPos(u,h.startSide),c=t.mapPos(d,h.endSide),l>c||l==c&&h.startSide>0&&h.endSide<=0)continue;(c-l||h.endSide-h.startSide)<0||(r<0&&(r=l),h.point&&(o=Math.max(o,c-l)),n.push(h),i.push(l-r),s.push(c-r))}return{mapped:n.length?new cn(i,s,n,o):null,pos:r}}}class hn{constructor(e,t,n,i){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=i}static create(e,t,n,i){return new hn(e,t,n,i)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:n=!1,filterFrom:i=0,filterTo:s=this.length}=e,r=e.filter;if(0==t.length&&!r)return this;if(n&&(t=t.slice().sort(ln)),this.isEmpty)return t.length?hn.of(t):this;let o=new fn(this,null,-1).goto(0),a=0,l=[],c=new un;for(;o.value||a<t.length;)if(a<t.length&&(o.from-t[a].from||o.startSide-t[a].value.startSide)>=0){let e=t[a++];c.addInner(e.from,e.to,e.value)||l.push(e)}else 1==o.rangeIndex&&o.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(o.chunkIndex)<t[a].from)&&(!r||i>this.chunkEnd(o.chunkIndex)||s<this.chunkPos[o.chunkIndex])&&c.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!r||i>o.to||s<o.from||r(o.from,o.to,o.value))&&(c.addInner(o.from,o.to,o.value)||l.push(an.create(o.from,o.to,o.value))),o.next());return c.finishInner(this.nextLayer.isEmpty&&!l.length?hn.empty:this.nextLayer.update({add:l,filter:r,filterFrom:i,filterTo:s}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],n=[],i=-1;for(let s=0;s<this.chunk.length;s++){let r=this.chunkPos[s],o=this.chunk[s],a=e.touchesRange(r,r+o.length);if(!1===a)i=Math.max(i,o.maxPoint),t.push(o),n.push(e.mapPos(r));else if(!0===a){let{mapped:s,pos:a}=o.map(r,e);s&&(i=Math.max(i,s.maxPoint),t.push(s),n.push(a))}}let s=this.nextLayer.map(e);return 0==t.length?s:new hn(n,t,s||hn.empty,i)}between(e,t,n){if(!this.isEmpty){for(let i=0;i<this.chunk.length;i++){let s=this.chunkPos[i],r=this.chunk[i];if(t>=s&&e<=s+r.length&&!1===r.between(s,e-s,t-s,n))return}this.nextLayer.between(e,t,n)}}iter(e=0){return pn.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return pn.from(e).goto(t)}static compare(e,t,n,i,s=-1){let r=e.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=s),o=t.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=s),a=dn(r,o,n),l=new gn(r,a,s),c=new gn(o,a,s);n.iterGaps((e,t,n)=>bn(l,e,c,t,n,i)),n.empty&&0==n.length&&bn(l,0,c,0,0,i)}static eq(e,t,n=0,i){null==i&&(i=999999999);let s=e.filter(e=>!e.isEmpty&&t.indexOf(e)<0),r=t.filter(t=>!t.isEmpty&&e.indexOf(t)<0);if(s.length!=r.length)return!1;if(!s.length)return!0;let o=dn(s,r),a=new gn(s,o,0).goto(n),l=new gn(r,o,0).goto(n);for(;;){if(a.to!=l.to||!yn(a.active,l.active)||a.point&&(!l.point||!on(a.point,l.point)))return!1;if(a.to>i)return!0;a.next(),l.next()}}static spans(e,t,n,i,s=-1){let r=new gn(e,null,s).goto(t),o=t,a=r.openStart;for(;;){let e=Math.min(r.to,n);if(r.point){let n=r.activeForPoint(r.to),s=r.pointFrom<t?n.length+1:r.point.startSide<0?n.length:Math.min(n.length,a);i.point(o,e,r.point,n,s,r.pointRank),a=Math.min(r.openEnd(e),n.length)}else e>o&&(i.span(o,e,r.active,a),a=r.openEnd(e));if(r.to>n)return a+(r.point&&r.to>n?1:0);o=r.to,r.next()}}static of(e,t=!1){let n=new un;for(let i of e instanceof an?[e]:t?function(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let i=e[n];if(ln(t,i)>0)return e.slice().sort(ln);t=i}return e}(e):e)n.add(i.from,i.to,i.value);return n.finish()}static join(e){if(!e.length)return hn.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let i=e[n];i!=hn.empty;i=i.nextLayer)t=new hn(i.chunkPos,i.chunk,t,Math.max(i.maxPoint,t.maxPoint));return t}}hn.empty=new hn([],[],null,-1),hn.empty.nextLayer=hn.empty;class un{finishChunk(e){this.chunks.push(new cn(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new un)).add(e,t,n)}addInner(e,t,n){let i=e-this.lastTo||n.startSide-this.last.endSide;if(i<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(i<0)&&(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(hn.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return e;let t=hn.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function dn(e,t,n){let i=new Map;for(let t of e)for(let e=0;e<t.chunk.length;e++)t.chunk[e].maxPoint<=0&&i.set(t.chunk[e],t.chunkPos[e]);let s=new Set;for(let e of t)for(let t=0;t<e.chunk.length;t++){let r=i.get(e.chunk[t]);null==r||(n?n.mapPos(r):r)!=e.chunkPos[t]||(null==n?void 0:n.touchesRange(r,r+e.chunk[t].length))||s.add(e.chunk[t])}return s}class fn{constructor(e,t,n,i=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=i}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let t=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(t)||this.layer.chunkEnd(this.chunkIndex)<e||t.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let i=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<i)&&this.setRangeIndex(i)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class pn{constructor(e){this.heap=e}static from(e,t=null,n=-1){let i=[];for(let s=0;s<e.length;s++)for(let r=e[s];!r.isEmpty;r=r.nextLayer)r.maxPoint>=n&&i.push(new fn(r,t,n,s));return 1==i.length?i[0]:new pn(i)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let e=this.heap.length>>1;e>=0;e--)mn(this.heap,e);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)mn(this.heap,e);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),mn(this.heap,0)}}}function mn(e,t){for(let n=e[t];;){let i=1+(t<<1);if(i>=e.length)break;let s=e[i];if(i+1<e.length&&s.compare(e[i+1])>=0&&(s=e[i+1],i++),n.compare(s)<0)break;e[i]=n,e[t]=s,t=i}}class gn{constructor(e,t,n){this.minPoint=n,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=pn.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){vn(this.active,e),vn(this.activeTo,e),vn(this.activeRank,e),this.minActive=wn(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:i,rank:s}=this.cursor;for(;t<this.activeRank.length&&(s-this.activeRank[t]||i-this.activeTo[t])>0;)t++;kn(this.active,t,n),kn(this.activeTo,t,i),kn(this.activeRank,t,s),e&&kn(e,t,this.cursor.from),this.minActive=wn(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let i=this.minActive;if(i>-1&&(this.activeTo[i]-this.cursor.from||this.active[i].endSide-this.cursor.startSide)<0){if(this.activeTo[i]>e){this.to=this.activeTo[i],this.endSide=this.active[i].endSide;break}this.removeActive(i),n&&vn(n,i)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}{let e=this.cursor.value;if(e.point){if(!(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=e,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=e.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(n),this.cursor.next()}}}if(n){this.openStart=0;for(let t=n.length-1;t>=0&&n[t]<e;t--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}}function bn(e,t,n,i,s,r){e.goto(t),n.goto(i);let o=i+s,a=i,l=i-t,c=!!r.boundChange;for(let t=!1;;){let i=e.to+l-n.to,s=i||e.endSide-n.endSide,h=s<0?e.to+l:n.to,u=Math.min(h,o);if(e.point||n.point?(e.point&&n.point&&on(e.point,n.point)&&yn(e.activeForPoint(e.to),n.activeForPoint(n.to))||r.comparePoint(a,u,e.point,n.point),t=!1):(t&&r.boundChange(a),u>a&&!yn(e.active,n.active)&&r.compareRange(a,u,e.active,n.active),c&&u<o&&(i||e.openEnd(h)!=n.openEnd(h))&&(t=!0)),h>o)break;a=h,s<=0&&e.next(),s>=0&&n.next()}}function yn(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!on(e[n],t[n]))return!1;return!0}function vn(e,t){for(let n=t,i=e.length-1;n<i;n++)e[n]=e[n+1];e.pop()}function kn(e,t,n){for(let n=e.length-1;n>=t;n--)e[n+1]=e[n];e[t]=n}function wn(e,t){let n=-1,i=1e9;for(let s=0;s<t.length;s++)(t[s]-i||e[s].endSide-e[n].endSide)<0&&(n=s,i=t[s]);return n}function xn(e,t,n=e.length){let i=0;for(let s=0;s<n&&s<e.length;)9==e.charCodeAt(s)?(i+=t-i%t,s++):(i++,s=Ye(e,s));return i}function Sn(e,t,n,i){for(let i=0,s=0;;){if(s>=t)return i;if(i==e.length)break;s+=9==e.charCodeAt(i)?n-s%n:1,i=Ye(e,i)}return!0===i?-1:e.length}const Cn="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),An="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),Tn="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class Nn{constructor(e,t){this.rules=[];let{finish:n}=t||{};function i(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function s(e,t,r,o){let a=[],l=/^@(\w+)\b/.exec(e[0]),c=l&&"keyframes"==l[1];if(l&&null==t)return r.push(e[0]+";");for(let n in t){let o=t[n];if(/&/.test(n))s(n.split(/,\s*/).map(t=>e.map(e=>t.replace(/&/,e))).reduce((e,t)=>e.concat(t)),o,r);else if(o&&"object"==typeof o){if(!l)throw new RangeError("The value of a property ("+n+") should be a primitive value.");s(i(n),o,a,c)}else null!=o&&a.push(n.replace(/_.*/,"").replace(/[A-Z]/g,e=>"-"+e.toLowerCase())+": "+o+";")}(a.length||c)&&r.push((!n||l||o?e:e.map(n)).join(", ")+" {"+a.join(" ")+"}")}for(let t in e)s(i(t),e[t],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let e=Tn[Cn]||1;return Tn[Cn]=e+1,"ͼ"+e.toString(36)}static mount(e,t,n){let i=e[An],s=n&&n.nonce;i?s&&i.setNonce(s):i=new Mn(e,s),i.mount(Array.isArray(t)?t:[t],e)}}let On=new Map;class Mn{constructor(e,t){let n=e.ownerDocument||e,i=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&i.CSSStyleSheet){let t=On.get(n);if(t)return e[An]=t;this.sheet=new i.CSSStyleSheet,On.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[An]=this}mount(e,t){let n=this.sheet,i=0,s=0;for(let t=0;t<e.length;t++){let r=e[t],o=this.modules.indexOf(r);if(o<s&&o>-1&&(this.modules.splice(o,1),s--,o=-1),-1==o){if(this.modules.splice(s++,0,r),n)for(let e=0;e<r.rules.length;e++)n.insertRule(r.rules[e],i++)}else{for(;s<o;)i+=this.modules[s++].rules.length;i+=r.rules.length,s++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let e="";for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+"\n";this.styleTag.textContent=e;let n=t.head||t;this.styleTag.parentNode!=n&&n.insertBefore(this.styleTag,n.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}for(var En={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:"'"},Dn={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},_n="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),In="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Bn=0;Bn<10;Bn++)En[48+Bn]=En[96+Bn]=String(Bn);for(Bn=1;Bn<=24;Bn++)En[Bn+111]="F"+Bn;for(Bn=65;Bn<=90;Bn++)En[Bn]=String.fromCharCode(Bn+32),Dn[Bn]=String.fromCharCode(Bn);for(var Pn in En)Dn.hasOwnProperty(Pn)||(Dn[Pn]=En[Pn]);function Rn(){var e=arguments[0];"string"==typeof e&&(e=document.createElement(e));var t=1,n=arguments[1];if(n&&"object"==typeof n&&null==n.nodeType&&!Array.isArray(n)){for(var i in n)if(Object.prototype.hasOwnProperty.call(n,i)){var s=n[i];"string"==typeof s?e.setAttribute(i,s):null!=s&&(e[i]=s)}t++}for(;t<arguments.length;t++)$n(e,arguments[t]);return e}function $n(e,t){if("string"==typeof t)e.appendChild(document.createTextNode(t));else if(null==t);else if(null!=t.nodeType)e.appendChild(t);else{if(!Array.isArray(t))throw new RangeError("Unsupported child node: "+t);for(var n=0;n<t.length;n++)$n(e,t[n])}}let Ln="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},zn="undefined"!=typeof document?document:{documentElement:{style:{}}};const Fn=/Edge\/(\d+)/.exec(Ln.userAgent),jn=/MSIE \d/.test(Ln.userAgent),Wn=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ln.userAgent),Un=!!(jn||Wn||Fn),Vn=!Un&&/gecko\/(\d+)/i.test(Ln.userAgent),Hn=!Un&&/Chrome\/(\d+)/.exec(Ln.userAgent),qn="webkitFontSmoothing"in zn.documentElement.style,Kn=!Un&&/Apple Computer/.test(Ln.vendor),Jn=Kn&&(/Mobile\/\w+/.test(Ln.userAgent)||Ln.maxTouchPoints>2);var Zn={mac:Jn||/Mac/.test(Ln.platform),windows:/Win/.test(Ln.platform),linux:/Linux|X11/.test(Ln.platform),ie:Un,ie_version:jn?zn.documentMode||6:Wn?+Wn[1]:Fn?+Fn[1]:0,gecko:Vn,gecko_version:Vn?+(/Firefox\/(\d+)/.exec(Ln.userAgent)||[0,0])[1]:0,chrome:!!Hn,chrome_version:Hn?+Hn[1]:0,ios:Jn,android:/Android\b/.test(Ln.userAgent),webkit_version:qn?+(/\bAppleWebKit\/(\d+)/.exec(Ln.userAgent)||[0,0])[1]:0,safari:Kn,safari_version:Kn?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Ln.userAgent)||[0,0])[1]:0,tabSize:null!=zn.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};function Yn(e,t){for(let n in e)"class"==n&&t.class?t.class+=" "+e.class:"style"==n&&t.style?t.style+=";"+e.style:t[n]=e[n];return t}const Gn=Object.create(null);function Qn(e,t,n){if(e==t)return!0;e||(e=Gn),t||(t=Gn);let i=Object.keys(e),s=Object.keys(t);if(i.length-0!=s.length-0)return!1;for(let r of i)if(r!=n&&(-1==s.indexOf(r)||e[r]!==t[r]))return!1;return!0}function Xn(e,t,n){let i=!1;if(t)for(let s in t)n&&s in n||(i=!0,"style"==s?e.style.cssText="":e.removeAttribute(s));if(n)for(let s in n)t&&t[s]==n[s]||(i=!0,"style"==s?e.style.cssText=n[s]:e.setAttribute(s,n[s]));return i}function ei(e){let t=Object.create(null);for(let n=0;n<e.attributes.length;n++){let i=e.attributes[n];t[i.name]=i.value}return t}class ti{eq(e){return!1}updateDOM(e,t,n){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var ni=function(e){return e[e.Text=0]="Text",e[e.WidgetBefore=1]="WidgetBefore",e[e.WidgetAfter=2]="WidgetAfter",e[e.WidgetRange=3]="WidgetRange",e}(ni||(ni={}));class ii extends rn{constructor(e,t,n,i){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=i}get heightRelevant(){return!1}static mark(e){return new si(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new oi(e,t,t,n,e.widget||null,!1)}static replace(e){let t,n,i=!!e.block;if(e.isBlockGap)t=-5e8,n=4e8;else{let{start:s,end:r}=ai(e,i);t=(s?i?-3e8:-1:5e8)-1,n=1+(r?i?2e8:1:-6e8)}return new oi(e,t,n,i,e.widget||null,!0)}static line(e){return new ri(e)}static set(e,t=!1){return hn.of(e,t)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}ii.none=hn.empty;class si extends ii{constructor(e){let{start:t,end:n}=ai(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Yn(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Gn}eq(e){return this==e||e instanceof si&&this.tagName==e.tagName&&Qn(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}si.prototype.point=!1;class ri extends ii{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof ri&&this.spec.class==e.spec.class&&Qn(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}ri.prototype.mapMode=tt.TrackBefore,ri.prototype.point=!0;class oi extends ii{constructor(e,t,n,i,s,r){super(t,n,s,e),this.block=i,this.isReplace=r,this.mapMode=i?t<=0?tt.TrackBefore:tt.TrackAfter:tt.TrackDel}get type(){return this.startSide!=this.endSide?ni.WidgetRange:this.startSide<=0?ni.WidgetBefore:ni.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof oi&&function(e,t){return e==t||!!(e&&t&&e.compare(t))}(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}function ai(e,t=!1){let{inclusiveStart:n,inclusiveEnd:i}=e;return null==n&&(n=e.inclusive),null==i&&(i=e.inclusive),{start:null!=n?n:t,end:null!=i?i:t}}function li(e,t,n,i=0){let s=n.length-1;s>=0&&n[s]+i>=e?n[s]=Math.max(n[s],t):n.push(e,t)}oi.prototype.point=!0;class ci extends rn{constructor(e,t){super(),this.tagName=e,this.attributes=t}eq(e){return e==this||e instanceof ci&&this.tagName==e.tagName&&Qn(this.attributes,e.attributes)}static create(e){return new ci(e.tagName,e.attributes||Gn)}static set(e,t=!1){return hn.of(e,t)}}function hi(e){let t;return t=11==e.nodeType?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function ui(e,t){return!!t&&(e==t||e.contains(1!=t.nodeType?t.parentNode:t))}function di(e,t){if(!t.anchorNode)return!1;try{return ui(e,t.anchorNode)}catch(e){return!1}}function fi(e){return 3==e.nodeType?Ni(e,0,e.nodeValue.length).getClientRects():1==e.nodeType?e.getClientRects():[]}function pi(e,t,n,i){return!!n&&(bi(e,t,n,i,-1)||bi(e,t,n,i,1))}function mi(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t}function gi(e){return 1==e.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function bi(e,t,n,i,s){for(;;){if(e==n&&t==i)return!0;if(t==(s<0?0:yi(e))){if("DIV"==e.nodeName)return!1;let n=e.parentNode;if(!n||1!=n.nodeType)return!1;t=mi(e)+(s<0?0:1),e=n}else{if(1!=e.nodeType)return!1;if(1==(e=e.childNodes[t+(s<0?-1:0)]).nodeType&&"false"==e.contentEditable)return!1;t=s<0?yi(e):0}}}function yi(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function vi(e,t){let n=t?e.left:e.right;return{left:n,right:n,top:e.top,bottom:e.bottom}}function ki(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function wi(e,t){let n=t.width/e.offsetWidth,i=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.width-e.offsetWidth)<1)&&(n=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(t.height-e.offsetHeight)<1)&&(i=1),{scaleX:n,scaleY:i}}function xi(e,t=!0){let n=e.ownerDocument,i=null,s=null;for(let r=e.parentNode;r&&(r!=n.body&&(t&&!i||!s));)if(1==r.nodeType)!s&&r.scrollHeight>r.clientHeight&&(s=r),t&&!i&&r.scrollWidth>r.clientWidth&&(i=r),r=r.assignedSlot||r.parentNode;else{if(11!=r.nodeType)break;r=r.host}return{x:i,y:s}}ci.prototype.startSide=ci.prototype.endSide=-1;class Si{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?yi(t):0),n,Math.min(e.focusOffset,n?yi(n):0))}set(e,t,n,i){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=i}}let Ci,Ai=null;function Ti(e){if(e.setActive)return e.setActive();if(Ai)return e.focus(Ai);let t=[];for(let n=e;n&&(t.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(e.focus(null==Ai?{get preventScroll(){return Ai={preventScroll:!0},!0}}:void 0),!Ai){Ai=!1;for(let e=0;e<t.length;){let n=t[e++],i=t[e++],s=t[e++];n.scrollTop!=i&&(n.scrollTop=i),n.scrollLeft!=s&&(n.scrollLeft=s)}}}function Ni(e,t,n=t){let i=Ci||(Ci=document.createRange());return i.setEnd(e,n),i.setStart(e,t),i}function Oi(e,t,n,i){let s={key:t,code:t,keyCode:n,which:n,cancelable:!0};i&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=i);let r=new KeyboardEvent("keydown",s);r.synthetic=!0,e.dispatchEvent(r);let o=new KeyboardEvent("keyup",s);return o.synthetic=!0,e.dispatchEvent(o),r.defaultPrevented||o.defaultPrevented}function Mi(e){return e instanceof Window?e.pageYOffset>Math.max(0,e.document.documentElement.scrollHeight-e.innerHeight-4):e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function Ei(e,t){for(let n=e,i=t;;){if(3==n.nodeType&&i>0)return{node:n,offset:i};if(1==n.nodeType&&i>0){if("false"==n.contentEditable)return null;n=n.childNodes[i-1],i=yi(n)}else{if(!n.parentNode||gi(n))return null;i=mi(n),n=n.parentNode}}}function Di(e,t){for(let n=e,i=t;;){if(3==n.nodeType&&i<n.nodeValue.length)return{node:n,offset:i};if(1==n.nodeType&&i<n.childNodes.length){if("false"==n.contentEditable)return null;n=n.childNodes[i],i=0}else{if(!n.parentNode||gi(n))return null;i=mi(n)+1,n=n.parentNode}}}Zn.safari&&Zn.safari_version>=26&&(Ai=!1);class _i{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(e,t){return new _i(e.parentNode,mi(e),t)}static after(e,t){return new _i(e.parentNode,mi(e)+1,t)}}var Ii=function(e){return e[e.LTR=0]="LTR",e[e.RTL=1]="RTL",e}(Ii||(Ii={}));const Bi=Ii.LTR,Pi=Ii.RTL;function Ri(e){let t=[];for(let n=0;n<e.length;n++)t.push(1<<+e[n]);return t}const $i=Ri("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Li=Ri("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),zi=Object.create(null),Fi=[];for(let e of["()","[]","{}"]){let t=e.charCodeAt(0),n=e.charCodeAt(1);zi[t]=n,zi[n]=-t}function ji(e){return e<=247?$i[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?Li[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}const Wi=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Ui{get dir(){return this.level%2?Pi:Bi}constructor(e,t,n){this.from=e,this.to=t,this.level=n}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,i){let s=-1;for(let r=0;r<e.length;r++){let o=e[r];if(o.from<=t&&o.to>=t){if(o.level==n)return r;(s<0||(0!=i?i<0?o.from<t:o.to>t:e[s].level>o.level))&&(s=r)}}if(s<0)throw new RangeError("Index out of range");return s}}function Vi(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let i=e[n],s=t[n];if(i.from!=s.from||i.to!=s.to||i.direction!=s.direction||!Vi(i.inner,s.inner))return!1}return!0}const Hi=[];function qi(e,t,n,i,s,r,o){let a=i%2?2:1;if(i%2==s%2)for(let l=t,c=0;l<n;){let t=!0,h=!1;if(c==r.length||l<r[c].from){let e=Hi[l];e!=a&&(t=!1,h=16==e)}let u=t||1!=a?null:[],d=t?i:i+1,f=l;e:for(;;)if(c<r.length&&f==r[c].from){if(h)break e;let p=r[c];if(!t)for(let e=p.to,t=c+1;;){if(e==n)break e;if(!(t<r.length&&r[t].from==e)){if(Hi[e]==a)break e;break}e=r[t++].to}if(c++,u)u.push(p);else{p.from>l&&o.push(new Ui(l,p.from,d)),Ki(e,p.direction==Bi!=!(d%2)?i+1:i,s,p.inner,p.from,p.to,o),l=p.to}f=p.to}else{if(f==n||(t?Hi[f]!=a:Hi[f]==a))break;f++}u?qi(e,l,f,i+1,s,u,o):l<f&&o.push(new Ui(l,f,d)),l=f}else for(let l=n,c=r.length;l>t;){let n=!0,h=!1;if(!c||l>r[c-1].to){let e=Hi[l-1];e!=a&&(n=!1,h=16==e)}let u=n||1!=a?null:[],d=n?i:i+1,f=l;e:for(;;)if(c&&f==r[c-1].to){if(h)break e;let p=r[--c];if(!n)for(let e=p.from,n=c;;){if(e==t)break e;if(!n||r[n-1].to!=e){if(Hi[e-1]==a)break e;break}e=r[--n].from}if(u)u.push(p);else{p.to<l&&o.push(new Ui(p.to,l,d)),Ki(e,p.direction==Bi!=!(d%2)?i+1:i,s,p.inner,p.from,p.to,o),l=p.from}f=p.from}else{if(f==t||(n?Hi[f-1]!=a:Hi[f-1]==a))break;f--}u?qi(e,f,l,i+1,s,u,o):f<l&&o.push(new Ui(f,l,d)),l=f}}function Ki(e,t,n,i,s,r,o){let a=t%2?2:1;!function(e,t,n,i,s){for(let r=0;r<=i.length;r++){let o=r?i[r-1].to:t,a=r<i.length?i[r].from:n,l=r?256:s;for(let t=o,n=l,i=l;t<a;t++){let s=ji(e.charCodeAt(t));512==s?s=n:8==s&&4==i&&(s=16),Hi[t]=4==s?2:s,7&s&&(i=s),n=s}for(let e=o,t=l,i=l;e<a;e++){let s=Hi[e];if(128==s)e<a-1&&t==Hi[e+1]&&24&t?s=Hi[e]=t:Hi[e]=256;else if(64==s){let s=e+1;for(;s<a&&64==Hi[s];)s++;let r=e&&8==t||s<n&&8==Hi[s]?1==i?1:8:256;for(let t=e;t<s;t++)Hi[t]=r;e=s-1}else 8==s&&1==i&&(Hi[e]=1);t=s,7&s&&(i=s)}}}(e,s,r,i,a),function(e,t,n,i,s){let r=1==s?2:1;for(let o=0,a=0,l=0;o<=i.length;o++){let c=o?i[o-1].to:t,h=o<i.length?i[o].from:n;for(let t,n,i,o=c;o<h;o++)if(n=zi[t=e.charCodeAt(o)])if(n<0){for(let e=a-3;e>=0;e-=3)if(Fi[e+1]==-n){let t=Fi[e+2],n=2&t?s:4&t?1&t?r:s:0;n&&(Hi[o]=Hi[Fi[e]]=n),a=e;break}}else{if(189==Fi.length)break;Fi[a++]=o,Fi[a++]=t,Fi[a++]=l}else if(2==(i=Hi[o])||1==i){let e=i==s;l=e?0:1;for(let t=a-3;t>=0;t-=3){let n=Fi[t+2];if(2&n)break;if(e)Fi[t+2]|=2;else{if(4&n)break;Fi[t+2]|=4}}}}}(e,s,r,i,a),function(e,t,n,i){for(let s=0,r=i;s<=n.length;s++){let o=s?n[s-1].to:e,a=s<n.length?n[s].from:t;for(let l=o;l<a;){let o=Hi[l];if(256==o){let o=l+1;for(;;)if(o==a){if(s==n.length)break;o=n[s++].to,a=s<n.length?n[s].from:t}else{if(256!=Hi[o])break;o++}let c=1==r,h=c==(1==(o<t?Hi[o]:i))?c?1:2:i;for(let t=o,i=s,r=i?n[i-1].to:e;t>l;)t==r&&(t=n[--i].from,r=i?n[i-1].to:e),Hi[--t]=h;l=o}else r=o,l++}}}(s,r,i,a),qi(e,s,r,t,n,i,o)}function Ji(e){return[new Ui(0,e,0)]}let Zi="";function Yi(e,t,n,i,s){var r;let o=i.head-e.from,a=Ui.find(t,o,null!==(r=i.bidiLevel)&&void 0!==r?r:-1,i.assoc),l=t[a],c=l.side(s,n);if(o==c){let e=a+=s?1:-1;if(e<0||e>=t.length)return null;l=t[a=e],o=l.side(!s,n),c=l.side(s,n)}let h=Ye(e.text,o,l.forward(s,n));(h<l.from||h>l.to)&&(h=c),Zi=e.text.slice(Math.min(o,h),Math.max(o,h));let u=a==(s?t.length-1:0)?null:t[a+(s?1:-1)];return u&&h==c&&u.level+(s?0:1)<l.level?ut.cursor(u.side(!s,n)+e.from,u.forward(s,n)?1:-1,u.level):ut.cursor(h+e.from,l.forward(s,n)?-1:1,l.level)}function Gi(e,t,n){for(let i=t;i<n;i++){let t=ji(e.charCodeAt(i));if(1==t)return Bi;if(2==t||4==t)return Pi}return Bi}const Qi=pt.define(),Xi=pt.define(),es=pt.define(),ts=pt.define(),ns=pt.define(),is=pt.define(),ss=pt.define(),rs=pt.define(),os=pt.define(),as=pt.define({combine:e=>e.some(e=>e)}),ls=pt.define({combine:e=>e.some(e=>e)}),cs=pt.define();class hs{constructor(e,t="nearest",n="nearest",i=5,s=5,r=!1){this.range=e,this.y=t,this.x=n,this.yMargin=i,this.xMargin=s,this.isSnapshot=r}map(e){return e.empty?this:new hs(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new hs(ut.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const us=Vt.define({map:(e,t)=>e.map(t)}),ds=Vt.define();function fs(e,t,n){let i=e.facet(ts);i.length?i[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)||(n?console.error(n+":",t):console.error(t))}const ps=pt.define({combine:e=>!e.length||e[0]});let ms=0;const gs=pt.define({combine:e=>e.filter((t,n)=>{for(let i=0;i<n;i++)if(e[i].plugin==t.plugin)return!1;return!0})});class bs{constructor(e,t,n,i,s){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=i,this.baseExtensions=s(this),this.extension=this.baseExtensions.concat(gs.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(gs.of({plugin:this,arg:e}))}static define(e,t){const{eventHandlers:n,eventObservers:i,provide:s,decorations:r}=t||{};return new bs(ms++,e,n,i,e=>{let t=[];return r&&t.push(ws.of(t=>{let n=t.plugin(e);return n?r(n):ii.none})),s&&t.push(s(e)),t})}static fromClass(e,t){return bs.define((t,n)=>new e(t,n),t)}}class ys{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(fs(e.state,t,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(e){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){fs(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(null===(t=this.value)||void 0===t?void 0:t.destroy)try{this.value.destroy()}catch(t){fs(e.state,t,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const vs=pt.define(),ks=pt.define(),ws=pt.define(),xs=pt.define(),Ss=pt.define(),Cs=pt.define(),As=pt.define();function Ts(e,t){let n=e.state.facet(As);if(!n.length)return n;let i=n.map(t=>t instanceof Function?t(e):t),s=[];return hn.spans(i,t.from,t.to,{point(){},span(e,n,i,r){let o=e-t.from,a=n-t.from,l=s;for(let e=i.length-1;e>=0;e--,r--){let n,s=i[e].spec.bidiIsolate;if(null==s&&(s=Gi(t.text,o,a)),r>0&&l.length&&(n=l[l.length-1]).to==o&&n.direction==s)n.to=a,l=n.inner;else{let e={from:o,to:a,direction:s,inner:[]};l.push(e),l=e.inner}}}}),s}const Ns=pt.define();function Os(e){let t=0,n=0,i=0,s=0;for(let r of e.state.facet(Ns)){let o=r(e);o&&(null!=o.left&&(t=Math.max(t,o.left)),null!=o.right&&(n=Math.max(n,o.right)),null!=o.top&&(i=Math.max(i,o.top)),null!=o.bottom&&(s=Math.max(s,o.bottom)))}return{left:t,right:n,top:i,bottom:s}}const Ms=pt.define();class Es{constructor(e,t,n,i){this.fromA=e,this.toA=t,this.fromB=n,this.toB=i}join(e){return new Es(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let i=e[t-1];if(!(i.fromA>n.toA)){if(i.toA<n.fromA)break;n=n.join(i),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(e,t){if(0==t.length)return e;let n=[];for(let i=0,s=0,r=0;;){let o=i<e.length?e[i].fromB:1e9,a=s<t.length?t[s]:1e9,l=Math.min(o,a);if(1e9==l)break;let c=l+r,h=l,u=c;for(;;)if(s<t.length&&t[s]<=h){let n=t[s+1];s+=2,h=Math.max(h,n);for(let t=i;t<e.length&&e[t].fromB<=h;t++)r=e[t].toA-e[t].toB;u=Math.max(u,n+r)}else{if(!(i<e.length&&e[i].fromB<=h))break;{let t=e[i++];h=Math.max(h,t.toB),u=Math.max(u,t.toA),r=t.toA-t.toB}}n.push(new Es(c,u,l,h))}return n}}class Ds{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=it.empty(this.startState.doc.length);for(let e of n)this.changes=this.changes.compose(e.changes);let i=[];this.changes.iterChangedRanges((e,t,n,s)=>i.push(new Es(e,t,n,s))),this.changedRanges=i}static create(e,t,n){return new Ds(e,t,n)}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(e=>e.selection)}get empty(){return 0==this.flags&&0==this.transactions.length}}const _s=[];class Is{constructor(e,t,n=0){this.dom=e,this.length=t,this.flags=n,this.parent=null,e.cmTile=this}get breakAfter(){return 1&this.flags}get children(){return _s}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,4&this.flags){this.flags&=-5;let e=this.domAttrs;e&&function(e,t){for(let n=e.attributes.length-1;n>=0;n--){let i=e.attributes[n].name;null==t[i]&&e.removeAttribute(i)}for(let n in t){let i=t[n];"style"==n?e.style.cssText=i:e.getAttribute(n)!=i&&e.setAttribute(n,i)}}(this.dom,e)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let n=t;for(let t of this.children){if(t==e)return n;n+=t.length+t.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t){return null}domPosFor(e,t){let n=mi(this.dom),i=this.length?e>0:t>0;return new _i(this.parent.dom,n+(i?1:0),0==e||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&2&this.parent.flags&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof Rs)return e;return null}static get(e){return e.cmTile}}class Bs extends Is{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(2&this.flags)return;super.sync(e);let t,n=this.dom,i=null,s=(null==e?void 0:e.node)==n?e:null,r=0;for(let o of this.children){if(o.sync(e),r+=o.length+o.breakAfter,t=i?i.nextSibling:n.firstChild,s&&t!=o.dom&&(s.written=!0),o.dom.parentNode==n)for(;t&&t!=o.dom;)t=Ps(t);else n.insertBefore(o.dom,t);i=o.dom}for(t=i?i.nextSibling:n.firstChild,s&&t&&(s.written=!0);t;)t=Ps(t);this.length=r}}function Ps(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class Rs extends Bs{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=Is.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],n=this,i=0,s=0;;)if(i==n.children.length){if(!t.length)return;n=n.parent,n.breakAfter&&s++,i=t.pop()}else{let r=n.children[i++];if(r instanceof $s)t.push(i),n=r,i=0;else{let t=s+r.length,n=e(r,s);if(void 0!==n)return n;s=t+r.breakAfter}}}resolveBlock(e,t){let n,i,s=-1,r=-1;if(this.blockTiles((o,a)=>{let l=a+o.length;if(e>=a&&e<=l){if(o.isWidget()&&t>=-1&&t<=1){if(32&o.flags)return!0;16&o.flags&&(n=void 0)}(a<e||e==l&&(t<-1?o.length:o.covers(1)))&&(!n||!o.isWidget()&&n.isWidget())&&(n=o,s=e-a),(l>e||e==a&&(t>1?o.length:o.covers(-1)))&&(!i||!o.isWidget()&&i.isWidget())&&(i=o,r=e-a)}}),!n&&!i)throw new Error("No tile at position "+e);return n&&t<0||!i?{tile:n,offset:s}:{tile:i,offset:r}}}class $s extends Bs{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return!!this.children.length&&(e<0?this.children[0].covers(-1):this.lastChild.covers(1))}get domAttrs(){return this.wrapper.attributes}static of(e,t){let n=new $s(t||document.createElement(e.tagName),e);return t||(n.flags|=4),n}}class Ls extends Bs{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,n){let i=new Ls(t||document.createElement("div"),e);return t&&n||(i.flags|=4),i}get domAttrs(){return this.attrs}resolveInline(e,t,n){let i=null,s=-1,r=null,o=-1;!function e(a,l){for(let c=0,h=0;c<a.children.length&&h<=l;c++){let u=a.children[c],d=h+u.length;d>=l&&(u.isComposite()?e(u,l-h):(!r||r.isHidden&&(t>0||n&&zs(r,u)))&&(d>l||32&u.flags)?(r=u,o=l-h):(h<l||16&u.flags&&!u.isHidden)&&(i=u,s=l-h)),h=d}}(this,e);let a=(t<0?i:r)||i||r;return a?{tile:a,offset:a==i?s:o}:null}coordsIn(e,t){let n=this.resolveInline(e,t,!0);return n?n.tile.coordsIn(Math.max(0,n.offset),t):function(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=fi(t);return n[n.length-1]||null}(this)}domIn(e,t){let n=this.resolveInline(e,t);if(n){let{tile:e,offset:i}=n;if(this.dom.contains(e.dom))return e.isText()?new _i(e.dom,Math.min(e.dom.nodeValue.length,i)):e.domPosFor(i,16&e.flags?1:32&e.flags?-1:t);let s=n.tile.parent,r=!1;for(let e of s.children){if(r)return new _i(e.dom,0);e==n.tile&&(r=!0)}}return new _i(this.dom,0)}}function zs(e,t){let n=e.coordsIn(0,1),i=t.coordsIn(0,1);return n&&i&&i.top<n.bottom}class Fs extends Bs{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(e,t){let n=new Fs(t||document.createElement(e.tagName),e);return t||(n.flags|=4),n}}class js extends Is{constructor(e,t){super(e,t.length),this.text=t}sync(e){2&this.flags||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t){let n=this.dom.nodeValue.length;e>n&&(e=n);let i=e,s=e,r=0;0==e&&t<0||e==n&&t>=0?Zn.chrome||Zn.gecko||(e?(i--,r=1):s<n&&(s++,r=-1)):t<0?i--:s<n&&s++;let o=Ni(this.dom,i,s).getClientRects();if(!o.length)return null;let a=o[(r?r<0:t>=0)?0:o.length-1];return Zn.safari&&!r&&0==a.width&&(a=Array.prototype.find.call(o,e=>e.width)||a),r?vi(a,r<0):a||null}static of(e,t){let n=new js(t||document.createTextNode(e),e);return t||(n.flags|=2),n}}class Ws extends Is{constructor(e,t,n,i){super(e,t,i),this.widget=n}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return!(48&this.flags)&&(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,n){let i=this.widget.coordsAt(this.dom,e,t);if(i)return i;if(n)return vi(this.dom.getBoundingClientRect(),this.length?0==e:t<=0);{let t=this.dom.getClientRects(),n=null;if(!t.length)return null;let i=!!(16&this.flags)||!(32&this.flags)&&e>0;for(let s=i?t.length-1:0;n=t[s],!(e>0?0==s:s==t.length-1||n.top<n.bottom);s+=i?-1:1);return vi(n,!i)}}get overrideDOMText(){if(!this.length)return Fe.empty;let{root:e}=this;if(!e)return Fe.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,t,n,i,s){return s||(s=e.toDOM(t),e.editable||(s.contentEditable="false")),new Ws(s,n,e,i)}}class Us extends Is{constructor(e){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return Fe.empty}coordsIn(e){return this.dom.getBoundingClientRect()}}class Vs{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,n){let{tile:i,index:s,beforeBreak:r,parents:o}=this;for(;e||t>0;)if(i.isComposite())if(r){if(!e)break;n&&n.break(),e--,r=!1}else if(s==i.children.length){if(!e&&!o.length)break;n&&n.leave(i),r=!!i.breakAfter,({tile:i,index:s}=o.pop()),s++}else{let a=i.children[s],l=a.breakAfter;!(t>0?a.length<=e:a.length<e)||n&&!1===n.skip(a,0,a.length)&&a.isComposite?(o.push({tile:i,index:s}),i=a,s=0,n&&a.isComposite()&&n.enter(a)):(r=!!l,s++,e-=a.length)}else if(s==i.length)r=!!i.breakAfter,({tile:i,index:s}=o.pop()),s++;else{if(!e)break;{let t=Math.min(e,i.length-s);n&&n.skip(i,s,s+t),e-=t,s+=t}}return this.tile=i,this.index=s,this.beforeBreak=r,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class Hs{constructor(e,t,n,i){this.from=e,this.to=t,this.wrapper=n,this.rank=i}}class qs{constructor(e,t,n){this.cache=e,this.root=t,this.blockWrappers=n,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,n,i){var s;this.flushBuffer();let r=this.ensureMarks(t,n),o=r.lastChild;if(o&&o.isText()&&!(8&o.flags)&&o.length+e.length<512){this.cache.reused.set(o,2),(r.children[r.children.length-1]=new js(o.dom,o.text+e)).parent=r}else r.append(i||js.of(e,null===(s=this.cache.find(js))||void 0===s?void 0:s.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let n=this.curLine;n.dom!=t.line.dom&&(n.setDOM(this.cache.reused.has(t.line)?Xs(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let i=n;for(let e=t.marks.length-1;e>=0;e--){let n=t.marks[e],s=i.lastChild;if(s instanceof Fs&&s.mark.eq(n.mark))s.dom!=n.dom&&s.setDOM(Xs(n.dom)),i=s;else{if(this.cache.reused.get(n)){let e=Is.get(n.dom);e&&e.setDOM(Xs(n.dom))}let e=Fs.of(n.mark,n.dom);i.append(e),i=e}this.cache.reused.set(n,2)}let s=Is.get(e.text);s&&this.cache.reused.set(s,2);let r=new js(e.text,e.text.nodeValue);r.flags|=8,i.append(r)}addInlineWidget(e,t,n){let i=this.afterWidget&&48&e.flags&&(48&this.afterWidget.flags)==(48&e.flags);i||this.flushBuffer();let s=this.ensureMarks(t,n);i||16&e.flags||s.append(this.getBuffer(1)),s.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,n){this.flushBuffer(),this.ensureMarks(t,n).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){(this.afterWidget||this.lastBlock).length+=e,this.pos+=e}addLineStart(e,t){var n;e||(e=Qs);let i=Ls.start(e,t||(null===(n=this.cache.find(Ls))||void 0===n?void 0:n.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=i)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var n;let i=this.curLine;for(let s=e.length-1;s>=0;s--){let r,o=e[s];if(t>0&&(r=i.lastChild)&&r instanceof Fs&&r.mark.eq(o))i=r,t--;else{let e=Fs.of(o,null===(n=this.cache.find(Fs,e=>e.mark.eq(o)))||void 0===n?void 0:n.dom);i.append(e),i=e,t=0}}return i}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;e&&Gs(this.curLine,!1)&&("BR"==e.dom.nodeName||!e.isWidget()||Zn.ios&&Gs(this.curLine,!0))||this.curLine.append(this.cache.findWidget(tr,0,32)||new Ws(tr.toDOM(),0,tr,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=new Hs(e.from,e.to,e.value,e.rank),n=this.wrappers.length;for(;n>0&&(this.wrappers[n-1].rank-t.rank||this.wrappers[n-1].to-t.to)<0;)n--;this.wrappers.splice(n,0,t)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let n of this.wrappers){let i=t.lastChild;if(n.from<this.pos&&i instanceof $s&&i.wrapper.eq(n.wrapper))t=i;else{let i=$s.of(n.wrapper,null===(e=this.cache.find($s,e=>e.wrapper.eq(n.wrapper)))||void 0===e?void 0:e.dom);t.append(i),t=i}}return t}blockPosCovered(){let e=this.lastBlock;return null!=e&&!e.breakAfter&&(!e.isWidget()||(160&e.flags)>0)}getBuffer(e){let t=2|(e<0?16:32),n=this.cache.find(Us,void 0,1);return n&&(n.flags=t),n||new Us(t)}flushBuffer(){!this.afterWidget||32&this.afterWidget.flags||(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class Ks{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:t,lineBreak:n,done:i}=this.cursor.next(this.skipCount);if(this.skipCount=0,i)throw new Error("Ran out of text content when drawing inline views");this.text=t;let s=this.textOff=Math.min(e,t.length);return n?null:t.slice(0,s)}let t=Math.min(this.text.length,this.textOff+e),n=this.text.slice(this.textOff,t);return this.textOff=t,n}}const Js=[Ws,Ls,js,Fs,Us,$s,Rs];for(let e=0;e<Js.length;e++)Js[e].bucket=e;class Zs{constructor(e){this.view=e,this.buckets=Js.map(()=>[]),this.index=Js.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,n=this.buckets[t];n.length<6?n.push(e):n[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,n=2){let i=e.bucket,s=this.buckets[i],r=this.index[i];for(let e=s.length-1;e>=0;e--){let o=(e+r)%s.length,a=s[o];if((!t||t(a))&&!this.reused.has(a))return s.splice(o,1),o<r&&this.index[i]--,this.reused.set(a,n),a}return null}findWidget(e,t,n){let i=this.buckets[0];if(i.length)for(let s=0,r=0;;s++){if(s==i.length){if(r)return null;r=1,s=0}let o=i[s];if(!this.reused.has(o)&&(0==r?o.widget.compare(e):o.widget.constructor==e.constructor&&e.updateDOM(o.dom,this.view,o.widget)))return i.splice(s,1),s<this.index[0]&&this.index[0]--,o.widget==e&&o.length==t&&(497&o.flags)==n?(this.reused.set(o,1),o):(this.reused.set(o,2),new Ws(o.dom,t,e,-498&o.flags|n))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}}class Ys{constructor(e,t,n,i,s){this.view=e,this.decorations=i,this.disallowBlockEffectsFor=s,this.openWidget=!1,this.openMarks=0,this.cache=new Zs(e),this.text=new Ks(e.state.doc),this.builder=new qs(this.cache,new Rs(e,e.contentDOM),hn.iter(n)),this.cache.reused.set(t,2),this.old=new Vs(t),this.reuseWalker={skip:(e,t,n)=>{if(this.cache.add(e),e.isComposite())return!1},enter:e=>this.cache.add(e),leave:()=>{},break:()=>{}}}run(e,t){let n=t&&this.getCompositionContext(t.text);for(let i=0,s=0,r=0;;){let o=r<e.length?e[r++]:null,a=o?o.fromA:this.old.root.length;if(a>i){let e=a-i;this.preserve(e,!r,!o),i=a,s+=e}if(!o)break;t&&o.fromA<=t.range.fromA&&o.toA>=t.range.toA?(this.forward(o.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(s,t.range.fromB),this.cache.clear(),this.builder.addComposition(t,n),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,o.toA),this.emit(t.range.toB,o.toB)):(this.forward(o.fromA,o.toA),this.emit(s,o.toB)),s=o.toB,i=o.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,n){let i=function(e){let t=[];for(let n=e.parents.length;n>1;n--){let i=n==e.parents.length?e.tile:e.parents[n].tile;i instanceof Fs&&t.push(i.mark)}return t}(this.old),s=this.openMarks;this.old.advance(e,n?1:-1,{skip:(e,t,n)=>{if(e.isWidget())if(this.openWidget)this.builder.continueWidget(n-t);else{let r=n>0||t<e.length?Ws.of(e.widget,this.view,n-t,496&e.flags,this.cache.maybeReuse(e)):this.cache.reuse(e);256&r.flags?(r.flags&=-2,this.builder.addBlockWidget(r)):(this.builder.ensureLine(null),this.builder.addInlineWidget(r,i,s),s=i.length)}else if(e.isText())this.builder.ensureLine(null),t||n!=e.length||this.cache.reused.has(e)?(this.cache.add(e),this.builder.addText(e.text.slice(t,n),i,s)):this.builder.addText(e.text,i,s,this.cache.reuse(e)),s=i.length;else if(e.isLine())e.flags&=-2,this.cache.reused.set(e,1),this.builder.addLine(e);else if(e instanceof Us)this.cache.add(e);else{if(!(e instanceof Fs))return!1;this.builder.ensureLine(null),this.builder.addMark(e,i,s),this.cache.reused.set(e,1),s=i.length}this.openWidget=!1},enter:e=>{e.isLine()?this.builder.addLineStart(e.attrs,this.cache.maybeReuse(e)):(this.cache.add(e),e instanceof Fs&&i.unshift(e.mark)),this.openWidget=!1},leave:e=>{e.isLine()?i.length&&(i.length=s=0):e instanceof Fs&&(i.shift(),s=Math.min(s,i.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let n=null,i=this.builder,s=0,r=hn.spans(this.decorations,e,t,{point:(e,t,r,o,a,l)=>{if(r instanceof oi){if(this.disallowBlockEffectsFor[l]){if(r.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.view.state.doc.lineAt(e).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(s=o.length,a>o.length)i.continueWidget(t-e);else{let s=r.widget||(r.block?er.block:er.inline),l=function(e){let t=e.isReplace?(e.startSide<0?64:0)|(e.endSide>0?128:0):e.startSide>0?32:16;e.block&&(t|=256);return t}(r),c=this.cache.findWidget(s,t-e,l)||Ws.of(s,this.view,t-e,l);r.block?(r.startSide>0&&i.addLineStartIfNotCovered(n),i.addBlockWidget(c)):(i.ensureLine(n),i.addInlineWidget(c,o,a))}n=null}else n=function(e,t){let n=t.spec.attributes,i=t.spec.class;if(!n&&!i)return e;e||(e={class:"cm-line"});n&&Yn(n,e);i&&(e.class+=" "+i);return e}(n,r);t>e&&this.text.skip(t-e)},span:(e,t,s,r)=>{for(let o=e;o<t;){let a=this.text.next(Math.min(512,t-o));null==a?(i.addLineStartIfNotCovered(n),i.addBreak(),o++):(i.ensureLine(n),i.addText(a,s,o==e?r:s.length),o+=a.length),n=null}}});i.addLineStartIfNotCovered(n),this.openWidget=r>s,this.openMarks=r}forward(e,t,n=1){t-e<=10?this.old.advance(t-e,n,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,n,this.reuseWalker))}getCompositionContext(e){let t=[],n=null;for(let i=e.parentNode;;i=i.parentNode){let e=Is.get(i);if(i==this.view.contentDOM)break;e instanceof Fs?t.push(e):(null==e?void 0:e.isLine())?n=e:e instanceof $s||("DIV"!=i.nodeName||n||i==this.view.contentDOM?n||t.push(Fs.of(new si({tagName:i.nodeName.toLowerCase(),attributes:ei(i)}),i)):n=new Ls(i,Qs))}return{line:n,marks:t}}}function Gs(e,t){let n=e=>{for(let i of e.children)if((t?i.isText():i.length)||n(i))return!0;return!1};return n(e)}const Qs={class:"cm-line"};function Xs(e){let t=Is.get(e);return t&&t.setDOM(e.cloneNode()),e}class er extends ti{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}er.inline=new er("span"),er.block=new er("div");const tr=new class extends ti{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class nr{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=ii.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 Rs(e,e.contentDOM),this.updateInner([new Es(0,0,0,e.state.doc.length)],null)}update(e){var t;let n=e.changedRanges;this.minWidth>0&&n.length&&(n.every(({fromA:e,toA:t})=>t<this.minWidthFrom||e>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let i=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&((null===(t=this.domChanged)||void 0===t?void 0:t.newSel)?i=this.domChanged.newSel.head:function(e,t){let n=!1;t&&e.iterChangedRanges((e,i)=>{e<t.to&&i>t.from&&(n=!0)});return n}(e.changes,this.hasComposition)||e.selectionSet||(i=e.state.selection.main.head));let s=i>-1?function(e,t,n){let i=sr(e,n);if(!i)return null;let{node:s,from:r,to:o}=i,a=s.nodeValue;if(/[\n\r]/.test(a))return null;if(e.state.doc.sliceString(i.from,i.to)!=a)return null;let l=t.invertedDesc;return{range:new Es(l.mapPos(r),l.mapPos(o),r,o),text:s}}(this.view,e.changes,i):null;if(this.domChanged=null,this.hasComposition){let{from:t,to:i}=this.hasComposition;n=new Es(t,i,e.changes.mapPos(t,-1),e.changes.mapPos(i,1)).addToSet(n.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(Zn.ie||Zn.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let r=this.decorations,o=this.blockWrappers;this.updateDeco();let a=function(e,t,n){let i=new rr;return hn.compare(e,t,n,i),i.changes}(r,this.decorations,e.changes);a.length&&(n=Es.extendWithRanges(n,a));let l=function(e,t,n){let i=new or;return hn.compare(e,t,n,i),i.changes}(o,this.blockWrappers,e.changes);return l.length&&(n=Es.extendWithRanges(n,l)),s&&!n.some(e=>e.fromA<=s.range.fromA&&e.toA>=s.range.toA)&&(n=s.range.addToSet(n.slice())),!(2&this.tile.flags&&0==n.length)&&(this.updateInner(n,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:n}=this.view;n.ignore(()=>{if(t||e.length){let n=this.tile,i=new Ys(this.view,n,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&Is.get(t.text)&&i.cache.reused.set(Is.get(t.text),2),this.tile=i.run(e,t),ir(n,i.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 i=Zn.chrome||Zn.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(i),!i||!i.written&&n.selectionRange.focusNode==i.node&&this.tile.dom.contains(i.node)||(this.forceSelection=!0),this.tile.dom.style.height=""});let i=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let e of this.tile.children)e.isWidget()&&e.widget instanceof ar&&i.push(e.dom);n.updateGaps(i)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let e of t.effects)e.is(ds)&&(this.editContextFormatting=e.value)}updateSelection(e=!1,t=!1){!e&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let{dom:n}=this.tile,i=this.view.root.activeElement,s=i==n,r=!s&&!(this.view.state.facet(ps)||n.tabIndex>-1)&&di(n,this.view.observer.selectionRange)&&!(i&&n.contains(i));if(!(s||t||r))return;let o=this.forceSelection;this.forceSelection=!1;let a,l,c=this.view.state.selection.main;if(c.empty?l=a=this.inlineDOMNearPos(c.anchor,c.assoc||1):(l=this.inlineDOMNearPos(c.head,c.head==c.from?1:-1),a=this.inlineDOMNearPos(c.anchor,c.anchor==c.from?1:-1)),Zn.gecko&&c.empty&&!this.hasComposition&&(1==(h=a).node.nodeType&&h.node.firstChild&&(0==h.offset||"false"==h.node.childNodes[h.offset-1].contentEditable)&&(h.offset==h.node.childNodes.length||"false"==h.node.childNodes[h.offset].contentEditable))){let e=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(e,a.node.childNodes[a.offset]||null)),a=l=new _i(e,0),o=!0}var h;let u=this.view.observer.selectionRange;!o&&u.focusNode&&(pi(a.node,a.offset,u.anchorNode,u.anchorOffset)&&pi(l.node,l.offset,u.focusNode,u.focusOffset)||this.suppressWidgetCursorChange(u,c))||(this.view.observer.ignore(()=>{Zn.android&&Zn.chrome&&n.contains(u.focusNode)&&function(e,t){for(let n=e;n&&n!=t;n=n.assignedSlot||n.parentNode)if(1==n.nodeType&&"false"==n.contentEditable)return!0;return!1}(u.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let e=hi(this.view.root);if(e)if(c.empty){if(Zn.gecko){let e=(t=a.node,s=a.offset,1!=t.nodeType?0:(s&&"false"==t.childNodes[s-1].contentEditable?1:0)|(s<t.childNodes.length&&"false"==t.childNodes[s].contentEditable?2:0));if(e&&3!=e){let t=(1==e?Ei:Di)(a.node,a.offset);t&&(a=new _i(t.node,t.offset))}}e.collapse(a.node,a.offset),null!=c.bidiLevel&&void 0!==e.caretBidiLevel&&(e.caretBidiLevel=c.bidiLevel)}else if(e.extend){e.collapse(a.node,a.offset);try{e.extend(l.node,l.offset)}catch(e){}}else{let t=document.createRange();c.anchor>c.head&&([a,l]=[l,a]),t.setEnd(l.node,l.offset),t.setStart(a.node,a.offset),e.removeAllRanges(),e.addRange(t)}else;var t,s;r&&this.view.root.activeElement==n&&(n.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(a,l)),this.impreciseAnchor=a.precise?null:new _i(u.anchorNode,u.anchorOffset),this.impreciseHead=l.precise?null:new _i(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&pi(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=hi(e.root),{anchorNode:i,anchorOffset:s}=e.observer.selectionRange;if(!(n&&t.empty&&t.assoc&&n.modify))return;let r=this.lineAt(t.head,t.assoc);if(!r)return;let o=r.posAtStart;if(t.head==o||t.head==o+r.length)return;let a=this.coordsAt(t.head,-1),l=this.coordsAt(t.head,1);if(!a||!l||a.bottom>l.top)return;let c=this.domAtPos(t.head+t.assoc,t.assoc);n.collapse(c.node,c.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let h=e.observer.selectionRange;e.docView.posFromDOM(h.anchorNode,h.anchorOffset)!=t.from&&n.collapse(i,s)}posFromDOM(e,t){let n=this.tile.nearest(e);if(!n)return 2&this.tile.dom.compareDocumentPosition(e)?0:this.view.state.doc.length;let i=n.posAtStart;if(!n.isComposite())return n.isText()?e==n.dom?i+t:i+(t?n.length:0):i;{let s;if(e==n.dom)s=n.dom.childNodes[t];else{let i=0==yi(e)?0:0==t?-1:1;for(;;){let t=e.parentNode;if(t==n.dom)break;0==i&&t.firstChild!=t.lastChild&&(i=e==t.firstChild?-1:1),e=t}s=i<0?e:e.nextSibling}if(s==n.dom.firstChild)return i;for(;s&&!Is.get(s);)s=s.nextSibling;if(!s)return i+n.length;for(let e=0,t=i;;e++){let i=n.children[e];if(i.dom==s)return t;t+=i.length+i.breakAfter}}}domAtPos(e,t){let{tile:n,offset:i}=this.tile.resolveBlock(e,t);return n.isWidget()?n.domPosFor(e,t):n.domIn(i,t)}inlineDOMNearPos(e,t){let n,i,s=-1,r=!1,o=-1,a=!1;return this.tile.blockTiles((t,l)=>{if(t.isWidget()){if(32&t.flags&&l>=e)return!0;16&t.flags&&(r=!0)}else{let c=l+t.length;if(l<=e&&(n=t,s=e-l,r=c<e),c>=e&&!i&&(i=t,o=e-l,a=l>e),l>e&&i)return!0}}),n||i?(r&&i?n=null:a&&n&&(i=null),n&&t<0||!i?n.domIn(s,t):i.domIn(o,t)):this.domAtPos(e,t)}coordsAt(e,t){let{tile:n,offset:i}=this.tile.resolveBlock(e,t);return n.isWidget()?n.widget instanceof ar?null:n.coordsInWidget(i,t,!0):n.coordsIn(i,t)}lineAt(e,t){let{tile:n}=this.tile.resolveBlock(e,t);return n.isLine()?n:null}coordsForChar(e){let{tile:t,offset:n}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;return function e(t,n){if(t.isComposite())for(let i of t.children){if(i.length>=n){let t=e(i,n);if(t)return t}if((n-=i.length)<0)break}else if(t.isText()&&n<t.length){let e=Ye(t.text,n);if(e==n)return null;let i=Ni(t.dom,n,e).getClientRects();for(let e=0;e<i.length;e++){let t=i[e];if(e==i.length-1||t.top<t.bottom&&t.left<t.right)return t}}return null}(t,n)}measureVisibleLineHeights(e){let t=[],{from:n,to:i}=e,s=this.view.contentDOM.clientWidth,r=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,a=this.view.textDirection==Ii.LTR,l=0,c=(e,h,u)=>{for(let d=0;d<e.children.length&&!(h>i);d++){let i=e.children[d],f=h+i.length,p=i.dom.getBoundingClientRect(),{height:m}=p;if(u&&!d&&(l+=p.top-u.top),i instanceof $s)f>n&&c(i,h,p);else if(h>=n&&(l>0&&t.push(-l),t.push(m+l),l=0,r)){let e=i.dom.lastChild,t=e?fi(e):[];if(t.length){let e=t[t.length-1],n=a?e.right-p.left:p.right-e.left;n>o&&(o=n,this.minWidth=s,this.minWidthFrom=h,this.minWidthTo=f)}}u&&d==e.children.length-1&&(l+=u.bottom-p.bottom),h=f+i.breakAfter}};return c(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return"rtl"==getComputedStyle(t.dom).direction?Ii.RTL:Ii.LTR}measureTextSize(){let e=this.tile.blockTiles(e=>{if(e.isLine()&&e.children.length&&e.length<=20){let t,n=0;for(let i of e.children){if(!i.isText()||/[^ -~]/.test(i.text))return;let e=fi(i.dom);if(1!=e.length)return;n+=e[0].width,t=e[0].height}if(n)return{lineHeight:e.dom.getBoundingClientRect().height,charWidth:n/e.length,textHeight:t}}});if(e)return e;let t,n,i,s=document.createElement("div");return s.className="cm-line",s.style.width="99999px",s.style.position="absolute",s.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(s);let e=fi(s.firstChild)[0];t=s.getBoundingClientRect().height,n=e&&e.width?e.width/27:7,i=e&&e.height?e.height:t,s.remove()}),{lineHeight:t,charWidth:n,textHeight:i}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,i=0;;i++){let s=i==t.viewports.length?null:t.viewports[i],r=s?s.from-1:this.view.state.doc.length;if(r>n){let i=(t.lineBlockAt(r).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(ii.replace({widget:new ar(i),block:!0,inclusive:!0,isBlockGap:!0}).range(n,r))}if(!s)break;n=s.to+1}return ii.set(e)}updateDeco(){let e=1,t=this.view.state.facet(ws).map(t=>(this.dynamicDecorationMap[e++]="function"==typeof t)?t(this.view):t),n=!1,i=this.view.state.facet(Ss).map((e,t)=>{let i="function"==typeof e;return i&&(n=!0),i?e(this.view):e});for(i.length&&(this.dynamicDecorationMap[e++]=n,t.push(hn.join(i))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(xs).map(e=>"function"==typeof e?e(this.view):e)}scrollIntoView(e){var t;if(e.isSnapshot){let t=this.view.viewState.lineBlockAt(e.range.head);return this.view.scrollDOM.scrollTop=t.top-e.yMargin,void(this.view.scrollDOM.scrollLeft=e.xMargin)}for(let t of this.view.state.facet(cs))try{if(t(this.view,e.range,e))return!0}catch(e){fs(this.view.state,e,"scroll handler")}let n,{range:i}=e,s=this.coordsAt(i.head,null!==(t=i.assoc)&&void 0!==t?t:i.empty?0:i.head>i.anchor?-1:1);if(!s)return;!i.empty&&(n=this.coordsAt(i.anchor,i.anchor>i.head?-1:1))&&(s={left:Math.min(s.left,n.left),top:Math.min(s.top,n.top),right:Math.max(s.right,n.right),bottom:Math.max(s.bottom,n.bottom)});let r=Os(this.view),o={left:s.left-r.left,top:s.top-r.top,right:s.right+r.right,bottom:s.bottom+r.bottom},{offsetWidth:a,offsetHeight:l}=this.view.scrollDOM;if(function(e,t,n,i,s,r,o,a){let l=e.ownerDocument,c=l.defaultView||window;for(let h=e,u=!1;h&&!u;)if(1==h.nodeType){let e,d=h==l.body,f=1,p=1;if(d)e=ki(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(h).position)&&(u=!0),h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.assignedSlot||h.parentNode;continue}let t=h.getBoundingClientRect();({scaleX:f,scaleY:p}=wi(h,t)),e={left:t.left,right:t.left+h.clientWidth*f,top:t.top,bottom:t.top+h.clientHeight*p}}let m=0,g=0;if("nearest"==s)t.top<e.top?(g=t.top-(e.top+o),n>0&&t.bottom>e.bottom+g&&(g=t.bottom-e.bottom+o)):t.bottom>e.bottom&&(g=t.bottom-e.bottom+o,n<0&&t.top-g<e.top&&(g=t.top-(e.top+o)));else{let i=t.bottom-t.top,r=e.bottom-e.top;g=("center"==s&&i<=r?t.top+i/2-r/2:"start"==s||"center"==s&&n<0?t.top-o:t.bottom-r+o)-e.top}if("nearest"==i?t.left<e.left?(m=t.left-(e.left+r),n>0&&t.right>e.right+m&&(m=t.right-e.right+r)):t.right>e.right&&(m=t.right-e.right+r,n<0&&t.left<e.left+m&&(m=t.left-(e.left+r))):m=("center"==i?t.left+(t.right-t.left)/2-(e.right-e.left)/2:"start"==i==a?t.left-r:t.right-(e.right-e.left)+r)-e.left,m||g)if(d)c.scrollBy(m,g);else{let e=0,n=0;if(g){let e=h.scrollTop;h.scrollTop+=g/p,n=(h.scrollTop-e)*p}if(m){let t=h.scrollLeft;h.scrollLeft+=m/f,e=(h.scrollLeft-t)*f}t={left:t.left-e,top:t.top-n,right:t.right-e,bottom:t.bottom-n},e&&Math.abs(e-m)<1&&(i="nearest"),n&&Math.abs(n-g)<1&&(s="nearest")}if(d)break;(t.top<e.top||t.bottom>e.bottom||t.left<e.left||t.right>e.right)&&(t={left:Math.max(t.left,e.left),right:Math.min(t.right,e.right),top:Math.max(t.top,e.top),bottom:Math.min(t.bottom,e.bottom)}),h=h.assignedSlot||h.parentNode}else{if(11!=h.nodeType)break;h=h.host}}(this.view.scrollDOM,o,i.head<i.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,a),-a),Math.max(Math.min(e.yMargin,l),-l),this.view.textDirection==Ii.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(s.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||s.bottom<window.pageYOffset+window.visualViewport.offsetTop)){let e=this.view.docView.lineAt(i.head,1);e&&e.dom.scrollIntoView({block:"nearest"})}}lineHasWidget(e){let t=e=>e.isWidget()||e.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){ir(this.tile)}}function ir(e,t){let n=null==t?void 0:t.get(e);if(1!=n){null==n&&e.destroy();for(let n of e.children)ir(n,t)}}function sr(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let i=Ei(n.focusNode,n.focusOffset),s=Di(n.focusNode,n.focusOffset),r=i||s;if(s&&i&&s.node!=i.node){let t=Is.get(s.node);if(!t||t.isText()&&t.text!=s.node.nodeValue)r=s;else if(e.docView.lastCompositionAfterCursor){let e=Is.get(i.node);!e||e.isText()&&e.text!=i.node.nodeValue||(r=s)}}if(e.docView.lastCompositionAfterCursor=r!=i,!r)return null;let o=t-r.offset;return{from:o,to:o+r.node.nodeValue.length,node:r.node}}let rr=class{constructor(){this.changes=[]}compareRange(e,t){li(e,t,this.changes)}comparePoint(e,t){li(e,t,this.changes)}boundChange(e){li(e,e,this.changes)}};class or{constructor(){this.changes=[]}compareRange(e,t){li(e,t,this.changes)}comparePoint(){}boundChange(e){li(e,e,this.changes)}}class ar extends ti{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function lr(e,t,n){let i=e.lineBlockAt(t);if(Array.isArray(i.type)){let e;for(let s of i.type){if(s.from>t)break;if(!(s.to<t)){if(s.from<t&&s.to>t)return s;e&&(s.type!=ni.Text||e.type==s.type&&!(n<0?s.from<t:s.to>t))||(e=s)}}return e||i}return i}function cr(e,t,n,i){let s=e.state.doc.lineAt(t.head),r=e.bidiSpans(s),o=e.textDirectionAt(s.from);for(let a=t,l=null;;){let t=Yi(s,r,o,a,n),c=Zi;if(!t){if(s.number==(n?e.state.doc.lines:1))return a;c="\n",s=e.state.doc.line(s.number+(n?1:-1)),r=e.bidiSpans(s),t=e.visualLineSide(s,!n)}if(l){if(!l(c))return a}else{if(!i)return t;l=i(c)}a=t}}function hr(e,t,n){for(;;){let i=0;for(let s of e)s.between(t-1,t+1,(e,s,r)=>{if(t>e&&t<s){let r=i||n||(t-e<s-t?-1:1);t=r<0?e:s,i=r}});if(!i)return t}}function ur(e,t){let n=null;for(let i=0;i<t.ranges.length;i++){let s=t.ranges[i],r=null;if(s.empty){let t=hr(e,s.from,0);t!=s.from&&(r=ut.cursor(t,-1))}else{let t=hr(e,s.from,-1),n=hr(e,s.to,1);t==s.from&&n==s.to||(r=ut.range(s.from==s.anchor?t:n,s.from==s.head?t:n))}r&&(n||(n=t.ranges.slice()),n[i]=r)}return n?ut.create(n,t.mainIndex):t}function dr(e,t,n){let i=hr(e.state.facet(Cs).map(t=>t(e)),n.from,t.head>n.from?-1:1);return i==n.from?n:ut.cursor(i,i<n.from?1:-1)}class fr{constructor(e,t){this.pos=e,this.assoc=t}}function pr(e,t,n,i){let s,r=e.contentDOM.getBoundingClientRect(),o=r.top+e.viewState.paddingTop,{x:a,y:l}=t,c=l-o;for(;;){if(c<0)return new fr(0,1);if(c>e.viewState.docHeight)return new fr(e.state.doc.length,-1);if(s=e.elementAtHeight(c),null==i)break;if(s.type==ni.Text){if(i<0?s.to<e.viewport.from:s.from>e.viewport.to)break;let t=e.docView.coordsAt(i<0?s.from:s.to,i>0?-1:1);if(t&&(i<0?t.top<=c+o:t.bottom>=c+o))break}let t=e.viewState.heightOracle.textHeight/2;c=i>0?s.bottom+t:s.top-t}if(e.viewport.from>=s.to||e.viewport.to<=s.from){if(n)return null;if(s.type==ni.Text){let t=function(e,t,n,i,s){let r=Math.round((i-t.left)*e.defaultCharacterWidth);if(e.lineWrapping&&n.height>1.5*e.defaultLineHeight){let t=e.viewState.heightOracle.textHeight;r+=Math.floor((s-n.top-.5*(e.defaultLineHeight-t))/t)*e.viewState.heightOracle.lineLength}let o=e.state.sliceDoc(n.from,n.to);return n.from+Sn(o,r,e.state.tabSize)}(e,r,s,a,l);return new fr(t,t==s.from?1:-1)}}if(s.type!=ni.Text)return c<(s.top+s.bottom)/2?new fr(s.from,1):new fr(s.to,-1);let h=e.docView.lineAt(s.from,2);return h&&h.length==s.length||(h=e.docView.lineAt(s.from,-2)),new mr(e,a,l,e.textDirectionAt(s.from)).scanTile(h,s.from)}class mr{constructor(e,t,n,i){this.view=e,this.x=t,this.y=n,this.baseDir=i,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,t){let{line:n,spans:i}=this.bidiSpansAt(e);return i[Ui.find(i,e-n.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:n,spans:i}=this.bidiSpansAt(e);return i[Ui.find(i,e-n.from,-1,t)].dir}bidiIn(e,t){let{spans:n,line:i}=this.bidiSpansAt(e);return n.length>1||n.length&&(n[0].level!=this.baseDir||n[0].to+i.from<t)}scan(e,t){let n,i,s,r=0,o=e.length-1,a=new Set,l=this.bidiIn(e[0],e[o]),c=-1,h=1e9;e:for(;r<o;){let u=o-r,d=r+o>>1;t:if(a.has(d)){let e=r+Math.floor(Math.random()*u);for(let t=0;t<u;t++){if(!a.has(e)){d=e;break t}e++,e==o&&(e=r)}break e}a.add(d);let f=t(d);if(f)for(let t=0;t<f.length;t++){let a=f[t],u=0;if(!(0==a.width&&f.length>1)){if(a.bottom<this.y)(!n||n.bottom<a.bottom)&&(n=a),u=1;else if(a.top>this.y)(!i||i.top>a.top)&&(i=a),u=-1;else{let e=a.left>this.x?this.x-a.left:a.right<this.x?this.x-a.right:0,t=Math.abs(e);t<h&&(c=d,h=t,s=a),e&&(u=e<0==(this.baseDir==Ii.LTR)?-1:1)}-1!=u||l&&!this.baseDirAt(e[d],1)?1!=u||l&&!this.baseDirAt(e[d+1],-1)||(r=d+1):o=d}}}if(!s){let s=n&&(!i||this.y-n.bottom<i.top-this.y)?n:i;return this.y=(s.top+s.bottom)/2,this.scan(e,t)}let u=(l?this.dirAt(e[c],1):this.baseDir)==Ii.LTR;return{i:c,after:this.x>(s.left+s.right)/2==u}}scanText(e,t){let n=[];for(let i=0;i<e.length;i=Ye(e.text,i))n.push(t+i);n.push(t+e.length);let i=this.scan(n,i=>{let s=n[i]-t,r=n[i+1]-t;return Ni(e.dom,s,r).getClientRects()});return i.after?new fr(n[i.i+1],-1):new fr(n[i.i],1)}scanTile(e,t){if(!e.length)return new fr(t,1);if(1==e.children.length){let n=e.children[0];if(n.isText())return this.scanText(n,t);if(n.isComposite())return this.scanTile(n,t)}let n=[t];for(let i=0,s=t;i<e.children.length;i++)n.push(s+=e.children[i].length);let i=this.scan(n,t=>{let n=e.children[t];return 48&n.flags?null:(1==n.dom.nodeType?n.dom:Ni(n.dom,0,n.length)).getClientRects()}),s=e.children[i.i],r=n[i.i];return s.isText()?this.scanText(s,r):s.isComposite()?this.scanTile(s,r):i.after?new fr(n[i.i+1],-1):new fr(r,1)}}const gr="";class br{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(nn.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=gr}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let i=e;;){this.findPointBefore(n,i);let e=this.text.length;this.readNode(i);let s=Is.get(i),r=i.nextSibling;if(r==t){(null==s?void 0:s.breakAfter)&&!r&&n!=this.view.contentDOM&&this.lineBreak();break}let o=Is.get(r);(s&&o?s.breakAfter:(s?s.breakAfter:gi(i))||gi(r)&&("BR"!=i.nodeName||(null==s?void 0:s.isWidget()))&&this.text.length>e)&&!vr(r,t)&&this.lineBreak(),i=r}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,i=this.lineSeparator?null:/\r\n?|\n/g;;){let s,r=-1,o=1;if(this.lineSeparator?(r=t.indexOf(this.lineSeparator,n),o=this.lineSeparator.length):(s=i.exec(t))&&(r=s.index,o=s[0].length),this.append(t.slice(n,r<0?t.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=o-1);n=r+o}}readNode(e){let t=Is.get(e),n=t&&t.overrideDOMText;if(null!=n){this.findPointInside(e,n.length);for(let e=n.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else 3==e.nodeType?this.readTextNode(e):"BR"==e.nodeName?e.nextSibling&&this.lineBreak():1==e.nodeType&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(3==e.nodeType?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(yr(e,n.node,n.offset)?t:0))}}function yr(e,t,n){for(;;){if(!t||n<yi(t))return!1;if(t==e)return!0;n=mi(t)+1,t=t.parentNode}}function vr(e,t){let n;for(;e!=t&&e;e=e.nextSibling){let t=Is.get(e);if(!(null==t?void 0:t.isWidget()))return!1;t&&(n||(n=[])).push(t)}if(n)for(let e of n){let t=e.overrideDOMText;if(null==t?void 0:t.length)return!1}return!0}class kr{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class wr{constructor(e,t,n,i){this.typeOver=i,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:s,impreciseAnchor:r}=e.docView,o=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=xr(e.docView.tile,t,n,0))){let t=s||r?[]:function(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:i,focusNode:s,focusOffset:r}=e.observer.selectionRange;n&&(t.push(new kr(n,i)),s==n&&r==i||t.push(new kr(s,r)));return t}(e),n=new br(t,e);n.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=n.text,this.newSel=function(e,t){if(0==e.length)return null;let n=e[0].pos,i=2==e.length?e[1].pos:n;return n>-1&&i>-1?ut.single(n+t,i+t):null}(t,this.bounds.from)}else{let t=e.observer.selectionRange,n=s&&s.node==t.focusNode&&s.offset==t.focusOffset||!ui(e.contentDOM,t.focusNode)?o.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),i=r&&r.node==t.anchorNode&&r.offset==t.anchorOffset||!ui(e.contentDOM,t.anchorNode)?o.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),a=e.viewport;if((Zn.ios||Zn.chrome)&&o.main.empty&&n!=i&&(a.from>0||a.to<e.state.doc.length)){let t=Math.min(n,i),s=Math.max(n,i),r=a.from-t,o=a.to-s;0!=r&&1!=r&&0!=t||0!=o&&-1!=o&&s!=e.state.doc.length||(n=0,i=e.state.doc.length)}if(e.inputState.composing>-1&&o.ranges.length>1)this.newSel=o.replaceRange(ut.range(i,n));else if(e.lineWrapping&&i==n&&(!o.main.empty||o.main.head!=n)&&e.inputState.lastTouchTime>Date.now()-100){let t=e.coordsAtPos(n,-1),i=0;t&&(i=e.inputState.lastTouchY<=t.bottom?-1:1),this.newSel=ut.create([ut.cursor(n,i)])}else this.newSel=ut.single(i,n)}}}function xr(e,t,n,i){if(e.isComposite()){let s=-1,r=-1,o=-1,a=-1;for(let l=0,c=i,h=i;l<e.children.length;l++){let i=e.children[l],u=c+i.length;if(c<t&&u>n)return xr(i,t,n,c);if(u>=t&&-1==s&&(s=l,r=c),c>n&&i.dom.parentNode==e.dom){o=l,a=h;break}h=u,c=u+i.breakAfter}return{from:r,to:a<0?i+e.length:a,startDOM:(s?e.children[s-1].dom.nextSibling:null)||e.dom.firstChild,endDOM:o<e.children.length&&o>=0?e.children[o].dom:null}}return e.isText()?{from:i,to:i+e.length,startDOM:e.dom,endDOM:e.dom.nextSibling}:null}function Sr(e,t){let n,{newSel:i}=t,{state:s}=e,r=s.selection.main,o=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:e,to:i}=t.bounds,a=r.from,l=null;(8===o||Zn.android&&t.text.length<i-e)&&(a=r.to,l="end");let c,h,u=s.doc.sliceString(e,i,gr);!r.empty&&r.from>=e&&r.to<=i&&(t.typeOver||u!=t.text)&&u.slice(0,r.from-e)==t.text.slice(0,r.from-e)&&u.slice(r.to-e)==t.text.slice(c=t.text.length-(u.length-(r.to-e)))?n={from:r.from,to:r.to,insert:Fe.of(t.text.slice(r.from-e,c).split(gr))}:(h=Ar(u,t.text,a-e,l))&&(Zn.chrome&&13==o&&h.toB==h.from+2&&t.text.slice(h.from,h.toB)==gr+gr&&h.toB--,n={from:e+h.from,to:e+h.toA,insert:Fe.of(t.text.slice(h.from,h.toB).split(gr))})}else i&&(!e.hasFocus&&s.facet(ps)||Tr(i,r))&&(i=null);if(!n&&!i)return!1;if((Zn.mac||Zn.android)&&n&&n.from==n.to&&n.from==r.head-1&&/^\. ?$/.test(n.insert.toString())&&"off"==e.contentDOM.getAttribute("autocorrect")?(i&&2==n.insert.length&&(i=ut.single(i.main.anchor-1,i.main.head-1)),n={from:n.from,to:n.to,insert:Fe.of([n.insert.toString().replace("."," ")])}):s.doc.lineAt(r.from).to<r.to&&e.docView.lineHasWidget(r.to)&&e.inputState.insertingTextAt>Date.now()-50?n={from:r.from,to:r.to,insert:s.toText(e.inputState.insertingText)}:Zn.chrome&&n&&n.from==n.to&&n.from==r.head&&"\n "==n.insert.toString()&&e.lineWrapping&&(i&&(i=ut.single(i.main.anchor-1,i.main.head-1)),n={from:r.from,to:r.to,insert:Fe.of([" "])}),n)return Cr(e,n,i,o);if(i&&!Tr(i,r)){let t=!1,n="select";return e.inputState.lastSelectionTime>Date.now()-50&&("select"==e.inputState.lastSelectionOrigin&&(t=!0),n=e.inputState.lastSelectionOrigin,"select.pointer"==n&&(i=ur(s.facet(Cs).map(t=>t(e)),i))),e.dispatch({selection:i,scrollIntoView:t,userEvent:n}),!0}return!1}function Cr(e,t,n,i=-1){if(Zn.ios&&e.inputState.flushIOSKey(t))return!0;let s=e.state.selection.main;if(Zn.android&&(t.to==s.to&&(t.from==s.from||t.from==s.from-1&&" "==e.state.sliceDoc(t.from,s.from))&&1==t.insert.length&&2==t.insert.lines&&Oi(e.contentDOM,"Enter",13)||(t.from==s.from-1&&t.to==s.to&&0==t.insert.length||8==i&&t.insert.length<t.to-t.from&&t.to>s.head)&&Oi(e.contentDOM,"Backspace",8)||t.from==s.from&&t.to==s.to+1&&0==t.insert.length&&Oi(e.contentDOM,"Delete",46)))return!0;let r,o=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let a=()=>r||(r=function(e,t,n){let i,s=e.state,r=s.selection.main,o=-1;if(t.from==t.to&&t.from<r.from||t.from>r.to){let n=t.from<r.from?-1:1,i=n<0?r.from:r.to,a=hr(s.facet(Cs).map(t=>t(e)),i,n);t.from==a&&(o=a)}if(o>-1)i={changes:t,selection:ut.cursor(t.from+t.insert.length,-1)};else if(t.from>=r.from&&t.to<=r.to&&t.to-t.from>=(r.to-r.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let n=r.from<t.from?s.sliceDoc(r.from,t.from):"",o=r.to>t.to?s.sliceDoc(t.to,r.to):"";i=s.replaceSelection(e.state.toText(n+t.insert.sliceString(0,void 0,e.state.lineBreak)+o))}else{let o=s.changes(t),a=n&&n.main.to<=o.newLength?n.main:void 0;if(s.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=r.to+10&&t.to>=r.to-10){let l,c=e.state.sliceDoc(t.from,t.to),h=n&&sr(e,n.main.head);if(h){let e=t.insert.length-(t.to-t.from);l={from:h.from,to:h.to-e}}else l=e.state.doc.lineAt(r.head);let u=r.to-t.to;i=s.changeByRange(n=>{if(n.from==r.from&&n.to==r.to)return{changes:o,range:a||n.map(o)};let i=n.to-u,h=i-c.length;if(e.state.sliceDoc(h,i)!=c||i>=l.from&&h<=l.to)return{range:n};let d=s.changes({from:h,to:i,insert:t.insert}),f=n.to-r.to;return{changes:d,range:a?ut.range(Math.max(0,a.anchor+f),Math.max(0,a.head+f)):n.map(d)}})}else i={changes:o,selection:a&&s.selection.replaceRange(a)}}let a="input.type";(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,a+=".compose",e.inputState.compositionFirstChange&&(a+=".start",e.inputState.compositionFirstChange=!1));return s.update(i,{userEvent:a,scrollIntoView:!0})}(e,t,n));return e.state.facet(is).some(n=>n(e,t.from,t.to,o,a))||e.dispatch(a()),!0}function Ar(e,t,n,i){let s=Math.min(e.length,t.length),r=0;for(;r<s&&e.charCodeAt(r)==t.charCodeAt(r);)r++;if(r==s&&e.length==t.length)return null;let o=e.length,a=t.length;for(;o>0&&a>0&&e.charCodeAt(o-1)==t.charCodeAt(a-1);)o--,a--;if("end"==i){n-=o+Math.max(0,r-Math.min(o,a))-r}if(o<r&&e.length<t.length){r-=n<=r&&n>=o?r-n:0,a=r+(a-o),o=r}else if(a<r){r-=n<=r&&n>=a?r-n:0,o=r+(o-a),a=r}return{from:r,toA:o,toB:a}}function Tr(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}class Nr{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Zn.safari&&e.contentDOM.addEventListener("input",()=>null),Zn.gecko&&function(e){Gr.has(e)||(Gr.add(e),e.addEventListener("copy",()=>{}),e.addEventListener("cut",()=>{}))}(e.contentDOM.ownerDocument)}handleEvent(e){(function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n,i=t.target;i!=e.contentDOM;i=i.parentNode)if(!i||11==i.nodeType||(n=Is.get(i))&&n.isWidget()&&!n.isHidden&&n.widget.ignoreEvent(t))return!1;return!0})(this.view,e)&&!this.ignoreDuringComposition(e)&&("keydown"==e.type&&this.keydown(e)||(0!=this.view.updateState?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e)))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let e of n.observers)e(this.view,t);for(let e of n.handlers){if(t.defaultPrevented)break;if(e(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=Mr(e),n=this.handlers,i=this.view.contentDOM;for(let e in t)if("scroll"!=e){let s=!t[e].handlers.length,r=n[e];r&&s!=!r.handlers.length&&(i.removeEventListener(e,this.handleEvent),r=null),r||i.addEventListener(e,this.handleEvent,{passive:s})}for(let e in n)"scroll"==e||t[e]||i.removeEventListener(e,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),9==e.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&27!=e.keyCode&&_r.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Zn.android&&Zn.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return!Zn.ios||e.synthetic||e.altKey||e.metaKey||e.shiftKey||!((t=Er.find(t=>t.keyCode==e.keyCode))&&!e.ctrlKey||Dr.indexOf(e.key)>-1&&e.ctrlKey)?(229!=e.keyCode&&this.view.observer.forceFlush(),!1):(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0)}flushIOSKey(e){let t=this.pendingIOSKey;return!!t&&(!("Enter"==t.key&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString()))&&(this.pendingIOSKey=void 0,Oi(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0)))}ignoreDuringComposition(e){return!(!/^key/.test(e.type)||e.synthetic)&&(this.composing>0||!!(Zn.safari&&!Zn.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function Or(e,t){return(n,i)=>{try{return t.call(e,i,n)}catch(e){fs(n.state,e)}}}function Mr(e){let t=Object.create(null);function n(e){return t[e]||(t[e]={observers:[],handlers:[]})}for(let t of e){let e=t.spec,i=e&&e.plugin.domEventHandlers,s=e&&e.plugin.domEventObservers;if(i)for(let e in i){let s=i[e];s&&n(e).handlers.push(Or(t.value,s))}if(s)for(let e in s){let i=s[e];i&&n(e).observers.push(Or(t.value,i))}}for(let e in Pr)n(e).handlers.push(Pr[e]);for(let e in Rr)n(e).observers.push(Rr[e]);return t}const Er=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Dr="dthko",_r=[16,17,18,20,91,92,224,225];function Ir(e){return.7*Math.max(0,e)+8}class Br{constructor(e,t,n,i){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=i,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=xi(e.contentDOM),this.atoms=e.state.facet(Cs).map(t=>t(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(nn.allowMultipleSelections)&&function(e,t){let n=e.state.facet(Qi);return n.length?n[0](t):Zn.mac?t.metaKey:t.ctrlKey}(e,t),this.dragging=!(!function(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let i=hi(e.root);if(!i||0==i.rangeCount)return!0;let s=i.getRangeAt(0).getClientRects();for(let e=0;e<s.length;e++){let n=s[e];if(n.left<=t.clientX&&n.right>=t.clientX&&n.top<=t.clientY&&n.bottom>=t.clientY)return!0}return!1}(e,t)||1!=Hr(t))&&null}start(e){!1===this.dragging&&this.select(e)}move(e){if(0==e.buttons)return this.destroy();if(this.dragging||null==this.dragging&&function(e,t){return Math.max(Math.abs(e.clientX-t.clientX),Math.abs(e.clientY-t.clientY))}(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,n=0,i=0,s=0,r=this.view.win.innerWidth,o=this.view.win.innerHeight;this.scrollParents.x&&({left:i,right:r}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:o}=this.scrollParents.y.getBoundingClientRect());let a=Os(this.view);e.clientX-a.left<=i+6?t=-Ir(i-e.clientX):e.clientX+a.right>=r-6&&(t=Ir(e.clientX-r)),e.clientY-a.top<=s+6?n=-Ir(s-e.clientY):e.clientY+a.bottom>=o-6&&(n=Ir(e.clientY-o)),this.setScrollSpeed(t,n)}up(e){null==this.dragging&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),!1===this.dragging&&this.select(this.lastEvent)}select(e){let{view:t}=this,n=ur(this.atoms,this.style.get(e,this.extend,this.multiple));!this.mustSelect&&n.eq(t.state.selection,!1===this.dragging)||this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(e=>e.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}const Pr=Object.create(null),Rr=Object.create(null),$r=Zn.ie&&Zn.ie_version<15||Zn.ios&&Zn.webkit_version<604;function Lr(e,t,n){for(let i of e.facet(t))n=i(n,e);return n}function zr(e,t){t=Lr(e.state,rs,t);let n,{state:i}=e,s=1,r=i.toText(t),o=r.lines==i.selection.ranges.length,a=null!=Kr&&i.selection.ranges.every(e=>e.empty)&&Kr==r.toString();if(a){let e=-1;n=i.changeByRange(n=>{let a=i.doc.lineAt(n.from);if(a.from==e)return{range:n};e=a.from;let l=i.toText((o?r.line(s++).text:t)+i.lineBreak);return{changes:{from:a.from,insert:l},range:ut.cursor(n.from+l.length)}})}else n=o?i.changeByRange(e=>{let t=r.line(s++);return{changes:{from:e.from,to:e.to,insert:t.text},range:ut.cursor(e.from+t.length)}}):i.replaceSelection(r);e.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}function Fr(e,t,n,i){if(1==i)return ut.cursor(t,n);if(2==i)return function(e,t,n=1){let i=e.charCategorizer(t),s=e.doc.lineAt(t),r=t-s.from;if(0==s.length)return ut.cursor(t);0==r?n=1:r==s.length&&(n=-1);let o=r,a=r;n<0?o=Ye(s.text,r,!1):a=Ye(s.text,r);let l=i(s.text.slice(o,a));for(;o>0;){let e=Ye(s.text,o,!1);if(i(s.text.slice(e,o))!=l)break;o=e}for(;a<s.length;){let e=Ye(s.text,a);if(i(s.text.slice(a,e))!=l)break;a=e}return ut.range(o+s.from,a+s.from)}(e.state,t,n);{let i=e.docView.lineAt(t,n),s=e.state.doc.lineAt(i?i.posAtEnd:t),r=i?i.posAtStart:s.from,o=i?i.posAtEnd:s.to;return o<e.state.doc.length&&o==s.to&&o++,ut.range(r,o)}}Rr.scroll=e=>{e.inputState.lastScrollTop=e.scrollDOM.scrollTop,e.inputState.lastScrollLeft=e.scrollDOM.scrollLeft},Rr.wheel=Rr.mousewheel=e=>{e.inputState.lastWheelEvent=Date.now()},Pr.keydown=(e,t)=>(e.inputState.setSelectionOrigin("select"),27==t.keyCode&&0!=e.inputState.tabFocusMode&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),Rr.touchstart=(e,t)=>{let n=e.inputState,i=t.targetTouches[0];n.lastTouchTime=Date.now(),i&&(n.lastTouchX=i.clientX,n.lastTouchY=i.clientY),n.setSelectionOrigin("select.pointer")},Rr.touchmove=e=>{e.inputState.setSelectionOrigin("select.pointer")},Pr.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let i of e.state.facet(es))if(n=i(e,t),n)break;if(n||0!=t.button||(n=function(e,t){let n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),i=Hr(t),s=e.state.selection;return{update(e){e.docChanged&&(n.pos=e.changes.mapPos(n.pos),s=s.map(e.changes))},get(t,r,o){let a,l=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),c=Fr(e,l.pos,l.assoc,i);if(n.pos!=l.pos&&!r){let t=Fr(e,n.pos,n.assoc,i),s=Math.min(t.from,c.from),r=Math.max(t.to,c.to);c=s<c.from?ut.range(s,r,c.assoc):ut.range(r,s,c.assoc)}return r?s.replaceRange(s.main.extend(c.from,c.to,c.assoc)):o&&1==i&&s.ranges.length>1&&(a=function(e,t){for(let n=0;n<e.ranges.length;n++){let{from:i,to:s}=e.ranges[n];if(i<=t&&s>=t)return ut.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-(e.mainIndex>n?1:0))}return null}(s,l.pos))?a:o?s.addRange(c):ut.create([c])}}}(e,t)),n){let i=!e.hasFocus;e.inputState.startMouseSelection(new Br(e,t,n,i)),i&&e.observer.ignore(()=>{Ti(e.contentDOM);let t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()});let s=e.inputState.mouseSelection;if(s)return s.start(t),!1===s.dragging}else e.inputState.setSelectionOrigin("select.pointer");return!1};const jr=Zn.ie&&Zn.ie_version<=11;let Wr=null,Ur=0,Vr=0;function Hr(e){if(!jr)return e.detail;let t=Wr,n=Vr;return Wr=e,Vr=Date.now(),Ur=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(Ur+1)%3:1}function qr(e,t,n,i){if(!(n=Lr(e.state,rs,n)))return;let s=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:r}=e.inputState,o=i&&r&&function(e,t){let n=e.state.facet(Xi);return n.length?n[0](t):Zn.mac?!t.altKey:!t.ctrlKey}(e,t)?{from:r.from,to:r.to}:null,a={from:s,insert:n},l=e.state.changes(o?[o,a]:a);e.focus(),e.dispatch({changes:l,selection:{anchor:l.mapPos(s,-1),head:l.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"}),e.inputState.draggedContent=null}Pr.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let i=e.docView.tile.nearest(t.target);if(i&&i.isWidget()){let e=i.posAtStart,t=e+i.length;(e>=n.to||t<=n.from)&&(n=ut.range(e,t))}}let{inputState:i}=e;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData("Text",Lr(e.state,os,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed="copyMove"),!1},Pr.dragend=e=>(e.inputState.draggedContent=null,!1),Pr.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let i=Array(n.length),s=0,r=()=>{++s==n.length&&qr(e,t,i.filter(e=>null!=e).join(e.state.lineBreak),!1)};for(let e=0;e<n.length;e++){let t=new FileReader;t.onerror=r,t.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(i[e]=t.result),r()},t.readAsText(n[e])}return!0}{let n=t.dataTransfer.getData("Text");if(n)return qr(e,t,n,!0),!0}return!1},Pr.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=$r?null:t.clipboardData;return n?(zr(e,n.getData("text/plain")||n.getData("text/uri-list")),!0):(function(e){let t=e.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{e.focus(),n.remove(),zr(e,n.value)},50)}(e),!1)};let Kr=null;Pr.copy=Pr.cut=(e,t)=>{if(!di(e.contentDOM,e.observer.selectionRange))return!1;let{text:n,ranges:i,linewise:s}=function(e){let t=[],n=[],i=!1;for(let i of e.selection.ranges)i.empty||(t.push(e.sliceDoc(i.from,i.to)),n.push(i));if(!t.length){let s=-1;for(let{from:i}of e.selection.ranges){let r=e.doc.lineAt(i);r.number>s&&(t.push(r.text),n.push({from:r.from,to:Math.min(e.doc.length,r.to+1)})),s=r.number}i=!0}return{text:Lr(e,os,t.join(e.lineBreak)),ranges:n,linewise:i}}(e.state);if(!n&&!s)return!1;Kr=s?n:null,"cut"!=t.type||e.state.readOnly||e.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let r=$r?null:t.clipboardData;return r?(r.clearData(),r.setData("text/plain",n),!0):(function(e,t){let n=e.dom.parentNode;if(!n)return;let i=n.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=t,i.focus(),i.selectionEnd=t.length,i.selectionStart=0,setTimeout(()=>{i.remove(),e.focus()},50)}(e,n),!1)};const Jr=jt.define();function Zr(e,t){let n=[];for(let i of e.facet(ss)){let s=i(e,t);s&&n.push(s)}return n.length?e.update({effects:n,annotations:Jr.of(!0)}):null}function Yr(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=Zr(e.state,t);n?e.dispatch(n):e.update([])}},10)}Rr.focus=e=>{e.inputState.lastFocusTime=Date.now(),e.scrollDOM.scrollTop||!e.inputState.lastScrollTop&&!e.inputState.lastScrollLeft||(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),Yr(e)},Rr.blur=e=>{e.observer.clearSelectionRange(),Yr(e)},Rr.compositionstart=Rr.compositionupdate=e=>{e.observer.editContext||(null==e.inputState.compositionFirstChange&&(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))},Rr.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,Zn.chrome&&Zn.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))},Rr.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},Pr.beforeinput=(e,t)=>{var n,i;if("insertText"!=t.inputType&&"insertCompositionText"!=t.inputType||(e.inputState.insertingText=t.data,e.inputState.insertingTextAt=Date.now()),"insertReplacementText"==t.inputType&&e.observer.editContext){let i=null===(n=t.dataTransfer)||void 0===n?void 0:n.getData("text/plain"),s=t.getTargetRanges();if(i&&s.length){let t=s[0],n=e.posAtDOM(t.startContainer,t.startOffset),r=e.posAtDOM(t.endContainer,t.endOffset);return Cr(e,{from:n,to:r,insert:e.state.toText(i)},null),!0}}let s;if(Zn.chrome&&Zn.android&&(s=Er.find(e=>e.inputType==t.inputType))&&(e.observer.delayAndroidKey(s.key,s.keyCode),"Backspace"==s.key||"Delete"==s.key)){let t=(null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0;setTimeout(()=>{var n;((null===(n=window.visualViewport)||void 0===n?void 0:n.height)||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return Zn.ios&&"deleteContentForward"==t.inputType&&e.observer.flushSoon(),Zn.safari&&"insertText"==t.inputType&&e.inputState.composing>=0&&setTimeout(()=>Rr.compositionend(e,t),20),!1};const Gr=new Set;const Qr=["pre-wrap","normal","pre-line","break-spaces"];let Xr=!1;function eo(){Xr=!1}class to{constructor(e){this.lineWrapping=e,this.doc=Fe.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Qr.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let i=e[n];i<0?n++:this.heightSamples[Math.floor(10*i)]||(t=!0,this.heightSamples[Math.floor(10*i)]=!0)}return t}refresh(e,t,n,i,s,r){let o=Qr.indexOf(e)>-1,a=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=o||Math.abs(n-this.charWidth)>.1;if(this.lineWrapping=o,this.lineHeight=t,this.charWidth=n,this.textHeight=i,this.lineLength=s,a){this.heightSamples={};for(let e=0;e<r.length;e++){let t=r[e];t<0?e++:this.heightSamples[Math.floor(10*t)]=!0}}return a}}class no{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class io{constructor(e,t,n,i,s){this.from=e,this.length=t,this.top=n,this.height=i,this._content=s}get type(){return"number"==typeof this._content?ni.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 oi?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new io(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var so=function(e){return e[e.ByPos=0]="ByPos",e[e.ByHeight=1]="ByHeight",e[e.ByPosNoHeight=2]="ByPosNoHeight",e}(so||(so={}));const ro=.001;class oo{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(2&this.flags)>0}set outdated(e){this.flags=(e?2:0)|-3&this.flags}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>ro&&(Xr=!0),this.height=e)}replace(e,t,n){return oo.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,i){let s=this,r=n.doc;for(let o=i.length-1;o>=0;o--){let{fromA:a,toA:l,fromB:c,toB:h}=i[o],u=s.lineAt(a,so.ByPosNoHeight,n.setDoc(t),0,0),d=u.to>=l?u:s.lineAt(l,so.ByPosNoHeight,n,0,0);for(h+=d.to-l,l=d.to;o>0&&u.from<=i[o-1].toA;)a=i[o-1].fromA,c=i[o-1].fromB,o--,a<u.from&&(u=s.lineAt(a,so.ByPosNoHeight,n,0,0));c+=u.from-a,a=u.from;let f=mo.build(n.setDoc(r),e,c,h);s=ao(s,s.replace(a,l,f))}return s.updateHeight(n,0)}static empty(){return new ho(0,0,0)}static of(e){if(1==e.length)return e[0];let t=0,n=e.length,i=0,s=0;for(;;)if(t==n)if(i>2*s){let s=e[t-1];s.break?e.splice(--t,1,s.left,null,s.right):e.splice(--t,1,s.left,s.right),n+=1+s.break,i-=s.size}else{if(!(s>2*i))break;{let t=e[n];t.break?e.splice(n,1,t.left,null,t.right):e.splice(n,1,t.left,t.right),n+=2+t.break,s-=t.size}}else if(i<s){let n=e[t++];n&&(i+=n.size)}else{let t=e[--n];t&&(s+=t.size)}let r=0;return null==e[t-1]?(r=1,t--):null==e[t]&&(r=1,n++),new fo(oo.of(e.slice(0,t)),r,oo.of(e.slice(n)))}}function ao(e,t){return e==t?e:(e.constructor!=t.constructor&&(Xr=!0),t)}oo.prototype.size=1;const lo=ii.replace({});class co extends oo{constructor(e,t,n){super(e,t),this.deco=n,this.spaceAbove=0}mainBlock(e,t){return new io(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,n,i){return this.spaceAbove&&e<n+this.spaceAbove?new io(i,0,n,this.spaceAbove,lo):this.mainBlock(n,i)}lineAt(e,t,n,i,s){let r=this.mainBlock(i,s);return this.spaceAbove?this.blockAt(0,n,i,s).join(r):r}forEachLine(e,t,n,i,s,r){e<=s+this.length&&t>=s&&r(this.lineAt(0,so.ByPos,n,i,s))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,n=!1,i){return i&&i.from<=t&&i.more&&this.setMeasuredHeight(i),this.outdated=!1,this}toString(){return`block(${this.length})`}}class ho extends co{constructor(e,t,n){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=n}mainBlock(e,t){return new io(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,n){let i=n[0];return 1==n.length&&(i instanceof ho||i instanceof uo&&4&i.flags)&&Math.abs(this.length-i.length)<10?(i instanceof uo?i=new ho(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):oo.of(n)}updateHeight(e,t=0,n=!1,i){return i&&i.from<=t&&i.more?this.setMeasuredHeight(i):(n||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class uo extends oo{constructor(e){super(e,0)}heightMetrics(e,t){let n,i=e.doc.lineAt(t).number,s=e.doc.lineAt(t+this.length).number,r=s-i+1,o=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*r);n=t/r,this.length>r+1&&(o=(this.height-t)/(this.length-r-1))}else n=this.height/r;return{firstLine:i,lastLine:s,perLine:n,perChar:o}}blockAt(e,t,n,i){let{firstLine:s,lastLine:r,perLine:o,perChar:a}=this.heightMetrics(t,i);if(t.lineWrapping){let s=i+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),r=t.doc.lineAt(s),l=o+r.length*a,c=Math.max(n,e-l/2);return new io(r.from,r.length,c,l,0)}{let i=Math.max(0,Math.min(r-s,Math.floor((e-n)/o))),{from:a,length:l}=t.doc.line(s+i);return new io(a,l,n+o*i,o,0)}}lineAt(e,t,n,i,s){if(t==so.ByHeight)return this.blockAt(e,n,i,s);if(t==so.ByPosNoHeight){let{from:t,to:i}=n.doc.lineAt(e);return new io(t,i-t,0,0,0)}let{firstLine:r,perLine:o,perChar:a}=this.heightMetrics(n,s),l=n.doc.lineAt(e),c=o+l.length*a,h=l.number-r,u=i+o*h+a*(l.from-s-h);return new io(l.from,l.length,Math.max(i,Math.min(u,i+this.height-c)),c,0)}forEachLine(e,t,n,i,s,r){e=Math.max(e,s),t=Math.min(t,s+this.length);let{firstLine:o,perLine:a,perChar:l}=this.heightMetrics(n,s);for(let c=e,h=i;c<=t;){let t=n.doc.lineAt(c);if(c==e){let n=t.number-o;h+=a*n+l*(e-s-n)}let i=a+l*t.length;r(new io(t.from,t.length,h,i,0)),h+=i,c=t.to+1}}replace(e,t,n){let i=this.length-t;if(i>0){let e=n[n.length-1];e instanceof uo?n[n.length-1]=new uo(e.length+i):n.push(null,new uo(i-1))}if(e>0){let t=n[0];t instanceof uo?n[0]=new uo(e+t.length):n.unshift(new uo(e-1),null)}return oo.of(n)}decomposeLeft(e,t){t.push(new uo(e-1),null)}decomposeRight(e,t){t.push(null,new uo(this.length-e-1))}updateHeight(e,t=0,n=!1,i){let s=t+this.length;if(i&&i.from<=t+this.length&&i.more){let n=[],r=Math.max(t,i.from),o=-1;for(i.from>t&&n.push(new uo(i.from-t-1).updateHeight(e,t));r<=s&&i.more;){let t=e.doc.lineAt(r).length;n.length&&n.push(null);let s=i.heights[i.index++],a=0;s<0&&(a=-s,s=i.heights[i.index++]),-1==o?o=s:Math.abs(s-o)>=ro&&(o=-2);let l=new ho(t,s,a);l.outdated=!1,n.push(l),r+=t+1}r<=s&&n.push(null,new uo(s-r).updateHeight(e,r));let a=oo.of(n);return(o<0||Math.abs(a.height-this.height)>=ro||Math.abs(o-this.heightMetrics(e,t).perLine)>=ro)&&(Xr=!0),ao(this,a)}return(n||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class fo extends oo{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return 1&this.flags}blockAt(e,t,n,i){let s=n+this.left.height;return e<s?this.left.blockAt(e,t,n,i):this.right.blockAt(e,t,s,i+this.left.length+this.break)}lineAt(e,t,n,i,s){let r=i+this.left.height,o=s+this.left.length+this.break,a=t==so.ByHeight?e<r:e<o,l=a?this.left.lineAt(e,t,n,i,s):this.right.lineAt(e,t,n,r,o);if(this.break||(a?l.to<o:l.from>o))return l;let c=t==so.ByPosNoHeight?so.ByPosNoHeight:so.ByPos;return a?l.join(this.right.lineAt(o,c,n,r,o)):this.left.lineAt(o,c,n,i,s).join(l)}forEachLine(e,t,n,i,s,r){let o=i+this.left.height,a=s+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,n,i,s,r),t>=a&&this.right.forEachLine(e,t,n,o,a,r);else{let l=this.lineAt(a,so.ByPos,n,i,s);e<l.from&&this.left.forEachLine(e,l.from-1,n,i,s,r),l.to>=e&&l.from<=t&&r(l),t>l.to&&this.right.forEachLine(l.to+1,t,n,o,a,r)}}replace(e,t,n){let i=this.left.length+this.break;if(t<i)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-i,t-i,n));let s=[];e>0&&this.decomposeLeft(e,s);let r=s.length;for(let e of n)s.push(e);if(e>0&&po(s,r-1),t<this.length){let e=s.length;this.decomposeRight(t,s),po(s,e)}return oo.of(s)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,i=n+this.break;if(e>=i)return this.right.decomposeRight(e-i,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<i&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?oo.of(this.break?[e,null,t]:[e,t]):(this.left=ao(this.left,e),this.right=ao(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,i){let{left:s,right:r}=this,o=t+s.length+this.break,a=null;return i&&i.from<=t+s.length&&i.more?a=s=s.updateHeight(e,t,n,i):s.updateHeight(e,t,n),i&&i.from<=o+r.length&&i.more?a=r=r.updateHeight(e,o,n,i):r.updateHeight(e,o,n),a?this.balanced(s,r):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function po(e,t){let n,i;null==e[t]&&(n=e[t-1])instanceof uo&&(i=e[t+1])instanceof uo&&e.splice(t-1,3,new uo(n.length+1+i.length))}class mo{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let e=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof ho?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new ho(e-this.pos,-1,0)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let i=n.widget?n.widget.estimatedHeight:0,s=n.widget?n.widget.lineBreaks:0;i<0&&(i=this.oracle.lineHeight);let r=t-e;n.block?this.addBlock(new co(r,i,n)):(r||s||i>=5)&&this.addLineDeco(i,s,r)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new ho(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let n=new uo(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof ho)return e;let t=new ho(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let i=this.ensureLine();i.length+=n,i.collapsed+=n,i.widgetHeight=Math.max(i.widgetHeight,e),i.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||t instanceof ho||this.isCovered?(this.writtenTo<this.pos||null==t)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new ho(0,-1,0));let n=e;for(let e of this.nodes)e instanceof ho&&e.updateHeight(this.oracle,n),n+=e?e.length:1;return this.nodes}static build(e,t,n,i){let s=new mo(n,e);return hn.spans(t,n,i,s,0),s.finish(n)}}class go{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,i){(e<t||n&&n.heightRelevant||i&&i.heightRelevant)&&li(e,t,this.changes,5)}}function bo(e,t){let n=e.getBoundingClientRect(),i=e.ownerDocument,s=i.defaultView||window,r=Math.max(0,n.left),o=Math.min(s.innerWidth,n.right),a=Math.max(0,n.top),l=Math.min(s.innerHeight,n.bottom);for(let t=e.parentNode;t&&t!=i.body;)if(1==t.nodeType){let n=t,i=window.getComputedStyle(n);if((n.scrollHeight>n.clientHeight||n.scrollWidth>n.clientWidth)&&"visible"!=i.overflow){let i=n.getBoundingClientRect();r=Math.max(r,i.left),o=Math.min(o,i.right),a=Math.max(a,i.top),l=Math.min(t==e.parentNode?s.innerHeight:l,i.bottom)}t="absolute"==i.position||"fixed"==i.position?n.offsetParent:n.parentNode}else{if(11!=t.nodeType)break;t=t.host}return{left:r-n.left,right:Math.max(r,o)-n.left,top:a-(n.top+t),bottom:Math.max(a,l)-(n.top+t)}}function yo(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}class vo{constructor(e,t,n,i){this.from=e,this.to=t,this.size=n,this.displaySize=i}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let i=e[n],s=t[n];if(i.from!=s.from||i.to!=s.to||i.size!=s.size)return!1}return!0}draw(e,t){return ii.replace({widget:new ko(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class ko extends ti{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class wo{constructor(e,t){this.view=e,this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=Ao,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Ii.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let n=t.facet(ks).some(e=>"function"!=typeof e&&"cm-lineWrapping"==e.class);this.heightOracle=new to(n),this.stateDeco=To(t),this.heightMap=oo.empty().applyChanges(this.stateDeco,Fe.empty,this.heightOracle.setDoc(t.doc),[new Es(0,0,0,t.doc.length)]);for(let e=0;e<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());e++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ii.set(this.lineGaps.map(e=>e.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let i=n?t.head:t.anchor;if(!e.some(({from:e,to:t})=>i>=e&&i<=t)){let{from:t,to:n}=this.lineBlockAt(i);e.push(new xo(t,n))}}return this.viewports=e.sort((e,t)=>e.from-t.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Ao:new No(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Oo(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=To(this.state);let i=e.changedRanges,s=Es.extendWithRanges(i,function(e,t,n){let i=new go;return hn.compare(e,t,n,i,0),i.changes}(n,this.stateDeco,e?e.changes:it.empty(this.state.doc.length))),r=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);eo(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=r||Xr)&&(e.flags|=2),o?(this.scrollAnchorPos=e.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=r);let a=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let l=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(l||!e.changes.empty||2&e.flags)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(ls)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,n=window.getComputedStyle(t),i=this.heightOracle,s=n.whiteSpace;this.defaultTextDirection="rtl"==n.direction?Ii.RTL:Ii.LTR;let r=this.heightOracle.mustRefreshForWrapping(s)||"refresh"===this.mustMeasureContent,o=t.getBoundingClientRect(),a=r||this.mustMeasureContent||this.contentDOMHeight!=o.height;this.contentDOMHeight=o.height,this.mustMeasureContent=!1;let l=0,c=0;if(o.width&&o.height){let{scaleX:e,scaleY:n}=wi(t,o);(e>.005&&Math.abs(this.scaleX-e)>.005||n>.005&&Math.abs(this.scaleY-n)>.005)&&(this.scaleX=e,this.scaleY=n,l|=16,r=a=!0)}let h=(parseInt(n.paddingTop)||0)*this.scaleY,u=(parseInt(n.paddingBottom)||0)*this.scaleY;this.paddingTop==h&&this.paddingBottom==u||(this.paddingTop=h,this.paddingBottom=u,l|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(i.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,l|=16);let d=xi(this.view.contentDOM,!1).y;d!=this.scrollParent&&(this.scrollParent=d,this.scrollAnchorHeight=-1,this.scrollOffset=0);let f=this.getScrollOffset();this.scrollOffset!=f&&(this.scrollAnchorHeight=-1,this.scrollOffset=f),this.scrolledToBottom=Mi(this.scrollParent||e.win);let p=(this.printing?yo:bo)(t,this.paddingTop),m=p.top-this.pixelViewport.top,g=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let b=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(b!=this.inView&&(this.inView=b,b&&(a=!0)),!this.inView&&!this.scrollTarget&&!function(e){let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView||window;return t.left<n.innerWidth&&t.right>0&&t.top<n.innerHeight&&t.bottom>0}(e.dom))return 0;let y=o.width;if(this.contentDOMWidth==y&&this.editorHeight==e.scrollDOM.clientHeight||(this.contentDOMWidth=o.width,this.editorHeight=e.scrollDOM.clientHeight,l|=16),a){let t=e.docView.measureVisibleLineHeights(this.viewport);if(i.mustRefreshForHeights(t)&&(r=!0),r||i.lineWrapping&&Math.abs(y-this.contentDOMWidth)>i.charWidth){let{lineHeight:n,charWidth:o,textHeight:a}=e.docView.measureTextSize();r=n>0&&i.refresh(s,n,o,a,Math.max(5,y/o),t),r&&(e.docView.minWidth=0,l|=16)}m>0&&g>0?c=Math.max(m,g):m<0&&g<0&&(c=Math.min(m,g)),eo();for(let n of this.viewports){let s=n.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(n);this.heightMap=(r?oo.empty().applyChanges(this.stateDeco,Fe.empty,this.heightOracle,[new Es(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(i,0,r,new no(n.from,s))}Xr&&(l|=2)}let v=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return v&&(2&l&&(l|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),l|=this.updateForViewport()),(2&l||v)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(r?[]:this.lineGaps,e)),l|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),l}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),i=this.heightMap,s=this.heightOracle,{visibleTop:r,visibleBottom:o}=this,a=new xo(i.lineAt(r-1e3*n,so.ByHeight,s,0,0).from,i.lineAt(o+1e3*(1-n),so.ByHeight,s,0,0).to);if(t){let{head:e}=t.range;if(e<a.from||e>a.to){let n,r=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),o=i.lineAt(e,so.ByPos,s,0,0);n="center"==t.y?(o.top+o.bottom)/2-r/2:"start"==t.y||"nearest"==t.y&&e<a.from?o.top:o.bottom-r,a=new xo(i.lineAt(n-500,so.ByHeight,s,0,0).from,i.lineAt(n+r+500,so.ByHeight,s,0,0).to)}}return a}mapViewport(e,t){let n=t.mapPos(e.from,-1),i=t.mapPos(e.to,1);return new xo(this.heightMap.lineAt(n,so.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(i,so.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:i}=this.heightMap.lineAt(e,so.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(t,so.ByPos,this.heightOracle,0,0),{visibleTop:r,visibleBottom:o}=this;return(0==e||i<=r-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||s>=o+Math.max(10,Math.min(n,250)))&&i>r-2e3&&s<o+2e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let i of e)t.touchesRange(i.from,i.to)||n.push(new vo(t.mapPos(i.from),t.mapPos(i.to),i.size,i.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,i=n?1e4:2e3,s=i>>1,r=i<<1;if(this.defaultTextDirection!=Ii.LTR&&!n)return[];let o=[],a=(i,r,l,c)=>{if(r-i<s)return;let h=this.state.selection.main,u=[h.from];h.empty||u.push(h.to);for(let e of u)if(e>i&&e<r)return a(i,e-10,l,c),void a(e+10,r,l,c);let d=function(e,t){for(let n of e)if(t(n))return n;return}(e,e=>e.from>=l.from&&e.to<=l.to&&Math.abs(e.from-i)<s&&Math.abs(e.to-r)<s&&!u.some(t=>e.from<t&&e.to>t));if(!d){if(r<l.to&&t&&n&&t.visibleRanges.some(e=>e.from<=r&&e.to>=r)){let e=t.moveToLineBoundary(ut.cursor(r),!1,!0).head;e>i&&(r=e)}let e=this.gapSize(l,i,r,c);d=new vo(i,r,e,n||e<2e6?e:2e6)}o.push(d)},l=t=>{if(t.length<r||t.type!=ni.Text)return;let s=function(e,t,n){let i=[],s=e,r=0;hn.spans(n,e,t,{span(){},point(e,t){e>s&&(i.push({from:s,to:e}),r+=e-s),s=t}},20),s<t&&(i.push({from:s,to:t}),r+=t-s);return{total:r,ranges:i}}(t.from,t.to,this.stateDeco);if(s.total<r)return;let o,l,c=this.scrollTarget?this.scrollTarget.range.head:null;if(n){let e,n,r=i/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=c){let i=Co(s,c),o=((this.visibleBottom-this.visibleTop)/2+r)/t.height;e=i-o,n=i+o}else e=(this.visibleTop-t.top-r)/t.height,n=(this.visibleBottom-t.top+r)/t.height;o=So(s,e),l=So(s,n)}else{let n=s.total*this.heightOracle.charWidth,r=i*this.heightOracle.charWidth,a=0;if(n>2e6)for(let n of e)n.from>=t.from&&n.from<t.to&&n.size!=n.displaySize&&n.from*this.heightOracle.charWidth+a<this.pixelViewport.left&&(a=n.size-n.displaySize);let h,u,d=this.pixelViewport.left+a,f=this.pixelViewport.right+a;if(null!=c){let e=Co(s,c),t=((f-d)/2+r)/n;h=e-t,u=e+t}else h=(d-r)/n,u=(f+r)/n;o=So(s,h),l=So(s,u)}o>t.from&&a(t.from,o,t,s),l<t.to&&a(l,t.to,t,s)};for(let e of this.viewportLines)Array.isArray(e.type)?e.type.forEach(l):l(e);return o}gapSize(e,t,n,i){let s=Co(i,n)-Co(i,t);return this.heightOracle.lineWrapping?e.height*s:i.total*this.heightOracle.charWidth*s}updateLineGaps(e){vo.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=ii.set(e.map(e=>e.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];hn.spans(t,this.viewport.from,this.viewport.to,{span(e,t){n.push({from:e,to:t})},point(){}},20);let i=0;if(n.length!=this.visibleRanges.length)i=12;else for(let t=0;t<n.length&&!(8&i);t++){let s=this.visibleRanges[t],r=n[t];s.from==r.from&&s.to==r.to||(i|=4,e&&e.mapPos(s.from,-1)==r.from&&e.mapPos(s.to,1)==r.to||(i|=8))}return this.visibleRanges=n,i}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||Oo(this.heightMap.lineAt(e,so.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||Oo(this.heightMap.lineAt(this.scaler.fromDOM(e),so.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return Oo(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class xo{constructor(e,t){this.from=e,this.to=t}}function So({total:e,ranges:t},n){if(n<=0)return t[0].from;if(n>=1)return t[t.length-1].to;let i=Math.floor(e*n);for(let e=0;;e++){let{from:n,to:s}=t[e],r=s-n;if(i<=r)return n+i;i-=r}}function Co(e,t){let n=0;for(let{from:i,to:s}of e.ranges){if(t<=s){n+=t-i;break}n+=s-i}return n/e.total}const Ao={toDOM:e=>e,fromDOM:e=>e,scale:1,eq(e){return e==this}};function To(e){let t=e.facet(ws).filter(e=>"function"!=typeof e),n=e.facet(Ss).filter(e=>"function"!=typeof e);return n.length&&t.push(hn.join(n)),t}class No{constructor(e,t,n){let i=0,s=0,r=0;this.viewports=n.map(({from:n,to:s})=>{let r=t.lineAt(n,so.ByPos,e,0,0).top,o=t.lineAt(s,so.ByPos,e,0,0).bottom;return i+=o-r,{from:n,to:s,top:r,bottom:o,domTop:0,domBottom:0}}),this.scale=(7e6-i)/(t.height-i);for(let e of this.viewports)e.domTop=r+(e.top-s)*this.scale,r=e.domBottom=e.domTop+(e.bottom-e.top),s=e.bottom}toDOM(e){for(let t=0,n=0,i=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.top)return i+(e-n)*this.scale;if(e<=s.bottom)return s.domTop+(e-s.top);n=s.bottom,i=s.domBottom}}fromDOM(e){for(let t=0,n=0,i=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.domTop)return n+(e-i)/this.scale;if(e<=s.domBottom)return s.top+(e-s.domTop);n=s.bottom,i=s.domBottom}}eq(e){return e instanceof No&&(this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,n)=>t.from==e.viewports[n].from&&t.to==e.viewports[n].to))}}function Oo(e,t){if(1==t.scale)return e;let n=t.toDOM(e.top),i=t.toDOM(e.bottom);return new io(e.from,e.length,n,i-n,Array.isArray(e._content)?e._content.map(e=>Oo(e,t)):e._content)}const Mo=pt.define({combine:e=>e.join(" ")}),Eo=pt.define({combine:e=>e.indexOf(!0)>-1}),Do=Nn.newName(),_o=Nn.newName(),Io=Nn.newName(),Bo={"&light":"."+_o,"&dark":"."+Io};function Po(e,t,n){return new Nn(t,{finish:t=>/&/.test(t)?t.replace(/&\w*/,t=>{if("&"==t)return e;if(!n||!n[t])throw new RangeError(`Unsupported selector: ${t}`);return n[t]}):e+" "+t})}const Ro=Po("."+Do,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Bo),$o={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Lo=Zn.ie&&Zn.ie_version<=11;class zo{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Si,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let e of t)this.queue.push(e);(Zn.ie&&Zn.ie_version<=11||Zn.ios&&e.composing)&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),!window.EditContext||!Zn.android||!1===e.constructor.EDIT_CONTEXT||Zn.chrome&&Zn.chrome_version<126||(this.editContext=new Wo(e),e.state.facet(ps)&&(e.contentDOM.editContext=this.editContext.editContext)),Lo&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.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 e;(null===(e=this.view.docView)||void 0===e?void 0:e.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver(e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.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(e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){("change"!=e.type&&e.type||e.matches)&&(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,i=this.selectionRange;if(n.state.facet(ps)?n.root.activeElement!=this.dom:!di(this.dom,i))return;let s=i.anchorNode&&n.docView.tile.nearest(i.anchorNode);s&&s.isWidget()&&s.widget.ignoreEvent(e)?t||(this.selectionChanged=!1):(Zn.ie&&Zn.ie_version<=11||Zn.android&&Zn.chrome)&&!n.state.selection.main.empty&&i.focusNode&&pi(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=hi(e.root);if(!t)return!1;let n=Zn.safari&&11==e.root.nodeType&&e.root.activeElement==this.dom&&function(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return jo(e,n)}let n=null;function i(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.contentDOM.addEventListener("beforeinput",i,!0),e.dom.ownerDocument.execCommand("indent"),e.contentDOM.removeEventListener("beforeinput",i,!0),n?jo(e,n):null}(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let i=di(this.dom,n);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&function(e,t){let n=t.focusNode,i=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=i)return!1;for(i=Math.min(i,yi(n));;)if(i){if(1!=n.nodeType)return!1;let e=n.childNodes[i-1];"false"==e.contentEditable?i--:(n=e,i=yi(n))}else{if(n==e)return!0;i=mi(n),n=n.parentNode}}(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),i&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(1==n.nodeType)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(n),n=n.assignedSlot||n.parentNode;else{if(11!=n.nodeType)break;n=n.host}if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let e of this.scrollTargets)e.removeEventListener("scroll",this.onScroll);for(let e of this.scrollTargets=t)e.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,$o),Lo&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Lo&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var n;if(!this.delayedAndroidKey){let e=()=>{let e=this.delayedAndroidKey;if(e){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&Oi(this.dom,e.key,e.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(e)}this.delayedAndroidKey&&"Enter"!=e||(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(null===(n=this.delayedAndroidKey)||void 0===n?void 0:n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,i=!1;for(let s of e){let e=this.readMutation(s);e&&(e.typeOver&&(i=!0),-1==t?({from:t,to:n}=e):(t=Math.min(e.from,t),n=Math.max(e.to,n)))}return{from:t,to:n,typeOver:i}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),i=this.selectionChanged&&di(this.dom,this.selectionRange);if(e<0&&!i)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new wr(this.view,e,t,n);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,i=Sr(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!Tr(this.view.state.selection,t.newSel.main))&&this.view.update([]),i}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty("attributes"==e.type),"childList"==e.type){let n=Fo(t,e.previousSibling||e.target.previousSibling,-1),i=Fo(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:i?t.posBefore(i):t.posAtEnd,typeOver:!1}}return"characterData"==e.type?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(ps)!=e.state.facet(ps)&&(e.view.contentDOM.editContext=e.state.facet(ps)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),null===(e=this.intersection)||void 0===e||e.disconnect(),null===(t=this.gapIntersection)||void 0===t||t.disconnect(),null===(n=this.resizeScroll)||void 0===n||n.disconnect();for(let e of this.scrollTargets)e.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 Fo(e,t,n){for(;t;){let i=Is.get(t);if(i&&i.parent==e)return i;let s=t.parentNode;t=s!=e.dom?s:n>0?t.nextSibling:t.previousSibling}return null}function jo(e,t){let n=t.startContainer,i=t.startOffset,s=t.endContainer,r=t.endOffset,o=e.docView.domAtPos(e.state.selection.main.anchor,1);return pi(o.node,o.offset,s,r)&&([n,i,s,r]=[s,r,n,i]),{anchorNode:n,anchorOffset:i,focusNode:s,focusOffset:r}}class Wo{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let i=e.state.selection.main,{anchor:s,head:r}=i,o=this.toEditorPos(n.updateRangeStart),a=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:o,drifted:!1});let l=a-o>n.text.length;o==this.from&&s<this.from?o=s:a==this.to&&s>this.to&&(a=s);let c=Ar(e.state.sliceDoc(o,a),n.text,(l?i.from:i.to)-o,l?"end":null);if(!c){let t=ut.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));return void(Tr(t,i)||e.dispatch({selection:t,userEvent:"select"}))}let h={from:c.from+o,to:c.toA+o,insert:Fe.of(n.text.slice(c.from,c.toB).split("\n"))};if((Zn.mac||Zn.android)&&h.from==r-1&&/^\. ?$/.test(n.text)&&"off"==e.contentDOM.getAttribute("autocorrect")&&(h={from:o,to:a,insert:Fe.of([n.text.replace("."," ")])}),this.pendingContextChange=h,!e.state.readOnly){let t=this.to-this.from+(h.to-h.from+h.insert.length);Cr(e,h,ut.single(this.toEditorPos(n.selectionStart,t),this.toEditorPos(n.selectionEnd,t)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),h.from<h.to&&!h.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let i=[],s=null;for(let t=this.toEditorPos(n.rangeStart),r=this.toEditorPos(n.rangeEnd);t<r;t++){let n=e.coordsForChar(t);s=n&&new DOMRect(n.left,n.top,n.right-n.left,n.bottom-n.top)||s||new DOMRect,i.push(s)}t.updateCharacterBounds(n.rangeStart,i)},this.handlers.textformatupdate=t=>{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,i=e.underlineThickness;if(!/none/i.test(t)&&!/none/i.test(i)){let s=this.toEditorPos(e.rangeStart),r=this.toEditorPos(e.rangeEnd);if(s<r){let e=`text-decoration: underline ${/^[a-z]/.test(t)?t+" ":"Dashed"==t?"dashed ":"Squiggle"==t?"wavy ":""}${/thin/i.test(i)?1:2}px`;n.push(ii.mark({attributes:{style:e}}).range(s,r))}}}e.dispatch({effects:ds.of(ii.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:t}=this.composing;this.composing=null,t&&this.reset(e.state)}};for(let e in this.handlers)t.addEventListener(e,this.handlers[e]);this.measureReq={read:e=>{this.editContext.updateControlBounds(e.contentDOM.getBoundingClientRect());let t=hi(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,i=this.pendingContextChange;return e.changes.iterChanges((s,r,o,a,l)=>{if(n)return;let c=l.length-(r-s);if(i&&r>=i.to){if(i.from==s&&i.to==r&&i.insert.eq(l))return i=this.pendingContextChange=null,t+=c,void(this.to+=c);i=null,this.revertPending(e.state)}if(s+=t,(r+=t)<=this.from)this.from+=c,this.to+=c;else if(s<this.to){if(s<this.from||r>this.to||this.to-this.from+l.length>3e4)return void(n=!0);this.editContext.updateText(this.toContextPos(s),this.toContextPos(r),l.toString()),this.to+=c}t+=c}),i&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(e=>!e.isUserEvent("input.type")&&e.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):this.applyEdits(e)&&this.rangeIsValid(e.state)?(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state):(this.pendingContextChange=null,this.reset(e.state)),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),i=this.toContextPos(t.head);this.editContext.selectionStart==n&&this.editContext.selectionEnd==i||this.editContext.updateSelection(n,i)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>3e4)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Uo{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;this.dispatchTransactions=e.dispatchTransactions||n&&(e=>e.forEach(e=>n(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||function(e){for(;e;){if(e&&(9==e.nodeType||11==e.nodeType&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}(e.parent)||document,this.viewState=new wo(this,e.state||nn.create(e)),e.scrollTo&&e.scrollTo.is(us)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(gs).map(e=>new ys(e));for(let e of this.plugins)e.update(this);this.observer=new zo(this),this.inputState=new Nr(this),this.inputState.ensureHandlers(this.plugins),this.docView=new nr(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),(null===(t=document.fonts)||void 0===t?void 0:t.ready)&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=1==e.length&&e[0]instanceof Ht?e:1==e.length&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t,n=!1,i=!1,s=this.state;for(let t of e){if(t.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=t.state}if(this.destroyed)return void(this.viewState.state=s);let r=this.hasFocus,o=0,a=null;e.some(e=>e.annotation(Jr))?(this.inputState.notifiedFocused=r,o=1):r!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=r,a=Zr(s,r),a||(o=1));let l=this.observer.delayedAndroidKey,c=null;if(l?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(c=null)):this.observer.clear(),s.facet(nn.phrases)!=this.state.facet(nn.phrases))return this.setState(s);t=Ds.create(this,s,e),t.flags|=o;let h=this.viewState.scrollTarget;try{this.updateState=2;for(let t of e){if(h&&(h=h.map(t.changes)),t.scrollIntoView){let{main:e}=t.state.selection;h=new hs(e.empty?e:ut.cursor(e.head,e.head>e.anchor?-1:1))}for(let e of t.effects)e.is(us)&&(h=e.value.clip(this.state))}this.viewState.update(t,h),this.bidiCache=qo.update(this.bidiCache,t.changes),t.empty||(this.updatePlugins(t),this.inputState.update(t)),n=this.docView.update(t),this.state.facet(Ms)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(e=>e.isUserEvent("select.pointer")))}finally{this.updateState=0}if(t.startState.facet(Mo)!=t.state.facet(Mo)&&(this.viewState.mustMeasureContent=!0),(n||i||h||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!t.empty)for(let e of this.state.facet(ns))try{e(t)}catch(e){fs(this.state,e,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!Sr(this,c)&&l.force&&Oi(this.contentDOM,l.key,l.keyCode)})}setState(e){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=e);this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);this.viewState=new wo(this,e),this.plugins=e.facet(gs).map(e=>new ys(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new nr(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(gs),n=e.state.facet(gs);if(t!=n){let i=[];for(let s of n){let n=t.indexOf(s);if(n<0)i.push(new ys(s));else{let t=this.plugins[n];t.mustUpdate=e,i.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=i,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e<this.plugins.length;e++)this.plugins[e].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(e){fs(this.state,e,"doc view update listener")}}}measure(e=!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,e&&this.observer.forceFlush();let t=null,n=this.viewState.scrollParent,i=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:r}=this.viewState;Math.abs(i-this.viewState.scrollOffset)>1&&(r=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(r<0)if(Mi(n||this.win))s=-1,r=this.viewState.heightMap.height;else{let e=this.viewState.scrollAnchorAt(i);s=e.from,r=e.top}this.updateState=1;let o=this.viewState.measure();if(!o&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(e>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let a=[];4&o||([this.measureRequests,a]=[a,this.measureRequests]);let l=a.map(e=>{try{return e.read(this)}catch(e){return fs(this.state,e),Ho}}),c=Ds.create(this,this.state,[]),h=!1;c.flags|=o,t?t.flags|=o:t=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),h=this.docView.update(c),h&&this.docViewUpdate());for(let e=0;e<a.length;e++)if(l[e]!=Ho)try{let t=a[e];t.write&&t.write(l[e],this)}catch(e){fs(this.state,e)}if(h&&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 e=((s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-r)/this.scaleY;if((e>1||e<-1)&&(n==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){i+=e,n?n.scrollTop+=e:this.win.scrollBy(0,e),r=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(ns))e(t)}get themeClasses(){return Do+" "+(this.state.facet(Eo)?Io:_o)+" "+this.state.facet(Mo)}updateAttrs(){let e=Ko(this,vs,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(ps)?"true":"false",class:"cm-content",style:`${Zn.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Ko(this,ks,t);let n=this.observer.ignore(()=>{let n=Xn(this.contentDOM,this.contentAttrs,t),i=Xn(this.dom,this.editorAttrs,e);return n||i});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let e of n.effects)if(e.is(Uo.announce)){t&&(this.announceDOM.textContent=""),t=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=e.value}}mountStyles(){this.styleModules=this.state.facet(Ms);let e=this.state.facet(Uo.cspNonce);Nn.mount(this.root,this.styleModules.concat(Ro).reverse(),e?{nonce:e}: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(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(null!=e.key)for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key)return void(this.measureRequests[t]=e);this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(void 0===t||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(t=>t.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return dr(this,e,cr(this,e,t,n))}moveByGroup(e,t){return dr(this,e,cr(this,e,t,t=>function(e,t,n){let i=e.state.charCategorizer(t),s=i(n);return e=>{let t=i(e);return s==Qt.Space&&(s=t),s==t}}(this,e.head,t)))}visualLineSide(e,t){let n=this.bidiSpans(e),i=this.textDirectionAt(e.from),s=n[t?n.length-1:0];return ut.cursor(s.side(t,i)+e.from,s.forward(!t,i)?1:-1)}moveToLineBoundary(e,t,n=!0){return function(e,t,n,i){let s=lr(e,t.head,t.assoc||-1),r=i&&s.type==ni.Text&&(e.lineWrapping||s.widgetLineBreaks)?e.coordsAtPos(t.assoc<0&&t.head>s.from?t.head-1:t.head):null;if(r){let t=e.dom.getBoundingClientRect(),i=e.textDirectionAt(s.from),o=e.posAtCoords({x:n==(i==Ii.LTR)?t.right-1:t.left+1,y:(r.top+r.bottom)/2});if(null!=o)return ut.cursor(o,n?-1:1)}return ut.cursor(n?s.to:s.from,n?-1:1)}(this,e,t,n)}moveVertically(e,t,n){return dr(this,e,function(e,t,n,i){let s=t.head,r=n?1:-1;if(s==(n?e.state.doc.length:0))return ut.cursor(s,t.assoc);let o,a=t.goalColumn,l=e.contentDOM.getBoundingClientRect(),c=e.coordsAtPos(s,t.assoc||((t.empty?n:t.head==t.from)?1:-1)),h=e.documentTop;if(c)null==a&&(a=c.left-l.left),o=r<0?c.top:c.bottom;else{let t=e.viewState.lineBlockAt(s);null==a&&(a=Math.min(l.right-l.left,e.defaultCharacterWidth*(s-t.from))),o=(r<0?t.top:t.bottom)+h}let u=l.left+a,d=e.viewState.heightOracle.textHeight>>1,f=null!=i?i:d;for(let t=0;;t+=d){let i=o+(f+t)*r,s=pr(e,{x:u,y:i},!1,r);if(n?i>l.bottom:i<l.top)return ut.cursor(s.pos,s.assoc);let c=e.coordsAtPos(s.pos,s.assoc),h=c?(c.top+c.bottom)/2:0;if(!c||(n?h>o:h<o))return ut.cursor(s.pos,s.assoc,void 0,a)}}(this,e,t,n))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let n=pr(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),pr(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let i=this.state.doc.lineAt(e),s=this.bidiSpans(i);return vi(n,s[Ui.find(s,e-i.from,-1,t)].dir==Ii.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(as)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Vo)return Ji(e.length);let t,n=this.textDirectionAt(e.from);for(let i of this.bidiCache)if(i.from==e.from&&i.dir==n&&(i.fresh||Vi(i.isolates,t=Ts(this,e))))return i.order;t||(t=Ts(this,e));let i=function(e,t,n){if(!e)return[new Ui(0,0,t==Pi?1:0)];if(t==Bi&&!n.length&&!Wi.test(e))return Ji(e.length);if(n.length)for(;e.length>Hi.length;)Hi[Hi.length]=256;let i=[],s=t==Bi?0:1;return Ki(e,s,s,n,0,e.length,i),i}(e.text,n,t);return this.bidiCache.push(new qo(e.from,e.to,n,t,!0,i)),i}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Zn.safari&&(null===(e=this.inputState)||void 0===e?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Ti(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((9==e.nodeType?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return us.of(new hs("number"==typeof e?ut.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return us.of(new hs(ut.cursor(n.from),"start","start",n.top-e,t,!0))}setTabFocusMode(e){null==e?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof e?this.inputState.tabFocusMode=e?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return bs.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return bs.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=Nn.newName(),i=[Mo.of(n),Ms.of(Po(`.${n}`,e))];return t&&t.dark&&i.push(Eo.of(!0)),i}static baseTheme(e){return Nt.lowest(Ms.of(Po("."+Do,e,Bo)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),i=n&&Is.get(n)||Is.get(e);return(null===(t=null==i?void 0:i.root)||void 0===t?void 0:t.view)||null}}Uo.styleModule=Ms,Uo.inputHandler=is,Uo.clipboardInputFilter=rs,Uo.clipboardOutputFilter=os,Uo.scrollHandler=cs,Uo.focusChangeEffect=ss,Uo.perLineTextDirection=as,Uo.exceptionSink=ts,Uo.updateListener=ns,Uo.editable=ps,Uo.mouseSelectionStyle=es,Uo.dragMovesSelection=Xi,Uo.clickAddsSelectionRange=Qi,Uo.decorations=ws,Uo.blockWrappers=xs,Uo.outerDecorations=Ss,Uo.atomicRanges=Cs,Uo.bidiIsolatedRanges=As,Uo.scrollMargins=Ns,Uo.darkTheme=Eo,Uo.cspNonce=pt.define({combine:e=>e.length?e[0]:""}),Uo.contentAttributes=ks,Uo.editorAttributes=vs,Uo.lineWrapping=Uo.contentAttributes.of({class:"cm-lineWrapping"}),Uo.announce=Vt.define();const Vo=4096,Ho={};class qo{constructor(e,t,n,i,s,r){this.from=e,this.to=t,this.dir=n,this.isolates=i,this.fresh=s,this.order=r}static update(e,t){if(t.empty&&!e.some(e=>e.fresh))return e;let n=[],i=e.length?e[e.length-1].dir:Ii.LTR;for(let s=Math.max(0,e.length-10);s<e.length;s++){let r=e[s];r.dir!=i||t.touchesRange(r.from,r.to)||n.push(new qo(t.mapPos(r.from,1),t.mapPos(r.to,-1),r.dir,r.isolates,!1,r.order))}return n}}function Ko(e,t,n){for(let i=e.state.facet(t),s=i.length-1;s>=0;s--){let t=i[s],r="function"==typeof t?t(e):t;r&&Yn(r,n)}return n}const Jo=Zn.mac?"mac":Zn.windows?"win":Zn.linux?"linux":"key";function Zo(e,t,n){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),!1!==n&&t.shiftKey&&(e="Shift-"+e),e}const Yo=Nt.default(Uo.domEventHandlers({keydown:(e,t)=>ia(Xo(t.state),e,t,"editor")})),Go=pt.define({enables:Yo}),Qo=new WeakMap;function Xo(e){let t=e.facet(Go),n=Qo.get(t);return n||Qo.set(t,n=function(e,t=Jo){let n=Object.create(null),i=Object.create(null),s=(e,t)=>{let n=i[e];if(null==n)i[e]=t;else if(n!=t)throw new Error("Key binding "+e+" is used both as a regular binding and as a multi-stroke prefix")},r=(e,i,r,o,a)=>{var l,c;let h=n[e]||(n[e]=Object.create(null)),u=i.split(/ (?!$)/).map(e=>function(e,t){const n=e.split(/-(?!$)/);let i,s,r,o,a=n[n.length-1];"Space"==a&&(a=" ");for(let e=0;e<n.length-1;++e){const a=n[e];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))i=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))r=!0;else{if(!/^mod$/i.test(a))throw new Error("Unrecognized modifier name: "+a);"mac"==t?o=!0:s=!0}}return i&&(a="Alt-"+a),s&&(a="Ctrl-"+a),o&&(a="Meta-"+a),r&&(a="Shift-"+a),a}(e,t));for(let t=1;t<u.length;t++){let n=u.slice(0,t).join(" ");s(n,!0),h[n]||(h[n]={preventDefault:!0,stopPropagation:!1,run:[t=>{let i=ea={view:t,prefix:n,scope:e};return setTimeout(()=>{ea==i&&(ea=null)},ta),!0}]})}let d=u.join(" ");s(d,!1);let f=h[d]||(h[d]={preventDefault:!1,stopPropagation:!1,run:(null===(c=null===(l=h._any)||void 0===l?void 0:l.run)||void 0===c?void 0:c.slice())||[]});r&&f.run.push(r),o&&(f.preventDefault=!0),a&&(f.stopPropagation=!0)};for(let i of e){let e=i.scope?i.scope.split(" "):["editor"];if(i.any)for(let t of e){let e=n[t]||(n[t]=Object.create(null));e._any||(e._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:s}=i;for(let t in e)e[t].run.push(e=>s(e,na))}let s=i[t]||i.key;if(s)for(let t of e)r(t,s,i.run,i.preventDefault,i.stopPropagation),i.shift&&r(t,"Shift-"+s,i.shift,i.preventDefault,i.stopPropagation)}return n}(t.reduce((e,t)=>e.concat(t),[]))),n}let ea=null;const ta=4e3;let na=null;function ia(e,t,n,i){na=t;let s=function(e){var t=!(_n&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||In&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?Dn:En)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}(t),r=Xe(Ge(s,0))==s.length&&" "!=s,o="",a=!1,l=!1,c=!1;ea&&ea.view==n&&ea.scope==i&&(o=ea.prefix+" ",_r.indexOf(t.keyCode)<0&&(l=!0,ea=null));let h,u,d=new Set,f=e=>{if(e){for(let t of e.run)if(!d.has(t)&&(d.add(t),t(n)))return e.stopPropagation&&(c=!0),!0;e.preventDefault&&(e.stopPropagation&&(c=!0),l=!0)}return!1},p=e[i];return p&&(f(p[o+Zo(s,t,!r)])?a=!0:!r||!(t.altKey||t.metaKey||t.ctrlKey)||Zn.windows&&t.ctrlKey&&t.altKey||Zn.mac&&t.altKey&&!t.ctrlKey&&!t.metaKey||!(h=En[t.keyCode])||h==s?r&&t.shiftKey&&f(p[o+Zo(s,t,!0)])&&(a=!0):(f(p[o+Zo(h,t,!0)])||t.shiftKey&&(u=Dn[t.keyCode])!=s&&u!=h&&f(p[o+Zo(u,t,!1)]))&&(a=!0),!a&&f(p._any)&&(a=!0)),l&&(a=!0),a&&c&&t.stopPropagation(),na=null,a}class sa{constructor(e,t,n,i,s){this.className=e,this.left=t,this.top=n,this.width=i,this.height=s}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className==this.className&&(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",null!=this.width&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,n){if(n.empty){let i=e.coordsAtPos(n.head,n.assoc||1);if(!i)return[];let s=ra(e);return[new sa(t,i.left-s.left,i.top-s.top,null,i.bottom-i.top)]}return function(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let i=Math.max(n.from,e.viewport.from),s=Math.min(n.to,e.viewport.to),r=e.textDirection==Ii.LTR,o=e.contentDOM,a=o.getBoundingClientRect(),l=ra(e),c=o.querySelector(".cm-line"),h=c&&window.getComputedStyle(c),u=a.left+(h?parseInt(h.paddingLeft)+Math.min(0,parseInt(h.textIndent)):0),d=a.right-(h?parseInt(h.paddingRight):0),f=lr(e,i,1),p=lr(e,s,-1),m=f.type==ni.Text?f:null,g=p.type==ni.Text?p:null;m&&(e.lineWrapping||f.widgetLineBreaks)&&(m=oa(e,i,1,m));g&&(e.lineWrapping||p.widgetLineBreaks)&&(g=oa(e,s,-1,g));if(m&&g&&m.from==g.from&&m.to==g.to)return y(v(n.from,n.to,m));{let t=m?v(n.from,null,m):k(f,!1),i=g?v(null,n.to,g):k(p,!0),s=[];return(m||f).to<(g||p).from-(m&&g?1:0)||f.widgetLineBreaks>1&&t.bottom+e.defaultLineHeight/2<i.top?s.push(b(u,t.bottom,d,i.top)):t.bottom<i.top&&e.elementAtHeight((t.bottom+i.top)/2).type==ni.Text&&(t.bottom=i.top=(t.bottom+i.top)/2),y(t).concat(s).concat(y(i))}function b(e,n,i,s){return new sa(t,e-l.left,n-l.top,Math.max(0,i-e),s-n)}function y({top:e,bottom:t,horizontal:n}){let i=[];for(let s=0;s<n.length;s+=2)i.push(b(n[s],e,n[s+1],t));return i}function v(t,n,i){let s=1e9,o=-1e9,a=[];function l(t,n,l,c,h){let f=e.coordsAtPos(t,t==i.to?-2:2),p=e.coordsAtPos(l,l==i.from?2:-2);f&&p&&(s=Math.min(f.top,p.top,s),o=Math.max(f.bottom,p.bottom,o),h==Ii.LTR?a.push(r&&n?u:f.left,r&&c?d:p.right):a.push(!r&&c?u:p.left,!r&&n?d:f.right))}let c=null!=t?t:i.from,h=null!=n?n:i.to;for(let i of e.visibleRanges)if(i.to>c&&i.from<h)for(let s=Math.max(i.from,c),r=Math.min(i.to,h);;){let i=e.state.doc.lineAt(s);for(let o of e.bidiSpans(i)){let e=o.from+i.from,a=o.to+i.from;if(e>=r)break;a>s&&l(Math.max(e,s),null==t&&e<=c,Math.min(a,r),null==n&&a>=h,o.dir)}if(s=i.to+1,s>=r)break}return 0==a.length&&l(c,null==t,h,null==n,e.textDirection),{top:s,bottom:o,horizontal:a}}function k(e,t){let n=a.top+(t?e.top:e.bottom);return{top:n,bottom:n,horizontal:[]}}}(e,t,n)}}function ra(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==Ii.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function oa(e,t,n,i){let s=e.coordsAtPos(t,2*n);if(!s)return i;let r=e.dom.getBoundingClientRect(),o=(s.top+s.bottom)/2,a=e.posAtCoords({x:r.left+1,y:o}),l=e.posAtCoords({x:r.right-1,y:o});return null==a||null==l?i:{from:Math.max(i.from,Math.min(a,l)),to:Math.min(i.to,Math.max(a,l))}}class aa{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(la)!=e.state.facet(la)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){!1!==this.layer.updateOnDocViewUpdate&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(la);for(;t<n.length&&n[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;e==this.scaleX&&t==this.scaleY||(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((e,t)=>!function(e,t){return e.constructor==t.constructor&&e.eq(t)}(e,this.drawn[t]))){let t=this.dom.firstChild,n=0;for(let i of e)i.update&&t&&i.constructor&&this.drawn[n].constructor&&i.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(i.draw(),t);for(;t;){let e=t.nextSibling;t.remove(),t=e}this.drawn=e,Zn.safari&&Zn.safari_version>=26&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const la=pt.define();function ca(e){return[bs.define(t=>new aa(t,e)),la.of(e)]}const ha=pt.define({combine:e=>sn(e,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})});function ua(e={}){return[ha.of(e),fa,ma,ga,ls.of(!0)]}function da(e){return e.startState.facet(ha)!=e.state.facet(ha)}const fa=ca({above:!0,markers(e){let{state:t}=e,n=t.facet(ha),i=[];for(let s of t.selection.ranges){let r=s==t.selection.main;if(s.empty||n.drawRangeCursor&&!(r&&Zn.ios&&n.iosSelectionHandles)){let t=r?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",n=s.empty?s:ut.cursor(s.head,s.assoc);for(let s of sa.forRange(e,t,n))i.push(s)}}return i},update(e,t){e.transactions.some(e=>e.selection)&&(t.style.animationName="cm-blink"==t.style.animationName?"cm-blink2":"cm-blink");let n=da(e);return n&&pa(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){pa(t.state,e)},class:"cm-cursorLayer"});function pa(e,t){t.style.animationDuration=e.facet(ha).cursorBlinkRate+"ms"}const ma=ca({above:!1,markers(e){let t=[],{main:n,ranges:i}=e.state.selection;for(let n of i)if(!n.empty)for(let i of sa.forRange(e,"cm-selectionBackground",n))t.push(i);if(Zn.ios&&!n.empty&&e.state.facet(ha).iosSelectionHandles){for(let i of sa.forRange(e,"cm-selectionHandle cm-selectionHandle-start",ut.cursor(n.from,1)))t.push(i);for(let i of sa.forRange(e,"cm-selectionHandle cm-selectionHandle-end",ut.cursor(n.to,1)))t.push(i)}return t},update:(e,t)=>e.docChanged||e.selectionSet||e.viewportChanged||da(e),class:"cm-selectionLayer"}),ga=Nt.highest(Uo.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),ba=Vt.define({map:(e,t)=>null==e?null:t.mapPos(e)}),ya=wt.define({create:()=>null,update:(e,t)=>(null!=e&&(e=t.changes.mapPos(e)),t.effects.reduce((e,t)=>t.is(ba)?t.value:e,e))}),va=bs.fromClass(class{constructor(e){this.view=e,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(e){var t;let n=e.state.field(ya);null==n?null!=this.cursor&&(null===(t=this.cursor)||void 0===t||t.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(e.startState.field(ya)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(ya),n=null!=t&&e.coordsAtPos(t);if(!n)return null;let i=e.scrollDOM.getBoundingClientRect();return{left:n.left-i.left+e.scrollDOM.scrollLeft*e.scaleX,top:n.top-i.top+e.scrollDOM.scrollTop*e.scaleY,height:n.bottom-n.top}}drawCursor(e){if(this.cursor){let{scaleX:t,scaleY:n}=this.view;e?(this.cursor.style.left=e.left/t+"px",this.cursor.style.top=e.top/n+"px",this.cursor.style.height=e.height/n+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(e){this.view.state.field(ya)!=e&&this.view.dispatch({effects:ba.of(e)})}},{eventObservers:{dragover(e){this.setDropPos(this.view.posAtCoords({x:e.clientX,y:e.clientY}))},dragleave(e){e.target!=this.view.contentDOM&&this.view.contentDOM.contains(e.relatedTarget)||this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function ka(e,t,n,i,s){t.lastIndex=0;for(let r,o=e.iterRange(n,i),a=n;!o.next().done;a+=o.value.length)if(!o.lineBreak)for(;r=t.exec(o.value);)s(a+r.index,r)}class wa{constructor(e){const{regexp:t,decoration:n,decorate:i,boundary:s,maxLength:r=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,i)this.addMatch=(e,t,n,s)=>i(s,n,n+e[0].length,e,t);else if("function"==typeof n)this.addMatch=(e,t,i,s)=>{let r=n(e,t,i);r&&s(i,i+e[0].length,r)};else{if(!n)throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.addMatch=(e,t,i,s)=>s(i,i+e[0].length,n)}this.boundary=s,this.maxLength=r}createDeco(e){let t=new un,n=t.add.bind(t);for(let{from:t,to:i}of function(e,t){let n=e.visibleRanges;if(1==n.length&&n[0].from==e.viewport.from&&n[0].to==e.viewport.to)return n;let i=[];for(let{from:s,to:r}of n)s=Math.max(e.state.doc.lineAt(s).from,s-t),r=Math.min(e.state.doc.lineAt(r).to,r+t),i.length&&i[i.length-1].to>=s?i[i.length-1].to=r:i.push({from:s,to:r});return i}(e,this.maxLength))ka(e.state.doc,this.regexp,t,i,(t,i)=>this.addMatch(i,e,t,n));return t.finish()}updateDeco(e,t){let n=1e9,i=-1;return e.docChanged&&e.changes.iterChanges((t,s,r,o)=>{o>=e.view.viewport.from&&r<=e.view.viewport.to&&(n=Math.min(r,n),i=Math.max(o,i))}),e.viewportMoved||i-n>1e3?this.createDeco(e.view):i>-1?this.updateRange(e.view,t.map(e.changes),n,i):t}updateRange(e,t,n,i){for(let s of e.visibleRanges){let r=Math.max(s.from,n),o=Math.min(s.to,i);if(o>=r){let n=e.state.doc.lineAt(r),i=n.to<o?e.state.doc.lineAt(o):n,a=Math.max(s.from,n.from),l=Math.min(s.to,i.to);if(this.boundary){for(;r>n.from;r--)if(this.boundary.test(n.text[r-1-n.from])){a=r;break}for(;o<i.to;o++)if(this.boundary.test(i.text[o-i.from])){l=o;break}}let c,h=[],u=(e,t,n)=>h.push(n.range(e,t));if(n==i)for(this.regexp.lastIndex=a-n.from;(c=this.regexp.exec(n.text))&&c.index<l-n.from;)this.addMatch(c,e,c.index+n.from,u);else ka(e.state.doc,this.regexp,a,l,(t,n)=>this.addMatch(n,e,t,u));t=t.update({filterFrom:a,filterTo:l,filter:(e,t)=>e<a||t>l,add:h})}}return t}}const xa=null!=/x/.unicode?"gu":"g",Sa=new RegExp("[\0-\b\n--\u2028\u2029\ufeff-]",xa),Ca={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 Aa=null;const Ta=pt.define({combine(e){let t=sn(e,{render:null,specialChars:Sa,addSpecialChars:null});return(t.replaceTabs=!function(){var e;if(null==Aa&&"undefined"!=typeof document&&document.body){let t=document.body.style;Aa=null!=(null!==(e=t.tabSize)&&void 0!==e?e:t.MozTabSize)}return Aa||!1}())&&(t.specialChars=new RegExp("\t|"+t.specialChars.source,xa)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,xa)),t}});function Na(e={}){return[Ta.of(e),Oa||(Oa=bs.fromClass(class{constructor(e){this.view=e,this.decorations=ii.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(Ta)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new wa({regexp:e.specialChars,decoration:(t,n,i)=>{let{doc:s}=n.state,r=Ge(t[0],0);if(9==r){let e=s.lineAt(i),t=n.state.tabSize,r=xn(e.text,t,i-e.from);return ii.replace({widget:new Ea((t-r%t)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[r]||(this.decorationCache[r]=ii.replace({widget:new Ma(e,r)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(Ta);e.startState.facet(Ta)!=t?(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(e.view)):this.decorations=this.decorator.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}))]}let Oa=null;class Ma extends ti{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=function(e){return e>=32?"•":10==e?"":String.fromCharCode(9216+e)}(this.code),n=e.state.phrase("Control character")+" "+(Ca[this.code]||"0x"+this.code.toString(16)),i=this.options.render&&this.options.render(this.code,n,t);if(i)return i;let s=document.createElement("span");return s.textContent=t,s.title=n,s.setAttribute("aria-label",n),s.className="cm-specialChar",s}ignoreEvent(){return!1}}class Ea extends ti{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent="\t",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}const Da=ii.line({class:"cm-activeLine"}),_a=bs.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,n=[];for(let i of e.state.selection.ranges){let s=e.lineBlockAt(i.head);s.from>t&&(n.push(Da.range(s.from)),t=s.from)}return ii.set(n)}},{decorations:e=>e.decorations}),Ia=2e3;function Ba(e,t){let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1),i=e.state.doc.lineAt(n),s=n-i.from,r=s>Ia?-1:s==i.length?function(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}(e,t.clientX):xn(i.text,e.state.tabSize,n-i.from);return{line:i.number,col:r,off:s}}function Pa(e,t){let n=Ba(e,t),i=e.state.selection;return n?{update(e){if(e.docChanged){let t=e.changes.mapPos(e.startState.doc.line(n.line).from),s=e.state.doc.lineAt(t);n={line:s.number,col:n.col,off:Math.min(n.off,s.length)},i=i.map(e.changes)}},get(t,s,r){let o=Ba(e,t);if(!o)return i;let a=function(e,t,n){let i=Math.min(t.line,n.line),s=Math.max(t.line,n.line),r=[];if(t.off>Ia||n.off>Ia||t.col<0||n.col<0){let o=Math.min(t.off,n.off),a=Math.max(t.off,n.off);for(let t=i;t<=s;t++){let n=e.doc.line(t);n.length<=a&&r.push(ut.range(n.from+o,n.to+a))}}else{let o=Math.min(t.col,n.col),a=Math.max(t.col,n.col);for(let t=i;t<=s;t++){let n=e.doc.line(t),i=Sn(n.text,o,e.tabSize,!0);if(i<0)r.push(ut.cursor(n.to));else{let t=Sn(n.text,a,e.tabSize);r.push(ut.range(n.from+i,n.from+t))}}}return r}(e.state,n,o);return a.length?r?ut.create(a.concat(i.ranges)):ut.create(a):i}}:null}const Ra={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},$a={style:"cursor: crosshair"};function La(e={}){let[t,n]=Ra[e.key||"Alt"],i=bs.fromClass(class{constructor(e){this.view=e,this.isDown=!1}set(e){this.isDown!=e&&(this.isDown=e,this.view.update([]))}},{eventObservers:{keydown(e){this.set(e.keyCode==t||n(e))},keyup(e){e.keyCode!=t&&n(e)||this.set(!1)},mousemove(e){this.set(n(e))}}});return[i,Uo.contentAttributes.of(e=>{var t;return(null===(t=e.plugin(i))||void 0===t?void 0:t.isDown)?$a:null})]}const za="-10000px";class Fa{constructor(e,t,n,i){this.facet=t,this.createTooltipView=n,this.removeTooltipView=i,this.input=e.state.facet(t),this.tooltips=this.input.filter(e=>e);let s=null;this.tooltipViews=this.tooltips.map(e=>s=n(e,s))}update(e,t){var n;let i=e.state.facet(this.facet),s=i.filter(e=>e);if(i===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let r=[],o=t?[]:null;for(let n=0;n<s.length;n++){let i=s[n],a=-1;if(i){for(let e=0;e<this.tooltips.length;e++){let t=this.tooltips[e];t&&t.create==i.create&&(a=e)}if(a<0)r[n]=this.createTooltipView(i,n?r[n-1]:null),o&&(o[n]=!!i.above);else{let i=r[n]=this.tooltipViews[a];o&&(o[n]=t[a]),i.update&&i.update(e)}}}for(let e of this.tooltipViews)r.indexOf(e)<0&&(this.removeTooltipView(e),null===(n=e.destroy)||void 0===n||n.call(e));return t&&(o.forEach((e,n)=>t[n]=e),t.length=o.length),this.input=i,this.tooltips=s,this.tooltipViews=r,!0}}function ja(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const Wa=pt.define({combine:e=>{var t,n,i;return{position:Zn.ios?"absolute":(null===(t=e.find(e=>e.position))||void 0===t?void 0:t.position)||"fixed",parent:(null===(n=e.find(e=>e.parent))||void 0===n?void 0:n.parent)||null,tooltipSpace:(null===(i=e.find(e=>e.tooltipSpace))||void 0===i?void 0:i.tooltipSpace)||ja}}}),Ua=new WeakMap,Va=bs.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(Wa);this.position=t.position,this.parent=t.parent,this.classes=e.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 Fa(e,Ja,(e,t)=>this.createTooltip(e,t),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver="function"==typeof IntersectionObserver?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.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 e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,i=e.state.facet(Wa);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let e of this.manager.tooltipViews)e.dom.style.position=this.position;n=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let e of this.manager.tooltipViews)this.container.appendChild(e.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),i=t?t.dom:null;if(n.dom.classList.add("cm-tooltip"),e.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let e=document.createElement("div");e.className="cm-tooltip-arrow",n.dom.appendChild(e)}return n.dom.style.position=this.position,n.dom.style.top=za,n.dom.style.left="0px",this.container.insertBefore(n.dom,i),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),null===(e=t.destroy)||void 0===e||e.call(t);this.parent&&this.container.remove(),null===(t=this.resizeObserver)||void 0===t||t.disconnect(),null===(n=this.intersectionObserver)||void 0===n||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if("fixed"==this.position&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(Zn.safari){let t=e.getBoundingClientRect();n=Math.abs(t.top+1e4)>1||Math.abs(t.left)>1}else n=!!e.offsetParent&&e.offsetParent!=this.container.ownerDocument.body}if(n||"absolute"==this.position)if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(e=n.width/this.parent.offsetWidth,t=n.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);let i=this.view.scrollDOM.getBoundingClientRect(),s=Os(this.view);return{visible:{left:i.left+s.left,top:i.top+s.top,right:i.right-s.right,bottom:i.bottom-s.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((e,t)=>{let n=this.manager.tooltipViews[t];return n.getCoords?n.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(Wa).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){var t;if(e.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let e of this.manager.tooltipViews)e.dom.style.position="absolute"}let{visible:n,space:i,scaleX:s,scaleY:r}=e,o=[];for(let a=0;a<this.manager.tooltips.length;a++){let l=this.manager.tooltips[a],c=this.manager.tooltipViews[a],{dom:h}=c,u=e.pos[a],d=e.size[a];if(!u||!1!==l.clip&&(u.bottom<=Math.max(n.top,i.top)||u.top>=Math.min(n.bottom,i.bottom)||u.right<Math.max(n.left,i.left)-.1||u.left>Math.min(n.right,i.right)+.1)){h.style.top=za;continue}let f=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=f?7:0,m=d.right-d.left,g=null!==(t=Ua.get(c))&&void 0!==t?t:d.bottom-d.top,b=c.offset||Ka,y=this.view.textDirection==Ii.LTR,v=d.width>i.right-i.left?y?i.left:i.right-d.width:y?Math.max(i.left,Math.min(u.left-(f?14:0)+b.x,i.right-m)):Math.min(Math.max(i.left,u.left-m+(f?14:0)-b.x),i.right-m),k=this.above[a];!l.strictSide&&(k?u.top-g-p-b.y<i.top:u.bottom+g+p+b.y>i.bottom)&&k==i.bottom-u.bottom>u.top-i.top&&(k=this.above[a]=!k);let w=(k?u.top-i.top:i.bottom-u.bottom)-p;if(w<g&&!1!==c.resize){if(w<this.view.defaultLineHeight){h.style.top=za;continue}Ua.set(c,g),h.style.height=(g=w)/r+"px"}else h.style.height&&(h.style.height="");let x=k?u.top-g-p-b.y:u.bottom+p+b.y,S=v+m;if(!0!==c.overlap)for(let e of o)e.left<S&&e.right>v&&e.top<x+g&&e.bottom>x&&(x=k?e.top-g-2-p:e.bottom+p+2);if("absolute"==this.position?(h.style.top=(x-e.parent.top)/r+"px",Ha(h,(v-e.parent.left)/s)):(h.style.top=x/r+"px",Ha(h,v/s)),f){let e=u.left+(y?b.x:-b.x)-(v+14-7);f.style.left=e/s+"px"}!0!==c.overlap&&o.push({left:v,top:x,right:S,bottom:x+g}),h.classList.toggle("cm-tooltip-above",k),h.classList.toggle("cm-tooltip-below",!k),c.positioned&&c.positioned(e.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 e of this.manager.tooltipViews)e.dom.style.top=za}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Ha(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}const qa=Uo.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"}}}),Ka={x:0,y:0},Ja=pt.define({enables:[Va,qa]}),Za=pt.define({combine:e=>e.reduce((e,t)=>e.concat(t),[])});class Ya{static create(e){return new Ya(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Fa(e,Za,(e,t)=>this.createHostedView(e,t),e=>e.dom.remove())}createHostedView(e,t){let n=e.create(this.view);return n.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(n.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)null===(e=t.destroy)||void 0===e||e.call(t)}passProp(e){let t;for(let n of this.manager.tooltipViews){let i=n[e];if(void 0!==i)if(void 0===t)t=i;else if(t!==i)return}return t}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 Ga=Ja.compute([Za],e=>{let t=e.facet(Za);return 0===t.length?null:{pos:Math.min(...t.map(e=>e.pos)),end:Math.max(...t.map(e=>{var t;return null!==(t=e.end)&&void 0!==t?t:e.pos})),create:Ya.create,above:t[0].above,arrow:t.some(e=>e.arrow)}});class Qa{constructor(e,t,n,i,s){this.view=e,this.source=t,this.field=n,this.setHover=i,this.hoverTime=s,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,n=e.docView.tile.nearest(t.target);if(!n)return;let i,s=1;if(n.isWidget())i=n.posAtStart;else{if(i=e.posAtCoords(t),null==i)return;let n=e.coordsAtPos(i);if(!n||t.y<n.top||t.y>n.bottom||t.x<n.left-e.defaultCharacterWidth||t.x>n.right+e.defaultCharacterWidth)return;let r=e.bidiSpans(e.state.doc.lineAt(i)).find(e=>e.from<=i&&e.to>=i),o=r&&r.dir==Ii.RTL?-1:1;s=t.x<n.left?-o:o}let r=this.source(e,i,s);if(null==r?void 0:r.then){let t=this.pending={pos:i};r.then(n=>{this.pending==t&&(this.pending=null,!n||Array.isArray(n)&&!n.length||e.dispatch({effects:this.setHover.of(Array.isArray(n)?n:[n])}))},t=>fs(e.state,t,"hover tooltip"))}else!r||Array.isArray(r)&&!r.length||e.dispatch({effects:this.setHover.of(Array.isArray(r)?r:[r])})}get tooltip(){let e=this.view.plugin(Va),t=e?e.manager.tooltips.findIndex(e=>e.create==Ya.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,n;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:s}=this;if(i.length&&s&&!function(e,t){let n,{left:i,right:s,top:r,bottom:o}=e.getBoundingClientRect();if(n=e.querySelector(".cm-tooltip-arrow")){let e=n.getBoundingClientRect();r=Math.min(e.top,r),o=Math.max(e.bottom,o)}return t.clientX>=i-Xa&&t.clientX<=s+Xa&&t.clientY>=r-Xa&&t.clientY<=o+Xa}(s.dom,e)||this.pending){let{pos:s}=i[0]||this.pending,r=null!==(n=null===(t=i[0])||void 0===t?void 0:t.end)&&void 0!==n?n:s;(s==r?this.view.posAtCoords(this.lastMove)==s:function(e,t,n,i,s){let r=e.scrollDOM.getBoundingClientRect(),o=e.documentTop+e.documentPadding.top+e.contentHeight;if(r.left>i||r.right<i||r.top>s||Math.min(r.bottom,o)<s)return!1;let a=e.posAtCoords({x:i,y:s},!1);return a>=t&&a<=n}(this.view,s,r,e.clientX,e.clientY))||(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length){let{tooltip:t}=this;t&&t.dom.contains(e.relatedTarget)?this.watchTooltipLeave(t.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=n=>{e.removeEventListener("mouseleave",t),this.active.length&&!this.view.dom.contains(n.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const Xa=4;function el(e,t={}){let n=Vt.define(),i=wt.define({create:()=>[],update(e,i){if(e.length&&(t.hideOnChange&&(i.docChanged||i.selection)?e=[]:t.hideOn&&(e=e.filter(e=>!t.hideOn(i,e))),i.docChanged)){let t=[];for(let n of e){let e=i.changes.mapPos(n.pos,-1,tt.TrackDel);if(null!=e){let s=Object.assign(Object.create(null),n);s.pos=e,null!=s.end&&(s.end=i.changes.mapPos(s.end)),t.push(s)}}e=t}for(let t of i.effects)t.is(n)&&(e=t.value),t.is(nl)&&(e=[]);return e},provide:e=>Za.from(e)});return{active:i,extension:[i,bs.define(s=>new Qa(s,e,i,n,t.hoverTime||300)),Ga]}}function tl(e,t){let n=e.plugin(Va);if(!n)return null;let i=n.manager.tooltips.indexOf(t);return i<0?null:n.manager.tooltipViews[i]}const nl=Vt.define(),il=pt.define({combine(e){let t,n;for(let i of e)t=t||i.topContainer,n=n||i.bottomContainer;return{topContainer:t,bottomContainer:n}}});function sl(e,t){let n=e.plugin(rl),i=n?n.specs.indexOf(t):-1;return i>-1?n.panels[i]:null}const rl=bs.fromClass(class{constructor(e){this.input=e.state.facet(ll),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(il);this.top=new ol(e,!0,t.topContainer),this.bottom=new ol(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top));for(let e of this.panels)e.dom.classList.add("cm-panel"),e.mount&&e.mount()}update(e){let t=e.state.facet(il);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new ol(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new ol(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(ll);if(n!=this.input){let t=n.filter(e=>e),i=[],s=[],r=[],o=[];for(let n of t){let t,a=this.specs.indexOf(n);a<0?(t=n(e.view),o.push(t)):(t=this.panels[a],t.update&&t.update(e)),i.push(t),(t.top?s:r).push(t)}this.specs=t,this.panels=i,this.top.sync(s),this.bottom.sync(r);for(let e of o)e.dom.classList.add("cm-panel"),e.mount&&e.mount()}else for(let t of this.panels)t.update&&t.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>Uo.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class ol{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(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",this.dom.style[this.top?"top":"bottom"]="0";let e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=al(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=al(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(this.container&&this.classes!=this.view.themeClasses){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function al(e){let t=e.nextSibling;return e.remove(),t}const ll=pt.define({enables:rl});function cl(e,t){let n,i=new Promise(e=>n=e),s=e=>function(e,t,n){let i=t.content?t.content(e,()=>o(null)):null;if(!i){if(i=Rn("form"),t.input){let e=Rn("input",t.input);/^(text|password|number|email|tel|url)$/.test(e.type)&&e.classList.add("cm-textfield"),e.name||(e.name="input"),i.appendChild(Rn("label",(t.label||"")+": ",e))}else i.appendChild(document.createTextNode(t.label||""));i.appendChild(document.createTextNode(" ")),i.appendChild(Rn("button",{class:"cm-button",type:"submit"},t.submitLabel||"OK"))}let s="FORM"==i.nodeName?[i]:i.querySelectorAll("form");for(let e=0;e<s.length;e++){let t=s[e];t.addEventListener("keydown",e=>{27==e.keyCode?(e.preventDefault(),o(null)):13==e.keyCode&&(e.preventDefault(),o(t))}),t.addEventListener("submit",e=>{e.preventDefault(),o(t)})}let r=Rn("div",i,Rn("button",{onclick:()=>o(null),"aria-label":e.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));t.class&&(r.className=t.class);function o(t){r.contains(r.ownerDocument.activeElement)&&e.focus(),n(t)}return r.classList.add("cm-dialog"),{dom:r,top:t.top,mount:()=>{if(t.focus){let e;e="string"==typeof t.focus?i.querySelector(t.focus):i.querySelector("input")||i.querySelector("button"),e&&"select"in e?e.select():e&&"focus"in e&&e.focus()}}}}(e,t,n);e.state.field(hl,!1)?e.dispatch({effects:ul.of(s)}):e.dispatch({effects:Vt.appendConfig.of(hl.init(()=>[s]))});let r=dl.of(s);return{close:r,result:i.then(t=>{let n=e.win.queueMicrotask||(t=>e.win.setTimeout(t,10));return n(()=>{e.state.field(hl).indexOf(s)>-1&&e.dispatch({effects:r})}),t})}}const hl=wt.define({create:()=>[],update(e,t){for(let n of t.effects)n.is(ul)?e=[n.value].concat(e):n.is(dl)&&(e=e.filter(e=>e!=n.value));return e},provide:e=>ll.computeN([e],t=>t.field(e))}),ul=Vt.define(),dl=Vt.define();class fl extends rn{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}fl.prototype.elementClass="",fl.prototype.toDOM=void 0,fl.prototype.mapMode=tt.TrackBefore,fl.prototype.startSide=fl.prototype.endSide=-1,fl.prototype.point=!0;const pl=pt.define(),ml=pt.define(),gl={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>hn.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},bl=pt.define();function yl(e){return[kl(),bl.of({...gl,...e})]}const vl=pt.define({combine:e=>e.some(e=>e)});function kl(e){return[wl]}const wl=bs.fromClass(class{constructor(e){this.view=e,this.domAfter=null,this.prevViewport=e.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=e.state.facet(bl).map(t=>new Al(e,t)),this.fixed=!e.state.facet(vl);for(let e of this.gutters)"after"==e.config.side?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.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(e){if(this.updateGutters(e)){let t=this.prevViewport,n=e.view.viewport,i=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(i<.8*(n.to-n.from))}if(e.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(vl)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=hn.iter(this.view.state.facet(pl),this.view.viewport.from),i=[],s=this.gutters.map(e=>new Cl(e,this.view.viewport,-this.view.documentPadding.top));for(let e of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(e.type)){let t=!0;for(let r of e.type)if(r.type==ni.Text&&t){Sl(n,i,r.from);for(let e of s)e.line(this.view,r,i);t=!1}else if(r.widget)for(let e of s)e.widget(this.view,r)}else if(e.type==ni.Text){Sl(n,i,e.from);for(let t of s)t.line(this.view,e,i)}else if(e.widget)for(let t of s)t.widget(this.view,e);for(let e of s)e.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(bl),n=e.state.facet(bl),i=e.docChanged||e.heightChanged||e.viewportChanged||!hn.eq(e.startState.facet(pl),e.state.facet(pl),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let t of this.gutters)t.update(e)&&(i=!0);else{i=!0;let s=[];for(let i of n){let n=t.indexOf(i);n<0?s.push(new Al(this.view,i)):(this.gutters[n].update(e),s.push(this.gutters[n]))}for(let e of this.gutters)e.dom.remove(),s.indexOf(e)<0&&e.destroy();for(let e of s)"after"==e.config.side?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.gutters=s}return i}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:e=>Uo.scrollMargins.of(t=>{let n=t.plugin(e);if(!n||0==n.gutters.length||!n.fixed)return null;let i=n.dom.offsetWidth*t.scaleX,s=n.domAfter?n.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==Ii.LTR?{left:i,right:s}:{right:i,left:s}})});function xl(e){return Array.isArray(e)?e:[e]}function Sl(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class Cl{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=hn.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:i}=this,s=(t.top-this.height)/e.scaleY,r=t.height/e.scaleY;if(this.i==i.elements.length){let t=new Tl(e,r,s,n);i.elements.push(t),i.dom.appendChild(t.dom)}else i.elements[this.i].update(e,r,s,n);this.height=t.bottom,this.i++}line(e,t,n){let i=[];Sl(this.cursor,i,t.from),n.length&&(i=i.concat(n));let s=this.gutter.config.lineMarker(e,t,i);s&&i.unshift(s);let r=this.gutter;(0!=i.length||r.config.renderEmptyElements)&&this.addElement(e,t,i)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),i=n?[n]:null;for(let n of e.state.facet(ml)){let s=n(e,t.widget,t);s&&(i||(i=[])).push(s)}i&&this.addElement(e,t,i)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class Al{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let n in t.domEventHandlers)this.dom.addEventListener(n,i=>{let s,r=i.target;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let e=r.getBoundingClientRect();s=(e.top+e.bottom)/2}else s=i.clientY;let o=e.lineBlockAtHeight(s-e.documentTop);t.domEventHandlers[n](e,o,i)&&i.preventDefault()});this.markers=xl(t.markers(e)),t.initialSpacer&&(this.spacer=new Tl(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=xl(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let t=this.config.updateSpacer(this.spacer.markers[0],e);t!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[t])}let n=e.view.viewport;return!hn.eq(this.markers,t,n.from,n.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(e)}destroy(){for(let e of this.elements)e.destroy()}}class Tl{constructor(e,t,n,i){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,n,i)}update(e,t,n,i){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),function(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].compare(t[n]))return!1;return!0}(this.markers,i)||this.setMarkers(e,i)}setMarkers(e,t){let n="cm-gutterElement",i=this.dom.firstChild;for(let s=0,r=0;;){let o=r,a=s<t.length?t[s++]:null,l=!1;if(a){let e=a.elementClass;e&&(n+=" "+e);for(let e=r;e<this.markers.length;e++)if(this.markers[e].compare(a)){o=e,l=!0;break}}else o=this.markers.length;for(;r<o;){let e=this.markers[r++];if(e.toDOM){e.destroy(i);let t=i.nextSibling;i.remove(),i=t}}if(!a)break;a.toDOM&&(l?i=i.nextSibling:this.dom.insertBefore(a.toDOM(e),i)),l&&r++}this.dom.className=n,this.markers=t}destroy(){this.setMarkers(null,[])}}const Nl=pt.define(),Ol=pt.define(),Ml=pt.define({combine:e=>sn(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let n=Object.assign({},e);for(let e in t){let i=n[e],s=t[e];n[e]=i?(e,t,n)=>i(e,t,n)||s(e,t,n):s}return n}})});class El extends fl{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Dl(e,t){return e.state.facet(Ml).formatNumber(t,e.state)}const _l=bl.compute([Ml],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:e=>e.state.facet(Nl),lineMarker:(e,t,n)=>n.some(e=>e.toDOM)?null:new El(Dl(e,e.state.doc.lineAt(t.from).number)),widgetMarker:(e,t,n)=>{for(let i of e.state.facet(Ol)){let s=i(e,t,n);if(s)return s}return null},lineMarkerChange:e=>e.startState.facet(Ml)!=e.state.facet(Ml),initialSpacer:e=>new El(Dl(e,Bl(e.state.doc.lines))),updateSpacer(e,t){let n=Dl(t.view,Bl(t.view.state.doc.lines));return n==e.number?e:new El(n)},domEventHandlers:e.facet(Ml).domEventHandlers,side:"before"}));function Il(e={}){return[Ml.of(e),kl(),_l]}function Bl(e){let t=9;for(;t<e;)t=10*t+9;return t}const Pl=new class extends fl{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},Rl=pl.compute(["selection"],e=>{let t=[],n=-1;for(let i of e.selection.ranges){let s=e.doc.lineAt(i.head).from;s>n&&(n=s,t.push(Pl.range(s)))}return hn.of(t)});var $l;const Ll=new s;const zl=new s;class Fl{constructor(e,t,n=[],i=""){this.data=e,this.name=i,nn.prototype.hasOwnProperty("tree")||Object.defineProperty(nn.prototype,"tree",{get(){return Ul(this)}}),this.parser=t,this.extension=[Ql.of(this),nn.languageData.of((e,t,n)=>{let i=jl(e,t,n),s=i.type.prop(Ll);if(!s)return[];let r=e.facet(s),o=i.type.prop(zl);if(o){let s=i.resolve(t-i.from,n);for(let t of o)if(t.test(s,e)){let n=e.facet(t.facet);return"replace"==t.type?n:n.concat(r)}}return r})].concat(n)}isActiveAt(e,t,n=-1){return jl(e,t,n).type.prop(Ll)==this.data}findRegions(e){let t=e.facet(Ql);if((null==t?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],i=(e,t)=>{if(e.prop(Ll)==this.data)return void n.push({from:t,to:t+e.length});let r=e.prop(s.mounted);if(r){if(r.tree.prop(Ll)==this.data){if(r.overlay)for(let e of r.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}if(r.overlay){let e=n.length;if(i(r.tree,r.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let s=e.children[n];s instanceof d&&i(s,e.positions[n]+t)}};return i(Ul(e),0),n}get allowsNesting(){return!0}}function jl(e,t,n){let i=e.facet(Ql),s=Ul(e).topNode;if(!i||i.allowsNesting)for(let e=s;e;e=e.enter(t,n,u.ExcludeBuffers|u.EnterBracketed))e.type.isTop&&(s=e);return s}Fl.setState=Vt.define();class Wl extends Fl{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(e){let t=(n=e.languageData,pt.define({combine:n?e=>e.concat(n):void 0}));var n;return new Wl(t,e.parser.configure({props:[Ll.add(e=>e.isTop?t:void 0)]}),e.name)}configure(e,t){return new Wl(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Ul(e){let t=e.field(Fl.state,!1);return t?t.tree:d.empty}class Vl{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}}let Hl=null;class ql{constructor(e,t,n=[],i,s,r,o,a){this.parser=e,this.state=t,this.fragments=n,this.tree=i,this.treeLen=s,this.viewport=r,this.skipped=o,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new ql(e,t,[],d.empty,0,n,[],null)}startParse(){return this.parser.startParse(new Vl(this.state.doc),this.fragments)}work(e,t){return null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=d.empty&&this.isDone(null!=t?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if("number"==typeof e){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||(this.parse=this.startParse()),null!=t&&(null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let i=this.parse.advance();if(i){if(this.fragments=this.withoutTempSkipped(E.addTree(i,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(n=this.parse.stoppedAt)&&void 0!==n?n:this.state.doc.length,this.tree=i,this.parse=null,!(this.treeLen<(null!=t?t:this.state.doc.length)))return!0;this.parse=this.startParse()}if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(E.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Hl;Hl=this;try{return e()}finally{Hl=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Kl(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:i,treeLen:s,viewport:r,skipped:o}=this;if(this.takeTree(),!e.empty){let t=[];if(e.iterChangedRanges((e,n,i,s)=>t.push({fromA:e,toA:n,fromB:i,toB:s})),n=E.applyChanges(n,t),i=d.empty,s=0,r={from:e.mapPos(r.from,-1),to:e.mapPos(r.to,1)},this.skipped.length){o=[];for(let t of this.skipped){let n=e.mapPos(t.from,1),i=e.mapPos(t.to,-1);n<i&&o.push({from:n,to:i})}}}return new ql(this.parser,t,n,i,s,r,o,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let t=0;t<this.skipped.length;t++){let{from:n,to:i}=this.skipped[t];n<e.to&&i>e.from&&(this.fragments=Kl(this.fragments,n,i),this.skipped.splice(t--,1))}return!(this.skipped.length>=t)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends D{createParse(t,n,i){let s=i[0].from,r=i[i.length-1].to,o={parsedPos:s,advance(){let t=Hl;if(t){for(let e of i)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=r,new d(a.none,[],[],r-s)},stoppedAt:null,stopAt(){}};return o}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&0==t[0].from&&t[0].to>=e}static get(){return Hl}}function Kl(e,t,n){return E.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class Jl{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new Jl(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=ql.create(e.facet(Ql).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new Jl(n)}}Fl.state=wt.define({create:Jl.init,update(e,t){for(let e of t.effects)if(e.is(Fl.setState))return e.value;return t.startState.facet(Ql)!=t.state.facet(Ql)?Jl.init(t.state):e.apply(t)}});let Zl=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};"undefined"!=typeof requestIdleCallback&&(Zl=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const Yl="undefined"!=typeof navigator&&(null===($l=navigator.scheduling)||void 0===$l?void 0:$l.isInputPending)?()=>navigator.scheduling.isInputPending():null,Gl=bs.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(Fl.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(Fl.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=Zl(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:i}}=this.view,s=n.field(Fl.state);if(s.tree==s.context.tree&&s.context.isDone(i+1e5))return;let r=Date.now()+Math.min(this.chunkBudget,100,e&&!Yl?Math.max(25,e.timeRemaining()-5):1e9),o=s.context.treeLen<i&&n.doc.length>i+1e3,a=s.context.work(()=>Yl&&Yl()||Date.now()>r,i+(o?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Fl.setState.of(new Jl(s.context))})),this.chunkBudget>0&&(!a||o)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>fs(this.view.state,e)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Ql=pt.define({combine:e=>e.length?e[0]:null,enables:e=>[Fl.state,Gl,Uo.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});class Xl{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const ec=pt.define(),tc=pt.define({combine:e=>{if(!e.length)return" ";let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return t}});function nc(e){let t=e.facet(tc);return 9==t.charCodeAt(0)?e.tabSize*t.length:t.length}function ic(e,t){let n="",i=e.tabSize,s=e.facet(tc)[0];if("\t"==s){for(;t>=i;)n+="\t",t-=i;s=" "}for(let e=0;e<t;e++)n+=s;return n}function sc(e,t){e instanceof nn&&(e=new rc(e));for(let n of e.state.facet(ec)){let i=n(e,t);if(void 0!==i)return i}let n=Ul(e.state);return n.length>=t?function(e,t,n){let i=t.resolveStack(n),s=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(s!=i.node){let e=[];for(let t=s;t&&!(t.from<i.node.from||t.to>i.node.to||t.from==i.node.from&&t.type==i.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)i={node:e[t],next:i}}return ac(i,e,n)}(e,n,t):null}class rc{constructor(e,t={}){this.state=e,this.options=t,this.unit=nc(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:i,simulateDoubleBreak:s}=this.options;return null!=i&&i>=n.from&&i<=n.to?s&&i==e?{text:"",from:e}:(t<0?i<e:i<=e)?{text:n.text.slice(i-n.from),from:i}:{text:n.text.slice(0,i-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:i}=this.lineAt(e,t);return n.slice(e-i,Math.min(n.length,e+100-i))}column(e,t=1){let{text:n,from:i}=this.lineAt(e,t),s=this.countColumn(n,e-i),r=this.options.overrideIndentation?this.options.overrideIndentation(i):-1;return r>-1&&(s+=r-this.countColumn(n,n.search(/\S|$/))),s}countColumn(e,t=e.length){return xn(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:i}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let e=s(i);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const oc=new s;function ac(e,t,n){for(let i=e;i;i=i.next){let e=lc(i.node);if(e)return e(hc.create(t,n,i))}return 0}function lc(e){let t=e.type.prop(oc);if(t)return t;let n,i=e.firstChild;if(i&&(n=i.type.prop(s.closedBy))){let t=e.lastChild,i=t&&n.indexOf(t.name)>-1;return e=>function(e,t,n,i,s){let r=e.textAfter,o=r.match(/^\s*/)[0].length,a=i&&r.slice(o,o+i.length)==i||s==e.pos+o,l=function(e){let t=e.node,n=t.childAfter(t.from),i=t.lastChild;if(!n)return null;let s=e.options.simulateBreak,r=e.state.doc.lineAt(n.from),o=null==s||s<=r.from?r.to:Math.min(r.to,s);for(let e=n.to;;){let s=t.childAfter(e);if(!s||s==i)return null;if(!s.type.isSkipped){if(s.from>=o)return null;let e=/^ */.exec(r.text.slice(n.to-r.from))[0].length;return{from:n.from,to:n.to+e}}e=s.to}}(e);return l?a?e.column(l.from):e.column(l.to):e.baseIndent+(a?0:e.unit*n)}(e,0,1,void 0,i&&!function(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}(e)?t.from:void 0)}return null==e.parent?cc:null}function cc(){return 0}class hc extends rc{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(e,t,n){return new hc(e,t,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(uc(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return ac(this.context.next,this.base,this.pos)}}function uc(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function dc({except:e,units:t=1}={}){return n=>{let i=e&&e.test(n.textAfter);return n.baseIndent+(i?0:t*n.unit)}}const fc=pt.define(),pc=new s;function mc(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function gc(e,t,n){for(let i of e.facet(fc)){let s=i(e,t,n);if(s)return s}return function(e,t,n){let i=Ul(e);if(i.length<n)return null;let s=null;for(let r=i.resolveStack(n,1);r;r=r.next){let o=r.node;if(o.to<=n||o.from>n)continue;if(s&&o.from<t)break;let a=o.type.prop(pc);if(a&&(o.to<i.length-50||i.length==e.doc.length||!mc(o))){let i=a(o,e);i&&i.from<=n&&i.from>=t&&i.to>n&&(s=i)}}return s}(e,t,n)}function bc(e,t){let n=t.mapPos(e.from,1),i=t.mapPos(e.to,-1);return n>=i?void 0:{from:n,to:i}}const yc=Vt.define({map:bc}),vc=Vt.define({map:bc});function kc(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(e=>e.from<=n&&e.to>=n)||t.push(e.lineBlockAt(n));return t}const wc=wt.define({create:()=>ii.none,update(e,t){t.isUserEvent("delete")&&t.changes.iterChangedRanges((t,n)=>e=xc(e,t,n)),e=e.map(t.changes);for(let n of t.effects)if(n.is(yc)&&!Cc(e,n.value.from,n.value.to)){let{preparePlaceholder:i}=t.state.facet(Mc),s=i?ii.replace({widget:new Ic(i(t.state,n.value))}):_c;e=e.update({add:[s.range(n.value.from,n.value.to)]})}else n.is(vc)&&(e=e.update({filter:(e,t)=>n.value.from!=e||n.value.to!=t,filterFrom:n.value.from,filterTo:n.value.to}));return t.selection&&(e=xc(e,t.selection.main.head)),e},provide:e=>Uo.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(e,t)=>{n.push(e,t)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw new RangeError("Invalid JSON for fold state");let t=[];for(let n=0;n<e.length;){let i=e[n++],s=e[n++];if("number"!=typeof i||"number"!=typeof s)throw new RangeError("Invalid JSON for fold state");t.push(_c.range(i,s))}return ii.set(t,!0)}});function xc(e,t,n=t){let i=!1;return e.between(t,n,(e,s)=>{e<n&&s>t&&(i=!0)}),i?e.update({filterFrom:t,filterTo:n,filter:(e,i)=>e>=n||i<=t}):e}function Sc(e,t,n){var i;let s=null;return null===(i=e.field(wc,!1))||void 0===i||i.between(t,n,(e,t)=>{(!s||s.from>e)&&(s={from:e,to:t})}),s}function Cc(e,t,n){let i=!1;return e.between(t,t,(e,s)=>{e==t&&s==n&&(i=!0)}),i}function Ac(e,t){return e.field(wc,!1)?t:t.concat(Vt.appendConfig.of(Ec()))}function Tc(e,t,n=!0){let i=e.state.doc.lineAt(t.from).number,s=e.state.doc.lineAt(t.to).number;return Uo.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${i} ${e.state.phrase("to")} ${s}.`)}const Nc=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:e=>{for(let t of kc(e)){let n=gc(e.state,t.from,t.to);if(n)return e.dispatch({effects:Ac(e.state,[yc.of(n),Tc(e,n)])}),!0}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:e=>{if(!e.state.field(wc,!1))return!1;let t=[];for(let n of kc(e)){let i=Sc(e.state,n.from,n.to);i&&t.push(vc.of(i),Tc(e,i,!1))}return t.length&&e.dispatch({effects:t}),t.length>0}},{key:"Ctrl-Alt-[",run:e=>{let{state:t}=e,n=[];for(let i=0;i<t.doc.length;){let s=e.lineBlockAt(i),r=gc(t,s.from,s.to);r&&n.push(yc.of(r)),i=(r?e.lineBlockAt(r.to):s).to+1}return n.length&&e.dispatch({effects:Ac(e.state,n)}),!!n.length}},{key:"Ctrl-Alt-]",run:e=>{let t=e.state.field(wc,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(e,t)=>{n.push(vc.of({from:e,to:t}))}),e.dispatch({effects:n}),!0}}],Oc={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Mc=pt.define({combine:e=>sn(e,Oc)});function Ec(e){return[wc,$c]}function Dc(e,t){let{state:n}=e,i=n.facet(Mc),s=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),i=Sc(e.state,n.from,n.to);i&&e.dispatch({effects:vc.of(i)}),t.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(e,s,t);let r=document.createElement("span");return r.textContent=i.placeholderText,r.setAttribute("aria-label",n.phrase("folded code")),r.title=n.phrase("unfold"),r.className="cm-foldPlaceholder",r.onclick=s,r}const _c=ii.replace({widget:new class extends ti{toDOM(e){return Dc(e,null)}}});class Ic extends ti{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return Dc(e,this.value)}}const Bc={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class Pc extends fl{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function Rc(e={}){let t={...Bc,...e},n=new Pc(t,!0),i=new Pc(t,!1),s=bs.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(Ql)!=e.state.facet(Ql)||e.startState.field(wc,!1)!=e.state.field(wc,!1)||Ul(e.startState)!=Ul(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new un;for(let s of e.viewportLineBlocks){let r=Sc(e.state,s.from,s.to)?i:gc(e.state,s.from,s.to)?n:null;r&&t.add(s.from,s.from,r)}return t.finish()}}),{domEventHandlers:r}=t;return[s,yl({class:"cm-foldGutter",markers(e){var t;return(null===(t=e.plugin(s))||void 0===t?void 0:t.markers)||hn.empty},initialSpacer:()=>new Pc(t,!1),domEventHandlers:{...r,click:(e,t,n)=>{if(r.click&&r.click(e,t,n))return!0;let i=Sc(e.state,t.from,t.to);if(i)return e.dispatch({effects:vc.of(i)}),!0;let s=gc(e.state,t.from,t.to);return!!s&&(e.dispatch({effects:yc.of(s)}),!0)}}}),Ec()]}const $c=Uo.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 Lc{constructor(e,t){let n;function i(e){let t=Nn.newName();return(n||(n=Object.create(null)))["."+t]=e,t}this.specs=e;const s="string"==typeof t.all?t.all:t.all?i(t.all):void 0,r=t.scope;this.scope=r instanceof Fl?e=>e.prop(Ll)==r.data:r?e=>e==r:void 0,this.style=le(e.map(e=>({tag:e.tag,class:e.class||i(Object.assign({},e,{tag:null}))})),{all:s}).style,this.module=n?new Nn(n):null,this.themeType=t.themeType}static define(e,t){return new Lc(e,t||{})}}const zc=pt.define(),Fc=pt.define({combine:e=>e.length?[e[0]]:null});function jc(e){let t=e.facet(zc);return t.length?t:e.facet(Fc)}function Wc(e,t){let n,i=[Vc];return e instanceof Lc&&(e.module&&i.push(Uo.styleModule.of(e.module)),n=e.themeType),(null==t?void 0:t.fallback)?i.push(Fc.of(e)):n?i.push(zc.computeN([Uo.darkTheme],t=>t.facet(Uo.darkTheme)==("dark"==n)?[e]:[])):i.push(zc.of(e)),i}class Uc{constructor(e){this.markCache=Object.create(null),this.tree=Ul(e.state),this.decorations=this.buildDeco(e,jc(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=Ul(e.state),n=jc(e.state),i=n!=jc(e.startState),{viewport:s}=e.view,r=e.changes.mapPos(this.decoratedTo,1);t.length<s.to&&!i&&t.type==this.tree.type&&r>=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=r):(t!=this.tree||e.viewportChanged||i)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=s.to)}buildDeco(e,t){if(!t||!this.tree.length)return ii.none;let n=new un;for(let{from:i,to:s}of e.visibleRanges)ce(this.tree,t,(e,t,i)=>{n.add(e,t,this.markCache[i]||(this.markCache[i]=ii.mark({class:i})))},i,s);return n.finish()}}const Vc=Nt.high(bs.fromClass(Uc,{decorations:e=>e.decorations})),Hc=Lc.define([{tag:Te.meta,color:"#404740"},{tag:Te.link,textDecoration:"underline"},{tag:Te.heading,textDecoration:"underline",fontWeight:"bold"},{tag:Te.emphasis,fontStyle:"italic"},{tag:Te.strong,fontWeight:"bold"},{tag:Te.strikethrough,textDecoration:"line-through"},{tag:Te.keyword,color:"#708"},{tag:[Te.atom,Te.bool,Te.url,Te.contentSeparator,Te.labelName],color:"#219"},{tag:[Te.literal,Te.inserted],color:"#164"},{tag:[Te.string,Te.deleted],color:"#a11"},{tag:[Te.regexp,Te.escape,Te.special(Te.string)],color:"#e40"},{tag:Te.definition(Te.variableName),color:"#00f"},{tag:Te.local(Te.variableName),color:"#30a"},{tag:[Te.typeName,Te.namespace],color:"#085"},{tag:Te.className,color:"#167"},{tag:[Te.special(Te.variableName),Te.macroName],color:"#256"},{tag:Te.definition(Te.propertyName),color:"#00c"},{tag:Te.comment,color:"#940"},{tag:Te.invalid,color:"#f00"}]),qc=Uo.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Kc="()[]{}",Jc=pt.define({combine:e=>sn(e,{afterCursor:!0,brackets:Kc,maxScanDistance:1e4,renderMatch:Gc})}),Zc=ii.mark({class:"cm-matchingBracket"}),Yc=ii.mark({class:"cm-nonmatchingBracket"});function Gc(e){let t=[],n=e.matched?Zc:Yc;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}function Qc(e){let t=[],n=e.facet(Jc);for(let i of e.selection.ranges){if(!i.empty)continue;let s=rh(e,i.head,-1,n)||i.head>0&&rh(e,i.head-1,1,n)||n.afterCursor&&(rh(e,i.head,1,n)||i.head<e.doc.length&&rh(e,i.head+1,-1,n));s&&(t=t.concat(n.renderMatch(s,e)))}return ii.set(t,!0)}const Xc=bs.fromClass(class{constructor(e){this.paused=!1,this.decorations=Qc(e.state)}update(e){(e.docChanged||e.selectionSet||this.paused)&&(e.view.composing?(this.decorations=this.decorations.map(e.changes),this.paused=!0):(this.decorations=Qc(e.state),this.paused=!1))}},{decorations:e=>e.decorations}),eh=[Xc,qc];function th(e={}){return[Jc.of(e),eh]}const nh=new s;function ih(e,t,n){let i=e.prop(t<0?s.openedBy:s.closedBy);if(i)return i;if(1==e.name.length){let i=n.indexOf(e.name);if(i>-1&&i%2==(t<0?1:0))return[n[i+t]]}return null}function sh(e){let t=e.type.prop(nh);return t?t(e.node):e}function rh(e,t,n,i={}){let s=i.maxScanDistance||1e4,r=i.brackets||Kc,o=Ul(e),a=o.resolveInner(t,n);for(let i=a;i;i=i.parent){let s=ih(i.type,n,r);if(s&&i.from<i.to){let o=sh(i);if(o&&(n>0?t>=o.from&&t<o.to:t>o.from&&t<=o.to))return oh(e,t,n,i,o,s,r)}}return function(e,t,n,i,s,r,o){if(n<0?!t:t==e.doc.length)return null;let a=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),l=o.indexOf(a);if(l<0||l%2==0!=n>0)return null;let c={from:n<0?t-1:t,to:n>0?t+1:t},h=e.doc.iterRange(t,n>0?e.doc.length:0),u=0;for(let e=0;!h.next().done&&e<=r;){let r=h.value;n<0&&(e+=r.length);let a=t+e*n;for(let e=n>0?0:r.length-1,t=n>0?r.length:-1;e!=t;e+=n){let t=o.indexOf(r[e]);if(!(t<0||i.resolveInner(a+e,1).type!=s))if(t%2==0==n>0)u++;else{if(1==u)return{start:c,end:{from:a+e,to:a+e+1},matched:t>>1==l>>1};u--}}n>0&&(e+=r.length)}return h.done?{start:c,matched:!1}:null}(e,t,n,o,a.type,s,r)}function oh(e,t,n,i,s,r,o){let a=i.parent,l={from:s.from,to:s.to},c=0,h=null==a?void 0:a.cursor();if(h&&(n<0?h.childBefore(i.from):h.childAfter(i.to)))do{if(n<0?h.to<=i.from:h.from>=i.to){if(0==c&&r.indexOf(h.type.name)>-1&&h.from<h.to){let e=sh(h);return{start:l,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}if(ih(h.type,n,o))c++;else if(ih(h.type,-n,o)){if(0==c){let e=sh(h);return{start:l,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}c--}}}while(n<0?h.prevSibling():h.nextSibling());return{start:l,matched:!1}}const ah=Object.create(null),lh=[a.none],ch=[],hh=Object.create(null),uh=Object.create(null);for(let[e,t]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"]])uh[e]=fh(ah,t);function dh(e,t){ch.indexOf(e)>-1||(ch.push(e),console.warn(t))}function fh(e,t){let n=[];for(let i of t.split(" ")){let t=[];for(let n of i.split(".")){let i=e[n]||Te[n];i?"function"==typeof i?t.length?t=t.map(i):dh(n,`Modifier ${n} used at start of tag`):t.length?dh(n,`Tag ${n} used as modifier`):t=Array.isArray(i)?i:[i]:dh(n,`Unknown highlighting tag ${n}`)}for(let e of t)n.push(e)}if(!n.length)return 0;let i=t.replace(/ /g,"_"),s=i+" "+n.map(e=>e.id),r=hh[s];if(r)return r.id;let o=hh[s]=a.define({id:lh.length,name:i,props:[re({[i]:n})]});return lh.push(o),o.id}Ii.RTL,Ii.LTR;const ph=Wl.define({name:"json",parser:Oe.configure({props:[oc.add({Object:dc({except:/^\s*\}/}),Array:dc({except:/^\s*\]/})}),pc.add({"Object Array":function(e){let t=e.firstChild,n=e.lastChild;return t&&t.to<n.from?{from:t.to,to:n.type.isError?e.to:n.from}:null}})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function mh(){return new Xl(ph)}function gh(e,t){return({state:n,dispatch:i})=>{if(n.readOnly)return!1;let s=e(t,n);return!!s&&(i(n.update(s)),!0)}}const bh=gh(Sh,0),yh=gh(xh,0),vh=gh((e,t)=>xh(e,t,function(e){let t=[];for(let n of e.selection.ranges){let i=e.doc.lineAt(n.from),s=n.to<=i.to?i:e.doc.lineAt(n.to);s.from>i.from&&s.from==n.to&&(s=n.to==i.to+1?i:e.doc.lineAt(n.to-1));let r=t.length-1;r>=0&&t[r].to>i.from?t[r].to=s.to:t.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:s.to})}return t}(t)),0);function kh(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}const wh=50;function xh(e,t,n=t.selection.ranges){let i=n.map(e=>kh(t,e.from).block);if(!i.every(e=>e))return null;let s=n.map((e,n)=>function(e,{open:t,close:n},i,s){let r,o,a=e.sliceDoc(i-wh,i),l=e.sliceDoc(s,s+wh),c=/\s*$/.exec(a)[0].length,h=/^\s*/.exec(l)[0].length,u=a.length-c;if(a.slice(u-t.length,u)==t&&l.slice(h,h+n.length)==n)return{open:{pos:i-c,margin:c&&1},close:{pos:s+h,margin:h&&1}};s-i<=2*wh?r=o=e.sliceDoc(i,s):(r=e.sliceDoc(i,i+wh),o=e.sliceDoc(s-wh,s));let d=/^\s*/.exec(r)[0].length,f=/\s*$/.exec(o)[0].length,p=o.length-f-n.length;return r.slice(d,d+t.length)==t&&o.slice(p,p+n.length)==n?{open:{pos:i+d+t.length,margin:/\s/.test(r.charAt(d+t.length))?1:0},close:{pos:s-f-n.length,margin:/\s/.test(o.charAt(p-1))?1:0}}:null}(t,i[n],e.from,e.to));if(2!=e&&!s.every(e=>e))return{changes:t.changes(n.map((e,t)=>s[t]?[]:[{from:e.from,insert:i[t].open+" "},{from:e.to,insert:" "+i[t].close}]))};if(1!=e&&s.some(e=>e)){let e=[];for(let t,n=0;n<s.length;n++)if(t=s[n]){let s=i[n],{open:r,close:o}=t;e.push({from:r.pos-s.open.length,to:r.pos+r.margin},{from:o.pos-o.margin,to:o.pos+s.close.length})}return{changes:e}}return null}function Sh(e,t,n=t.selection.ranges){let i=[],s=-1;e:for(let{from:e,to:r}of n){let n,o=i.length,a=1e9;for(let o=e;o<=r;){let l=t.doc.lineAt(o);if(null==n&&(n=kh(t,l.from).line,!n))continue e;if(l.from>s&&(e==r||r>l.from)){s=l.from;let e=/^\s*/.exec(l.text)[0].length,t=e==l.length,r=l.text.slice(e,e+n.length)==n?e:-1;e<l.text.length&&e<a&&(a=e),i.push({line:l,comment:r,token:n,indent:e,empty:t,single:!1})}o=l.to+1}if(a<1e9)for(let e=o;e<i.length;e++)i[e].indent<i[e].line.text.length&&(i[e].indent=a);i.length==o+1&&(i[o].single=!0)}if(2!=e&&i.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:s,empty:r,single:o}of i)!o&&r||e.push({from:t.from+s,insert:n+" "});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(1!=e&&i.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:s}of i)if(n>=0){let i=t.from+n,r=i+s.length;" "==t.text[r-t.from]&&r++,e.push({from:i,to:r})}return{changes:e}}return null}const Ch=jt.define(),Ah=jt.define(),Th=pt.define(),Nh=pt.define({combine:e=>sn(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,i)=>e(n,i)||t(n,i)})}),Oh=wt.define({create:()=>Hh.empty,update(e,t){let n=t.state.facet(Nh),i=t.annotation(Ch);if(i){let s=Ph.fromTransaction(t,i.selection),r=i.side,o=0==r?e.undone:e.done;return o=s?Rh(o,o.length,n.minDepth,s):Fh(o,t.startState.selection),new Hh(0==r?i.rest:o,0==r?o:i.rest)}let s=t.annotation(Ah);if("full"!=s&&"before"!=s||(e=e.isolate()),!1===t.annotation(Ht.addToHistory))return t.changes.empty?e:e.addMapping(t.changes.desc);let r=Ph.fromTransaction(t),o=t.annotation(Ht.time),a=t.annotation(Ht.userEvent);return r?e=e.addChanges(r,o,a,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,a,n.newGroupDelay)),"full"!=s&&"after"!=s||(e=e.isolate()),e},toJSON:e=>({done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}),fromJSON:e=>new Hh(e.done.map(Ph.fromJSON),e.undone.map(Ph.fromJSON))});function Mh(e={}){return[Oh,Nh.of(e),Uo.domEventHandlers({beforeinput(e,t){let n="historyUndo"==e.inputType?Dh:"historyRedo"==e.inputType?_h:null;return!!n&&(e.preventDefault(),n(t))}})]}function Eh(e,t){return function({state:n,dispatch:i}){if(!t&&n.readOnly)return!1;let s=n.field(Oh,!1);if(!s)return!1;let r=s.pop(e,n,t);return!!r&&(i(r),!0)}}const Dh=Eh(0,!1),_h=Eh(1,!1),Ih=Eh(0,!0),Bh=Eh(1,!0);class Ph{constructor(e,t,n,i,s){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=i,this.selectionsAfter=s}setSelAfter(e){return new Ph(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:null===(e=this.changes)||void 0===e?void 0:e.toJSON(),mapped:null===(t=this.mapped)||void 0===t?void 0:t.toJSON(),startSelection:null===(n=this.startSelection)||void 0===n?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(e){return new Ph(e.changes&&it.fromJSON(e.changes),[],e.mapped&&nt.fromJSON(e.mapped),e.startSelection&&ut.fromJSON(e.startSelection),e.selectionsAfter.map(ut.fromJSON))}static fromTransaction(e,t){let n=Lh;for(let t of e.startState.facet(Th)){let i=t(e);i.length&&(n=n.concat(i))}return!n.length&&e.changes.empty?null:new Ph(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,Lh)}static selection(e){return new Ph(void 0,Lh,void 0,void 0,e)}}function Rh(e,t,n,i){let s=t+1>n+20?t-n-1:0,r=e.slice(s,t);return r.push(i),r}function $h(e,t){return e.length?t.length?e.concat(t):e:t}const Lh=[],zh=200;function Fh(e,t){if(e.length){let n=e[e.length-1],i=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-zh));return i.length&&i[i.length-1].eq(t)?e:(i.push(t),Rh(e,e.length-1,1e9,n.setSelAfter(i)))}return[Ph.selection([t])]}function jh(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function Wh(e,t){if(!e.length)return e;let n=e.length,i=Lh;for(;n;){let s=Uh(e[n-1],t,i);if(s.changes&&!s.changes.empty||s.effects.length){let t=e.slice(0,n);return t[n-1]=s,t}t=s.mapped,n--,i=s.selectionsAfter}return i.length?[Ph.selection(i)]:Lh}function Uh(e,t,n){let i=$h(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):Lh,n);if(!e.changes)return Ph.selection(i);let s=e.changes.map(t),r=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(r):r;return new Ph(s,Vt.mapEffects(e.effects,t),o,e.startSelection.map(r),i)}const Vh=/^(input\.type|delete)($|\.)/;class Hh{constructor(e,t,n=0,i=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=i}isolate(){return this.prevTime?new Hh(this.done,this.undone):this}addChanges(e,t,n,i,s){let r=this.done,o=r[r.length-1];return r=o&&o.changes&&!o.changes.empty&&e.changes&&(!n||Vh.test(n))&&(!o.selectionsAfter.length&&t-this.prevTime<i.newGroupDelay&&i.joinToEvent(s,function(e,t){let n=[],i=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,s,r)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];r>=t&&s<=o&&(i=!0)}}),i}(o.changes,e.changes))||"input.type.compose"==n)?Rh(r,r.length-1,i.minDepth,new Ph(e.changes.compose(o.changes),$h(Vt.mapEffects(e.effects,o.changes),o.effects),o.mapped,o.startSelection,Lh)):Rh(r,r.length,i.minDepth,e),new Hh(r,Lh,t,n)}addSelection(e,t,n,i){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:Lh;return s.length>0&&t-this.prevTime<i&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&function(e,t){return e.ranges.length==t.ranges.length&&0===e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length}(s[s.length-1],e)?this:new Hh(Fh(this.done,e),this.undone,t,n)}addMapping(e){return new Hh(Wh(this.done,e),Wh(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let i=0==e?this.done:this.undone;if(0==i.length)return null;let s=i[i.length-1],r=s.selectionsAfter[0]||(s.startSelection?s.startSelection.map(s.changes.invertedDesc,1):t.selection);if(n&&s.selectionsAfter.length)return t.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:Ch.of({side:e,rest:jh(i),selection:r}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let n=1==i.length?Lh:i.slice(0,i.length-1);return s.mapped&&(n=Wh(n,s.mapped)),t.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:Ch.of({side:e,rest:n,selection:r}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}return null}}Hh.empty=new Hh(Lh,Lh);const qh=[{key:"Mod-z",run:Dh,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:_h,preventDefault:!0},{linux:"Ctrl-Shift-z",run:_h,preventDefault:!0},{key:"Mod-u",run:Ih,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Bh,preventDefault:!0}];function Kh(e,t){return ut.create(e.ranges.map(t),e.mainIndex)}function Jh(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function Zh({state:e,dispatch:t},n){let i=Kh(e.selection,n);return!i.eq(e.selection,!0)&&(t(Jh(e,i)),!0)}function Yh(e,t){return ut.cursor(t?e.to:e.from)}function Gh(e,t){return Zh(e,n=>n.empty?e.moveByChar(n,t):Yh(n,t))}function Qh(e){return e.textDirectionAt(e.state.selection.main.head)==Ii.LTR}const Xh=e=>Gh(e,!Qh(e)),eu=e=>Gh(e,Qh(e));function tu(e,t){return Zh(e,n=>n.empty?e.moveByGroup(n,t):Yh(n,t))}function nu(e,t,n){if(t.type.prop(n))return!0;let i=t.to-t.from;return i&&(i>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function iu(e,t,n){let i,r,o=Ul(e).resolveInner(t.head),a=n?s.closedBy:s.openedBy;for(let i=t.head;;){let t=n?o.childAfter(i):o.childBefore(i);if(!t)break;nu(e,t,a)?o=t:i=n?t.to:t.from}return r=o.type.prop(a)&&(i=n?rh(e,o.from,1):rh(e,o.to,-1))&&i.matched?n?i.end.to:i.end.from:n?o.to:o.from,ut.cursor(r,n?-1:1)}function su(e,t){return Zh(e,n=>{if(!n.empty)return Yh(n,t);let i=e.moveVertically(n,t);return i.head!=n.head?i:e.moveToLineBoundary(n,t)})}const ru=e=>su(e,!1),ou=e=>su(e,!0);function au(e){let t,n=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,i=0,s=0;if(n){for(let t of e.state.facet(Uo.scrollMargins)){let n=t(e);(null==n?void 0:n.top)&&(i=Math.max(null==n?void 0:n.top,i)),(null==n?void 0:n.bottom)&&(s=Math.max(null==n?void 0:n.bottom,s))}t=e.scrollDOM.clientHeight-i-s}else t=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:i,marginBottom:s,selfScroll:n,height:Math.max(e.defaultLineHeight,t-5)}}function lu(e,t){let n,i=au(e),{state:s}=e,r=Kh(s.selection,n=>n.empty?e.moveVertically(n,t,i.height):Yh(n,t));if(r.eq(s.selection))return!1;if(i.selfScroll){let t=e.coordsAtPos(s.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),a=o.top+i.marginTop,l=o.bottom-i.marginBottom;t&&t.top>a&&t.bottom<l&&(n=Uo.scrollIntoView(r.main.head,{y:"start",yMargin:t.top-a}))}return e.dispatch(Jh(s,r),{effects:n}),!0}const cu=e=>lu(e,!1),hu=e=>lu(e,!0);function uu(e,t,n){let i=e.lineBlockAt(t.head),s=e.moveToLineBoundary(t,n);if(s.head==t.head&&s.head!=(n?i.to:i.from)&&(s=e.moveToLineBoundary(t,n,!1)),!n&&s.head==i.from&&i.length){let n=/^\s*/.exec(e.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;n&&t.head!=i.from+n&&(s=ut.cursor(i.from+n))}return s}function du(e,t){let n=Kh(e.state.selection,e=>{let n=t(e);return ut.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return!n.eq(e.state.selection)&&(e.dispatch(Jh(e.state,n)),!0)}function fu(e,t){return du(e,n=>e.moveByChar(n,t))}const pu=e=>fu(e,!Qh(e)),mu=e=>fu(e,Qh(e));function gu(e,t){return du(e,n=>e.moveByGroup(n,t))}function bu(e,t){return du(e,n=>e.moveVertically(n,t))}const yu=e=>bu(e,!1),vu=e=>bu(e,!0);function ku(e,t){return du(e,n=>e.moveVertically(n,t,au(e).height))}const wu=e=>ku(e,!1),xu=e=>ku(e,!0),Su=({state:e,dispatch:t})=>(t(Jh(e,{anchor:0})),!0),Cu=({state:e,dispatch:t})=>(t(Jh(e,{anchor:e.doc.length})),!0),Au=({state:e,dispatch:t})=>(t(Jh(e,{anchor:e.selection.main.anchor,head:0})),!0),Tu=({state:e,dispatch:t})=>(t(Jh(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0);function Nu(e,t){let{state:n}=e,i=n.selection,s=n.selection.ranges.slice();for(let i of n.selection.ranges){let r=n.doc.lineAt(i.head);if(t?r.to<e.state.doc.length:r.from>0)for(let n=i;;){let i=e.moveVertically(n,t);if(i.head<r.from||i.head>r.to){s.some(e=>e.head==i.head)||s.push(i);break}if(i.head==n.head)break;n=i}}return s.length!=i.ranges.length&&(e.dispatch(Jh(n,ut.create(s,s.length-1))),!0)}function Ou(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:i}=e,s=i.changeByRange(i=>{let{from:s,to:r}=i;if(s==r){let o=t(i);o<s?(n="delete.backward",o=Mu(e,o,!1)):o>s&&(n="delete.forward",o=Mu(e,o,!0)),s=Math.min(s,o),r=Math.max(r,o)}else s=Mu(e,s,!1),r=Mu(e,r,!0);return s==r?{range:i}:{changes:{from:s,to:r},range:ut.cursor(s,s<i.head?-1:1)}});return!s.changes.empty&&(e.dispatch(i.update(s,{scrollIntoView:!0,userEvent:n,effects:"delete.selection"==n?Uo.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function Mu(e,t,n){if(e instanceof Uo)for(let i of e.state.facet(Uo.atomicRanges).map(t=>t(e)))i.between(t,t,(e,i)=>{e<t&&i>t&&(t=n?i:e)});return t}const Eu=(e,t,n)=>Ou(e,i=>{let s,r,o=i.from,{state:a}=e,l=a.doc.lineAt(o);if(n&&!t&&o>l.from&&o<l.from+200&&!/[^ \t]/.test(s=l.text.slice(0,o-l.from))){if("\t"==s[s.length-1])return o-1;let e=xn(s,a.tabSize)%nc(a)||nc(a);for(let t=0;t<e&&" "==s[s.length-1-t];t++)o--;r=o}else r=Ye(l.text,o-l.from,t,t)+l.from,r==o&&l.number!=(t?a.doc.lines:1)?r+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(l.text.slice(r-l.from,o-l.from))&&(r=Ye(l.text,r-l.from,!1,!1)+l.from);return r}),Du=e=>Eu(e,!1,!0),_u=e=>Eu(e,!0,!1),Iu=(e,t)=>Ou(e,n=>{let i=n.head,{state:s}=e,r=s.doc.lineAt(i),o=s.charCategorizer(i);for(let e=null;;){if(i==(t?r.to:r.from)){i==n.head&&r.number!=(t?s.doc.lines:1)&&(i+=t?1:-1);break}let a=Ye(r.text,i-r.from,t)+r.from,l=r.text.slice(Math.min(i,a)-r.from,Math.max(i,a)-r.from),c=o(l);if(null!=e&&c!=e)break;" "==l&&i==n.head||(e=c),i=a}return i}),Bu=e=>Iu(e,!1);function Pu(e){let t=[],n=-1;for(let i of e.selection.ranges){let s=e.doc.lineAt(i.from),r=e.doc.lineAt(i.to);if(i.empty||i.to!=r.from||(r=e.doc.lineAt(i.to-1)),n>=s.number){let e=t[t.length-1];e.to=r.to,e.ranges.push(i)}else t.push({from:s.from,to:r.to,ranges:[i]});n=r.number+1}return t}function Ru(e,t,n){if(e.readOnly)return!1;let i=[],s=[];for(let t of Pu(e)){if(n?t.to==e.doc.length:0==t.from)continue;let r=e.doc.lineAt(n?t.to+1:t.from-1),o=r.length+1;if(n){i.push({from:t.to,to:r.to},{from:t.from,insert:r.text+e.lineBreak});for(let n of t.ranges)s.push(ut.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{i.push({from:r.from,to:t.from},{from:t.to,insert:e.lineBreak+r.text});for(let e of t.ranges)s.push(ut.range(e.anchor-o,e.head-o))}}return!!i.length&&(t(e.update({changes:i,scrollIntoView:!0,selection:ut.create(s,e.selection.mainIndex),userEvent:"move.line"})),!0)}function $u(e,t,n){if(e.readOnly)return!1;let i=[];for(let t of Pu(e))n?i.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):i.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let s=e.changes(i);return t(e.update({changes:s,selection:e.selection.map(s,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Lu=Fu(!1),zu=Fu(!0);function Fu(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let i=t.changeByRange(n=>{let{from:i,to:r}=n,o=t.doc.lineAt(i),a=!e&&i==r&&function(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n,i=Ul(e).resolveInner(t),r=i.childBefore(t),o=i.childAfter(t);return r&&o&&r.to<=t&&o.from>=t&&(n=r.type.prop(s.closedBy))&&n.indexOf(o.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(o.from).from&&!/\S/.test(e.sliceDoc(r.to,o.from))?{from:r.to,to:o.from}:null}(t,i);e&&(i=r=(r<=o.to?o:t.doc.lineAt(r)).to);let l=new rc(t,{simulateBreak:i,simulateDoubleBreak:!!a}),c=sc(l,i);for(null==c&&(c=xn(/^\s*/.exec(t.doc.lineAt(i).text)[0],t.tabSize));r<o.to&&/\s/.test(o.text[r-o.from]);)r++;a?({from:i,to:r}=a):i>o.from&&i<o.from+100&&!/\S/.test(o.text.slice(0,i))&&(i=o.from);let h=["",ic(t,c)];return a&&h.push(ic(t,l.lineIndent(o.from,-1))),{changes:{from:i,to:r,insert:Fe.of(h)},range:ut.cursor(i+1+h[1].length)}});return n(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function ju(e,t){let n=-1;return e.changeByRange(i=>{let s=[];for(let r=i.from;r<=i.to;){let o=e.doc.lineAt(r);o.number>n&&(i.empty||i.to>o.from)&&(t(o,s,i),n=o.number),r=o.to+1}let r=e.changes(s);return{changes:s,range:ut.range(r.mapPos(i.anchor,1),r.mapPos(i.head,1))}})}const Wu=[{key:"ArrowLeft",run:Xh,shift:pu,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:e=>tu(e,!Qh(e)),shift:e=>gu(e,!Qh(e)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:e=>Zh(e,t=>uu(e,t,!Qh(e))),shift:e=>du(e,t=>uu(e,t,!Qh(e))),preventDefault:!0},{key:"ArrowRight",run:eu,shift:mu,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:e=>tu(e,Qh(e)),shift:e=>gu(e,Qh(e)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:e=>Zh(e,t=>uu(e,t,Qh(e))),shift:e=>du(e,t=>uu(e,t,Qh(e))),preventDefault:!0},{key:"ArrowUp",run:ru,shift:yu,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Su,shift:Au},{mac:"Ctrl-ArrowUp",run:cu,shift:wu},{key:"ArrowDown",run:ou,shift:vu,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Cu,shift:Tu},{mac:"Ctrl-ArrowDown",run:hu,shift:xu},{key:"PageUp",run:cu,shift:wu},{key:"PageDown",run:hu,shift:xu},{key:"Home",run:e=>Zh(e,t=>uu(e,t,!1)),shift:e=>du(e,t=>uu(e,t,!1)),preventDefault:!0},{key:"Mod-Home",run:Su,shift:Au},{key:"End",run:e=>Zh(e,t=>uu(e,t,!0)),shift:e=>du(e,t=>uu(e,t,!0)),preventDefault:!0},{key:"Mod-End",run:Cu,shift:Tu},{key:"Enter",run:Lu,shift:Lu},{key:"Mod-a",run:({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:Du,shift:Du,preventDefault:!0},{key:"Delete",run:_u,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Bu,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:e=>Iu(e,!0),preventDefault:!0},{mac:"Mod-Backspace",run:e=>Ou(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),preventDefault:!0},{mac:"Mod-Delete",run:e=>Ou(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),preventDefault:!0}].concat([{key:"Ctrl-b",run:Xh,shift:pu,preventDefault:!0},{key:"Ctrl-f",run:eu,shift:mu},{key:"Ctrl-p",run:ru,shift:yu},{key:"Ctrl-n",run:ou,shift:vu},{key:"Ctrl-a",run:e=>Zh(e,t=>ut.cursor(e.lineBlockAt(t.head).from,1)),shift:e=>du(e,t=>ut.cursor(e.lineBlockAt(t.head).from))},{key:"Ctrl-e",run:e=>Zh(e,t=>ut.cursor(e.lineBlockAt(t.head).to,-1)),shift:e=>du(e,t=>ut.cursor(e.lineBlockAt(t.head).to))},{key:"Ctrl-d",run:_u},{key:"Ctrl-h",run:Du},{key:"Ctrl-k",run:e=>Ou(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)})},{key:"Ctrl-Alt-h",run:Bu},{key:"Ctrl-o",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:Fe.of(["",""])},range:ut.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||0==t.from||t.from==e.doc.length)return{range:t};let n=t.from,i=e.doc.lineAt(n),s=n==i.from?n-1:Ye(i.text,n-i.from,!1)+i.from,r=n==i.to?n+1:Ye(i.text,n-i.from,!0)+i.from;return{changes:{from:s,to:r,insert:e.doc.slice(n,r).append(e.doc.slice(s,n))},range:ut.cursor(r)}});return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:hu}].map(e=>({mac:e.key,run:e.run,shift:e.shift}))),Uu=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:e=>Zh(e,t=>iu(e.state,t,!Qh(e))),shift:e=>du(e,t=>iu(e.state,t,!Qh(e)))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e=>Zh(e,t=>iu(e.state,t,Qh(e))),shift:e=>du(e,t=>iu(e.state,t,Qh(e)))},{key:"Alt-ArrowUp",run:({state:e,dispatch:t})=>Ru(e,t,!1)},{key:"Shift-Alt-ArrowUp",run:({state:e,dispatch:t})=>$u(e,t,!1)},{key:"Alt-ArrowDown",run:({state:e,dispatch:t})=>Ru(e,t,!0)},{key:"Shift-Alt-ArrowDown",run:({state:e,dispatch:t})=>$u(e,t,!0)},{key:"Mod-Alt-ArrowUp",run:e=>Nu(e,!1)},{key:"Mod-Alt-ArrowDown",run:e=>Nu(e,!0)},{key:"Escape",run:({state:e,dispatch:t})=>{let n=e.selection,i=null;return n.ranges.length>1?i=ut.create([n.main]):n.main.empty||(i=ut.create([ut.cursor(n.main.head)])),!!i&&(t(Jh(e,i)),!0)}},{key:"Mod-Enter",run:zu},{key:"Alt-l",mac:"Ctrl-l",run:({state:e,dispatch:t})=>{let n=Pu(e).map(({from:t,to:n})=>ut.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:ut.create(n),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:e,dispatch:t})=>{let n=Kh(e.selection,t=>{let n=Ul(e),i=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=i.node.from&&e.node.to<=i.node.to&&(i=e)}for(let e=i;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return ut.range(n.to,n.from)}return t});return!n.eq(e.selection)&&(t(Jh(e,n)),!0)},preventDefault:!0},{key:"Mod-[",run:({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(ju(e,(t,n)=>{let i=/^\s*/.exec(t.text)[0];if(!i)return;let s=xn(i,e.tabSize),r=0,o=ic(e,Math.max(0,s-nc(e)));for(;r<i.length&&r<o.length&&i.charCodeAt(r)==o.charCodeAt(r);)r++;n.push({from:t.from+r,to:t.from+i.length,insert:o.slice(r)})}),{userEvent:"delete.dedent"})),!0)},{key:"Mod-]",run:({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(ju(e,(t,n)=>{n.push({from:t.from,insert:e.facet(tc)})}),{userEvent:"input.indent"})),!0)},{key:"Mod-Alt-\\",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),i=new rc(e,{overrideIndentation:e=>{let t=n[e];return null==t?-1:t}}),s=ju(e,(t,s,r)=>{let o=sc(i,t.from);if(null==o)return;/\S/.test(t.text)||(o=0);let a=/^\s*/.exec(t.text)[0],l=ic(e,o);(a!=l||r.from<t.from+a.length)&&(n[t.from]=o,s.push({from:t.from,to:t.from+a.length,insert:l}))});return s.changes.empty||t(e.update(s,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(Pu(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),i=Kh(t.selection,t=>{let n;if(e.lineWrapping){let i=e.lineBlockAt(t.head),s=e.coordsAtPos(t.head,t.assoc||1);s&&(n=i.bottom+e.documentTop-s.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:e,dispatch:t})=>function(e,t){let n=!1,i=Kh(e.selection,t=>{let i=rh(e,t.head,-1)||rh(e,t.head,1)||t.head>0&&rh(e,t.head-1,1)||t.head<e.doc.length&&rh(e,t.head+1,-1);if(!i||!i.end)return t;n=!0;let s=i.start.from==t.head?i.end.to:i.end.from;return ut.cursor(s)});return!!n&&(t(Jh(e,i)),!0)}(e,t)},{key:"Mod-/",run:e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),i=kh(e.state,n.from);return i.line?bh(e):!!i.block&&vh(e)}},{key:"Alt-A",run:yh},{key:"Ctrl-m",mac:"Shift-Alt-m",run:e=>(e.setTabFocusMode(),!0)}].concat(Wu),Vu="function"==typeof String.prototype.normalize?e=>e.normalize("NFKD"):e=>e;class Hu{constructor(e,t,n=0,i=e.length,s,r){this.test=r,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,i),this.bufferStart=n,this.normalize=s?e=>s(Vu(e)):Vu,this.query=this.normalize(t)}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 Ge(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=Qe(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=Xe(e);let i=this.normalize(t);if(i.length)for(let e=0,s=n;;e++){let r=i.charCodeAt(e),o=this.match(r,s,this.bufferPos+this.bufferStart);if(e==i.length-1){if(o)return this.value=o,this;break}s==n&&e<t.length&&t.charCodeAt(e)==r&&s++}}}match(e,t,n){let i=null;for(let t=0;t<this.matches.length;t+=2){let s=this.matches[t],r=!1;this.query.charCodeAt(s)==e&&(s==this.query.length-1?i={from:this.matches[t+1],to:n}:(this.matches[t]++,r=!0)),r||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(1==this.query.length?i={from:t,to:n}:this.matches.push(1,t)),i&&this.test&&!this.test(i.from,i.to,this.buffer,this.bufferStart)&&(i=null),i}}"undefined"!=typeof Symbol&&(Hu.prototype[Symbol.iterator]=function(){return this});const qu={from:-1,to:-1,match:/.*/.exec("")},Ku="gm"+(null==/x/.unicode?"":"u");class Ju{constructor(e,t,n,i=0,s=e.length){if(this.text=e,this.to=s,this.curLine="",this.done=!1,this.value=qu,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new Gu(e,t,n,i,s);this.re=new RegExp(t,Ku+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.iter=e.iter();let r=e.lineAt(i);this.curLineStart=r.from,this.matchPos=Qu(e,i),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),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 e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,i=n+t[0].length;if(this.matchPos=Qu(this.text,i+(n==i?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<i||n>this.value.to)&&(!this.test||this.test(n,i,t)))return this.value={from:n,to:i,match:t},this;e=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),e=0}}}}const Zu=new WeakMap;class Yu{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,n){let i=Zu.get(e);if(!i||i.from>=n||i.to<=t){let i=new Yu(t,e.sliceString(t,n));return Zu.set(e,i),i}if(i.from==t&&i.to==n)return i;let{text:s,from:r}=i;return r>t&&(s=e.sliceString(t,r)+s,r=t),i.to<n&&(s+=e.sliceString(i.to,n)),Zu.set(e,new Yu(r,s)),new Yu(t,s.slice(t-r,n-r))}}class Gu{constructor(e,t,n,i,s){this.text=e,this.to=s,this.done=!1,this.value=qu,this.matchPos=Qu(e,i),this.re=new RegExp(t,Ku+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.flat=Yu.get(e,i,this.chunkEnd(i+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=Qu(this.text,n+(e==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Yu.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function Qu(e,t){if(t>=e.length)return t;let n,i=e.lineAt(t);for(;t<i.to&&(n=i.text.charCodeAt(t-i.from))>=56320&&n<57344;)t++;return t}"undefined"!=typeof Symbol&&(Ju.prototype[Symbol.iterator]=Gu.prototype[Symbol.iterator]=function(){return this});const Xu={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},ed=pt.define({combine:e=>sn(e,Xu,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})});const td=ii.mark({class:"cm-selectionMatch"}),nd=ii.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function id(e,t,n,i){return!(0!=n&&e(t.sliceDoc(n-1,n))==Qt.Word||i!=t.doc.length&&e(t.sliceDoc(i,i+1))==Qt.Word)}const sd=bs.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(ed),{state:n}=e,i=n.selection;if(i.ranges.length>1)return ii.none;let s,r=i.main,o=null;if(r.empty){if(!t.highlightWordAroundCursor)return ii.none;let e=n.wordAt(r.head);if(!e)return ii.none;o=n.charCategorizer(r.head),s=n.sliceDoc(e.from,e.to)}else{let e=r.to-r.from;if(e<t.minSelectionLength||e>200)return ii.none;if(t.wholeWords){if(s=n.sliceDoc(r.from,r.to),o=n.charCategorizer(r.head),!id(o,n,r.from,r.to)||!function(e,t,n,i){return e(t.sliceDoc(n,n+1))==Qt.Word&&e(t.sliceDoc(i-1,i))==Qt.Word}(o,n,r.from,r.to))return ii.none}else if(s=n.sliceDoc(r.from,r.to),!s)return ii.none}let a=[];for(let i of e.visibleRanges){let e=new Hu(n.doc,s,i.from,i.to);for(;!e.next().done;){let{from:i,to:s}=e.value;if((!o||id(o,n,i,s))&&(r.empty&&i<=r.from&&s>=r.to?a.push(nd.range(i,s)):(i>=r.to||s<=r.from)&&a.push(td.range(i,s)),a.length>t.maxMatches))return ii.none}}return ii.set(a)}},{decorations:e=>e.decorations}),rd=Uo.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}});const od=pt.define({combine:e=>sn(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Pd(e),scrollToMatch:e=>Uo.scrollIntoView(e)})});class ad{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||function(e){try{return new RegExp(e,Ku),!0}catch(e){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>"n"==t?"\n":"r"==t?"\r":"t"==t?"\t":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new pd(this):new hd(this)}getCursor(e,t=0,n){let i=e.doc?e:nn.create({doc:e});return null==n&&(n=i.doc.length),this.regexp?ud(this,i,t,n):cd(this,i,t,n)}}class ld{constructor(e){this.spec=e}}function cd(e,t,n,i){let s;return e.wholeWord&&(s=function(e,t){return(n,i,s,r)=>((r>n||r+s.length<i)&&(r=Math.max(0,n-2),s=e.sliceString(r,Math.min(e.length,i+2))),!(t(dd(s,n-r))==Qt.Word&&t(fd(s,n-r))==Qt.Word||t(fd(s,i-r))==Qt.Word&&t(dd(s,i-r))==Qt.Word))}(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(s=function(e,t,n){return(i,s,r,o)=>{if(n&&!n(i,s,r,o))return!1;let a=i>=o&&s<=o+r.length?r.slice(i-o,s-o):t.doc.sliceString(i,s);return e(a,t,i,s)}}(e.test,t,s)),new Hu(t.doc,e.unquoted,n,i,e.caseSensitive?void 0:e=>e.toLowerCase(),s)}class hd extends ld{constructor(e){super(e)}nextMatch(e,t,n){let i=cd(this.spec,e,n,e.doc.length).nextOverlapping();if(i.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);i=cd(this.spec,e,0,n).nextOverlapping()}return i.done||i.value.from==t&&i.value.to==n?null:i.value}prevMatchInRange(e,t,n){for(let i=n;;){let n=Math.max(t,i-1e4-this.spec.unquoted.length),s=cd(this.spec,e,n,i),r=null;for(;!s.nextOverlapping().done;)r=s.value;if(r)return r;if(n==t)return null;i-=1e4}}prevMatch(e,t,n){let i=this.prevMatchInRange(e,0,t);return i||(i=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length)),!i||i.from==t&&i.to==n?null:i}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=cd(this.spec,e,0,e.doc.length),i=[];for(;!n.next().done;){if(i.length>=t)return null;i.push(n.value)}return i}highlight(e,t,n,i){let s=cd(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!s.next().done;)i(s.value.from,s.value.to)}}function ud(e,t,n,i){let s;var r;return e.wholeWord&&(r=t.charCategorizer(t.selection.main.head),s=(e,t,n)=>!n[0].length||(r(dd(n.input,n.index))!=Qt.Word||r(fd(n.input,n.index))!=Qt.Word)&&(r(fd(n.input,n.index+n[0].length))!=Qt.Word||r(dd(n.input,n.index+n[0].length))!=Qt.Word)),e.test&&(s=function(e,t,n){return(i,s,r)=>(!n||n(i,s,r))&&e(r[0],t,i,s)}(e.test,t,s)),new Ju(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:s},n,i)}function dd(e,t){return e.slice(Ye(e,t,!1),t)}function fd(e,t){return e.slice(t,Ye(e,t))}class pd extends ld{nextMatch(e,t,n){let i=ud(this.spec,e,n,e.doc.length).next();return i.done&&(i=ud(this.spec,e,0,t).next()),i.done?null:i.value}prevMatchInRange(e,t,n){for(let i=1;;i++){let s=Math.max(t,n-1e4*i),r=ud(this.spec,e,s,n),o=null;for(;!r.next().done;)o=r.value;if(o&&(s==t||o.from>s+10))return o;if(s==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if("&"==n)return e.match[0];if("$"==n)return"$";for(let t=n.length;t>0;t--){let i=+n.slice(0,t);if(i>0&&i<e.match.length)return e.match[i]+n.slice(t)}return t})}matchAll(e,t){let n=ud(this.spec,e,0,e.doc.length),i=[];for(;!n.next().done;){if(i.length>=t)return null;i.push(n.value)}return i}highlight(e,t,n,i){let s=ud(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!s.next().done;)i(s.value.from,s.value.to)}}const md=Vt.define(),gd=Vt.define(),bd=wt.define({create:e=>new yd(Md(e).create(),null),update(e,t){for(let n of t.effects)n.is(md)?e=new yd(n.value.create(),e.panel):n.is(gd)&&(e=new yd(e.query,n.value?Od:null));return e},provide:e=>ll.from(e,e=>e.panel)});class yd{constructor(e,t){this.query=e,this.panel=t}}const vd=ii.mark({class:"cm-searchMatch"}),kd=ii.mark({class:"cm-searchMatch cm-searchMatch-selected"}),wd=bs.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(bd))}update(e){let t=e.state.field(bd);(t!=e.startState.field(bd)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return ii.none;let{view:n}=this,i=new un;for(let t=0,s=n.visibleRanges,r=s.length;t<r;t++){let{from:o,to:a}=s[t];for(;t<r-1&&a>s[t+1].from-500;)a=s[++t].to;e.highlight(n.state,o,a,(e,t)=>{let s=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);i.add(e,t,s?kd:vd)})}return i.finish()}},{decorations:e=>e.decorations});function xd(e){return t=>{let n=t.state.field(bd,!1);return n&&n.query.spec.valid?e(t,n):_d(t)}}const Sd=xd((e,{query:t})=>{let{to:n}=e.state.selection.main,i=t.nextMatch(e.state,n,n);if(!i)return!1;let s=ut.single(i.from,i.to),r=e.state.facet(od);return e.dispatch({selection:s,effects:[zd(e,i),r.scrollToMatch(s.main,e)],userEvent:"select.search"}),Dd(e),!0}),Cd=xd((e,{query:t})=>{let{state:n}=e,{from:i}=n.selection.main,s=t.prevMatch(n,i,i);if(!s)return!1;let r=ut.single(s.from,s.to),o=e.state.facet(od);return e.dispatch({selection:r,effects:[zd(e,s),o.scrollToMatch(r.main,e)],userEvent:"select.search"}),Dd(e),!0}),Ad=xd((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!(!n||!n.length)&&(e.dispatch({selection:ut.create(n.map(e=>ut.range(e.from,e.to))),userEvent:"select.search.matches"}),!0)}),Td=xd((e,{query:t})=>{let{state:n}=e,{from:i,to:s}=n.selection.main;if(n.readOnly)return!1;let r=t.nextMatch(n,i,i);if(!r)return!1;let o,a,l=r,c=[],h=[];l.from==i&&l.to==s&&(a=n.toText(t.getReplacement(l)),c.push({from:l.from,to:l.to,insert:a}),l=t.nextMatch(n,l.from,l.to),h.push(Uo.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(i).number)+".")));let u=e.state.changes(c);return l&&(o=ut.single(l.from,l.to).map(u),h.push(zd(e,l)),h.push(n.facet(od).scrollToMatch(o.main,e))),e.dispatch({changes:u,selection:o,effects:h,userEvent:"input.replace"}),!0}),Nd=xd((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map(e=>{let{from:n,to:i}=e;return{from:n,to:i,insert:t.getReplacement(e)}});if(!n.length)return!1;let i=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:Uo.announce.of(i),userEvent:"input.replace.all"}),!0});function Od(e){return e.state.facet(od).createPanel(e)}function Md(e,t){var n,i,s,r,o;let a=e.selection.main,l=a.empty||a.to>a.from+100?"":e.sliceDoc(a.from,a.to);if(t&&!l)return t;let c=e.facet(od);return new ad({search:(null!==(n=null==t?void 0:t.literal)&&void 0!==n?n:c.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:null!==(i=null==t?void 0:t.caseSensitive)&&void 0!==i?i:c.caseSensitive,literal:null!==(s=null==t?void 0:t.literal)&&void 0!==s?s:c.literal,regexp:null!==(r=null==t?void 0:t.regexp)&&void 0!==r?r:c.regexp,wholeWord:null!==(o=null==t?void 0:t.wholeWord)&&void 0!==o?o:c.wholeWord})}function Ed(e){let t=sl(e,Od);return t&&t.dom.querySelector("[main-field]")}function Dd(e){let t=Ed(e);t&&t==e.root.activeElement&&t.select()}const _d=e=>{let t=e.state.field(bd,!1);if(t&&t.panel){let n=Ed(e);if(n&&n!=e.root.activeElement){let i=Md(e.state,t.query.spec);i.valid&&e.dispatch({effects:md.of(i)}),n.focus(),n.select()}}else e.dispatch({effects:[gd.of(!0),t?md.of(Md(e.state,t.query.spec)):Vt.appendConfig.of(jd)]});return!0},Id=e=>{let t=e.state.field(bd,!1);if(!t||!t.panel)return!1;let n=sl(e,Od);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:gd.of(!1)}),!0},Bd=[{key:"Mod-f",run:_d,scope:"editor search-panel"},{key:"F3",run:Sd,shift:Cd,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Sd,shift:Cd,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Id,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:i,to:s}=n.main,r=[],o=0;for(let t=new Hu(e.doc,e.sliceDoc(i,s));!t.next().done;){if(r.length>1e3)return!1;t.value.from==i&&(o=r.length),r.push(ut.range(t.value.from,t.value.to))}return t(e.update({selection:ut.create(r,o),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:i,result:s}=cl(e,{label:t.phrase("Go to line"),input:{type:"text",name:"line",value:n},focus:!0,submitLabel:t.phrase("go")});return s.then(n=>{let s=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!s)return void e.dispatch({effects:i});let r=t.doc.lineAt(t.selection.main.head),[,o,a,l,c]=s,h=l?+l.slice(1):0,u=a?+a:r.number;if(a&&c){let e=u/100;o&&(e=e*("-"==o?-1:1)+r.number/t.doc.lines),u=Math.round(t.doc.lines*e)}else a&&o&&(u=u*("-"==o?-1:1)+r.number);let d=t.doc.line(Math.max(1,Math.min(t.doc.lines,u))),f=ut.cursor(d.from+Math.max(0,Math.min(h,d.length)));e.dispatch({effects:[i,Uo.scrollIntoView(f.from,{y:"center"})],selection:f})}),!0}},{key:"Mod-d",run:({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return(({state:e,dispatch:t})=>{let{selection:n}=e,i=ut.create(n.ranges.map(t=>e.wordAt(t.head)||ut.cursor(t.head)),n.mainIndex);return!i.eq(n)&&(t(e.update({selection:i})),!0)})({state:e,dispatch:t});let i=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=i))return!1;let s=function(e,t){let{main:n,ranges:i}=e.selection,s=e.wordAt(n.head),r=s&&s.from==n.from&&s.to==n.to;for(let n=!1,s=new Hu(e.doc,t,i[i.length-1].to);;){if(s.next(),!s.done){if(n&&i.some(e=>e.from==s.value.from))continue;if(r){let t=e.wordAt(s.value.from);if(!t||t.from!=s.value.from||t.to!=s.value.to)continue}return s.value}if(n)return null;s=new Hu(e.doc,t,0,Math.max(0,i[i.length-1].from-1)),n=!0}}(e,i);return!!s&&(t(e.update({selection:e.selection.addRange(ut.range(s.from,s.to),!1),effects:Uo.scrollIntoView(s.to)})),!0)},preventDefault:!0}];class Pd{constructor(e){this.view=e;let t=this.query=e.state.field(bd).query.spec;function n(e,t,n){return Rn("button",{class:"cm-button",name:e,onclick:t,type:"button"},n)}this.commit=this.commit.bind(this),this.searchField=Rn("input",{value:t.search,placeholder:Rd(e,"Find"),"aria-label":Rd(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Rn("input",{value:t.replace,placeholder:Rd(e,"Replace"),"aria-label":Rd(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Rn("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=Rn("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=Rn("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit}),this.dom=Rn("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,n("next",()=>Sd(e),[Rd(e,"next")]),n("prev",()=>Cd(e),[Rd(e,"previous")]),n("select",()=>Ad(e),[Rd(e,"all")]),Rn("label",null,[this.caseField,Rd(e,"match case")]),Rn("label",null,[this.reField,Rd(e,"regexp")]),Rn("label",null,[this.wordField,Rd(e,"by word")]),...e.state.readOnly?[]:[Rn("br"),this.replaceField,n("replace",()=>Td(e),[Rd(e,"replace")]),n("replaceAll",()=>Nd(e),[Rd(e,"replace all")])],Rn("button",{name:"close",onclick:()=>Id(e),"aria-label":Rd(e,"close"),type:"button"},["×"])])}commit(){let e=new ad({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:md.of(e)}))}keydown(e){var t,n,i;t=this.view,n=e,i="search-panel",ia(Xo(t.state),n,t,i)?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Cd:Sd)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),Td(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(md)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(od).top}}function Rd(e,t){return e.state.phrase(t)}const $d=30,Ld=/[\s\.,:;?!]/;function zd(e,{from:t,to:n}){let i=e.state.doc.lineAt(t),s=e.state.doc.lineAt(n).to,r=Math.max(i.from,t-$d),o=Math.min(s,n+$d),a=e.state.sliceDoc(r,o);if(r!=i.from)for(let e=0;e<$d;e++)if(!Ld.test(a[e+1])&&Ld.test(a[e])){a=a.slice(e);break}if(o!=s)for(let e=a.length-1;e>a.length-$d;e--)if(!Ld.test(a[e-1])&&Ld.test(a[e])){a=a.slice(0,e);break}return Uo.announce.of(`${e.state.phrase("current match")}. ${a} ${e.state.phrase("on line")} ${i.number}.`)}const Fd=Uo.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"}}),jd=[bd,Nt.low(wd),Fd];class Wd{constructor(e,t,n,i){this.state=e,this.pos=t,this.explicit=n,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=Ul(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),i=t.text.slice(n-t.from,this.pos-t.from),s=i.search(Kd(e,!1));return s<0?null:{from:n+s,to:this.pos,text:i.slice(s)}}get aborted(){return null==this.abortListeners}addEventListener(e,t,n){"abort"==e&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}}function Ud(e){let t=Object.keys(e).join(""),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,"")),`[${n?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function Vd(e){let t=e.map(e=>"string"==typeof e?{label:e}:e),[n,i]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:function(e){let t=Object.create(null),n=Object.create(null);for(let{label:i}of e){t[i[0]]=!0;for(let e=1;e<i.length;e++)n[i[e]]=!0}let i=Ud(t)+Ud(n)+"*$";return[new RegExp("^"+i),new RegExp(i)]}(t);return e=>{let s=e.matchBefore(i);return s||e.explicit?{from:s?s.from:e.pos,options:t,validFor:n}:null}}class Hd{constructor(e,t,n,i){this.completion=e,this.source=t,this.match=n,this.score=i}}function qd(e){return e.selection.main.from}function Kd(e,t){var n;let{source:i}=e,s=t&&"^"!=i[0],r="$"!=i[i.length-1];return s||r?new RegExp(`${s?"^":""}(?:${i})${r?"$":""}`,null!==(n=e.flags)&&void 0!==n?n:e.ignoreCase?"i":""):e}const Jd=jt.define();function Zd(e,t,n,i){let{main:s}=e.selection,r=n-s.from,o=i-s.from;return{...e.changeByRange(a=>{if(a!=s&&n!=i&&e.sliceDoc(a.from+r,a.from+o)!=e.sliceDoc(n,i))return{range:a};let l=e.toText(t);return{changes:{from:a.from+r,to:i==s.from?a.to:a.from+o,insert:l},range:ut.cursor(a.from+r+l.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const Yd=new WeakMap;function Gd(e){if(!Array.isArray(e))return e;let t=Yd.get(e);return t||Yd.set(e,t=Vd(e)),t}const Qd=Vt.define(),Xd=Vt.define();class ef{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=Ge(e,t),i=Xe(n);this.chars.push(n);let s=e.slice(t,t+i),r=s.toUpperCase();this.folded.push(Ge(r==s?s.toLowerCase():r,0)),t+=i}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(0==this.pattern.length)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:i,precise:s,byWord:r}=this;if(1==t.length){let i=Ge(e,0),s=Xe(i),r=s==e.length?0:-100;if(i==t[0]);else{if(i!=n[0])return null;r+=-200}return this.ret(r,[0,s])}let o=e.indexOf(this.pattern);if(0==o)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=t.length,l=0;if(o<0){for(let s=0,r=Math.min(e.length,200);s<r&&l<a;){let r=Ge(e,s);r!=t[l]&&r!=n[l]||(i[l++]=s),s+=Xe(r)}if(l<a)return null}let c=0,h=0,u=!1,d=0,f=-1,p=-1,m=/[a-z]/.test(e),g=!0;for(let i=0,l=Math.min(e.length,200),b=0;i<l&&h<a;){let l=Ge(e,i);o<0&&(c<a&&l==t[c]&&(s[c++]=i),d<a&&(l==t[d]||l==n[d]?(0==d&&(f=i),p=i+1,d++):d=0));let y,v=l<255?l>=48&&l<=57||l>=97&&l<=122?2:l>=65&&l<=90?1:0:(y=Qe(l))!=y.toLowerCase()?1:y!=y.toUpperCase()?2:0;(!i||1==v&&m||0==b&&0!=v)&&(t[h]==l||n[h]==l&&(u=!0)?r[h++]=i:r.length&&(g=!1)),b=v,i+=Xe(l)}return h==a&&0==r[0]&&g?this.result((u?-200:0)-100,r,e):d==a&&0==f?this.ret(-200-e.length+(p==e.length?0:-100),[0,p]):o>-1?this.ret(-700-e.length,[o,o+this.pattern.length]):d==a?this.ret(-900-e.length,[f,p]):h==a?this.result((u?-200:0)-100-700+(g?0:-1100),r,e):2==t.length?null:this.result((i[0]?-700:0)-200-1100,i,e)}result(e,t,n){let i=[],s=0;for(let e of t){let t=e+(this.astral?Xe(Ge(n,e)):1);s&&i[s-1]==e?i[s-1]=t:(i[s++]=e,i[s++]=t)}return this.ret(e-n.length,i)}}class tf{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return null==n?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}}const nf=pt.define({combine:e=>sn(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:rf,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>sf(e(n),t(n)),optionClass:(e,t)=>n=>sf(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})});function sf(e,t){return e?t?e+" "+t:e:t}function rf(e,t,n,i,s,r){let o,a,l=e.textDirection==Ii.RTL,c=l,h=!1,u="top",d=t.left-s.left,f=s.right-t.right,p=i.right-i.left,m=i.bottom-i.top;if(c&&d<Math.min(p,f)?c=!1:!c&&f<Math.min(p,d)&&(c=!0),p<=(c?d:f))o=Math.max(s.top,Math.min(n.top,s.bottom-m))-t.top,a=Math.min(400,c?d:f);else{h=!0,a=Math.min(400,(l?t.right:s.right-t.left)-30);let e=s.bottom-t.bottom;e>=m||e>t.top?o=n.bottom-t.top:(u="bottom",o=t.bottom-n.top)}return{style:`${u}: ${o/((t.bottom-t.top)/r.offsetHeight)}px; max-width: ${a/((t.right-t.left)/r.offsetWidth)}px`,class:"cm-completionInfo-"+(h?l?"left-narrow":"right-narrow":c?"left":"right")}}const of=Vt.define();function af(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let i=Math.floor((e-t)/n);return{from:e-(i+1)*n,to:e-i*n}}class lf{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass="";let i=e.state.field(t),{options:s,selected:r}=i.open,o=e.state.facet(nf);this.optionContent=function(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement("div");return t.classList.add("cm-completionIcon"),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>"cm-completionIcon-"+e)),t.setAttribute("aria-hidden","true"),t},position:20}),t.push({render(e,t,n,i){let s=document.createElement("span");s.className="cm-completionLabel";let r=e.displayLabel||e.label,o=0;for(let e=0;e<i.length;){let t=i[e++],n=i[e++];t>o&&s.appendChild(document.createTextNode(r.slice(o,t)));let a=s.appendChild(document.createElement("span"));a.appendChild(document.createTextNode(r.slice(t,n))),a.className="cm-completionMatchedText",o=n}return o<r.length&&s.appendChild(document.createTextNode(r.slice(o))),s},position:50},{render(e){if(!e.detail)return null;let t=document.createElement("span");return t.className="cm-completionDetail",t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=af(s.length,r,o.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",n=>{let{options:i}=e.state.field(t).open;for(let t,s=n.target;s&&s!=this.dom;s=s.parentNode)if("LI"==s.nodeName&&(t=/-(\d+)$/.exec(s.id))&&+t[1]<i.length)return this.applyCompletion(e,i[+t[1]]),void n.preventDefault();if(n.target==this.list){let t=this.list.classList.contains("cm-completionListIncompleteTop")&&n.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&n.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;null!=t&&(e.dispatch({effects:of.of(t)}),n.preventDefault())}}),this.dom.addEventListener("focusout",t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(nf).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:Xd.of(null)})}),this.showOptions(s,i.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let n=e.state.field(this.stateField),i=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),n!=i){let{options:s,selected:r,disabled:o}=n.open;i.open&&i.open.options==s||(this.range=af(s.length,r,e.state.facet(nf).maxRenderedOptions),this.showOptions(s,n.id)),this.updateSel(),o!=(null===(t=i.open)||void 0===t?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!o)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(" "))e&&this.dom.classList.remove(e);for(let e of t.split(" "))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=af(t.options.length,t.selected,this.view.state.facet(nf).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:i}=t.options[t.selected],{info:s}=i;if(!s)return;let r="string"==typeof s?document.createTextNode(s):s(i);if(!r)return;"then"in r?r.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,i)}).catch(e=>fs(this.view.state,e,"completion info")):(this.addInfoPane(r,i),n.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",n.id="cm-completionInfo-"+Math.floor(65535*Math.random()).toString(16),null!=e.nodeType)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:i}=e;n.appendChild(t),this.infoDestroy=i||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,i=this.range.from;n;n=n.nextSibling,i++)"LI"==n.nodeName&&n.id?i==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),t=n):n.hasAttribute("aria-selected")&&(n.removeAttribute("aria-selected"),n.removeAttribute("aria-describedby")):i--;return t&&function(e,t){let n=e.getBoundingClientRect(),i=t.getBoundingClientRect(),s=n.height/e.offsetHeight;i.top<n.top?e.scrollTop-=(n.top-i.top)/s:i.bottom>n.bottom&&(e.scrollTop+=(i.bottom-n.bottom)/s)}(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),i=e.getBoundingClientRect(),s=this.space;if(!s){let e=this.dom.ownerDocument.documentElement;s={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return i.top>Math.min(s.bottom,t.bottom)-10||i.bottom<Math.max(s.top,t.top)+10?null:this.view.state.facet(nf).positionInfo(this.view,t,i,n,s,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,n){const i=document.createElement("ul");i.id=t,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions")),i.addEventListener("mousedown",e=>{e.target==i&&e.preventDefault()});let s=null;for(let r=n.from;r<n.to;r++){let{completion:o,match:a}=e[r],{section:l}=o;if(l){let e="string"==typeof l?l:l.name;if(e!=s&&(r>n.from||0==n.from))if(s=e,"string"!=typeof l&&l.header)i.appendChild(l.header(l));else{i.appendChild(document.createElement("completion-section")).textContent=e}}const c=i.appendChild(document.createElement("li"));c.id=t+"-"+r,c.setAttribute("role","option");let h=this.optionClass(o);h&&(c.className=h);for(let e of this.optionContent){let t=e(o,this.view.state,this.view,a);t&&c.appendChild(t)}}return n.from&&i.classList.add("cm-completionListIncompleteTop"),n.to<e.length&&i.classList.add("cm-completionListIncompleteBottom"),i}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function cf(e,t){return n=>new lf(n,e,t)}function hf(e){return 100*(e.boost||0)+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}class uf{constructor(e,t,n,i,s,r){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=i,this.selected=s,this.disabled=r}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new uf(this.options,mf(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,i,s,r){if(i&&!r&&e.some(e=>e.isPending))return i.setDisabled();let o=function(e,t){let n=[],i=null,s=null,r=e=>{n.push(e);let{section:t}=e.completion;if(t){i||(i=[]);let e="string"==typeof t?t:t.name;i.some(t=>t.name==e)||i.push("string"==typeof t?{name:e}:t)}},o=t.facet(nf);for(let i of e)if(i.hasResult()){let e=i.result.getMatch;if(!1===i.result.filter)for(let t of i.result.options)r(new Hd(t,i.source,e?e(t):[],1e9-n.length));else{let n,a=t.sliceDoc(i.from,i.to),l=o.filterStrict?new tf(a):new ef(a);for(let t of i.result.options)if(n=l.match(t.label)){let o=t.displayLabel?e?e(t,n.matched):[]:n.matched,a=n.score+(t.boost||0);if(r(new Hd(t,i.source,o,a)),"object"==typeof t.section&&"dynamic"===t.section.rank){let{name:e}=t.section;s||(s=Object.create(null)),s[e]=Math.max(a,s[e]||-1e9)}}}}if(i){let e=Object.create(null),t=0,r=(e,t)=>("dynamic"===e.rank&&"dynamic"===t.rank?s[t.name]-s[e.name]:0)||("number"==typeof e.rank?e.rank:1e9)-("number"==typeof t.rank?t.rank:1e9)||(e.name<t.name?-1:1);for(let n of i.sort(r))t-=1e5,e[n.name]=t;for(let t of n){let{section:n}=t.completion;n&&(t.score+=e["string"==typeof n?n:n.name])}}let a=[],l=null,c=o.compareCompletions;for(let e of n.sort((e,t)=>t.score-e.score||c(e.completion,t.completion))){let t=e.completion;!l||l.label!=t.label||l.detail!=t.detail||null!=l.type&&null!=t.type&&l.type!=t.type||l.apply!=t.apply||l.boost!=t.boost?a.push(e):hf(e.completion)>hf(l)&&(a[a.length-1]=e),l=e.completion}return a}(e,t);if(!o.length)return i&&e.some(e=>e.isPending)?i.setDisabled():null;let a=t.facet(nf).selectOnOpen?0:-1;if(i&&i.selected!=a&&-1!=i.selected){let e=i.options[i.selected].completion;for(let t=0;t<o.length;t++)if(o[t].completion==e){a=t;break}}return new uf(o,mf(n,a),{pos:e.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:Sf,above:s.aboveCursor},i?i.timestamp:Date.now(),a,!1)}map(e){return new uf(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new uf(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class df{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new df(gf,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(e){let{state:t}=e,n=t.facet(nf),i=(n.override||t.languageDataAt("autocomplete",qd(t)).map(Gd)).map(t=>{let i=this.active.find(e=>e.source==t)||new yf(t,this.active.some(e=>0!=e.state)?1:0);return i.update(e,n)});i.length==this.active.length&&i.every((e,t)=>e==this.active[t])&&(i=this.active);let s=this.open,r=e.effects.some(e=>e.is(kf));s&&e.docChanged&&(s=s.map(e.changes)),e.selection||i.some(t=>t.hasResult()&&e.changes.touchesRange(t.from,t.to))||!function(e,t){if(e==t)return!0;for(let n=0,i=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;i<t.length&&!t[i].hasResult();)i++;let s=n==e.length,r=i==t.length;if(s||r)return s==r;if(e[n++].result!=t[i++].result)return!1}}(i,this.active)||r?s=uf.build(i,t,this.id,s,n,r):s&&s.disabled&&!i.some(e=>e.isPending)&&(s=null),!s&&i.every(e=>!e.isPending)&&i.some(e=>e.hasResult())&&(i=i.map(e=>e.hasResult()?new yf(e.source,0):e));for(let t of e.effects)t.is(of)&&(s=s&&s.setSelected(t.value,this.id));return i==this.active&&s==this.open?this:new df(i,this.id,s)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?ff:pf}}const ff={"aria-autocomplete":"list"},pf={};function mf(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const gf=[];function bf(e,t){if(e.isUserEvent("input.complete")){let n=e.annotation(Jd);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent("input.type");return n&&t.activateOnTyping?5:n?1:e.isUserEvent("delete.backward")?2:e.selection?8:e.docChanged?16:0}class yf{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return 1==this.state}update(e,t){let n=bf(e,t),i=this;(8&n||16&n&&this.touches(e))&&(i=new yf(i.source,0)),4&n&&0==i.state&&(i=new yf(this.source,1)),i=i.updateFor(e,n);for(let t of e.effects)if(t.is(Qd))i=new yf(i.source,1,t.value);else if(t.is(Xd))i=new yf(i.source,0);else if(t.is(kf))for(let e of t.value)e.source==i.source&&(i=e);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(qd(e.state))}}class vf extends yf{constructor(e,t,n,i,s,r){super(e,3,t),this.limit=n,this.result=i,this.from=s,this.to=r}hasResult(){return!0}updateFor(e,t){var n;if(!(3&t))return this.map(e.changes);let i=this.result;i.map&&!e.changes.empty&&(i=i.map(i,e.changes));let s=e.changes.mapPos(this.from),r=e.changes.mapPos(this.to,1),o=qd(e.state);if(o>r||!i||2&t&&(qd(e.startState)==this.from||o<this.limit))return new yf(this.source,4&t?1:0);let a=e.changes.mapPos(this.limit);return function(e,t,n,i){if(!e)return!1;let s=t.sliceDoc(n,i);return"function"==typeof e?e(s,n,i,t):Kd(e,!0).test(s)}(i.validFor,e.state,s,r)?new vf(this.source,this.explicit,a,i,s,r):i.update&&(i=i.update(i,s,r,new Wd(e.state,o,!1)))?new vf(this.source,this.explicit,a,i,i.from,null!==(n=i.to)&&void 0!==n?n:qd(e.state)):new yf(this.source,1,this.explicit)}map(e){if(e.empty)return this;return(this.result.map?this.result.map(this.result,e):this.result)?new vf(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new yf(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}const kf=Vt.define({map:(e,t)=>e.map(e=>e.map(t))}),wf=wt.define({create:()=>df.start(),update:(e,t)=>e.update(t),provide:e=>[Ja.from(e,e=>e.tooltip),Uo.contentAttributes.from(e,e=>e.attrs)]});function xf(e,t){const n=t.completion.apply||t.completion.label;let i=e.state.field(wf).active.find(e=>e.source==t.source);return i instanceof vf&&("string"==typeof n?e.dispatch({...Zd(e.state,n,i.from,i.to),annotations:Jd.of(t.completion)}):n(e,t.completion,i.from,i.to),!0)}const Sf=cf(wf,xf);function Cf(e,t="option"){return n=>{let i=n.state.field(wf,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<n.state.facet(nf).interactionDelay)return!1;let s,r=1;"page"==t&&(s=tl(n,i.open.tooltip))&&(r=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:o}=i.open.options,a=i.open.selected>-1?i.open.selected+r*(e?1:-1):e?0:o-1;return a<0?a="page"==t?0:o-1:a>=o&&(a="page"==t?o-1:0),n.dispatch({effects:of.of(a)}),!0}}const Af=e=>!!e.state.field(wf,!1)&&(e.dispatch({effects:Qd.of(!0)}),!0);class Tf{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const Nf=bs.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(wf).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(wf),n=e.state.facet(nf);if(!e.selectionSet&&!e.docChanged&&e.startState.field(wf)==t)return;let i=e.transactions.some(e=>{let t=bf(e,n);return 8&t||(e.selection||e.docChanged)&&!(3&t)});for(let t=0;t<this.running.length;t++){let n=this.running[t];if(i||n.context.abortOnDocChange&&e.docChanged||n.updates.length+e.transactions.length>50&&Date.now()-n.time>1e3){for(let e of n.context.abortListeners)try{e()}catch(e){fs(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(Qd)))&&(this.pendingStart=!0);let s=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),s):-1,0!=this.composing)for(let t of e.transactions)t.isUserEvent("input.type")?this.composing=2:2==this.composing&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(wf);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(nf).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=qd(t),i=new Wd(t,n,e.explicit,this.view),s=new Tf(e,i);this.running.push(s),Promise.resolve(e.source(i)).then(e=>{s.context.aborted||(s.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:Xd.of(null)}),fs(this.view.state,e)})}scheduleAccept(){this.running.every(e=>void 0!==e.done)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(nf).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(nf),i=this.view.state.field(wf);for(let s=0;s<this.running.length;s++){let r=this.running[s];if(void 0===r.done)continue;if(this.running.splice(s--,1),r.done){let i=qd(r.updates.length?r.updates[0].startState:this.view.state),s=Math.min(i,r.done.from+(r.active.explicit?0:1)),o=new vf(r.active.source,r.active.explicit,s,r.done,r.done.from,null!==(e=r.done.to)&&void 0!==e?e:i);for(let e of r.updates)o=o.update(e,n);if(o.hasResult()){t.push(o);continue}}let o=i.active.find(e=>e.source==r.active.source);if(o&&o.isPending)if(null==r.done){let e=new yf(r.active.source,0);for(let t of r.updates)e=e.update(t,n);e.isPending||t.push(e)}else this.startQuery(o)}(t.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:kf.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(wf,!1);if(t&&t.tooltip&&this.view.state.facet(nf).closeOnBlur){let n=t.open&&tl(this.view,t.open.tooltip);n&&n.dom.contains(e.relatedTarget)||setTimeout(()=>this.view.dispatch({effects:Xd.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout(()=>this.view.dispatch({effects:Qd.of(!1)}),20),this.composing=0}}}),Of="object"==typeof navigator&&/Win/.test(navigator.platform),Mf=Nt.highest(Uo.domEventHandlers({keydown(e,t){let n=t.state.field(wf,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&(!Of||!e.altKey)||e.metaKey)return!1;let i=n.open.options[n.open.selected],s=n.active.find(e=>e.source==i.source),r=i.completion.commitCharacters||s.result.commitCharacters;return r&&r.indexOf(e.key)>-1&&xf(t,i),!1}})),Ef=Uo.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"},".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"}}}),Df={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},_f=Vt.define({map(e,t){let n=t.mapPos(e,-1,tt.TrackAfter);return null==n?void 0:n}}),If=new class extends rn{};If.startSide=1,If.endSide=-1;const Bf=wt.define({create:()=>hn.empty,update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:e=>e>=n.from&&e<=n.to})}for(let n of t.effects)n.is(_f)&&(e=e.update({add:[If.range(n.value,n.value+1)]}));return e}});function Pf(){return[Ff,Bf]}const Rf="()[]{}<>«»»«[]{}";function $f(e){for(let t=0;t<16;t+=2)if(Rf.charCodeAt(t)==e)return Rf.charAt(t+1);return Qe(e<128?e:e+1)}function Lf(e,t){return e.languageDataAt("closeBrackets",t)[0]||Df}const zf="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),Ff=Uo.inputHandler.of((e,t,n,i)=>{if((zf?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let s=e.state.selection.main;if(i.length>2||2==i.length&&1==Xe(Ge(i,0))||t!=s.from||n!=s.to)return!1;let r=function(e,t){let n=Lf(e,e.selection.main.head),i=n.brackets||Df.brackets;for(let s of i){let r=$f(Ge(s,0));if(t==s)return r==s?qf(e,s,i.indexOf(s+s+s)>-1,n):Vf(e,s,r,n.before||Df.before);if(t==r&&Wf(e,e.selection.main.from))return Hf(e,s,r)}return null}(e.state,i);return!!r&&(e.dispatch(r),!0)}),jf=[{key:"Backspace",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Lf(e,e.selection.main.head).brackets||Df.brackets,i=null,s=e.changeByRange(t=>{if(t.empty){let i=function(e,t){let n=e.sliceString(t-2,t);return Xe(Ge(n,0))==n.length?n:n.slice(1)}(e.doc,t.head);for(let s of n)if(s==i&&Uf(e.doc,t.head)==$f(Ge(s,0)))return{changes:{from:t.head-s.length,to:t.head+s.length},range:ut.cursor(t.head-s.length)}}return{range:i=t}});return i||t(e.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!i}}];function Wf(e,t){let n=!1;return e.field(Bf).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function Uf(e,t){let n=e.sliceString(t,t+2);return n.slice(0,Xe(Ge(n,0)))}function Vf(e,t,n,i){let s=null,r=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:n,from:r.to}],effects:_f.of(r.to+t.length),range:ut.range(r.anchor+t.length,r.head+t.length)};let o=Uf(e.doc,r.head);return!o||/\s/.test(o)||i.indexOf(o)>-1?{changes:{insert:t+n,from:r.head},effects:_f.of(r.head+t.length),range:ut.cursor(r.head+t.length)}:{range:s=r}});return s?null:e.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function Hf(e,t,n){let i=null,s=e.changeByRange(t=>t.empty&&Uf(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:ut.cursor(t.head+n.length)}:i={range:t});return i?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function qf(e,t,n,i){let s=i.stringPrefixes||Df.stringPrefixes,r=null,o=e.changeByRange(i=>{if(!i.empty)return{changes:[{insert:t,from:i.from},{insert:t,from:i.to}],effects:_f.of(i.to+t.length),range:ut.range(i.anchor+t.length,i.head+t.length)};let o,a=i.head,l=Uf(e.doc,a);if(l==t){if(Kf(e,a))return{changes:{insert:t+t,from:a},effects:_f.of(a+t.length),range:ut.cursor(a+t.length)};if(Wf(e,a)){let i=n&&e.sliceDoc(a,a+3*t.length)==t+t+t?t+t+t:t;return{changes:{from:a,to:a+i.length,insert:i},range:ut.cursor(a+i.length)}}}else{if(n&&e.sliceDoc(a-2*t.length,a)==t+t&&(o=Jf(e,a-2*t.length,s))>-1&&Kf(e,o))return{changes:{insert:t+t+t+t,from:a},effects:_f.of(a+t.length),range:ut.cursor(a+t.length)};if(e.charCategorizer(a)(l)!=Qt.Word&&Jf(e,a,s)>-1&&!function(e,t,n,i){let s=Ul(e).resolveInner(t,-1),r=i.reduce((e,t)=>Math.max(e,t.length),0);for(let o=0;o<5;o++){let o=e.sliceDoc(s.from,Math.min(s.to,s.from+n.length+r)),a=o.indexOf(n);if(!a||a>-1&&i.indexOf(o.slice(0,a))>-1){let t=s.firstChild;for(;t&&t.from==s.from&&t.to-t.from>n.length+a;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let l=s.to==t&&s.parent;if(!l)break;s=l}return!1}(e,a,t,s))return{changes:{insert:t+t,from:a},effects:_f.of(a+t.length),range:ut.cursor(a+t.length)}}return{range:r=i}});return r?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function Kf(e,t){let n=Ul(e).resolveInner(t+1);return n.parent&&n.from==t}function Jf(e,t,n){let i=e.charCategorizer(t);if(i(e.sliceDoc(t-1,t))!=Qt.Word)return t;for(let s of n){let n=t-s.length;if(e.sliceDoc(n,t)==s&&i(e.sliceDoc(n-1,n))!=Qt.Word)return n}return-1}function Zf(e={}){return[Mf,wf,nf.of(e),Nf,Gf,Ef]}const Yf=[{key:"Ctrl-Space",run:Af},{mac:"Alt-`",run:Af},{mac:"Alt-i",run:Af},{key:"Escape",run:e=>{let t=e.state.field(wf,!1);return!(!t||!t.active.some(e=>0!=e.state))&&(e.dispatch({effects:Xd.of(null)}),!0)}},{key:"ArrowDown",run:Cf(!0)},{key:"ArrowUp",run:Cf(!1)},{key:"PageDown",run:Cf(!0,"page")},{key:"PageUp",run:Cf(!1,"page")},{key:"Enter",run:e=>{let t=e.state.field(wf,!1);return!(e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(nf).interactionDelay)&&xf(e,t.open.options[t.open.selected])}}],Gf=Nt.highest(Go.computeN([nf],e=>e.facet(nf).defaultKeymap?[Yf]:[]));class Qf{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}}class Xf{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let i=n.facet(fp).markerFilter;i&&(e=i(e,n));let s=e.slice().sort((e,t)=>e.from-t.from||e.to-t.to),r=new un,o=[],a=0,l=n.doc.iter(),c=0,h=n.doc.length;for(let e=0;;){let t,n,i=e==s.length?null:s[e];if(!i&&!o.length)break;if(o.length)t=a,n=o.reduce((e,t)=>Math.min(e,t.to),i&&i.from>t?i.from:1e8);else{if(t=i.from,t>h)break;n=i.to,o.push(i),e++}for(;e<s.length;){let i=s[e];if(i.from!=t||!(i.to>i.from||i.to==t)){n=Math.min(i.from,n);break}o.push(i),e++,n=Math.min(i.to,n)}n=Math.min(n,h);let u=!1;if(o.some(e=>e.from==t&&(e.to==n||n==h))&&(u=t==n,!u&&n-t<10)){let e=t-(c+l.value.length);e>0&&(l.next(e),c=t);for(let e=t;;){if(e>=n){u=!0;break}if(!l.lineBreak&&c+l.value.length>e)break;e=c+l.value.length,c+=l.value.length,l.next()}}let d=Ap(o);if(u)r.add(t,t,ii.widget({widget:new yp(d),diagnostics:o.slice()}));else{let e=o.reduce((e,t)=>t.markClass?e+" "+t.markClass:e,"");r.add(t,n,ii.mark({class:"cm-lintRange cm-lintRange-"+d+e,diagnostics:o.slice(),inclusiveEnd:o.some(e=>e.to>n)}))}if(a=n,a==h)break;for(let e=0;e<o.length;e++)o[e].to<=a&&o.splice(e--,1)}let u=r.finish();return new Xf(u,t,ep(u))}}function ep(e,t=null,n=0){let i=null;return e.between(n,1e9,(e,n,{spec:s})=>{if(!(t&&s.diagnostics.indexOf(t)<0))if(i){if(s.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new Qf(i.from,n,i.diagnostic)}else i=new Qf(e,n,t||s.diagnostics[0])}),i}function tp(e,t){let n=t.pos,i=t.end||n,s=e.state.facet(fp).hideOn(e,n,i);if(null!=s)return s;let r=e.startState.doc.lineAt(t.pos);return!(!e.effects.some(e=>e.is(ip))&&!e.changes.touchesRange(r.from,Math.max(r.to,i)))}function np(e,t){return e.field(op,!1)?t:t.concat(Vt.appendConfig.of(Ip))}const ip=Vt.define(),sp=Vt.define(),rp=Vt.define(),op=wt.define({create:()=>new Xf(ii.none,null,null),update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),i=null,s=e.panel;if(e.selected){let s=t.changes.mapPos(e.selected.from,1);i=ep(n,e.selected.diagnostic,s)||ep(n,null,s)}!n.size&&s&&t.state.facet(fp).autoPanel&&(s=null),e=new Xf(n,s,i)}for(let n of t.effects)if(n.is(ip)){let i=t.state.facet(fp).autoPanel?n.value.length?kp.open:null:e.panel;e=Xf.init(n.value,i,t.state)}else n.is(sp)?e=new Xf(e.diagnostics,n.value?kp.open:null,e.selected):n.is(rp)&&(e=new Xf(e.diagnostics,e.panel,n.value));return e},provide:e=>[ll.from(e,e=>e.panel),Uo.decorations.from(e,e=>e.diagnostics)]}),ap=ii.mark({class:"cm-lintRange cm-lintRange-active"});function lp(e,t,n){let i,{diagnostics:s}=e.state.field(op),r=-1,o=-1;s.between(t-(n<0?1:0),t+(n>0?1:0),(e,s,{spec:a})=>{if(t>=e&&t<=s&&(e==s||(t>e||n>0)&&(t<s||n<0)))return i=a.diagnostics,r=e,o=s,!1});let a=e.state.facet(fp).tooltipFilter;return i&&a&&(i=a(i,e.state)),i?{pos:r,end:o,above:e.state.doc.lineAt(r).to<o,create:()=>({dom:cp(e,i)})}:null}function cp(e,t){return Rn("ul",{class:"cm-tooltip-lint"},t.map(t=>bp(e,t,!1)))}const hp=e=>{let t=e.state.field(op,!1);return!(!t||!t.panel)&&(e.dispatch({effects:sp.of(!1)}),!0)},up=[{key:"Mod-Shift-m",run:e=>{let t=e.state.field(op,!1);t&&t.panel||e.dispatch({effects:np(e.state,[sp.of(!0)])});let n=sl(e,kp.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:e=>{let t=e.state.field(op,!1);if(!t)return!1;let n=e.state.selection.main,i=ep(t.diagnostics,null,n.to+1);return!(!i&&(i=ep(t.diagnostics,null,0),!i||i.from==n.from&&i.to==n.to))&&(e.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)}}],dp=bs.fromClass(class{constructor(e){this.view=e,this.timeout=-1,this.set=!0;let{delay:t}=e.state.facet(fp);this.lintTime=Date.now()+t,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,t)}run(){clearTimeout(this.timeout);let e=Date.now();if(e<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-e);else{this.set=!1;let{state:e}=this.view,{sources:t}=e.facet(fp);t.length&&function(e,t,n){let i=[],s=-1;for(let r of e)r.then(n=>{i.push(n),clearTimeout(s),i.length==e.length?t(i):s=setTimeout(()=>t(i),200)},n)}(t.map(e=>Promise.resolve(e(this.view))),t=>{this.view.state.doc==e.doc&&this.view.dispatch(function(e,t){return{effects:np(e,[ip.of(t)])}}(this.view.state,t.reduce((e,t)=>e.concat(t))))},e=>{fs(this.view.state,e)})}}update(e){let t=e.state.facet(fp);(e.docChanged||t!=e.startState.facet(fp)||t.needsRefresh&&t.needsRefresh(e))&&(this.lintTime=Date.now()+t.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,t.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});const fp=pt.define({combine:e=>({sources:e.map(e=>e.source).filter(e=>null!=e),...sn(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:pp,tooltipFilter:pp,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,i,s)=>e(n,i,s)||t(n,i,s):e:t,autoPanel:(e,t)=>e||t})})});function pp(e,t){return e?t?(n,i)=>t(e(n,i),i):e:t}function mp(e,t={}){return[fp.of({source:e,config:t}),dp,Ip]}function gp(e){let t=[];if(e)e:for(let{name:n}of e){for(let e=0;e<n.length;e++){let i=n[e];if(/[a-zA-Z]/.test(i)&&!t.some(e=>e.toLowerCase()==i.toLowerCase())){t.push(i);continue e}}t.push("")}return t}function bp(e,t,n){var i;let s=n?gp(t.actions):[];return Rn("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},Rn("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(e):t.message),null===(i=t.actions)||void 0===i?void 0:i.map((n,i)=>{let r=!1,o=i=>{if(i.preventDefault(),r)return;r=!0;let s=ep(e.state.field(op).diagnostics,t);s&&n.apply(e,s.from,s.to)},{name:a}=n,l=s[i]?a.indexOf(s[i]):-1,c=l<0?a:[a.slice(0,l),Rn("u",a.slice(l,l+1)),a.slice(l+1)];return Rn("button",{type:"button",class:"cm-diagnosticAction"+(n.markClass?" "+n.markClass:""),onclick:o,onmousedown:o,"aria-label":` Action: ${a}${l<0?"":` (access key "${s[i]})"`}.`},c)}),t.source&&Rn("div",{class:"cm-diagnosticSource"},t.source))}class yp extends ti{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return Rn("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class vp{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=bp(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class kp{constructor(e){this.view=e,this.items=[];this.list=Rn("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(27==t.keyCode)hp(this.view),this.view.focus();else if(38==t.keyCode||33==t.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==t.keyCode||34==t.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==t.keyCode)this.moveSelection(0);else if(35==t.keyCode)this.moveSelection(this.items.length-1);else if(13==t.keyCode)this.view.focus();else{if(!(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0))return;{let{diagnostic:n}=this.items[this.selectedIndex],i=gp(n.actions);for(let s=0;s<i.length;s++)if(i[s].toUpperCase().charCodeAt(0)==t.keyCode){let t=ep(this.view.state.field(op).diagnostics,n);t&&n.actions[s].apply(e,t.from,t.to)}}}t.preventDefault()}},onclick:e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)}}),this.dom=Rn("div",{class:"cm-panel-lint"},this.list,Rn("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>hp(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(op).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(op),n=0,i=!1,s=null,r=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:a})=>{for(let e of a.diagnostics){if(r.has(e))continue;r.add(e);let o,a=-1;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){a=t;break}a<0?(o=new vp(this.view,e),this.items.splice(n,0,o),i=!0):(o=this.items[a],a>n&&(this.items.splice(n,a-n),i=!0)),t&&o.diagnostic==t.diagnostic?o.dom.hasAttribute("aria-selected")||(o.dom.setAttribute("aria-selected","true"),s=o):o.dom.hasAttribute("aria-selected")&&o.dom.removeAttribute("aria-selected"),n++}});n<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)i=!0,this.items.pop();0==this.items.length&&(this.items.push(new vp(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),i=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:()=>({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=ep(this.view.state.field(op).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:rp.of(t)})}static open(e){return new kp(e)}}function wp(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function xp(e){return wp(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Sp=Uo.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:xp("#d11")},".cm-lintRange-warning":{backgroundImage:xp("orange")},".cm-lintRange-info":{backgroundImage:xp("#999")},".cm-lintRange-hint":{backgroundImage:xp("#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 Cp(e){return"error"==e?4:"warning"==e?3:"info"==e?2:1}function Ap(e){let t="hint",n=1;for(let i of e){let e=Cp(i.severity);e>n&&(n=e,t=i.severity)}return t}class Tp extends fl{constructor(e){super(),this.diagnostics=e,this.severity=Ap(e)}toDOM(e){let t=document.createElement("div");t.className="cm-lint-marker cm-lint-marker-"+this.severity;let n=this.diagnostics,i=e.state.facet(Bp).tooltipFilter;return i&&(n=i(n,e.state)),n.length&&(t.onmouseover=()=>function(e,t,n){function i(){let i=e.elementAtHeight(t.getBoundingClientRect().top+5-e.documentTop);e.coordsAtPos(i.from)&&e.dispatch({effects:Ep.of({pos:i.from,above:!1,clip:!1,create:()=>({dom:cp(e,n),getCoords:()=>t.getBoundingClientRect()})})}),t.onmouseout=t.onmousemove=null,function(e,t){let n=i=>{let s=t.getBoundingClientRect();if(!(i.clientX>s.left-10&&i.clientX<s.right+10&&i.clientY>s.top-10&&i.clientY<s.bottom+10)){for(let e=i.target;e;e=e.parentNode)if(1==e.nodeType&&e.classList.contains("cm-tooltip-lint"))return;window.removeEventListener("mousemove",n),e.state.field(Dp)&&e.dispatch({effects:Ep.of(null)})}};window.addEventListener("mousemove",n)}(e,t)}let{hoverTime:s}=e.state.facet(Bp),r=setTimeout(i,s);t.onmouseout=()=>{clearTimeout(r),t.onmouseout=t.onmousemove=null},t.onmousemove=()=>{clearTimeout(r),r=setTimeout(i,s)}}(e,t,n)),t}}function Np(e,t){let n=Object.create(null);for(let i of t){let t=e.lineAt(i.from);(n[t.from]||(n[t.from]=[])).push(i)}let i=[];for(let e in n)i.push(new Tp(n[e]).range(+e));return hn.of(i,!0)}const Op=yl({class:"cm-gutter-lint",markers:e=>e.state.field(Mp),widgetMarker:(e,t,n)=>{let i=[];return e.state.field(Mp).between(n.from,n.to,(e,t,s)=>{e>n.from&&e<n.to&&i.push(...s.diagnostics)}),i.length?new Tp(i):null}}),Mp=wt.define({create:()=>hn.empty,update(e,t){e=e.map(t.changes);let n=t.state.facet(Bp).markerFilter;for(let i of t.effects)if(i.is(ip)){let s=i.value;n&&(s=n(s||[],t.state)),e=Np(t.state.doc,s.slice(0))}return e}}),Ep=Vt.define(),Dp=wt.define({create:()=>null,update:(e,t)=>(e&&t.docChanged&&(e=tp(t,e)?null:{...e,pos:t.changes.mapPos(e.pos)}),t.effects.reduce((e,t)=>t.is(Ep)?t.value:e,e)),provide:e=>Ja.from(e)}),_p=Uo.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:wp('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:wp('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:wp('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),Ip=[op,Uo.decorations.compute([op],e=>{let{selected:t,panel:n}=e.field(op);return t&&n&&t.from!=t.to?ii.set([ap.range(t.from,t.to)]):ii.none}),el(lp,{hideOn:tp}),Sp],Bp=pt.define({combine:e=>sn(e,{hoverTime:300,markerFilter:null,tooltipFilter:null})});function Pp(e={}){return[Bp.of(e),Mp,Op,_p,Dp]}const Rp=(()=>[Il(),Rl,Na(),Mh(),Rc(),ua(),[ya,va],nn.allowMultipleSelections.of(!0),nn.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:i}=e.newSelection.main,s=n.lineAt(i);if(i>s.from+200)return e;let r=n.sliceString(s.from,i);if(!t.some(e=>e.test(r)))return e;let{state:o}=e,a=-1,l=[];for(let{head:e}of o.selection.ranges){let t=o.doc.lineAt(e);if(t.from==a)continue;a=t.from;let n=sc(o,t.from);if(null==n)continue;let i=/^\s*/.exec(t.text)[0],s=ic(o,n);i!=s&&l.push({from:t.from,to:t.from+i.length,insert:s})}return l.length?[e,{changes:l,sequential:!0}]:e}),Wc(Hc,{fallback:!0}),th(),Pf(),Zf(),Uo.mouseSelectionStyle.of((e,t)=>(e=>e.altKey&&0==e.button)(t)?Pa(e,t):null),La(),_a,[rd,sd],Go.of([...jf,...Uu,...Bd,...qh,...Nc,...Yf,...up])])(),$p=(()=>[Na(),Mh(),ua(),Wc(Hc,{fallback:!0}),Go.of([...Uu,...qh])])(),Lp=globalThis,zp=Lp.ShadowRoot&&(void 0===Lp.ShadyCSS||Lp.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Fp=Symbol(),jp=new WeakMap;let Wp=class{constructor(e,t,n){if(this._$cssResult$=!0,n!==Fp)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(zp&&void 0===e){const n=void 0!==t&&1===t.length;n&&(e=jp.get(t)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&jp.set(t,e))}return e}toString(){return this.cssText}};const Up=(e,...t)=>{const n=1===e.length?e[0]:t.reduce((t,n,i)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if("number"==typeof e)return e;throw Error("Value passed to 'css' function must be a 'css' function result: "+e+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+e[i+1],e[0]);return new Wp(n,e,Fp)},Vp=zp?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const n of e.cssRules)t+=n.cssText;return(e=>new Wp("string"==typeof e?e:e+"",void 0,Fp))(t)})(e):e,{is:Hp,defineProperty:qp,getOwnPropertyDescriptor:Kp,getOwnPropertyNames:Jp,getOwnPropertySymbols:Zp,getPrototypeOf:Yp}=Object,Gp=globalThis,Qp=Gp.trustedTypes,Xp=Qp?Qp.emptyScript:"",em=Gp.reactiveElementPolyfillSupport,tm=(e,t)=>e,nm={toAttribute(e,t){switch(t){case Boolean:e=e?Xp:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=null!==e;break;case Number:n=null===e?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch(e){n=null}}return n}},im=(e,t)=>!Hp(e,t),sm={attribute:!0,type:String,converter:nm,reflect:!1,useDefault:!1,hasChanged:im};
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2017 Google LLC
|
|
@@ -9,12 +9,12 @@ var SkirFormatConverter=function(e){"use strict";const t=1024;let n=0,i=class{co
|
|
|
9
9
|
* Copyright 2017 Google LLC
|
|
10
10
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
11
11
|
*/
|
|
12
|
-
const om=globalThis,am=e=>e,lm=om.trustedTypes,cm=lm?lm.createPolicy("lit-html",{createHTML:e=>e}):void 0,hm="$lit$",um=`lit$${Math.random().toFixed(9).slice(2)}$`,dm="?"+um,fm=`<${dm}>`,pm=document,mm=()=>pm.createComment(""),gm=e=>null===e||"object"!=typeof e&&"function"!=typeof e,
|
|
12
|
+
const om=globalThis,am=e=>e,lm=om.trustedTypes,cm=lm?lm.createPolicy("lit-html",{createHTML:e=>e}):void 0,hm="$lit$",um=`lit$${Math.random().toFixed(9).slice(2)}$`,dm="?"+um,fm=`<${dm}>`,pm=document,mm=()=>pm.createComment(""),gm=e=>null===e||"object"!=typeof e&&"function"!=typeof e,bm=Array.isArray,ym="[ \t\n\f\r]",vm=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,km=/-->/g,wm=/>/g,xm=RegExp(`>|${ym}(?:([^\\s"'>=/]+)(${ym}*=${ym}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),Sm=/'/g,Cm=/"/g,Am=/^(?:script|style|textarea|title)$/i,Tm=(e=>(t,...n)=>({_$litType$:e,strings:t,values:n}))(1),Nm=Symbol.for("lit-noChange"),Om=Symbol.for("lit-nothing"),Mm=new WeakMap,Em=pm.createTreeWalker(pm,129);function Dm(e,t){if(!bm(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==cm?cm.createHTML(t):t}const _m=(e,t)=>{const n=e.length-1,i=[];let s,r=2===t?"<svg>":3===t?"<math>":"",o=vm;for(let t=0;t<n;t++){const n=e[t];let a,l,c=-1,h=0;for(;h<n.length&&(o.lastIndex=h,l=o.exec(n),null!==l);)h=o.lastIndex,o===vm?"!--"===l[1]?o=km:void 0!==l[1]?o=wm:void 0!==l[2]?(Am.test(l[2])&&(s=RegExp("</"+l[2],"g")),o=xm):void 0!==l[3]&&(o=xm):o===xm?">"===l[0]?(o=s??vm,c=-1):void 0===l[1]?c=-2:(c=o.lastIndex-l[2].length,a=l[1],o=void 0===l[3]?xm:'"'===l[3]?Cm:Sm):o===Cm||o===Sm?o=xm:o===km||o===wm?o=vm:(o=xm,s=void 0);const u=o===xm&&e[t+1].startsWith("/>")?" ":"";r+=o===vm?n+fm:c>=0?(i.push(a),n.slice(0,c)+hm+n.slice(c)+um+u):n+um+(-2===c?t:u)}return[Dm(e,r+(e[n]||"<?>")+(2===t?"</svg>":3===t?"</math>":"")),i]};class Im{constructor({strings:e,_$litType$:t},n){let i;this.parts=[];let s=0,r=0;const o=e.length-1,a=this.parts,[l,c]=_m(e,t);if(this.el=Im.createElement(l,n),Em.currentNode=this.el.content,2===t||3===t){const e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;null!==(i=Em.nextNode())&&a.length<o;){if(1===i.nodeType){if(i.hasAttributes())for(const e of i.getAttributeNames())if(e.endsWith(hm)){const t=c[r++],n=i.getAttribute(e).split(um),o=/([.?@])?(.*)/.exec(t);a.push({type:1,index:s,name:o[2],strings:n,ctor:"."===o[1]?Lm:"?"===o[1]?zm:"@"===o[1]?Fm:$m}),i.removeAttribute(e)}else e.startsWith(um)&&(a.push({type:6,index:s}),i.removeAttribute(e));if(Am.test(i.tagName)){const e=i.textContent.split(um),t=e.length-1;if(t>0){i.textContent=lm?lm.emptyScript:"";for(let n=0;n<t;n++)i.append(e[n],mm()),Em.nextNode(),a.push({type:2,index:++s});i.append(e[t],mm())}}}else if(8===i.nodeType)if(i.data===dm)a.push({type:2,index:s});else{let e=-1;for(;-1!==(e=i.data.indexOf(um,e+1));)a.push({type:7,index:s}),e+=um.length-1}s++}}static createElement(e,t){const n=pm.createElement("template");return n.innerHTML=e,n}}function Bm(e,t,n=e,i){if(t===Nm)return t;let s=void 0!==i?n._$Co?.[i]:n._$Cl;const r=gm(t)?void 0:t._$litDirective$;return s?.constructor!==r&&(s?._$AO?.(!1),void 0===r?s=void 0:(s=new r(e),s._$AT(e,n,i)),void 0!==i?(n._$Co??=[])[i]=s:n._$Cl=s),void 0!==s&&(t=Bm(e,s._$AS(e,t.values),s,i)),t}class Pm{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:n}=this._$AD,i=(e?.creationScope??pm).importNode(t,!0);Em.currentNode=i;let s=Em.nextNode(),r=0,o=0,a=n[0];for(;void 0!==a;){if(r===a.index){let t;2===a.type?t=new Rm(s,s.nextSibling,this,e):1===a.type?t=new a.ctor(s,a.name,a.strings,this,e):6===a.type&&(t=new jm(s,this,e)),this._$AV.push(t),a=n[++o]}r!==a?.index&&(s=Em.nextNode(),r++)}return Em.currentNode=pm,i}p(e){let t=0;for(const n of this._$AV)void 0!==n&&(void 0!==n.strings?(n._$AI(e,n,t),t+=n.strings.length-2):n._$AI(e[t])),t++}}class Rm{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,n,i){this.type=2,this._$AH=Om,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return void 0!==t&&11===e?.nodeType&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=Bm(this,e,t),gm(e)?e===Om||null==e||""===e?(this._$AH!==Om&&this._$AR(),this._$AH=Om):e!==this._$AH&&e!==Nm&&this._(e):void 0!==e._$litType$?this.$(e):void 0!==e.nodeType?this.T(e):(e=>bm(e)||"function"==typeof e?.[Symbol.iterator])(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==Om&&gm(this._$AH)?this._$AA.nextSibling.data=e:this.T(pm.createTextNode(e)),this._$AH=e}$(e){const{values:t,_$litType$:n}=e,i="number"==typeof n?this._$AC(e):(void 0===n.el&&(n.el=Im.createElement(Dm(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===i)this._$AH.p(t);else{const e=new Pm(i,this),n=e.u(this.options);e.p(t),this.T(n),this._$AH=e}}_$AC(e){let t=Mm.get(e.strings);return void 0===t&&Mm.set(e.strings,t=new Im(e)),t}k(e){bm(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let n,i=0;for(const s of e)i===t.length?t.push(n=new Rm(this.O(mm()),this.O(mm()),this,this.options)):n=t[i],n._$AI(s),i++;i<t.length&&(this._$AR(n&&n._$AB.nextSibling,i),t.length=i)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){const t=am(e).nextSibling;am(e).remove(),e=t}}setConnected(e){void 0===this._$AM&&(this._$Cv=e,this._$AP?.(e))}}class $m{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,n,i,s){this.type=1,this._$AH=Om,this._$AN=void 0,this.element=e,this.name=t,this._$AM=i,this.options=s,n.length>2||""!==n[0]||""!==n[1]?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=Om}_$AI(e,t=this,n,i){const s=this.strings;let r=!1;if(void 0===s)e=Bm(this,e,t,0),r=!gm(e)||e!==this._$AH&&e!==Nm,r&&(this._$AH=e);else{const i=e;let o,a;for(e=s[0],o=0;o<s.length-1;o++)a=Bm(this,i[n+o],t,o),a===Nm&&(a=this._$AH[o]),r||=!gm(a)||a!==this._$AH[o],a===Om?e=Om:e!==Om&&(e+=(a??"")+s[o+1]),this._$AH[o]=a}r&&!i&&this.j(e)}j(e){e===Om?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class Lm extends $m{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===Om?void 0:e}}class zm extends $m{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==Om)}}class Fm extends $m{constructor(e,t,n,i,s){super(e,t,n,i,s),this.type=5}_$AI(e,t=this){if((e=Bm(this,e,t,0)??Om)===Nm)return;const n=this._$AH,i=e===Om&&n!==Om||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,s=e!==Om&&(n===Om||i);i&&this.element.removeEventListener(this.name,this,n),s&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}}class jm{constructor(e,t,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){Bm(this,e)}}const Wm=om.litHtmlPolyfillSupport;Wm?.(Im,Rm),(om.litHtmlVersions??=[]).push("3.3.2");const Um=globalThis;
|
|
13
13
|
/**
|
|
14
14
|
* @license
|
|
15
15
|
* Copyright 2017 Google LLC
|
|
16
16
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
17
|
-
*/class Vm extends rm{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=((e,t,n)=>{const i=n?.renderBefore??t;let s=i._$litPart$;if(void 0===s){const e=n?.renderBefore??null;i._$litPart$=s=new
|
|
17
|
+
*/class Vm extends rm{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=((e,t,n)=>{const i=n?.renderBefore??t;let s=i._$litPart$;if(void 0===s){const e=n?.renderBefore??null;i._$litPart$=s=new Rm(t.insertBefore(mm(),e),e,void 0,n??{})}return s._$AI(e),s})(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Nm}}Vm._$litElement$=!0,Vm.finalized=!0,Um.litElementHydrateSupport?.({LitElement:Vm});const Hm=Um.litElementPolyfillSupport;Hm?.({LitElement:Vm}),(Um.litElementVersions??=[]).push("4.2.2");
|
|
18
18
|
/**
|
|
19
19
|
* @license
|
|
20
20
|
* Copyright 2017 Google LLC
|
|
@@ -41,7 +41,7 @@ const qm=e=>(t,n)=>{void 0!==n?n.addInitializer(()=>{customElements.define(e,t)}
|
|
|
41
41
|
* Copyright 2017 Google LLC
|
|
42
42
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
43
43
|
*/
|
|
44
|
-
function Gm(e,t){return(t,n,i)=>((e,t,n)=>(n.configurable=!0,n.enumerable=!0,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,n),n))(t,n,{get(){return(t=>t.renderRoot?.querySelector(e)??null)(this)}})}function Qm(e){return e[0].toUpperCase()+e.slice(1)}function Xm(e){const t=e.slice(1,-1).split("\\\\");for(let e=0;e<t.length;++e){const n=t[e].replace(/\\(\r\n|\n|\r)/g,"\\n").replace(/(?<=^|[^\\])"/g,'\\"');t[e]=JSON.parse(`"${n}"`)}return t.join("\\")}function eg(e,t){const n=[];for(const[i,s]of Object.entries(e)){if("removed"===s.kind||!t(s))continue;const e="import"!==s.kind&&"import-alias"!==s.kind?s.doc:void 0;n.push({name:i,doc:e})}return n}class tg{constructor(){this.expectedNamesData=[],this.expectedNameSet=new Set}collect(e){for(const t of e)t.modulePath?this.expectedNamesData.push(t):this.expectedNameSet.has(t.name)||(this.expectedNamesData.push(t),this.expectedNameSet.add(t.name))}get expectedNames(){return this.expectedNamesData}}function ng(e,t,n,i,s){const r=("field"===e.kind?e.field.doc:e.doc).pieces.filter(e=>"reference"===e.kind);if(r.length<=0)return;const o=function(e,t,n){const i=[],s=e=>{const{key:t}=e,s=[...n.get(t).recordAncestors].reverse();for(const e of s)i.push(e)},r=e=>{if(e){const t=rg(e);if(t){const{record:e}=n.get(t);i.push(e)}}};switch(e.kind){case"constant":i.push(t),r(e.type);break;case"field":{const{field:n,record:o}=e;s(o),i.push(t),r(n.type);break}case"method":i.push(t),r(e.requestType),r(e.responseType);break;case"record":s(e),i.push(t)}return i}(e,t,i);for(const e of r)ig(e,o,t,n,s)}function ig(e,t,n,i,s){const{nameParts:r}=e;if(r.length<=0)return;const o=new tg;for(const a of t){if(e.absolute&&a!==n)continue;const t=sg(r,a,n,i);if("no-match"!==t.kind)return"failed-match"===t.kind?void(t.error&&s.push(t.error)):void(e.referee=t);o.collect(t.expectedNames)}const a=r[0].token;s.push({token:a,message:"Not found",expectedNames:o.expectedNames})}function sg(e,t,n,i){let s=!1;for(let r=0;r<e.length;r++){const o=e[r],a=t.nameToDeclaration[o.token.text];if(!a){const e=eg(t.nameToDeclaration,e=>t===n||"import"!==e.kind&&"import-alias"!==e.kind);return s?{kind:"failed-match",error:{token:o.token,message:"Not found",expectedNames:e}}:{kind:"no-match",expectedNames:e}}s=!0;const l=r===e.length-1,c=()=>({kind:"failed-match",error:{token:o.token,message:"Expected to be the last name in the sequence"}});switch(a.kind){case"constant":case"method":return o.declaration=a,l?a:c();case"record":if(t=a,o.declaration=a,l)return a;break;case"field":return o.declaration=a,l?{kind:"field",field:a,record:t}:c();case"import-alias":if(l)return{kind:"failed-match",error:{token:o.token,message:"Cannot be the last name in the sequence"}};case"import":{if(t!==n)return{kind:"failed-match",error:{token:o.token,message:"Cannot refer to other module's imports"}};const{resolvedModulePath:e}=a;if(!e)return{kind:"failed-match",error:null};const s=i(e);if(!s)return{kind:"failed-match",error:null};t=s,"import"===a.kind?--r:o.declaration=a;break}case"removed":throw new TypeError}}throw new Error("Unreachable")}function rg(e){switch(e.kind){case"array":return rg(e.item);case"optional":return rg(e.other);case"record":return e.key;case"primitive":return null}}function og(e,t){switch(t){case"bool":return"false"===e||"true"===e;case"bytes":return ag(e)&&/^hex:([0-9A-Fa-f]{2})*$/.test(Xm(e));case"timestamp":{if(!ag(e))return!1;const t=Xm(e),n=Date.parse(t).valueOf();return/(Z|[+-]\d\d:\d\d)$/.test(t)&&-864e13<=n&&n<=864e13&&n===Math.round(n)}case"int32":return lg(e,BigInt(-2147483648),BigInt(2147483647));case"int64":return lg(e,BigInt("-9223372036854775808"),BigInt("9223372036854775807"));case"hash64":return lg(e,BigInt(0),BigInt("18446744073709551615"));case"float32":case"float64":if(ag(e)){const t=Xm(e);return"NaN"===t||"Infinity"===t||"-Infinity"===t}return/^[-0-9]/.test(e);case"string":return ag(e)}}function ag(e){return/^['"]/.test(e)}function lg(e,t,n){if(!/^-?[0-9]+$/.test(e))return!1;const i=BigInt(e);return t<=i&&i<=n}function cg(e,t){switch(t){case"bool":return"true"===e?1:0;case"bytes":return function(e){const t=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2)t[n/2]=parseInt(e.slice(n,n+2),16);const n=Array.from(t,e=>String.fromCharCode(e)).join("");return btoa(n)}(Xm(e).substring(4));case"timestamp":{const t=Xm(e);return Math.round(new Date(t).valueOf())}case"int32":case"float32":case"float64":return ag(e)?Xm(e):Number(e);case"int64":case"hash64":return String(BigInt(e));case"string":return Xm(e)}}function hg(e,t){const n=cg(e,t);return"string"==typeof n?n:JSON.stringify(n)}function ug(e,t,n){(function(e,t){switch(t){case"lower_underscore":return/^[a-z][0-9a-z]*(_[a-z][0-9a-z]*)*$/.test(e);case"UpperCamel":return/^[A-Z][0-9A-Za-z]*$/.test(e)&&(/^[A-Z][0-9]*$/.test(e)||/[a-z]/.test(e));case"UPPER_UNDERSCORE":return/^[A-Z][0-9A-Z]*(_[A-Z][0-9A-Z]*)*$/.test(e)}})(e.text,t)||n.push({token:e,expected:t})}function dg(e,t){return new fg(e,t).parse()}class fg{constructor(e,t){this.docComment=e,this.completionMode=t,this.pieces=[],this.errors=[],this.currentText="",this.charIndex=-1;const{text:n}=e;if(n.startsWith("/// "))this.content=n.slice(4);else{if(!n.startsWith("///"))throw new Error("Expected doc comment to start with ///");this.content=n.slice(3)}this.charIndex=0}parse(){this.parseDocComment(),this.currentText.length>0&&this.pieces.push({kind:"text",text:this.currentText});const{pieces:e}=this,t=e.map(e=>{switch(e.kind){case"text":return e.text;case"reference":return e.referenceRange.text}}).join("");return{result:{text:t,pieces:this.pieces},errors:this.errors}}parseDocComment(){const e=/\[\[|\]\]|\[|\]/g;for(;this.charIndex<this.content.length;){e.lastIndex=this.charIndex;const t=e.exec(this.content);if(!t){this.currentText+=this.content.slice(this.charIndex);break}t.index>this.charIndex&&(this.currentText+=this.content.slice(this.charIndex,t.index));const n=t[0];if(this.charIndex=t.index,"[["===n)this.currentText+="[",this.charIndex+=2;else if("]]"===n)this.currentText+="]",this.charIndex+=2;else if("["===n){this.currentText.length>0&&(this.pieces.push({kind:"text",text:this.currentText}),this.currentText="");const e=this.parseReference();this.pieces.push(e)}else"]"===n&&(this.currentText+=n,this.charIndex++)}}parseReference(){const{content:e,docComment:t}=this,n=this.charIndex,i=t.text.length-e.length,s=t.position+i+n,r=e.indexOf("]",n),o=r<0?e.length:r+1,a=e.slice(n,o),l={text:a,originalText:a,position:s,line:t.line,colNumber:s-t.line.position};let c=!1;r<0&&(c=!0,this.errors.push({token:l,message:"Unterminated reference"})),this.charIndex++;const h=/[a-zA-Z][_a-zA-Z0-9]*/g,u=[];for(;this.charIndex<o;){const n=e[this.charIndex],i=t.text.length-e.length,s=t.position+i+this.charIndex,r=e=>({text:e,originalText:e,position:s,line:t.line,colNumber:s-t.line.position});if("."===n)u.push(r(".")),this.charIndex++;else if(/^[a-zA-Z]/.test(n)){h.lastIndex=this.charIndex;const t=h.exec(e)[0];u.push(r(t)),this.charIndex+=t.length}else if("]"===n)u.push(r("]")),this.charIndex++;else{const n=t.text.length-e.length,i=this.docComment.colNumber+n+this.charIndex;c=!0,this.errors.push({token:l,message:`Invalid character in reference at column ${i+1}`}),this.charIndex=o}}if(!c&&this.completionMode){const{position:e}=this.completionMode,n=s,r=t.position+i+o;if(e>=n&&e<r){const n=u.some(t=>/^[a-zA-Z]/.test(t.text)&&e>=t.position&&e<=t.position+t.text.length);if(!n){const n={text:"...",originalText:"",position:e,line:t.line,colNumber:e-t.line.position},i=u.findIndex(t=>t.position>=e);-1===i?u.push(n):u.splice(i,0,n)}}}return{kind:"reference",nameParts:c?[]:this.parseNameParts(u),absolute:"."===u[0]?.text,referee:void 0,docComment:this.docComment,referenceRange:l}}parseNameParts(e){const t=[];let n="identifier or '.'";for(const i of e){let e;if(/^[a-zA-Z]/.test(i.text)||"..."===i.text)e="identifier or '.'"===n||"identifier"===n,n="'.' or ']'",t.push({token:i,declaration:void 0});else if("."===i.text)e="identifier or '.'"===n||"'.' or ']'"===n,n="identifier";else{if("]"!==i.text)throw new Error(`Unexpected token in doc reference: ${i.text}`);e="'.' or ']'"===n}if(!e)return this.errors.push({token:i,expected:n}),[];if("]"===i.text)return t}return[]}}const pg=Object.freeze({text:"",pieces:Object.freeze([])});function mg(e,t){const{modulePath:n,sourceCode:i}=e,s=[],r=new Pg(e,t,s),o=gg(r,"module"),a=o.filter(e=>"broken-constant"===e.kind),l=o.filter(e=>"broken-method"===e.kind),c=o.filter(e=>"broken-constant"!==e.kind&&"broken-method"!==e.kind);r.expectThenNext([""]);const h={},u=new Map;for(const e of c){let t,i,r;if("import"===e.kind?(t=e.importedNames,i=Bg(e.modulePath,n,s),r=e):"import-alias"===e.kind?(t=[e.name],i=Bg(e.modulePath,n,s),r=e):t=[e.name],i){let e=u.get(i);e||(e=[],u.set(i,e)),e.push(r),r.resolvedModulePath=i}for(const n of t){const t=n.text;t in h?s.push({token:n,message:`Duplicate identifier '${t}'`}):h[t]=e}}const d=function(e,t,n){let i,s="no-import-seen",r=-1,o=!1;for(const t of e)"import"===t.kind||"import-alias"===t.kind?("no-import-seen"===s?(s="first-legal-import-seen",i=t.range.start):"last-legal-import-seen"===s&&(n.push({token:t.importToken,message:"Import declarations must be grouped together at the top"}),o=!0),r=Math.max(r,t.range.end)):s="last-legal-import-seen";if(void 0===i||o)return null;const a={start:i,end:r};{let e=t.tokensWithComments;e=e.slice(e.findIndex(e=>e.position>=a.start)),e=e.slice(0,e.findIndex(e=>e.position>=a.end));for(const t of e)t.text.startsWith("//")&&(n.push({token:t,message:"Comments not allowed within import block"}),o=!0)}return o?null:a}(c,e,s),f={};for(const[e,t]of u){const n=t.filter(e=>"import"===e.kind),i=t.filter(e=>"import-alias"===e.kind);if(n.length&&i.length)for(const e of n)s.push({token:e.modulePath,message:"Module already imported with an alias"});else if(i.length>=2)for(const e of i.slice(1))s.push({token:e.modulePath,message:"Module already imported with a different alias"});else if(n.length){const t=new Set;for(const e of n)for(const n of e.importedNames)t.add(n.text);f[e]={kind:"some",names:t}}else{const t=i[0].name.text;f[e]={kind:"all",alias:t}}}const p=c.filter(e=>"method"===e.kind),m=c.filter(e=>"constant"===e.kind);return{result:{kind:"module",path:n,sourceCode:i,nameToDeclaration:h,declarations:c,importBlockRange:d,records:Ig(c),pathToImportedNames:f,methods:p,brokenMethods:l,constants:m,brokenConstants:a},errors:s}}function gg(e,t){const n=[],i=e=>""===e||"module"!==t&&"}"===e,s=e=>"}"===e||";"===e;for(;!i(e.current);){const i=e.index,r=yg(e,t);if(null!==r)n.push(r),"method"!==r.kind&&"broken-method"!==r.kind||(r.inlineRequestRecord&&n.push(r.inlineRequestRecord),r.inlineResponseRecord&&n.push(r.inlineResponseRecord));else{const t=e.index===i;if(t&&(e.next(),s(e.previous)))continue;if(t||""!==e.current&&!s(e.previous)){let t=0;for(;;){const n=e.current;if(""===n)break;if(e.next(),"{"===n?++t:"}"===n&&--t,t<=0&&s(n))break}}}}return n}function yg(e,t){const n=function(e){const{moduleTokens:t}=e,n=[];for(;e.current.startsWith("///");)n.push(e.currentToken),e.next();return function(e){if(e.length<=0)return pg;const t=e.map(e=>e.text).join("\n"),n=[];for(let t=0;t<e.length;++t){const i=e[t];0!==t&&n.push({kind:"text",text:"\n"}),i.pieces.forEach(e=>n.push(e))}return{text:t,pieces:n}}(n.map(e=>t.posToDoc[e.position]??Og))}(e);let i="enum";const s="module"===t,r=["struct","enum",s?null:"removed",s?null:Eg,s?"import":null,s?"method":null,s?"const":null],o=e.expectThenNext(r);switch(o.case){case 0:i="struct";case 1:return bg(e,i,n);case 2:return function(e,t){const n=[];let i,s="?";e:for(;;){const r="?"===s||","===s||".."===s,o=[","===s||".."===s?",":null,"?"===s||"0"===s||"1"===s?Ng:null,r?";":null,".."===s?"..":null],a=e.expectThenNext(o);switch(a.case){case 0:s="0";break;case 1:{const r=+a.token.text;if(void 0===i)s="..",n.push(r);else{s=",",r<=i&&e.errors.push({token:t,message:"Upper bound must be greater than lower bound"});for(let e=i;e<=r;++e)n.push(e);i=void 0}break}case 2:break e;case 3:s="1",i=n.pop();break;case-1:if(r)break e;return null}}const r=new Set;for(const i of n){if(r.has(i))return e.errors.push({token:t,message:`Duplicate field number ${i}`}),null;r.add(i)}return{kind:"removed",removedToken:t,numbers:n}}(e,o.token);case 3:return function(e,t,n,i){let s,r,o=-1;const a=()=>({kind:"field",name:t,number:o,doc:n,unresolvedType:s,type:void 0,isRecursive:!1,inlineRecord:r});for(;;){const n=void 0!==s||"enum"===i,l=[void 0===s&&o<0?":":null,o<0&&n?"=":null,n?";":null];switch(e.expectThenNext(l).case){case 0:{const n=kg(e,{context:"field",originalName:t});if(s=n.type,r=n.inlineRecord,void 0===s)return null;break}case 1:if(o=Cg(e),o<0)return null;break;case 2:return ug(t,s?"lower_underscore":"UPPER_UNDERSCORE",e.errors),"enum"===i&&"UNKNOWN"===t.text&&e.errors.push({token:t,message:"Cannot name field of enum: UNKNOWN"}),a();case-1:return n?a():null}}}(e,o.token,n,t);case 4:return function(e,t){const n=e.expectThenNext(["*","{",Eg]);switch(n.case){case 0:return function(e,t){if(e.expectThenNext(["as"]).case<0)return null;const n=e.expectThenNext([Eg]);if(n.case<0)return null;if(ug(n.token,"lower_underscore",e.errors),e.expectThenNext(["from"]).case<0)return null;const i=e.expectThenNext([_g]);if(i.case<0)return null;const s={start:t.position,end:e.currentToken.position+e.current.length};e.expectThenNext([";"]);const r=i.token;return{kind:"import-alias",importToken:t,name:n.token,range:s,modulePath:r}}(e,t);case 1:return Ag(e,t);case 2:return Ag(e,t,n.token);default:return null}}(e,o.token);case 5:return function(e,t){const n=e.expectThenNext([Eg]);if(n.case<0)return null;const i=n.token;if(ug(i,"UpperCamel",e.errors),e.expectThenNext(["("]).case<0)return null;const s=kg(e,{context:"method-request",originalName:i}),r=s.type;if(!r)return null;if(e.expectThenNext([")"]).case<0)return null;if(e.expectThenNext([":"]).case<0)return{kind:"broken-method",unresolvedRequestType:r,inlineRequestRecord:s.inlineRecord,unresolvedResponseType:void 0,inlineResponseRecord:void 0};const o=kg(e,{context:"method-response",originalName:i}),a=o.type;if(!a)return null;if(e.expectThenNext(["="]).case<0)return{kind:"broken-method",unresolvedRequestType:r,inlineRequestRecord:s.inlineRecord,unresolvedResponseType:a,inlineResponseRecord:o.inlineRecord};const l=Cg(e,"?");if(-2===l)return null;return e.expectThenNext([";"]),{kind:"method",name:n.token,doc:t,unresolvedRequestType:r,unresolvedResponseType:a,requestType:void 0,responseType:void 0,number:l,inlineRequestRecord:s.inlineRecord,inlineResponseRecord:o.inlineRecord}}(e,n);case 6:return function(e,t){const n=e.expectThenNext([Eg]);if(n.case<0)return null;if(ug(n.token,"UPPER_UNDERSCORE",e.errors),e.expectThenNext([":"]).case<0)return null;const i=xg(e);if(!i)return null;if(e.expectThenNext(["="]).case<0)return{kind:"broken-constant",unresolvedType:i};const s=Tg(e);if(null===s)return null;return e.expectThenNext([";"]),{kind:"constant",name:n.token,doc:t,unresolvedType:i,type:void 0,value:s,valueAsDenseJson:void 0}}(e,n);default:return null}}class vg{constructor(e,t,n,i,s,r){this.recordName=e,this.recordType=t,this.doc=n,this.stableId=i,this.inlineContext=s,this.errors=r,this.nameToDeclaration={},this.numbers=new Set,this.numbering="",this.removedNumbers=[]}addDeclaration(e){if("broken"===this.numbering)return;let t,n,i=[],s=this.numbering;const r=this.numbers.size+("enum"===this.recordType?1:0);switch(e.kind){case"field":t=e.name,n=t,s=e.number<0?"implicit":"explicit",e.number<0&&(e={...e,number:r}),i=[e.number];break;case"record":t=e.name,n=t;break;case"removed":n=e.removedToken,e.numbers.length?(s="explicit",i=e.numbers):(s="implicit",i=[r])}if(""===this.numbering?this.numbering=s:this.numbering!==s&&(this.errors.push({token:n,message:"Cannot mix implicit and explicit numbering"}),this.numbering="broken"),void 0!==t){const n=t.text;if(n in this.nameToDeclaration)return void this.errors.push({token:t,message:`Duplicate identifier '${n}'`});this.nameToDeclaration[n]=e}for(const e of i){if(this.numbers.has(e))return this.errors.push({token:n,message:`Duplicate field number ${e}`}),void(this.numbering="broken");if(0===e&&"enum"===this.recordType)return void this.errors.push({token:n,message:"Number 0 is reserved for UNKNOWN field"});this.numbers.add(e)}"removed"===e.kind&&this.removedNumbers.push(...i)}build(){const e="struct"===this.recordType;if(e)for(let e=0;e<this.numbers.size;++e)if(!this.numbers.has(e)){this.errors.push({token:this.recordName,message:`Missing field number ${e}`});break}const t=Object.values(this.nameToDeclaration),n=t.filter(e=>"field"===e.kind),i=t.filter(e=>"record"===e.kind),{recordName:s}=this;let r=`${s.line.modulePath}:${s.position}`;this.inlineContext&&(r+=`:${this.inlineContext.context}`);const o=e&&n.length?Math.max(...n.map(e=>e.number))+1:0,a=e?this.numbers.size:0;return{kind:"record",key:r,name:this.recordName,recordType:this.recordType,doc:this.doc,nameToDeclaration:this.nameToDeclaration,declarations:Object.values(this.nameToDeclaration),fields:n,nestedRecords:i,removedNumbers:this.removedNumbers.sort(),recordNumber:this.stableId,numSlots:o,numSlotsInclRemovedNumbers:a}}}function bg(e,t,n,i){let s;if(i){const{originalName:e}=i;let t=function(e,t){let n;switch(n=e.includes("_")||!/[a-z]/.test(e)?e.split("_").map(e=>e.toLowerCase()):e.split(/(?=[A-Z])/).map(e=>e.toLowerCase()),t){case"lowerCamel":return n.map((e,t)=>t?Qm(e):e).join("");case"lower_underscore":return n.join("_");case"UpperCamel":return n.map(Qm).join("");case"UPPER_UNDERSCORE":return n.map(e=>e.toUpperCase()).join("_")}}(e.text,"UpperCamel");"method-request"===i.context?t+="Request":"method-response"===i.context&&(t+="Response"),s={...e,text:t}}else{const t=e.expectThenNext([Eg]);if(t.case<0)return null;ug(t.token,"UpperCamel",e.errors),s=t.token}let r=null;if("("===e.current){if(e.next(),r=Cg(e,"?"),-2===r)return null;if(e.expectThenNext([")"]).case<0)return null}if(e.expectThenNext(["{"]).case<0)return null;const o=gg(e,t);e.expectThenNext(["}"]);const a=new vg(s,t,n,r,i,e.errors);for(const e of o)a.addDeclaration(e),"field"===e.kind&&e.inlineRecord&&a.addDeclaration(e.inlineRecord);return a.build()}const wg=new Set(["bool","int32","int64","hash64","float32","float64","timestamp","string","bytes"]);function kg(e,t){if("struct"===e.current||"enum"===e.current){const n=e.current;e.next();const i=bg(e,n,Og,t);return{type:i?{kind:"record",nameParts:[i.name],absolute:!1}:void 0,inlineRecord:i||void 0}}return{type:xg(e),inlineRecord:void 0}}function xg(e){const t=e.expectThenNext(["[",Eg,"."]);let n;switch(t.case){case 0:n=function(e){const t=xg(e);if(void 0===t)return;let n;for(;;){const i=!n&&"record"===t.kind,s=e.expectThenNext([i?"|":null,"]"]);switch(s.case){case 0:if(n=Sg(e,s.token),null===n)return;break;case 1:return{kind:"array",item:t,key:n};default:return}}}(e);break;case 1:if(wg.has(t.token.text)){n={kind:"primitive",primitive:t.token.text};break}case 2:n=function(e,t){const n="."===t.text,i=[];if("."===t.text){const t=e.expectThenNext([Eg]);if(t.case<0)return;i.push(t.token)}else i.push(t);for(;"."===e.current;){e.next();const t=e.expectThenNext([Eg]);if(t.case<0)return;i.push(t.token)}return{kind:"record",nameParts:i,absolute:n}}(e,t.token);break;default:return}if(void 0!==n)return"?"===e.current?(e.next(),{kind:"optional",other:n}):n}function Sg(e,t){const n=[];for(;;){const t=e.expectThenNext([Eg]);if(t.case<0)return;if(n.push(t.token),"."!==e.current)break;e.next()}const i=n.map(e=>({name:e}));return{pipeToken:t,path:i,keyType:{kind:"primitive",primitive:"bool"}}}function Cg(e,t){if(t&&"lenient"===e.mode&&"?"===e.current)return e.next(),-1;const n=e.expectThenNext([Ng]);if(n.case<0)return-2;const{text:i}=n.token;return BigInt(i)<BigInt(2**32)?+i:(e.errors.push({token:n.token,message:"Value out of uint32 range"}),-2)}function Ag(e,t,n){const i=n?[n]:[];if(n)for(;","===e.current;){e.next();const t=e.expectThenNext([Eg]);if(t.case<0)return null;i.push(t.token)}else for(;;){let t=e.expectThenNext([Eg,"}"]);if(0!==t.case){if(1===t.case)break;return null}if(i.push(t.token),t=e.expectThenNext([",","}"]),1===t.case)break;if(t.case<0)return null}if(e.expectThenNext(["from"]).case<0)return null;const s=e.expectThenNext([_g]);if(s.case<0)return null;const r={start:t.position,end:e.currentToken.position+e.current.length};e.expectThenNext([";"]);return{kind:"import",importToken:t,importedNames:i,range:r,modulePath:s.token}}function Tg(e){const t=["{","{|","[","false","true","null",Dg,_g],n=e.expectThenNext(t);switch(n.case){case 0:case 1:{const t=1===n.case;return function(e,t,n){const i=n?"|}":"}",s={},r=[],o=()=>({kind:"object",token:e,entries:s,orphanNames:r,partial:n});for(;;){if(t.current===i)return t.next(),o();const e=t.expectThenNext([Eg]);if(e.case<0)return null;const n=e.token,a=e.token.text;if(t.expectThenNext([":"]).case<0){r.push(n);continue}a in s&&t.errors.push({token:e.token,message:"Duplicate field"});const l=Tg(t);if(null===l)return null;s[a]={name:n,value:l};const c=t.expectThenNext([",",i]);if(c.case<0)return null;if(c.token.text===i)return o()}}(n.token,e,t)}case 2:{const t=function(e){if("]"===e.current)return e.next(),[];const t=[];for(;;){const n=Tg(e);if(null===n)return null;t.push(n);const i=e.expectThenNext([",","]"]);if(i.case<0)return null;if("]"===i.token.text)return t;if("]"===e.current)return e.next(),t}}(e);return null===t?null:{kind:"array",token:n.token,items:t}}case 3:case 4:case 5:case 6:case 7:return{kind:"literal",token:n.token};default:return null}}const Og=Object.freeze({text:"",pieces:Object.freeze([])});class Mg{}const Eg=new class extends Mg{matches(e){return/^\w/.test(e)||"..."===e}what(){return"identifier"}};const Ng=new class extends Mg{matches(e){return/^[0-9]+$/.test(e)}what(){return"positive integer"}};const Dg=new class extends Mg{matches(e){return/^[0-9-]/.test(e)}what(){return"number"}};const _g=new class extends Mg{matches(e){return/^["']/.test(e)}what(){return"string literal"}};class Pg{constructor(e,t,n){this.moduleTokens=e,this.mode=t,this.errors=n,this.tokenIndex=0,this.tokens=e.tokens}expectThenNext(e){let t=this.tokens[this.tokenIndex];for(;t.text.startsWith("///");)this.errors.push({token:t,message:"Doc comments can only precede declarations"}),++this.tokenIndex,t=this.tokens[this.tokenIndex];for(let n=0;n<e.length;++n){const i=e[n];if(null===i)continue;if(i instanceof Mg?i.matches(t.text):t.text===i)return++this.tokenIndex,{case:n,token:t}}const n=[];for(let t=0;t<e.length;++t){const i=e[t];null!==i&&n.push(i instanceof Mg?i.what():`'${i}'`)}const i=1===n.length?n[0]:`one of: ${n.join(", ")}`;return this.errors.push({token:t,expected:i}),{case:-1,token:t}}get currentToken(){return this.tokens[this.tokenIndex]}get current(){return this.currentToken.text}get previous(){return this.tokens[this.tokenIndex-1].text}next(){++this.tokenIndex}get index(){return this.tokenIndex}}function Ig(e){const t=[],n=(e,i)=>{for(const s of e){if("record"!==s.kind)continue;const e=i.concat([s]),r={kind:"record-location",record:s,recordAncestors:e,modulePath:s.name.line.modulePath};n(s.declarations,e),t.push(r)}};return n(e,[]),t}function Rg(e){const t=e.match(/^(@[^/]+\/[^/]+\/)/);return t?.at(1)??""}function $g(e){const t=e.split("/"),n=[];for(const e of t)".."===e?n.length>0&&".."!==n[n.length-1]?n.pop():n.push(".."):"."!==e&&""!==e&&n.push(e);return 0===n.length?".":n.join("/")}function Bg(e,t,n){let i=Xm(e.text);if(/\\/.test(i))n.push({token:e,message:"Replace backslash with slash"});else{if(i.startsWith("./")||i.startsWith("../")){if(i.includes("/@"))return void n.push({token:e,message:"Use absolute path"});i=$g(function(e){const t=e.lastIndexOf("/");return t>=0?e.slice(0,t):""}(t)+"/"+i)}else if(t.startsWith("@")&&!i.startsWith("@")){i=Rg(t)+i}if(i=$g(i),!i.startsWith("../"))return i;n.push({token:e,message:"Module path must point to a file within skir-src"})}}function Lg(e,t){return/^[0-9]/.test(e.text)?(t.push({token:e,message:"Invalid number"}),!1):e.text.startsWith("_")?(t.push({token:e,message:"Identifier cannot start with _"}),!1):e.text.endsWith("_")?(t.push({token:e,message:"Identifier cannot end with _"}),!1):e.text.includes("__")?(t.push({token:e,message:"Identifier cannot contain __ sequence"}),!1):!/_[0-9]/.test(e.text)||(t.push({token:e,message:"Digit cannot follow _"}),!1)}class zg{constructor(e,t){this.lines=[];const n=this.lines;let i,s=0;const r=/\n|\r|\n\r|$/g;for(;null!==(i=r.exec(e));){const o=i[0],a=r.lastIndex-o.length,l=e.substring(s,a);if(n.push({lineNumber:n.length,line:l,position:s,modulePath:t}),s=r.lastIndex,""===o)break}}advancePosition(e){const t=this.lines;for(;t.length>=2&&e>=this.lines[1].position;)t.shift();return t[0]}}class jg{static compile(e,t,n="strict"){return new jg(e,t,n)}static compileForCompletion(e,t,n,i){if(!n.has(e))throw new Error(`Not found: ${e}`);return new jg(n,i,"lenient",{modulePath:e,position:t}).modules.get(e)}constructor(e,t,n,i){this.modulePathToContent=e,this.parseMode=n,this.completionMode=i,this.moduleBundles=new Map,this.registry=new Fg,this.cache=t?new Ug(e,t.moduleBundles,t.registry):void 0;const s=i?[i.modulePath]:e.keys();for(const e of s)this.parseAndResolve(e,new Set);this.finalizationResult=this.finalize(),this.cache=void 0}parseAndResolve(e,t){const n=this.moduleBundles.get(e);if(void 0!==n)return n;const i=this.doParseAndResolve(e,t);return i&&this.moduleBundles.set(e,i),i}doParseAndResolve(e,t){const n=this.modulePathToContent.get(e);if(void 0===n)return null;let i,s;{let t;switch(t=e===this.completionMode?.modulePath?{kind:"no-cache"}:this.cache?.getModuleCacheResult(e)??{kind:"no-cache"},t.kind){case"no-cache":i=function(e,t,n){const i=[],s=[],r=new zg(e,t),o=/(\/\*([^*]|\*[^/])*(\*\/)?)|(\/\/[^\n\r]*)|(-?(0|[1-9][0-9]*)(\.[0-9]+)?\b)|\b(\w+)\b|([ \n\r\t]+)|(\.\.|\{\||\|\}|[{}[\]()*.:=;|?,])|("(\\(\n|\r|\n\r|.)|[^\\"\n\r])*"?)|('(\\(\n|\r|\n\r|.)|[^\\'\n\r])*'?)|($)/g;let a,l=0;for(;null!==(a=o.exec(e));){const t=o.lastIndex-a[0].length;if(t!==l){const n=r.advancePosition(l),i=l-n.position,o=e.substring(l,t);s.push({token:{text:o,originalText:o,position:l,line:n,colNumber:i},message:"Invalid sequence of characters"})}l=o.lastIndex;const n=r.advancePosition(t),c=t-n.position,h={text:a[0],originalText:a[0],position:t,line:n,colNumber:c};if(void 0===a[1]||a[1].endsWith("*/")||s.push({token:h,message:"Unterminated multi-line comment"}),void 0!==a[8]&&!Lg(h,s))continue;if(void 0!==a[9])continue;const u=a[11]||a[14];if(void 0!==u){if(!u.endsWith(u[0])){s.push({token:h,message:"Unterminated string literal"});continue}if(!/^["'](\\(\r\n|u[0-9A-Fa-f]{4}|["'\\/bfnrt\n\r])|[^\\])*["']$/.test(u)){s.push({token:h,message:"String literal contains invalid escape sequence"});continue}const e=Xm(u);try{encodeURIComponent(e)}catch{s.push({token:h,message:"String literal contains lone surrogates"});continue}}if(i.push(h),void 0!==a[17])break}if(void 0!==n){const{position:s}=n,r=i.find(e=>{const t=e.position,n=e.position+e.text.length;return/^\w/.test(e.text)?s>=t&&s<=n:s>t&&s<n});if(void 0===r){const n=new zg(e,t).advancePosition(s),r=s-n.position,o={text:"...",originalText:"",position:s,line:n,colNumber:r},a=i.findIndex(e=>e.position>=s);-1===a?i.push(o):i.splice(a,0,o)}}const c={};for(const e of i){if(!e.text.startsWith("///"))continue;const t=dg(e,n);c[e.position]=t.result,t.errors.forEach(e=>s.push(e))}return{result:{tokens:i.filter(e=>{return!((t=e.originalText).startsWith("/*")||t.startsWith("//")&&!t.startsWith("///"));var t}),tokensWithComments:i,posToDoc:c,sourceCode:e,modulePath:t},errors:s}}(n,e,this.completionMode);break;case"module-tokens":i=t.tokens;break;case"module-bundle":return this.registry.mergeFrom(t.bundle.registry),t.bundle}}const r=[];{const e=mg(i.result,this.parseMode);r.push(...e.errors),s=e.result}const o=new Vg(i,{result:s,errors:r});for(const n of s.declarations){if("import"!==n.kind&&"import-alias"!==n.kind)continue;const i=n.resolvedModulePath;if(void 0===i)continue;const s="Circular dependency between modules";if(t.has(e)){r.push({token:n.modulePath,message:s});continue}t.add(e);const o=this.parseAndResolve(i,t);if(t.delete(e),null===o)r.push({token:n.modulePath,message:"Module not found",expectedNames:Kg(Xm(n.modulePath.text),e,this.modulePathToContent.keys())});else if(0!==o.tokens.errors.length||0!==o.module.errors.length){const e=o.module.errors.some(e=>e.message===s);e?r.push({token:n.modulePath,message:s}):r.push({token:n.modulePath,message:"Imported module has errors",errorIsInOtherModule:!0})}else if("import"===n.kind)for(const e of n.importedNames){const t=o.module.result.nameToDeclaration[e.text];void 0===t?r.push({token:e,message:"Not found",expectedNames:eg(o.module.result.nameToDeclaration,e=>"record"===e.kind)}):"import"===t.kind?r.push({token:e,message:"Cannot reimport imported record"}):"record"!==t.kind&&r.push({token:e,message:"Not a record"})}}if(r.length&&!this.completionMode)return o;for(const t of s.records){const{key:n}=t.record;this.registry.recordMap.set(n,t),o.registry.recordMap.set(n,t);const{recordNumber:i}=t.record;null==i||e.startsWith("@")||o.registry.pushNumberRecord(i,n)}const a=new Set,l=new Wg(s,this.moduleBundles,this.completionMode?this.cache?.registry.topLevelNameToRecordLocations:void 0,a,r);for(const e of s.records)this.storeResolvedFieldTypes(e,l);const c=e=>ng(e,s,e=>this.moduleBundles.get(e)?.module.result,this.recordMap,r);for(const e of s.records){const{record:t}=e;this.storeFieldRecursivity(t);for(const e of t.fields){const{type:n}=e;n&&this.validateArrayKeys(n,r),c({kind:"field",field:e,record:t})}c(t)}const h=e=>{const t=l.resolve(e,"top-level");return t&&this.validateArrayKeys(t,r),t};for(const t of s.methods){const{unresolvedRequestType:n,unresolvedResponseType:i}=t;t.requestType=h(n),t.responseType=h(i);const{number:s}=t;e.startsWith("@")||o.registry.pushNumberMethod(s,t),c(t)}for(const e of s.brokenMethods){const{unresolvedRequestType:t,unresolvedResponseType:n}=e;h(t),n&&h(n)}for(const e of s.constants){const{unresolvedType:t}=e,n=h(t);e.type=n,n&&(e.valueAsDenseJson=this.valueToDenseJson(e.value,n,r)),c(e)}for(const e of s.brokenConstants){const{unresolvedType:t}=e;h(t)}return o.registry.pushTopLevelNames(s.declarations.filter(e=>"record"===e.kind).map(t=>({name:t.name.text,doc:t.doc,modulePath:e}))),function(e,t,n){for(const i of e.declarations)if("import"===i.kind)for(const e of i.importedNames)t.has(e.text)||n.push({token:e,message:"Unused import"});else"import-alias"===i.kind&&(t.has(i.name.text)||n.push({token:i.name,message:"Unused import alias"}))}(s,a,r),this.registry.mergeFrom(o.registry),o}storeResolvedFieldTypes(e,t){for(const n of e.record.fields)void 0!==n.unresolvedType&&(n.type=t.resolve(n.unresolvedType,e))}storeFieldRecursivity(e){for(const t of e.fields){if(!t.type)continue;const n="struct"===e.recordType?["hard","via-optional","soft"]:["soft"];for(const i of n){const n=new Set;if(this.collectTypeDeps(t.type,i,n),n.has(e.key)){t.isRecursive=i;break}}}}collectTypeDeps(e,t,n){switch(e.kind){case"record":{if("via-optional"===t)return;const{key:i}=e;if(n.has(i))return;n.add(i);const s=this.recordMap.get(i)?.record;if(!s)return void console.error("collectTypeDeps: record not found",i);if("hard"===t&&"enum"===s.recordType)return;for(const e of s.fields)void 0!==e.type&&this.collectTypeDeps(e.type,t,n);break}case"array":"soft"===t&&this.collectTypeDeps(e.item,t,n);break;case"optional":switch(t){case"soft":this.collectTypeDeps(e.other,t,n);break;case"via-optional":this.collectTypeDeps(e.other,"hard",n)}}}validateArrayKeys(e,t){const n=e=>{const{key:n,item:i}=e;if(!n)return;const{path:s}=n;let r,o=i;for(let e=0;e<s.length;++e){const i=s[e],a=i.name;if("record"!==o.kind){if(0===e)t.push({token:n.pipeToken,message:"Item must have struct type"});else{const n=s[e-1].name;t.push({token:n,message:"Must have struct type"})}return}const l=this.recordMap.get(o.key)?.record;if(!l)return void console.error("validateArrayKeys: record not found",o.key);if("struct"===l.recordType){const e=l.nameToDeclaration[a.text];if("field"!==e?.kind)return void t.push({token:a,message:`Field not found in struct ${l.name.text}`,expectedNames:eg(l.nameToDeclaration,e=>"field"===e.kind)});if(i.declaration=e,!e.type)return;o=e.type}else{if("kind"!==a.text)return void t.push({token:a,expected:"'kind'",expectedNames:[{name:"kind"}]});r=o,o={kind:"primitive",primitive:"string"}}}"primitive"===o.kind?n.keyType=r||o:t.push({token:s.at(-1).name,message:"Does not have primitive type"})},i=e=>{switch(e.kind){case"array":return n(e),i(e.item);case"optional":return i(e.other)}};i(e)}valueToDenseJson(e,t,n){switch(t.kind){case"optional":return"literal"===e.kind&&"null"===e.token.text?(e.type={kind:"null"},null):this.valueToDenseJson(e,t.other,n);case"array":{if("array"!==e.kind)return void n.push({token:e.token,expected:"array"});const i=[];let s=!0;for(const r of e.items){const e=this.valueToDenseJson(r,t.item,n);void 0!==e?i.push(e):s=!1}if(!s)return;const{key:r}=t;return e.key=r,r&&function(e,t,n){const{keyType:i,path:s}=t,r=e=>{let t=e;for(const e of s){const i=e.name;if("literal"===t.kind&&"kind"===i.text)return t;if("object"!==t.kind)return;const s=t.entries[i.text];if(!s)return void n.push({token:t.token,message:`Missing entry: ${i.text}`});t=s.value}return t},o=new Map;for(const t of e){const e=r(t);if(!e)return;if("literal"!==e.kind)return;let n;const s=e.token.text;if("primitive"===i.kind){const{primitive:e}=i;if(!og(s,e))continue;n=hg(s,e)}else{if(!ag(s))continue;n=Xm(s)}o.has(n)?o.get(n).push(e):o.set(n,[e])}for(const e of o.values())if(!(e.length<=1))for(const t of e)n.push({token:t.token,message:"Duplicate key"})}(e.items,r,n),i}case"record":{const i=this.recordMap.get(t.key);if(!i)return;return"struct"===i.record.recordType?this.structValueToDenseJson(e,i.record,n):this.enumValueToDenseJson(e,i.record,n)}case"primitive":{const{token:i}=e,{primitive:s}=t;return"literal"===e.kind&&og(i.text,s)?(e.type=t,cg(i.text,t.primitive)):void n.push({token:e.token,expected:s})}}}structValueToDenseJson(e,t,n){const{token:i}=e;if("object"!==e.kind)return void n.push({token:i,expected:"object"});const s=Array(t.numSlotsInclRemovedNumbers).fill(0);let r=!0;const o=Object.values(e.entries).map(e=>e.name).concat(e.orphanNames),a=new Set(o.map(e=>e.text));for(const e of o){const i=t.nameToDeclaration[e.text];"field"===i?.kind||(n.push({token:e,message:`Field not found in struct ${t.name.text}`,expectedNames:eg(t.nameToDeclaration,e=>"field"===e.kind&&!a.has(e.name.text))}),r=!1)}let l=0;for(const o of t.fields){const{type:t}=o;if(!t){r=!1;continue}const a=e.entries[o.name.text];let c;if(a?(a.fieldDeclaration=o,c=this.valueToDenseJson(a.value,t,n)):e.partial?c=this.getDefaultJson(t):n.push({token:i,message:`Missing entry: ${o.name.text}`}),void 0===c){r=!1;continue}s[o.number]=c;("optional"===t.kind?null===c:!c||Array.isArray(c)&&!c.length||"primitive"===t.kind&&("int64"===t.primitive||"hash64"===t.primitive)&&"0"===c)||(l=Math.max(l,o.number+1))}return r?(e.record=t,s.slice(0,l)):void 0}enumValueToDenseJson(e,t,n){const{token:i}=e;if("literal"===e.kind&&ag(i.text)){const s=Xm(i.text);if("UNKNOWN"===s)return 0;const r=t.nameToDeclaration[s];return"field"!==r?.kind?void n.push({token:i,message:`Variant not found in enum ${t.name.text}`,expectedNames:[{name:"UNKNOWN"}].concat(eg(t.nameToDeclaration,e=>"field"===e.kind&&!e.type))}):r.type?void n.push({token:i,message:"Refers to a wrapper variant"}):(e.type={kind:"enum",enum:t,variant:r},r.number)}if("object"===e.kind){const{entries:s}=e,r=s.kind,o=s.value,a=Object.values(s).map(e=>e.name).concat(e.orphanNames);for(const e of a){if("kind"===e.text||"value"===e.text)continue;const t=(r?[]:[{name:"kind"}]).concat(o?[]:[{name:"value"}]);return void n.push({token:e,message:"Extraneous entry",expectedNames:t})}if(!r)return void n.push({token:i,message:"Missing entry: kind"});const l=r.value.token;if("literal"!==r.value.kind||!ag(l.text))return void n.push({token:l,expected:"string"});const c=Xm(l.text),h=t.nameToDeclaration[c];if("field"!==h?.kind)return void n.push({token:l,message:`Variant not found in enum ${t.name.text}`,expectedNames:eg(t.nameToDeclaration,e=>"field"===e.kind&&!!e.type)});if(!h.type)return void n.push({token:l,message:"Refers to a constant variant"});if(!o)return void n.push({token:i,message:"Missing entry: value"});const u=this.valueToDenseJson(o.value,h.type,n);if(void 0===u)return;return e.record=t,[h.number,u]}n.push({token:i,expected:"string or object"})}getDefaultJson(e){switch(e.kind){case"primitive":switch(e.primitive){case"bool":case"int32":case"int64":case"hash64":case"float32":case"float64":case"timestamp":return 0;case"string":case"bytes":return"";default:{const t=e.primitive;throw new TypeError(t)}}case"array":return[];case"optional":return null;case"record":switch(this.recordMap.get(e.key).record.recordType){case"struct":return[];case"enum":return 0}}}finalize(){const e=new Map;for(const[t,n]of this.moduleBundles){const{module:i,tokens:s}=n,r=s.errors.length?s.errors:i.errors;e.set(t,{result:i.result,errors:[...r]})}for(const t of this.registry.numberToMethods.values()){if(t.length<=1)continue;const n=(t,n)=>{const i=t.name.line.modulePath,s=e.get(i),r=n.name.text,o=n.name.line.modulePath;s.errors.push({token:t.name,message:`Same number as ${r} in ${o}`})};n(t[0],t[1]);for(let e=1;e<t.length;++e)n(t[e],t[0])}for(const t of this.registry.numberToRecords.values()){if(t.length<=1)continue;const n=(t,n)=>{const i=this.registry.recordMap.get(t),s=this.registry.recordMap.get(n),r=i.record.name.line.modulePath,o=e.get(r),a=s.record.name.text,l=s.modulePath;o.errors.push({token:i.record.name,message:`Same number as ${a} in ${l}`})};n(t[0],t[1]);for(let e=1;e<t.length;++e)n(t[e],t[0])}const t=[];for(const n of e.values())t.push(...n.errors);return{modules:e,errors:t}}findRecordByNumber(e){const{numberToRecords:t,recordMap:n}=this.registry,i=t.get(e);return 1===i?.length?n.get(i[0]):void 0}findMethodByNumber(e){const{numberToMethods:t}=this.registry,n=t.get(e);return 1===n?.length?n[0]:void 0}get recordMap(){return this.registry.recordMap}get errors(){return this.finalizationResult.errors}get modules(){return this.finalizationResult.modules}}class Wg{constructor(e,t,n,i,s){this.module=e,this.moduleBundles=t,this.topLevelNameToRecordLocations=n,this.usedImports=i,this.errors=s}resolve(e,t){switch(e.kind){case"primitive":return e;case"array":{const n=this.resolve(e.item,t);if(!n)return;return{kind:"array",item:n,key:e.key}}case"optional":{const n=this.resolve(e.other,t);if(!n)return;return{kind:"optional",other:n}}case"record":return this.resolveRecordRef(e,t)}}resolveRecordRef(e,t){const n=e.nameParts[0],i=e=>({token:e,message:"Does not refer to a struct or an enum"}),s=(e,t)=>({token:e,message:`Cannot find name '${e.text}'`,expectedNames:t}),{errors:r,module:o,moduleBundles:a,usedImports:l}=this;let c;const h=new tg;if("top-level"!==t&&!e.absolute)for(const e of[...t.recordAncestors].reverse()){const t=e.nameToDeclaration[n.text];if(t&&"record"===t.kind){c=e;break}h.collect(eg(e.nameToDeclaration,e=>"record"===e.kind))}if(void 0===c){if(!o.nameToDeclaration[n.text])return h.collect(eg(o.nameToDeclaration,e=>"record"===e.kind||"import"===e.kind||"import-alias"===e.kind)),h.collect(this.topLevelNameToRecordLocations?.get(n.text)?.filter(e=>e.modulePath!==o.path)??[]),void r.push(s(n,h.expectedNames));c=o}let u=c;const d=[];for(let t=0;t<e.nameParts.length;++t){const n=e.nameParts[t],o=n.text;let c=u.nameToDeclaration[o];if(void 0===c)return void r.push(s(n,eg(u.nameToDeclaration,e=>"record"===e.kind||0===t&&"import-alias"===e.kind||0===t&&"import"===e.kind)));if("record"===c.kind)u=c;else{if("import"!==c.kind&&"import-alias"!==c.kind)return void this.errors.push(i(n));{const e=()=>({token:n,message:"Cannot refer to imports of imported module"});if(0!==t)return void r.push(e());l.add(o);const h=c.resolvedModulePath;if(void 0===h)return;const d=a.get(h);if(!d)return;const f=d.module.result;if("import"===c.kind){if(c=f.nameToDeclaration[o],!c)return void r.push(s(n,eg(f.nameToDeclaration,e=>"record"===e.kind)));if("record"!==c.kind)return void this.errors.push("import"===c.kind||"import-alias"===c.kind?e():i(n));u=c}else u=f}}d.push({token:n,declaration:c})}if("record"!==u.kind){const t=e.nameParts[0];return void this.errors.push(i(t))}return{kind:"record",key:u.key,recordType:u.recordType,nameParts:d,refToken:e.nameParts.at(-1)}}}class Ug{constructor(e,t,n){this.registry=n,this.modulePathToCacheResult=new Map;const i=new Set;for(const[n,s]of e){const e=t.get(n);e?.tokens.result.sourceCode===s&&i.add(n)}const s=n=>{const i=t.get(n);if(!i)return{kind:"no-cache"};{const e=this.modulePathToCacheResult.get(n);if(e)return e}let r;if(e.get(n)===i.tokens.result.sourceCode){this.modulePathToCacheResult.set(n,{kind:"module-bundle",bundle:i});r=Object.keys(i.module.result?.pathToImportedNames).every(e=>"module-bundle"===s(e).kind)?{kind:"module-bundle",bundle:i}:{kind:"module-tokens",tokens:i.tokens}}else r={kind:"no-cache"};return this.modulePathToCacheResult.set(n,r),r};for(const e of t.keys())s(e)}getModuleCacheResult(e){return this.modulePathToCacheResult.get(e)??{kind:"no-cache"}}}class Fg{constructor(){this.recordMap=new Map,this.numberToRecords=new Map,this.numberToMethods=new Map,this.topLevelNameToRecordLocations=new Map}mergeFrom(e){for(const[t,n]of e.recordMap)this.recordMap.set(t,n);for(const[t,n]of e.numberToRecords){let e=this.numberToRecords.get(t);e||(e=[],this.numberToRecords.set(t,e)),e.push(...n)}for(const[t,n]of e.numberToMethods){let e=this.numberToMethods.get(t);e||(e=[],this.numberToMethods.set(t,e)),e.push(...n)}for(const[t,n]of e.topLevelNameToRecordLocations){let e=this.topLevelNameToRecordLocations.get(t);e||(e=[],this.topLevelNameToRecordLocations.set(t,e)),e.push(...n)}}pushNumberRecord(e,t){let n=this.numberToRecords.get(e);n||(n=[],this.numberToRecords.set(e,n)),n.push(t)}pushNumberMethod(e,t){let n=this.numberToMethods.get(e);n||(n=[],this.numberToMethods.set(e,n)),n.push(t)}pushTopLevelNames(e){for(const t of e){let e=this.topLevelNameToRecordLocations.get(t.name);e||(e=[],this.topLevelNameToRecordLocations.set(t.name,e)),e.push(t)}}}class Vg{constructor(e,t){this.tokens=e,this.module=t,this.registry=new Fg}}function Hg(e){const t=e.lastIndexOf("/");return t>=0?e.slice(0,t):""}function qg(e,t){const n=""===e?[]:e.split("/"),i=""===t?[]:t.split("/");let s=0;for(;s<n.length&&s<i.length&&n[s]===i[s];)s++;const r=n.length-s,o=i.slice(s);return[...Array(r).fill(".."),...o].join("/")}function Kg(e,t,n){const i=e.startsWith("./")||e.startsWith("../");let s;if(i){const n=e.lastIndexOf("/"),i=e.slice(0,n+1),r=e.slice(n+1),o=i+"__dummy__",a=function(e,t){const n=(e+"/"+t).split("/"),i=[];for(const e of n)".."===e?i.length>0&&".."!==i[i.length-1]?i.pop():i.push(".."):"."!==e&&""!==e&&i.push(e);return i.join("/")}(Hg(t),o.startsWith("./")?o.slice(2):o);s=a.slice(0,a.length-9)+r}else s=t.startsWith("@")&&!e.startsWith("@")?Rg(t)+e:e;if(s=s.replace(/\\/g,"/"),s.startsWith("../"))return[];const r=Hg(t),o=new Set;for(const a of n){if(!a.startsWith(s))continue;if(a===t)continue;if(i&&a.startsWith("@"))continue;const n=a.slice(s.length),l=n.indexOf("/"),c=l>=0?s+n.slice(0,l+1):a;if(i){const t=c.endsWith("/");let n=qg(r,t?c.slice(0,-1):c);""===n&&(n="."),n.startsWith(".")||(n="./"+n);const i=t?n+"/":n;if(e.startsWith("../")&&"./"===i)continue;o.add(i)}else o.add(c)}return[...o].map(e=>({name:e}))}const Jg=Symbol.for("yaml.alias"),Zg=Symbol.for("yaml.document"),Yg=Symbol.for("yaml.map"),Gg=Symbol.for("yaml.pair"),Qg=Symbol.for("yaml.scalar"),Xg=Symbol.for("yaml.seq"),ey=Symbol.for("yaml.node.type"),ty=e=>!!e&&"object"==typeof e&&e[ey]===Jg,ny=e=>!!e&&"object"==typeof e&&e[ey]===Zg,iy=e=>!!e&&"object"==typeof e&&e[ey]===Yg,sy=e=>!!e&&"object"==typeof e&&e[ey]===Gg,ry=e=>!!e&&"object"==typeof e&&e[ey]===Qg,oy=e=>!!e&&"object"==typeof e&&e[ey]===Xg;function ay(e){if(e&&"object"==typeof e)switch(e[ey]){case Yg:case Xg:return!0}return!1}function ly(e){if(e&&"object"==typeof e)switch(e[ey]){case Jg:case Yg:case Qg:case Xg:return!0}return!1}const cy=e=>(ry(e)||ay(e))&&!!e.anchor,hy=Symbol("break visit"),uy=Symbol("skip children"),dy=Symbol("remove node");function fy(e,t){const n=function(e){if("object"==typeof e&&(e.Collection||e.Node||e.Value))return Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e);return e}(t);if(ny(e)){py(null,e.contents,n,Object.freeze([e]))===dy&&(e.contents=null)}else py(null,e,n,Object.freeze([]))}function py(e,t,n,i){const s=function(e,t,n,i){return"function"==typeof n?n(e,t,i):iy(t)?n.Map?.(e,t,i):oy(t)?n.Seq?.(e,t,i):sy(t)?n.Pair?.(e,t,i):ry(t)?n.Scalar?.(e,t,i):ty(t)?n.Alias?.(e,t,i):void 0}(e,t,n,i);if(ly(s)||sy(s))return function(e,t,n){const i=t[t.length-1];if(ay(i))i.items[e]=n;else if(sy(i))"key"===e?i.key=n:i.value=n;else{if(!ny(i)){const e=ty(i)?"alias":"scalar";throw new Error(`Cannot replace node with ${e} parent`)}i.contents=n}}(e,i,s),py(e,s,n,i);if("symbol"!=typeof s)if(ay(t)){i=Object.freeze(i.concat(t));for(let e=0;e<t.items.length;++e){const s=py(e,t.items[e],n,i);if("number"==typeof s)e=s-1;else{if(s===hy)return hy;s===dy&&(t.items.splice(e,1),e-=1)}}}else if(sy(t)){i=Object.freeze(i.concat(t));const e=py("key",t.key,n,i);if(e===hy)return hy;e===dy&&(t.key=null);const s=py("value",t.value,n,i);if(s===hy)return hy;s===dy&&(t.value=null)}return s}fy.BREAK=hy,fy.SKIP=uy,fy.REMOVE=dy;const my={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},gy=e=>e.replace(/[!,[\]{}]/g,e=>my[e]);class yy{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},yy.defaultYaml,e),this.tags=Object.assign({},yy.defaultTags,t)}clone(){const e=new yy(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){const e=new yy(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:yy.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},yy.defaultTags)}return e}add(e,t){this.atNextDocument&&(this.yaml={explicit:yy.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},yy.defaultTags),this.atNextDocument=!1);const n=e.trim().split(/[ \t]+/),i=n.shift();switch(i){case"%TAG":{if(2!==n.length&&(t(0,"%TAG directive should contain exactly two parts"),n.length<2))return!1;const[e,i]=n;return this.tags[e]=i,!0}case"%YAML":{if(this.yaml.explicit=!0,1!==n.length)return t(0,"%YAML directive should contain exactly one part"),!1;const[e]=n;if("1.1"===e||"1.2"===e)return this.yaml.version=e,!0;return t(6,`Unsupported YAML version ${e}`,/^\d+\.\d+$/.test(e)),!1}default:return t(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if("!"===e)return"!";if("!"!==e[0])return t(`Not a valid tag: ${e}`),null;if("<"===e[1]){const n=e.slice(2,-1);return"!"===n||"!!"===n?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(">"!==e[e.length-1]&&t("Verbatim tags must end with a >"),n)}const[,n,i]=e.match(/^(.*!)([^!]*)$/s);i||t(`The ${e} tag has no suffix`);const s=this.tags[n];if(s)try{return s+decodeURIComponent(i)}catch(e){return t(String(e)),null}return"!"===n?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(const[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+gy(e.substring(n.length));return"!"===e[0]?e:`!<${e}>`}toString(e){const t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],n=Object.entries(this.tags);let i;if(e&&n.length>0&&ly(e.contents)){const t={};fy(e.contents,(e,n)=>{ly(n)&&n.tag&&(t[n.tag]=!0)}),i=Object.keys(t)}else i=[];for(const[s,r]of n)"!!"===s&&"tag:yaml.org,2002:"===r||e&&!i.some(e=>e.startsWith(r))||t.push(`%TAG ${s} ${r}`);return t.join("\n")}}function vy(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){const t=JSON.stringify(e);throw new Error(`Anchor must not contain whitespace or control characters: ${t}`)}return!0}function by(e){const t=new Set;return fy(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function wy(e,t){for(let n=1;;++n){const i=`${e}${n}`;if(!t.has(i))return i}}function ky(e,t,n,i){if(i&&"object"==typeof i)if(Array.isArray(i))for(let t=0,n=i.length;t<n;++t){const n=i[t],s=ky(e,i,String(t),n);void 0===s?delete i[t]:s!==n&&(i[t]=s)}else if(i instanceof Map)for(const t of Array.from(i.keys())){const n=i.get(t),s=ky(e,i,t,n);void 0===s?i.delete(t):s!==n&&i.set(t,s)}else if(i instanceof Set)for(const t of Array.from(i)){const n=ky(e,i,t,t);void 0===n?i.delete(t):n!==t&&(i.delete(t),i.add(n))}else for(const[t,n]of Object.entries(i)){const s=ky(e,i,t,n);void 0===s?delete i[t]:s!==n&&(i[t]=s)}return e.call(t,n,i)}function xy(e,t,n){if(Array.isArray(e))return e.map((e,t)=>xy(e,String(t),n));if(e&&"function"==typeof e.toJSON){if(!n||!cy(e))return e.toJSON(t,n);const i={aliasCount:0,count:1,res:void 0};n.anchors.set(e,i),n.onCreate=e=>{i.res=e,delete n.onCreate};const s=e.toJSON(t,n);return n.onCreate&&n.onCreate(s),s}return"bigint"!=typeof e||n?.keep?e:Number(e)}yy.defaultYaml={explicit:!1,version:"1.2"},yy.defaultTags={"!!":"tag:yaml.org,2002:"};class Sy{constructor(e){Object.defineProperty(this,ey,{value:e})}clone(){const e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:i,reviver:s}={}){if(!ny(e))throw new TypeError("A document argument is required");const r={anchors:new Map,doc:e,keep:!0,mapAsMap:!0===t,mapKeyWarned:!1,maxAliasCount:"number"==typeof n?n:100},o=xy(this,"",r);if("function"==typeof i)for(const{count:e,res:t}of r.anchors.values())i(t,e);return"function"==typeof s?ky(s,{"":o},"",o):o}}class Cy extends Sy{constructor(e){super(Jg),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,t){let n,i;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],fy(e,{Node:(e,t)=>{(ty(t)||cy(t))&&n.push(t)}}),t&&(t.aliasResolveCache=n));for(const e of n){if(e===this)break;e.anchor===this.source&&(i=e)}return i}toJSON(e,t){if(!t)return{source:this.source};const{anchors:n,doc:i,maxAliasCount:s}=t,r=this.resolve(i,t);if(!r){const e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(e)}let o=n.get(r);if(o||(xy(r,null,t),o=n.get(r)),void 0===o?.res){throw new ReferenceError("This should not happen: Alias anchor was not resolved?")}if(s>=0&&(o.count+=1,0===o.aliasCount&&(o.aliasCount=Ay(i,r,n)),o.count*o.aliasCount>s)){throw new ReferenceError("Excessive alias count indicates a resource exhaustion attack")}return o.res}toString(e,t,n){const i=`*${this.source}`;if(e){if(vy(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){const e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(e)}if(e.implicitKey)return`${i} `}return i}}function Ay(e,t,n){if(ty(t)){const i=t.resolve(e),s=n&&i&&n.get(i);return s?s.count*s.aliasCount:0}if(ay(t)){let i=0;for(const s of t.items){const t=Ay(e,s,n);t>i&&(i=t)}return i}if(sy(t)){const i=Ay(e,t.key,n),s=Ay(e,t.value,n);return Math.max(i,s)}return 1}const Ty=e=>!e||"function"!=typeof e&&"object"!=typeof e;class Oy extends Sy{constructor(e){super(Qg),this.value=e}toJSON(e,t){return t?.keep?this.value:xy(this.value,e,t)}toString(){return String(this.value)}}Oy.BLOCK_FOLDED="BLOCK_FOLDED",Oy.BLOCK_LITERAL="BLOCK_LITERAL",Oy.PLAIN="PLAIN",Oy.QUOTE_DOUBLE="QUOTE_DOUBLE",Oy.QUOTE_SINGLE="QUOTE_SINGLE";function My(e,t,n){if(ny(e)&&(e=e.contents),ly(e))return e;if(sy(e)){const t=n.schema[Yg].createNode?.(n.schema,null,n);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||"undefined"!=typeof BigInt&&e instanceof BigInt)&&(e=e.valueOf());const{aliasDuplicateObjects:i,onAnchor:s,onTagObj:r,schema:o,sourceObjects:a}=n;let l;if(i&&e&&"object"==typeof e){if(l=a.get(e),l)return l.anchor??(l.anchor=s(e)),new Cy(l.anchor);l={anchor:null,node:null},a.set(e,l)}t?.startsWith("!!")&&(t="tag:yaml.org,2002:"+t.slice(2));let c=function(e,t,n){if(t){const e=n.filter(e=>e.tag===t),i=e.find(e=>!e.format)??e[0];if(!i)throw new Error(`Tag ${t} not found`);return i}return n.find(t=>t.identify?.(e)&&!t.format)}(e,t,o.tags);if(!c){if(e&&"function"==typeof e.toJSON&&(e=e.toJSON()),!e||"object"!=typeof e){const t=new Oy(e);return l&&(l.node=t),t}c=e instanceof Map?o[Yg]:Symbol.iterator in Object(e)?o[Xg]:o[Yg]}r&&(r(c),delete n.onTagObj);const h=c?.createNode?c.createNode(n.schema,e,n):"function"==typeof c?.nodeClass?.from?c.nodeClass.from(n.schema,e,n):new Oy(e);return t?h.tag=t:c.default||(h.tag=c.tag),l&&(l.node=h),h}function Ey(e,t,n){let i=n;for(let e=t.length-1;e>=0;--e){const n=t[e];if("number"==typeof n&&Number.isInteger(n)&&n>=0){const e=[];e[n]=i,i=e}else i=new Map([[n,i]])}return My(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}const Ny=e=>null==e||"object"==typeof e&&!!e[Symbol.iterator]().next().done;class Dy extends Sy{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){const t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>ly(t)||sy(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(Ny(e))this.add(t);else{const[n,...i]=e,s=this.get(n,!0);if(ay(s))s.addIn(i,t);else{if(void 0!==s||!this.schema)throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`);this.set(n,Ey(this.schema,i,t))}}}deleteIn(e){const[t,...n]=e;if(0===n.length)return this.delete(t);const i=this.get(t,!0);if(ay(i))return i.deleteIn(n);throw new Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){const[n,...i]=e,s=this.get(n,!0);return 0===i.length?!t&&ry(s)?s.value:s:ay(s)?s.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!sy(t))return!1;const n=t.value;return null==n||e&&ry(n)&&null==n.value&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){const[t,...n]=e;if(0===n.length)return this.has(t);const i=this.get(t,!0);return!!ay(i)&&i.hasIn(n)}setIn(e,t){const[n,...i]=e;if(0===i.length)this.set(n,t);else{const e=this.get(n,!0);if(ay(e))e.setIn(i,t);else{if(void 0!==e||!this.schema)throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`);this.set(n,Ey(this.schema,i,t))}}}}const _y=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function Py(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}const Iy=(e,t,n)=>e.endsWith("\n")?Py(n,t):n.includes("\n")?"\n"+Py(n,t):(e.endsWith(" ")?"":" ")+n,Ry="flow",$y="block",By="quoted";function Ly(e,t,n="flow",{indentAtStart:i,lineWidth:s=80,minContentWidth:r=20,onFold:o,onOverflow:a}={}){if(!s||s<0)return e;s<r&&(r=0);const l=Math.max(1+r,1+s-t.length);if(e.length<=l)return e;const c=[],h={};let u,d,f=s-t.length;"number"==typeof i&&(i>s-Math.max(2,r)?c.push(0):f=s-i);let p=!1,m=-1,g=-1,y=-1;n===$y&&(m=zy(e,m,t.length),-1!==m&&(f=m+l));for(let i;i=e[m+=1];){if(n===By&&"\\"===i){switch(g=m,e[m+1]){case"x":m+=3;break;case"u":m+=5;break;case"U":m+=9;break;default:m+=1}y=m}if("\n"===i)n===$y&&(m=zy(e,m,t.length)),f=m+t.length+l,u=void 0;else{if(" "===i&&d&&" "!==d&&"\n"!==d&&"\t"!==d){const t=e[m+1];t&&" "!==t&&"\n"!==t&&"\t"!==t&&(u=m)}if(m>=f)if(u)c.push(u),f=u+l,u=void 0;else if(n===By){for(;" "===d||"\t"===d;)d=i,i=e[m+=1],p=!0;const t=m>y+1?m-2:g-1;if(h[t])return e;c.push(t),h[t]=!0,f=t+l,u=void 0}else p=!0}d=i}if(p&&a&&a(),0===c.length)return e;o&&o();let v=e.slice(0,c[0]);for(let i=0;i<c.length;++i){const s=c[i],r=c[i+1]||e.length;0===s?v=`\n${t}${e.slice(0,r)}`:(n===By&&h[s]&&(v+=`${e[s]}\\`),v+=`\n${t}${e.slice(s+1,r)}`)}return v}function zy(e,t,n){let i=t,s=t+1,r=e[s];for(;" "===r||"\t"===r;)if(t<s+n)r=e[++t];else{do{r=e[++t]}while(r&&"\n"!==r);i=t,s=t+1,r=e[s]}return i}const jy=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),Wy=e=>/^(%|---|\.\.\.)/m.test(e);function Uy(e,t){const n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;const{implicitKey:i}=t,s=t.options.doubleQuotedMinMultiLineLength,r=t.indent||(Wy(e)?" ":"");let o="",a=0;for(let e=0,t=n[e];t;t=n[++e])if(" "===t&&"\\"===n[e+1]&&"n"===n[e+2]&&(o+=n.slice(a,e)+"\\ ",e+=1,a=e,t="\\"),"\\"===t)switch(n[e+1]){case"u":{o+=n.slice(a,e);const t=n.substr(e+2,4);switch(t){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:"00"===t.substr(0,2)?o+="\\x"+t.substr(2):o+=n.substr(e,6)}e+=5,a=e+1}break;case"n":if(i||'"'===n[e+2]||n.length<s)e+=1;else{for(o+=n.slice(a,e)+"\n\n";"\\"===n[e+2]&&"n"===n[e+3]&&'"'!==n[e+4];)o+="\n",e+=2;o+=r," "===n[e+2]&&(o+="\\"),e+=1,a=e+1}break;default:e+=1}return o=a?o+n.slice(a):n,i?o:Ly(o,r,By,jy(t,!1))}function Fy(e,t){if(!1===t.options.singleQuote||t.implicitKey&&e.includes("\n")||/[ \t]\n|\n[ \t]/.test(e))return Uy(e,t);const n=t.indent||(Wy(e)?" ":""),i="'"+e.replace(/'/g,"''").replace(/\n+/g,`$&\n${n}`)+"'";return t.implicitKey?i:Ly(i,n,Ry,jy(t,!1))}function Vy(e,t){const{singleQuote:n}=t.options;let i;if(!1===n)i=Uy;else{const t=e.includes('"'),s=e.includes("'");i=t&&!s?Fy:s&&!t?Uy:n?Fy:Uy}return i(e,t)}let Hy;try{Hy=new RegExp("(^|(?<!\n))\n+(?!\n|$)","g")}catch{Hy=/\n+(?!\n|$)/g}function qy({comment:e,type:t,value:n},i,s,r){const{blockQuote:o,commentString:a,lineWidth:l}=i.options;if(!o||/\n[\t ]+$/.test(n))return Vy(n,i);const c=i.indent||(i.forceBlockIndent||Wy(n)?" ":""),h="literal"===o||"folded"!==o&&t!==Oy.BLOCK_FOLDED&&(t===Oy.BLOCK_LITERAL||!function(e,t,n){if(!t||t<0)return!1;const i=t-n,s=e.length;if(s<=i)return!1;for(let t=0,n=0;t<s;++t)if("\n"===e[t]){if(t-n>i)return!0;if(n=t+1,s-n<=i)return!1}return!0}(n,l,c.length));if(!n)return h?"|\n":">\n";let u,d;for(d=n.length;d>0;--d){const e=n[d-1];if("\n"!==e&&"\t"!==e&&" "!==e)break}let f=n.substring(d);const p=f.indexOf("\n");-1===p?u="-":n===f||p!==f.length-1?(u="+",r&&r()):u="",f&&(n=n.slice(0,-f.length),"\n"===f[f.length-1]&&(f=f.slice(0,-1)),f=f.replace(Hy,`$&${c}`));let m,g=!1,y=-1;for(m=0;m<n.length;++m){const e=n[m];if(" "===e)g=!0;else{if("\n"!==e)break;y=m}}let v=n.substring(0,y<m?y+1:m);v&&(n=n.substring(v.length),v=v.replace(/\n+/g,`$&${c}`));let b=(g?c?"2":"1":"")+u;if(e&&(b+=" "+a(e.replace(/ ?[\r\n]+/g," ")),s&&s()),!h){const e=n.replace(/\n+/g,"\n$&").replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`);let s=!1;const r=jy(i,!0);"folded"!==o&&t!==Oy.BLOCK_FOLDED&&(r.onOverflow=()=>{s=!0});const a=Ly(`${v}${e}${f}`,c,$y,r);if(!s)return`>${b}\n${c}${a}`}return`|${b}\n${c}${v}${n=n.replace(/\n+/g,`$&${c}`)}${f}`}function Ky(e,t,n,i){const{implicitKey:s,inFlow:r}=t,o="string"==typeof e.value?e:Object.assign({},e,{value:String(e.value)});let{type:a}=e;a!==Oy.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(a=Oy.QUOTE_DOUBLE);const l=e=>{switch(e){case Oy.BLOCK_FOLDED:case Oy.BLOCK_LITERAL:return s||r?Vy(o.value,t):qy(o,t,n,i);case Oy.QUOTE_DOUBLE:return Uy(o.value,t);case Oy.QUOTE_SINGLE:return Fy(o.value,t);case Oy.PLAIN:return function(e,t,n,i){const{type:s,value:r}=e,{actualString:o,implicitKey:a,indent:l,indentStep:c,inFlow:h}=t;if(a&&r.includes("\n")||h&&/[[\]{},]/.test(r))return Vy(r,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(r))return a||h||!r.includes("\n")?Vy(r,t):qy(e,t,n,i);if(!a&&!h&&s!==Oy.PLAIN&&r.includes("\n"))return qy(e,t,n,i);if(Wy(r)){if(""===l)return t.forceBlockIndent=!0,qy(e,t,n,i);if(a&&l===c)return Vy(r,t)}const u=r.replace(/\n+/g,`$&\n${l}`);if(o){const e=e=>e.default&&"tag:yaml.org,2002:str"!==e.tag&&e.test?.test(u),{compat:n,tags:i}=t.doc.schema;if(i.some(e)||n?.some(e))return Vy(r,t)}return a?u:Ly(u,l,Ry,jy(t,!1))}(o,t,n,i);default:return null}};let c=l(a);if(null===c){const{defaultKeyType:e,defaultStringType:n}=t.options,i=s&&e||n;if(c=l(i),null===c)throw new Error(`Unsupported default string type ${i}`)}return c}function Jy(e,t){const n=Object.assign({blockQuote:!0,commentString:_y,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},e.schema.toStringOptions,t);let i;switch(n.collectionStyle){case"block":i=!1;break;case"flow":i=!0;break;default:i=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?" ":"",indent:"",indentStep:"number"==typeof n.indent?" ".repeat(n.indent):" ",inFlow:i,options:n}}function Zy(e,t,n,i){if(sy(e))return e.toString(t,n,i);if(ty(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw new TypeError("Cannot stringify circular structure without alias nodes");t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let s;const r=ly(e)?e:t.doc.createNode(e,{onTagObj:e=>s=e});s??(s=function(e,t){if(t.tag){const n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let n,i;if(ry(t)){i=t.value;let s=e.filter(e=>e.identify?.(i));if(s.length>1){const e=s.filter(e=>e.test);e.length>0&&(s=e)}n=s.find(e=>e.format===t.format)??s.find(e=>!e.format)}else i=t,n=e.find(e=>e.nodeClass&&i instanceof e.nodeClass);if(!n)throw new Error(`Tag not resolved for ${i?.constructor?.name??(null===i?"null":typeof i)} value`);return n}(t.doc.schema.tags,r));const o=function(e,t,{anchors:n,doc:i}){if(!i.directives)return"";const s=[],r=(ry(e)||ay(e))&&e.anchor;r&&vy(r)&&(n.add(r),s.push(`&${r}`));const o=e.tag??(t.default?null:t.tag);return o&&s.push(i.directives.tagString(o)),s.join(" ")}(r,s,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);const a="function"==typeof s.stringify?s.stringify(r,t,n,i):ry(r)?Ky(r,t,n,i):r.toString(t,n,i);return o?ry(r)||"{"===a[0]||"["===a[0]?`${o} ${a}`:`${o}\n${t.indent}${a}`:a}const Yy="<<",Gy={identify:e=>e===Yy||"symbol"==typeof e&&e.description===Yy,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Oy(Symbol(Yy)),{addToJSMap:Qy}),stringify:()=>Yy};function Qy(e,t,n){if(n=e&&ty(n)?n.resolve(e.doc):n,oy(n))for(const i of n.items)Xy(e,t,i);else if(Array.isArray(n))for(const i of n)Xy(e,t,i);else Xy(e,t,n)}function Xy(e,t,n){const i=e&&ty(n)?n.resolve(e.doc):n;if(!iy(i))throw new Error("Merge sources must be maps or map aliases");const s=i.toJSON(null,e,Map);for(const[e,n]of s)t instanceof Map?t.has(e)||t.set(e,n):t instanceof Set?t.add(e):Object.prototype.hasOwnProperty.call(t,e)||Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0});return t}function ev(e,t,{key:n,value:i}){if(ly(n)&&n.addToJSMap)n.addToJSMap(e,t,i);else if(((e,t)=>(Gy.identify(t)||ry(t)&&(!t.type||t.type===Oy.PLAIN)&&Gy.identify(t.value))&&e?.doc.schema.tags.some(e=>e.tag===Gy.tag&&e.default))(e,n))Qy(e,t,i);else{const s=xy(n,"",e);if(t instanceof Map)t.set(s,xy(i,s,e));else if(t instanceof Set)t.add(s);else{const r=function(e,t,n){if(null===t)return"";if("object"!=typeof t)return String(t);if(ly(e)&&n?.doc){const t=Jy(n.doc,{});t.anchors=new Set;for(const e of n.anchors.keys())t.anchors.add(e.anchor);t.inFlow=!0,t.inStringifyKey=!0;const r=e.toString(t);if(!n.mapKeyWarned){let e=JSON.stringify(r);e.length>40&&(e=e.substring(0,36)+'..."'),i=n.doc.options.logLevel,s=`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`,"debug"!==i&&"warn"!==i||console.warn(s),n.mapKeyWarned=!0}return r}var i,s;return JSON.stringify(t)}(n,s,e),o=xy(i,r,e);r in t?Object.defineProperty(t,r,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[r]=o}}return t}function tv(e,t,n){const i=My(e,void 0,n),s=My(t,void 0,n);return new nv(i,s)}class nv{constructor(e,t=null){Object.defineProperty(this,ey,{value:Gg}),this.key=e,this.value=t}clone(e){let{key:t,value:n}=this;return ly(t)&&(t=t.clone(e)),ly(n)&&(n=n.clone(e)),new nv(t,n)}toJSON(e,t){return ev(t,t?.mapAsMap?new Map:{},this)}toString(e,t,n){return e?.doc?function({key:e,value:t},n,i,s){const{allNullValues:r,doc:o,indent:a,indentStep:l,options:{commentString:c,indentSeq:h,simpleKeys:u}}=n;let d=ly(e)&&e.comment||null;if(u){if(d)throw new Error("With simple keys, key nodes cannot have comments");if(ay(e)||!ly(e)&&"object"==typeof e)throw new Error("With simple keys, collection cannot be used as a key value")}let f=!u&&(!e||d&&null==t&&!n.inFlow||ay(e)||(ry(e)?e.type===Oy.BLOCK_FOLDED||e.type===Oy.BLOCK_LITERAL:"object"==typeof e));n=Object.assign({},n,{allNullValues:!1,implicitKey:!f&&(u||!r),indent:a+l});let p,m,g,y=!1,v=!1,b=Zy(e,n,()=>y=!0,()=>v=!0);if(!f&&!n.inFlow&&b.length>1024){if(u)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");f=!0}if(n.inFlow){if(r||null==t)return y&&i&&i(),""===b?"?":f?`? ${b}`:b}else if(r&&!u||null==t&&f)return b=`? ${b}`,d&&!y?b+=Iy(b,n.indent,c(d)):v&&s&&s(),b;y&&(d=null),f?(d&&(b+=Iy(b,n.indent,c(d))),b=`? ${b}\n${a}:`):(b=`${b}:`,d&&(b+=Iy(b,n.indent,c(d)))),ly(t)?(p=!!t.spaceBefore,m=t.commentBefore,g=t.comment):(p=!1,m=null,g=null,t&&"object"==typeof t&&(t=o.createNode(t))),n.implicitKey=!1,f||d||!ry(t)||(n.indentAtStart=b.length+1),v=!1,h||!(l.length>=2)||n.inFlow||f||!oy(t)||t.flow||t.tag||t.anchor||(n.indent=n.indent.substring(2));let w=!1;const k=Zy(t,n,()=>w=!0,()=>v=!0);let x=" ";if(d||p||m)x=p?"\n":"",m&&(x+=`\n${Py(c(m),n.indent)}`),""!==k||n.inFlow?x+=`\n${n.indent}`:"\n"===x&&g&&(x="\n\n");else if(!f&&ay(t)){const e=k[0],i=k.indexOf("\n"),s=-1!==i,r=n.inFlow??t.flow??0===t.items.length;if(s||!r){let t=!1;if(s&&("&"===e||"!"===e)){let n=k.indexOf(" ");"&"===e&&-1!==n&&n<i&&"!"===k[n+1]&&(n=k.indexOf(" ",n+1)),(-1===n||i<n)&&(t=!0)}t||(x=`\n${n.indent}`)}}else""!==k&&"\n"!==k[0]||(x="");return b+=x+k,n.inFlow?w&&i&&i():g&&!w?b+=Iy(b,n.indent,c(g)):v&&s&&s(),b}(this,e,t,n):JSON.stringify(this)}}function iv(e,t,n){return(t.inFlow??e.flow?rv:sv)(e,t,n)}function sv({comment:e,items:t},n,{blockItemPrefix:i,flowChars:s,itemIndent:r,onChompKeep:o,onComment:a}){const{indent:l,options:{commentString:c}}=n,h=Object.assign({},n,{indent:r,type:null});let u=!1;const d=[];for(let e=0;e<t.length;++e){const s=t[e];let o=null;if(ly(s))!u&&s.spaceBefore&&d.push(""),ov(n,d,s.commentBefore,u),s.comment&&(o=s.comment);else if(sy(s)){const e=ly(s.key)?s.key:null;e&&(!u&&e.spaceBefore&&d.push(""),ov(n,d,e.commentBefore,u))}u=!1;let a=Zy(s,h,()=>o=null,()=>u=!0);o&&(a+=Iy(a,r,c(o))),u&&o&&(u=!1),d.push(i+a)}let f;if(0===d.length)f=s.start+s.end;else{f=d[0];for(let e=1;e<d.length;++e){const t=d[e];f+=t?`\n${l}${t}`:"\n"}}return e?(f+="\n"+Py(c(e),l),a&&a()):u&&o&&o(),f}function rv({items:e},t,{flowChars:n,itemIndent:i}){const{indent:s,indentStep:r,flowCollectionPadding:o,options:{commentString:a}}=t;i+=r;const l=Object.assign({},t,{indent:i,inFlow:!0,type:null});let c=!1,h=0;const u=[];for(let n=0;n<e.length;++n){const s=e[n];let r=null;if(ly(s))s.spaceBefore&&u.push(""),ov(t,u,s.commentBefore,!1),s.comment&&(r=s.comment);else if(sy(s)){const e=ly(s.key)?s.key:null;e&&(e.spaceBefore&&u.push(""),ov(t,u,e.commentBefore,!1),e.comment&&(c=!0));const n=ly(s.value)?s.value:null;n?(n.comment&&(r=n.comment),n.commentBefore&&(c=!0)):null==s.value&&e?.comment&&(r=e.comment)}r&&(c=!0);let o=Zy(s,l,()=>r=null);c||(c=u.length>h||o.includes("\n")),n<e.length-1?o+=",":t.options.trailingComma&&(t.options.lineWidth>0&&(c||(c=u.reduce((e,t)=>e+t.length+2,2)+(o.length+2)>t.options.lineWidth)),c&&(o+=",")),r&&(o+=Iy(o,i,a(r))),u.push(o),h=u.length}const{start:d,end:f}=n;if(0===u.length)return d+f;if(!c){const e=u.reduce((e,t)=>e+t.length+2,2);c=t.options.lineWidth>0&&e>t.options.lineWidth}if(c){let e=d;for(const t of u)e+=t?`\n${r}${s}${t}`:"\n";return`${e}\n${s}${f}`}return`${d}${o}${u.join(" ")}${o}${f}`}function ov({indent:e,options:{commentString:t}},n,i,s){if(i&&s&&(i=i.replace(/^\n+/,"")),i){const s=Py(t(i),e);n.push(s.trimStart())}}function av(e,t){const n=ry(t)?t.value:t;for(const i of e)if(sy(i)){if(i.key===t||i.key===n)return i;if(ry(i.key)&&i.key.value===n)return i}}class lv extends Dy{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Yg,e),this.items=[]}static from(e,t,n){const{keepUndefined:i,replacer:s}=n,r=new this(e),o=(e,o)=>{if("function"==typeof s)o=s.call(t,e,o);else if(Array.isArray(s)&&!s.includes(e))return;(void 0!==o||i)&&r.items.push(tv(e,o,n))};if(t instanceof Map)for(const[e,n]of t)o(e,n);else if(t&&"object"==typeof t)for(const e of Object.keys(t))o(e,t[e]);return"function"==typeof e.sortMapEntries&&r.items.sort(e.sortMapEntries),r}add(e,t){let n;n=sy(e)?e:e&&"object"==typeof e&&"key"in e?new nv(e.key,e.value):new nv(e,e?.value);const i=av(this.items,n.key),s=this.schema?.sortMapEntries;if(i){if(!t)throw new Error(`Key ${n.key} already set`);ry(i.value)&&Ty(n.value)?i.value.value=n.value:i.value=n.value}else if(s){const e=this.items.findIndex(e=>s(n,e)<0);-1===e?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){const t=av(this.items,e);if(!t)return!1;return this.items.splice(this.items.indexOf(t),1).length>0}get(e,t){const n=av(this.items,e),i=n?.value;return(!t&&ry(i)?i.value:i)??void 0}has(e){return!!av(this.items,e)}set(e,t){this.add(new nv(e,t),!0)}toJSON(e,t,n){const i=n?new n:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(i);for(const e of this.items)ev(t,i,e);return i}toString(e,t,n){if(!e)return JSON.stringify(this);for(const e of this.items)if(!sy(e))throw new Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),iv(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:n,onComment:t})}}const cv={collection:"map",default:!0,nodeClass:lv,tag:"tag:yaml.org,2002:map",resolve:(e,t)=>(iy(e)||t("Expected a mapping for this tag"),e),createNode:(e,t,n)=>lv.from(e,t,n)};class hv extends Dy{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(Xg,e),this.items=[]}add(e){this.items.push(e)}delete(e){const t=uv(e);if("number"!=typeof t)return!1;return this.items.splice(t,1).length>0}get(e,t){const n=uv(e);if("number"!=typeof n)return;const i=this.items[n];return!t&&ry(i)?i.value:i}has(e){const t=uv(e);return"number"==typeof t&&t<this.items.length}set(e,t){const n=uv(e);if("number"!=typeof n)throw new Error(`Expected a valid index, not ${e}.`);const i=this.items[n];ry(i)&&Ty(t)?i.value=t:this.items[n]=t}toJSON(e,t){const n=[];t?.onCreate&&t.onCreate(n);let i=0;for(const e of this.items)n.push(xy(e,String(i++),t));return n}toString(e,t,n){return e?iv(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:n,onComment:t}):JSON.stringify(this)}static from(e,t,n){const{replacer:i}=n,s=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let r of t){if("function"==typeof i){const n=t instanceof Set?r:String(e++);r=i.call(t,n,r)}s.items.push(My(r,void 0,n))}}return s}}function uv(e){let t=ry(e)?e.value:e;return t&&"string"==typeof t&&(t=Number(t)),"number"==typeof t&&Number.isInteger(t)&&t>=0?t:null}const dv={collection:"seq",default:!0,nodeClass:hv,tag:"tag:yaml.org,2002:seq",resolve:(e,t)=>(oy(e)||t("Expected a sequence for this tag"),e),createNode:(e,t,n)=>hv.from(e,t,n)},fv={identify:e=>"string"==typeof e,default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:(e,t,n,i)=>Ky(e,t=Object.assign({actualString:!0},t),n,i)},pv={identify:e=>null==e,createNode:()=>new Oy(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Oy(null),stringify:({source:e},t)=>"string"==typeof e&&pv.test.test(e)?e:t.options.nullStr},mv={identify:e=>"boolean"==typeof e,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new Oy("t"===e[0]||"T"===e[0]),stringify({source:e,value:t},n){if(e&&mv.test.test(e)){if(t===("t"===e[0]||"T"===e[0]))return e}return t?n.options.trueStr:n.options.falseStr}};function gv({format:e,minFractionDigits:t,tag:n,value:i}){if("bigint"==typeof i)return String(i);const s="number"==typeof i?i:Number(i);if(!isFinite(s))return isNaN(s)?".nan":s<0?"-.inf":".inf";let r=Object.is(i,-0)?"-0":JSON.stringify(i);if(!e&&t&&(!n||"tag:yaml.org,2002:float"===n)&&/^\d/.test(r)){let e=r.indexOf(".");e<0&&(e=r.length,r+=".");let n=t-(r.length-e-1);for(;n-- >0;)r+="0"}return r}const yv={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>"nan"===e.slice(-3).toLowerCase()?NaN:"-"===e[0]?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:gv},vv={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){const t=Number(e.value);return isFinite(t)?t.toExponential():gv(e)}},bv={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){const t=new Oy(parseFloat(e)),n=e.indexOf(".");return-1!==n&&"0"===e[e.length-1]&&(t.minFractionDigits=e.length-n-1),t},stringify:gv},wv=e=>"bigint"==typeof e||Number.isInteger(e),kv=(e,t,n,{intAsBigInt:i})=>i?BigInt(e):parseInt(e.substring(t),n);function xv(e,t,n){const{value:i}=e;return wv(i)&&i>=0?n+i.toString(t):gv(e)}const Sv={identify:e=>wv(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,n)=>kv(e,2,8,n),stringify:e=>xv(e,8,"0o")},Cv={identify:wv,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>kv(e,0,10,n),stringify:gv},Av={identify:e=>wv(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>kv(e,2,16,n),stringify:e=>xv(e,16,"0x")},Tv=[cv,dv,fv,pv,mv,Sv,Cv,Av,yv,vv,bv];function Ov(e){return"bigint"==typeof e||Number.isInteger(e)}const Mv=({value:e})=>JSON.stringify(e),Ev=[cv,dv].concat([{identify:e=>"string"==typeof e,default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:Mv},{identify:e=>null==e,createNode:()=>new Oy(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Mv},{identify:e=>"boolean"==typeof e,default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:e=>"true"===e,stringify:Mv},{identify:Ov,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>Ov(e)?e.toString():JSON.stringify(e)},{identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:Mv}],{default:!0,tag:"",test:/^/,resolve:(e,t)=>(t(`Unresolved plain scalar ${JSON.stringify(e)}`),e)}),Nv={identify:e=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if("function"==typeof atob){const t=atob(e.replace(/[\n\r]/g,"")),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n[e]=t.charCodeAt(e);return n}return t("This environment does not support reading binary tags; either Buffer or atob is required"),e},stringify({comment:e,type:t,value:n},i,s,r){if(!n)return"";const o=n;let a;if("function"!=typeof btoa)throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");{let e="";for(let t=0;t<o.length;++t)e+=String.fromCharCode(o[t]);a=btoa(e)}if(t??(t=Oy.BLOCK_LITERAL),t!==Oy.QUOTE_DOUBLE){const e=Math.max(i.options.lineWidth-i.indent.length,i.options.minContentWidth),n=Math.ceil(a.length/e),s=new Array(n);for(let t=0,i=0;t<n;++t,i+=e)s[t]=a.substr(i,e);a=s.join(t===Oy.BLOCK_LITERAL?"\n":" ")}return Ky({comment:e,type:t,value:a},i,s,r)}};function Dv(e,t){if(oy(e))for(let n=0;n<e.items.length;++n){let i=e.items[n];if(!sy(i)){if(iy(i)){i.items.length>1&&t("Each pair must have its own sequence indicator");const e=i.items[0]||new nv(new Oy(null));if(i.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${i.commentBefore}\n${e.key.commentBefore}`:i.commentBefore),i.comment){const t=e.value??e.key;t.comment=t.comment?`${i.comment}\n${t.comment}`:i.comment}i=e}e.items[n]=sy(i)?i:new nv(i)}}else t("Expected a sequence for this tag");return e}function _v(e,t,n){const{replacer:i}=n,s=new hv(e);s.tag="tag:yaml.org,2002:pairs";let r=0;if(t&&Symbol.iterator in Object(t))for(let e of t){let o,a;if("function"==typeof i&&(e=i.call(t,String(r++),e)),Array.isArray(e)){if(2!==e.length)throw new TypeError(`Expected [key, value] tuple: ${e}`);o=e[0],a=e[1]}else if(e&&e instanceof Object){const t=Object.keys(e);if(1!==t.length)throw new TypeError(`Expected tuple with one key, not ${t.length} keys`);o=t[0],a=e[o]}else o=e;s.items.push(tv(o,a,n))}return s}const Pv={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Dv,createNode:_v};class Iv extends hv{constructor(){super(),this.add=lv.prototype.add.bind(this),this.delete=lv.prototype.delete.bind(this),this.get=lv.prototype.get.bind(this),this.has=lv.prototype.has.bind(this),this.set=lv.prototype.set.bind(this),this.tag=Iv.tag}toJSON(e,t){if(!t)return super.toJSON(e);const n=new Map;t?.onCreate&&t.onCreate(n);for(const e of this.items){let i,s;if(sy(e)?(i=xy(e.key,"",t),s=xy(e.value,i,t)):i=xy(e,"",t),n.has(i))throw new Error("Ordered maps must not include duplicate keys");n.set(i,s)}return n}static from(e,t,n){const i=_v(e,t,n),s=new this;return s.items=i.items,s}}Iv.tag="tag:yaml.org,2002:omap";const Rv={collection:"seq",identify:e=>e instanceof Map,nodeClass:Iv,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){const n=Dv(e,t),i=[];for(const{key:e}of n.items)ry(e)&&(i.includes(e.value)?t(`Ordered maps must not include duplicate keys: ${e.value}`):i.push(e.value));return Object.assign(new Iv,n)},createNode:(e,t,n)=>Iv.from(e,t,n)};function $v({value:e,source:t},n){return t&&(e?Bv:Lv).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}const Bv={identify:e=>!0===e,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Oy(!0),stringify:$v},Lv={identify:e=>!1===e,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Oy(!1),stringify:$v},zv={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>"nan"===e.slice(-3).toLowerCase()?NaN:"-"===e[0]?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:gv},jv={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,"")),stringify(e){const t=Number(e.value);return isFinite(t)?t.toExponential():gv(e)}},Wv={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){const t=new Oy(parseFloat(e.replace(/_/g,""))),n=e.indexOf(".");if(-1!==n){const i=e.substring(n+1).replace(/_/g,"");"0"===i[i.length-1]&&(t.minFractionDigits=i.length)}return t},stringify:gv},Uv=e=>"bigint"==typeof e||Number.isInteger(e);function Fv(e,t,n,{intAsBigInt:i}){const s=e[0];if("-"!==s&&"+"!==s||(t+=1),e=e.substring(t).replace(/_/g,""),i){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`}const t=BigInt(e);return"-"===s?BigInt(-1)*t:t}const r=parseInt(e,n);return"-"===s?-1*r:r}function Vv(e,t,n){const{value:i}=e;if(Uv(i)){const e=i.toString(t);return i<0?"-"+n+e.substr(1):n+e}return gv(e)}const Hv={identify:Uv,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>Fv(e,2,2,n),stringify:e=>Vv(e,2,"0b")},qv={identify:Uv,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>Fv(e,1,8,n),stringify:e=>Vv(e,8,"0")},Kv={identify:Uv,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>Fv(e,0,10,n),stringify:gv},Jv={identify:Uv,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>Fv(e,2,16,n),stringify:e=>Vv(e,16,"0x")};class Zv extends lv{constructor(e){super(e),this.tag=Zv.tag}add(e){let t;t=sy(e)?e:e&&"object"==typeof e&&"key"in e&&"value"in e&&null===e.value?new nv(e.key,null):new nv(e,null);av(this.items,t.key)||this.items.push(t)}get(e,t){const n=av(this.items,e);return!t&&sy(n)?ry(n.key)?n.key.value:n.key:n}set(e,t){if("boolean"!=typeof t)throw new Error("Expected boolean value for set(key, value) in a YAML set, not "+typeof t);const n=av(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new nv(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw new Error("Set items must all have null values")}static from(e,t,n){const{replacer:i}=n,s=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)"function"==typeof i&&(e=i.call(t,e,e)),s.items.push(tv(e,null,n));return s}}Zv.tag="tag:yaml.org,2002:set";const Yv={collection:"map",identify:e=>e instanceof Set,nodeClass:Zv,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,n)=>Zv.from(e,t,n),resolve(e,t){if(iy(e)){if(e.hasAllNullValues(!0))return Object.assign(new Zv,e);t("Set items must all have null values")}else t("Expected a mapping for this tag");return e}};function Gv(e,t){const n=e[0],i="-"===n||"+"===n?e.substring(1):e,s=e=>t?BigInt(e):Number(e),r=i.replace(/_/g,"").split(":").reduce((e,t)=>e*s(60)+s(t),s(0));return"-"===n?s(-1)*r:r}function Qv(e){let{value:t}=e,n=e=>e;if("bigint"==typeof t)n=e=>BigInt(e);else if(isNaN(t)||!isFinite(t))return gv(e);let i="";t<0&&(i="-",t*=n(-1));const s=n(60),r=[t%s];return t<60?r.unshift(0):(t=(t-r[0])/s,r.unshift(t%s),t>=60&&(t=(t-r[0])/s,r.unshift(t))),i+r.map(e=>String(e).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}const Xv={identify:e=>"bigint"==typeof e||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:n})=>Gv(e,n),stringify:Qv},eb={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>Gv(e,!1),stringify:Qv},tb={identify:e=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){const t=e.match(tb.test);if(!t)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");const[,n,i,s,r,o,a]=t.map(Number),l=t[7]?Number((t[7]+"00").substr(1,3)):0;let c=Date.UTC(n,i-1,s,r||0,o||0,a||0,l);const h=t[8];if(h&&"Z"!==h){let e=Gv(h,!1);Math.abs(e)<30&&(e*=60),c-=6e4*e}return new Date(c)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""},nb=[cv,dv,fv,pv,Bv,Lv,Hv,qv,Kv,Jv,zv,jv,Wv,Nv,Gy,Rv,Pv,Yv,Xv,eb,tb],ib=new Map([["core",Tv],["failsafe",[cv,dv,fv]],["json",Ev],["yaml11",nb],["yaml-1.1",nb]]),sb={binary:Nv,bool:mv,float:bv,floatExp:vv,floatNaN:yv,floatTime:eb,int:Cv,intHex:Av,intOct:Sv,intTime:Xv,map:cv,merge:Gy,null:pv,omap:Rv,pairs:Pv,seq:dv,set:Yv,timestamp:tb},rb={"tag:yaml.org,2002:binary":Nv,"tag:yaml.org,2002:merge":Gy,"tag:yaml.org,2002:omap":Rv,"tag:yaml.org,2002:pairs":Pv,"tag:yaml.org,2002:set":Yv,"tag:yaml.org,2002:timestamp":tb};function ob(e,t,n){const i=ib.get(t);if(i&&!e)return n&&!i.includes(Gy)?i.concat(Gy):i.slice();let s=i;if(!s){if(!Array.isArray(e)){const e=Array.from(ib.keys()).filter(e=>"yaml11"!==e).map(e=>JSON.stringify(e)).join(", ");throw new Error(`Unknown schema "${t}"; use one of ${e} or define customTags array`)}s=[]}if(Array.isArray(e))for(const t of e)s=s.concat(t);else"function"==typeof e&&(s=e(s.slice()));return n&&(s=s.concat(Gy)),s.reduce((e,t)=>{const n="string"==typeof t?sb[t]:t;if(!n){const e=JSON.stringify(t),n=Object.keys(sb).map(e=>JSON.stringify(e)).join(", ");throw new Error(`Unknown custom tag ${e}; use one of ${n}`)}return e.includes(n)||e.push(n),e},[])}const ab=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0;class lb{constructor({compat:e,customTags:t,merge:n,resolveKnownTags:i,schema:s,sortMapEntries:r,toStringDefaults:o}){this.compat=Array.isArray(e)?ob(e,"compat"):e?ob(null,e):null,this.name="string"==typeof s&&s||"core",this.knownTags=i?rb:{},this.tags=ob(t,this.name,n),this.toStringOptions=o??null,Object.defineProperty(this,Yg,{value:cv}),Object.defineProperty(this,Qg,{value:fv}),Object.defineProperty(this,Xg,{value:dv}),this.sortMapEntries="function"==typeof r?r:!0===r?ab:null}clone(){const e=Object.create(lb.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}let cb=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,ey,{value:Zg});let i=null;"function"==typeof t||Array.isArray(t)?i=t:void 0===n&&t&&(n=t,t=void 0);const s=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},n);this.options=s;let{version:r}=s;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(r=this.directives.yaml.version)):this.directives=new yy({version:r}),this.setSchema(r,n),this.contents=void 0===e?null:this.createNode(e,i,n)}clone(){const t=Object.create(e.prototype,{[ey]:{value:Zg}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=ly(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){hb(this.contents)&&this.contents.add(e)}addIn(e,t){hb(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){const n=by(this);e.anchor=!t||n.has(t)?wy(t||"a",n):t}return new Cy(e.anchor)}createNode(e,t,n){let i;if("function"==typeof t)e=t.call({"":e},"",e),i=t;else if(Array.isArray(t)){const e=e=>"number"==typeof e||e instanceof String||e instanceof Number,n=t.filter(e).map(String);n.length>0&&(t=t.concat(n)),i=t}else void 0===n&&t&&(n=t,t=void 0);const{aliasDuplicateObjects:s,anchorPrefix:r,flow:o,keepUndefined:a,onTagObj:l,tag:c}=n??{},{onAnchor:h,setAnchors:u,sourceObjects:d}=function(e,t){const n=[],i=new Map;let s=null;return{onAnchor:i=>{n.push(i),s??(s=by(e));const r=wy(t,s);return s.add(r),r},setAnchors:()=>{for(const e of n){const t=i.get(e);if("object"!=typeof t||!t.anchor||!ry(t.node)&&!ay(t.node)){const t=new Error("Failed to resolve repeated object (this should not happen)");throw t.source=e,t}t.node.anchor=t.anchor}},sourceObjects:i}}(this,r||"a"),f=My(e,c,{aliasDuplicateObjects:s??!0,keepUndefined:a??!1,onAnchor:h,onTagObj:l,replacer:i,schema:this.schema,sourceObjects:d});return o&&ay(f)&&(f.flow=!0),u(),f}createPair(e,t,n={}){const i=this.createNode(e,null,n),s=this.createNode(t,null,n);return new nv(i,s)}delete(e){return!!hb(this.contents)&&this.contents.delete(e)}deleteIn(e){return Ny(e)?null!=this.contents&&(this.contents=null,!0):!!hb(this.contents)&&this.contents.deleteIn(e)}get(e,t){return ay(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return Ny(e)?!t&&ry(this.contents)?this.contents.value:this.contents:ay(this.contents)?this.contents.getIn(e,t):void 0}has(e){return!!ay(this.contents)&&this.contents.has(e)}hasIn(e){return Ny(e)?void 0!==this.contents:!!ay(this.contents)&&this.contents.hasIn(e)}set(e,t){null==this.contents?this.contents=Ey(this.schema,[e],t):hb(this.contents)&&this.contents.set(e,t)}setIn(e,t){Ny(e)?this.contents=t:null==this.contents?this.contents=Ey(this.schema,Array.from(e),t):hb(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){let n;switch("number"==typeof e&&(e=String(e)),e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new yy({version:"1.1"}),n={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new yy({version:e}),n={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,n=null;break;default:{const t=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else{if(!n)throw new Error("With a null YAML version, the { schema: Schema } option is required");this.schema=new lb(Object.assign(n,t))}}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:i,onAnchor:s,reviver:r}={}){const o={anchors:new Map,doc:this,keep:!e,mapAsMap:!0===n,mapKeyWarned:!1,maxAliasCount:"number"==typeof i?i:100},a=xy(this.contents,t??"",o);if("function"==typeof s)for(const{count:e,res:t}of o.anchors.values())s(t,e);return"function"==typeof r?ky(r,{"":a},"",a):a}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){const t=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${t}`)}return function(e,t){const n=[];let i=!0===t.directives;if(!1!==t.directives&&e.directives){const t=e.directives.toString(e);t?(n.push(t),i=!0):e.directives.docStart&&(i=!0)}i&&n.push("---");const s=Jy(e,t),{commentString:r}=s.options;if(e.commentBefore){1!==n.length&&n.unshift("");const t=r(e.commentBefore);n.unshift(Py(t,""))}let o=!1,a=null;if(e.contents){if(ly(e.contents)){if(e.contents.spaceBefore&&i&&n.push(""),e.contents.commentBefore){const t=r(e.contents.commentBefore);n.push(Py(t,""))}s.forceBlockIndent=!!e.comment,a=e.contents.comment}const t=a?void 0:()=>o=!0;let l=Zy(e.contents,s,()=>a=null,t);a&&(l+=Iy(l,"",r(a))),"|"!==l[0]&&">"!==l[0]||"---"!==n[n.length-1]?n.push(l):n[n.length-1]=`--- ${l}`}else n.push(Zy(e.contents,s));if(e.directives?.docEnd)if(e.comment){const t=r(e.comment);t.includes("\n")?(n.push("..."),n.push(Py(t,""))):n.push(`... ${t}`)}else n.push("...");else{let t=e.comment;t&&o&&(t=t.replace(/^\n+/,"")),t&&(o&&!a||""===n[n.length-1]||n.push(""),n.push(Py(r(t),"")))}return n.join("\n")+"\n"}(this,e)}};function hb(e){if(ay(e))return!0;throw new Error("Expected a YAML collection as document contents")}class ub extends Error{constructor(e,t,n,i){super(),this.name=e,this.code=n,this.message=i,this.pos=t}}class db extends ub{constructor(e,t,n){super("YAMLParseError",e,t,n)}}class fb extends ub{constructor(e,t,n){super("YAMLWarning",e,t,n)}}const pb=(e,t)=>n=>{if(-1===n.pos[0])return;n.linePos=n.pos.map(e=>t.linePos(e));const{line:i,col:s}=n.linePos[0];n.message+=` at line ${i}, column ${s}`;let r=s-1,o=e.substring(t.lineStarts[i-1],t.lineStarts[i]).replace(/[\n\r]+$/,"");if(r>=60&&o.length>80){const e=Math.min(r-39,o.length-79);o="…"+o.substring(e),r-=e-1}if(o.length>80&&(o=o.substring(0,79)+"…"),i>1&&/^ *$/.test(o.substring(0,r))){let n=e.substring(t.lineStarts[i-2],t.lineStarts[i-1]);n.length>80&&(n=n.substring(0,79)+"…\n"),o=n+o}if(/[^ ]/.test(o)){let e=1;const t=n.linePos[1];t?.line===i&&t.col>s&&(e=Math.max(1,Math.min(t.col-s,80-r)));const a=" ".repeat(r)+"^".repeat(e);n.message+=`:\n\n${o}\n${a}\n`}};function mb(e,{flow:t,indicator:n,next:i,offset:s,onError:r,parentIndent:o,startOnNewline:a}){let l=!1,c=a,h=a,u="",d="",f=!1,p=!1,m=null,g=null,y=null,v=null,b=null,w=null,k=null;for(const s of e)switch(p&&("space"!==s.type&&"newline"!==s.type&&"comma"!==s.type&&r(s.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),p=!1),m&&(c&&"comment"!==s.type&&"newline"!==s.type&&r(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),m=null),s.type){case"space":t||"doc-start"===n&&"flow-collection"===i?.type||!s.source.includes("\t")||(m=s),h=!0;break;case"comment":{h||r(s,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");const e=s.source.substring(1)||" ";u?u+=d+e:u=e,d="",c=!1;break}case"newline":c?u?u+=s.source:w&&"seq-item-ind"===n||(l=!0):d+=s.source,c=!0,f=!0,(g||y)&&(v=s),h=!0;break;case"anchor":g&&r(s,"MULTIPLE_ANCHORS","A node can have at most one anchor"),s.source.endsWith(":")&&r(s.offset+s.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),g=s,k??(k=s.offset),c=!1,h=!1,p=!0;break;case"tag":y&&r(s,"MULTIPLE_TAGS","A node can have at most one tag"),y=s,k??(k=s.offset),c=!1,h=!1,p=!0;break;case n:(g||y)&&r(s,"BAD_PROP_ORDER",`Anchors and tags must be after the ${s.source} indicator`),w&&r(s,"UNEXPECTED_TOKEN",`Unexpected ${s.source} in ${t??"collection"}`),w=s,c="seq-item-ind"===n||"explicit-key-ind"===n,h=!1;break;case"comma":if(t){b&&r(s,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`),b=s,c=!1,h=!1;break}default:r(s,"UNEXPECTED_TOKEN",`Unexpected ${s.type} token`),c=!1,h=!1}const x=e[e.length-1],S=x?x.offset+x.source.length:s;return p&&i&&"space"!==i.type&&"newline"!==i.type&&"comma"!==i.type&&("scalar"!==i.type||""!==i.source)&&r(i.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m&&(c&&m.indent<=o||"block-map"===i?.type||"block-seq"===i?.type)&&r(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:b,found:w,spaceBefore:l,comment:u,hasNewline:f,anchor:g,tag:y,newlineAfterProp:v,end:S,start:k??S}}function gb(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes("\n"))return!0;if(e.end)for(const t of e.end)if("newline"===t.type)return!0;return!1;case"flow-collection":for(const t of e.items){for(const e of t.start)if("newline"===e.type)return!0;if(t.sep)for(const e of t.sep)if("newline"===e.type)return!0;if(gb(t.key)||gb(t.value))return!0}return!1;default:return!0}}function yb(e,t,n){if("flow-collection"===t?.type){const i=t.end[0];if(i.indent===e&&("]"===i.source||"}"===i.source)&&gb(t)){n(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}}function vb(e,t,n){const{uniqueKeys:i}=e.options;if(!1===i)return!1;const s="function"==typeof i?i:(e,t)=>e===t||ry(e)&&ry(t)&&e.value===t.value;return t.some(e=>s(e.key,n))}const bb="All mapping items must start at the same column";function wb(e,t,n,i){let s="";if(e){let r=!1,o="";for(const a of e){const{source:e,type:l}=a;switch(l){case"space":r=!0;break;case"comment":{n&&!r&&i(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");const t=e.substring(1)||" ";s?s+=o+t:s=t,o="";break}case"newline":s&&(o+=e),r=!0;break;default:i(a,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}t+=e.length}}return{comment:s,offset:t}}const kb="Block collections are not allowed within flow collections",xb=e=>e&&("block-map"===e.type||"block-seq"===e.type);function Sb(e,t,n,i,s,r){const o="block-map"===n.type?function({composeNode:e,composeEmptyNode:t},n,i,s,r){const o=new(r?.nodeClass??lv)(n.schema);n.atRoot&&(n.atRoot=!1);let a=i.offset,l=null;for(const r of i.items){const{start:c,key:h,sep:u,value:d}=r,f=mb(c,{indicator:"explicit-key-ind",next:h??u?.[0],offset:a,onError:s,parentIndent:i.indent,startOnNewline:!0}),p=!f.found;if(p){if(h&&("block-seq"===h.type?s(a,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in h&&h.indent!==i.indent&&s(a,"BAD_INDENT",bb)),!f.anchor&&!f.tag&&!u){l=f.end,f.comment&&(o.comment?o.comment+="\n"+f.comment:o.comment=f.comment);continue}(f.newlineAfterProp||gb(h))&&s(h??c[c.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else f.found?.indent!==i.indent&&s(a,"BAD_INDENT",bb);n.atKey=!0;const m=f.end,g=h?e(n,h,f,s):t(n,m,c,null,f,s);n.schema.compat&&yb(i.indent,h,s),n.atKey=!1,vb(n,o.items,g)&&s(m,"DUPLICATE_KEY","Map keys must be unique");const y=mb(u??[],{indicator:"map-value-ind",next:d,offset:g.range[2],onError:s,parentIndent:i.indent,startOnNewline:!h||"block-scalar"===h.type});if(a=y.end,y.found){p&&("block-map"!==d?.type||y.hasNewline||s(a,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),n.options.strict&&f.start<y.found.offset-1024&&s(g.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));const l=d?e(n,d,y,s):t(n,a,u,null,y,s);n.schema.compat&&yb(i.indent,d,s),a=l.range[2];const c=new nv(g,l);n.options.keepSourceTokens&&(c.srcToken=r),o.items.push(c)}else{p&&s(g.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),y.comment&&(g.comment?g.comment+="\n"+y.comment:g.comment=y.comment);const e=new nv(g);n.options.keepSourceTokens&&(e.srcToken=r),o.items.push(e)}}return l&&l<a&&s(l,"IMPOSSIBLE","Map comment with trailing content"),o.range=[i.offset,a,l??a],o}(e,t,n,i,r):"block-seq"===n.type?function({composeNode:e,composeEmptyNode:t},n,i,s,r){const o=new(r?.nodeClass??hv)(n.schema);n.atRoot&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let a=i.offset,l=null;for(const{start:r,value:c}of i.items){const h=mb(r,{indicator:"seq-item-ind",next:c,offset:a,onError:s,parentIndent:i.indent,startOnNewline:!0});if(!h.found){if(!(h.anchor||h.tag||c)){l=h.end,h.comment&&(o.comment=h.comment);continue}"block-seq"===c?.type?s(h.end,"BAD_INDENT","All sequence items must start at the same column"):s(a,"MISSING_CHAR","Sequence item without - indicator")}const u=c?e(n,c,h,s):t(n,h.end,r,null,h,s);n.schema.compat&&yb(i.indent,c,s),a=u.range[2],o.items.push(u)}return o.range=[i.offset,a,l??a],o}(e,t,n,i,r):function({composeNode:e,composeEmptyNode:t},n,i,s,r){const o="{"===i.start.source,a=o?"flow map":"flow sequence",l=new(r?.nodeClass??(o?lv:hv))(n.schema);l.flow=!0;const c=n.atRoot;c&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let h=i.offset+i.start.source.length;for(let r=0;r<i.items.length;++r){const c=i.items[r],{start:u,key:d,sep:f,value:p}=c,m=mb(u,{flow:a,indicator:"explicit-key-ind",next:d??f?.[0],offset:h,onError:s,parentIndent:i.indent,startOnNewline:!1});if(!m.found){if(!(m.anchor||m.tag||f||p)){0===r&&m.comma?s(m.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):r<i.items.length-1&&s(m.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),m.comment&&(l.comment?l.comment+="\n"+m.comment:l.comment=m.comment),h=m.end;continue}!o&&n.options.strict&&gb(d)&&s(d,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(0===r)m.comma&&s(m.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(m.comma||s(m.start,"MISSING_CHAR",`Missing , between ${a} items`),m.comment){let e="";e:for(const t of u)switch(t.type){case"comma":case"space":break;case"comment":e=t.source.substring(1);break e;default:break e}if(e){let t=l.items[l.items.length-1];sy(t)&&(t=t.value??t.key),t.comment?t.comment+="\n"+e:t.comment=e,m.comment=m.comment.substring(e.length+1)}}if(o||f||m.found){n.atKey=!0;const r=m.end,g=d?e(n,d,m,s):t(n,r,u,null,m,s);xb(d)&&s(g.range,"BLOCK_IN_FLOW",kb),n.atKey=!1;const y=mb(f??[],{flow:a,indicator:"map-value-ind",next:p,offset:g.range[2],onError:s,parentIndent:i.indent,startOnNewline:!1});if(y.found){if(!o&&!m.found&&n.options.strict){if(f)for(const e of f){if(e===y.found)break;if("newline"===e.type){s(e,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}m.start<y.found.offset-1024&&s(y.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else p&&("source"in p&&":"===p.source?.[0]?s(p,"MISSING_CHAR",`Missing space after : in ${a}`):s(y.start,"MISSING_CHAR",`Missing , or : between ${a} items`));const v=p?e(n,p,y,s):y.found?t(n,y.end,f,null,y,s):null;v?xb(p)&&s(v.range,"BLOCK_IN_FLOW",kb):y.comment&&(g.comment?g.comment+="\n"+y.comment:g.comment=y.comment);const b=new nv(g,v);if(n.options.keepSourceTokens&&(b.srcToken=c),o){const e=l;vb(n,e.items,g)&&s(r,"DUPLICATE_KEY","Map keys must be unique"),e.items.push(b)}else{const e=new lv(n.schema);e.flow=!0,e.items.push(b);const t=(v??g).range;e.range=[g.range[0],t[1],t[2]],l.items.push(e)}h=v?v.range[2]:y.end}else{const i=p?e(n,p,m,s):t(n,m.end,f,null,m,s);l.items.push(i),h=i.range[2],xb(p)&&s(i.range,"BLOCK_IN_FLOW",kb)}}const u=o?"}":"]",[d,...f]=i.end;let p=h;if(d?.source===u)p=d.offset+d.source.length;else{const e=a[0].toUpperCase()+a.substring(1);s(h,c?"MISSING_CHAR":"BAD_INDENT",c?`${e} must end with a ${u}`:`${e} in block collection must be sufficiently indented and end with a ${u}`),d&&1!==d.source.length&&f.unshift(d)}if(f.length>0){const e=wb(f,p,n.options.strict,s);e.comment&&(l.comment?l.comment+="\n"+e.comment:l.comment=e.comment),l.range=[i.offset,p,e.offset]}else l.range=[i.offset,p,p];return l}(e,t,n,i,r),a=o.constructor;return"!"===s||s===a.tagName?(o.tag=a.tagName,o):(s&&(o.tag=s),o)}function Cb(e,t,n){const i=t.offset,s=function({offset:e,props:t},n,i){if("block-scalar-header"!==t[0].type)return i(t[0],"IMPOSSIBLE","Block scalar header not found"),null;const{source:s}=t[0],r=s[0];let o=0,a="",l=-1;for(let t=1;t<s.length;++t){const n=s[t];if(a||"-"!==n&&"+"!==n){const i=Number(n);!o&&i?o=i:-1===l&&(l=e+t)}else a=n}-1!==l&&i(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${s}`);let c=!1,h="",u=s.length;for(let e=1;e<t.length;++e){const s=t[e];switch(s.type){case"space":c=!0;case"newline":u+=s.source.length;break;case"comment":if(n&&!c){i(s,"MISSING_CHAR","Comments must be separated from other tokens by white space characters")}u+=s.source.length,h=s.source.substring(1);break;case"error":i(s,"UNEXPECTED_TOKEN",s.message),u+=s.source.length;break;default:{i(s,"UNEXPECTED_TOKEN",`Unexpected token in block scalar header: ${s.type}`);const e=s.source;e&&"string"==typeof e&&(u+=e.length)}}}return{mode:r,indent:o,chomp:a,comment:h,length:u}}(t,e.options.strict,n);if(!s)return{value:"",type:null,comment:"",range:[i,i,i]};const r=">"===s.mode?Oy.BLOCK_FOLDED:Oy.BLOCK_LITERAL,o=t.source?function(e){const t=e.split(/\n( *)/),n=t[0],i=n.match(/^( *)/),s=i?.[1]?[i[1],n.slice(i[1].length)]:["",n],r=[s];for(let e=1;e<t.length;e+=2)r.push([t[e],t[e+1]]);return r}(t.source):[];let a=o.length;for(let e=o.length-1;e>=0;--e){const t=o[e][1];if(""!==t&&"\r"!==t)break;a=e}if(0===a){const e="+"===s.chomp&&o.length>0?"\n".repeat(Math.max(1,o.length-1)):"";let n=i+s.length;return t.source&&(n+=t.source.length),{value:e,type:r,comment:s.comment,range:[i,n,n]}}let l=t.indent+s.indent,c=t.offset+s.length,h=0;for(let t=0;t<a;++t){const[i,r]=o[t];if(""!==r&&"\r"!==r){if(i.length<l){const e="Block scalars with more-indented leading empty lines must use an explicit indentation indicator";n(c+i.length,"MISSING_CHAR",e)}if(0===s.indent&&(l=i.length),h=t,0===l&&!e.atRoot){n(c,"BAD_INDENT","Block scalar values in collections must be indented")}break}0===s.indent&&i.length>l&&(l=i.length),c+=i.length+r.length+1}for(let e=o.length-1;e>=a;--e)o[e][0].length>l&&(a=e+1);let u="",d="",f=!1;for(let e=0;e<h;++e)u+=o[e][0].slice(l)+"\n";for(let e=h;e<a;++e){let[t,i]=o[e];c+=t.length+i.length+1;const a="\r"===i[i.length-1];if(a&&(i=i.slice(0,-1)),i&&t.length<l){const e=`Block scalar lines must not be less indented than their ${s.indent?"explicit indentation indicator":"first line"}`;n(c-i.length-(a?2:1),"BAD_INDENT",e),t=""}r===Oy.BLOCK_LITERAL?(u+=d+t.slice(l)+i,d="\n"):t.length>l||"\t"===i[0]?(" "===d?d="\n":f||"\n"!==d||(d="\n\n"),u+=d+t.slice(l)+i,d="\n",f=!0):""===i?"\n"===d?u+="\n":d="\n":(u+=d+i,d=" ",f=!1)}switch(s.chomp){case"-":break;case"+":for(let e=a;e<o.length;++e)u+="\n"+o[e][0].slice(l);"\n"!==u[u.length-1]&&(u+="\n");break;default:u+="\n"}const p=i+s.length+t.source.length;return{value:u,type:r,comment:s.comment,range:[i,p,p]}}function Ab(e,t,n){const{offset:i,type:s,source:r,end:o}=e;let a,l;const c=(e,t,s)=>n(i+e,t,s);switch(s){case"scalar":a=Oy.PLAIN,l=function(e,t){let n="";switch(e[0]){case"\t":n="a tab character";break;case",":n="flow indicator character ,";break;case"%":n="directive indicator character %";break;case"|":case">":n=`block scalar indicator ${e[0]}`;break;case"@":case"`":n=`reserved character ${e[0]}`}n&&t(0,"BAD_SCALAR_START",`Plain value cannot start with ${n}`);return Tb(e)}(r,c);break;case"single-quoted-scalar":a=Oy.QUOTE_SINGLE,l=function(e,t){"'"===e[e.length-1]&&1!==e.length||t(e.length,"MISSING_CHAR","Missing closing 'quote");return Tb(e.slice(1,-1)).replace(/''/g,"'")}(r,c);break;case"double-quoted-scalar":a=Oy.QUOTE_DOUBLE,l=function(e,t){let n="";for(let i=1;i<e.length-1;++i){const s=e[i];if("\r"!==s||"\n"!==e[i+1])if("\n"===s){const{fold:t,offset:s}=Ob(e,i);n+=t,i=s}else if("\\"===s){let s=e[++i];const r=Mb[s];if(r)n+=r;else if("\n"===s)for(s=e[i+1];" "===s||"\t"===s;)s=e[1+ ++i];else if("\r"===s&&"\n"===e[i+1])for(s=e[1+ ++i];" "===s||"\t"===s;)s=e[1+ ++i];else if("x"===s||"u"===s||"U"===s){const r={x:2,u:4,U:8}[s];n+=Eb(e,i+1,r,t),i+=r}else{const s=e.substr(i-1,2);t(i-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),n+=s}}else if(" "===s||"\t"===s){const t=i;let r=e[i+1];for(;" "===r||"\t"===r;)r=e[1+ ++i];"\n"===r||"\r"===r&&"\n"===e[i+2]||(n+=i>t?e.slice(t,i+1):s)}else n+=s}'"'===e[e.length-1]&&1!==e.length||t(e.length,"MISSING_CHAR",'Missing closing "quote');return n}(r,c);break;default:return n(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${s}`),{value:"",type:null,comment:"",range:[i,i+r.length,i+r.length]}}const h=i+r.length,u=wb(o,h,t,n);return{value:l,type:a,comment:u.comment,range:[i,h,u.offset]}}function Tb(e){let t,n;try{t=new RegExp("(.*?)(?<![ \t])[ \t]*\r?\n","sy"),n=new RegExp("[ \t]*(.*?)(?:(?<![ \t])[ \t]*)?\r?\n","sy")}catch{t=/(.*?)[ \t]*\r?\n/sy,n=/[ \t]*(.*?)[ \t]*\r?\n/sy}let i=t.exec(e);if(!i)return e;let s=i[1],r=" ",o=t.lastIndex;for(n.lastIndex=o;i=n.exec(e);)""===i[1]?"\n"===r?s+=r:r="\n":(s+=r+i[1],r=" "),o=n.lastIndex;const a=/[ \t]*(.*)/sy;return a.lastIndex=o,i=a.exec(e),s+r+(i?.[1]??"")}function Ob(e,t){let n="",i=e[t+1];for(;!(" "!==i&&"\t"!==i&&"\n"!==i&&"\r"!==i||"\r"===i&&"\n"!==e[t+2]);)"\n"===i&&(n+="\n"),i=e[(t+=1)+1];return n||(n=" "),{fold:n,offset:t}}const Mb={0:"\0",a:"",b:"\b",e:"",f:"\f",n:"\n",r:"\r",t:"\t",v:"\v",N:"
",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function Eb(e,t,n,i){const s=e.substr(t,n),r=s.length===n&&/^[0-9a-fA-F]+$/.test(s)?parseInt(s,16):NaN;if(isNaN(r)){const s=e.substr(t-2,n+2);return i(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),s}return String.fromCodePoint(r)}function Nb(e,t,n,i){const{value:s,type:r,comment:o,range:a}="block-scalar"===t.type?Cb(e,t,i):Ab(t,e.options.strict,i),l=n?e.directives.tagName(n.source,e=>i(n,"TAG_RESOLVE_FAILED",e)):null;let c,h;c=e.options.stringKeys&&e.atKey?e.schema[Qg]:l?function(e,t,n,i,s){if("!"===n)return e[Qg];const r=[];for(const t of e.tags)if(!t.collection&&t.tag===n){if(!t.default||!t.test)return t;r.push(t)}for(const e of r)if(e.test?.test(t))return e;const o=e.knownTags[n];if(o&&!o.collection)return e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o;return s(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${n}`,"tag:yaml.org,2002:str"!==n),e[Qg]}(e.schema,s,l,n,i):"scalar"===t.type?function({atKey:e,directives:t,schema:n},i,s,r){const o=n.tags.find(t=>(!0===t.default||e&&"key"===t.default)&&t.test?.test(i))||n[Qg];if(n.compat){const e=n.compat.find(e=>e.default&&e.test?.test(i))??n[Qg];if(o.tag!==e.tag){r(s,"TAG_RESOLVE_FAILED",`Value may be parsed as either ${t.tagString(o.tag)} or ${t.tagString(e.tag)}`,!0)}}return o}(e,s,t,i):e.schema[Qg];try{const r=c.resolve(s,e=>i(n??t,"TAG_RESOLVE_FAILED",e),e.options);h=ry(r)?r:new Oy(r)}catch(e){const r=e instanceof Error?e.message:String(e);i(n??t,"TAG_RESOLVE_FAILED",r),h=new Oy(s)}return h.range=a,h.source=s,r&&(h.type=r),l&&(h.tag=l),c.format&&(h.format=c.format),o&&(h.comment=o),h}function Db(e,t,n){if(t){n??(n=t.length);for(let i=n-1;i>=0;--i){let n=t[i];switch(n.type){case"space":case"comment":case"newline":e-=n.source.length;continue}for(n=t[++i];"space"===n?.type;)e+=n.source.length,n=t[++i];break}}return e}const _b={composeNode:Pb,composeEmptyNode:Ib};function Pb(e,t,n,i){const s=e.atKey,{spaceBefore:r,comment:o,anchor:a,tag:l}=n;let c,h=!0;switch(t.type){case"alias":c=function({options:e},{offset:t,source:n,end:i},s){const r=new Cy(n.substring(1));""===r.source&&s(t,"BAD_ALIAS","Alias cannot be an empty string");r.source.endsWith(":")&&s(t+n.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);const o=t+n.length,a=wb(i,o,e.strict,s);r.range=[t,o,a.offset],a.comment&&(r.comment=a.comment);return r}(e,t,i),(a||l)&&i(t,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":c=Nb(e,t,l,i),a&&(c.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{c=function(e,t,n,i,s){const r=i.tag,o=r?t.directives.tagName(r.source,e=>s(r,"TAG_RESOLVE_FAILED",e)):null;if("block-seq"===n.type){const{anchor:e,newlineAfterProp:t}=i,n=e&&r?e.offset>r.offset?e:r:e??r;n&&(!t||t.offset<n.offset)&&s(n,"MISSING_CHAR","Missing newline after block sequence props")}const a="block-map"===n.type?"map":"block-seq"===n.type?"seq":"{"===n.start.source?"map":"seq";if(!r||!o||"!"===o||o===lv.tagName&&"map"===a||o===hv.tagName&&"seq"===a)return Sb(e,t,n,s,o);let l=t.schema.tags.find(e=>e.tag===o&&e.collection===a);if(!l){const i=t.schema.knownTags[o];if(i?.collection!==a)return i?s(r,"BAD_COLLECTION_TYPE",`${i.tag} used for ${a} collection, but expects ${i.collection??"scalar"}`,!0):s(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),Sb(e,t,n,s,o);t.schema.tags.push(Object.assign({},i,{default:!1})),l=i}const c=Sb(e,t,n,s,o,l),h=l.resolve?.(c,e=>s(r,"TAG_RESOLVE_FAILED",e),t.options)??c,u=ly(h)?h:new Oy(h);return u.range=c.range,u.tag=o,l?.format&&(u.format=l.format),u}(_b,e,t,n,i),a&&(c.anchor=a.source.substring(1))}catch(e){i(t,"RESOURCE_EXHAUSTION",e instanceof Error?e.message:String(e))}break;default:i(t,"UNEXPECTED_TOKEN","error"===t.type?t.message:`Unsupported token (type: ${t.type})`),h=!1}if(c??(c=Ib(e,t.offset,void 0,null,n,i)),a&&""===c.anchor&&i(a,"BAD_ALIAS","Anchor cannot be an empty string"),s&&e.options.stringKeys&&(!ry(c)||"string"!=typeof c.value||c.tag&&"tag:yaml.org,2002:str"!==c.tag)){i(l??t,"NON_STRING_KEY","With stringKeys, all keys must be strings")}return r&&(c.spaceBefore=!0),o&&("scalar"===t.type&&""===t.source?c.comment=o:c.commentBefore=o),e.options.keepSourceTokens&&h&&(c.srcToken=t),c}function Ib(e,t,n,i,{spaceBefore:s,comment:r,anchor:o,tag:a,end:l},c){const h=Nb(e,{type:"scalar",offset:Db(t,n,i),indent:-1,source:""},a,c);return o&&(h.anchor=o.source.substring(1),""===h.anchor&&c(o,"BAD_ALIAS","Anchor cannot be an empty string")),s&&(h.spaceBefore=!0),r&&(h.comment=r,h.range[2]=l),h}function Rb(e){if("number"==typeof e)return[e,e+1];if(Array.isArray(e))return 2===e.length?e:[e[0],e[1]];const{offset:t,source:n}=e;return[t,t+("string"==typeof n?n.length:1)]}function $b(e){let t="",n=!1,i=!1;for(let s=0;s<e.length;++s){const r=e[s];switch(r[0]){case"#":t+=(""===t?"":i?"\n\n":"\n")+(r.substring(1)||" "),n=!0,i=!1;break;case"%":"#"!==e[s+1]?.[0]&&(s+=1),n=!1;break;default:n||(i=!0),n=!1}}return{comment:t,afterEmptyLine:i}}class Bb{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,i)=>{const s=Rb(e);i?this.warnings.push(new fb(s,t,n)):this.errors.push(new db(s,t,n))},this.directives=new yy({version:e.version||"1.2"}),this.options=e}decorate(e,t){const{comment:n,afterEmptyLine:i}=$b(this.prelude);if(n){const s=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(i||e.directives.docStart||!s)e.commentBefore=n;else if(ay(s)&&!s.flow&&s.items.length>0){let e=s.items[0];sy(e)&&(e=e.key);const t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{const e=s.commentBefore;s.commentBefore=e?`${n}\n${e}`:n}}t?(Array.prototype.push.apply(e.errors,this.errors),Array.prototype.push.apply(e.warnings,this.warnings)):(e.errors=this.errors,e.warnings=this.warnings),this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:$b(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(const t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(e.type){case"directive":this.directives.add(e.source,(t,n,i)=>{const s=Rb(e);s[0]+=t,this.onError(s,"BAD_DIRECTIVE",n,i)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{const t=function(e,t,{offset:n,start:i,value:s,end:r},o){const a=Object.assign({_directives:t},e),l=new cb(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},h=mb(i,{indicator:"doc-start",next:s??r?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});h.found&&(l.directives.docStart=!0,!s||"block-map"!==s.type&&"block-seq"!==s.type||h.hasNewline||o(h.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),l.contents=s?Pb(c,s,h,o):Ib(c,h.end,i,null,h,o);const u=l.contents.range[2],d=wb(r,u,!1,o);return d.comment&&(l.comment=d.comment),l.range=[n,u,d.offset],l}(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{const t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new db(Rb(e),"UNEXPECTED_TOKEN",t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case"doc-end":{if(!this.doc){const t="Unexpected doc-end without preceding document";this.errors.push(new db(Rb(e),"UNEXPECTED_TOKEN",t));break}this.doc.directives.docEnd=!0;const t=wb(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){const e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new db(Rb(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){const e=Object.assign({_directives:this.directives},this.options),n=new cb(void 0,e);this.atDirectives&&this.onError(t,"MISSING_CHAR","Missing directives-end indicator line"),n.range=[0,t,t],this.decorate(n,!1),yield n}}}function Lb(e){switch(e){case void 0:case" ":case"\n":case"\r":case"\t":return!0;default:return!1}}const zb=new Set("0123456789ABCDEFabcdef"),jb=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Wb=new Set(",[]{}"),Ub=new Set(" ,[]{}\n\r\t"),Fb=e=>!e||Ub.has(e);class Vb{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if("string"!=typeof e)throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let n=this.next??"stream";for(;n&&(t||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;" "===t||"\t"===t;)t=this.buffer[++e];return!t||"#"===t||"\n"===t||"\r"===t&&"\n"===this.buffer[e+1]}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let n=0;for(;" "===t;)t=this.buffer[++n+e];if("\r"===t){const t=this.buffer[n+e+1];if("\n"===t||!t&&!this.atEnd)return e+n+1}return"\n"===t||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if("-"===t||"."===t){const t=this.buffer.substr(e,3);if(("---"===t||"..."===t)&&Lb(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return("number"!=typeof e||-1!==e&&e<this.pos)&&(e=this.buffer.indexOf("\n",this.pos),this.lineEndPos=e),-1===e?this.atEnd?this.buffer.substring(this.pos):null:("\r"===this.buffer[e-1]&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(null===e)return this.setNext("stream");if("\ufeff"===e[0]&&(yield*this.pushCount(1),e=e.substring(1)),"%"===e[0]){let t=e.length,n=e.indexOf("#");for(;-1!==n;){const i=e[n-1];if(" "===i||"\t"===i){t=n-1;break}n=e.indexOf("#",n+1)}for(;;){const n=e[t-1];if(" "!==n&&"\t"!==n)break;t-=1}const i=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-i),this.pushNewline(),"stream"}if(this.atLineEnd()){const t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),"stream"}return yield"",yield*this.parseLineStart()}*parseLineStart(){const e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if("-"===e||"."===e){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");const e=this.peek(3);if(("---"===e||"..."===e)&&Lb(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,"---"===e?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!Lb(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){const[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext("block-start");if(("-"===e||"?"===e||":"===e)&&Lb(t)){const e=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=e,yield*this.parseBlockStart()}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);const e=this.getLine();if(null===e)return this.setNext("doc");let t=yield*this.pushIndicators();switch(e[t]){case"#":yield*this.pushCount(e.length-t);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(Fb),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return t+=(yield*this.parseBlockScalarHeader()),t+=(yield*this.pushSpaces(!0)),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,n=-1;do{e=yield*this.pushNewline(),e>0?(t=yield*this.pushSpaces(!1),this.indentValue=n=t):t=0,t+=(yield*this.pushSpaces(!0))}while(e+t>0);const i=this.getLine();if(null===i)return this.setNext("flow");if(-1!==n&&n<this.indentNext&&"#"!==i[0]||0===n&&(i.startsWith("---")||i.startsWith("..."))&&Lb(i[3])){if(!(n===this.indentNext-1&&1===this.flowLevel&&("]"===i[0]||"}"===i[0])))return this.flowLevel=0,yield"",yield*this.parseLineStart()}let s=0;for(;","===i[s];)s+=(yield*this.pushCount(1)),s+=(yield*this.pushSpaces(!0)),this.flowKey=!1;switch(s+=(yield*this.pushIndicators()),i[s]){case void 0:return"flow";case"#":return yield*this.pushCount(i.length-s),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(Fb),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{const e=this.charAt(1);if(this.flowKey||Lb(e)||","===e)return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){const e=this.charAt(0);let t=this.buffer.indexOf(e,this.pos+1);if("'"===e)for(;-1!==t&&"'"===this.buffer[t+1];)t=this.buffer.indexOf("'",t+2);else for(;-1!==t;){let e=0;for(;"\\"===this.buffer[t-1-e];)e+=1;if(e%2==0)break;t=this.buffer.indexOf('"',t+1)}const n=this.buffer.substring(0,t);let i=n.indexOf("\n",this.pos);if(-1!==i){for(;-1!==i;){const e=this.continueScalar(i+1);if(-1===e)break;i=n.indexOf("\n",e)}-1!==i&&(t=i-("\r"===n[i-1]?2:1))}if(-1===t){if(!this.atEnd)return this.setNext("quoted-scalar");t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){const t=this.buffer[++e];if("+"===t)this.blockScalarKeep=!0;else if(t>"0"&&t<="9")this.blockScalarIndent=Number(t)-1;else if("-"!==t)break}return yield*this.pushUntil(e=>Lb(e)||"#"===e)}*parseBlockScalar(){let e,t=this.pos-1,n=0;e:for(let i=this.pos;e=this.buffer[i];++i)switch(e){case" ":n+=1;break;case"\n":t=i,n=0;break;case"\r":{const e=this.buffer[i+1];if(!e&&!this.atEnd)return this.setNext("block-scalar");if("\n"===e)break}default:break e}if(!e&&!this.atEnd)return this.setNext("block-scalar");if(n>=this.indentNext){-1===this.blockScalarIndent?this.indentNext=n:this.indentNext=this.blockScalarIndent+(0===this.indentNext?1:this.indentNext);do{const e=this.continueScalar(t+1);if(-1===e)break;t=this.buffer.indexOf("\n",e)}while(-1!==t);if(-1===t){if(!this.atEnd)return this.setNext("block-scalar");t=this.buffer.length}}let i=t+1;for(e=this.buffer[i];" "===e;)e=this.buffer[++i];if("\t"===e){for(;"\t"===e||" "===e||"\r"===e||"\n"===e;)e=this.buffer[++i];t=i-1}else if(!this.blockScalarKeep)for(;;){let e=t-1,i=this.buffer[e];"\r"===i&&(i=this.buffer[--e]);const s=e;for(;" "===i;)i=this.buffer[--e];if(!("\n"===i&&e>=this.pos&&e+1+n>s))break;t=e}return yield"",yield*this.pushToIndex(t+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){const e=this.flowLevel>0;let t,n=this.pos-1,i=this.pos-1;for(;t=this.buffer[++i];)if(":"===t){const t=this.buffer[i+1];if(Lb(t)||e&&Wb.has(t))break;n=i}else if(Lb(t)){let s=this.buffer[i+1];if("\r"===t&&("\n"===s?(i+=1,t="\n",s=this.buffer[i+1]):n=i),"#"===s||e&&Wb.has(s))break;if("\n"===t){const e=this.continueScalar(i+1);if(-1===e)break;i=Math.max(i,e-2)}}else{if(e&&Wb.has(t))break;n=i}return t||this.atEnd?(yield"",yield*this.pushToIndex(n+1,!0),e?"flow":"doc"):this.setNext("plain-scalar")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){const n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.length):(t&&(yield""),0)}*pushIndicators(){switch(this.charAt(0)){case"!":return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"&":return(yield*this.pushUntil(Fb))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{const e=this.flowLevel>0,t=this.charAt(1);if(Lb(t)||e&&Wb.has(t))return e?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,(yield*this.pushCount(1))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators())}}return 0}*pushTag(){if("<"===this.charAt(1)){let e=this.pos+2,t=this.buffer[e];for(;!Lb(t)&&">"!==t;)t=this.buffer[++e];return yield*this.pushToIndex(">"===t?e+1:e,!1)}{let e=this.pos+1,t=this.buffer[e];for(;t;)if(jb.has(t))t=this.buffer[++e];else{if("%"!==t||!zb.has(this.buffer[e+1])||!zb.has(this.buffer[e+2]))break;t=this.buffer[e+=3]}return yield*this.pushToIndex(e,!1)}}*pushNewline(){const e=this.buffer[this.pos];return"\n"===e?yield*this.pushCount(1):"\r"===e&&"\n"===this.charAt(1)?yield*this.pushCount(2):0}*pushSpaces(e){let t,n=this.pos-1;do{t=this.buffer[++n]}while(" "===t||e&&"\t"===t);const i=n-this.pos;return i>0&&(yield this.buffer.substr(this.pos,i),this.pos=n),i}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}class Hb{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){const i=t+n>>1;this.lineStarts[i]<e?t=i+1:n=i}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(0===t)return{line:0,col:e};return{line:t,col:e-this.lineStarts[t-1]+1}}}}function qb(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function Kb(e){for(let t=0;t<e.length;++t)switch(e[t].type){case"space":case"comment":case"newline":break;default:return t}return-1}function Jb(e){switch(e?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function Zb(e){switch(e.type){case"document":return e.start;case"block-map":{const t=e.items[e.items.length-1];return t.sep??t.start}case"block-seq":return e.items[e.items.length-1].start;default:return[]}}function Yb(e){if(0===e.length)return[];let t=e.length;e:for(;--t>=0;)switch(e[t].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;"space"===e[++t]?.type;);return e.splice(t,e.length)}function Gb(e){if("flow-seq-start"===e.start.type)for(const t of e.items)!t.sep||t.value||qb(t.start,"explicit-key-ind")||qb(t.sep,"map-value-ind")||(t.key&&(t.value=t.key),delete t.key,Jb(t.value)?t.value.end?Array.prototype.push.apply(t.value.end,t.sep):t.value.end=t.sep:Array.prototype.push.apply(t.start,t.sep),delete t.sep)}class Qb{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new Vb,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&0===this.offset&&this.onNewLine(0);for(const n of this.lexer.lex(e,t))yield*this.next(n);t||(yield*this.end())}*next(e){if(this.source=e,this.atScalar)return this.atScalar=!1,yield*this.step(),void(this.offset+=e.length);const t=function(e){switch(e){case"\ufeff":return"byte-order-mark";case"":return"doc-mode";case"":return"flow-error-end";case"":return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case"\n":case"\r\n":return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(e[0]){case" ":case"\t":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}(e);if(t)if("scalar"===t)this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=t,yield*this.step(),t){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&" "===e[0]&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{const t=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:t,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){const e=this.peek(1);if("doc-end"!==this.type||"doc-end"===e?.type){if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}else{for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source})}}peek(e){return this.stack[this.stack.length-e]}*pop(e){const t=e??this.stack.pop();if(t)if(0===this.stack.length)yield t;else{const e=this.peek(1);switch("block-scalar"===t.type?t.indent="indent"in e?e.indent:0:"flow-collection"===t.type&&"document"===e.type&&(t.indent=0),"flow-collection"===t.type&&Gb(t),e.type){case"document":e.value=t;break;case"block-scalar":e.props.push(t);break;case"block-map":{const n=e.items[e.items.length-1];if(n.value)return e.items.push({start:[],key:t,sep:[]}),void(this.onKeyLine=!0);if(!n.sep)return Object.assign(n,{key:t,sep:[]}),void(this.onKeyLine=!n.explicitKey);n.value=t;break}case"block-seq":{const n=e.items[e.items.length-1];n.value?e.items.push({start:[],value:t}):n.value=t;break}case"flow-collection":{const n=e.items[e.items.length-1];return void(!n||n.value?e.items.push({start:[],key:t,sep:[]}):n.sep?n.value=t:Object.assign(n,{key:t,sep:[]}))}default:yield*this.pop(),yield*this.pop(t)}if(!("document"!==e.type&&"block-map"!==e.type&&"block-seq"!==e.type||"block-map"!==t.type&&"block-seq"!==t.type)){const n=t.items[t.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&-1===Kb(n.start)&&(0===t.indent||n.start.every(e=>"comment"!==e.type||e.indent<t.indent))&&("document"===e.type?e.end=n.start:e.items.push({start:n.start}),t.items.splice(-1,1))}}else{const e="Tried to pop an empty stack";yield{type:"error",offset:this.offset,source:"",message:e}}}*stream(){switch(this.type){case"directive-line":return void(yield{type:"directive",offset:this.offset,source:this.source});case"byte-order-mark":case"space":case"comment":case"newline":return void(yield this.sourceToken);case"doc-mode":case"doc-start":{const e={type:"document",offset:this.offset,start:[]};return"doc-start"===this.type&&e.start.push(this.sourceToken),void this.stack.push(e)}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":return void(-1!==Kb(e.start)?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken));case"anchor":case"tag":case"space":case"comment":case"newline":return void e.start.push(this.sourceToken)}const t=this.startBlockValue(e);t?this.stack.push(t):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if("map-value-ind"===this.type){const t=Yb(Zb(this.peek(2)));let n;e.end?(n=e.end,n.push(this.sourceToken),delete e.end):n=[this.sourceToken];const i={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:t,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":return void e.props.push(this.sourceToken);case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let e=this.source.indexOf("\n")+1;for(;0!==e;)this.onNewLine(this.offset+e),e=this.source.indexOf("\n",e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){const t=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,t.value){const n="end"in t.value?t.value.end:void 0,i=Array.isArray(n)?n[n.length-1]:void 0;"comment"===i?.type?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){const n=e.items[e.items.length-2],i=n?.value?.end;if(Array.isArray(i))return Array.prototype.push.apply(i,t.start),i.push(this.sourceToken),void e.items.pop()}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){const n=!this.onKeyLine&&this.indent===e.indent,i=n&&(t.sep||t.explicitKey)&&"seq-item-ind"!==this.type;let s=[];if(i&&t.sep&&!t.value){const n=[];for(let i=0;i<t.sep.length;++i){const s=t.sep[i];switch(s.type){case"newline":n.push(i);break;case"space":break;case"comment":s.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(s=t.sep.splice(n[1]))}switch(this.type){case"anchor":case"tag":return void(i||t.value?(s.push(this.sourceToken),e.items.push({start:s}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken));case"explicit-key-ind":return t.sep||t.explicitKey?i||t.value?(s.push(this.sourceToken),e.items.push({start:s,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}):(t.start.push(this.sourceToken),t.explicitKey=!0),void(this.onKeyLine=!0);case"map-value-ind":if(t.explicitKey)if(t.sep)if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(qb(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:null,sep:[this.sourceToken]}]});else if(Jb(t.key)&&!qb(t.sep,"newline")){const e=Yb(t.start),n=t.key,i=t.sep;i.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:i}]})}else s.length>0?t.sep=t.sep.concat(s,this.sourceToken):t.sep.push(this.sourceToken);else if(qb(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{const e=Yb(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}else t.sep?t.value||i?e.items.push({start:s,key:null,sep:[this.sourceToken]}):qb(t.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return void(this.onKeyLine=!0);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const n=this.flowScalar(this.type);return void(i||t.value?(e.items.push({start:s,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0))}default:{const i=this.startBlockValue(e);if(i){if("block-seq"===i.type){if(!t.explicitKey&&t.sep&&!qb(t.sep,"newline"))return void(yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source}))}else n&&e.items.push({start:s});return void this.stack.push(i)}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){const t=e.items[e.items.length-1];switch(this.type){case"newline":if(t.value){const n="end"in t.value?t.value.end:void 0,i=Array.isArray(n)?n[n.length-1]:void 0;"comment"===i?.type?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){const n=e.items[e.items.length-2],i=n?.value?.end;if(Array.isArray(i))return Array.prototype.push.apply(i,t.start),i.push(this.sourceToken),void e.items.pop()}t.start.push(this.sourceToken)}return;case"anchor":case"tag":if(t.value||this.indent<=e.indent)break;return void t.start.push(this.sourceToken);case"seq-item-ind":if(this.indent!==e.indent)break;return void(t.value||qb(t.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken))}if(this.indent>e.indent){const t=this.startBlockValue(e);if(t)return void this.stack.push(t)}yield*this.pop(),yield*this.step()}*flowCollection(e){const t=e.items[e.items.length-1];if("flow-error-end"===this.type){let e;do{yield*this.pop(),e=this.peek(1)}while("flow-collection"===e?.type)}else if(0===e.end.length){switch(this.type){case"comma":case"explicit-key-ind":return void(!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken));case"map-value-ind":return void(!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]}));case"space":case"comment":case"newline":case"anchor":case"tag":return void(!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken));case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const n=this.flowScalar(this.type);return void(!t||t.value?e.items.push({start:[],key:n,sep:[]}):t.sep?this.stack.push(n):Object.assign(t,{key:n,sep:[]}))}case"flow-map-end":case"flow-seq-end":return void e.end.push(this.sourceToken)}const n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{const t=this.peek(2);if("block-map"===t.type&&("map-value-ind"===this.type&&t.indent===e.indent||"newline"===this.type&&!t.items[t.items.length-1].sep))yield*this.pop(),yield*this.step();else if("map-value-ind"===this.type&&"flow-collection"!==t.type){const n=Yb(Zb(t));Gb(e);const i=e.end.splice(1,e.end.length);i.push(this.sourceToken);const s={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:i}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=s}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf("\n")+1;for(;0!==e;)this.onNewLine(this.offset+e),e=this.source.indexOf("\n",e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;const t=Yb(Zb(e));return t.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;const t=Yb(Zb(e));return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return"comment"===this.type&&(!(this.indent<=t)&&e.every(e=>"newline"===e.type||"space"===e.type))}*documentEnd(e){"doc-mode"!==this.type&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],"newline"===this.type&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],"newline"===this.type&&(yield*this.pop())}}}function Xb(e,t={}){const{lineCounter:n,prettyErrors:i}=function(e){const t=!1!==e.prettyErrors;return{lineCounter:e.lineCounter||t&&new Hb||null,prettyErrors:t}}(t),s=new Qb(n?.addNewLine),r=new Bb(t);let o=null;for(const t of r.compose(s.parse(e),!0,e.length))if(o){if("silent"!==o.options.logLevel){o.errors.push(new db(t.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}}else o=t;return i&&n&&(o.errors.forEach(pb(e,n)),o.warnings.forEach(pb(e,n))),o}function ew(e,t,n){function i(n,i){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:i,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,i);const s=o.prototype,r=Object.keys(s);for(let e=0;e<r.length;e++){const t=r[e];t in n||(n[t]=s[t].bind(n))}}const s=n?.Parent??Object;class r extends s{}function o(e){var t;const s=n?.Parent?new r:this;i(s,e),(t=s._zod).deferred??(t.deferred=[]);for(const e of s._zod.deferred)e();return s}return Object.defineProperty(r,"name",{value:e}),Object.defineProperty(o,"init",{value:i}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>!!(n?.Parent&&t instanceof n.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}class tw extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class nw extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const iw={};function sw(e){return iw}function rw(e){const t=Object.values(e).filter(e=>"number"==typeof e),n=Object.entries(e).filter(([e,n])=>-1===t.indexOf(+e)).map(([e,t])=>t);return n}function ow(e,t){return"bigint"==typeof t?t.toString():t}function aw(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function lw(e){return null==e}function cw(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}const hw=Symbol("evaluating");function uw(e,t,n){let i;Object.defineProperty(e,t,{get(){if(i!==hw)return void 0===i&&(i=hw,i=n()),i},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function dw(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function fw(...e){const t={};for(const n of e){const e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function pw(e){return JSON.stringify(e)}const mw="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function gw(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const yw=aw(()=>{if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function vw(e){if(!1===gw(e))return!1;const t=e.constructor;if(void 0===t)return!0;if("function"!=typeof t)return!0;const n=t.prototype;return!1!==gw(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function bw(e){return vw(e)?{...e}:Array.isArray(e)?[...e]:e}const ww=new Set(["string","number","symbol"]);function kw(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function xw(e,t,n){const i=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(i._zod.parent=e),i}function Sw(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}function Cw(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!0!==e.issues[n]?.continue)return!0;return!1}function Aw(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Tw(e){return"string"==typeof e?e:e?.message}function Ow(e,t,n){const i={...e,path:e.path??[]};if(!e.message){const s=Tw(e.inst?._zod.def?.error?.(e))??Tw(t?.error?.(e))??Tw(n.customError?.(e))??Tw(n.localeError?.(e))??"Invalid input";i.message=s}return delete i.inst,delete i.continue,t?.reportInput||delete i.input,i}function Mw(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function Ew(...e){const[t,n,i]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:i}:{...t}}const Nw=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,ow,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Dw=ew("$ZodError",Nw),_w=ew("$ZodError",Nw,{Parent:Error});const Pw=e=>(t,n,i,s)=>{const r=i?Object.assign(i,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},r);if(o instanceof Promise)throw new tw;if(o.issues.length){const t=new(s?.Err??e)(o.issues.map(e=>Ow(e,r,sw())));throw mw(t,s?.callee),t}return o.value},Iw=e=>async(t,n,i,s)=>{const r=i?Object.assign(i,{async:!0}):{async:!0};let o=t._zod.run({value:n,issues:[]},r);if(o instanceof Promise&&(o=await o),o.issues.length){const t=new(s?.Err??e)(o.issues.map(e=>Ow(e,r,sw())));throw mw(t,s?.callee),t}return o.value},Rw=e=>(t,n,i)=>{const s=i?{...i,async:!1}:{async:!1},r=t._zod.run({value:n,issues:[]},s);if(r instanceof Promise)throw new tw;return r.issues.length?{success:!1,error:new(e??Dw)(r.issues.map(e=>Ow(e,s,sw())))}:{success:!0,data:r.value}},$w=Rw(_w),Bw=e=>async(t,n,i)=>{const s=i?Object.assign(i,{async:!0}):{async:!0};let r=t._zod.run({value:n,issues:[]},s);return r instanceof Promise&&(r=await r),r.issues.length?{success:!1,error:new e(r.issues.map(e=>Ow(e,s,sw())))}:{success:!0,data:r.value}},Lw=Bw(_w),zw=e=>(t,n,i)=>{const s=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return Pw(e)(t,n,s)},jw=e=>(t,n,i)=>Pw(e)(t,n,i),Ww=e=>async(t,n,i)=>{const s=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return Iw(e)(t,n,s)},Uw=e=>async(t,n,i)=>Iw(e)(t,n,i),Fw=e=>(t,n,i)=>{const s=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return Rw(e)(t,n,s)},Vw=e=>(t,n,i)=>Rw(e)(t,n,i),Hw=e=>async(t,n,i)=>{const s=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return Bw(e)(t,n,s)},qw=e=>async(t,n,i)=>Bw(e)(t,n,i),Kw=/^[cC][^\s-]{8,}$/,Jw=/^[0-9a-z]+$/,Zw=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Yw=/^[0-9a-vA-V]{20}$/,Gw=/^[A-Za-z0-9]{27}$/,Qw=/^[a-zA-Z0-9_-]{21}$/,Xw=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ek=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,tk=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,nk=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;const ik=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,sk=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,rk=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,ok=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ak=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,lk=/^[A-Za-z0-9_-]*$/,ck=/^\+[1-9]\d{6,14}$/,hk="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",uk=new RegExp(`^${hk}$`);function dk(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}const fk=/^-?\d+(?:\.\d+)?$/,pk=/^[^A-Z]*$/,mk=/^[^a-z]*$/,gk=ew("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),yk=ew("$ZodCheckMaxLength",(e,t)=>{var n;gk.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!lw(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const i=n.value;if(i.length<=t.maximum)return;const s=Mw(i);n.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),vk=ew("$ZodCheckMinLength",(e,t)=>{var n;gk.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!lw(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const i=n.value;if(i.length>=t.minimum)return;const s=Mw(i);n.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),bk=ew("$ZodCheckLengthEquals",(e,t)=>{var n;gk.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!lw(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{const i=n.value,s=i.length;if(s===t.length)return;const r=Mw(i),o=s>t.length;n.issues.push({origin:r,...o?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),wk=ew("$ZodCheckStringFormat",(e,t)=>{var n,i;gk.init(e,t),e._zod.onattach.push(e=>{const n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??(n.patterns=new Set),n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(i=e._zod).check??(i.check=()=>{})}),kk=ew("$ZodCheckRegex",(e,t)=>{wk.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),xk=ew("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=pk),wk.init(e,t)}),Sk=ew("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=mk),wk.init(e,t)}),Ck=ew("$ZodCheckIncludes",(e,t)=>{gk.init(e,t);const n=kw(t.includes),i=new RegExp("number"==typeof t.position?`^.{${t.position}}${n}`:n);t.pattern=i,e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(i)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Ak=ew("$ZodCheckStartsWith",(e,t)=>{gk.init(e,t);const n=new RegExp(`^${kw(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Tk=ew("$ZodCheckEndsWith",(e,t)=>{gk.init(e,t);const n=new RegExp(`.*${kw(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Ok=ew("$ZodCheckOverwrite",(e,t)=>{gk.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class Mk{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});const t=e.split("\n").filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),i=t.map(e=>e.slice(n)).map(e=>" ".repeat(2*this.indent)+e);for(const e of i)this.content.push(e)}compile(){const e=Function,t=this?.args,n=[...(this?.content??[""]).map(e=>` ${e}`)];return new e(...t,n.join("\n"))}}const Ek={major:4,minor:3,patch:6},Nk=ew("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ek;const i=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&i.unshift(e);for(const t of i)for(const n of t._zod.onattach)n(e);if(0===i.length)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const t=(e,t,n)=>{let i,s=Cw(e);for(const r of t){if(r._zod.def.when){if(!r._zod.def.when(e))continue}else if(s)continue;const t=e.issues.length,o=r._zod.check(e);if(o instanceof Promise&&!1===n?.async)throw new tw;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o;e.issues.length!==t&&(s||(s=Cw(e,t)))});else{if(e.issues.length===t)continue;s||(s=Cw(e,t))}}return i?i.then(()=>e):e},n=(n,s,r)=>{if(Cw(n))return n.aborted=!0,n;const o=t(s,i,r);if(o instanceof Promise){if(!1===r.async)throw new tw;return o.then(t=>e._zod.parse(t,r))}return e._zod.parse(o,r)};e._zod.run=(s,r)=>{if(r.skipChecks)return e._zod.parse(s,r);if("backward"===r.direction){const t=e._zod.parse({value:s.value,issues:[]},{...r,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,s,r)):n(t,s,r)}const o=e._zod.parse(s,r);if(o instanceof Promise){if(!1===r.async)throw new tw;return o.then(e=>t(e,i,r))}return t(o,i,r)}}uw(e,"~standard",()=>({validate:t=>{try{const n=$w(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return Lw(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),Dk=ew("$ZodString",(e,t)=>{var n;Nk.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(n=e._zod.bag,new RegExp(`^${n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*"}$`)),e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=String(n.value)}catch(i){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),_k=ew("$ZodStringFormat",(e,t)=>{wk.init(e,t),Dk.init(e,t)}),Pk=ew("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=ek),_k.init(e,t)}),Ik=ew("$ZodUUID",(e,t)=>{if(t.version){const e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=tk(e))}else t.pattern??(t.pattern=tk());_k.init(e,t)}),Rk=ew("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=nk),_k.init(e,t)}),$k=ew("$ZodURL",(e,t)=>{_k.init(e,t),e._zod.check=n=>{try{const i=n.value.trim(),s=new URL(i);return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(s.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(s.protocol.endsWith(":")?s.protocol.slice(0,-1):s.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),void(t.normalize?n.value=s.href:n.value=i)}catch(i){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Bk=ew("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),_k.init(e,t)}),Lk=ew("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Qw),_k.init(e,t)}),zk=ew("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Kw),_k.init(e,t)}),jk=ew("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Jw),_k.init(e,t)}),Wk=ew("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Zw),_k.init(e,t)}),Uk=ew("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Yw),_k.init(e,t)}),Fk=ew("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Gw),_k.init(e,t)}),Vk=ew("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=dk({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const i=`${t}(?:${n.join("|")})`;return new RegExp(`^${hk}T(?:${i})$`)}(t)),_k.init(e,t)}),Hk=ew("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=uk),_k.init(e,t)}),qk=ew("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${dk(t)}$`)),_k.init(e,t)}),Kk=ew("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Xw),_k.init(e,t)}),Jk=ew("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ik),_k.init(e,t),e._zod.bag.format="ipv4"}),Zk=ew("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=sk),_k.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),Yk=ew("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=rk),_k.init(e,t)}),Gk=ew("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ok),_k.init(e,t),e._zod.check=n=>{const i=n.value.split("/");try{if(2!==i.length)throw new Error;const[e,t]=i;if(!t)throw new Error;const n=Number(t);if(`${n}`!==t)throw new Error;if(n<0||n>128)throw new Error;new URL(`http://[${e}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Qk(e){if(""===e)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const Xk=ew("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=ak),_k.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Qk(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});const ex=ew("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=lk),_k.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{(function(e){if(!lk.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return Qk(t.padEnd(4*Math.ceil(t.length/4),"="))})(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),tx=ew("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ck),_k.init(e,t)});const nx=ew("$ZodJWT",(e,t)=>{_k.init(e,t),e._zod.check=n=>{(function(e,t=null){try{const n=e.split(".");if(3!==n.length)return!1;const[i]=n;if(!i)return!1;const s=JSON.parse(atob(i));return!("typ"in s&&"JWT"!==s?.typ||!s.alg||t&&(!("alg"in s)||s.alg!==t))}catch{return!1}})(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),ix=ew("$ZodUnknown",(e,t)=>{Nk.init(e,t),e._zod.parse=e=>e}),sx=ew("$ZodNever",(e,t)=>{Nk.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function rx(e,t,n){e.issues.length&&t.issues.push(...Aw(n,e.issues)),t.value[n]=e.value}const ox=ew("$ZodArray",(e,t)=>{Nk.init(e,t),e._zod.parse=(n,i)=>{const s=n.value;if(!Array.isArray(s))return n.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),n;n.value=Array(s.length);const r=[];for(let e=0;e<s.length;e++){const o=s[e],a=t.element._zod.run({value:o,issues:[]},i);a instanceof Promise?r.push(a.then(t=>rx(t,n,e))):rx(a,n,e)}return r.length?Promise.all(r).then(()=>n):n}});function ax(e,t,n,i,s){if(e.issues.length){if(s&&!(n in i))return;t.issues.push(...Aw(n,e.issues))}void 0===e.value?n in i&&(t.value[n]=void 0):t.value[n]=e.value}function lx(e){const t=Object.keys(e.shape);for(const n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);const n=(i=e.shape,Object.keys(i).filter(e=>"optional"===i[e]._zod.optin&&"optional"===i[e]._zod.optout));var i;return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function cx(e,t,n,i,s,r){const o=[],a=s.keySet,l=s.catchall._zod,c=l.def.type,h="optional"===l.optout;for(const s in t){if(a.has(s))continue;if("never"===c){o.push(s);continue}const r=l.run({value:t[s],issues:[]},i);r instanceof Promise?e.push(r.then(e=>ax(e,n,s,t,h))):ax(r,n,s,t,h)}return o.length&&n.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:r}),e.length?Promise.all(e).then(()=>n):n}const hx=ew("$ZodObject",(e,t)=>{Nk.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!n?.get){const e=t.shape;Object.defineProperty(t,"shape",{get:()=>{const n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}const i=aw(()=>lx(t));uw(e._zod,"propValues",()=>{const e=t.shape,n={};for(const t in e){const i=e[t]._zod;if(i.values){n[t]??(n[t]=new Set);for(const e of i.values)n[t].add(e)}}return n});const s=gw,r=t.catchall;let o;e._zod.parse=(t,n)=>{o??(o=i.value);const a=t.value;if(!s(a))return t.issues.push({expected:"object",code:"invalid_type",input:a,inst:e}),t;t.value={};const l=[],c=o.shape;for(const e of o.keys){const i=c[e],s="optional"===i._zod.optout,r=i._zod.run({value:a[e],issues:[]},n);r instanceof Promise?l.push(r.then(n=>ax(n,t,e,a,s))):ax(r,t,e,a,s)}return r?cx(l,a,t,n,i.value,e):l.length?Promise.all(l).then(()=>t):t}}),ux=ew("$ZodObjectJIT",(e,t)=>{hx.init(e,t);const n=e._zod.parse,i=aw(()=>lx(t));let s;const r=gw,o=!iw.jitless,a=o&&yw.value,l=t.catchall;let c;e._zod.parse=(h,u)=>{c??(c=i.value);const d=h.value;return r(d)?o&&a&&!1===u?.async&&!0!==u.jitless?(s||(s=(e=>{const t=new Mk(["shape","payload","ctx"]),n=i.value,s=e=>{const t=pw(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const r=Object.create(null);let o=0;for(const e of n.keys)r[e]="key_"+o++;t.write("const newResult = {};");for(const i of n.keys){const n=r[i],o=pw(i),a=e[i],l="optional"===a?._zod?.optout;t.write(`const ${n} = ${s(i)};`),l?t.write(`\n if (${n}.issues.length) {\n if (${o} in input) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${o}, ...iss.path] : [${o}]\n })));\n }\n }\n \n if (${n}.value === undefined) {\n if (${o} in input) {\n newResult[${o}] = undefined;\n }\n } else {\n newResult[${o}] = ${n}.value;\n }\n \n `):t.write(`\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${o}, ...iss.path] : [${o}]\n })));\n }\n \n if (${n}.value === undefined) {\n if (${o} in input) {\n newResult[${o}] = undefined;\n }\n } else {\n newResult[${o}] = ${n}.value;\n }\n \n `)}t.write("payload.value = newResult;"),t.write("return payload;");const a=t.compile();return(t,n)=>a(e,t,n)})(t.shape)),h=s(h,u),l?cx([],d,h,u,c,e):h):n(h,u):(h.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),h)}});function dx(e,t,n,i){for(const n of e)if(0===n.issues.length)return t.value=n.value,t;const s=e.filter(e=>!Cw(e));return 1===s.length?(t.value=s[0].value,s[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Ow(e,i,sw())))}),t)}const fx=ew("$ZodUnion",(e,t)=>{Nk.init(e,t),uw(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),uw(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),uw(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),uw(e._zod,"pattern",()=>{if(t.options.every(e=>e._zod.pattern)){const e=t.options.map(e=>e._zod.pattern);return new RegExp(`^(${e.map(e=>cw(e.source)).join("|")})$`)}});const n=1===t.options.length,i=t.options[0]._zod.run;e._zod.parse=(s,r)=>{if(n)return i(s,r);let o=!1;const a=[];for(const e of t.options){const t=e._zod.run({value:s.value,issues:[]},r);if(t instanceof Promise)a.push(t),o=!0;else{if(0===t.issues.length)return t;a.push(t)}}return o?Promise.all(a).then(t=>dx(t,s,e,r)):dx(a,s,e,r)}}),px=ew("$ZodIntersection",(e,t)=>{Nk.init(e,t),e._zod.parse=(e,n)=>{const i=e.value,s=t.left._zod.run({value:i,issues:[]},n),r=t.right._zod.run({value:i,issues:[]},n);return s instanceof Promise||r instanceof Promise?Promise.all([s,r]).then(([t,n])=>gx(e,t,n)):gx(e,s,r)}});function mx(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(vw(e)&&vw(t)){const n=Object.keys(t),i=Object.keys(e).filter(e=>-1!==n.indexOf(e)),s={...e,...t};for(const n of i){const i=mx(e[n],t[n]);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};s[n]=i.data}return{valid:!0,data:s}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let i=0;i<e.length;i++){const s=mx(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function gx(e,t,n){const i=new Map;let s;for(const n of t.issues)if("unrecognized_keys"===n.code){s??(s=n);for(const e of n.keys)i.has(e)||i.set(e,{}),i.get(e).l=!0}else e.issues.push(n);for(const t of n.issues)if("unrecognized_keys"===t.code)for(const e of t.keys)i.has(e)||i.set(e,{}),i.get(e).r=!0;else e.issues.push(t);const r=[...i].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(r.length&&s&&e.issues.push({...s,keys:r}),Cw(e))return e;const o=mx(t.value,n.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const yx=ew("$ZodRecord",(e,t)=>{Nk.init(e,t),e._zod.parse=(n,i)=>{const s=n.value;if(!vw(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),n;const r=[],o=t.keyType._zod.values;if(o){n.value={};const a=new Set;for(const e of o)if("string"==typeof e||"number"==typeof e||"symbol"==typeof e){a.add("number"==typeof e?e.toString():e);const o=t.valueType._zod.run({value:s[e],issues:[]},i);o instanceof Promise?r.push(o.then(t=>{t.issues.length&&n.issues.push(...Aw(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...Aw(e,o.issues)),n.value[e]=o.value)}let l;for(const e in s)a.has(e)||(l=l??[],l.push(e));l&&l.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:l})}else{n.value={};for(const o of Reflect.ownKeys(s)){if("__proto__"===o)continue;let a=t.keyType._zod.run({value:o,issues:[]},i);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if("string"==typeof o&&fk.test(o)&&a.issues.length){const e=t.keyType._zod.run({value:Number(o),issues:[]},i);if(e instanceof Promise)throw new Error("Async schemas not supported in object keys currently");0===e.issues.length&&(a=e)}if(a.issues.length){"loose"===t.mode?n.value[o]=s[o]:n.issues.push({code:"invalid_key",origin:"record",issues:a.issues.map(e=>Ow(e,i,sw())),input:o,path:[o],inst:e});continue}const l=t.valueType._zod.run({value:s[o],issues:[]},i);l instanceof Promise?r.push(l.then(e=>{e.issues.length&&n.issues.push(...Aw(o,e.issues)),n.value[a.value]=e.value})):(l.issues.length&&n.issues.push(...Aw(o,l.issues)),n.value[a.value]=l.value)}}return r.length?Promise.all(r).then(()=>n):n}}),vx=ew("$ZodEnum",(e,t)=>{Nk.init(e,t);const n=rw(t.entries),i=new Set(n);e._zod.values=i,e._zod.pattern=new RegExp(`^(${n.filter(e=>ww.has(typeof e)).map(e=>"string"==typeof e?kw(e):e.toString()).join("|")})$`),e._zod.parse=(t,s)=>{const r=t.value;return i.has(r)||t.issues.push({code:"invalid_value",values:n,input:r,inst:e}),t}}),bx=ew("$ZodTransform",(e,t)=>{Nk.init(e,t),e._zod.parse=(n,i)=>{if("backward"===i.direction)throw new nw(e.constructor.name);const s=t.transform(n.value,n);if(i.async){return(s instanceof Promise?s:Promise.resolve(s)).then(e=>(n.value=e,n))}if(s instanceof Promise)throw new tw;return n.value=s,n}});function wx(e,t){return e.issues.length&&void 0===t?{issues:[],value:void 0}:e}const kx=ew("$ZodOptional",(e,t)=>{Nk.init(e,t),e._zod.optin="optional",e._zod.optout="optional",uw(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),uw(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${cw(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if("optional"===t.innerType._zod.optin){const i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(t=>wx(t,e.value)):wx(i,e.value)}return void 0===e.value?e:t.innerType._zod.run(e,n)}}),xx=ew("$ZodExactOptional",(e,t)=>{kx.init(e,t),uw(e._zod,"values",()=>t.innerType._zod.values),uw(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Sx=ew("$ZodNullable",(e,t)=>{Nk.init(e,t),uw(e._zod,"optin",()=>t.innerType._zod.optin),uw(e._zod,"optout",()=>t.innerType._zod.optout),uw(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${cw(e.source)}|null)$`):void 0}),uw(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>null===e.value?e:t.innerType._zod.run(e,n)}),Cx=ew("$ZodDefault",(e,t)=>{Nk.init(e,t),e._zod.optin="optional",uw(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);if(void 0===e.value)return e.value=t.defaultValue,e;const i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>Ax(e,t)):Ax(i,t)}});function Ax(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}const Tx=ew("$ZodPrefault",(e,t)=>{Nk.init(e,t),e._zod.optin="optional",uw(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>("backward"===n.direction||void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Ox=ew("$ZodNonOptional",(e,t)=>{Nk.init(e,t),uw(e._zod,"values",()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter(e=>void 0!==e)):void 0}),e._zod.parse=(n,i)=>{const s=t.innerType._zod.run(n,i);return s instanceof Promise?s.then(t=>Mx(t,e)):Mx(s,e)}});function Mx(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Ex=ew("$ZodCatch",(e,t)=>{Nk.init(e,t),uw(e._zod,"optin",()=>t.innerType._zod.optin),uw(e._zod,"optout",()=>t.innerType._zod.optout),uw(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(i=>(e.value=i.value,i.issues.length&&(e.value=t.catchValue({...e,error:{issues:i.issues.map(e=>Ow(e,n,sw()))},input:e.value}),e.issues=[]),e)):(e.value=i.value,i.issues.length&&(e.value=t.catchValue({...e,error:{issues:i.issues.map(e=>Ow(e,n,sw()))},input:e.value}),e.issues=[]),e)}}),Nx=ew("$ZodPipe",(e,t)=>{Nk.init(e,t),uw(e._zod,"values",()=>t.in._zod.values),uw(e._zod,"optin",()=>t.in._zod.optin),uw(e._zod,"optout",()=>t.out._zod.optout),uw(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if("backward"===n.direction){const i=t.out._zod.run(e,n);return i instanceof Promise?i.then(e=>Dx(e,t.in,n)):Dx(i,t.in,n)}const i=t.in._zod.run(e,n);return i instanceof Promise?i.then(e=>Dx(e,t.out,n)):Dx(i,t.out,n)}});function Dx(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const _x=ew("$ZodReadonly",(e,t)=>{Nk.init(e,t),uw(e._zod,"propValues",()=>t.innerType._zod.propValues),uw(e._zod,"values",()=>t.innerType._zod.values),uw(e._zod,"optin",()=>t.innerType?._zod?.optin),uw(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(Px):Px(i)}});function Px(e){return e.value=Object.freeze(e.value),e}const Ix=ew("$ZodCustom",(e,t)=>{gk.init(e,t),Nk.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{const i=n.value,s=t.fn(i);if(s instanceof Promise)return s.then(t=>Rx(t,n,i,e));Rx(s,n,i,e)}});function Rx(e,t,n,i){if(!e){const e={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(e.params=i._zod.def.params),t.issues.push(Ew(e))}}var $x;class Bx{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const n=t[0];return this._map.set(e,n),n&&"object"==typeof n&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const n={...this.get(t)??{}};delete n.id;const i={...n,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}($x=globalThis).__zod_globalRegistry??($x.__zod_globalRegistry=new Bx);const Lx=globalThis.__zod_globalRegistry;function zx(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Sw(t)})}function jx(e,t){return new yk({check:"max_length",...Sw(t),maximum:e})}function Wx(e,t){return new vk({check:"min_length",...Sw(t),minimum:e})}function Ux(e,t){return new bk({check:"length_equals",...Sw(t),length:e})}function Fx(e){return new Ok({check:"overwrite",tx:e})}function Vx(e){const t=function(e,t){const n=new gk({check:"custom",...Sw(t)});return n._zod.check=e,n}(n=>(n.addIssue=e=>{if("string"==typeof e)n.issues.push(Ew(e,n.value,t._zod.def));else{const i=e;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),n.issues.push(Ew(i))}},e(n.value,n)));return t}function Hx(e){let t=e?.target??"draft-2020-12";return"draft-4"===t&&(t="draft-04"),"draft-7"===t&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Lx,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function qx(e,t,n={path:[],schemaPath:[]}){var i;const s=e._zod.def,r=t.seen.get(e);if(r){r.count++;return n.schemaPath.includes(e)&&(r.cycle=n.path),r.schema}const o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);const a=e._zod.toJSONSchema?.();if(a)o.schema=a;else{const i={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,i);else{const n=o.schema,r=t.processors[s.type];if(!r)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${s.type}`);r(e,t,n,i)}const r=e._zod.parent;r&&(o.ref||(o.ref=r),qx(r,t,i),t.seen.get(r).isParent=!0)}const l=t.metadataRegistry.get(e);l&&Object.assign(o.schema,l),"input"===t.io&&Zx(e)&&(delete o.schema.examples,delete o.schema.default),"input"===t.io&&o.schema._prefault&&((i=o.schema).default??(i.default=o.schema._prefault)),delete o.schema._prefault;return t.seen.get(e).schema}function Kx(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const i=new Map;for(const t of e.seen.entries()){const n=e.metadataRegistry.get(t[0])?.id;if(n){const e=i.get(n);if(e&&e!==t[0])throw new Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(n,t[0])}}const s=t=>{if(t[1].schema.$ref)return;const i=t[1],{ref:s,defId:r}=(t=>{const i="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){const n=e.external.registry.get(t[0])?.id,s=e.external.uri??(e=>e);if(n)return{ref:s(n)};const r=t[1].defId??t[1].schema.id??"schema"+e.counter++;return t[1].defId=r,{defId:r,ref:`${s("__shared")}#/${i}/${r}`}}if(t[1]===n)return{ref:"#"};const s=`#/${i}/`,r=t[1].schema.id??"__schema"+e.counter++;return{defId:r,ref:s+r}})(t);i.def={...i.schema},r&&(i.defId=r);const o=i.schema;for(const e in o)delete o[e];o.$ref=s};if("throw"===e.cycles)for(const t of e.seen.entries()){const e=t[1];if(e.cycle)throw new Error(`Cycle detected: #/${e.cycle?.join("/")}/<root>\n\nSet the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const n of e.seen.entries()){const i=n[1];if(t===n[0]){s(n);continue}if(e.external){const i=e.external.registry.get(n[0])?.id;if(t!==n[0]&&i){s(n);continue}}const r=e.metadataRegistry.get(n[0])?.id;r?s(n):(i.cycle||i.count>1&&"ref"===e.reused)&&s(n)}}function Jx(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const i=t=>{const n=e.seen.get(t);if(null===n.ref)return;const s=n.def??n.schema,r={...s},o=n.ref;if(n.ref=null,o){i(o);const n=e.seen.get(o),a=n.schema;!a.$ref||"draft-07"!==e.target&&"draft-04"!==e.target&&"openapi-3.0"!==e.target?Object.assign(s,a):(s.allOf=s.allOf??[],s.allOf.push(a)),Object.assign(s,r);if(t._zod.parent===o)for(const e in s)"$ref"!==e&&"allOf"!==e&&(e in r||delete s[e]);if(a.$ref&&n.def)for(const e in s)"$ref"!==e&&"allOf"!==e&&e in n.def&&JSON.stringify(s[e])===JSON.stringify(n.def[e])&&delete s[e]}const a=t._zod.parent;if(a&&a!==o){i(a);const t=e.seen.get(a);if(t?.schema.$ref&&(s.$ref=t.schema.$ref,t.def))for(const e in s)"$ref"!==e&&"allOf"!==e&&e in t.def&&JSON.stringify(s[e])===JSON.stringify(t.def[e])&&delete s[e]}e.override({zodSchema:t,jsonSchema:s,path:n.path??[]})};for(const t of[...e.seen.entries()].reverse())i(t[0]);const s={};if("draft-2020-12"===e.target?s.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?s.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?s.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const n=e.external.registry.get(t)?.id;if(!n)throw new Error("Schema is missing an `id` property");s.$id=e.external.uri(n)}Object.assign(s,n.def??n.schema);const r=e.external?.defs??{};for(const t of e.seen.entries()){const e=t[1];e.def&&e.defId&&(r[e.defId]=e.def)}e.external||Object.keys(r).length>0&&("draft-2020-12"===e.target?s.$defs=r:s.definitions=r);try{const n=JSON.parse(JSON.stringify(s));return Object.defineProperty(n,"~standard",{value:{...t["~standard"],jsonSchema:{input:Yx(t,"input",e.processors),output:Yx(t,"output",e.processors)}},enumerable:!1,writable:!1}),n}catch(e){throw new Error("Error converting schema to JSON.")}}function Zx(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const i=e._zod.def;if("transform"===i.type)return!0;if("array"===i.type)return Zx(i.element,n);if("set"===i.type)return Zx(i.valueType,n);if("lazy"===i.type)return Zx(i.getter(),n);if("promise"===i.type||"optional"===i.type||"nonoptional"===i.type||"nullable"===i.type||"readonly"===i.type||"default"===i.type||"prefault"===i.type)return Zx(i.innerType,n);if("intersection"===i.type)return Zx(i.left,n)||Zx(i.right,n);if("record"===i.type||"map"===i.type)return Zx(i.keyType,n)||Zx(i.valueType,n);if("pipe"===i.type)return Zx(i.in,n)||Zx(i.out,n);if("object"===i.type){for(const e in i.shape)if(Zx(i.shape[e],n))return!0;return!1}if("union"===i.type){for(const e of i.options)if(Zx(e,n))return!0;return!1}if("tuple"===i.type){for(const e of i.items)if(Zx(e,n))return!0;return!(!i.rest||!Zx(i.rest,n))}return!1}const Yx=(e,t,n={})=>i=>{const{libraryOptions:s,target:r}=i??{},o=Hx({...s??{},target:r,io:t,processors:n});return qx(e,o),Kx(o,e),Jx(o,e)},Gx={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Qx=(e,t,n,i)=>{const s=e._zod.def;qx(s.innerType,t,i);t.seen.get(e).ref=s.innerType},Xx=ew("ZodISODateTime",(e,t)=>{Vk.init(e,t),CS.init(e,t)});function eS(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Sw(t)})}(Xx,e)}const tS=ew("ZodISODate",(e,t)=>{Hk.init(e,t),CS.init(e,t)});function nS(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...Sw(t)})}(tS,e)}const iS=ew("ZodISOTime",(e,t)=>{qk.init(e,t),CS.init(e,t)});function sS(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Sw(t)})}(iS,e)}const rS=ew("ZodISODuration",(e,t)=>{Kk.init(e,t),CS.init(e,t)});function oS(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...Sw(t)})}(rS,e)}const aS=ew("ZodError",(e,t)=>{Dw.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t=e=>e.message){const n={_errors:[]},i=e=>{for(const s of e.issues)if("invalid_union"===s.code&&s.errors.length)s.errors.map(e=>i({issues:e}));else if("invalid_key"===s.code)i({issues:s.issues});else if("invalid_element"===s.code)i({issues:s.issues});else if(0===s.path.length)n._errors.push(t(s));else{let e=n,i=0;for(;i<s.path.length;){const n=s.path[i];i===s.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(s))):e[n]=e[n]||{_errors:[]},e=e[n],i++}}};return i(e),n}(e,t)},flatten:{value:t=>function(e,t=e=>e.message){const n={},i=[];for(const s of e.issues)s.path.length>0?(n[s.path[0]]=n[s.path[0]]||[],n[s.path[0]].push(t(s))):i.push(t(s));return{formErrors:i,fieldErrors:n}}(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,ow,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,ow,2)}},isEmpty:{get:()=>0===e.issues.length}})},{Parent:Error}),lS=Pw(aS),cS=Iw(aS),hS=Rw(aS),uS=Bw(aS),dS=zw(aS),fS=jw(aS),pS=Ww(aS),mS=Uw(aS),gS=Fw(aS),yS=Vw(aS),vS=Hw(aS),bS=qw(aS),wS=ew("ZodType",(e,t)=>(Nk.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Yx(e,"input"),output:Yx(e,"output")}}),e.toJSONSchema=((e,t={})=>n=>{const i=Hx({...n,processors:t});return qx(e,i),Kx(i,e),Jx(i,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(fw(t,{checks:[...t.checks??[],...n.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>xw(e,t,n),e.brand=()=>e,e.register=(t,n)=>(t.add(e,n),e),e.parse=(t,n)=>lS(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>hS(e,t,n),e.parseAsync=async(t,n)=>cS(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>uS(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>dS(e,t,n),e.decode=(t,n)=>fS(e,t,n),e.encodeAsync=async(t,n)=>pS(e,t,n),e.decodeAsync=async(t,n)=>mS(e,t,n),e.safeEncode=(t,n)=>gS(e,t,n),e.safeDecode=(t,n)=>yS(e,t,n),e.safeEncodeAsync=async(t,n)=>vS(e,t,n),e.safeDecodeAsync=async(t,n)=>bS(e,t,n),e.refine=(t,n)=>e.check(function(e,t={}){return function(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Sw(n)})}(fC,e,t)}(t,n)),e.superRefine=t=>e.check(Vx(t)),e.overwrite=t=>e.check(Fx(t)),e.optional=()=>nC(e),e.exactOptional=()=>new iC({type:"optional",innerType:e}),e.nullable=()=>rC(e),e.nullish=()=>nC(rC(e)),e.nonoptional=t=>function(e,t){return new lC({type:"nonoptional",innerType:e,...Sw(t)})}(e,t),e.array=()=>{return function(e,t,n){return new e({type:"array",element:t,...Sw(n)})}(JS,e,t);var t},e.or=t=>{return new YS({type:"union",options:[e,t],...Sw(n)});var n},e.and=t=>new GS({type:"intersection",left:e,right:t}),e.transform=t=>uC(e,new eC({type:"transform",transform:t})),e.default=t=>{return n=t,new oC({type:"default",innerType:e,get defaultValue(){return"function"==typeof n?n():bw(n)}});var n},e.prefault=t=>{return n=t,new aC({type:"prefault",innerType:e,get defaultValue(){return"function"==typeof n?n():bw(n)}});var n},e.catch=t=>{return new cC({type:"catch",innerType:e,catchValue:"function"==typeof(n=t)?n:()=>n});var n},e.pipe=t=>uC(e,t),e.readonly=()=>new dC({type:"readonly",innerType:e}),e.describe=t=>{const n=e.clone();return Lx.add(n,{description:t}),n},Object.defineProperty(e,"description",{get:()=>Lx.get(e)?.description,configurable:!0}),e.meta=(...t)=>{if(0===t.length)return Lx.get(e);const n=e.clone();return Lx.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),kS=ew("_ZodString",(e,t)=>{Dk.init(e,t),wS.init(e,t),e._zod.processJSONSchema=(t,n,i)=>((e,t,n)=>{const i=n;i.type="string";const{minimum:s,maximum:r,format:o,patterns:a,contentEncoding:l}=e._zod.bag;if("number"==typeof s&&(i.minLength=s),"number"==typeof r&&(i.maxLength=r),o&&(i.format=Gx[o]??o,""===i.format&&delete i.format,"time"===o&&delete i.format),l&&(i.contentEncoding=l),a&&a.size>0){const e=[...a];1===e.length?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({..."draft-07"===t.target||"draft-04"===t.target||"openapi-3.0"===t.target?{type:"string"}:{},pattern:e.source}))])}})(e,t,n);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(function(e,t){return new kk({check:"string_format",format:"regex",...Sw(t),pattern:e})}(...t)),e.includes=(...t)=>e.check(function(e,t){return new Ck({check:"string_format",format:"includes",...Sw(t),includes:e})}(...t)),e.startsWith=(...t)=>e.check(function(e,t){return new Ak({check:"string_format",format:"starts_with",...Sw(t),prefix:e})}(...t)),e.endsWith=(...t)=>e.check(function(e,t){return new Tk({check:"string_format",format:"ends_with",...Sw(t),suffix:e})}(...t)),e.min=(...t)=>e.check(Wx(...t)),e.max=(...t)=>e.check(jx(...t)),e.length=(...t)=>e.check(Ux(...t)),e.nonempty=(...t)=>e.check(Wx(1,...t)),e.lowercase=t=>e.check(function(e){return new xk({check:"string_format",format:"lowercase",...Sw(e)})}(t)),e.uppercase=t=>e.check(function(e){return new Sk({check:"string_format",format:"uppercase",...Sw(e)})}(t)),e.trim=()=>e.check(Fx(e=>e.trim())),e.normalize=(...t)=>e.check(function(e){return Fx(t=>t.normalize(e))}(...t)),e.toLowerCase=()=>e.check(Fx(e=>e.toLowerCase())),e.toUpperCase=()=>e.check(Fx(e=>e.toUpperCase())),e.slugify=()=>e.check(Fx(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}),xS=ew("ZodString",(e,t)=>{Dk.init(e,t),kS.init(e,t),e.email=t=>e.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Sw(t)})}(AS,t)),e.url=t=>e.check(function(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Sw(t)})}(MS,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Sw(t)})}(FS,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Sw(t)})}(ES,t)),e.guid=t=>e.check(zx(TS,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Sw(t)})}(OS,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Sw(t)})}(OS,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Sw(t)})}(OS,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Sw(t)})}(OS,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Sw(t)})}(NS,t)),e.guid=t=>e.check(zx(TS,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Sw(t)})}(DS,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Sw(t)})}(_S,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Sw(t)})}(PS,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Sw(t)})}(jS,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Sw(t)})}(WS,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Sw(t)})}(IS,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Sw(t)})}(RS,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Sw(t)})}($S,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Sw(t)})}(BS,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Sw(t)})}(LS,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Sw(t)})}(zS,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Sw(t)})}(US,t)),e.datetime=t=>e.check(eS(t)),e.date=t=>e.check(nS(t)),e.time=t=>e.check(sS(t)),e.duration=t=>e.check(oS(t))});function SS(e){return function(e,t){return new e({type:"string",...Sw(t)})}(xS,e)}const CS=ew("ZodStringFormat",(e,t)=>{_k.init(e,t),kS.init(e,t)}),AS=ew("ZodEmail",(e,t)=>{Rk.init(e,t),CS.init(e,t)}),TS=ew("ZodGUID",(e,t)=>{Pk.init(e,t),CS.init(e,t)}),OS=ew("ZodUUID",(e,t)=>{Ik.init(e,t),CS.init(e,t)}),MS=ew("ZodURL",(e,t)=>{$k.init(e,t),CS.init(e,t)}),ES=ew("ZodEmoji",(e,t)=>{Bk.init(e,t),CS.init(e,t)}),NS=ew("ZodNanoID",(e,t)=>{Lk.init(e,t),CS.init(e,t)}),DS=ew("ZodCUID",(e,t)=>{zk.init(e,t),CS.init(e,t)}),_S=ew("ZodCUID2",(e,t)=>{jk.init(e,t),CS.init(e,t)}),PS=ew("ZodULID",(e,t)=>{Wk.init(e,t),CS.init(e,t)}),IS=ew("ZodXID",(e,t)=>{Uk.init(e,t),CS.init(e,t)}),RS=ew("ZodKSUID",(e,t)=>{Fk.init(e,t),CS.init(e,t)}),$S=ew("ZodIPv4",(e,t)=>{Jk.init(e,t),CS.init(e,t)}),BS=ew("ZodIPv6",(e,t)=>{Zk.init(e,t),CS.init(e,t)}),LS=ew("ZodCIDRv4",(e,t)=>{Yk.init(e,t),CS.init(e,t)}),zS=ew("ZodCIDRv6",(e,t)=>{Gk.init(e,t),CS.init(e,t)}),jS=ew("ZodBase64",(e,t)=>{Xk.init(e,t),CS.init(e,t)}),WS=ew("ZodBase64URL",(e,t)=>{ex.init(e,t),CS.init(e,t)}),US=ew("ZodE164",(e,t)=>{tx.init(e,t),CS.init(e,t)}),FS=ew("ZodJWT",(e,t)=>{nx.init(e,t),CS.init(e,t)}),VS=ew("ZodUnknown",(e,t)=>{ix.init(e,t),wS.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}});function HS(){return new VS({type:"unknown"})}const qS=ew("ZodNever",(e,t)=>{sx.init(e,t),wS.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.not={}})(0,0,t)});function KS(e){return function(e,t){return new e({type:"never",...Sw(t)})}(qS,e)}const JS=ew("ZodArray",(e,t)=>{ox.init(e,t),wS.init(e,t),e._zod.processJSONSchema=(t,n,i)=>((e,t,n,i)=>{const s=n,r=e._zod.def,{minimum:o,maximum:a}=e._zod.bag;"number"==typeof o&&(s.minItems=o),"number"==typeof a&&(s.maxItems=a),s.type="array",s.items=qx(r.element,t,{...i,path:[...i.path,"items"]})})(e,t,n,i),e.element=t.element,e.min=(t,n)=>e.check(Wx(t,n)),e.nonempty=t=>e.check(Wx(1,t)),e.max=(t,n)=>e.check(jx(t,n)),e.length=(t,n)=>e.check(Ux(t,n)),e.unwrap=()=>e.element});const ZS=ew("ZodObject",(e,t)=>{ux.init(e,t),wS.init(e,t),e._zod.processJSONSchema=(t,n,i)=>((e,t,n,i)=>{const s=n,r=e._zod.def;s.type="object",s.properties={};const o=r.shape;for(const e in o)s.properties[e]=qx(o[e],t,{...i,path:[...i.path,"properties",e]});const a=new Set(Object.keys(o)),l=new Set([...a].filter(e=>{const n=r.shape[e]._zod;return"input"===t.io?void 0===n.optin:void 0===n.optout}));l.size>0&&(s.required=Array.from(l)),"never"===r.catchall?._zod.def.type?s.additionalProperties=!1:r.catchall?r.catchall&&(s.additionalProperties=qx(r.catchall,t,{...i,path:[...i.path,"additionalProperties"]})):"output"===t.io&&(s.additionalProperties=!1)})(e,t,n,i),uw(e,"shape",()=>t.shape),e.keyof=()=>function(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new XS({type:"enum",entries:n,...Sw(t)})}(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:HS()}),e.loose=()=>e.clone({...e._zod.def,catchall:HS()}),e.strict=()=>e.clone({...e._zod.def,catchall:KS()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>function(e,t){if(!vw(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const n=e._zod.def.shape;for(const e in t)if(void 0!==Object.getOwnPropertyDescriptor(n,e))throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=fw(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return dw(this,"shape",n),n}});return xw(e,i)}(e,t),e.safeExtend=t=>function(e,t){if(!vw(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=fw(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return dw(this,"shape",n),n}});return xw(e,n)}(e,t),e.merge=t=>function(e,t){const n=fw(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return dw(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return xw(e,n)}(e,t),e.pick=t=>function(e,t){const n=e._zod.def,i=n.checks;if(i&&i.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return xw(e,fw(e._zod.def,{get shape(){const e={};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(e[i]=n.shape[i])}return dw(this,"shape",e),e},checks:[]}))}(e,t),e.omit=t=>function(e,t){const n=e._zod.def,i=n.checks;if(i&&i.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=fw(e._zod.def,{get shape(){const i={...e._zod.def.shape};for(const e in t){if(!(e in n.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete i[e]}return dw(this,"shape",i),i},checks:[]});return xw(e,s)}(e,t),e.partial=(...t)=>function(e,t,n){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const s=fw(t._zod.def,{get shape(){const i=t._zod.def.shape,s={...i};if(n)for(const t in n){if(!(t in i))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(s[t]=e?new e({type:"optional",innerType:i[t]}):i[t])}else for(const t in i)s[t]=e?new e({type:"optional",innerType:i[t]}):i[t];return dw(this,"shape",s),s},checks:[]});return xw(t,s)}(tC,e,t[0]),e.required=(...t)=>function(e,t,n){const i=fw(t._zod.def,{get shape(){const i=t._zod.def.shape,s={...i};if(n)for(const t in n){if(!(t in s))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(s[t]=new e({type:"nonoptional",innerType:i[t]}))}else for(const t in i)s[t]=new e({type:"nonoptional",innerType:i[t]});return dw(this,"shape",s),s}});return xw(t,i)}(lC,e,t[0])});const YS=ew("ZodUnion",(e,t)=>{fx.init(e,t),wS.init(e,t),e._zod.processJSONSchema=(t,n,i)=>((e,t,n,i)=>{const s=e._zod.def,r=!1===s.inclusive,o=s.options.map((e,n)=>qx(e,t,{...i,path:[...i.path,r?"oneOf":"anyOf",n]}));r?n.oneOf=o:n.anyOf=o})(e,t,n,i),e.options=t.options});const GS=ew("ZodIntersection",(e,t)=>{px.init(e,t),wS.init(e,t),e._zod.processJSONSchema=(t,n,i)=>((e,t,n,i)=>{const s=e._zod.def,r=qx(s.left,t,{...i,path:[...i.path,"allOf",0]}),o=qx(s.right,t,{...i,path:[...i.path,"allOf",1]}),a=e=>"allOf"in e&&1===Object.keys(e).length,l=[...a(r)?r.allOf:[r],...a(o)?o.allOf:[o]];n.allOf=l})(e,t,n,i)});const QS=ew("ZodRecord",(e,t)=>{yx.init(e,t),wS.init(e,t),e._zod.processJSONSchema=(t,n,i)=>((e,t,n,i)=>{const s=n,r=e._zod.def;s.type="object";const o=r.keyType,a=o._zod.bag,l=a?.patterns;if("loose"===r.mode&&l&&l.size>0){const e=qx(r.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});s.patternProperties={};for(const t of l)s.patternProperties[t.source]=e}else"draft-07"!==t.target&&"draft-2020-12"!==t.target||(s.propertyNames=qx(r.keyType,t,{...i,path:[...i.path,"propertyNames"]})),s.additionalProperties=qx(r.valueType,t,{...i,path:[...i.path,"additionalProperties"]});const c=o._zod.values;if(c){const e=[...c].filter(e=>"string"==typeof e||"number"==typeof e);e.length>0&&(s.required=e)}})(e,t,n,i),e.keyType=t.keyType,e.valueType=t.valueType});const XS=ew("ZodEnum",(e,t)=>{vx.init(e,t),wS.init(e,t),e._zod.processJSONSchema=(t,n,i)=>((e,t,n)=>{const i=rw(e._zod.def.entries);i.every(e=>"number"==typeof e)&&(n.type="number"),i.every(e=>"string"==typeof e)&&(n.type="string"),n.enum=i})(e,0,n),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(e,i)=>{const s={};for(const i of e){if(!n.has(i))throw new Error(`Key ${i} not found in enum`);s[i]=t.entries[i]}return new XS({...t,checks:[],...Sw(i),entries:s})},e.exclude=(e,i)=>{const s={...t.entries};for(const t of e){if(!n.has(t))throw new Error(`Key ${t} not found in enum`);delete s[t]}return new XS({...t,checks:[],...Sw(i),entries:s})}});const eC=ew("ZodTransform",(e,t)=>{bx.init(e,t),wS.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Transforms cannot be represented in JSON Schema")})(0,e),e._zod.parse=(n,i)=>{if("backward"===i.direction)throw new nw(e.constructor.name);n.addIssue=i=>{if("string"==typeof i)n.issues.push(Ew(i,n.value,t));else{const t=i;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=n.value),t.inst??(t.inst=e),n.issues.push(Ew(t))}};const s=t.transform(n.value,n);return s instanceof Promise?s.then(e=>(n.value=e,n)):(n.value=s,n)}});const tC=ew("ZodOptional",(e,t)=>{kx.init(e,t),wS.init(e,t),e._zod.processJSONSchema=(t,n,i)=>Qx(e,t,0,i),e.unwrap=()=>e._zod.def.innerType});function nC(e){return new tC({type:"optional",innerType:e})}const iC=ew("ZodExactOptional",(e,t)=>{xx.init(e,t),wS.init(e,t),e._zod.processJSONSchema=(t,n,i)=>Qx(e,t,0,i),e.unwrap=()=>e._zod.def.innerType});const sC=ew("ZodNullable",(e,t)=>{Sx.init(e,t),wS.init(e,t),e._zod.processJSONSchema=(t,n,i)=>((e,t,n,i)=>{const s=e._zod.def,r=qx(s.innerType,t,i),o=t.seen.get(e);"openapi-3.0"===t.target?(o.ref=s.innerType,n.nullable=!0):n.anyOf=[r,{type:"null"}]})(e,t,n,i),e.unwrap=()=>e._zod.def.innerType});function rC(e){return new sC({type:"nullable",innerType:e})}const oC=ew("ZodDefault",(e,t)=>{Cx.init(e,t),wS.init(e,t),e._zod.processJSONSchema=(t,n,i)=>((e,t,n,i)=>{const s=e._zod.def;qx(s.innerType,t,i),t.seen.get(e).ref=s.innerType,n.default=JSON.parse(JSON.stringify(s.defaultValue))})(e,t,n,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});const aC=ew("ZodPrefault",(e,t)=>{Tx.init(e,t),wS.init(e,t),e._zod.processJSONSchema=(t,n,i)=>((e,t,n,i)=>{const s=e._zod.def;qx(s.innerType,t,i),t.seen.get(e).ref=s.innerType,"input"===t.io&&(n._prefault=JSON.parse(JSON.stringify(s.defaultValue)))})(e,t,n,i),e.unwrap=()=>e._zod.def.innerType});const lC=ew("ZodNonOptional",(e,t)=>{Ox.init(e,t),wS.init(e,t),e._zod.processJSONSchema=(t,n,i)=>((e,t,n,i)=>{const s=e._zod.def;qx(s.innerType,t,i),t.seen.get(e).ref=s.innerType})(e,t,0,i),e.unwrap=()=>e._zod.def.innerType});const cC=ew("ZodCatch",(e,t)=>{Ex.init(e,t),wS.init(e,t),e._zod.processJSONSchema=(t,n,i)=>((e,t,n,i)=>{const s=e._zod.def;let r;qx(s.innerType,t,i),t.seen.get(e).ref=s.innerType;try{r=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=r})(e,t,n,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});const hC=ew("ZodPipe",(e,t)=>{Nx.init(e,t),wS.init(e,t),e._zod.processJSONSchema=(t,n,i)=>((e,t,n,i)=>{const s=e._zod.def,r="input"===t.io?"transform"===s.in._zod.def.type?s.out:s.in:s.out;qx(r,t,i),t.seen.get(e).ref=r})(e,t,0,i),e.in=t.in,e.out=t.out});function uC(e,t){return new hC({type:"pipe",in:e,out:t})}const dC=ew("ZodReadonly",(e,t)=>{_x.init(e,t),wS.init(e,t),e._zod.processJSONSchema=(t,n,i)=>((e,t,n,i)=>{const s=e._zod.def;qx(s.innerType,t,i),t.seen.get(e).ref=s.innerType,n.readOnly=!0})(e,t,n,i),e.unwrap=()=>e._zod.def.innerType});const fC=ew("ZodCustom",(e,t)=>{Ix.init(e,t),wS.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Custom types cannot be represented in JSON Schema")})(0,e)});function pC(e){return`[36m${e}[0m`}function mC(e){return`[33m${e}[0m`}async function gC(e,t,n){const i=e.substring(1),s=await async function(e,t,n){const i=`https://api.github.com/repos/${e}/git/trees/${t}?recursive=1`,s=await yC(i,AC(n));if(!s.ok){if(404===s.status){const i=`https://api.github.com/repos/${e}`;return(await yC(i,AC(n))).ok?{kind:"error",message:`Version not found: https://github.com/${e}/releases/tag/${t}`}:{kind:"error",message:`Repository not found: https://github.com/${e}`}}throw new Error(`Github API request failed: ${s.status} ${s.statusText}`)}return{kind:"success",tree:await s.json()}}(i,t,n);if("error"===s.kind)return s;const r=s.tree,o={},a=r.tree.filter(e=>"blob"===e.type&&e.path.startsWith("skir-src/")&&e.path.endsWith(".skir")).map(async t=>{const s=await vC(i,t.sha,n);return{modulePath:e+t.path.substring(8),content:s}}),l=await Promise.all(a);for(const{modulePath:e,content:t}of l)o[e]=t;const c=r.tree.find(e=>"blob"===e.type&&"skir.yml"===e.path);if(!c)return{kind:"error",message:`Package ${e}@${t} is missing required skir.yml configuration file`};const h=function(e){const t=[],n=new Hb,i=Xb(e,{lineCounter:n}),s=e=>{const t=n.linePos(e);return{offset:e,lineNumber:t.line,colNumber:t.col}},r=(e,t)=>({start:s(e),end:s(t)}),o=e=>{const t=i.getIn(e,!0);if(t?.range)return r(t.range[0],t.range[1])},a=(e,n)=>{let i=e;const s=[];for(;0!==i.length;){if(o(i))break;s.push(i.at(-1)),i=i.slice(0,-1)}s.reverse();const r=s.map((e,t)=>"number"==typeof e?`[${e}]`:0===t?e:`.${String(e)}`).join(""),a=s.length?`Missing property '${r}': `:"";t.push({message:a+n,range:o(i)})};if(i.errors.length>0){for(const e of i.errors)t.push({message:e.message,range:r(e.pos[0],e.pos[1])});return{dependencies:void 0,errors:t}}const l=kC.safeParse(i.toJS());if(!l.success){for(const e of l.error.issues)a(e.path,e.message);return{dependencies:void 0,errors:t}}return{dependencies:l.data.dependencies,errors:t}}(await vC(i,c.sha,n));if(h.errors.length>0)return{kind:"error",message:h.errors.map(t=>function(e,t){const{message:n,range:i}=e,{skirConfigPath:s}=t;return[i?[pC(s),mC(i.start.lineNumber.toString()),mC(i.start.colNumber.toString())].join(":"):pC(s)," - ",(r="error",`[31m${r}[0m`),": ",n].join("");var r}(t,{skirConfigPath:`${e}/skir.yml`})).join("\n")};const u=h.dependencies??{};return{kind:"success",package:{packageId:e,version:t,modules:o,dependencies:u}}}async function yC(e,t,n=3){let i;for(let s=0;s<=n;s++){const r=await fetch(e,{headers:t});if(403!==r.status&&429!==r.status)return r;if(i=r,s===n)break;const o=r.headers.get("Retry-After"),a=o?1e3*parseInt(o,10):1e3*2**s;await new Promise(e=>setTimeout(e,a))}return i}async function vC(e,t,n){const i=`https://api.github.com/repos/${e}/git/blobs/${t}`,s=await yC(i,AC(n));if(!s.ok)throw new Error(`Failed to download file: ${s.status} ${s.statusText}`);const r=await s.json();return"base64"===r.encoding?function(e){const t=e.replace(/\s/g,""),n=atob(t),i=Uint8Array.from(n,e=>e.charCodeAt(0));return(new TextDecoder).decode(i)}(r.content):r.content}const bC=SS().regex(/^@[A-Za-z0-9-]+\/[A-Za-z0-9\-_.]+$/),wC=SS().regex(/^[A-Za-z0-9\-_./+]+$/),kC=function(e,t){const n={type:"object",shape:e??{},...Sw(t)};return new ZS(n)}({dependencies:(xC=bC,SC=wC,new QS({type:"record",keyType:xC,valueType:SC,...Sw(CC)})).default({})});var xC,SC,CC;function AC(e){const t={Accept:"application/vnd.github.v3+json"};return e&&(t.Authorization=`token ${e}`),t}class TC{constructor(e,t,n){this.cachedPackages=e,this.githubToken=t,this.packageDownloader=n,this.packageBundles={},this.dependencyChain=[],this.errors=[],this.allDependenciesOnDisk=!0}async run(e){for(const[t,n]of Object.entries(e))if(await this.getDependency(t,n),this.errors.length>0)return this.errors[0];const t=!(this.allDependenciesOnDisk&&Object.keys(e).length===Object.keys(this.cachedPackages).length);return{kind:"success",packages:Object.fromEntries(Object.entries(this.packageBundles).map(([e,t])=>[e,t.pkg])),changed:t}}async getDependency(e,t){this.dependencyChain.push({packageId:e,version:t});try{const n=this.packageBundles[e];if(n?.pkg.version===t)return;if(n)return void this.errors.push({kind:"error",message:[`Version conflict for package ${e}:`,`- ${OC(this.dependencyChain)}`,`- ${OC(n.dependencyChain)}`].join("\n")});let i=this.getCachedPackage(e,t);if(!i){this.allDependenciesOnDisk=!1;const n=await this.packageDownloader(e,t,this.githubToken);if("success"!==n.kind)return void this.errors.push(n);i=n.package}this.packageBundles[e]={pkg:i,dependencyChain:[...this.dependencyChain]};for(const[e,t]of Object.entries(i.dependencies))await this.getDependency(e,t)}finally{this.dependencyChain.pop()}}getCachedPackage(e,t){const n=this.cachedPackages[e];return n?.version===t?n:void 0}}function OC(e){return"main depends on "+e.map(e=>`${e.packageId}:${e.version}`).join(" which depends on ")}async function MC(e,t,n=gC){const i=function(e){const t=e.match(/^https:\/\/github\.com\/([^/]+)\/([^/]+)\/blob\/([^/]+)\/(.+)#L(\d+)$/);if(!t)return{kind:"error",message:`Invalid GitHub URL: ${e}`};const n=t[1],i=t[2],s=t[3],r=t[4],o=Number(t[5]);if(!r.startsWith("skir-src/")||!r.endsWith(".skir"))return{kind:"error",message:`URL must target a .skir file in skir-src: ${e}`};if(!Number.isInteger(o)||o<=0)return{kind:"error",message:`Invalid line number in URL: ${e}`};const a=`@${n}/${i}`,l=a+r.substring(8);return{kind:"success",packageId:a,version:s,modulePath:l,lineNumber:o-1}}(e);if("error"===i.kind)return i;const{packageId:s,version:r,modulePath:o,lineNumber:a}=i,l=new TC({},t,n),c=await l.run({[s]:r});if("error"===c.kind)return c;const h=new Map;for(const e of Object.values(c.packages))for(const[t,n]of Object.entries(e.modules))h.set(t,n);const u=jg.compile(h);if(u.errors.length>0)return{kind:"error",message:u.errors[0].message||"Compilation failed"};const d=u.modules.get(o);if(!d)return{kind:"error",message:`Module not found: ${o}`};const f=d.result.records.find(e=>e.record.name.line.lineNumber===a);return f?{kind:"success",record:f.record,moduleSet:u}:{kind:"error",message:`No record found at line ${a+1} in ${o}`}}class EC{static from(e){return this.fromUnixMillis(e.getTime())}static fromUnixMillis(e){if(e<=this.MIN.unixMillis)return EC.MIN;if(e<EC.MAX.unixMillis)return new EC(Math.round(e));if(Number.isNaN(e))throw new Error("Cannot construct Timestamp from NaN");return EC.MAX}static fromUnixSeconds(e){return this.fromUnixMillis(1e3*e)}static parse(e){return this.fromUnixMillis(Date.parse(e))}static now(){return this.fromUnixMillis(Date.now())}constructor(e){this.unixMillis=e,Object.freeze(this)}get unixSeconds(){return this.unixMillis/1e3}toDate(){return new Date(this.unixMillis)}toString(){return this.toDate().toISOString()}}EC.UNIX_EPOCH=new EC(0),EC.MIN=new EC(-864e13),EC.MAX=new EC(864e13);class NC{static sliceOf(e,t=0,n){const{byteLength:i}=e;if(t<0&&(t=0),(void 0===n||n>i)&&(n=i),n<=t)return NC.EMPTY;if(e instanceof NC){if(t<=0&&i<=n)return e;{const i=e.byteOffset+t,s=n-t;return new NC(e.arrayBuffer,i,s)}}if(e instanceof ArrayBuffer)return new NC(e.slice(t,n));if(e instanceof SharedArrayBuffer){const i=e.slice(t,n),s=new ArrayBuffer(i.byteLength);return new Uint8Array(s).set(new Uint8Array(i)),new NC(s)}throw new TypeError(e)}static fromBase64(e){const t=atob(e),n=Uint8Array.from(t,e=>e.codePointAt(0));return new this(n.buffer)}static fromBase16(e){const t=new Uint8Array(e.length/2);for(let n=0;n<t.length;++n){const i=parseInt(e.substring(2*n,2*n+2),16);if(Number.isNaN(i))throw new Error("Not a valid Base64 string");t[n]=i}return new NC(t.buffer)}copyTo(e,t=0){new Uint8Array(e).set(this.uint8Array,t)}toBuffer(){return this.arrayBuffer.slice(this.byteOffset,this.byteOffset+this.byteLength)}toBase64(){const e=Array.from(this.uint8Array,e=>String.fromCodePoint(e)).join("");return btoa(e)}toBase16(){return[...this.uint8Array].map(e=>e.toString(16).padStart(2,"0")).join("")}at(e){return this.uint8Array[e<0?e+this.byteLength:e]}toString(){return`ByteString(${this.byteLength})`}constructor(e,t=0,n=e.byteLength){this.arrayBuffer=e,this.byteOffset=t,this.byteLength=n,this.uint8Array=new Uint8Array(e,t,n),Object.freeze(this)}}function DC(e){return QC[e]}NC.EMPTY=new NC(new ArrayBuffer(0));class _C{constructor(e,t){this.buffer=e,this.offset=0,this.dataView=new DataView(e),this.keepUnrecognizedValues=!!t}readUint8(){return this.dataView.getUint8(this.offset++)}}const PC=[e=>e.dataView.getUint16((e.offset+=2)-2,!0),e=>e.dataView.getUint32((e.offset+=4)-4,!0),e=>e.dataView.getBigUint64((e.offset+=8)-8,!0),e=>e.readUint8()-256,e=>e.dataView.getUint16((e.offset+=2)-2,!0)-65536,e=>e.dataView.getInt32((e.offset+=4)-4,!0),e=>e.dataView.getBigInt64((e.offset+=8)-8,!0),e=>e.dataView.getBigInt64((e.offset+=8)-8,!0),e=>e.dataView.getFloat32((e.offset+=4)-4,!0),e=>e.dataView.getFloat64((e.offset+=8)-8,!0)];function IC(e){const t=e.readUint8();return t<232?t:PC[t-232](e)}function RC(e){const t=IC(e);return"bigint"==typeof t?t:BigInt(Math.round(t))}class $C{constructor(){this.buffer=new ArrayBuffer(128),this.dataView=new DataView(this.buffer),this.offset=0,this.pieces=[],this.byteLength=0}writeUint8(e){this.reserve(1).setUint8(++this.offset-1,e)}writeUint16(e){this.reserve(2).setUint16((this.offset+=2)-2,e,!0)}writeUint32(e){this.reserve(4).setUint32((this.offset+=4)-4,e,!0)}writeInt32(e){this.reserve(4).setInt32((this.offset+=4)-4,e,!0)}writeHash64(e){this.reserve(8).setBigUint64((this.offset+=8)-8,e,!0)}writeInt64(e){this.reserve(8).setBigInt64((this.offset+=8)-8,e,!0)}writeFloat32(e){this.reserve(4).setFloat32((this.offset+=4)-4,e,!0)}writeFloat64(e){this.reserve(8).setFloat64((this.offset+=8)-8,e,!0)}putUtf8String(e){let t=this.dataView,n=0;for(;e;){const i=JC.encodeInto(e,new Uint8Array(t.buffer,this.offset));this.offset+=i.written,n+=i.written,(e=e.substring(i.read))&&(t=this.reserve(2*e.length))}return n}putBytes(e){const{buffer:t}=this,n=t.byteLength-this.offset,i=NC.sliceOf(e,0,n);i.copyTo(t,this.offset),this.offset+=i.byteLength;const s=e.byteLength-i.byteLength;if(s<=0)return;const r=NC.sliceOf(e,s);this.reserve(s),r.copyTo(t,this.offset),this.offset+=s}finalize(){return this.flush(),Object.freeze(this.pieces),Object.freeze(this),this}copyTo(e,t=0){const n=new Uint8Array(e);for(const e of this.pieces)n.set(e,t),t+=e.length}toBuffer(){const e=new ArrayBuffer(this.byteLength);return this.copyTo(e),e}reserve(e){if(this.offset<this.buffer.byteLength-e)return this.dataView;this.flush();const t=Math.max(this.byteLength,e);return this.offset=0,this.buffer=new ArrayBuffer(t),this.dataView=new DataView(this.buffer)}flush(){const{offset:e}=this;this.pieces.push(new Uint8Array(this.dataView.buffer,0,e)),this.byteLength+=e}}function BC(e,t){if(e<232)t.writeUint8(e);else if(e<65536)t.writeUint8(232),t.writeUint16(e);else{if(!(e<4294967296))throw new Error(`max length exceeded: ${e}`);t.writeUint8(233),t.writeUint32(e)}}class LC{fromJsonCode(e,t){return this.fromJson(JSON.parse(e),t)}fromBytes(e,t){const n=new _C(e,t);return n.offset=4,this.decode(n)}toJsonCode(e,t){const n="readable"===t?" ":void 0;return JSON.stringify(this.toJson(e,t),void 0,n)}toBytes(e){const t=new $C;return t.putUtf8String("skir"),this.encode(e,t),t.finalize()}isDefault(e){return!e}get typeDescriptor(){return this}asJson(){const e={};this.addRecordDefinitionsTo(e);return{type:this.typeSignature,records:Object.values(e)}}asJsonCode(){return JSON.stringify(this.asJson(),void 0," ")}transform(e,t){const n=e instanceof ArrayBuffer?this.fromBytes(e):this.fromJson(e);return"bytes"===t?this.toBytes(n).toBuffer():this.toJson(n,t)}}const zC={name:"UNKNOWN",number:0};class jC extends LC{constructor(){super(...arguments),this.kind="primitive"}get typeSignature(){return{kind:"primitive",value:this.primitive}}addRecordDefinitionsTo(e){}}const WC=new class extends jC{constructor(){super(...arguments),this.primitive="int32",this.defaultValue=0}toJson(e){return 0|e}fromJson(e){return 0|+e}encode(e,t){e<0?e>=-256?(t.writeUint8(235),t.writeUint8(e+256)):e>=-65536?(t.writeUint8(236),t.writeUint16(e+65536)):(t.writeUint8(237),t.writeInt32(e>=-2147483648?e:-2147483648)):e<232?t.writeUint8(e):e<65536?(t.writeUint8(232),t.writeUint16(e)):(t.writeUint8(233),t.writeUint32(e<=2147483647?e:2147483647))}decode(e){return 0|Number(IC(e))}};class UC extends jC{constructor(){super(...arguments),this.defaultValue=0}toJson(e){if(Number.isFinite(e))return e;if("number"==typeof e)return e.toString();throw new TypeError}fromJson(e){return+e}decode(e){return Number(IC(e))}isDefault(e){return 0===e}}class FC extends jC{constructor(){super(...arguments),this.defaultValue=BigInt(0)}fromJson(e){try{return BigInt(e)}catch(t){if("number"==typeof e)return BigInt(Math.round(e));throw t}}}const VC=BigInt("-9223372036854775808"),HC=BigInt("9223372036854775807");const qC=BigInt("18446744073709551615");class KC{constructor(e,t,n,i,s){this.name=e,this.property=t,this.number=n,this.serializer=i,this.doc=s}get type(){return this.serializer.typeDescriptor}get(e){return Reflect.get(e,this.property)}set(e,t){Reflect.set(e,this.property,t)}}const JC=new TextEncoder,ZC=new TextDecoder;class YC extends LC{constructor(e,t){super(),this.itemSerializer=e,this.keyExtractor=t,this.kind="array",this.defaultValue=hA}toJson(e,t){return e.map(e=>this.itemSerializer.toJson(e,t))}fromJson(e,t){return 0===e?hA:cA(e.map(e=>this.itemSerializer.fromJson(e,t)))}encode(e,t){const{length:n}=e;n<=3?t.writeUint8(246+n):(t.writeUint8(250),BC(n,t));const{itemSerializer:i}=this;for(let n=0;n<e.length;++n)i.encode(e[n],t)}decode(e){const t=e.readUint8();if(0===t||246===t)return hA;const n=250===t?IC(e):t-246,{itemSerializer:i}=this,s=new Array(n);for(let t=0;t<n;++t)s[t]=i.decode(e);return cA(s)}isDefault(e){return!e.length}get itemType(){return this.itemSerializer.typeDescriptor}get typeSignature(){return{kind:"array",value:{item:this.itemSerializer.typeSignature,key_extractor:this.keyExtractor}}}addRecordDefinitionsTo(e){this.itemSerializer.addRecordDefinitionsTo(e)}}class GC extends LC{constructor(e){super(),this.otherSerializer=e,this.kind="optional",this.defaultValue=null}toJson(e,t){return null!==e?this.otherSerializer.toJson(e,t):null}fromJson(e,t){return null!==e?this.otherSerializer.fromJson(e,t):null}encode(e,t){null===e?t.writeUint8(255):this.otherSerializer.encode(e,t)}decode(e){return 255===e.dataView.getUint8(e.offset)?(++e.offset,null):this.otherSerializer.decode(e)}isDefault(e){return null===e}get otherType(){return this.otherSerializer.typeDescriptor}get typeSignature(){return{kind:"optional",value:this.otherSerializer.typeSignature}}addRecordDefinitionsTo(e){this.otherSerializer.addRecordDefinitionsTo(e)}}const QC={bool:new class extends jC{constructor(){super(...arguments),this.primitive="bool",this.defaultValue=!1}toJson(e,t){return"readable"===t?!!e:e?1:0}fromJson(e){return!!e&&"0"!==e}encode(e,t){t.writeUint8(e?1:0)}decode(e){return!!IC(e)}},int32:WC,int64:new class extends FC{constructor(){super(...arguments),this.primitive="int64"}toJson(e){if(-9007199254740991<=e&&e<=9007199254740991)return Number(e);const t=BigInt(e).toString();return t.length<=18?t:e<VC?VC.toString():e<HC?t:HC.toString()}encode(e,t){e?-2147483648<=e&&e<=2147483647?WC.encode(Number(e),t):(t.writeUint8(238),t.writeInt64(e<VC?VC:e<HC?e:HC)):t.writeUint8(0)}decode(e){return RC(e)}},hash64:new class extends FC{constructor(){super(...arguments),this.primitive="hash64"}toJson(e){return e<=9007199254740991?e<=0?0:Number(e):(e=BigInt(e),qC<e?qC.toString():e.toString())}encode(e,t){e<232?t.writeUint8(e<=0?0:Number(e)):e<4294967296?e<65536?(t.writeUint8(232),t.writeUint16(Number(e))):(t.writeUint8(233),t.writeUint32(Number(e))):(t.writeUint8(234),t.writeHash64(e<=qC?e:qC))}decode(e){return RC(e)}},float32:new class extends UC{constructor(){super(...arguments),this.primitive="float32"}encode(e,t){0===e?t.writeUint8(0):(t.writeUint8(240),t.writeFloat32(e))}},float64:new class extends UC{constructor(){super(...arguments),this.primitive="float64"}encode(e,t){0===e?t.writeUint8(0):(t.writeUint8(241),t.writeFloat64(e))}},timestamp:new class extends jC{constructor(){super(...arguments),this.primitive="timestamp",this.defaultValue=EC.UNIX_EPOCH}toJson(e,t){return"readable"===t?{unix_millis:e.unixMillis,formatted:e.toDate().toISOString()}:e.unixMillis}fromJson(e){return EC.fromUnixMillis("number"==typeof e?e:"string"==typeof e?+e:e.unix_millis)}encode(e,t){const{unixMillis:n}=e;n?(t.writeUint8(239),t.writeInt64(BigInt(n))):t.writeUint8(0)}decode(e){const t=IC(e);return EC.fromUnixMillis(Number(t))}isDefault(e){return!e.unixMillis}},string:new class extends jC{constructor(){super(...arguments),this.primitive="string",this.defaultValue=""}toJson(e){if("string"==typeof e)return e;throw this.newTypeError(e)}fromJson(e){if("string"==typeof e)return e;if(0===e)return"";throw this.newTypeError(e)}encode(e,t){if(!e)return void t.writeUint8(242);t.writeUint8(243);const n=3*e.length;n<232?t.writeUint8(0):n<65536?(t.writeUint8(232),t.writeUint16(0)):(t.writeUint8(233),t.writeUint32(0));const{dataView:i,offset:s}=t,r=t.putUtf8String(e);n<232?i.setUint8(s-1,r):n<65536?i.setUint16(s-2,r,!0):i.setUint32(s-4,r,!0)}decode(e){const t=e.readUint8();if(0===t||242===t)return"";const n=IC(e);return ZC.decode(new Uint8Array(e.buffer,(e.offset+=n)-n,n))}newTypeError(e){return new TypeError("expected: string; actual: "+typeof e)}},bytes:new class extends jC{constructor(){super(...arguments),this.primitive="bytes",this.defaultValue=NC.EMPTY}toJson(e,t){return"readable"===t?"hex:"+e.toBase16():e.toBase64()}fromJson(e){if(0===e)return NC.EMPTY;const t=e;return t.startsWith("hex:")?NC.fromBase16(t.substring(4)):NC.fromBase64(t)}encode(e,t){const{byteLength:n}=e;n?(t.writeUint8(245),BC(n,t),t.putBytes(e)):t.writeUint8(244)}decode(e){const t=e.readUint8();if(0===t||244===t)return NC.EMPTY;const n=IC(e);return NC.sliceOf(e.buffer,e.offset,e.offset+=n)}isDefault(e){return!e.byteLength}}};function XC(e){const t=e.readUint8();if(!(t<232))switch(t-232){case 0:case 4:e.offset+=2;break;case 1:case 5:case 8:e.offset+=4;break;case 2:case 6:case 7:case 9:e.offset+=8;break;case 3:++e.offset;break;case 11:case 13:{const t=IC(e);e.offset+=t;break}case 15:case 19:case 20:case 21:case 22:XC(e);break;case 16:XC(e),XC(e);break;case 17:XC(e),XC(e),XC(e);break;case 18:{const t=IC(e);for(let n=0;n<t;++n)XC(e);break}}}class eA extends LC{constructor(){super(...arguments),this.token=Symbol(),this.name="",this.modulePath="",this.doc="",this.removedNumbers=new Set}init(e,t,n,i,s,r){this.name=e,this.modulePath=t,this.parentType=n,this.doc=i,this.removedNumbers=new Set(r),this.registerFieldsOrVariants(s),this.initialized=!0,aA(this)}get qualifiedName(){const{name:e,parentType:t}=this;return t?`${t.name}.${e}`:e}addRecordDefinitionsTo(e){const t=`${this.modulePath}:${this.qualifiedName}`;if(e[t])return;const n=this.makeRecordDefinition(t);this.doc&&(n.doc=this.doc),this.removedNumbers.size&&(n.removed_numbers=[...this.removedNumbers]),e[t]=n;for(const t of this.dependencies())t.addRecordDefinitionsTo(e)}}class tA{constructor(e,t,n,i){this.token=e,this.totalSlots=t,this.json=n,this.bytes=i,Object.freeze(this)}}class nA extends eA{constructor(e,t,n){super(),this.defaultValue=e,this.createFn=t,this.newMutableFn=n,this.kind="struct",this.fields=[],this.fieldMapping={},this.reversedFields=[],this.slots=[],this.recognizedSlots=0,this.zeros=[],this.initializerTemplate={}}toJson(e,t){if(e===this.defaultValue)return"readable"===t?{}:[];if("readable"===t){const{fields:n}=this,i={};for(const s of n){const{serializer:n}=s,r=e[s.property];s.serializer.isDefault(r)||(i[s.name]=n.toJson(r,t))}return i}{const{slots:n}=this;let i;const s=e["^"];if(s&&s.json&&s.token===this.token){i=this.zeros.concat(s.json);for(const n of this.fields)i[n.number]=n.serializer.toJson(e[n.property],t)}else{i=[];const s=this.getArrayLength(e);for(let r=0;r<s;++r){const s=n[r];i[r]=s?s.serializer.toJson(e[s.property],t):0}}return i}}fromJson(e,t){if(!e)return this.defaultValue;const n=Object.assign({},this.initializerTemplate);if(e instanceof Array){const{slots:i,recognizedSlots:s}=this;if(e.length>s){if(t){const t=new tA(this.token,e.length,oA(e.slice(s)));n["^"]=t}e=e.slice(0,s)}for(let s=0;s<e.length&&s<i.length;++s){const r=i[s];r&&(n[r.property]=r.serializer.fromJson(e[s],t))}return this.createFn(n)}if(e instanceof Object){const{fieldMapping:i}=this;for(const s in e){const r=i[s];r&&(n[r.property]=r.serializer.fromJson(e[s],t))}return this.createFn(n)}throw TypeError()}encode(e,t){let n,i,s;const r=e["^"];r&&r.bytes&&r.token===this.token?(n=r.totalSlots,i=this.recognizedSlots,s=r.bytes):n=i=this.getArrayLength(e),n<=3?t.writeUint8(246+n):(t.writeUint8(250),BC(n,t));const{slots:o}=this;for(let n=0;n<i;++n){const i=o[n];i?i.serializer.encode(e[i.property],t):t.writeUint8(0)}s&&t.putBytes(s)}decode(e){const t=e.readUint8();if(0===t||246===t)return this.defaultValue;const n=Object.assign({},this.initializerTemplate),i=250===t?IC(e):t-246,{slots:s,recognizedSlots:r}=this;for(let t=0;t<i&&t<r;++t){const i=s[t];i?n[i.property]=i.serializer.decode(e):XC(e)}if(i>r){const t=e.offset;for(let t=r;t<i;++t)XC(e);if(e.keepUnrecognizedValues){const s=e.offset,r=NC.sliceOf(e.buffer,t,s),o=new tA(this.token,i,void 0,r);n["^"]=o}}return this.createFn(n)}getArrayLength(e){const{reversedFields:t}=this;for(let n=0;n<t.length;++n){const i=t[n];if(!i.serializer.isDefault(e[i.property]))return i.number+1}return 0}isDefault(e){return e===this.defaultValue||!e["^"]&&this.fields.every(t=>t.serializer.isDefault(e[t.property]))}get typeSignature(){return{kind:"record",value:`${this.modulePath}:${this.qualifiedName}`}}getField(e){return this.fieldMapping[e]}newMutable(e){return this.newMutableFn(e)}registerFieldsOrVariants(e){for(const t of e){const{name:e,number:n,property:i}=t;this.fields.push(t),this.slots[n]=t,this.fieldMapping[e]=t,this.fieldMapping[i]=t,this.fieldMapping[n]=t,this.initializerTemplate[i]=this.defaultValue[t.property]}this.recognizedSlots=Math.max(this.slots.length-1,...this.removedNumbers)+1,this.zeros.push(...Array(this.recognizedSlots).fill(0)),this.reversedFields=[...this.fields].sort((e,t)=>t.number-e.number)}makeRecordDefinition(e){return{kind:"struct",id:e,doc:void 0,fields:this.fields.map(e=>({name:e.name,number:e.number,type:e.serializer.typeSignature,doc:gA(e.doc)}))}}dependencies(){return this.fields.map(e=>e.serializer)}}class iA{constructor(e,t,n){this.token=e,this.json=t,this.bytes=n,Object.freeze(this)}}class sA{constructor(e,t,n,i,s){this.name=e,this.number=t,this.serializer=n,this.doc=i,this.createFn=s}get type(){return this.serializer.typeDescriptor}get(e){return e.kind===this.name?e.value:void 0}wrap(e){return this.createFn({kind:this.name,value:e})}}class rA extends eA{constructor(e){super(),this.createFn=e,this.kind="enum",this.variants=[],this.variantMapping={},this.defaultValue=e("UNKNOWN")}toJson(e,t){const n=e["^"];if(n&&n.json&&n.token===this.token)return n.json;const i=e.kind;if("UNKNOWN"===i)return"readable"===t?"UNKNOWN":0;const s=this.variantMapping[i],{serializer:r}=s;if(r){const n=e.value;return"readable"===t?{kind:s.name,value:r.toJson(n,t)}:[s.number,r.toJson(n,t)]}return"readable"===t?s.name:s.number}fromJson(e,t){const n="number"==typeof e;if(n||"string"==typeof e){const i=this.variantMapping[n?e:String(e)];if(!i)return!t||n&&this.removedNumbers.has(e)?this.defaultValue:this.createFn(new iA(this.token,oA(e)));if(i.serializer)throw new Error(`refers to a wrapper variant: ${e}`);return i.constant}let i,s;if(e instanceof Array)i=e[0],s=e[1];else{if(!(e instanceof Object))throw TypeError();i=e.kind,s=e.value}const r=this.variantMapping[i];if(!r)return!t||"number"==typeof i&&this.removedNumbers.has(i)?this.defaultValue:this.createFn(new iA(this.token,oA(e),void 0));const{serializer:o}=r;if(!o)throw new Error(`refers to a constant variant: ${e}`);return r.wrap(o.fromJson(s,t))}encode(e,t){const n=e["^"];if(n&&n.bytes&&n.token===this.token)return void t.putBytes(n.bytes);const i=e.kind;if("UNKNOWN"===i)return void t.writeUint8(0);const s=this.variantMapping[i],{number:r,serializer:o}=s;if(o){const n=e.value;r<5?t.writeUint8(250+r):(t.writeUint8(248),BC(r,t)),o.encode(n,t)}else BC(r,t)}decode(e){const t=e.offset,n=e.dataView.getUint8(t);if(n<242){const n=IC(e),i=this.variantMapping[n];if(!i){if(!e.keepUnrecognizedValues||this.removedNumbers.has(n))return this.defaultValue;{const{offset:n}=e,i=NC.sliceOf(e.buffer,t,n);return this.createFn(new iA(this.token,void 0,i))}}if(i.serializer)throw new Error(`refers to a wrapper variant: ${n}`);return i.constant}{++e.offset;const i=248===n?IC(e):n-250,s=this.variantMapping[i];if(!s){if(XC(e),!e.keepUnrecognizedValues||this.removedNumbers.has(i))return this.defaultValue;{const{offset:n}=e,i=NC.sliceOf(e.buffer,t,n);return this.createFn(new iA(this.token,void 0,i))}}const{serializer:r}=s;if(!r)throw new Error(`refers to a constant variant: ${i}`);return s.wrap(r.decode(e))}}get typeSignature(){return{kind:"record",value:`${this.modulePath}:${this.qualifiedName}`}}isDefault(e){return"UNKNOWN"===e.kind&&!e["^"]}getVariant(e){return this.variantMapping[e]}registerFieldsOrVariants(e){for(const t of e)this.variants.push(t),this.variantMapping[t.name]=t,this.variantMapping[t.number]=t}makeRecordDefinition(e){return{kind:"enum",id:e,doc:void 0,variants:this.variants.filter(e=>e.number).map(e=>{var t;const n={name:e.name,number:e.number,doc:gA(e.doc)},i=null===(t=null==e?void 0:e.serializer)||void 0===t?void 0:t.typeSignature;return i?Object.assign(Object.assign({},n),{type:i}):n})}}dependencies(){const e=[];for(const t of this.variants)t.serializer&&e.push(t.serializer);return e}}function oA(e){return e instanceof Array?Object.freeze(e.map(oA)):e instanceof Object?Object.freeze(Object.fromEntries(Object.entries(e).map((e,t)=>[e,oA(t)]))):e}function aA(e){if(e instanceof Object&&!(e instanceof fA||e instanceof pA)&&(!(e instanceof eA)||e.initialized)&&!Object.isFrozen(e)){Object.freeze(e);for(const t of Object.values(e))aA(t)}}const lA=new WeakMap;function cA(e){return lA.has(e)||lA.set(Object.freeze(e),{}),e}const hA=cA([]),uA=Symbol();function dA(e){const t=Object.getPrototypeOf(e).constructor,{qualifiedName:n}=t.serializer;return Error(["Do not call the constructor directly; ",`instead, call ${n}.create(...)`].join(""))}class fA{constructor(e){if(e!==uA)throw dA(this)}toMutable(){return new(Object.getPrototypeOf(this).constructor.Mutable)(this)}toFrozen(){return this}toString(){return mA(this)}}class pA{constructor(e,t,n,i){if(e!==uA)throw dA(this);if(this.kind=t,this.value=n,i){if(!(i instanceof iA))throw new TypeError;this["^"]=i}Object.freeze(this)}toString(){return mA(this)}}function mA(e){return Object.getPrototypeOf(e).constructor.serializer.toJsonCode(e,"readable")}function gA(e){return e||void 0}function yA(){return yA=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},yA.apply(null,arguments)}Object.defineProperty(pA.prototype,"union",{get:function(){return this}});var vA=e=>{var{theme:t,settings:n={},styles:i=[]}=e,s={".cm-gutters":{}},r={};n.background&&(r.backgroundColor=n.background),n.backgroundImage&&(r.backgroundImage=n.backgroundImage),n.foreground&&(r.color=n.foreground),n.fontSize&&(r.fontSize=n.fontSize),(n.background||n.foreground)&&(s["&"]=r),n.fontFamily&&(s["&.cm-editor .cm-scroller"]={fontFamily:n.fontFamily}),n.gutterBackground&&(s[".cm-gutters"].backgroundColor=n.gutterBackground),n.gutterForeground&&(s[".cm-gutters"].color=n.gutterForeground),n.gutterBorder&&(s[".cm-gutters"].borderRightColor=n.gutterBorder),n.caret&&(s[".cm-content"]={caretColor:n.caret},s[".cm-cursor, .cm-dropCursor"]={borderLeftColor:n.caret});var o={};return n.gutterActiveForeground&&(o.color=n.gutterActiveForeground),n.lineHighlight&&(s[".cm-activeLine"]={backgroundColor:n.lineHighlight},o.backgroundColor=n.lineHighlight),s[".cm-activeLineGutter"]=o,n.selection&&(s["&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection"]={background:n.selection+" !important"}),n.selectionMatch&&(s["& .cm-selectionMatch"]={backgroundColor:n.selectionMatch}),[Fo.theme(s,{dark:"dark"===t}),Uc(Lc.define(i))]},bA={background:"#1a1b26",foreground:"#787c99",caret:"#c0caf5",selection:"#515c7e40",selectionMatch:"#16161e",gutterBackground:"#1a1b26",gutterForeground:"#787c99",gutterBorder:"transparent",lineHighlight:"#474b6611"},wA=[{tag:Te.keyword,color:"#bb9af7"},{tag:[Te.name,Te.deleted,Te.character,Te.macroName],color:"#c0caf5"},{tag:[Te.propertyName],color:"#7aa2f7"},{tag:[Te.processingInstruction,Te.string,Te.inserted,Te.special(Te.string)],color:"#9ece6a"},{tag:[Te.function(Te.variableName),Te.labelName],color:"#7aa2f7"},{tag:[Te.color,Te.constant(Te.name),Te.standard(Te.name)],color:"#bb9af7"},{tag:[Te.definition(Te.name),Te.separator],color:"#c0caf5"},{tag:[Te.className],color:"#c0caf5"},{tag:[Te.number,Te.changed,Te.annotation,Te.modifier,Te.self,Te.namespace],color:"#ff9e64"},{tag:[Te.typeName],color:"#0db9d7"},{tag:[Te.operator,Te.operatorKeyword],color:"#bb9af7"},{tag:[Te.url,Te.escape,Te.regexp,Te.link],color:"#b4f9f8"},{tag:[Te.meta,Te.comment],color:"#444b6a"},{tag:Te.strong,fontWeight:"bold"},{tag:Te.emphasis,fontStyle:"italic"},{tag:Te.link,textDecoration:"underline"},{tag:Te.heading,fontWeight:"bold",color:"#89ddff"},{tag:[Te.atom,Te.bool,Te.special(Te.variableName)],color:"#c0caf5"},{tag:Te.invalid,color:"#ff5370"},{tag:Te.strikethrough,textDecoration:"line-through"}],kA=(()=>{var{theme:e="dark",settings:t={},styles:n=[]}={};return vA({theme:e,settings:yA({},bA,t),styles:[...wA,...n]})})(),xA={background:"#e1e2e7",foreground:"#3760bf",caret:"#3760bf",selection:"#99a7df",selectionMatch:"#99a7df",gutterBackground:"#e1e2e7",gutterForeground:"#3760bf",gutterBorder:"transparent",lineHighlight:"#5f5faf11"},SA=[{tag:Te.keyword,color:"#007197"},{tag:[Te.name,Te.deleted,Te.character,Te.macroName],color:"#3760bf"},{tag:[Te.propertyName],color:"#3760bf"},{tag:[Te.processingInstruction,Te.string,Te.inserted,Te.special(Te.string)],color:"#587539"},{tag:[Te.function(Te.variableName),Te.labelName],color:"#3760bf"},{tag:[Te.color,Te.constant(Te.name),Te.standard(Te.name)],color:"#3760bf"},{tag:[Te.definition(Te.name),Te.separator],color:"#3760bf"},{tag:[Te.className],color:"#3760bf"},{tag:[Te.number,Te.changed,Te.annotation,Te.modifier,Te.self,Te.namespace],color:"#b15c00"},{tag:[Te.typeName],color:"#007197",fontStyle:"#007197"},{tag:[Te.operator,Te.operatorKeyword],color:"#007197"},{tag:[Te.url,Te.escape,Te.regexp,Te.link],color:"#587539"},{tag:[Te.meta,Te.comment],color:"#848cb5"},{tag:Te.strong,fontWeight:"bold"},{tag:Te.emphasis,fontStyle:"italic"},{tag:Te.link,textDecoration:"underline"},{tag:Te.heading,fontWeight:"bold",color:"#b15c00"},{tag:[Te.atom,Te.bool,Te.special(Te.variableName)],color:"#3760bf"},{tag:Te.invalid,color:"#f52a65"},{tag:Te.strikethrough,textDecoration:"line-through"}],CA=(()=>{var{theme:e="light",settings:t={},styles:n=[]}={};return vA({theme:e,settings:yA({},xA,t),styles:[...SA,...n]})})();function AA(e){switch(e.kind){case"literal":return JSON.parse(e.jsonCode);case"array":return e.values.map(AA);case"object":return Object.fromEntries(Object.values(e.keyValues).map(e=>[e.key,AA(e.value)]))}}function TA(e,t,n){switch(e.kind){case"array":return[];case"optional":return null;case"record":{const i=t[e.value];return"struct"===i.kind?n?{}:Object.fromEntries(i.fields.map(e=>[e.name,TA(e.type,t,"depth")])):"UNKNOWN"}case"primitive":switch(e.value){case"bool":return!1;case"int32":case"float32":case"float64":return 0;case"int64":case"hash64":return"0";case"timestamp":return{unix_millis:0,formatted:"1970-01-01T00:00:00Z"};case"string":case"bytes":return""}}}function OA(e){const t=function(e){const t=[];let n=0;const i=/[ \t\r\n]*/y,s=/([[\]{}:,]|(-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?)|false|true|null|("(((?=\\)\\(["\\/ bfnrt]|u[0-9a-fA-F]{4}))|[^"\\\0-\x1F\x7F]+)*")|$)/y;for(;;){i.lastIndex=n,i.exec(e),n=i.lastIndex,s.lastIndex=n;const r=s.exec(e);if(!r){const t=/\w*/uy;t.lastIndex=n+1,t.exec(e);return{kind:"error",message:"not a token",segment:{start:n,end:t.lastIndex||n+1}}}{const e=r[0],i={segment:{start:n,end:n+e.length},jsonCode:e};if(n=s.lastIndex,t.push(i),""===e)return{kind:"tokens",tokens:t}}}}(e);if("error"===t.kind)return{value:void 0,errors:[t],edits:[]};const n=new MA(t.tokens,e),i=n.parseValueOrSkip();return n.expectEnd(),{value:i,errors:n.errors,edits:n.edits}}class MA{constructor(e,t){this.tokens=e,this.input=t,this.tokenIndex=0,this.errors=[],this.edits=[],this.indent=""}parseValueOrSkip(){const e=this.peekToken();switch(e.jsonCode?e.jsonCode[0]:""){case"[":return this.parseArray();case"{":return this.parseObject();case"n":return this.nextToken(),{kind:"literal",firstToken:e.segment,segment:e.segment,jsonCode:"null",type:"null"};case"f":return this.nextToken(),{kind:"literal",firstToken:e.segment,segment:e.segment,jsonCode:"false",type:"boolean"};case"t":return this.nextToken(),{kind:"literal",firstToken:e.segment,segment:e.segment,jsonCode:"true",type:"boolean"};case'"':return this.nextToken(),{kind:"literal",firstToken:e.segment,segment:e.segment,jsonCode:e.jsonCode,type:"string"};case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"-":return this.nextToken(),{kind:"literal",firstToken:e.segment,segment:e.segment,jsonCode:e.jsonCode,type:"number"}}this.errors.push({kind:"error",message:"expected: value",segment:this.peekToken().segment}),this.skip()}parseArray(){const e=this.nextToken(),t=[];for(;;){if("]"===this.peekToken().jsonCode){const n=this.nextToken();return{kind:"array",firstToken:e.segment,segment:{start:e.segment.start,end:n.segment.end},values:t}}if("}"===this.peekToken().jsonCode){this.errors.push({kind:"error",message:"expected: ']'",segment:this.peekToken().segment});const n=this.nextToken();return{kind:"array",firstToken:e.segment,segment:{start:e.segment.start,end:n.segment.end},values:t}}if(""===this.peekToken().jsonCode)return this.expectSymbolOrSkip("]"),{kind:"array",firstToken:e.segment,segment:{start:e.segment.start,end:this.peekToken().segment.start},values:t};const n=this.parseValueOrSkip();if(n&&t.push(n),","===this.peekToken().jsonCode){const e=this.nextToken();"]"===this.peekToken().jsonCode&&this.edits.push({segment:e.segment,replacement:""})}}}parseObject(){const e=this.nextToken(),t={},n=[];for(;;){if("}"===this.peekToken().jsonCode){const i=this.nextToken();return{kind:"object",firstToken:e.segment,segment:{start:e.segment.start,end:i.segment.end},keyValues:t,allKeys:n}}if("]"===this.peekToken().jsonCode){this.errors.push({kind:"error",message:"expected: ']'",segment:this.peekToken().segment});const i=this.nextToken();return{kind:"object",firstToken:e.segment,segment:{start:e.segment.start,end:i.segment.end},keyValues:t,allKeys:n}}if(""===this.peekToken().jsonCode)return this.expectSymbolOrSkip("}"),{kind:"object",firstToken:e.segment,segment:{start:e.segment.start,end:this.peekToken().segment.start},keyValues:t,allKeys:n};const i=this.peekToken();if(!i.jsonCode.startsWith('"')){this.errors.push({kind:"error",message:"expected: string",segment:i.segment}),this.skip(),","===this.peekToken().jsonCode&&this.nextToken();continue}const s=JSON.parse(i.jsonCode);if(n.push({key:s,keySegment:i.segment}),this.nextToken(),!this.expectSymbolOrSkip(":"))continue;t[s]&&this.errors.push({kind:"error",message:"duplicate key",segment:i.segment});const r=this.parseValueOrSkip();if(r&&(t[s]={keySegment:i.segment,key:s,value:r}),","===this.peekToken().jsonCode){const e=this.nextToken();"}"===this.peekToken().jsonCode&&this.edits.push({segment:e.segment,replacement:""})}}}expectEnd(){this.nextToken().jsonCode&&this.errors.push({kind:"error",message:"expected: end",segment:this.peekToken().segment})}nextToken(){const e=this.tokens[this.tokenIndex];{const t=this.tokenIndex<=0?void 0:this.tokens[this.tokenIndex-1],n={start:t?t.segment.end:0,end:e.segment.start},i=this.input.substring(n.start,n.end),s=this.inferWhitespaceSeparator(t?.jsonCode??"",e.jsonCode);i!==s.text&&this.edits.push({segment:n,replacement:s.text}),this.indent=s.newIndent??this.indent}return++this.tokenIndex,e}inferWhitespaceSeparator(e,t){const{indent:n}=this;if(":"===e)return{text:" "};if(","===e&&"]"!==t&&"}"!==t)return{text:`\n${n}`};if(/[0-9"}\]el]$/.test(e)&&/^[0-9"{[tfn-]/.test(t))return{text:`,\n${n}`};if("["===e&&"]"!==t||"{"===e&&"}"!==t){const e=n+EA;return{text:`\n${e}`,newIndent:e}}if("["!==e&&"]"===t||"{"!==e&&"}"===t){const e=n.replace(EA,"");return{text:`\n${e}`,newIndent:e}}return{text:""}}peekToken(){return this.tokens[this.tokenIndex]}expectSymbolOrSkip(e){return this.peekToken().jsonCode!==e?(this.errors.push({kind:"error",message:`expected: '${e}'`,segment:this.peekToken().segment}),this.skip(),!1):(this.nextToken(),!0)}skip(){for(;;){const e=this.peekToken().jsonCode;if(""===e||","===e||"]"===e||"}"===e||e.startsWith('"'))return;"["===e?this.parseArray():"{"===e?this.parseObject():this.nextToken()}}}const EA=" ";function NA(e,t){const n={};for(const e of t.records)n[e.id]=e;const i=new DA(n);i.validate(e,{kind:"root"},t.type);const s=new Map;for(const e of i.hints){const{valueContext:t}=e;t&&s.set(t.path,e)}return{errors:i.errors,hints:i.hints,rootTypeHint:i.rootTypeHint,pathToTypeHint:s}}class DA{constructor(e){this.idToRecordDef=e,this.errors=[],this.hints=[],this.typeHintStack=[]}validate(e,t,n,i){const{idToRecordDef:s,typeHintStack:r}=this;e.expectedType=n;const o=()=>{const o=function(e){function t(e){switch(e.kind){case"primitive":return e.value;case"array":return`[${t(e.value.item)}]`;case"optional":return`${t(e.value)}?`;case"record":return e.value.split(":")[1]}}function n(e){switch(e.kind){case"primitive":return null;case"array":return n(e.value.item);case"optional":return n(e.value);case"record":return e.value.split(":")[0]}}const i=t(e),s=n(e);return s?`${i} (${s})`:i}(i??n),a=IA(n,s),l=[o];if(a&&l.push(a),"array"===e.kind){const{length:t}=e.values;t&&l.push(`Length: ${t}`)}const c={segment:e.firstToken,message:1===l.length?l[0]:l,valueContext:{value:e,path:t},childHints:[]};if(r.length){r[r.length-1].childHints.push(c)}else this.rootTypeHint=c;this.hints.push(c),r.push(c)};switch(n.kind){case"array":if("array"===e.kind){o();for(const[i,s]of e.values.entries()){const{key_extractor:e,item:r}=n.value,o={kind:"array-item",index:i,key:_A(s,e),arrayPath:t};this.validate(s,o,r)}r.pop()}else this.errors.push({kind:"error",segment:e.segment,message:"Expected: array"});break;case"optional":"literal"===e.kind&&"null"===e.jsonCode?(o(),r.pop()):this.validate(e,t,n.value,n);break;case"primitive":{const t=n.value;"timestamp"===t?this.validateTimestamp(e)&&(o(),r.pop()):!function(e,t){switch(t){case"bool":return"literal"===e.kind&&"boolean"===e.type;case"int32":return PA(e,-2147483648n,2147483647n);case"int64":return PA(e,-9223372036854775808n,9223372036854775807n);case"hash64":return PA(e,0n,18446744073709551615n);case"float32":case"float64":return function(e){if("literal"!==e.kind)return!1;if("number"===e.type)return!0;if("string"!==e.type)return!1;try{return DC("float64").fromJsonCode(e.jsonCode),!0}catch{return!1}}(e);case"string":return"literal"===e.kind&&"string"===e.type;case"bytes":if("literal"!==e.kind)return!1;try{return DC("bytes").fromJsonCode(e.jsonCode),!0}catch{return!1}case"timestamp":throw new Error}}(e,t)?this.errors.push({kind:"error",segment:e.firstToken,message:`Expected: ${t}`}):(o(),r.pop());break}case"record":{const i=s[n.value];if("struct"===i.kind){const n={};if(i.fields.forEach(e=>{n[e.name]=e}),"object"===e.kind){o();for(const i of Object.values(e.keyValues)){const{key:e,value:s}=i,r=n[e];if(r){r.doc&&this.hints.push({segment:i.keySegment,message:r.doc});const n={kind:"field-value",fieldName:e,structPath:t};this.validate(s,n,r.type)}else this.errors.push({kind:"error",segment:i.keySegment,message:"Unknown field"})}r.pop()}else this.errors.push({kind:"error",segment:e.firstToken,message:"Expected: object"})}else{const n={};if(i.variants.forEach(e=>{n[e.name]=e}),"object"===e.kind)o(),this.validateEnumObject(e,t,n),r.pop();else if("literal"===e.kind&&"string"===e.type){const t=JSON.parse(e.jsonCode),i=n[t];"UNKNOWN"===t||i?(o(),r.pop()):this.errors.push({kind:"error",segment:e.segment,message:"Unknown variant"})}else this.errors.push({kind:"error",segment:e.firstToken,message:"Expected: object or string"})}break}default:throw new Error(n)}}validateEnumObject(e,t,n){const i=e.keyValues.kind;if(!i)return void this.errors.push({kind:"error",segment:e.segment,message:"Missing: 'kind'"});if("literal"!==i.value.kind||"string"!==i.value.type)return void this.errors.push({kind:"error",segment:i.value.firstToken,message:"Expected: string"});const s=JSON.parse(i.value.jsonCode);if(s!==s.toLowerCase())return void this.errors.push({kind:"error",segment:i.value.segment,message:"Expected: lowercase variant name"});const r=n[s];if(!r)return void this.errors.push({kind:"error",segment:i.value.segment,message:"Unknown variant"});const o=e.keyValues.value;if(!o)return void this.errors.push({kind:"error",segment:e.segment,message:"Missing: 'value'"});for(const t of e.allKeys)"kind"!==t.key&&"value"!==t.key&&this.errors.push({kind:"error",segment:t.keySegment,message:"Unexpected entry"});const a={kind:"variant-value",variantName:r.name,enumPath:t};this.validate(o.value,a,r.type)}validateTimestamp(e){if("object"!==e.kind)return this.errors.push({kind:"error",segment:e.firstToken,message:"Expected: timestamp"}),!1;const t=e.keyValues.unix_millis;if(!t)return this.errors.push({kind:"error",segment:e.firstToken,message:"Missing: 'unix_millis'"}),!0;if("literal"!==t.value.kind||"number"!==t.value.type)return this.errors.push({kind:"error",segment:t.value.firstToken,message:"Expected: number"}),!0;const n=AA(t.value);if(n<-864e13||864e13<n)return this.errors.push({kind:"error",segment:t.value.firstToken,message:"Timestamp out of range"}),!0;const i=e.keyValues.formatted;if(!i)return!0;if("literal"!==i.value.kind||"string"!==i.value.type)return this.errors.push({kind:"error",segment:i.value.firstToken,message:"Expected: string"}),!0;const s=AA(i.value);if("n/a"===s)return!0;const r=Date.parse(s);if(Number.isNaN(r))return this.errors.push({kind:"error",segment:i.value.firstToken,message:"Invalid ISO 8601 date string"}),!0;r!==n&&this.errors.push({kind:"error",segment:i.value.firstToken,message:"Does not match 'unix_millis'"});for(const t of e.allKeys)"unix_millis"!==t.key&&"formatted"!==t.key&&this.errors.push({kind:"error",segment:t.keySegment,message:"Unexpected entry"});return!0}}function _A(e,t){if(void 0===t)return null;const n=t.split(".");let i=e;for(const e of n){if("object"!==i.kind)return null;const t=i.keyValues[e];if(!t)return null;i=t.value}switch(i.kind){case"literal":switch(i.type){case"string":case"number":case"boolean":return i.jsonCode}return null;case"object":{const e=i.keyValues.unix_millis;return e&&"literal"===e.value.kind&&"number"===e.value.type?e.value.jsonCode:null}case"array":return null}}function PA(e,t,n){if("literal"!==e.kind)return!1;let i,s;if("string"===e.type)i=JSON.parse(e.jsonCode);else{if("number"!==e.type)return!1;i=e.jsonCode}try{s=BigInt(i)}catch{return!1}return t<=s&&s<=n}function IA(e,t){switch(e.kind){case"primitive":return;case"array":return IA(e.value.item,t);case"optional":return IA(e.value,t);case"record":return t[e.value].doc}}const RA=Vt.define(),$A=kt.define({create:()=>null,update(e,t){for(const e of t.effects)if(e.is(RA))return e.value;return e}});function BA(e){return[$A,ys.fromClass(class{constructor(e){this.timeout=null,this.view=e,this.scheduleUpdate()}update(e){if(e.docChanged){const t=e.transactions.some(e=>"undo"===e.annotation(Ht.userEvent)||"redo"===e.annotation(Ht.userEvent));this.scheduleUpdate(t?"from-undo":void 0)}}scheduleUpdate(e){null!==this.timeout&&clearTimeout(this.timeout),this.timeout=window.setTimeout(()=>{this.parseJson(e),this.timeout=null},200)}parseJson(t){const n=this.view.state.doc.toString(),i=OA(n);let s;i.value&&(s=NA(i.value,e));if(!t&&i.edits.length&&i.errors.length<=0&&!(()=>{const e=this.view.state.selection.main.head;return i.edits.some(t=>t.segment.start<=e&&e<=t.segment.end)})()){const e=i.edits.map(e=>({from:e.segment.start,to:e.segment.end,insert:e.replacement}));this.view.dispatch({changes:e,effects:RA.of({parseResult:i,validationResult:s,source:n}),scrollIntoView:!0})}else this.view.dispatch({effects:RA.of({parseResult:i,validationResult:s,source:n})})}destroy(){null!==this.timeout&&clearTimeout(this.timeout)}})]}function LA(e){const t={};for(const n of e.records)t[n.id]=n;function n(e,i){if(!zA(i,e.segment))return null;const{expectedType:s}=e;if(!s)return null;switch("optional"===s.kind&&s.value,e.kind){case"array":if("array"!==s.kind)return null;for(const t of e.values){if(i<t.firstToken.start)return null;const e=n(t,i);if(e)return e}return null;case"object":{if("record"!==s.kind)return null;const r=t[s.value];if("struct"===r.kind)for(const t of e.allKeys){const{keySegment:s}=t;if(zA(i,s)){const t=jA(e,r);return{from:s.start+1,to:s.end-1,options:t.map(e=>({label:e}))}}const o=e.keyValues[t.key];if(o){const e=n(o.value,i);if(e)return e}}else{const t=e.keyValues.kind;if(t&&zA(i,t.value.firstToken)&&"literal"===t.value.kind&&"string"===t.value.type){const e=r.variants.filter(e=>e.type).map(e=>({label:e.name}));return{from:t.value.firstToken.start+1,to:t.value.firstToken.end-1,options:e}}const s=e.keyValues.value;if(s){const e=n(s?.value,i);if(e)return e}}return null}case"literal":{if("record"!==s.kind)return null;const n=t[s.value];if("enum"!==n.kind)return null;const i=n.variants.filter(e=>!e.type).map(e=>({label:e.name})).concat({label:"UNKNOWN"});return{from:e.firstToken.start+1,to:e.firstToken.end-1,options:i}}}}return function(t){const i=t.pos;if(!t.view)return null;const s=i>0?t.state.doc.sliceString(i-1,i):"",r=t.explicit||'"'===s?function(e,t){const n=e.state.field($A,!1),i=e.state.doc.toString();if(n&&n.source===i)return n;const s=OA(i);let r;s.value&&(r=NA(s.value,t));const o={parseResult:s,validationResult:r,source:i};return n&&n===o||e.dispatch({effects:RA.of(o)}),o}(t.view,e):t.state.field($A,!1);if(!r)return null;const o=r.parseResult;return o.value?n(o.value,i):null}}function zA(e,t){return e>=t.start&&e<t.end}function jA(e,t){const n=[];for(const i of t.fields)e.keyValues[i.name]||n.push(i.name);return n}function WA(e){return function(t){const n=t.state.field($A,!1);if(!n)return[];const i=n.parseResult;if(i.errors.length)return i.errors.map(UA);if(!n.validationResult)return[];const{errors:s,hints:r}=n.validationResult;return s.map(UA).concat(r.map(t=>function(e,t){const{message:n}=e;return{from:e.segment.start,to:e.segment.end,message:"",severity:"info",renderMessage:i=>{const s=document.createElement("div");let r;if(s.className="cm-diagnostic-wrapper","string"!==n&&"string?"!==n||!e.valueContext||"literal"!==e.valueContext.value.kind||"string"!==e.valueContext.value.type)if("timestamp"!==n&&"timestamp?"!==n||!e.valueContext||"object"!==e.valueContext.value.kind||"editable"!==t){r=("string"==typeof n?[n]:n).map(e=>{const t=document.createElement("div");return t.textContent=e,t})}else;else r=function(e,t,n,i){const s=document.createElement("div");s.textContent=t.message;const r=n.jsonCode,o=JSON.parse(r),a=document.createElement("div");a.className="cm-diagnostic-controls";const l=document.createElement("span");l.textContent="Value:";const c=document.createElement("textarea");c.className="cm-diagnostic-textarea",c.value=o,c.rows=1;const h="read-only"===i;return c.readOnly=h,c.addEventListener("keydown",e=>{"Enter"===e.key&&e.shiftKey}),a.appendChild(l),a.appendChild(c),[s,a]}(0,e,e.valueContext.value,t);for(const e of r)e.classList.add("diagnostic-row"),s.appendChild(e);return s},markClass:""}}(t,e)))}}function UA(e){return{from:e.segment.start,to:e.segment.end,message:e.message,severity:"error",renderMessage:()=>{const t=document.createElement("div");return t.className="cm-diagnostic-wrapper",t.textContent=e.message,t}}}function FA(e){const t=document.createElement("div");function n(){const n=e.state.selection.main.head,i=e.state.field($A,!1),s=i?.validationResult,r=s?.rootTypeHint,o=[];if(r){const t=VA(n,r);if(t){const{pathToTypeHint:n}=s,i=new HA(n,e);i.appendNodesForPath(t.valueContext.path),o.push(...i.nodes),o.reverse()}}t.replaceChildren(...o)}return t.className="cm-status-bar",n(),{dom:t,update(e){e.selectionSet&&n()},top:!1}}function VA(e,t){const n=t.valueContext.value.segment;if(e<n.start||e>n.end)return;let i,s=0,r=t.childHints.length-1;for(;s<=r;){const n=Math.floor((s+r)/2),o=t.childHints[n],a=o.valueContext.value.segment;if(e<a.start)r=n-1;else{if(!(e>a.end)){i=o;break}s=n+1}}if(i){const t=VA(e,i);return void 0!==t?t:i}return t}class HA{constructor(e,t){this.pathToTypeHint=e,this.view=t,this.nodes=[]}appendNodesForPath(e){const t=this.pathToTypeHint.get(e).valueContext.value.segment.start,n=document.createElement("a");switch(n.className="cm-status-bar-link",n.addEventListener("click",e=>{e.preventDefault(),this.view.dispatch({selection:{anchor:t,head:t},scrollIntoView:!0}),this.view.focus()}),e.kind){case"root":n.append("root"),this.nodes.push(n);break;case"array-item":this.appendNodesForPath(e.arrayPath),null!=e.key?n.append(`[${e.index}|${e.key}]`):n.append(`[${e.index}]`),this.nodes.push(n);break;case"field-value":this.appendNodesForPath(e.structPath),n.append(`.${e.fieldName}`),this.nodes.push(n);break;case"variant-value":this.appendNodesForPath(e.enumPath),n.append(`.value("${e.variantName}")`),this.nodes.push(n)}}}function qA({schema:e,readOnly:t,json:n,theme:i}){const s={};for(const t of e.records)s[t.id]=t;const r=n??TA(e.type,s);switch(i){case void 0:case"tokyo-night":i={backgroundColor:"#1a1b26",lighterBgColor:"#1f2335",borderColor:"#414868",foregroundColor:"#c0caf5",accentColor:"#7aa2f7",errorColor:"#f7768e",selectionColor:"#515c7e40",themeExtension:kA};break;case"tokyo-night-day":i={backgroundColor:"#d5d6db",lighterBgColor:"#e1e2e7",borderColor:"#adb0bb",foregroundColor:"#3760bf",accentColor:"#2e7de9",errorColor:"#f52a65",selectionColor:"#3760bf33",themeExtension:CA}}return nn.create({doc:JSON.stringify(r,null,2),extensions:[nn.readOnly.of(!0),[],$p,nn.languageData.of(()=>[{closeBrackets:{before:",]}"}}]),Rf(),i.themeExtension??[],mh(),BA(e),mp(WA("read-only")),Zf({override:[LA(e)]}),Rp(),ll.of(FA),Fo.theme({"&":{fontSize:"14px",height:"100%"},".cm-scroller":{fontFamily:"'JetBrains Mono', monospace",overflow:"auto"},".cm-lintRange-info":{backgroundImage:"none"},".cm-lintRange-info:hover":{backgroundColor:i.selectionColor},".cm-lintRange-error":{backgroundImage:"none",borderBottom:`3px solid ${i.errorColor}`},".cm-tooltip-hover":{backgroundColor:i.lighterBgColor,border:`1px solid ${i.borderColor}`,borderRadius:"4px",padding:"8px 12px",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.5)",fontSize:"14px",lineHeight:"1.4",color:i.foregroundColor},".cm-tooltip.cm-tooltip-lint":{backgroundColor:i.lighterBgColor,border:`1px solid ${i.borderColor}`,borderRadius:"4px",padding:"8px 12px",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.5)",fontSize:"14px",color:i.foregroundColor},".cm-tooltip-lint .cm-diagnostic-error":{fontWeight:"bold",color:i.errorColor},".cm-status-bar":{backgroundColor:i.lighterBgColor,borderTopColor:i.borderColor,color:i.accentColor},".cm-diagnostic-textarea":{backgroundColor:i.lighterBgColor,borderColor:i.borderColor,color:i.foregroundColor},".cm-diagnostic-textarea[readonly]":{backgroundColor:i.backgroundColor},".cm-diagnostic-input":{backgroundColor:i.lighterBgColor,borderColor:i.borderColor,color:i.foregroundColor},".cm-diagnostic-button":{backgroundColor:i.lighterBgColor,borderColor:i.borderColor,color:i.foregroundColor},".cm-diagnostic-button:hover":{backgroundColor:i.borderColor},".cm-diagnostic-error-message":{color:i.errorColor},".diagnostic-row + .diagnostic-row":{borderTopColor:i.borderColor}}),Fo.baseTheme({".cm-lint-marker-info":{display:"none"},".cm-status-bar":{display:"flex",flexDirection:"row-reverse",justifyContent:"flex-end",padding:"4px 12px",borderTop:"1px solid",fontSize:"12px",height:"16px"},".cm-status-bar-link":{textDecoration:"none",cursor:"pointer"},".cm-status-bar-link:hover":{textDecoration:"underline"},".cm-status-bar-link:hover ~ .cm-status-bar-link":{textDecoration:"underline"},".cm-diagnostic-wrapper":{fontSize:"12px",lineHeight:"1.3",padding:"2px"},".cm-diagnostic-controls":{marginTop:"4px",display:"flex",gap:"6px",alignItems:"center"},".cm-diagnostic-label":{whiteSpace:"nowrap",fontWeight:"500",minWidth:"64px"},".cm-diagnostic-textarea":{flex:"1",padding:"3px 6px",border:"1px solid",borderRadius:"3px",fontSize:"12px",fontFamily:"'JetBrains Mono', monospace",resize:"none",overflow:"auto",boxSizing:"border-box"},".cm-diagnostic-textarea[readonly]":{cursor:"default"},".cm-diagnostic-input":{padding:"3px 6px",border:"1px solid",borderRadius:"3px",fontSize:"12px",fontFamily:"'JetBrains Mono', monospace",boxSizing:"border-box",width:"100%"},".cm-diagnostic-button":{padding:"3px 12px",border:"1px solid",borderRadius:"3px",fontSize:"12px",fontFamily:"'JetBrains Mono', monospace",cursor:"pointer",boxSizing:"border-box"},".cm-diagnostic-button:active":{transform:"translateY(1px)"},".cm-diagnostic-error-message":{fontSize:"11px",marginTop:"2px",fontWeight:"500"},".cm-timestamp-field":{display:"flex",flexDirection:"column",gap:"2px",flex:"1"},".cm-tooltip-lint .cm-diagnostic":{padding:"0",borderTop:"none",borderLeft:"none"},".cm-tooltip-lint .cm-diagnostic-error":{borderLeft:"none",fontWeight:"bold"},".cm-tooltip-lint .cm-diagnostic-info":{borderLeft:"none"},".diagnostic-row + .diagnostic-row":{marginTop:"8px",paddingTop:"8px",borderTop:"1px solid"}})]})}var KA="#000",JA="#fff",ZA=null,YA=null,GA=null,QA="#a8a8b1",XA=null,eT=null,tT=null,nT="#2e2e37",iT=null,sT=null,rT="#a8a8b1",oT=null,aT={background:KA,foreground:JA,caret:"#7d46fc",selection:"#7d46fc3f",selectionMatch:"#7d46fc7f",gutterBackground:KA,gutterForeground:JA,lineHighlight:"#00346eb0"},lT=[{tag:Te.keyword,color:ZA,fontWeight:"bold"},{tag:[Te.name,Te.deleted,Te.character,Te.macroName],color:YA},{tag:[Te.propertyName],color:GA},{tag:[Te.processingInstruction,Te.string,Te.inserted,Te.special(Te.string)],color:QA},{tag:[Te.function(Te.variableName),Te.labelName],color:GA},{tag:[Te.color,Te.constant(Te.name),Te.standard(Te.name)],color:XA},{tag:[Te.definition(Te.name),Te.separator],color:YA},{tag:[Te.className],color:tT},{tag:[Te.typeName],color:eT,fontStyle:eT},{tag:[Te.url,Te.escape,Te.regexp,Te.link],color:rT},{tag:[Te.meta,Te.comment],color:nT},{tag:Te.tagName,color:oT},{tag:Te.strong,fontWeight:"bold"},{tag:Te.emphasis,fontStyle:"italic"},{tag:Te.link,textDecoration:"underline"},{tag:Te.heading,fontWeight:"bold",color:iT},{tag:[Te.atom,Te.special(Te.variableName)],color:YA},{tag:Te.invalid,color:sT},{tag:Te.strikethrough,textDecoration:"line-through"},{tag:[Te.operatorKeyword,Te.bool,Te.null,Te.variableName],color:XA},{tag:[Te.operator],color:"#bb9af7"},{tag:[Te.number],color:"#a8a8b1"},{tag:[Te.bracket],color:"#bb9af7"}];(()=>{var{theme:e="dark",settings:t={},styles:n=[]}={};vA({theme:e,settings:yA({},aT,t),styles:[...lT,...n]})})();var cT="#fff",hT="#000",uT=null,dT=null,fT=null,pT="#6b7a88",mT=null,gT=null,yT=null,vT="#bec9d3",bT=null,wT=null,kT="#6b7a88",xT=null,ST={background:cT,foreground:hT,caret:"#004bff",selection:"#0064ff26",selectionMatch:"#0064ff4c",gutterBackground:cT,gutterForeground:hT,lineHighlight:"#0064ff0c"},CT=[{tag:Te.keyword,color:uT,fontWeight:"bold"},{tag:[Te.name,Te.deleted,Te.character,Te.macroName],color:dT},{tag:[Te.propertyName],color:fT},{tag:[Te.processingInstruction,Te.string,Te.inserted,Te.special(Te.string)],color:pT},{tag:[Te.function(Te.variableName),Te.labelName],color:fT},{tag:[Te.color,Te.constant(Te.name),Te.standard(Te.name)],color:mT},{tag:[Te.definition(Te.name),Te.separator],color:dT},{tag:[Te.className],color:yT},{tag:[Te.typeName],color:gT,fontStyle:gT},{tag:[Te.url,Te.escape,Te.regexp,Te.link],color:kT},{tag:[Te.meta,Te.comment],color:vT},{tag:Te.tagName,color:xT},{tag:Te.strong,fontWeight:"bold"},{tag:Te.emphasis,fontStyle:"italic"},{tag:Te.link,textDecoration:"underline"},{tag:Te.heading,fontWeight:"bold",color:bT},{tag:[Te.atom,Te.special(Te.variableName)],color:dT},{tag:Te.invalid,color:wT},{tag:Te.strikethrough,textDecoration:"line-through"},{tag:[Te.operatorKeyword,Te.bool,Te.null,Te.variableName],color:mT},{tag:[Te.operator],color:"#0431fa"},{tag:[Te.number],color:"#a8a8b1"},{tag:[Te.bracket],color:"#0431fa"}],AT=(()=>{var{theme:e="light",settings:t={},styles:n=[]}={};return vA({theme:e,settings:yA({},ST,t),styles:[...CT,...n]})})();const TT=[AT,Fo.theme({"&":{height:"100%",fontSize:"14px"},".cm-scroller":{fontFamily:"'IBM Plex Mono', monospace"},".cm-gutters":{borderRight:"1px solid #d4d0c4",backgroundColor:"#f7f3e8",color:"#746f63"},".cm-activeLine, .cm-activeLineGutter":{backgroundColor:"#f3eee1"},".cm-selectionBackground, &.cm-focused .cm-selectionBackground, ::selection":{backgroundColor:"#d9d4c7"},".cm-tooltip":{border:"1px solid #232323",backgroundColor:"#fffdf7",color:"#111111"},".cm-tooltip-autocomplete ul li[aria-selected]":{backgroundColor:"#111111",color:"#fffdf7"},".cm-panels":{backgroundColor:"#f3eee1",color:"#111111"},".cm-searchMatch":{backgroundColor:"#ece7da",outline:"1px solid #232323"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#d9d4c7"},".cm-matchingBracket":{backgroundColor:"#ece7da",outline:"1px solid #232323",color:"#111111"},".cm-nonmatchingBracket":{backgroundColor:"#111111",color:"#fffdf7"},".cm-foldPlaceholder":{border:"1px solid #d4d0c4",backgroundColor:"#f3eee1",color:"#545454"},".cm-lintRange-error":{backgroundImage:"none",borderBottom:"2px solid #232323"},".cm-status-bar":{borderTop:"1px solid #d4d0c4",backgroundColor:"#f3eee1",color:"#545454"}})],OT={backgroundColor:"#fffdf7",lighterBgColor:"#f3eee1",borderColor:"#d4d0c4",foregroundColor:"#111111",accentColor:"#111111",errorColor:"#232323",selectionColor:"#d9d4c7",themeExtension:TT};function MT(e){if(""===e)return{text:e,parsed:{kind:"not-set"}};let t,n;t=/^736[Bb]6972/.test(e)?"base16":e.startsWith("c2tpc")?"base64":"json";try{if("json"===t){n={kind:"json",value:JSON.parse(e)}}else if("base16"===t){n={kind:"bytes",value:new Uint8Array(e.match(/.{1,2}/g)?.map(e=>parseInt(e,16))??[]).buffer}}else if("base64"===t){const t=atob(e),i=new Uint8Array(t.length);for(let e=0;e<t.length;e++)i[e]=t.charCodeAt(e);n={kind:"bytes",value:i.buffer}}else n={kind:"not-set"}}catch(e){n={kind:"parse-error",error:String(e)}}return{text:e,parsed:n}}function ET(e){if(""===e)return{text:e,typeDescriptor:{kind:"not-set"}};try{const t=function(e){var t,n,i;const s=e,r={};for(const e of s.records){let t;switch(e.kind){case"struct":t=new nA({},e=>Object.freeze(Object.assign({},e)),()=>({}));break;case"enum":t=new rA(e=>{if(e instanceof iA)return Object.freeze({kind:"UNKNOWN"});if("string"==typeof e)return Object.freeze({kind:e});{const t=e.kind,n=e.value;return Object.freeze({kind:t,value:n})}})}const n={definition:e,serializer:t};r[e.id]=n}function o(e){switch(e.kind){case"array":{const{item:t,key_extractor:n}=e.value;return new YC(o(t),n)}case"optional":return new GC(o(e.value));case"primitive":return DC(e.value);case"record":{const t=e.value;return r[t].serializer}}}const a=[];for(const e of Object.values(r)){const{definition:s,serializer:l}=e,{defaultValue:c}=l,{id:h,removed_numbers:u}=s,d=h.split(":"),f=d[0],p=d[1].split("."),m=p[p.length-1],g=f+":"+p.slice(0,-1).join("."),y=null===(t=r[g])||void 0===t?void 0:t.serializer,v=null!==(n=s.doc)&&void 0!==n?n:"";switch(s.kind){case"struct":{const e=[];for(const t of s.fields){const n=o(t.type);e.push(new KC(t.name,t.name,t.number,n,null!==(i=t.doc)&&void 0!==i?i:"")),c[t.name]=n.defaultValue}const t=l;a.push(()=>t.init(m,f,y,v,e,null!=u?u:[]));break}case"enum":{const e=l,t=[zC].concat(s.variants).map(e=>{var t,n;return e.type?new sA(e.name,e.number,o(e.type),null!==(t=e.doc)&&void 0!==t?t:"",l.createFn):{name:e.name,number:e.number,constant:Object.freeze({kind:e.name}),doc:null!==(n=e.doc)&&void 0!==n?n:""}});a.push(()=>e.init(m,f,y,v,t,null!=u?u:[]));break}}}return a.forEach(e=>e()),o(s.type).typeDescriptor}(JSON.parse(e));return{text:e,typeDescriptor:{kind:"ok",value:t}}}catch(t){return{text:e,typeDescriptor:{kind:"error",error:String(t)}}}}function NT(e,t){const{typeDescriptor:n}=t;if("not-set"===n.kind)return{kind:"schema-not-set"};if("error"===n.kind)return{kind:"schema-error",error:n.error};if("not-set"===e.parsed.kind)return{kind:"value-not-set"};if("parse-error"===e.parsed.kind)return{kind:"value-parse-error",error:e.parsed.error};let i,s,r;try{i=n.value.transform(e.parsed.value,"dense"),s=n.value.transform(e.parsed.value,"readable"),r="json"===e.parsed.kind?n.value.transform(e.parsed.value,"bytes"):e.parsed.value}catch(e){return{kind:"schema-value-match-error",error:String(e)}}return{kind:"ok",readableJsonEditorState:qA({json:s,schema:n.value.asJson(),readOnly:!0,theme:OT}),denseJsonEditorState:nn.create({doc:JSON.stringify(i),extensions:[Bp,TT,mh()]}),base16EditorState:nn.create({doc:Array.from(new Uint8Array(r)).map(e=>e.toString(16).padStart(2,"0")).join(""),extensions:[Bp,TT]}),base64EditorState:nn.create({doc:btoa(String.fromCharCode(...new Uint8Array(r))),extensions:[Bp,TT]})}}var DT=function(e,t,n,i){var s,r=arguments.length,o=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,i);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(o=(r<3?s(o):r>3?s(t,n,o):s(t,n))||o);return r>3&&o&&Object.defineProperty(t,n,o),o};let _T=class extends Vm{constructor(){super(...arguments),this.initialState=nn.create({}),this.fillHeight=!1,this.editor={kind:"state",value:null}}render(){return Tm`<div id="container"></div>`}firstUpdated(){const e=this.renderRoot.querySelector("#container");this.editor={kind:"view",value:new Fo({state:this.state,dispatchTransactions:(e,t)=>{t.update(e),e.some(e=>e.docChanged)&&this.dispatchEvent(new CustomEvent("text-modified"))},parent:e})}}get state(){return"state"===this.editor.kind?this.editor.value??this.initialState:this.editor.value.state}set state(e){"state"===this.editor.kind?this.editor={kind:"state",value:e}:this.editor.value.setState(e)}get view(){if("view"===this.editor.kind)return this.editor.value;throw new Error("Editor view not yet initialized")}};_T.styles=Fp`
|
|
44
|
+
function Gm(e,t){return(t,n,i)=>((e,t,n)=>(n.configurable=!0,n.enumerable=!0,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,n),n))(t,n,{get(){return(t=>t.renderRoot?.querySelector(e)??null)(this)}})}function Qm(e){return e[0].toUpperCase()+e.slice(1)}function Xm(e){const t=e.slice(1,-1).split("\\\\");for(let e=0;e<t.length;++e){const n=t[e].replace(/\\(\r\n|\n|\r)/g,"\\n").replace(/(?<=^|[^\\])"/g,'\\"');t[e]=JSON.parse(`"${n}"`)}return t.join("\\")}function eg(e,t){const n=[];for(const[i,s]of Object.entries(e)){if("removed"===s.kind||!t(s))continue;const e="import"!==s.kind&&"import-alias"!==s.kind?s.doc:void 0;n.push({name:i,doc:e})}return n}class tg{constructor(){this.expectedNamesData=[],this.expectedNameSet=new Set}collect(e){for(const t of e)t.modulePath?this.expectedNamesData.push(t):this.expectedNameSet.has(t.name)||(this.expectedNamesData.push(t),this.expectedNameSet.add(t.name))}get expectedNames(){return this.expectedNamesData}}function ng(e,t,n,i,s){const r=("field"===e.kind?e.field.doc:e.doc).pieces.filter(e=>"reference"===e.kind);if(r.length<=0)return;const o=function(e,t,n){const i=[],s=e=>{const{key:t}=e,s=[...n.get(t).recordAncestors].reverse();for(const e of s)i.push(e)},r=e=>{if(e){const t=rg(e);if(t){const{record:e}=n.get(t);i.push(e)}}};switch(e.kind){case"constant":i.push(t),r(e.type);break;case"field":{const{field:n,record:o}=e;s(o),i.push(t),r(n.type);break}case"method":i.push(t),r(e.requestType),r(e.responseType);break;case"record":s(e),i.push(t)}return i}(e,t,i);for(const e of r)ig(e,o,t,n,s)}function ig(e,t,n,i,s){const{nameParts:r}=e;if(r.length<=0)return;const o=new tg;for(const a of t){if(e.absolute&&a!==n)continue;const t=sg(r,a,n,i);if("no-match"!==t.kind)return"failed-match"===t.kind?void(t.error&&s.push(t.error)):void(e.referee=t);o.collect(t.expectedNames)}const a=r[0].token;s.push({token:a,message:"Not found",expectedNames:o.expectedNames})}function sg(e,t,n,i){let s=!1;for(let r=0;r<e.length;r++){const o=e[r],a=t.nameToDeclaration[o.token.text];if(!a){const e=eg(t.nameToDeclaration,e=>t===n||"import"!==e.kind&&"import-alias"!==e.kind);return s?{kind:"failed-match",error:{token:o.token,message:"Not found",expectedNames:e}}:{kind:"no-match",expectedNames:e}}s=!0;const l=r===e.length-1,c=()=>({kind:"failed-match",error:{token:o.token,message:"Expected to be the last name in the sequence"}});switch(a.kind){case"constant":case"method":return o.declaration=a,l?a:c();case"record":if(t=a,o.declaration=a,l)return a;break;case"field":return o.declaration=a,l?{kind:"field",field:a,record:t}:c();case"import-alias":if(l)return{kind:"failed-match",error:{token:o.token,message:"Cannot be the last name in the sequence"}};case"import":{if(t!==n)return{kind:"failed-match",error:{token:o.token,message:"Cannot refer to other module's imports"}};const{resolvedModulePath:e}=a;if(!e)return{kind:"failed-match",error:null};const s=i(e);if(!s)return{kind:"failed-match",error:null};t=s,"import"===a.kind?--r:o.declaration=a;break}case"removed":throw new TypeError}}throw new Error("Unreachable")}function rg(e){switch(e.kind){case"array":return rg(e.item);case"optional":return rg(e.other);case"record":return e.key;case"primitive":return null}}function og(e,t){switch(t){case"bool":return"false"===e||"true"===e;case"bytes":return ag(e)&&/^hex:([0-9A-Fa-f]{2})*$/.test(Xm(e));case"timestamp":{if(!ag(e))return!1;const t=Xm(e),n=Date.parse(t).valueOf();return/(Z|[+-]\d\d:\d\d)$/.test(t)&&-864e13<=n&&n<=864e13&&n===Math.round(n)}case"int32":return lg(e,BigInt(-2147483648),BigInt(2147483647));case"int64":return lg(e,BigInt("-9223372036854775808"),BigInt("9223372036854775807"));case"hash64":return lg(e,BigInt(0),BigInt("18446744073709551615"));case"float32":case"float64":if(ag(e)){const t=Xm(e);return"NaN"===t||"Infinity"===t||"-Infinity"===t}return/^[-0-9]/.test(e);case"string":return ag(e)}}function ag(e){return/^['"]/.test(e)}function lg(e,t,n){if(!/^-?[0-9]+$/.test(e))return!1;const i=BigInt(e);return t<=i&&i<=n}function cg(e,t){switch(t){case"bool":return"true"===e?1:0;case"bytes":return function(e){const t=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2)t[n/2]=parseInt(e.slice(n,n+2),16);const n=Array.from(t,e=>String.fromCharCode(e)).join("");return btoa(n)}(Xm(e).substring(4));case"timestamp":{const t=Xm(e);return Math.round(new Date(t).valueOf())}case"int32":case"float32":case"float64":return ag(e)?Xm(e):Number(e);case"int64":case"hash64":return String(BigInt(e));case"string":return Xm(e)}}function hg(e,t){const n=cg(e,t);return"string"==typeof n?n:JSON.stringify(n)}function ug(e,t,n){(function(e,t){switch(t){case"lower_underscore":return/^[a-z][0-9a-z]*(_[a-z][0-9a-z]*)*$/.test(e);case"UpperCamel":return/^[A-Z][0-9A-Za-z]*$/.test(e)&&(/^[A-Z][0-9]*$/.test(e)||/[a-z]/.test(e));case"UPPER_UNDERSCORE":return/^[A-Z][0-9A-Z]*(_[A-Z][0-9A-Z]*)*$/.test(e)}})(e.text,t)||n.push({token:e,expected:t})}function dg(e,t){return new fg(e,t).parse()}class fg{constructor(e,t){this.docComment=e,this.completionMode=t,this.pieces=[],this.errors=[],this.currentText="",this.charIndex=-1;const{text:n}=e;if(n.startsWith("/// "))this.content=n.slice(4);else{if(!n.startsWith("///"))throw new Error("Expected doc comment to start with ///");this.content=n.slice(3)}this.charIndex=0}parse(){this.parseDocComment(),this.currentText.length>0&&this.pieces.push({kind:"text",text:this.currentText});const{pieces:e}=this,t=e.map(e=>{switch(e.kind){case"text":return e.text;case"reference":return e.referenceRange.text}}).join("");return{result:{text:t,pieces:this.pieces},errors:this.errors}}parseDocComment(){const e=/\[\[|\]\]|\[|\]/g;for(;this.charIndex<this.content.length;){e.lastIndex=this.charIndex;const t=e.exec(this.content);if(!t){this.currentText+=this.content.slice(this.charIndex);break}t.index>this.charIndex&&(this.currentText+=this.content.slice(this.charIndex,t.index));const n=t[0];if(this.charIndex=t.index,"[["===n)this.currentText+="[",this.charIndex+=2;else if("]]"===n)this.currentText+="]",this.charIndex+=2;else if("["===n){this.currentText.length>0&&(this.pieces.push({kind:"text",text:this.currentText}),this.currentText="");const e=this.parseReference();this.pieces.push(e)}else"]"===n&&(this.currentText+=n,this.charIndex++)}}parseReference(){const{content:e,docComment:t}=this,n=this.charIndex,i=t.text.length-e.length,s=t.position+i+n,r=e.indexOf("]",n),o=r<0?e.length:r+1,a=e.slice(n,o),l={text:a,originalText:a,position:s,line:t.line,colNumber:s-t.line.position};let c=!1;r<0&&(c=!0,this.errors.push({token:l,message:"Unterminated reference"})),this.charIndex++;const h=/[a-zA-Z][_a-zA-Z0-9]*/g,u=[];for(;this.charIndex<o;){const n=e[this.charIndex],i=t.text.length-e.length,s=t.position+i+this.charIndex,r=e=>({text:e,originalText:e,position:s,line:t.line,colNumber:s-t.line.position});if("."===n)u.push(r(".")),this.charIndex++;else if(/^[a-zA-Z]/.test(n)){h.lastIndex=this.charIndex;const t=h.exec(e)[0];u.push(r(t)),this.charIndex+=t.length}else if("]"===n)u.push(r("]")),this.charIndex++;else{const n=t.text.length-e.length,i=this.docComment.colNumber+n+this.charIndex;c=!0,this.errors.push({token:l,message:`Invalid character in reference at column ${i+1}`}),this.charIndex=o}}if(!c&&this.completionMode){const{position:e}=this.completionMode,n=s,r=t.position+i+o;if(e>=n&&e<r){const n=u.some(t=>/^[a-zA-Z]/.test(t.text)&&e>=t.position&&e<=t.position+t.text.length);if(!n){const n={text:"...",originalText:"",position:e,line:t.line,colNumber:e-t.line.position},i=u.findIndex(t=>t.position>=e);-1===i?u.push(n):u.splice(i,0,n)}}}return{kind:"reference",nameParts:c?[]:this.parseNameParts(u),absolute:"."===u[0]?.text,referee:void 0,docComment:this.docComment,referenceRange:l}}parseNameParts(e){const t=[];let n="identifier or '.'";for(const i of e){let e;if(/^[a-zA-Z]/.test(i.text)||"..."===i.text)e="identifier or '.'"===n||"identifier"===n,n="'.' or ']'",t.push({token:i,declaration:void 0});else if("."===i.text)e="identifier or '.'"===n||"'.' or ']'"===n,n="identifier";else{if("]"!==i.text)throw new Error(`Unexpected token in doc reference: ${i.text}`);e="'.' or ']'"===n}if(!e)return this.errors.push({token:i,expected:n}),[];if("]"===i.text)return t}return[]}}const pg=Object.freeze({text:"",pieces:Object.freeze([])});function mg(e,t){const{modulePath:n,sourceCode:i}=e,s=[],r=new Ig(e,t,s),o=gg(r,"module"),a=o.filter(e=>"broken-constant"===e.kind),l=o.filter(e=>"broken-method"===e.kind),c=o.filter(e=>"broken-constant"!==e.kind&&"broken-method"!==e.kind);r.expectThenNext([""]);const h={},u=new Map;for(const e of c){let t,i,r;if("import"===e.kind?(t=e.importedNames,i=$g(e.modulePath,n,s),r=e):"import-alias"===e.kind?(t=[e.name],i=$g(e.modulePath,n,s),r=e):t=[e.name],i){let e=u.get(i);e||(e=[],u.set(i,e)),e.push(r),r.resolvedModulePath=i}for(const n of t){const t=n.text;t in h?s.push({token:n,message:`Duplicate identifier '${t}'`}):h[t]=e}}const d=function(e,t,n){let i,s="no-import-seen",r=-1,o=!1;for(const t of e)"import"===t.kind||"import-alias"===t.kind?("no-import-seen"===s?(s="first-legal-import-seen",i=t.range.start):"last-legal-import-seen"===s&&(n.push({token:t.importToken,message:"Import declarations must be grouped together at the top"}),o=!0),r=Math.max(r,t.range.end)):s="last-legal-import-seen";if(void 0===i||o)return null;const a={start:i,end:r};{let e=t.tokensWithComments;e=e.slice(e.findIndex(e=>e.position>=a.start)),e=e.slice(0,e.findIndex(e=>e.position>=a.end));for(const t of e)t.text.startsWith("//")&&(n.push({token:t,message:"Comments not allowed within import block"}),o=!0)}return o?null:a}(c,e,s),f={};for(const[e,t]of u){const n=t.filter(e=>"import"===e.kind),i=t.filter(e=>"import-alias"===e.kind);if(n.length&&i.length)for(const e of n)s.push({token:e.modulePath,message:"Module already imported with an alias"});else if(i.length>=2)for(const e of i.slice(1))s.push({token:e.modulePath,message:"Module already imported with a different alias"});else if(n.length){const t=new Set;for(const e of n)for(const n of e.importedNames)t.add(n.text);f[e]={kind:"some",names:t}}else{const t=i[0].name.text;f[e]={kind:"all",alias:t}}}const p=c.filter(e=>"method"===e.kind),m=c.filter(e=>"constant"===e.kind);return{result:{kind:"module",path:n,sourceCode:i,nameToDeclaration:h,declarations:c,importBlockRange:d,records:Bg(c),pathToImportedNames:f,methods:p,brokenMethods:l,constants:m,brokenConstants:a},errors:s}}function gg(e,t){const n=[],i=e=>""===e||"module"!==t&&"}"===e,s=e=>"}"===e||";"===e;for(;!i(e.current);){const i=e.index,r=bg(e,t);if(null!==r)n.push(r),"method"!==r.kind&&"broken-method"!==r.kind||(r.inlineRequestRecord&&n.push(r.inlineRequestRecord),r.inlineResponseRecord&&n.push(r.inlineResponseRecord));else{const t=e.index===i;if(t&&(e.next(),s(e.previous)))continue;if(t||""!==e.current&&!s(e.previous)){let t=0;for(;;){const n=e.current;if(""===n)break;if(e.next(),"{"===n?++t:"}"===n&&--t,t<=0&&s(n))break}}}}return n}function bg(e,t){const n=function(e){const{moduleTokens:t}=e,n=[];for(;e.current.startsWith("///");)n.push(e.currentToken),e.next();return function(e){if(e.length<=0)return pg;const t=e.map(e=>e.text).join("\n"),n=[];for(let t=0;t<e.length;++t){const i=e[t];0!==t&&n.push({kind:"text",text:"\n"}),i.pieces.forEach(e=>n.push(e))}return{text:t,pieces:n}}(n.map(e=>t.posToDoc[e.position]??Ng))}(e);let i="enum";const s="module"===t,r=["struct","enum",s?null:"removed",s?null:Mg,s?"import":null,s?"method":null,s?"const":null],o=e.expectThenNext(r);switch(o.case){case 0:i="struct";case 1:return vg(e,i,n);case 2:return function(e,t){const n=[];let i,s="?";e:for(;;){const r="?"===s||","===s||".."===s,o=[","===s||".."===s?",":null,"?"===s||"0"===s||"1"===s?Eg:null,r?";":null,".."===s?"..":null],a=e.expectThenNext(o);switch(a.case){case 0:s="0";break;case 1:{const r=+a.token.text;if(void 0===i)s="..",n.push(r);else{s=",",r<=i&&e.errors.push({token:t,message:"Upper bound must be greater than lower bound"});for(let e=i;e<=r;++e)n.push(e);i=void 0}break}case 2:break e;case 3:s="1",i=n.pop();break;case-1:if(r)break e;return null}}const r=new Set;for(const i of n){if(r.has(i))return e.errors.push({token:t,message:`Duplicate field number ${i}`}),null;r.add(i)}return{kind:"removed",removedToken:t,numbers:n}}(e,o.token);case 3:return function(e,t,n,i){let s,r,o=-1;const a=()=>({kind:"field",name:t,number:o,doc:n,unresolvedType:s,type:void 0,isRecursive:!1,inlineRecord:r});for(;;){const n=void 0!==s||"enum"===i,l=[void 0===s&&o<0?":":null,o<0&&n?"=":null,n?";":null];switch(e.expectThenNext(l).case){case 0:{const n=wg(e,{context:"field",originalName:t});if(s=n.type,r=n.inlineRecord,void 0===s)return null;break}case 1:if(o=Cg(e),o<0)return null;break;case 2:return ug(t,s?"lower_underscore":"UPPER_UNDERSCORE",e.errors),"enum"===i&&"UNKNOWN"===t.text&&e.errors.push({token:t,message:"Cannot name field of enum: UNKNOWN"}),a();case-1:return n?a():null}}}(e,o.token,n,t);case 4:return function(e,t){const n=e.expectThenNext(["*","{",Mg]);switch(n.case){case 0:return function(e,t){if(e.expectThenNext(["as"]).case<0)return null;const n=e.expectThenNext([Mg]);if(n.case<0)return null;if(ug(n.token,"lower_underscore",e.errors),e.expectThenNext(["from"]).case<0)return null;const i=e.expectThenNext([_g]);if(i.case<0)return null;const s={start:t.position,end:e.currentToken.position+e.current.length};e.expectThenNext([";"]);const r=i.token;return{kind:"import-alias",importToken:t,name:n.token,range:s,modulePath:r}}(e,t);case 1:return Ag(e,t);case 2:return Ag(e,t,n.token);default:return null}}(e,o.token);case 5:return function(e,t){const n=e.expectThenNext([Mg]);if(n.case<0)return null;const i=n.token;if(ug(i,"UpperCamel",e.errors),e.expectThenNext(["("]).case<0)return null;const s=wg(e,{context:"method-request",originalName:i}),r=s.type;if(!r)return null;if(e.expectThenNext([")"]).case<0)return null;if(e.expectThenNext([":"]).case<0)return{kind:"broken-method",unresolvedRequestType:r,inlineRequestRecord:s.inlineRecord,unresolvedResponseType:void 0,inlineResponseRecord:void 0};const o=wg(e,{context:"method-response",originalName:i}),a=o.type;if(!a)return null;if(e.expectThenNext(["="]).case<0)return{kind:"broken-method",unresolvedRequestType:r,inlineRequestRecord:s.inlineRecord,unresolvedResponseType:a,inlineResponseRecord:o.inlineRecord};const l=Cg(e,"?");if(-2===l)return null;return e.expectThenNext([";"]),{kind:"method",name:n.token,doc:t,unresolvedRequestType:r,unresolvedResponseType:a,requestType:void 0,responseType:void 0,number:l,inlineRequestRecord:s.inlineRecord,inlineResponseRecord:o.inlineRecord}}(e,n);case 6:return function(e,t){const n=e.expectThenNext([Mg]);if(n.case<0)return null;if(ug(n.token,"UPPER_UNDERSCORE",e.errors),e.expectThenNext([":"]).case<0)return null;const i=xg(e);if(!i)return null;if(e.expectThenNext(["="]).case<0)return{kind:"broken-constant",unresolvedType:i};const s=Tg(e);if(null===s)return null;return e.expectThenNext([";"]),{kind:"constant",name:n.token,doc:t,unresolvedType:i,type:void 0,value:s,valueAsDenseJson:void 0}}(e,n);default:return null}}class yg{constructor(e,t,n,i,s,r){this.recordName=e,this.recordType=t,this.doc=n,this.stableId=i,this.inlineContext=s,this.errors=r,this.nameToDeclaration={},this.numbers=new Set,this.numbering="",this.removedNumbers=[]}addDeclaration(e){if("broken"===this.numbering)return;let t,n,i=[],s=this.numbering;const r=this.numbers.size+("enum"===this.recordType?1:0);switch(e.kind){case"field":t=e.name,n=t,s=e.number<0?"implicit":"explicit",e.number<0&&(e={...e,number:r}),i=[e.number];break;case"record":t=e.name,n=t;break;case"removed":n=e.removedToken,e.numbers.length?(s="explicit",i=e.numbers):(s="implicit",i=[r])}if(""===this.numbering?this.numbering=s:this.numbering!==s&&(this.errors.push({token:n,message:"Cannot mix implicit and explicit numbering"}),this.numbering="broken"),void 0!==t){const n=t.text;if(n in this.nameToDeclaration)return void this.errors.push({token:t,message:`Duplicate identifier '${n}'`});this.nameToDeclaration[n]=e}for(const e of i){if(this.numbers.has(e))return this.errors.push({token:n,message:`Duplicate field number ${e}`}),void(this.numbering="broken");if(0===e&&"enum"===this.recordType)return void this.errors.push({token:n,message:"Number 0 is reserved for UNKNOWN field"});this.numbers.add(e)}"removed"===e.kind&&this.removedNumbers.push(...i)}build(){const e="struct"===this.recordType;if(e)for(let e=0;e<this.numbers.size;++e)if(!this.numbers.has(e)){this.errors.push({token:this.recordName,message:`Missing field number ${e}`});break}const t=Object.values(this.nameToDeclaration),n=t.filter(e=>"field"===e.kind),i=t.filter(e=>"record"===e.kind),{recordName:s}=this;let r=`${s.line.modulePath}:${s.position}`;this.inlineContext&&(r+=`:${this.inlineContext.context}`);const o=e&&n.length?Math.max(...n.map(e=>e.number))+1:0,a=e?this.numbers.size:0;return{kind:"record",key:r,name:this.recordName,recordType:this.recordType,doc:this.doc,nameToDeclaration:this.nameToDeclaration,declarations:Object.values(this.nameToDeclaration),fields:n,nestedRecords:i,removedNumbers:this.removedNumbers.sort(),recordNumber:this.stableId,numSlots:o,numSlotsInclRemovedNumbers:a}}}function vg(e,t,n,i){let s;if(i){const{originalName:e}=i;let t=function(e,t){let n;switch(n=e.includes("_")||!/[a-z]/.test(e)?e.split("_").map(e=>e.toLowerCase()):e.split(/(?=[A-Z])/).map(e=>e.toLowerCase()),t){case"lowerCamel":return n.map((e,t)=>t?Qm(e):e).join("");case"lower_underscore":return n.join("_");case"UpperCamel":return n.map(Qm).join("");case"UPPER_UNDERSCORE":return n.map(e=>e.toUpperCase()).join("_")}}(e.text,"UpperCamel");"method-request"===i.context?t+="Request":"method-response"===i.context&&(t+="Response"),s={...e,text:t}}else{const t=e.expectThenNext([Mg]);if(t.case<0)return null;ug(t.token,"UpperCamel",e.errors),s=t.token}let r=null;if("("===e.current){if(e.next(),r=Cg(e,"?"),-2===r)return null;if(e.expectThenNext([")"]).case<0)return null}if(e.expectThenNext(["{"]).case<0)return null;const o=gg(e,t);e.expectThenNext(["}"]);const a=new yg(s,t,n,r,i,e.errors);for(const e of o)a.addDeclaration(e),"field"===e.kind&&e.inlineRecord&&a.addDeclaration(e.inlineRecord);return a.build()}const kg=new Set(["bool","int32","int64","hash64","float32","float64","timestamp","string","bytes"]);function wg(e,t){if("struct"===e.current||"enum"===e.current){const n=e.current;e.next();const i=vg(e,n,Ng,t);return{type:i?{kind:"record",nameParts:[i.name],absolute:!1}:void 0,inlineRecord:i||void 0}}return{type:xg(e),inlineRecord:void 0}}function xg(e){const t=e.expectThenNext(["[",Mg,"."]);let n;switch(t.case){case 0:n=function(e){const t=xg(e);if(void 0===t)return;let n;for(;;){const i=!n&&"record"===t.kind,s=e.expectThenNext([i?"|":null,"]"]);switch(s.case){case 0:if(n=Sg(e,s.token),null===n)return;break;case 1:return{kind:"array",item:t,key:n};default:return}}}(e);break;case 1:if(kg.has(t.token.text)){n={kind:"primitive",primitive:t.token.text};break}case 2:n=function(e,t){const n="."===t.text,i=[];if("."===t.text){const t=e.expectThenNext([Mg]);if(t.case<0)return;i.push(t.token)}else i.push(t);for(;"."===e.current;){e.next();const t=e.expectThenNext([Mg]);if(t.case<0)return;i.push(t.token)}return{kind:"record",nameParts:i,absolute:n}}(e,t.token);break;default:return}if(void 0!==n)return"?"===e.current?(e.next(),{kind:"optional",other:n}):n}function Sg(e,t){const n=[];for(;;){const t=e.expectThenNext([Mg]);if(t.case<0)return;if(n.push(t.token),"."!==e.current)break;e.next()}const i=n.map(e=>({name:e}));return{pipeToken:t,path:i,keyType:{kind:"primitive",primitive:"bool"}}}function Cg(e,t){if(t&&"lenient"===e.mode&&"?"===e.current)return e.next(),-1;const n=e.expectThenNext([Eg]);if(n.case<0)return-2;const{text:i}=n.token;return BigInt(i)<BigInt(2**32)?+i:(e.errors.push({token:n.token,message:"Value out of uint32 range"}),-2)}function Ag(e,t,n){const i=n?[n]:[];if(n)for(;","===e.current;){e.next();const t=e.expectThenNext([Mg]);if(t.case<0)return null;i.push(t.token)}else for(;;){let t=e.expectThenNext([Mg,"}"]);if(0!==t.case){if(1===t.case)break;return null}if(i.push(t.token),t=e.expectThenNext([",","}"]),1===t.case)break;if(t.case<0)return null}if(e.expectThenNext(["from"]).case<0)return null;const s=e.expectThenNext([_g]);if(s.case<0)return null;const r={start:t.position,end:e.currentToken.position+e.current.length};e.expectThenNext([";"]);return{kind:"import",importToken:t,importedNames:i,range:r,modulePath:s.token}}function Tg(e){const t=["{","{|","[","false","true","null",Dg,_g],n=e.expectThenNext(t);switch(n.case){case 0:case 1:{const t=1===n.case;return function(e,t,n){const i=n?"|}":"}",s={},r=[],o=()=>({kind:"object",token:e,entries:s,orphanNames:r,partial:n});for(;;){if(t.current===i)return t.next(),o();const e=t.expectThenNext([Mg]);if(e.case<0)return null;const n=e.token,a=e.token.text;if(t.expectThenNext([":"]).case<0){r.push(n);continue}a in s&&t.errors.push({token:e.token,message:"Duplicate field"});const l=Tg(t);if(null===l)return null;s[a]={name:n,value:l};const c=t.expectThenNext([",",i]);if(c.case<0)return null;if(c.token.text===i)return o()}}(n.token,e,t)}case 2:{const t=function(e){if("]"===e.current)return e.next(),[];const t=[];for(;;){const n=Tg(e);if(null===n)return null;t.push(n);const i=e.expectThenNext([",","]"]);if(i.case<0)return null;if("]"===i.token.text)return t;if("]"===e.current)return e.next(),t}}(e);return null===t?null:{kind:"array",token:n.token,items:t}}case 3:case 4:case 5:case 6:case 7:return{kind:"literal",token:n.token};default:return null}}const Ng=Object.freeze({text:"",pieces:Object.freeze([])});class Og{}const Mg=new class extends Og{matches(e){return/^\w/.test(e)||"..."===e}what(){return"identifier"}};const Eg=new class extends Og{matches(e){return/^[0-9]+$/.test(e)}what(){return"positive integer"}};const Dg=new class extends Og{matches(e){return/^[0-9-]/.test(e)}what(){return"number"}};const _g=new class extends Og{matches(e){return/^["']/.test(e)}what(){return"string literal"}};class Ig{constructor(e,t,n){this.moduleTokens=e,this.mode=t,this.errors=n,this.tokenIndex=0,this.tokens=e.tokens}expectThenNext(e){let t=this.tokens[this.tokenIndex];for(;t.text.startsWith("///");)this.errors.push({token:t,message:"Doc comments can only precede declarations"}),++this.tokenIndex,t=this.tokens[this.tokenIndex];for(let n=0;n<e.length;++n){const i=e[n];if(null===i)continue;if(i instanceof Og?i.matches(t.text):t.text===i)return++this.tokenIndex,{case:n,token:t}}const n=[];for(let t=0;t<e.length;++t){const i=e[t];null!==i&&n.push(i instanceof Og?i.what():`'${i}'`)}const i=1===n.length?n[0]:`one of: ${n.join(", ")}`;return this.errors.push({token:t,expected:i}),{case:-1,token:t}}get currentToken(){return this.tokens[this.tokenIndex]}get current(){return this.currentToken.text}get previous(){return this.tokens[this.tokenIndex-1].text}next(){++this.tokenIndex}get index(){return this.tokenIndex}}function Bg(e){const t=[],n=(e,i)=>{for(const s of e){if("record"!==s.kind)continue;const e=i.concat([s]),r={kind:"record-location",record:s,recordAncestors:e,modulePath:s.name.line.modulePath};n(s.declarations,e),t.push(r)}};return n(e,[]),t}function Pg(e){const t=e.match(/^(@[^/]+\/[^/]+\/)/);return t?.at(1)??""}function Rg(e){const t=e.split("/"),n=[];for(const e of t)".."===e?n.length>0&&".."!==n[n.length-1]?n.pop():n.push(".."):"."!==e&&""!==e&&n.push(e);return 0===n.length?".":n.join("/")}function $g(e,t,n){let i=Xm(e.text);if(/\\/.test(i))n.push({token:e,message:"Replace backslash with slash"});else{if(i.startsWith("./")||i.startsWith("../")){if(i.includes("/@"))return void n.push({token:e,message:"Use absolute path"});i=Rg(function(e){const t=e.lastIndexOf("/");return t>=0?e.slice(0,t):""}(t)+"/"+i)}else if(t.startsWith("@")&&!i.startsWith("@")){i=Pg(t)+i}if(i=Rg(i),!i.startsWith("../"))return i;n.push({token:e,message:"Module path must point to a file within skir-src"})}}function Lg(e,t){return/^[0-9]/.test(e.text)?(t.push({token:e,message:"Invalid number"}),!1):e.text.startsWith("_")?(t.push({token:e,message:"Identifier cannot start with _"}),!1):e.text.endsWith("_")?(t.push({token:e,message:"Identifier cannot end with _"}),!1):e.text.includes("__")?(t.push({token:e,message:"Identifier cannot contain __ sequence"}),!1):!/_[0-9]/.test(e.text)||(t.push({token:e,message:"Digit cannot follow _"}),!1)}class zg{constructor(e,t){this.lines=[];const n=this.lines;let i,s=0;const r=/\n|\r|\n\r|$/g;for(;null!==(i=r.exec(e));){const o=i[0],a=r.lastIndex-o.length,l=e.substring(s,a);if(n.push({lineNumber:n.length,line:l,position:s,modulePath:t}),s=r.lastIndex,""===o)break}}advancePosition(e){const t=this.lines;for(;t.length>=2&&e>=this.lines[1].position;)t.shift();return t[0]}}class Fg{static compile(e,t,n="strict"){return new Fg(e,t,n)}static compileForCompletion(e,t,n,i){if(!n.has(e))throw new Error(`Not found: ${e}`);return new Fg(n,i,"lenient",{modulePath:e,position:t}).modules.get(e)}constructor(e,t,n,i){this.modulePathToContent=e,this.parseMode=n,this.completionMode=i,this.moduleBundles=new Map,this.registry=new Ug,this.cache=t?new Wg(e,t.moduleBundles,t.registry):void 0;const s=i?[i.modulePath]:e.keys();for(const e of s)this.parseAndResolve(e,new Set);this.finalizationResult=this.finalize(),this.cache=void 0}parseAndResolve(e,t){const n=this.moduleBundles.get(e);if(void 0!==n)return n;const i=this.doParseAndResolve(e,t);return i&&this.moduleBundles.set(e,i),i}doParseAndResolve(e,t){const n=this.modulePathToContent.get(e);if(void 0===n)return null;let i,s;{let t;switch(t=e===this.completionMode?.modulePath?{kind:"no-cache"}:this.cache?.getModuleCacheResult(e)??{kind:"no-cache"},t.kind){case"no-cache":i=function(e,t,n){const i=[],s=[],r=new zg(e,t),o=/(\/\*([^*]|\*[^/])*(\*\/)?)|(\/\/[^\n\r]*)|(-?(0|[1-9][0-9]*)(\.[0-9]+)?\b)|\b(\w+)\b|([ \n\r\t]+)|(\.\.|\{\||\|\}|[{}[\]()*.:=;|?,])|("(\\(\n|\r|\n\r|.)|[^\\"\n\r])*"?)|('(\\(\n|\r|\n\r|.)|[^\\'\n\r])*'?)|($)/g;let a,l=0;for(;null!==(a=o.exec(e));){const t=o.lastIndex-a[0].length;if(t!==l){const n=r.advancePosition(l),i=l-n.position,o=e.substring(l,t);s.push({token:{text:o,originalText:o,position:l,line:n,colNumber:i},message:"Invalid sequence of characters"})}l=o.lastIndex;const n=r.advancePosition(t),c=t-n.position,h={text:a[0],originalText:a[0],position:t,line:n,colNumber:c};if(void 0===a[1]||a[1].endsWith("*/")||s.push({token:h,message:"Unterminated multi-line comment"}),void 0!==a[8]&&!Lg(h,s))continue;if(void 0!==a[9])continue;const u=a[11]||a[14];if(void 0!==u){if(!u.endsWith(u[0])){s.push({token:h,message:"Unterminated string literal"});continue}if(!/^["'](\\(\r\n|u[0-9A-Fa-f]{4}|["'\\/bfnrt\n\r])|[^\\])*["']$/.test(u)){s.push({token:h,message:"String literal contains invalid escape sequence"});continue}const e=Xm(u);try{encodeURIComponent(e)}catch{s.push({token:h,message:"String literal contains lone surrogates"});continue}}if(i.push(h),void 0!==a[17])break}if(void 0!==n){const{position:s}=n,r=i.find(e=>{const t=e.position,n=e.position+e.text.length;return/^\w/.test(e.text)?s>=t&&s<=n:s>t&&s<n});if(void 0===r){const n=new zg(e,t).advancePosition(s),r=s-n.position,o={text:"...",originalText:"",position:s,line:n,colNumber:r},a=i.findIndex(e=>e.position>=s);-1===a?i.push(o):i.splice(a,0,o)}}const c={};for(const e of i){if(!e.text.startsWith("///"))continue;const t=dg(e,n);c[e.position]=t.result,t.errors.forEach(e=>s.push(e))}return{result:{tokens:i.filter(e=>{return!((t=e.originalText).startsWith("/*")||t.startsWith("//")&&!t.startsWith("///"));var t}),tokensWithComments:i,posToDoc:c,sourceCode:e,modulePath:t},errors:s}}(n,e,this.completionMode);break;case"module-tokens":i=t.tokens;break;case"module-bundle":return this.registry.mergeFrom(t.bundle.registry),t.bundle}}const r=[];{const e=mg(i.result,this.parseMode);r.push(...e.errors),s=e.result}const o=new Vg(i,{result:s,errors:r});for(const n of s.declarations){if("import"!==n.kind&&"import-alias"!==n.kind)continue;const i=n.resolvedModulePath;if(void 0===i)continue;const s="Circular dependency between modules";if(t.has(e)){r.push({token:n.modulePath,message:s});continue}t.add(e);const o=this.parseAndResolve(i,t);if(t.delete(e),null===o)r.push({token:n.modulePath,message:"Module not found",expectedNames:Kg(Xm(n.modulePath.text),e,this.modulePathToContent.keys())});else if(0!==o.tokens.errors.length||0!==o.module.errors.length){const e=o.module.errors.some(e=>e.message===s);e?r.push({token:n.modulePath,message:s}):r.push({token:n.modulePath,message:"Imported module has errors",errorIsInOtherModule:!0})}else if("import"===n.kind)for(const e of n.importedNames){const t=o.module.result.nameToDeclaration[e.text];void 0===t?r.push({token:e,message:"Not found",expectedNames:eg(o.module.result.nameToDeclaration,e=>"record"===e.kind)}):"import"===t.kind?r.push({token:e,message:"Cannot reimport imported record"}):"record"!==t.kind&&r.push({token:e,message:"Not a record"})}}if(r.length&&!this.completionMode)return o;for(const t of s.records){const{key:n}=t.record;this.registry.recordMap.set(n,t),o.registry.recordMap.set(n,t);const{recordNumber:i}=t.record;null==i||e.startsWith("@")||o.registry.pushNumberRecord(i,n)}const a=new Set,l=new jg(s,this.moduleBundles,this.completionMode?this.cache?.registry.topLevelNameToRecordLocations:void 0,a,r);for(const e of s.records)this.storeResolvedFieldTypes(e,l);const c=e=>ng(e,s,e=>this.moduleBundles.get(e)?.module.result,this.recordMap,r);for(const e of s.records){const{record:t}=e;this.storeFieldRecursivity(t);for(const e of t.fields){const{type:n}=e;n&&this.validateArrayKeys(n,r),c({kind:"field",field:e,record:t})}c(t)}const h=e=>{const t=l.resolve(e,"top-level");return t&&this.validateArrayKeys(t,r),t};for(const t of s.methods){const{unresolvedRequestType:n,unresolvedResponseType:i}=t;t.requestType=h(n),t.responseType=h(i);const{number:s}=t;e.startsWith("@")||o.registry.pushNumberMethod(s,t),c(t)}for(const e of s.brokenMethods){const{unresolvedRequestType:t,unresolvedResponseType:n}=e;h(t),n&&h(n)}for(const e of s.constants){const{unresolvedType:t}=e,n=h(t);e.type=n,n&&(e.valueAsDenseJson=this.valueToDenseJson(e.value,n,r)),c(e)}for(const e of s.brokenConstants){const{unresolvedType:t}=e;h(t)}return o.registry.pushTopLevelNames(s.declarations.filter(e=>"record"===e.kind).map(t=>({name:t.name.text,doc:t.doc,modulePath:e}))),function(e,t,n){for(const i of e.declarations)if("import"===i.kind)for(const e of i.importedNames)t.has(e.text)||n.push({token:e,message:"Unused import"});else"import-alias"===i.kind&&(t.has(i.name.text)||n.push({token:i.name,message:"Unused import alias"}))}(s,a,r),this.registry.mergeFrom(o.registry),o}storeResolvedFieldTypes(e,t){for(const n of e.record.fields)void 0!==n.unresolvedType&&(n.type=t.resolve(n.unresolvedType,e))}storeFieldRecursivity(e){for(const t of e.fields){if(!t.type)continue;const n="struct"===e.recordType?["hard","via-optional","soft"]:["soft"];for(const i of n){const n=new Set;if(this.collectTypeDeps(t.type,i,n),n.has(e.key)){t.isRecursive=i;break}}}}collectTypeDeps(e,t,n){switch(e.kind){case"record":{if("via-optional"===t)return;const{key:i}=e;if(n.has(i))return;n.add(i);const s=this.recordMap.get(i)?.record;if(!s)return void console.error("collectTypeDeps: record not found",i);if("hard"===t&&"enum"===s.recordType)return;for(const e of s.fields)void 0!==e.type&&this.collectTypeDeps(e.type,t,n);break}case"array":"soft"===t&&this.collectTypeDeps(e.item,t,n);break;case"optional":switch(t){case"soft":this.collectTypeDeps(e.other,t,n);break;case"via-optional":this.collectTypeDeps(e.other,"hard",n)}}}validateArrayKeys(e,t){const n=e=>{const{key:n,item:i}=e;if(!n)return;const{path:s}=n;let r,o=i;for(let e=0;e<s.length;++e){const i=s[e],a=i.name;if("record"!==o.kind){if(0===e)t.push({token:n.pipeToken,message:"Item must have struct type"});else{const n=s[e-1].name;t.push({token:n,message:"Must have struct type"})}return}const l=this.recordMap.get(o.key)?.record;if(!l)return void console.error("validateArrayKeys: record not found",o.key);if("struct"===l.recordType){const e=l.nameToDeclaration[a.text];if("field"!==e?.kind)return void t.push({token:a,message:`Field not found in struct ${l.name.text}`,expectedNames:eg(l.nameToDeclaration,e=>"field"===e.kind)});if(i.declaration=e,!e.type)return;o=e.type}else{if("kind"!==a.text)return void t.push({token:a,expected:"'kind'",expectedNames:[{name:"kind"}]});r=o,o={kind:"primitive",primitive:"string"}}}"primitive"===o.kind?n.keyType=r||o:t.push({token:s.at(-1).name,message:"Does not have primitive type"})},i=e=>{switch(e.kind){case"array":return n(e),i(e.item);case"optional":return i(e.other)}};i(e)}valueToDenseJson(e,t,n){switch(t.kind){case"optional":return"literal"===e.kind&&"null"===e.token.text?(e.type={kind:"null"},null):this.valueToDenseJson(e,t.other,n);case"array":{if("array"!==e.kind)return void n.push({token:e.token,expected:"array"});const i=[];let s=!0;for(const r of e.items){const e=this.valueToDenseJson(r,t.item,n);void 0!==e?i.push(e):s=!1}if(!s)return;const{key:r}=t;return e.key=r,r&&function(e,t,n){const{keyType:i,path:s}=t,r=e=>{let t=e;for(const e of s){const i=e.name;if("literal"===t.kind&&"kind"===i.text)return t;if("object"!==t.kind)return;const s=t.entries[i.text];if(!s)return void n.push({token:t.token,message:`Missing entry: ${i.text}`});t=s.value}return t},o=new Map;for(const t of e){const e=r(t);if(!e)return;if("literal"!==e.kind)return;let n;const s=e.token.text;if("primitive"===i.kind){const{primitive:e}=i;if(!og(s,e))continue;n=hg(s,e)}else{if(!ag(s))continue;n=Xm(s)}o.has(n)?o.get(n).push(e):o.set(n,[e])}for(const e of o.values())if(!(e.length<=1))for(const t of e)n.push({token:t.token,message:"Duplicate key"})}(e.items,r,n),i}case"record":{const i=this.recordMap.get(t.key);if(!i)return;return"struct"===i.record.recordType?this.structValueToDenseJson(e,i.record,n):this.enumValueToDenseJson(e,i.record,n)}case"primitive":{const{token:i}=e,{primitive:s}=t;return"literal"===e.kind&&og(i.text,s)?(e.type=t,cg(i.text,t.primitive)):void n.push({token:e.token,expected:s})}}}structValueToDenseJson(e,t,n){const{token:i}=e;if("object"!==e.kind)return void n.push({token:i,expected:"object"});const s=Array(t.numSlotsInclRemovedNumbers).fill(0);let r=!0;const o=Object.values(e.entries).map(e=>e.name).concat(e.orphanNames),a=new Set(o.map(e=>e.text));for(const e of o){const i=t.nameToDeclaration[e.text];"field"===i?.kind||(n.push({token:e,message:`Field not found in struct ${t.name.text}`,expectedNames:eg(t.nameToDeclaration,e=>"field"===e.kind&&!a.has(e.name.text))}),r=!1)}let l=0;for(const o of t.fields){const{type:t}=o;if(!t){r=!1;continue}const a=e.entries[o.name.text];let c;if(a?(a.fieldDeclaration=o,c=this.valueToDenseJson(a.value,t,n)):e.partial?c=this.getDefaultJson(t):n.push({token:i,message:`Missing entry: ${o.name.text}`}),void 0===c){r=!1;continue}s[o.number]=c;("optional"===t.kind?null===c:!c||Array.isArray(c)&&!c.length||"primitive"===t.kind&&("int64"===t.primitive||"hash64"===t.primitive)&&"0"===c)||(l=Math.max(l,o.number+1))}return r?(e.record=t,s.slice(0,l)):void 0}enumValueToDenseJson(e,t,n){const{token:i}=e;if("literal"===e.kind&&ag(i.text)){const s=Xm(i.text);if("UNKNOWN"===s)return 0;const r=t.nameToDeclaration[s];return"field"!==r?.kind?void n.push({token:i,message:`Variant not found in enum ${t.name.text}`,expectedNames:[{name:"UNKNOWN"}].concat(eg(t.nameToDeclaration,e=>"field"===e.kind&&!e.type))}):r.type?void n.push({token:i,message:"Refers to a wrapper variant"}):(e.type={kind:"enum",enum:t,variant:r},r.number)}if("object"===e.kind){const{entries:s}=e,r=s.kind,o=s.value,a=Object.values(s).map(e=>e.name).concat(e.orphanNames);for(const e of a){if("kind"===e.text||"value"===e.text)continue;const t=(r?[]:[{name:"kind"}]).concat(o?[]:[{name:"value"}]);return void n.push({token:e,message:"Extraneous entry",expectedNames:t})}if(!r)return void n.push({token:i,message:"Missing entry: kind"});const l=r.value.token;if("literal"!==r.value.kind||!ag(l.text))return void n.push({token:l,expected:"string"});const c=Xm(l.text),h=t.nameToDeclaration[c];if("field"!==h?.kind)return void n.push({token:l,message:`Variant not found in enum ${t.name.text}`,expectedNames:eg(t.nameToDeclaration,e=>"field"===e.kind&&!!e.type)});if(!h.type)return void n.push({token:l,message:"Refers to a constant variant"});if(!o)return void n.push({token:i,message:"Missing entry: value"});const u=this.valueToDenseJson(o.value,h.type,n);if(void 0===u)return;return e.record=t,[h.number,u]}n.push({token:i,expected:"string or object"})}getDefaultJson(e){switch(e.kind){case"primitive":switch(e.primitive){case"bool":case"int32":case"int64":case"hash64":case"float32":case"float64":case"timestamp":return 0;case"string":case"bytes":return"";default:{const t=e.primitive;throw new TypeError(t)}}case"array":return[];case"optional":return null;case"record":switch(this.recordMap.get(e.key).record.recordType){case"struct":return[];case"enum":return 0}}}finalize(){const e=new Map;for(const[t,n]of this.moduleBundles){const{module:i,tokens:s}=n,r=s.errors.length?s.errors:i.errors;e.set(t,{result:i.result,errors:[...r]})}for(const t of this.registry.numberToMethods.values()){if(t.length<=1)continue;const n=(t,n)=>{const i=t.name.line.modulePath,s=e.get(i),r=n.name.text,o=n.name.line.modulePath;s.errors.push({token:t.name,message:`Same number as ${r} in ${o}`})};n(t[0],t[1]);for(let e=1;e<t.length;++e)n(t[e],t[0])}for(const t of this.registry.numberToRecords.values()){if(t.length<=1)continue;const n=(t,n)=>{const i=this.registry.recordMap.get(t),s=this.registry.recordMap.get(n),r=i.record.name.line.modulePath,o=e.get(r),a=s.record.name.text,l=s.modulePath;o.errors.push({token:i.record.name,message:`Same number as ${a} in ${l}`})};n(t[0],t[1]);for(let e=1;e<t.length;++e)n(t[e],t[0])}const t=[];for(const n of e.values())t.push(...n.errors);return{modules:e,errors:t}}findRecordByNumber(e){const{numberToRecords:t,recordMap:n}=this.registry,i=t.get(e);return 1===i?.length?n.get(i[0]):void 0}findMethodByNumber(e){const{numberToMethods:t}=this.registry,n=t.get(e);return 1===n?.length?n[0]:void 0}get recordMap(){return this.registry.recordMap}get errors(){return this.finalizationResult.errors}get modules(){return this.finalizationResult.modules}}class jg{constructor(e,t,n,i,s){this.module=e,this.moduleBundles=t,this.topLevelNameToRecordLocations=n,this.usedImports=i,this.errors=s}resolve(e,t){switch(e.kind){case"primitive":return e;case"array":{const n=this.resolve(e.item,t);if(!n)return;return{kind:"array",item:n,key:e.key}}case"optional":{const n=this.resolve(e.other,t);if(!n)return;return{kind:"optional",other:n}}case"record":return this.resolveRecordRef(e,t)}}resolveRecordRef(e,t){const n=e.nameParts[0],i=e=>({token:e,message:"Does not refer to a struct or an enum"}),s=(e,t)=>({token:e,message:`Cannot find name '${e.text}'`,expectedNames:t}),{errors:r,module:o,moduleBundles:a,usedImports:l}=this;let c;const h=new tg;if("top-level"!==t&&!e.absolute)for(const e of[...t.recordAncestors].reverse()){const t=e.nameToDeclaration[n.text];if(t&&"record"===t.kind){c=e;break}h.collect(eg(e.nameToDeclaration,e=>"record"===e.kind))}if(void 0===c){if(!o.nameToDeclaration[n.text])return h.collect(eg(o.nameToDeclaration,e=>"record"===e.kind||"import"===e.kind||"import-alias"===e.kind)),h.collect(this.topLevelNameToRecordLocations?.get(n.text)?.filter(e=>e.modulePath!==o.path)??[]),void r.push(s(n,h.expectedNames));c=o}let u=c;const d=[];for(let t=0;t<e.nameParts.length;++t){const n=e.nameParts[t],o=n.text;let c=u.nameToDeclaration[o];if(void 0===c)return void r.push(s(n,eg(u.nameToDeclaration,e=>"record"===e.kind||0===t&&"import-alias"===e.kind||0===t&&"import"===e.kind)));if("record"===c.kind)u=c;else{if("import"!==c.kind&&"import-alias"!==c.kind)return void this.errors.push(i(n));{const e=()=>({token:n,message:"Cannot refer to imports of imported module"});if(0!==t)return void r.push(e());l.add(o);const h=c.resolvedModulePath;if(void 0===h)return;const d=a.get(h);if(!d)return;const f=d.module.result;if("import"===c.kind){if(c=f.nameToDeclaration[o],!c)return void r.push(s(n,eg(f.nameToDeclaration,e=>"record"===e.kind)));if("record"!==c.kind)return void this.errors.push("import"===c.kind||"import-alias"===c.kind?e():i(n));u=c}else u=f}}d.push({token:n,declaration:c})}if("record"!==u.kind){const t=e.nameParts[0];return void this.errors.push(i(t))}return{kind:"record",key:u.key,recordType:u.recordType,nameParts:d,refToken:e.nameParts.at(-1)}}}class Wg{constructor(e,t,n){this.registry=n,this.modulePathToCacheResult=new Map;const i=new Set;for(const[n,s]of e){const e=t.get(n);e?.tokens.result.sourceCode===s&&i.add(n)}const s=n=>{const i=t.get(n);if(!i)return{kind:"no-cache"};{const e=this.modulePathToCacheResult.get(n);if(e)return e}let r;if(e.get(n)===i.tokens.result.sourceCode){this.modulePathToCacheResult.set(n,{kind:"module-bundle",bundle:i});r=Object.keys(i.module.result?.pathToImportedNames).every(e=>"module-bundle"===s(e).kind)?{kind:"module-bundle",bundle:i}:{kind:"module-tokens",tokens:i.tokens}}else r={kind:"no-cache"};return this.modulePathToCacheResult.set(n,r),r};for(const e of t.keys())s(e)}getModuleCacheResult(e){return this.modulePathToCacheResult.get(e)??{kind:"no-cache"}}}class Ug{constructor(){this.recordMap=new Map,this.numberToRecords=new Map,this.numberToMethods=new Map,this.topLevelNameToRecordLocations=new Map}mergeFrom(e){for(const[t,n]of e.recordMap)this.recordMap.set(t,n);for(const[t,n]of e.numberToRecords){let e=this.numberToRecords.get(t);e||(e=[],this.numberToRecords.set(t,e)),e.push(...n)}for(const[t,n]of e.numberToMethods){let e=this.numberToMethods.get(t);e||(e=[],this.numberToMethods.set(t,e)),e.push(...n)}for(const[t,n]of e.topLevelNameToRecordLocations){let e=this.topLevelNameToRecordLocations.get(t);e||(e=[],this.topLevelNameToRecordLocations.set(t,e)),e.push(...n)}}pushNumberRecord(e,t){let n=this.numberToRecords.get(e);n||(n=[],this.numberToRecords.set(e,n)),n.push(t)}pushNumberMethod(e,t){let n=this.numberToMethods.get(e);n||(n=[],this.numberToMethods.set(e,n)),n.push(t)}pushTopLevelNames(e){for(const t of e){let e=this.topLevelNameToRecordLocations.get(t.name);e||(e=[],this.topLevelNameToRecordLocations.set(t.name,e)),e.push(t)}}}class Vg{constructor(e,t){this.tokens=e,this.module=t,this.registry=new Ug}}function Hg(e){const t=e.lastIndexOf("/");return t>=0?e.slice(0,t):""}function qg(e,t){const n=""===e?[]:e.split("/"),i=""===t?[]:t.split("/");let s=0;for(;s<n.length&&s<i.length&&n[s]===i[s];)s++;const r=n.length-s,o=i.slice(s);return[...Array(r).fill(".."),...o].join("/")}function Kg(e,t,n){const i=e.startsWith("./")||e.startsWith("../");let s;if(i){const n=e.lastIndexOf("/"),i=e.slice(0,n+1),r=e.slice(n+1),o=i+"__dummy__",a=function(e,t){const n=(e+"/"+t).split("/"),i=[];for(const e of n)".."===e?i.length>0&&".."!==i[i.length-1]?i.pop():i.push(".."):"."!==e&&""!==e&&i.push(e);return i.join("/")}(Hg(t),o.startsWith("./")?o.slice(2):o);s=a.slice(0,a.length-9)+r}else s=t.startsWith("@")&&!e.startsWith("@")?Pg(t)+e:e;if(s=s.replace(/\\/g,"/"),s.startsWith("../"))return[];const r=Hg(t),o=new Set;for(const a of n){if(!a.startsWith(s))continue;if(a===t)continue;if(i&&a.startsWith("@"))continue;const n=a.slice(s.length),l=n.indexOf("/"),c=l>=0?s+n.slice(0,l+1):a;if(i){const t=c.endsWith("/");let n=qg(r,t?c.slice(0,-1):c);""===n&&(n="."),n.startsWith(".")||(n="./"+n);const i=t?n+"/":n;if(e.startsWith("../")&&"./"===i)continue;o.add(i)}else o.add(c)}return[...o].map(e=>({name:e}))}const Jg=Symbol.for("yaml.alias"),Zg=Symbol.for("yaml.document"),Yg=Symbol.for("yaml.map"),Gg=Symbol.for("yaml.pair"),Qg=Symbol.for("yaml.scalar"),Xg=Symbol.for("yaml.seq"),eb=Symbol.for("yaml.node.type"),tb=e=>!!e&&"object"==typeof e&&e[eb]===Jg,nb=e=>!!e&&"object"==typeof e&&e[eb]===Zg,ib=e=>!!e&&"object"==typeof e&&e[eb]===Yg,sb=e=>!!e&&"object"==typeof e&&e[eb]===Gg,rb=e=>!!e&&"object"==typeof e&&e[eb]===Qg,ob=e=>!!e&&"object"==typeof e&&e[eb]===Xg;function ab(e){if(e&&"object"==typeof e)switch(e[eb]){case Yg:case Xg:return!0}return!1}function lb(e){if(e&&"object"==typeof e)switch(e[eb]){case Jg:case Yg:case Qg:case Xg:return!0}return!1}const cb=e=>(rb(e)||ab(e))&&!!e.anchor,hb=Symbol("break visit"),ub=Symbol("skip children"),db=Symbol("remove node");function fb(e,t){const n=function(e){if("object"==typeof e&&(e.Collection||e.Node||e.Value))return Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e);return e}(t);if(nb(e)){pb(null,e.contents,n,Object.freeze([e]))===db&&(e.contents=null)}else pb(null,e,n,Object.freeze([]))}function pb(e,t,n,i){const s=function(e,t,n,i){return"function"==typeof n?n(e,t,i):ib(t)?n.Map?.(e,t,i):ob(t)?n.Seq?.(e,t,i):sb(t)?n.Pair?.(e,t,i):rb(t)?n.Scalar?.(e,t,i):tb(t)?n.Alias?.(e,t,i):void 0}(e,t,n,i);if(lb(s)||sb(s))return function(e,t,n){const i=t[t.length-1];if(ab(i))i.items[e]=n;else if(sb(i))"key"===e?i.key=n:i.value=n;else{if(!nb(i)){const e=tb(i)?"alias":"scalar";throw new Error(`Cannot replace node with ${e} parent`)}i.contents=n}}(e,i,s),pb(e,s,n,i);if("symbol"!=typeof s)if(ab(t)){i=Object.freeze(i.concat(t));for(let e=0;e<t.items.length;++e){const s=pb(e,t.items[e],n,i);if("number"==typeof s)e=s-1;else{if(s===hb)return hb;s===db&&(t.items.splice(e,1),e-=1)}}}else if(sb(t)){i=Object.freeze(i.concat(t));const e=pb("key",t.key,n,i);if(e===hb)return hb;e===db&&(t.key=null);const s=pb("value",t.value,n,i);if(s===hb)return hb;s===db&&(t.value=null)}return s}fb.BREAK=hb,fb.SKIP=ub,fb.REMOVE=db;const mb={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},gb=e=>e.replace(/[!,[\]{}]/g,e=>mb[e]);class bb{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},bb.defaultYaml,e),this.tags=Object.assign({},bb.defaultTags,t)}clone(){const e=new bb(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){const e=new bb(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:bb.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},bb.defaultTags)}return e}add(e,t){this.atNextDocument&&(this.yaml={explicit:bb.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},bb.defaultTags),this.atNextDocument=!1);const n=e.trim().split(/[ \t]+/),i=n.shift();switch(i){case"%TAG":{if(2!==n.length&&(t(0,"%TAG directive should contain exactly two parts"),n.length<2))return!1;const[e,i]=n;return this.tags[e]=i,!0}case"%YAML":{if(this.yaml.explicit=!0,1!==n.length)return t(0,"%YAML directive should contain exactly one part"),!1;const[e]=n;if("1.1"===e||"1.2"===e)return this.yaml.version=e,!0;return t(6,`Unsupported YAML version ${e}`,/^\d+\.\d+$/.test(e)),!1}default:return t(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if("!"===e)return"!";if("!"!==e[0])return t(`Not a valid tag: ${e}`),null;if("<"===e[1]){const n=e.slice(2,-1);return"!"===n||"!!"===n?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(">"!==e[e.length-1]&&t("Verbatim tags must end with a >"),n)}const[,n,i]=e.match(/^(.*!)([^!]*)$/s);i||t(`The ${e} tag has no suffix`);const s=this.tags[n];if(s)try{return s+decodeURIComponent(i)}catch(e){return t(String(e)),null}return"!"===n?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(const[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+gb(e.substring(n.length));return"!"===e[0]?e:`!<${e}>`}toString(e){const t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],n=Object.entries(this.tags);let i;if(e&&n.length>0&&lb(e.contents)){const t={};fb(e.contents,(e,n)=>{lb(n)&&n.tag&&(t[n.tag]=!0)}),i=Object.keys(t)}else i=[];for(const[s,r]of n)"!!"===s&&"tag:yaml.org,2002:"===r||e&&!i.some(e=>e.startsWith(r))||t.push(`%TAG ${s} ${r}`);return t.join("\n")}}function yb(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){const t=JSON.stringify(e);throw new Error(`Anchor must not contain whitespace or control characters: ${t}`)}return!0}function vb(e){const t=new Set;return fb(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function kb(e,t){for(let n=1;;++n){const i=`${e}${n}`;if(!t.has(i))return i}}function wb(e,t,n,i){if(i&&"object"==typeof i)if(Array.isArray(i))for(let t=0,n=i.length;t<n;++t){const n=i[t],s=wb(e,i,String(t),n);void 0===s?delete i[t]:s!==n&&(i[t]=s)}else if(i instanceof Map)for(const t of Array.from(i.keys())){const n=i.get(t),s=wb(e,i,t,n);void 0===s?i.delete(t):s!==n&&i.set(t,s)}else if(i instanceof Set)for(const t of Array.from(i)){const n=wb(e,i,t,t);void 0===n?i.delete(t):n!==t&&(i.delete(t),i.add(n))}else for(const[t,n]of Object.entries(i)){const s=wb(e,i,t,n);void 0===s?delete i[t]:s!==n&&(i[t]=s)}return e.call(t,n,i)}function xb(e,t,n){if(Array.isArray(e))return e.map((e,t)=>xb(e,String(t),n));if(e&&"function"==typeof e.toJSON){if(!n||!cb(e))return e.toJSON(t,n);const i={aliasCount:0,count:1,res:void 0};n.anchors.set(e,i),n.onCreate=e=>{i.res=e,delete n.onCreate};const s=e.toJSON(t,n);return n.onCreate&&n.onCreate(s),s}return"bigint"!=typeof e||n?.keep?e:Number(e)}bb.defaultYaml={explicit:!1,version:"1.2"},bb.defaultTags={"!!":"tag:yaml.org,2002:"};class Sb{constructor(e){Object.defineProperty(this,eb,{value:e})}clone(){const e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:i,reviver:s}={}){if(!nb(e))throw new TypeError("A document argument is required");const r={anchors:new Map,doc:e,keep:!0,mapAsMap:!0===t,mapKeyWarned:!1,maxAliasCount:"number"==typeof n?n:100},o=xb(this,"",r);if("function"==typeof i)for(const{count:e,res:t}of r.anchors.values())i(t,e);return"function"==typeof s?wb(s,{"":o},"",o):o}}class Cb extends Sb{constructor(e){super(Jg),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,t){let n,i;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],fb(e,{Node:(e,t)=>{(tb(t)||cb(t))&&n.push(t)}}),t&&(t.aliasResolveCache=n));for(const e of n){if(e===this)break;e.anchor===this.source&&(i=e)}return i}toJSON(e,t){if(!t)return{source:this.source};const{anchors:n,doc:i,maxAliasCount:s}=t,r=this.resolve(i,t);if(!r){const e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(e)}let o=n.get(r);if(o||(xb(r,null,t),o=n.get(r)),void 0===o?.res){throw new ReferenceError("This should not happen: Alias anchor was not resolved?")}if(s>=0&&(o.count+=1,0===o.aliasCount&&(o.aliasCount=Ab(i,r,n)),o.count*o.aliasCount>s)){throw new ReferenceError("Excessive alias count indicates a resource exhaustion attack")}return o.res}toString(e,t,n){const i=`*${this.source}`;if(e){if(yb(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){const e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(e)}if(e.implicitKey)return`${i} `}return i}}function Ab(e,t,n){if(tb(t)){const i=t.resolve(e),s=n&&i&&n.get(i);return s?s.count*s.aliasCount:0}if(ab(t)){let i=0;for(const s of t.items){const t=Ab(e,s,n);t>i&&(i=t)}return i}if(sb(t)){const i=Ab(e,t.key,n),s=Ab(e,t.value,n);return Math.max(i,s)}return 1}const Tb=e=>!e||"function"!=typeof e&&"object"!=typeof e;class Nb extends Sb{constructor(e){super(Qg),this.value=e}toJSON(e,t){return t?.keep?this.value:xb(this.value,e,t)}toString(){return String(this.value)}}Nb.BLOCK_FOLDED="BLOCK_FOLDED",Nb.BLOCK_LITERAL="BLOCK_LITERAL",Nb.PLAIN="PLAIN",Nb.QUOTE_DOUBLE="QUOTE_DOUBLE",Nb.QUOTE_SINGLE="QUOTE_SINGLE";function Ob(e,t,n){if(nb(e)&&(e=e.contents),lb(e))return e;if(sb(e)){const t=n.schema[Yg].createNode?.(n.schema,null,n);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||"undefined"!=typeof BigInt&&e instanceof BigInt)&&(e=e.valueOf());const{aliasDuplicateObjects:i,onAnchor:s,onTagObj:r,schema:o,sourceObjects:a}=n;let l;if(i&&e&&"object"==typeof e){if(l=a.get(e),l)return l.anchor??(l.anchor=s(e)),new Cb(l.anchor);l={anchor:null,node:null},a.set(e,l)}t?.startsWith("!!")&&(t="tag:yaml.org,2002:"+t.slice(2));let c=function(e,t,n){if(t){const e=n.filter(e=>e.tag===t),i=e.find(e=>!e.format)??e[0];if(!i)throw new Error(`Tag ${t} not found`);return i}return n.find(t=>t.identify?.(e)&&!t.format)}(e,t,o.tags);if(!c){if(e&&"function"==typeof e.toJSON&&(e=e.toJSON()),!e||"object"!=typeof e){const t=new Nb(e);return l&&(l.node=t),t}c=e instanceof Map?o[Yg]:Symbol.iterator in Object(e)?o[Xg]:o[Yg]}r&&(r(c),delete n.onTagObj);const h=c?.createNode?c.createNode(n.schema,e,n):"function"==typeof c?.nodeClass?.from?c.nodeClass.from(n.schema,e,n):new Nb(e);return t?h.tag=t:c.default||(h.tag=c.tag),l&&(l.node=h),h}function Mb(e,t,n){let i=n;for(let e=t.length-1;e>=0;--e){const n=t[e];if("number"==typeof n&&Number.isInteger(n)&&n>=0){const e=[];e[n]=i,i=e}else i=new Map([[n,i]])}return Ob(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}const Eb=e=>null==e||"object"==typeof e&&!!e[Symbol.iterator]().next().done;class Db extends Sb{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){const t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>lb(t)||sb(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(Eb(e))this.add(t);else{const[n,...i]=e,s=this.get(n,!0);if(ab(s))s.addIn(i,t);else{if(void 0!==s||!this.schema)throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`);this.set(n,Mb(this.schema,i,t))}}}deleteIn(e){const[t,...n]=e;if(0===n.length)return this.delete(t);const i=this.get(t,!0);if(ab(i))return i.deleteIn(n);throw new Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){const[n,...i]=e,s=this.get(n,!0);return 0===i.length?!t&&rb(s)?s.value:s:ab(s)?s.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!sb(t))return!1;const n=t.value;return null==n||e&&rb(n)&&null==n.value&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){const[t,...n]=e;if(0===n.length)return this.has(t);const i=this.get(t,!0);return!!ab(i)&&i.hasIn(n)}setIn(e,t){const[n,...i]=e;if(0===i.length)this.set(n,t);else{const e=this.get(n,!0);if(ab(e))e.setIn(i,t);else{if(void 0!==e||!this.schema)throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`);this.set(n,Mb(this.schema,i,t))}}}}const _b=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function Ib(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}const Bb=(e,t,n)=>e.endsWith("\n")?Ib(n,t):n.includes("\n")?"\n"+Ib(n,t):(e.endsWith(" ")?"":" ")+n,Pb="flow",Rb="block",$b="quoted";function Lb(e,t,n="flow",{indentAtStart:i,lineWidth:s=80,minContentWidth:r=20,onFold:o,onOverflow:a}={}){if(!s||s<0)return e;s<r&&(r=0);const l=Math.max(1+r,1+s-t.length);if(e.length<=l)return e;const c=[],h={};let u,d,f=s-t.length;"number"==typeof i&&(i>s-Math.max(2,r)?c.push(0):f=s-i);let p=!1,m=-1,g=-1,b=-1;n===Rb&&(m=zb(e,m,t.length),-1!==m&&(f=m+l));for(let i;i=e[m+=1];){if(n===$b&&"\\"===i){switch(g=m,e[m+1]){case"x":m+=3;break;case"u":m+=5;break;case"U":m+=9;break;default:m+=1}b=m}if("\n"===i)n===Rb&&(m=zb(e,m,t.length)),f=m+t.length+l,u=void 0;else{if(" "===i&&d&&" "!==d&&"\n"!==d&&"\t"!==d){const t=e[m+1];t&&" "!==t&&"\n"!==t&&"\t"!==t&&(u=m)}if(m>=f)if(u)c.push(u),f=u+l,u=void 0;else if(n===$b){for(;" "===d||"\t"===d;)d=i,i=e[m+=1],p=!0;const t=m>b+1?m-2:g-1;if(h[t])return e;c.push(t),h[t]=!0,f=t+l,u=void 0}else p=!0}d=i}if(p&&a&&a(),0===c.length)return e;o&&o();let y=e.slice(0,c[0]);for(let i=0;i<c.length;++i){const s=c[i],r=c[i+1]||e.length;0===s?y=`\n${t}${e.slice(0,r)}`:(n===$b&&h[s]&&(y+=`${e[s]}\\`),y+=`\n${t}${e.slice(s+1,r)}`)}return y}function zb(e,t,n){let i=t,s=t+1,r=e[s];for(;" "===r||"\t"===r;)if(t<s+n)r=e[++t];else{do{r=e[++t]}while(r&&"\n"!==r);i=t,s=t+1,r=e[s]}return i}const Fb=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),jb=e=>/^(%|---|\.\.\.)/m.test(e);function Wb(e,t){const n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;const{implicitKey:i}=t,s=t.options.doubleQuotedMinMultiLineLength,r=t.indent||(jb(e)?" ":"");let o="",a=0;for(let e=0,t=n[e];t;t=n[++e])if(" "===t&&"\\"===n[e+1]&&"n"===n[e+2]&&(o+=n.slice(a,e)+"\\ ",e+=1,a=e,t="\\"),"\\"===t)switch(n[e+1]){case"u":{o+=n.slice(a,e);const t=n.substr(e+2,4);switch(t){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:"00"===t.substr(0,2)?o+="\\x"+t.substr(2):o+=n.substr(e,6)}e+=5,a=e+1}break;case"n":if(i||'"'===n[e+2]||n.length<s)e+=1;else{for(o+=n.slice(a,e)+"\n\n";"\\"===n[e+2]&&"n"===n[e+3]&&'"'!==n[e+4];)o+="\n",e+=2;o+=r," "===n[e+2]&&(o+="\\"),e+=1,a=e+1}break;default:e+=1}return o=a?o+n.slice(a):n,i?o:Lb(o,r,$b,Fb(t,!1))}function Ub(e,t){if(!1===t.options.singleQuote||t.implicitKey&&e.includes("\n")||/[ \t]\n|\n[ \t]/.test(e))return Wb(e,t);const n=t.indent||(jb(e)?" ":""),i="'"+e.replace(/'/g,"''").replace(/\n+/g,`$&\n${n}`)+"'";return t.implicitKey?i:Lb(i,n,Pb,Fb(t,!1))}function Vb(e,t){const{singleQuote:n}=t.options;let i;if(!1===n)i=Wb;else{const t=e.includes('"'),s=e.includes("'");i=t&&!s?Ub:s&&!t?Wb:n?Ub:Wb}return i(e,t)}let Hb;try{Hb=new RegExp("(^|(?<!\n))\n+(?!\n|$)","g")}catch{Hb=/\n+(?!\n|$)/g}function qb({comment:e,type:t,value:n},i,s,r){const{blockQuote:o,commentString:a,lineWidth:l}=i.options;if(!o||/\n[\t ]+$/.test(n))return Vb(n,i);const c=i.indent||(i.forceBlockIndent||jb(n)?" ":""),h="literal"===o||"folded"!==o&&t!==Nb.BLOCK_FOLDED&&(t===Nb.BLOCK_LITERAL||!function(e,t,n){if(!t||t<0)return!1;const i=t-n,s=e.length;if(s<=i)return!1;for(let t=0,n=0;t<s;++t)if("\n"===e[t]){if(t-n>i)return!0;if(n=t+1,s-n<=i)return!1}return!0}(n,l,c.length));if(!n)return h?"|\n":">\n";let u,d;for(d=n.length;d>0;--d){const e=n[d-1];if("\n"!==e&&"\t"!==e&&" "!==e)break}let f=n.substring(d);const p=f.indexOf("\n");-1===p?u="-":n===f||p!==f.length-1?(u="+",r&&r()):u="",f&&(n=n.slice(0,-f.length),"\n"===f[f.length-1]&&(f=f.slice(0,-1)),f=f.replace(Hb,`$&${c}`));let m,g=!1,b=-1;for(m=0;m<n.length;++m){const e=n[m];if(" "===e)g=!0;else{if("\n"!==e)break;b=m}}let y=n.substring(0,b<m?b+1:m);y&&(n=n.substring(y.length),y=y.replace(/\n+/g,`$&${c}`));let v=(g?c?"2":"1":"")+u;if(e&&(v+=" "+a(e.replace(/ ?[\r\n]+/g," ")),s&&s()),!h){const e=n.replace(/\n+/g,"\n$&").replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`);let s=!1;const r=Fb(i,!0);"folded"!==o&&t!==Nb.BLOCK_FOLDED&&(r.onOverflow=()=>{s=!0});const a=Lb(`${y}${e}${f}`,c,Rb,r);if(!s)return`>${v}\n${c}${a}`}return`|${v}\n${c}${y}${n=n.replace(/\n+/g,`$&${c}`)}${f}`}function Kb(e,t,n,i){const{implicitKey:s,inFlow:r}=t,o="string"==typeof e.value?e:Object.assign({},e,{value:String(e.value)});let{type:a}=e;a!==Nb.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(a=Nb.QUOTE_DOUBLE);const l=e=>{switch(e){case Nb.BLOCK_FOLDED:case Nb.BLOCK_LITERAL:return s||r?Vb(o.value,t):qb(o,t,n,i);case Nb.QUOTE_DOUBLE:return Wb(o.value,t);case Nb.QUOTE_SINGLE:return Ub(o.value,t);case Nb.PLAIN:return function(e,t,n,i){const{type:s,value:r}=e,{actualString:o,implicitKey:a,indent:l,indentStep:c,inFlow:h}=t;if(a&&r.includes("\n")||h&&/[[\]{},]/.test(r))return Vb(r,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(r))return a||h||!r.includes("\n")?Vb(r,t):qb(e,t,n,i);if(!a&&!h&&s!==Nb.PLAIN&&r.includes("\n"))return qb(e,t,n,i);if(jb(r)){if(""===l)return t.forceBlockIndent=!0,qb(e,t,n,i);if(a&&l===c)return Vb(r,t)}const u=r.replace(/\n+/g,`$&\n${l}`);if(o){const e=e=>e.default&&"tag:yaml.org,2002:str"!==e.tag&&e.test?.test(u),{compat:n,tags:i}=t.doc.schema;if(i.some(e)||n?.some(e))return Vb(r,t)}return a?u:Lb(u,l,Pb,Fb(t,!1))}(o,t,n,i);default:return null}};let c=l(a);if(null===c){const{defaultKeyType:e,defaultStringType:n}=t.options,i=s&&e||n;if(c=l(i),null===c)throw new Error(`Unsupported default string type ${i}`)}return c}function Jb(e,t){const n=Object.assign({blockQuote:!0,commentString:_b,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},e.schema.toStringOptions,t);let i;switch(n.collectionStyle){case"block":i=!1;break;case"flow":i=!0;break;default:i=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?" ":"",indent:"",indentStep:"number"==typeof n.indent?" ".repeat(n.indent):" ",inFlow:i,options:n}}function Zb(e,t,n,i){if(sb(e))return e.toString(t,n,i);if(tb(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw new TypeError("Cannot stringify circular structure without alias nodes");t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let s;const r=lb(e)?e:t.doc.createNode(e,{onTagObj:e=>s=e});s??(s=function(e,t){if(t.tag){const n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let n,i;if(rb(t)){i=t.value;let s=e.filter(e=>e.identify?.(i));if(s.length>1){const e=s.filter(e=>e.test);e.length>0&&(s=e)}n=s.find(e=>e.format===t.format)??s.find(e=>!e.format)}else i=t,n=e.find(e=>e.nodeClass&&i instanceof e.nodeClass);if(!n)throw new Error(`Tag not resolved for ${i?.constructor?.name??(null===i?"null":typeof i)} value`);return n}(t.doc.schema.tags,r));const o=function(e,t,{anchors:n,doc:i}){if(!i.directives)return"";const s=[],r=(rb(e)||ab(e))&&e.anchor;r&&yb(r)&&(n.add(r),s.push(`&${r}`));const o=e.tag??(t.default?null:t.tag);return o&&s.push(i.directives.tagString(o)),s.join(" ")}(r,s,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);const a="function"==typeof s.stringify?s.stringify(r,t,n,i):rb(r)?Kb(r,t,n,i):r.toString(t,n,i);return o?rb(r)||"{"===a[0]||"["===a[0]?`${o} ${a}`:`${o}\n${t.indent}${a}`:a}const Yb="<<",Gb={identify:e=>e===Yb||"symbol"==typeof e&&e.description===Yb,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Nb(Symbol(Yb)),{addToJSMap:Qb}),stringify:()=>Yb};function Qb(e,t,n){if(n=e&&tb(n)?n.resolve(e.doc):n,ob(n))for(const i of n.items)Xb(e,t,i);else if(Array.isArray(n))for(const i of n)Xb(e,t,i);else Xb(e,t,n)}function Xb(e,t,n){const i=e&&tb(n)?n.resolve(e.doc):n;if(!ib(i))throw new Error("Merge sources must be maps or map aliases");const s=i.toJSON(null,e,Map);for(const[e,n]of s)t instanceof Map?t.has(e)||t.set(e,n):t instanceof Set?t.add(e):Object.prototype.hasOwnProperty.call(t,e)||Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0});return t}function ey(e,t,{key:n,value:i}){if(lb(n)&&n.addToJSMap)n.addToJSMap(e,t,i);else if(((e,t)=>(Gb.identify(t)||rb(t)&&(!t.type||t.type===Nb.PLAIN)&&Gb.identify(t.value))&&e?.doc.schema.tags.some(e=>e.tag===Gb.tag&&e.default))(e,n))Qb(e,t,i);else{const s=xb(n,"",e);if(t instanceof Map)t.set(s,xb(i,s,e));else if(t instanceof Set)t.add(s);else{const r=function(e,t,n){if(null===t)return"";if("object"!=typeof t)return String(t);if(lb(e)&&n?.doc){const t=Jb(n.doc,{});t.anchors=new Set;for(const e of n.anchors.keys())t.anchors.add(e.anchor);t.inFlow=!0,t.inStringifyKey=!0;const r=e.toString(t);if(!n.mapKeyWarned){let e=JSON.stringify(r);e.length>40&&(e=e.substring(0,36)+'..."'),i=n.doc.options.logLevel,s=`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`,"debug"!==i&&"warn"!==i||console.warn(s),n.mapKeyWarned=!0}return r}var i,s;return JSON.stringify(t)}(n,s,e),o=xb(i,r,e);r in t?Object.defineProperty(t,r,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[r]=o}}return t}function ty(e,t,n){const i=Ob(e,void 0,n),s=Ob(t,void 0,n);return new ny(i,s)}class ny{constructor(e,t=null){Object.defineProperty(this,eb,{value:Gg}),this.key=e,this.value=t}clone(e){let{key:t,value:n}=this;return lb(t)&&(t=t.clone(e)),lb(n)&&(n=n.clone(e)),new ny(t,n)}toJSON(e,t){return ey(t,t?.mapAsMap?new Map:{},this)}toString(e,t,n){return e?.doc?function({key:e,value:t},n,i,s){const{allNullValues:r,doc:o,indent:a,indentStep:l,options:{commentString:c,indentSeq:h,simpleKeys:u}}=n;let d=lb(e)&&e.comment||null;if(u){if(d)throw new Error("With simple keys, key nodes cannot have comments");if(ab(e)||!lb(e)&&"object"==typeof e)throw new Error("With simple keys, collection cannot be used as a key value")}let f=!u&&(!e||d&&null==t&&!n.inFlow||ab(e)||(rb(e)?e.type===Nb.BLOCK_FOLDED||e.type===Nb.BLOCK_LITERAL:"object"==typeof e));n=Object.assign({},n,{allNullValues:!1,implicitKey:!f&&(u||!r),indent:a+l});let p,m,g,b=!1,y=!1,v=Zb(e,n,()=>b=!0,()=>y=!0);if(!f&&!n.inFlow&&v.length>1024){if(u)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");f=!0}if(n.inFlow){if(r||null==t)return b&&i&&i(),""===v?"?":f?`? ${v}`:v}else if(r&&!u||null==t&&f)return v=`? ${v}`,d&&!b?v+=Bb(v,n.indent,c(d)):y&&s&&s(),v;b&&(d=null),f?(d&&(v+=Bb(v,n.indent,c(d))),v=`? ${v}\n${a}:`):(v=`${v}:`,d&&(v+=Bb(v,n.indent,c(d)))),lb(t)?(p=!!t.spaceBefore,m=t.commentBefore,g=t.comment):(p=!1,m=null,g=null,t&&"object"==typeof t&&(t=o.createNode(t))),n.implicitKey=!1,f||d||!rb(t)||(n.indentAtStart=v.length+1),y=!1,h||!(l.length>=2)||n.inFlow||f||!ob(t)||t.flow||t.tag||t.anchor||(n.indent=n.indent.substring(2));let k=!1;const w=Zb(t,n,()=>k=!0,()=>y=!0);let x=" ";if(d||p||m)x=p?"\n":"",m&&(x+=`\n${Ib(c(m),n.indent)}`),""!==w||n.inFlow?x+=`\n${n.indent}`:"\n"===x&&g&&(x="\n\n");else if(!f&&ab(t)){const e=w[0],i=w.indexOf("\n"),s=-1!==i,r=n.inFlow??t.flow??0===t.items.length;if(s||!r){let t=!1;if(s&&("&"===e||"!"===e)){let n=w.indexOf(" ");"&"===e&&-1!==n&&n<i&&"!"===w[n+1]&&(n=w.indexOf(" ",n+1)),(-1===n||i<n)&&(t=!0)}t||(x=`\n${n.indent}`)}}else""!==w&&"\n"!==w[0]||(x="");return v+=x+w,n.inFlow?k&&i&&i():g&&!k?v+=Bb(v,n.indent,c(g)):y&&s&&s(),v}(this,e,t,n):JSON.stringify(this)}}function iy(e,t,n){return(t.inFlow??e.flow?ry:sy)(e,t,n)}function sy({comment:e,items:t},n,{blockItemPrefix:i,flowChars:s,itemIndent:r,onChompKeep:o,onComment:a}){const{indent:l,options:{commentString:c}}=n,h=Object.assign({},n,{indent:r,type:null});let u=!1;const d=[];for(let e=0;e<t.length;++e){const s=t[e];let o=null;if(lb(s))!u&&s.spaceBefore&&d.push(""),oy(n,d,s.commentBefore,u),s.comment&&(o=s.comment);else if(sb(s)){const e=lb(s.key)?s.key:null;e&&(!u&&e.spaceBefore&&d.push(""),oy(n,d,e.commentBefore,u))}u=!1;let a=Zb(s,h,()=>o=null,()=>u=!0);o&&(a+=Bb(a,r,c(o))),u&&o&&(u=!1),d.push(i+a)}let f;if(0===d.length)f=s.start+s.end;else{f=d[0];for(let e=1;e<d.length;++e){const t=d[e];f+=t?`\n${l}${t}`:"\n"}}return e?(f+="\n"+Ib(c(e),l),a&&a()):u&&o&&o(),f}function ry({items:e},t,{flowChars:n,itemIndent:i}){const{indent:s,indentStep:r,flowCollectionPadding:o,options:{commentString:a}}=t;i+=r;const l=Object.assign({},t,{indent:i,inFlow:!0,type:null});let c=!1,h=0;const u=[];for(let n=0;n<e.length;++n){const s=e[n];let r=null;if(lb(s))s.spaceBefore&&u.push(""),oy(t,u,s.commentBefore,!1),s.comment&&(r=s.comment);else if(sb(s)){const e=lb(s.key)?s.key:null;e&&(e.spaceBefore&&u.push(""),oy(t,u,e.commentBefore,!1),e.comment&&(c=!0));const n=lb(s.value)?s.value:null;n?(n.comment&&(r=n.comment),n.commentBefore&&(c=!0)):null==s.value&&e?.comment&&(r=e.comment)}r&&(c=!0);let o=Zb(s,l,()=>r=null);c||(c=u.length>h||o.includes("\n")),n<e.length-1?o+=",":t.options.trailingComma&&(t.options.lineWidth>0&&(c||(c=u.reduce((e,t)=>e+t.length+2,2)+(o.length+2)>t.options.lineWidth)),c&&(o+=",")),r&&(o+=Bb(o,i,a(r))),u.push(o),h=u.length}const{start:d,end:f}=n;if(0===u.length)return d+f;if(!c){const e=u.reduce((e,t)=>e+t.length+2,2);c=t.options.lineWidth>0&&e>t.options.lineWidth}if(c){let e=d;for(const t of u)e+=t?`\n${r}${s}${t}`:"\n";return`${e}\n${s}${f}`}return`${d}${o}${u.join(" ")}${o}${f}`}function oy({indent:e,options:{commentString:t}},n,i,s){if(i&&s&&(i=i.replace(/^\n+/,"")),i){const s=Ib(t(i),e);n.push(s.trimStart())}}function ay(e,t){const n=rb(t)?t.value:t;for(const i of e)if(sb(i)){if(i.key===t||i.key===n)return i;if(rb(i.key)&&i.key.value===n)return i}}class ly extends Db{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Yg,e),this.items=[]}static from(e,t,n){const{keepUndefined:i,replacer:s}=n,r=new this(e),o=(e,o)=>{if("function"==typeof s)o=s.call(t,e,o);else if(Array.isArray(s)&&!s.includes(e))return;(void 0!==o||i)&&r.items.push(ty(e,o,n))};if(t instanceof Map)for(const[e,n]of t)o(e,n);else if(t&&"object"==typeof t)for(const e of Object.keys(t))o(e,t[e]);return"function"==typeof e.sortMapEntries&&r.items.sort(e.sortMapEntries),r}add(e,t){let n;n=sb(e)?e:e&&"object"==typeof e&&"key"in e?new ny(e.key,e.value):new ny(e,e?.value);const i=ay(this.items,n.key),s=this.schema?.sortMapEntries;if(i){if(!t)throw new Error(`Key ${n.key} already set`);rb(i.value)&&Tb(n.value)?i.value.value=n.value:i.value=n.value}else if(s){const e=this.items.findIndex(e=>s(n,e)<0);-1===e?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){const t=ay(this.items,e);if(!t)return!1;return this.items.splice(this.items.indexOf(t),1).length>0}get(e,t){const n=ay(this.items,e),i=n?.value;return(!t&&rb(i)?i.value:i)??void 0}has(e){return!!ay(this.items,e)}set(e,t){this.add(new ny(e,t),!0)}toJSON(e,t,n){const i=n?new n:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(i);for(const e of this.items)ey(t,i,e);return i}toString(e,t,n){if(!e)return JSON.stringify(this);for(const e of this.items)if(!sb(e))throw new Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),iy(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:n,onComment:t})}}const cy={collection:"map",default:!0,nodeClass:ly,tag:"tag:yaml.org,2002:map",resolve:(e,t)=>(ib(e)||t("Expected a mapping for this tag"),e),createNode:(e,t,n)=>ly.from(e,t,n)};class hy extends Db{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(Xg,e),this.items=[]}add(e){this.items.push(e)}delete(e){const t=uy(e);if("number"!=typeof t)return!1;return this.items.splice(t,1).length>0}get(e,t){const n=uy(e);if("number"!=typeof n)return;const i=this.items[n];return!t&&rb(i)?i.value:i}has(e){const t=uy(e);return"number"==typeof t&&t<this.items.length}set(e,t){const n=uy(e);if("number"!=typeof n)throw new Error(`Expected a valid index, not ${e}.`);const i=this.items[n];rb(i)&&Tb(t)?i.value=t:this.items[n]=t}toJSON(e,t){const n=[];t?.onCreate&&t.onCreate(n);let i=0;for(const e of this.items)n.push(xb(e,String(i++),t));return n}toString(e,t,n){return e?iy(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:n,onComment:t}):JSON.stringify(this)}static from(e,t,n){const{replacer:i}=n,s=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let r of t){if("function"==typeof i){const n=t instanceof Set?r:String(e++);r=i.call(t,n,r)}s.items.push(Ob(r,void 0,n))}}return s}}function uy(e){let t=rb(e)?e.value:e;return t&&"string"==typeof t&&(t=Number(t)),"number"==typeof t&&Number.isInteger(t)&&t>=0?t:null}const dy={collection:"seq",default:!0,nodeClass:hy,tag:"tag:yaml.org,2002:seq",resolve:(e,t)=>(ob(e)||t("Expected a sequence for this tag"),e),createNode:(e,t,n)=>hy.from(e,t,n)},fy={identify:e=>"string"==typeof e,default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:(e,t,n,i)=>Kb(e,t=Object.assign({actualString:!0},t),n,i)},py={identify:e=>null==e,createNode:()=>new Nb(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Nb(null),stringify:({source:e},t)=>"string"==typeof e&&py.test.test(e)?e:t.options.nullStr},my={identify:e=>"boolean"==typeof e,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new Nb("t"===e[0]||"T"===e[0]),stringify({source:e,value:t},n){if(e&&my.test.test(e)){if(t===("t"===e[0]||"T"===e[0]))return e}return t?n.options.trueStr:n.options.falseStr}};function gy({format:e,minFractionDigits:t,tag:n,value:i}){if("bigint"==typeof i)return String(i);const s="number"==typeof i?i:Number(i);if(!isFinite(s))return isNaN(s)?".nan":s<0?"-.inf":".inf";let r=Object.is(i,-0)?"-0":JSON.stringify(i);if(!e&&t&&(!n||"tag:yaml.org,2002:float"===n)&&/^\d/.test(r)){let e=r.indexOf(".");e<0&&(e=r.length,r+=".");let n=t-(r.length-e-1);for(;n-- >0;)r+="0"}return r}const by={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>"nan"===e.slice(-3).toLowerCase()?NaN:"-"===e[0]?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:gy},yy={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){const t=Number(e.value);return isFinite(t)?t.toExponential():gy(e)}},vy={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){const t=new Nb(parseFloat(e)),n=e.indexOf(".");return-1!==n&&"0"===e[e.length-1]&&(t.minFractionDigits=e.length-n-1),t},stringify:gy},ky=e=>"bigint"==typeof e||Number.isInteger(e),wy=(e,t,n,{intAsBigInt:i})=>i?BigInt(e):parseInt(e.substring(t),n);function xy(e,t,n){const{value:i}=e;return ky(i)&&i>=0?n+i.toString(t):gy(e)}const Sy={identify:e=>ky(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,n)=>wy(e,2,8,n),stringify:e=>xy(e,8,"0o")},Cy={identify:ky,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>wy(e,0,10,n),stringify:gy},Ay={identify:e=>ky(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>wy(e,2,16,n),stringify:e=>xy(e,16,"0x")},Ty=[cy,dy,fy,py,my,Sy,Cy,Ay,by,yy,vy];function Ny(e){return"bigint"==typeof e||Number.isInteger(e)}const Oy=({value:e})=>JSON.stringify(e),My=[cy,dy].concat([{identify:e=>"string"==typeof e,default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:Oy},{identify:e=>null==e,createNode:()=>new Nb(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Oy},{identify:e=>"boolean"==typeof e,default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:e=>"true"===e,stringify:Oy},{identify:Ny,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>Ny(e)?e.toString():JSON.stringify(e)},{identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:Oy}],{default:!0,tag:"",test:/^/,resolve:(e,t)=>(t(`Unresolved plain scalar ${JSON.stringify(e)}`),e)}),Ey={identify:e=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if("function"==typeof atob){const t=atob(e.replace(/[\n\r]/g,"")),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n[e]=t.charCodeAt(e);return n}return t("This environment does not support reading binary tags; either Buffer or atob is required"),e},stringify({comment:e,type:t,value:n},i,s,r){if(!n)return"";const o=n;let a;if("function"!=typeof btoa)throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");{let e="";for(let t=0;t<o.length;++t)e+=String.fromCharCode(o[t]);a=btoa(e)}if(t??(t=Nb.BLOCK_LITERAL),t!==Nb.QUOTE_DOUBLE){const e=Math.max(i.options.lineWidth-i.indent.length,i.options.minContentWidth),n=Math.ceil(a.length/e),s=new Array(n);for(let t=0,i=0;t<n;++t,i+=e)s[t]=a.substr(i,e);a=s.join(t===Nb.BLOCK_LITERAL?"\n":" ")}return Kb({comment:e,type:t,value:a},i,s,r)}};function Dy(e,t){if(ob(e))for(let n=0;n<e.items.length;++n){let i=e.items[n];if(!sb(i)){if(ib(i)){i.items.length>1&&t("Each pair must have its own sequence indicator");const e=i.items[0]||new ny(new Nb(null));if(i.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${i.commentBefore}\n${e.key.commentBefore}`:i.commentBefore),i.comment){const t=e.value??e.key;t.comment=t.comment?`${i.comment}\n${t.comment}`:i.comment}i=e}e.items[n]=sb(i)?i:new ny(i)}}else t("Expected a sequence for this tag");return e}function _y(e,t,n){const{replacer:i}=n,s=new hy(e);s.tag="tag:yaml.org,2002:pairs";let r=0;if(t&&Symbol.iterator in Object(t))for(let e of t){let o,a;if("function"==typeof i&&(e=i.call(t,String(r++),e)),Array.isArray(e)){if(2!==e.length)throw new TypeError(`Expected [key, value] tuple: ${e}`);o=e[0],a=e[1]}else if(e&&e instanceof Object){const t=Object.keys(e);if(1!==t.length)throw new TypeError(`Expected tuple with one key, not ${t.length} keys`);o=t[0],a=e[o]}else o=e;s.items.push(ty(o,a,n))}return s}const Iy={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Dy,createNode:_y};class By extends hy{constructor(){super(),this.add=ly.prototype.add.bind(this),this.delete=ly.prototype.delete.bind(this),this.get=ly.prototype.get.bind(this),this.has=ly.prototype.has.bind(this),this.set=ly.prototype.set.bind(this),this.tag=By.tag}toJSON(e,t){if(!t)return super.toJSON(e);const n=new Map;t?.onCreate&&t.onCreate(n);for(const e of this.items){let i,s;if(sb(e)?(i=xb(e.key,"",t),s=xb(e.value,i,t)):i=xb(e,"",t),n.has(i))throw new Error("Ordered maps must not include duplicate keys");n.set(i,s)}return n}static from(e,t,n){const i=_y(e,t,n),s=new this;return s.items=i.items,s}}By.tag="tag:yaml.org,2002:omap";const Py={collection:"seq",identify:e=>e instanceof Map,nodeClass:By,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){const n=Dy(e,t),i=[];for(const{key:e}of n.items)rb(e)&&(i.includes(e.value)?t(`Ordered maps must not include duplicate keys: ${e.value}`):i.push(e.value));return Object.assign(new By,n)},createNode:(e,t,n)=>By.from(e,t,n)};function Ry({value:e,source:t},n){return t&&(e?$y:Ly).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}const $y={identify:e=>!0===e,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Nb(!0),stringify:Ry},Ly={identify:e=>!1===e,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Nb(!1),stringify:Ry},zy={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>"nan"===e.slice(-3).toLowerCase()?NaN:"-"===e[0]?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:gy},Fy={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,"")),stringify(e){const t=Number(e.value);return isFinite(t)?t.toExponential():gy(e)}},jy={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){const t=new Nb(parseFloat(e.replace(/_/g,""))),n=e.indexOf(".");if(-1!==n){const i=e.substring(n+1).replace(/_/g,"");"0"===i[i.length-1]&&(t.minFractionDigits=i.length)}return t},stringify:gy},Wy=e=>"bigint"==typeof e||Number.isInteger(e);function Uy(e,t,n,{intAsBigInt:i}){const s=e[0];if("-"!==s&&"+"!==s||(t+=1),e=e.substring(t).replace(/_/g,""),i){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`}const t=BigInt(e);return"-"===s?BigInt(-1)*t:t}const r=parseInt(e,n);return"-"===s?-1*r:r}function Vy(e,t,n){const{value:i}=e;if(Wy(i)){const e=i.toString(t);return i<0?"-"+n+e.substr(1):n+e}return gy(e)}const Hy={identify:Wy,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>Uy(e,2,2,n),stringify:e=>Vy(e,2,"0b")},qy={identify:Wy,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>Uy(e,1,8,n),stringify:e=>Vy(e,8,"0")},Ky={identify:Wy,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>Uy(e,0,10,n),stringify:gy},Jy={identify:Wy,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>Uy(e,2,16,n),stringify:e=>Vy(e,16,"0x")};class Zy extends ly{constructor(e){super(e),this.tag=Zy.tag}add(e){let t;t=sb(e)?e:e&&"object"==typeof e&&"key"in e&&"value"in e&&null===e.value?new ny(e.key,null):new ny(e,null);ay(this.items,t.key)||this.items.push(t)}get(e,t){const n=ay(this.items,e);return!t&&sb(n)?rb(n.key)?n.key.value:n.key:n}set(e,t){if("boolean"!=typeof t)throw new Error("Expected boolean value for set(key, value) in a YAML set, not "+typeof t);const n=ay(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new ny(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw new Error("Set items must all have null values")}static from(e,t,n){const{replacer:i}=n,s=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)"function"==typeof i&&(e=i.call(t,e,e)),s.items.push(ty(e,null,n));return s}}Zy.tag="tag:yaml.org,2002:set";const Yy={collection:"map",identify:e=>e instanceof Set,nodeClass:Zy,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,n)=>Zy.from(e,t,n),resolve(e,t){if(ib(e)){if(e.hasAllNullValues(!0))return Object.assign(new Zy,e);t("Set items must all have null values")}else t("Expected a mapping for this tag");return e}};function Gy(e,t){const n=e[0],i="-"===n||"+"===n?e.substring(1):e,s=e=>t?BigInt(e):Number(e),r=i.replace(/_/g,"").split(":").reduce((e,t)=>e*s(60)+s(t),s(0));return"-"===n?s(-1)*r:r}function Qy(e){let{value:t}=e,n=e=>e;if("bigint"==typeof t)n=e=>BigInt(e);else if(isNaN(t)||!isFinite(t))return gy(e);let i="";t<0&&(i="-",t*=n(-1));const s=n(60),r=[t%s];return t<60?r.unshift(0):(t=(t-r[0])/s,r.unshift(t%s),t>=60&&(t=(t-r[0])/s,r.unshift(t))),i+r.map(e=>String(e).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}const Xy={identify:e=>"bigint"==typeof e||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:n})=>Gy(e,n),stringify:Qy},ev={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>Gy(e,!1),stringify:Qy},tv={identify:e=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){const t=e.match(tv.test);if(!t)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");const[,n,i,s,r,o,a]=t.map(Number),l=t[7]?Number((t[7]+"00").substr(1,3)):0;let c=Date.UTC(n,i-1,s,r||0,o||0,a||0,l);const h=t[8];if(h&&"Z"!==h){let e=Gy(h,!1);Math.abs(e)<30&&(e*=60),c-=6e4*e}return new Date(c)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""},nv=[cy,dy,fy,py,$y,Ly,Hy,qy,Ky,Jy,zy,Fy,jy,Ey,Gb,Py,Iy,Yy,Xy,ev,tv],iv=new Map([["core",Ty],["failsafe",[cy,dy,fy]],["json",My],["yaml11",nv],["yaml-1.1",nv]]),sv={binary:Ey,bool:my,float:vy,floatExp:yy,floatNaN:by,floatTime:ev,int:Cy,intHex:Ay,intOct:Sy,intTime:Xy,map:cy,merge:Gb,null:py,omap:Py,pairs:Iy,seq:dy,set:Yy,timestamp:tv},rv={"tag:yaml.org,2002:binary":Ey,"tag:yaml.org,2002:merge":Gb,"tag:yaml.org,2002:omap":Py,"tag:yaml.org,2002:pairs":Iy,"tag:yaml.org,2002:set":Yy,"tag:yaml.org,2002:timestamp":tv};function ov(e,t,n){const i=iv.get(t);if(i&&!e)return n&&!i.includes(Gb)?i.concat(Gb):i.slice();let s=i;if(!s){if(!Array.isArray(e)){const e=Array.from(iv.keys()).filter(e=>"yaml11"!==e).map(e=>JSON.stringify(e)).join(", ");throw new Error(`Unknown schema "${t}"; use one of ${e} or define customTags array`)}s=[]}if(Array.isArray(e))for(const t of e)s=s.concat(t);else"function"==typeof e&&(s=e(s.slice()));return n&&(s=s.concat(Gb)),s.reduce((e,t)=>{const n="string"==typeof t?sv[t]:t;if(!n){const e=JSON.stringify(t),n=Object.keys(sv).map(e=>JSON.stringify(e)).join(", ");throw new Error(`Unknown custom tag ${e}; use one of ${n}`)}return e.includes(n)||e.push(n),e},[])}const av=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0;class lv{constructor({compat:e,customTags:t,merge:n,resolveKnownTags:i,schema:s,sortMapEntries:r,toStringDefaults:o}){this.compat=Array.isArray(e)?ov(e,"compat"):e?ov(null,e):null,this.name="string"==typeof s&&s||"core",this.knownTags=i?rv:{},this.tags=ov(t,this.name,n),this.toStringOptions=o??null,Object.defineProperty(this,Yg,{value:cy}),Object.defineProperty(this,Qg,{value:fy}),Object.defineProperty(this,Xg,{value:dy}),this.sortMapEntries="function"==typeof r?r:!0===r?av:null}clone(){const e=Object.create(lv.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}let cv=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,eb,{value:Zg});let i=null;"function"==typeof t||Array.isArray(t)?i=t:void 0===n&&t&&(n=t,t=void 0);const s=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},n);this.options=s;let{version:r}=s;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(r=this.directives.yaml.version)):this.directives=new bb({version:r}),this.setSchema(r,n),this.contents=void 0===e?null:this.createNode(e,i,n)}clone(){const t=Object.create(e.prototype,{[eb]:{value:Zg}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=lb(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){hv(this.contents)&&this.contents.add(e)}addIn(e,t){hv(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){const n=vb(this);e.anchor=!t||n.has(t)?kb(t||"a",n):t}return new Cb(e.anchor)}createNode(e,t,n){let i;if("function"==typeof t)e=t.call({"":e},"",e),i=t;else if(Array.isArray(t)){const e=e=>"number"==typeof e||e instanceof String||e instanceof Number,n=t.filter(e).map(String);n.length>0&&(t=t.concat(n)),i=t}else void 0===n&&t&&(n=t,t=void 0);const{aliasDuplicateObjects:s,anchorPrefix:r,flow:o,keepUndefined:a,onTagObj:l,tag:c}=n??{},{onAnchor:h,setAnchors:u,sourceObjects:d}=function(e,t){const n=[],i=new Map;let s=null;return{onAnchor:i=>{n.push(i),s??(s=vb(e));const r=kb(t,s);return s.add(r),r},setAnchors:()=>{for(const e of n){const t=i.get(e);if("object"!=typeof t||!t.anchor||!rb(t.node)&&!ab(t.node)){const t=new Error("Failed to resolve repeated object (this should not happen)");throw t.source=e,t}t.node.anchor=t.anchor}},sourceObjects:i}}(this,r||"a"),f=Ob(e,c,{aliasDuplicateObjects:s??!0,keepUndefined:a??!1,onAnchor:h,onTagObj:l,replacer:i,schema:this.schema,sourceObjects:d});return o&&ab(f)&&(f.flow=!0),u(),f}createPair(e,t,n={}){const i=this.createNode(e,null,n),s=this.createNode(t,null,n);return new ny(i,s)}delete(e){return!!hv(this.contents)&&this.contents.delete(e)}deleteIn(e){return Eb(e)?null!=this.contents&&(this.contents=null,!0):!!hv(this.contents)&&this.contents.deleteIn(e)}get(e,t){return ab(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return Eb(e)?!t&&rb(this.contents)?this.contents.value:this.contents:ab(this.contents)?this.contents.getIn(e,t):void 0}has(e){return!!ab(this.contents)&&this.contents.has(e)}hasIn(e){return Eb(e)?void 0!==this.contents:!!ab(this.contents)&&this.contents.hasIn(e)}set(e,t){null==this.contents?this.contents=Mb(this.schema,[e],t):hv(this.contents)&&this.contents.set(e,t)}setIn(e,t){Eb(e)?this.contents=t:null==this.contents?this.contents=Mb(this.schema,Array.from(e),t):hv(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){let n;switch("number"==typeof e&&(e=String(e)),e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new bb({version:"1.1"}),n={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new bb({version:e}),n={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,n=null;break;default:{const t=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else{if(!n)throw new Error("With a null YAML version, the { schema: Schema } option is required");this.schema=new lv(Object.assign(n,t))}}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:i,onAnchor:s,reviver:r}={}){const o={anchors:new Map,doc:this,keep:!e,mapAsMap:!0===n,mapKeyWarned:!1,maxAliasCount:"number"==typeof i?i:100},a=xb(this.contents,t??"",o);if("function"==typeof s)for(const{count:e,res:t}of o.anchors.values())s(t,e);return"function"==typeof r?wb(r,{"":a},"",a):a}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){const t=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${t}`)}return function(e,t){const n=[];let i=!0===t.directives;if(!1!==t.directives&&e.directives){const t=e.directives.toString(e);t?(n.push(t),i=!0):e.directives.docStart&&(i=!0)}i&&n.push("---");const s=Jb(e,t),{commentString:r}=s.options;if(e.commentBefore){1!==n.length&&n.unshift("");const t=r(e.commentBefore);n.unshift(Ib(t,""))}let o=!1,a=null;if(e.contents){if(lb(e.contents)){if(e.contents.spaceBefore&&i&&n.push(""),e.contents.commentBefore){const t=r(e.contents.commentBefore);n.push(Ib(t,""))}s.forceBlockIndent=!!e.comment,a=e.contents.comment}const t=a?void 0:()=>o=!0;let l=Zb(e.contents,s,()=>a=null,t);a&&(l+=Bb(l,"",r(a))),"|"!==l[0]&&">"!==l[0]||"---"!==n[n.length-1]?n.push(l):n[n.length-1]=`--- ${l}`}else n.push(Zb(e.contents,s));if(e.directives?.docEnd)if(e.comment){const t=r(e.comment);t.includes("\n")?(n.push("..."),n.push(Ib(t,""))):n.push(`... ${t}`)}else n.push("...");else{let t=e.comment;t&&o&&(t=t.replace(/^\n+/,"")),t&&(o&&!a||""===n[n.length-1]||n.push(""),n.push(Ib(r(t),"")))}return n.join("\n")+"\n"}(this,e)}};function hv(e){if(ab(e))return!0;throw new Error("Expected a YAML collection as document contents")}class uv extends Error{constructor(e,t,n,i){super(),this.name=e,this.code=n,this.message=i,this.pos=t}}class dv extends uv{constructor(e,t,n){super("YAMLParseError",e,t,n)}}class fv extends uv{constructor(e,t,n){super("YAMLWarning",e,t,n)}}const pv=(e,t)=>n=>{if(-1===n.pos[0])return;n.linePos=n.pos.map(e=>t.linePos(e));const{line:i,col:s}=n.linePos[0];n.message+=` at line ${i}, column ${s}`;let r=s-1,o=e.substring(t.lineStarts[i-1],t.lineStarts[i]).replace(/[\n\r]+$/,"");if(r>=60&&o.length>80){const e=Math.min(r-39,o.length-79);o="…"+o.substring(e),r-=e-1}if(o.length>80&&(o=o.substring(0,79)+"…"),i>1&&/^ *$/.test(o.substring(0,r))){let n=e.substring(t.lineStarts[i-2],t.lineStarts[i-1]);n.length>80&&(n=n.substring(0,79)+"…\n"),o=n+o}if(/[^ ]/.test(o)){let e=1;const t=n.linePos[1];t?.line===i&&t.col>s&&(e=Math.max(1,Math.min(t.col-s,80-r)));const a=" ".repeat(r)+"^".repeat(e);n.message+=`:\n\n${o}\n${a}\n`}};function mv(e,{flow:t,indicator:n,next:i,offset:s,onError:r,parentIndent:o,startOnNewline:a}){let l=!1,c=a,h=a,u="",d="",f=!1,p=!1,m=null,g=null,b=null,y=null,v=null,k=null,w=null;for(const s of e)switch(p&&("space"!==s.type&&"newline"!==s.type&&"comma"!==s.type&&r(s.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),p=!1),m&&(c&&"comment"!==s.type&&"newline"!==s.type&&r(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),m=null),s.type){case"space":t||"doc-start"===n&&"flow-collection"===i?.type||!s.source.includes("\t")||(m=s),h=!0;break;case"comment":{h||r(s,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");const e=s.source.substring(1)||" ";u?u+=d+e:u=e,d="",c=!1;break}case"newline":c?u?u+=s.source:k&&"seq-item-ind"===n||(l=!0):d+=s.source,c=!0,f=!0,(g||b)&&(y=s),h=!0;break;case"anchor":g&&r(s,"MULTIPLE_ANCHORS","A node can have at most one anchor"),s.source.endsWith(":")&&r(s.offset+s.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),g=s,w??(w=s.offset),c=!1,h=!1,p=!0;break;case"tag":b&&r(s,"MULTIPLE_TAGS","A node can have at most one tag"),b=s,w??(w=s.offset),c=!1,h=!1,p=!0;break;case n:(g||b)&&r(s,"BAD_PROP_ORDER",`Anchors and tags must be after the ${s.source} indicator`),k&&r(s,"UNEXPECTED_TOKEN",`Unexpected ${s.source} in ${t??"collection"}`),k=s,c="seq-item-ind"===n||"explicit-key-ind"===n,h=!1;break;case"comma":if(t){v&&r(s,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`),v=s,c=!1,h=!1;break}default:r(s,"UNEXPECTED_TOKEN",`Unexpected ${s.type} token`),c=!1,h=!1}const x=e[e.length-1],S=x?x.offset+x.source.length:s;return p&&i&&"space"!==i.type&&"newline"!==i.type&&"comma"!==i.type&&("scalar"!==i.type||""!==i.source)&&r(i.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m&&(c&&m.indent<=o||"block-map"===i?.type||"block-seq"===i?.type)&&r(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:v,found:k,spaceBefore:l,comment:u,hasNewline:f,anchor:g,tag:b,newlineAfterProp:y,end:S,start:w??S}}function gv(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes("\n"))return!0;if(e.end)for(const t of e.end)if("newline"===t.type)return!0;return!1;case"flow-collection":for(const t of e.items){for(const e of t.start)if("newline"===e.type)return!0;if(t.sep)for(const e of t.sep)if("newline"===e.type)return!0;if(gv(t.key)||gv(t.value))return!0}return!1;default:return!0}}function bv(e,t,n){if("flow-collection"===t?.type){const i=t.end[0];if(i.indent===e&&("]"===i.source||"}"===i.source)&&gv(t)){n(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}}function yv(e,t,n){const{uniqueKeys:i}=e.options;if(!1===i)return!1;const s="function"==typeof i?i:(e,t)=>e===t||rb(e)&&rb(t)&&e.value===t.value;return t.some(e=>s(e.key,n))}const vv="All mapping items must start at the same column";function kv(e,t,n,i){let s="";if(e){let r=!1,o="";for(const a of e){const{source:e,type:l}=a;switch(l){case"space":r=!0;break;case"comment":{n&&!r&&i(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");const t=e.substring(1)||" ";s?s+=o+t:s=t,o="";break}case"newline":s&&(o+=e),r=!0;break;default:i(a,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}t+=e.length}}return{comment:s,offset:t}}const wv="Block collections are not allowed within flow collections",xv=e=>e&&("block-map"===e.type||"block-seq"===e.type);function Sv(e,t,n,i,s,r){const o="block-map"===n.type?function({composeNode:e,composeEmptyNode:t},n,i,s,r){const o=new(r?.nodeClass??ly)(n.schema);n.atRoot&&(n.atRoot=!1);let a=i.offset,l=null;for(const r of i.items){const{start:c,key:h,sep:u,value:d}=r,f=mv(c,{indicator:"explicit-key-ind",next:h??u?.[0],offset:a,onError:s,parentIndent:i.indent,startOnNewline:!0}),p=!f.found;if(p){if(h&&("block-seq"===h.type?s(a,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in h&&h.indent!==i.indent&&s(a,"BAD_INDENT",vv)),!f.anchor&&!f.tag&&!u){l=f.end,f.comment&&(o.comment?o.comment+="\n"+f.comment:o.comment=f.comment);continue}(f.newlineAfterProp||gv(h))&&s(h??c[c.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else f.found?.indent!==i.indent&&s(a,"BAD_INDENT",vv);n.atKey=!0;const m=f.end,g=h?e(n,h,f,s):t(n,m,c,null,f,s);n.schema.compat&&bv(i.indent,h,s),n.atKey=!1,yv(n,o.items,g)&&s(m,"DUPLICATE_KEY","Map keys must be unique");const b=mv(u??[],{indicator:"map-value-ind",next:d,offset:g.range[2],onError:s,parentIndent:i.indent,startOnNewline:!h||"block-scalar"===h.type});if(a=b.end,b.found){p&&("block-map"!==d?.type||b.hasNewline||s(a,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),n.options.strict&&f.start<b.found.offset-1024&&s(g.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));const l=d?e(n,d,b,s):t(n,a,u,null,b,s);n.schema.compat&&bv(i.indent,d,s),a=l.range[2];const c=new ny(g,l);n.options.keepSourceTokens&&(c.srcToken=r),o.items.push(c)}else{p&&s(g.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),b.comment&&(g.comment?g.comment+="\n"+b.comment:g.comment=b.comment);const e=new ny(g);n.options.keepSourceTokens&&(e.srcToken=r),o.items.push(e)}}return l&&l<a&&s(l,"IMPOSSIBLE","Map comment with trailing content"),o.range=[i.offset,a,l??a],o}(e,t,n,i,r):"block-seq"===n.type?function({composeNode:e,composeEmptyNode:t},n,i,s,r){const o=new(r?.nodeClass??hy)(n.schema);n.atRoot&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let a=i.offset,l=null;for(const{start:r,value:c}of i.items){const h=mv(r,{indicator:"seq-item-ind",next:c,offset:a,onError:s,parentIndent:i.indent,startOnNewline:!0});if(!h.found){if(!(h.anchor||h.tag||c)){l=h.end,h.comment&&(o.comment=h.comment);continue}"block-seq"===c?.type?s(h.end,"BAD_INDENT","All sequence items must start at the same column"):s(a,"MISSING_CHAR","Sequence item without - indicator")}const u=c?e(n,c,h,s):t(n,h.end,r,null,h,s);n.schema.compat&&bv(i.indent,c,s),a=u.range[2],o.items.push(u)}return o.range=[i.offset,a,l??a],o}(e,t,n,i,r):function({composeNode:e,composeEmptyNode:t},n,i,s,r){const o="{"===i.start.source,a=o?"flow map":"flow sequence",l=new(r?.nodeClass??(o?ly:hy))(n.schema);l.flow=!0;const c=n.atRoot;c&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let h=i.offset+i.start.source.length;for(let r=0;r<i.items.length;++r){const c=i.items[r],{start:u,key:d,sep:f,value:p}=c,m=mv(u,{flow:a,indicator:"explicit-key-ind",next:d??f?.[0],offset:h,onError:s,parentIndent:i.indent,startOnNewline:!1});if(!m.found){if(!(m.anchor||m.tag||f||p)){0===r&&m.comma?s(m.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):r<i.items.length-1&&s(m.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),m.comment&&(l.comment?l.comment+="\n"+m.comment:l.comment=m.comment),h=m.end;continue}!o&&n.options.strict&&gv(d)&&s(d,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(0===r)m.comma&&s(m.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(m.comma||s(m.start,"MISSING_CHAR",`Missing , between ${a} items`),m.comment){let e="";e:for(const t of u)switch(t.type){case"comma":case"space":break;case"comment":e=t.source.substring(1);break e;default:break e}if(e){let t=l.items[l.items.length-1];sb(t)&&(t=t.value??t.key),t.comment?t.comment+="\n"+e:t.comment=e,m.comment=m.comment.substring(e.length+1)}}if(o||f||m.found){n.atKey=!0;const r=m.end,g=d?e(n,d,m,s):t(n,r,u,null,m,s);xv(d)&&s(g.range,"BLOCK_IN_FLOW",wv),n.atKey=!1;const b=mv(f??[],{flow:a,indicator:"map-value-ind",next:p,offset:g.range[2],onError:s,parentIndent:i.indent,startOnNewline:!1});if(b.found){if(!o&&!m.found&&n.options.strict){if(f)for(const e of f){if(e===b.found)break;if("newline"===e.type){s(e,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}m.start<b.found.offset-1024&&s(b.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else p&&("source"in p&&":"===p.source?.[0]?s(p,"MISSING_CHAR",`Missing space after : in ${a}`):s(b.start,"MISSING_CHAR",`Missing , or : between ${a} items`));const y=p?e(n,p,b,s):b.found?t(n,b.end,f,null,b,s):null;y?xv(p)&&s(y.range,"BLOCK_IN_FLOW",wv):b.comment&&(g.comment?g.comment+="\n"+b.comment:g.comment=b.comment);const v=new ny(g,y);if(n.options.keepSourceTokens&&(v.srcToken=c),o){const e=l;yv(n,e.items,g)&&s(r,"DUPLICATE_KEY","Map keys must be unique"),e.items.push(v)}else{const e=new ly(n.schema);e.flow=!0,e.items.push(v);const t=(y??g).range;e.range=[g.range[0],t[1],t[2]],l.items.push(e)}h=y?y.range[2]:b.end}else{const i=p?e(n,p,m,s):t(n,m.end,f,null,m,s);l.items.push(i),h=i.range[2],xv(p)&&s(i.range,"BLOCK_IN_FLOW",wv)}}const u=o?"}":"]",[d,...f]=i.end;let p=h;if(d?.source===u)p=d.offset+d.source.length;else{const e=a[0].toUpperCase()+a.substring(1);s(h,c?"MISSING_CHAR":"BAD_INDENT",c?`${e} must end with a ${u}`:`${e} in block collection must be sufficiently indented and end with a ${u}`),d&&1!==d.source.length&&f.unshift(d)}if(f.length>0){const e=kv(f,p,n.options.strict,s);e.comment&&(l.comment?l.comment+="\n"+e.comment:l.comment=e.comment),l.range=[i.offset,p,e.offset]}else l.range=[i.offset,p,p];return l}(e,t,n,i,r),a=o.constructor;return"!"===s||s===a.tagName?(o.tag=a.tagName,o):(s&&(o.tag=s),o)}function Cv(e,t,n){const i=t.offset,s=function({offset:e,props:t},n,i){if("block-scalar-header"!==t[0].type)return i(t[0],"IMPOSSIBLE","Block scalar header not found"),null;const{source:s}=t[0],r=s[0];let o=0,a="",l=-1;for(let t=1;t<s.length;++t){const n=s[t];if(a||"-"!==n&&"+"!==n){const i=Number(n);!o&&i?o=i:-1===l&&(l=e+t)}else a=n}-1!==l&&i(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${s}`);let c=!1,h="",u=s.length;for(let e=1;e<t.length;++e){const s=t[e];switch(s.type){case"space":c=!0;case"newline":u+=s.source.length;break;case"comment":if(n&&!c){i(s,"MISSING_CHAR","Comments must be separated from other tokens by white space characters")}u+=s.source.length,h=s.source.substring(1);break;case"error":i(s,"UNEXPECTED_TOKEN",s.message),u+=s.source.length;break;default:{i(s,"UNEXPECTED_TOKEN",`Unexpected token in block scalar header: ${s.type}`);const e=s.source;e&&"string"==typeof e&&(u+=e.length)}}}return{mode:r,indent:o,chomp:a,comment:h,length:u}}(t,e.options.strict,n);if(!s)return{value:"",type:null,comment:"",range:[i,i,i]};const r=">"===s.mode?Nb.BLOCK_FOLDED:Nb.BLOCK_LITERAL,o=t.source?function(e){const t=e.split(/\n( *)/),n=t[0],i=n.match(/^( *)/),s=i?.[1]?[i[1],n.slice(i[1].length)]:["",n],r=[s];for(let e=1;e<t.length;e+=2)r.push([t[e],t[e+1]]);return r}(t.source):[];let a=o.length;for(let e=o.length-1;e>=0;--e){const t=o[e][1];if(""!==t&&"\r"!==t)break;a=e}if(0===a){const e="+"===s.chomp&&o.length>0?"\n".repeat(Math.max(1,o.length-1)):"";let n=i+s.length;return t.source&&(n+=t.source.length),{value:e,type:r,comment:s.comment,range:[i,n,n]}}let l=t.indent+s.indent,c=t.offset+s.length,h=0;for(let t=0;t<a;++t){const[i,r]=o[t];if(""!==r&&"\r"!==r){if(i.length<l){const e="Block scalars with more-indented leading empty lines must use an explicit indentation indicator";n(c+i.length,"MISSING_CHAR",e)}if(0===s.indent&&(l=i.length),h=t,0===l&&!e.atRoot){n(c,"BAD_INDENT","Block scalar values in collections must be indented")}break}0===s.indent&&i.length>l&&(l=i.length),c+=i.length+r.length+1}for(let e=o.length-1;e>=a;--e)o[e][0].length>l&&(a=e+1);let u="",d="",f=!1;for(let e=0;e<h;++e)u+=o[e][0].slice(l)+"\n";for(let e=h;e<a;++e){let[t,i]=o[e];c+=t.length+i.length+1;const a="\r"===i[i.length-1];if(a&&(i=i.slice(0,-1)),i&&t.length<l){const e=`Block scalar lines must not be less indented than their ${s.indent?"explicit indentation indicator":"first line"}`;n(c-i.length-(a?2:1),"BAD_INDENT",e),t=""}r===Nb.BLOCK_LITERAL?(u+=d+t.slice(l)+i,d="\n"):t.length>l||"\t"===i[0]?(" "===d?d="\n":f||"\n"!==d||(d="\n\n"),u+=d+t.slice(l)+i,d="\n",f=!0):""===i?"\n"===d?u+="\n":d="\n":(u+=d+i,d=" ",f=!1)}switch(s.chomp){case"-":break;case"+":for(let e=a;e<o.length;++e)u+="\n"+o[e][0].slice(l);"\n"!==u[u.length-1]&&(u+="\n");break;default:u+="\n"}const p=i+s.length+t.source.length;return{value:u,type:r,comment:s.comment,range:[i,p,p]}}function Av(e,t,n){const{offset:i,type:s,source:r,end:o}=e;let a,l;const c=(e,t,s)=>n(i+e,t,s);switch(s){case"scalar":a=Nb.PLAIN,l=function(e,t){let n="";switch(e[0]){case"\t":n="a tab character";break;case",":n="flow indicator character ,";break;case"%":n="directive indicator character %";break;case"|":case">":n=`block scalar indicator ${e[0]}`;break;case"@":case"`":n=`reserved character ${e[0]}`}n&&t(0,"BAD_SCALAR_START",`Plain value cannot start with ${n}`);return Tv(e)}(r,c);break;case"single-quoted-scalar":a=Nb.QUOTE_SINGLE,l=function(e,t){"'"===e[e.length-1]&&1!==e.length||t(e.length,"MISSING_CHAR","Missing closing 'quote");return Tv(e.slice(1,-1)).replace(/''/g,"'")}(r,c);break;case"double-quoted-scalar":a=Nb.QUOTE_DOUBLE,l=function(e,t){let n="";for(let i=1;i<e.length-1;++i){const s=e[i];if("\r"!==s||"\n"!==e[i+1])if("\n"===s){const{fold:t,offset:s}=Nv(e,i);n+=t,i=s}else if("\\"===s){let s=e[++i];const r=Ov[s];if(r)n+=r;else if("\n"===s)for(s=e[i+1];" "===s||"\t"===s;)s=e[1+ ++i];else if("\r"===s&&"\n"===e[i+1])for(s=e[1+ ++i];" "===s||"\t"===s;)s=e[1+ ++i];else if("x"===s||"u"===s||"U"===s){const r={x:2,u:4,U:8}[s];n+=Mv(e,i+1,r,t),i+=r}else{const s=e.substr(i-1,2);t(i-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),n+=s}}else if(" "===s||"\t"===s){const t=i;let r=e[i+1];for(;" "===r||"\t"===r;)r=e[1+ ++i];"\n"===r||"\r"===r&&"\n"===e[i+2]||(n+=i>t?e.slice(t,i+1):s)}else n+=s}'"'===e[e.length-1]&&1!==e.length||t(e.length,"MISSING_CHAR",'Missing closing "quote');return n}(r,c);break;default:return n(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${s}`),{value:"",type:null,comment:"",range:[i,i+r.length,i+r.length]}}const h=i+r.length,u=kv(o,h,t,n);return{value:l,type:a,comment:u.comment,range:[i,h,u.offset]}}function Tv(e){let t,n;try{t=new RegExp("(.*?)(?<![ \t])[ \t]*\r?\n","sy"),n=new RegExp("[ \t]*(.*?)(?:(?<![ \t])[ \t]*)?\r?\n","sy")}catch{t=/(.*?)[ \t]*\r?\n/sy,n=/[ \t]*(.*?)[ \t]*\r?\n/sy}let i=t.exec(e);if(!i)return e;let s=i[1],r=" ",o=t.lastIndex;for(n.lastIndex=o;i=n.exec(e);)""===i[1]?"\n"===r?s+=r:r="\n":(s+=r+i[1],r=" "),o=n.lastIndex;const a=/[ \t]*(.*)/sy;return a.lastIndex=o,i=a.exec(e),s+r+(i?.[1]??"")}function Nv(e,t){let n="",i=e[t+1];for(;!(" "!==i&&"\t"!==i&&"\n"!==i&&"\r"!==i||"\r"===i&&"\n"!==e[t+2]);)"\n"===i&&(n+="\n"),i=e[(t+=1)+1];return n||(n=" "),{fold:n,offset:t}}const Ov={0:"\0",a:"",b:"\b",e:"",f:"\f",n:"\n",r:"\r",t:"\t",v:"\v",N:"
",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function Mv(e,t,n,i){const s=e.substr(t,n),r=s.length===n&&/^[0-9a-fA-F]+$/.test(s)?parseInt(s,16):NaN;if(isNaN(r)){const s=e.substr(t-2,n+2);return i(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),s}return String.fromCodePoint(r)}function Ev(e,t,n,i){const{value:s,type:r,comment:o,range:a}="block-scalar"===t.type?Cv(e,t,i):Av(t,e.options.strict,i),l=n?e.directives.tagName(n.source,e=>i(n,"TAG_RESOLVE_FAILED",e)):null;let c,h;c=e.options.stringKeys&&e.atKey?e.schema[Qg]:l?function(e,t,n,i,s){if("!"===n)return e[Qg];const r=[];for(const t of e.tags)if(!t.collection&&t.tag===n){if(!t.default||!t.test)return t;r.push(t)}for(const e of r)if(e.test?.test(t))return e;const o=e.knownTags[n];if(o&&!o.collection)return e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o;return s(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${n}`,"tag:yaml.org,2002:str"!==n),e[Qg]}(e.schema,s,l,n,i):"scalar"===t.type?function({atKey:e,directives:t,schema:n},i,s,r){const o=n.tags.find(t=>(!0===t.default||e&&"key"===t.default)&&t.test?.test(i))||n[Qg];if(n.compat){const e=n.compat.find(e=>e.default&&e.test?.test(i))??n[Qg];if(o.tag!==e.tag){r(s,"TAG_RESOLVE_FAILED",`Value may be parsed as either ${t.tagString(o.tag)} or ${t.tagString(e.tag)}`,!0)}}return o}(e,s,t,i):e.schema[Qg];try{const r=c.resolve(s,e=>i(n??t,"TAG_RESOLVE_FAILED",e),e.options);h=rb(r)?r:new Nb(r)}catch(e){const r=e instanceof Error?e.message:String(e);i(n??t,"TAG_RESOLVE_FAILED",r),h=new Nb(s)}return h.range=a,h.source=s,r&&(h.type=r),l&&(h.tag=l),c.format&&(h.format=c.format),o&&(h.comment=o),h}function Dv(e,t,n){if(t){n??(n=t.length);for(let i=n-1;i>=0;--i){let n=t[i];switch(n.type){case"space":case"comment":case"newline":e-=n.source.length;continue}for(n=t[++i];"space"===n?.type;)e+=n.source.length,n=t[++i];break}}return e}const _v={composeNode:Iv,composeEmptyNode:Bv};function Iv(e,t,n,i){const s=e.atKey,{spaceBefore:r,comment:o,anchor:a,tag:l}=n;let c,h=!0;switch(t.type){case"alias":c=function({options:e},{offset:t,source:n,end:i},s){const r=new Cb(n.substring(1));""===r.source&&s(t,"BAD_ALIAS","Alias cannot be an empty string");r.source.endsWith(":")&&s(t+n.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);const o=t+n.length,a=kv(i,o,e.strict,s);r.range=[t,o,a.offset],a.comment&&(r.comment=a.comment);return r}(e,t,i),(a||l)&&i(t,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":c=Ev(e,t,l,i),a&&(c.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{c=function(e,t,n,i,s){const r=i.tag,o=r?t.directives.tagName(r.source,e=>s(r,"TAG_RESOLVE_FAILED",e)):null;if("block-seq"===n.type){const{anchor:e,newlineAfterProp:t}=i,n=e&&r?e.offset>r.offset?e:r:e??r;n&&(!t||t.offset<n.offset)&&s(n,"MISSING_CHAR","Missing newline after block sequence props")}const a="block-map"===n.type?"map":"block-seq"===n.type?"seq":"{"===n.start.source?"map":"seq";if(!r||!o||"!"===o||o===ly.tagName&&"map"===a||o===hy.tagName&&"seq"===a)return Sv(e,t,n,s,o);let l=t.schema.tags.find(e=>e.tag===o&&e.collection===a);if(!l){const i=t.schema.knownTags[o];if(i?.collection!==a)return i?s(r,"BAD_COLLECTION_TYPE",`${i.tag} used for ${a} collection, but expects ${i.collection??"scalar"}`,!0):s(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),Sv(e,t,n,s,o);t.schema.tags.push(Object.assign({},i,{default:!1})),l=i}const c=Sv(e,t,n,s,o,l),h=l.resolve?.(c,e=>s(r,"TAG_RESOLVE_FAILED",e),t.options)??c,u=lb(h)?h:new Nb(h);return u.range=c.range,u.tag=o,l?.format&&(u.format=l.format),u}(_v,e,t,n,i),a&&(c.anchor=a.source.substring(1))}catch(e){i(t,"RESOURCE_EXHAUSTION",e instanceof Error?e.message:String(e))}break;default:i(t,"UNEXPECTED_TOKEN","error"===t.type?t.message:`Unsupported token (type: ${t.type})`),h=!1}if(c??(c=Bv(e,t.offset,void 0,null,n,i)),a&&""===c.anchor&&i(a,"BAD_ALIAS","Anchor cannot be an empty string"),s&&e.options.stringKeys&&(!rb(c)||"string"!=typeof c.value||c.tag&&"tag:yaml.org,2002:str"!==c.tag)){i(l??t,"NON_STRING_KEY","With stringKeys, all keys must be strings")}return r&&(c.spaceBefore=!0),o&&("scalar"===t.type&&""===t.source?c.comment=o:c.commentBefore=o),e.options.keepSourceTokens&&h&&(c.srcToken=t),c}function Bv(e,t,n,i,{spaceBefore:s,comment:r,anchor:o,tag:a,end:l},c){const h=Ev(e,{type:"scalar",offset:Dv(t,n,i),indent:-1,source:""},a,c);return o&&(h.anchor=o.source.substring(1),""===h.anchor&&c(o,"BAD_ALIAS","Anchor cannot be an empty string")),s&&(h.spaceBefore=!0),r&&(h.comment=r,h.range[2]=l),h}function Pv(e){if("number"==typeof e)return[e,e+1];if(Array.isArray(e))return 2===e.length?e:[e[0],e[1]];const{offset:t,source:n}=e;return[t,t+("string"==typeof n?n.length:1)]}function Rv(e){let t="",n=!1,i=!1;for(let s=0;s<e.length;++s){const r=e[s];switch(r[0]){case"#":t+=(""===t?"":i?"\n\n":"\n")+(r.substring(1)||" "),n=!0,i=!1;break;case"%":"#"!==e[s+1]?.[0]&&(s+=1),n=!1;break;default:n||(i=!0),n=!1}}return{comment:t,afterEmptyLine:i}}class $v{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,i)=>{const s=Pv(e);i?this.warnings.push(new fv(s,t,n)):this.errors.push(new dv(s,t,n))},this.directives=new bb({version:e.version||"1.2"}),this.options=e}decorate(e,t){const{comment:n,afterEmptyLine:i}=Rv(this.prelude);if(n){const s=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(i||e.directives.docStart||!s)e.commentBefore=n;else if(ab(s)&&!s.flow&&s.items.length>0){let e=s.items[0];sb(e)&&(e=e.key);const t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{const e=s.commentBefore;s.commentBefore=e?`${n}\n${e}`:n}}t?(Array.prototype.push.apply(e.errors,this.errors),Array.prototype.push.apply(e.warnings,this.warnings)):(e.errors=this.errors,e.warnings=this.warnings),this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Rv(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(const t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(e.type){case"directive":this.directives.add(e.source,(t,n,i)=>{const s=Pv(e);s[0]+=t,this.onError(s,"BAD_DIRECTIVE",n,i)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{const t=function(e,t,{offset:n,start:i,value:s,end:r},o){const a=Object.assign({_directives:t},e),l=new cv(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},h=mv(i,{indicator:"doc-start",next:s??r?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});h.found&&(l.directives.docStart=!0,!s||"block-map"!==s.type&&"block-seq"!==s.type||h.hasNewline||o(h.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),l.contents=s?Iv(c,s,h,o):Bv(c,h.end,i,null,h,o);const u=l.contents.range[2],d=kv(r,u,!1,o);return d.comment&&(l.comment=d.comment),l.range=[n,u,d.offset],l}(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{const t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new dv(Pv(e),"UNEXPECTED_TOKEN",t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case"doc-end":{if(!this.doc){const t="Unexpected doc-end without preceding document";this.errors.push(new dv(Pv(e),"UNEXPECTED_TOKEN",t));break}this.doc.directives.docEnd=!0;const t=kv(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){const e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new dv(Pv(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){const e=Object.assign({_directives:this.directives},this.options),n=new cv(void 0,e);this.atDirectives&&this.onError(t,"MISSING_CHAR","Missing directives-end indicator line"),n.range=[0,t,t],this.decorate(n,!1),yield n}}}function Lv(e){switch(e){case void 0:case" ":case"\n":case"\r":case"\t":return!0;default:return!1}}const zv=new Set("0123456789ABCDEFabcdef"),Fv=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),jv=new Set(",[]{}"),Wv=new Set(" ,[]{}\n\r\t"),Uv=e=>!e||Wv.has(e);class Vv{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if("string"!=typeof e)throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let n=this.next??"stream";for(;n&&(t||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;" "===t||"\t"===t;)t=this.buffer[++e];return!t||"#"===t||"\n"===t||"\r"===t&&"\n"===this.buffer[e+1]}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let n=0;for(;" "===t;)t=this.buffer[++n+e];if("\r"===t){const t=this.buffer[n+e+1];if("\n"===t||!t&&!this.atEnd)return e+n+1}return"\n"===t||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if("-"===t||"."===t){const t=this.buffer.substr(e,3);if(("---"===t||"..."===t)&&Lv(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return("number"!=typeof e||-1!==e&&e<this.pos)&&(e=this.buffer.indexOf("\n",this.pos),this.lineEndPos=e),-1===e?this.atEnd?this.buffer.substring(this.pos):null:("\r"===this.buffer[e-1]&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(null===e)return this.setNext("stream");if("\ufeff"===e[0]&&(yield*this.pushCount(1),e=e.substring(1)),"%"===e[0]){let t=e.length,n=e.indexOf("#");for(;-1!==n;){const i=e[n-1];if(" "===i||"\t"===i){t=n-1;break}n=e.indexOf("#",n+1)}for(;;){const n=e[t-1];if(" "!==n&&"\t"!==n)break;t-=1}const i=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-i),this.pushNewline(),"stream"}if(this.atLineEnd()){const t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),"stream"}return yield"",yield*this.parseLineStart()}*parseLineStart(){const e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if("-"===e||"."===e){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");const e=this.peek(3);if(("---"===e||"..."===e)&&Lv(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,"---"===e?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!Lv(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){const[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext("block-start");if(("-"===e||"?"===e||":"===e)&&Lv(t)){const e=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=e,yield*this.parseBlockStart()}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);const e=this.getLine();if(null===e)return this.setNext("doc");let t=yield*this.pushIndicators();switch(e[t]){case"#":yield*this.pushCount(e.length-t);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(Uv),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return t+=(yield*this.parseBlockScalarHeader()),t+=(yield*this.pushSpaces(!0)),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,n=-1;do{e=yield*this.pushNewline(),e>0?(t=yield*this.pushSpaces(!1),this.indentValue=n=t):t=0,t+=(yield*this.pushSpaces(!0))}while(e+t>0);const i=this.getLine();if(null===i)return this.setNext("flow");if(-1!==n&&n<this.indentNext&&"#"!==i[0]||0===n&&(i.startsWith("---")||i.startsWith("..."))&&Lv(i[3])){if(!(n===this.indentNext-1&&1===this.flowLevel&&("]"===i[0]||"}"===i[0])))return this.flowLevel=0,yield"",yield*this.parseLineStart()}let s=0;for(;","===i[s];)s+=(yield*this.pushCount(1)),s+=(yield*this.pushSpaces(!0)),this.flowKey=!1;switch(s+=(yield*this.pushIndicators()),i[s]){case void 0:return"flow";case"#":return yield*this.pushCount(i.length-s),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(Uv),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{const e=this.charAt(1);if(this.flowKey||Lv(e)||","===e)return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){const e=this.charAt(0);let t=this.buffer.indexOf(e,this.pos+1);if("'"===e)for(;-1!==t&&"'"===this.buffer[t+1];)t=this.buffer.indexOf("'",t+2);else for(;-1!==t;){let e=0;for(;"\\"===this.buffer[t-1-e];)e+=1;if(e%2==0)break;t=this.buffer.indexOf('"',t+1)}const n=this.buffer.substring(0,t);let i=n.indexOf("\n",this.pos);if(-1!==i){for(;-1!==i;){const e=this.continueScalar(i+1);if(-1===e)break;i=n.indexOf("\n",e)}-1!==i&&(t=i-("\r"===n[i-1]?2:1))}if(-1===t){if(!this.atEnd)return this.setNext("quoted-scalar");t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){const t=this.buffer[++e];if("+"===t)this.blockScalarKeep=!0;else if(t>"0"&&t<="9")this.blockScalarIndent=Number(t)-1;else if("-"!==t)break}return yield*this.pushUntil(e=>Lv(e)||"#"===e)}*parseBlockScalar(){let e,t=this.pos-1,n=0;e:for(let i=this.pos;e=this.buffer[i];++i)switch(e){case" ":n+=1;break;case"\n":t=i,n=0;break;case"\r":{const e=this.buffer[i+1];if(!e&&!this.atEnd)return this.setNext("block-scalar");if("\n"===e)break}default:break e}if(!e&&!this.atEnd)return this.setNext("block-scalar");if(n>=this.indentNext){-1===this.blockScalarIndent?this.indentNext=n:this.indentNext=this.blockScalarIndent+(0===this.indentNext?1:this.indentNext);do{const e=this.continueScalar(t+1);if(-1===e)break;t=this.buffer.indexOf("\n",e)}while(-1!==t);if(-1===t){if(!this.atEnd)return this.setNext("block-scalar");t=this.buffer.length}}let i=t+1;for(e=this.buffer[i];" "===e;)e=this.buffer[++i];if("\t"===e){for(;"\t"===e||" "===e||"\r"===e||"\n"===e;)e=this.buffer[++i];t=i-1}else if(!this.blockScalarKeep)for(;;){let e=t-1,i=this.buffer[e];"\r"===i&&(i=this.buffer[--e]);const s=e;for(;" "===i;)i=this.buffer[--e];if(!("\n"===i&&e>=this.pos&&e+1+n>s))break;t=e}return yield"",yield*this.pushToIndex(t+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){const e=this.flowLevel>0;let t,n=this.pos-1,i=this.pos-1;for(;t=this.buffer[++i];)if(":"===t){const t=this.buffer[i+1];if(Lv(t)||e&&jv.has(t))break;n=i}else if(Lv(t)){let s=this.buffer[i+1];if("\r"===t&&("\n"===s?(i+=1,t="\n",s=this.buffer[i+1]):n=i),"#"===s||e&&jv.has(s))break;if("\n"===t){const e=this.continueScalar(i+1);if(-1===e)break;i=Math.max(i,e-2)}}else{if(e&&jv.has(t))break;n=i}return t||this.atEnd?(yield"",yield*this.pushToIndex(n+1,!0),e?"flow":"doc"):this.setNext("plain-scalar")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){const n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.length):(t&&(yield""),0)}*pushIndicators(){switch(this.charAt(0)){case"!":return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"&":return(yield*this.pushUntil(Uv))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{const e=this.flowLevel>0,t=this.charAt(1);if(Lv(t)||e&&jv.has(t))return e?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,(yield*this.pushCount(1))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators())}}return 0}*pushTag(){if("<"===this.charAt(1)){let e=this.pos+2,t=this.buffer[e];for(;!Lv(t)&&">"!==t;)t=this.buffer[++e];return yield*this.pushToIndex(">"===t?e+1:e,!1)}{let e=this.pos+1,t=this.buffer[e];for(;t;)if(Fv.has(t))t=this.buffer[++e];else{if("%"!==t||!zv.has(this.buffer[e+1])||!zv.has(this.buffer[e+2]))break;t=this.buffer[e+=3]}return yield*this.pushToIndex(e,!1)}}*pushNewline(){const e=this.buffer[this.pos];return"\n"===e?yield*this.pushCount(1):"\r"===e&&"\n"===this.charAt(1)?yield*this.pushCount(2):0}*pushSpaces(e){let t,n=this.pos-1;do{t=this.buffer[++n]}while(" "===t||e&&"\t"===t);const i=n-this.pos;return i>0&&(yield this.buffer.substr(this.pos,i),this.pos=n),i}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}class Hv{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){const i=t+n>>1;this.lineStarts[i]<e?t=i+1:n=i}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(0===t)return{line:0,col:e};return{line:t,col:e-this.lineStarts[t-1]+1}}}}function qv(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function Kv(e){for(let t=0;t<e.length;++t)switch(e[t].type){case"space":case"comment":case"newline":break;default:return t}return-1}function Jv(e){switch(e?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function Zv(e){switch(e.type){case"document":return e.start;case"block-map":{const t=e.items[e.items.length-1];return t.sep??t.start}case"block-seq":return e.items[e.items.length-1].start;default:return[]}}function Yv(e){if(0===e.length)return[];let t=e.length;e:for(;--t>=0;)switch(e[t].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;"space"===e[++t]?.type;);return e.splice(t,e.length)}function Gv(e){if("flow-seq-start"===e.start.type)for(const t of e.items)!t.sep||t.value||qv(t.start,"explicit-key-ind")||qv(t.sep,"map-value-ind")||(t.key&&(t.value=t.key),delete t.key,Jv(t.value)?t.value.end?Array.prototype.push.apply(t.value.end,t.sep):t.value.end=t.sep:Array.prototype.push.apply(t.start,t.sep),delete t.sep)}class Qv{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new Vv,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&0===this.offset&&this.onNewLine(0);for(const n of this.lexer.lex(e,t))yield*this.next(n);t||(yield*this.end())}*next(e){if(this.source=e,this.atScalar)return this.atScalar=!1,yield*this.step(),void(this.offset+=e.length);const t=function(e){switch(e){case"\ufeff":return"byte-order-mark";case"":return"doc-mode";case"":return"flow-error-end";case"":return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case"\n":case"\r\n":return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(e[0]){case" ":case"\t":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}(e);if(t)if("scalar"===t)this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=t,yield*this.step(),t){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&" "===e[0]&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{const t=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:t,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){const e=this.peek(1);if("doc-end"!==this.type||"doc-end"===e?.type){if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}else{for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source})}}peek(e){return this.stack[this.stack.length-e]}*pop(e){const t=e??this.stack.pop();if(t)if(0===this.stack.length)yield t;else{const e=this.peek(1);switch("block-scalar"===t.type?t.indent="indent"in e?e.indent:0:"flow-collection"===t.type&&"document"===e.type&&(t.indent=0),"flow-collection"===t.type&&Gv(t),e.type){case"document":e.value=t;break;case"block-scalar":e.props.push(t);break;case"block-map":{const n=e.items[e.items.length-1];if(n.value)return e.items.push({start:[],key:t,sep:[]}),void(this.onKeyLine=!0);if(!n.sep)return Object.assign(n,{key:t,sep:[]}),void(this.onKeyLine=!n.explicitKey);n.value=t;break}case"block-seq":{const n=e.items[e.items.length-1];n.value?e.items.push({start:[],value:t}):n.value=t;break}case"flow-collection":{const n=e.items[e.items.length-1];return void(!n||n.value?e.items.push({start:[],key:t,sep:[]}):n.sep?n.value=t:Object.assign(n,{key:t,sep:[]}))}default:yield*this.pop(),yield*this.pop(t)}if(!("document"!==e.type&&"block-map"!==e.type&&"block-seq"!==e.type||"block-map"!==t.type&&"block-seq"!==t.type)){const n=t.items[t.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&-1===Kv(n.start)&&(0===t.indent||n.start.every(e=>"comment"!==e.type||e.indent<t.indent))&&("document"===e.type?e.end=n.start:e.items.push({start:n.start}),t.items.splice(-1,1))}}else{const e="Tried to pop an empty stack";yield{type:"error",offset:this.offset,source:"",message:e}}}*stream(){switch(this.type){case"directive-line":return void(yield{type:"directive",offset:this.offset,source:this.source});case"byte-order-mark":case"space":case"comment":case"newline":return void(yield this.sourceToken);case"doc-mode":case"doc-start":{const e={type:"document",offset:this.offset,start:[]};return"doc-start"===this.type&&e.start.push(this.sourceToken),void this.stack.push(e)}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":return void(-1!==Kv(e.start)?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken));case"anchor":case"tag":case"space":case"comment":case"newline":return void e.start.push(this.sourceToken)}const t=this.startBlockValue(e);t?this.stack.push(t):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if("map-value-ind"===this.type){const t=Yv(Zv(this.peek(2)));let n;e.end?(n=e.end,n.push(this.sourceToken),delete e.end):n=[this.sourceToken];const i={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:t,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":return void e.props.push(this.sourceToken);case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let e=this.source.indexOf("\n")+1;for(;0!==e;)this.onNewLine(this.offset+e),e=this.source.indexOf("\n",e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){const t=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,t.value){const n="end"in t.value?t.value.end:void 0,i=Array.isArray(n)?n[n.length-1]:void 0;"comment"===i?.type?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){const n=e.items[e.items.length-2],i=n?.value?.end;if(Array.isArray(i))return Array.prototype.push.apply(i,t.start),i.push(this.sourceToken),void e.items.pop()}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){const n=!this.onKeyLine&&this.indent===e.indent,i=n&&(t.sep||t.explicitKey)&&"seq-item-ind"!==this.type;let s=[];if(i&&t.sep&&!t.value){const n=[];for(let i=0;i<t.sep.length;++i){const s=t.sep[i];switch(s.type){case"newline":n.push(i);break;case"space":break;case"comment":s.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(s=t.sep.splice(n[1]))}switch(this.type){case"anchor":case"tag":return void(i||t.value?(s.push(this.sourceToken),e.items.push({start:s}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken));case"explicit-key-ind":return t.sep||t.explicitKey?i||t.value?(s.push(this.sourceToken),e.items.push({start:s,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}):(t.start.push(this.sourceToken),t.explicitKey=!0),void(this.onKeyLine=!0);case"map-value-ind":if(t.explicitKey)if(t.sep)if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(qv(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:null,sep:[this.sourceToken]}]});else if(Jv(t.key)&&!qv(t.sep,"newline")){const e=Yv(t.start),n=t.key,i=t.sep;i.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:i}]})}else s.length>0?t.sep=t.sep.concat(s,this.sourceToken):t.sep.push(this.sourceToken);else if(qv(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{const e=Yv(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}else t.sep?t.value||i?e.items.push({start:s,key:null,sep:[this.sourceToken]}):qv(t.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return void(this.onKeyLine=!0);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const n=this.flowScalar(this.type);return void(i||t.value?(e.items.push({start:s,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0))}default:{const i=this.startBlockValue(e);if(i){if("block-seq"===i.type){if(!t.explicitKey&&t.sep&&!qv(t.sep,"newline"))return void(yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source}))}else n&&e.items.push({start:s});return void this.stack.push(i)}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){const t=e.items[e.items.length-1];switch(this.type){case"newline":if(t.value){const n="end"in t.value?t.value.end:void 0,i=Array.isArray(n)?n[n.length-1]:void 0;"comment"===i?.type?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){const n=e.items[e.items.length-2],i=n?.value?.end;if(Array.isArray(i))return Array.prototype.push.apply(i,t.start),i.push(this.sourceToken),void e.items.pop()}t.start.push(this.sourceToken)}return;case"anchor":case"tag":if(t.value||this.indent<=e.indent)break;return void t.start.push(this.sourceToken);case"seq-item-ind":if(this.indent!==e.indent)break;return void(t.value||qv(t.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken))}if(this.indent>e.indent){const t=this.startBlockValue(e);if(t)return void this.stack.push(t)}yield*this.pop(),yield*this.step()}*flowCollection(e){const t=e.items[e.items.length-1];if("flow-error-end"===this.type){let e;do{yield*this.pop(),e=this.peek(1)}while("flow-collection"===e?.type)}else if(0===e.end.length){switch(this.type){case"comma":case"explicit-key-ind":return void(!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken));case"map-value-ind":return void(!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]}));case"space":case"comment":case"newline":case"anchor":case"tag":return void(!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken));case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const n=this.flowScalar(this.type);return void(!t||t.value?e.items.push({start:[],key:n,sep:[]}):t.sep?this.stack.push(n):Object.assign(t,{key:n,sep:[]}))}case"flow-map-end":case"flow-seq-end":return void e.end.push(this.sourceToken)}const n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{const t=this.peek(2);if("block-map"===t.type&&("map-value-ind"===this.type&&t.indent===e.indent||"newline"===this.type&&!t.items[t.items.length-1].sep))yield*this.pop(),yield*this.step();else if("map-value-ind"===this.type&&"flow-collection"!==t.type){const n=Yv(Zv(t));Gv(e);const i=e.end.splice(1,e.end.length);i.push(this.sourceToken);const s={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:i}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=s}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf("\n")+1;for(;0!==e;)this.onNewLine(this.offset+e),e=this.source.indexOf("\n",e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;const t=Yv(Zv(e));return t.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;const t=Yv(Zv(e));return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return"comment"===this.type&&(!(this.indent<=t)&&e.every(e=>"newline"===e.type||"space"===e.type))}*documentEnd(e){"doc-mode"!==this.type&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],"newline"===this.type&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],"newline"===this.type&&(yield*this.pop())}}}function Xv(e,t={}){const{lineCounter:n,prettyErrors:i}=function(e){const t=!1!==e.prettyErrors;return{lineCounter:e.lineCounter||t&&new Hv||null,prettyErrors:t}}(t),s=new Qv(n?.addNewLine),r=new $v(t);let o=null;for(const t of r.compose(s.parse(e),!0,e.length))if(o){if("silent"!==o.options.logLevel){o.errors.push(new dv(t.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}}else o=t;return i&&n&&(o.errors.forEach(pv(e,n)),o.warnings.forEach(pv(e,n))),o}function ek(e,t,n){function i(n,i){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:i,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,i);const s=o.prototype,r=Object.keys(s);for(let e=0;e<r.length;e++){const t=r[e];t in n||(n[t]=s[t].bind(n))}}const s=n?.Parent??Object;class r extends s{}function o(e){var t;const s=n?.Parent?new r:this;i(s,e),(t=s._zod).deferred??(t.deferred=[]);for(const e of s._zod.deferred)e();return s}return Object.defineProperty(r,"name",{value:e}),Object.defineProperty(o,"init",{value:i}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>!!(n?.Parent&&t instanceof n.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}class tk extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class nk extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const ik={};function sk(e){return ik}function rk(e){const t=Object.values(e).filter(e=>"number"==typeof e),n=Object.entries(e).filter(([e,n])=>-1===t.indexOf(+e)).map(([e,t])=>t);return n}function ok(e,t){return"bigint"==typeof t?t.toString():t}function ak(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function lk(e){return null==e}function ck(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}const hk=Symbol("evaluating");function uk(e,t,n){let i;Object.defineProperty(e,t,{get(){if(i!==hk)return void 0===i&&(i=hk,i=n()),i},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function dk(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function fk(...e){const t={};for(const n of e){const e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function pk(e){return JSON.stringify(e)}const mk="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function gk(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const bk=ak(()=>{if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function yk(e){if(!1===gk(e))return!1;const t=e.constructor;if(void 0===t)return!0;if("function"!=typeof t)return!0;const n=t.prototype;return!1!==gk(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function vk(e){return yk(e)?{...e}:Array.isArray(e)?[...e]:e}const kk=new Set(["string","number","symbol"]);function wk(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function xk(e,t,n){const i=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(i._zod.parent=e),i}function Sk(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}function Ck(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!0!==e.issues[n]?.continue)return!0;return!1}function Ak(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Tk(e){return"string"==typeof e?e:e?.message}function Nk(e,t,n){const i={...e,path:e.path??[]};if(!e.message){const s=Tk(e.inst?._zod.def?.error?.(e))??Tk(t?.error?.(e))??Tk(n.customError?.(e))??Tk(n.localeError?.(e))??"Invalid input";i.message=s}return delete i.inst,delete i.continue,t?.reportInput||delete i.input,i}function Ok(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function Mk(...e){const[t,n,i]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:i}:{...t}}const Ek=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,ok,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Dk=ek("$ZodError",Ek),_k=ek("$ZodError",Ek,{Parent:Error});const Ik=e=>(t,n,i,s)=>{const r=i?Object.assign(i,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},r);if(o instanceof Promise)throw new tk;if(o.issues.length){const t=new(s?.Err??e)(o.issues.map(e=>Nk(e,r,sk())));throw mk(t,s?.callee),t}return o.value},Bk=e=>async(t,n,i,s)=>{const r=i?Object.assign(i,{async:!0}):{async:!0};let o=t._zod.run({value:n,issues:[]},r);if(o instanceof Promise&&(o=await o),o.issues.length){const t=new(s?.Err??e)(o.issues.map(e=>Nk(e,r,sk())));throw mk(t,s?.callee),t}return o.value},Pk=e=>(t,n,i)=>{const s=i?{...i,async:!1}:{async:!1},r=t._zod.run({value:n,issues:[]},s);if(r instanceof Promise)throw new tk;return r.issues.length?{success:!1,error:new(e??Dk)(r.issues.map(e=>Nk(e,s,sk())))}:{success:!0,data:r.value}},Rk=Pk(_k),$k=e=>async(t,n,i)=>{const s=i?Object.assign(i,{async:!0}):{async:!0};let r=t._zod.run({value:n,issues:[]},s);return r instanceof Promise&&(r=await r),r.issues.length?{success:!1,error:new e(r.issues.map(e=>Nk(e,s,sk())))}:{success:!0,data:r.value}},Lk=$k(_k),zk=e=>(t,n,i)=>{const s=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return Ik(e)(t,n,s)},Fk=e=>(t,n,i)=>Ik(e)(t,n,i),jk=e=>async(t,n,i)=>{const s=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return Bk(e)(t,n,s)},Wk=e=>async(t,n,i)=>Bk(e)(t,n,i),Uk=e=>(t,n,i)=>{const s=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return Pk(e)(t,n,s)},Vk=e=>(t,n,i)=>Pk(e)(t,n,i),Hk=e=>async(t,n,i)=>{const s=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return $k(e)(t,n,s)},qk=e=>async(t,n,i)=>$k(e)(t,n,i),Kk=/^[cC][^\s-]{8,}$/,Jk=/^[0-9a-z]+$/,Zk=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Yk=/^[0-9a-vA-V]{20}$/,Gk=/^[A-Za-z0-9]{27}$/,Qk=/^[a-zA-Z0-9_-]{21}$/,Xk=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ew=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,tw=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,nw=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;const iw=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,sw=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,rw=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,ow=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,aw=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,lw=/^[A-Za-z0-9_-]*$/,cw=/^\+[1-9]\d{6,14}$/,hw="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",uw=new RegExp(`^${hw}$`);function dw(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}const fw=/^-?\d+(?:\.\d+)?$/,pw=/^[^A-Z]*$/,mw=/^[^a-z]*$/,gw=ek("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),bw=ek("$ZodCheckMaxLength",(e,t)=>{var n;gw.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!lk(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const i=n.value;if(i.length<=t.maximum)return;const s=Ok(i);n.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),yw=ek("$ZodCheckMinLength",(e,t)=>{var n;gw.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!lk(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const i=n.value;if(i.length>=t.minimum)return;const s=Ok(i);n.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),vw=ek("$ZodCheckLengthEquals",(e,t)=>{var n;gw.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!lk(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{const i=n.value,s=i.length;if(s===t.length)return;const r=Ok(i),o=s>t.length;n.issues.push({origin:r,...o?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),kw=ek("$ZodCheckStringFormat",(e,t)=>{var n,i;gw.init(e,t),e._zod.onattach.push(e=>{const n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??(n.patterns=new Set),n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(i=e._zod).check??(i.check=()=>{})}),ww=ek("$ZodCheckRegex",(e,t)=>{kw.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),xw=ek("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=pw),kw.init(e,t)}),Sw=ek("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=mw),kw.init(e,t)}),Cw=ek("$ZodCheckIncludes",(e,t)=>{gw.init(e,t);const n=wk(t.includes),i=new RegExp("number"==typeof t.position?`^.{${t.position}}${n}`:n);t.pattern=i,e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(i)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Aw=ek("$ZodCheckStartsWith",(e,t)=>{gw.init(e,t);const n=new RegExp(`^${wk(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Tw=ek("$ZodCheckEndsWith",(e,t)=>{gw.init(e,t);const n=new RegExp(`.*${wk(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Nw=ek("$ZodCheckOverwrite",(e,t)=>{gw.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class Ow{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});const t=e.split("\n").filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),i=t.map(e=>e.slice(n)).map(e=>" ".repeat(2*this.indent)+e);for(const e of i)this.content.push(e)}compile(){const e=Function,t=this?.args,n=[...(this?.content??[""]).map(e=>` ${e}`)];return new e(...t,n.join("\n"))}}const Mw={major:4,minor:3,patch:6},Ew=ek("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Mw;const i=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&i.unshift(e);for(const t of i)for(const n of t._zod.onattach)n(e);if(0===i.length)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const t=(e,t,n)=>{let i,s=Ck(e);for(const r of t){if(r._zod.def.when){if(!r._zod.def.when(e))continue}else if(s)continue;const t=e.issues.length,o=r._zod.check(e);if(o instanceof Promise&&!1===n?.async)throw new tk;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o;e.issues.length!==t&&(s||(s=Ck(e,t)))});else{if(e.issues.length===t)continue;s||(s=Ck(e,t))}}return i?i.then(()=>e):e},n=(n,s,r)=>{if(Ck(n))return n.aborted=!0,n;const o=t(s,i,r);if(o instanceof Promise){if(!1===r.async)throw new tk;return o.then(t=>e._zod.parse(t,r))}return e._zod.parse(o,r)};e._zod.run=(s,r)=>{if(r.skipChecks)return e._zod.parse(s,r);if("backward"===r.direction){const t=e._zod.parse({value:s.value,issues:[]},{...r,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,s,r)):n(t,s,r)}const o=e._zod.parse(s,r);if(o instanceof Promise){if(!1===r.async)throw new tk;return o.then(e=>t(e,i,r))}return t(o,i,r)}}uk(e,"~standard",()=>({validate:t=>{try{const n=Rk(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return Lk(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),Dw=ek("$ZodString",(e,t)=>{var n;Ew.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(n=e._zod.bag,new RegExp(`^${n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*"}$`)),e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=String(n.value)}catch(i){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),_w=ek("$ZodStringFormat",(e,t)=>{kw.init(e,t),Dw.init(e,t)}),Iw=ek("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=ew),_w.init(e,t)}),Bw=ek("$ZodUUID",(e,t)=>{if(t.version){const e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=tw(e))}else t.pattern??(t.pattern=tw());_w.init(e,t)}),Pw=ek("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=nw),_w.init(e,t)}),Rw=ek("$ZodURL",(e,t)=>{_w.init(e,t),e._zod.check=n=>{try{const i=n.value.trim(),s=new URL(i);return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(s.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(s.protocol.endsWith(":")?s.protocol.slice(0,-1):s.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),void(t.normalize?n.value=s.href:n.value=i)}catch(i){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),$w=ek("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),_w.init(e,t)}),Lw=ek("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Qk),_w.init(e,t)}),zw=ek("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Kk),_w.init(e,t)}),Fw=ek("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Jk),_w.init(e,t)}),jw=ek("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Zk),_w.init(e,t)}),Ww=ek("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Yk),_w.init(e,t)}),Uw=ek("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Gk),_w.init(e,t)}),Vw=ek("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=dw({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const i=`${t}(?:${n.join("|")})`;return new RegExp(`^${hw}T(?:${i})$`)}(t)),_w.init(e,t)}),Hw=ek("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=uw),_w.init(e,t)}),qw=ek("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${dw(t)}$`)),_w.init(e,t)}),Kw=ek("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Xk),_w.init(e,t)}),Jw=ek("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=iw),_w.init(e,t),e._zod.bag.format="ipv4"}),Zw=ek("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=sw),_w.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),Yw=ek("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=rw),_w.init(e,t)}),Gw=ek("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ow),_w.init(e,t),e._zod.check=n=>{const i=n.value.split("/");try{if(2!==i.length)throw new Error;const[e,t]=i;if(!t)throw new Error;const n=Number(t);if(`${n}`!==t)throw new Error;if(n<0||n>128)throw new Error;new URL(`http://[${e}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Qw(e){if(""===e)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const Xw=ek("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=aw),_w.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Qw(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});const ex=ek("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=lw),_w.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{(function(e){if(!lw.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return Qw(t.padEnd(4*Math.ceil(t.length/4),"="))})(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),tx=ek("$ZodE164",(e,t)=>{t.pattern??(t.pattern=cw),_w.init(e,t)});const nx=ek("$ZodJWT",(e,t)=>{_w.init(e,t),e._zod.check=n=>{(function(e,t=null){try{const n=e.split(".");if(3!==n.length)return!1;const[i]=n;if(!i)return!1;const s=JSON.parse(atob(i));return!("typ"in s&&"JWT"!==s?.typ||!s.alg||t&&(!("alg"in s)||s.alg!==t))}catch{return!1}})(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),ix=ek("$ZodUnknown",(e,t)=>{Ew.init(e,t),e._zod.parse=e=>e}),sx=ek("$ZodNever",(e,t)=>{Ew.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function rx(e,t,n){e.issues.length&&t.issues.push(...Ak(n,e.issues)),t.value[n]=e.value}const ox=ek("$ZodArray",(e,t)=>{Ew.init(e,t),e._zod.parse=(n,i)=>{const s=n.value;if(!Array.isArray(s))return n.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),n;n.value=Array(s.length);const r=[];for(let e=0;e<s.length;e++){const o=s[e],a=t.element._zod.run({value:o,issues:[]},i);a instanceof Promise?r.push(a.then(t=>rx(t,n,e))):rx(a,n,e)}return r.length?Promise.all(r).then(()=>n):n}});function ax(e,t,n,i,s){if(e.issues.length){if(s&&!(n in i))return;t.issues.push(...Ak(n,e.issues))}void 0===e.value?n in i&&(t.value[n]=void 0):t.value[n]=e.value}function lx(e){const t=Object.keys(e.shape);for(const n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);const n=(i=e.shape,Object.keys(i).filter(e=>"optional"===i[e]._zod.optin&&"optional"===i[e]._zod.optout));var i;return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function cx(e,t,n,i,s,r){const o=[],a=s.keySet,l=s.catchall._zod,c=l.def.type,h="optional"===l.optout;for(const s in t){if(a.has(s))continue;if("never"===c){o.push(s);continue}const r=l.run({value:t[s],issues:[]},i);r instanceof Promise?e.push(r.then(e=>ax(e,n,s,t,h))):ax(r,n,s,t,h)}return o.length&&n.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:r}),e.length?Promise.all(e).then(()=>n):n}const hx=ek("$ZodObject",(e,t)=>{Ew.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!n?.get){const e=t.shape;Object.defineProperty(t,"shape",{get:()=>{const n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}const i=ak(()=>lx(t));uk(e._zod,"propValues",()=>{const e=t.shape,n={};for(const t in e){const i=e[t]._zod;if(i.values){n[t]??(n[t]=new Set);for(const e of i.values)n[t].add(e)}}return n});const s=gk,r=t.catchall;let o;e._zod.parse=(t,n)=>{o??(o=i.value);const a=t.value;if(!s(a))return t.issues.push({expected:"object",code:"invalid_type",input:a,inst:e}),t;t.value={};const l=[],c=o.shape;for(const e of o.keys){const i=c[e],s="optional"===i._zod.optout,r=i._zod.run({value:a[e],issues:[]},n);r instanceof Promise?l.push(r.then(n=>ax(n,t,e,a,s))):ax(r,t,e,a,s)}return r?cx(l,a,t,n,i.value,e):l.length?Promise.all(l).then(()=>t):t}}),ux=ek("$ZodObjectJIT",(e,t)=>{hx.init(e,t);const n=e._zod.parse,i=ak(()=>lx(t));let s;const r=gk,o=!ik.jitless,a=o&&bk.value,l=t.catchall;let c;e._zod.parse=(h,u)=>{c??(c=i.value);const d=h.value;return r(d)?o&&a&&!1===u?.async&&!0!==u.jitless?(s||(s=(e=>{const t=new Ow(["shape","payload","ctx"]),n=i.value,s=e=>{const t=pk(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const r=Object.create(null);let o=0;for(const e of n.keys)r[e]="key_"+o++;t.write("const newResult = {};");for(const i of n.keys){const n=r[i],o=pk(i),a=e[i],l="optional"===a?._zod?.optout;t.write(`const ${n} = ${s(i)};`),l?t.write(`\n if (${n}.issues.length) {\n if (${o} in input) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${o}, ...iss.path] : [${o}]\n })));\n }\n }\n \n if (${n}.value === undefined) {\n if (${o} in input) {\n newResult[${o}] = undefined;\n }\n } else {\n newResult[${o}] = ${n}.value;\n }\n \n `):t.write(`\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${o}, ...iss.path] : [${o}]\n })));\n }\n \n if (${n}.value === undefined) {\n if (${o} in input) {\n newResult[${o}] = undefined;\n }\n } else {\n newResult[${o}] = ${n}.value;\n }\n \n `)}t.write("payload.value = newResult;"),t.write("return payload;");const a=t.compile();return(t,n)=>a(e,t,n)})(t.shape)),h=s(h,u),l?cx([],d,h,u,c,e):h):n(h,u):(h.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),h)}});function dx(e,t,n,i){for(const n of e)if(0===n.issues.length)return t.value=n.value,t;const s=e.filter(e=>!Ck(e));return 1===s.length?(t.value=s[0].value,s[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Nk(e,i,sk())))}),t)}const fx=ek("$ZodUnion",(e,t)=>{Ew.init(e,t),uk(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),uk(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),uk(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),uk(e._zod,"pattern",()=>{if(t.options.every(e=>e._zod.pattern)){const e=t.options.map(e=>e._zod.pattern);return new RegExp(`^(${e.map(e=>ck(e.source)).join("|")})$`)}});const n=1===t.options.length,i=t.options[0]._zod.run;e._zod.parse=(s,r)=>{if(n)return i(s,r);let o=!1;const a=[];for(const e of t.options){const t=e._zod.run({value:s.value,issues:[]},r);if(t instanceof Promise)a.push(t),o=!0;else{if(0===t.issues.length)return t;a.push(t)}}return o?Promise.all(a).then(t=>dx(t,s,e,r)):dx(a,s,e,r)}}),px=ek("$ZodIntersection",(e,t)=>{Ew.init(e,t),e._zod.parse=(e,n)=>{const i=e.value,s=t.left._zod.run({value:i,issues:[]},n),r=t.right._zod.run({value:i,issues:[]},n);return s instanceof Promise||r instanceof Promise?Promise.all([s,r]).then(([t,n])=>gx(e,t,n)):gx(e,s,r)}});function mx(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(yk(e)&&yk(t)){const n=Object.keys(t),i=Object.keys(e).filter(e=>-1!==n.indexOf(e)),s={...e,...t};for(const n of i){const i=mx(e[n],t[n]);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};s[n]=i.data}return{valid:!0,data:s}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let i=0;i<e.length;i++){const s=mx(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function gx(e,t,n){const i=new Map;let s;for(const n of t.issues)if("unrecognized_keys"===n.code){s??(s=n);for(const e of n.keys)i.has(e)||i.set(e,{}),i.get(e).l=!0}else e.issues.push(n);for(const t of n.issues)if("unrecognized_keys"===t.code)for(const e of t.keys)i.has(e)||i.set(e,{}),i.get(e).r=!0;else e.issues.push(t);const r=[...i].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(r.length&&s&&e.issues.push({...s,keys:r}),Ck(e))return e;const o=mx(t.value,n.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const bx=ek("$ZodRecord",(e,t)=>{Ew.init(e,t),e._zod.parse=(n,i)=>{const s=n.value;if(!yk(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),n;const r=[],o=t.keyType._zod.values;if(o){n.value={};const a=new Set;for(const e of o)if("string"==typeof e||"number"==typeof e||"symbol"==typeof e){a.add("number"==typeof e?e.toString():e);const o=t.valueType._zod.run({value:s[e],issues:[]},i);o instanceof Promise?r.push(o.then(t=>{t.issues.length&&n.issues.push(...Ak(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...Ak(e,o.issues)),n.value[e]=o.value)}let l;for(const e in s)a.has(e)||(l=l??[],l.push(e));l&&l.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:l})}else{n.value={};for(const o of Reflect.ownKeys(s)){if("__proto__"===o)continue;let a=t.keyType._zod.run({value:o,issues:[]},i);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if("string"==typeof o&&fw.test(o)&&a.issues.length){const e=t.keyType._zod.run({value:Number(o),issues:[]},i);if(e instanceof Promise)throw new Error("Async schemas not supported in object keys currently");0===e.issues.length&&(a=e)}if(a.issues.length){"loose"===t.mode?n.value[o]=s[o]:n.issues.push({code:"invalid_key",origin:"record",issues:a.issues.map(e=>Nk(e,i,sk())),input:o,path:[o],inst:e});continue}const l=t.valueType._zod.run({value:s[o],issues:[]},i);l instanceof Promise?r.push(l.then(e=>{e.issues.length&&n.issues.push(...Ak(o,e.issues)),n.value[a.value]=e.value})):(l.issues.length&&n.issues.push(...Ak(o,l.issues)),n.value[a.value]=l.value)}}return r.length?Promise.all(r).then(()=>n):n}}),yx=ek("$ZodEnum",(e,t)=>{Ew.init(e,t);const n=rk(t.entries),i=new Set(n);e._zod.values=i,e._zod.pattern=new RegExp(`^(${n.filter(e=>kk.has(typeof e)).map(e=>"string"==typeof e?wk(e):e.toString()).join("|")})$`),e._zod.parse=(t,s)=>{const r=t.value;return i.has(r)||t.issues.push({code:"invalid_value",values:n,input:r,inst:e}),t}}),vx=ek("$ZodTransform",(e,t)=>{Ew.init(e,t),e._zod.parse=(n,i)=>{if("backward"===i.direction)throw new nk(e.constructor.name);const s=t.transform(n.value,n);if(i.async){return(s instanceof Promise?s:Promise.resolve(s)).then(e=>(n.value=e,n))}if(s instanceof Promise)throw new tk;return n.value=s,n}});function kx(e,t){return e.issues.length&&void 0===t?{issues:[],value:void 0}:e}const wx=ek("$ZodOptional",(e,t)=>{Ew.init(e,t),e._zod.optin="optional",e._zod.optout="optional",uk(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),uk(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${ck(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if("optional"===t.innerType._zod.optin){const i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(t=>kx(t,e.value)):kx(i,e.value)}return void 0===e.value?e:t.innerType._zod.run(e,n)}}),xx=ek("$ZodExactOptional",(e,t)=>{wx.init(e,t),uk(e._zod,"values",()=>t.innerType._zod.values),uk(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Sx=ek("$ZodNullable",(e,t)=>{Ew.init(e,t),uk(e._zod,"optin",()=>t.innerType._zod.optin),uk(e._zod,"optout",()=>t.innerType._zod.optout),uk(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${ck(e.source)}|null)$`):void 0}),uk(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>null===e.value?e:t.innerType._zod.run(e,n)}),Cx=ek("$ZodDefault",(e,t)=>{Ew.init(e,t),e._zod.optin="optional",uk(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);if(void 0===e.value)return e.value=t.defaultValue,e;const i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>Ax(e,t)):Ax(i,t)}});function Ax(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}const Tx=ek("$ZodPrefault",(e,t)=>{Ew.init(e,t),e._zod.optin="optional",uk(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>("backward"===n.direction||void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Nx=ek("$ZodNonOptional",(e,t)=>{Ew.init(e,t),uk(e._zod,"values",()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter(e=>void 0!==e)):void 0}),e._zod.parse=(n,i)=>{const s=t.innerType._zod.run(n,i);return s instanceof Promise?s.then(t=>Ox(t,e)):Ox(s,e)}});function Ox(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Mx=ek("$ZodCatch",(e,t)=>{Ew.init(e,t),uk(e._zod,"optin",()=>t.innerType._zod.optin),uk(e._zod,"optout",()=>t.innerType._zod.optout),uk(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(i=>(e.value=i.value,i.issues.length&&(e.value=t.catchValue({...e,error:{issues:i.issues.map(e=>Nk(e,n,sk()))},input:e.value}),e.issues=[]),e)):(e.value=i.value,i.issues.length&&(e.value=t.catchValue({...e,error:{issues:i.issues.map(e=>Nk(e,n,sk()))},input:e.value}),e.issues=[]),e)}}),Ex=ek("$ZodPipe",(e,t)=>{Ew.init(e,t),uk(e._zod,"values",()=>t.in._zod.values),uk(e._zod,"optin",()=>t.in._zod.optin),uk(e._zod,"optout",()=>t.out._zod.optout),uk(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if("backward"===n.direction){const i=t.out._zod.run(e,n);return i instanceof Promise?i.then(e=>Dx(e,t.in,n)):Dx(i,t.in,n)}const i=t.in._zod.run(e,n);return i instanceof Promise?i.then(e=>Dx(e,t.out,n)):Dx(i,t.out,n)}});function Dx(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const _x=ek("$ZodReadonly",(e,t)=>{Ew.init(e,t),uk(e._zod,"propValues",()=>t.innerType._zod.propValues),uk(e._zod,"values",()=>t.innerType._zod.values),uk(e._zod,"optin",()=>t.innerType?._zod?.optin),uk(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(Ix):Ix(i)}});function Ix(e){return e.value=Object.freeze(e.value),e}const Bx=ek("$ZodCustom",(e,t)=>{gw.init(e,t),Ew.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{const i=n.value,s=t.fn(i);if(s instanceof Promise)return s.then(t=>Px(t,n,i,e));Px(s,n,i,e)}});function Px(e,t,n,i){if(!e){const e={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(e.params=i._zod.def.params),t.issues.push(Mk(e))}}var Rx;class $x{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const n=t[0];return this._map.set(e,n),n&&"object"==typeof n&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const n={...this.get(t)??{}};delete n.id;const i={...n,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}(Rx=globalThis).__zod_globalRegistry??(Rx.__zod_globalRegistry=new $x);const Lx=globalThis.__zod_globalRegistry;function zx(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Sk(t)})}function Fx(e,t){return new bw({check:"max_length",...Sk(t),maximum:e})}function jx(e,t){return new yw({check:"min_length",...Sk(t),minimum:e})}function Wx(e,t){return new vw({check:"length_equals",...Sk(t),length:e})}function Ux(e){return new Nw({check:"overwrite",tx:e})}function Vx(e){const t=function(e,t){const n=new gw({check:"custom",...Sk(t)});return n._zod.check=e,n}(n=>(n.addIssue=e=>{if("string"==typeof e)n.issues.push(Mk(e,n.value,t._zod.def));else{const i=e;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),n.issues.push(Mk(i))}},e(n.value,n)));return t}function Hx(e){let t=e?.target??"draft-2020-12";return"draft-4"===t&&(t="draft-04"),"draft-7"===t&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Lx,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function qx(e,t,n={path:[],schemaPath:[]}){var i;const s=e._zod.def,r=t.seen.get(e);if(r){r.count++;return n.schemaPath.includes(e)&&(r.cycle=n.path),r.schema}const o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);const a=e._zod.toJSONSchema?.();if(a)o.schema=a;else{const i={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,i);else{const n=o.schema,r=t.processors[s.type];if(!r)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${s.type}`);r(e,t,n,i)}const r=e._zod.parent;r&&(o.ref||(o.ref=r),qx(r,t,i),t.seen.get(r).isParent=!0)}const l=t.metadataRegistry.get(e);l&&Object.assign(o.schema,l),"input"===t.io&&Zx(e)&&(delete o.schema.examples,delete o.schema.default),"input"===t.io&&o.schema._prefault&&((i=o.schema).default??(i.default=o.schema._prefault)),delete o.schema._prefault;return t.seen.get(e).schema}function Kx(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const i=new Map;for(const t of e.seen.entries()){const n=e.metadataRegistry.get(t[0])?.id;if(n){const e=i.get(n);if(e&&e!==t[0])throw new Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(n,t[0])}}const s=t=>{if(t[1].schema.$ref)return;const i=t[1],{ref:s,defId:r}=(t=>{const i="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){const n=e.external.registry.get(t[0])?.id,s=e.external.uri??(e=>e);if(n)return{ref:s(n)};const r=t[1].defId??t[1].schema.id??"schema"+e.counter++;return t[1].defId=r,{defId:r,ref:`${s("__shared")}#/${i}/${r}`}}if(t[1]===n)return{ref:"#"};const s=`#/${i}/`,r=t[1].schema.id??"__schema"+e.counter++;return{defId:r,ref:s+r}})(t);i.def={...i.schema},r&&(i.defId=r);const o=i.schema;for(const e in o)delete o[e];o.$ref=s};if("throw"===e.cycles)for(const t of e.seen.entries()){const e=t[1];if(e.cycle)throw new Error(`Cycle detected: #/${e.cycle?.join("/")}/<root>\n\nSet the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const n of e.seen.entries()){const i=n[1];if(t===n[0]){s(n);continue}if(e.external){const i=e.external.registry.get(n[0])?.id;if(t!==n[0]&&i){s(n);continue}}const r=e.metadataRegistry.get(n[0])?.id;r?s(n):(i.cycle||i.count>1&&"ref"===e.reused)&&s(n)}}function Jx(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const i=t=>{const n=e.seen.get(t);if(null===n.ref)return;const s=n.def??n.schema,r={...s},o=n.ref;if(n.ref=null,o){i(o);const n=e.seen.get(o),a=n.schema;!a.$ref||"draft-07"!==e.target&&"draft-04"!==e.target&&"openapi-3.0"!==e.target?Object.assign(s,a):(s.allOf=s.allOf??[],s.allOf.push(a)),Object.assign(s,r);if(t._zod.parent===o)for(const e in s)"$ref"!==e&&"allOf"!==e&&(e in r||delete s[e]);if(a.$ref&&n.def)for(const e in s)"$ref"!==e&&"allOf"!==e&&e in n.def&&JSON.stringify(s[e])===JSON.stringify(n.def[e])&&delete s[e]}const a=t._zod.parent;if(a&&a!==o){i(a);const t=e.seen.get(a);if(t?.schema.$ref&&(s.$ref=t.schema.$ref,t.def))for(const e in s)"$ref"!==e&&"allOf"!==e&&e in t.def&&JSON.stringify(s[e])===JSON.stringify(t.def[e])&&delete s[e]}e.override({zodSchema:t,jsonSchema:s,path:n.path??[]})};for(const t of[...e.seen.entries()].reverse())i(t[0]);const s={};if("draft-2020-12"===e.target?s.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?s.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?s.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const n=e.external.registry.get(t)?.id;if(!n)throw new Error("Schema is missing an `id` property");s.$id=e.external.uri(n)}Object.assign(s,n.def??n.schema);const r=e.external?.defs??{};for(const t of e.seen.entries()){const e=t[1];e.def&&e.defId&&(r[e.defId]=e.def)}e.external||Object.keys(r).length>0&&("draft-2020-12"===e.target?s.$defs=r:s.definitions=r);try{const n=JSON.parse(JSON.stringify(s));return Object.defineProperty(n,"~standard",{value:{...t["~standard"],jsonSchema:{input:Yx(t,"input",e.processors),output:Yx(t,"output",e.processors)}},enumerable:!1,writable:!1}),n}catch(e){throw new Error("Error converting schema to JSON.")}}function Zx(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const i=e._zod.def;if("transform"===i.type)return!0;if("array"===i.type)return Zx(i.element,n);if("set"===i.type)return Zx(i.valueType,n);if("lazy"===i.type)return Zx(i.getter(),n);if("promise"===i.type||"optional"===i.type||"nonoptional"===i.type||"nullable"===i.type||"readonly"===i.type||"default"===i.type||"prefault"===i.type)return Zx(i.innerType,n);if("intersection"===i.type)return Zx(i.left,n)||Zx(i.right,n);if("record"===i.type||"map"===i.type)return Zx(i.keyType,n)||Zx(i.valueType,n);if("pipe"===i.type)return Zx(i.in,n)||Zx(i.out,n);if("object"===i.type){for(const e in i.shape)if(Zx(i.shape[e],n))return!0;return!1}if("union"===i.type){for(const e of i.options)if(Zx(e,n))return!0;return!1}if("tuple"===i.type){for(const e of i.items)if(Zx(e,n))return!0;return!(!i.rest||!Zx(i.rest,n))}return!1}const Yx=(e,t,n={})=>i=>{const{libraryOptions:s,target:r}=i??{},o=Hx({...s??{},target:r,io:t,processors:n});return qx(e,o),Kx(o,e),Jx(o,e)},Gx={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Qx=(e,t,n,i)=>{const s=e._zod.def;qx(s.innerType,t,i);t.seen.get(e).ref=s.innerType},Xx=ek("ZodISODateTime",(e,t)=>{Vw.init(e,t),CS.init(e,t)});function eS(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Sk(t)})}(Xx,e)}const tS=ek("ZodISODate",(e,t)=>{Hw.init(e,t),CS.init(e,t)});function nS(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...Sk(t)})}(tS,e)}const iS=ek("ZodISOTime",(e,t)=>{qw.init(e,t),CS.init(e,t)});function sS(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Sk(t)})}(iS,e)}const rS=ek("ZodISODuration",(e,t)=>{Kw.init(e,t),CS.init(e,t)});function oS(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...Sk(t)})}(rS,e)}const aS=ek("ZodError",(e,t)=>{Dk.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t=e=>e.message){const n={_errors:[]},i=e=>{for(const s of e.issues)if("invalid_union"===s.code&&s.errors.length)s.errors.map(e=>i({issues:e}));else if("invalid_key"===s.code)i({issues:s.issues});else if("invalid_element"===s.code)i({issues:s.issues});else if(0===s.path.length)n._errors.push(t(s));else{let e=n,i=0;for(;i<s.path.length;){const n=s.path[i];i===s.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(s))):e[n]=e[n]||{_errors:[]},e=e[n],i++}}};return i(e),n}(e,t)},flatten:{value:t=>function(e,t=e=>e.message){const n={},i=[];for(const s of e.issues)s.path.length>0?(n[s.path[0]]=n[s.path[0]]||[],n[s.path[0]].push(t(s))):i.push(t(s));return{formErrors:i,fieldErrors:n}}(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,ok,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,ok,2)}},isEmpty:{get:()=>0===e.issues.length}})},{Parent:Error}),lS=Ik(aS),cS=Bk(aS),hS=Pk(aS),uS=$k(aS),dS=zk(aS),fS=Fk(aS),pS=jk(aS),mS=Wk(aS),gS=Uk(aS),bS=Vk(aS),yS=Hk(aS),vS=qk(aS),kS=ek("ZodType",(e,t)=>(Ew.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Yx(e,"input"),output:Yx(e,"output")}}),e.toJSONSchema=((e,t={})=>n=>{const i=Hx({...n,processors:t});return qx(e,i),Kx(i,e),Jx(i,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(fk(t,{checks:[...t.checks??[],...n.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>xk(e,t,n),e.brand=()=>e,e.register=(t,n)=>(t.add(e,n),e),e.parse=(t,n)=>lS(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>hS(e,t,n),e.parseAsync=async(t,n)=>cS(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>uS(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>dS(e,t,n),e.decode=(t,n)=>fS(e,t,n),e.encodeAsync=async(t,n)=>pS(e,t,n),e.decodeAsync=async(t,n)=>mS(e,t,n),e.safeEncode=(t,n)=>gS(e,t,n),e.safeDecode=(t,n)=>bS(e,t,n),e.safeEncodeAsync=async(t,n)=>yS(e,t,n),e.safeDecodeAsync=async(t,n)=>vS(e,t,n),e.refine=(t,n)=>e.check(function(e,t={}){return function(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Sk(n)})}(fC,e,t)}(t,n)),e.superRefine=t=>e.check(Vx(t)),e.overwrite=t=>e.check(Ux(t)),e.optional=()=>nC(e),e.exactOptional=()=>new iC({type:"optional",innerType:e}),e.nullable=()=>rC(e),e.nullish=()=>nC(rC(e)),e.nonoptional=t=>function(e,t){return new lC({type:"nonoptional",innerType:e,...Sk(t)})}(e,t),e.array=()=>{return function(e,t,n){return new e({type:"array",element:t,...Sk(n)})}(JS,e,t);var t},e.or=t=>{return new YS({type:"union",options:[e,t],...Sk(n)});var n},e.and=t=>new GS({type:"intersection",left:e,right:t}),e.transform=t=>uC(e,new eC({type:"transform",transform:t})),e.default=t=>{return n=t,new oC({type:"default",innerType:e,get defaultValue(){return"function"==typeof n?n():vk(n)}});var n},e.prefault=t=>{return n=t,new aC({type:"prefault",innerType:e,get defaultValue(){return"function"==typeof n?n():vk(n)}});var n},e.catch=t=>{return new cC({type:"catch",innerType:e,catchValue:"function"==typeof(n=t)?n:()=>n});var n},e.pipe=t=>uC(e,t),e.readonly=()=>new dC({type:"readonly",innerType:e}),e.describe=t=>{const n=e.clone();return Lx.add(n,{description:t}),n},Object.defineProperty(e,"description",{get:()=>Lx.get(e)?.description,configurable:!0}),e.meta=(...t)=>{if(0===t.length)return Lx.get(e);const n=e.clone();return Lx.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),wS=ek("_ZodString",(e,t)=>{Dw.init(e,t),kS.init(e,t),e._zod.processJSONSchema=(t,n,i)=>((e,t,n)=>{const i=n;i.type="string";const{minimum:s,maximum:r,format:o,patterns:a,contentEncoding:l}=e._zod.bag;if("number"==typeof s&&(i.minLength=s),"number"==typeof r&&(i.maxLength=r),o&&(i.format=Gx[o]??o,""===i.format&&delete i.format,"time"===o&&delete i.format),l&&(i.contentEncoding=l),a&&a.size>0){const e=[...a];1===e.length?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({..."draft-07"===t.target||"draft-04"===t.target||"openapi-3.0"===t.target?{type:"string"}:{},pattern:e.source}))])}})(e,t,n);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(function(e,t){return new ww({check:"string_format",format:"regex",...Sk(t),pattern:e})}(...t)),e.includes=(...t)=>e.check(function(e,t){return new Cw({check:"string_format",format:"includes",...Sk(t),includes:e})}(...t)),e.startsWith=(...t)=>e.check(function(e,t){return new Aw({check:"string_format",format:"starts_with",...Sk(t),prefix:e})}(...t)),e.endsWith=(...t)=>e.check(function(e,t){return new Tw({check:"string_format",format:"ends_with",...Sk(t),suffix:e})}(...t)),e.min=(...t)=>e.check(jx(...t)),e.max=(...t)=>e.check(Fx(...t)),e.length=(...t)=>e.check(Wx(...t)),e.nonempty=(...t)=>e.check(jx(1,...t)),e.lowercase=t=>e.check(function(e){return new xw({check:"string_format",format:"lowercase",...Sk(e)})}(t)),e.uppercase=t=>e.check(function(e){return new Sw({check:"string_format",format:"uppercase",...Sk(e)})}(t)),e.trim=()=>e.check(Ux(e=>e.trim())),e.normalize=(...t)=>e.check(function(e){return Ux(t=>t.normalize(e))}(...t)),e.toLowerCase=()=>e.check(Ux(e=>e.toLowerCase())),e.toUpperCase=()=>e.check(Ux(e=>e.toUpperCase())),e.slugify=()=>e.check(Ux(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}),xS=ek("ZodString",(e,t)=>{Dw.init(e,t),wS.init(e,t),e.email=t=>e.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Sk(t)})}(AS,t)),e.url=t=>e.check(function(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Sk(t)})}(OS,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Sk(t)})}(US,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Sk(t)})}(MS,t)),e.guid=t=>e.check(zx(TS,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Sk(t)})}(NS,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Sk(t)})}(NS,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Sk(t)})}(NS,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Sk(t)})}(NS,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Sk(t)})}(ES,t)),e.guid=t=>e.check(zx(TS,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Sk(t)})}(DS,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Sk(t)})}(_S,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Sk(t)})}(IS,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Sk(t)})}(FS,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Sk(t)})}(jS,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Sk(t)})}(BS,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Sk(t)})}(PS,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Sk(t)})}(RS,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Sk(t)})}($S,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Sk(t)})}(LS,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Sk(t)})}(zS,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Sk(t)})}(WS,t)),e.datetime=t=>e.check(eS(t)),e.date=t=>e.check(nS(t)),e.time=t=>e.check(sS(t)),e.duration=t=>e.check(oS(t))});function SS(e){return function(e,t){return new e({type:"string",...Sk(t)})}(xS,e)}const CS=ek("ZodStringFormat",(e,t)=>{_w.init(e,t),wS.init(e,t)}),AS=ek("ZodEmail",(e,t)=>{Pw.init(e,t),CS.init(e,t)}),TS=ek("ZodGUID",(e,t)=>{Iw.init(e,t),CS.init(e,t)}),NS=ek("ZodUUID",(e,t)=>{Bw.init(e,t),CS.init(e,t)}),OS=ek("ZodURL",(e,t)=>{Rw.init(e,t),CS.init(e,t)}),MS=ek("ZodEmoji",(e,t)=>{$w.init(e,t),CS.init(e,t)}),ES=ek("ZodNanoID",(e,t)=>{Lw.init(e,t),CS.init(e,t)}),DS=ek("ZodCUID",(e,t)=>{zw.init(e,t),CS.init(e,t)}),_S=ek("ZodCUID2",(e,t)=>{Fw.init(e,t),CS.init(e,t)}),IS=ek("ZodULID",(e,t)=>{jw.init(e,t),CS.init(e,t)}),BS=ek("ZodXID",(e,t)=>{Ww.init(e,t),CS.init(e,t)}),PS=ek("ZodKSUID",(e,t)=>{Uw.init(e,t),CS.init(e,t)}),RS=ek("ZodIPv4",(e,t)=>{Jw.init(e,t),CS.init(e,t)}),$S=ek("ZodIPv6",(e,t)=>{Zw.init(e,t),CS.init(e,t)}),LS=ek("ZodCIDRv4",(e,t)=>{Yw.init(e,t),CS.init(e,t)}),zS=ek("ZodCIDRv6",(e,t)=>{Gw.init(e,t),CS.init(e,t)}),FS=ek("ZodBase64",(e,t)=>{Xw.init(e,t),CS.init(e,t)}),jS=ek("ZodBase64URL",(e,t)=>{ex.init(e,t),CS.init(e,t)}),WS=ek("ZodE164",(e,t)=>{tx.init(e,t),CS.init(e,t)}),US=ek("ZodJWT",(e,t)=>{nx.init(e,t),CS.init(e,t)}),VS=ek("ZodUnknown",(e,t)=>{ix.init(e,t),kS.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}});function HS(){return new VS({type:"unknown"})}const qS=ek("ZodNever",(e,t)=>{sx.init(e,t),kS.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.not={}})(0,0,t)});function KS(e){return function(e,t){return new e({type:"never",...Sk(t)})}(qS,e)}const JS=ek("ZodArray",(e,t)=>{ox.init(e,t),kS.init(e,t),e._zod.processJSONSchema=(t,n,i)=>((e,t,n,i)=>{const s=n,r=e._zod.def,{minimum:o,maximum:a}=e._zod.bag;"number"==typeof o&&(s.minItems=o),"number"==typeof a&&(s.maxItems=a),s.type="array",s.items=qx(r.element,t,{...i,path:[...i.path,"items"]})})(e,t,n,i),e.element=t.element,e.min=(t,n)=>e.check(jx(t,n)),e.nonempty=t=>e.check(jx(1,t)),e.max=(t,n)=>e.check(Fx(t,n)),e.length=(t,n)=>e.check(Wx(t,n)),e.unwrap=()=>e.element});const ZS=ek("ZodObject",(e,t)=>{ux.init(e,t),kS.init(e,t),e._zod.processJSONSchema=(t,n,i)=>((e,t,n,i)=>{const s=n,r=e._zod.def;s.type="object",s.properties={};const o=r.shape;for(const e in o)s.properties[e]=qx(o[e],t,{...i,path:[...i.path,"properties",e]});const a=new Set(Object.keys(o)),l=new Set([...a].filter(e=>{const n=r.shape[e]._zod;return"input"===t.io?void 0===n.optin:void 0===n.optout}));l.size>0&&(s.required=Array.from(l)),"never"===r.catchall?._zod.def.type?s.additionalProperties=!1:r.catchall?r.catchall&&(s.additionalProperties=qx(r.catchall,t,{...i,path:[...i.path,"additionalProperties"]})):"output"===t.io&&(s.additionalProperties=!1)})(e,t,n,i),uk(e,"shape",()=>t.shape),e.keyof=()=>function(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new XS({type:"enum",entries:n,...Sk(t)})}(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:HS()}),e.loose=()=>e.clone({...e._zod.def,catchall:HS()}),e.strict=()=>e.clone({...e._zod.def,catchall:KS()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>function(e,t){if(!yk(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const n=e._zod.def.shape;for(const e in t)if(void 0!==Object.getOwnPropertyDescriptor(n,e))throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=fk(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return dk(this,"shape",n),n}});return xk(e,i)}(e,t),e.safeExtend=t=>function(e,t){if(!yk(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=fk(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return dk(this,"shape",n),n}});return xk(e,n)}(e,t),e.merge=t=>function(e,t){const n=fk(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return dk(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return xk(e,n)}(e,t),e.pick=t=>function(e,t){const n=e._zod.def,i=n.checks;if(i&&i.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return xk(e,fk(e._zod.def,{get shape(){const e={};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(e[i]=n.shape[i])}return dk(this,"shape",e),e},checks:[]}))}(e,t),e.omit=t=>function(e,t){const n=e._zod.def,i=n.checks;if(i&&i.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=fk(e._zod.def,{get shape(){const i={...e._zod.def.shape};for(const e in t){if(!(e in n.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete i[e]}return dk(this,"shape",i),i},checks:[]});return xk(e,s)}(e,t),e.partial=(...t)=>function(e,t,n){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const s=fk(t._zod.def,{get shape(){const i=t._zod.def.shape,s={...i};if(n)for(const t in n){if(!(t in i))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(s[t]=e?new e({type:"optional",innerType:i[t]}):i[t])}else for(const t in i)s[t]=e?new e({type:"optional",innerType:i[t]}):i[t];return dk(this,"shape",s),s},checks:[]});return xk(t,s)}(tC,e,t[0]),e.required=(...t)=>function(e,t,n){const i=fk(t._zod.def,{get shape(){const i=t._zod.def.shape,s={...i};if(n)for(const t in n){if(!(t in s))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(s[t]=new e({type:"nonoptional",innerType:i[t]}))}else for(const t in i)s[t]=new e({type:"nonoptional",innerType:i[t]});return dk(this,"shape",s),s}});return xk(t,i)}(lC,e,t[0])});const YS=ek("ZodUnion",(e,t)=>{fx.init(e,t),kS.init(e,t),e._zod.processJSONSchema=(t,n,i)=>((e,t,n,i)=>{const s=e._zod.def,r=!1===s.inclusive,o=s.options.map((e,n)=>qx(e,t,{...i,path:[...i.path,r?"oneOf":"anyOf",n]}));r?n.oneOf=o:n.anyOf=o})(e,t,n,i),e.options=t.options});const GS=ek("ZodIntersection",(e,t)=>{px.init(e,t),kS.init(e,t),e._zod.processJSONSchema=(t,n,i)=>((e,t,n,i)=>{const s=e._zod.def,r=qx(s.left,t,{...i,path:[...i.path,"allOf",0]}),o=qx(s.right,t,{...i,path:[...i.path,"allOf",1]}),a=e=>"allOf"in e&&1===Object.keys(e).length,l=[...a(r)?r.allOf:[r],...a(o)?o.allOf:[o]];n.allOf=l})(e,t,n,i)});const QS=ek("ZodRecord",(e,t)=>{bx.init(e,t),kS.init(e,t),e._zod.processJSONSchema=(t,n,i)=>((e,t,n,i)=>{const s=n,r=e._zod.def;s.type="object";const o=r.keyType,a=o._zod.bag,l=a?.patterns;if("loose"===r.mode&&l&&l.size>0){const e=qx(r.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});s.patternProperties={};for(const t of l)s.patternProperties[t.source]=e}else"draft-07"!==t.target&&"draft-2020-12"!==t.target||(s.propertyNames=qx(r.keyType,t,{...i,path:[...i.path,"propertyNames"]})),s.additionalProperties=qx(r.valueType,t,{...i,path:[...i.path,"additionalProperties"]});const c=o._zod.values;if(c){const e=[...c].filter(e=>"string"==typeof e||"number"==typeof e);e.length>0&&(s.required=e)}})(e,t,n,i),e.keyType=t.keyType,e.valueType=t.valueType});const XS=ek("ZodEnum",(e,t)=>{yx.init(e,t),kS.init(e,t),e._zod.processJSONSchema=(t,n,i)=>((e,t,n)=>{const i=rk(e._zod.def.entries);i.every(e=>"number"==typeof e)&&(n.type="number"),i.every(e=>"string"==typeof e)&&(n.type="string"),n.enum=i})(e,0,n),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(e,i)=>{const s={};for(const i of e){if(!n.has(i))throw new Error(`Key ${i} not found in enum`);s[i]=t.entries[i]}return new XS({...t,checks:[],...Sk(i),entries:s})},e.exclude=(e,i)=>{const s={...t.entries};for(const t of e){if(!n.has(t))throw new Error(`Key ${t} not found in enum`);delete s[t]}return new XS({...t,checks:[],...Sk(i),entries:s})}});const eC=ek("ZodTransform",(e,t)=>{vx.init(e,t),kS.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Transforms cannot be represented in JSON Schema")})(0,e),e._zod.parse=(n,i)=>{if("backward"===i.direction)throw new nk(e.constructor.name);n.addIssue=i=>{if("string"==typeof i)n.issues.push(Mk(i,n.value,t));else{const t=i;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=n.value),t.inst??(t.inst=e),n.issues.push(Mk(t))}};const s=t.transform(n.value,n);return s instanceof Promise?s.then(e=>(n.value=e,n)):(n.value=s,n)}});const tC=ek("ZodOptional",(e,t)=>{wx.init(e,t),kS.init(e,t),e._zod.processJSONSchema=(t,n,i)=>Qx(e,t,0,i),e.unwrap=()=>e._zod.def.innerType});function nC(e){return new tC({type:"optional",innerType:e})}const iC=ek("ZodExactOptional",(e,t)=>{xx.init(e,t),kS.init(e,t),e._zod.processJSONSchema=(t,n,i)=>Qx(e,t,0,i),e.unwrap=()=>e._zod.def.innerType});const sC=ek("ZodNullable",(e,t)=>{Sx.init(e,t),kS.init(e,t),e._zod.processJSONSchema=(t,n,i)=>((e,t,n,i)=>{const s=e._zod.def,r=qx(s.innerType,t,i),o=t.seen.get(e);"openapi-3.0"===t.target?(o.ref=s.innerType,n.nullable=!0):n.anyOf=[r,{type:"null"}]})(e,t,n,i),e.unwrap=()=>e._zod.def.innerType});function rC(e){return new sC({type:"nullable",innerType:e})}const oC=ek("ZodDefault",(e,t)=>{Cx.init(e,t),kS.init(e,t),e._zod.processJSONSchema=(t,n,i)=>((e,t,n,i)=>{const s=e._zod.def;qx(s.innerType,t,i),t.seen.get(e).ref=s.innerType,n.default=JSON.parse(JSON.stringify(s.defaultValue))})(e,t,n,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});const aC=ek("ZodPrefault",(e,t)=>{Tx.init(e,t),kS.init(e,t),e._zod.processJSONSchema=(t,n,i)=>((e,t,n,i)=>{const s=e._zod.def;qx(s.innerType,t,i),t.seen.get(e).ref=s.innerType,"input"===t.io&&(n._prefault=JSON.parse(JSON.stringify(s.defaultValue)))})(e,t,n,i),e.unwrap=()=>e._zod.def.innerType});const lC=ek("ZodNonOptional",(e,t)=>{Nx.init(e,t),kS.init(e,t),e._zod.processJSONSchema=(t,n,i)=>((e,t,n,i)=>{const s=e._zod.def;qx(s.innerType,t,i),t.seen.get(e).ref=s.innerType})(e,t,0,i),e.unwrap=()=>e._zod.def.innerType});const cC=ek("ZodCatch",(e,t)=>{Mx.init(e,t),kS.init(e,t),e._zod.processJSONSchema=(t,n,i)=>((e,t,n,i)=>{const s=e._zod.def;let r;qx(s.innerType,t,i),t.seen.get(e).ref=s.innerType;try{r=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=r})(e,t,n,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});const hC=ek("ZodPipe",(e,t)=>{Ex.init(e,t),kS.init(e,t),e._zod.processJSONSchema=(t,n,i)=>((e,t,n,i)=>{const s=e._zod.def,r="input"===t.io?"transform"===s.in._zod.def.type?s.out:s.in:s.out;qx(r,t,i),t.seen.get(e).ref=r})(e,t,0,i),e.in=t.in,e.out=t.out});function uC(e,t){return new hC({type:"pipe",in:e,out:t})}const dC=ek("ZodReadonly",(e,t)=>{_x.init(e,t),kS.init(e,t),e._zod.processJSONSchema=(t,n,i)=>((e,t,n,i)=>{const s=e._zod.def;qx(s.innerType,t,i),t.seen.get(e).ref=s.innerType,n.readOnly=!0})(e,t,n,i),e.unwrap=()=>e._zod.def.innerType});const fC=ek("ZodCustom",(e,t)=>{Bx.init(e,t),kS.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Custom types cannot be represented in JSON Schema")})(0,e)});function pC(e){return`[36m${e}[0m`}function mC(e){return`[33m${e}[0m`}async function gC(e,t,n){const i=e.substring(1),s=await async function(e,t,n){const i=`https://api.github.com/repos/${e}/git/trees/${t}?recursive=1`,s=await bC(i,AC(n));if(!s.ok){if(404===s.status){const i=`https://api.github.com/repos/${e}`;return(await bC(i,AC(n))).ok?{kind:"error",message:`Version not found: https://github.com/${e}/releases/tag/${t}`}:{kind:"error",message:`Repository not found: https://github.com/${e}`}}throw new Error(`Github API request failed: ${s.status} ${s.statusText}`)}return{kind:"success",tree:await s.json()}}(i,t,n);if("error"===s.kind)return s;const r=s.tree,o={},a=r.tree.filter(e=>"blob"===e.type&&e.path.startsWith("skir-src/")&&e.path.endsWith(".skir")).map(async t=>{const s=await yC(i,t.sha,n);return{modulePath:e+t.path.substring(8),content:s}}),l=await Promise.all(a);for(const{modulePath:e,content:t}of l)o[e]=t;const c=r.tree.find(e=>"blob"===e.type&&"skir.yml"===e.path);if(!c)return{kind:"error",message:`Package ${e}@${t} is missing required skir.yml configuration file`};const h=function(e){const t=[],n=new Hv,i=Xv(e,{lineCounter:n}),s=e=>{const t=n.linePos(e);return{offset:e,lineNumber:t.line,colNumber:t.col}},r=(e,t)=>({start:s(e),end:s(t)}),o=e=>{const t=i.getIn(e,!0);if(t?.range)return r(t.range[0],t.range[1])},a=(e,n)=>{let i=e;const s=[];for(;0!==i.length;){if(o(i))break;s.push(i.at(-1)),i=i.slice(0,-1)}s.reverse();const r=s.map((e,t)=>"number"==typeof e?`[${e}]`:0===t?e:`.${String(e)}`).join(""),a=s.length?`Missing property '${r}': `:"";t.push({message:a+n,range:o(i)})};if(i.errors.length>0){for(const e of i.errors)t.push({message:e.message,range:r(e.pos[0],e.pos[1])});return{dependencies:void 0,errors:t}}const l=wC.safeParse(i.toJS());if(!l.success){for(const e of l.error.issues)a(e.path,e.message);return{dependencies:void 0,errors:t}}return{dependencies:l.data.dependencies,errors:t}}(await yC(i,c.sha,n));if(h.errors.length>0)return{kind:"error",message:h.errors.map(t=>function(e,t){const{message:n,range:i}=e,{skirConfigPath:s}=t;return[i?[pC(s),mC(i.start.lineNumber.toString()),mC(i.start.colNumber.toString())].join(":"):pC(s)," - ",(r="error",`[31m${r}[0m`),": ",n].join("");var r}(t,{skirConfigPath:`${e}/skir.yml`})).join("\n")};const u=h.dependencies??{};return{kind:"success",package:{packageId:e,version:t,modules:o,dependencies:u}}}async function bC(e,t,n=3){let i;for(let s=0;s<=n;s++){const r=await fetch(e,{headers:t});if(403!==r.status&&429!==r.status)return r;if(i=r,s===n)break;const o=r.headers.get("Retry-After"),a=o?1e3*parseInt(o,10):1e3*2**s;await new Promise(e=>setTimeout(e,a))}return i}async function yC(e,t,n){const i=`https://api.github.com/repos/${e}/git/blobs/${t}`,s=await bC(i,AC(n));if(!s.ok)throw new Error(`Failed to download file: ${s.status} ${s.statusText}`);const r=await s.json();return"base64"===r.encoding?function(e){const t=e.replace(/\s/g,""),n=atob(t),i=Uint8Array.from(n,e=>e.charCodeAt(0));return(new TextDecoder).decode(i)}(r.content):r.content}const vC=SS().regex(/^@[A-Za-z0-9-]+\/[A-Za-z0-9\-_.]+$/),kC=SS().regex(/^[A-Za-z0-9\-_./+]+$/),wC=function(e,t){const n={type:"object",shape:e??{},...Sk(t)};return new ZS(n)}({dependencies:(xC=vC,SC=kC,new QS({type:"record",keyType:xC,valueType:SC,...Sk(CC)})).default({})});var xC,SC,CC;function AC(e){const t={Accept:"application/vnd.github.v3+json"};return e&&(t.Authorization=`token ${e}`),t}class TC{constructor(e,t,n){this.cachedPackages=e,this.githubToken=t,this.packageDownloader=n,this.packageBundles={},this.dependencyChain=[],this.errors=[],this.allDependenciesOnDisk=!0}async run(e){for(const[t,n]of Object.entries(e))if(await this.getDependency(t,n),this.errors.length>0)return this.errors[0];const t=!(this.allDependenciesOnDisk&&Object.keys(e).length===Object.keys(this.cachedPackages).length);return{kind:"success",packages:Object.fromEntries(Object.entries(this.packageBundles).map(([e,t])=>[e,t.pkg])),changed:t}}async getDependency(e,t){this.dependencyChain.push({packageId:e,version:t});try{const n=this.packageBundles[e];if(n?.pkg.version===t)return;if(n)return void this.errors.push({kind:"error",message:[`Version conflict for package ${e}:`,`- ${NC(this.dependencyChain)}`,`- ${NC(n.dependencyChain)}`].join("\n")});let i=this.getCachedPackage(e,t);if(!i){this.allDependenciesOnDisk=!1;const n=await this.packageDownloader(e,t,this.githubToken);if("success"!==n.kind)return void this.errors.push(n);i=n.package}this.packageBundles[e]={pkg:i,dependencyChain:[...this.dependencyChain]};for(const[e,t]of Object.entries(i.dependencies))await this.getDependency(e,t)}finally{this.dependencyChain.pop()}}getCachedPackage(e,t){const n=this.cachedPackages[e];return n?.version===t?n:void 0}}function NC(e){return"main depends on "+e.map(e=>`${e.packageId}:${e.version}`).join(" which depends on ")}async function OC(e,t,n=gC){const i=function(e){const t=e.match(/^https:\/\/github\.com\/([^/]+)\/([^/]+)\/blob\/([^/]+)\/(.+)#L(\d+)$/);if(!t)return{kind:"error",message:`Invalid GitHub URL: ${e}`};const n=t[1],i=t[2],s=t[3],r=t[4],o=Number(t[5]);if(!r.startsWith("skir-src/")||!r.endsWith(".skir"))return{kind:"error",message:`URL must target a .skir file in skir-src: ${e}`};if(!Number.isInteger(o)||o<=0)return{kind:"error",message:`Invalid line number in URL: ${e}`};const a=`@${n}/${i}`,l=a+r.substring(8);return{kind:"success",packageId:a,version:s,modulePath:l,lineNumber:o-1}}(e);if("error"===i.kind)return i;const{packageId:s,version:r,modulePath:o,lineNumber:a}=i,l=new TC({},t,n),c=await l.run({[s]:r});if("error"===c.kind)return c;const h=new Map;for(const e of Object.values(c.packages))for(const[t,n]of Object.entries(e.modules))h.set(t,n);const u=Fg.compile(h);if(u.errors.length>0)return{kind:"error",message:u.errors[0].message||"Compilation failed"};const d=u.modules.get(o);if(!d)return{kind:"error",message:`Module not found: ${o}`};const f=d.result.records.find(e=>e.record.name.line.lineNumber===a);return f?{kind:"success",record:f.record,moduleSet:u}:{kind:"error",message:`No record found at line ${a+1} in ${o}`}}class MC{static from(e){return this.fromUnixMillis(e.getTime())}static fromUnixMillis(e){if(e<=this.MIN.unixMillis)return MC.MIN;if(e<MC.MAX.unixMillis)return new MC(Math.round(e));if(Number.isNaN(e))throw new Error("Cannot construct Timestamp from NaN");return MC.MAX}static fromUnixSeconds(e){return this.fromUnixMillis(1e3*e)}static parse(e){return this.fromUnixMillis(Date.parse(e))}static now(){return this.fromUnixMillis(Date.now())}constructor(e){this.unixMillis=e,Object.freeze(this)}get unixSeconds(){return this.unixMillis/1e3}toDate(){return new Date(this.unixMillis)}toString(){return this.toDate().toISOString()}}MC.UNIX_EPOCH=new MC(0),MC.MIN=new MC(-864e13),MC.MAX=new MC(864e13);class EC{static sliceOf(e,t=0,n){const{byteLength:i}=e;if(t<0&&(t=0),(void 0===n||n>i)&&(n=i),n<=t)return EC.EMPTY;if(e instanceof EC){if(t<=0&&i<=n)return e;{const i=e.byteOffset+t,s=n-t;return new EC(e.arrayBuffer,i,s)}}if(e instanceof ArrayBuffer)return new EC(e.slice(t,n));if(e instanceof SharedArrayBuffer){const i=e.slice(t,n),s=new ArrayBuffer(i.byteLength);return new Uint8Array(s).set(new Uint8Array(i)),new EC(s)}throw new TypeError(e)}static fromBase64(e){const t=atob(e),n=Uint8Array.from(t,e=>e.codePointAt(0));return new this(n.buffer)}static fromBase16(e){const t=new Uint8Array(e.length/2);for(let n=0;n<t.length;++n){const i=parseInt(e.substring(2*n,2*n+2),16);if(Number.isNaN(i))throw new Error("Not a valid Base64 string");t[n]=i}return new EC(t.buffer)}copyTo(e,t=0){new Uint8Array(e).set(this.uint8Array,t)}toBuffer(){return this.arrayBuffer.slice(this.byteOffset,this.byteOffset+this.byteLength)}toBase64(){const e=Array.from(this.uint8Array,e=>String.fromCodePoint(e)).join("");return btoa(e)}toBase16(){return[...this.uint8Array].map(e=>e.toString(16).padStart(2,"0")).join("")}at(e){return this.uint8Array[e<0?e+this.byteLength:e]}toString(){return`ByteString(${this.byteLength})`}constructor(e,t=0,n=e.byteLength){this.arrayBuffer=e,this.byteOffset=t,this.byteLength=n,this.uint8Array=new Uint8Array(e,t,n),Object.freeze(this)}}function DC(e){return QC[e]}EC.EMPTY=new EC(new ArrayBuffer(0));class _C{constructor(e,t){this.buffer=e,this.offset=0,this.dataView=new DataView(e),this.keepUnrecognizedValues=!!t}readUint8(){return this.dataView.getUint8(this.offset++)}}const IC=[e=>e.dataView.getUint16((e.offset+=2)-2,!0),e=>e.dataView.getUint32((e.offset+=4)-4,!0),e=>e.dataView.getBigUint64((e.offset+=8)-8,!0),e=>e.readUint8()-256,e=>e.dataView.getUint16((e.offset+=2)-2,!0)-65536,e=>e.dataView.getInt32((e.offset+=4)-4,!0),e=>e.dataView.getBigInt64((e.offset+=8)-8,!0),e=>e.dataView.getBigInt64((e.offset+=8)-8,!0),e=>e.dataView.getFloat32((e.offset+=4)-4,!0),e=>e.dataView.getFloat64((e.offset+=8)-8,!0)];function BC(e){const t=e.readUint8();return t<232?t:IC[t-232](e)}function PC(e){const t=BC(e);return"bigint"==typeof t?t:BigInt(Math.round(t))}class RC{constructor(){this.buffer=new ArrayBuffer(128),this.dataView=new DataView(this.buffer),this.offset=0,this.pieces=[],this.byteLength=0}writeUint8(e){this.reserve(1).setUint8(++this.offset-1,e)}writeUint16(e){this.reserve(2).setUint16((this.offset+=2)-2,e,!0)}writeUint32(e){this.reserve(4).setUint32((this.offset+=4)-4,e,!0)}writeInt32(e){this.reserve(4).setInt32((this.offset+=4)-4,e,!0)}writeHash64(e){this.reserve(8).setBigUint64((this.offset+=8)-8,e,!0)}writeInt64(e){this.reserve(8).setBigInt64((this.offset+=8)-8,e,!0)}writeFloat32(e){this.reserve(4).setFloat32((this.offset+=4)-4,e,!0)}writeFloat64(e){this.reserve(8).setFloat64((this.offset+=8)-8,e,!0)}putUtf8String(e){let t=this.dataView,n=0;for(;e;){const i=JC.encodeInto(e,new Uint8Array(t.buffer,this.offset));this.offset+=i.written,n+=i.written,(e=e.substring(i.read))&&(t=this.reserve(2*e.length))}return n}putBytes(e){const{buffer:t}=this,n=t.byteLength-this.offset,i=EC.sliceOf(e,0,n);i.copyTo(t,this.offset),this.offset+=i.byteLength;const s=e.byteLength-i.byteLength;if(s<=0)return;const r=EC.sliceOf(e,s);this.reserve(s),r.copyTo(t,this.offset),this.offset+=s}finalize(){return this.flush(),Object.freeze(this.pieces),Object.freeze(this),this}copyTo(e,t=0){const n=new Uint8Array(e);for(const e of this.pieces)n.set(e,t),t+=e.length}toBuffer(){const e=new ArrayBuffer(this.byteLength);return this.copyTo(e),e}reserve(e){if(this.offset<this.buffer.byteLength-e)return this.dataView;this.flush();const t=Math.max(this.byteLength,e);return this.offset=0,this.buffer=new ArrayBuffer(t),this.dataView=new DataView(this.buffer)}flush(){const{offset:e}=this;this.pieces.push(new Uint8Array(this.dataView.buffer,0,e)),this.byteLength+=e}}function $C(e,t){if(e<232)t.writeUint8(e);else if(e<65536)t.writeUint8(232),t.writeUint16(e);else{if(!(e<4294967296))throw new Error(`max length exceeded: ${e}`);t.writeUint8(233),t.writeUint32(e)}}class LC{fromJsonCode(e,t){return this.fromJson(JSON.parse(e),t)}fromBytes(e,t){const n=new _C(e,t);return n.offset=4,this.decode(n)}toJsonCode(e,t){const n="readable"===t?" ":void 0;return JSON.stringify(this.toJson(e,t),void 0,n)}toBytes(e){const t=new RC;return t.putUtf8String("skir"),this.encode(e,t),t.finalize()}isDefault(e){return!e}get typeDescriptor(){return this}asJson(){const e={};this.addRecordDefinitionsTo(e);return{type:this.typeSignature,records:Object.values(e)}}asJsonCode(){return JSON.stringify(this.asJson(),void 0," ")}transform(e,t){const n=e instanceof ArrayBuffer?this.fromBytes(e):this.fromJson(e);return"bytes"===t?this.toBytes(n).toBuffer():this.toJson(n,t)}}const zC={name:"UNKNOWN",number:0};class FC extends LC{constructor(){super(...arguments),this.kind="primitive"}get typeSignature(){return{kind:"primitive",value:this.primitive}}addRecordDefinitionsTo(e){}}const jC=new class extends FC{constructor(){super(...arguments),this.primitive="int32",this.defaultValue=0}toJson(e){return 0|e}fromJson(e){return 0|+e}encode(e,t){e<0?e>=-256?(t.writeUint8(235),t.writeUint8(e+256)):e>=-65536?(t.writeUint8(236),t.writeUint16(e+65536)):(t.writeUint8(237),t.writeInt32(e>=-2147483648?e:-2147483648)):e<232?t.writeUint8(e):e<65536?(t.writeUint8(232),t.writeUint16(e)):(t.writeUint8(233),t.writeUint32(e<=2147483647?e:2147483647))}decode(e){return 0|Number(BC(e))}};class WC extends FC{constructor(){super(...arguments),this.defaultValue=0}toJson(e){if(Number.isFinite(e))return e;if("number"==typeof e)return e.toString();throw new TypeError}fromJson(e){return+e}decode(e){return Number(BC(e))}isDefault(e){return 0===e}}class UC extends FC{constructor(){super(...arguments),this.defaultValue=BigInt(0)}fromJson(e){try{return BigInt(e)}catch(t){if("number"==typeof e)return BigInt(Math.round(e));throw t}}}const VC=BigInt("-9223372036854775808"),HC=BigInt("9223372036854775807");const qC=BigInt("18446744073709551615");class KC{constructor(e,t,n,i,s){this.name=e,this.property=t,this.number=n,this.serializer=i,this.doc=s}get type(){return this.serializer.typeDescriptor}get(e){return Reflect.get(e,this.property)}set(e,t){Reflect.set(e,this.property,t)}}const JC=new TextEncoder,ZC=new TextDecoder;class YC extends LC{constructor(e,t){super(),this.itemSerializer=e,this.keyExtractor=t,this.kind="array",this.defaultValue=hA}toJson(e,t){return e.map(e=>this.itemSerializer.toJson(e,t))}fromJson(e,t){return 0===e?hA:cA(e.map(e=>this.itemSerializer.fromJson(e,t)))}encode(e,t){const{length:n}=e;n<=3?t.writeUint8(246+n):(t.writeUint8(250),$C(n,t));const{itemSerializer:i}=this;for(let n=0;n<e.length;++n)i.encode(e[n],t)}decode(e){const t=e.readUint8();if(0===t||246===t)return hA;const n=250===t?BC(e):t-246,{itemSerializer:i}=this,s=new Array(n);for(let t=0;t<n;++t)s[t]=i.decode(e);return cA(s)}isDefault(e){return!e.length}get itemType(){return this.itemSerializer.typeDescriptor}get typeSignature(){return{kind:"array",value:{item:this.itemSerializer.typeSignature,key_extractor:this.keyExtractor}}}addRecordDefinitionsTo(e){this.itemSerializer.addRecordDefinitionsTo(e)}}class GC extends LC{constructor(e){super(),this.otherSerializer=e,this.kind="optional",this.defaultValue=null}toJson(e,t){return null!==e?this.otherSerializer.toJson(e,t):null}fromJson(e,t){return null!==e?this.otherSerializer.fromJson(e,t):null}encode(e,t){null===e?t.writeUint8(255):this.otherSerializer.encode(e,t)}decode(e){return 255===e.dataView.getUint8(e.offset)?(++e.offset,null):this.otherSerializer.decode(e)}isDefault(e){return null===e}get otherType(){return this.otherSerializer.typeDescriptor}get typeSignature(){return{kind:"optional",value:this.otherSerializer.typeSignature}}addRecordDefinitionsTo(e){this.otherSerializer.addRecordDefinitionsTo(e)}}const QC={bool:new class extends FC{constructor(){super(...arguments),this.primitive="bool",this.defaultValue=!1}toJson(e,t){return"readable"===t?!!e:e?1:0}fromJson(e){return!!e&&"0"!==e}encode(e,t){t.writeUint8(e?1:0)}decode(e){return!!BC(e)}},int32:jC,int64:new class extends UC{constructor(){super(...arguments),this.primitive="int64"}toJson(e){if(-9007199254740991<=e&&e<=9007199254740991)return Number(e);const t=BigInt(e).toString();return t.length<=18?t:e<VC?VC.toString():e<HC?t:HC.toString()}encode(e,t){e?-2147483648<=e&&e<=2147483647?jC.encode(Number(e),t):(t.writeUint8(238),t.writeInt64(e<VC?VC:e<HC?e:HC)):t.writeUint8(0)}decode(e){return PC(e)}},hash64:new class extends UC{constructor(){super(...arguments),this.primitive="hash64"}toJson(e){return e<=9007199254740991?e<=0?0:Number(e):(e=BigInt(e),qC<e?qC.toString():e.toString())}encode(e,t){e<232?t.writeUint8(e<=0?0:Number(e)):e<4294967296?e<65536?(t.writeUint8(232),t.writeUint16(Number(e))):(t.writeUint8(233),t.writeUint32(Number(e))):(t.writeUint8(234),t.writeHash64(e<=qC?e:qC))}decode(e){return PC(e)}},float32:new class extends WC{constructor(){super(...arguments),this.primitive="float32"}encode(e,t){0===e?t.writeUint8(0):(t.writeUint8(240),t.writeFloat32(e))}},float64:new class extends WC{constructor(){super(...arguments),this.primitive="float64"}encode(e,t){0===e?t.writeUint8(0):(t.writeUint8(241),t.writeFloat64(e))}},timestamp:new class extends FC{constructor(){super(...arguments),this.primitive="timestamp",this.defaultValue=MC.UNIX_EPOCH}toJson(e,t){return"readable"===t?{unix_millis:e.unixMillis,formatted:e.toDate().toISOString()}:e.unixMillis}fromJson(e){return MC.fromUnixMillis("number"==typeof e?e:"string"==typeof e?+e:e.unix_millis)}encode(e,t){const{unixMillis:n}=e;n?(t.writeUint8(239),t.writeInt64(BigInt(n))):t.writeUint8(0)}decode(e){const t=BC(e);return MC.fromUnixMillis(Number(t))}isDefault(e){return!e.unixMillis}},string:new class extends FC{constructor(){super(...arguments),this.primitive="string",this.defaultValue=""}toJson(e){if("string"==typeof e)return e;throw this.newTypeError(e)}fromJson(e){if("string"==typeof e)return e;if(0===e)return"";throw this.newTypeError(e)}encode(e,t){if(!e)return void t.writeUint8(242);t.writeUint8(243);const n=3*e.length;n<232?t.writeUint8(0):n<65536?(t.writeUint8(232),t.writeUint16(0)):(t.writeUint8(233),t.writeUint32(0));const{dataView:i,offset:s}=t,r=t.putUtf8String(e);n<232?i.setUint8(s-1,r):n<65536?i.setUint16(s-2,r,!0):i.setUint32(s-4,r,!0)}decode(e){const t=e.readUint8();if(0===t||242===t)return"";const n=BC(e);return ZC.decode(new Uint8Array(e.buffer,(e.offset+=n)-n,n))}newTypeError(e){return new TypeError("expected: string; actual: "+typeof e)}},bytes:new class extends FC{constructor(){super(...arguments),this.primitive="bytes",this.defaultValue=EC.EMPTY}toJson(e,t){return"readable"===t?"hex:"+e.toBase16():e.toBase64()}fromJson(e){if(0===e)return EC.EMPTY;const t=e;return t.startsWith("hex:")?EC.fromBase16(t.substring(4)):EC.fromBase64(t)}encode(e,t){const{byteLength:n}=e;n?(t.writeUint8(245),$C(n,t),t.putBytes(e)):t.writeUint8(244)}decode(e){const t=e.readUint8();if(0===t||244===t)return EC.EMPTY;const n=BC(e);return EC.sliceOf(e.buffer,e.offset,e.offset+=n)}isDefault(e){return!e.byteLength}}};function XC(e){const t=e.readUint8();if(!(t<232))switch(t-232){case 0:case 4:e.offset+=2;break;case 1:case 5:case 8:e.offset+=4;break;case 2:case 6:case 7:case 9:e.offset+=8;break;case 3:++e.offset;break;case 11:case 13:{const t=BC(e);e.offset+=t;break}case 15:case 19:case 20:case 21:case 22:XC(e);break;case 16:XC(e),XC(e);break;case 17:XC(e),XC(e),XC(e);break;case 18:{const t=BC(e);for(let n=0;n<t;++n)XC(e);break}}}class eA extends LC{constructor(){super(...arguments),this.token=Symbol(),this.name="",this.modulePath="",this.doc="",this.removedNumbers=new Set}init(e,t,n,i,s,r){this.name=e,this.modulePath=t,this.parentType=n,this.doc=i,this.removedNumbers=new Set(r),this.registerFieldsOrVariants(s),this.initialized=!0,aA(this)}get qualifiedName(){const{name:e,parentType:t}=this;return t?`${t.name}.${e}`:e}addRecordDefinitionsTo(e){const t=`${this.modulePath}:${this.qualifiedName}`;if(e[t])return;const n=this.makeRecordDefinition(t);this.doc&&(n.doc=this.doc),this.removedNumbers.size&&(n.removed_numbers=[...this.removedNumbers]),e[t]=n;for(const t of this.dependencies())t.addRecordDefinitionsTo(e)}}class tA{constructor(e,t,n,i){this.token=e,this.totalSlots=t,this.json=n,this.bytes=i,Object.freeze(this)}}class nA extends eA{constructor(e,t,n){super(),this.defaultValue=e,this.createFn=t,this.newMutableFn=n,this.kind="struct",this.fields=[],this.fieldMapping={},this.reversedFields=[],this.slots=[],this.recognizedSlots=0,this.zeros=[],this.initializerTemplate={}}toJson(e,t){if(e===this.defaultValue)return"readable"===t?{}:[];if("readable"===t){const{fields:n}=this,i={};for(const s of n){const{serializer:n}=s,r=e[s.property];s.serializer.isDefault(r)||(i[s.name]=n.toJson(r,t))}return i}{const{slots:n}=this;let i;const s=e["^"];if(s&&s.json&&s.token===this.token){i=this.zeros.concat(s.json);for(const n of this.fields)i[n.number]=n.serializer.toJson(e[n.property],t)}else{i=[];const s=this.getArrayLength(e);for(let r=0;r<s;++r){const s=n[r];i[r]=s?s.serializer.toJson(e[s.property],t):0}}return i}}fromJson(e,t){if(!e)return this.defaultValue;const n=Object.assign({},this.initializerTemplate);if(e instanceof Array){const{slots:i,recognizedSlots:s}=this;if(e.length>s){if(t){const t=new tA(this.token,e.length,oA(e.slice(s)));n["^"]=t}e=e.slice(0,s)}for(let s=0;s<e.length&&s<i.length;++s){const r=i[s];r&&(n[r.property]=r.serializer.fromJson(e[s],t))}return this.createFn(n)}if(e instanceof Object){const{fieldMapping:i}=this;for(const s in e){const r=i[s];r&&(n[r.property]=r.serializer.fromJson(e[s],t))}return this.createFn(n)}throw TypeError()}encode(e,t){let n,i,s;const r=e["^"];r&&r.bytes&&r.token===this.token?(n=r.totalSlots,i=this.recognizedSlots,s=r.bytes):n=i=this.getArrayLength(e),n<=3?t.writeUint8(246+n):(t.writeUint8(250),$C(n,t));const{slots:o}=this;for(let n=0;n<i;++n){const i=o[n];i?i.serializer.encode(e[i.property],t):t.writeUint8(0)}s&&t.putBytes(s)}decode(e){const t=e.readUint8();if(0===t||246===t)return this.defaultValue;const n=Object.assign({},this.initializerTemplate),i=250===t?BC(e):t-246,{slots:s,recognizedSlots:r}=this;for(let t=0;t<i&&t<r;++t){const i=s[t];i?n[i.property]=i.serializer.decode(e):XC(e)}if(i>r){const t=e.offset;for(let t=r;t<i;++t)XC(e);if(e.keepUnrecognizedValues){const s=e.offset,r=EC.sliceOf(e.buffer,t,s),o=new tA(this.token,i,void 0,r);n["^"]=o}}return this.createFn(n)}getArrayLength(e){const{reversedFields:t}=this;for(let n=0;n<t.length;++n){const i=t[n];if(!i.serializer.isDefault(e[i.property]))return i.number+1}return 0}isDefault(e){return e===this.defaultValue||!e["^"]&&this.fields.every(t=>t.serializer.isDefault(e[t.property]))}get typeSignature(){return{kind:"record",value:`${this.modulePath}:${this.qualifiedName}`}}getField(e){return this.fieldMapping[e]}newMutable(e){return this.newMutableFn(e)}registerFieldsOrVariants(e){for(const t of e){const{name:e,number:n,property:i}=t;this.fields.push(t),this.slots[n]=t,this.fieldMapping[e]=t,this.fieldMapping[i]=t,this.fieldMapping[n]=t,this.initializerTemplate[i]=this.defaultValue[t.property]}this.recognizedSlots=Math.max(this.slots.length-1,...this.removedNumbers)+1,this.zeros.push(...Array(this.recognizedSlots).fill(0)),this.reversedFields=[...this.fields].sort((e,t)=>t.number-e.number)}makeRecordDefinition(e){return{kind:"struct",id:e,doc:void 0,fields:this.fields.map(e=>({name:e.name,number:e.number,type:e.serializer.typeSignature,doc:gA(e.doc)}))}}dependencies(){return this.fields.map(e=>e.serializer)}}class iA{constructor(e,t,n){this.token=e,this.json=t,this.bytes=n,Object.freeze(this)}}class sA{constructor(e,t,n,i,s){this.name=e,this.number=t,this.serializer=n,this.doc=i,this.createFn=s}get type(){return this.serializer.typeDescriptor}get(e){return e.kind===this.name?e.value:void 0}wrap(e){return this.createFn({kind:this.name,value:e})}}class rA extends eA{constructor(e){super(),this.createFn=e,this.kind="enum",this.variants=[],this.variantMapping={},this.defaultValue=e("UNKNOWN")}toJson(e,t){const n=e["^"];if(n&&n.json&&n.token===this.token)return n.json;const i=e.kind;if("UNKNOWN"===i)return"readable"===t?"UNKNOWN":0;const s=this.variantMapping[i],{serializer:r}=s;if(r){const n=e.value;return"readable"===t?{kind:s.name,value:r.toJson(n,t)}:[s.number,r.toJson(n,t)]}return"readable"===t?s.name:s.number}fromJson(e,t){const n="number"==typeof e;if(n||"string"==typeof e){const i=this.variantMapping[n?e:String(e)];if(!i)return!t||n&&this.removedNumbers.has(e)?this.defaultValue:this.createFn(new iA(this.token,oA(e)));if(i.serializer)throw new Error(`refers to a wrapper variant: ${e}`);return i.constant}let i,s;if(e instanceof Array)i=e[0],s=e[1];else{if(!(e instanceof Object))throw TypeError();i=e.kind,s=e.value}const r=this.variantMapping[i];if(!r)return!t||"number"==typeof i&&this.removedNumbers.has(i)?this.defaultValue:this.createFn(new iA(this.token,oA(e),void 0));const{serializer:o}=r;if(!o)throw new Error(`refers to a constant variant: ${e}`);return r.wrap(o.fromJson(s,t))}encode(e,t){const n=e["^"];if(n&&n.bytes&&n.token===this.token)return void t.putBytes(n.bytes);const i=e.kind;if("UNKNOWN"===i)return void t.writeUint8(0);const s=this.variantMapping[i],{number:r,serializer:o}=s;if(o){const n=e.value;r<5?t.writeUint8(250+r):(t.writeUint8(248),$C(r,t)),o.encode(n,t)}else $C(r,t)}decode(e){const t=e.offset,n=e.dataView.getUint8(t);if(n<242){const n=BC(e),i=this.variantMapping[n];if(!i){if(!e.keepUnrecognizedValues||this.removedNumbers.has(n))return this.defaultValue;{const{offset:n}=e,i=EC.sliceOf(e.buffer,t,n);return this.createFn(new iA(this.token,void 0,i))}}if(i.serializer)throw new Error(`refers to a wrapper variant: ${n}`);return i.constant}{++e.offset;const i=248===n?BC(e):n-250,s=this.variantMapping[i];if(!s){if(XC(e),!e.keepUnrecognizedValues||this.removedNumbers.has(i))return this.defaultValue;{const{offset:n}=e,i=EC.sliceOf(e.buffer,t,n);return this.createFn(new iA(this.token,void 0,i))}}const{serializer:r}=s;if(!r)throw new Error(`refers to a constant variant: ${i}`);return s.wrap(r.decode(e))}}get typeSignature(){return{kind:"record",value:`${this.modulePath}:${this.qualifiedName}`}}isDefault(e){return"UNKNOWN"===e.kind&&!e["^"]}getVariant(e){return this.variantMapping[e]}registerFieldsOrVariants(e){for(const t of e)this.variants.push(t),this.variantMapping[t.name]=t,this.variantMapping[t.number]=t}makeRecordDefinition(e){return{kind:"enum",id:e,doc:void 0,variants:this.variants.filter(e=>e.number).map(e=>{var t;const n={name:e.name,number:e.number,doc:gA(e.doc)},i=null===(t=null==e?void 0:e.serializer)||void 0===t?void 0:t.typeSignature;return i?Object.assign(Object.assign({},n),{type:i}):n})}}dependencies(){const e=[];for(const t of this.variants)t.serializer&&e.push(t.serializer);return e}}function oA(e){return e instanceof Array?Object.freeze(e.map(oA)):e instanceof Object?Object.freeze(Object.fromEntries(Object.entries(e).map((e,t)=>[e,oA(t)]))):e}function aA(e){if(e instanceof Object&&!(e instanceof fA||e instanceof pA)&&(!(e instanceof eA)||e.initialized)&&!Object.isFrozen(e)){Object.freeze(e);for(const t of Object.values(e))aA(t)}}const lA=new WeakMap;function cA(e){return lA.has(e)||lA.set(Object.freeze(e),{}),e}const hA=cA([]),uA=Symbol();function dA(e){const t=Object.getPrototypeOf(e).constructor,{qualifiedName:n}=t.serializer;return Error(["Do not call the constructor directly; ",`instead, call ${n}.create(...)`].join(""))}class fA{constructor(e){if(e!==uA)throw dA(this)}toMutable(){return new(Object.getPrototypeOf(this).constructor.Mutable)(this)}toFrozen(){return this}toString(){return mA(this)}}class pA{constructor(e,t,n,i){if(e!==uA)throw dA(this);if(this.kind=t,this.value=n,i){if(!(i instanceof iA))throw new TypeError;this["^"]=i}Object.freeze(this)}toString(){return mA(this)}}function mA(e){return Object.getPrototypeOf(e).constructor.serializer.toJsonCode(e,"readable")}function gA(e){return e||void 0}function bA(){return bA=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},bA.apply(null,arguments)}Object.defineProperty(pA.prototype,"union",{get:function(){return this}});var yA=e=>{var{theme:t,settings:n={},styles:i=[]}=e,s={".cm-gutters":{}},r={};n.background&&(r.backgroundColor=n.background),n.backgroundImage&&(r.backgroundImage=n.backgroundImage),n.foreground&&(r.color=n.foreground),n.fontSize&&(r.fontSize=n.fontSize),(n.background||n.foreground)&&(s["&"]=r),n.fontFamily&&(s["&.cm-editor .cm-scroller"]={fontFamily:n.fontFamily}),n.gutterBackground&&(s[".cm-gutters"].backgroundColor=n.gutterBackground),n.gutterForeground&&(s[".cm-gutters"].color=n.gutterForeground),n.gutterBorder&&(s[".cm-gutters"].borderRightColor=n.gutterBorder),n.caret&&(s[".cm-content"]={caretColor:n.caret},s[".cm-cursor, .cm-dropCursor"]={borderLeftColor:n.caret});var o={};return n.gutterActiveForeground&&(o.color=n.gutterActiveForeground),n.lineHighlight&&(s[".cm-activeLine"]={backgroundColor:n.lineHighlight},o.backgroundColor=n.lineHighlight),s[".cm-activeLineGutter"]=o,n.selection&&(s["&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection"]={background:n.selection+" !important"}),n.selectionMatch&&(s["& .cm-selectionMatch"]={backgroundColor:n.selectionMatch}),[Uo.theme(s,{dark:"dark"===t}),Wc(Lc.define(i))]},vA={background:"#0f0f0f",foreground:"#defdef",caret:"#00FF00",selection:"#515151",selectionMatch:"#515151",gutterBackground:"#555",gutterForeground:"#FFFFFF",lineHighlight:"#0a6bcb3d"},kA=[{tag:Te.keyword,color:"darkgoldenrod",fontWeight:"bold"},{tag:Te.atom,color:"#77F"},{tag:Te.comment,color:"#7a7b7c",fontStyle:"italic"},{tag:Te.number,color:"violet"},{tag:Te.definition(Te.variableName),color:"#fffabc"},{tag:Te.variableName,color:"#abcdef"},{tag:Te.function(Te.variableName),color:"#fffabc"},{tag:Te.typeName,color:"#FFDD44"},{tag:Te.tagName,color:"#def"},{tag:Te.string,color:"#2b4"},{tag:Te.meta,color:"#C9F"},{tag:Te.bracket,color:"#8a8a8a"},{tag:Te.attributeName,color:"#DDFF00"},{tag:Te.heading,color:"aquamarine",fontWeight:"bold"},{tag:Te.link,color:"blueviolet",fontWeight:"bold"}],wA=(()=>{var{theme:e="dark",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},vA,t),styles:[...kA,...n]})})(),xA="#000c18",SA="#6688cc",CA="#770811",AA="#770811",TA="#ddbb88",NA="#0055ff30",OA="#225588",MA="#2277ff",EA="#9966b8",DA="#22aa44",_A="#f280d0",IA="#9966b8",BA="#ddbb88",PA="#f280d0",RA="#384887",$A="#6688cc",LA="#A22D44",zA="#22aa44",FA="#225588",jA={background:xA,foreground:SA,caret:TA,selection:CA,selectionMatch:AA,gutterBackground:xA,gutterForeground:SA,lineHighlight:NA},WA=[{tag:Te.keyword,color:OA},{tag:[Te.name,Te.deleted,Te.character,Te.macroName],color:MA},{tag:[Te.propertyName],color:EA},{tag:[Te.processingInstruction,Te.string,Te.inserted,Te.special(Te.string)],color:DA},{tag:[Te.function(Te.variableName),Te.labelName],color:EA},{tag:[Te.color,Te.constant(Te.name),Te.standard(Te.name)],color:_A},{tag:[Te.definition(Te.name),Te.separator],color:MA},{tag:[Te.className],color:BA},{tag:[Te.number,Te.changed,Te.annotation,Te.modifier,Te.self,Te.namespace],color:PA},{tag:[Te.typeName],color:IA,fontStyle:IA},{tag:[Te.operator,Te.operatorKeyword],color:OA},{tag:[Te.url,Te.escape,Te.regexp,Te.link],color:zA},{tag:[Te.meta,Te.comment],color:RA},{tag:Te.tagName,color:FA},{tag:Te.strong,fontWeight:"bold"},{tag:Te.emphasis,fontStyle:"italic"},{tag:Te.link,textDecoration:"underline"},{tag:Te.heading,fontWeight:"bold",color:$A},{tag:[Te.atom,Te.bool,Te.special(Te.variableName)],color:MA},{tag:Te.invalid,color:LA},{tag:Te.strikethrough,textDecoration:"line-through"}],UA=(()=>{var{theme:e="dark",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},jA,t),styles:[...WA,...n]})})(),VA={background:"#282b2e",foreground:"#a9b7c6",caret:"#00FF00",selection:"#4e5254",selectionMatch:"#4e5254",lineHighlight:"#7f85891f"},HA=[{tag:[Te.keyword,Te.deleted,Te.className],color:"#cc7832"},{tag:[Te.number,Te.literal,Te.derefOperator],color:"#6897bb"},{tag:[Te.link,Te.variableName],color:"#629755"},{tag:[Te.comment,Te.quote],color:"grey"},{tag:[Te.meta,Te.documentMeta],color:"#bbb529"},{tag:[Te.string,Te.propertyName,Te.attributeValue],color:"#6a8759"},{tag:[Te.heading,Te.typeName],color:"#ffc66d"},{tag:[Te.attributeName],color:"#a9b7c6"},{tag:[Te.emphasis],fontStyle:"italic"}],qA=(()=>{var{theme:e="dark",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},VA,t),styles:[...HA,...n]})})(),KA="#23262E",JA="#D5CED9",ZA="#db45a280",YA="#db45a280",GA="#FFF",QA="#596a992e",XA="#c74ded",eT="#00e8c6",tT="#FFE66D",nT="#96E072",iT="#ee5d43",sT="#FFE66D",rT="#FFE66D",oT="#ee5d43",aT="#A0A1A7cc",lT="#ff00aa",cT=null,hT="#96E072",uT="#f92672",dT={background:KA,foreground:JA,caret:GA,selection:ZA,selectionMatch:YA,gutterBackground:KA,gutterForeground:JA,lineHighlight:QA},fT=[{tag:Te.keyword,color:XA},{tag:[Te.name,Te.deleted,Te.character,Te.macroName],color:eT},{tag:[Te.propertyName],color:tT},{tag:[Te.processingInstruction,Te.string,Te.inserted,Te.special(Te.string)],color:nT},{tag:[Te.function(Te.variableName),Te.labelName],color:tT},{tag:[Te.color,Te.constant(Te.name),Te.standard(Te.name)],color:iT},{tag:[Te.definition(Te.name),Te.separator],color:eT},{tag:[Te.className],color:rT},{tag:[Te.number,Te.changed,Te.annotation,Te.modifier,Te.self,Te.namespace],color:oT},{tag:[Te.typeName],color:sT,fontStyle:sT},{tag:[Te.operator],color:XA},{tag:[Te.url,Te.escape,Te.regexp,Te.link],color:hT},{tag:[Te.meta,Te.comment],color:aT},{tag:Te.tagName,color:uT},{tag:Te.strong,fontWeight:"bold"},{tag:Te.emphasis,fontStyle:"italic"},{tag:Te.link,textDecoration:"underline"},{tag:Te.heading,fontWeight:"bold",color:lT},{tag:[Te.atom,Te.special(Te.variableName)],color:eT},{tag:Te.invalid,color:cT},{tag:Te.strikethrough,textDecoration:"line-through"},{tag:[Te.operatorKeyword,Te.bool,Te.null,Te.variableName],color:iT}],pT=(()=>{var{theme:e="dark",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},dT,t),styles:[...fT,...n]})})(),mT={background:"#272C35",foreground:"#9d9b97",caret:"#797977",selection:"#3d4c64",selectionMatch:"#3d4c64",gutterBackground:"#272C35",gutterForeground:"#465063",gutterBorder:"transparent",lineHighlight:"#2e3f5940"},gT=[{tag:[Te.function(Te.variableName),Te.function(Te.propertyName),Te.url,Te.processingInstruction],color:"hsl(207, 82%, 66%)"},{tag:[Te.tagName,Te.heading],color:"#e06c75"},{tag:Te.comment,color:"#54636D"},{tag:[Te.propertyName],color:"hsl(220, 14%, 71%)"},{tag:[Te.attributeName,Te.number],color:"hsl( 29, 54%, 61%)"},{tag:Te.className,color:"hsl( 39, 67%, 69%)"},{tag:Te.keyword,color:"hsl(286, 60%, 67%)"},{tag:[Te.string,Te.regexp,Te.special(Te.propertyName)],color:"#98c379"}],bT=(()=>{var{theme:e="dark",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},mT,t),styles:[...gT,...n]})})(),yT={background:"#21202e",foreground:"#edecee",caret:"#a277ff",selection:"#5a51898f",selectionMatch:"#5a51898f",gutterBackground:"#21202e",gutterForeground:"#edecee",gutterBorder:"transparent",lineHighlight:"#a394f033"},vT=[{tag:Te.keyword,color:"#a277ff"},{tag:[Te.name,Te.deleted,Te.character,Te.macroName],color:"#edecee"},{tag:[Te.propertyName],color:"#ffca85"},{tag:[Te.processingInstruction,Te.string,Te.inserted,Te.special(Te.string)],color:"#61ffca"},{tag:[Te.function(Te.variableName),Te.labelName],color:"#ffca85"},{tag:[Te.color,Te.constant(Te.name),Te.standard(Te.name)],color:"#61ffca"},{tag:[Te.definition(Te.name),Te.separator],color:"#edecee"},{tag:[Te.className],color:"#82e2ff"},{tag:[Te.number,Te.changed,Te.annotation,Te.modifier,Te.self,Te.namespace],color:"#61ffca"},{tag:[Te.typeName],color:"#82e2ff"},{tag:[Te.operator,Te.operatorKeyword],color:"#a277ff"},{tag:[Te.url,Te.escape,Te.regexp,Te.link],color:"#61ffca"},{tag:[Te.meta,Te.comment],color:"#6d6d6d"},{tag:Te.strong,fontWeight:"bold"},{tag:Te.emphasis,fontStyle:"italic"},{tag:Te.link,textDecoration:"underline"},{tag:Te.heading,fontWeight:"bold",color:"#a277ff"},{tag:[Te.atom,Te.bool,Te.special(Te.variableName)],color:"#edecee"},{tag:Te.invalid,color:"#ff6767"},{tag:Te.strikethrough,textDecoration:"line-through"}],kT=(()=>{var{theme:e="dark",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},yT,t),styles:[...vT,...n]})})(),wT={background:"#2E3235",foreground:"#DDDDDD",caret:"#DDDDDD",selection:"#202325",selectionMatch:"#202325",gutterBackground:"#292d30",gutterForeground:"#808080",gutterBorder:"1px solid #ffffff10",lineHighlight:"#B9D2FF30"},xT=[{tag:Te.keyword,color:"#fda331"},{tag:[Te.name,Te.deleted,Te.character,Te.propertyName,Te.macroName],color:"#b5bd68"},{tag:[Te.variableName],color:"#6fb3d2"},{tag:[Te.function(Te.variableName)],color:"#fda331"},{tag:[Te.labelName],color:"#fc6d24"},{tag:[Te.color,Te.constant(Te.name),Te.standard(Te.name)],color:"#fda331"},{tag:[Te.definition(Te.name),Te.separator],color:"#cc99cc"},{tag:[Te.brace],color:"#cc99cc"},{tag:[Te.annotation],color:"#fc6d24"},{tag:[Te.number,Te.changed,Te.annotation,Te.modifier,Te.self,Te.namespace],color:"#fda331"},{tag:[Te.typeName,Te.className],color:"#6fb3d2"},{tag:[Te.operator,Te.operatorKeyword],color:"#cc99cc"},{tag:[Te.tagName],color:"#fda331"},{tag:[Te.squareBracket],color:"#cc99cc"},{tag:[Te.angleBracket],color:"#cc99cc"},{tag:[Te.attributeName],color:"#6fb3d2"},{tag:[Te.regexp],color:"#fda331"},{tag:[Te.quote],color:"#DDDDDD"},{tag:[Te.string],color:"#b5bd68"},{tag:Te.link,color:"#6987AF",textDecoration:"underline",textUnderlinePosition:"under"},{tag:[Te.url,Te.escape,Te.special(Te.string)],color:"#8abeb7"},{tag:[Te.meta],color:"#A54543"},{tag:[Te.comment],color:"#808080",fontStyle:"italic"},{tag:Te.monospace,color:"#DDDDDD"},{tag:Te.strong,fontWeight:"bold",color:"#fda331"},{tag:Te.emphasis,fontStyle:"italic",color:"#6fb3d2"},{tag:Te.strikethrough,textDecoration:"line-through"},{tag:Te.heading,fontWeight:"bold",color:"#DDDDDD"},{tag:Te.special(Te.heading1),fontWeight:"bold",color:"#DDDDDD"},{tag:Te.heading1,fontWeight:"bold",color:"#DDDDDD"},{tag:[Te.heading2,Te.heading3,Te.heading4],fontWeight:"bold",color:"#DDDDDD"},{tag:[Te.heading5,Te.heading6],color:"#DDDDDD"},{tag:[Te.atom,Te.bool,Te.special(Te.variableName)],color:"#8abeb7"},{tag:[Te.processingInstruction,Te.inserted],color:"#8abeb7"},{tag:[Te.contentSeparator],color:"#6fb3d2"},{tag:Te.invalid,color:"#B9D2FF",borderBottom:"1px dotted #fc6d24"}],ST=(()=>{var{theme:e="dark",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},wT,t),styles:[...xT,...n]})})(),CT={background:"#ffffff",foreground:"#2e3440",caret:"#3b4252",selection:"#eceff4",selectionMatch:"#e5e9f0",gutterBackground:"#eceff4",gutterForeground:"#2e3440",gutterBorder:"none",lineHighlight:"#02255f11"},AT=[{tag:Te.keyword,color:"#5e81ac"},{tag:[Te.name,Te.deleted,Te.character,Te.propertyName,Te.macroName],color:"#d08770"},{tag:[Te.variableName],color:"#d08770"},{tag:[Te.function(Te.variableName)],color:"#5e81ac"},{tag:[Te.labelName],color:"#81a1c1"},{tag:[Te.color,Te.constant(Te.name),Te.standard(Te.name)],color:"#5e81ac"},{tag:[Te.definition(Te.name),Te.separator],color:"#a3be8c"},{tag:[Te.brace],color:"#8fbcbb"},{tag:[Te.annotation],color:"#d30102"},{tag:[Te.number,Te.changed,Te.annotation,Te.modifier,Te.self,Te.namespace],color:"#88c0d0"},{tag:[Te.typeName,Te.className],color:"#ebcb8b"},{tag:[Te.operator,Te.operatorKeyword],color:"#a3be8c"},{tag:[Te.tagName],color:"#b48ead"},{tag:[Te.squareBracket],color:"#bf616a"},{tag:[Te.angleBracket],color:"#d08770"},{tag:[Te.attributeName],color:"#ebcb8b"},{tag:[Te.regexp],color:"#5e81ac"},{tag:[Te.quote],color:"#3b4252"},{tag:[Te.string],color:"#d08770"},{tag:Te.link,color:"#8fbcbb",textDecoration:"underline",textUnderlinePosition:"under"},{tag:[Te.url,Te.escape,Te.special(Te.string)],color:"#d08770"},{tag:[Te.meta],color:"#88c0d0"},{tag:[Te.comment],color:"#434c5e",fontStyle:"italic"},{tag:Te.strong,fontWeight:"bold",color:"#5e81ac"},{tag:Te.emphasis,fontStyle:"italic",color:"#5e81ac"},{tag:Te.strikethrough,textDecoration:"line-through"},{tag:Te.heading,fontWeight:"bold",color:"#5e81ac"},{tag:Te.special(Te.heading1),fontWeight:"bold",color:"#5e81ac"},{tag:Te.heading1,fontWeight:"bold",color:"#5e81ac"},{tag:[Te.heading2,Te.heading3,Te.heading4],fontWeight:"bold",color:"#5e81ac"},{tag:[Te.heading5,Te.heading6],color:"#5e81ac"},{tag:[Te.atom,Te.bool,Te.special(Te.variableName)],color:"#d08770"},{tag:[Te.processingInstruction,Te.inserted],color:"#8fbcbb"},{tag:[Te.contentSeparator],color:"#ebcb8b"},{tag:Te.invalid,color:"#434c5e",borderBottom:"1px dotted #d30102"}],TT=(()=>{var{theme:e="light",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},CT,t),styles:[...AT,...n]})})(),NT={background:"#FFFFFF",foreground:"#000000",caret:"#FBAC52",selection:"#FFD420",selectionMatch:"#FFD420",gutterBackground:"#f5f5f5",gutterForeground:"#4D4D4C",gutterBorder:"transparent",lineHighlight:"#00000012"},OT=[{tag:[Te.meta,Te.comment],color:"#804000"},{tag:[Te.keyword,Te.strong],color:"#0000FF"},{tag:[Te.number],color:"#FF0080"},{tag:[Te.string],color:"#FF0080"},{tag:[Te.variableName],color:"#006600"},{tag:[Te.escape],color:"#33CC33"},{tag:[Te.tagName],color:"#1C02FF"},{tag:[Te.heading],color:"#0C07FF"},{tag:[Te.quote],color:"#000000"},{tag:[Te.list],color:"#B90690"},{tag:[Te.documentMeta],color:"#888888"},{tag:[Te.function(Te.variableName)],color:"#0000A2"},{tag:[Te.definition(Te.typeName),Te.typeName],color:"#6D79DE"}],MT=(()=>{var{theme:e="light",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},NT,t),styles:[...OT,...n]})})(),ET={background:"#28211c",foreground:"#9d9b97",caret:"#797977",selection:"#4f382b",selectionMatch:"#4f382b",gutterBackground:"#28211c",gutterForeground:"#666666",lineHighlight:"#ffffff1a"},DT=[{tag:[Te.atom,Te.number,Te.link,Te.bool],color:"#9b859d"},{tag:Te.comment,color:"#937121"},{tag:[Te.keyword,Te.tagName],color:"#cf6a4c"},{tag:Te.string,color:"#f9ee98"},{tag:Te.bracket,color:"#9d9b97"},{tag:[Te.variableName],color:"#5ea6ea"},{tag:Te.definition(Te.variableName),color:"#cf7d34"},{tag:[Te.function(Te.variableName),Te.className],color:"#cf7d34"},{tag:[Te.propertyName,Te.attributeName],color:"#54be0d"}],_T=(()=>{var{theme:e="dark",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},ET,t),styles:[...DT,...n]})})(),IT={background:"#000",foreground:"#fff",caret:"#fff",selection:"#5c6c9b",selectionMatch:"#2a3967",gutterBackground:"#000",gutterForeground:"#ada9a9",gutterActiveForeground:"#fff",lineHighlight:"#82828275"},BT=(()=>{var{theme:e="dark",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},IT,t),styles:[...n]})})(),PT={background:"#fff",foreground:"#000",caret:"#000",selection:"#c2d2ff",selectionMatch:"#b1c1ef",gutterBackground:"#fff",gutterForeground:"#ada9a9",gutterActiveForeground:"#000",lineHighlight:"#c7c5c575"},RT=(()=>{var{theme:e="light",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},PT,t),styles:[...n]})})(),$T="#232a2f",LT="#939da5",zT="#204062",FT="#204062",jT="#939da5",WT="#4469832b",UT="#ba8ef7",VT="#939da5",HT="#ffea6b",qT="#5bec95",KT="#939da5",JT="#89ddff",ZT="#ffea6b",YT="#89ddff",GT="#707a84",QT="#5bec95",XT="#ff6a80",eN="#56adb7",tN="#ff6a80",nN={background:$T,foreground:LT,caret:jT,selection:zT,selectionMatch:FT,gutterBackground:$T,gutterForeground:LT,lineHighlight:WT},iN=[{tag:Te.keyword,color:UT},{tag:[Te.name,Te.deleted,Te.character,Te.macroName],color:VT},{tag:[Te.propertyName],color:HT},{tag:[Te.processingInstruction,Te.string,Te.inserted,Te.special(Te.string)],color:qT},{tag:[Te.function(Te.variableName),Te.labelName],color:HT},{tag:[Te.color,Te.constant(Te.name),Te.standard(Te.name)],color:KT},{tag:[Te.definition(Te.name),Te.separator],color:VT},{tag:[Te.className],color:ZT},{tag:[Te.number,Te.changed,Te.annotation,Te.modifier,Te.self,Te.namespace],color:YT},{tag:[Te.typeName],color:JT,fontStyle:JT},{tag:[Te.operator],color:UT},{tag:[Te.url,Te.escape,Te.regexp,Te.link],color:eN},{tag:[Te.meta,Te.comment],color:GT},{tag:Te.tagName,color:tN},{tag:Te.strong,fontWeight:"bold"},{tag:Te.emphasis,fontStyle:"italic"},{tag:Te.link,textDecoration:"underline"},{tag:Te.heading,fontWeight:"bold",color:QT},{tag:[Te.atom,Te.special(Te.variableName)],color:VT},{tag:Te.invalid,color:XT},{tag:Te.strikethrough,textDecoration:"line-through"},{tag:[Te.operatorKeyword,Te.bool,Te.null,Te.variableName],color:KT}],sN=(()=>{var{theme:e="dark",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},nN,t),styles:[...iN,...n]})})(),rN={background:"#2B2B2B",foreground:"#f8f8f2",caret:"#FFFFFF",selection:"rgba(255, 255, 255, 0.1)",selectionMatch:"rgba(255, 255, 255, 0.2)",gutterBackground:"rgba(255, 255, 255, 0.1)",gutterForeground:"#999",gutterBorder:"transparent",lineHighlight:"rgba(255, 255, 255, 0.1)"},oN=[{tag:[Te.atom,Te.number],color:"#bd93f9"},{tag:[Te.comment],color:"#61A151"},{tag:[Te.string],color:"#6A8759"},{tag:[Te.variableName,Te.operator],color:"#A9B7C6"},{tag:[Te.meta,Te.className],color:"#A9B7C6"},{tag:[Te.propertyName],color:"#FFC66D"},{tag:[Te.keyword],color:"#CC7832"},{tag:[Te.tagName],color:"#ff79c6"},{tag:[Te.typeName],color:"#ffb86c"}],aN=(()=>{var{theme:e="dark",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},rN,t),styles:[...oN,...n]})})(),lN={background:"#282a36",foreground:"#f8f8f2",caret:"#f8f8f0",selection:"rgba(255, 255, 255, 0.1)",selectionMatch:"rgba(255, 255, 255, 0.2)",gutterBackground:"#282a36",gutterForeground:"#6D8A88",gutterBorder:"transparent",lineHighlight:"rgba(255, 255, 255, 0.1)"},cN=[{tag:Te.comment,color:"#6272a4"},{tag:Te.string,color:"#f1fa8c"},{tag:Te.atom,color:"#bd93f9"},{tag:Te.meta,color:"#f8f8f2"},{tag:[Te.keyword,Te.operator,Te.tagName],color:"#ff79c6"},{tag:[Te.function(Te.propertyName),Te.propertyName],color:"#66d9ef"},{tag:[Te.definition(Te.variableName),Te.function(Te.variableName),Te.className,Te.attributeName],color:"#50fa7b"},{tag:Te.atom,color:"#bd93f9"}],hN=(()=>{var{theme:e="dark",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},lN,t),styles:[...cN,...n]})})(),uN={background:"#faf8f5",foreground:"#b29762",caret:"#93abdc",selection:"#e3dcce",selectionMatch:"#e3dcce",gutterBackground:"#faf8f5",gutterForeground:"#cdc4b1",gutterBorder:"transparent",lineHighlight:"#ddceb154"},dN=[{tag:[Te.comment,Te.bracket],color:"#b6ad9a"},{tag:[Te.atom,Te.number,Te.keyword,Te.link,Te.attributeName,Te.quote],color:"#063289"},{tag:[Te.emphasis,Te.heading,Te.tagName,Te.propertyName,Te.variableName],color:"#2d2006"},{tag:[Te.typeName,Te.url,Te.string],color:"#896724"},{tag:[Te.operator,Te.string],color:"#1659df"},{tag:[Te.propertyName],color:"#b29762"},{tag:[Te.unit,Te.punctuation],color:"#063289"}],fN=(()=>{var{theme:e="light",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},uN,t),styles:[...dN,...n]})})(),pN={background:"#2a2734",foreground:"#6c6783",caret:"#ffad5c",selection:"#91ff6c26",selectionMatch:"#91ff6c26",gutterBackground:"#2a2734",gutterForeground:"#545167",lineHighlight:"#36334280"},mN=[{tag:[Te.comment,Te.bracket],color:"#6c6783"},{tag:[Te.atom,Te.number,Te.keyword,Te.link,Te.attributeName,Te.quote],color:"#ffcc99"},{tag:[Te.emphasis,Te.heading,Te.tagName,Te.propertyName,Te.className,Te.variableName],color:"#eeebff"},{tag:[Te.typeName,Te.url],color:"#7a63ee"},{tag:Te.operator,color:"#ffad5c"},{tag:Te.string,color:"#ffb870"},{tag:[Te.propertyName],color:"#9a86fd"},{tag:[Te.unit,Te.punctuation],color:"#e09142"}],gN=(()=>{var{theme:e="dark",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},pN,t),styles:[...mN,...n]})})(),bN={background:"#fff",foreground:"#000",caret:"#FFFFFF",selection:"#d7d4f0",selectionMatch:"#d7d4f0",gutterBackground:"#f7f7f7",gutterForeground:"#999",lineHighlight:"#006fff1c",gutterBorder:"transparent"},yN=[{tag:[Te.comment],color:"#3F7F5F"},{tag:[Te.documentMeta],color:"#FF1717"},{tag:Te.keyword,color:"#7F0055",fontWeight:"bold"},{tag:Te.atom,color:"#00f"},{tag:Te.number,color:"#164"},{tag:Te.propertyName,color:"#164"},{tag:[Te.variableName,Te.definition(Te.variableName)],color:"#0000C0"},{tag:Te.function(Te.variableName),color:"#0000C0"},{tag:Te.string,color:"#2A00FF"},{tag:Te.operator,color:"black"},{tag:Te.tagName,color:"#170"},{tag:Te.attributeName,color:"#00c"},{tag:Te.link,color:"#219"}],vN=(()=>{var{theme:e="light",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},bN,t),styles:[...yN,...n]})})(),kN={background:"#fff",foreground:"#24292e",selection:"#BBDFFF",selectionMatch:"#BBDFFF",gutterBackground:"#fff",gutterForeground:"#6e7781"},wN=[{tag:[Te.standard(Te.tagName),Te.tagName],color:"#116329"},{tag:[Te.comment,Te.bracket],color:"#6a737d"},{tag:[Te.className,Te.propertyName],color:"#6f42c1"},{tag:[Te.variableName,Te.attributeName,Te.number,Te.operator],color:"#005cc5"},{tag:[Te.keyword,Te.typeName,Te.typeOperator,Te.typeName],color:"#d73a49"},{tag:[Te.string,Te.meta,Te.regexp],color:"#032f62"},{tag:[Te.name,Te.quote],color:"#22863a"},{tag:[Te.heading,Te.strong],color:"#24292e",fontWeight:"bold"},{tag:[Te.emphasis],color:"#24292e",fontStyle:"italic"},{tag:[Te.deleted],color:"#b31d28",backgroundColor:"ffeef0"},{tag:[Te.atom,Te.bool,Te.special(Te.variableName)],color:"#e36209"},{tag:[Te.url,Te.escape,Te.regexp,Te.link],color:"#032f62"},{tag:Te.link,textDecoration:"underline"},{tag:Te.strikethrough,textDecoration:"line-through"},{tag:Te.invalid,color:"#cb2431"}],xN=(()=>{var{theme:e="light",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},kN,t),styles:[...wN,...n]})})(),SN={background:"#0d1117",foreground:"#c9d1d9",caret:"#c9d1d9",selection:"#003d73",selectionMatch:"#003d73",lineHighlight:"#36334280"},CN=[{tag:[Te.standard(Te.tagName),Te.tagName],color:"#7ee787"},{tag:[Te.comment,Te.bracket],color:"#8b949e"},{tag:[Te.className,Te.propertyName],color:"#d2a8ff"},{tag:[Te.variableName,Te.attributeName,Te.number,Te.operator],color:"#79c0ff"},{tag:[Te.keyword,Te.typeName,Te.typeOperator,Te.typeName],color:"#ff7b72"},{tag:[Te.string,Te.meta,Te.regexp],color:"#a5d6ff"},{tag:[Te.name,Te.quote],color:"#7ee787"},{tag:[Te.heading,Te.strong],color:"#d2a8ff",fontWeight:"bold"},{tag:[Te.emphasis],color:"#d2a8ff",fontStyle:"italic"},{tag:[Te.deleted],color:"#ffdcd7",backgroundColor:"ffeef0"},{tag:[Te.atom,Te.bool,Te.special(Te.variableName)],color:"#ffab70"},{tag:Te.link,textDecoration:"underline"},{tag:Te.strikethrough,textDecoration:"line-through"},{tag:Te.invalid,color:"#f97583"}],AN=(()=>{var{theme:e="dark",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},SN,t),styles:[...CN,...n]})})(),TN={background:"#282828",foreground:"#ebdbb2",caret:"#ebdbb2",selection:"#b99d555c",selectionMatch:"#b99d555c",lineHighlight:"#baa1602b",gutterBackground:"#282828",gutterForeground:"#7c6f64"},NN=[{tag:Te.keyword,color:"#fb4934"},{tag:[Te.name,Te.deleted,Te.character,Te.propertyName,Te.macroName],color:"#8ec07c"},{tag:[Te.variableName],color:"#83a598"},{tag:[Te.function(Te.variableName)],color:"#b8bb26",fontStyle:"bold"},{tag:[Te.labelName],color:"#ebdbb2"},{tag:[Te.color,Te.constant(Te.name),Te.standard(Te.name)],color:"#d3869b"},{tag:[Te.definition(Te.name),Te.separator],color:"#ebdbb2"},{tag:[Te.brace],color:"#ebdbb2"},{tag:[Te.annotation],color:"#fb4934d"},{tag:[Te.number,Te.changed,Te.annotation,Te.modifier,Te.self,Te.namespace],color:"#d3869b"},{tag:[Te.typeName,Te.className],color:"#fabd2f"},{tag:[Te.operator,Te.operatorKeyword],color:"#fb4934"},{tag:[Te.tagName],color:"#8ec07c",fontStyle:"bold"},{tag:[Te.squareBracket],color:"#fe8019"},{tag:[Te.angleBracket],color:"#83a598"},{tag:[Te.attributeName],color:"#8ec07c"},{tag:[Te.regexp],color:"#8ec07c"},{tag:[Te.quote],color:"#928374"},{tag:[Te.string],color:"#ebdbb2"},{tag:Te.link,color:"#a89984",textDecoration:"underline",textUnderlinePosition:"under"},{tag:[Te.url,Te.escape,Te.special(Te.string)],color:"#d3869b"},{tag:[Te.meta],color:"#fabd2f"},{tag:[Te.comment],color:"#928374",fontStyle:"italic"},{tag:Te.strong,fontWeight:"bold",color:"#fe8019"},{tag:Te.emphasis,fontStyle:"italic",color:"#b8bb26"},{tag:Te.strikethrough,textDecoration:"line-through"},{tag:Te.heading,fontWeight:"bold",color:"#b8bb26"},{tag:[Te.heading1,Te.heading2],fontWeight:"bold",color:"#b8bb26"},{tag:[Te.heading3,Te.heading4],fontWeight:"bold",color:"#fabd2f"},{tag:[Te.heading5,Te.heading6],color:"#fabd2f"},{tag:[Te.atom,Te.bool,Te.special(Te.variableName)],color:"#d3869b"},{tag:[Te.processingInstruction,Te.inserted],color:"#83a598"},{tag:[Te.contentSeparator],color:"#fb4934"},{tag:Te.invalid,color:"#fe8019",borderBottom:"1px dotted #fb4934d"}],ON=(()=>{var{theme:e="dark",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},TN,t),styles:[...NN,...n]})})(),MN={background:"#fbf1c7",foreground:"#3c3836",caret:"#af3a03",selection:"#bdae9391",selectionMatch:"#bdae9391",lineHighlight:"#a37f2238",gutterBackground:"#ebdbb2",gutterForeground:"#665c54",gutterBorder:"transparent"},EN=(()=>{var{theme:e="light",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},MN,t),styles:[{tag:Te.keyword,color:"#9d0006"},{tag:[Te.name,Te.deleted,Te.character,Te.propertyName,Te.macroName],color:"#427b58"},{tag:[Te.variableName],color:"#076678"},{tag:[Te.function(Te.variableName)],color:"#79740e",fontStyle:"bold"},{tag:[Te.labelName],color:"#3c3836"},{tag:[Te.color,Te.constant(Te.name),Te.standard(Te.name)],color:"#8f3f71"},{tag:[Te.definition(Te.name),Te.separator],color:"#3c3836"},{tag:[Te.brace],color:"#3c3836"},{tag:[Te.annotation],color:"#9d0006"},{tag:[Te.number,Te.changed,Te.annotation,Te.modifier,Te.self,Te.namespace],color:"#8f3f71"},{tag:[Te.typeName,Te.className],color:"#b57614"},{tag:[Te.operator,Te.operatorKeyword],color:"#9d0006"},{tag:[Te.tagName],color:"#427b58",fontStyle:"bold"},{tag:[Te.squareBracket],color:"#af3a03"},{tag:[Te.angleBracket],color:"#076678"},{tag:[Te.attributeName],color:"#427b58"},{tag:[Te.regexp],color:"#427b58"},{tag:[Te.quote],color:"#928374"},{tag:[Te.string],color:"#3c3836"},{tag:Te.link,color:"#7c6f64",textDecoration:"underline",textUnderlinePosition:"under"},{tag:[Te.url,Te.escape,Te.special(Te.string)],color:"#8f3f71"},{tag:[Te.meta],color:"#b57614"},{tag:[Te.comment],color:"#928374",fontStyle:"italic"},{tag:Te.strong,fontWeight:"bold",color:"#af3a03"},{tag:Te.emphasis,fontStyle:"italic",color:"#79740e"},{tag:Te.strikethrough,textDecoration:"line-through"},{tag:Te.heading,fontWeight:"bold",color:"#79740e"},{tag:[Te.heading1,Te.heading2],fontWeight:"bold",color:"#79740e"},{tag:[Te.heading3,Te.heading4],fontWeight:"bold",color:"#b57614"},{tag:[Te.heading5,Te.heading6],color:"#b57614"},{tag:[Te.atom,Te.bool,Te.special(Te.variableName)],color:"#8f3f71"},{tag:[Te.processingInstruction,Te.inserted],color:"#076678"},{tag:[Te.contentSeparator],color:"#9d0006"},{tag:Te.invalid,color:"#af3a03",borderBottom:"1px dotted #9d0006"},...n]})})(),DN="#221a0f",_N="#d3af86",IN="#84613daa",BN="#98676a",PN="#dc3958",RN="#7e602c",$N="#889b4a",LN="#f79a32",zN="#f06431",FN="#f06431",jN="#f79a32",WN="#a57a4c",UN="#8ab1b0",VN="#dc3958",HN="#7e602c",qN="#dc3958",KN={background:DN,foreground:_N,caret:"#d3af86",selection:IN,selectionMatch:IN,gutterBackground:DN,gutterForeground:_N,lineHighlight:"#5e452b52"},JN=[{tag:Te.keyword,color:BN},{tag:[Te.name,Te.deleted,Te.character,Te.macroName],color:PN},{tag:[Te.propertyName],color:RN},{tag:[Te.processingInstruction,Te.string,Te.inserted,Te.special(Te.string)],color:$N},{tag:[Te.function(Te.variableName),Te.labelName],color:RN},{tag:[Te.color,Te.constant(Te.name),Te.standard(Te.name)],color:LN},{tag:[Te.definition(Te.name),Te.separator],color:PN},{tag:[Te.className],color:FN},{tag:[Te.number,Te.changed,Te.annotation,Te.modifier,Te.self,Te.namespace],color:jN},{tag:[Te.typeName],color:zN,fontStyle:zN},{tag:[Te.operator,Te.operatorKeyword],color:BN},{tag:[Te.url,Te.escape,Te.regexp,Te.link],color:HN},{tag:[Te.meta,Te.comment],color:WN},{tag:Te.tagName,color:qN},{tag:Te.strong,fontWeight:"bold"},{tag:Te.emphasis,fontStyle:"italic"},{tag:Te.link,textDecoration:"underline"},{tag:Te.heading,fontWeight:"bold",color:UN},{tag:[Te.atom,Te.bool,Te.special(Te.variableName)],color:PN},{tag:Te.invalid,color:VN},{tag:Te.strikethrough,textDecoration:"line-through"}],ZN=(()=>{var{theme:e="dark",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},KN,t),styles:[...JN,...n]})})(),YN={background:"#2e3235",foreground:"#bdbdbd",caret:"#a0a4ae",selection:"#d7d4f063",selectionMatch:"#d7d4f063",gutterBackground:"#2e3235",gutterForeground:"#999",gutterActiveForeground:"#4f5b66",lineHighlight:"#545b6130"},GN=YN,QN=[{tag:Te.keyword,color:"#cf6edf"},{tag:[Te.name,Te.deleted,Te.character,Te.macroName],color:"#56c8d8"},{tag:[Te.propertyName],color:"#facf4e"},{tag:[Te.variableName],color:"#bdbdbd"},{tag:[Te.function(Te.variableName)],color:"#56c8d8"},{tag:[Te.labelName],color:"#cf6edf"},{tag:[Te.color,Te.constant(Te.name),Te.standard(Te.name)],color:"#facf4e"},{tag:[Te.definition(Te.name),Te.separator],color:"#fa5788"},{tag:[Te.brace],color:"#cf6edf"},{tag:[Te.annotation],color:"#ff5f52"},{tag:[Te.number,Te.changed,Te.annotation,Te.modifier,Te.self,Te.namespace],color:"#ffad42"},{tag:[Te.typeName,Te.className],color:"#ffad42"},{tag:[Te.operator,Te.operatorKeyword],color:"#7186f0"},{tag:[Te.tagName],color:"#99d066"},{tag:[Te.squareBracket],color:"#ff5f52"},{tag:[Te.angleBracket],color:"#606f7a"},{tag:[Te.attributeName],color:"#bdbdbd"},{tag:[Te.regexp],color:"#ff5f52"},{tag:[Te.quote],color:"#6abf69"},{tag:[Te.string],color:"#99d066"},{tag:Te.link,color:"#56c8d8",textDecoration:"underline",textUnderlinePosition:"under"},{tag:[Te.url,Te.escape,Te.special(Te.string)],color:"#facf4e"},{tag:[Te.meta],color:"#707d8b"},{tag:[Te.comment],color:"#707d8b",fontStyle:"italic"},{tag:Te.monospace,color:"#bdbdbd"},{tag:Te.strong,fontWeight:"bold",color:"#ff5f52"},{tag:Te.emphasis,fontStyle:"italic",color:"#99d066"},{tag:Te.strikethrough,textDecoration:"line-through"},{tag:Te.heading,fontWeight:"bold",color:"#facf4e"},{tag:Te.heading1,fontWeight:"bold",color:"#facf4e"},{tag:[Te.heading2,Te.heading3,Te.heading4],fontWeight:"bold",color:"#facf4e"},{tag:[Te.heading5,Te.heading6],color:"#facf4e"},{tag:[Te.atom,Te.bool,Te.special(Te.variableName)],color:"#56c8d8"},{tag:[Te.processingInstruction,Te.inserted],color:"#ff5f52"},{tag:[Te.contentSeparator],color:"#56c8d8"},{tag:Te.invalid,color:"#606f7a",borderBottom:"1px dotted #ff5f52"}],XN=e=>{var{theme:t="dark",settings:n={},styles:i=[]}=e||{};return yA({theme:t,settings:bA({},YN,n),styles:[...QN,...i]})},eO=XN(),tO=XN(),nO={background:"#FAFAFA",foreground:"#90A4AE",caret:"#272727",selection:"#80CBC440",selectionMatch:"#80CBC440",gutterBackground:"#FAFAFA",gutterForeground:"#90A4AE",gutterBorder:"transparent",lineHighlight:"#CCD7DA50"},iO=[{tag:Te.keyword,color:"#39ADB5"},{tag:[Te.name,Te.deleted,Te.character,Te.macroName],color:"#90A4AE"},{tag:[Te.propertyName],color:"#6182B8"},{tag:[Te.processingInstruction,Te.string,Te.inserted,Te.special(Te.string)],color:"#91B859"},{tag:[Te.function(Te.variableName),Te.labelName],color:"#6182B8"},{tag:[Te.color,Te.constant(Te.name),Te.standard(Te.name)],color:"#39ADB5"},{tag:[Te.definition(Te.name),Te.separator],color:"#90A4AE"},{tag:[Te.className],color:"#E2931D"},{tag:[Te.number,Te.changed,Te.annotation,Te.modifier,Te.self,Te.namespace],color:"#F76D47"},{tag:[Te.typeName],color:"#E2931D",fontStyle:"#E2931D"},{tag:[Te.operator,Te.operatorKeyword],color:"#39ADB5"},{tag:[Te.url,Te.escape,Te.regexp,Te.link],color:"#91B859"},{tag:[Te.meta,Te.comment],color:"#90A4AE"},{tag:Te.strong,fontWeight:"bold"},{tag:Te.emphasis,fontStyle:"italic"},{tag:Te.link,textDecoration:"underline"},{tag:Te.heading,fontWeight:"bold",color:"#39ADB5"},{tag:[Te.atom,Te.bool,Te.special(Te.variableName)],color:"#90A4AE"},{tag:Te.invalid,color:"#E5393570"},{tag:Te.strikethrough,textDecoration:"line-through"}],sO=(()=>{var{theme:e="light",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},nO,t),styles:[...iO,...n]})})(),rO="#272822",oO="#f8f8f2",aO="#4a4a76",lO="#F92672",cO="#FD971F",hO="#66D9EF",uO="#E6DB74",dO="#AE81FF",fO="#66D9EF",pO="#A6E22E",mO="#AE81FF",gO="#88846f",bO="#A6E22E",yO="#F44747",vO="#E6DB74",kO="#F92672",wO={background:rO,foreground:oO,caret:"#f8f8f0",selection:aO,selectionMatch:aO,gutterBackground:rO,gutterForeground:oO,lineHighlight:"#3e3d3257"},xO=[{tag:Te.keyword,color:lO},{tag:[Te.name,Te.deleted,Te.character,Te.macroName],color:cO},{tag:[Te.propertyName],color:hO},{tag:[Te.processingInstruction,Te.string,Te.inserted,Te.special(Te.string)],color:uO},{tag:[Te.function(Te.variableName),Te.labelName],color:hO},{tag:[Te.color,Te.constant(Te.name),Te.standard(Te.name)],color:dO},{tag:[Te.definition(Te.name),Te.separator],color:cO},{tag:[Te.className],color:pO},{tag:[Te.number,Te.changed,Te.annotation,Te.modifier,Te.self,Te.namespace],color:mO},{tag:[Te.typeName],color:fO,fontStyle:fO},{tag:[Te.operator,Te.operatorKeyword],color:lO},{tag:[Te.url,Te.escape,Te.regexp,Te.link],color:vO},{tag:[Te.meta,Te.comment],color:gO},{tag:Te.tagName,color:kO},{tag:Te.strong,fontWeight:"bold"},{tag:Te.emphasis,fontStyle:"italic"},{tag:Te.link,textDecoration:"underline"},{tag:Te.heading,fontWeight:"bold",color:bO},{tag:[Te.atom,Te.bool,Te.special(Te.variableName)],color:cO},{tag:Te.invalid,color:yO},{tag:Te.strikethrough,textDecoration:"line-through"}],SO=(()=>{var{theme:e="dark",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},wO,t),styles:[...xO,...n]})})(),CO="#1e1e1e",AO="#c5c8c6",TO="#4747a1",NO="#676867",OO="#c7444a",MO="#9872A2",EO="#D08442",DO="#8080FF",_O="#9B0000",IO="#CE6700",BO="#6089B4",PO="#9A9B99",RO="#D0B344",$O="#FF0B00",LO="#D08442",zO="#6089B4",FO={background:CO,foreground:AO,caret:"#c07020",selection:TO,selectionMatch:TO,gutterBackground:CO,gutterForeground:AO,lineHighlight:"#30303078"},jO=[{tag:Te.keyword,color:NO},{tag:[Te.name,Te.deleted,Te.character,Te.macroName],color:OO},{tag:[Te.propertyName],color:MO},{tag:[Te.processingInstruction,Te.string,Te.inserted,Te.special(Te.string)],color:EO},{tag:[Te.function(Te.variableName),Te.labelName],color:MO},{tag:[Te.color,Te.constant(Te.name),Te.standard(Te.name)],color:DO},{tag:[Te.definition(Te.name),Te.separator],color:OO},{tag:[Te.className],color:IO},{tag:[Te.number,Te.changed,Te.annotation,Te.modifier,Te.self,Te.namespace],color:BO},{tag:[Te.typeName],color:_O,fontStyle:_O},{tag:[Te.operator,Te.operatorKeyword],color:NO},{tag:[Te.url,Te.escape,Te.regexp,Te.link],color:LO},{tag:[Te.meta,Te.comment],color:PO},{tag:Te.tagName,color:zO},{tag:Te.strong,fontWeight:"bold"},{tag:Te.emphasis,fontStyle:"italic"},{tag:Te.link,textDecoration:"underline"},{tag:Te.heading,fontWeight:"bold",color:RO},{tag:[Te.atom,Te.bool,Te.special(Te.variableName)],color:OO},{tag:Te.invalid,color:$O},{tag:Te.strikethrough,textDecoration:"line-through"}],WO=(()=>{var{theme:e="dark",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},FO,t),styles:[...jO,...n]})})(),UO={background:"#f2f1f8",foreground:"#0c006b",caret:"#5c49e9",selection:"#d5d1f2",selectionMatch:"#d5d1f2",gutterBackground:"#f2f1f8",gutterForeground:"#0c006b70",lineHighlight:"#16067911"},VO=[{tag:Te.comment,color:"#9995b7"},{tag:Te.keyword,color:"#ff5792",fontWeight:"bold"},{tag:[Te.definitionKeyword,Te.modifier],color:"#ff5792"},{tag:[Te.className,Te.tagName,Te.definition(Te.typeName)],color:"#0094f0"},{tag:[Te.number,Te.bool,Te.null,Te.special(Te.brace)],color:"#5842ff"},{tag:[Te.definition(Te.propertyName),Te.function(Te.variableName)],color:"#0095a8"},{tag:Te.typeName,color:"#b3694d"},{tag:[Te.propertyName,Te.variableName],color:"#fa8900"},{tag:Te.operator,color:"#ff5792"},{tag:Te.self,color:"#e64100"},{tag:[Te.string,Te.regexp],color:"#00b368"},{tag:[Te.paren,Te.bracket],color:"#0431fa"},{tag:Te.labelName,color:"#00bdd6"},{tag:Te.attributeName,color:"#e64100"},{tag:Te.angleBracket,color:"#9995b7"}],HO=(()=>{var{theme:e="light",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},UO,t),styles:[...VO,...n]})})(),qO={background:"#2e3440",foreground:"#FFFFFF",caret:"#FFFFFF",selection:"#00000073",selectionMatch:"#00000073",gutterBackground:"#2e3440",gutterForeground:"#4c566a",gutterActiveForeground:"#d8dee9",lineHighlight:"#4c566a29"},KO=[{tag:Te.keyword,color:"#5e81ac"},{tag:[Te.name,Te.deleted,Te.character,Te.propertyName,Te.macroName],color:"#88c0d0"},{tag:[Te.variableName],color:"#8fbcbb"},{tag:[Te.function(Te.variableName)],color:"#8fbcbb"},{tag:[Te.labelName],color:"#81a1c1"},{tag:[Te.color,Te.constant(Te.name),Te.standard(Te.name)],color:"#5e81ac"},{tag:[Te.definition(Te.name),Te.separator],color:"#a3be8c"},{tag:[Te.brace],color:"#8fbcbb"},{tag:[Te.annotation],color:"#d30102"},{tag:[Te.number,Te.changed,Te.annotation,Te.modifier,Te.self,Te.namespace],color:"#b48ead"},{tag:[Te.typeName,Te.className],color:"#ebcb8b"},{tag:[Te.operator,Te.operatorKeyword],color:"#a3be8c"},{tag:[Te.tagName],color:"#b48ead"},{tag:[Te.squareBracket],color:"#bf616a"},{tag:[Te.angleBracket],color:"#d08770"},{tag:[Te.attributeName],color:"#ebcb8b"},{tag:[Te.regexp],color:"#5e81ac"},{tag:[Te.quote],color:"#b48ead"},{tag:[Te.string],color:"#a3be8c"},{tag:Te.link,color:"#a3be8c",textDecoration:"underline",textUnderlinePosition:"under"},{tag:[Te.url,Te.escape,Te.special(Te.string)],color:"#8fbcbb"},{tag:[Te.meta],color:"#88c0d0"},{tag:[Te.monospace],color:"#d8dee9",fontStyle:"italic"},{tag:[Te.comment],color:"#4c566a",fontStyle:"italic"},{tag:Te.strong,fontWeight:"bold",color:"#5e81ac"},{tag:Te.emphasis,fontStyle:"italic",color:"#5e81ac"},{tag:Te.strikethrough,textDecoration:"line-through"},{tag:Te.heading,fontWeight:"bold",color:"#5e81ac"},{tag:Te.special(Te.heading1),fontWeight:"bold",color:"#5e81ac"},{tag:Te.heading1,fontWeight:"bold",color:"#5e81ac"},{tag:[Te.heading2,Te.heading3,Te.heading4],fontWeight:"bold",color:"#5e81ac"},{tag:[Te.heading5,Te.heading6],color:"#5e81ac"},{tag:[Te.atom,Te.bool,Te.special(Te.variableName)],color:"#d08770"},{tag:[Te.processingInstruction,Te.inserted],color:"#8fbcbb"},{tag:[Te.contentSeparator],color:"#ebcb8b"},{tag:Te.invalid,color:"#434c5e",borderBottom:"1px dotted #d30102"}],JO=(()=>{var{theme:e="dark",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},qO,t),styles:[...KO,...n]})})(),ZO={background:"#272822",foreground:"#FFFFFF",caret:"#FFFFFF",selection:"#49483E",selectionMatch:"#49483E",gutterBackground:"#272822",gutterForeground:"#FFFFFF70",lineHighlight:"#0000003b"},YO=[{tag:[Te.comment,Te.documentMeta],color:"#8292a2"},{tag:[Te.number,Te.bool,Te.null,Te.atom],color:"#ae81ff"},{tag:[Te.attributeValue,Te.className,Te.name],color:"#e6db74"},{tag:[Te.propertyName,Te.attributeName],color:"#a6e22e"},{tag:[Te.variableName],color:"#9effff"},{tag:[Te.squareBracket],color:"#bababa"},{tag:[Te.string,Te.special(Te.brace)],color:"#e6db74"},{tag:[Te.regexp,Te.className,Te.typeName,Te.definition(Te.typeName)],color:"#66d9ef"},{tag:[Te.definition(Te.variableName),Te.definition(Te.propertyName),Te.function(Te.variableName)],color:"#fd971f"},{tag:[Te.keyword,Te.definitionKeyword,Te.modifier,Te.tagName,Te.angleBracket],color:"#f92672"}],GO=(()=>{var{theme:e="dark",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},ZO,t),styles:[...YO,...n]})})(),QO="#F5F5F5",XO="#333333",eM="#C9D0D9",tM="#4B69C6",nM="#7A3E9D",iM="#AA3731",sM="#448C27",rM="#9C5D27",oM="#7A3E9D",aM="#AA3731",lM="#9C5D27",cM="#AAAAAA",hM="#AA3731",uM="#cd3131",dM="#4B69C6",fM="#4B69C6",pM={background:QO,foreground:XO,caret:"#54494B",selection:eM,selectionMatch:eM,gutterBackground:QO,gutterForeground:XO,gutterBorder:"transparent",lineHighlight:"#79ff002b"},mM=[{tag:Te.keyword,color:tM},{tag:[Te.name,Te.deleted,Te.character,Te.macroName],color:nM},{tag:[Te.propertyName],color:iM},{tag:[Te.processingInstruction,Te.string,Te.inserted,Te.special(Te.string)],color:sM},{tag:[Te.function(Te.variableName),Te.labelName],color:iM},{tag:[Te.color,Te.constant(Te.name),Te.standard(Te.name)],color:rM},{tag:[Te.definition(Te.name),Te.separator],color:nM},{tag:[Te.className],color:aM},{tag:[Te.number,Te.changed,Te.annotation,Te.modifier,Te.self,Te.namespace],color:lM},{tag:[Te.typeName],color:oM,fontStyle:oM},{tag:[Te.operator,Te.operatorKeyword],color:tM},{tag:[Te.url,Te.escape,Te.regexp,Te.link],color:dM},{tag:[Te.meta,Te.comment],color:cM},{tag:Te.tagName,color:fM},{tag:Te.strong,fontWeight:"bold"},{tag:Te.emphasis,fontStyle:"italic"},{tag:Te.link,textDecoration:"underline"},{tag:Te.heading,fontWeight:"bold",color:hM},{tag:[Te.atom,Te.bool,Te.special(Te.variableName)],color:nM},{tag:Te.invalid,color:uM},{tag:Te.strikethrough,textDecoration:"line-through"}],gM=(()=>{var{theme:e="light",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},pM,t),styles:[...mM,...n]})})(),bM="#390000",yM="#F8F8F8",vM="#750000",kM="#f12727ff",wM="#edef7dff",xM="#ffb454ff",SM="#edef7dff",CM="#ec0d1e",AM="#9df39fff",TM="#fec758ff",NM="#994646ff",OM="#e7c0c0ff",MM="#fec758ff",EM="#ffffffff",DM="#edef7dff",_M="#aa5507ff",IM={background:bM,foreground:yM,caret:"#970000",selection:vM,selectionMatch:vM,gutterBackground:bM,gutterForeground:yM,lineHighlight:"#ff000033"},BM=[{tag:Te.keyword,color:kM},{tag:[Te.name,Te.deleted,Te.character,Te.macroName],color:wM},{tag:[Te.propertyName],color:xM},{tag:[Te.processingInstruction,Te.string,Te.inserted,Te.special(Te.string)],color:SM},{tag:[Te.function(Te.variableName),Te.labelName],color:xM},{tag:[Te.color,Te.constant(Te.name),Te.standard(Te.name)],color:CM},{tag:[Te.definition(Te.name),Te.separator],color:wM},{tag:[Te.className],color:TM},{tag:[Te.number,Te.changed,Te.annotation,Te.modifier,Te.self,Te.namespace],color:NM},{tag:[Te.typeName],color:AM,fontStyle:AM},{tag:[Te.operator,Te.operatorKeyword],color:kM},{tag:[Te.url,Te.escape,Te.regexp,Te.link],color:DM},{tag:[Te.meta,Te.comment],color:OM},{tag:Te.tagName,color:_M},{tag:Te.strong,fontWeight:"bold"},{tag:Te.emphasis,fontStyle:"italic"},{tag:Te.link,textDecoration:"underline"},{tag:Te.heading,fontWeight:"bold",color:MM},{tag:[Te.atom,Te.bool,Te.special(Te.variableName)],color:wM},{tag:Te.invalid,color:EM},{tag:Te.strikethrough,textDecoration:"line-through"}],PM=(()=>{var{theme:e="dark",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},IM,t),styles:[...BM,...n]})})(),RM="#002B36",$M="#839496",LM="#004454AA",zM="#859900",FM="#268BD2",jM="#268BD2",WM="#2AA198",UM="#CB4B16",VM="#859900",HM="#268BD2",qM="#D33682",KM="#586E75",JM="#268BD2",ZM="#DC322F",YM="#DC322F",GM="#268BD2",QM={background:RM,foreground:$M,caret:"#D30102",selection:LM,selectionMatch:LM,gutterBackground:RM,gutterForeground:$M,gutterBorder:"transparent",lineHighlight:"#00cafe11"},XM=[{tag:Te.keyword,color:zM},{tag:[Te.name,Te.deleted,Te.character,Te.macroName],color:FM},{tag:[Te.propertyName],color:jM},{tag:[Te.processingInstruction,Te.string,Te.inserted,Te.special(Te.string)],color:WM},{tag:[Te.function(Te.variableName),Te.labelName],color:jM},{tag:[Te.color,Te.constant(Te.name),Te.standard(Te.name)],color:UM},{tag:[Te.definition(Te.name),Te.separator],color:FM},{tag:[Te.className],color:HM},{tag:[Te.number,Te.changed,Te.annotation,Te.modifier,Te.self,Te.namespace],color:qM},{tag:[Te.typeName],color:VM,fontStyle:VM},{tag:[Te.operator,Te.operatorKeyword],color:zM},{tag:[Te.url,Te.escape,Te.regexp,Te.link],color:YM},{tag:[Te.meta,Te.comment],color:KM},{tag:Te.tagName,color:GM},{tag:Te.strong,fontWeight:"bold"},{tag:Te.emphasis,fontStyle:"italic"},{tag:Te.link,textDecoration:"underline"},{tag:Te.heading,fontWeight:"bold",color:JM},{tag:[Te.atom,Te.bool,Te.special(Te.variableName)],color:FM},{tag:Te.invalid,color:ZM},{tag:Te.strikethrough,textDecoration:"line-through"}],eE=(()=>{var{theme:e="dark",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},QM,t),styles:[...XM,...n]})})(),tE="#FDF6E3",nE="#657B83",iE="#859900",sE="#268BD2",rE="#268BD2",oE="#2AA198",aE="#CB4B16",lE="#859900",cE="#268BD2",hE="#D33682",uE="#93A1A1",dE="#268BD2",fE="#DC322F",pE="#DC322F",mE="#268BD2",gE={background:tE,foreground:nE,caret:"#657B83",selection:"#EEE8D5",selectionMatch:"#EEE8D5",gutterBackground:tE,gutterForeground:nE,gutterBorder:"transparent",lineHighlight:"#3d392d11"},bE=[{tag:Te.keyword,color:iE},{tag:[Te.name,Te.deleted,Te.character,Te.macroName],color:sE},{tag:[Te.propertyName],color:rE},{tag:[Te.processingInstruction,Te.string,Te.inserted,Te.special(Te.string)],color:oE},{tag:[Te.function(Te.variableName),Te.labelName],color:rE},{tag:[Te.color,Te.constant(Te.name),Te.standard(Te.name)],color:aE},{tag:[Te.definition(Te.name),Te.separator],color:sE},{tag:[Te.className],color:cE},{tag:[Te.number,Te.changed,Te.annotation,Te.modifier,Te.self,Te.namespace],color:hE},{tag:[Te.typeName],color:lE,fontStyle:lE},{tag:[Te.operator,Te.operatorKeyword],color:iE},{tag:[Te.url,Te.escape,Te.regexp,Te.link],color:pE},{tag:[Te.meta,Te.comment],color:uE},{tag:Te.tagName,color:mE},{tag:Te.strong,fontWeight:"bold"},{tag:Te.emphasis,fontStyle:"italic"},{tag:Te.link,textDecoration:"underline"},{tag:Te.heading,fontWeight:"bold",color:dE},{tag:[Te.atom,Te.bool,Te.special(Te.variableName)],color:sE},{tag:Te.invalid,color:fE},{tag:Te.strikethrough,textDecoration:"line-through"}],yE=(()=>{var{theme:e="light",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},gE,t),styles:[...bE,...n]})})(),vE={background:"#303841",foreground:"#FFFFFF",caret:"#FBAC52",selection:"#4C5964",selectionMatch:"#3A546E",gutterBackground:"#303841",gutterForeground:"#FFFFFF70",lineHighlight:"#00000059"},kE=[{tag:[Te.meta,Te.comment],color:"#A2A9B5"},{tag:[Te.attributeName,Te.keyword],color:"#B78FBA"},{tag:Te.function(Te.variableName),color:"#5AB0B0"},{tag:[Te.string,Te.regexp,Te.attributeValue],color:"#99C592"},{tag:Te.operator,color:"#f47954"},{tag:[Te.tagName,Te.modifier],color:"#E35F63"},{tag:[Te.number,Te.definition(Te.tagName),Te.className,Te.definition(Te.variableName)],color:"#fbac52"},{tag:[Te.atom,Te.bool,Te.special(Te.variableName)],color:"#E35F63"},{tag:Te.variableName,color:"#539ac4"},{tag:[Te.propertyName,Te.typeName],color:"#629ccd"},{tag:Te.propertyName,color:"#36b7b5"}];var wE=function(){var{theme:e="dark",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},vE,t),styles:[...kE,...n]})}(),xE={background:"#1a1b26",foreground:"#787c99",caret:"#c0caf5",selection:"#515c7e40",selectionMatch:"#16161e",gutterBackground:"#1a1b26",gutterForeground:"#787c99",gutterBorder:"transparent",lineHighlight:"#474b6611"},SE=[{tag:Te.keyword,color:"#bb9af7"},{tag:[Te.name,Te.deleted,Te.character,Te.macroName],color:"#c0caf5"},{tag:[Te.propertyName],color:"#7aa2f7"},{tag:[Te.processingInstruction,Te.string,Te.inserted,Te.special(Te.string)],color:"#9ece6a"},{tag:[Te.function(Te.variableName),Te.labelName],color:"#7aa2f7"},{tag:[Te.color,Te.constant(Te.name),Te.standard(Te.name)],color:"#bb9af7"},{tag:[Te.definition(Te.name),Te.separator],color:"#c0caf5"},{tag:[Te.className],color:"#c0caf5"},{tag:[Te.number,Te.changed,Te.annotation,Te.modifier,Te.self,Te.namespace],color:"#ff9e64"},{tag:[Te.typeName],color:"#0db9d7"},{tag:[Te.operator,Te.operatorKeyword],color:"#bb9af7"},{tag:[Te.url,Te.escape,Te.regexp,Te.link],color:"#b4f9f8"},{tag:[Te.meta,Te.comment],color:"#444b6a"},{tag:Te.strong,fontWeight:"bold"},{tag:Te.emphasis,fontStyle:"italic"},{tag:Te.link,textDecoration:"underline"},{tag:Te.heading,fontWeight:"bold",color:"#89ddff"},{tag:[Te.atom,Te.bool,Te.special(Te.variableName)],color:"#c0caf5"},{tag:Te.invalid,color:"#ff5370"},{tag:Te.strikethrough,textDecoration:"line-through"}],CE=(()=>{var{theme:e="dark",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},xE,t),styles:[...SE,...n]})})(),AE={background:"#24283b",foreground:"#7982a9",caret:"#c0caf5",selection:"#6f7bb630",selectionMatch:"#343b5f",gutterBackground:"#24283b",gutterForeground:"#7982a9",gutterBorder:"transparent",lineHighlight:"#292e427a"},TE=[{tag:Te.keyword,color:"#bb9af7"},{tag:[Te.name,Te.deleted,Te.character,Te.macroName],color:"#c0caf5"},{tag:[Te.propertyName],color:"#7aa2f7"},{tag:[Te.processingInstruction,Te.string,Te.inserted,Te.special(Te.string)],color:"#9ece6a"},{tag:[Te.function(Te.variableName),Te.labelName],color:"#7aa2f7"},{tag:[Te.color,Te.constant(Te.name),Te.standard(Te.name)],color:"#bb9af7"},{tag:[Te.definition(Te.name),Te.separator],color:"#c0caf5"},{tag:[Te.className],color:"#c0caf5"},{tag:[Te.number,Te.changed,Te.annotation,Te.modifier,Te.self,Te.namespace],color:"#ff9e64"},{tag:[Te.typeName],color:"#2ac3de",fontStyle:"#2ac3de"},{tag:[Te.operator,Te.operatorKeyword],color:"#bb9af7"},{tag:[Te.url,Te.escape,Te.regexp,Te.link],color:"#b4f9f8"},{tag:[Te.meta,Te.comment],color:"#565f89"},{tag:Te.strong,fontWeight:"bold"},{tag:Te.emphasis,fontStyle:"italic"},{tag:Te.link,textDecoration:"underline"},{tag:Te.heading,fontWeight:"bold",color:"#89ddff"},{tag:[Te.atom,Te.bool,Te.special(Te.variableName)],color:"#c0caf5"},{tag:Te.invalid,color:"#ff5370"},{tag:Te.strikethrough,textDecoration:"line-through"}],NE=(()=>{var{theme:e="dark",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},AE,t),styles:[...TE,...n]})})(),OE={background:"#e1e2e7",foreground:"#3760bf",caret:"#3760bf",selection:"#99a7df",selectionMatch:"#99a7df",gutterBackground:"#e1e2e7",gutterForeground:"#3760bf",gutterBorder:"transparent",lineHighlight:"#5f5faf11"},ME=[{tag:Te.keyword,color:"#007197"},{tag:[Te.name,Te.deleted,Te.character,Te.macroName],color:"#3760bf"},{tag:[Te.propertyName],color:"#3760bf"},{tag:[Te.processingInstruction,Te.string,Te.inserted,Te.special(Te.string)],color:"#587539"},{tag:[Te.function(Te.variableName),Te.labelName],color:"#3760bf"},{tag:[Te.color,Te.constant(Te.name),Te.standard(Te.name)],color:"#3760bf"},{tag:[Te.definition(Te.name),Te.separator],color:"#3760bf"},{tag:[Te.className],color:"#3760bf"},{tag:[Te.number,Te.changed,Te.annotation,Te.modifier,Te.self,Te.namespace],color:"#b15c00"},{tag:[Te.typeName],color:"#007197",fontStyle:"#007197"},{tag:[Te.operator,Te.operatorKeyword],color:"#007197"},{tag:[Te.url,Te.escape,Te.regexp,Te.link],color:"#587539"},{tag:[Te.meta,Te.comment],color:"#848cb5"},{tag:Te.strong,fontWeight:"bold"},{tag:Te.emphasis,fontStyle:"italic"},{tag:Te.link,textDecoration:"underline"},{tag:Te.heading,fontWeight:"bold",color:"#b15c00"},{tag:[Te.atom,Te.bool,Te.special(Te.variableName)],color:"#3760bf"},{tag:Te.invalid,color:"#f52a65"},{tag:Te.strikethrough,textDecoration:"line-through"}],EE=(()=>{var{theme:e="light",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},OE,t),styles:[...ME,...n]})})(),DE="#002451",_E="#ffffff",IE="#003f8e",BE="#EBBBFF",PE="#FFC58F",RE="#BBDAFF",$E="#D1F1A9",LE="#FFC58F",zE="#FFEEAD",FE="#BBDAFF",jE="#FFC58F",WE="#7285B7",UE="#D1F1A9",VE="#a92049",HE="#D1F1A9",qE="#FF9DA4",KE={background:DE,foreground:_E,caret:"#ffffff",selection:IE,selectionMatch:IE,gutterBackground:DE,gutterForeground:_E,lineHighlight:"#00346e7a"},JE=[{tag:Te.keyword,color:BE},{tag:[Te.name,Te.deleted,Te.character,Te.macroName],color:PE},{tag:[Te.propertyName],color:RE},{tag:[Te.processingInstruction,Te.string,Te.inserted,Te.special(Te.string)],color:$E},{tag:[Te.function(Te.variableName),Te.labelName],color:RE},{tag:[Te.color,Te.constant(Te.name),Te.standard(Te.name)],color:LE},{tag:[Te.definition(Te.name),Te.separator],color:PE},{tag:[Te.className],color:FE},{tag:[Te.number,Te.changed,Te.annotation,Te.modifier,Te.self,Te.namespace],color:jE},{tag:[Te.typeName],color:zE,fontStyle:zE},{tag:[Te.operator,Te.operatorKeyword],color:BE},{tag:[Te.url,Te.escape,Te.regexp,Te.link],color:HE},{tag:[Te.meta,Te.comment],color:WE},{tag:Te.tagName,color:qE},{tag:Te.strong,fontWeight:"bold"},{tag:Te.emphasis,fontStyle:"italic"},{tag:Te.link,textDecoration:"underline"},{tag:Te.heading,fontWeight:"bold",color:UE},{tag:[Te.atom,Te.bool,Te.special(Te.variableName)],color:PE},{tag:Te.invalid,color:VE},{tag:Te.strikethrough,textDecoration:"line-through"}],ZE=(()=>{var{theme:e="dark",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},KE,t),styles:[...JE,...n]})})(),YE={background:"#ffffff",foreground:"#383a42",caret:"#000",selection:"#add6ff",selectionMatch:"#a8ac94",lineHighlight:"#99999926",gutterBackground:"#fff",gutterForeground:"#237893",gutterActiveForeground:"#0b216f",fontFamily:'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace'},GE=[{tag:[Te.keyword,Te.operatorKeyword,Te.modifier,Te.color,Te.constant(Te.name),Te.standard(Te.name),Te.standard(Te.tagName),Te.special(Te.brace),Te.atom,Te.bool,Te.special(Te.variableName)],color:"#0000ff"},{tag:[Te.moduleKeyword,Te.controlKeyword],color:"#af00db"},{tag:[Te.name,Te.deleted,Te.character,Te.macroName,Te.propertyName,Te.variableName,Te.labelName,Te.definition(Te.name)],color:"#0070c1"},{tag:Te.heading,fontWeight:"bold",color:"#0070c1"},{tag:[Te.typeName,Te.className,Te.tagName,Te.number,Te.changed,Te.annotation,Te.self,Te.namespace],color:"#267f99"},{tag:[Te.function(Te.variableName),Te.function(Te.propertyName)],color:"#795e26"},{tag:[Te.number],color:"#098658"},{tag:[Te.operator,Te.punctuation,Te.separator,Te.url,Te.escape,Te.regexp],color:"#383a42"},{tag:[Te.regexp],color:"#af00db"},{tag:[Te.special(Te.string),Te.processingInstruction,Te.string,Te.inserted],color:"#a31515"},{tag:[Te.angleBracket],color:"#383a42"},{tag:Te.strong,fontWeight:"bold"},{tag:Te.emphasis,fontStyle:"italic"},{tag:Te.strikethrough,textDecoration:"line-through"},{tag:[Te.meta,Te.comment],color:"#008000"},{tag:Te.link,color:"#4078f2",textDecoration:"underline"},{tag:Te.invalid,color:"#e45649"}];var QE=function(){var{theme:e="light",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},YE,t),styles:[...GE,...n]})}(),XE={background:"#1e1e1e",foreground:"#9cdcfe",caret:"#c6c6c6",selection:"#6199ff2f",selectionMatch:"#72a1ff59",lineHighlight:"#ffffff0f",gutterBackground:"#1e1e1e",gutterForeground:"#838383",gutterActiveForeground:"#fff",fontFamily:'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace'},eD=[{tag:[Te.keyword,Te.operatorKeyword,Te.modifier,Te.color,Te.constant(Te.name),Te.standard(Te.name),Te.standard(Te.tagName),Te.special(Te.brace),Te.atom,Te.bool,Te.special(Te.variableName)],color:"#569cd6"},{tag:[Te.controlKeyword,Te.moduleKeyword],color:"#c586c0"},{tag:[Te.name,Te.deleted,Te.character,Te.macroName,Te.propertyName,Te.variableName,Te.labelName,Te.definition(Te.name)],color:"#9cdcfe"},{tag:Te.heading,fontWeight:"bold",color:"#9cdcfe"},{tag:[Te.typeName,Te.className,Te.tagName,Te.number,Te.changed,Te.annotation,Te.self,Te.namespace],color:"#4ec9b0"},{tag:[Te.function(Te.variableName),Te.function(Te.propertyName)],color:"#dcdcaa"},{tag:[Te.number],color:"#b5cea8"},{tag:[Te.operator,Te.punctuation,Te.separator,Te.url,Te.escape,Te.regexp],color:"#d4d4d4"},{tag:[Te.regexp],color:"#d16969"},{tag:[Te.special(Te.string),Te.processingInstruction,Te.string,Te.inserted],color:"#ce9178"},{tag:[Te.angleBracket],color:"#808080"},{tag:Te.strong,fontWeight:"bold"},{tag:Te.emphasis,fontStyle:"italic"},{tag:Te.strikethrough,textDecoration:"line-through"},{tag:[Te.meta,Te.comment],color:"#6a9955"},{tag:Te.link,color:"#6a9955",textDecoration:"underline"},{tag:Te.invalid,color:"#ff0000"}];var tD=function(){var{theme:e="dark",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},XE,t),styles:[...eD,...n]})}(),nD="#000",iD="#fff",sD=null,rD=null,oD=null,aD="#a8a8b1",lD=null,cD=null,hD=null,uD="#2e2e37",dD=null,fD=null,pD="#a8a8b1",mD=null,gD={background:nD,foreground:iD,caret:"#7d46fc",selection:"#7d46fc3f",selectionMatch:"#7d46fc7f",gutterBackground:nD,gutterForeground:iD,lineHighlight:"#00346eb0"},bD=[{tag:Te.keyword,color:sD,fontWeight:"bold"},{tag:[Te.name,Te.deleted,Te.character,Te.macroName],color:rD},{tag:[Te.propertyName],color:oD},{tag:[Te.processingInstruction,Te.string,Te.inserted,Te.special(Te.string)],color:aD},{tag:[Te.function(Te.variableName),Te.labelName],color:oD},{tag:[Te.color,Te.constant(Te.name),Te.standard(Te.name)],color:lD},{tag:[Te.definition(Te.name),Te.separator],color:rD},{tag:[Te.className],color:hD},{tag:[Te.typeName],color:cD,fontStyle:cD},{tag:[Te.url,Te.escape,Te.regexp,Te.link],color:pD},{tag:[Te.meta,Te.comment],color:uD},{tag:Te.tagName,color:mD},{tag:Te.strong,fontWeight:"bold"},{tag:Te.emphasis,fontStyle:"italic"},{tag:Te.link,textDecoration:"underline"},{tag:Te.heading,fontWeight:"bold",color:dD},{tag:[Te.atom,Te.special(Te.variableName)],color:rD},{tag:Te.invalid,color:fD},{tag:Te.strikethrough,textDecoration:"line-through"},{tag:[Te.operatorKeyword,Te.bool,Te.null,Te.variableName],color:lD},{tag:[Te.operator],color:"#bb9af7"},{tag:[Te.number],color:"#a8a8b1"},{tag:[Te.bracket],color:"#bb9af7"}],yD=(()=>{var{theme:e="dark",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},gD,t),styles:[...bD,...n]})})(),vD="#fff",kD="#000",wD=null,xD=null,SD=null,CD="#6b7a88",AD=null,TD=null,ND=null,OD="#bec9d3",MD=null,ED=null,DD="#6b7a88",_D=null,ID={background:vD,foreground:kD,caret:"#004bff",selection:"#0064ff26",selectionMatch:"#0064ff4c",gutterBackground:vD,gutterForeground:kD,lineHighlight:"#0064ff0c"},BD=[{tag:Te.keyword,color:wD,fontWeight:"bold"},{tag:[Te.name,Te.deleted,Te.character,Te.macroName],color:xD},{tag:[Te.propertyName],color:SD},{tag:[Te.processingInstruction,Te.string,Te.inserted,Te.special(Te.string)],color:CD},{tag:[Te.function(Te.variableName),Te.labelName],color:SD},{tag:[Te.color,Te.constant(Te.name),Te.standard(Te.name)],color:AD},{tag:[Te.definition(Te.name),Te.separator],color:xD},{tag:[Te.className],color:ND},{tag:[Te.typeName],color:TD,fontStyle:TD},{tag:[Te.url,Te.escape,Te.regexp,Te.link],color:DD},{tag:[Te.meta,Te.comment],color:OD},{tag:Te.tagName,color:_D},{tag:Te.strong,fontWeight:"bold"},{tag:Te.emphasis,fontStyle:"italic"},{tag:Te.link,textDecoration:"underline"},{tag:Te.heading,fontWeight:"bold",color:MD},{tag:[Te.atom,Te.special(Te.variableName)],color:xD},{tag:Te.invalid,color:ED},{tag:Te.strikethrough,textDecoration:"line-through"},{tag:[Te.operatorKeyword,Te.bool,Te.null,Te.variableName],color:AD},{tag:[Te.operator],color:"#0431fa"},{tag:[Te.number],color:"#a8a8b1"},{tag:[Te.bracket],color:"#0431fa"}],PD=(()=>{var{theme:e="light",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},ID,t),styles:[...BD,...n]})})(),RD={background:"#fff",foreground:"#3D3D3D",selection:"#BBDFFF",selectionMatch:"#BBDFFF",gutterBackground:"#fff",gutterForeground:"#AFAFAF",lineHighlight:"#d5e6ff69"},$D=[{tag:[Te.comment,Te.quote],color:"#707F8D"},{tag:[Te.typeName,Te.typeOperator],color:"#aa0d91"},{tag:[Te.keyword],color:"#aa0d91",fontWeight:"bold"},{tag:[Te.string,Te.meta],color:"#D23423"},{tag:[Te.name],color:"#032f62"},{tag:[Te.typeName],color:"#522BB2"},{tag:[Te.variableName],color:"#23575C"},{tag:[Te.definition(Te.variableName)],color:"#327A9E"},{tag:[Te.regexp,Te.link],color:"#0e0eff"}];var LD=function(){var{theme:e="light",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},RD,t),styles:[...$D,...n]})}(),zD={background:"#292A30",foreground:"#CECFD0",caret:"#fff",selection:"#727377",selectionMatch:"#727377",lineHighlight:"#ffffff0f"},FD=[{tag:[Te.comment,Te.quote],color:"#7F8C98"},{tag:[Te.keyword],color:"#FF7AB2",fontWeight:"bold"},{tag:[Te.string,Te.meta],color:"#FF8170"},{tag:[Te.typeName],color:"#DABAFF"},{tag:[Te.definition(Te.variableName)],color:"#6BDFFF"},{tag:[Te.name],color:"#6BAA9F"},{tag:[Te.variableName],color:"#ACF2E4"},{tag:[Te.regexp,Te.link],color:"#FF8170"}],jD=(()=>{var{theme:e="dark",settings:t={},styles:n=[]}={};return yA({theme:e,settings:bA({},zD,t),styles:[...FD,...n]})})();function WD(e){switch(e.kind){case"literal":return JSON.parse(e.jsonCode);case"array":return e.values.map(WD);case"object":return Object.fromEntries(Object.values(e.keyValues).map(e=>[e.key,WD(e.value)]))}}function UD(e,t,n){switch(e.kind){case"array":return[];case"optional":return null;case"record":{const i=t[e.value];return"struct"===i.kind?n?{}:Object.fromEntries(i.fields.map(e=>[e.name,UD(e.type,t,"nested")])):"UNKNOWN"}case"primitive":switch(e.value){case"bool":return!1;case"int32":case"float32":case"float64":return 0;case"int64":case"hash64":return"0";case"timestamp":return{unix_millis:0,formatted:"1970-01-01T00:00:00Z"};case"string":case"bytes":return""}}}function VD(e){const t=function(e){const t=[];let n=0,i=0,s=!1;const r=/[ \t\r\n]*/y,o=/([[\]{}:,]|(-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?)|false|true|null|("(((?=\\)\\(["\\/ bfnrt]|u[0-9a-fA-F]{4}))|[^"\\\0-\x1F\x7F]+)*")|$)/y;for(;;){const a=n;r.lastIndex=n,r.exec(e),n=r.lastIndex;for(let t=a;t<n;++t){const n=e[t];"\n"===n?(i=0,s=!1):s||" "!==n&&"\t"!==n||i++}o.lastIndex=n;const l=o.exec(e);if(!l){const t=/\w*/uy;t.lastIndex=n+1,t.exec(e);return{kind:"error",message:"not a token",segment:{start:n,end:t.lastIndex||n+1}}}{const e=l[0],r={segment:{start:n,end:n+e.length},jsonCode:e,indent:i};if(n=o.lastIndex,t.push(r),""!==e&&(s=!0),""===e)return{kind:"tokens",tokens:t}}}}(e);if("error"===t.kind)return{value:void 0,errors:[t],edits:[]};const n=new HD(t.tokens,e),i=n.parseValueOrSkip();return n.expectEnd(),{value:i,errors:n.errors,edits:n.edits}}class HD{constructor(e,t){this.tokens=e,this.input=t,this.tokenIndex=0,this.errors=[],this.edits=[],this.indent=""}parseValueOrSkip(){const e=this.peekToken(),t=e.jsonCode?e.jsonCode[0]:"",{indent:n}=e;switch(t){case"[":return this.parseArray();case"{":return this.parseObject();case"n":return this.nextToken(),{kind:"literal",firstToken:e.segment,segment:e.segment,jsonCode:"null",type:"null",indent:n};case"f":return this.nextToken(),{kind:"literal",firstToken:e.segment,segment:e.segment,jsonCode:"false",type:"boolean",indent:n};case"t":return this.nextToken(),{kind:"literal",firstToken:e.segment,segment:e.segment,jsonCode:"true",type:"boolean",indent:n};case'"':return this.nextToken(),{kind:"literal",firstToken:e.segment,segment:e.segment,jsonCode:e.jsonCode,type:"string",indent:n};case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"-":return this.nextToken(),{kind:"literal",firstToken:e.segment,segment:e.segment,jsonCode:e.jsonCode,type:"number",indent:n}}this.errors.push({kind:"error",message:"expected: value",segment:this.peekToken().segment}),this.skip()}parseArray(){const e=this.nextToken(),{indent:t}=e,n=[];for(;;){if("]"===this.peekToken().jsonCode){const i=this.nextToken();return{kind:"array",firstToken:e.segment,segment:{start:e.segment.start,end:i.segment.end},values:n,indent:t}}if("}"===this.peekToken().jsonCode){this.errors.push({kind:"error",message:"expected: ']'",segment:this.peekToken().segment});const i=this.nextToken();return{kind:"array",firstToken:e.segment,segment:{start:e.segment.start,end:i.segment.end},values:n,indent:t}}if(""===this.peekToken().jsonCode)return this.expectSymbolOrSkip("]"),{kind:"array",firstToken:e.segment,segment:{start:e.segment.start,end:this.peekToken().segment.start},values:n,indent:t};const i=this.parseValueOrSkip();if(i&&n.push(i),","===this.peekToken().jsonCode){const e=this.nextToken();"]"===this.peekToken().jsonCode&&this.edits.push({segment:e.segment,replacement:""})}}}parseObject(){const e=this.nextToken(),{indent:t}=e,n={},i=[];for(;;){if("}"===this.peekToken().jsonCode){const s=this.nextToken();return{kind:"object",firstToken:e.segment,segment:{start:e.segment.start,end:s.segment.end},keyValues:n,allKeys:i,indent:t}}if("]"===this.peekToken().jsonCode){this.errors.push({kind:"error",message:"expected: ']'",segment:this.peekToken().segment});const s=this.nextToken();return{kind:"object",firstToken:e.segment,segment:{start:e.segment.start,end:s.segment.end},keyValues:n,allKeys:i,indent:t}}if(""===this.peekToken().jsonCode)return this.expectSymbolOrSkip("}"),{kind:"object",firstToken:e.segment,segment:{start:e.segment.start,end:this.peekToken().segment.start},keyValues:n,allKeys:i,indent:t};const s=this.peekToken();if(!s.jsonCode.startsWith('"')){this.errors.push({kind:"error",message:"expected: string",segment:s.segment}),this.skip(),","===this.peekToken().jsonCode&&this.nextToken();continue}const r=JSON.parse(s.jsonCode);if(i.push({key:r,keySegment:s.segment}),this.nextToken(),!this.expectSymbolOrSkip(":"))continue;n[r]&&this.errors.push({kind:"error",message:"duplicate key",segment:s.segment});const o=this.parseValueOrSkip();if(o&&(n[r]={keySegment:s.segment,key:r,value:o}),","===this.peekToken().jsonCode){const e=this.nextToken();"}"===this.peekToken().jsonCode&&this.edits.push({segment:e.segment,replacement:""})}}}expectEnd(){this.nextToken().jsonCode&&this.errors.push({kind:"error",message:"expected: end",segment:this.peekToken().segment})}nextToken(){const e=this.tokens[this.tokenIndex];{const t=this.tokenIndex<=0?void 0:this.tokens[this.tokenIndex-1],n={start:t?t.segment.end:0,end:e.segment.start},i=this.input.substring(n.start,n.end),s=this.inferWhitespaceSeparator(t?.jsonCode??"",e.jsonCode);i!==s.text&&this.edits.push({segment:n,replacement:s.text}),this.indent=s.newIndent??this.indent}return++this.tokenIndex,e}inferWhitespaceSeparator(e,t){const{indent:n}=this;if(":"===e)return{text:" "};if(","===e&&"]"!==t&&"}"!==t)return{text:`\n${n}`};if(/[0-9"}\]el]$/.test(e)&&/^[0-9"{[tfn-]/.test(t))return{text:`,\n${n}`};if("["===e&&"]"!==t||"{"===e&&"}"!==t){const e=n+qD;return{text:`\n${e}`,newIndent:e}}if("["!==e&&"]"===t||"{"!==e&&"}"===t){const e=n.replace(qD,"");return{text:`\n${e}`,newIndent:e}}return{text:""}}peekToken(){return this.tokens[this.tokenIndex]}expectSymbolOrSkip(e){return this.peekToken().jsonCode!==e?(this.errors.push({kind:"error",message:`expected: '${e}'`,segment:this.peekToken().segment}),this.skip(),!1):(this.nextToken(),!0)}skip(){for(;;){const e=this.peekToken().jsonCode;if(""===e||","===e||"]"===e||"}"===e||e.startsWith('"'))return;"["===e?this.parseArray():"{"===e?this.parseObject():this.nextToken()}}}const qD=" ";function KD(e,t){const n={};for(const e of t.records)n[e.id]=e;const i=new JD(n);i.validate(e,{kind:"root"},t.type);const s=new Map;for(const e of i.hints){const{valueContext:t}=e;t&&s.set(t.path,e)}return{errors:i.errors,hints:i.hints,rootTypeHint:i.rootTypeHint,pathToTypeHint:s}}class JD{constructor(e){this.idToRecordDef=e,this.errors=[],this.hints=[],this.typeHintStack=[]}validate(e,t,n,i){const{idToRecordDef:s,typeHintStack:r}=this;e.expectedType=n;const o=o=>{const a=function(e){function t(e){switch(e.kind){case"primitive":return e.value;case"array":return`[${t(e.value.item)}]`;case"optional":return`${t(e.value)}?`;case"record":return e.value.split(":")[1]}}function n(e){switch(e.kind){case"primitive":return null;case"array":return n(e.value.item);case"optional":return n(e.value);case"record":return e.value.split(":")[0]}}const i=t(e),s=n(e);return s?`${i} (${s})`:i}(i??n),l=GD(n,s),c=[a];if(l&&c.push(l),"array"===e.kind){const{length:t}=e.values;t&&c.push(`Length: ${t}`)}const h={segment:e.firstToken,message:1===c.length?c[0]:c,valueContext:{value:e,path:t},childHints:[],enumDefinition:o?.enumDefinition};if(r.length){r[r.length-1].childHints.push(h)}else this.rootTypeHint=h;this.hints.push(h),r.push(h)};switch(n.kind){case"array":if("array"===e.kind){o();for(const[i,s]of e.values.entries()){const{key_extractor:e,item:r}=n.value,o={kind:"array-item",index:i,key:ZD(s,e),arrayPath:t};this.validate(s,o,r)}r.pop()}else this.errors.push({kind:"error",segment:e.segment,message:"Expected: array"});break;case"optional":"literal"===e.kind&&"null"===e.jsonCode?(o(),r.pop()):this.validate(e,t,n.value,n);break;case"primitive":{const t=n.value;"timestamp"===t?this.validateTimestamp(e)&&(o(),r.pop()):!function(e,t){switch(t){case"bool":return"literal"===e.kind&&"boolean"===e.type;case"int32":return YD(e,-2147483648n,2147483647n);case"int64":return YD(e,-9223372036854775808n,9223372036854775807n);case"hash64":return YD(e,0n,18446744073709551615n);case"float32":case"float64":return function(e){if("literal"!==e.kind)return!1;return"number"===e.type||"string"===e.type&&('"NaN"'===e.jsonCode||'"Infinity"'===e.jsonCode||'"-Infinity"'===e.jsonCode)}(e);case"string":return"literal"===e.kind&&"string"===e.type;case"bytes":if("literal"!==e.kind)return!1;try{return DC("bytes").fromJsonCode(e.jsonCode),!0}catch{return!1}case"timestamp":throw new Error}}(e,t)?this.errors.push({kind:"error",segment:e.firstToken,message:`Expected: ${t}`}):(o(),r.pop());break}case"record":{const i=s[n.value];if("struct"===i.kind){const n={};if(i.fields.forEach(e=>{n[e.name]=e}),"object"===e.kind){o();for(const i of Object.values(e.keyValues)){const{key:e,value:s}=i,r=n[e];if(r){r.doc&&this.hints.push({segment:i.keySegment,message:r.doc});const n={kind:"field-value",fieldName:e,structPath:t};this.validate(s,n,r.type)}else this.errors.push({kind:"error",segment:i.keySegment,message:"Unknown field"})}r.pop()}else this.errors.push({kind:"error",segment:e.firstToken,message:"Expected: object"})}else{const n={};if(i.variants.forEach(e=>{n[e.name]=e}),"object"===e.kind)o(),this.validateEnumObject(e,t,n),r.pop();else if("literal"===e.kind&&"string"===e.type){const t=JSON.parse(e.jsonCode),s=n[t];s&&s.type?this.errors.push({kind:"error",segment:e.segment,message:"Expected: uppercase variant name"}):"UNKNOWN"===t||s?(o({enumDefinition:i}),r.pop()):this.errors.push({kind:"error",segment:e.segment,message:"Unknown variant"})}else this.errors.push({kind:"error",segment:e.firstToken,message:"Expected: object or string"})}break}default:throw new Error(n)}}validateEnumObject(e,t,n){const i=e.keyValues.kind;if(!i)return void this.errors.push({kind:"error",segment:e.segment,message:"Missing: 'kind'"});if("literal"!==i.value.kind||"string"!==i.value.type)return void this.errors.push({kind:"error",segment:i.value.firstToken,message:"Expected: string"});const s=JSON.parse(i.value.jsonCode);if(s!==s.toLowerCase())return void this.errors.push({kind:"error",segment:i.value.segment,message:"Expected: lowercase variant name"});const r=n[s];if(!r)return void this.errors.push({kind:"error",segment:i.value.segment,message:"Unknown variant"});const o=e.keyValues.value;if(!o)return void this.errors.push({kind:"error",segment:e.segment,message:"Missing: 'value'"});for(const t of e.allKeys)"kind"!==t.key&&"value"!==t.key&&this.errors.push({kind:"error",segment:t.keySegment,message:"Unexpected entry"});const a={kind:"variant-value",variantName:r.name,enumPath:t};this.validate(o.value,a,r.type)}validateTimestamp(e){if("object"!==e.kind)return this.errors.push({kind:"error",segment:e.firstToken,message:"Expected: timestamp"}),!1;const t=e.keyValues.unix_millis;if(!t)return this.errors.push({kind:"error",segment:e.firstToken,message:"Missing: 'unix_millis'"}),!0;if("literal"!==t.value.kind||"number"!==t.value.type)return this.errors.push({kind:"error",segment:t.value.firstToken,message:"Expected: number"}),!0;const n=WD(t.value);if(n<-864e13||864e13<n)return this.errors.push({kind:"error",segment:t.value.firstToken,message:"Timestamp out of range"}),!0;const i=e.keyValues.formatted;if(!i)return!0;if("literal"!==i.value.kind||"string"!==i.value.type)return this.errors.push({kind:"error",segment:i.value.firstToken,message:"Expected: string"}),!0;const s=WD(i.value);if("n/a"===s)return!0;const r=Date.parse(s);if(Number.isNaN(r))return this.errors.push({kind:"error",segment:i.value.firstToken,message:"Invalid ISO 8601 date string"}),!0;r!==n&&this.errors.push({kind:"error",segment:i.value.firstToken,message:"Does not match 'unix_millis'"});for(const t of e.allKeys)"unix_millis"!==t.key&&"formatted"!==t.key&&this.errors.push({kind:"error",segment:t.keySegment,message:"Unexpected entry"});return!0}}function ZD(e,t){if(void 0===t)return null;const n=t.split(".");let i=e;for(const e of n){if("object"!==i.kind)return null;const t=i.keyValues[e];if(!t)return null;i=t.value}switch(i.kind){case"literal":switch(i.type){case"string":case"number":case"boolean":return i.jsonCode}return null;case"object":{const e=i.keyValues.unix_millis;return e&&"literal"===e.value.kind&&"number"===e.value.type?e.value.jsonCode:null}case"array":return null}}function YD(e,t,n){if("literal"!==e.kind)return!1;let i,s;if("string"===e.type)i=JSON.parse(e.jsonCode);else{if("number"!==e.type)return!1;i=e.jsonCode}try{s=BigInt(i)}catch{return!1}return t<=s&&s<=n}function GD(e,t){switch(e.kind){case"primitive":return;case"array":return GD(e.value.item,t);case"optional":return GD(e.value,t);case"record":return t[e.value].doc}}const QD=Vt.define(),XD=wt.define({create:()=>null,update(e,t){for(const e of t.effects)if(e.is(QD))return e.value;return e}});function e_(e){return[XD,bs.fromClass(class{constructor(e){this.timeout=null,this.view=e,this.scheduleUpdate()}update(e){if(e.docChanged){const t=e.transactions.some(e=>"undo"===e.annotation(Ht.userEvent)||"redo"===e.annotation(Ht.userEvent));this.scheduleUpdate(t?"from-undo":void 0)}}scheduleUpdate(e){null!==this.timeout&&clearTimeout(this.timeout),this.timeout=window.setTimeout(()=>{this.parseJson(e),this.timeout=null},200)}parseJson(t){const n=this.view.state.doc.toString(),i=VD(n);let s;i.value&&(s=KD(i.value,e));if(!t&&i.edits.length&&i.errors.length<=0&&!(()=>{const e=this.view.state.selection.main.head;return i.edits.some(t=>t.segment.start<=e&&e<=t.segment.end)})()){const t=i.edits.map(e=>({from:e.segment.start,to:e.segment.end,insert:e.replacement})),r=this.view.state.field(XD,!1),o=t_(e,r);this.view.dispatch({changes:t,effects:QD.of({parseResult:i,validationResult:s,source:n,schema:e,recordIdToDefinition:o}),scrollIntoView:!0})}else{const t=this.view.state.field(XD,!1),r=t_(e,t);this.view.dispatch({effects:QD.of({parseResult:i,validationResult:s,source:n,schema:e,recordIdToDefinition:r})})}}destroy(){null!==this.timeout&&clearTimeout(this.timeout)}})]}function t_(e,t){if(e===t?.schema)return t.recordIdToDefinition;const n={};for(const t of e.records)n[t.id]=t;return n}function n_(e){const t={};for(const n of e.records)t[n.id]=n;function n(e,i){if(!i_(i,e.segment))return null;const{expectedType:s}=e;if(!s)return null;switch("optional"===s.kind&&s.value,e.kind){case"array":if("array"!==s.kind)return null;for(const t of e.values){if(i<t.firstToken.start)return null;const e=n(t,i);if(e)return e}return null;case"object":{if("record"!==s.kind)return null;const r=t[s.value];if("struct"===r.kind)for(const t of e.allKeys){const{keySegment:s}=t;if(i_(i,s)){const t=s_(e,r);return{from:s.start+1,to:s.end-1,options:t.map(e=>({label:e}))}}const o=e.keyValues[t.key];if(o){const e=n(o.value,i);if(e)return e}}else{const t=e.keyValues.kind;if(t&&i_(i,t.value.firstToken)&&"literal"===t.value.kind&&"string"===t.value.type){const e=r.variants.filter(e=>e.type).map(e=>({label:e.name}));return{from:t.value.firstToken.start+1,to:t.value.firstToken.end-1,options:e}}const s=e.keyValues.value;if(s){const e=n(s?.value,i);if(e)return e}}return null}case"literal":{if("record"!==s.kind)return null;const n=t[s.value];if("enum"!==n.kind)return null;const i=n.variants.filter(e=>!e.type).map(e=>({label:e.name})).concat({label:"UNKNOWN"});return{from:e.firstToken.start+1,to:e.firstToken.end-1,options:i}}}}return function(t){const i=t.pos;if(!t.view)return null;const s=i>0?t.state.doc.sliceString(i-1,i):"",r=t.explicit||'"'===s?function(e,t){const n=e.state.field(XD,!1),i=e.state.doc.toString();if(n&&n.source===i)return n;const s=VD(i);let r;s.value&&(r=KD(s.value,t));const o={parseResult:s,validationResult:r,source:i,schema:t,recordIdToDefinition:t_(t,n)};return n&&n===o||e.dispatch({effects:QD.of(o)}),o}(t.view,e):t.state.field(XD,!1);if(!r)return null;const o=r.parseResult;return o.value?n(o.value,i):null}}function i_(e,t){return e>=t.start&&e<t.end}function s_(e,t){const n=[];for(const i of t.fields)e.keyValues[i.name]||n.push(i.name);return n}function r_(e){return function(t){const n=t.state.field(XD,!1);if(!n)return[];const i=n.parseResult;if(i.errors.length)return i.errors.map(o_);if(!n.validationResult)return[];const{errors:s,hints:r}=n.validationResult;return s.map(o_).concat(r.map(t=>function(e,t){const{message:n}=e;return{from:e.segment.start,to:e.segment.end,message:"",severity:"info",renderMessage:i=>{const s=document.createElement("div");let r;if(s.className="cm-diagnostic-wrapper","string"!==n&&"string?"!==n||!e.valueContext||"literal"!==e.valueContext.value.kind||"string"!==e.valueContext.value.type)if("timestamp"!==n&&"timestamp?"!==n||!e.valueContext||"object"!==e.valueContext.value.kind||"editable"!==t){r=("string"==typeof n?[n]:n).map(e=>{const t=document.createElement("div");return t.textContent=e,t}),e.valueContext&&e.enumDefinition}else;else r=function(e,t,n,i){const s=document.createElement("div");s.textContent=t.message;const r=n.jsonCode,o=JSON.parse(r),a=document.createElement("div");a.className="cm-diagnostic-controls";const l=document.createElement("span");l.textContent="Value:";const c=document.createElement("textarea");c.className="cm-diagnostic-textarea",c.value=o,c.rows=1;const h="read-only"===i;return c.readOnly=h,c.addEventListener("keydown",e=>{"Enter"===e.key&&e.shiftKey}),a.appendChild(l),a.appendChild(c),[s,a]}(0,e,e.valueContext.value,t);for(const e of r)e.classList.add("diagnostic-row"),s.appendChild(e);return s},markClass:""}}(t,e)))}}function o_(e){return{from:e.segment.start,to:e.segment.end,message:e.message,severity:"error",renderMessage:()=>{const t=document.createElement("div");return t.className="cm-diagnostic-wrapper",t.textContent=e.message,t}}}function a_(e){const t=document.createElement("div");function n(){const n=e.state.selection.main.head,i=e.state.field(XD,!1),s=i?.validationResult,r=s?.rootTypeHint,o=[];if(r){const t=l_(n,r);if(t){const{pathToTypeHint:n}=s,i=new c_(n,e);i.appendNodesForPath(t.valueContext.path),o.push(...i.nodes),o.reverse()}}t.replaceChildren(...o)}return t.className="cm-status-bar",n(),{dom:t,update(e){e.selectionSet&&n()},top:!1}}function l_(e,t){const n=t.valueContext.value.segment;if(e<n.start||e>n.end)return;let i,s=0,r=t.childHints.length-1;for(;s<=r;){const n=Math.floor((s+r)/2),o=t.childHints[n],a=o.valueContext.value.segment;if(e<a.start)r=n-1;else{if(!(e>a.end)){i=o;break}s=n+1}}if(i){const t=l_(e,i);return void 0!==t?t:i}return t}class c_{constructor(e,t){this.pathToTypeHint=e,this.view=t,this.nodes=[]}appendNodesForPath(e){const t=this.pathToTypeHint.get(e).valueContext.value.segment.start,n=document.createElement("a");switch(n.className="cm-status-bar-link",n.addEventListener("click",e=>{e.preventDefault(),this.view.dispatch({selection:{anchor:t,head:t},scrollIntoView:!0}),this.view.focus()}),e.kind){case"root":n.append("root"),this.nodes.push(n);break;case"array-item":this.appendNodesForPath(e.arrayPath),null!=e.key?n.append(`[${e.index}|${e.key}]`):n.append(`[${e.index}]`),this.nodes.push(n);break;case"field-value":this.appendNodesForPath(e.structPath),n.append(`.${e.fieldName}`),this.nodes.push(n);break;case"variant-value":this.appendNodesForPath(e.enumPath),n.append(`.value("${e.variantName}")`),this.nodes.push(n)}}}const h_={backgroundColor:"#fffdf7",lighterBgColor:"#f3eee1",borderColor:"#d4d0c4",foregroundColor:"#111111",accentColor:"#111111",errorColor:"#232323",selectionColor:"#d9d4c7"},u_={backgroundColor:"#1a1b26",lighterBgColor:"#1f2335",borderColor:"#414868",foregroundColor:"#c0caf5",accentColor:"#7aa2f7",errorColor:"#f7768e",selectionColor:"#515c7e40"},d_={backgroundColor:"#d5d6db",lighterBgColor:"#e1e2e7",borderColor:"#adb0bb",foregroundColor:"#3760bf",accentColor:"#2e7de9",errorColor:"#f52a65",selectionColor:"#3760bf33"},f_={abcdef:wA,abyss:UA,androidstudio:qA,andromeda:pT,atomone:bT,aura:kT,"basic-dark":ST,"basic-light":TT,bbedit:MT,bespin:_T,"console-dark":BT,"console-light":RT,copilot:sN,darcula:aN,dracula:hN,"duotone-dark":gN,"duotone-light":fN,eclipse:vN,"github-dark":AN,"github-light":xN,"gruvbox-dark":ON,"gruvbox-light":EN,kimbie:ZN,material:tO,"material-dark":eO,"material-light":sO,monokai:SO,"monokai-dimmed":WO,"noctis-lilac":HO,nord:JO,okaidia:GO,quietlight:gM,red:PM,"solarized-dark":eE,"solarized-light":yE,sublime:wE,"tokyo-night":CE,"tokyo-night-day":EE,"tokyo-night-storm":NE,"tomorrow-night-blue":ZE,"vscode-dark":tD,"vscode-light":QE,white:PD,"white-dark":yD,"white-light":PD,"xcode-dark":jD,"xcode-light":LD},p_={abcdef:vA,abyss:jA,androidstudio:VA,andromeda:dT,atomone:mT,aura:yT,"basic-dark":wT,"basic-light":CT,bbedit:NT,bespin:ET,"console-dark":IT,"console-light":PT,copilot:nN,darcula:rN,dracula:lN,"duotone-dark":pN,"duotone-light":uN,eclipse:bN,"github-dark":SN,"github-light":kN,"gruvbox-dark":TN,"gruvbox-light":MN,kimbie:KN,material:YN,"material-dark":GN,"material-light":nO,monokai:wO,"monokai-dimmed":FO,"noctis-lilac":UO,nord:qO,okaidia:ZO,quietlight:pM,red:IM,"solarized-dark":QM,"solarized-light":gE,sublime:vE,"tokyo-night":xE,"tokyo-night-day":OE,"tokyo-night-storm":AE,"tomorrow-night-blue":KE,"vscode-dark":XE,"vscode-light":YE,white:ID,"white-dark":gD,"white-light":ID,"xcode-dark":zD,"xcode-light":RD};function m_(...e){for(const t of e)if(t&&"transparent"!==t)return t}function g_(e){const t=f_[e];return"white"===e?{...h_,themeExtension:t}:"tokyo-night"===e?{...u_,themeExtension:t}:"tokyo-night-day"===e?{...d_,themeExtension:t}:function(e,t){const n=m_(e.background,e.gutterBackground),i=m_(e.caret,e.foreground,e.gutterForeground),s=m_(e.selection,e.selectionMatch,e.lineHighlight);return{backgroundColor:n??"#1a1b26",lighterBgColor:m_(e.gutterBackground,e.lineHighlight,n)??"#1f2335",borderColor:m_(e.gutterBorder,e.selectionMatch,e.selection,e.foreground)??"#414868",foregroundColor:i??"#c0caf5",accentColor:m_(e.foreground,e.caret)??"#7aa2f7",errorColor:m_(e.caret,e.foreground)??"#f7768e",selectionColor:s??"#515c7e40",themeExtension:t}}(p_[e],t)}function b_({schema:e,readOnly:t,json:n,theme:i,otherExtension:s}){const r={};for(const t of e.records)r[t.id]=t;const o=n??UD(e.type,r);return void 0===i?i=g_("tokyo-night"):"string"==typeof i&&(i=g_(i)),nn.create({doc:JSON.stringify(o,null,2),extensions:[nn.readOnly.of(!0),[],Rp,nn.languageData.of(()=>[{closeBrackets:{before:",]}"}}]),Pf(),i.themeExtension??[],mh(),e_(e),mp(r_("read-only")),Zf({override:[n_(e)]}),Pp(),ll.of(a_),Uo.theme({"&":{fontSize:"14px",height:"100%"},".cm-scroller":{fontFamily:"'JetBrains Mono', monospace",overflow:"auto"},".cm-lintRange-info":{backgroundImage:"none"},".cm-lintRange-info:hover":{backgroundColor:i.selectionColor},".cm-lintRange-error":{backgroundImage:"none",borderBottom:`3px solid ${i.errorColor}`},".cm-tooltip-hover":{backgroundColor:i.lighterBgColor,border:`1px solid ${i.borderColor}`,borderRadius:"4px",padding:"8px 12px",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.5)",fontSize:"14px",lineHeight:"1.4",color:i.foregroundColor},".cm-tooltip.cm-tooltip-lint":{backgroundColor:i.lighterBgColor,border:`1px solid ${i.borderColor}`,borderRadius:"4px",padding:"8px 12px",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.5)",fontSize:"14px",color:i.foregroundColor},".cm-tooltip-lint .cm-diagnostic-error":{fontWeight:"bold",color:i.errorColor},".cm-status-bar":{backgroundColor:i.lighterBgColor,borderTopColor:i.borderColor,color:i.accentColor},".cm-diagnostic-textarea":{backgroundColor:i.lighterBgColor,borderColor:i.borderColor,color:i.foregroundColor},".cm-diagnostic-textarea[readonly]":{backgroundColor:i.backgroundColor},".cm-diagnostic-input":{backgroundColor:i.lighterBgColor,borderColor:i.borderColor,color:i.foregroundColor},".cm-diagnostic-button":{backgroundColor:i.lighterBgColor,borderColor:i.borderColor,color:i.foregroundColor},".cm-diagnostic-button:hover":{backgroundColor:i.borderColor},".cm-diagnostic-error-message":{color:i.errorColor},".diagnostic-row + .diagnostic-row":{borderTopColor:i.borderColor}}),Uo.baseTheme({".cm-lint-marker-info":{display:"none"},".cm-status-bar":{display:"flex",flexDirection:"row-reverse",justifyContent:"flex-end",padding:"4px 12px",borderTop:"1px solid",fontSize:"12px",height:"16px"},".cm-status-bar-link":{textDecoration:"none",cursor:"pointer"},".cm-status-bar-link:hover":{textDecoration:"underline"},".cm-status-bar-link:hover ~ .cm-status-bar-link":{textDecoration:"underline"},".cm-diagnostic-wrapper":{fontSize:"12px",lineHeight:"1.3",padding:"2px"},".cm-diagnostic-controls":{marginTop:"4px",display:"flex",gap:"6px",alignItems:"center"},".cm-diagnostic-label":{whiteSpace:"nowrap",fontWeight:"500",minWidth:"64px"},".cm-diagnostic-textarea":{flex:"1",padding:"3px 6px",border:"1px solid",borderRadius:"3px",fontSize:"12px",fontFamily:"'JetBrains Mono', monospace",resize:"none",overflow:"auto",boxSizing:"border-box"},".cm-diagnostic-textarea[readonly]":{cursor:"default"},".cm-diagnostic-input":{padding:"3px 6px",border:"1px solid",borderRadius:"3px",fontSize:"12px",fontFamily:"'JetBrains Mono', monospace",boxSizing:"border-box",width:"100%"},".cm-diagnostic-button":{padding:"3px 12px",border:"1px solid",borderRadius:"3px",fontSize:"12px",fontFamily:"'JetBrains Mono', monospace",cursor:"pointer",boxSizing:"border-box"},".cm-diagnostic-button:active":{transform:"translateY(1px)"},".cm-diagnostic-error-message":{fontSize:"11px",marginTop:"2px",fontWeight:"500"},".cm-timestamp-field":{display:"flex",flexDirection:"column",gap:"2px",flex:"1"},".cm-tooltip-lint .cm-diagnostic":{padding:"0",borderTop:"none",borderLeft:"none"},".cm-tooltip-lint .cm-diagnostic-error":{borderLeft:"none",fontWeight:"bold"},".cm-tooltip-lint .cm-diagnostic-info":{borderLeft:"none"},".diagnostic-row + .diagnostic-row":{marginTop:"8px",paddingTop:"8px",borderTop:"1px solid"}}),s??[]]})}const y_=[PD,Uo.theme({"&":{height:"100%",fontSize:"14px"},".cm-scroller":{fontFamily:"'IBM Plex Mono', monospace"},".cm-gutters":{borderRight:"1px solid #d4d0c4",backgroundColor:"#f7f3e8",color:"#746f63"},".cm-activeLine, .cm-activeLineGutter":{backgroundColor:"#f3eee1"},".cm-selectionBackground, &.cm-focused .cm-selectionBackground, ::selection":{backgroundColor:"#d9d4c7"},".cm-tooltip":{border:"1px solid #232323",backgroundColor:"#fffdf7",color:"#111111"},".cm-tooltip-autocomplete ul li[aria-selected]":{backgroundColor:"#111111",color:"#fffdf7"},".cm-panels":{backgroundColor:"#f3eee1",color:"#111111"},".cm-searchMatch":{backgroundColor:"#ece7da",outline:"1px solid #232323"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#d9d4c7"},".cm-matchingBracket":{backgroundColor:"#ece7da",outline:"1px solid #232323",color:"#111111"},".cm-nonmatchingBracket":{backgroundColor:"#111111",color:"#fffdf7"},".cm-foldPlaceholder":{border:"1px solid #d4d0c4",backgroundColor:"#f3eee1",color:"#545454"},".cm-lintRange-error":{backgroundImage:"none",borderBottom:"2px solid #232323"},".cm-status-bar":{borderTop:"1px solid #d4d0c4",backgroundColor:"#f3eee1",color:"#545454"}})],v_={backgroundColor:"#fffdf7",lighterBgColor:"#f3eee1",borderColor:"#d4d0c4",foregroundColor:"#111111",accentColor:"#111111",errorColor:"#232323",selectionColor:"#d9d4c7",themeExtension:y_};function k_(e){if(""===e)return{text:e,parsed:{kind:"not-set"}};let t,n;t=/^736[Bb]6972/.test(e)?"base16":e.startsWith("c2tpc")?"base64":"json";try{if("json"===t){n={kind:"json",value:JSON.parse(e)}}else if("base16"===t){n={kind:"bytes",value:new Uint8Array(e.match(/.{1,2}/g)?.map(e=>parseInt(e,16))??[]).buffer}}else if("base64"===t){const t=atob(e),i=new Uint8Array(t.length);for(let e=0;e<t.length;e++)i[e]=t.charCodeAt(e);n={kind:"bytes",value:i.buffer}}else n={kind:"not-set"}}catch(e){n={kind:"parse-error",error:String(e)}}return{text:e,parsed:n}}function w_(e){if(""===e)return{text:e,typeDescriptor:{kind:"not-set"}};try{const t=function(e){var t,n,i;const s=e,r={};for(const e of s.records){let t;switch(e.kind){case"struct":t=new nA({},e=>Object.freeze(Object.assign({},e)),()=>({}));break;case"enum":t=new rA(e=>{if(e instanceof iA)return Object.freeze({kind:"UNKNOWN"});if("string"==typeof e)return Object.freeze({kind:e});{const t=e.kind,n=e.value;return Object.freeze({kind:t,value:n})}})}const n={definition:e,serializer:t};r[e.id]=n}function o(e){switch(e.kind){case"array":{const{item:t,key_extractor:n}=e.value;return new YC(o(t),n)}case"optional":return new GC(o(e.value));case"primitive":return DC(e.value);case"record":{const t=e.value;return r[t].serializer}}}const a=[];for(const e of Object.values(r)){const{definition:s,serializer:l}=e,{defaultValue:c}=l,{id:h,removed_numbers:u}=s,d=h.split(":"),f=d[0],p=d[1].split("."),m=p[p.length-1],g=f+":"+p.slice(0,-1).join("."),b=null===(t=r[g])||void 0===t?void 0:t.serializer,y=null!==(n=s.doc)&&void 0!==n?n:"";switch(s.kind){case"struct":{const e=[];for(const t of s.fields){const n=o(t.type);e.push(new KC(t.name,t.name,t.number,n,null!==(i=t.doc)&&void 0!==i?i:"")),c[t.name]=n.defaultValue}const t=l;a.push(()=>t.init(m,f,b,y,e,null!=u?u:[]));break}case"enum":{const e=l,t=[zC].concat(s.variants).map(e=>{var t,n;return e.type?new sA(e.name,e.number,o(e.type),null!==(t=e.doc)&&void 0!==t?t:"",l.createFn):{name:e.name,number:e.number,constant:Object.freeze({kind:e.name}),doc:null!==(n=e.doc)&&void 0!==n?n:""}});a.push(()=>e.init(m,f,b,y,t,null!=u?u:[]));break}}}return a.forEach(e=>e()),o(s.type).typeDescriptor}(JSON.parse(e));return{text:e,typeDescriptor:{kind:"ok",value:t}}}catch(t){return{text:e,typeDescriptor:{kind:"error",error:String(t)}}}}function x_(e,t){const{typeDescriptor:n}=t;if("not-set"===n.kind)return{kind:"schema-not-set"};if("error"===n.kind)return{kind:"schema-error",error:n.error};if("not-set"===e.parsed.kind)return{kind:"value-not-set"};if("parse-error"===e.parsed.kind)return{kind:"value-parse-error",error:e.parsed.error};let i,s,r;try{i=n.value.transform(e.parsed.value,"dense"),s=n.value.transform(e.parsed.value,"readable"),r="json"===e.parsed.kind?n.value.transform(e.parsed.value,"bytes"):e.parsed.value}catch(e){return{kind:"schema-value-match-error",error:String(e)}}return{kind:"ok",readableJsonEditorState:b_({json:s,schema:n.value.asJson(),readOnly:!0,theme:v_}),denseJsonEditorState:nn.create({doc:JSON.stringify(i),extensions:[$p,y_,mh()]}),base16EditorState:nn.create({doc:Array.from(new Uint8Array(r)).map(e=>e.toString(16).padStart(2,"0")).join(""),extensions:[$p,y_]}),base64EditorState:nn.create({doc:btoa(String.fromCharCode(...new Uint8Array(r))),extensions:[$p,y_]})}}var S_=function(e,t,n,i){var s,r=arguments.length,o=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,i);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(o=(r<3?s(o):r>3?s(t,n,o):s(t,n))||o);return r>3&&o&&Object.defineProperty(t,n,o),o};let C_=class extends Vm{constructor(){super(...arguments),this.initialState=nn.create({}),this.fillHeight=!1,this.editor={kind:"state",value:null}}render(){return Tm`<div id="container"></div>`}firstUpdated(){const e=this.renderRoot.querySelector("#container");this.editor={kind:"view",value:new Uo({state:this.state,dispatchTransactions:(e,t)=>{t.update(e),e.some(e=>e.docChanged)&&this.dispatchEvent(new CustomEvent("text-modified"))},parent:e})}}get state(){return"state"===this.editor.kind?this.editor.value??this.initialState:this.editor.value.state}set state(e){"state"===this.editor.kind?this.editor={kind:"state",value:e}:this.editor.value.setState(e)}get view(){if("view"===this.editor.kind)return this.editor.value;throw new Error("Editor view not yet initialized")}};C_.styles=Up`
|
|
45
45
|
:host {
|
|
46
46
|
display: block;
|
|
47
47
|
min-height: 0;
|
|
@@ -78,7 +78,7 @@ function Gm(e,t){return(t,n,i)=>((e,t,n)=>(n.configurable=!0,n.enumerable=!0,Ref
|
|
|
78
78
|
#container .cm-content {
|
|
79
79
|
min-height: 100%;
|
|
80
80
|
}
|
|
81
|
-
`,
|
|
81
|
+
`,S_([Zm({type:Object})],C_.prototype,"initialState",void 0),S_([Zm({type:Boolean,reflect:!0,attribute:"fill-height"})],C_.prototype,"fillHeight",void 0),C_=S_([qm("skir-code-mirror")],C_);class A_{constructor(e){this.modules=e,this.seenRecords=new Set,this.recordDefinitions=[]}run(e){return{type:this.getRecordSignature(e.key),records:this.recordDefinitions}}getRecordSignature(e){const{modulePath:t,record:n,recordAncestors:i}=this.modules.recordMap.get(e),s=i.map(e=>e.name.text).join("."),r=`${t}:${s}`;return this.seenRecords.has(n.key)||(this.seenRecords.add(n.key),this.addRecordDefinition(r,n)),{kind:"record",value:r}}getTypeSignature(e){switch(e.kind){case"record":return this.getRecordSignature(e.key);case"array":return{kind:"array",value:{item:this.getTypeSignature(e.item),key_extractor:e.key?e.key.path.map(e=>e.name.text).join("."):void 0}};case"optional":return{kind:"optional",value:this.getTypeSignature(e.other)};case"primitive":return{kind:"primitive",value:e.primitive}}}addRecordDefinition(e,t){let n;n="struct"===t.recordType?{kind:"struct",id:e,doc:t.doc.text,fields:t.fields.map(e=>({name:e.name.text,type:this.getTypeSignature(e.type),number:e.number,doc:e.doc.text})),removed_numbers:t.removedNumbers}:{kind:"enum",id:e,doc:t.doc.text,variants:t.fields.map(e=>({name:e.name.text,type:e.type?this.getTypeSignature(e.type):void 0,number:e.number,doc:e.doc.text})),removed_numbers:t.removedNumbers},this.recordDefinitions.push(n)}}var T_=function(e,t,n,i){var s,r=arguments.length,o=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,i);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(o=(r<3?s(o):r>3?s(t,n,o):s(t,n))||o);return r>3&&o&&Object.defineProperty(t,n,o),o};return e.App=class extends Vm{constructor(){super(...arguments),this.resultTab="readable-json",this.copied=!1,this.schemaOverlayDismissed=!1,this.valueOverlayDismissed=!1,this.schemaInputMode="paste-json",this.githubUrl="",this.githubToken="",this.valueTextWasModified=!1,this.schemaTextWasModified=!1,this.appState=function(){const e=k_(""),t=w_("");return{input:e,schema:t,result:x_(e,t)}}(),this.githubState={kind:"initial"}}render(){const e="fetching"===this.githubState.kind,t="success"===this.githubState.kind?{kind:"success",message:"Fetched schema from GitHub."}:"error"===this.githubState.kind?{kind:"error",message:this.githubState.error}:void 0;return Tm`
|
|
82
82
|
<main class="app-shell">
|
|
83
83
|
<header class="headline">
|
|
84
84
|
<div class="brand-lockup">
|
|
@@ -226,7 +226,7 @@ function Gm(e,t){return(t,n,i)=>((e,t,n)=>(n.configurable=!0,n.enumerable=!0,Ref
|
|
|
226
226
|
<skir-code-mirror
|
|
227
227
|
id="input-value"
|
|
228
228
|
fill-height
|
|
229
|
-
.initialState=${nn.create({extensions:[
|
|
229
|
+
.initialState=${nn.create({extensions:[$p,y_,mh()]})}
|
|
230
230
|
@text-modified=${()=>this.onValueTextModified()}
|
|
231
231
|
></skir-code-mirror>
|
|
232
232
|
</div>
|
|
@@ -298,7 +298,7 @@ function Gm(e,t){return(t,n,i)=>((e,t,n)=>(n.configurable=!0,n.enumerable=!0,Ref
|
|
|
298
298
|
>
|
|
299
299
|
${e}
|
|
300
300
|
</button>
|
|
301
|
-
`}getResultEditorState(e,t){return"dense-json"===e?t.denseJsonEditorState:"readable-json"===e?t.readableJsonEditorState:"base16"===e?t.base16EditorState:t.base64EditorState}getResultText(e){return this.getResultEditorState(this.resultTab,e).doc.toString()}updateState(){const e=this.appState;let t,n;this.valueTextWasModified?(t=this.inputValueElement.state.doc.toString(),this.valueTextWasModified=!1):t=e.input.text,this.schemaTextWasModified?(n=this.inputSchemaElement.state.doc.toString(),this.schemaTextWasModified=!1):n=e.schema.text;const i=function(e,t,n){const i=e===n.input.text?n.input:
|
|
301
|
+
`}getResultEditorState(e,t){return"dense-json"===e?t.denseJsonEditorState:"readable-json"===e?t.readableJsonEditorState:"base16"===e?t.base16EditorState:t.base64EditorState}getResultText(e){return this.getResultEditorState(this.resultTab,e).doc.toString()}updateState(){const e=this.appState;let t,n;this.valueTextWasModified?(t=this.inputValueElement.state.doc.toString(),this.valueTextWasModified=!1):t=e.input.text,this.schemaTextWasModified?(n=this.inputSchemaElement.state.doc.toString(),this.schemaTextWasModified=!1):n=e.schema.text;const i=function(e,t,n){const i=e===n.input.text?n.input:k_(e),s=t===n.schema.text?n.schema:w_(t);return i===n.input&&s===n.schema?n:{input:i,schema:s,result:x_(i,s)}}(t,n,e);this.appState=i,this.updateComplete.then(()=>{this.syncResultEditors(i)})}syncResultEditors(e){"ok"===e.result.kind&&(this.resultReadableJsonElement&&(this.resultReadableJsonElement.state=e.result.readableJsonEditorState),this.resultDenseJsonElement&&(this.resultDenseJsonElement.state=e.result.denseJsonEditorState),this.resultBase16Element&&(this.resultBase16Element.state=e.result.base16EditorState),this.resultBase64Element&&(this.resultBase64Element.state=e.result.base64EditorState))}onValueTextModified(){this.valueTextWasModified=!0,this.scheduleStateUpdate()}onSchemaTextModified(){this.schemaTextWasModified=!0,this.scheduleStateUpdate()}async onGithubFetch(){this.githubState={kind:"fetching"};const e=this.githubUrlElement.value,t=this.githubTokenElement.value,n=e=>{const t={kind:"error",error:e};this.githubState=t,window.setTimeout(()=>{this.githubState===t&&(this.githubState={kind:"initial"})},4e3)};try{const i=await OC(e,t);if("success"===i.kind){const e=JSON.stringify(function(e,t){return new A_(t).run(e)}(i.record,i.moduleSet),void 0," ");this.inputSchemaElement.state=this.makeInputSchemaEditorState(e),this.schemaOverlayDismissed=!0,this.schemaTextWasModified=!0,this.updateState();const t={kind:"success"};this.githubState=t,window.setTimeout(()=>{this.githubState===t&&(this.githubState={kind:"initial"})},2e3)}else n(i.message)}catch(e){e instanceof Error?n(e.message):n(String(e))}}scheduleStateUpdate(){void 0!==this.stateUpdateTimeoutHandle&&clearTimeout(this.stateUpdateTimeoutHandle),this.stateUpdateTimeoutHandle=setTimeout(()=>{this.stateUpdateTimeoutHandle=void 0,this.updateState()},100)}dismissOverlay(e){if("schema"===e)return this.schemaOverlayDismissed=!0,void requestAnimationFrame(()=>{this.inputSchemaElement?.view.focus()});this.valueOverlayDismissed=!0,requestAnimationFrame(()=>{this.inputValueElement?.view.focus()})}makeInputSchemaEditorState(e){return nn.create({extensions:[$p,y_,mh()],doc:e})}},e.App.styles=Up`
|
|
302
302
|
@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600;700&family=Press+Start+2P&display=swap");
|
|
303
303
|
|
|
304
304
|
:host {
|
|
@@ -895,5 +895,5 @@ function Gm(e,t){return(t,n,i)=>((e,t,n)=>(n.configurable=!0,n.enumerable=!0,Ref
|
|
|
895
895
|
justify-content: space-between;
|
|
896
896
|
}
|
|
897
897
|
}
|
|
898
|
-
`,
|
|
898
|
+
`,T_([Ym()],e.App.prototype,"resultTab",void 0),T_([Ym()],e.App.prototype,"copied",void 0),T_([Ym()],e.App.prototype,"schemaOverlayDismissed",void 0),T_([Ym()],e.App.prototype,"valueOverlayDismissed",void 0),T_([Ym()],e.App.prototype,"schemaInputMode",void 0),T_([Ym()],e.App.prototype,"githubUrl",void 0),T_([Ym()],e.App.prototype,"githubToken",void 0),T_([Gm("#input-value")],e.App.prototype,"inputValueElement",void 0),T_([Gm("#schema-json")],e.App.prototype,"inputSchemaElement",void 0),T_([Gm("#github-url")],e.App.prototype,"githubUrlElement",void 0),T_([Gm("#github-token")],e.App.prototype,"githubTokenElement",void 0),T_([Gm("#result-readable-json")],e.App.prototype,"resultReadableJsonElement",void 0),T_([Gm("#result-dense-json")],e.App.prototype,"resultDenseJsonElement",void 0),T_([Gm("#result-base16")],e.App.prototype,"resultBase16Element",void 0),T_([Gm("#result-base64")],e.App.prototype,"resultBase64Element",void 0),T_([Ym()],e.App.prototype,"appState",void 0),T_([Ym()],e.App.prototype,"githubState",void 0),e.App=T_([qm("skir-converter-app")],e.App),customElements.get("skir-converter-app")||customElements.define("skir-converter-app",e.App),e}({});
|
|
899
899
|
//# sourceMappingURL=skir-converter-standalone.js.map
|