p3x-redis-ui-material
Version:
💿 P3X Redis UI triple frontend — Angular + React/MUI + Vue/Vuetify with 54 languages, 7 themes, Socket.IO, desktop notifications, and full feature parity
1 lines • 52.9 kB
JavaScript
import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{b as t,d as n,l as r,m as i,o as a,p as o,s,u as c,y as l}from"./dist-CXQINIyJ.js";import{a as u,d,g as f,i as p,l as m,n as h,o as g,r as _,t as v}from"./dist-BKX20y_2.js";var ee=1024,te=0,y=class{constructor(e,t){this.from=e,this.to=t}},b=class{constructor(e={}){this.id=te++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw Error(`This node type doesn't define a deserialize function`)}),this.combine=e.combine||null}add(e){if(this.perNode)throw RangeError(`Can't add per-node props to node types`);return typeof e!=`function`&&(e=C.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};b.closedBy=new b({deserialize:e=>e.split(` `)}),b.openedBy=new b({deserialize:e=>e.split(` `)}),b.group=new b({deserialize:e=>e.split(` `)}),b.isolate=new b({deserialize:e=>{if(e&&e!=`rtl`&&e!=`ltr`&&e!=`auto`)throw RangeError(`Invalid value for isolate: `+e);return e||`auto`}}),b.contextHash=new b({perNode:!0}),b.lookAhead=new b({perNode:!0}),b.mounted=new b({perNode:!0});var x=class{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[b.mounted.id]}},S=Object.create(null),C=class e{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(t){let n=t.props&&t.props.length?Object.create(null):S,r=!!t.top|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new e(t.name||``,n,t.id,r);if(t.props){for(let e of t.props)if(Array.isArray(e)||(e=e(i)),e){if(e[0].perNode)throw RangeError(`Can't store a per-node prop on a node type`);n[e[0].id]=e[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(b.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(` `))t[r]=e[n];return e=>{for(let n=e.prop(b.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}};C.none=new C(``,Object.create(null),0,8);var w=class e{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw RangeError(`Node type ids should correspond to array positions when creating a node set`)}extend(...t){let n=[];for(let e of this.types){let r=null;for(let n of t){let t=n(e);if(t){r||=Object.assign({},e.props);let n=t[1],i=t[0];i.combine&&i.id in r&&(n=i.combine(r[i.id],n)),r[i.id]=n}}n.push(r?new C(e.name,r,e.id,e.flags):e)}return new e(n)}},T=new WeakMap,E=new WeakMap,D;(function(e){e[e.ExcludeBuffers=1]=`ExcludeBuffers`,e[e.IncludeAnonymous=2]=`IncludeAnonymous`,e[e.IgnoreMounts=4]=`IgnoreMounts`,e[e.IgnoreOverlays=8]=`IgnoreOverlays`,e[e.EnterBracketed=16]=`EnterBracketed`})(D||={});var O=class e{constructor(e,t,n,r,i){if(this.type=e,this.children=t,this.positions=n,this.length=r,this.props=null,i&&i.length){this.props=Object.create(null);for(let[e,t]of i)this.props[typeof e==`number`?e:e.id]=t}}toString(){let e=x.get(this);if(e&&!e.overlay)return e.tree.toString();let t=``;for(let e of this.children){let n=e.toString();n&&(t&&(t+=`,`),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?`(`+t+`)`:``):t}cursor(e=0){return new fe(this.topNode,e)}cursorAt(e,t=0,n=0){let r=new fe(T.get(this)||this.topNode);return r.moveTo(e,t),T.set(this,r._tree),r}get topNode(){return new j(this,0,0,null)}resolve(e,t=0){let n=A(T.get(this)||this.topNode,e,t,!1);return T.set(this,n),n}resolveInner(e,t=0){let n=A(E.get(this)||this.topNode,e,t,!0);return E.set(this,n),n}resolveStack(e,t=0){return de(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,a=e.mode||0,o=(a&D.IncludeAnonymous)>0;for(let e=this.cursor(a|D.IncludeAnonymous);;){let a=!1;if(e.from<=i&&e.to>=r&&(!o&&e.type.isAnonymous||t(e)!==!1)){if(e.firstChild())continue;a=!0}for(;a&&n&&(o||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;a=!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(t={}){return this.children.length<=8?this:ge(C.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new e(this.type,t,n,r,this.propValues),t.makeTree||((t,n,r)=>new e(C.none,t,n,r)))}static build(e){return me(e)}};O.empty=new O(C.none,[],[],0);var ne=class e{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 e(this.buffer,this.index)}},k=class e{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return C.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(`,`)}childString(e){let t=this.buffer[e],n=this.buffer[e+3],r=this.set.types[t],i=r.name;if(/\W/.test(i)&&!r.isError&&(i=JSON.stringify(i)),e+=4,n==e)return i;let a=[];for(;e<n;)a.push(this.childString(e)),e=this.buffer[e+3];return i+`(`+a.join(`,`)+`)`}findChild(e,t,n,r,i){let{buffer:a}=this,o=-1;for(let s=e;s!=t&&!(re(i,r,a[s+1],a[s+2])&&(o=s,n>0));s=a[s+3]);return o}slice(t,n,r){let i=this.buffer,a=new Uint16Array(n-t),o=0;for(let e=t,s=0;e<n;){a[s++]=i[e++],a[s++]=i[e++]-r;let n=a[s++]=i[e++]-r;a[s++]=i[e++]-t,o=Math.max(o,n)}return new e(a,o,this.set)}};function re(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function A(e,t,n,r){for(;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!r&&e instanceof j&&e.index<0?null:e.parent;if(!t)return e;e=t}let i=r?0:D.IgnoreOverlays;if(r)for(let r=e,a=r.parent;a;r=a,a=r.parent)r instanceof j&&r.index<0&&a.enter(t,n,i)?.from!=r.from&&(e=a);for(;;){let r=e.enter(t,n,i);if(!r)return e;e=r}}var ie=class{cursor(e=0){return new fe(this,e)}getChild(e,t=null,n=null){let r=ae(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return ae(this,e,t,n)}resolve(e,t=0){return A(this,e,t,!1)}resolveInner(e,t=0){return A(this,e,t,!0)}matchContext(e){return oe(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}},j=class e extends ie{constructor(e,t,n,r){super(),this._tree=e,this.from=t,this.index=n,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,n,r,i,a=0){for(let o=this;;){for(let{children:s,positions:c}=o._tree,l=n>0?s.length:-1;t!=l;t+=n){let l=s[t],u=c[t]+o.from,d;if(!(!(a&D.EnterBracketed&&l instanceof O&&(d=x.get(l))&&!d.overlay&&d.bracketed&&r>=u&&r<=u+l.length)&&!re(i,r,u,u+l.length))){if(l instanceof k){if(a&D.ExcludeBuffers)continue;let e=l.findChild(0,l.buffer.length,n,r-u,i);if(e>-1)return new ce(new se(o,l,t,u),null,e)}else if(a&D.IncludeAnonymous||!l.type.isAnonymous||pe(l)){let s;if(!(a&D.IgnoreMounts)&&(s=x.get(l))&&!s.overlay)return new e(s.tree,u,t,o);let c=new e(l,u,t,o);return a&D.IncludeAnonymous||!c.type.isAnonymous?c:c.nextChild(n<0?l.children.length-1:0,n,r,i,a)}}}if(a&D.IncludeAnonymous||!o.type.isAnonymous||(t=o.index>=0?o.index+n:n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(t,n,r=0){let i;if(!(r&D.IgnoreOverlays)&&(i=x.get(this._tree))&&i.overlay){let a=t-this.from,o=r&D.EnterBracketed&&i.bracketed;for(let{from:t,to:r}of i.overlay)if((n>0||o?t<=a:t<a)&&(n<0||o?r>=a:r>a))return new e(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,n,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 ae(e,t,n,r){let i=e.cursor(),a=[];if(!i.firstChild())return a;if(n!=null){for(let e=!1;!e;)if(e=i.type.is(n),!i.nextSibling())return a}for(;;){if(r!=null&&i.type.is(r))return a;if(i.type.is(t)&&a.push(i.node),!i.nextSibling())return r==null?a:[]}}function oe(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}var se=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},ce=class e extends ie{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(t,n,r){let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return a<0?null:new e(this.context,this,a)}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(t,n,r=0){if(r&D.ExcludeBuffers)return null;let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return a<0?null:new e(this.context,this,a)}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:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new e(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new e(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let a=n.buffer[this.index+1];e.push(n.slice(r,i,a)),t.push(0)}return new O(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function le(e){if(!e.length)return null;let t=0,n=e[0];for(let r=1;r<e.length;r++){let i=e[r];(i.from>n.from||i.to<n.to)&&(n=i,t=r)}let r=n instanceof j&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new ue(i,n)}var ue=class{constructor(e,t){this.heads=e,this.node=t}get next(){return le(this.heads)}};function de(e,t,n){let r=e.resolveInner(t,n),i=null;for(let e=r instanceof j?r:r.context.parent;e;e=e.parent)if(e.index<0){let a=e.parent;(i||=[r]).push(a.resolve(t,n)),e=a}else{let a=x.get(e.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){let o=new j(a.tree,a.overlay[0].from+e.from,-1,e);(i||=[r]).push(A(o,t,n,!1))}}return i?le(i):r}var fe=class{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&~D.EnterBracketed,e instanceof j)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof j?(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,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&D.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&D.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&D.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,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(r.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=r)}else({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&D.IncludeAnonymous||e instanceof k||!e.type.isAnonymous||pe(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)scan:for(let r=this.index,i=this.stack.length;i>=0;){for(let a=e;a;a=a._parent)if(a.index==r){if(r==this.index)return a;t=a,n=i+1;break scan}r=this.stack[--i]}for(let e=n;e<this.stack.length;e++)t=new ce(this.buffer,t,this.stack[e]);return this.bufferNode=new ce(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return oe(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return oe(this._tree,e,r);let a=n[t.buffer[this.stack[i]]];if(!a.isAnonymous){if(e[r]&&e[r]!=a.name)return!1;r--}}return!0}};function pe(e){return e.children.some(e=>e instanceof k||!e.type.isAnonymous||pe(e))}function me(e){let{buffer:t,nodeSet:n,maxBufferLength:r=ee,reused:i=[],minRepeatType:a=n.types.length}=e,o=Array.isArray(t)?new ne(t,t.length):t,s=n.types,c=0,l=0;function u(e,t,_,v,ee,te){let{id:y,start:b,end:x,size:S}=o,C=l,w=c;if(S<0)if(o.next(),S==-1){let t=i[y];_.push(t),v.push(b-e);return}else if(S==-3){c=y;return}else if(S==-4){l=y;return}else throw RangeError(`Unrecognized record size: ${S}`);let T=s[y],E,D,O=b-e;if(x-b<=r&&(D=h(o.pos-t,ee))){let t=new Uint16Array(D.size-D.skip),r=o.pos-D.size,i=t.length;for(;o.pos>r;)i=g(D.start,t,i);E=new k(t,x-D.start,n),O=D.start-e}else{let e=o.pos-S;o.next();let t=[],n=[],i=y>=a?y:-1,s=0,c=x;for(;o.pos>e;)i>=0&&o.id==i&&o.size>=0?(o.end<=c-r&&(p(t,n,b,s,o.end,c,i,C,w),s=t.length,c=o.end),o.next()):te>2500?d(b,e,t,n):u(b,e,t,n,i,te+1);if(i>=0&&s>0&&s<t.length&&p(t,n,b,s,b,c,i,C,w),t.reverse(),n.reverse(),i>-1&&s>0){let e=f(T,w);E=ge(T,t,n,0,t.length,0,x-b,e,e)}else E=m(T,t,n,x-b,C-x,w)}_.push(E),v.push(O)}function d(e,t,i,a){let s=[],c=0,l=-1;for(;o.pos>t;){let{id:e,start:t,end:n,size:i}=o;if(i>4)o.next();else if(l>-1&&t<l)break;else l<0&&(l=n-r),s.push(e,t,n),c++,o.next()}if(c){let t=new Uint16Array(c*4),r=s[s.length-2];for(let e=s.length-3,n=0;e>=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-r,t[n++]=s[e+2]-r,t[n++]=n;i.push(new k(t,s[2]-r,n)),a.push(r-e)}}function f(e,t){return(n,r,i)=>{let a=0,o=n.length-1,s,c;if(o>=0&&(s=n[o])instanceof O){if(!o&&s.type==e&&s.length==i)return s;(c=s.prop(b.lookAhead))&&(a=r[o]+s.length+c)}return m(e,n,r,i,a,t)}}function p(e,t,r,i,a,o,s,c,l){let u=[],d=[];for(;e.length>i;)u.push(e.pop()),d.push(t.pop()+r-a);e.push(m(n.types[s],u,d,o-a,c-o,l)),t.push(a-r)}function m(e,t,n,r,i,a,o){if(a){let e=[b.contextHash,a];o=o?[e].concat(o):[e]}if(i>25){let e=[b.lookAhead,i];o=o?[e].concat(o):[e]}return new O(e,t,n,r,o)}function h(e,t){let n=o.fork(),i=0,s=0,c=0,l=n.end-r,u={size:0,start:0,skip:0};scan:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){u.size=i,u.start=s,u.skip=c,c+=4,i+=4,n.next();continue}let o=n.pos-e;if(e<0||o<r||n.start<l)break;let d=n.id>=a?4:0,f=n.start;for(n.next();n.pos>o;){if(n.size<0)if(n.size==-3||n.size==-4)d+=4;else break scan;else n.id>=a&&(d+=4);n.next()}s=f,i+=e,c+=d}return(t<0||i==e)&&(u.size=i,u.start=s,u.skip=c),u.size>4?u:void 0}function g(e,t,n){let{id:r,start:i,end:s,size:u}=o;if(o.next(),u>=0&&r<a){let a=n;if(u>4){let r=o.pos-(u-4);for(;o.pos>r;)n=g(e,t,n)}t[--n]=a,t[--n]=s-e,t[--n]=i-e,t[--n]=r}else u==-3?c=r:u==-4&&(l=r);return n}let _=[],v=[];for(;o.pos>0;)u(e.start||0,e.bufferStart||0,_,v,-1,0);let te=e.length??(_.length?v[0]+_[0].length:0);return new O(s[e.topID],_.reverse(),v.reverse(),te)}var he=new WeakMap;function M(e,t){if(!e.isAnonymous||t instanceof k||t.type!=e)return 1;let n=he.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof O)){n=1;break}n+=M(e,r)}he.set(t,n)}return n}function ge(e,t,n,r,i,a,o,s,c){let l=0;for(let n=r;n<i;n++)l+=M(e,t[n]);let u=Math.ceil(l*1.5/8),d=[],f=[];function p(t,n,r,i,o){for(let s=r;s<i;){let r=s,l=n[s],m=M(e,t[s]);for(s++;s<i;s++){let n=M(e,t[s]);if(m+n>=u)break;m+=n}if(s==r+1){if(m>u){let e=t[r];p(e.children,e.positions,0,e.children.length,n[r]+o);continue}d.push(t[r])}else{let i=n[s-1]+t[s-1].length-l;d.push(ge(e,t,n,r,s,l,i,null,c))}f.push(l+o-a)}}return p(t,n,r,i,0),(s||c)(d,f,o)}var _e=class e{constructor(e,t,n,r,i=!1,a=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=!!i|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],r=!1){let i=[new e(0,t.length,t,0,!1,r)];for(let e of n)e.to>t.length&&i.push(e);return i}static applyChanges(t,n,r=128){if(!n.length)return t;let i=[],a=1,o=t.length?t[0]:null;for(let s=0,c=0,l=0;;s++){let u=s<n.length?n[s]:null,d=u?u.fromA:1e9;if(d-c>=r)for(;o&&o.from<d;){let n=o;if(c>=n.from||d<=n.to||l){let t=Math.max(n.from,c)-l,r=Math.min(n.to,d)-l;n=t>=r?null:new e(t,r,n.tree,n.offset+l,s>0,!!u)}if(n&&i.push(n),o.to>d)break;o=a<t.length?t[a++]:null}if(!u)break;c=u.toA,l=u.toA-u.toB}return i}},ve=class{startParse(e,t,n){return typeof e==`string`&&(e=new ye(e)),n=n?n.length?n.map(e=>new y(e.from,e.to)):[new y(0,0)]:[new y(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}},ye=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};new b({perNode:!0});var be=0,N=class e{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=be++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(t,n){let r=typeof t==`string`?t:`?`;if(t instanceof e&&(n=t),n?.base)throw Error(`Can not derive from a modified tag`);let i=new e(r,[],null,[]);if(i.set.push(i),n)for(let e of n.set)i.set.push(e);return i}static defineModifier(e){let t=new Se(e);return e=>e.modified.indexOf(t)>-1?e:Se.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}},xe=0,Se=class e{constructor(e){this.name=e,this.instances=[],this.id=xe++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(e=>e.base==t&&Ce(n,e.modified));if(r)return r;let i=[],a=new N(t.name,i,t,n);for(let e of n)e.instances.push(a);let o=we(n);for(let n of t.set)if(!n.modified.length)for(let t of o)i.push(e.get(n,t));return a}};function Ce(e,t){return e.length==t.length&&e.every((e,n)=>e==t[n])}function we(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((e,t)=>t.length-e.length)}function Te(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(` `))if(e){let n=[],i=2,a=e;for(let t=0;;){if(a==`...`&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!r)throw RangeError(`Invalid path: `+e);if(n.push(r[0]==`*`?``:r[0][0]==`"`?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let o=e[t++];if(t==e.length&&o==`!`){i=0;break}if(o!=`/`)throw RangeError(`Invalid path: `+e);a=e.slice(t)}let o=n.length-1,s=n[o];if(!s)throw RangeError(`Invalid path: `+e);t[s]=new P(r,i,o>0?n.slice(0,o):null).sort(t[s])}}return Ee.add(t)}var Ee=new b({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth>=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let a=new P(i.tags,i.mode,i.context);n?n.next=a:r=a,n=a}return r}}),P=class{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}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}};P.empty=new P([],2,null);function De(e,t){let n=Object.create(null);for(let t of e)if(!Array.isArray(t.tag))n[t.tag.id]=t.class;else for(let e of t.tag)n[e.id]=t.class;let{scope:r,all:i=null}=t||{};return{style:e=>{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+` `+r:r;break}}return t},scope:r}}function Oe(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+` `+e:e)}return n}function ke(e,t,n,r=0,i=e.length){let a=new Ae(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,``,a.highlighters),a.flush(i)}var Ae=class{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=``}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,i){let{type:a,from:o,to:s}=e;if(o>=n||s<=t)return;a.isTop&&(i=this.highlighters.filter(e=>!e.scope||e.scope(a)));let c=r,l=je(e)||P.empty,u=Oe(i,l.tags);if(u&&(c&&(c+=` `),c+=u,l.mode==1&&(r+=(r?` `:``)+u)),this.startSpan(Math.max(t,o),c),l.opaque)return;let d=e.tree&&e.tree.prop(b.mounted);if(d&&d.overlay){let a=e.node.enter(d.overlay[0].from+o,1),l=this.highlighters.filter(e=>!e.scope||e.scope(d.tree.type)),u=e.firstChild();for(let f=0,p=o;;f++){let m=f<d.overlay.length?d.overlay[f]:null,h=m?m.from+o:s,g=Math.max(t,p),_=Math.min(n,h);if(g<_&&u)for(;e.from<_&&(this.highlightRange(e,g,_,r,i),this.startSpan(Math.min(_,e.to),c),!(e.to>=h||!e.nextSibling())););if(!m||h>n)break;p=m.to+o,p>t&&(this.highlightRange(a.cursor(),Math.max(t,m.from+o),Math.min(n,p),``,l),this.startSpan(Math.min(n,p),c))}u&&e.parent()}else if(e.firstChild()){d&&(r=``);do{if(e.to<=t)continue;if(e.from>=n)break;this.highlightRange(e,t,n,r,i),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}};function je(e){let t=e.type.prop(Ee);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}var F=N.define,Me=F(),I=F(),Ne=F(I),Pe=F(I),L=F(),Fe=F(L),Ie=F(L),R=F(),z=F(R),B=F(),V=F(),Le=F(),H=F(Le),Re=F(),U={comment:Me,lineComment:F(Me),blockComment:F(Me),docComment:F(Me),name:I,variableName:F(I),typeName:Ne,tagName:F(Ne),propertyName:Pe,attributeName:F(Pe),className:F(I),labelName:F(I),namespace:F(I),macroName:F(I),literal:L,string:Fe,docString:F(Fe),character:F(Fe),attributeValue:F(Fe),number:Ie,integer:F(Ie),float:F(Ie),bool:F(L),regexp:F(L),escape:F(L),color:F(L),url:F(L),keyword:B,self:F(B),null:F(B),atom:F(B),unit:F(B),modifier:F(B),operatorKeyword:F(B),controlKeyword:F(B),definitionKeyword:F(B),moduleKeyword:F(B),operator:V,derefOperator:F(V),arithmeticOperator:F(V),logicOperator:F(V),bitwiseOperator:F(V),compareOperator:F(V),updateOperator:F(V),definitionOperator:F(V),typeOperator:F(V),controlOperator:F(V),punctuation:Le,separator:F(Le),bracket:H,angleBracket:F(H),squareBracket:F(H),paren:F(H),brace:F(H),content:R,heading:z,heading1:F(z),heading2:F(z),heading3:F(z),heading4:F(z),heading5:F(z),heading6:F(z),contentSeparator:F(R),list:F(R),quote:F(R),emphasis:F(R),strong:F(R),link:F(R),monospace:F(R),strikethrough:F(R),inserted:F(),deleted:F(),changed:F(),invalid:F(),meta:Re,documentMeta:F(Re),annotation:F(Re),processingInstruction:F(Re),definition:N.defineModifier(`definition`),constant:N.defineModifier(`constant`),function:N.defineModifier(`function`),standard:N.defineModifier(`standard`),local:N.defineModifier(`local`),special:N.defineModifier(`special`)};for(let e in U){let t=U[e];t instanceof N&&(t.name=e)}De([{tag:U.link,class:`tok-link`},{tag:U.heading,class:`tok-heading`},{tag:U.emphasis,class:`tok-emphasis`},{tag:U.strong,class:`tok-strong`},{tag:U.keyword,class:`tok-keyword`},{tag:U.atom,class:`tok-atom`},{tag:U.bool,class:`tok-bool`},{tag:U.url,class:`tok-url`},{tag:U.labelName,class:`tok-labelName`},{tag:U.inserted,class:`tok-inserted`},{tag:U.deleted,class:`tok-deleted`},{tag:U.literal,class:`tok-literal`},{tag:U.string,class:`tok-string`},{tag:U.number,class:`tok-number`},{tag:[U.regexp,U.escape,U.special(U.string)],class:`tok-string2`},{tag:U.variableName,class:`tok-variableName`},{tag:U.local(U.variableName),class:`tok-variableName tok-local`},{tag:U.definition(U.variableName),class:`tok-variableName tok-definition`},{tag:U.special(U.variableName),class:`tok-variableName2`},{tag:U.definition(U.propertyName),class:`tok-propertyName tok-definition`},{tag:U.typeName,class:`tok-typeName`},{tag:U.namespace,class:`tok-namespace`},{tag:U.className,class:`tok-className`},{tag:U.macroName,class:`tok-macroName`},{tag:U.propertyName,class:`tok-propertyName`},{tag:U.operator,class:`tok-operator`},{tag:U.comment,class:`tok-comment`},{tag:U.meta,class:`tok-meta`},{tag:U.invalid,class:`tok-invalid`},{tag:U.punctuation,class:`tok-punctuation`}]);var ze=e({DocInput:()=>We,HighlightStyle:()=>Wt,IndentContext:()=>rt,LRLanguage:()=>Ue,Language:()=>G,LanguageSupport:()=>Ze,ParseContext:()=>Ge,TreeIndentContext:()=>ut,bracketMatching:()=>cn,bracketMatchingHandle:()=>ln,codeFolding:()=>It,continuedIndent:()=>mt,defaultHighlightStyle:()=>Zt,defineLanguageFacet:()=>Be,foldAll:()=>jt,foldCode:()=>Ot,foldEffect:()=>X,foldGutter:()=>Ht,foldInside:()=>yt,foldKeymap:()=>Nt,foldNodeProp:()=>vt,foldService:()=>_t,foldState:()=>Q,foldable:()=>Y,getIndentUnit:()=>et,getIndentation:()=>nt,indentNodeProp:()=>it,indentOnInput:()=>gt,indentService:()=>Qe,indentString:()=>tt,indentUnit:()=>$e,language:()=>J,languageDataProp:()=>W,matchBrackets:()=>$,sublanguageProp:()=>Ve,syntaxHighlighting:()=>Jt,syntaxTree:()=>K,unfoldAll:()=>Mt,unfoldCode:()=>kt,unfoldEffect:()=>Z}),W=new b;function Be(e){return s.define({combine:e?t=>t.concat(e):void 0})}var Ve=new b,G=class{constructor(e,t,n=[],r=``){this.data=e,this.name=r,a.prototype.hasOwnProperty(`tree`)||Object.defineProperty(a.prototype,"tree",{get(){return K(this)}}),this.parser=t,this.extension=[J.of(this),a.languageData.of((e,t,n)=>{let r=He(e,t,n),i=r.type.prop(W);if(!i)return[];let a=e.facet(i),o=r.type.prop(Ve);if(o){let i=r.resolve(t-r.from,n);for(let t of o)if(t.test(i,e)){let n=e.facet(t.facet);return t.type==`replace`?n:n.concat(a)}}return a})].concat(n)}isActiveAt(e,t,n=-1){return He(e,t,n).type.prop(W)==this.data}findRegions(e){let t=e.facet(J);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(e,t)=>{if(e.prop(W)==this.data){n.push({from:t,to:t+e.length});return}let i=e.prop(b.mounted);if(i){if(i.tree.prop(W)==this.data){if(i.overlay)for(let e of i.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}else if(i.overlay){let e=n.length;if(r(i.tree,i.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let i=e.children[n];i instanceof O&&r(i,e.positions[n]+t)}};return r(K(e),0),n}get allowsNesting(){return!0}};G.setState=o.define();function He(e,t,n){let r=e.facet(J),i=K(e).topNode;if(!r||r.allowsNesting)for(let e=i;e;e=e.enter(t,n,D.ExcludeBuffers|D.EnterBracketed))e.type.isTop&&(i=e);return i}var Ue=class e extends G{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(t){let n=Be(t.languageData);return new e(n,t.parser.configure({props:[W.add(e=>e.isTop?n:void 0)]}),t.name)}configure(t,n){return new e(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function K(e){let t=e.field(G.state,!1);return t?t.tree:O.empty}var We=class{constructor(e){this.doc=e,this.cursorPos=0,this.string=``,this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},q=null,Ge=class e{constructor(e,t,n=[],r,i,a,o,s){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=i,this.viewport=a,this.skipped=o,this.scheduleOn=s,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new e(t,n,[],O.empty,0,r,[],null)}startParse(){return this.parser.startParse(new We(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=O.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{if(typeof e==`number`){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||=this.startParse(),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let n=this.parse.advance();if(n)if(this.fragments=this.withoutTempSkipped(_e.addTree(n,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=this.parse.stoppedAt??this.state.doc.length,this.tree=n,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(_e.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=q;q=this;try{return e()}finally{q=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Ke(e,t.from,t.to);return e}changes(t,n){let{fragments:r,tree:i,treeLen:a,viewport:o,skipped:s}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,n,r,i)=>e.push({fromA:t,toA:n,fromB:r,toB:i})),r=_e.applyChanges(r,e),i=O.empty,a=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){s=[];for(let e of this.skipped){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);n<r&&s.push({from:n,to:r})}}}return new e(this.parser,n,r,i,a,o,s,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let t=0;t<this.skipped.length;t++){let{from:n,to:r}=this.skipped[t];n<e.to&&r>e.from&&(this.fragments=Ke(this.fragments,n,r),this.skipped.splice(t--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&=(this.takeTree(),null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends ve{createParse(t,n,r){let i=r[0].from,a=r[r.length-1].to;return{parsedPos:i,advance(){let t=q;if(t){for(let e of r)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=a,new O(C.none,[],[],a-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return q}};function Ke(e,t,n){return _e.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var qe=class e{constructor(e){this.context=e,this.tree=e.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new e(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=Ge.create(t.facet(J).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new e(r)}};G.state=i.define({create:qe.init,update(e,t){for(let e of t.effects)if(e.is(G.setState))return e.value;return t.startState.facet(J)==t.state.facet(J)?e.apply(t):qe.init(t.state)}});var Je=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<`u`&&(Je=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var Ye=typeof navigator<`u`&&navigator.scheduling?.isInputPending?()=>navigator.scheduling.isInputPending():null,Xe=u.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(G.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(G.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=Je(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:r}}=this.view,i=n.field(G.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,e&&!Ye?Math.max(25,e.timeRemaining()-5):1e9),o=i.context.treeLen<r&&n.doc.length>r+1e3,s=i.context.work(()=>Ye&&Ye()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-t,(s||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:G.setState.of(new qe(i.context))})),this.chunkBudget>0&&!(s&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&=(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>d(this.view.state,e)).then(()=>this.workScheduled--),null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),J=s.define({combine(e){return e.length?e[0]:null},enables:e=>[G.state,Xe,_.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),Ze=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},Qe=s.define(),$e=s.define({combine:e=>{if(!e.length)return` `;let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw Error(`Invalid indent unit: `+JSON.stringify(e[0]));return t}});function et(e){let t=e.facet($e);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function tt(e,t){let n=``,r=e.tabSize,i=e.facet($e)[0];if(i==` `){for(;t>=r;)n+=` `,t-=r;i=` `}for(let e=0;e<t;e++)n+=i;return n}function nt(e,t){e instanceof a&&(e=new rt(e));for(let n of e.state.facet(Qe)){let r=n(e,t);if(r!==void 0)return r}let n=K(e.state);return n.length>=t?at(e,n,t):null}var rt=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=et(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return r!=null&&r>=n.from&&r<=n.to?i&&r==e?{text:``,from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return``;let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.countColumn(n,e-r),a=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return a>-1&&(i+=a-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,n=e.length){return t(e,this.state.tabSize,n)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let e=i(r);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},it=new b;function at(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let e=[];for(let t=i;t&&!(t.from<r.node.from||t.to>r.node.to||t.from==r.node.from&&t.type==r.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)r={node:e[t],next:r}}return ot(r,e,n)}function ot(e,t,n){for(let r=e;r;r=r.next){let e=ct(r.node);if(e)return e(ut.create(t,n,r))}return 0}function st(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function ct(e){let t=e.type.prop(it);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(b.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>pt(e,!0,1,void 0,n&&!st(e)?t.from:void 0)}return e.parent==null?lt:null}function lt(){return 0}var ut=class e extends rt{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(t,n,r){return new e(t,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(dt(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return ot(this.context.next,this.base,this.pos)}};function dt(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function ft(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,a=e.state.doc.lineAt(n.from),o=i==null||i<=a.from?a.to:Math.min(a.to,i);for(let e=n.to;;){let i=t.childAfter(e);if(!i||i==r)return null;if(!i.type.isSkipped){if(i.from>=o)return null;let e=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+e}}e=i.to}}function pt(e,t,n,r,i){let a=e.textAfter,o=a.match(/^\s*/)[0].length,s=r&&a.slice(o,o+r.length)==r||i==e.pos+o,c=t?ft(e):null;return c?s?e.column(c.from):e.column(c.to):e.baseIndent+(s?0:e.unit*n)}function mt({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}var ht=200;function gt(){return a.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent(`input.type`)&&!e.isUserEvent(`input.complete`))return e;let t=e.startState.languageDataAt(`indentOnInput`,e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:r}=e.newSelection.main,i=n.lineAt(r);if(r>i.from+ht)return e;let a=n.sliceString(i.from,r);if(!t.some(e=>e.test(a)))return e;let{state:o}=e,s=-1,c=[];for(let{head:e}of o.selection.ranges){let t=o.doc.lineAt(e);if(t.from==s)continue;s=t.from;let n=nt(o,t.from);if(n==null)continue;let r=/^\s*/.exec(t.text)[0],i=tt(o,n);r!=i&&c.push({from:t.from,to:t.from+r.length,insert:i})}return c.length?[e,{changes:c,sequential:!0}]:e})}var _t=s.define(),vt=new b;function yt(e){let t=e.firstChild,n=e.lastChild;return t&&t.to<n.from?{from:t.to,to:n.type.isError?e.to:n.from}:null}function bt(e,t,n){let r=K(e);if(r.length<n)return null;let i=r.resolveStack(n,1),a=null;for(let o=i;o;o=o.next){let i=o.node;if(i.to<=n||i.from>n)continue;if(a&&i.from<t)break;let s=i.type.prop(vt);if(s&&(i.to<r.length-50||r.length==e.doc.length||!xt(i))){let r=s(i,e);r&&r.from<=n&&r.from>=t&&r.to>n&&(a=r)}}return a}function xt(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function Y(e,t,n){for(let r of e.facet(_t)){let i=r(e,t,n);if(i)return i}return bt(e,t,n)}function St(e,t){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);return n>=r?void 0:{from:n,to:r}}var X=o.define({map:St}),Z=o.define({map:St});function Ct(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(e=>e.from<=n&&e.to>=n)||t.push(e.lineBlockAt(n));return t}var Q=i.define({create(){return v.none},update(e,t){t.isUserEvent(`delete`)&&t.changes.iterChangedRanges((t,n)=>e=wt(e,t,n)),e=e.map(t.changes);for(let n of t.effects)if(n.is(X)&&!Et(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(Ft),i=r?v.replace({widget:new zt(r(t.state,n.value))}):Rt;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(Z)&&(e=e.update({filter:(e,t)=>n.value.from!=e||n.value.to!=t,filterFrom:n.value.from,filterTo:n.value.to}));return t.selection&&(e=wt(e,t.selection.main.head)),e},provide:e=>_.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(e,t)=>{n.push(e,t)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw RangeError(`Invalid JSON for fold state`);let t=[];for(let n=0;n<e.length;){let r=e[n++],i=e[n++];if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid JSON for fold state`);t.push(Rt.range(r,i))}return v.set(t,!0)}});function wt(e,t,n=t){let r=!1;return e.between(t,n,(e,i)=>{e<n&&i>t&&(r=!0)}),r?e.update({filterFrom:t,filterTo:n,filter:(e,r)=>e>=n||r<=t}):e}function Tt(e,t,n){var r;let i=null;return(r=e.field(Q,!1))==null||r.between(t,n,(e,t)=>{(!i||i.from>e)&&(i={from:e,to:t})}),i}function Et(e,t,n){let r=!1;return e.between(t,t,(e,i)=>{e==t&&i==n&&(r=!0)}),r}function Dt(e,t){return e.field(Q,!1)?t:t.concat(o.appendConfig.of(It()))}var Ot=e=>{for(let t of Ct(e)){let n=Y(e.state,t.from,t.to);if(n)return e.dispatch({effects:Dt(e.state,[X.of(n),At(e,n)])}),!0}return!1},kt=e=>{if(!e.state.field(Q,!1))return!1;let t=[];for(let n of Ct(e)){let r=Tt(e.state,n.from,n.to);r&&t.push(Z.of(r),At(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function At(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return _.announce.of(`${e.state.phrase(n?`Folded lines`:`Unfolded lines`)} ${r} ${e.state.phrase(`to`)} ${i}.`)}var jt=e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),a=Y(t,i.from,i.to);a&&n.push(X.of(a)),r=(a?e.lineBlockAt(a.to):i).to+1}return n.length&&e.dispatch({effects:Dt(e.state,n)}),!!n.length},Mt=e=>{let t=e.state.field(Q,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(e,t)=>{n.push(Z.of({from:e,to:t}))}),e.dispatch({effects:n}),!0},Nt=[{key:`Ctrl-Shift-[`,mac:`Cmd-Alt-[`,run:Ot},{key:`Ctrl-Shift-]`,mac:`Cmd-Alt-]`,run:kt},{key:`Ctrl-Alt-[`,run:jt},{key:`Ctrl-Alt-]`,run:Mt}],Pt={placeholderDOM:null,preparePlaceholder:null,placeholderText:`…`},Ft=s.define({combine(e){return l(e,Pt)}});function It(e){let t=[Q,Ut];return e&&t.push(Ft.of(e)),t}function Lt(e,t){let{state:n}=e,r=n.facet(Ft),i=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),r=Tt(e.state,n.from,n.to);r&&e.dispatch({effects:Z.of(r)}),t.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(e,i,t);let a=document.createElement(`span`);return a.textContent=r.placeholderText,a.setAttribute(`aria-label`,n.phrase(`folded code`)),a.title=n.phrase(`unfold`),a.className=`cm-foldPlaceholder`,a.onclick=i,a}var Rt=v.replace({widget:new class extends g{toDOM(e){return Lt(e,null)}}}),zt=class extends g{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return Lt(e,this.value)}},Bt={openText:`⌄`,closedText:`›`,markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1},Vt=class extends p{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement(`span`);return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?`Fold line`:`Unfold line`),t}};function Ht(e={}){let t={...Bt,...e},r=new Vt(t,!0),i=new Vt(t,!1),a=u.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(J)!=e.state.facet(J)||e.startState.field(Q,!1)!=e.state.field(Q,!1)||K(e.startState)!=K(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new n;for(let n of e.viewportLineBlocks){let a=Tt(e.state,n.from,n.to)?i:Y(e.state,n.from,n.to)?r:null;a&&t.add(n.from,n.from,a)}return t.finish()}}),{domEventHandlers:o}=t;return[a,m({class:`cm-foldGutter`,markers(e){return e.plugin(a)?.markers||c.empty},initialSpacer(){return new Vt(t,!1)},domEventHandlers:{...o,click:(e,t,n)=>{if(o.click&&o.click(e,t,n))return!0;let r=Tt(e.state,t.from,t.to);if(r)return e.dispatch({effects:Z.of(r)}),!0;let i=Y(e.state,t.from,t.to);return i?(e.dispatch({effects:X.of(i)}),!0):!1}}}),It()]}var Ut=_.baseTheme({".cm-foldPlaceholder":{backgroundColor:`#eee`,border:`1px solid #ddd`,color:`#888`,borderRadius:`.2em`,margin:`0 1px`,padding:`0 1px`,cursor:`pointer`},".cm-foldGutter span":{padding:`0 1px`,cursor:`pointer`}}),Wt=class e{constructor(e,t){this.specs=e;let n;function r(e){let t=f.newName();return(n||=Object.create(null))[`.`+t]=e,t}let i=typeof t.all==`string`?t.all:t.all?r(t.all):void 0,a=t.scope;this.scope=a instanceof G?e=>e.prop(W)==a.data:a?e=>e==a:void 0,this.style=De(e.map(e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))})),{all:i}).style,this.module=n?new f(n):null,this.themeType=t.themeType}static define(t,n){return new e(t,n||{})}},Gt=s.define(),Kt=s.define({combine(e){return e.length?[e[0]]:null}});function qt(e){let t=e.facet(Gt);return t.length?t:e.facet(Kt)}function Jt(e,t){let n=[Xt],r;return e instanceof Wt&&(e.module&&n.push(_.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(Kt.of(e)):r?n.push(Gt.computeN([_.darkTheme],t=>t.facet(_.darkTheme)==(r==`dark`)?[e]:[])):n.push(Gt.of(e)),n}var Yt=class{constructor(e){this.markCache=Object.create(null),this.tree=K(e.state),this.decorations=this.buildDeco(e,qt(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=K(e.state),n=qt(e.state),r=n!=qt(e.startState),{viewport:i}=e.view,a=e.changes.mapPos(this.decoratedTo,1);t.length<i.to&&!r&&t.type==this.tree.type&&a>=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=a):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=i.to)}buildDeco(e,t){if(!t||!this.tree.length)return v.none;let r=new n;for(let{from:n,to:i}of e.visibleRanges)ke(this.tree,t,(e,t,n)=>{r.add(e,t,this.markCache[n]||(this.markCache[n]=v.mark({class:n})))},n,i);return r.finish()}},Xt=r.high(u.fromClass(Yt,{decorations:e=>e.decorations})),Zt=Wt.define([{tag:U.meta,color:`#404740`},{tag:U.link,textDecoration:`underline`},{tag:U.heading,textDecoration:`underline`,fontWeight:`bold`},{tag:U.emphasis,fontStyle:`italic`},{tag:U.strong,fontWeight:`bold`},{tag:U.strikethrough,textDecoration:`line-through`},{tag:U.keyword,color:`#708`},{tag:[U.atom,U.bool,U.url,U.contentSeparator,U.labelName],color:`#219`},{tag:[U.literal,U.inserted],color:`#164`},{tag:[U.string,U.deleted],color:`#a11`},{tag:[U.regexp,U.escape,U.special(U.string)],color:`#e40`},{tag:U.definition(U.variableName),color:`#00f`},{tag:U.local(U.variableName),color:`#30a`},{tag:[U.typeName,U.namespace],color:`#085`},{tag:U.className,color:`#167`},{tag:[U.special(U.variableName),U.macroName],color:`#256`},{tag:U.definition(U.propertyName),color:`#00c`},{tag:U.comment,color:`#940`},{tag:U.invalid,color:`#f00`}]),Qt=_.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:`#328c8252`},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bb555544`}}),$t=1e4,en=`()[]{}`,tn=s.define({combine(e){return l(e,{afterCursor:!0,brackets:en,maxScanDistance:$t,renderMatch:an})}}),nn=v.mark({class:`cm-matchingBracket`}),rn=v.mark({class:`cm-nonmatchingBracket`});function an(e){let t=[],n=e.matched?nn:rn;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}function on(e){let t=[],n=e.facet(tn);for(let r of e.selection.ranges){if(!r.empty)continue;let i=$(e,r.head,-1,n)||r.head>0&&$(e,r.head-1,1,n)||n.afterCursor&&($(e,r.head,1,n)||r.head<e.doc.length&&$(e,r.head+1,-1,n));i&&(t=t.concat(n.renderMatch(i,e)))}return v.set(t,!0)}var sn=[u.fromClass(class{constructor(e){this.paused=!1,this.decorations=on(e.state)}update(e){(e.docChanged||e.selectionSet||this.paused)&&(e.view.composing?(this.decorations=this.decorations.map(e.changes),this.paused=!0):(this.decorations=on(e.state),this.paused=!1))}},{decorations:e=>e.decorations}),Qt];function cn(e={}){return[tn.of(e