studiograph 1.3.8 → 1.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/tools/sync-tools.js +4 -7
- package/dist/agent/tools/sync-tools.js.map +1 -1
- package/dist/cli/commands/sync-collection.js +3 -14
- package/dist/cli/commands/sync-collection.js.map +1 -1
- package/dist/server/index.js +4 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/routes/sync-api.js +14 -20
- package/dist/server/routes/sync-api.js.map +1 -1
- package/dist/services/sync/collection-sync.d.ts +22 -35
- package/dist/services/sync/collection-sync.js +123 -357
- package/dist/services/sync/collection-sync.js.map +1 -1
- package/dist/services/sync/structured-extractor.d.ts +2 -0
- package/dist/services/sync/structured-extractor.js +1 -1
- package/dist/services/sync/structured-extractor.js.map +1 -1
- package/dist/services/sync/types.d.ts +10 -5
- package/dist/web/_app/immutable/chunks/{DCGmlzGM.js → AWihU6Ne.js} +1 -1
- package/dist/web/_app/immutable/chunks/B1Cz8BMn.js +1 -0
- package/dist/web/_app/immutable/chunks/BqzGUHtY.js +27 -0
- package/dist/web/_app/immutable/chunks/{BXuvR8Ks.js → C7VoTosa.js} +1 -1
- package/dist/web/_app/immutable/chunks/{BBLgaWN8.js → CTRxNfZk.js} +1 -1
- package/dist/web/_app/immutable/chunks/CWQRQXxy.js +1 -0
- package/dist/web/_app/immutable/chunks/{Cs5oz2oJ.js → CX_61fY8.js} +1 -1
- package/dist/web/_app/immutable/chunks/{BxXlKFyx.js → CfTe44NH.js} +1 -1
- package/dist/web/_app/immutable/chunks/{0oxpWEgM.js → CrdV0ttd.js} +1 -1
- package/dist/web/_app/immutable/chunks/{B1y7Wy5O.js → CscoF-YL.js} +1 -1
- package/dist/web/_app/immutable/chunks/{D2aTbzFm.js → D7ZqAKi9.js} +1 -1
- package/dist/web/_app/immutable/chunks/{hnbuI7Nz.js → D9er1L5a.js} +1 -1
- package/dist/web/_app/immutable/chunks/DKQjBKyp.js +1 -0
- package/dist/web/_app/immutable/chunks/{DEzvDbcy.js → Dkz6p8Jo.js} +1 -1
- package/dist/web/_app/immutable/chunks/{BVBRzmeQ.js → DnL9f0lc.js} +2 -2
- package/dist/web/_app/immutable/chunks/{BCB5cYCz.js → i9c_RUF6.js} +2 -2
- package/dist/web/_app/immutable/entry/{app.DJBDJcSh.js → app.mJ5Araew.js} +2 -2
- package/dist/web/_app/immutable/entry/start.DF_0_BfK.js +1 -0
- package/dist/web/_app/immutable/nodes/{0.CAcmB7D0.js → 0.BvuYB1gx.js} +3 -3
- package/dist/web/_app/immutable/nodes/{1.CTI57h4T.js → 1.DJ_l-bGr.js} +1 -1
- package/dist/web/_app/immutable/nodes/{2.DLksu1-5.js → 2.BGwKASX5.js} +1 -1
- package/dist/web/_app/immutable/nodes/3.xRAvlc2o.js +11 -0
- package/dist/web/_app/immutable/nodes/{4.b6iwPmuI.js → 4.B0ynwCv_.js} +1 -1
- package/dist/web/_app/immutable/nodes/{5.BHhKeE_h.js → 5.BfU_Rt3A.js} +1 -1
- package/dist/web/_app/immutable/nodes/{6.B3IKA9tf.js → 6.9tzx4cb2.js} +1 -1
- package/dist/web/_app/immutable/nodes/7.DExKUmUV.js +2 -0
- package/dist/web/_app/immutable/nodes/{8.rJtfXi9L.js → 8.BfIZOncu.js} +1 -1
- package/dist/web/_app/version.json +1 -1
- package/dist/web/index.html +6 -6
- package/package.json +1 -1
- package/dist/web/_app/immutable/chunks/BPUy9_sS.js +0 -1
- package/dist/web/_app/immutable/chunks/Bt3IOBgW.js +0 -27
- package/dist/web/_app/immutable/chunks/C_8lGlxx.js +0 -1
- package/dist/web/_app/immutable/entry/start.3Q9lJ-bM.js +0 -1
- package/dist/web/_app/immutable/nodes/3.B5xlkeVI.js +0 -11
- package/dist/web/_app/immutable/nodes/7.Eq6DAyo_.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const ct=1024;let Je=0;class H{constructor(e,t){this.from=e,this.to=t}}class A{constructor(e={}){this.id=Je++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=L.match(e)),t=>{let r=e(t);return r===void 0?null:[this,r]}}}A.closedBy=new A({deserialize:l=>l.split(" ")});A.openedBy=new A({deserialize:l=>l.split(" ")});A.group=new A({deserialize:l=>l.split(" ")});A.isolate=new A({deserialize:l=>{if(l&&l!="rtl"&&l!="ltr"&&l!="auto")throw new RangeError("Invalid value for isolate: "+l);return l||"auto"}});A.contextHash=new A({perNode:!0});A.lookAhead=new A({perNode:!0});A.mounted=new A({perNode:!0});class re{constructor(e,t,r,i=!1){this.tree=e,this.overlay=t,this.parser=r,this.bracketed=i}static get(e){return e&&e.props&&e.props[A.mounted.id]}}const Ke=Object.create(null);class L{constructor(e,t,r,i=0){this.name=e,this.props=t,this.id=r,this.flags=i}static define(e){let t=e.props&&e.props.length?Object.create(null):Ke,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),i=new L(e.name||"",t,e.id,r);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(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(A.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let r in e)for(let i of r.split(" "))t[i]=e[r];return r=>{for(let i=r.prop(A.group),n=-1;n<(i?i.length:0);n++){let s=t[n<0?r.name:i[n]];if(s)return s}}}}L.none=new L("",Object.create(null),0,8);class je{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 r of this.types){let i=null;for(let n of e){let s=n(r);if(s){i||(i=Object.assign({},r.props));let o=s[1],a=s[0];a.combine&&a.id in i&&(o=a.combine(i[a.id],o)),i[a.id]=o}}t.push(i?new L(r.name,i,r.id,r.flags):r)}return new je(t)}}const he=new WeakMap,Ne=new WeakMap;var v;(function(l){l[l.ExcludeBuffers=1]="ExcludeBuffers",l[l.IncludeAnonymous=2]="IncludeAnonymous",l[l.IgnoreMounts=4]="IgnoreMounts",l[l.IgnoreOverlays=8]="IgnoreOverlays",l[l.EnterBracketed=16]="EnterBracketed"})(v||(v={}));class R{constructor(e,t,r,i,n){if(this.type=e,this.children=t,this.positions=r,this.length=i,this.props=null,n&&n.length){this.props=Object.create(null);for(let[s,o]of n)this.props[typeof s=="number"?s:s.id]=o}}toString(){let e=re.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let r of this.children){let i=r.toString();i&&(t&&(t+=","),t+=i)}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 ge(this.topNode,e)}cursorAt(e,t=0,r=0){let i=he.get(this)||this.topNode,n=new ge(i);return n.moveTo(e,t),he.set(this,n._tree),n}get topNode(){return new T(this,0,0,null)}resolve(e,t=0){let r=se(he.get(this)||this.topNode,e,t,!1);return he.set(this,r),r}resolveInner(e,t=0){let r=se(Ne.get(this)||this.topNode,e,t,!0);return Ne.set(this,r),r}resolveStack(e,t=0){return Ge(this,e,t)}iterate(e){let{enter:t,leave:r,from:i=0,to:n=this.length}=e,s=e.mode||0,o=(s&v.IncludeAnonymous)>0;for(let a=this.cursor(s|v.IncludeAnonymous);;){let h=!1;if(a.from<=n&&a.to>=i&&(!o&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;h=!0}for(;h&&r&&(o||!a.type.isAnonymous)&&r(a),!a.nextSibling();){if(!a.parent())return;h=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Ae(L.none,this.children,this.positions,0,this.children.length,0,this.length,(t,r,i)=>new R(this.type,t,r,i,this.propValues),e.makeTree||((t,r,i)=>new R(L.none,t,r,i)))}static build(e){return Qe(e)}}R.empty=new R(L.none,[],[],0);class ke{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 ke(this.buffer,this.index)}}class X{constructor(e,t,r){this.buffer=e,this.length=t,this.set=r}get type(){return L.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],r=this.buffer[e+3],i=this.set.types[t],n=i.name;if(/\W/.test(n)&&!i.isError&&(n=JSON.stringify(n)),e+=4,r==e)return n;let s=[];for(;e<r;)s.push(this.childString(e)),e=this.buffer[e+3];return n+"("+s.join(",")+")"}findChild(e,t,r,i,n){let{buffer:s}=this,o=-1;for(let a=e;a!=t&&!(Fe(n,i,s[a+1],s[a+2])&&(o=a,r>0));a=s[a+3]);return o}slice(e,t,r){let i=this.buffer,n=new Uint16Array(t-e),s=0;for(let o=e,a=0;o<t;){n[a++]=i[o++],n[a++]=i[o++]-r;let h=n[a++]=i[o++]-r;n[a++]=i[o++]-e,s=Math.max(s,h)}return new X(n,s,this.set)}}function Fe(l,e,t,r){switch(l){case-2:return t<e;case-1:return r>=e&&t<e;case 0:return t<e&&r>e;case 1:return t<=e&&r>e;case 2:return r>e;case 4:return!0}}function se(l,e,t,r){for(var i;l.from==l.to||(t<1?l.from>=e:l.from>e)||(t>-1?l.to<=e:l.to<e);){let s=!r&&l instanceof T&&l.index<0?null:l.parent;if(!s)return l;l=s}let n=r?0:v.IgnoreOverlays;if(r)for(let s=l,o=s.parent;o;s=o,o=s.parent)s instanceof T&&s.index<0&&((i=o.enter(e,t,n))===null||i===void 0?void 0:i.from)!=s.from&&(l=o);for(;;){let s=l.enter(e,t,n);if(!s)return l;l=s}}class De{cursor(e=0){return new ge(this,e)}getChild(e,t=null,r=null){let i=_e(this,e,t,r);return i.length?i[0]:null}getChildren(e,t=null,r=null){return _e(this,e,t,r)}resolve(e,t=0){return se(this,e,t,!1)}resolveInner(e,t=0){return se(this,e,t,!0)}matchContext(e){return be(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),r=this;for(;t;){let i=t.lastChild;if(!i||i.to!=t.to)break;i.type.isError&&i.from==i.to?(r=t,t=i.prevSibling):t=i}return r}get node(){return this}get next(){return this.parent}}class T extends De{constructor(e,t,r,i){super(),this._tree=e,this.from=t,this.index=r,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,r,i,n=0){for(let s=this;;){for(let{children:o,positions:a}=s._tree,h=t>0?o.length:-1;e!=h;e+=t){let u=o[e],p=a[e]+s.from,c;if(!(!(n&v.EnterBracketed&&u instanceof R&&(c=re.get(u))&&!c.overlay&&c.bracketed&&r>=p&&r<=p+u.length)&&!Fe(i,r,p,p+u.length))){if(u instanceof X){if(n&v.ExcludeBuffers)continue;let m=u.findChild(0,u.buffer.length,t,r-p,i);if(m>-1)return new K(new Ve(s,u,e,p),null,m)}else if(n&v.IncludeAnonymous||!u.type.isAnonymous||ve(u)){let m;if(!(n&v.IgnoreMounts)&&(m=re.get(u))&&!m.overlay)return new T(m.tree,p,e,s);let w=new T(u,p,e,s);return n&v.IncludeAnonymous||!w.type.isAnonymous?w:w.nextChild(t<0?u.children.length-1:0,t,r,i,n)}}}if(n&v.IncludeAnonymous||!s.type.isAnonymous||(s.index>=0?e=s.index+t:e=t<0?-1:s._parent._tree.children.length,s=s._parent,!s))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,r=0){let i;if(!(r&v.IgnoreOverlays)&&(i=re.get(this._tree))&&i.overlay){let n=e-this.from,s=r&v.EnterBracketed&&i.bracketed;for(let{from:o,to:a}of i.overlay)if((t>0||s?o<=n:o<n)&&(t<0||s?a>=n:a>n))return new T(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,r)}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 _e(l,e,t,r){let i=l.cursor(),n=[];if(!i.firstChild())return n;if(t!=null){for(let s=!1;!s;)if(s=i.type.is(t),!i.nextSibling())return n}for(;;){if(r!=null&&i.type.is(r))return n;if(i.type.is(e)&&n.push(i.node),!i.nextSibling())return r==null?n:[]}}function be(l,e,t=e.length-1){for(let r=l;t>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[t]&&e[t]!=r.name)return!1;t--}}return!0}class Ve{constructor(e,t,r,i){this.parent=e,this.buffer=t,this.index=r,this.start=i}}class K extends De{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,r){super(),this.context=e,this._parent=t,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,t,r){let{buffer:i}=this.context,n=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.context.start,r);return n<0?null:new K(this.context,this,n)}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,r=0){if(r&v.ExcludeBuffers)return null;let{buffer:i}=this.context,n=i.findChild(this.index+4,i.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return n<0?null:new K(this.context,this,n)}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 K(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 K(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:r}=this.context,i=this.index+4,n=r.buffer[this.index+3];if(n>i){let s=r.buffer[this.index+1];e.push(r.slice(i,n,s)),t.push(0)}return new R(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function He(l){if(!l.length)return null;let e=0,t=l[0];for(let n=1;n<l.length;n++){let s=l[n];(s.from>t.from||s.to<t.to)&&(t=s,e=n)}let r=t instanceof T&&t.index<0?null:t.parent,i=l.slice();return r?i[e]=r:i.splice(e,1),new $e(i,t)}class $e{constructor(e,t){this.heads=e,this.node=t}get next(){return He(this.heads)}}function Ge(l,e,t){let r=l.resolveInner(e,t),i=null;for(let n=r instanceof T?r:r.context.parent;n;n=n.parent)if(n.index<0){let s=n.parent;(i||(i=[r])).push(s.resolve(e,t)),n=s}else{let s=re.get(n.tree);if(s&&s.overlay&&s.overlay[0].from<=e&&s.overlay[s.overlay.length-1].to>=e){let o=new T(s.tree,s.overlay[0].from+n.from,-1,n);(i||(i=[r])).push(se(o,e,t,!1))}}return i?He(i):r}class ge{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&~v.EnterBracketed,e instanceof T)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:r,buffer:i}=this.buffer;return this.type=t||i.set.types[i.buffer[e]],this.from=r+i.buffer[e+1],this.to=r+i.buffer[e+2],!0}yield(e){return e?e instanceof T?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,r,this.mode));let{buffer:i}=this.buffer,n=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.buffer.start,r);return n<0?!1:(this.stack.push(this.index),this.yieldBuf(n))}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,r=this.mode){return this.buffer?r&v.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&v.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&v.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,r=this.stack.length-1;if(e<0){let i=r<0?0:this.stack[r]+4;if(this.index!=i)return this.yieldBuf(t.findChild(i,this.index,-1,0,4))}else{let i=t.buffer[this.index+3];if(i<(r<0?t.buffer.length:t.buffer[this.stack[r]+3]))return this.yieldBuf(i)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,r,{buffer:i}=this;if(i){if(e>0){if(this.index<i.buffer.buffer.length)return!1}else for(let n=0;n<this.index;n++)if(i.buffer.buffer[n+3]<this.index)return!1;({index:t,parent:r}=i)}else({index:t,_parent:r}=this._tree);for(;r;{index:t,_parent:r}=r)if(t>-1)for(let n=t+e,s=e<0?-1:r._tree.children.length;n!=s;n+=e){let o=r._tree.children[n];if(this.mode&v.IncludeAnonymous||o instanceof X||!o.type.isAnonymous||ve(o))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,r=0;if(e&&e.context==this.buffer)e:for(let i=this.index,n=this.stack.length;n>=0;){for(let s=e;s;s=s._parent)if(s.index==i){if(i==this.index)return s;t=s,r=n+1;break e}i=this.stack[--n]}for(let i=r;i<this.stack.length;i++)t=new K(this.buffer,t,this.stack[i]);return this.bufferNode=new K(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let r=0;;){let i=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){r++;continue}this.type.isAnonymous||(i=!0)}for(;;){if(i&&t&&t(this),i=this.type.isAnonymous,!r)return;if(this.nextSibling())break;this.parent(),r--,i=!0}}}matchContext(e){if(!this.buffer)return be(this.node.parent,e);let{buffer:t}=this.buffer,{types:r}=t.set;for(let i=e.length-1,n=this.stack.length-1;i>=0;n--){if(n<0)return be(this._tree,e,i);let s=r[t.buffer[this.stack[n]]];if(!s.isAnonymous){if(e[i]&&e[i]!=s.name)return!1;i--}}return!0}}function ve(l){return l.children.some(e=>e instanceof X||!e.type.isAnonymous||ve(e))}function Qe(l){var e;let{buffer:t,nodeSet:r,maxBufferLength:i=1024,reused:n=[],minRepeatType:s=r.types.length}=l,o=Array.isArray(t)?new ke(t,t.length):t,a=r.types,h=0,u=0;function p(x,N,d,B,k,I){let{id:b,start:g,end:S,size:_}=o,O=u,$=h;if(_<0)if(o.next(),_==-1){let V=n[b];d.push(V),B.push(g-x);return}else if(_==-3){h=b;return}else if(_==-4){u=b;return}else throw new RangeError(`Unrecognized record size: ${_}`);let ie=a[b],ae,Y,Ce=g-x;if(S-g<=i&&(Y=M(o.pos-N,k))){let V=new Uint16Array(Y.size-Y.skip),D=o.pos-Y.size,W=V.length;for(;o.pos>D;)W=E(Y.start,V,W);ae=new X(V,S-Y.start,r),Ce=Y.start-x}else{let V=o.pos-_;o.next();let D=[],W=[],Z=b>=s?b:-1,te=0,fe=S;for(;o.pos>V;)Z>=0&&o.id==Z&&o.size>=0?(o.end<=fe-i&&(w(D,W,g,te,o.end,fe,Z,O,$),te=D.length,fe=o.end),o.next()):I>2500?c(g,V,D,W):p(g,V,D,W,Z,I+1);if(Z>=0&&te>0&&te<D.length&&w(D,W,g,te,g,fe,Z,O,$),D.reverse(),W.reverse(),Z>-1&&te>0){let Se=m(ie,$);ae=Ae(ie,D,W,0,D.length,0,S-g,Se,Se)}else ae=P(ie,D,W,S-g,O-S,$)}d.push(ae),B.push(Ce)}function c(x,N,d,B){let k=[],I=0,b=-1;for(;o.pos>N;){let{id:g,start:S,end:_,size:O}=o;if(O>4)o.next();else{if(b>-1&&S<b)break;b<0&&(b=_-i),k.push(g,S,_),I++,o.next()}}if(I){let g=new Uint16Array(I*4),S=k[k.length-2];for(let _=k.length-3,O=0;_>=0;_-=3)g[O++]=k[_],g[O++]=k[_+1]-S,g[O++]=k[_+2]-S,g[O++]=O;d.push(new X(g,k[2]-S,r)),B.push(S-x)}}function m(x,N){return(d,B,k)=>{let I=0,b=d.length-1,g,S;if(b>=0&&(g=d[b])instanceof R){if(!b&&g.type==x&&g.length==k)return g;(S=g.prop(A.lookAhead))&&(I=B[b]+g.length+S)}return P(x,d,B,k,I,N)}}function w(x,N,d,B,k,I,b,g,S){let _=[],O=[];for(;x.length>B;)_.push(x.pop()),O.push(N.pop()+d-k);x.push(P(r.types[b],_,O,I-k,g-I,S)),N.push(k-d)}function P(x,N,d,B,k,I,b){if(I){let g=[A.contextHash,I];b=b?[g].concat(b):[g]}if(k>25){let g=[A.lookAhead,k];b=b?[g].concat(b):[g]}return new R(x,N,d,B,b)}function M(x,N){let d=o.fork(),B=0,k=0,I=0,b=d.end-i,g={size:0,start:0,skip:0};e:for(let S=d.pos-x;d.pos>S;){let _=d.size;if(d.id==N&&_>=0){g.size=B,g.start=k,g.skip=I,I+=4,B+=4,d.next();continue}let O=d.pos-_;if(_<0||O<S||d.start<b)break;let $=d.id>=s?4:0,ie=d.start;for(d.next();d.pos>O;){if(d.size<0)if(d.size==-3||d.size==-4)$+=4;else break e;else d.id>=s&&($+=4);d.next()}k=ie,B+=_,I+=$}return(N<0||B==x)&&(g.size=B,g.start=k,g.skip=I),g.size>4?g:void 0}function E(x,N,d){let{id:B,start:k,end:I,size:b}=o;if(o.next(),b>=0&&B<s){let g=d;if(b>4){let S=o.pos-(b-4);for(;o.pos>S;)d=E(x,N,d)}N[--d]=g,N[--d]=I-x,N[--d]=k-x,N[--d]=B}else b==-3?h=B:b==-4&&(u=B);return d}let z=[],C=[];for(;o.pos>0;)p(l.start||0,l.bufferStart||0,z,C,-1,0);let F=(e=l.length)!==null&&e!==void 0?e:z.length?C[0]+z[0].length:0;return new R(a[l.topID],z.reverse(),C.reverse(),F)}const Be=new WeakMap;function de(l,e){if(!l.isAnonymous||e instanceof X||e.type!=l)return 1;let t=Be.get(e);if(t==null){t=1;for(let r of e.children){if(r.type!=l||!(r instanceof R)){t=1;break}t+=de(l,r)}Be.set(e,t)}return t}function Ae(l,e,t,r,i,n,s,o,a){let h=0;for(let w=r;w<i;w++)h+=de(l,e[w]);let u=Math.ceil(h*1.5/8),p=[],c=[];function m(w,P,M,E,z){for(let C=M;C<E;){let F=C,x=P[C],N=de(l,w[C]);for(C++;C<E;C++){let d=de(l,w[C]);if(N+d>=u)break;N+=d}if(C==F+1){if(N>u){let d=w[F];m(d.children,d.positions,0,d.children.length,P[F]+z);continue}p.push(w[F])}else{let d=P[C-1]+w[C-1].length-x;p.push(Ae(l,w,P,F,C,x,d,null,a))}c.push(x+z-n)}}return m(e,t,r,i,0),(o||a)(p,c,s)}class dt{constructor(){this.map=new WeakMap}setBuffer(e,t,r){let i=this.map.get(e);i||this.map.set(e,i=new Map),i.set(t,r)}getBuffer(e,t){let r=this.map.get(e);return r&&r.get(t)}set(e,t){e instanceof K?this.setBuffer(e.context.buffer,e.index,t):e instanceof T&&this.map.set(e.tree,t)}get(e){return e instanceof K?this.getBuffer(e.context.buffer,e.index):e instanceof T?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class le{constructor(e,t,r,i,n=!1,s=!1){this.from=e,this.to=t,this.tree=r,this.offset=i,this.open=(n?1:0)|(s?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],r=!1){let i=[new le(0,e.length,e,0,!1,r)];for(let n of t)n.to>e.length&&i.push(n);return i}static applyChanges(e,t,r=128){if(!t.length)return e;let i=[],n=1,s=e.length?e[0]:null;for(let o=0,a=0,h=0;;o++){let u=o<t.length?t[o]:null,p=u?u.fromA:1e9;if(p-a>=r)for(;s&&s.from<p;){let c=s;if(a>=c.from||p<=c.to||h){let m=Math.max(c.from,a)-h,w=Math.min(c.to,p)-h;c=m>=w?null:new le(m,w,c.tree,c.offset+h,o>0,!!u)}if(c&&i.push(c),s.to>p)break;s=n<e.length?e[n++]:null}if(!u)break;a=u.toA,h=u.toA-u.toB}return i}}class gt{startParse(e,t,r){return typeof e=="string"&&(e=new Xe(e)),r=r?r.length?r.map(i=>new H(i.from,i.to)):[new H(0,0)]:[new H(0,e.length)],this.createParse(e,t||[],r)}parse(e,t,r){let i=this.startParse(e,t,r);for(;;){let n=i.advance();if(n)return n}}}class Xe{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}function mt(l){return(e,t,r,i)=>new Ze(e,l,t,r,i)}class Ie{constructor(e,t,r,i,n,s){this.parser=e,this.parse=t,this.overlay=r,this.bracketed=i,this.target=n,this.from=s}}function Pe(l){if(!l.length||l.some(e=>e.from>=e.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(l))}class Ye{constructor(e,t,r,i,n,s,o,a){this.parser=e,this.predicate=t,this.mounts=r,this.index=i,this.start=n,this.bracketed=s,this.target=o,this.prev=a,this.depth=0,this.ranges=[]}}const xe=new A({perNode:!0});class Ze{constructor(e,t,r,i,n){this.nest=t,this.input=r,this.fragments=i,this.ranges=n,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let r=this.baseParse.advance();if(!r)return null;if(this.baseParse=null,this.baseTree=r,this.startInner(),this.stoppedAt!=null)for(let i of this.inner)i.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let r=this.baseTree;return this.stoppedAt!=null&&(r=new R(r.type,r.children,r.positions,r.length,r.propValues.concat([[xe,this.stoppedAt]]))),r}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let r=Object.assign(Object.create(null),e.target.props);r[A.mounted.id]=new re(t,e.overlay,e.parser,e.bracketed),e.target.props=r}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].from<e&&(e=Math.min(e,this.inner[t].parse.parsedPos));return e}stopAt(e){if(this.stoppedAt=e,this.baseParse)this.baseParse.stopAt(e);else for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].parse.stopAt(e)}startInner(){let e=new rt(this.fragments),t=null,r=null,i=new ge(new T(this.baseTree,this.ranges[0].from,0,null),v.IncludeAnonymous|v.IgnoreMounts);e:for(let n,s;;){let o=!0,a;if(this.stoppedAt!=null&&i.from>=this.stoppedAt)o=!1;else if(e.hasNode(i)){if(t){let h=t.mounts.find(u=>u.frag.from<=i.from&&u.frag.to>=i.to&&u.mount.overlay);if(h)for(let u of h.mount.overlay){let p=u.from+h.pos,c=u.to+h.pos;p>=i.from&&c<=i.to&&!t.ranges.some(m=>m.from<c&&m.to>p)&&t.ranges.push({from:p,to:c})}}o=!1}else if(r&&(s=et(r.ranges,i.from,i.to)))o=s!=2;else if(!i.type.isAnonymous&&(n=this.nest(i,this.input))&&(i.from<i.to||!n.overlay)){i.tree||(tt(i),t&&t.depth++,r&&r.depth++);let h=e.findMounts(i.from,n.parser);if(typeof n.overlay=="function")t=new Ye(n.parser,n.overlay,h,this.inner.length,i.from,!!n.bracketed,i.tree,t);else{let u=Ee(this.ranges,n.overlay||(i.from<i.to?[new H(i.from,i.to)]:[]));u.length&&Pe(u),(u.length||!n.overlay)&&this.inner.push(new Ie(n.parser,u.length?n.parser.startParse(this.input,Oe(h,u),u):n.parser.startParse(""),n.overlay?n.overlay.map(p=>new H(p.from-i.from,p.to-i.from)):null,!!n.bracketed,i.tree,u.length?u[0].from:i.from)),n.overlay?u.length&&(r={ranges:u,depth:0,prev:r}):o=!1}}else if(t&&(a=t.predicate(i))&&(a===!0&&(a=new H(i.from,i.to)),a.from<a.to)){let h=t.ranges.length-1;h>=0&&t.ranges[h].to==a.from?t.ranges[h]={from:t.ranges[h].from,to:a.to}:t.ranges.push(a)}if(o&&i.firstChild())t&&t.depth++,r&&r.depth++;else for(;!i.nextSibling();){if(!i.parent())break e;if(t&&!--t.depth){let h=Ee(this.ranges,t.ranges);h.length&&(Pe(h),this.inner.splice(t.index,0,new Ie(t.parser,t.parser.startParse(this.input,Oe(t.mounts,h),h),t.ranges.map(u=>new H(u.from-t.start,u.to-t.start)),t.bracketed,t.target,h[0].from))),t=t.prev}r&&!--r.depth&&(r=r.prev)}}}}function et(l,e,t){for(let r of l){if(r.from>=t)break;if(r.to>e)return r.from<=e&&r.to>=t?2:1}return 0}function Me(l,e,t,r,i,n){if(e<t){let s=l.buffer[e+1];r.push(l.slice(e,t,s)),i.push(s-n)}}function tt(l){let{node:e}=l,t=[],r=e.context.buffer;do t.push(l.index),l.parent();while(!l.tree);let i=l.tree,n=i.children.indexOf(r),s=i.children[n],o=s.buffer,a=[n];function h(u,p,c,m,w,P){let M=t[P],E=[],z=[];Me(s,u,M,E,z,m);let C=o[M+1],F=o[M+2];a.push(E.length);let x=P?h(M+4,o[M+3],s.set.types[o[M]],C,F-C,P-1):e.toTree();return E.push(x),z.push(C-m),Me(s,o[M+3],p,E,z,m),new R(c,E,z,w)}i.children[n]=h(0,o.length,L.none,0,s.length,t.length-1);for(let u of a){let p=l.tree.children[u],c=l.tree.positions[u];l.yield(new T(p,c+l.from,u,l._tree))}}class ze{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(v.IncludeAnonymous|v.IgnoreMounts)}moveTo(e){let{cursor:t}=this,r=e-this.offset;for(;!this.done&&t.from<r;)t.to>=e&&t.enter(r,1,v.IgnoreOverlays|v.ExcludeBuffers)||t.next(!1)||(this.done=!0)}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return!0;if(t.children.length&&t.positions[0]==0&&t.children[0]instanceof R)t=t.children[0];else break}return!1}}class rt{constructor(e){var t;if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let r=this.curFrag=e[0];this.curTo=(t=r.tree.prop(xe))!==null&&t!==void 0?t:r.to,this.inner=new ze(r.tree,-r.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){var e;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let t=this.curFrag=this.fragments[this.fragI];this.curTo=(e=t.tree.prop(xe))!==null&&e!==void 0?e:t.to,this.inner=new ze(t.tree,-t.offset)}}findMounts(e,t){var r;let i=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let n=this.inner.cursor.node;n;n=n.parent){let s=(r=n.tree)===null||r===void 0?void 0:r.prop(A.mounted);if(s&&s.parser==t)for(let o=this.fragI;o<this.fragments.length;o++){let a=this.fragments[o];if(a.from>=n.to)break;a.tree==this.curFrag.tree&&i.push({frag:a,pos:n.from-a.offset,mount:s})}}}return i}}function Ee(l,e){let t=null,r=e;for(let i=1,n=0;i<l.length;i++){let s=l[i-1].to,o=l[i].from;for(;n<r.length;n++){let a=r[n];if(a.from>=o)break;a.to<=s||(t||(r=t=e.slice()),a.from<s?(t[n]=new H(a.from,s),a.to>o&&t.splice(n+1,0,new H(o,a.to))):a.to>o?t[n--]=new H(o,a.to):t.splice(n--,1))}}return r}function it(l,e,t,r){let i=0,n=0,s=!1,o=!1,a=-1e9,h=[];for(;;){let u=i==l.length?1e9:s?l[i].to:l[i].from,p=n==e.length?1e9:o?e[n].to:e[n].from;if(s!=o){let c=Math.max(a,t),m=Math.min(u,p,r);c<m&&h.push(new H(c,m))}if(a=Math.min(u,p),a==1e9)break;u==a&&(s?(s=!1,i++):s=!0),p==a&&(o?(o=!1,n++):o=!0)}return h}function Oe(l,e){let t=[];for(let{pos:r,mount:i,frag:n}of l){let s=r+(i.overlay?i.overlay[0].from:0),o=s+i.tree.length,a=Math.max(n.from,s),h=Math.min(n.to,o);if(i.overlay){let u=i.overlay.map(c=>new H(c.from+r,c.to+r)),p=it(e,u,a,h);for(let c=0,m=a;;c++){let w=c==p.length,P=w?h:p[c].from;if(P>m&&t.push(new le(m,P,i.tree,-s,n.from>=m||n.openStart,n.to<=P||n.openEnd)),w)break;m=p[c].to}}else t.push(new le(a,h,i.tree,-s,n.from>=s||n.openStart,n.to<=o||n.openEnd))}return t}let nt=0;class j{constructor(e,t,r,i){this.name=e,this.set=t,this.base=r,this.modified=i,this.id=nt++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let r=typeof e=="string"?e:"?";if(e instanceof j&&(t=e),t?.base)throw new Error("Can not derive from a modified tag");let i=new j(r,[],null,[]);if(i.set.push(i),t)for(let n of t.set)i.set.push(n);return i}static defineModifier(e){let t=new me(e);return r=>r.modified.indexOf(t)>-1?r:me.get(r.base||r,r.modified.concat(t).sort((i,n)=>i.id-n.id))}}let st=0;class me{constructor(e){this.name=e,this.instances=[],this.id=st++}static get(e,t){if(!t.length)return e;let r=t[0].instances.find(o=>o.base==e&<(t,o.modified));if(r)return r;let i=[],n=new j(e.name,i,e,t);for(let o of t)o.instances.push(n);let s=ot(t);for(let o of e.set)if(!o.modified.length)for(let a of s)i.push(me.get(o,a));return n}}function lt(l,e){return l.length==e.length&&l.every((t,r)=>t==e[r])}function ot(l){let e=[[]];for(let t=0;t<l.length;t++)for(let r=0,i=e.length;r<i;r++)e.push(e[r].concat(l[t]));return e.sort((t,r)=>r.length-t.length)}function at(l){let e=Object.create(null);for(let t in l){let r=l[t];Array.isArray(r)||(r=[r]);for(let i of t.split(" "))if(i){let n=[],s=2,o=i;for(let p=0;;){if(o=="..."&&p>0&&p+3==i.length){s=1;break}let c=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(o);if(!c)throw new RangeError("Invalid path: "+i);if(n.push(c[0]=="*"?"":c[0][0]=='"'?JSON.parse(c[0]):c[0]),p+=c[0].length,p==i.length)break;let m=i[p++];if(p==i.length&&m=="!"){s=0;break}if(m!="/")throw new RangeError("Invalid path: "+i);o=i.slice(p)}let a=n.length-1,h=n[a];if(!h)throw new RangeError("Invalid path: "+i);let u=new oe(r,s,a>0?n.slice(0,a):null);e[h]=u.sort(e[h])}}return Le.add(e)}const Le=new A({combine(l,e){let t,r,i;for(;l||e;){if(!l||e&&l.depth>=e.depth?(i=e,e=e.next):(i=l,l=l.next),t&&t.mode==i.mode&&!i.context&&!t.context)continue;let n=new oe(i.tags,i.mode,i.context);t?t.next=n:r=n,t=n}return r}});class oe{constructor(e,t,r,i){this.tags=e,this.mode=t,this.context=r,this.next=i}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}oe.empty=new oe([],2,null);function We(l,e){let t=Object.create(null);for(let n of l)if(!Array.isArray(n.tag))t[n.tag.id]=n.class;else for(let s of n.tag)t[s.id]=n.class;let{scope:r,all:i=null}=e||{};return{style:n=>{let s=i;for(let o of n)for(let a of o.set){let h=t[a.id];if(h){s=s?s+" "+h:h;break}}return s},scope:r}}function ft(l,e){let t=null;for(let r of l){let i=r.style(e);i&&(t=t?t+" "+i:i)}return t}function Ue(l,e,t,r=0,i=l.length){let n=new ut(r,Array.isArray(e)?e:[e],t);n.highlightRange(l.cursor(),r,i,"",n.highlighters),n.flush(i)}function ht(l,e,t,r,i,n=0,s=l.length){let o=n;function a(h,u){if(!(h<=o)){for(let p=l.slice(o,h),c=0;;){let m=p.indexOf(`
|
|
2
|
-
`,c),w=m<0?p.length:m;if(w>c&&r(p.slice(c,w),u),m<0)break;i(),c=m+1}o=h}}Ue(e,t,(h,u,p)=>{a(h,""),a(u,p)},n,s),a(s,"")}class ut{constructor(e,t,r){this.at=e,this.highlighters=t,this.span=r,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,r,i,n){let{type:s,from:o,to:a}=e;if(o>=r||a<=t)return;s.isTop&&(n=this.highlighters.filter(m=>!m.scope||m.scope(s)));let h=i,u=qe(e)||oe.empty,p=ft(n,u.tags);if(p&&(h&&(h+=" "),h+=p,u.mode==1&&(i+=(i?" ":"")+p)),this.startSpan(Math.max(t,o),h),u.opaque)return;let c=e.tree&&e.tree.prop(A.mounted);if(c&&c.overlay){let m=e.node.enter(c.overlay[0].from+o,1),w=this.highlighters.filter(M=>!M.scope||M.scope(c.tree.type)),P=e.firstChild();for(let M=0,E=o;;M++){let z=M<c.overlay.length?c.overlay[M]:null,C=z?z.from+o:a,F=Math.max(t,E),x=Math.min(r,C);if(F<x&&P)for(;e.from<x&&(this.highlightRange(e,F,x,i,n),this.startSpan(Math.min(x,e.to),h),!(e.to>=C||!e.nextSibling())););if(!z||C>r)break;E=z.to+o,E>t&&(this.highlightRange(m.cursor(),Math.max(t,z.from+o),Math.min(r,E),"",w),this.startSpan(Math.min(r,E),h))}P&&e.parent()}else if(e.firstChild()){c&&(i="");do if(!(e.to<=t)){if(e.from>=r)break;this.highlightRange(e,t,r,i,n),this.startSpan(Math.min(r,e.to),h)}while(e.nextSibling());e.parent()}}}function qe(l){let e=l.type.prop(Le);for(;e&&e.context&&!l.matchContext(e.context);)e=e.next;return e||null}const f=j.define,ue=f(),G=f(),Te=f(G),Re=f(G),Q=f(),pe=f(Q),ye=f(Q),J=f(),ee=f(J),U=f(),q=f(),we=f(),ne=f(we),ce=f(),y={comment:ue,lineComment:f(ue),blockComment:f(ue),docComment:f(ue),name:G,variableName:f(G),typeName:Te,tagName:f(Te),propertyName:Re,attributeName:f(Re),className:f(G),labelName:f(G),namespace:f(G),macroName:f(G),literal:Q,string:pe,docString:f(pe),character:f(pe),attributeValue:f(pe),number:ye,integer:f(ye),float:f(ye),bool:f(Q),regexp:f(Q),escape:f(Q),color:f(Q),url:f(Q),keyword:U,self:f(U),null:f(U),atom:f(U),unit:f(U),modifier:f(U),operatorKeyword:f(U),controlKeyword:f(U),definitionKeyword:f(U),moduleKeyword:f(U),operator:q,derefOperator:f(q),arithmeticOperator:f(q),logicOperator:f(q),bitwiseOperator:f(q),compareOperator:f(q),updateOperator:f(q),definitionOperator:f(q),typeOperator:f(q),controlOperator:f(q),punctuation:we,separator:f(we),bracket:ne,angleBracket:f(ne),squareBracket:f(ne),paren:f(ne),brace:f(ne),content:J,heading:ee,heading1:f(ee),heading2:f(ee),heading3:f(ee),heading4:f(ee),heading5:f(ee),heading6:f(ee),contentSeparator:f(J),list:f(J),quote:f(J),emphasis:f(J),strong:f(J),link:f(J),monospace:f(J),strikethrough:f(J),inserted:f(),deleted:f(),changed:f(),invalid:f(),meta:ce,documentMeta:f(ce),annotation:f(ce),processingInstruction:f(ce),definition:j.defineModifier("definition"),constant:j.defineModifier("constant"),function:j.defineModifier("function"),standard:j.defineModifier("standard"),local:j.defineModifier("local"),special:j.defineModifier("special")};for(let l in y){let e=y[l];e instanceof j&&(e.name=l)}const pt=We([{tag:y.link,class:"tok-link"},{tag:y.heading,class:"tok-heading"},{tag:y.emphasis,class:"tok-emphasis"},{tag:y.strong,class:"tok-strong"},{tag:y.keyword,class:"tok-keyword"},{tag:y.atom,class:"tok-atom"},{tag:y.bool,class:"tok-bool"},{tag:y.url,class:"tok-url"},{tag:y.labelName,class:"tok-labelName"},{tag:y.inserted,class:"tok-inserted"},{tag:y.deleted,class:"tok-deleted"},{tag:y.literal,class:"tok-literal"},{tag:y.string,class:"tok-string"},{tag:y.number,class:"tok-number"},{tag:[y.regexp,y.escape,y.special(y.string)],class:"tok-string2"},{tag:y.variableName,class:"tok-variableName"},{tag:y.local(y.variableName),class:"tok-variableName tok-local"},{tag:y.definition(y.variableName),class:"tok-variableName tok-definition"},{tag:y.special(y.variableName),class:"tok-variableName2"},{tag:y.definition(y.propertyName),class:"tok-propertyName tok-definition"},{tag:y.typeName,class:"tok-typeName"},{tag:y.namespace,class:"tok-namespace"},{tag:y.className,class:"tok-className"},{tag:y.macroName,class:"tok-macroName"},{tag:y.propertyName,class:"tok-propertyName"},{tag:y.operator,class:"tok-operator"},{tag:y.comment,class:"tok-comment"},{tag:y.meta,class:"tok-meta"},{tag:y.invalid,class:"tok-invalid"},{tag:y.punctuation,class:"tok-punctuation"}]),yt=Object.freeze(Object.defineProperty({__proto__:null,Tag:j,classHighlighter:pt,getStyleTags:qe,highlightCode:ht,highlightTree:Ue,styleTags:at,tagHighlighter:We,tags:y},Symbol.toStringTag,{value:"Module"}));export{ct as D,v as I,
|
|
2
|
+
`,c),w=m<0?p.length:m;if(w>c&&r(p.slice(c,w),u),m<0)break;i(),c=m+1}o=h}}Ue(e,t,(h,u,p)=>{a(h,""),a(u,p)},n,s),a(s,"")}class ut{constructor(e,t,r){this.at=e,this.highlighters=t,this.span=r,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,r,i,n){let{type:s,from:o,to:a}=e;if(o>=r||a<=t)return;s.isTop&&(n=this.highlighters.filter(m=>!m.scope||m.scope(s)));let h=i,u=qe(e)||oe.empty,p=ft(n,u.tags);if(p&&(h&&(h+=" "),h+=p,u.mode==1&&(i+=(i?" ":"")+p)),this.startSpan(Math.max(t,o),h),u.opaque)return;let c=e.tree&&e.tree.prop(A.mounted);if(c&&c.overlay){let m=e.node.enter(c.overlay[0].from+o,1),w=this.highlighters.filter(M=>!M.scope||M.scope(c.tree.type)),P=e.firstChild();for(let M=0,E=o;;M++){let z=M<c.overlay.length?c.overlay[M]:null,C=z?z.from+o:a,F=Math.max(t,E),x=Math.min(r,C);if(F<x&&P)for(;e.from<x&&(this.highlightRange(e,F,x,i,n),this.startSpan(Math.min(x,e.to),h),!(e.to>=C||!e.nextSibling())););if(!z||C>r)break;E=z.to+o,E>t&&(this.highlightRange(m.cursor(),Math.max(t,z.from+o),Math.min(r,E),"",w),this.startSpan(Math.min(r,E),h))}P&&e.parent()}else if(e.firstChild()){c&&(i="");do if(!(e.to<=t)){if(e.from>=r)break;this.highlightRange(e,t,r,i,n),this.startSpan(Math.min(r,e.to),h)}while(e.nextSibling());e.parent()}}}function qe(l){let e=l.type.prop(Le);for(;e&&e.context&&!l.matchContext(e.context);)e=e.next;return e||null}const f=j.define,ue=f(),G=f(),Te=f(G),Re=f(G),Q=f(),pe=f(Q),ye=f(Q),J=f(),ee=f(J),U=f(),q=f(),we=f(),ne=f(we),ce=f(),y={comment:ue,lineComment:f(ue),blockComment:f(ue),docComment:f(ue),name:G,variableName:f(G),typeName:Te,tagName:f(Te),propertyName:Re,attributeName:f(Re),className:f(G),labelName:f(G),namespace:f(G),macroName:f(G),literal:Q,string:pe,docString:f(pe),character:f(pe),attributeValue:f(pe),number:ye,integer:f(ye),float:f(ye),bool:f(Q),regexp:f(Q),escape:f(Q),color:f(Q),url:f(Q),keyword:U,self:f(U),null:f(U),atom:f(U),unit:f(U),modifier:f(U),operatorKeyword:f(U),controlKeyword:f(U),definitionKeyword:f(U),moduleKeyword:f(U),operator:q,derefOperator:f(q),arithmeticOperator:f(q),logicOperator:f(q),bitwiseOperator:f(q),compareOperator:f(q),updateOperator:f(q),definitionOperator:f(q),typeOperator:f(q),controlOperator:f(q),punctuation:we,separator:f(we),bracket:ne,angleBracket:f(ne),squareBracket:f(ne),paren:f(ne),brace:f(ne),content:J,heading:ee,heading1:f(ee),heading2:f(ee),heading3:f(ee),heading4:f(ee),heading5:f(ee),heading6:f(ee),contentSeparator:f(J),list:f(J),quote:f(J),emphasis:f(J),strong:f(J),link:f(J),monospace:f(J),strikethrough:f(J),inserted:f(),deleted:f(),changed:f(),invalid:f(),meta:ce,documentMeta:f(ce),annotation:f(ce),processingInstruction:f(ce),definition:j.defineModifier("definition"),constant:j.defineModifier("constant"),function:j.defineModifier("function"),standard:j.defineModifier("standard"),local:j.defineModifier("local"),special:j.defineModifier("special")};for(let l in y){let e=y[l];e instanceof j&&(e.name=l)}const pt=We([{tag:y.link,class:"tok-link"},{tag:y.heading,class:"tok-heading"},{tag:y.emphasis,class:"tok-emphasis"},{tag:y.strong,class:"tok-strong"},{tag:y.keyword,class:"tok-keyword"},{tag:y.atom,class:"tok-atom"},{tag:y.bool,class:"tok-bool"},{tag:y.url,class:"tok-url"},{tag:y.labelName,class:"tok-labelName"},{tag:y.inserted,class:"tok-inserted"},{tag:y.deleted,class:"tok-deleted"},{tag:y.literal,class:"tok-literal"},{tag:y.string,class:"tok-string"},{tag:y.number,class:"tok-number"},{tag:[y.regexp,y.escape,y.special(y.string)],class:"tok-string2"},{tag:y.variableName,class:"tok-variableName"},{tag:y.local(y.variableName),class:"tok-variableName tok-local"},{tag:y.definition(y.variableName),class:"tok-variableName tok-definition"},{tag:y.special(y.variableName),class:"tok-variableName2"},{tag:y.definition(y.propertyName),class:"tok-propertyName tok-definition"},{tag:y.typeName,class:"tok-typeName"},{tag:y.namespace,class:"tok-namespace"},{tag:y.className,class:"tok-className"},{tag:y.macroName,class:"tok-macroName"},{tag:y.propertyName,class:"tok-propertyName"},{tag:y.operator,class:"tok-operator"},{tag:y.comment,class:"tok-comment"},{tag:y.meta,class:"tok-meta"},{tag:y.invalid,class:"tok-invalid"},{tag:y.punctuation,class:"tok-punctuation"}]),yt=Object.freeze(Object.defineProperty({__proto__:null,Tag:j,classHighlighter:pt,getStyleTags:qe,highlightCode:ht,highlightTree:Ue,styleTags:at,tagHighlighter:We,tags:y},Symbol.toStringTag,{value:"Module"}));export{ct as D,v as I,A as N,gt as P,R as T,je as a,L as b,le as c,y as d,j as e,dt as f,Ue as h,yt as i,mt as p,at as s,We as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{L as r}from"./
|
|
1
|
+
import{L as r}from"./CrdV0ttd.js";import{s as P,d as O}from"./C7VoTosa.js";import{LanguageSupport as a,LRLanguage as Q,indentNodeProp as o,continuedIndent as e,foldNodeProp as t,foldInside as s}from"./D7ZqAKi9.js";const n=P({String:O.string,Number:O.number,"True False":O.bool,PropertyName:O.propertyName,Null:O.null,", :":O.separator,"[ ]":O.squareBracket,"{ }":O.brace}),i=r.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:[n],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}),c=Q.define({name:"json",parser:i.configure({props:[o.add({Object:e({except:/^\s*\}/}),Array:e({except:/^\s*\]/})}),t.add({"Object Array":s})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function d(){return new a(c)}export{d as json,c as jsonLanguage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{StateField as ze,Transaction as P,Facet as oe,combineConfig as He,EditorSelection as h,StateEffect as le,ChangeSet as qe,ChangeDesc as Ke,Annotation as ce,countColumn as $,Text as se,findClusterBreak as E}from"./CX_61fY8.js";import{E as x,D as $e}from"./DnL9f0lc.js";import{IndentContext as ie,getIndentation as ue,indentString as v,syntaxTree as W,matchBrackets as D,getIndentUnit as G,indentUnit as We}from"./D7ZqAKi9.js";import{N as F}from"./C7VoTosa.js";const Qe=e=>{let{state:t}=e,r=t.doc.lineAt(t.selection.main.from),n=X(e.state,r.from);return n.line?Xe(e):n.block?Ze(e):!1};function Q(e,t){return({state:r,dispatch:n})=>{if(r.readOnly)return!1;let l=e(t,r);return l?(n(r.update(l)),!0):!1}}const Xe=Q(we,0),Ye=Q(fe,0),Ze=Q((e,t)=>fe(e,t,_e(t)),0);function X(e,t){let r=e.languageDataAt("commentTokens",t,1);return r.length?r[0]:{}}const M=50;function je(e,{open:t,close:r},n,l){let o=e.sliceDoc(n-M,n),c=e.sliceDoc(l,l+M),s=/\s*$/.exec(o)[0].length,i=/^\s*/.exec(c)[0].length,f=o.length-s;if(o.slice(f-t.length,f)==t&&c.slice(i,i+r.length)==r)return{open:{pos:n-s,margin:s&&1},close:{pos:l+i,margin:i&&1}};let u,a;l-n<=2*M?u=a=e.sliceDoc(n,l):(u=e.sliceDoc(n,n+M),a=e.sliceDoc(l-M,l));let p=/^\s*/.exec(u)[0].length,T=/\s*$/.exec(a)[0].length,L=a.length-T-r.length;return u.slice(p,p+t.length)==t&&a.slice(L,L+r.length)==r?{open:{pos:n+p+t.length,margin:/\s/.test(u.charAt(p+t.length))?1:0},close:{pos:l-T-r.length,margin:/\s/.test(a.charAt(L-1))?1:0}}:null}function _e(e){let t=[];for(let r of e.selection.ranges){let n=e.doc.lineAt(r.from),l=r.to<=n.to?n:e.doc.lineAt(r.to);l.from>n.from&&l.from==r.to&&(l=r.to==n.to+1?n:e.doc.lineAt(r.to-1));let o=t.length-1;o>=0&&t[o].to>n.from?t[o].to=l.to:t.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:l.to})}return t}function fe(e,t,r=t.selection.ranges){let n=r.map(o=>X(t,o.from).block);if(!n.every(o=>o))return null;let l=r.map((o,c)=>je(t,n[c],o.from,o.to));if(e!=2&&!l.every(o=>o))return{changes:t.changes(r.map((o,c)=>l[c]?[]:[{from:o.from,insert:n[c].open+" "},{from:o.to,insert:" "+n[c].close}]))};if(e!=1&&l.some(o=>o)){let o=[];for(let c=0,s;c<l.length;c++)if(s=l[c]){let i=n[c],{open:f,close:u}=s;o.push({from:f.pos-i.open.length,to:f.pos+f.margin},{from:u.pos-u.margin,to:u.pos+i.close.length})}return{changes:o}}return null}function we(e,t,r=t.selection.ranges){let n=[],l=-1;e:for(let{from:o,to:c}of r){let s=n.length,i=1e9,f;for(let u=o;u<=c;){let a=t.doc.lineAt(u);if(f==null&&(f=X(t,a.from).line,!f))continue e;if(a.from>l&&(o==c||c>a.from)){l=a.from;let p=/^\s*/.exec(a.text)[0].length,T=p==a.length,L=a.text.slice(p,p+f.length)==f?p:-1;p<a.text.length&&p<i&&(i=p),n.push({line:a,comment:L,token:f,indent:p,empty:T,single:!1})}u=a.to+1}if(i<1e9)for(let u=s;u<n.length;u++)n[u].indent<n[u].line.text.length&&(n[u].indent=i);n.length==s+1&&(n[s].single=!0)}if(e!=2&&n.some(o=>o.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:s,token:i,indent:f,empty:u,single:a}of n)(a||!u)&&o.push({from:s.from+f,insert:i+" "});let c=t.changes(o);return{changes:c,selection:t.selection.map(c,1)}}else if(e!=1&&n.some(o=>o.comment>=0)){let o=[];for(let{line:c,comment:s,token:i}of n)if(s>=0){let f=c.from+s,u=f+i.length;c.text[u-c.from]==" "&&u++,o.push({from:f,to:u})}return{changes:o}}return null}const z=ce.define(),et=ce.define(),tt=oe.define(),ae=oe.define({combine(e){return He(e,{minDepth:100,newGroupDelay:500,joinToEvent:(t,r)=>r},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,r)=>(n,l)=>t(n,l)||r(n,l)})}}),he=ze.define({create(){return B.empty},update(e,t){let r=t.state.facet(ae),n=t.annotation(z);if(n){let i=m.fromTransaction(t,n.selection),f=n.side,u=f==0?e.undone:e.done;return i?u=R(u,u.length,r.minDepth,i):u=pe(u,t.startState.selection),new B(f==0?n.rest:u,f==0?u:n.rest)}let l=t.annotation(et);if((l=="full"||l=="before")&&(e=e.isolate()),t.annotation(P.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let o=m.fromTransaction(t),c=t.annotation(P.time),s=t.annotation(P.userEvent);return o?e=e.addChanges(o,c,s,r,t):t.selection&&(e=e.addSelection(t.startState.selection,c,s,r.newGroupDelay)),(l=="full"||l=="after")&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(t=>t.toJSON()),undone:e.undone.map(t=>t.toJSON())}},fromJSON(e){return new B(e.done.map(m.fromJSON),e.undone.map(m.fromJSON))}});function un(e={}){return[he,ae.of(e),x.domEventHandlers({beforeinput(t,r){let n=t.inputType=="historyUndo"?de:t.inputType=="historyRedo"?H:null;return n?(t.preventDefault(),n(r)):!1}})]}function I(e,t){return function({state:r,dispatch:n}){if(!t&&r.readOnly)return!1;let l=r.field(he,!1);if(!l)return!1;let o=l.pop(e,r,t);return o?(n(o),!0):!1}}const de=I(0,!1),H=I(1,!1),nt=I(0,!0),rt=I(1,!0);class m{constructor(t,r,n,l,o){this.changes=t,this.effects=r,this.mapped=n,this.startSelection=l,this.selectionsAfter=o}setSelAfter(t){return new m(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,r,n;return{changes:(t=this.changes)===null||t===void 0?void 0:t.toJSON(),mapped:(r=this.mapped)===null||r===void 0?void 0:r.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(l=>l.toJSON())}}static fromJSON(t){return new m(t.changes&&qe.fromJSON(t.changes),[],t.mapped&&Ke.fromJSON(t.mapped),t.startSelection&&h.fromJSON(t.startSelection),t.selectionsAfter.map(h.fromJSON))}static fromTransaction(t,r){let n=g;for(let l of t.startState.facet(tt)){let o=l(t);o.length&&(n=n.concat(o))}return!n.length&&t.changes.empty?null:new m(t.changes.invert(t.startState.doc),n,void 0,r||t.startState.selection,g)}static selection(t){return new m(void 0,g,void 0,void 0,t)}}function R(e,t,r,n){let l=t+1>r+20?t-r-1:0,o=e.slice(l,t);return o.push(n),o}function ot(e,t){let r=[],n=!1;return e.iterChangedRanges((l,o)=>r.push(l,o)),t.iterChangedRanges((l,o,c,s)=>{for(let i=0;i<r.length;){let f=r[i++],u=r[i++];s>=f&&c<=u&&(n=!0)}}),n}function lt(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((r,n)=>r.empty!=t.ranges[n].empty).length===0}function me(e,t){return e.length?t.length?e.concat(t):e:t}const g=[],ct=200;function pe(e,t){if(e.length){let r=e[e.length-1],n=r.selectionsAfter.slice(Math.max(0,r.selectionsAfter.length-ct));return n.length&&n[n.length-1].eq(t)?e:(n.push(t),R(e,e.length-1,1e9,r.setSelAfter(n)))}else return[m.selection([t])]}function st(e){let t=e[e.length-1],r=e.slice();return r[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),r}function J(e,t){if(!e.length)return e;let r=e.length,n=g;for(;r;){let l=it(e[r-1],t,n);if(l.changes&&!l.changes.empty||l.effects.length){let o=e.slice(0,r);return o[r-1]=l,o}else t=l.mapped,r--,n=l.selectionsAfter}return n.length?[m.selection(n)]:g}function it(e,t,r){let n=me(e.selectionsAfter.length?e.selectionsAfter.map(s=>s.map(t)):g,r);if(!e.changes)return m.selection(n);let l=e.changes.map(t),o=t.mapDesc(e.changes,!0),c=e.mapped?e.mapped.composeDesc(o):o;return new m(l,le.mapEffects(e.effects,t),c,e.startSelection.map(o),n)}const ut=/^(input\.type|delete)($|\.)/;class B{constructor(t,r,n=0,l=void 0){this.done=t,this.undone=r,this.prevTime=n,this.prevUserEvent=l}isolate(){return this.prevTime?new B(this.done,this.undone):this}addChanges(t,r,n,l,o){let c=this.done,s=c[c.length-1];return s&&s.changes&&!s.changes.empty&&t.changes&&(!n||ut.test(n))&&(!s.selectionsAfter.length&&r-this.prevTime<l.newGroupDelay&&l.joinToEvent(o,ot(s.changes,t.changes))||n=="input.type.compose")?c=R(c,c.length-1,l.minDepth,new m(t.changes.compose(s.changes),me(le.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,g)):c=R(c,c.length,l.minDepth,t),new B(c,g,r,n)}addSelection(t,r,n,l){let o=this.done.length?this.done[this.done.length-1].selectionsAfter:g;return o.length>0&&r-this.prevTime<l&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&<(o[o.length-1],t)?this:new B(pe(this.done,t),this.undone,r,n)}addMapping(t){return new B(J(this.done,t),J(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,r,n){let l=t==0?this.done:this.undone;if(l.length==0)return null;let o=l[l.length-1],c=o.selectionsAfter[0]||(o.startSelection?o.startSelection.map(o.changes.invertedDesc,1):r.selection);if(n&&o.selectionsAfter.length)return r.update({selection:o.selectionsAfter[o.selectionsAfter.length-1],annotations:z.of({side:t,rest:st(l),selection:c}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(o.changes){let s=l.length==1?g:l.slice(0,l.length-1);return o.mapped&&(s=J(s,o.mapped)),r.update({changes:o.changes,selection:o.startSelection,effects:o.effects,annotations:z.of({side:t,rest:s,selection:c}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}}B.empty=new B(g,g);const fn=[{key:"Mod-z",run:de,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:nt,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:rt,preventDefault:!0}];function C(e,t){return h.create(e.ranges.map(t),e.mainIndex)}function k(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function A({state:e,dispatch:t},r){let n=C(e.selection,r);return n.eq(e.selection,!0)?!1:(t(k(e,n)),!0)}function N(e,t){return h.cursor(t?e.to:e.from)}function ge(e,t){return A(e,r=>r.empty?e.moveByChar(r,t):N(r,t))}function d(e){return e.textDirectionAt(e.state.selection.main.head)==$e.LTR}const ye=e=>ge(e,!d(e)),ke=e=>ge(e,d(e));function Ae(e,t){return A(e,r=>r.empty?e.moveByGroup(r,t):N(r,t))}const ft=e=>Ae(e,!d(e)),at=e=>Ae(e,d(e));function ht(e,t,r){if(t.type.prop(r))return!0;let n=t.to-t.from;return n&&(n>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function U(e,t,r){let n=W(e).resolveInner(t.head),l=r?F.closedBy:F.openedBy;for(let i=t.head;;){let f=r?n.childAfter(i):n.childBefore(i);if(!f)break;ht(e,f,l)?n=f:i=r?f.to:f.from}let o=n.type.prop(l),c,s;return o&&(c=r?D(e,n.from,1):D(e,n.to,-1))&&c.matched?s=r?c.end.to:c.end.from:s=r?n.to:n.from,h.cursor(s,r?-1:1)}const dt=e=>A(e,t=>U(e.state,t,!d(e))),mt=e=>A(e,t=>U(e.state,t,d(e)));function Be(e,t){return A(e,r=>{if(!r.empty)return N(r,t);let n=e.moveVertically(r,t);return n.head!=r.head?n:e.moveToLineBoundary(r,t)})}const Se=e=>Be(e,!1),De=e=>Be(e,!0);function xe(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,r=0,n=0,l;if(t){for(let o of e.state.facet(x.scrollMargins)){let c=o(e);c?.top&&(r=Math.max(c?.top,r)),c?.bottom&&(n=Math.max(c?.bottom,n))}l=e.scrollDOM.clientHeight-r-n}else l=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:r,marginBottom:n,selfScroll:t,height:Math.max(e.defaultLineHeight,l-5)}}function Ce(e,t){let r=xe(e),{state:n}=e,l=C(n.selection,c=>c.empty?e.moveVertically(c,t,r.height):N(c,t));if(l.eq(n.selection))return!1;let o;if(r.selfScroll){let c=e.coordsAtPos(n.selection.main.head),s=e.scrollDOM.getBoundingClientRect(),i=s.top+r.marginTop,f=s.bottom-r.marginBottom;c&&c.top>i&&c.bottom<f&&(o=x.scrollIntoView(l.main.head,{y:"start",yMargin:c.top-i}))}return e.dispatch(k(n,l),{effects:o}),!0}const Z=e=>Ce(e,!1),q=e=>Ce(e,!0);function S(e,t,r){let n=e.lineBlockAt(t.head),l=e.moveToLineBoundary(t,r);if(l.head==t.head&&l.head!=(r?n.to:n.from)&&(l=e.moveToLineBoundary(t,r,!1)),!r&&l.head==n.from&&n.length){let o=/^\s*/.exec(e.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;o&&t.head!=n.from+o&&(l=h.cursor(n.from+o))}return l}const pt=e=>A(e,t=>S(e,t,!0)),gt=e=>A(e,t=>S(e,t,!1)),yt=e=>A(e,t=>S(e,t,!d(e))),kt=e=>A(e,t=>S(e,t,d(e))),At=e=>A(e,t=>h.cursor(e.lineBlockAt(t.head).from,1)),Bt=e=>A(e,t=>h.cursor(e.lineBlockAt(t.head).to,-1));function St(e,t,r){let n=!1,l=C(e.selection,o=>{let c=D(e,o.head,-1)||D(e,o.head,1)||o.head>0&&D(e,o.head-1,1)||o.head<e.doc.length&&D(e,o.head+1,-1);if(!c||!c.end)return o;n=!0;let s=c.start.from==o.head?c.end.to:c.end.from;return h.cursor(s)});return n?(t(k(e,l)),!0):!1}const Dt=({state:e,dispatch:t})=>St(e,t);function y(e,t){let r=C(e.state.selection,n=>{let l=t(n);return h.range(n.anchor,l.head,l.goalColumn,l.bidiLevel||void 0,l.assoc)});return r.eq(e.state.selection)?!1:(e.dispatch(k(e.state,r)),!0)}function Le(e,t){return y(e,r=>e.moveByChar(r,t))}const Me=e=>Le(e,!d(e)),Ee=e=>Le(e,d(e));function Oe(e,t){return y(e,r=>e.moveByGroup(r,t))}const xt=e=>Oe(e,!d(e)),Ct=e=>Oe(e,d(e)),Lt=e=>y(e,t=>U(e.state,t,!d(e))),Mt=e=>y(e,t=>U(e.state,t,d(e)));function Te(e,t){return y(e,r=>e.moveVertically(r,t))}const be=e=>Te(e,!1),ve=e=>Te(e,!0);function Re(e,t){return y(e,r=>e.moveVertically(r,t,xe(e).height))}const j=e=>Re(e,!1),_=e=>Re(e,!0),Et=e=>y(e,t=>S(e,t,!0)),Ot=e=>y(e,t=>S(e,t,!1)),Tt=e=>y(e,t=>S(e,t,!d(e))),bt=e=>y(e,t=>S(e,t,d(e))),vt=e=>y(e,t=>h.cursor(e.lineBlockAt(t.head).from)),Rt=e=>y(e,t=>h.cursor(e.lineBlockAt(t.head).to)),w=({state:e,dispatch:t})=>(t(k(e,{anchor:0})),!0),ee=({state:e,dispatch:t})=>(t(k(e,{anchor:e.doc.length})),!0),te=({state:e,dispatch:t})=>(t(k(e,{anchor:e.selection.main.anchor,head:0})),!0),ne=({state:e,dispatch:t})=>(t(k(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),It=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0),Nt=({state:e,dispatch:t})=>{let r=V(e).map(({from:n,to:l})=>h.range(n,Math.min(l+1,e.doc.length)));return t(e.update({selection:h.create(r),userEvent:"select"})),!0},Ut=({state:e,dispatch:t})=>{let r=C(e.selection,n=>{let l=W(e),o=l.resolveStack(n.from,1);if(n.empty){let c=l.resolveStack(n.from,-1);c.node.from>=o.node.from&&c.node.to<=o.node.to&&(o=c)}for(let c=o;c;c=c.next){let{node:s}=c;if((s.from<n.from&&s.to>=n.to||s.to>n.to&&s.from<=n.from)&&c.next)return h.range(s.to,s.from)}return n});return r.eq(e.selection)?!1:(t(k(e,r)),!0)};function Ie(e,t){let{state:r}=e,n=r.selection,l=r.selection.ranges.slice();for(let o of r.selection.ranges){let c=r.doc.lineAt(o.head);if(t?c.to<e.state.doc.length:c.from>0)for(let s=o;;){let i=e.moveVertically(s,t);if(i.head<c.from||i.head>c.to){l.some(f=>f.head==i.head)||l.push(i);break}else{if(i.head==s.head)break;s=i}}}return l.length==n.ranges.length?!1:(e.dispatch(k(r,h.create(l,l.length-1))),!0)}const Vt=e=>Ie(e,!1),Pt=e=>Ie(e,!0),Jt=({state:e,dispatch:t})=>{let r=e.selection,n=null;return r.ranges.length>1?n=h.create([r.main]):r.main.empty||(n=h.create([h.cursor(r.main.head)])),n?(t(k(e,n)),!0):!1};function O(e,t){if(e.state.readOnly)return!1;let r="delete.selection",{state:n}=e,l=n.changeByRange(o=>{let{from:c,to:s}=o;if(c==s){let i=t(o);i<c?(r="delete.backward",i=b(e,i,!1)):i>c&&(r="delete.forward",i=b(e,i,!0)),c=Math.min(c,i),s=Math.max(s,i)}else c=b(e,c,!1),s=b(e,s,!0);return c==s?{range:o}:{changes:{from:c,to:s},range:h.cursor(c,c<o.head?-1:1)}});return l.changes.empty?!1:(e.dispatch(n.update(l,{scrollIntoView:!0,userEvent:r,effects:r=="delete.selection"?x.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function b(e,t,r){if(e instanceof x)for(let n of e.state.facet(x.atomicRanges).map(l=>l(e)))n.between(t,t,(l,o)=>{l<t&&o>t&&(t=r?o:l)});return t}const Ne=(e,t,r)=>O(e,n=>{let l=n.from,{state:o}=e,c=o.doc.lineAt(l),s,i;if(r&&!t&&l>c.from&&l<c.from+200&&!/[^ \t]/.test(s=c.text.slice(0,l-c.from))){if(s[s.length-1]==" ")return l-1;let f=$(s,o.tabSize),u=f%G(o)||G(o);for(let a=0;a<u&&s[s.length-1-a]==" ";a++)l--;i=l}else i=E(c.text,l-c.from,t,t)+c.from,i==l&&c.number!=(t?o.doc.lines:1)?i+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(c.text.slice(i-c.from,l-c.from))&&(i=E(c.text,i-c.from,!1,!1)+c.from);return i}),K=e=>Ne(e,!1,!0),Ue=e=>Ne(e,!0,!1),Ve=(e,t)=>O(e,r=>{let n=r.head,{state:l}=e,o=l.doc.lineAt(n),c=l.charCategorizer(n);for(let s=null;;){if(n==(t?o.to:o.from)){n==r.head&&o.number!=(t?l.doc.lines:1)&&(n+=t?1:-1);break}let i=E(o.text,n-o.from,t)+o.from,f=o.text.slice(Math.min(n,i)-o.from,Math.max(n,i)-o.from),u=c(f);if(s!=null&&u!=s)break;(f!=" "||n!=r.head)&&(s=u),n=i}return n}),Pe=e=>Ve(e,!1),Gt=e=>Ve(e,!0),Ft=e=>O(e,t=>{let r=e.lineBlockAt(t.head).to;return t.head<r?r:Math.min(e.state.doc.length,t.head+1)}),zt=e=>O(e,t=>{let r=e.moveToLineBoundary(t,!1).head;return t.head>r?r:Math.max(0,t.head-1)}),Ht=e=>O(e,t=>{let r=e.moveToLineBoundary(t,!0).head;return t.head<r?r:Math.min(e.state.doc.length,t.head+1)}),qt=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=e.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:se.of(["",""])},range:h.cursor(n.from)}));return t(e.update(r,{scrollIntoView:!0,userEvent:"input"})),!0},Kt=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=e.changeByRange(n=>{if(!n.empty||n.from==0||n.from==e.doc.length)return{range:n};let l=n.from,o=e.doc.lineAt(l),c=l==o.from?l-1:E(o.text,l-o.from,!1)+o.from,s=l==o.to?l+1:E(o.text,l-o.from,!0)+o.from;return{changes:{from:c,to:s,insert:e.doc.slice(l,s).append(e.doc.slice(c,l))},range:h.cursor(s)}});return r.changes.empty?!1:(t(e.update(r,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function V(e){let t=[],r=-1;for(let n of e.selection.ranges){let l=e.doc.lineAt(n.from),o=e.doc.lineAt(n.to);if(!n.empty&&n.to==o.from&&(o=e.doc.lineAt(n.to-1)),r>=l.number){let c=t[t.length-1];c.to=o.to,c.ranges.push(n)}else t.push({from:l.from,to:o.to,ranges:[n]});r=o.number+1}return t}function Je(e,t,r){if(e.readOnly)return!1;let n=[],l=[];for(let o of V(e)){if(r?o.to==e.doc.length:o.from==0)continue;let c=e.doc.lineAt(r?o.to+1:o.from-1),s=c.length+1;if(r){n.push({from:o.to,to:c.to},{from:o.from,insert:c.text+e.lineBreak});for(let i of o.ranges)l.push(h.range(Math.min(e.doc.length,i.anchor+s),Math.min(e.doc.length,i.head+s)))}else{n.push({from:c.from,to:o.from},{from:o.to,insert:e.lineBreak+c.text});for(let i of o.ranges)l.push(h.range(i.anchor-s,i.head-s))}}return n.length?(t(e.update({changes:n,scrollIntoView:!0,selection:h.create(l,e.selection.mainIndex),userEvent:"move.line"})),!0):!1}const $t=({state:e,dispatch:t})=>Je(e,t,!1),Wt=({state:e,dispatch:t})=>Je(e,t,!0);function Ge(e,t,r){if(e.readOnly)return!1;let n=[];for(let o of V(e))r?n.push({from:o.from,insert:e.doc.slice(o.from,o.to)+e.lineBreak}):n.push({from:o.to,insert:e.lineBreak+e.doc.slice(o.from,o.to)});let l=e.changes(n);return t(e.update({changes:l,selection:e.selection.map(l,r?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Qt=({state:e,dispatch:t})=>Ge(e,t,!1),Xt=({state:e,dispatch:t})=>Ge(e,t,!0),Yt=e=>{if(e.state.readOnly)return!1;let{state:t}=e,r=t.changes(V(t).map(({from:l,to:o})=>(l>0?l--:o<t.doc.length&&o++,{from:l,to:o}))),n=C(t.selection,l=>{let o;if(e.lineWrapping){let c=e.lineBlockAt(l.head),s=e.coordsAtPos(l.head,l.assoc||1);s&&(o=c.bottom+e.documentTop-s.bottom+e.defaultLineHeight/2)}return e.moveVertically(l,!0,o)}).map(r);return e.dispatch({changes:r,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Zt(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let r=W(e).resolveInner(t),n=r.childBefore(t),l=r.childAfter(t),o;return n&&l&&n.to<=t&&l.from>=t&&(o=n.type.prop(F.closedBy))&&o.indexOf(l.name)>-1&&e.doc.lineAt(n.to).from==e.doc.lineAt(l.from).from&&!/\S/.test(e.sliceDoc(n.to,l.from))?{from:n.to,to:l.from}:null}const re=Fe(!1),jt=Fe(!0);function Fe(e){return({state:t,dispatch:r})=>{if(t.readOnly)return!1;let n=t.changeByRange(l=>{let{from:o,to:c}=l,s=t.doc.lineAt(o),i=!e&&o==c&&Zt(t,o);e&&(o=c=(c<=s.to?s:t.doc.lineAt(c)).to);let f=new ie(t,{simulateBreak:o,simulateDoubleBreak:!!i}),u=ue(f,o);for(u==null&&(u=$(/^\s*/.exec(t.doc.lineAt(o).text)[0],t.tabSize));c<s.to&&/\s/.test(s.text[c-s.from]);)c++;i?{from:o,to:c}=i:o>s.from&&o<s.from+100&&!/\S/.test(s.text.slice(0,o))&&(o=s.from);let a=["",v(t,u)];return i&&a.push(v(t,f.lineIndent(s.from,-1))),{changes:{from:o,to:c,insert:se.of(a)},range:h.cursor(o+1+a[1].length)}});return r(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function Y(e,t){let r=-1;return e.changeByRange(n=>{let l=[];for(let c=n.from;c<=n.to;){let s=e.doc.lineAt(c);s.number>r&&(n.empty||n.to>s.from)&&(t(s,l,n),r=s.number),c=s.to+1}let o=e.changes(l);return{changes:l,range:h.range(o.mapPos(n.anchor,1),o.mapPos(n.head,1))}})}const _t=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=Object.create(null),n=new ie(e,{overrideIndentation:o=>{let c=r[o];return c??-1}}),l=Y(e,(o,c,s)=>{let i=ue(n,o.from);if(i==null)return;/\S/.test(o.text)||(i=0);let f=/^\s*/.exec(o.text)[0],u=v(e,i);(f!=u||s.from<o.from+f.length)&&(r[o.from]=i,c.push({from:o.from,to:o.from+f.length,insert:u}))});return l.changes.empty||t(e.update(l,{userEvent:"indent"})),!0},wt=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Y(e,(r,n)=>{n.push({from:r.from,insert:e.facet(We)})}),{userEvent:"input.indent"})),!0),en=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Y(e,(r,n)=>{let l=/^\s*/.exec(r.text)[0];if(!l)return;let o=$(l,e.tabSize),c=0,s=v(e,Math.max(0,o-G(e)));for(;c<l.length&&c<s.length&&l.charCodeAt(c)==s.charCodeAt(c);)c++;n.push({from:r.from+c,to:r.from+l.length,insert:s.slice(c)})}),{userEvent:"delete.dedent"})),!0),tn=e=>(e.setTabFocusMode(),!0),nn=[{key:"Ctrl-b",run:ye,shift:Me,preventDefault:!0},{key:"Ctrl-f",run:ke,shift:Ee},{key:"Ctrl-p",run:Se,shift:be},{key:"Ctrl-n",run:De,shift:ve},{key:"Ctrl-a",run:At,shift:vt},{key:"Ctrl-e",run:Bt,shift:Rt},{key:"Ctrl-d",run:Ue},{key:"Ctrl-h",run:K},{key:"Ctrl-k",run:Ft},{key:"Ctrl-Alt-h",run:Pe},{key:"Ctrl-o",run:qt},{key:"Ctrl-t",run:Kt},{key:"Ctrl-v",run:q}],rn=[{key:"ArrowLeft",run:ye,shift:Me,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:ft,shift:xt,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:yt,shift:Tt,preventDefault:!0},{key:"ArrowRight",run:ke,shift:Ee,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:at,shift:Ct,preventDefault:!0},{mac:"Cmd-ArrowRight",run:kt,shift:bt,preventDefault:!0},{key:"ArrowUp",run:Se,shift:be,preventDefault:!0},{mac:"Cmd-ArrowUp",run:w,shift:te},{mac:"Ctrl-ArrowUp",run:Z,shift:j},{key:"ArrowDown",run:De,shift:ve,preventDefault:!0},{mac:"Cmd-ArrowDown",run:ee,shift:ne},{mac:"Ctrl-ArrowDown",run:q,shift:_},{key:"PageUp",run:Z,shift:j},{key:"PageDown",run:q,shift:_},{key:"Home",run:gt,shift:Ot,preventDefault:!0},{key:"Mod-Home",run:w,shift:te},{key:"End",run:pt,shift:Et,preventDefault:!0},{key:"Mod-End",run:ee,shift:ne},{key:"Enter",run:re,shift:re},{key:"Mod-a",run:It},{key:"Backspace",run:K,shift:K,preventDefault:!0},{key:"Delete",run:Ue,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Pe,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:Gt,preventDefault:!0},{mac:"Mod-Backspace",run:zt,preventDefault:!0},{mac:"Mod-Delete",run:Ht,preventDefault:!0}].concat(nn.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),an=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:dt,shift:Lt},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:mt,shift:Mt},{key:"Alt-ArrowUp",run:$t},{key:"Shift-Alt-ArrowUp",run:Qt},{key:"Alt-ArrowDown",run:Wt},{key:"Shift-Alt-ArrowDown",run:Xt},{key:"Mod-Alt-ArrowUp",run:Vt},{key:"Mod-Alt-ArrowDown",run:Pt},{key:"Escape",run:Jt},{key:"Mod-Enter",run:jt},{key:"Alt-l",mac:"Ctrl-l",run:Nt},{key:"Mod-i",run:Ut,preventDefault:!0},{key:"Mod-[",run:en},{key:"Mod-]",run:wt},{key:"Mod-Alt-\\",run:_t},{key:"Shift-Mod-k",run:Yt},{key:"Shift-Mod-\\",run:Dt},{key:"Mod-/",run:Qe},{key:"Alt-A",run:Ye},{key:"Ctrl-m",mac:"Shift-Alt-m",run:tn}].concat(rn);export{Vt as addCursorAbove,Pt as addCursorBelow,Xt as copyLineDown,Qt as copyLineUp,ye as cursorCharLeft,ke as cursorCharRight,ee as cursorDocEnd,w as cursorDocStart,ft as cursorGroupLeft,at as cursorGroupRight,gt as cursorLineBoundaryBackward,pt as cursorLineBoundaryForward,yt as cursorLineBoundaryLeft,kt as cursorLineBoundaryRight,De as cursorLineDown,Bt as cursorLineEnd,At as cursorLineStart,Se as cursorLineUp,Dt as cursorMatchingBracket,q as cursorPageDown,Z as cursorPageUp,dt as cursorSyntaxLeft,mt as cursorSyntaxRight,an as defaultKeymap,K as deleteCharBackward,Ue as deleteCharForward,Pe as deleteGroupBackward,Gt as deleteGroupForward,Yt as deleteLine,zt as deleteLineBoundaryBackward,Ht as deleteLineBoundaryForward,Ft as deleteToLineEnd,nn as emacsStyleKeymap,un as history,fn as historyKeymap,en as indentLess,wt as indentMore,_t as indentSelection,jt as insertBlankLine,re as insertNewlineAndIndent,tt as invertedEffects,et as isolateHistory,Wt as moveLineDown,$t as moveLineUp,H as redo,rt as redoSelection,It as selectAll,Me as selectCharLeft,Ee as selectCharRight,ne as selectDocEnd,te as selectDocStart,xt as selectGroupLeft,Ct as selectGroupRight,Nt as selectLine,Ot as selectLineBoundaryBackward,Et as selectLineBoundaryForward,Tt as selectLineBoundaryLeft,bt as selectLineBoundaryRight,ve as selectLineDown,Rt as selectLineEnd,vt as selectLineStart,be as selectLineUp,_ as selectPageDown,j as selectPageUp,Ut as selectParentSyntax,Lt as selectSyntaxLeft,Mt as selectSyntaxRight,Jt as simplifySelection,qt as splitLine,rn as standardKeymap,Ye as toggleBlockComment,Ze as toggleBlockCommentByLine,Qe as toggleComment,Xe as toggleLineComment,tn as toggleTabFocusMode,Kt as transposeChars,de as undo,nt as undoSelection};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
let re=[],Ee=[];(()=>{let l="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<l.length;e++)(e%2?Ee:re).push(t=t+l[e])})();function Ge(l){if(l<768)return!1;for(let e=0,t=re.length;;){let n=e+t>>1;if(l<re[n])t=n;else if(l>=Ee[n])e=n+1;else return!0;if(e==t)return!1}}function ke(l){return l>=127462&&l<=127487}const ye=8205;function je(l,e,t=!0,n=!0){return(t?Oe:Ze)(l,e,n)}function Oe(l,e,t){if(e==l.length)return e;e&&Me(l.charCodeAt(e))&&Re(l.charCodeAt(e-1))&&e--;let n=ie(l,e);for(e+=Se(n);e<l.length;){let i=ie(l,e);if(n==ye||i==ye||t&&Ge(i))e+=Se(i),n=i;else if(ke(i)){let s=0,r=e-2;for(;r>=0&&ke(ie(l,r));)s++,r-=2;if(s%2==0)break;e+=2}else break}return e}function Ze(l,e,t){for(;e>0;){let n=Oe(l,e-2,t);if(n<e)return n;e--}return 0}function ie(l,e){let t=l.charCodeAt(e);if(!Re(t)||e+1==l.length)return t;let n=l.charCodeAt(e+1);return Me(n)?(t-55296<<10)+(n-56320)+65536:t}function Me(l){return l>=56320&&l<57344}function Re(l){return l>=55296&&l<56320}function Se(l){return l<65536?1:2}class x{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]=J(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),C.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]=J(this,e,t);let n=[];return this.decompose(e,t,n,0),C.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 N(this),s=new N(e);for(let r=t,h=t;;){if(i.next(r),s.next(r),r=0,i.lineBreak!=s.lineBreak||i.done!=s.done||i.value!=s.value)return!1;if(h+=i.value.length,i.done||h>=n)return!0}}iter(e=1){return new N(this,e)}iterRange(e,t=this.length){return new Te(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t==null&&(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 Be(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?x.empty:e.length<=32?new m(e):C.from(m.split(e,[]))}}class m extends x{constructor(e,t=Ke(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],h=i+r.length;if((t?n:h)>=e)return new Qe(i,h,n,r);i=h+1,n++}}decompose(e,t,n,i){let s=e<=0&&t>=this.length?this:new m(Ie(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(i&1){let r=n.pop(),h=Z(s.text,r.text.slice(),0,s.length);if(h.length<=32)n.push(new m(h,r.length+s.length));else{let o=h.length>>1;n.push(new m(h.slice(0,o)),new m(h.slice(o)))}}else n.push(s)}replace(e,t,n){if(!(n instanceof m))return super.replace(e,t,n);[e,t]=J(this,e,t);let i=Z(this.text,Z(n.text,Ie(this.text,0,e)),t),s=this.length+n.length-(t-e);return i.length<=32?new m(i,s):C.from(m.split(i,[]),s)}sliceString(e,t=this.length,n=`
|
|
2
2
|
`){[e,t]=J(this,e,t);let i="";for(let s=0,r=0;s<=t&&r<this.text.length;r++){let h=this.text[r],o=s+h.length;s>e&&r&&(i+=n),e<o&&t>s&&(i+=h.slice(Math.max(0,e-s),t-s)),s=o+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,n.length==32&&(t.push(new m(n,i)),n=[],i=-1);return i>-1&&t.push(new m(n,i)),t}}class C extends x{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let n of e)this.lines+=n.lines}lineInner(e,t,n,i){for(let s=0;;s++){let r=this.children[s],h=i+r.length,o=n+r.lines-1;if((t?o:h)>=e)return r.lineInner(e,t,n,i);i=h+1,n=o+1}}decompose(e,t,n,i){for(let s=0,r=0;r<=t&&s<this.children.length;s++){let h=this.children[s],o=r+h.length;if(e<=o&&t>=r){let a=i&((r<=e?1:0)|(o>=t?2:0));r>=e&&o<=t&&!a?n.push(h):h.decompose(e-r,t-r,n,a)}r=o+1}}replace(e,t,n){if([e,t]=J(this,e,t),n.lines<this.lines)for(let i=0,s=0;i<this.children.length;i++){let r=this.children[i],h=s+r.length;if(e>=s&&t<=h){let o=r.replace(e-s,t-s,n),a=this.lines-r.lines+o.lines;if(o.lines<a>>4&&o.lines>a>>6){let u=this.children.slice();return u[i]=o,new C(u,this.length-(t-e)+n.length)}return super.replace(s,h,o)}s=h+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n=`
|
|
3
3
|
`){[e,t]=J(this,e,t);let i="";for(let s=0,r=0;s<this.children.length&&r<=t;s++){let h=this.children[s],o=r+h.length;r>e&&s&&(i+=n),e<o&&t>r&&(i+=h.sliceString(e-r,t-r,n)),r=o+1}return i}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof C))return 0;let n=0,[i,s,r,h]=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==h)return n;let o=this.children[i],a=e.children[s];if(o!=a)return n+o.scanIdentical(a,t);n+=o.length+1}}static from(e,t=e.reduce((n,i)=>n+i.length+1,-1)){let n=0;for(let c of e)n+=c.lines;if(n<32){let c=[];for(let g of e)g.flatten(c);return new m(c,t)}let i=Math.max(32,n>>5),s=i<<1,r=i>>1,h=[],o=0,a=-1,u=[];function f(c){let g;if(c.lines>s&&c instanceof C)for(let b of c.children)f(b);else c.lines>r&&(o>r||!o)?(d(),h.push(c)):c instanceof m&&o&&(g=u[u.length-1])instanceof m&&c.lines+g.lines<=32?(o+=c.lines,a+=c.length+1,u[u.length-1]=new m(g.text.concat(c.text),g.length+1+c.length)):(o+c.lines>i&&d(),o+=c.lines,a+=c.length+1,u.push(c))}function d(){o!=0&&(h.push(u.length==1?u[0]:C.from(u,a)),a=-1,o=u.length=0)}for(let c of e)f(c);return d(),h.length==1?h[0]:new C(h,t)}}x.empty=new m([""],0);function Ke(l){let e=-1;for(let t of l)e+=t.length+1;return e}function Z(l,e,t=0,n=1e9){for(let i=0,s=0,r=!0;s<l.length&&i<=n;s++){let h=l[s],o=i+h.length;o>=t&&(o>n&&(h=h.slice(0,n-i)),i<t&&(h=h.slice(t-i)),r?(e[e.length-1]+=h,r=!1):e.push(h)),i=o+1}return e}function Ie(l,e,t){return Z(l,[""],e,t)}class N{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 m?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,h=i instanceof m?i.text.length:i.children.length;if(r==(t>0?h:0)){if(n==0)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
|
|
4
|
-
`,this;e--}else if(i instanceof m){let o=i.text[r+(t<0?-1:0)];if(this.offsets[n]+=t,o.length>Math.max(0,e))return this.value=e==0?o:t>0?o.slice(e):o.slice(0,o.length-e),this;e-=o.length}else{let o=i.children[r+(t<0?-1:0)];e>o.length?(e-=o.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(o),this.offsets.push(t>0?1:(o instanceof m?o.text.length:o.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Te{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new N(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 Be{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}}typeof Symbol<"u"&&(x.prototype[Symbol.iterator]=function(){return this.iter()},N.prototype[Symbol.iterator]=Te.prototype[Symbol.iterator]=Be.prototype[Symbol.iterator]=function(){return this});class Qe{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 J(l,e,t){return e=Math.max(0,Math.min(l.length,e)),[e,Math.max(e,Math.min(l.length,t))]}function Q(l,e,t=!0,n=!0){return je(l,e,t,n)}function Xe(l){return l>=56320&&l<57344}function Ye(l){return l>=55296&&l<56320}function ft(l,e){let t=l.charCodeAt(e);if(!Ye(t)||e+1==l.length)return t;let n=l.charCodeAt(e+1);return Xe(n)?(t-55296<<10)+(n-56320)+65536:t}function ct(l){return l<=65535?String.fromCharCode(l):(l-=65536,String.fromCharCode((l>>10)+55296,(l&1023)+56320))}function dt(l){return l<65536?1:2}const le=/\r\n?|\n/;var O=(function(l){return l[l.Simple=0]="Simple",l[l.TrackDel=1]="TrackDel",l[l.TrackBefore=2]="TrackBefore",l[l.TrackAfter=3]="TrackAfter",l})(O||(O={}));class E{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 this.sections.length==0||this.sections.length==2&&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){he(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 E(e)}composeDesc(e){return this.empty?e:e.empty?this:Fe(this,e)}mapDesc(e,t=!1){return e.empty?this:oe(this,e,t)}mapPos(e,t=-1,n=O.Simple){let i=0,s=0;for(let r=0;r<this.sections.length;){let h=this.sections[r++],o=this.sections[r++],a=i+h;if(o<0){if(a>e)return s+(e-i);s+=h}else{if(n!=O.Simple&&a>=e&&(n==O.TrackDel&&i<e&&a>e||n==O.TrackBefore&&i<e||n==O.TrackAfter&&a>e))return null;if(a>e||a==e&&t<0&&!h)return e==i||t<0?s:s+o;s+=o}i=a}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=this.sections[n++],r=this.sections[n++],h=i+s;if(r>=0&&i<=t&&h>=e)return i<e&&h>t?"cover":!0;i=h}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(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new E(e)}static create(e){return new E(e)}}class k extends E{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 he(this,(t,n,i,s,r)=>e=e.replace(i,i+(n-t),r),!1),e}mapDesc(e,t=!1){return oe(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],h=t[i+1];if(h>=0){t[i]=h,t[i+1]=r;let o=i>>1;for(;n.length<o;)n.push(x.empty);n.push(r?e.slice(s,s+r):x.empty)}s+=r}return new k(t,n)}compose(e){return this.empty?e:e.empty?this:Fe(this,e,!0)}map(e,t=!1){return e.empty?this:oe(this,e,t,!0)}iterChanges(e,t=!1){he(this,e,t)}get desc(){return E.create(this.sections)}filter(e){let t=[],n=[],i=[],s=new q(this);e:for(let r=0,h=0;;){let o=r==e.length?1e9:e[r++];for(;h<o||h==o&&s.len==0;){if(s.done)break e;let u=Math.min(s.len,o-h);y(i,u,-1);let f=s.ins==-1?-1:s.off==0?s.ins:0;y(t,u,f),f>0&&M(n,t,s.text),s.forward(u),h+=u}let a=e[r++];for(;h<a;){if(s.done)break e;let u=Math.min(s.len,a-h);y(t,u,-1),y(i,u,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(u),h+=u}}return{changes:new k(t,n),filtered:E.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):i==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let i=[],s=[],r=0,h=null;function o(u=!1){if(!u&&!i.length)return;r<t&&y(i,t-r,-1);let f=new k(i,s);h=h?h.compose(f.map(h)):f,i=[],s=[],r=0}function a(u){if(Array.isArray(u))for(let f of u)a(f);else if(u instanceof k){if(u.length!=t)throw new RangeError(`Mismatched change set length (got ${u.length}, expected ${t})`);o(),h=h?h.compose(u.map(h)):u}else{let{from:f,to:d=f,insert:c}=u;if(f>d||f<0||d>t)throw new RangeError(`Invalid change range ${f} to ${d} (in doc of length ${t})`);let g=c?typeof c=="string"?x.of(c.split(n||le)):c:x.empty,b=g.length;if(f==d&&b==0)return;f<r&&o(),f>r&&y(i,f-r,-1),y(i,d-f,b),M(s,i,g),r=d}}return a(e),o(!h),h}static empty(e){return new k(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(typeof s=="number")t.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((r,h)=>h&&typeof r!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;n.length<i;)n.push(x.empty);n[i]=x.of(s.slice(1)),t.push(s[0],n[i].length)}}}return new k(t,n)}static createSet(e,t){return new k(e,t)}}function y(l,e,t,n=!1){if(e==0&&t<=0)return;let i=l.length-2;i>=0&&t<=0&&t==l[i+1]?l[i]+=e:i>=0&&e==0&&l[i]==0?l[i+1]+=t:n?(l[i]+=e,l[i+1]+=t):l.push(e,t)}function M(l,e,t){if(t.length==0)return;let n=e.length-2>>1;if(n<l.length)l[l.length-1]=l[l.length-1].append(t);else{for(;l.length<n;)l.push(x.empty);l.push(t)}}function he(l,e,t){let n=l.inserted;for(let i=0,s=0,r=0;r<l.sections.length;){let h=l.sections[r++],o=l.sections[r++];if(o<0)i+=h,s+=h;else{let a=i,u=s,f=x.empty;for(;a+=h,u+=o,o&&n&&(f=f.append(n[r-2>>1])),!(t||r==l.sections.length||l.sections[r+1]<0);)h=l.sections[r++],o=l.sections[r++];e(i,a,s,u,f),i=a,s=u}}}function oe(l,e,t,n=!1){let i=[],s=n?[]:null,r=new q(l),h=new q(e);for(let o=-1;;){if(r.done&&h.len||h.done&&r.len)throw new Error("Mismatched change set lengths");if(r.ins==-1&&h.ins==-1){let a=Math.min(r.len,h.len);y(i,a,-1),r.forward(a),h.forward(a)}else if(h.ins>=0&&(r.ins<0||o==r.i||r.off==0&&(h.len<r.len||h.len==r.len&&!t))){let a=h.len;for(y(i,h.ins,-1);a;){let u=Math.min(r.len,a);r.ins>=0&&o<r.i&&r.len<=u&&(y(i,0,r.ins),s&&M(s,i,r.text),o=r.i),r.forward(u),a-=u}h.next()}else if(r.ins>=0){let a=0,u=r.len;for(;u;)if(h.ins==-1){let f=Math.min(u,h.len);a+=f,u-=f,h.forward(f)}else if(h.ins==0&&h.len<u)u-=h.len,h.next();else break;y(i,a,o<r.i?r.ins:0),s&&o<r.i&&M(s,i,r.text),o=r.i,r.forward(r.len-u)}else{if(r.done&&h.done)return s?k.createSet(i,s):E.create(i);throw new Error("Mismatched change set lengths")}}}function Fe(l,e,t=!1){let n=[],i=t?[]:null,s=new q(l),r=new q(e);for(let h=!1;;){if(s.done&&r.done)return i?k.createSet(n,i):E.create(n);if(s.ins==0)y(n,s.len,0,h),s.next();else if(r.len==0&&!r.done)y(n,0,r.ins,h),i&&M(i,n,r.text),r.next();else{if(s.done||r.done)throw new Error("Mismatched change set lengths");{let o=Math.min(s.len2,r.len),a=n.length;if(s.ins==-1){let u=r.ins==-1?-1:r.off?0:r.ins;y(n,o,u,h),i&&u&&M(i,n,r.text)}else r.ins==-1?(y(n,s.off?0:s.len,o,h),i&&M(i,n,s.textBit(o))):(y(n,s.off?0:s.len,r.off?0:r.ins,h),i&&!r.off&&M(i,n,r.text));h=(s.ins>o||r.ins>=0&&r.len>o)&&(h||n.length>a),s.forward2(o),r.forward(o)}}}}class q{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?x.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?x.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class B{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let 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 B(n,i,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return p.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return p.range(this.anchor,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||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return p.range(e.anchor,e.head)}static create(e,t,n){return new B(e,t,n)}}class p{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:p.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 this.ranges.length==1?this:new p([this.main],0)}addRange(e,t=!0){return p.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,p.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)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new p(e.ranges.map(t=>B.fromJSON(t)),e.main)}static single(e,t=e){return new p([p.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let n=0,i=0;i<e.length;i++){let s=e[i];if(s.empty?s.from<=n:s.from<n)return p.normalized(e.slice(),t);n=s.to}return new p(e,t)}static cursor(e,t=0,n,i){return B.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n))|(i??16777215)<<6)}static range(e,t,n,i){let s=(n??16777215)<<6|(i==null?7:Math.min(6,i));return t<e?B.create(t,e,48|s):B.create(e,t,(t>e?8:0)|s)}static normalized(e,t=0){let n=e[t];e.sort((i,s)=>i.from-s.from),t=e.indexOf(n);for(let i=1;i<e.length;i++){let s=e[i],r=e[i-1];if(s.empty?s.from<=r.to:s.from<r.to){let h=r.from,o=Math.max(s.to,r.to);i<=t&&t--,e.splice(--i,2,s.anchor>s.head?p.range(o,h):p.range(h,o))}}return new p(e,t)}}function Je(l,e){for(let t of l.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let me=0;class A{constructor(e,t,n,i,s){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=i,this.id=me++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new A(e.combine||(t=>t),e.compareInput||((t,n)=>t===n),e.compare||(e.combine?(t,n)=>t===n:we),!!e.static,e.enables)}of(e){return new K([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new K(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new K(e,this,2,t)}from(e,t){return t||(t=n=>n),this.compute([e],n=>t(n.field(e)))}}function we(l,e){return l==e||l.length==e.length&&l.every((t,n)=>t===e[n])}class K{constructor(e,t,n,i){this.dependencies=e,this.facet=t,this.type=n,this.value=i,this.id=me++}dynamicSlot(e){var t;let n=this.value,i=this.facet.compareInput,s=this.id,r=e[s]>>1,h=this.type==2,o=!1,a=!1,u=[];for(let f of this.dependencies)f=="doc"?o=!0:f=="selection"?a=!0:(((t=e[f.id])!==null&&t!==void 0?t:1)&1)==0&&u.push(e[f.id]);return{create(f){return f.values[r]=n(f),1},update(f,d){if(o&&d.docChanged||a&&(d.docChanged||d.selection)||ae(f,u)){let c=n(f);if(h?!Pe(c,f.values[r],i):!i(c,f.values[r]))return f.values[r]=c,1}return 0},reconfigure:(f,d)=>{let c,g=d.config.address[s];if(g!=null){let b=Y(d,g);if(this.dependencies.every(v=>v instanceof A?d.facet(v)===f.facet(v):v instanceof L?d.field(v,!1)==f.field(v,!1):!0)||(h?Pe(c=n(f),b,i):i(c=n(f),b)))return f.values[r]=b,0}else c=n(f);return f.values[r]=c,1}}}}function Pe(l,e,t){if(l.length!=e.length)return!1;for(let n=0;n<l.length;n++)if(!t(l[n],e[n]))return!1;return!0}function ae(l,e){let t=!1;for(let n of e)$(l,n)&1&&(t=!0);return t}function _e(l,e,t){let n=t.map(o=>l[o.id]),i=t.map(o=>o.type),s=n.filter(o=>!(o&1)),r=l[e.id]>>1;function h(o){let a=[];for(let u=0;u<n.length;u++){let f=Y(o,n[u]);if(i[u]==2)for(let d of f)a.push(d);else a.push(f)}return e.combine(a)}return{create(o){for(let a of n)$(o,a);return o.values[r]=h(o),1},update(o,a){if(!ae(o,s))return 0;let u=h(o);return e.compare(u,o.values[r])?0:(o.values[r]=u,1)},reconfigure(o,a){let u=ae(o,n),f=a.config.facets[e.id],d=a.facet(e);if(f&&!u&&we(t,f))return o.values[r]=d,0;let c=h(o);return e.compare(c,d)?(o.values[r]=d,0):(o.values[r]=c,1)}}}const U=A.define({static:!0});class L{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 L(me++,e.create,e.update,e.compare||((n,i)=>n===i),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(U).find(n=>n.field==this);return(t?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:n=>(n.values[t]=this.create(n),1),update:(n,i)=>{let s=n.values[t],r=this.updateF(s,i);return this.compareF(s,r)?0:(n.values[t]=r,1)},reconfigure:(n,i)=>{let s=n.facet(U),r=i.facet(U),h;return(h=s.find(o=>o.field==this))&&h!=r.find(o=>o.field==this)?(n.values[t]=h.create(n),1):i.config.address[this.id]!=null?(n.values[t]=i.field(this),0):(n.values[t]=this.create(n),1)}}}init(e){return[this,U.of({field:this,create:e})]}get extension(){return this}}const T={lowest:4,low:3,default:2,high:1,highest:0};function D(l){return e=>new Le(e,l)}const gt={highest:D(T.highest),high:D(T.high),default:D(T.default),low:D(T.low),lowest:D(T.lowest)};class Le{constructor(e,t){this.inner=e,this.prec=t}}class te{of(e){return new ue(this,e)}reconfigure(e){return te.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class ue{constructor(e,t){this.compartment=e,this.inner=t}}class X{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 t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,n){let i=[],s=Object.create(null),r=new Map;for(let d of et(e,t,r))d instanceof L?i.push(d):(s[d.facet.id]||(s[d.facet.id]=[])).push(d);let h=Object.create(null),o=[],a=[];for(let d of i)h[d.id]=a.length<<1,a.push(c=>d.slot(c));let u=n?.config.facets;for(let d in s){let c=s[d],g=c[0].facet,b=u&&u[d]||[];if(c.every(v=>v.type==0))if(h[g.id]=o.length<<1|1,we(b,c))o.push(n.facet(g));else{let v=g.combine(c.map(ne=>ne.value));o.push(n&&g.compare(v,n.facet(g))?n.facet(g):v)}else{for(let v of c)v.type==0?(h[v.id]=o.length<<1|1,o.push(v.value)):(h[v.id]=a.length<<1,a.push(ne=>v.dynamicSlot(ne)));h[g.id]=a.length<<1,a.push(v=>_e(v,g,c))}}let f=a.map(d=>d(h));return new X(e,r,f,h,o,s)}}function et(l,e,t){let n=[[],[],[],[],[]],i=new Map;function s(r,h){let o=i.get(r);if(o!=null){if(o<=h)return;let a=n[o].indexOf(r);a>-1&&n[o].splice(a,1),r instanceof ue&&t.delete(r.compartment)}if(i.set(r,h),Array.isArray(r))for(let a of r)s(a,h);else if(r instanceof ue){if(t.has(r.compartment))throw new RangeError("Duplicate use of compartment in extensions");let a=e.get(r.compartment)||r.inner;t.set(r.compartment,a),s(a,h)}else if(r instanceof Le)s(r.inner,r.prec);else if(r instanceof L)n[h].push(r),r.provides&&s(r.provides,h);else if(r instanceof K)n[h].push(r),r.facet.extensions&&s(r.facet.extensions,T.default);else{let a=r.extension;if(!a)throw new Error(`Unrecognized extension value in extension set (${r}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(a,h)}}return s(l,T.default),n.reduce((r,h)=>r.concat(h))}function $(l,e){if(e&1)return 2;let t=e>>1,n=l.status[t];if(n==4)throw new Error("Cyclic dependency between fields and/or facets");if(n&2)return n;l.status[t]=4;let i=l.computeSlot(l,l.config.dynamicSlots[t]);return l.status[t]=2|i}function Y(l,e){return e&1?l.config.staticValues[e>>1]:l.values[e>>1]}const De=A.define(),fe=A.define({combine:l=>l.some(e=>e),static:!0}),Ve=A.define({combine:l=>l.length?l[0]:void 0,static:!0}),Ne=A.define(),$e=A.define(),qe=A.define(),ze=A.define({combine:l=>l.length?l[0]:!1});class H{constructor(e,t){this.type=e,this.value=t}static define(){return new tt}}class tt{of(e){return new H(this,e)}}class nt{constructor(e){this.map=e}of(e){return new I(this,e)}}class I{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new I(this.type,t)}is(e){return this.type==e}static define(e={}){return new nt(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let i of e){let s=i.map(t);s&&n.push(s)}return n}}I.reconfigure=I.define();I.appendConfig=I.define();class P{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&&Je(n,t.newLength),s.some(h=>h.type==P.time)||(this.annotations=s.concat(P.time.of(Date.now())))}static create(e,t,n,i,s,r){return new P(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(P.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}P.time=H.define();P.userEvent=H.define();P.addToHistory=H.define();P.remote=H.define();function it(l,e){let t=[];for(let n=0,i=0;;){let s,r;if(n<l.length&&(i==e.length||e[i]>=l[n]))s=l[n++],r=l[n++];else if(i<e.length)s=e[i++],r=e[i++];else return t;!t.length||t[t.length-1]<s?t.push(s,r):t[t.length-1]<r&&(t[t.length-1]=r)}}function We(l,e,t){var n;let i,s,r;return t?(i=e.changes,s=k.empty(e.changes.length),r=l.changes.compose(e.changes)):(i=e.changes.map(l.changes),s=l.changes.mapDesc(e.changes,!0),r=l.changes.compose(i)),{changes:r,selection:e.selection?e.selection.map(s):(n=l.selection)===null||n===void 0?void 0:n.map(i),effects:I.mapEffects(l.effects,i).concat(I.mapEffects(e.effects,s)),annotations:l.annotations.length?l.annotations.concat(e.annotations):e.annotations,scrollIntoView:l.scrollIntoView||e.scrollIntoView}}function ce(l,e,t){let n=e.selection,i=F(e.annotations);return e.userEvent&&(i=i.concat(P.userEvent.of(e.userEvent))),{changes:e.changes instanceof k?e.changes:k.of(e.changes||[],t,l.facet(Ve)),selection:n&&(n instanceof p?n:p.single(n.anchor,n.head)),effects:F(e.effects),annotations:i,scrollIntoView:!!e.scrollIntoView}}function He(l,e,t){let n=ce(l,e.length?e[0]:{},l.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(t=!1);let r=!!e[s].sequential;n=We(n,ce(l,e[s],r?n.changes.newLength:l.doc.length),r)}let i=P.create(l,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return rt(t?st(i):i)}function st(l){let e=l.startState,t=!0;for(let i of e.facet(Ne)){let s=i(l);if(s===!1){t=!1;break}Array.isArray(s)&&(t=t===!0?s:it(t,s))}if(t!==!0){let i,s;if(t===!1)s=l.changes.invertedDesc,i=k.empty(e.doc.length);else{let r=l.changes.filter(t);i=r.changes,s=r.filtered.mapDesc(r.changes).invertedDesc}l=P.create(e,i,l.selection&&l.selection.map(s),I.mapEffects(l.effects,s),l.annotations,l.scrollIntoView)}let n=e.facet($e);for(let i=n.length-1;i>=0;i--){let s=n[i](l);s instanceof P?l=s:Array.isArray(s)&&s.length==1&&s[0]instanceof P?l=s[0]:l=He(e,F(s),!1)}return l}function rt(l){let e=l.startState,t=e.facet(qe),n=l;for(let i=t.length-1;i>=0;i--){let s=t[i](l);s&&Object.keys(s).length&&(n=We(n,ce(e,s,l.changes.newLength),!0))}return n==l?l:P.create(e,l.changes,l.selection,n.effects,n.annotations,n.scrollIntoView)}const lt=[];function F(l){return l==null?lt:Array.isArray(l)?l:[l]}var R=(function(l){return l[l.Word=0]="Word",l[l.Space=1]="Space",l[l.Other=2]="Other",l})(R||(R={}));const ht=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let de;try{de=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function ot(l){if(de)return de.test(l);for(let e=0;e<l.length;e++){let t=l[e];if(/\w/.test(t)||t>""&&(t.toUpperCase()!=t.toLowerCase()||ht.test(t)))return!0}return!1}function at(l){return e=>{if(!/\S/.test(e))return R.Space;if(ot(e))return R.Word;for(let t=0;t<l.length;t++)if(e.indexOf(l[t])>-1)return R.Word;return R.Other}}class w{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 h=0;h<this.config.dynamicSlots.length;h++)$(this,h<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw new RangeError("Field is not present in this state");return}return $(this,n),Y(this,n)}update(...e){return He(this,e,!0)}applyTransaction(e){let t=this.config,{base:n,compartments:i}=t;for(let h of e.effects)h.is(te.reconfigure)?(t&&(i=new Map,t.compartments.forEach((o,a)=>i.set(a,o)),t=null),i.set(h.value.compartment,h.value.extension)):h.is(I.reconfigure)?(t=null,n=h.value):h.is(I.appendConfig)&&(t=null,n=F(n).concat(h.value));let s;t?s=e.startState.values.slice():(t=X.resolve(n,i,this),s=new w(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(o,a)=>a.reconfigure(o,this),null).values);let r=e.startState.facet(fe)?e.newSelection:e.newSelection.asSingle();new w(t,e.newDoc,r,s,(h,o)=>o.update(h,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:p.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=F(n.effects);for(let h=1;h<t.ranges.length;h++){let o=e(t.ranges[h]),a=this.changes(o.changes),u=a.map(i);for(let d=0;d<h;d++)s[d]=s[d].map(u);let f=i.mapDesc(a,!0);s.push(o.range.map(f)),i=i.compose(u),r=I.mapEffects(r,u).concat(I.mapEffects(F(o.effects),f))}return{changes:i,selection:p.create(s,t.mainIndex),effects:r}}changes(e=[]){return e instanceof k?e:k.of(e,this.doc.length,this.facet(w.lineSeparator))}toText(e){return x.of(e.split(this.facet(w.lineSeparator)||le))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:($(this,t),Y(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 L&&this.config.address[i.id]!=null&&(t[n]=i.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e,t={},n){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let i=[];if(n){for(let s in n)if(Object.prototype.hasOwnProperty.call(e,s)){let r=n[s],h=e[s];i.push(r.init(o=>r.spec.fromJSON(h,o)))}}return w.create({doc:e.doc,selection:p.fromJSON(e.selection),extensions:t.extensions?i.concat([t.extensions]):i})}static create(e={}){let t=X.resolve(e.extensions||[],new Map),n=e.doc instanceof x?e.doc:x.of((e.doc||"").split(t.staticFacet(w.lineSeparator)||le)),i=e.selection?e.selection instanceof p?e.selection:p.single(e.selection.anchor,e.selection.head):p.single(0);return Je(i,n.length),t.staticFacet(fe)||(i=i.asSingle()),new w(t,n,i,t.dynamicSlots.map(()=>null),(s,r)=>r.create(s),null)}get tabSize(){return this.facet(w.tabSize)}get lineBreak(){return this.facet(w.lineSeparator)||`
|
|
4
|
+
`,this;e--}else if(i instanceof m){let o=i.text[r+(t<0?-1:0)];if(this.offsets[n]+=t,o.length>Math.max(0,e))return this.value=e==0?o:t>0?o.slice(e):o.slice(0,o.length-e),this;e-=o.length}else{let o=i.children[r+(t<0?-1:0)];e>o.length?(e-=o.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(o),this.offsets.push(t>0?1:(o instanceof m?o.text.length:o.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Te{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new N(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 Be{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}}typeof Symbol<"u"&&(x.prototype[Symbol.iterator]=function(){return this.iter()},N.prototype[Symbol.iterator]=Te.prototype[Symbol.iterator]=Be.prototype[Symbol.iterator]=function(){return this});class Qe{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 J(l,e,t){return e=Math.max(0,Math.min(l.length,e)),[e,Math.max(e,Math.min(l.length,t))]}function Q(l,e,t=!0,n=!0){return je(l,e,t,n)}function Xe(l){return l>=56320&&l<57344}function Ye(l){return l>=55296&&l<56320}function ft(l,e){let t=l.charCodeAt(e);if(!Ye(t)||e+1==l.length)return t;let n=l.charCodeAt(e+1);return Xe(n)?(t-55296<<10)+(n-56320)+65536:t}function ct(l){return l<=65535?String.fromCharCode(l):(l-=65536,String.fromCharCode((l>>10)+55296,(l&1023)+56320))}function dt(l){return l<65536?1:2}const le=/\r\n?|\n/;var O=(function(l){return l[l.Simple=0]="Simple",l[l.TrackDel=1]="TrackDel",l[l.TrackBefore=2]="TrackBefore",l[l.TrackAfter=3]="TrackAfter",l})(O||(O={}));class E{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 this.sections.length==0||this.sections.length==2&&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){he(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 E(e)}composeDesc(e){return this.empty?e:e.empty?this:Fe(this,e)}mapDesc(e,t=!1){return e.empty?this:oe(this,e,t)}mapPos(e,t=-1,n=O.Simple){let i=0,s=0;for(let r=0;r<this.sections.length;){let h=this.sections[r++],o=this.sections[r++],a=i+h;if(o<0){if(a>e)return s+(e-i);s+=h}else{if(n!=O.Simple&&a>=e&&(n==O.TrackDel&&i<e&&a>e||n==O.TrackBefore&&i<e||n==O.TrackAfter&&a>e))return null;if(a>e||a==e&&t<0&&!h)return e==i||t<0?s:s+o;s+=o}i=a}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=this.sections[n++],r=this.sections[n++],h=i+s;if(r>=0&&i<=t&&h>=e)return i<e&&h>t?"cover":!0;i=h}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(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new E(e)}static create(e){return new E(e)}}class k extends E{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 he(this,(t,n,i,s,r)=>e=e.replace(i,i+(n-t),r),!1),e}mapDesc(e,t=!1){return oe(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],h=t[i+1];if(h>=0){t[i]=h,t[i+1]=r;let o=i>>1;for(;n.length<o;)n.push(x.empty);n.push(r?e.slice(s,s+r):x.empty)}s+=r}return new k(t,n)}compose(e){return this.empty?e:e.empty?this:Fe(this,e,!0)}map(e,t=!1){return e.empty?this:oe(this,e,t,!0)}iterChanges(e,t=!1){he(this,e,t)}get desc(){return E.create(this.sections)}filter(e){let t=[],n=[],i=[],s=new q(this);e:for(let r=0,h=0;;){let o=r==e.length?1e9:e[r++];for(;h<o||h==o&&s.len==0;){if(s.done)break e;let u=Math.min(s.len,o-h);y(i,u,-1);let f=s.ins==-1?-1:s.off==0?s.ins:0;y(t,u,f),f>0&&M(n,t,s.text),s.forward(u),h+=u}let a=e[r++];for(;h<a;){if(s.done)break e;let u=Math.min(s.len,a-h);y(t,u,-1),y(i,u,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(u),h+=u}}return{changes:new k(t,n),filtered:E.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):i==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let i=[],s=[],r=0,h=null;function o(u=!1){if(!u&&!i.length)return;r<t&&y(i,t-r,-1);let f=new k(i,s);h=h?h.compose(f.map(h)):f,i=[],s=[],r=0}function a(u){if(Array.isArray(u))for(let f of u)a(f);else if(u instanceof k){if(u.length!=t)throw new RangeError(`Mismatched change set length (got ${u.length}, expected ${t})`);o(),h=h?h.compose(u.map(h)):u}else{let{from:f,to:d=f,insert:c}=u;if(f>d||f<0||d>t)throw new RangeError(`Invalid change range ${f} to ${d} (in doc of length ${t})`);let g=c?typeof c=="string"?x.of(c.split(n||le)):c:x.empty,b=g.length;if(f==d&&b==0)return;f<r&&o(),f>r&&y(i,f-r,-1),y(i,d-f,b),M(s,i,g),r=d}}return a(e),o(!h),h}static empty(e){return new k(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(typeof s=="number")t.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((r,h)=>h&&typeof r!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;n.length<i;)n.push(x.empty);n[i]=x.of(s.slice(1)),t.push(s[0],n[i].length)}}}return new k(t,n)}static createSet(e,t){return new k(e,t)}}function y(l,e,t,n=!1){if(e==0&&t<=0)return;let i=l.length-2;i>=0&&t<=0&&t==l[i+1]?l[i]+=e:i>=0&&e==0&&l[i]==0?l[i+1]+=t:n?(l[i]+=e,l[i+1]+=t):l.push(e,t)}function M(l,e,t){if(t.length==0)return;let n=e.length-2>>1;if(n<l.length)l[l.length-1]=l[l.length-1].append(t);else{for(;l.length<n;)l.push(x.empty);l.push(t)}}function he(l,e,t){let n=l.inserted;for(let i=0,s=0,r=0;r<l.sections.length;){let h=l.sections[r++],o=l.sections[r++];if(o<0)i+=h,s+=h;else{let a=i,u=s,f=x.empty;for(;a+=h,u+=o,o&&n&&(f=f.append(n[r-2>>1])),!(t||r==l.sections.length||l.sections[r+1]<0);)h=l.sections[r++],o=l.sections[r++];e(i,a,s,u,f),i=a,s=u}}}function oe(l,e,t,n=!1){let i=[],s=n?[]:null,r=new q(l),h=new q(e);for(let o=-1;;){if(r.done&&h.len||h.done&&r.len)throw new Error("Mismatched change set lengths");if(r.ins==-1&&h.ins==-1){let a=Math.min(r.len,h.len);y(i,a,-1),r.forward(a),h.forward(a)}else if(h.ins>=0&&(r.ins<0||o==r.i||r.off==0&&(h.len<r.len||h.len==r.len&&!t))){let a=h.len;for(y(i,h.ins,-1);a;){let u=Math.min(r.len,a);r.ins>=0&&o<r.i&&r.len<=u&&(y(i,0,r.ins),s&&M(s,i,r.text),o=r.i),r.forward(u),a-=u}h.next()}else if(r.ins>=0){let a=0,u=r.len;for(;u;)if(h.ins==-1){let f=Math.min(u,h.len);a+=f,u-=f,h.forward(f)}else if(h.ins==0&&h.len<u)u-=h.len,h.next();else break;y(i,a,o<r.i?r.ins:0),s&&o<r.i&&M(s,i,r.text),o=r.i,r.forward(r.len-u)}else{if(r.done&&h.done)return s?k.createSet(i,s):E.create(i);throw new Error("Mismatched change set lengths")}}}function Fe(l,e,t=!1){let n=[],i=t?[]:null,s=new q(l),r=new q(e);for(let h=!1;;){if(s.done&&r.done)return i?k.createSet(n,i):E.create(n);if(s.ins==0)y(n,s.len,0,h),s.next();else if(r.len==0&&!r.done)y(n,0,r.ins,h),i&&M(i,n,r.text),r.next();else{if(s.done||r.done)throw new Error("Mismatched change set lengths");{let o=Math.min(s.len2,r.len),a=n.length;if(s.ins==-1){let u=r.ins==-1?-1:r.off?0:r.ins;y(n,o,u,h),i&&u&&M(i,n,r.text)}else r.ins==-1?(y(n,s.off?0:s.len,o,h),i&&M(i,n,s.textBit(o))):(y(n,s.off?0:s.len,r.off?0:r.ins,h),i&&!r.off&&M(i,n,r.text));h=(s.ins>o||r.ins>=0&&r.len>o)&&(h||n.length>a),s.forward2(o),r.forward(o)}}}}class q{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?x.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?x.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class B{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let 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 B(n,i,this.flags)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return p.range(e,t,void 0,void 0,n);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return p.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||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return p.range(e.anchor,e.head)}static create(e,t,n){return new B(e,t,n)}}class p{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:p.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 this.ranges.length==1?this:new p([this.main],0)}addRange(e,t=!0){return p.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,p.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)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new p(e.ranges.map(t=>B.fromJSON(t)),e.main)}static single(e,t=e){return new p([p.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let n=0,i=0;i<e.length;i++){let s=e[i];if(s.empty?s.from<=n:s.from<n)return p.normalized(e.slice(),t);n=s.to}return new p(e,t)}static cursor(e,t=0,n,i){return B.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n))|(i??16777215)<<6)}static range(e,t,n,i,s){let r=(n??16777215)<<6|(i==null?7:Math.min(6,i));return!s&&e!=t&&(s=t<e?1:-1),t<e?B.create(t,e,48|r):B.create(e,t,(s?s<0?8:16:0)|r)}static normalized(e,t=0){let n=e[t];e.sort((i,s)=>i.from-s.from),t=e.indexOf(n);for(let i=1;i<e.length;i++){let s=e[i],r=e[i-1];if(s.empty?s.from<=r.to:s.from<r.to){let h=r.from,o=Math.max(s.to,r.to);i<=t&&t--,e.splice(--i,2,s.anchor>s.head?p.range(o,h):p.range(h,o))}}return new p(e,t)}}function Je(l,e){for(let t of l.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let me=0;class A{constructor(e,t,n,i,s){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=i,this.id=me++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new A(e.combine||(t=>t),e.compareInput||((t,n)=>t===n),e.compare||(e.combine?(t,n)=>t===n:we),!!e.static,e.enables)}of(e){return new K([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new K(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new K(e,this,2,t)}from(e,t){return t||(t=n=>n),this.compute([e],n=>t(n.field(e)))}}function we(l,e){return l==e||l.length==e.length&&l.every((t,n)=>t===e[n])}class K{constructor(e,t,n,i){this.dependencies=e,this.facet=t,this.type=n,this.value=i,this.id=me++}dynamicSlot(e){var t;let n=this.value,i=this.facet.compareInput,s=this.id,r=e[s]>>1,h=this.type==2,o=!1,a=!1,u=[];for(let f of this.dependencies)f=="doc"?o=!0:f=="selection"?a=!0:(((t=e[f.id])!==null&&t!==void 0?t:1)&1)==0&&u.push(e[f.id]);return{create(f){return f.values[r]=n(f),1},update(f,d){if(o&&d.docChanged||a&&(d.docChanged||d.selection)||ae(f,u)){let c=n(f);if(h?!Pe(c,f.values[r],i):!i(c,f.values[r]))return f.values[r]=c,1}return 0},reconfigure:(f,d)=>{let c,g=d.config.address[s];if(g!=null){let b=Y(d,g);if(this.dependencies.every(v=>v instanceof A?d.facet(v)===f.facet(v):v instanceof L?d.field(v,!1)==f.field(v,!1):!0)||(h?Pe(c=n(f),b,i):i(c=n(f),b)))return f.values[r]=b,0}else c=n(f);return f.values[r]=c,1}}}}function Pe(l,e,t){if(l.length!=e.length)return!1;for(let n=0;n<l.length;n++)if(!t(l[n],e[n]))return!1;return!0}function ae(l,e){let t=!1;for(let n of e)$(l,n)&1&&(t=!0);return t}function _e(l,e,t){let n=t.map(o=>l[o.id]),i=t.map(o=>o.type),s=n.filter(o=>!(o&1)),r=l[e.id]>>1;function h(o){let a=[];for(let u=0;u<n.length;u++){let f=Y(o,n[u]);if(i[u]==2)for(let d of f)a.push(d);else a.push(f)}return e.combine(a)}return{create(o){for(let a of n)$(o,a);return o.values[r]=h(o),1},update(o,a){if(!ae(o,s))return 0;let u=h(o);return e.compare(u,o.values[r])?0:(o.values[r]=u,1)},reconfigure(o,a){let u=ae(o,n),f=a.config.facets[e.id],d=a.facet(e);if(f&&!u&&we(t,f))return o.values[r]=d,0;let c=h(o);return e.compare(c,d)?(o.values[r]=d,0):(o.values[r]=c,1)}}}const U=A.define({static:!0});class L{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 L(me++,e.create,e.update,e.compare||((n,i)=>n===i),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(U).find(n=>n.field==this);return(t?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:n=>(n.values[t]=this.create(n),1),update:(n,i)=>{let s=n.values[t],r=this.updateF(s,i);return this.compareF(s,r)?0:(n.values[t]=r,1)},reconfigure:(n,i)=>{let s=n.facet(U),r=i.facet(U),h;return(h=s.find(o=>o.field==this))&&h!=r.find(o=>o.field==this)?(n.values[t]=h.create(n),1):i.config.address[this.id]!=null?(n.values[t]=i.field(this),0):(n.values[t]=this.create(n),1)}}}init(e){return[this,U.of({field:this,create:e})]}get extension(){return this}}const T={lowest:4,low:3,default:2,high:1,highest:0};function D(l){return e=>new Le(e,l)}const gt={highest:D(T.highest),high:D(T.high),default:D(T.default),low:D(T.low),lowest:D(T.lowest)};class Le{constructor(e,t){this.inner=e,this.prec=t}}class te{of(e){return new ue(this,e)}reconfigure(e){return te.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class ue{constructor(e,t){this.compartment=e,this.inner=t}}class X{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 t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,n){let i=[],s=Object.create(null),r=new Map;for(let d of et(e,t,r))d instanceof L?i.push(d):(s[d.facet.id]||(s[d.facet.id]=[])).push(d);let h=Object.create(null),o=[],a=[];for(let d of i)h[d.id]=a.length<<1,a.push(c=>d.slot(c));let u=n?.config.facets;for(let d in s){let c=s[d],g=c[0].facet,b=u&&u[d]||[];if(c.every(v=>v.type==0))if(h[g.id]=o.length<<1|1,we(b,c))o.push(n.facet(g));else{let v=g.combine(c.map(ne=>ne.value));o.push(n&&g.compare(v,n.facet(g))?n.facet(g):v)}else{for(let v of c)v.type==0?(h[v.id]=o.length<<1|1,o.push(v.value)):(h[v.id]=a.length<<1,a.push(ne=>v.dynamicSlot(ne)));h[g.id]=a.length<<1,a.push(v=>_e(v,g,c))}}let f=a.map(d=>d(h));return new X(e,r,f,h,o,s)}}function et(l,e,t){let n=[[],[],[],[],[]],i=new Map;function s(r,h){let o=i.get(r);if(o!=null){if(o<=h)return;let a=n[o].indexOf(r);a>-1&&n[o].splice(a,1),r instanceof ue&&t.delete(r.compartment)}if(i.set(r,h),Array.isArray(r))for(let a of r)s(a,h);else if(r instanceof ue){if(t.has(r.compartment))throw new RangeError("Duplicate use of compartment in extensions");let a=e.get(r.compartment)||r.inner;t.set(r.compartment,a),s(a,h)}else if(r instanceof Le)s(r.inner,r.prec);else if(r instanceof L)n[h].push(r),r.provides&&s(r.provides,h);else if(r instanceof K)n[h].push(r),r.facet.extensions&&s(r.facet.extensions,T.default);else{let a=r.extension;if(!a)throw new Error(`Unrecognized extension value in extension set (${r}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(a,h)}}return s(l,T.default),n.reduce((r,h)=>r.concat(h))}function $(l,e){if(e&1)return 2;let t=e>>1,n=l.status[t];if(n==4)throw new Error("Cyclic dependency between fields and/or facets");if(n&2)return n;l.status[t]=4;let i=l.computeSlot(l,l.config.dynamicSlots[t]);return l.status[t]=2|i}function Y(l,e){return e&1?l.config.staticValues[e>>1]:l.values[e>>1]}const De=A.define(),fe=A.define({combine:l=>l.some(e=>e),static:!0}),Ve=A.define({combine:l=>l.length?l[0]:void 0,static:!0}),Ne=A.define(),$e=A.define(),qe=A.define(),ze=A.define({combine:l=>l.length?l[0]:!1});class H{constructor(e,t){this.type=e,this.value=t}static define(){return new tt}}class tt{of(e){return new H(this,e)}}class nt{constructor(e){this.map=e}of(e){return new I(this,e)}}class I{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new I(this.type,t)}is(e){return this.type==e}static define(e={}){return new nt(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let i of e){let s=i.map(t);s&&n.push(s)}return n}}I.reconfigure=I.define();I.appendConfig=I.define();class P{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&&Je(n,t.newLength),s.some(h=>h.type==P.time)||(this.annotations=s.concat(P.time.of(Date.now())))}static create(e,t,n,i,s,r){return new P(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(P.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}P.time=H.define();P.userEvent=H.define();P.addToHistory=H.define();P.remote=H.define();function it(l,e){let t=[];for(let n=0,i=0;;){let s,r;if(n<l.length&&(i==e.length||e[i]>=l[n]))s=l[n++],r=l[n++];else if(i<e.length)s=e[i++],r=e[i++];else return t;!t.length||t[t.length-1]<s?t.push(s,r):t[t.length-1]<r&&(t[t.length-1]=r)}}function We(l,e,t){var n;let i,s,r;return t?(i=e.changes,s=k.empty(e.changes.length),r=l.changes.compose(e.changes)):(i=e.changes.map(l.changes),s=l.changes.mapDesc(e.changes,!0),r=l.changes.compose(i)),{changes:r,selection:e.selection?e.selection.map(s):(n=l.selection)===null||n===void 0?void 0:n.map(i),effects:I.mapEffects(l.effects,i).concat(I.mapEffects(e.effects,s)),annotations:l.annotations.length?l.annotations.concat(e.annotations):e.annotations,scrollIntoView:l.scrollIntoView||e.scrollIntoView}}function ce(l,e,t){let n=e.selection,i=F(e.annotations);return e.userEvent&&(i=i.concat(P.userEvent.of(e.userEvent))),{changes:e.changes instanceof k?e.changes:k.of(e.changes||[],t,l.facet(Ve)),selection:n&&(n instanceof p?n:p.single(n.anchor,n.head)),effects:F(e.effects),annotations:i,scrollIntoView:!!e.scrollIntoView}}function He(l,e,t){let n=ce(l,e.length?e[0]:{},l.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(t=!1);let r=!!e[s].sequential;n=We(n,ce(l,e[s],r?n.changes.newLength:l.doc.length),r)}let i=P.create(l,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return rt(t?st(i):i)}function st(l){let e=l.startState,t=!0;for(let i of e.facet(Ne)){let s=i(l);if(s===!1){t=!1;break}Array.isArray(s)&&(t=t===!0?s:it(t,s))}if(t!==!0){let i,s;if(t===!1)s=l.changes.invertedDesc,i=k.empty(e.doc.length);else{let r=l.changes.filter(t);i=r.changes,s=r.filtered.mapDesc(r.changes).invertedDesc}l=P.create(e,i,l.selection&&l.selection.map(s),I.mapEffects(l.effects,s),l.annotations,l.scrollIntoView)}let n=e.facet($e);for(let i=n.length-1;i>=0;i--){let s=n[i](l);s instanceof P?l=s:Array.isArray(s)&&s.length==1&&s[0]instanceof P?l=s[0]:l=He(e,F(s),!1)}return l}function rt(l){let e=l.startState,t=e.facet(qe),n=l;for(let i=t.length-1;i>=0;i--){let s=t[i](l);s&&Object.keys(s).length&&(n=We(n,ce(e,s,l.changes.newLength),!0))}return n==l?l:P.create(e,l.changes,l.selection,n.effects,n.annotations,n.scrollIntoView)}const lt=[];function F(l){return l==null?lt:Array.isArray(l)?l:[l]}var R=(function(l){return l[l.Word=0]="Word",l[l.Space=1]="Space",l[l.Other=2]="Other",l})(R||(R={}));const ht=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let de;try{de=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function ot(l){if(de)return de.test(l);for(let e=0;e<l.length;e++){let t=l[e];if(/\w/.test(t)||t>""&&(t.toUpperCase()!=t.toLowerCase()||ht.test(t)))return!0}return!1}function at(l){return e=>{if(!/\S/.test(e))return R.Space;if(ot(e))return R.Word;for(let t=0;t<l.length;t++)if(e.indexOf(l[t])>-1)return R.Word;return R.Other}}class w{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 h=0;h<this.config.dynamicSlots.length;h++)$(this,h<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw new RangeError("Field is not present in this state");return}return $(this,n),Y(this,n)}update(...e){return He(this,e,!0)}applyTransaction(e){let t=this.config,{base:n,compartments:i}=t;for(let h of e.effects)h.is(te.reconfigure)?(t&&(i=new Map,t.compartments.forEach((o,a)=>i.set(a,o)),t=null),i.set(h.value.compartment,h.value.extension)):h.is(I.reconfigure)?(t=null,n=h.value):h.is(I.appendConfig)&&(t=null,n=F(n).concat(h.value));let s;t?s=e.startState.values.slice():(t=X.resolve(n,i,this),s=new w(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(o,a)=>a.reconfigure(o,this),null).values);let r=e.startState.facet(fe)?e.newSelection:e.newSelection.asSingle();new w(t,e.newDoc,r,s,(h,o)=>o.update(h,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:p.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=F(n.effects);for(let h=1;h<t.ranges.length;h++){let o=e(t.ranges[h]),a=this.changes(o.changes),u=a.map(i);for(let d=0;d<h;d++)s[d]=s[d].map(u);let f=i.mapDesc(a,!0);s.push(o.range.map(f)),i=i.compose(u),r=I.mapEffects(r,u).concat(I.mapEffects(F(o.effects),f))}return{changes:i,selection:p.create(s,t.mainIndex),effects:r}}changes(e=[]){return e instanceof k?e:k.of(e,this.doc.length,this.facet(w.lineSeparator))}toText(e){return x.of(e.split(this.facet(w.lineSeparator)||le))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:($(this,t),Y(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 L&&this.config.address[i.id]!=null&&(t[n]=i.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e,t={},n){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let i=[];if(n){for(let s in n)if(Object.prototype.hasOwnProperty.call(e,s)){let r=n[s],h=e[s];i.push(r.init(o=>r.spec.fromJSON(h,o)))}}return w.create({doc:e.doc,selection:p.fromJSON(e.selection),extensions:t.extensions?i.concat([t.extensions]):i})}static create(e={}){let t=X.resolve(e.extensions||[],new Map),n=e.doc instanceof x?e.doc:x.of((e.doc||"").split(t.staticFacet(w.lineSeparator)||le)),i=e.selection?e.selection instanceof p?e.selection:p.single(e.selection.anchor,e.selection.head):p.single(0);return Je(i,n.length),t.staticFacet(fe)||(i=i.asSingle()),new w(t,n,i,t.dynamicSlots.map(()=>null),(s,r)=>r.create(s),null)}get tabSize(){return this.facet(w.tabSize)}get lineBreak(){return this.facet(w.lineSeparator)||`
|
|
5
5
|
`}get readOnly(){return this.facet(ze)}phrase(e,...t){for(let n of this.facet(w.phrases))if(Object.prototype.hasOwnProperty.call(n,e)){e=n[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(n,i)=>{if(i=="$")return"$";let s=+(i||1);return!s||s>t.length?n:t[s-1]})),e}languageDataAt(e,t,n=-1){let i=[];for(let s of this.facet(De))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 at(t.length?t[0]:"")}wordAt(e){let{text:t,from:n,length:i}=this.doc.lineAt(e),s=this.charCategorizer(e),r=e-n,h=e-n;for(;r>0;){let o=Q(t,r,!1);if(s(t.slice(o,r))!=R.Word)break;r=o}for(;h<i;){let o=Q(t,h);if(s(t.slice(h,o))!=R.Word)break;h=o}return r==h?null:p.range(r+n,h+n)}}w.allowMultipleSelections=fe;w.tabSize=A.define({combine:l=>l.length?l[0]:4});w.lineSeparator=Ve;w.readOnly=ze;w.phrases=A.define({compare(l,e){let t=Object.keys(l),n=Object.keys(e);return t.length==n.length&&t.every(i=>l[i]==e[i])}});w.languageData=De;w.changeFilter=Ne;w.transactionFilter=$e;w.transactionExtender=qe;te.reconfigure=I.define();function pt(l,e,t={}){let n={};for(let i of l)for(let s of Object.keys(i)){let r=i[s],h=n[s];if(h===void 0)n[s]=r;else if(!(h===r||r===void 0))if(Object.hasOwnProperty.call(t,s))n[s]=t[s](h,r);else throw new Error("Config merge conflict for field "+s)}for(let i in e)n[i]===void 0&&(n[i]=e[i]);return n}class _{eq(e){return this==e}range(e,t=e){return z.create(e,t,this)}}_.prototype.startSide=_.prototype.endSide=0;_.prototype.point=!1;_.prototype.mapMode=O.TrackDel;function ve(l,e){return l==e||l.constructor==e.constructor&&l.eq(e)}class z{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new z(e,t,n)}}function ge(l,e){return l.from-e.from||l.value.startSide-e.value.startSide}class xe{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,h=s.length;;){if(r==h)return r;let o=r+h>>1,a=s[o]-e||(n?this.value[o].endSide:this.value[o].startSide)-t;if(o==r)return a>=0?r:h;a>=0?h=o:r=o+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(i(this.from[s]+e,this.to[s]+e,this.value[s])===!1)return!1}map(e,t){let n=[],i=[],s=[],r=-1,h=-1;for(let o=0;o<this.value.length;o++){let a=this.value[o],u=this.from[o]+e,f=this.to[o]+e,d,c;if(u==f){let g=t.mapPos(u,a.startSide,a.mapMode);if(g==null||(d=c=g,a.startSide!=a.endSide&&(c=t.mapPos(u,a.endSide),c<d)))continue}else if(d=t.mapPos(u,a.startSide),c=t.mapPos(f,a.endSide),d>c||d==c&&a.startSide>0&&a.endSide<=0)continue;(c-d||a.endSide-a.startSide)<0||(r<0&&(r=d),a.point&&(h=Math.max(h,c-d)),n.push(a),i.push(d-r),s.push(c-r))}return{mapped:n.length?new xe(i,s,n,h):null,pos:r}}}class S{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 S(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(t.length==0&&!r)return this;if(n&&(t=t.slice().sort(ge)),this.isEmpty)return t.length?S.of(t):this;let h=new Ue(this,null,-1).goto(0),o=0,a=[],u=new ee;for(;h.value||o<t.length;)if(o<t.length&&(h.from-t[o].from||h.startSide-t[o].value.startSide)>=0){let f=t[o++];u.addInner(f.from,f.to,f.value)||a.push(f)}else h.rangeIndex==1&&h.chunkIndex<this.chunk.length&&(o==t.length||this.chunkEnd(h.chunkIndex)<t[o].from)&&(!r||i>this.chunkEnd(h.chunkIndex)||s<this.chunkPos[h.chunkIndex])&&u.addChunk(this.chunkPos[h.chunkIndex],this.chunk[h.chunkIndex])?h.nextChunk():((!r||i>h.to||s<h.from||r(h.from,h.to,h.value))&&(u.addInner(h.from,h.to,h.value)||a.push(z.create(h.from,h.to,h.value))),h.next());return u.finishInner(this.nextLayer.isEmpty&&!a.length?S.empty:this.nextLayer.update({add:a,filter:r,filterFrom:i,filterTo:s}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],n=[],i=-1;for(let r=0;r<this.chunk.length;r++){let h=this.chunkPos[r],o=this.chunk[r],a=e.touchesRange(h,h+o.length);if(a===!1)i=Math.max(i,o.maxPoint),t.push(o),n.push(e.mapPos(h));else if(a===!0){let{mapped:u,pos:f}=o.map(h,e);u&&(i=Math.max(i,u.maxPoint),t.push(u),n.push(f))}}let s=this.nextLayer.map(e);return t.length==0?s:new S(n,t,s||S.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&&r.between(s,e-s,t-s,n)===!1)return}this.nextLayer.between(e,t,n)}}iter(e=0){return W.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return W.from(e).goto(t)}static compare(e,t,n,i,s=-1){let r=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),h=t.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),o=Ae(r,h,n),a=new V(r,o,s),u=new V(h,o,s);n.iterGaps((f,d,c)=>be(a,f,u,d,c,i)),n.empty&&n.length==0&&be(a,0,u,0,0,i)}static eq(e,t,n=0,i){i==null&&(i=999999999);let s=e.filter(u=>!u.isEmpty&&t.indexOf(u)<0),r=t.filter(u=>!u.isEmpty&&e.indexOf(u)<0);if(s.length!=r.length)return!1;if(!s.length)return!0;let h=Ae(s,r),o=new V(s,h,0).goto(n),a=new V(r,h,0).goto(n);for(;;){if(o.to!=a.to||!pe(o.active,a.active)||o.point&&(!a.point||!ve(o.point,a.point)))return!1;if(o.to>i)return!0;o.next(),a.next()}}static spans(e,t,n,i,s=-1){let r=new V(e,null,s).goto(t),h=t,o=r.openStart;for(;;){let a=Math.min(r.to,n);if(r.point){let u=r.activeForPoint(r.to),f=r.pointFrom<t?u.length+1:r.point.startSide<0?u.length:Math.min(u.length,o);i.point(h,a,r.point,u,f,r.pointRank),o=Math.min(r.openEnd(a),u.length)}else a>h&&(i.span(h,a,r.active,o),o=r.openEnd(a));if(r.to>n)return o+(r.point&&r.to>n?1:0);h=r.to,r.next()}}static of(e,t=!1){let n=new ee;for(let i of e instanceof z?[e]:t?ut(e):e)n.add(i.from,i.to,i.value);return n.finish()}static join(e){if(!e.length)return S.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let i=e[n];i!=S.empty;i=i.nextLayer)t=new S(i.chunkPos,i.chunk,t,Math.max(i.maxPoint,t.maxPoint));return t}}S.empty=new S([],[],null,-1);function ut(l){if(l.length>1)for(let e=l[0],t=1;t<l.length;t++){let n=l[t];if(ge(e,n)>0)return l.slice().sort(ge);e=n}return l}S.empty.nextLayer=S.empty;class ee{finishChunk(e){this.chunks.push(new xe(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 ee)).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?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=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(S.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=S.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function Ae(l,e,t){let n=new Map;for(let s of l)for(let r=0;r<s.chunk.length;r++)s.chunk[r].maxPoint<=0&&n.set(s.chunk[r],s.chunkPos[r]);let i=new Set;for(let s of e)for(let r=0;r<s.chunk.length;r++){let h=n.get(s.chunk[r]);h!=null&&(t?t.mapPos(h):h)==s.chunkPos[r]&&!t?.touchesRange(h,h+s.chunk[r].length)&&i.add(s.chunk[r])}return i}class Ue{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 i=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(i)||this.layer.chunkEnd(this.chunkIndex)<e||i.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}else{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 W{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 Ue(r,t,n,s));return i.length==1?i[0]:new W(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 n=this.heap.length>>1;n>=0;n--)se(this.heap,n);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let n=this.heap.length>>1;n>=0;n--)se(this.heap,n);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),se(this.heap,0)}}}function se(l,e){for(let t=l[e];;){let n=(e<<1)+1;if(n>=l.length)break;let i=l[n];if(n+1<l.length&&i.compare(l[n+1])>=0&&(i=l[n+1],n++),t.compare(i)<0)break;l[n]=t,l[e]=i,e=n}}class V{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=W.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){G(this.active,e),G(this.activeTo,e),G(this.activeRank,e),this.minActive=Ce(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++;j(this.active,t,n),j(this.activeTo,t,i),j(this.activeRank,t,s),e&&j(e,t,this.cursor.from),this.minActive=Ce(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&&G(n,i)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(n),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=s,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=s.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(n){this.openStart=0;for(let i=n.length-1;i>=0&&n[i]<e;i--)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 be(l,e,t,n,i,s){l.goto(e),t.goto(n);let r=n+i,h=n,o=n-e,a=!!s.boundChange;for(let u=!1;;){let f=l.to+o-t.to,d=f||l.endSide-t.endSide,c=d<0?l.to+o:t.to,g=Math.min(c,r);if(l.point||t.point?(l.point&&t.point&&ve(l.point,t.point)&&pe(l.activeForPoint(l.to),t.activeForPoint(t.to))||s.comparePoint(h,g,l.point,t.point),u=!1):(u&&s.boundChange(h),g>h&&!pe(l.active,t.active)&&s.compareRange(h,g,l.active,t.active),a&&g<r&&(f||l.openEnd(c)!=t.openEnd(c))&&(u=!0)),c>r)break;h=c,d<=0&&l.next(),d>=0&&t.next()}}function pe(l,e){if(l.length!=e.length)return!1;for(let t=0;t<l.length;t++)if(l[t]!=e[t]&&!ve(l[t],e[t]))return!1;return!0}function G(l,e){for(let t=e,n=l.length-1;t<n;t++)l[t]=l[t+1];l.pop()}function j(l,e,t){for(let n=l.length-1;n>=e;n--)l[n+1]=l[n];l[e]=t}function Ce(l,e){let t=-1,n=1e9;for(let i=0;i<e.length;i++)(e[i]-n||l[i].endSide-l[t].endSide)<0&&(t=i,n=e[i]);return t}function mt(l,e,t=l.length){let n=0;for(let i=0;i<t&&i<l.length;)l.charCodeAt(i)==9?(n+=e-n%e,i++):(n++,i=Q(l,i));return n}function wt(l,e,t,n){for(let i=0,s=0;;){if(s>=e)return i;if(i==l.length)break;s+=l.charCodeAt(i)==9?t-s%t:1,i=Q(l,i)}return n===!0?-1:l.length}export{H as Annotation,tt as AnnotationType,E as ChangeDesc,k as ChangeSet,R as CharCategory,te as Compartment,p as EditorSelection,w as EditorState,A as Facet,Qe as Line,O as MapMode,gt as Prec,z as Range,S as RangeSet,ee as RangeSetBuilder,_ as RangeValue,B as SelectionRange,I as StateEffect,nt as StateEffectType,L as StateField,x as Text,P as Transaction,ft as codePointAt,dt as codePointSize,pt as combineConfig,mt as countColumn,Q as findClusterBreak,wt as findColumn,ct as fromCodePoint};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{O as B,f as F,g as A,e as V,w as S,a as J,t as v,c as D,r as L,b as _,d as N,h as E,i as P,j as G,k as O,l as q,D as R,m as z}from"./CLFba8FK.js";import{r as M}from"./
|
|
1
|
+
import{O as B,f as F,g as A,e as V,w as S,a as J,t as v,c as D,r as L,b as _,d as N,h as E,i as P,j as G,k as O,l as q,D as R,m as z}from"./CLFba8FK.js";import{r as M}from"./Dkz6p8Jo.js";const b=3e4;class K extends B{constructor(n){super(),this.doc=n,this.clientID=n.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const e=A();this.getLocalState()!==null&&b/2<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const s=[];this.meta.forEach((a,c)=>{c!==this.clientID&&b<=e-a.lastUpdated&&this.states.has(c)&&s.push(c)}),s.length>0&&x(this,s,"timeout")},F(b/10)),n.on("destroy",()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(n){const e=this.clientID,s=this.meta.get(e),a=s===void 0?0:s.clock+1,c=this.states.get(e);n===null?this.states.delete(e):this.states.set(e,n),this.meta.set(e,{clock:a,lastUpdated:A()});const l=[],u=[],r=[],p=[];n===null?p.push(e):c==null?n!=null&&l.push(e):(u.push(e),V(c,n)||r.push(e)),(l.length>0||r.length>0||p.length>0)&&this.emit("change",[{added:l,updated:r,removed:p},"local"]),this.emit("update",[{added:l,updated:u,removed:p},"local"])}setLocalStateField(n,e){const s=this.getLocalState();s!==null&&this.setLocalState({...s,[n]:e})}getStates(){return this.states}}const x=(t,n,e)=>{const s=[];for(let a=0;a<n.length;a++){const c=n[a];if(t.states.has(c)){if(t.states.delete(c),c===t.clientID){const l=t.meta.get(c);t.meta.set(c,{clock:l.clock+1,lastUpdated:A()})}s.push(c)}}s.length>0&&(t.emit("change",[{added:[],updated:[],removed:s},e]),t.emit("update",[{added:[],updated:[],removed:s},e]))},Q=(t,n,e=t.states)=>{const s=n.length,a=D();S(a,s);for(let c=0;c<s;c++){const l=n[c],u=e.get(l)||null,r=t.meta.get(l).clock;S(a,l),S(a,r),J(a,JSON.stringify(u))}return v(a)},X=(t,n,e)=>{const s=N(n),a=A(),c=[],l=[],u=[],r=[],p=L(s);for(let m=0;m<p;m++){const d=L(s);let g=L(s);const h=JSON.parse(_(s)),y=t.meta.get(d),k=t.states.get(d),o=y===void 0?0:y.clock;(o<g||o===g&&h===null&&t.states.has(d))&&(h===null?d===t.clientID&&t.getLocalState()!=null?g++:t.states.delete(d):t.states.set(d,h),t.meta.set(d,{clock:g,lastUpdated:a}),y===void 0&&h!==null?c.push(d):y!==void 0&&h===null?r.push(d):h!==null&&(V(h,k)||u.push(d),l.push(d)))}(c.length>0||u.length>0||r.length>0)&&t.emit("change",[{added:c,updated:u,removed:r},e]),(c.length>0||l.length>0||r.length>0)&&t.emit("update",[{added:c,updated:l,removed:r},e])},W=0,j=1,C=2,Z=(t,n)=>{S(t,W);const e=P(n);E(t,e)},$=(t,n,e)=>{S(t,j),E(t,q(n,e))},H=(t,n,e)=>$(n,e,O(t)),Y=(t,n,e,s)=>{try{G(n,O(t),e)}catch(a){s?.(a),console.error("Caught error while handling a Yjs update",a)}},tt=(t,n)=>{S(t,C),E(t,n)},et=Y,nt=(t,n,e,s,a)=>{const c=L(t);switch(c){case W:H(t,n,e);break;case j:Y(t,e,s,a);break;case C:et(t,e,s,a);break;default:throw new Error("Unknown message type")}return c},U=0,T=1;function st(t,n,e){const s=new TextEncoder().encode(t),a=new ArrayBuffer(2+s.length+1+e.length);return new DataView(a).setUint16(0,s.length),new Uint8Array(a,2,s.length).set(s),new Uint8Array(a)[2+s.length]=n,new Uint8Array(a,2+s.length+1).set(e),a}function at(t){if(t.byteLength<3)return null;const e=new DataView(t).getUint16(0);if(t.byteLength<2+e+1)return null;const s=new TextDecoder().decode(new Uint8Array(t,2,e)),a=new Uint8Array(t)[2+e],c=new Uint8Array(t,2+e+1);return{docName:s,msgType:a,payload:c}}function lt(t,n){const e=new R,s=e.getText("content"),a=new K(e);a.setLocalStateField("user",{name:n.name,color:n.color,colorLight:n.colorLight??n.color+"33"});let c=null,l=!1;function u(){return M.ws??null}function r(o,f){const i=u();!i||i.readyState!==WebSocket.OPEN||i.send(st(t,o,f))}function p(){const o=D();Z(o,e),r(U,v(o))}function m(o){const f=o??[e.clientID],i=Q(a,f);r(T,i)}function d(o){if(l||typeof o.data=="string")return;const f=o.data instanceof ArrayBuffer?o.data:null;if(!f)return;const i=at(f);if(!(!i||i.docName!==t))if(i.msgType===U){const I=N(i.payload),w=D();nt(I,w,e,"ws-server"),z(w)>0&&r(U,v(w))}else i.msgType===T&&X(a,i.payload,"ws-server")}function g(o,f){if(l||f==="ws-server")return;const i=D();tt(i,o),r(U,v(i))}function h({added:o,updated:f,removed:i},I){if(l||I==="ws-server")return;const w=o.concat(f,i);m(w)}function y(){if(l)return;const o=u();!o||o.readyState!==WebSocket.OPEN||(o.send(JSON.stringify({type:"collab:join",docName:t})),c&&o.removeEventListener("message",c),c=d,o.addEventListener("message",c),p(),m())}e.on("update",g),a.on("update",h),y(),M.addConnectHandler(y);function k(){if(l)return;l=!0,x(a,[e.clientID],"local"),m([e.clientID]);const o=u();o&&o.readyState===WebSocket.OPEN&&o.send(JSON.stringify({type:"collab:leave",docName:t})),c&&o&&(o.removeEventListener("message",c),c=null),e.off("update",g),a.off("update",h),a.destroy(),e.destroy()}return{ydoc:e,ytext:s,awareness:a,destroy:k}}export{lt as createCollabSession};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{P as L,N as $,a as E,D as j,b as y,T as S,I as G}from"./BXuvR8Ks.js";var N={};class v{constructor(t,e,s,i,h,r,n,o,a,u=0,f){this.p=t,this.stack=e,this.state=s,this.reducePos=i,this.pos=h,this.score=r,this.buffer=n,this.bufferBase=o,this.curContext=a,this.lookAhead=u,this.parent=f}toString(){return`[${this.stack.filter((t,e)=>e%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(t,e,s=0){let i=t.parser.context;return new v(t,[],e,s,s,0,[],0,i?new R(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(t,e){this.stack.push(this.state,e,this.bufferBase+this.buffer.length),this.state=t}reduce(t){var e;let s=t>>19,i=t&65535,{parser:h}=this.p,r=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),n=h.dynamicPrecedence(i);if(n&&(this.score+=n),s==0){this.pushState(h.getGoto(this.state,i,!0),this.reducePos),i<h.minRepeatTerm&&this.storeNode(i,this.reducePos,this.reducePos,r?8:4,!0),this.reduceContext(i,this.reducePos);return}let o=this.stack.length-(s-1)*3-(t&262144?6:0),a=o?this.stack[o-2]:this.p.ranges[0].from,u=this.reducePos-a;u>=2e3&&!(!((e=this.p.parser.nodeSet.types[i])===null||e===void 0)&&e.isAnonymous)&&(a==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=u):this.p.lastBigReductionSize<u&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=a,this.p.lastBigReductionSize=u));let f=o?this.stack[o-1]:0,p=this.bufferBase+this.buffer.length-f;if(i<h.minRepeatTerm||t&131072){let c=h.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(i,a,c,p+4,!0)}if(t&262144)this.state=this.stack[o];else{let c=this.stack[o-3];this.state=h.getGoto(c,i,!0)}for(;this.stack.length>o;)this.stack.pop();this.reduceContext(i,a)}storeNode(t,e,s,i=4,h=!1){if(t==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let r=this,n=this.buffer.length;if(n==0&&r.parent&&(n=r.bufferBase-r.parent.bufferBase,r=r.parent),n>0&&r.buffer[n-4]==0&&r.buffer[n-1]>-1){if(e==s)return;if(r.buffer[n-2]>=e){r.buffer[n-2]=s;return}}}if(!h||this.pos==s)this.buffer.push(t,e,s,i);else{let r=this.buffer.length;if(r>0&&(this.buffer[r-4]!=0||this.buffer[r-1]<0)){let n=!1;for(let o=r;o>0&&this.buffer[o-2]>s;o-=4)if(this.buffer[o-1]>=0){n=!0;break}if(n)for(;r>0&&this.buffer[r-2]>s;)this.buffer[r]=this.buffer[r-4],this.buffer[r+1]=this.buffer[r-3],this.buffer[r+2]=this.buffer[r-2],this.buffer[r+3]=this.buffer[r-1],r-=4,i>4&&(i-=4)}this.buffer[r]=t,this.buffer[r+1]=e,this.buffer[r+2]=s,this.buffer[r+3]=i}}shift(t,e,s,i){if(t&131072)this.pushState(t&65535,this.pos);else if((t&262144)==0){let h=t,{parser:r}=this.p;this.pos=i;let n=r.stateFlag(h,1);!n&&(i>s||e<=r.maxNode)&&(this.reducePos=i),this.pushState(h,n?s:Math.min(s,this.reducePos)),this.shiftContext(e,s),e<=r.maxNode&&this.buffer.push(e,s,i,4)}else this.pos=i,this.shiftContext(e,s),e<=this.p.parser.maxNode&&this.buffer.push(e,s,i,4)}apply(t,e,s,i){t&65536?this.reduce(t):this.shift(t,e,s,i)}useNode(t,e){let s=this.p.reused.length-1;(s<0||this.p.reused[s]!=t)&&(this.p.reused.push(t),s++);let i=this.pos;this.reducePos=this.pos=i+t.length,this.pushState(e,i),this.buffer.push(s,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,t,this,this.p.stream.reset(this.pos-t.length)))}split(){let t=this,e=t.buffer.length;for(;e>0&&t.buffer[e-2]>t.reducePos;)e-=4;let s=t.buffer.slice(e),i=t.bufferBase+e;for(;t&&i==t.bufferBase;)t=t.parent;return new v(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,s,i,this.curContext,this.lookAhead,t)}recoverByDelete(t,e){let s=t<=this.p.parser.maxNode;s&&this.storeNode(t,this.pos,e,4),this.storeNode(0,this.pos,e,s?8:4),this.pos=this.reducePos=e,this.score-=190}canShift(t){for(let e=new U(this);;){let s=this.p.parser.stateSlot(e.state,4)||this.p.parser.hasAction(e.state,t);if(s==0)return!1;if((s&65536)==0)return!0;e.reduce(s)}}recoverByInsert(t){if(this.stack.length>=300)return[];let e=this.p.parser.nextStates(this.state);if(e.length>8||this.stack.length>=120){let i=[];for(let h=0,r;h<e.length;h+=2)(r=e[h+1])!=this.state&&this.p.parser.hasAction(r,t)&&i.push(e[h],r);if(this.stack.length<120)for(let h=0;i.length<8&&h<e.length;h+=2){let r=e[h+1];i.some((n,o)=>o&1&&n==r)||i.push(e[h],r)}e=i}let s=[];for(let i=0;i<e.length&&s.length<4;i+=2){let h=e[i+1];if(h==this.state)continue;let r=this.split();r.pushState(h,this.pos),r.storeNode(0,r.pos,r.pos,4,!0),r.shiftContext(e[i],this.pos),r.reducePos=this.pos,r.score-=200,s.push(r)}return s}forceReduce(){let{parser:t}=this.p,e=t.stateSlot(this.state,5);if((e&65536)==0)return!1;if(!t.validAction(this.state,e)){let s=e>>19,i=e&65535,h=this.stack.length-s*3;if(h<0||t.getGoto(this.stack[h],i,!1)<0){let r=this.findForcedReduction();if(r==null)return!1;e=r}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(e),!0}findForcedReduction(){let{parser:t}=this.p,e=[],s=(i,h)=>{if(!e.includes(i))return e.push(i),t.allActions(i,r=>{if(!(r&393216))if(r&65536){let n=(r>>19)-h;if(n>1){let o=r&65535,a=this.stack.length-n*3;if(a>=0&&t.getGoto(this.stack[a],o,!1)>=0)return n<<19|65536|o}}else{let n=s(r,h+1);if(n!=null)return n}})};return s(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:t}=this.p;return t.data[t.stateSlot(this.state,1)]==65535&&!t.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(t){if(this.state!=t.state||this.stack.length!=t.stack.length)return!1;for(let e=0;e<this.stack.length;e+=3)if(this.stack[e]!=t.stack[e])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(t){return this.p.parser.dialect.flags[t]}shiftContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,t,this,this.p.stream.reset(e)))}reduceContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,t,this,this.p.stream.reset(e)))}emitContext(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(t){if(t!=this.curContext.context){let e=new R(this.curContext.tracker,t);e.hash!=this.curContext.hash&&this.emitContext(),this.curContext=e}}setLookAhead(t){return t<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=t,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class R{constructor(t,e){this.tracker=t,this.context=e,this.hash=t.strict?t.hash(e):0}}class U{constructor(t){this.start=t,this.state=t.state,this.stack=t.stack,this.base=this.stack.length}reduce(t){let e=t&65535,s=t>>19;s==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(s-1)*3;let i=this.start.p.parser.getGoto(this.stack[this.base-3],e,!0);this.state=i}}class A{constructor(t,e,s){this.stack=t,this.pos=e,this.index=s,this.buffer=t.buffer,this.index==0&&this.maybeNext()}static create(t,e=t.bufferBase+t.buffer.length){return new A(t,e,e-t.bufferBase)}maybeNext(){let t=this.stack.parent;t!=null&&(this.index=this.stack.bufferBase-t.bufferBase,this.stack=t,this.buffer=t.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new A(this.stack,this.pos,this.index)}}function x(l,t=Uint16Array){if(typeof l!="string")return l;let e=null;for(let s=0,i=0;s<l.length;){let h=0;for(;;){let r=l.charCodeAt(s++),n=!1;if(r==126){h=65535;break}r>=92&&r--,r>=34&&r--;let o=r-32;if(o>=46&&(o-=46,n=!0),h+=o,n)break;h*=46}e?e[i++]=h:e=new t(h)}return e}class P{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 P;class H{constructor(t,e){this.input=t,this.ranges=e,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=z,this.rangeIndex=0,this.pos=this.chunkPos=e[0].from,this.range=e[0],this.end=e[e.length-1].to,this.readNext()}resolveOffset(t,e){let s=this.range,i=this.rangeIndex,h=this.pos+t;for(;h<s.from;){if(!i)return null;let r=this.ranges[--i];h-=s.from-r.to,s=r}for(;e<0?h>s.to:h>=s.to;){if(i==this.ranges.length-1)return null;let r=this.ranges[++i];h+=r.from-s.to,s=r}return h}clipPos(t){if(t>=this.range.from&&t<this.range.to)return t;for(let e of this.ranges)if(e.to>t)return Math.max(t,e.from);return this.end}peek(t){let e=this.chunkOff+t,s,i;if(e>=0&&e<this.chunk.length)s=this.pos+t,i=this.chunk.charCodeAt(e);else{let h=this.resolveOffset(t,1);if(h==null)return-1;if(s=h,s>=this.chunk2Pos&&s<this.chunk2Pos+this.chunk2.length)i=this.chunk2.charCodeAt(s-this.chunk2Pos);else{let r=this.rangeIndex,n=this.range;for(;n.to<=s;)n=this.ranges[++r];this.chunk2=this.input.chunk(this.chunk2Pos=s),s+this.chunk2.length>n.to&&(this.chunk2=this.chunk2.slice(0,n.to-s)),i=this.chunk2.charCodeAt(0)}}return s>=this.token.lookAhead&&(this.token.lookAhead=s+1),i}acceptToken(t,e=0){let s=e?this.resolveOffset(e,-1):this.pos;if(s==null||s<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=t,this.token.end=s}acceptTokenTo(t,e){this.token.value=t,this.token.end=e}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:t,chunkPos:e}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=t,this.chunk2Pos=e,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let t=this.input.chunk(this.pos),e=this.pos+t.length;this.chunk=e>this.range.to?t.slice(0,this.range.to-this.pos):t,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(t=1){for(this.chunkOff+=t;this.pos+t>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();t-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=t,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(t,e){if(e?(this.token=e,e.start=t,e.lookAhead=t+1,e.value=e.extended=-1):this.token=z,this.pos!=t){if(this.pos=t,t==this.end)return this.setDone(),this;for(;t<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;t>=this.range.to;)this.range=this.ranges[++this.rangeIndex];t>=this.chunkPos&&t<this.chunkPos+this.chunk.length?this.chunkOff=t-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(t,e){if(t>=this.chunkPos&&e<=this.chunkPos+this.chunk.length)return this.chunk.slice(t-this.chunkPos,e-this.chunkPos);if(t>=this.chunk2Pos&&e<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(t-this.chunk2Pos,e-this.chunk2Pos);if(t>=this.range.from&&e<=this.range.to)return this.input.read(t,e);let s="";for(let i of this.ranges){if(i.from>=e)break;i.to>t&&(s+=this.input.read(Math.max(i.from,t),Math.min(i.to,e)))}return s}}class m{constructor(t,e){this.data=t,this.id=e}token(t,e){let{parser:s}=e.p;O(this.data,t,e,this.id,s.data,s.tokenPrecTable)}}m.prototype.contextual=m.prototype.fallback=m.prototype.extend=!1;class W{constructor(t,e,s){this.precTable=e,this.elseToken=s,this.data=typeof t=="string"?x(t):t}token(t,e){let s=t.pos,i=0;for(;;){let h=t.next<0,r=t.resolveOffset(1,1);if(O(this.data,t,e,0,this.data,this.precTable),t.token.value>-1)break;if(this.elseToken==null)return;if(h||i++,r==null)break;t.reset(r,t.token)}i&&(t.reset(s,t.token),t.acceptToken(this.elseToken,i))}}W.prototype.contextual=m.prototype.fallback=m.prototype.extend=!1;class Z{constructor(t,e={}){this.token=t,this.contextual=!!e.contextual,this.fallback=!!e.fallback,this.extend=!!e.extend}}function O(l,t,e,s,i,h){let r=0,n=1<<s,{dialect:o}=e.p.parser;t:for(;(n&l[r])!=0;){let a=l[r+1];for(let c=r+3;c<a;c+=2)if((l[c+1]&n)>0){let d=l[c];if(o.allows(d)&&(t.token.value==-1||t.token.value==d||q(d,t.token.value,i,h))){t.acceptToken(d);break}}let u=t.next,f=0,p=l[r+2];if(t.next<0&&p>f&&l[a+p*3-3]==65535){r=l[a+p*3-1];continue t}for(;f<p;){let c=f+p>>1,d=a+c+(c<<1),b=l[d],M=l[d+1]||65536;if(u<b)p=c;else if(u>=M)f=c+1;else{r=l[d+2],t.advance();continue t}}break}}function I(l,t,e){for(let s=t,i;(i=l[s])!=65535;s++)if(i==e)return s-t;return-1}function q(l,t,e,s){let i=I(e,s,t);return i<0||I(e,s,l)<i}const g=typeof process<"u"&&N&&/\bparse\b/.test(N.LOG);let T=null;function D(l,t,e){let s=l.cursor(G.IncludeAnonymous);for(s.moveTo(t);;)if(!(e<0?s.childBefore(t):s.childAfter(t)))for(;;){if((e<0?s.to<t:s.from>t)&&!s.type.isError)return e<0?Math.max(0,Math.min(s.to-1,t-25)):Math.min(l.length,Math.max(s.from+1,t+25));if(e<0?s.prevSibling():s.nextSibling())break;if(!s.parent())return e<0?0:l.length}}class J{constructor(t,e){this.fragments=t,this.nodeSet=e,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let t=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(t){for(this.safeFrom=t.openStart?D(t.tree,t.from+t.offset,1)-t.offset:t.from,this.safeTo=t.openEnd?D(t.tree,t.to+t.offset,-1)-t.offset:t.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(t.tree),this.start.push(-t.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(t){if(t<this.nextStart)return null;for(;this.fragment&&this.safeTo<=t;)this.nextFragment();if(!this.fragment)return null;for(;;){let e=this.trees.length-1;if(e<0)return this.nextFragment(),null;let s=this.trees[e],i=this.index[e];if(i==s.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let h=s.children[i],r=this.start[e]+s.positions[i];if(r>t)return this.nextStart=r,null;if(h instanceof S){if(r==t){if(r<this.safeFrom)return null;let n=r+h.length;if(n<=this.safeTo){let o=h.prop(y.lookAhead);if(!o||n+o<this.fragment.to)return h}}this.index[e]++,r+h.length>=Math.max(this.safeFrom,t)&&(this.trees.push(h),this.start.push(r),this.index.push(0))}else this.index[e]++,this.nextStart=r+h.length}}}class K{constructor(t,e){this.stream=e,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=t.tokenizers.map(s=>new P)}getActions(t){let e=0,s=null,{parser:i}=t.p,{tokenizers:h}=i,r=i.stateSlot(t.state,3),n=t.curContext?t.curContext.hash:0,o=0;for(let a=0;a<h.length;a++){if((1<<a&r)==0)continue;let u=h[a],f=this.tokens[a];if(!(s&&!u.fallback)&&((u.contextual||f.start!=t.pos||f.mask!=r||f.context!=n)&&(this.updateCachedToken(f,u,t),f.mask=r,f.context=n),f.lookAhead>f.end+25&&(o=Math.max(f.lookAhead,o)),f.value!=0)){let p=e;if(f.extended>-1&&(e=this.addActions(t,f.extended,f.end,e)),e=this.addActions(t,f.value,f.end,e),!u.extend&&(s=f,e>p))break}}for(;this.actions.length>e;)this.actions.pop();return o&&t.setLookAhead(o),!s&&t.pos==this.stream.end&&(s=new P,s.value=t.p.parser.eofTerm,s.start=s.end=t.pos,e=this.addActions(t,s.value,s.end,e)),this.mainToken=s,this.actions}getMainToken(t){if(this.mainToken)return this.mainToken;let e=new P,{pos:s,p:i}=t;return e.start=s,e.end=Math.min(s+1,i.stream.end),e.value=s==i.stream.end?i.parser.eofTerm:0,e}updateCachedToken(t,e,s){let i=this.stream.clipPos(s.pos);if(e.token(this.stream.reset(i,t),s),t.value>-1){let{parser:h}=s.p;for(let r=0;r<h.specialized.length;r++)if(h.specialized[r]==t.value){let n=h.specializers[r](this.stream.read(t.start,t.end),s);if(n>=0&&s.p.parser.dialect.allows(n>>1)){(n&1)==0?t.value=n>>1:t.extended=n>>1;break}}}else t.value=0,t.end=this.stream.clipPos(i+1)}putAction(t,e,s,i){for(let h=0;h<i;h+=3)if(this.actions[h]==t)return i;return this.actions[i++]=t,this.actions[i++]=e,this.actions[i++]=s,i}addActions(t,e,s,i){let{state:h}=t,{parser:r}=t.p,{data:n}=r;for(let o=0;o<2;o++)for(let a=r.stateSlot(h,o?2:1);;a+=3){if(n[a]==65535)if(n[a+1]==1)a=k(n,a+2);else{i==0&&n[a+1]==2&&(i=this.putAction(k(n,a+2),e,s,i));break}n[a]==e&&(i=this.putAction(k(n,a+1),e,s,i))}return i}}class Q{constructor(t,e,s,i){this.parser=t,this.input=e,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 H(e,i),this.tokens=new K(t,this.stream),this.topTerm=t.top[1];let{from:h}=i[0];this.stacks=[v.start(this,t.top[0],h)],this.fragments=s.length&&this.stream.end-h>t.bufferLength*4?new J(s,t.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let t=this.stacks,e=this.minStackPos,s=this.stacks=[],i,h;if(this.bigReductionCount>300&&t.length==1){let[r]=t;for(;r.forceReduce()&&r.stack.length&&r.stack[r.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let r=0;r<t.length;r++){let n=t[r];for(;;){if(this.tokens.mainToken=null,n.pos>e)s.push(n);else{if(this.advanceStack(n,s,t))continue;{i||(i=[],h=[]),i.push(n);let o=this.tokens.getMainToken(n);h.push(o.value,o.end)}}break}}if(!s.length){let r=i&&X(i);if(r)return g&&console.log("Finish with "+this.stackID(r)),this.stackToTree(r);if(this.parser.strict)throw g&&i&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+e);this.recovering||(this.recovering=5)}if(this.recovering&&i){let r=this.stoppedAt!=null&&i[0].pos>this.stoppedAt?i[0]:this.runRecovery(i,h,s);if(r)return g&&console.log("Force-finish "+this.stackID(r)),this.stackToTree(r.forceAll())}if(this.recovering){let r=this.recovering==1?1:this.recovering*3;if(s.length>r)for(s.sort((n,o)=>o.score-n.score);s.length>r;)s.pop();s.some(n=>n.reducePos>e)&&this.recovering--}else if(s.length>1){t:for(let r=0;r<s.length-1;r++){let n=s[r];for(let o=r+1;o<s.length;o++){let a=s[o];if(n.sameState(a)||n.buffer.length>500&&a.buffer.length>500)if((n.score-a.score||n.buffer.length-a.buffer.length)>0)s.splice(o--,1);else{s.splice(r--,1);continue t}}}s.length>12&&(s.sort((r,n)=>n.score-r.score),s.splice(12,s.length-12))}this.minStackPos=s[0].pos;for(let r=1;r<s.length;r++)s[r].pos<this.minStackPos&&(this.minStackPos=s[r].pos);return null}stopAt(t){if(this.stoppedAt!=null&&this.stoppedAt<t)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=t}advanceStack(t,e,s){let i=t.pos,{parser:h}=this,r=g?this.stackID(t)+" -> ":"";if(this.stoppedAt!=null&&i>this.stoppedAt)return t.forceReduce()?t:null;if(this.fragments){let a=t.curContext&&t.curContext.tracker.strict,u=a?t.curContext.hash:0;for(let f=this.fragments.nodeAt(i);f;){let p=this.parser.nodeSet.types[f.type.id]==f.type?h.getGoto(t.state,f.type.id):-1;if(p>-1&&f.length&&(!a||(f.prop(y.contextHash)||0)==u))return t.useNode(f,p),g&&console.log(r+this.stackID(t)+` (via reuse of ${h.getName(f.type.id)})`),!0;if(!(f instanceof S)||f.children.length==0||f.positions[0]>0)break;let c=f.children[0];if(c instanceof S&&f.positions[0]==0)f=c;else break}}let n=h.stateSlot(t.state,4);if(n>0)return t.reduce(n),g&&console.log(r+this.stackID(t)+` (via always-reduce ${h.getName(n&65535)})`),!0;if(t.stack.length>=8400)for(;t.stack.length>6e3&&t.forceReduce(););let o=this.tokens.getActions(t);for(let a=0;a<o.length;){let u=o[a++],f=o[a++],p=o[a++],c=a==o.length||!s,d=c?t:t.split(),b=this.tokens.mainToken;if(d.apply(u,f,b?b.start:d.pos,p),g&&console.log(r+this.stackID(d)+` (via ${(u&65536)==0?"shift":`reduce of ${h.getName(u&65535)}`} for ${h.getName(f)} @ ${i}${d==t?"":", split"})`),c)return!0;d.pos>i?e.push(d):s.push(d)}return!1}advanceFully(t,e){let s=t.pos;for(;;){if(!this.advanceStack(t,null,null))return!1;if(t.pos>s)return B(t,e),!0}}runRecovery(t,e,s){let i=null,h=!1;for(let r=0;r<t.length;r++){let n=t[r],o=e[r<<1],a=e[(r<<1)+1],u=g?this.stackID(n)+" -> ":"";if(n.deadEnd&&(h||(h=!0,n.restart(),g&&console.log(u+this.stackID(n)+" (restarted)"),this.advanceFully(n,s))))continue;let f=n.split(),p=u;for(let c=0;c<10&&f.forceReduce()&&(g&&console.log(p+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,s));c++)g&&(p=this.stackID(f)+" -> ");for(let c of n.recoverByInsert(o))g&&console.log(u+this.stackID(c)+" (via recover-insert)"),this.advanceFully(c,s);this.stream.end>n.pos?(a==n.pos&&(a++,o=0),n.recoverByDelete(o,a),g&&console.log(u+this.stackID(n)+` (via recover-delete ${this.parser.getName(o)})`),B(n,s)):(!i||i.score<f.score)&&(i=f)}return i}stackToTree(t){return t.close(),S.build({buffer:A.create(t),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:t.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(t){let e=(T||(T=new WeakMap)).get(t);return e||T.set(t,e=String.fromCodePoint(this.nextStackID++)),e+t}}function B(l,t){for(let e=0;e<t.length;e++){let s=t[e];if(s.pos==l.pos&&s.sameState(l)){t[e].score<l.score&&(t[e]=l);return}}t.push(l)}class V{constructor(t,e,s){this.source=t,this.flags=e,this.disabled=s}allows(t){return!this.disabled||this.disabled[t]==0}}const C=l=>l;class _{constructor(t){this.start=t.start,this.shift=t.shift||C,this.reduce=t.reduce||C,this.reuse=t.reuse||C,this.hash=t.hash||(()=>0),this.strict=t.strict!==!1}}class w extends L{constructor(t){if(super(),this.wrappers=[],t.version!=14)throw new RangeError(`Parser version (${t.version}) doesn't match runtime version (14)`);let e=t.nodeNames.split(" ");this.minRepeatTerm=e.length;for(let n=0;n<t.repeatNodeCount;n++)e.push("");let s=Object.keys(t.topRules).map(n=>t.topRules[n][1]),i=[];for(let n=0;n<e.length;n++)i.push([]);function h(n,o,a){i[n].push([o,o.deserialize(String(a))])}if(t.nodeProps)for(let n of t.nodeProps){let o=n[0];typeof o=="string"&&(o=y[o]);for(let a=1;a<n.length;){let u=n[a++];if(u>=0)h(u,o,n[a++]);else{let f=n[a+-u];for(let p=-u;p>0;p--)h(n[a++],o,f);a++}}}this.nodeSet=new $(e.map((n,o)=>E.define({name:o>=this.minRepeatTerm?void 0:n,id:o,props:i[o],top:s.indexOf(o)>-1,error:o==0,skipped:t.skippedNodes&&t.skippedNodes.indexOf(o)>-1}))),t.propSources&&(this.nodeSet=this.nodeSet.extend(...t.propSources)),this.strict=!1,this.bufferLength=j;let r=x(t.tokenData);this.context=t.context,this.specializerSpecs=t.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let n=0;n<this.specializerSpecs.length;n++)this.specialized[n]=this.specializerSpecs[n].term;this.specializers=this.specializerSpecs.map(F),this.states=x(t.states,Uint32Array),this.data=x(t.stateData),this.goto=x(t.goto),this.maxTerm=t.maxTerm,this.tokenizers=t.tokenizers.map(n=>typeof n=="number"?new m(r,n):n),this.topRules=t.topRules,this.dialects=t.dialects||{},this.dynamicPrecedences=t.dynamicPrecedences||null,this.tokenPrecTable=t.tokenPrec,this.termNames=t.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(t,e,s){let i=new Q(this,t,e,s);for(let h of this.wrappers)i=h(i,t,e,s);return i}getGoto(t,e,s=!1){let i=this.goto;if(e>=i[0])return-1;for(let h=i[e+1];;){let r=i[h++],n=r&1,o=i[h++];if(n&&s)return o;for(let a=h+(r>>1);h<a;h++)if(i[h]==t)return o;if(n)return-1}}hasAction(t,e){let s=this.data;for(let i=0;i<2;i++)for(let h=this.stateSlot(t,i?2:1),r;;h+=3){if((r=s[h])==65535)if(s[h+1]==1)r=s[h=k(s,h+2)];else{if(s[h+1]==2)return k(s,h+2);break}if(r==e||r==0)return k(s,h+1)}return 0}stateSlot(t,e){return this.states[t*6+e]}stateFlag(t,e){return(this.stateSlot(t,0)&e)>0}validAction(t,e){return!!this.allActions(t,s=>s==e?!0:null)}allActions(t,e){let s=this.stateSlot(t,4),i=s?e(s):void 0;for(let h=this.stateSlot(t,1);i==null;h+=3){if(this.data[h]==65535)if(this.data[h+1]==1)h=k(this.data,h+2);else break;i=e(k(this.data,h+1))}return i}nextStates(t){let e=[];for(let s=this.stateSlot(t,1);;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=k(this.data,s+2);else break;if((this.data[s+2]&1)==0){let i=this.data[s+1];e.some((h,r)=>r&1&&h==i)||e.push(this.data[s],i)}}return e}configure(t){let e=Object.assign(Object.create(w.prototype),this);if(t.props&&(e.nodeSet=this.nodeSet.extend(...t.props)),t.top){let s=this.topRules[t.top];if(!s)throw new RangeError(`Invalid top rule name ${t.top}`);e.top=s}return t.tokenizers&&(e.tokenizers=this.tokenizers.map(s=>{let i=t.tokenizers.find(h=>h.from==s);return i?i.to:s})),t.specializers&&(e.specializers=this.specializers.slice(),e.specializerSpecs=this.specializerSpecs.map((s,i)=>{let h=t.specializers.find(n=>n.from==s.external);if(!h)return s;let r=Object.assign(Object.assign({},s),{external:h.to});return e.specializers[i]=F(r),r})),t.contextTracker&&(e.context=t.contextTracker),t.dialect&&(e.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(e.strict=t.strict),t.wrap&&(e.wrappers=e.wrappers.concat(t.wrap)),t.bufferLength!=null&&(e.bufferLength=t.bufferLength),e}hasWrappers(){return this.wrappers.length>0}getName(t){return this.termNames?this.termNames[t]:String(t<=this.maxNode&&this.nodeSet.types[t].name||t)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(t){let e=this.dynamicPrecedences;return e==null?0:e[t]||0}parseDialect(t){let e=Object.keys(this.dialects),s=e.map(()=>!1);if(t)for(let h of t.split(" ")){let r=e.indexOf(h);r>=0&&(s[r]=!0)}let i=null;for(let h=0;h<e.length;h++)if(!s[h])for(let r=this.dialects[e[h]],n;(n=this.data[r++])!=65535;)(i||(i=new Uint8Array(this.maxTerm+1)))[n]=1;return new V(t,s,i)}static deserialize(t){return new w(t)}}function k(l,t){return l[t]|l[t+1]<<16}function X(l){let t=null;for(let e of l){let s=e.p.stoppedAt;(e.pos==e.p.stream.end||s!=null&&e.pos>s)&&e.p.parser.stateFlag(e.state,2)&&(!t||t.score<e.score)&&(t=e)}return t}function F(l){if(l.external){let t=l.extend?1:0;return(e,s)=>l.external(e,s)<<1|t}return l.get}export{_ as C,Z as E,w as L,W as a};
|
|
1
|
+
import{P as L,a as $,b as E,D as j,N as y,T as S,I as G}from"./C7VoTosa.js";var N={};class v{constructor(t,e,s,i,h,r,n,o,a,u=0,f){this.p=t,this.stack=e,this.state=s,this.reducePos=i,this.pos=h,this.score=r,this.buffer=n,this.bufferBase=o,this.curContext=a,this.lookAhead=u,this.parent=f}toString(){return`[${this.stack.filter((t,e)=>e%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(t,e,s=0){let i=t.parser.context;return new v(t,[],e,s,s,0,[],0,i?new R(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(t,e){this.stack.push(this.state,e,this.bufferBase+this.buffer.length),this.state=t}reduce(t){var e;let s=t>>19,i=t&65535,{parser:h}=this.p,r=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),n=h.dynamicPrecedence(i);if(n&&(this.score+=n),s==0){this.pushState(h.getGoto(this.state,i,!0),this.reducePos),i<h.minRepeatTerm&&this.storeNode(i,this.reducePos,this.reducePos,r?8:4,!0),this.reduceContext(i,this.reducePos);return}let o=this.stack.length-(s-1)*3-(t&262144?6:0),a=o?this.stack[o-2]:this.p.ranges[0].from,u=this.reducePos-a;u>=2e3&&!(!((e=this.p.parser.nodeSet.types[i])===null||e===void 0)&&e.isAnonymous)&&(a==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=u):this.p.lastBigReductionSize<u&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=a,this.p.lastBigReductionSize=u));let f=o?this.stack[o-1]:0,p=this.bufferBase+this.buffer.length-f;if(i<h.minRepeatTerm||t&131072){let c=h.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(i,a,c,p+4,!0)}if(t&262144)this.state=this.stack[o];else{let c=this.stack[o-3];this.state=h.getGoto(c,i,!0)}for(;this.stack.length>o;)this.stack.pop();this.reduceContext(i,a)}storeNode(t,e,s,i=4,h=!1){if(t==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let r=this,n=this.buffer.length;if(n==0&&r.parent&&(n=r.bufferBase-r.parent.bufferBase,r=r.parent),n>0&&r.buffer[n-4]==0&&r.buffer[n-1]>-1){if(e==s)return;if(r.buffer[n-2]>=e){r.buffer[n-2]=s;return}}}if(!h||this.pos==s)this.buffer.push(t,e,s,i);else{let r=this.buffer.length;if(r>0&&(this.buffer[r-4]!=0||this.buffer[r-1]<0)){let n=!1;for(let o=r;o>0&&this.buffer[o-2]>s;o-=4)if(this.buffer[o-1]>=0){n=!0;break}if(n)for(;r>0&&this.buffer[r-2]>s;)this.buffer[r]=this.buffer[r-4],this.buffer[r+1]=this.buffer[r-3],this.buffer[r+2]=this.buffer[r-2],this.buffer[r+3]=this.buffer[r-1],r-=4,i>4&&(i-=4)}this.buffer[r]=t,this.buffer[r+1]=e,this.buffer[r+2]=s,this.buffer[r+3]=i}}shift(t,e,s,i){if(t&131072)this.pushState(t&65535,this.pos);else if((t&262144)==0){let h=t,{parser:r}=this.p;this.pos=i;let n=r.stateFlag(h,1);!n&&(i>s||e<=r.maxNode)&&(this.reducePos=i),this.pushState(h,n?s:Math.min(s,this.reducePos)),this.shiftContext(e,s),e<=r.maxNode&&this.buffer.push(e,s,i,4)}else this.pos=i,this.shiftContext(e,s),e<=this.p.parser.maxNode&&this.buffer.push(e,s,i,4)}apply(t,e,s,i){t&65536?this.reduce(t):this.shift(t,e,s,i)}useNode(t,e){let s=this.p.reused.length-1;(s<0||this.p.reused[s]!=t)&&(this.p.reused.push(t),s++);let i=this.pos;this.reducePos=this.pos=i+t.length,this.pushState(e,i),this.buffer.push(s,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,t,this,this.p.stream.reset(this.pos-t.length)))}split(){let t=this,e=t.buffer.length;for(;e>0&&t.buffer[e-2]>t.reducePos;)e-=4;let s=t.buffer.slice(e),i=t.bufferBase+e;for(;t&&i==t.bufferBase;)t=t.parent;return new v(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,s,i,this.curContext,this.lookAhead,t)}recoverByDelete(t,e){let s=t<=this.p.parser.maxNode;s&&this.storeNode(t,this.pos,e,4),this.storeNode(0,this.pos,e,s?8:4),this.pos=this.reducePos=e,this.score-=190}canShift(t){for(let e=new U(this);;){let s=this.p.parser.stateSlot(e.state,4)||this.p.parser.hasAction(e.state,t);if(s==0)return!1;if((s&65536)==0)return!0;e.reduce(s)}}recoverByInsert(t){if(this.stack.length>=300)return[];let e=this.p.parser.nextStates(this.state);if(e.length>8||this.stack.length>=120){let i=[];for(let h=0,r;h<e.length;h+=2)(r=e[h+1])!=this.state&&this.p.parser.hasAction(r,t)&&i.push(e[h],r);if(this.stack.length<120)for(let h=0;i.length<8&&h<e.length;h+=2){let r=e[h+1];i.some((n,o)=>o&1&&n==r)||i.push(e[h],r)}e=i}let s=[];for(let i=0;i<e.length&&s.length<4;i+=2){let h=e[i+1];if(h==this.state)continue;let r=this.split();r.pushState(h,this.pos),r.storeNode(0,r.pos,r.pos,4,!0),r.shiftContext(e[i],this.pos),r.reducePos=this.pos,r.score-=200,s.push(r)}return s}forceReduce(){let{parser:t}=this.p,e=t.stateSlot(this.state,5);if((e&65536)==0)return!1;if(!t.validAction(this.state,e)){let s=e>>19,i=e&65535,h=this.stack.length-s*3;if(h<0||t.getGoto(this.stack[h],i,!1)<0){let r=this.findForcedReduction();if(r==null)return!1;e=r}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(e),!0}findForcedReduction(){let{parser:t}=this.p,e=[],s=(i,h)=>{if(!e.includes(i))return e.push(i),t.allActions(i,r=>{if(!(r&393216))if(r&65536){let n=(r>>19)-h;if(n>1){let o=r&65535,a=this.stack.length-n*3;if(a>=0&&t.getGoto(this.stack[a],o,!1)>=0)return n<<19|65536|o}}else{let n=s(r,h+1);if(n!=null)return n}})};return s(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:t}=this.p;return t.data[t.stateSlot(this.state,1)]==65535&&!t.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(t){if(this.state!=t.state||this.stack.length!=t.stack.length)return!1;for(let e=0;e<this.stack.length;e+=3)if(this.stack[e]!=t.stack[e])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(t){return this.p.parser.dialect.flags[t]}shiftContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,t,this,this.p.stream.reset(e)))}reduceContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,t,this,this.p.stream.reset(e)))}emitContext(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(t){if(t!=this.curContext.context){let e=new R(this.curContext.tracker,t);e.hash!=this.curContext.hash&&this.emitContext(),this.curContext=e}}setLookAhead(t){return t<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=t,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class R{constructor(t,e){this.tracker=t,this.context=e,this.hash=t.strict?t.hash(e):0}}class U{constructor(t){this.start=t,this.state=t.state,this.stack=t.stack,this.base=this.stack.length}reduce(t){let e=t&65535,s=t>>19;s==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(s-1)*3;let i=this.start.p.parser.getGoto(this.stack[this.base-3],e,!0);this.state=i}}class A{constructor(t,e,s){this.stack=t,this.pos=e,this.index=s,this.buffer=t.buffer,this.index==0&&this.maybeNext()}static create(t,e=t.bufferBase+t.buffer.length){return new A(t,e,e-t.bufferBase)}maybeNext(){let t=this.stack.parent;t!=null&&(this.index=this.stack.bufferBase-t.bufferBase,this.stack=t,this.buffer=t.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new A(this.stack,this.pos,this.index)}}function x(l,t=Uint16Array){if(typeof l!="string")return l;let e=null;for(let s=0,i=0;s<l.length;){let h=0;for(;;){let r=l.charCodeAt(s++),n=!1;if(r==126){h=65535;break}r>=92&&r--,r>=34&&r--;let o=r-32;if(o>=46&&(o-=46,n=!0),h+=o,n)break;h*=46}e?e[i++]=h:e=new t(h)}return e}class P{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 P;class H{constructor(t,e){this.input=t,this.ranges=e,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=z,this.rangeIndex=0,this.pos=this.chunkPos=e[0].from,this.range=e[0],this.end=e[e.length-1].to,this.readNext()}resolveOffset(t,e){let s=this.range,i=this.rangeIndex,h=this.pos+t;for(;h<s.from;){if(!i)return null;let r=this.ranges[--i];h-=s.from-r.to,s=r}for(;e<0?h>s.to:h>=s.to;){if(i==this.ranges.length-1)return null;let r=this.ranges[++i];h+=r.from-s.to,s=r}return h}clipPos(t){if(t>=this.range.from&&t<this.range.to)return t;for(let e of this.ranges)if(e.to>t)return Math.max(t,e.from);return this.end}peek(t){let e=this.chunkOff+t,s,i;if(e>=0&&e<this.chunk.length)s=this.pos+t,i=this.chunk.charCodeAt(e);else{let h=this.resolveOffset(t,1);if(h==null)return-1;if(s=h,s>=this.chunk2Pos&&s<this.chunk2Pos+this.chunk2.length)i=this.chunk2.charCodeAt(s-this.chunk2Pos);else{let r=this.rangeIndex,n=this.range;for(;n.to<=s;)n=this.ranges[++r];this.chunk2=this.input.chunk(this.chunk2Pos=s),s+this.chunk2.length>n.to&&(this.chunk2=this.chunk2.slice(0,n.to-s)),i=this.chunk2.charCodeAt(0)}}return s>=this.token.lookAhead&&(this.token.lookAhead=s+1),i}acceptToken(t,e=0){let s=e?this.resolveOffset(e,-1):this.pos;if(s==null||s<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=t,this.token.end=s}acceptTokenTo(t,e){this.token.value=t,this.token.end=e}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:t,chunkPos:e}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=t,this.chunk2Pos=e,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let t=this.input.chunk(this.pos),e=this.pos+t.length;this.chunk=e>this.range.to?t.slice(0,this.range.to-this.pos):t,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(t=1){for(this.chunkOff+=t;this.pos+t>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();t-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=t,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(t,e){if(e?(this.token=e,e.start=t,e.lookAhead=t+1,e.value=e.extended=-1):this.token=z,this.pos!=t){if(this.pos=t,t==this.end)return this.setDone(),this;for(;t<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;t>=this.range.to;)this.range=this.ranges[++this.rangeIndex];t>=this.chunkPos&&t<this.chunkPos+this.chunk.length?this.chunkOff=t-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(t,e){if(t>=this.chunkPos&&e<=this.chunkPos+this.chunk.length)return this.chunk.slice(t-this.chunkPos,e-this.chunkPos);if(t>=this.chunk2Pos&&e<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(t-this.chunk2Pos,e-this.chunk2Pos);if(t>=this.range.from&&e<=this.range.to)return this.input.read(t,e);let s="";for(let i of this.ranges){if(i.from>=e)break;i.to>t&&(s+=this.input.read(Math.max(i.from,t),Math.min(i.to,e)))}return s}}class m{constructor(t,e){this.data=t,this.id=e}token(t,e){let{parser:s}=e.p;O(this.data,t,e,this.id,s.data,s.tokenPrecTable)}}m.prototype.contextual=m.prototype.fallback=m.prototype.extend=!1;class W{constructor(t,e,s){this.precTable=e,this.elseToken=s,this.data=typeof t=="string"?x(t):t}token(t,e){let s=t.pos,i=0;for(;;){let h=t.next<0,r=t.resolveOffset(1,1);if(O(this.data,t,e,0,this.data,this.precTable),t.token.value>-1)break;if(this.elseToken==null)return;if(h||i++,r==null)break;t.reset(r,t.token)}i&&(t.reset(s,t.token),t.acceptToken(this.elseToken,i))}}W.prototype.contextual=m.prototype.fallback=m.prototype.extend=!1;class Z{constructor(t,e={}){this.token=t,this.contextual=!!e.contextual,this.fallback=!!e.fallback,this.extend=!!e.extend}}function O(l,t,e,s,i,h){let r=0,n=1<<s,{dialect:o}=e.p.parser;t:for(;(n&l[r])!=0;){let a=l[r+1];for(let c=r+3;c<a;c+=2)if((l[c+1]&n)>0){let d=l[c];if(o.allows(d)&&(t.token.value==-1||t.token.value==d||q(d,t.token.value,i,h))){t.acceptToken(d);break}}let u=t.next,f=0,p=l[r+2];if(t.next<0&&p>f&&l[a+p*3-3]==65535){r=l[a+p*3-1];continue t}for(;f<p;){let c=f+p>>1,d=a+c+(c<<1),b=l[d],M=l[d+1]||65536;if(u<b)p=c;else if(u>=M)f=c+1;else{r=l[d+2],t.advance();continue t}}break}}function I(l,t,e){for(let s=t,i;(i=l[s])!=65535;s++)if(i==e)return s-t;return-1}function q(l,t,e,s){let i=I(e,s,t);return i<0||I(e,s,l)<i}const g=typeof process<"u"&&N&&/\bparse\b/.test(N.LOG);let T=null;function D(l,t,e){let s=l.cursor(G.IncludeAnonymous);for(s.moveTo(t);;)if(!(e<0?s.childBefore(t):s.childAfter(t)))for(;;){if((e<0?s.to<t:s.from>t)&&!s.type.isError)return e<0?Math.max(0,Math.min(s.to-1,t-25)):Math.min(l.length,Math.max(s.from+1,t+25));if(e<0?s.prevSibling():s.nextSibling())break;if(!s.parent())return e<0?0:l.length}}class J{constructor(t,e){this.fragments=t,this.nodeSet=e,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let t=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(t){for(this.safeFrom=t.openStart?D(t.tree,t.from+t.offset,1)-t.offset:t.from,this.safeTo=t.openEnd?D(t.tree,t.to+t.offset,-1)-t.offset:t.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(t.tree),this.start.push(-t.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(t){if(t<this.nextStart)return null;for(;this.fragment&&this.safeTo<=t;)this.nextFragment();if(!this.fragment)return null;for(;;){let e=this.trees.length-1;if(e<0)return this.nextFragment(),null;let s=this.trees[e],i=this.index[e];if(i==s.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let h=s.children[i],r=this.start[e]+s.positions[i];if(r>t)return this.nextStart=r,null;if(h instanceof S){if(r==t){if(r<this.safeFrom)return null;let n=r+h.length;if(n<=this.safeTo){let o=h.prop(y.lookAhead);if(!o||n+o<this.fragment.to)return h}}this.index[e]++,r+h.length>=Math.max(this.safeFrom,t)&&(this.trees.push(h),this.start.push(r),this.index.push(0))}else this.index[e]++,this.nextStart=r+h.length}}}class K{constructor(t,e){this.stream=e,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=t.tokenizers.map(s=>new P)}getActions(t){let e=0,s=null,{parser:i}=t.p,{tokenizers:h}=i,r=i.stateSlot(t.state,3),n=t.curContext?t.curContext.hash:0,o=0;for(let a=0;a<h.length;a++){if((1<<a&r)==0)continue;let u=h[a],f=this.tokens[a];if(!(s&&!u.fallback)&&((u.contextual||f.start!=t.pos||f.mask!=r||f.context!=n)&&(this.updateCachedToken(f,u,t),f.mask=r,f.context=n),f.lookAhead>f.end+25&&(o=Math.max(f.lookAhead,o)),f.value!=0)){let p=e;if(f.extended>-1&&(e=this.addActions(t,f.extended,f.end,e)),e=this.addActions(t,f.value,f.end,e),!u.extend&&(s=f,e>p))break}}for(;this.actions.length>e;)this.actions.pop();return o&&t.setLookAhead(o),!s&&t.pos==this.stream.end&&(s=new P,s.value=t.p.parser.eofTerm,s.start=s.end=t.pos,e=this.addActions(t,s.value,s.end,e)),this.mainToken=s,this.actions}getMainToken(t){if(this.mainToken)return this.mainToken;let e=new P,{pos:s,p:i}=t;return e.start=s,e.end=Math.min(s+1,i.stream.end),e.value=s==i.stream.end?i.parser.eofTerm:0,e}updateCachedToken(t,e,s){let i=this.stream.clipPos(s.pos);if(e.token(this.stream.reset(i,t),s),t.value>-1){let{parser:h}=s.p;for(let r=0;r<h.specialized.length;r++)if(h.specialized[r]==t.value){let n=h.specializers[r](this.stream.read(t.start,t.end),s);if(n>=0&&s.p.parser.dialect.allows(n>>1)){(n&1)==0?t.value=n>>1:t.extended=n>>1;break}}}else t.value=0,t.end=this.stream.clipPos(i+1)}putAction(t,e,s,i){for(let h=0;h<i;h+=3)if(this.actions[h]==t)return i;return this.actions[i++]=t,this.actions[i++]=e,this.actions[i++]=s,i}addActions(t,e,s,i){let{state:h}=t,{parser:r}=t.p,{data:n}=r;for(let o=0;o<2;o++)for(let a=r.stateSlot(h,o?2:1);;a+=3){if(n[a]==65535)if(n[a+1]==1)a=k(n,a+2);else{i==0&&n[a+1]==2&&(i=this.putAction(k(n,a+2),e,s,i));break}n[a]==e&&(i=this.putAction(k(n,a+1),e,s,i))}return i}}class Q{constructor(t,e,s,i){this.parser=t,this.input=e,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 H(e,i),this.tokens=new K(t,this.stream),this.topTerm=t.top[1];let{from:h}=i[0];this.stacks=[v.start(this,t.top[0],h)],this.fragments=s.length&&this.stream.end-h>t.bufferLength*4?new J(s,t.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let t=this.stacks,e=this.minStackPos,s=this.stacks=[],i,h;if(this.bigReductionCount>300&&t.length==1){let[r]=t;for(;r.forceReduce()&&r.stack.length&&r.stack[r.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let r=0;r<t.length;r++){let n=t[r];for(;;){if(this.tokens.mainToken=null,n.pos>e)s.push(n);else{if(this.advanceStack(n,s,t))continue;{i||(i=[],h=[]),i.push(n);let o=this.tokens.getMainToken(n);h.push(o.value,o.end)}}break}}if(!s.length){let r=i&&X(i);if(r)return g&&console.log("Finish with "+this.stackID(r)),this.stackToTree(r);if(this.parser.strict)throw g&&i&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+e);this.recovering||(this.recovering=5)}if(this.recovering&&i){let r=this.stoppedAt!=null&&i[0].pos>this.stoppedAt?i[0]:this.runRecovery(i,h,s);if(r)return g&&console.log("Force-finish "+this.stackID(r)),this.stackToTree(r.forceAll())}if(this.recovering){let r=this.recovering==1?1:this.recovering*3;if(s.length>r)for(s.sort((n,o)=>o.score-n.score);s.length>r;)s.pop();s.some(n=>n.reducePos>e)&&this.recovering--}else if(s.length>1){t:for(let r=0;r<s.length-1;r++){let n=s[r];for(let o=r+1;o<s.length;o++){let a=s[o];if(n.sameState(a)||n.buffer.length>500&&a.buffer.length>500)if((n.score-a.score||n.buffer.length-a.buffer.length)>0)s.splice(o--,1);else{s.splice(r--,1);continue t}}}s.length>12&&(s.sort((r,n)=>n.score-r.score),s.splice(12,s.length-12))}this.minStackPos=s[0].pos;for(let r=1;r<s.length;r++)s[r].pos<this.minStackPos&&(this.minStackPos=s[r].pos);return null}stopAt(t){if(this.stoppedAt!=null&&this.stoppedAt<t)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=t}advanceStack(t,e,s){let i=t.pos,{parser:h}=this,r=g?this.stackID(t)+" -> ":"";if(this.stoppedAt!=null&&i>this.stoppedAt)return t.forceReduce()?t:null;if(this.fragments){let a=t.curContext&&t.curContext.tracker.strict,u=a?t.curContext.hash:0;for(let f=this.fragments.nodeAt(i);f;){let p=this.parser.nodeSet.types[f.type.id]==f.type?h.getGoto(t.state,f.type.id):-1;if(p>-1&&f.length&&(!a||(f.prop(y.contextHash)||0)==u))return t.useNode(f,p),g&&console.log(r+this.stackID(t)+` (via reuse of ${h.getName(f.type.id)})`),!0;if(!(f instanceof S)||f.children.length==0||f.positions[0]>0)break;let c=f.children[0];if(c instanceof S&&f.positions[0]==0)f=c;else break}}let n=h.stateSlot(t.state,4);if(n>0)return t.reduce(n),g&&console.log(r+this.stackID(t)+` (via always-reduce ${h.getName(n&65535)})`),!0;if(t.stack.length>=8400)for(;t.stack.length>6e3&&t.forceReduce(););let o=this.tokens.getActions(t);for(let a=0;a<o.length;){let u=o[a++],f=o[a++],p=o[a++],c=a==o.length||!s,d=c?t:t.split(),b=this.tokens.mainToken;if(d.apply(u,f,b?b.start:d.pos,p),g&&console.log(r+this.stackID(d)+` (via ${(u&65536)==0?"shift":`reduce of ${h.getName(u&65535)}`} for ${h.getName(f)} @ ${i}${d==t?"":", split"})`),c)return!0;d.pos>i?e.push(d):s.push(d)}return!1}advanceFully(t,e){let s=t.pos;for(;;){if(!this.advanceStack(t,null,null))return!1;if(t.pos>s)return B(t,e),!0}}runRecovery(t,e,s){let i=null,h=!1;for(let r=0;r<t.length;r++){let n=t[r],o=e[r<<1],a=e[(r<<1)+1],u=g?this.stackID(n)+" -> ":"";if(n.deadEnd&&(h||(h=!0,n.restart(),g&&console.log(u+this.stackID(n)+" (restarted)"),this.advanceFully(n,s))))continue;let f=n.split(),p=u;for(let c=0;c<10&&f.forceReduce()&&(g&&console.log(p+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,s));c++)g&&(p=this.stackID(f)+" -> ");for(let c of n.recoverByInsert(o))g&&console.log(u+this.stackID(c)+" (via recover-insert)"),this.advanceFully(c,s);this.stream.end>n.pos?(a==n.pos&&(a++,o=0),n.recoverByDelete(o,a),g&&console.log(u+this.stackID(n)+` (via recover-delete ${this.parser.getName(o)})`),B(n,s)):(!i||i.score<f.score)&&(i=f)}return i}stackToTree(t){return t.close(),S.build({buffer:A.create(t),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:t.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(t){let e=(T||(T=new WeakMap)).get(t);return e||T.set(t,e=String.fromCodePoint(this.nextStackID++)),e+t}}function B(l,t){for(let e=0;e<t.length;e++){let s=t[e];if(s.pos==l.pos&&s.sameState(l)){t[e].score<l.score&&(t[e]=l);return}}t.push(l)}class V{constructor(t,e,s){this.source=t,this.flags=e,this.disabled=s}allows(t){return!this.disabled||this.disabled[t]==0}}const C=l=>l;class _{constructor(t){this.start=t.start,this.shift=t.shift||C,this.reduce=t.reduce||C,this.reuse=t.reuse||C,this.hash=t.hash||(()=>0),this.strict=t.strict!==!1}}class w extends L{constructor(t){if(super(),this.wrappers=[],t.version!=14)throw new RangeError(`Parser version (${t.version}) doesn't match runtime version (14)`);let e=t.nodeNames.split(" ");this.minRepeatTerm=e.length;for(let n=0;n<t.repeatNodeCount;n++)e.push("");let s=Object.keys(t.topRules).map(n=>t.topRules[n][1]),i=[];for(let n=0;n<e.length;n++)i.push([]);function h(n,o,a){i[n].push([o,o.deserialize(String(a))])}if(t.nodeProps)for(let n of t.nodeProps){let o=n[0];typeof o=="string"&&(o=y[o]);for(let a=1;a<n.length;){let u=n[a++];if(u>=0)h(u,o,n[a++]);else{let f=n[a+-u];for(let p=-u;p>0;p--)h(n[a++],o,f);a++}}}this.nodeSet=new $(e.map((n,o)=>E.define({name:o>=this.minRepeatTerm?void 0:n,id:o,props:i[o],top:s.indexOf(o)>-1,error:o==0,skipped:t.skippedNodes&&t.skippedNodes.indexOf(o)>-1}))),t.propSources&&(this.nodeSet=this.nodeSet.extend(...t.propSources)),this.strict=!1,this.bufferLength=j;let r=x(t.tokenData);this.context=t.context,this.specializerSpecs=t.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let n=0;n<this.specializerSpecs.length;n++)this.specialized[n]=this.specializerSpecs[n].term;this.specializers=this.specializerSpecs.map(F),this.states=x(t.states,Uint32Array),this.data=x(t.stateData),this.goto=x(t.goto),this.maxTerm=t.maxTerm,this.tokenizers=t.tokenizers.map(n=>typeof n=="number"?new m(r,n):n),this.topRules=t.topRules,this.dialects=t.dialects||{},this.dynamicPrecedences=t.dynamicPrecedences||null,this.tokenPrecTable=t.tokenPrec,this.termNames=t.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(t,e,s){let i=new Q(this,t,e,s);for(let h of this.wrappers)i=h(i,t,e,s);return i}getGoto(t,e,s=!1){let i=this.goto;if(e>=i[0])return-1;for(let h=i[e+1];;){let r=i[h++],n=r&1,o=i[h++];if(n&&s)return o;for(let a=h+(r>>1);h<a;h++)if(i[h]==t)return o;if(n)return-1}}hasAction(t,e){let s=this.data;for(let i=0;i<2;i++)for(let h=this.stateSlot(t,i?2:1),r;;h+=3){if((r=s[h])==65535)if(s[h+1]==1)r=s[h=k(s,h+2)];else{if(s[h+1]==2)return k(s,h+2);break}if(r==e||r==0)return k(s,h+1)}return 0}stateSlot(t,e){return this.states[t*6+e]}stateFlag(t,e){return(this.stateSlot(t,0)&e)>0}validAction(t,e){return!!this.allActions(t,s=>s==e?!0:null)}allActions(t,e){let s=this.stateSlot(t,4),i=s?e(s):void 0;for(let h=this.stateSlot(t,1);i==null;h+=3){if(this.data[h]==65535)if(this.data[h+1]==1)h=k(this.data,h+2);else break;i=e(k(this.data,h+1))}return i}nextStates(t){let e=[];for(let s=this.stateSlot(t,1);;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=k(this.data,s+2);else break;if((this.data[s+2]&1)==0){let i=this.data[s+1];e.some((h,r)=>r&1&&h==i)||e.push(this.data[s],i)}}return e}configure(t){let e=Object.assign(Object.create(w.prototype),this);if(t.props&&(e.nodeSet=this.nodeSet.extend(...t.props)),t.top){let s=this.topRules[t.top];if(!s)throw new RangeError(`Invalid top rule name ${t.top}`);e.top=s}return t.tokenizers&&(e.tokenizers=this.tokenizers.map(s=>{let i=t.tokenizers.find(h=>h.from==s);return i?i.to:s})),t.specializers&&(e.specializers=this.specializers.slice(),e.specializerSpecs=this.specializerSpecs.map((s,i)=>{let h=t.specializers.find(n=>n.from==s.external);if(!h)return s;let r=Object.assign(Object.assign({},s),{external:h.to});return e.specializers[i]=F(r),r})),t.contextTracker&&(e.context=t.contextTracker),t.dialect&&(e.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(e.strict=t.strict),t.wrap&&(e.wrappers=e.wrappers.concat(t.wrap)),t.bufferLength!=null&&(e.bufferLength=t.bufferLength),e}hasWrappers(){return this.wrappers.length>0}getName(t){return this.termNames?this.termNames[t]:String(t<=this.maxNode&&this.nodeSet.types[t].name||t)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(t){let e=this.dynamicPrecedences;return e==null?0:e[t]||0}parseDialect(t){let e=Object.keys(this.dialects),s=e.map(()=>!1);if(t)for(let h of t.split(" ")){let r=e.indexOf(h);r>=0&&(s[r]=!0)}let i=null;for(let h=0;h<e.length;h++)if(!s[h])for(let r=this.dialects[e[h]],n;(n=this.data[r++])!=65535;)(i||(i=new Uint8Array(this.maxTerm+1)))[n]=1;return new V(t,s,i)}static deserialize(t){return new w(t)}}function k(l,t){return l[t]|l[t+1]<<16}function X(l){let t=null;for(let e of l){let s=e.p.stoppedAt;(e.pos==e.p.stream.end||s!=null&&e.pos>s)&&e.p.parser.stateFlag(e.state,2)&&(!t||t.score<e.score)&&(t=e)}return t}function F(l){if(l.external){let t=l.extend?1:0;return(e,s)=>l.external(e,s)<<1|t}return l.get}export{_ as C,Z as E,w as L,W as a};
|