@bagelink/vue 1.20.76 → 1.20.80
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/StructuredEditor-B-Vp4pa2.cjs +2 -0
- package/dist/StructuredEditor-DWfRtYZa.js +2431 -0
- package/dist/StructuredEditor.css +1 -0
- package/dist/babel-BVvTH0ev.js +10053 -0
- package/dist/babel-BzIDwrmk.cjs +16 -0
- package/dist/components/form/inputs/CodeEditor/Index.vue.d.ts +45 -28
- package/dist/components/form/inputs/CodeEditor/Index.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/CodeEditor/SearchPanel.vue.d.ts +10 -0
- package/dist/components/form/inputs/CodeEditor/SearchPanel.vue.d.ts.map +1 -0
- package/dist/components/form/inputs/CodeEditor/StructuredEditor.vue.d.ts +27 -0
- package/dist/components/form/inputs/CodeEditor/StructuredEditor.vue.d.ts.map +1 -0
- package/dist/components/form/inputs/CodeEditor/formatCode.d.ts +4 -0
- package/dist/components/form/inputs/CodeEditor/formatCode.d.ts.map +1 -0
- package/dist/components/form/inputs/DatePicker.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/OTP.vue.d.ts +2 -2
- package/dist/components/form/inputs/OTP.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText/index.vue.d.ts.map +1 -1
- package/dist/core.css +3 -1
- package/dist/dist-B-MCiFKR.cjs +10 -0
- package/dist/dist-B0uc2InW.js +6 -0
- package/dist/dist-BIAEQGHn.cjs +1 -0
- package/dist/dist-BLxHnfU6.js +1071 -0
- package/dist/dist-BRA2DQF2.cjs +1 -0
- package/dist/dist-BnLdfA7w.js +69 -0
- package/dist/dist-CL50Ff42.cjs +1 -0
- package/dist/dist-CwUttjIh.js +1100 -0
- package/dist/dist-CzY35u4H.cjs +1 -0
- package/dist/dist-D8OWrPLr.js +1336 -0
- package/dist/dist-DSCI9g6w.cjs +13 -0
- package/dist/dist-DsBgijLf.cjs +1 -0
- package/dist/dist-GbVY_Jpv.cjs +1 -0
- package/dist/dist-IV7z-zur.js +11909 -0
- package/dist/dist-Mr0UMyoK.js +1063 -0
- package/dist/dist-jq7acmcZ.js +6 -0
- package/dist/estree-CKgw47OZ.js +8211 -0
- package/dist/estree-HqeJuE3g.cjs +44 -0
- package/dist/html-B-hsQYII.js +7289 -0
- package/dist/html-BrqW5pT-.cjs +25 -0
- package/dist/index.cjs +1 -764
- package/dist/index.mjs +308 -65621
- package/dist/postcss-Bk65KKdh.js +6703 -0
- package/dist/postcss-BxY0xtVZ.cjs +61 -0
- package/dist/src-DwJEyASG.js +65571 -0
- package/dist/src-Uy-ww1Nz.cjs +764 -0
- package/dist/src.css +1 -0
- package/dist/standalone-CAcRm_h6.cjs +29 -0
- package/dist/standalone-D-HcbQmf.js +3549 -0
- package/dist/style.css +3 -1
- package/dist/utils/calendarDate.d.ts +6 -0
- package/dist/utils/calendarDate.d.ts.map +1 -0
- package/dist/utils/date.d.ts.map +1 -1
- package/package.json +13 -2
- package/src/components/form/inputs/CodeEditor/Index.vue +70 -310
- package/src/components/form/inputs/CodeEditor/SearchPanel.vue +124 -0
- package/src/components/form/inputs/CodeEditor/StructuredEditor.vue +266 -0
- package/src/components/form/inputs/CodeEditor/formatCode.ts +34 -0
- package/src/components/form/inputs/DatePicker.vue +4 -1
- package/src/components/form/inputs/OTP.vue +42 -19
- package/src/components/form/inputs/RichText/index.vue +2 -1
- package/src/utils/calendarDate.ts +16 -0
- package/src/utils/date.ts +2 -1
- package/vite.config.ts +5 -3
- package/dist/components/form/inputs/CodeEditor/useHighlight.d.ts +0 -33
- package/dist/components/form/inputs/CodeEditor/useHighlight.d.ts.map +0 -1
- package/dist/index.css +0 -1
- package/src/components/form/inputs/CodeEditor/useHighlight.ts +0 -123
- /package/dist/{page-flip.browser-BXnk8BM6.js → page-flip.browser-0kqlwcC8.js} +0 -0
- /package/dist/{page-flip.browser-ByKQXhqK.cjs → page-flip.browser-Dfy5mAgM.cjs} +0 -0
- /package/dist/{pdf-CV7M2d0x.cjs → pdf-BBd7GH-5.cjs} +0 -0
- /package/dist/{pdf-DuN3_wNN.js → pdf-scP2ZqGZ.js} +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var ao=1024,Fa=0,le=class{constructor(t,e){this.from=t,this.to=e}},B=class{constructor(t={}){this.id=Fa++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=t.combine||null}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof t!="function"&&(t=se.match(t)),e=>{let i=t(e);return i===void 0?null:[this,i]}}};B.closedBy=new B({deserialize:t=>t.split(" ")});B.openedBy=new B({deserialize:t=>t.split(" ")});B.group=new B({deserialize:t=>t.split(" ")});B.isolate=new B({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}});B.contextHash=new B({perNode:!0});B.lookAhead=new B({perNode:!0});B.mounted=new B({perNode:!0});var mt=class{constructor(t,e,i,n=!1){this.tree=t,this.overlay=e,this.parser=i,this.bracketed=n}static get(t){return t&&t.props&&t.props[B.mounted.id]}},Va=Object.create(null),se=class ho{constructor(e,i,n,r=0){this.name=e,this.props=i,this.id=n,this.flags=r}static define(e){let i=e.props&&e.props.length?Object.create(null):Va,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new ho(e.name||"",i,e.id,n);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");i[s[0].id]=s[1]}}return r}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 i=this.prop(B.group);return i?i.indexOf(e)>-1:!1}return this.id==e}static match(e){let i=Object.create(null);for(let n in e)for(let r of n.split(" "))i[r]=e[n];return n=>{for(let r=n.prop(B.group),s=-1;s<(r?r.length:0);s++){let o=i[s<0?n.name:r[s]];if(o)return o}}}};se.none=new se("",Object.create(null),0,8);var $a=class fo{constructor(e){this.types=e;for(let i=0;i<e.length;i++)if(e[i].id!=i)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let i=[];for(let n of this.types){let r=null;for(let s of e){let o=s(n);if(o){r||(r=Object.assign({},n.props));let l=o[1],a=o[0];a.combine&&a.id in r&&(l=a.combine(r[a.id],l)),r[a.id]=l}}i.push(r?new se(n.name,r,n.id,n.flags):n)}return new fo(i)}},fi=new WeakMap,qr=new WeakMap,R;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(R||(R={}));var Y=class kn{constructor(e,i,n,r,s){if(this.type=e,this.children=i,this.positions=n,this.length=r,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,l]of s)this.props[typeof o=="number"?o:o.id]=l}}toString(){let e=mt.get(this);if(e&&!e.overlay)return e.tree.toString();let i="";for(let n of this.children){let r=n.toString();r&&(i&&(i+=","),i+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(i.length?"("+i+")":""):i}cursor(e=0){return new Li(this.topNode,e)}cursorAt(e,i=0,n=0){let r=new Li(fi.get(this)||this.topNode);return r.moveTo(e,i),fi.set(this,r._tree),r}get topNode(){return new fe(this,0,0,null)}resolve(e,i=0){let n=Jt(fi.get(this)||this.topNode,e,i,!1);return fi.set(this,n),n}resolveInner(e,i=0){let n=Jt(qr.get(this)||this.topNode,e,i,!0);return qr.set(this,n),n}resolveStack(e,i=0){return qa(this,e,i)}iterate(e){let{enter:i,leave:n,from:r=0,to:s=this.length}=e,o=e.mode||0,l=(o&R.IncludeAnonymous)>0;for(let a=this.cursor(o|R.IncludeAnonymous);;){let h=!1;if(a.from<=s&&a.to>=r&&(!l&&a.type.isAnonymous||i(a)!==!1)){if(a.firstChild())continue;h=!0}for(;h&&n&&(l||!a.type.isAnonymous)&&n(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 i in this.props)e.push([+i,this.props[i]]);return e}balance(e={}){return this.children.length<=8?this:Cr(se.none,this.children,this.positions,0,this.children.length,0,this.length,(i,n,r)=>new kn(this.type,i,n,r,this.propValues),e.makeTree||((i,n,r)=>new kn(se.none,i,n,r)))}static build(e){return Ga(e)}};Y.empty=new Y(se.none,[],[],0);var ja=class uo{constructor(e,i){this.buffer=e,this.index=i}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 uo(this.buffer,this.index)}},Ct=class co{constructor(e,i,n){this.buffer=e,this.length=i,this.set=n}get type(){return se.none}toString(){let e=[];for(let i=0;i<this.buffer.length;)e.push(this.childString(i)),i=this.buffer[i+3];return e.join(",")}childString(e){let i=this.buffer[e],n=this.buffer[e+3],r=this.set.types[i],s=r.name;if(/\W/.test(s)&&!r.isError&&(s=JSON.stringify(s)),e+=4,n==e)return s;let o=[];for(;e<n;)o.push(this.childString(e)),e=this.buffer[e+3];return s+"("+o.join(",")+")"}findChild(e,i,n,r,s){let{buffer:o}=this,l=-1;for(let a=e;a!=i&&!(po(s,r,o[a+1],o[a+2])&&(l=a,n>0));a=o[a+3]);return l}slice(e,i,n){let r=this.buffer,s=new Uint16Array(i-e),o=0;for(let l=e,a=0;l<i;){s[a++]=r[l++],s[a++]=r[l++]-n;let h=s[a++]=r[l++]-n;s[a++]=r[l++]-e,o=Math.max(o,h)}return new co(s,o,this.set)}};function po(t,e,i,n){switch(t){case-2:return i<e;case-1:return n>=e&&i<e;case 0:return i<e&&n>e;case 1:return i<=e&&n>e;case 2:return n>e;case 4:return!0}}function Jt(t,e,i,n){for(var r;t.from==t.to||(i<1?t.from>=e:t.from>e)||(i>-1?t.to<=e:t.to<e);){let o=!n&&t instanceof fe&&t.index<0?null:t.parent;if(!o)return t;t=o}let s=n?0:R.IgnoreOverlays;if(n)for(let o=t,l=o.parent;l;o=l,l=o.parent)o instanceof fe&&o.index<0&&((r=l.enter(e,i,s))===null||r===void 0?void 0:r.from)!=o.from&&(t=l);for(;;){let o=t.enter(e,i,s);if(!o)return t;t=o}}var go=class{cursor(t=0){return new Li(this,t)}getChild(t,e=null,i=null){let n=Gr(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return Gr(this,t,e,i)}resolve(t,e=0){return Jt(this,t,e,!1)}resolveInner(t,e=0){return Jt(this,t,e,!0)}matchContext(t){return Sn(this.parent,t)}enterUnfinishedNodesBefore(t){let e=this.childBefore(t),i=this;for(;e;){let n=e.lastChild;if(!n||n.to!=e.to)break;n.type.isError&&n.from==n.to?(i=e,e=n.prevSibling):e=n}return i}get node(){return this}get next(){return this.parent}},fe=class Mi extends go{constructor(e,i,n,r){super(),this._tree=e,this.from=i,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(e,i,n,r,s=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,h=i>0?l.length:-1;e!=h;e+=i){let f=l[e],u=a[e]+o.from,c;if(!(!(s&R.EnterBracketed&&f instanceof Y&&(c=mt.get(f))&&!c.overlay&&c.bracketed&&n>=u&&n<=u+f.length)&&!po(r,n,u,u+f.length))){if(f instanceof Ct){if(s&R.ExcludeBuffers)continue;let d=f.findChild(0,f.buffer.length,i,n-u,r);if(d>-1)return new Xt(new za(o,f,e,u),null,d)}else if(s&R.IncludeAnonymous||!f.type.isAnonymous||Sr(f)){let d;if(!(s&R.IgnoreMounts)&&(d=mt.get(f))&&!d.overlay)return new Mi(d.tree,u,e,o);let p=new Mi(f,u,e,o);return s&R.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(i<0?f.children.length-1:0,i,n,r,s)}}}if(s&R.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+i:e=i<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,i,n=0){let r;if(!(n&R.IgnoreOverlays)&&(r=mt.get(this._tree))&&r.overlay){let s=e-this.from,o=n&R.EnterBracketed&&r.bracketed;for(let{from:l,to:a}of r.overlay)if((i>0||o?l<=s:l<s)&&(i<0||o?a>=s:a>s))return new Mi(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,i,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function Gr(t,e,i,n){let r=t.cursor(),s=[];if(!r.firstChild())return s;if(i!=null){for(let o=!1;!o;)if(o=r.type.is(i),!r.nextSibling())return s}for(;;){if(n!=null&&r.type.is(n))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return n==null?s:[]}}function Sn(t,e,i=e.length-1){for(let n=t;i>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[i]&&e[i]!=n.name)return!1;i--}}return!0}var za=class{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}},Xt=class Ht extends go{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,i,n){super(),this.context=e,this._parent=i,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,i,n){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,i-this.context.start,n);return s<0?null:new Ht(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,i,n=0){if(n&R.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],i>0?1:-1,e-this.context.start,i);return s<0?null:new Ht(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,i=e.buffer[this.index+3];return i<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Ht(this.context,this._parent,i):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,i=this._parent?this._parent.index+4:0;return this.index==i?this.externalSibling(-1):new Ht(this.context,this._parent,e.findChild(i,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],i=[],{buffer:n}=this.context,r=this.index+4,s=n.buffer[this.index+3];if(s>r){let o=n.buffer[this.index+1];e.push(n.slice(r,s,o)),i.push(0)}return new Y(this.type,e,i,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function mo(t){if(!t.length)return null;let e=0,i=t[0];for(let s=1;s<t.length;s++){let o=t[s];(o.from>i.from||o.to<i.to)&&(i=o,e=s)}let n=i instanceof fe&&i.index<0?null:i.parent,r=t.slice();return n?r[e]=n:r.splice(e,1),new Ka(r,i)}var Ka=class{constructor(t,e){this.heads=t,this.node=e}get next(){return mo(this.heads)}};function qa(t,e,i){let n=t.resolveInner(e,i),r=null;for(let s=n instanceof fe?n:n.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(r||(r=[n])).push(o.resolve(e,i)),s=o}else{let o=mt.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let l=new fe(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[n])).push(Jt(l,e,i,!1))}}return r?mo(r):n}var Li=class{get name(){return this.type.name}constructor(t,e=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=e&~R.EnterBracketed,t instanceof fe)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let i=t._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return t?(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0):!1}yieldBuf(t,e){this.index=t;let{start:i,buffer:n}=this.buffer;return this.type=e||n.set.types[n.buffer[t]],this.from=i+n.buffer[t+1],this.to=i+n.buffer[t+2],!0}yield(t){return t?t instanceof fe?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,i){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,i,this.mode));let{buffer:n}=this.buffer,r=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.buffer.start,i);return r<0?!1:(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,i=this.mode){return this.buffer?i&R.ExcludeBuffers?!1:this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&R.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&R.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode)):!1;let{buffer:e}=this.buffer,i=this.stack.length-1;if(t<0){let n=i<0?0:this.stack[i]+4;if(this.index!=n)return this.yieldBuf(e.findChild(n,this.index,-1,0,4))}else{let n=e.buffer[this.index+3];if(n<(i<0?e.buffer.length:e.buffer[this.stack[i]+3]))return this.yieldBuf(n)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,i,{buffer:n}=this;if(n){if(t>0){if(this.index<n.buffer.buffer.length)return!1}else for(let r=0;r<this.index;r++)if(n.buffer.buffer[r+3]<this.index)return!1;({index:e,parent:i}=n)}else({index:e,_parent:i}=this._tree);for(;i;{index:e,_parent:i}=i)if(e>-1)for(let r=e+t,s=t<0?-1:i._tree.children.length;r!=s;r+=t){let o=i._tree.children[r];if(this.mode&R.IncludeAnonymous||o instanceof Ct||!o.type.isAnonymous||Sr(o))return!1}return!0}move(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,i=0;if(t&&t.context==this.buffer)e:for(let n=this.index,r=this.stack.length;r>=0;){for(let s=t;s;s=s._parent)if(s.index==n){if(n==this.index)return s;e=s,i=r+1;break e}n=this.stack[--r]}for(let n=i;n<this.stack.length;n++)e=new Xt(this.buffer,e,this.stack[n]);return this.bufferNode=new Xt(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let i=0;;){let n=!1;if(this.type.isAnonymous||t(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(n=!0)}for(;;){if(n&&e&&e(this),n=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,n=!0}}}matchContext(t){if(!this.buffer)return Sn(this.node.parent,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let n=t.length-1,r=this.stack.length-1;n>=0;r--){if(r<0)return Sn(this._tree,t,n);let s=i[e.buffer[this.stack[r]]];if(!s.isAnonymous){if(t[n]&&t[n]!=s.name)return!1;n--}}return!0}};function Sr(t){return t.children.some(e=>e instanceof Ct||!e.type.isAnonymous||Sr(e))}function Ga(t){var e;let{buffer:i,nodeSet:n,maxBufferLength:r=ao,reused:s=[],minRepeatType:o=n.types.length}=t,l=Array.isArray(i)?new ja(i,i.length):i,a=n.types,h=0,f=0;function u(k,P,M,z,L,K){let{id:E,start:T,end:V,size:j}=l,X=f,Ee=h;if(j<0)if(l.next(),j==-1){let Re=s[E];M.push(Re),z.push(T-k);return}else if(j==-3){h=E;return}else if(j==-4){f=E;return}else throw new RangeError(`Unrecognized record size: ${j}`);let Pt=a[E],hi,tt,zr=T-k;if(V-T<=r&&(tt=m(l.pos-P,L))){let Re=new Uint16Array(tt.size-tt.skip),Z=l.pos-tt.size,ue=Re.length;for(;l.pos>Z;)ue=b(tt.start,Re,ue);hi=new Ct(Re,V-tt.start,n),zr=tt.start-k}else{let Re=l.pos-j;l.next();let Z=[],ue=[],we=E>=o?E:-1,Ne=0,ht=V,Bt=X;for(;l.pos>Re;)we>=0&&l.id==we&&l.size>=0?(l.end<=ht-r&&(p(Z,ue,T,Ne,l.end,ht,we,Bt,Ee),Ne=Z.length,ht=l.end,Bt=f),l.next()):K>2500?c(T,Re,Z,ue):(we>=0&&l.size==-1&&s[l.id].type==n.types[we]&&(Ne<Z.length&&p(Z,ue,T,Ne,l.end,ht,we,Bt,Ee),Ne=Z.length+1,ht=l.start,Bt=f),u(T,Re,Z,ue,we,K+1));if(we>=0&&Ne>0&&Ne<Z.length&&p(Z,ue,T,Ne,T,ht,we,Bt,Ee),Z.reverse(),ue.reverse(),we>-1&&Ne>0){let Kr=d(Pt,Ee);hi=Cr(Pt,Z,ue,0,Z.length,0,V-T,Kr,Kr)}else hi=g(Pt,Z,ue,V-T,X-V,Ee)}M.push(hi),z.push(zr)}function c(k,P,M,z){let L=[],K=0,E=-1;for(;l.pos>P;){let{id:T,start:V,end:j,size:X}=l;if(X>4)l.next();else{if(E>-1&&V<E)break;E<0&&(E=j-r),L.push(T,V,j),K++,l.next()}}if(K){let T=new Uint16Array(K*4),V=L[L.length-2];for(let j=L.length-3,X=0;j>=0;j-=3)T[X++]=L[j],T[X++]=L[j+1]-V,T[X++]=L[j+2]-V,T[X++]=X;M.push(new Ct(T,L[2]-V,n)),z.push(V-k)}}function d(k,P){return(M,z,L)=>{let K=0,E=M.length-1,T,V;if(E>=0&&(T=M[E])instanceof Y){if(!E&&T.type==k&&T.length==L)return T;(V=T.prop(B.lookAhead))&&(K=z[E]+T.length+V-L)}return g(k,M,z,L,K,P)}}function p(k,P,M,z,L,K,E,T,V){let j=[],X=[];for(;k.length>z;)j.push(k.pop()),X.push(P.pop()+M-L);k.push(g(n.types[E],j,X,K-L,T-K,V)),P.push(L-M)}function g(k,P,M,z,L,K,E){if(K){let T=[B.contextHash,K];E=E?[T].concat(E):[T]}if(L>25){let T=[B.lookAhead,L];E=E?[T].concat(E):[T]}return new Y(k,P,M,z,E)}function m(k,P){let M=l.fork(),z=0,L=0,K=0,E=M.end-r,T={size:0,start:0,skip:0};e:for(let V=M.pos-k;M.pos>V;){let j=M.size;if(M.id==P&&j>=0){T.size=z,T.start=L,T.skip=K,K+=4,z+=4,M.next();continue}let X=M.pos-j;if(j<0||X<V||M.start<E)break;let Ee=M.id>=o?4:0,Pt=M.start;for(M.next();M.pos>X;){if(M.size<0)if(M.size==-3||M.size==-4)Ee+=4;else break e;else M.id>=o&&(Ee+=4);M.next()}L=Pt,z+=j,K+=Ee}return(P<0||z==k)&&(T.size=z,T.start=L,T.skip=K),T.size>4?T:void 0}function b(k,P,M){let{id:z,start:L,end:K,size:E}=l;if(l.next(),E>=0&&z<o){let T=M;if(E>4){let V=l.pos-(E-4);for(;l.pos>V;)M=b(k,P,M)}P[--M]=T,P[--M]=K-k,P[--M]=L-k,P[--M]=z}else E==-3?h=z:E==-4&&(f=z);return M}let x=[],A=[];for(;l.pos>0;)u(t.start||0,t.bufferStart||0,x,A,-1,0);let O=(e=t.length)!==null&&e!==void 0?e:x.length?A[0]+x[0].length:0;return new Y(a[t.topID],x.reverse(),A.reverse(),O)}var Ur=new WeakMap;function Oi(t,e){if(!t.isAnonymous||e instanceof Ct||e.type!=t)return 1;let i=Ur.get(e);if(i==null){i=1;for(let n of e.children){if(n.type!=t||!(n instanceof Y)){i=1;break}i+=Oi(t,n)}Ur.set(e,i)}return i}function Cr(t,e,i,n,r,s,o,l,a){let h=0;for(let p=n;p<r;p++)h+=Oi(t,e[p]);let f=Math.ceil(h*1.5/8),u=[],c=[];function d(p,g,m,b,x){for(let A=m;A<b;){let O=A,k=g[A],P=Oi(t,p[A]);for(A++;A<b;A++){let M=Oi(t,p[A]);if(P+M>=f)break;P+=M}if(A==O+1){if(P>f){let M=p[O];d(M.children,M.positions,0,M.children.length,g[O]+x);continue}u.push(p[O])}else{let M=g[A-1]+p[A-1].length-k;u.push(Cr(t,p,g,O,A,k,M,null,a))}c.push(k+x-s)}}return d(e,i,n,r,0),(l||a)(u,c,o)}var Ua=class{constructor(){this.map=new WeakMap}setBuffer(t,e,i){let n=this.map.get(t);n||this.map.set(t,n=new Map),n.set(e,i)}getBuffer(t,e){let i=this.map.get(t);return i&&i.get(e)}set(t,e){t instanceof Xt?this.setBuffer(t.context.buffer,t.index,e):t instanceof fe&&this.map.set(t.tree,e)}get(t){return t instanceof Xt?this.getBuffer(t.context.buffer,t.index):t instanceof fe?this.map.get(t.tree):void 0}cursorSet(t,e){t.buffer?this.setBuffer(t.buffer.buffer,t.index,e):this.map.set(t.tree,e)}cursorGet(t){return t.buffer?this.getBuffer(t.buffer.buffer,t.index):this.map.get(t.tree)}},bt=class Cn{constructor(e,i,n,r,s=!1,o=!1){this.from=e,this.to=i,this.tree=n,this.offset=r,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,i=[],n=!1){let r=[new Cn(0,e.length,e,0,!1,n)];for(let s of i)s.to>e.length&&r.push(s);return r}static applyChanges(e,i,n=128){if(!i.length)return e;let r=[],s=1,o=e.length?e[0]:null;for(let l=0,a=0,h=0;;l++){let f=l<i.length?i[l]:null,u=f?f.fromA:1e9;if(u-a>=n)for(;o&&o.from<u;){let c=o;if(a>=c.from||u<=c.to||h){let d=Math.max(c.from,a)-h,p=Math.min(c.to,u)-h;c=d>=p?null:new Cn(d,p,c.tree,c.offset+h,l>0,!!f)}if(c&&r.push(c),o.to>u)break;o=s<e.length?e[s++]:null}if(!f)break;a=f.toA,h=f.toA-f.toB}return r}},bo=class{startParse(t,e,i){return typeof t=="string"&&(t=new Ya(t)),i=i?i.length?i.map(n=>new le(n.from,n.to)):[new le(0,0)]:[new le(0,t.length)],this.createParse(t,e||[],i)}parse(t,e,i){let n=this.startParse(t,e,i);for(;;){let r=n.advance();if(r)return r}}},Ya=class{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}};function _a(t){return(e,i,n,r)=>new Xa(e,t,i,n,r)}var Yr=class{constructor(t,e,i,n,r,s){this.parser=t,this.parse=e,this.overlay=i,this.bracketed=n,this.target=r,this.from=s}};function _r(t){if(!t.length||t.some(e=>e.from>=e.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(t))}var Ja=class{constructor(t,e,i,n,r,s,o,l){this.parser=t,this.predicate=e,this.mounts=i,this.index=n,this.start=r,this.bracketed=s,this.target=o,this.prev=l,this.depth=0,this.ranges=[]}},yo=new B({perNode:!0}),Xa=class{constructor(t,e,i,n,r){this.nest=e,this.input=i,this.fragments=n,this.ranges=r,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=t}advance(){if(this.baseParse){let i=this.baseParse.advance();if(!i)return null;if(this.baseParse=null,this.baseTree=i,this.startInner(),this.stoppedAt!=null)for(let n of this.inner)n.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let i=this.baseTree;return this.stoppedAt!=null&&(i=new Y(i.type,i.children,i.positions,i.length,i.propValues.concat([[yo,this.stoppedAt]]))),i}let t=this.inner[this.innerDone],e=t.parse.advance();if(e){this.innerDone++;let i=Object.assign(Object.create(null),t.target.props);i[B.mounted.id]=new mt(e,t.overlay,t.parser,t.bracketed),t.target.props=i}return null}get parsedPos(){if(this.baseParse)return 0;let t=this.input.length;for(let e=this.innerDone;e<this.inner.length;e++)this.inner[e].from<t&&(t=Math.min(t,this.inner[e].parse.parsedPos));return t}stopAt(t){if(this.stoppedAt=t,this.baseParse)this.baseParse.stopAt(t);else for(let e=this.innerDone;e<this.inner.length;e++)this.inner[e].parse.stopAt(t)}startInner(){let t=new eh(this.fragments),e=null,i=null,n=new Li(new fe(this.baseTree,this.ranges[0].from,0,null),R.IncludeAnonymous|R.IgnoreMounts);e:for(let r,s;;){let o=!0,l;if(this.stoppedAt!=null&&n.from>=this.stoppedAt)o=!1;else if(t.hasNode(n)){if(e){let a=e.mounts.find(h=>h.frag.from<=n.from&&h.frag.to>=n.to&&h.mount.overlay);if(a)for(let h of a.mount.overlay){let f=h.from+a.pos,u=h.to+a.pos;f>=n.from&&u<=n.to&&!e.ranges.some(c=>c.from<u&&c.to>f)&&e.ranges.push({from:f,to:u})}}o=!1}else if(i&&(s=Qa(i.ranges,n.from,n.to)))o=s!=2;else if(!n.type.isAnonymous&&(r=this.nest(n,this.input))&&(n.from<n.to||!r.overlay)){n.tree||(Za(n),e&&e.depth++,i&&i.depth++);let a=t.findMounts(n.from,r.parser);if(typeof r.overlay=="function")e=new Ja(r.parser,r.overlay,a,this.inner.length,n.from,!!r.bracketed,n.tree,e);else{let h=Zr(this.ranges,r.overlay||(n.from<n.to?[new le(n.from,n.to)]:[]));h.length&&_r(h),(h.length||!r.overlay)&&this.inner.push(new Yr(r.parser,h.length?r.parser.startParse(this.input,es(a,h),h):r.parser.startParse(""),r.overlay?r.overlay.map(f=>new le(f.from-n.from,f.to-n.from)):null,!!r.bracketed,n.tree,h.length?h[0].from:n.from)),r.overlay?h.length&&(i={ranges:h,depth:0,prev:i}):o=!1}}else if(e&&(l=e.predicate(n))&&(l===!0&&(l=new le(n.from,n.to)),l.from<l.to)){let a=e.ranges.length-1;a>=0&&e.ranges[a].to==l.from?e.ranges[a]={from:e.ranges[a].from,to:l.to}:e.ranges.push(l)}if(o&&n.firstChild())e&&e.depth++,i&&i.depth++;else for(;!n.nextSibling();){if(!n.parent())break e;if(e&&!--e.depth){let a=Zr(this.ranges,e.ranges);a.length&&(_r(a),this.inner.splice(e.index,0,new Yr(e.parser,e.parser.startParse(this.input,es(e.mounts,a),a),e.ranges.map(h=>new le(h.from-e.start,h.to-e.start)),e.bracketed,e.target,a[0].from))),e=e.prev}i&&!--i.depth&&(i=i.prev)}}}};function Qa(t,e,i){for(let n of t){if(n.from>=i)break;if(n.to>e)return n.from<=e&&n.to>=i?2:1}return 0}function Jr(t,e,i,n,r,s){if(e<i){let o=t.buffer[e+1];n.push(t.slice(e,i,o)),r.push(o-s)}}function Za(t){let{node:e}=t,i=[],n=e.context.buffer;do i.push(t.index),t.parent();while(!t.tree);let r=t.tree,s=r.children.indexOf(n),o=r.children[s],l=o.buffer,a=[s];function h(f,u,c,d,p,g){let m=i[g],b=[],x=[];Jr(o,f,m,b,x,d);let A=l[m+1],O=l[m+2];a.push(b.length);let k=g?h(m+4,l[m+3],o.set.types[l[m]],A,O-A,g-1):e.toTree();return b.push(k),x.push(A-d),Jr(o,l[m+3],u,b,x,d),new Y(c,b,x,p)}r.children[s]=h(0,l.length,se.none,0,o.length,i.length-1);for(let f of a){let u=t.tree.children[f],c=t.tree.positions[f];t.yield(new fe(u,c+t.from,f,t._tree))}}var Xr=class{constructor(t,e){this.offset=e,this.done=!1,this.cursor=t.cursor(R.IncludeAnonymous|R.IgnoreMounts|R.ExcludeBuffers)}moveTo(t){let{cursor:e}=this,i=t-this.offset;for(;!this.done&&e.from<i;)if(!(e.to>=i&&e.enter(i,1,R.IncludeAnonymous|R.IgnoreMounts|R.IgnoreOverlays|R.ExcludeBuffers)))if(e.to<=i)e.next(!1)||(this.done=!0);else break}hasNode(t){if(this.moveTo(t.from),!this.done&&this.cursor.from+this.offset==t.from&&this.cursor.tree)for(let e=this.cursor.tree;;){if(e==t.tree)return!0;if(e.children.length&&e.positions[0]==0&&e.children[0]instanceof Y)e=e.children[0];else break}return!1}};function Qr(t){let e=t.tree.prop(yo);return e==null?t.to:Math.min(t.to,e-t.offset)}var eh=class{constructor(t){if(this.fragments=t,this.curTo=0,this.fragI=0,t.length){let e=this.curFrag=t[0];this.curTo=Qr(e),this.inner=new Xr(e.tree,-e.offset)}else this.curFrag=this.inner=null}hasNode(t){for(;this.curFrag&&t.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=t.from&&this.curTo>=t.to&&this.inner.hasNode(t)}nextFrag(){if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let t=this.curFrag=this.fragments[this.fragI];this.curTo=Qr(t),this.inner=new Xr(t.tree,-t.offset)}}findMounts(t,e){var i;let n=[];if(this.inner){this.inner.cursor.moveTo(t,1);for(let r=this.inner.cursor.node;r;r=r.parent){let s=(i=r.tree)===null||i===void 0?void 0:i.prop(B.mounted);if(s&&s.parser==e)for(let o=this.fragI;o<this.fragments.length;o++){let l=this.fragments[o];if(l.from>=r.to)break;l.tree==this.curFrag.tree&&n.push({frag:l,pos:r.from-l.offset,mount:s})}}}return n}};function Zr(t,e){let i=null,n=e;for(let r=1,s=0;r<t.length;r++){let o=t[r-1].to,l=t[r].from;for(;s<n.length;s++){let a=n[s];if(a.from>=l)break;a.to<=o||(i||(n=i=e.slice()),a.from<o?(i[s]=new le(a.from,o),a.to>l&&i.splice(s+1,0,new le(l,a.to))):a.to>l?i[s--]=new le(l,a.to):i.splice(s--,1))}}return n}function th(t,e,i,n){let r=0,s=0,o=!1,l=!1,a=-1e9,h=[];for(;;){let f=r==t.length?1e9:o?t[r].to:t[r].from,u=s==e.length?1e9:l?e[s].to:e[s].from;if(o!=l){let c=Math.max(a,i),d=Math.min(f,u,n);c<d&&h.push(new le(c,d))}if(a=Math.min(f,u),a==1e9)break;f==a&&(o?(o=!1,r++):o=!0),u==a&&(l?(l=!1,s++):l=!0)}return h}function es(t,e){let i=[];for(let{pos:n,mount:r,frag:s}of t){let o=n+(r.overlay?r.overlay[0].from:0),l=o+r.tree.length,a=Math.max(s.from,o),h=Math.min(s.to,l);if(r.overlay){let f=th(e,r.overlay.map(u=>new le(u.from+n,u.to+n)),a,h);for(let u=0,c=a;;u++){let d=u==f.length,p=d?h:f[u].from;if(p>c&&i.push(new bt(c,p,r.tree,-o,s.from>=c||s.openStart,s.to<=p||s.openEnd)),d)break;c=f[u].to}}else i.push(new bt(a,h,r.tree,-o,s.from>=o||s.openStart,s.to<=l||s.openEnd))}return i}var ih=0,Le=class An{constructor(e,i,n,r){this.name=e,this.set=i,this.base=n,this.modified=r,this.id=ih++}toString(){let{name:e}=this;for(let i of this.modified)i.name&&(e=`${i.name}(${e})`);return e}static define(e,i){let n=typeof e=="string"?e:"?";if(e instanceof An&&(i=e),i?.base)throw new Error("Can not derive from a modified tag");let r=new An(n,[],null,[]);if(r.set.push(r),i)for(let s of i.set)r.set.push(s);return r}static defineModifier(e){let i=new ts(e);return n=>n.modified.indexOf(i)>-1?n:ts.get(n.base||n,n.modified.concat(i).sort((r,s)=>r.id-s.id))}},nh=0,ts=class vo{constructor(e){this.name=e,this.instances=[],this.id=nh++}static get(e,i){if(!i.length)return e;let n=i[0].instances.find(l=>l.base==e&&rh(i,l.modified));if(n)return n;let r=[],s=new Le(e.name,r,e,i);for(let l of i)l.instances.push(s);let o=sh(i);for(let l of e.set)if(!l.modified.length)for(let a of o)r.push(vo.get(l,a));return s}};function rh(t,e){return t.length==e.length&&t.every((i,n)=>i==e[n])}function sh(t){let e=[[]];for(let i=0;i<t.length;i++)for(let n=0,r=e.length;n<r;n++)e.push(e[n].concat(t[i]));return e.sort((i,n)=>n.length-i.length)}function wo(t){let e=Object.create(null);for(let i in t){let n=t[i];Array.isArray(n)||(n=[n]);for(let r of i.split(" "))if(r){let s=[],o=2,l=r;for(let f=0;;){if(l=="..."&&f>0&&f+3==r.length){o=1;break}let u=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!u)throw new RangeError("Invalid path: "+r);if(s.push(u[0]=="*"?"":u[0][0]=='"'?JSON.parse(u[0]):u[0]),f+=u[0].length,f==r.length)break;let c=r[f++];if(f==r.length&&c=="!"){o=0;break}if(c!="/")throw new RangeError("Invalid path: "+r);l=r.slice(f)}let a=s.length-1,h=s[a];if(!h)throw new RangeError("Invalid path: "+r);e[h]=new Qt(n,o,a>0?s.slice(0,a):null).sort(e[h])}}return xo.add(e)}var xo=new B({combine(t,e){let i,n,r;for(;t||e;){if(!t||e&&t.depth<=e.depth?(r=e,e=e.next):(r=t,t=t.next),i&&i.mode==r.mode&&!r.context&&!i.context)continue;let s=new Qt(r.tags,r.mode,r.context);i?i.next=s:n=s,i=s}return n}}),Qt=class{constructor(t,e,i,n){this.tags=t,this.mode=e,this.context=i,this.next=n}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}};Qt.empty=new Qt([],2,null);function ko(t,e){let i=Object.create(null);for(let s of t)if(!Array.isArray(s.tag))i[s.tag.id]=s.class;else for(let o of s.tag)i[o.id]=s.class;let{scope:n,all:r=null}=e||{};return{style:s=>{let o=r;for(let l of s)for(let a of l.set){let h=i[a.id];if(h){o=o?o+" "+h:h;break}}return o},scope:n}}function oh(t,e){let i=null;for(let n of t){let r=n.style(e);r&&(i=i?i+" "+r:r)}return i}function lh(t,e,i,n=0,r=t.length){let s=new ah(n,Array.isArray(e)?e:[e],i);s.highlightRange(t.cursor(),n,r,"",s.highlighters),s.flush(r)}var ah=class{constructor(t,e,i){this.at=t,this.highlighters=e,this.span=i,this.class=""}startSpan(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,e,i,n,r){let{type:s,from:o,to:l}=t;if(o>=i||l<=e)return;s.isTop&&(r=this.highlighters.filter(c=>!c.scope||c.scope(s)));let a=n,h=hh(t)||Qt.empty,f=oh(r,h.tags);if(f&&(a&&(a+=" "),a+=f,h.mode==1&&(n+=(n?" ":"")+f)),this.startSpan(Math.max(e,o),a),h.opaque)return;let u=t.tree&&t.tree.prop(B.mounted);if(u&&u.overlay){let c=t.node.enter(u.overlay[0].from+o,1),d=this.highlighters.filter(g=>!g.scope||g.scope(u.tree.type)),p=t.firstChild();for(let g=0,m=o;;g++){let b=g<u.overlay.length?u.overlay[g]:null,x=b?b.from+o:l,A=Math.max(e,m),O=Math.min(i,x);if(A<O&&p)for(;t.from<O&&(this.highlightRange(t,A,O,n,r),this.startSpan(Math.min(O,t.to),a),!(t.to>=x||!t.nextSibling())););if(!b||x>i)break;m=b.to+o,m>e&&(this.highlightRange(c.cursor(),Math.max(e,b.from+o),Math.min(i,m),"",d),this.startSpan(Math.min(i,m),a))}p&&t.parent()}else if(t.firstChild()){u&&(n="");do if(!(t.to<=e)){if(t.from>=i)break;this.highlightRange(t,e,i,n,r),this.startSpan(Math.min(i,t.to),a)}while(t.nextSibling());t.parent()}}};function hh(t){let e=t.type.prop(xo);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}var y=Le.define,ui=y(),je=y(),is=y(je),ns=y(je),ze=y(),ci=y(ze),en=y(ze),Ce=y(),it=y(Ce),xe=y(),ke=y(),Mn=y(),Et=y(Mn),di=y(),v={comment:ui,lineComment:y(ui),blockComment:y(ui),docComment:y(ui),name:je,variableName:y(je),typeName:is,tagName:y(is),propertyName:ns,attributeName:y(ns),className:y(je),labelName:y(je),namespace:y(je),macroName:y(je),literal:ze,string:ci,docString:y(ci),character:y(ci),attributeValue:y(ci),number:en,integer:y(en),float:y(en),bool:y(ze),regexp:y(ze),escape:y(ze),color:y(ze),url:y(ze),keyword:xe,self:y(xe),null:y(xe),atom:y(xe),unit:y(xe),modifier:y(xe),operatorKeyword:y(xe),controlKeyword:y(xe),definitionKeyword:y(xe),moduleKeyword:y(xe),operator:ke,derefOperator:y(ke),arithmeticOperator:y(ke),logicOperator:y(ke),bitwiseOperator:y(ke),compareOperator:y(ke),updateOperator:y(ke),definitionOperator:y(ke),typeOperator:y(ke),controlOperator:y(ke),punctuation:Mn,separator:y(Mn),bracket:Et,angleBracket:y(Et),squareBracket:y(Et),paren:y(Et),brace:y(Et),content:Ce,heading:it,heading1:y(it),heading2:y(it),heading3:y(it),heading4:y(it),heading5:y(it),heading6:y(it),contentSeparator:y(Ce),list:y(Ce),quote:y(Ce),emphasis:y(Ce),strong:y(Ce),link:y(Ce),monospace:y(Ce),strikethrough:y(Ce),inserted:y(),deleted:y(),changed:y(),invalid:y(),meta:di,documentMeta:y(di),annotation:y(di),processingInstruction:y(di),definition:Le.defineModifier("definition"),constant:Le.defineModifier("constant"),function:Le.defineModifier("function"),standard:Le.defineModifier("standard"),local:Le.defineModifier("local"),special:Le.defineModifier("special")};for(let t in v){let e=v[t];e instanceof Le&&(e.name=t)}var Lc=ko([{tag:v.link,class:"tok-link"},{tag:v.heading,class:"tok-heading"},{tag:v.emphasis,class:"tok-emphasis"},{tag:v.strong,class:"tok-strong"},{tag:v.keyword,class:"tok-keyword"},{tag:v.atom,class:"tok-atom"},{tag:v.bool,class:"tok-bool"},{tag:v.url,class:"tok-url"},{tag:v.labelName,class:"tok-labelName"},{tag:v.inserted,class:"tok-inserted"},{tag:v.deleted,class:"tok-deleted"},{tag:v.literal,class:"tok-literal"},{tag:v.string,class:"tok-string"},{tag:v.number,class:"tok-number"},{tag:[v.regexp,v.escape,v.special(v.string)],class:"tok-string2"},{tag:v.variableName,class:"tok-variableName"},{tag:v.local(v.variableName),class:"tok-variableName tok-local"},{tag:v.definition(v.variableName),class:"tok-variableName tok-definition"},{tag:v.special(v.variableName),class:"tok-variableName2"},{tag:v.definition(v.propertyName),class:"tok-propertyName tok-definition"},{tag:v.typeName,class:"tok-typeName"},{tag:v.namespace,class:"tok-namespace"},{tag:v.className,class:"tok-className"},{tag:v.macroName,class:"tok-macroName"},{tag:v.propertyName,class:"tok-propertyName"},{tag:v.operator,class:"tok-operator"},{tag:v.comment,class:"tok-comment"},{tag:v.meta,class:"tok-meta"},{tag:v.invalid,class:"tok-invalid"},{tag:v.punctuation,class:"tok-punctuation"}]),On=[],So=[];(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,i=0;e<t.length;e++)(e%2?So:On).push(i=i+t[e])})();function fh(t){if(t<768)return!1;for(let e=0,i=On.length;;){let n=e+i>>1;if(t<On[n])i=n;else if(t>=So[n])e=n+1;else return!0;if(e==i)return!1}}function rs(t){return t>=127462&&t<=127487}var ss=8205;function uh(t,e,i=!0,n=!0){return(i?Co:ch)(t,e,n)}function Co(t,e,i){if(e==t.length)return e;e&&Ao(t.charCodeAt(e))&&Mo(t.charCodeAt(e-1))&&e--;let n=tn(t,e);for(e+=os(n);e<t.length;){let r=tn(t,e);if(n==ss||r==ss||i&&fh(r))e+=os(r),n=r;else if(rs(r)){let s=0,o=e-2;for(;o>=0&&rs(tn(t,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function ch(t,e,i){for(;e>1;){let n=Co(t,e-2,i);if(n<e)return n;e--}return 0}function tn(t,e){let i=t.charCodeAt(e);if(!Mo(i)||e+1==t.length)return i;let n=t.charCodeAt(e+1);return Ao(n)?(i-55296<<10)+(n-56320)+65536:i}function Ao(t){return t>=56320&&t<57344}function Mo(t){return t>=55296&&t<56320}function os(t){return t<65536?1:2}var I=class Oo{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,i,n){[e,i]=At(this,e,i);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(i,this.length,r,1),Ti.from(r,this.length-(i-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,i=this.length){[e,i]=At(this,e,i);let n=[];return this.decompose(e,i,n,0),Ti.from(n,i-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let i=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new zt(this),s=new zt(e);for(let o=i,l=i;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(l+=r.value.length,r.done||l>=n)return!0}}iter(e=1){return new zt(this,e)}iterRange(e,i=this.length){return new To(this,e,i)}iterLines(e,i){let n;if(e==null)n=this.iter();else{i==null&&(i=this.lines+1);let r=this.line(e).from;n=this.iterRange(r,Math.max(r,i==this.lines+1?this.length:i<=1?0:this.line(i-1).to))}return new Do(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]?Oo.empty:e.length<=32?new pe(e):Ti.from(pe.split(e,[]))}},pe=class Ae extends I{constructor(e,i=dh(e)){super(),this.text=e,this.length=i}get lines(){return this.text.length}get children(){return null}lineInner(e,i,n,r){for(let s=0;;s++){let o=this.text[s],l=r+o.length;if((i?n:l)>=e)return new ph(r,l,n,o);r=l+1,n++}}decompose(e,i,n,r){let s=e<=0&&i>=this.length?this:new Ae(ls(this.text,e,i),Math.min(i,this.length)-Math.max(0,e));if(r&1){let o=n.pop(),l=Di(s.text,o.text.slice(),0,s.length);if(l.length<=32)n.push(new Ae(l,o.length+s.length));else{let a=l.length>>1;n.push(new Ae(l.slice(0,a)),new Ae(l.slice(a)))}}else n.push(s)}replace(e,i,n){if(!(n instanceof Ae))return super.replace(e,i,n);[e,i]=At(this,e,i);let r=Di(this.text,Di(n.text,ls(this.text,0,e)),i),s=this.length+n.length-(i-e);return r.length<=32?new Ae(r,s):Ti.from(Ae.split(r,[]),s)}sliceString(e,i=this.length,n=`
|
|
2
|
+
`){[e,i]=At(this,e,i);let r="";for(let s=0,o=0;s<=i&&o<this.text.length;o++){let l=this.text[o],a=s+l.length;s>e&&o&&(r+=n),e<a&&i>s&&(r+=l.slice(Math.max(0,e-s),i-s)),s=a+1}return r}flatten(e){for(let i of this.text)e.push(i)}scanIdentical(){return 0}static split(e,i){let n=[],r=-1;for(let s of e)n.push(s),r+=s.length+1,n.length==32&&(i.push(new Ae(n,r)),n=[],r=-1);return r>-1&&i.push(new Ae(n,r)),i}},Ti=class ft extends I{constructor(e,i){super(),this.children=e,this.length=i,this.lines=0;for(let n of e)this.lines+=n.lines}lineInner(e,i,n,r){for(let s=0;;s++){let o=this.children[s],l=r+o.length,a=n+o.lines-1;if((i?a:l)>=e)return o.lineInner(e,i,n,r);r=l+1,n=a+1}}decompose(e,i,n,r){for(let s=0,o=0;o<=i&&s<this.children.length;s++){let l=this.children[s],a=o+l.length;if(e<=a&&i>=o){let h=r&((o<=e?1:0)|(a>=i?2:0));o>=e&&a<=i&&!h?n.push(l):l.decompose(e-o,i-o,n,h)}o=a+1}}replace(e,i,n){if([e,i]=At(this,e,i),n.lines<this.lines)for(let r=0,s=0;r<this.children.length;r++){let o=this.children[r],l=s+o.length;if(e>=s&&i<=l){let a=o.replace(e-s,i-s,n),h=this.lines-o.lines+a.lines;if(a.lines<h>>4&&a.lines>h>>6){let f=this.children.slice();return f[r]=a,new ft(f,this.length-(i-e)+n.length)}return super.replace(s,l,a)}s=l+1}return super.replace(e,i,n)}sliceString(e,i=this.length,n=`
|
|
3
|
+
`){[e,i]=At(this,e,i);let r="";for(let s=0,o=0;s<this.children.length&&o<=i;s++){let l=this.children[s],a=o+l.length;o>e&&s&&(r+=n),e<a&&i>o&&(r+=l.sliceString(e-o,i-o,n)),o=a+1}return r}flatten(e){for(let i of this.children)i.flatten(e)}scanIdentical(e,i){if(!(e instanceof ft))return 0;let n=0,[r,s,o,l]=i>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=i,s+=i){if(r==o||s==l)return n;let a=this.children[r],h=e.children[s];if(a!=h)return n+a.scanIdentical(h,i);n+=a.length+1}}static from(e,i=e.reduce((n,r)=>n+r.length+1,-1)){let n=0;for(let d of e)n+=d.lines;if(n<32){let d=[];for(let p of e)p.flatten(d);return new pe(d,i)}let r=Math.max(32,n>>5),s=r<<1,o=r>>1,l=[],a=0,h=-1,f=[];function u(d){let p;if(d.lines>s&&d instanceof ft)for(let g of d.children)u(g);else d.lines>o&&(a>o||!a)?(c(),l.push(d)):d instanceof pe&&a&&(p=f[f.length-1])instanceof pe&&d.lines+p.lines<=32?(a+=d.lines,h+=d.length+1,f[f.length-1]=new pe(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>r&&c(),a+=d.lines,h+=d.length+1,f.push(d))}function c(){a!=0&&(l.push(f.length==1?f[0]:ft.from(f,h)),h=-1,a=f.length=0)}for(let d of e)u(d);return c(),l.length==1?l[0]:new ft(l,i)}};I.empty=new pe([""],0);function dh(t){let e=-1;for(let i of t)e+=i.length+1;return e}function Di(t,e,i=0,n=1e9){for(let r=0,s=0,o=!0;s<t.length&&r<=n;s++){let l=t[s],a=r+l.length;a>=i&&(a>n&&(l=l.slice(0,n-r)),r<i&&(l=l.slice(i-r)),o?(e[e.length-1]+=l,o=!1):e.push(l)),r=a+1}return e}function ls(t,e,i){return Di(t,[""],e,i)}var zt=class{constructor(t,e=1){this.dir=e,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[e>0?1:(t instanceof pe?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],r=this.offsets[i],s=r>>1,o=n instanceof pe?n.text.length:n.children.length;if(s==(e>0?o:0)){if(i==0)return this.done=!0,this.value="",this;e>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((r&1)==(e>0?0:1)){if(this.offsets[i]+=e,t==0)return this.lineBreak=!0,this.value=`
|
|
4
|
+
`,this;t--}else if(n instanceof pe){let l=n.text[s+(e<0?-1:0)];if(this.offsets[i]+=e,l.length>Math.max(0,t))return this.value=t==0?l:e>0?l.slice(t):l.slice(0,l.length-t),this;t-=l.length}else{let l=n.children[s+(e<0?-1:0)];t>l.length?(t-=l.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(l),this.offsets.push(e>0?1:(l instanceof pe?l.text.length:l.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}},To=class{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new zt(t,e>i?-1:1),this.pos=e>i?t.length:0,this.from=Math.min(e,i),this.to=Math.max(e,i)}nextInner(t,e){if(e<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;t+=Math.max(0,e<0?this.pos-this.to:this.from-this.pos);let i=e<0?this.pos-this.from:this.to-this.pos;t>i&&(t=i),i-=t;let{value:n}=this.cursor.next(t);return this.pos+=(n.length+t)*e,this.value=n.length<=i?n:e<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(t=0){return t<0?t=Math.max(t,this.from-this.pos):t>0&&(t=Math.min(t,this.to-this.pos)),this.nextInner(t,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}},Do=class{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:n}=this.inner.next(t);return e&&this.afterBreak?(this.value="",this.afterBreak=!1):e?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<"u"&&(I.prototype[Symbol.iterator]=function(){return this.iter()},zt.prototype[Symbol.iterator]=To.prototype[Symbol.iterator]=Do.prototype[Symbol.iterator]=function(){return this});var ph=class{constructor(t,e,i,n){this.from=t,this.to=e,this.number=i,this.text=n}get length(){return this.to-this.from}};function At(t,e,i){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,i))]}function ae(t,e,i=!0,n=!0){return uh(t,e,i,n)}function gh(t){return t>=56320&&t<57344}function mh(t){return t>=55296&&t<56320}function Po(t,e){let i=t.charCodeAt(e);if(!mh(i)||e+1==t.length)return i;let n=t.charCodeAt(e+1);return gh(n)?(i-55296<<10)+(n-56320)+65536:i}function bh(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}function Bo(t){return t<65536?1:2}var Tn=/\r\n?|\n/,ie=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(ie||(ie={})),yt=class Pi{constructor(e){this.sections=e}get length(){let e=0;for(let i=0;i<this.sections.length;i+=2)e+=this.sections[i];return e}get newLength(){let e=0;for(let i=0;i<this.sections.length;i+=2){let n=this.sections[i+1];e+=n<0?this.sections[i]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let i=0,n=0,r=0;i<this.sections.length;){let s=this.sections[i++],o=this.sections[i++];o<0?(e(n,r,s),r+=s):r+=o,n+=s}}iterChangedRanges(e,i=!1){Dn(this,e,i)}get invertedDesc(){let e=[];for(let i=0;i<this.sections.length;){let n=this.sections[i++],r=this.sections[i++];r<0?e.push(n,r):e.push(r,n)}return new Pi(e)}composeDesc(e){return this.empty?e:e.empty?this:Eo(this,e)}mapDesc(e,i=!1){return e.empty?this:Pn(this,e,i)}mapPos(e,i=-1,n=ie.Simple){let r=0,s=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],h=r+l;if(a<0){if(h>e)return s+(e-r);s+=l}else{if(n!=ie.Simple&&h>=e&&(n==ie.TrackDel&&r<e&&h>e||n==ie.TrackBefore&&r<e||n==ie.TrackAfter&&h>e))return null;if(h>e||h==e&&i<0&&!l)return e==r||i<0?s:s+a;s+=a}r=h}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(e,i=e){for(let n=0,r=0;n<this.sections.length&&r<=i;){let s=this.sections[n++],o=this.sections[n++],l=r+s;if(o>=0&&r<=i&&l>=e)return r<e&&l>i?"cover":!0;r=l}return!1}toString(){let e="";for(let i=0;i<this.sections.length;){let n=this.sections[i++],r=this.sections[i++];e+=(e?" ":"")+n+(r>=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(i=>typeof i!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Pi(e)}static create(e){return new Pi(e)}},be=class $e extends yt{constructor(e,i){super(e),this.inserted=i}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Dn(this,(i,n,r,s,o)=>e=e.replace(r,r+(n-i),o),!1),e}mapDesc(e,i=!1){return Pn(this,e,i,!0)}invert(e){let i=this.sections.slice(),n=[];for(let r=0,s=0;r<i.length;r+=2){let o=i[r],l=i[r+1];if(l>=0){i[r]=l,i[r+1]=o;let a=r>>1;for(;n.length<a;)n.push(I.empty);n.push(o?e.slice(s,s+o):I.empty)}s+=o}return new $e(i,n)}compose(e){return this.empty?e:e.empty?this:Eo(this,e,!0)}map(e,i=!1){return e.empty?this:Pn(this,e,i,!0)}iterChanges(e,i=!1){Dn(this,e,i)}get desc(){return yt.create(this.sections)}filter(e){let i=[],n=[],r=[],s=new Zt(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&s.len==0;){if(s.done)break e;let f=Math.min(s.len,a-l);Q(r,f,-1);let u=s.ins==-1?-1:s.off==0?s.ins:0;Q(i,f,u),u>0&&qe(n,i,s.text),s.forward(f),l+=f}let h=e[o++];for(;l<h;){if(s.done)break e;let f=Math.min(s.len,h-l);Q(i,f,-1),Q(r,f,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(f),l+=f}}return{changes:new $e(i,n),filtered:yt.create(r)}}toJSON(){let e=[];for(let i=0;i<this.sections.length;i+=2){let n=this.sections[i],r=this.sections[i+1];r<0?e.push(n):r==0?e.push([n]):e.push([n].concat(this.inserted[i>>1].toJSON()))}return e}static of(e,i,n){let r=[],s=[],o=0,l=null;function a(f=!1){if(!f&&!r.length)return;o<i&&Q(r,i-o,-1);let u=new $e(r,s);l=l?l.compose(u.map(l)):u,r=[],s=[],o=0}function h(f){if(Array.isArray(f))for(let u of f)h(u);else if(f instanceof $e){if(f.length!=i)throw new RangeError(`Mismatched change set length (got ${f.length}, expected ${i})`);a(),l=l?l.compose(f.map(l)):f}else{let{from:u,to:c=u,insert:d}=f;if(u>c||u<0||c>i)throw new RangeError(`Invalid change range ${u} to ${c} (in doc of length ${i})`);let p=d?typeof d=="string"?I.of(d.split(n||Tn)):d:I.empty,g=p.length;if(u==c&&g==0)return;u<o&&a(),u>o&&Q(r,u-o,-1),Q(r,c-u,g),qe(s,r,p),o=c}}return h(e),a(!l),l}static empty(e){return new $e(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let i=[],n=[];for(let r=0;r<e.length;r++){let s=e[r];if(typeof s=="number")i.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)i.push(s[0],0);else{for(;n.length<r;)n.push(I.empty);n[r]=I.of(s.slice(1)),i.push(s[0],n[r].length)}}}return new $e(i,n)}static createSet(e,i){return new $e(e,i)}};function Q(t,e,i,n=!1){if(e==0&&i<=0)return;let r=t.length-2;r>=0&&i<=0&&i==t[r+1]?t[r]+=e:r>=0&&e==0&&t[r]==0?t[r+1]+=i:n?(t[r]+=e,t[r+1]+=i):t.push(e,i)}function qe(t,e,i){if(i.length==0)return;let n=e.length-2>>1;if(n<t.length)t[t.length-1]=t[t.length-1].append(i);else{for(;t.length<n;)t.push(I.empty);t.push(i)}}function Dn(t,e,i){let n=t.inserted;for(let r=0,s=0,o=0;o<t.sections.length;){let l=t.sections[o++],a=t.sections[o++];if(a<0)r+=l,s+=l;else{let h=r,f=s,u=I.empty;for(;h+=l,f+=a,a&&n&&(u=u.append(n[o-2>>1])),!(i||o==t.sections.length||t.sections[o+1]<0);)l=t.sections[o++],a=t.sections[o++];e(r,h,s,f,u),r=h,s=f}}}function Pn(t,e,i,n=!1){let r=[],s=n?[]:null,o=new Zt(t),l=new Zt(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);Q(r,h,-1),o.forward(h),l.forward(h)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!i))){let h=l.len;for(Q(r,l.ins,-1);h;){let f=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=f&&(Q(r,0,o.ins),s&&qe(s,r,o.text),a=o.i),o.forward(f),h-=f}l.next()}else if(o.ins>=0){let h=0,f=o.len;for(;f;)if(l.ins==-1){let u=Math.min(f,l.len);h+=u,f-=u,l.forward(u)}else if(l.ins==0&&l.len<f)f-=l.len,l.next();else break;Q(r,h,a<o.i?o.ins:0),s&&a<o.i&&qe(s,r,o.text),a=o.i,o.forward(o.len-f)}else{if(o.done&&l.done)return s?be.createSet(r,s):yt.create(r);throw new Error("Mismatched change set lengths")}}}function Eo(t,e,i=!1){let n=[],r=i?[]:null,s=new Zt(t),o=new Zt(e);for(let l=!1;;){if(s.done&&o.done)return r?be.createSet(n,r):yt.create(n);if(s.ins==0)Q(n,s.len,0,l),s.next();else if(o.len==0&&!o.done)Q(n,0,o.ins,l),r&&qe(r,n,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(s.len2,o.len),h=n.length;if(s.ins==-1){let f=o.ins==-1?-1:o.off?0:o.ins;Q(n,a,f,l),r&&f&&qe(r,n,o.text)}else o.ins==-1?(Q(n,s.off?0:s.len,a,l),r&&qe(r,n,s.textBit(a))):(Q(n,s.off?0:s.len,o.off?0:o.ins,l),r&&!o.off&&qe(r,n,o.text));l=(s.ins>a||o.ins>=0&&o.len>a)&&(l||n.length>h),s.forward2(a),o.forward(a)}}}}var Zt=class{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i<t.length?(this.len=t[this.i++],this.ins=t[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:t}=this.set,e=this.i-2>>1;return e>=t.length?I.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?I.empty:e[i].slice(this.off,t==null?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){this.ins==-1?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}},Rt=class Bn{constructor(e,i,n,r){this.from=e,this.to=i,this.flags=n,this.goalColumn=r}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 undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,i=-1){let n,r;return this.empty?n=r=e.mapPos(this.from,i):(n=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),n==this.from&&r==this.to?this:new Bn(n,r,this.flags,this.goalColumn)}extend(e,i=e,n=0){if(e<=this.anchor&&i>=this.anchor)return S.range(e,i,void 0,void 0,n);let r=Math.abs(e-this.anchor)>Math.abs(i-this.anchor)?e:i;return S.range(this.anchor,r,void 0,void 0,n)}eq(e,i=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!i||!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 S.range(e.anchor,e.head)}static create(e,i,n,r){return new Bn(e,i,n,r)}},S=class re{constructor(e,i){this.ranges=e,this.mainIndex=i}map(e,i=-1){return e.empty?this:re.create(this.ranges.map(n=>n.map(e,i)),this.mainIndex)}eq(e,i=!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],i))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new re([this.main],0)}addRange(e,i=!0){return re.create([e].concat(this.ranges),i?0:this.mainIndex+1)}replaceRange(e,i=this.mainIndex){let n=this.ranges.slice();return n[i]=e,re.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 re(e.ranges.map(i=>Rt.fromJSON(i)),e.main)}static single(e,i=e){return new re([re.range(e,i)],0)}static create(e,i=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let n=0,r=0;r<e.length;r++){let s=e[r];if(s.empty?s.from<=n:s.from<n)return re.normalized(e.slice(),i);n=s.to}return new re(e,i)}static cursor(e,i=0,n,r){return Rt.create(e,e,(i==0?0:i<0?8:16)|(n==null?7:Math.min(6,n)),r)}static range(e,i,n,r,s){let o=r==null?7:Math.min(6,r);return!s&&e!=i&&(s=i<e?1:-1),s&&(o|=s<0?8:16),i<e?Rt.create(i,e,o|32,n):Rt.create(e,i,o,n)}static undirectionalRange(e,i){return Rt.create(e,i,64,void 0)}static normalized(e,i=0){let n=e[i];e.sort((r,s)=>r.from-s.from),i=e.indexOf(n);for(let r=1;r<e.length;r++){let s=e[r],o=e[r-1];if(s.empty?s.from<=o.to:s.from<o.to){let l=o.from,a=Math.max(s.to,o.to);r<=i&&i--,e.splice(--r,2,s.anchor>s.head?re.range(a,l):re.range(l,a))}}return new re(e,i)}};function Ro(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}var Ar=0,C=class No{constructor(e,i,n,r,s){this.combine=e,this.compareInput=i,this.compare=n,this.isStatic=r,this.id=Ar++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new No(e.combine||(i=>i),e.compareInput||((i,n)=>i===n),e.compare||(e.combine?(i,n)=>i===n:Mr),!!e.static,e.enables)}of(e){return new Bi([],this,0,e)}compute(e,i){if(this.isStatic)throw new Error("Can't compute a static facet");return new Bi(e,this,1,i)}computeN(e,i){if(this.isStatic)throw new Error("Can't compute a static facet");return new Bi(e,this,2,i)}from(e,i){return i||(i=n=>n),this.compute([e],n=>i(n.field(e)))}};function Mr(t,e){return t==e||t.length==e.length&&t.every((i,n)=>i===e[n])}var Bi=class{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=Ar++}dynamicSlot(t){var e;let i=this.value,n=this.facet.compareInput,r=this.id,s=t[r]>>1,o=this.type==2,l=!1,a=!1,h=[];for(let f of this.dependencies)f=="doc"?l=!0:f=="selection"?a=!0:(((e=t[f.id])!==null&&e!==void 0?e:1)&1)==0&&h.push(t[f.id]);return{create(f){return f.values[s]=i(f),1},update(f,u){if(l&&u.docChanged||a&&(u.docChanged||u.selection)||En(f,h)){let c=i(f);if(o?!as(c,f.values[s],n):!n(c,f.values[s]))return f.values[s]=c,1}return 0},reconfigure:(f,u)=>{let c,d=u.config.address[r];if(d!=null){let p=Hi(u,d);if(this.dependencies.every(g=>g instanceof C?u.facet(g)===f.facet(g):g instanceof Ze?u.field(g,!1)==f.field(g,!1):!0)||(o?as(c=i(f),p,n):n(c=i(f),p)))return f.values[s]=p,0}else c=i(f);return f.values[s]=c,1}}}get extension(){return this}};function as(t,e,i){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!i(t[n],e[n]))return!1;return!0}function En(t,e){let i=!1;for(let n of e)Kt(t,n)&1&&(i=!0);return i}function yh(t,e,i){let n=i.map(a=>t[a.id]),r=i.map(a=>a.type),s=n.filter(a=>!(a&1)),o=t[e.id]>>1;function l(a){let h=[];for(let f=0;f<n.length;f++){let u=Hi(a,n[f]);if(r[f]==2)for(let c of u)h.push(c);else h.push(u)}return e.combine(h)}return{create(a){for(let h of n)Kt(a,h);return a.values[o]=l(a),1},update(a,h){if(!En(a,s))return 0;let f=l(a);return e.compare(f,a.values[o])?0:(a.values[o]=f,1)},reconfigure(a,h){let f=En(a,n),u=h.config.facets[e.id],c=h.facet(e);if(u&&!f&&Mr(i,u))return a.values[o]=c,0;let d=l(a);return e.compare(d,c)?(a.values[o]=c,0):(a.values[o]=d,1)}}}var pi=C.define({static:!0}),Ze=class Io{constructor(e,i,n,r,s){this.id=e,this.createF=i,this.updateF=n,this.compareF=r,this.spec=s,this.provides=void 0}static define(e){let i=new Io(Ar++,e.create,e.update,e.compare||((n,r)=>n===r),e);return e.provide&&(i.provides=e.provide(i)),i}create(e){let i=e.facet(pi).find(n=>n.field==this);return(i?.create||this.createF)(e)}slot(e){let i=e[this.id]>>1;return{create:n=>(n.values[i]=this.create(n),1),update:(n,r)=>{let s=n.values[i],o=this.updateF(s,r);return this.compareF(s,o)?0:(n.values[i]=o,1)},reconfigure:(n,r)=>{let s=n.facet(pi),o=r.facet(pi),l;return(l=s.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(n.values[i]=l.create(n),1):r.config.address[this.id]!=null?(n.values[i]=r.field(this),0):(n.values[i]=this.create(n),1)}}}init(e){return[this,pi.of({field:this,create:e})]}get extension(){return this}},st={lowest:4,low:3,default:2,high:1,highest:0};function Nt(t){return e=>new Lo(e,t)}var oi={highest:Nt(st.highest),high:Nt(st.high),default:Nt(st.default),low:Nt(st.low),lowest:Nt(st.lowest)},Lo=class{constructor(t,e){this.inner=t,this.prec=e}get extension(){return this}},Or=class Ho{of(e){return new Rn(this,e)}reconfigure(e){return Ho.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},Rn=class{constructor(t,e){this.compartment=t,this.inner=e}get extension(){return this}},hs=class Wo{constructor(e,i,n,r,s,o){for(this.base=e,this.compartments=i,this.dynamicSlots=n,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let i=this.address[e.id];return i==null?e.default:this.staticValues[i>>1]}static resolve(e,i,n){let r=[],s=Object.create(null),o=new Map;for(let u of vh(e,i,o))u instanceof Ze?r.push(u):(s[u.facet.id]||(s[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],h=[];for(let u of r)l[u.id]=h.length<<1,h.push(c=>u.slot(c));let f=n?.config.facets;for(let u in s){let c=s[u],d=c[0].facet,p=f&&f[u]||[];if(c.every(g=>g.type==0))if(l[d.id]=a.length<<1|1,Mr(p,c))a.push(n.facet(d));else{let g=d.combine(c.map(m=>m.value));a.push(n&&d.compare(g,n.facet(d))?n.facet(d):g)}else{for(let g of c)g.type==0?(l[g.id]=a.length<<1|1,a.push(g.value)):(l[g.id]=h.length<<1,h.push(m=>g.dynamicSlot(m)));l[d.id]=h.length<<1,h.push(g=>yh(g,d,c))}}return new Wo(e,o,h.map(u=>u(l)),l,a,s)}};function vh(t,e,i){let n=[[],[],[],[],[]],r=new Map;function s(o,l){let a=r.get(o);if(a!=null){if(a<=l)return;let h=n[a].indexOf(o);h>-1&&n[a].splice(h,1),o instanceof Rn&&i.delete(o.compartment)}if(r.set(o,l),Array.isArray(o))for(let h of o)s(h,l);else if(o instanceof Rn){if(i.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;i.set(o.compartment,h),s(h,l)}else if(o instanceof Lo)s(o.inner,o.prec);else if(o instanceof Ze)n[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof Bi)n[l].push(o),o.facet.extensions&&s(o.facet.extensions,st.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(h==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(h,l)}}return s(t,st.default),n.reduce((o,l)=>o.concat(l))}function Kt(t,e){if(e&1)return 2;let i=e>>1,n=t.status[i];if(n==4)throw new Error("Cyclic dependency between fields and/or facets");if(n&2)return n;t.status[i]=4;let r=t.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|r}function Hi(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}var Fo=C.define(),Nn=C.define({combine:t=>t.some(e=>e),static:!0}),Vo=C.define({combine:t=>t.length?t[0]:void 0,static:!0}),$o=C.define(),jo=C.define(),zo=C.define(),Ko=C.define({combine:t=>t.length?t[0]:!1}),at=class{constructor(t,e){this.type=t,this.value=e}static define(){return new wh}},wh=class{of(t){return new at(this,t)}},xh=class{constructor(t){this.map=t}of(t){return new $(this,t)}},$=class qo{constructor(e,i){this.type=e,this.value=i}map(e){let i=this.type.map(this.value,e);return i===void 0?void 0:i==this.value?this:new qo(this.type,i)}is(e){return this.type==e}static define(e={}){return new xh(e.map||(i=>i))}static mapEffects(e,i){if(!e.length)return e;let n=[];for(let r of e){let s=r.map(i);s&&n.push(s)}return n}};$.reconfigure=$.define();$.appendConfig=$.define();var he=class Wt{constructor(e,i,n,r,s,o){this.startState=e,this.changes=i,this.selection=n,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,n&&Ro(n,i.newLength),s.some(l=>l.type==Wt.time)||(this.annotations=s.concat(Wt.time.of(Date.now())))}static create(e,i,n,r,s,o){return new Wt(e,i,n,r,s,o)}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 i of this.annotations)if(i.type==e)return i.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let i=this.annotation(Wt.userEvent);return!!(i&&(i==e||i.length>e.length&&i.slice(0,e.length)==e&&i[e.length]=="."))}};he.time=at.define();he.userEvent=at.define();he.addToHistory=at.define();he.remote=at.define();function kh(t,e){let i=[];for(let n=0,r=0;;){let s,o;if(n<t.length&&(r==e.length||e[r]>=t[n]))s=t[n++],o=t[n++];else if(r<e.length)s=e[r++],o=e[r++];else return i;!i.length||i[i.length-1]<s?i.push(s,o):i[i.length-1]<o&&(i[i.length-1]=o)}}function Go(t,e,i){var n;let r,s,o;return i?(r=e.changes,s=be.empty(e.changes.length),o=t.changes.compose(e.changes)):(r=e.changes.map(t.changes),s=t.changes.mapDesc(e.changes,!0),o=t.changes.compose(r)),{changes:o,selection:e.selection?e.selection.map(s):(n=t.selection)===null||n===void 0?void 0:n.map(r),effects:$.mapEffects(t.effects,r).concat($.mapEffects(e.effects,s)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function In(t,e,i){let n=e.selection,r=vt(e.annotations);return e.userEvent&&(r=r.concat(he.userEvent.of(e.userEvent))),{changes:e.changes instanceof be?e.changes:be.of(e.changes||[],i,t.facet(Vo)),selection:n&&(n instanceof S?n:S.single(n.anchor,n.head)),effects:vt(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}function Uo(t,e,i){let n=In(t,e.length?e[0]:{},t.doc.length);e.length&&e[0].filter===!1&&(i=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(i=!1);let o=!!e[s].sequential;n=Go(n,In(t,e[s],o?n.changes.newLength:t.doc.length),o)}let r=he.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return Ch(i?Sh(r):r)}function Sh(t){let e=t.startState,i=!0;for(let r of e.facet($o)){let s=r(t);if(s===!1){i=!1;break}Array.isArray(s)&&(i=i===!0?s:kh(i,s))}if(i!==!0){let r,s;if(i===!1)s=t.changes.invertedDesc,r=be.empty(e.doc.length);else{let o=t.changes.filter(i);r=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}t=he.create(e,r,t.selection&&t.selection.map(s),$.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let n=e.facet(jo);for(let r=n.length-1;r>=0;r--){let s=n[r](t);s instanceof he?t=s:Array.isArray(s)&&s.length==1&&s[0]instanceof he?t=s[0]:t=Uo(e,vt(s),!1)}return t}function Ch(t){let e=t.startState,i=e.facet(zo),n=t;for(let r=i.length-1;r>=0;r--){let s=i[r](t);s&&Object.keys(s).length&&(n=Go(n,In(e,s,t.changes.newLength),!0))}return n==t?t:he.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}var Ah=[];function vt(t){return t==null?Ah:Array.isArray(t)?t:[t]}var Te=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(Te||(Te={})),Mh=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Ln;try{Ln=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Oh(t){if(Ln)return Ln.test(t);for(let e=0;e<t.length;e++){let i=t[e];if(/\w/.test(i)||i>""&&(i.toUpperCase()!=i.toLowerCase()||Mh.test(i)))return!0}return!1}function Th(t){return e=>{if(!/\S/.test(e))return Te.Space;if(Oh(e))return Te.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return Te.Word;return Te.Other}}var U=class ce{constructor(e,i,n,r,s,o){this.config=e,this.doc=i,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)Kt(this,l<<1);this.computeSlot=null}field(e,i=!0){let n=this.config.address[e.id];if(n==null){if(i)throw new RangeError("Field is not present in this state");return}return Kt(this,n),Hi(this,n)}update(...e){return Uo(this,e,!0)}applyTransaction(e){let i=this.config,{base:n,compartments:r}=i;for(let l of e.effects)l.is(Or.reconfigure)?(i&&(r=new Map,i.compartments.forEach((a,h)=>r.set(h,a)),i=null),r.set(l.value.compartment,l.value.extension)):l.is($.reconfigure)?(i=null,n=l.value):l.is($.appendConfig)&&(i=null,n=vt(n).concat(l.value));let s;i?s=e.startState.values.slice():(i=hs.resolve(n,r,this),s=new ce(i,this.doc,this.selection,i.dynamicSlots.map(()=>null),(l,a)=>a.reconfigure(l,this),null).values);let o=e.startState.facet(Nn)?e.newSelection:e.newSelection.asSingle();new ce(i,e.newDoc,o,s,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:e},range:S.cursor(i.from+e.length,-1)}))}changeByRange(e){let i=this.selection,n=e(i.ranges[0]),r=this.changes(n.changes),s=[n.range],o=vt(n.effects);for(let l=1;l<i.ranges.length;l++){let a=e(i.ranges[l]),h=this.changes(a.changes),f=h.map(r);for(let c=0;c<l;c++)s[c]=s[c].map(f);let u=r.mapDesc(h,!0);s.push(a.range.map(u)),r=r.compose(f),o=$.mapEffects(o,f).concat($.mapEffects(vt(a.effects),u))}return{changes:r,selection:S.create(s,i.mainIndex),effects:o}}changes(e=[]){return e instanceof be?e:be.of(e,this.doc.length,this.facet(ce.lineSeparator))}toText(e){return I.of(e.split(this.facet(ce.lineSeparator)||Tn))}sliceDoc(e=0,i=this.doc.length){return this.doc.sliceString(e,i,this.lineBreak)}facet(e){let i=this.config.address[e.id];return i==null?e.default:(Kt(this,i),Hi(this,i))}toJSON(e){let i={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof Ze&&this.config.address[r.id]!=null&&(i[n]=r.spec.toJSON(this.field(e[n]),this))}return i}static fromJSON(e,i={},n){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(n){for(let s in n)if(Object.prototype.hasOwnProperty.call(e,s)){let o=n[s],l=e[s];r.push(o.init(a=>o.spec.fromJSON(l,a)))}}return ce.create({doc:e.doc,selection:S.fromJSON(e.selection),extensions:i.extensions?r.concat([i.extensions]):r})}static create(e={}){let i=hs.resolve(e.extensions||[],new Map),n=e.doc instanceof I?e.doc:I.of((e.doc||"").split(i.staticFacet(ce.lineSeparator)||Tn)),r=e.selection?e.selection instanceof S?e.selection:S.single(e.selection.anchor,e.selection.head):S.single(0);return Ro(r,n.length),i.staticFacet(Nn)||(r=r.asSingle()),new ce(i,n,r,i.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(ce.tabSize)}get lineBreak(){return this.facet(ce.lineSeparator)||`
|
|
5
|
+
`}get readOnly(){return this.facet(Ko)}phrase(e,...i){for(let n of this.facet(ce.phrases))if(Object.prototype.hasOwnProperty.call(n,e)){e=n[e];break}return i.length&&(e=e.replace(/\$(\$|\d*)/g,(n,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>i.length?n:i[s-1]})),e}languageDataAt(e,i,n=-1){let r=[];for(let s of this.facet(Fo))for(let o of s(this,i,n))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){let i=this.languageDataAt("wordChars",e);return Th(i.length?i[0]:"")}wordAt(e){let{text:i,from:n,length:r}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-n,l=e-n;for(;o>0;){let a=ae(i,o,!1);if(s(i.slice(a,o))!=Te.Word)break;o=a}for(;l<r;){let a=ae(i,l);if(s(i.slice(l,a))!=Te.Word)break;l=a}return o==l?null:S.range(o+n,l+n)}};U.allowMultipleSelections=Nn;U.tabSize=C.define({combine:t=>t.length?t[0]:4});U.lineSeparator=Vo;U.readOnly=Ko;U.phrases=C.define({compare(t,e){let i=Object.keys(t),n=Object.keys(e);return i.length==n.length&&i.every(r=>t[r]==e[r])}});U.languageData=Fo;U.changeFilter=$o;U.transactionFilter=jo;U.transactionExtender=zo;Or.reconfigure=$.define();function Ui(t,e,i={}){let n={};for(let r of t)for(let s of Object.keys(r)){let o=r[s],l=n[s];if(l===void 0)n[s]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(i,s))n[s]=i[s](l,o);else throw new Error("Config merge conflict for field "+s)}for(let r in e)n[r]===void 0&&(n[r]=e[r]);return n}var Ue=class{eq(t){return this==t}range(t,e=t){return Hn.create(t,e,this)}};Ue.prototype.startSide=Ue.prototype.endSide=0;Ue.prototype.point=!1;Ue.prototype.mapMode=ie.TrackDel;function Tr(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}var Hn=class Yo{constructor(e,i,n){this.from=e,this.to=i,this.value=n}static create(e,i,n){return new Yo(e,i,n)}};function Wn(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}var Dh=class _o{constructor(e,i,n,r){this.from=e,this.to=i,this.value=n,this.maxPoint=r}get length(){return ut(this.to)}findIndex(e,i,n,r=0){let s=n?this.to:this.from;for(let o=r,l=s.length;;){if(o==l)return o;let a=o+l>>1,h=s[a]-e||(n?this.value[a].endSide:this.value[a].startSide)-i;if(a==o)return h>=0?o:l;h>=0?l=a:o=a+1}}between(e,i,n,r){for(let s=this.findIndex(i,-1e9,!0),o=this.findIndex(n,1e9,!1,s);s<o;s++)if(r(this.from[s]+e,this.to[s]+e,this.value[s])===!1)return!1}map(e,i,n,r,s){let o=[],l=[],a=[],h=-1,f=-1;e:for(let u=0;u<this.value.length;u++){let c=this.value[u],d=this.from[u]+e,p=this.to[u]+e,g,m;if(d==p){let b=i.mapPos(d,c.startSide,c.mapMode);if(b==null||(g=m=b,c.startSide!=c.endSide&&(m=i.mapPos(d,c.endSide),m<g)))continue}else if(g=i.mapPos(d,c.startSide),m=i.mapPos(p,c.endSide),g>m||g==m&&c.startSide>0&&c.endSide<=0)continue;if(!((m-g||c.endSide-c.startSide)<0))if(h<0&&(h=g),c.point&&(f=Math.max(f,m-g)),(g-n||c.startSide-r)>=0)o.push(c),l.push(g-h),a.push(m-h),n=m,r=c.endSide;else{if(g==m)for(let b=o.length;b>0;b--){if((g-(a[b-1]+h)||c.startSide-o[b-1].endSide)>=0){o.splice(b,0,c),l.splice(b,0,g-h),a.splice(b,0,m-h);continue e}if((g-(l[b-1]+h)||c.endSide-o[b-1].startSide)>0)break}s(g,m,c)}}return{mapped:o.length?new _o(l,a,o,f):null,pos:h}}},F=class Ie{constructor(e,i,n,r){this.chunkPos=e,this.chunk=i,this.nextLayer=n,this.maxPoint=r}static create(e,i,n,r){return new Ie(e,i,n,r)}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 i of this.chunk)e+=i.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:i=[],sort:n=!1,filterFrom:r=0,filterTo:s=this.length}=e,o=e.filter;if(i.length==0&&!o)return this;if(n&&(i=i.slice().sort(Wn)),this.isEmpty)return i.length?Ie.of(i):this;let l=new Xo(this,null,-1).goto(0),a=0,h=[],f=new wt;for(;l.value||a<i.length;)if(a<i.length&&(l.from-i[a].from||l.startSide-i[a].value.startSide)>=0){let u=i[a++];f.addInner(u.from,u.to,u.value,!1)||h.push(u)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(a==i.length||this.chunkEnd(l.chunkIndex)<i[a].from)&&(!o||r>this.chunkEnd(l.chunkIndex)||s<this.chunkPos[l.chunkIndex])&&f.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!o||r>l.to||s<l.from||o(l.from,l.to,l.value))&&(f.addInner(l.from,l.to,l.value,!1)||h.push(Hn.create(l.from,l.to,l.value))),l.next());return f.finishInner(this.nextLayer.isEmpty&&!h.length?Ie.empty:this.nextLayer.update({add:h,filter:o,filterFrom:r,filterTo:s}))}map(e){if(e.empty||this.isEmpty)return this;let i=[],n=[],r=-1,s,o=(a,h,f)=>{s||(s=new wt),s.addRange(a,h,f,!1)};for(let a=0;a<this.chunk.length;a++){let h=this.chunkPos[a],f=this.chunk[a],u=e.touchesRange(h,h+f.length);if(u===!1)r=Math.max(r,f.maxPoint),i.push(f),n.push(e.mapPos(h));else if(u===!0){let[c,d]=i.length?[ut(n)+ut(i).length,ut(ut(i).value).endSide]:[-1,-1],{mapped:p,pos:g}=f.map(h,e,c,d,o);p&&(r=Math.max(r,p.maxPoint),i.push(p),n.push(g))}}let l=this.nextLayer.map(e);return s&&(l=s.finishInner(l)),i.length==0?l:new Ie(n,i,l||Ie.empty,r)}between(e,i,n){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let s=this.chunkPos[r],o=this.chunk[r];if(i>=s&&e<=s+o.length&&o.between(s,e-s,i-s,n)===!1)return}this.nextLayer.between(e,i,n)}}iter(e=0){return Fn.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,i=0){return Fn.from(e).goto(i)}static compare(e,i,n,r,s=-1){let o=e.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=s),l=i.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=s),a=fs(o,l,n),h=new It(o,a,s),f=new It(l,a,s);n.iterGaps((u,c,d)=>us(h,u,f,c,d,r)),n.empty&&n.length==0&&us(h,0,f,0,0,r)}static eq(e,i,n=0,r){r==null&&(r=999999999);let s=e.filter(f=>!f.isEmpty&&i.indexOf(f)<0),o=i.filter(f=>!f.isEmpty&&e.indexOf(f)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let l=fs(s,o),a=new It(s,l,0).goto(n),h=new It(o,l,0).goto(n);for(;;){if(a.to!=h.to||!Vn(a.active,h.active)||a.point&&(!h.point||!Tr(a.point,h.point)))return!1;if(a.to>r)return!0;a.next(),h.next()}}static spans(e,i,n,r,s=-1){let o=new It(e,null,s).goto(i),l=i,a=o.openStart;for(;;){let h=Math.min(o.to,n);if(o.point){let f=o.activeForPoint(o.to),u=o.pointFrom<i?f.length+1:o.point.startSide<0?f.length:Math.min(f.length,a);r.point(l,h,o.point,f,u,o.pointRank),a=Math.min(o.openEnd(h),f.length)}else h>l&&(r.span(l,h,o.active,a),a=o.openEnd(h));if(o.to>n)return a+(o.point&&o.to>n?1:0);l=o.to,o.next()}}static of(e,i=!1){let n=new wt;for(let r of e instanceof Hn?[e]:i?Ph(e):e)n.add(r.from,r.to,r.value);return n.finish()}static join(e){if(!e.length)return Ie.empty;let i=ut(e);for(let n=e.length-2;n>=0;n--)for(let r=e[n];r!=Ie.empty;r=r.nextLayer)i=new Ie(r.chunkPos,r.chunk,i,Math.max(r.maxPoint,i.maxPoint));return i}};F.empty=new F([],[],null,-1);function ut(t){return t[t.length-1]}function Ph(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let n=t[i];if(Wn(e,n)>0)return t.slice().sort(Wn);e=n}return t}F.empty.nextLayer=F.empty;var wt=class Jo{finishChunk(e){this.chunks.push(new Dh(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,i,n){this.addRange(e,i,n,!0)}addRange(e,i,n,r){this.addInner(e,i,n,r)||(this.nextLayer||(this.nextLayer=new Jo)).addRange(e,i,n,r)}addInner(e,i,n,r){let s=e-this.lastTo||n.startSide-this.last.endSide;if(r&&s<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return s<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(i-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=i,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,i-e)),!0)}addChunk(e,i){if((e-this.lastTo||i.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,i.maxPoint),this.chunks.push(i),this.chunkPos.push(e);let n=i.value.length-1;return this.last=i.value[n],this.lastFrom=i.from[n]+e,this.lastTo=i.to[n]+e,!0}finish(){return this.finishInner(F.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let i=F.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,i}};function fs(t,e,i){let n=new Map;for(let s of t)for(let o=0;o<s.chunk.length;o++)s.chunk[o].maxPoint<=0&&n.set(s.chunk[o],s.chunkPos[o]);let r=new Set;for(let s of e)for(let o=0;o<s.chunk.length;o++){let l=n.get(s.chunk[o]);l!=null&&(i?i.mapPos(l):l)==s.chunkPos[o]&&!i?.touchesRange(l,l+s.chunk[o].length)&&r.add(s.chunk[o])}return r}var Xo=class{constructor(t,e,i,n=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex<this.layer.chunk.length;){let n=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(n)||this.layer.chunkEnd(this.chunkIndex)<t||n.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let n=this.layer.chunk[this.chunkIndex].findIndex(t-this.layer.chunkPos[this.chunkIndex],e,!0);(!i||this.rangeIndex<n)&&this.setRangeIndex(n)}this.next()}forward(t,e){(this.to-t||this.endSide-e)<0&&this.gotoInner(t,e,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let t=this.layer.chunkPos[this.chunkIndex],e=this.layer.chunk[this.chunkIndex];if(this.from=t+e.from[this.rangeIndex],this.to=t+e.to[this.rangeIndex],this.value=e.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(t){if(t==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=t}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.rank-t.rank||this.to-t.to||this.endSide-t.endSide}},Fn=class Qo{constructor(e){this.heap=e}static from(e,i=null,n=-1){let r=[];for(let s=0;s<e.length;s++)for(let o=e[s];!o.isEmpty;o=o.nextLayer)o.maxPoint>=n&&r.push(new Xo(o,i,n,s));return r.length==1?r[0]:new Qo(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,i=-1e9){for(let n of this.heap)n.goto(e,i);for(let n=this.heap.length>>1;n>=0;n--)nn(this.heap,n);return this.next(),this}forward(e,i){for(let n of this.heap)n.forward(e,i);for(let n=this.heap.length>>1;n>=0;n--)nn(this.heap,n);(this.to-e||this.value.endSide-i)<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(),nn(this.heap,0)}}};function nn(t,e){for(let i=t[e];;){let n=(e<<1)+1;if(n>=t.length)break;let r=t[n];if(n+1<t.length&&r.compare(t[n+1])>=0&&(r=t[n+1],n++),i.compare(r)<0)break;t[n]=i,t[e]=r,e=n}}var It=class{constructor(t,e,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Fn.from(t,e,i)}goto(t,e=-1e9){return this.cursor.goto(t,e),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=t,this.endSide=e,this.openStart=-1,this.next(),this}forward(t,e){for(;this.minActive>-1&&(this.activeTo[this.minActive]-t||this.active[this.minActive].endSide-e)<0;)this.removeActive(this.minActive);this.cursor.forward(t,e)}removeActive(t){gi(this.active,t),gi(this.activeTo,t),gi(this.activeRank,t),this.minActive=cs(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:n,rank:r}=this.cursor;for(;e<this.activeRank.length&&(r-this.activeRank[e]||n-this.activeTo[e])>0;)e++;mi(this.active,e,i),mi(this.activeTo,e,n),mi(this.activeRank,e,r),t&&mi(t,e,this.cursor.from),this.minActive=cs(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>t){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&gi(i,n)}else if(this.cursor.value)if(this.cursor.from>t){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let r=this.cursor.value;if(!r.point)this.addActive(i),this.cursor.next();else if(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=r,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=r.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(i){this.openStart=0;for(let n=i.length-1;n>=0&&i[n]<t;n--)this.openStart++}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&e.push(this.active[i]);return e.reverse()}openEnd(t){let e=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)e++;return e}};function us(t,e,i,n,r,s){t.goto(e),i.goto(n);let o=n+r,l=n,a=n-e,h=!!s.boundChange;for(let f=!1;;){let u=t.to+a-i.to,c=u||t.endSide-i.endSide,d=c<0?t.to+a:i.to,p=Math.min(d,o);if(t.point||i.point?(t.point&&i.point&&Tr(t.point,i.point)&&Vn(t.activeForPoint(t.to),i.activeForPoint(i.to))||s.comparePoint(l,p,t.point,i.point),f=!1):(f&&(s.boundChange(l),f=!1),p>l&&!Vn(t.active,i.active)&&s.compareRange(l,p,t.active,i.active),h&&p<o&&(u||t.openEnd(d)!=i.openEnd(d))&&(f=!0)),d>o)break;l=d,c<=0&&t.next(),c>=0&&i.next()}}function Vn(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(t[i]!=e[i]&&!Tr(t[i],e[i]))return!1;return!0}function gi(t,e){for(let i=e,n=t.length-1;i<n;i++)t[i]=t[i+1];t.pop()}function mi(t,e,i){for(let n=t.length-1;n>=e;n--)t[n+1]=t[n];t[e]=i}function cs(t,e){let i=-1,n=1e9;for(let r=0;r<e.length;r++)(e[r]-n||t[r].endSide-t[i].endSide)<0&&(i=r,n=e[r]);return i}function Zo(t,e,i=t.length){let n=0;for(let r=0;r<i&&r<t.length;)t.charCodeAt(r)==9?(n+=e-n%e,r++):(n++,r=ae(t,r));return n}function Bh(t,e,i,n){for(let r=0,s=0;;){if(s>=e)return r;if(r==t.length)break;s+=t.charCodeAt(r)==9?i-s%i:1,r=ae(t,r)}return n===!0?-1:t.length}var $n="ͼ",ds=typeof Symbol>"u"?"__"+$n:Symbol.for($n),jn=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),ps=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{},Ye=class{constructor(t,e){this.rules=[];let{finish:i}=e||{};function n(s){return/^@/.test(s)?[s]:s.split(/,\s*/)}function r(s,o,l,a){let h=[],f=/^@(\w+)\b/.exec(s[0]),u=f&&f[1]=="keyframes";if(f&&o==null)return l.push(s[0]+";");for(let c in o){let d=o[c];if(/&/.test(c))r(c.split(/,\s*/).map(p=>s.map(g=>p.replace(/&/,g))).reduce((p,g)=>p.concat(g)),d,l);else if(d&&typeof d=="object"){if(!f)throw new RangeError("The value of a property ("+c+") should be a primitive value.");r(n(c),d,h,u)}else d!=null&&h.push(c.replace(/_.*/,"").replace(/[A-Z]/g,p=>"-"+p.toLowerCase())+": "+d+";")}(h.length||u)&&l.push((i&&!f&&!a?s.map(i):s).join(", ")+" {"+h.join(" ")+"}")}for(let s in t)r(n(s),t[s],this.rules)}getRules(){return this.rules.join(`
|
|
6
|
+
`)}static newName(){let t=ps[ds]||1;return ps[ds]=t+1,$n+t.toString(36)}static mount(t,e,i){let n=t[jn],r=i&&i.nonce;n?r&&n.setNonce(r):n=new Eh(t,r),n.mount(Array.isArray(e)?e:[e],t)}},gs=new Map,Eh=class{constructor(t,e){let i=t.ownerDocument||t,n=i.defaultView;if(!t.head&&t.adoptedStyleSheets&&n.CSSStyleSheet){let r=gs.get(i);if(r)return t[jn]=r;this.sheet=new n.CSSStyleSheet,gs.set(i,this)}else this.styleTag=i.createElement("style"),e&&this.styleTag.setAttribute("nonce",e);this.modules=[],t[jn]=this}mount(t,e){let i=this.sheet,n=0,r=0,s=!1;for(let o=0;o<t.length;o++){let l=t[o],a=this.modules.indexOf(l);if(a<r&&a>-1&&(this.modules.splice(a,1),s=!0,r--,a=-1),a==-1){if(this.modules.splice(r++,0,l),s=!0,i)for(let h=0;h<l.rules.length;h++)i.insertRule(l.rules[h],n++)}else{for(;r<a;)n+=this.modules[r++].rules.length;n+=l.rules.length,r++}}if(i)e.adoptedStyleSheets.indexOf(this.sheet)<0&&(e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets]);else{if(s){let l="";for(let a=0;a<this.modules.length;a++)l+=this.modules[a].getRules()+`
|
|
7
|
+
`;this.styleTag.textContent=l}let o=e.head||e;this.styleTag.parentNode!=o&&o.insertBefore(this.styleTag,o.firstChild)}}setNonce(t){this.styleTag&&this.styleTag.getAttribute("nonce")!=t&&this.styleTag.setAttribute("nonce",t)}},_e={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},ei={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Rh=typeof navigator<"u"&&/Mac/.test(navigator.platform),Nh=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var J=0;J<10;J++)_e[48+J]=_e[96+J]=String(J);for(var J=1;J<=24;J++)_e[J+111]="F"+J;for(var J=65;J<=90;J++)_e[J]=String.fromCharCode(J+32),ei[J]=String.fromCharCode(J);for(var rn in _e)ei.hasOwnProperty(rn)||(ei[rn]=_e[rn]);function Ih(t){var e=!(Rh&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Nh&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified")&&t.key||(t.shiftKey?ei:_e)[t.keyCode]||t.key||"Unidentified";return e=="Esc"&&(e="Escape"),e=="Del"&&(e="Delete"),e=="Left"&&(e="ArrowLeft"),e=="Up"&&(e="ArrowUp"),e=="Right"&&(e="ArrowRight"),e=="Down"&&(e="ArrowDown"),e}function nt(){var t=arguments[0];typeof t=="string"&&(t=document.createElement(t));var e=1,i=arguments[1];if(i&&typeof i=="object"&&i.nodeType==null&&!Array.isArray(i)){for(var n in i)if(Object.prototype.hasOwnProperty.call(i,n)){var r=i[n];typeof r=="string"?t.setAttribute(n,r):r!=null&&(t[n]=r)}e++}for(;e<arguments.length;e++)el(t,arguments[e]);return t}function el(t,e){if(typeof e=="string")t.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)t.appendChild(e);else if(Array.isArray(e))for(var i=0;i<e.length;i++)el(t,e[i]);else throw new RangeError("Unsupported child node: "+e)}var ee=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},zn=typeof document<"u"?document:{documentElement:{style:{}}},Kn=/Edge\/(\d+)/.exec(ee.userAgent),tl=/MSIE \d/.test(ee.userAgent),qn=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ee.userAgent),Yi=!!(tl||qn||Kn),ms=!Yi&&/gecko\/(\d+)/i.test(ee.userAgent),sn=!Yi&&/Chrome\/(\d+)/.exec(ee.userAgent),bs="webkitFontSmoothing"in zn.documentElement.style,Gn=!Yi&&/Apple Computer/.test(ee.vendor),ys=Gn&&(/Mobile\/\w+/.test(ee.userAgent)||ee.maxTouchPoints>2),w={mac:ys||/Mac/.test(ee.platform),windows:/Win/.test(ee.platform),linux:/Linux|X11/.test(ee.platform),ie:Yi,ie_version:tl?zn.documentMode||6:qn?+qn[1]:Kn?+Kn[1]:0,gecko:ms,gecko_version:ms?+(/Firefox\/(\d+)/.exec(ee.userAgent)||[0,0])[1]:0,chrome:!!sn,chrome_version:sn?+sn[1]:0,ios:ys,android:/Android\b/.test(ee.userAgent),webkit:bs,webkit_version:bs?+(/\bAppleWebKit\/(\d+)/.exec(ee.userAgent)||[0,0])[1]:0,safari:Gn,safari_version:Gn?+(/\bVersion\/(\d+(\.\d+)?)/.exec(ee.userAgent)||[0,0])[1]:0,tabSize:zn.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Dr(t,e){for(let i in t)i=="class"&&e.class?e.class+=" "+t.class:i=="style"&&e.style?e.style+=";"+t.style:e[i]=t[i];return e}var Wi=Object.create(null);function Pr(t,e,i){if(t==e)return!0;t||(t=Wi),e||(e=Wi);let n=Object.keys(t),r=Object.keys(e);if(n.length-0!=r.length-0)return!1;for(let s of n)if(s!=i&&(r.indexOf(s)==-1||t[s]!==e[s]))return!1;return!0}function Lh(t,e){for(let i=t.attributes.length-1;i>=0;i--){let n=t.attributes[i].name;e[n]==null&&t.removeAttribute(n)}for(let i in e){let n=e[i];i=="style"?t.style.cssText=n:t.getAttribute(i)!=n&&t.setAttribute(i,n)}}function vs(t,e,i){let n=!1;if(e)for(let r in e)i&&r in i||(n=!0,r=="style"?t.style.cssText="":t.removeAttribute(r));if(i)for(let r in i)e&&e[r]==i[r]||(n=!0,r=="style"?t.style.cssText=i[r]:t.setAttribute(r,i[r]));return n}function Hh(t){let e=Object.create(null);for(let i=0;i<t.attributes.length;i++){let n=t.attributes[i];e[n.name]=n.value}return e}var et=class{eq(t){return!1}updateDOM(t,e,i){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(t){return!0}coordsAt(t,e,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(t){}},ne=(function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t})(ne||(ne={})),N=class extends Ue{constructor(t,e,i,n){super(),this.startSide=t,this.endSide=e,this.widget=i,this.spec=n}get heightRelevant(){return!1}static mark(t){return new Br(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),i=!!t.block;return e+=i&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8,new ti(t,e,e,i,t.widget||null,!1)}static replace(t){let e=!!t.block,i,n;if(t.isBlockGap)i=-5e8,n=4e8;else{let{start:r,end:s}=sl(t,e);i=(r?e?-3e8:-1:5e8)-1,n=(s?e?2e8:1:-6e8)+1}return new ti(t,i,n,e,t.widget||null,!0)}static line(t){return new Er(t)}static set(t,e=!1){return F.of(t,e)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};N.none=F.empty;var Br=class il extends N{constructor(e){let{start:i,end:n}=sl(e);super(i?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Dr(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Wi}eq(e){return this==e||e instanceof il&&this.tagName==e.tagName&&Pr(this.attrs,e.attrs)}range(e,i=e){if(e>=i)throw new RangeError("Mark decorations may not be empty");return super.range(e,i)}};Br.prototype.point=!1;var Er=class nl extends N{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof nl&&this.spec.class==e.spec.class&&Pr(this.spec.attributes,e.spec.attributes)}range(e,i=e){if(i!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,i)}};Er.prototype.mapMode=ie.TrackBefore;Er.prototype.point=!0;var ti=class rl extends N{constructor(e,i,n,r,s,o){super(i,n,s,e),this.block=r,this.isReplace=o,this.mapMode=r?i<=0?ie.TrackBefore:ie.TrackAfter:ie.TrackDel}get type(){return this.startSide!=this.endSide?ne.WidgetRange:this.startSide<=0?ne.WidgetBefore:ne.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof rl&&Wh(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,i=e){if(this.isReplace&&(e>i||e==i&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&i!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,i)}};ti.prototype.point=!0;function sl(t,e=!1){let{inclusiveStart:i,inclusiveEnd:n}=t;return i==null&&(i=t.inclusive),n==null&&(n=t.inclusive),{start:i??e,end:n??e}}function Wh(t,e){return t==e||!!(t&&e&&t.compare(e))}function xt(t,e,i,n=0){let r=i.length-1;r>=0&&i[r]+n>=t?i[r]=Math.max(i[r],e):i.push(t,e)}var ws=class Un extends Ue{constructor(e,i,n){super(),this.tagName=e,this.attributes=i,this.rank=n}eq(e){return e==this||e instanceof Un&&this.tagName==e.tagName&&Pr(this.attributes,e.attributes)}static create(e){return new Un(e.tagName,e.attributes||Wi,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,i=!1){return F.of(e,i)}};ws.prototype.startSide=ws.prototype.endSide=-1;var _=t=>t.nodeType==1,Mt=t=>t.nodeType==3;function ii(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Yn(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function qt(t,e){if(!e.anchorNode)return!1;try{return Yn(t,e.anchorNode)}catch{return!1}}function Gt(t){return Mt(t)?ri(t,0,t.nodeValue.length).getClientRects():_(t)?t.getClientRects():[]}function Ut(t,e,i,n){return i?xs(t,e,i,n,-1)||xs(t,e,i,n,1):!1}function Je(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function Fi(t){return _(t)&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function xs(t,e,i,n,r){for(;;){if(t==i&&e==n)return!0;if(e==(r<0?0:Ve(t))){if(t.nodeName=="DIV")return!1;let s=t.parentNode;if(!s||!_(s))return!1;e=Je(t)+(r<0?0:1),t=s}else if(_(t)){if(t=t.childNodes[e+(r<0?-1:0)],_(t)&&(t.nodeName=="IMG"||t.nodeName=="BR"||t.contentEditable=="false"))return!1;e=r<0?Ve(t):0}else return!1}}function Ve(t){return Mt(t)?t.nodeValue.length:t.childNodes.length}function ni(t,e){let{left:i,right:n}=t;if(i==n)return t;let r=e?i:n;return{left:r,right:r,top:t.top,bottom:t.bottom}}function Fh(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function ol(t,e){let i=e.width/t.offsetWidth,n=e.height/t.offsetHeight;return(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.width-t.offsetWidth)<1)&&(i=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.height-t.offsetHeight)<1)&&(n=1),{scaleX:i,scaleY:n}}function Vh(t,e,i,n,r,s,o,l){let a=t.ownerDocument,h=a.defaultView||window;for(let f=t,u=!1;f&&!u;)if(_(f)){let c,d=f==a.body,p=1,g=1,m=!0,b=!0;if(d)c=Fh(h);else{let O=getComputedStyle(f);if(/^(fixed|sticky)$/.test(O.position)&&(u=!0),(f.scrollHeight<=f.clientHeight||!/auto|scroll/.test(O.overflowY))&&(b=!1),(f.scrollWidth<=f.clientWidth||!/auto|scroll/.test(O.overflowX))&&(m=!1),!m&&!b){f=f.assignedSlot||f.parentNode;continue}let k=f.getBoundingClientRect();({scaleX:p,scaleY:g}=ol(f,k)),c={left:k.left,right:k.left+f.clientWidth*p,top:k.top,bottom:k.top+f.clientHeight*g}}let x=0,A=0;if(b)if(r=="nearest")e.top<c.top+o?(A=e.top-(c.top+o),i>0&&e.bottom>c.bottom+A&&(A=e.bottom-c.bottom+o)):e.bottom>c.bottom-o&&(A=e.bottom-c.bottom+o,i<0&&e.top-A<c.top&&(A=e.top-(c.top+o)));else{let O=e.bottom-e.top,k=c.bottom-c.top;A=(r=="center"&&O<=k?e.top+O/2-k/2:r=="start"||r=="center"&&i<0?e.top-o:e.bottom-k+o)-c.top}if(m&&(n=="nearest"?e.left<c.left+s?(x=e.left-(c.left+s),i>0&&e.right>c.right+x&&(x=e.right-c.right+s)):e.right>c.right-s&&(x=e.right-c.right+s,i<0&&e.left<c.left+x&&(x=e.left-(c.left+s))):x=(n=="center"?e.left+(e.right-e.left)/2-(c.right-c.left)/2:n=="start"==l?e.left-s:e.right-(c.right-c.left)+s)-c.left),x||A)if(d)h.scrollBy(x,A);else{let O=0,k=0;if(A){let P=f.scrollTop;f.scrollTop+=A/g,k=(f.scrollTop-P)*g}if(x){let P=f.scrollLeft;f.scrollLeft+=x/p,O=(f.scrollLeft-P)*p}e={left:e.left-O,top:e.top-k,right:e.right-O,bottom:e.bottom-k},O&&Math.abs(O-x)<1&&(n="nearest"),k&&Math.abs(k-A)<1&&(r="nearest")}if(d)break;(e.top<c.top||e.bottom>c.bottom||e.left<c.left||e.right>c.right)&&(e={left:Math.max(e.left,c.left),right:Math.min(e.right,c.right),top:Math.max(e.top,c.top),bottom:Math.min(e.bottom,c.bottom)}),f=f.assignedSlot||f.parentNode}else if(f.nodeType==11)f=f.host;else break}function ll(t,e=!0){let i=t.ownerDocument,n=null,r=null;for(let s=t.parentNode;s&&!(s==i.body||(!e||n)&&r);)if(_(s))!r&&s.scrollHeight>s.clientHeight&&/scroll|auto/.test(getComputedStyle(s).overflowY)&&(r=s),e&&!n&&s.scrollWidth>s.clientWidth&&/scroll|auto/.test(getComputedStyle(s).overflowX)&&(n=s),s=s.assignedSlot||s.parentNode;else if(s.nodeType==11)s=s.host;else break;return{x:n,y:r}}var $h=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:i}=t;this.set(e,Math.min(t.anchorOffset,e?Ve(e):0),i,Math.min(t.focusOffset,i?Ve(i):0))}set(t,e,i,n){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=n}};function al(t){let e=[];for(let i=t;i;i=i.nodeType==11?i.host:i.parentNode)_(i)&&e.push({node:i,left:i.scrollLeft,top:i.scrollTop});return e}function hl(t,e=!0){for(let{node:i,left:n,top:r}of t)e&&i.scrollTop!=r&&(i.scrollTop=r),i.scrollLeft!=n&&(i.scrollLeft=n)}var rt=null;w.safari&&w.safari_version>=26&&(rt=!1);function fl(t){if(t.setActive)return t.setActive();if(rt)return t.focus(rt);let e=al(t);t.focus(rt==null?{get preventScroll(){return rt={preventScroll:!0},!0}}:void 0),rt||(rt=!1,hl(e))}var ks;function ri(t,e,i=e){let n=ks||(ks=document.createRange());return n.setEnd(t,i),n.setStart(t,e),n}function kt(t,e,i,n){let r={key:e,code:e,keyCode:i,which:i,cancelable:!0};n&&({altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}=n);let s=new KeyboardEvent("keydown",r);s.synthetic=!0,t.dispatchEvent(s);let o=new KeyboardEvent("keyup",r);return o.synthetic=!0,t.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function jh(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function zh(t,e){let i=e.focusNode,n=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=n)return!1;for(n=Math.min(n,Ve(i));;)if(n){if(!_(i))return!1;let r=i.childNodes[n-1];r.contentEditable=="false"?n--:(i=r,n=Ve(i))}else{if(i==t)return!0;n=Je(i),i=i.parentNode}}function ul(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function cl(t,e){for(let i=t,n=e;;){if(Mt(i)&&n>0)return{node:i,offset:n};if(_(i)&&n>0){if(i.contentEditable=="false")return null;i=i.childNodes[n-1],n=Ve(i)}else if(i.parentNode&&!Fi(i))n=Je(i),i=i.parentNode;else return null}}function dl(t,e){for(let i=t,n=e;;){if(Mt(i)&&n<i.nodeValue.length)return{node:i,offset:n};if(_(i)&&n<i.childNodes.length){if(i.contentEditable=="false")return null;i=i.childNodes[n],n=0}else if(i.parentNode&&!Fi(i))n=Je(i)+1,i=i.parentNode;else return null}}var Ge=class _n{constructor(e,i,n=!0){this.node=e,this.offset=i,this.precise=n}static before(e,i){return new _n(e.parentNode,Je(e),i)}static after(e,i){return new _n(e.parentNode,Je(e)+1,i)}},q=(function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t})(q||(q={})),Ot=q.LTR,Rr=q.RTL;function pl(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}var Kh=pl("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),qh=pl("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Jn=Object.create(null),Se=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),i=t.charCodeAt(1);Jn[e]=i,Jn[i]=-e}function gl(t){return t<=247?Kh[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?qh[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8204?256:64336<=t&&t<=65023?4:1}var Gh=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,De=class{get dir(){return this.level%2?Rr:Ot}constructor(t,e,i){this.from=t,this.to=e,this.level=i}side(t,e){return this.dir==e==t?this.to:this.from}forward(t,e){return t==(this.dir==e)}static find(t,e,i,n){let r=-1;for(let s=0;s<t.length;s++){let o=t[s];if(o.from<=e&&o.to>=e){if(o.level==i)return s;(r<0||(n!=0?n<0?o.from<e:o.to>e:t[r].level>o.level))&&(r=s)}}if(r<0)throw new RangeError("Index out of range");return r}};function ml(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let n=t[i],r=e[i];if(n.from!=r.from||n.to!=r.to||n.direction!=r.direction||!ml(n.inner,r.inner))return!1}return!0}var H=[];function Uh(t,e,i,n,r){for(let s=0;s<=n.length;s++){let o=s?n[s-1].to:e,l=s<n.length?n[s].from:i,a=s?256:r;for(let h=o,f=a,u=a;h<l;h++){let c=gl(t.charCodeAt(h));c==512?c=f:c==8&&u==4&&(c=16),H[h]=c==4?2:c,c&7&&(u=c),f=c}for(let h=o,f=a,u=a;h<l;h++){let c=H[h];if(c==128)h<l-1&&f==H[h+1]&&f&24?c=H[h]=f:H[h]=256;else if(c==64){let d=h+1;for(;d<l&&H[d]==64;)d++;let p=h&&f==8||d<i&&H[d]==8?u==1?1:8:256;for(let g=h;g<d;g++)H[g]=p;h=d-1}else c==8&&u==1&&(H[h]=1);f=c,c&7&&(u=c)}}}function Yh(t,e,i,n,r){let s=r==1?2:1;for(let o=0,l=0,a=0;o<=n.length;o++){let h=o?n[o-1].to:e,f=o<n.length?n[o].from:i;for(let u=h,c,d,p;u<f;u++)if(d=Jn[c=t.charCodeAt(u)])if(d<0){for(let g=l-3;g>=0;g-=3)if(Se[g+1]==-d){let m=Se[g+2],b=m&2?r:m&4?m&1?s:r:0;b&&(H[u]=H[Se[g]]=b),l=g;break}}else{if(Se.length==189)break;Se[l++]=u,Se[l++]=c,Se[l++]=a}else if((p=H[u])==2||p==1){let g=p==r;a=g?0:1;for(let m=l-3;m>=0;m-=3){let b=Se[m+2];if(b&2)break;if(g)Se[m+2]|=2;else{if(b&4)break;Se[m+2]|=4}}}}}function _h(t,e,i,n){for(let r=0,s=n;r<=i.length;r++){let o=r?i[r-1].to:t,l=r<i.length?i[r].from:e;for(let a=o;a<l;){let h=H[a];if(h==256){let f=a+1;for(;;)if(f==l){if(r==i.length)break;f=i[r++].to,l=r<i.length?i[r].from:e}else if(H[f]==256)f++;else break;let u=s==1,c=u==((f<e?H[f]:n)==1)?u?1:2:n;for(let d=f,p=r,g=p?i[p-1].to:t;d>a;)d==g&&(d=i[--p].from,g=p?i[p-1].to:t),H[--d]=c;a=f}else s=h,a++}}}function Xn(t,e,i,n,r,s,o){let l=n%2?2:1;if(n%2==r%2)for(let a=e,h=0;a<i;){let f=!0,u=!1;if(h==s.length||a<s[h].from){let g=H[a];g!=l&&(f=!1,u=g==16)}let c=!f&&l==1?[]:null,d=f?n:n+1,p=a;e:for(;;)if(h<s.length&&p==s[h].from){if(u)break e;let g=s[h];if(!f)for(let m=g.to,b=h+1;;){if(m==i)break e;if(b<s.length&&s[b].from==m)m=s[b++].to;else{if(H[m]==l)break e;break}}h++,c?c.push(g):(g.from>a&&o.push(new De(a,g.from,d)),Qn(t,g.direction==Ot!=!(d%2)?n+1:n,r,g.inner,g.from,g.to,o),a=g.to),p=g.to}else{if(p==i||(f?H[p]!=l:H[p]==l))break;p++}c?Xn(t,a,p,n+1,r,c,o):a<p&&o.push(new De(a,p,d)),a=p}else for(let a=i,h=s.length;a>e;){let f=!0,u=!1;if(!h||a>s[h-1].to){let g=H[a-1];g!=l&&(f=!1,u=g==16)}let c=!f&&l==1?[]:null,d=f?n:n+1,p=a;e:for(;;)if(h&&p==s[h-1].to){if(u)break e;let g=s[--h];if(!f)for(let m=g.from,b=h;;){if(m==e)break e;if(b&&s[b-1].to==m)m=s[--b].from;else{if(H[m-1]==l)break e;break}}c?c.push(g):(g.to<a&&o.push(new De(g.to,a,d)),Qn(t,g.direction==Ot!=!(d%2)?n+1:n,r,g.inner,g.from,g.to,o),a=g.from),p=g.from}else{if(p==e||(f?H[p-1]!=l:H[p-1]==l))break;p--}c?Xn(t,p,a,n+1,r,c,o):p<a&&o.push(new De(p,a,d)),a=p}}function Qn(t,e,i,n,r,s,o){let l=e%2?2:1;Uh(t,r,s,n,l),Yh(t,r,s,n,l),_h(r,s,n,l),Xn(t,r,s,e,i,n,o)}function Jh(t,e,i){if(!t)return[new De(0,0,e==Rr?1:0)];if(e==Ot&&!i.length&&!Gh.test(t))return bl(t.length);if(i.length)for(;t.length>H.length;)H[H.length]=256;let n=[],r=e==Ot?0:1;return Qn(t,r,r,i,0,t.length,n),n}function bl(t){return[new De(0,t,0)]}var yl="";function Xh(t,e,i,n,r){var s;if(!t.length)return null;let o=n.head-t.from,l;if(n.head==t.from&&n.assoc<0){if(!r)return null;o=e[l=0].side(!1,i)}else if(n.head==t.to&&n.assoc>0){if(r)return null;o=e[l=e.length-1].side(!0,i)}else l=De.find(e,o,(s=n.bidiLevel)!==null&&s!==void 0?s:-1,n.assoc);let a=e[l],h=a.side(r,i);if(o==h){let c=l+=r?1:-1;if(c<0||c>=e.length)return null;a=e[l=c],o=a.side(!r,i),h=a.side(r,i)}let f=ae(t.text,o,a.forward(r,i));(f<a.from||f>a.to)&&(f=h),yl=t.text.slice(Math.min(o,f),Math.max(o,f));let u=l==(r?e.length-1:0)?null:e[l+(r?1:-1)];if(f==h){if(!u)return r?S.cursor(t.to,1):S.cursor(t.from,-1);if(u.level+(r?0:1)<a.level)return S.cursor(u.side(!r,i)+t.from,u.forward(r,i)?1:-1,u.level)}return S.cursor(f+t.from,a.forward(r,i)?-1:1,a.level)}function Qh(t,e,i){for(let n=e;n<i;n++){let r=gl(t.charCodeAt(n));if(r==1)return Ot;if(r==2||r==4)return Rr}}var vl=C.define(),wl=C.define(),xl=C.define(),kl=C.define(),Zn=C.define(),Sl=C.define(),Cl=C.define(),Nr=C.define(),Ir=C.define(),Al=C.define({combine:t=>t.some(e=>e)}),Zh=C.define({combine:t=>t.some(e=>e)}),Ml=C.define(),on=class er{constructor(e,i,n,r,s,o=!1){this.range=e,this.y=i,this.x=n,this.yMargin=r,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new er(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new er(S.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},bi=$.define({map:(t,e)=>t.map(e)}),Ol=$.define();function Pe(t,e,i){let n=t.facet(kl);n.length?n[0](e):window.onerror&&window.onerror(String(e),i,void 0,void 0,e)}var He=C.define({combine:t=>t.length?t[0]:!0}),ef=0,dt=C.define({combine(t){return t.filter((e,i)=>{for(let n=0;n<i;n++)if(t[n].plugin==e.plugin)return!1;return!0})}}),Be=class tr{constructor(e,i,n,r,s){this.id=e,this.create=i,this.domEventHandlers=n,this.domEventObservers=r,this.baseExtensions=s(this),this.extension=this.baseExtensions.concat(dt.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(dt.of({plugin:this,arg:e}))}static define(e,i){const{eventHandlers:n,eventObservers:r,provide:s,decorations:o}=i||{};return new tr(ef++,e,n,r,l=>{let a=[];return o&&a.push(_i.of(h=>{let f=h.plugin(l);return f?o(f):N.none})),s&&a.push(s(l)),a})}static fromClass(e,i){return tr.define((n,r)=>new e(n,r),i)}},ln=class{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(t){if(this.value){if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(i){if(Pe(e.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(t,this.spec.arg)}catch(e){Pe(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(!((e=this.value)===null||e===void 0)&&e.destroy)try{this.value.destroy()}catch(i){Pe(t.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},Tl=C.define(),Lr=C.define(),_i=C.define(),Dl=C.define(),Hr=C.define(),li=C.define(),Pl=C.define();function Ss(t,e){let i=t.state.facet(Pl);if(!i.length)return i;let n=i.map(s=>s instanceof Function?s(t):s),r=[];return F.spans(n,e.from,e.to,{point(){},span(s,o,l,a){let h=s-e.from,f=o-e.from,u=r;for(let c=l.length-1;c>=0;c--,a--){let d=l[c].spec.bidiIsolate,p;if(a>0&&u.length&&(p=u[u.length-1]).to==h&&p.direction==d)p.to=f,u=p.inner;else{let g={from:h,to:f,direction:d,inner:[]};u.push(g),u=g.inner}}}}),Bl(e.text,r)}function Bl(t,e){for(let i of e){if(i.direction==null){for(let n=i.from,r=0;n<i.to;r++){let s=r<i.inner.length?i.inner[r]:null,o=Qh(t,n,s?s.from:i.to);if(o){i.direction=o;break}if(!s)break;n=s.to}i.direction==null&&(i.direction=q.LTR)}Bl(t,i.inner)}return e}var El=C.define();function Rl(t){let e=0,i=0,n=0,r=0;for(let s of t.state.facet(El)){let o=s(t);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(i=Math.max(i,o.right)),o.top!=null&&(n=Math.max(n,o.top)),o.bottom!=null&&(r=Math.max(r,o.bottom)))}return{left:e,right:i,top:n,bottom:r}}var Ft=C.define(),Fe=class ir{constructor(e,i,n,r){this.fromA=e,this.toA=i,this.fromB=n,this.toB=r}join(e){return new ir(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let i=e.length,n=this;for(;i>0;i--){let r=e[i-1];if(!(r.fromA>n.toA)){if(r.toA<n.fromA)break;n=n.join(r),e.splice(i-1,1)}}return e.splice(i,0,n),e}static extendWithRanges(e,i){if(i.length==0)return e;let n=[];for(let r=0,s=0,o=0;;){let l=r<e.length?e[r].fromB:1e9,a=s<i.length?i[s]:1e9,h=Math.min(l,a);if(h==1e9)break;let f=h+o,u=h,c=f;for(;;)if(s<i.length&&i[s]<=u){let d=i[s+1];s+=2,u=Math.max(u,d);for(let p=r;p<e.length&&e[p].fromB<=u;p++)o=e[p].toA-e[p].toB;c=Math.max(c,d+o)}else if(r<e.length&&e[r].fromB<=u){let d=e[r++];u=Math.max(u,d.toB),c=Math.max(c,d.toA),o=d.toA-d.toB}else break;n.push(new ir(f,c,h,u))}return n}},Cs=class Nl{constructor(e,i,n){this.view=e,this.state=i,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=be.empty(this.startState.doc.length);for(let s of n)this.changes=this.changes.compose(s.changes);let r=[];this.changes.iterChangedRanges((s,o,l,a)=>r.push(new Fe(s,o,l,a))),this.changedRanges=r}static create(e,i,n){return new Nl(e,i,n)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},tf=[],G=class{constructor(t,e,i=0){this.dom=t,this.length=e,this.flags=i,this.parent=null,t.cmTile=this}get breakAfter(){return this.flags&1}get children(){return tf}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(t){if(this.flags|=2,this.flags&4){this.flags&=-5;let e=this.domAttrs;e&&Lh(this.dom,e)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(t){this.dom=t,t.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(t,e=this.posAtStart){let i=e;for(let n of this.children){if(n==t)return i;i+=n.length+n.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}covers(t){return!0}coordsIn(t,e,i){return null}domPosFor(t,e){let i=Je(this.dom),n=this.length?t>0:e>0;return new Ge(this.parent.dom,i+(n?1:0),t==0||t==this.length)}markDirty(t){this.flags&=-3,t&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let t=this;t;t=t.parent)if(t instanceof Xi)return t;return null}static get(t){return t.cmTile}},Ji=class extends G{constructor(t){super(t,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(t){this.children.push(t),t.parent=this}sync(t){if(this.flags&2)return;super.sync(t);let e=this.dom,i=null,n,r=t?.node==e?t:null,s=0;for(let o of this.children){if(o.sync(t),s+=o.length+o.breakAfter,n=i?i.nextSibling:e.firstChild,r&&n!=o.dom&&(r.written=!0),o.dom.parentNode==e)for(;n&&n!=o.dom;)n=As(n);else e.insertBefore(o.dom,n);i=o.dom}for(n=i?i.nextSibling:e.firstChild,r&&n&&(r.written=!0);n;)n=As(n);this.length=s}};function As(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}var Xi=class extends Ji{constructor(t,e){super(e),this.view=t}owns(t){for(;t;t=t.parent)if(t==this)return!0;return!1}isBlock(){return!0}nearest(t){for(;;){if(!t)return null;let e=G.get(t);if(e&&this.owns(e))return e;t=t.parentNode}}blockTiles(t){for(let e=[],i=this,n=0,r=0;;)if(n==i.children.length){if(!e.length)return;i=i.parent,i.breakAfter&&r++,n=e.pop()}else{let s=i.children[n++];if(s instanceof ot)e.push(n),i=s,n=0;else{let o=r+s.length,l=t(s,r);if(l!==void 0)return l;r=o+s.breakAfter}}}resolveBlock(t,e){let i,n=-1,r,s=-1;if(this.blockTiles((o,l)=>{let a=l+o.length;if(t>=l&&t<=a){if(o.isWidget()&&e>=-1&&e<=1){if(o.flags&32)return!0;o.flags&16&&(i=void 0)}(l<t||t==a&&(e<-1?o.length:o.covers(1)))&&(!i||!o.isWidget()&&i.isWidget())&&(i=o,n=t-l),(a>t||t==l&&(e>1?o.length:o.covers(-1)))&&(!r||!o.isWidget()&&r.isWidget())&&(r=o,s=t-l)}}),!i&&!r)throw new Error("No tile at position "+t);return i&&e<0||!r?{tile:i,offset:n}:{tile:r,offset:s}}},ot=class Il extends Ji{constructor(e,i){super(e),this.wrapper=i}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,i){let n=new Il(i||document.createElement(e.tagName),e);return i||(n.flags|=4),n}},Vi=class Ll extends Ji{constructor(e,i){super(e),this.attrs=i}isLine(){return!0}static start(e,i,n){let r=new Ll(i||document.createElement("div"),e);return(!i||!n)&&(r.flags|=4),r}get domAttrs(){return this.attrs}resolveInline(e,i,n=!1){let r=null,s=-1,o=null,l=-1;function a(f,u){for(let c=0,d=0;c<f.children.length&&d<=u;c++){let p=f.children[c],g=d+p.length;g>=u&&(p.isComposite()?a(p,u-d):(!o||n&&o.isHidden&&(i>0&&!(o.flags&32)||n&&rf(o,p)))&&(g>u||p.flags&32&&i<=1)?(o=p,l=u-d):(d<u||p.flags&16&&!(n&&p.isHidden)&&i>=-1)&&(r=p,s=u-d)),d=g}}a(this,e);let h=(i<0?r:o)||r||o;return h?{tile:h,offset:h==r?s:l}:null}coordsIn(e,i,n){let r=this.resolveInline(e,i,!0);return r?r.tile.coordsIn(Math.max(0,r.offset),i,n):nf(this)}domIn(e,i){let n=this.resolveInline(e,i);if(n){let{tile:r,offset:s}=n;if(this.dom.contains(r.dom))return r.isText()?new Ge(r.dom,Math.min(r.dom.nodeValue.length,s)):r.domPosFor(s,r.flags&16?1:r.flags&32?-1:i);let o=n.tile.parent,l=!1;for(let a of o.children){if(l)return new Ge(a.dom,0);a==n.tile&&(l=!0)}}return new Ge(this.dom,0)}};function nf(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=Gt(e);return i[i.length-1]||null}function rf(t,e){let i=t.coordsIn(0,1),n=e.coordsIn(0,1);return i&&n&&n.top<i.bottom}var oe=class Hl extends Ji{constructor(e,i){super(e),this.mark=i}get domAttrs(){return this.mark.attrs}static of(e,i){let n=new Hl(i||document.createElement(e.tagName),e);return i||(n.flags|=4),n}},Vt=class Wl extends G{constructor(e,i){super(e,i.length),this.text=i}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,i,n){let r=this.dom.nodeValue.length;e>r&&(e=r);let s=e,o=e,l=0;e==0&&i<0||e==r&&i>=0?w.chrome||w.gecko||(e?(s--,l=1):o<r&&(o++,l=-1)):i<0?s--:o<r&&o++;let a=ri(this.dom,s,o).getClientRects();if(!a.length)return null;let h=a[(l?l<0:i>=0)?0:a.length-1];return w.safari&&!l&&h.width==0&&(h=Array.prototype.find.call(a,f=>f.width)||h),n==null?h:ni(h,(l?l>0:i<0)==n)}static of(e,i){let n=new Wl(i||document.createTextNode(e),e);return i||(n.flags|=2),n}},si=class Fl extends G{constructor(e,i,n,r){super(e,i,r),this.widget=n}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,i){return this.coordsInWidget(e,i,!1)}coordsInWidget(e,i,n){let r=this.widget.coordsAt(this.dom,e,i);if(r)return r;if(n)return ni(this.dom.getBoundingClientRect(),this.length?e==0:i<=0);{let s=this.dom.getClientRects(),o=null;if(!s.length)return null;let l=this.flags&16?!0:this.flags&32?!1:e>0;for(let a=l?s.length-1:0;o=s[a],!(e>0?a==0:a==s.length-1||o.top<o.bottom);a+=l?-1:1);return ni(o,!l)}}get overrideDOMText(){if(!this.length)return I.empty;let{root:e}=this;if(!e)return I.empty;let i=this.posAtStart;return e.view.state.doc.slice(i,i+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,i,n,r,s){return s||(s=e.toDOM(i),e.editable||(s.contentEditable="false")),new Fl(s,n,e,r)}},$i=class extends G{constructor(t){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),super(e,0,t)}get isHidden(){return!0}get overrideDOMText(){return I.empty}coordsIn(t,e,i){let n=this.dom.getBoundingClientRect();return i==null?n:ni(n,e>0==i)}},sf=class{constructor(t){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=t}advance(t,e,i){let{tile:n,index:r,beforeBreak:s,parents:o}=this;for(;t||e>0;)if(n.isComposite())if(s){if(!t)break;i&&i.break(),t--,s=!1}else if(r==n.children.length){if(!t&&!o.length)break;i&&i.leave(n),s=!!n.breakAfter,{tile:n,index:r}=o.pop(),r++}else{let l=n.children[r],a=l.breakAfter;(e>0?l.length<=t:l.length<t)&&(!i||i.skip(l,0,l.length)!==!1||!l.isComposite)?(s=!!a,r++,t-=l.length):(o.push({tile:n,index:r}),n=l,r=0,i&&l.isComposite()&&i.enter(l))}else{let l=n.length;if(r<l&&t){let a=Math.min(t,l-r);i&&i.skip(n,r,r+a),t-=a,r+=a}if(r==l)s=!!n.breakAfter,{tile:n,index:r}=o.pop(),r++;else if(!t)break}return this.tile=n,this.index=r,this.beforeBreak=s,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}},of=class{constructor(t,e,i,n){this.from=t,this.to=e,this.wrapper=i,this.rank=n}},lf=class{constructor(t,e,i){this.cache=t,this.root=e,this.blockWrappers=i,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(t,e,i,n){var r;this.flushBuffer();let s=this.ensureMarks(e,i),o=s.lastChild;if(o&&o.isText()&&!(o.flags&8)&&o.length+t.length<512){this.cache.reused.set(o,2);let l=s.children[s.children.length-1]=new Vt(o.dom,o.text+t);l.parent=s}else s.append(n||Vt.of(t,(r=this.cache.find(Vt))===null||r===void 0?void 0:r.dom));this.pos+=t.length,this.afterWidget=null}addComposition(t,e){let i=this.curLine;i.dom!=e.line.dom&&(i.setDOM(this.cache.reused.has(e.line)?an(e.line.dom):e.line.dom),this.cache.reused.set(e.line,2));let n=i;for(let o=e.marks.length-1;o>=0;o--){let l=e.marks[o],a=n.lastChild;if(a instanceof oe&&a.mark.eq(l.mark))a.dom!=l.dom&&a.setDOM(an(l.dom)),n=a;else{let{dom:h}=l;this.cache.reused.get(l)&&G.get(l.dom)&&(h=an(l.dom));let f=oe.of(l.mark,h);n.append(f),n=f}this.cache.reused.set(l,2)}let r=G.get(t.text);r&&this.cache.reused.set(r,2);let s=new Vt(t.text,t.text.nodeValue);s.flags|=8,this.pos=t.range.toB,n.append(s)}addInlineWidget(t,e,i){let n=this.afterWidget&&t.flags&48&&(this.afterWidget.flags&48)==(t.flags&48);n||this.flushBuffer();let r=this.ensureMarks(e,i);!n&&!(t.flags&16)&&r.append(this.getBuffer(1)),r.append(t),this.pos+=t.length,this.afterWidget=t}addMark(t,e,i){this.flushBuffer(),this.ensureMarks(e,i).append(t),this.pos+=t.length,this.afterWidget=null}addBlockWidget(t){this.getBlockPos().append(t),this.pos+=t.length,this.lastBlock=t,this.endLine()}continueWidget(t){let e=this.afterWidget||this.lastBlock;e.length+=t,this.pos+=t}addLineStart(t,e){var i;t||(t=Vl);let n=Vi.start(t,e||((i=this.cache.find(Vi))===null||i===void 0?void 0:i.dom),!!e);this.getBlockPos().append(this.lastBlock=this.curLine=n)}addLine(t){this.getBlockPos().append(t),this.pos+=t.length,this.lastBlock=t,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(t){this.blockPosCovered()||this.addLineStart(t)}ensureLine(t){this.curLine||this.addLineStart(t)}ensureMarks(t,e){var i;let n=this.curLine;for(let r=t.length-1;r>=0;r--){let s=t[r],o;if(e>0&&(o=n.lastChild)&&o instanceof oe&&o.mark.eq(s))n=o,e--;else{let l=oe.of(s,(i=this.cache.find(oe,a=>a.mark.eq(s)))===null||i===void 0?void 0:i.dom);n.append(l),n=l,e=0}}return n}endLine(){if(this.curLine){this.flushBuffer();let t=this.curLine.lastChild;(!t||!Ms(this.curLine,!1)||t.dom.nodeName!="BR"&&t.isWidget()&&!(w.ios&&Ms(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(hn,0,32)||new si(hn.toDOM(),0,hn,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let t=this.wrappers.length-1;t>=0;t--)this.wrappers[t].to<this.pos&&this.wrappers.splice(t,1);for(let t=this.blockWrappers;t.value&&t.from<=this.pos;t.next())if(t.to>=this.pos){let e=t.rank*102+t.value.rank,i=new of(t.from,t.to,t.value,e),n=this.wrappers.length;for(;n>0&&(this.wrappers[n-1].rank-i.rank||this.wrappers[n-1].to-i.to)<0;)n--;this.wrappers.splice(n,0,i)}this.wrapperPos=this.pos}getBlockPos(){var t;this.updateBlockWrappers();let e=this.root;for(let i of this.wrappers){let n=e.lastChild;if(i.from<this.pos&&n instanceof ot&&n.wrapper.eq(i.wrapper))e=n;else{let r=ot.of(i.wrapper,(t=this.cache.find(ot,s=>s.wrapper.eq(i.wrapper)))===null||t===void 0?void 0:t.dom);e.append(r),e=r}}return e}blockPosCovered(){let t=this.lastBlock;return t!=null&&!t.breakAfter&&(!t.isWidget()||(t.flags&160)>0)}getBuffer(t){let e=2|(t<0?16:32),i=this.cache.find($i,void 0,1);return i&&(i.flags=e),i||new $i(e)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},af=class{constructor(t){this.skipCount=0,this.text="",this.textOff=0,this.cursor=t.iter()}skip(t){this.textOff+t<=this.text.length?this.textOff+=t:(this.skipCount+=t-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(t){if(this.textOff==this.text.length){let{value:n,lineBreak:r,done:s}=this.cursor.next(this.skipCount);if(this.skipCount=0,s)throw new Error("Ran out of text content when drawing inline views");this.text=n;let o=this.textOff=Math.min(t,n.length);return r?null:n.slice(0,o)}let e=Math.min(this.text.length,this.textOff+t),i=this.text.slice(this.textOff,e);return this.textOff=e,i}},ji=[si,Vi,Vt,oe,$i,ot,Xi];for(let t=0;t<ji.length;t++)ji[t].bucket=t;var hf=class{constructor(t){this.view=t,this.buckets=ji.map(()=>[]),this.index=ji.map(()=>0),this.reused=new Map}add(t){let e=t.constructor.bucket,i=this.buckets[e];i.length<6?i.push(t):i[this.index[e]=(this.index[e]+1)%6]=t}find(t,e,i=2){let n=t.bucket,r=this.buckets[n],s=this.index[n];for(let o=0;o<r.length;o++){let l=(o+s)%r.length,a=r[l];if((!e||e(a))&&!this.reused.has(a))return r.splice(l,1),l<s&&this.index[n]--,this.reused.set(a,i),a}return null}findWidget(t,e,i){let n=this.buckets[0];if(n.length)for(let r=0,s=0;;r++){if(r==n.length){if(s)return null;s=1,r=0}let o=n[r];if(!this.reused.has(o)&&(s==0?o.widget.compare(t):o.widget.constructor==t.constructor&&t.updateDOM(o.dom,this.view,o.widget)))return n.splice(r,1),r<this.index[0]&&this.index[0]--,o.widget==t&&o.length==e&&(o.flags&497)==i?(this.reused.set(o,1),o):(this.reused.set(o,2),new si(o.dom,e,t,o.flags&-498|i))}}reuse(t){return this.reused.set(t,1),t}maybeReuse(t,e=2){if(!this.reused.has(t))return this.reused.set(t,e),t.dom}clear(){for(let t=0;t<this.buckets.length;t++)this.buckets[t].length=this.index[t]=0}},ff=class{constructor(t,e,i,n,r){this.view=t,this.decorations=n,this.disallowBlockEffectsFor=r,this.openWidget=!1,this.openMarks=0,this.cache=new hf(t),this.text=new af(t.state.doc),this.builder=new lf(this.cache,new Xi(t,t.contentDOM),F.iter(i)),this.cache.reused.set(e,2),this.old=new sf(e),this.reuseWalker={skip:(s,o,l)=>{if(this.cache.add(s),s.isComposite())return!1},enter:s=>this.cache.add(s),leave:()=>{},break:()=>{}}}run(t,e){let i=e&&this.getCompositionContext(e.text);for(let n=0,r=0,s=0;;){let o=s<t.length?t[s++]:null,l=o?o.fromA:this.old.root.length;if(l>n){let a=l-n;this.preserve(a,!s,!o),n=l,r+=a}if(!o)break;e&&o.fromA<=e.range.fromA&&o.toA>=e.range.toA?(this.forward(o.fromA,e.range.fromA,e.range.fromA<e.range.toA?1:-1),this.emit(r,e.range.fromB),this.builder.flushBuffer(),this.cache.clear(),this.builder.addComposition(e,i),this.text.skip(e.range.toB-e.range.fromB),this.forward(e.range.fromA,o.toA),this.emit(e.range.toB,o.toB)):(this.forward(o.fromA,o.toA),this.emit(r,o.toB)),r=o.toB,n=o.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(t,e,i){let n=df(this.old),r=this.openMarks;this.old.advance(t,i?1:-1,{skip:(s,o,l)=>{if(s.isWidget())if(this.openWidget)this.builder.continueWidget(l-o);else{let a=l>0||o<s.length?si.of(s.widget,this.view,l-o,s.flags&496,this.cache.maybeReuse(s)):this.cache.reuse(s);a.flags&256?(a.flags&=-2,this.builder.addBlockWidget(a)):(this.builder.ensureLine(null),this.builder.addInlineWidget(a,n,r),r=n.length)}else if(s.isText())this.builder.ensureLine(null),!o&&l==s.length&&!this.cache.reused.has(s)?this.builder.addText(s.text,n,r,this.cache.reuse(s)):(this.cache.add(s),this.builder.addText(s.text.slice(o,l),n,r)),r=n.length;else if(s.isLine())s.flags&=-2,this.cache.reused.set(s,1),this.builder.addLine(s);else if(s instanceof $i)this.cache.add(s);else if(s instanceof oe)this.builder.ensureLine(null),this.builder.addMark(s,n,r),this.cache.reused.set(s,1),r=n.length;else return!1;this.openWidget=!1},enter:s=>{s.isLine()?this.builder.addLineStart(s.attrs,this.cache.maybeReuse(s)):(this.cache.add(s),s instanceof oe&&n.unshift(s.mark)),this.openWidget=!1},leave:s=>{s.isLine()?n.length&&(n.length=r=0):s instanceof oe&&(n.shift(),r=Math.min(r,n.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(t)}emit(t,e){let i=null,n=this.builder,r=-1,s=F.spans(this.decorations,t,e,{point:(o,l,a,h,f,u)=>{if(a instanceof ti){if(this.disallowBlockEffectsFor[u]){if(a.block)throw new RangeError("Block decorations may not be specified via plugins");if(l>this.view.state.doc.lineAt(o).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(r=h.length,f>h.length)n.continueWidget(l-o);else{let c=a.widget||(a.block?Tt.block:Tt.inline),d=uf(a),p=this.cache.findWidget(c,l-o,d)||si.of(c,this.view,l-o,d);a.block?(a.startSide>0&&n.addLineStartIfNotCovered(i),n.addBlockWidget(p)):(n.ensureLine(i),n.addInlineWidget(p,h,f))}i=null}else i=cf(i,a);l>o&&this.text.skip(l-o)},span:(o,l,a,h)=>{for(let f=o;f<l;){let u=this.text.next(Math.min(512,l-f));u==null?(n.addLineStartIfNotCovered(i),n.addBreak(),f++):(n.ensureLine(i),n.addText(u,a,f==o?h:a.length),f+=u.length),i=null}r=a.length}});r>-1&&(this.openWidget=s>r),this.openWidget||n.addLineStartIfNotCovered(i),this.openMarks=s}forward(t,e,i=1){e-t<=10?this.old.advance(e-t,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(e-t-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(t){let e=[],i=null;for(let n=t.parentNode;;n=n.parentNode){let r=G.get(n);if(n==this.view.contentDOM)break;r instanceof oe?e.push(r):r?.isLine()?i=r:r instanceof ot||(n.nodeName=="DIV"&&!i?i=new Vi(n,Vl):i||e.push(oe.of(new Br({tagName:n.nodeName.toLowerCase(),attributes:Hh(n)}),n)))}return i?{line:i,marks:e}:null}};function Ms(t,e){let i=n=>{for(let r of n.children)if((e?r.isText():r.length)||i(r))return!0;return!1};return i(t)}function uf(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}var Vl={class:"cm-line"};function cf(t,e){let i=e.spec.attributes,n=e.spec.class;return!i&&!n||(t||(t={class:"cm-line"}),i&&Dr(i,t),n&&(t.class+=" "+n)),t}function df(t){let e=[];for(let i=t.parents.length;i>1;i--){let n=i==t.parents.length?t.tile:t.parents[i].tile;n instanceof oe&&e.push(n.mark)}return e}function an(t){let e=G.get(t);return e&&e.setDOM(t.cloneNode()),t}var Tt=class extends et{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}};Tt.inline=new Tt("span");Tt.block=new Tt("div");var hn=new class extends et{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}},Os=class{constructor(t){this.view=t,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=N.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new Xi(t,t.contentDOM),this.updateInner([new Fe(0,0,0,t.state.doc.length)],null)}update(t){var e;let i=t.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:h,toA:f})=>f<this.minWidthFrom||h>this.minWidthTo)?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(t);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((e=this.domChanged)===null||e===void 0)&&e.newSel?n=this.domChanged.newSel.head:!kf(t.changes,this.hasComposition)&&!t.selectionSet&&(n=t.state.selection.main.head));let r=n>-1?gf(this.view,t.changes,n):null;if(this.domChanged=null,this.hasComposition){let{from:h,to:f}=this.hasComposition;i=new Fe(h,f,t.changes.mapPos(h,-1),t.changes.mapPos(f,1)).addToSet(i.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(w.ie||w.chrome)&&!r&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let s=this.decorations,o=this.blockWrappers;this.updateDeco();let l=yf(s,this.decorations,t.changes);l.length&&(i=Fe.extendWithRanges(i,l));let a=wf(o,this.blockWrappers,t.changes);return a.length&&(i=Fe.extendWithRanges(i,a)),r&&!i.some(h=>h.fromA<=r.range.fromA&&h.toA>=r.range.toA)&&(i=r.range.addToSet(i.slice())),this.tile.flags&2&&i.length==0?!1:(this.updateInner(i,r),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(e||t.length){let s=this.tile,o=new ff(this.view,s,this.blockWrappers,this.decorations,this.dynamicDecorationMap);e&&G.get(e.text)&&o.cache.reused.set(G.get(e.text),2),this.tile=o.run(t,e),nr(s,o.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let r=w.chrome||w.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),r&&(r.written||i.selectionRange.focusNode!=r.node||!this.tile.dom.contains(r.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let n=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let r of this.tile.children)r.isWidget()&&r.widget instanceof fn&&n.push(r.dom);i.updateGaps(n)}updateEditContextFormatting(t){this.editContextFormatting=this.editContextFormatting.map(t.changes);for(let e of t.transactions)for(let i of e.effects)i.is(Ol)&&(this.editContextFormatting=i.value)}updateSelection(t=!1,e=!1){(t||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:i}=this.tile,n=this.view.root.activeElement,r=n==i,s=!r&&!(this.view.state.facet(He)||i.tabIndex>-1)&&qt(i,this.view.observer.selectionRange)&&!(n&&i.contains(n));if(!(r||e||s))return;let o=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,a,h;if(l.empty?h=a=this.inlineDOMNearPos(l.anchor,l.assoc||1):(h=this.inlineDOMNearPos(l.head,l.head==l.from?1:-1),a=this.inlineDOMNearPos(l.anchor,l.anchor==l.from?1:-1)),w.gecko&&l.empty&&!this.hasComposition&&pf(a)){let u=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(u,a.node.childNodes[a.offset]||null)),a=h=new Ge(u,0),o=!0}let f=this.view.observer.selectionRange;(o||!f.focusNode||(!Ut(a.node,a.offset,f.anchorNode,f.anchorOffset)||!Ut(h.node,h.offset,f.focusNode,f.focusOffset))&&!this.suppressWidgetCursorChange(f,l))&&(this.view.observer.ignore(()=>{w.android&&w.chrome&&i.contains(f.focusNode)&&xf(f.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let u=ii(this.view.root);if(u)if(l.empty){if(w.gecko){let c=mf(a.node,a.offset);if(c&&c!=3){let d=(c==1?cl:dl)(a.node,a.offset);d&&(a=new Ge(d.node,d.offset))}}u.collapse(a.node,a.offset),l.bidiLevel!=null&&u.caretBidiLevel!==void 0&&(u.caretBidiLevel=l.bidiLevel)}else if(u.extend){u.collapse(a.node,a.offset);try{u.extend(h.node,h.offset)}catch{}}else{let c=document.createRange();l.anchor>l.head&&([a,h]=[h,a]),c.setEnd(h.node,h.offset),c.setStart(a.node,a.offset),u.removeAllRanges(),u.addRange(c)}s&&this.view.root.activeElement==i&&(i.blur(),n&&n.focus())}),this.view.observer.setSelectionRange(a,h)),this.impreciseAnchor=a.precise?null:new Ge(f.anchorNode,f.anchorOffset),this.impreciseHead=h.precise?null:new Ge(f.focusNode,f.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&Ut(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)&&this.posFromDOM(t.focusNode,t.focusOffset)==e.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:t}=this,e=t.state.selection.main,i=ii(t.root),{anchorNode:n,anchorOffset:r}=t.observer.selectionRange;if(!i||!e.empty||!e.assoc||!i.modify)return;let s=this.lineAt(e.head,e.assoc);if(!s)return;let o=s.posAtStart;if(e.head==o||e.head==o+s.length)return;let l=this.coordsAt(e.head,-1),a=this.coordsAt(e.head,1);if(!l||!a||l.bottom>a.top)return;let h=this.domAtPos(e.head+e.assoc,e.assoc);i.collapse(h.node,h.offset),i.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let f=t.observer.selectionRange;t.docView.posFromDOM(f.anchorNode,f.anchorOffset)!=e.from&&i.collapse(n,r)}posFromDOM(t,e){let i=this.tile.nearest(t);if(!i)return this.tile.dom.compareDocumentPosition(t)&2?0:this.view.state.doc.length;let n=i.posAtStart;if(i.isComposite()){let r;if(t==i.dom)r=i.dom.childNodes[e];else{let s=Ve(t)==0?0:e==0?-1:1;for(;;){let o=t.parentNode;if(o==i.dom)break;s==0&&o.firstChild!=o.lastChild&&(t==o.firstChild?s=-1:s=1),t=o}s<0?r=t:r=t.nextSibling}if(r==i.dom.firstChild)return n;for(;r&&!G.get(r);)r=r.nextSibling;if(!r)return n+i.length;for(let s=0,o=n;;s++){let l=i.children[s];if(l.dom==r)return o;o+=l.length+l.breakAfter}}else return i.isText()?t==i.dom?n+e:n+(e?i.length:0):n}domAtPos(t,e){let{tile:i,offset:n}=this.tile.resolveBlock(t,e);return i.isWidget()?i.domPosFor(n,e):i.domIn(n,e)}inlineDOMNearPos(t,e){let i,n=-1,r=!1,s,o=-1,l=!1;return this.tile.blockTiles((a,h)=>{if(a.isWidget()){if(a.flags&32&&h>=t)return!0;a.flags&16&&(r=!0)}else{let f=h+a.length;if(h<=t&&(i=a,n=t-h,r=f<t),f>=t&&!s&&(s=a,o=t-h,l=h>t),h>t&&s)return!0}}),!i&&!s?this.domAtPos(t,e):(r&&s?i=null:l&&i&&(s=null),i&&e<0||!s?i.domIn(n,e):s.domIn(o,e))}coordsAt(t,e,i){let{tile:n,offset:r}=this.tile.resolveBlock(t,e);return n.isWidget()?n.widget instanceof fn?null:n.coordsInWidget(r,e,!0):n.coordsIn(r,e,i)}lineAt(t,e){let{tile:i}=this.tile.resolveBlock(t,e);return i.isLine()?i:null}coordsForChar(t){let{tile:e,offset:i}=this.tile.resolveBlock(t,1);if(!e.isLine())return null;function n(r,s){if(r.isComposite())for(let o of r.children){if(o.length>=s){let l=n(o,s);if(l)return l}if(s-=o.length,s<0)break}else if(r.isText()&&s<r.length){let o=ae(r.text,s);if(o==s)return null;let l=ri(r.dom,s,o).getClientRects();for(let a=0;a<l.length;a++){let h=l[a];if(a==l.length-1||h.top<h.bottom&&h.left<h.right)return h}}return null}return n(e,i)}measureVisibleLineHeights(t){let e=[],{from:i,to:n}=t,r=this.view.contentDOM.clientWidth,s=r>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,l=this.view.textDirection==q.LTR,a=0,h=(f,u,c)=>{for(let d=0;d<f.children.length&&!(u>n);d++){let p=f.children[d],g=u+p.length,m=p.dom.getBoundingClientRect(),{height:b}=m;if(c&&!d&&(a+=m.top-c.top),p instanceof ot)g>i&&h(p,u,m);else if(u>=i&&(a>0&&e.push(-a),e.push(b+a),a=0,s)){let x=p.dom.lastChild,A=x?Gt(x):[];if(A.length){let O=A[A.length-1],k=l?O.right-m.left:m.right-O.left;k>o&&(o=k,this.minWidth=r,this.minWidthFrom=u,this.minWidthTo=g)}}c&&d==f.children.length-1&&(a+=c.bottom-m.bottom),u=g+p.breakAfter}};return h(this.tile,0,null),e}textDirectionAt(t){let{tile:e}=this.tile.resolveBlock(t,1);return getComputedStyle(e.dom).direction=="rtl"?q.RTL:q.LTR}measureTextSize(){let t=this.tile.blockTiles(s=>{if(s.isLine()&&s.children.length&&s.length<=20){let o=0,l;for(let a of s.children){if(!a.isText()||/[^ -~]/.test(a.text))return;let h=Gt(a.dom);if(h.length!=1)return;o+=h[0].width,l=h[0].height}if(o)return{lineHeight:s.dom.getBoundingClientRect().height,charWidth:o/s.length,textHeight:l}}});if(t)return t;let e=document.createElement("div"),i,n,r;return e.className="cm-line",e.style.width="99999px",e.style.position="absolute",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(e);let s=Gt(e.firstChild)[0];i=e.getBoundingClientRect().height,n=s&&s.width?s.width/27:7,r=s&&s.height?s.height:i,e.remove()}),{lineHeight:i,charWidth:n,textHeight:r}}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let i=0,n=0;;n++){let r=n==e.viewports.length?null:e.viewports[n],s=r?r.from-1:this.view.state.doc.length;if(s>i){let o=(e.lineBlockAt(s).bottom-e.lineBlockAt(i).top)/this.view.scaleY;t.push(N.replace({widget:new fn(o),block:!0,inclusive:!0,isBlockGap:!0}).range(i,s))}if(!r)break;i=r.to+1}return N.set(t)}updateDeco(){let t=1,e=this.view.state.facet(_i).map(r=>(this.dynamicDecorationMap[t++]=typeof r=="function")?r(this.view):r),i=!1,n=this.view.state.facet(Hr).map((r,s)=>{let o=typeof r=="function";return o&&(i=!0),o?r(this.view):r});for(n.length&&(this.dynamicDecorationMap[t++]=i,e.push(F.join(n))),this.decorations=[this.editContextFormatting,...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];t<this.decorations.length;)this.dynamicDecorationMap[t++]=!1;this.blockWrappers=this.view.state.facet(Dl).map(r=>typeof r=="function"?r(this.view):r)}scrollIntoView(t){if(t.isSnapshot){let a=this.view.viewState.lineBlockAt(t.range.head);this.view.scrollDOM.scrollTop=a.top-t.yMargin,this.view.scrollDOM.scrollLeft=t.xMargin;return}for(let a of this.view.state.facet(Ml))try{if(a(this.view,t.range,t))return!0}catch(h){Pe(this.view.state,h,"scroll handler")}let{range:e}=t,i=this.coordsAt(e.head,e.assoc||(e.head>e.anchor?-1:1)),n;if(!i)return;!e.empty&&(n=this.coordsAt(e.anchor,e.anchor>e.head?-1:1))&&(i={left:Math.min(i.left,n.left),top:Math.min(i.top,n.top),right:Math.max(i.right,n.right),bottom:Math.max(i.bottom,n.bottom)});let r=Rl(this.view),s={left:i.left-r.left,top:i.top-r.top,right:i.right+r.right,bottom:i.bottom+r.bottom},{offsetWidth:o,offsetHeight:l}=this.view.scrollDOM;if(Vh(this.view.scrollDOM,s,e.head<e.anchor?-1:1,t.x,t.y,Math.max(Math.min(t.xMargin,o),-o),Math.max(Math.min(t.yMargin,l),-l),this.view.textDirection==q.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(i.top>window.visualViewport.offsetTop+window.visualViewport.height||i.bottom<window.visualViewport.offsetTop)){let a=this.view.docView.lineAt(e.head,1);if(a){let h=al(a.dom);a.dom.scrollIntoView({block:"nearest"}),hl(h,!1)}}}lineHasWidget(t){let e=i=>i.isWidget()||i.children.some(e);return e(this.tile.resolveBlock(t,1).tile)}destroy(){nr(this.tile)}};function nr(t,e){let i=e?.get(t);if(i!=1){i==null&&t.destroy();for(let n of t.children)nr(n,e)}}function pf(t){return _(t.node)&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function $l(t,e){let i=t.observer.selectionRange;if(!i.focusNode)return null;let n=cl(i.focusNode,i.focusOffset),r=dl(i.focusNode,i.focusOffset),s=n||r;if(r&&n&&r.node!=n.node){let l=G.get(r.node);if(!l||l.isText()&&l.text!=r.node.nodeValue)s=r;else if(t.docView.lastCompositionAfterCursor){let a=G.get(n.node);!a||a.isText()&&a.text!=n.node.nodeValue||(s=r)}}if(t.docView.lastCompositionAfterCursor=s!=n,!s)return null;let o=e-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}function gf(t,e,i){let n=$l(t,i);if(!n)return null;let{node:r,from:s,to:o}=n,l=r.nodeValue;if(/[\n\r]/.test(l)||t.state.doc.sliceString(n.from,n.to)!=l)return null;let a=e.invertedDesc;return{range:new Fe(a.mapPos(s),a.mapPos(o),s,o),text:r}}function mf(t,e){return _(t)?(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e<t.childNodes.length&&t.childNodes[e].contentEditable=="false"?2:0):0}var bf=class{constructor(){this.changes=[]}compareRange(e,i){xt(e,i,this.changes)}comparePoint(e,i){xt(e,i,this.changes)}boundChange(e){xt(e,e,this.changes)}};function yf(t,e,i){let n=new bf;return F.compare(t,e,i,n),n.changes}var vf=class{constructor(){this.changes=[]}compareRange(t,e){xt(t,e,this.changes)}comparePoint(){}boundChange(t){xt(t,t,this.changes)}};function wf(t,e,i){let n=new vf;return F.compare(t,e,i,n),n.changes}function xf(t,e){for(let i=t;i&&i!=e;i=i.assignedSlot||i.parentNode)if(_(i)&&i.contentEditable=="false")return!0;return!1}function kf(t,e){let i=!1;return e&&t.iterChangedRanges((n,r)=>{n<e.to&&r>e.from&&(i=!0)}),i}var fn=class extends et{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return t.className="cm-gap",this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}};function Sf(t,e,i=1){let n=t.charCategorizer(e),r=t.doc.lineAt(e),s=e-r.from;if(r.length==0)return S.cursor(e);s==0?i=1:s==r.length&&(i=-1);let o=s,l=s;i<0?o=ae(r.text,s,!1):l=ae(r.text,s);let a=n(r.text.slice(o,l));for(;o>0;){let h=ae(r.text,o,!1);if(n(r.text.slice(h,o))!=a)break;o=h}for(;l<r.length;){let h=ae(r.text,l);if(n(r.text.slice(l,h))!=a)break;l=h}return S.undirectionalRange(o+r.from,l+r.from)}function Cf(t,e,i,n,r){let s=Math.round((n-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>t.defaultLineHeight*1.5){let l=t.viewState.heightOracle.textHeight,a=Math.floor((r-i.top-(t.defaultLineHeight-l)*.5)/l);s+=a*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(i.from,i.to);return i.from+Bh(o,s,t.state.tabSize)}function Af(t,e,i){let n=t.lineBlockAt(e);if(Array.isArray(n.type)){let r;for(let s of n.type){if(s.from>e)break;if(!(s.to<e)){if(s.from<e&&s.to>e)return s;(!r||s.type==ne.Text&&(r.type!=s.type||(i<0?s.from<e:s.to>e)))&&(r=s)}}return r||n}return n}function Mf(t,e,i,n){let r=Af(t,e.head,e.assoc||-1),s=!n||r.type!=ne.Text||!(t.lineWrapping||r.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head);if(s){let o=t.dom.getBoundingClientRect(),l=t.textDirectionAt(r.from),a=t.posAndSideAtCoords({x:i==(l==q.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(a)return S.cursor(a.pos,a.assoc)}return S.cursor(i?r.to:r.from,i?1:-1)}function Ts(t,e,i,n){let r=t.state.doc.lineAt(e.head),s=t.bidiSpans(r),o=t.textDirectionAt(r.from);for(let l=e,a=null;;){let h=Xh(r,s,o,l,i),f=yl;if(!h){if(r.number==(i?t.state.doc.lines:1))return l;f=`
|
|
8
|
+
`,r=t.state.doc.line(r.number+(i?1:-1)),s=t.bidiSpans(r),h=i?S.cursor(r.from,-1):S.cursor(r.to,1)}if(a){if(!a(f))return l}else{if(!n)return h;a=n(f)}l=h}}function Of(t,e,i){let n=t.state.charCategorizer(e),r=n(i);return s=>{let o=n(s);return r==Te.Space&&(r=o),r==o}}function Tf(t,e,i,n){let r=e.head,s=i?1:-1;if(r==(i?t.state.doc.length:0))return S.cursor(r,e.assoc);let o=e.goalColumn,l,a=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(r,e.assoc||((e.empty?i:e.head==e.from)?1:-1)),f=t.documentTop;if(h)o==null&&(o=h.left-a.left),l=s<0?h.top:h.bottom;else{let p=t.viewState.lineBlockAt(r);o==null&&(o=Math.min(a.right-a.left,t.defaultCharacterWidth*(r-p.from))),l=(s<0?p.top:p.bottom)+f}let u=a.left+o,c=t.viewState.heightOracle.textHeight>>1,d=n??c;for(let p=0;;p+=c){let g=l+(d+p)*s,m=rr(t,{x:u,y:g},!1,s);if(i?g>a.bottom:g<a.top)return S.cursor(m.pos,m.assoc);let b=t.coordsAtPos(m.pos,m.assoc),x=b?(b.top+b.bottom)/2:0;if(!b||(i?x>l:x<l))return S.cursor(m.pos,m.assoc,void 0,o)}}function Yt(t,e,i){for(;;){let n=0;for(let r of t)r.between(e-1,e+1,(s,o,l)=>{if(e>s&&e<o){let a=n||i||(e-s<o-e?-1:1);e=a<0?s:o,n=a}});if(!n)return e}}function jl(t,e){let i=null;for(let n=0;n<e.ranges.length;n++){let r=e.ranges[n],s=null;if(r.empty){let o=Yt(t,r.from,0);o!=r.from&&(s=S.cursor(o,-1))}else{let o=Yt(t,r.from,-1),l=Yt(t,r.to,1);(o!=r.from||l!=r.to)&&(r.undirectional?s=S.undirectionalRange(r.from,r.to):s=S.range(r.from==r.anchor?o:l,r.from==r.head?o:l))}s&&(i||(i=e.ranges.slice()),i[n]=s)}return i?S.create(i,e.mainIndex):e}function un(t,e,i){let n=Yt(t.state.facet(li).map(r=>r(t)),i.from,e.head>i.from?-1:1);return n==i.from?i:S.cursor(n,n<i.from?1:-1)}var Oe=class{constructor(t,e){this.pos=t,this.assoc=e}};function rr(t,e,i,n){let r=t.contentDOM.getBoundingClientRect(),s=r.top+t.viewState.paddingTop,{x:o,y:l}=e,a=l-s,h;for(;;){if(a<0)return new Oe(0,1);if(a>t.viewState.docHeight)return new Oe(t.state.doc.length,-1);if(h=t.elementAtHeight(a),n==null)break;if(h.type==ne.Text){if(n<0?h.to<t.viewport.from:h.from>t.viewport.to)break;let c=t.docView.coordsAt(n<0?h.from:h.to,n>0?-1:1);if(c&&(n<0?c.top<=a+s:c.bottom>=a+s))break}let u=t.viewState.heightOracle.textHeight/2;a=n>0?h.bottom+u:h.top-u}if(t.viewport.from>=h.to||t.viewport.to<=h.from){if(i)return null;if(h.type==ne.Text){let u=Cf(t,r,h,o,l);return new Oe(u,u==h.from?1:-1)}}if(h.type!=ne.Text)return a<(h.top+h.bottom)/2?new Oe(h.from,1):new Oe(h.to,-1);let f=t.docView.lineAt(h.from,2);return(!f||f.length!=h.length)&&(f=t.docView.lineAt(h.from,-2)),new Df(t,o,l,t.textDirectionAt(h.from)).scanTile(f,h.from)}var Df=class{constructor(t,e,i,n){this.view=t,this.x=e,this.y=i,this.baseDir=n,this.line=null,this.spans=null}bidiSpansAt(t){return(!this.line||this.line.from>t||this.line.to<t)&&(this.line=this.view.state.doc.lineAt(t),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(t,e){let{line:i,spans:n}=this.bidiSpansAt(t);return n[De.find(n,t-i.from,-1,e)].level==this.baseDir}dirAt(t,e){let{line:i,spans:n}=this.bidiSpansAt(t);return n[De.find(n,t-i.from,-1,e)].dir}bidiIn(t,e){let{spans:i,line:n}=this.bidiSpansAt(t);return i.length>1||i.length&&(i[0].level!=this.baseDir||i[0].to+n.from<e)}scan(t,e,i=!1){let n=0,r=t.length-1,s=new Set,o=this.bidiIn(t[0],t[r]),l,a,h=-1,f=1e9,u;e:for(;n<r;){let d=r-n,p=n+r>>1;t:if(s.has(p)){for(let b=1;b<d;b++){let x=p+b;if(x>=r&&(x-=d),!s.has(x)){p=x;break t}}break e}s.add(p);let g=e(p),m=0;if(g)for(let b=0;b<g.length;b++){let x=g[b];if(!(x.width==0&&g.length>1))if(x.bottom<this.y)(!l||l.bottom<x.bottom)&&(l=x),m=1;else if(x.top>this.y)(!a||a.top>x.top)&&(a=x),m=-1;else{let A=x.left>this.x?this.x-x.left:x.right<this.x?this.x-x.right:0,O=Math.abs(A);O<f&&(h=p,f=O,u=x),A&&(m=A<0==(this.baseDir==q.LTR)?-1:1)}}m==-1&&(!o||this.baseDirAt(t[p],1))?r=p:m==1&&(!o||this.baseDirAt(t[p+1],-1))&&(n=p+1)}if(!u){if(!a&&!l)return{i:0,after:!1};let d=l&&(!a||this.y-l.bottom<a.top-this.y)?l:a;return this.y=(d.top+d.bottom)/2,this.scan(t,e,!0)}if(f&&!i){let{top:d,bottom:p}=u;if(l&&l.bottom>(d+d+p)/3)return this.y=l.bottom-1,this.scan(t,e,!0);if(a&&a.top<(d+p+p)/3)return this.y=a.top+1,this.scan(t,e,!0)}let c=(o?this.dirAt(t[h],1):this.baseDir)==q.LTR;return{i:h,after:this.x>(u.left+u.right)/2==c}}scanText(t,e){let i=[];for(let r=0;r<t.length;r=ae(t.text,r))i.push(e+r);i.push(e+t.length);let n=this.scan(i,r=>{let s=i[r]-e,o=i[r+1]-e;return ri(t.dom,s,o).getClientRects()});return n.after?new Oe(i[n.i+1],-1):new Oe(i[n.i],1)}scanTile(t,e){if(!t.length)return new Oe(e,1);if(t.children.length==1){let o=t.children[0];if(o.isText())return this.scanText(o,e);if(o.isComposite())return this.scanTile(o,e)}let i=[e];for(let o=0,l=e;o<t.children.length;o++)i.push(l+=t.children[o].length);let n=this.scan(i,o=>{let l=t.children[o];return l.flags&48?null:(_(l.dom)?l.dom:ri(l.dom,0,l.length)).getClientRects()}),r=t.children[n.i],s=i[n.i];return r.isText()?this.scanText(r,s):r.isComposite()?this.scanTile(r,s):n.after?new Oe(i[n.i+1],-1):new Oe(s,1)}},ct="",Pf=class{constructor(t,e){this.points=t,this.view=e,this.text="",this.lineSeparator=e.state.facet(U.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=ct}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let n=t;;){this.findPointBefore(i,n);let r=this.text.length;this.readNode(n);let s=G.get(n),o=n.nextSibling;if(o==e){s?.breakAfter&&!o&&i!=this.view.contentDOM&&this.lineBreak();break}let l=G.get(o);(s&&l?s.breakAfter:(s?s.breakAfter:Fi(n))||Fi(o)&&(n.nodeName!="BR"||s?.isWidget())&&this.text.length>r)&&!Ef(o,e)&&this.lineBreak(),n=o}return this.findPointBefore(i,e),this}readTextNode(t){let e=t.nodeValue;for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e.length));for(let i=0,n=this.lineSeparator?null:/\r\n?|\n/g;;){let r=-1,s=1,o;if(this.lineSeparator?(r=e.indexOf(this.lineSeparator,i),s=this.lineSeparator.length):(o=n.exec(e))&&(r=o.index,s=o[0].length),this.append(e.slice(i,r<0?e.length:r)),r<0)break;if(this.lineBreak(),s>1)for(let l of this.points)l.node==t&&l.pos>this.text.length&&(l.pos-=s-1);i=r+s}}readNode(t){let e=G.get(t),i=e&&e.overrideDOMText;if(i!=null){this.findPointInside(t,i.length);for(let n=i.iter();!n.next().done;)n.lineBreak?this.lineBreak():this.append(n.value)}else Mt(t)?this.readTextNode(t):t.nodeName=="BR"?t.nextSibling&&this.lineBreak():_(t)&&this.readRange(t.firstChild,null)}findPointBefore(t,e){for(let i of this.points)i.node==t&&t.childNodes[i.offset]==e&&(i.pos=this.text.length)}findPointInside(t,e){for(let i of this.points)(Mt(t)?i.node==t:t.contains(i.node))&&(i.pos=this.text.length+(Bf(t,i.node,i.offset)?e:0))}};function Bf(t,e,i){for(;;){if(!e||i<Ve(e))return!1;if(e==t)return!0;i=Je(e)+1,e=e.parentNode}}function Ef(t,e){let i;for(;!(t==e||!t);t=t.nextSibling){let n=G.get(t);if(!n?.isWidget())return!1;n&&(i||(i=[])).push(n)}if(i)for(let n of i){let r=n.overrideDOMText;if(r?.length)return!1}return!0}var Ds=class{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}},Rf=class{constructor(t,e,i,n){this.typeOver=n,this.bounds=null,this.text="",this.domChanged=e>-1;let{impreciseHead:r,impreciseAnchor:s}=t.docView,o=t.state.selection;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=zl(t.docView.tile,e,i,0))){let l=r||s?[]:If(t),a=new Pf(l,t);a.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=a.text,this.newSel=Lf(l,this.bounds.from)}else{let l=t.observer.selectionRange,a=r&&r.node==l.focusNode&&r.offset==l.focusOffset||!Yn(t.contentDOM,l.focusNode)?o.main.head:t.docView.posFromDOM(l.focusNode,l.focusOffset),h=s&&s.node==l.anchorNode&&s.offset==l.anchorOffset||!Yn(t.contentDOM,l.anchorNode)?o.main.anchor:t.docView.posFromDOM(l.anchorNode,l.anchorOffset),f=t.viewport;if((w.ios||w.chrome)&&a!=h&&Math.min(a,h)<=o.main.from&&Math.max(a,h)>=o.main.to&&(f.from>0||f.to<t.state.doc.length)){let u=Math.min(a,h),c=Math.max(a,h),d=f.from-u,p=f.to-c;(d==0||d==1||u==0)&&(p==0||p==-1||c==t.state.doc.length)&&(a=0,h=t.state.doc.length)}if(t.inputState.composing>-1&&o.ranges.length>1)this.newSel=o.replaceRange(S.range(h,a));else if(t.lineWrapping&&h==a&&!(o.main.empty&&o.main.head==a)&&t.inputState.lastTouchTime>Date.now()-100){let u=t.coordsAtPos(a,-1),c=0;u&&(c=t.inputState.lastTouchY<=u.bottom?-1:1),this.newSel=S.create([S.cursor(a,c)])}else this.newSel=S.single(h,a)}}};function zl(t,e,i,n){if(t.isComposite()){let r=-1,s=-1,o=-1,l=-1;for(let a=0,h=n,f=n;a<t.children.length;a++){let u=t.children[a],c=h+u.length;if(h<e&&c>i)return zl(u,e,i,h);if(c>=e&&r==-1&&(r=a,s=h),h>i&&u.dom.parentNode==t.dom){o=a,l=f;break}f=c,h=c+u.breakAfter}return{from:s,to:l<0?n+t.length:l,startDOM:(r?t.children[r-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:o<t.children.length&&o>=0?t.children[o].dom:null}}else return t.isText()?{from:n,to:n+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function Kl(t,e){let i,{newSel:n}=e,{state:r}=t,s=r.selection.main,o=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:l,to:a}=e.bounds,h=s.from,f=null;(o===8||w.android&&e.text.length<a-l)&&(h=s.to,f="end");let u=r.doc.sliceString(l,a,ct),c,d;!s.empty&&s.from>=l&&s.to<=a&&(e.typeOver||u!=e.text)&&u.slice(0,s.from-l)==e.text.slice(0,s.from-l)&&u.slice(s.to-l)==e.text.slice(c=e.text.length-(u.length-(s.to-l)))?i={from:s.from,to:s.to,insert:I.of(e.text.slice(s.from-l,c).split(ct))}:(d=ql(u,e.text,h-l,f))&&(w.chrome&&o==13&&d.toB==d.from+2&&e.text.slice(d.from,d.toB)==ct+ct&&d.toB--,i={from:l+d.from,to:l+d.toA,insert:I.of(e.text.slice(d.from,d.toB).split(ct))})}else n&&(!t.hasFocus&&r.facet(He)||sr(n,s))&&(n=null);if(!i&&!n)return!1;if((w.mac||w.android)&&i&&i.from==i.to&&i.from==s.head-1&&/^\. ?$/.test(i.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(n&&i.insert.length==2&&(n=S.single(n.main.anchor-1,n.main.head-1)),i={from:i.from,to:i.to,insert:I.of([i.insert.toString().replace("."," ")])}):r.doc.lineAt(s.from).to<s.to&&t.docView.lineHasWidget(s.to)&&t.inputState.insertingTextAt>Date.now()-50?i={from:s.from,to:s.to,insert:r.toText(t.inputState.insertingText)}:w.chrome&&i&&i.from==i.to&&i.from==s.head&&i.insert.toString()==`
|
|
9
|
+
`&&t.lineWrapping&&(n&&(n=S.single(n.main.anchor-1,n.main.head-1)),i={from:s.from,to:s.to,insert:I.of([" "])}),i)return Wr(t,i,n,o);if(n&&!sr(n,s)){let l=!1,a="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(l=!0),a=t.inputState.lastSelectionOrigin,a=="select.pointer"&&(n=jl(r.facet(li).map(h=>h(t)),n))),t.dispatch({selection:n,scrollIntoView:l,userEvent:a}),!0}else return!1}function Wr(t,e,i,n=-1){if(w.ios&&t.inputState.flushIOSKey(e))return!0;let r=t.state.selection.main;if(w.android&&(e.to==r.to&&(e.from==r.from||e.from==r.from-1&&t.state.sliceDoc(e.from,r.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&kt(t.contentDOM,"Enter",13)||(e.from==r.from-1&&e.to==r.to&&e.insert.length==0||n==8&&e.insert.length<e.to-e.from&&e.to>r.head)&&kt(t.contentDOM,"Backspace",8)||e.from==r.from&&e.to==r.to+1&&e.insert.length==0&&kt(t.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let o,l=()=>o||(o=Nf(t,e,i));return t.state.facet(Sl).some(a=>a(t,e.from,e.to,s,l))||t.dispatch(l()),!0}function Nf(t,e,i){let n,r=t.state,s=r.selection.main,o=-1;if(e.from==e.to&&e.from<s.from||e.from>s.to){let a=e.from<s.from?-1:1,h=a<0?s.from:s.to,f=Yt(r.facet(li).map(u=>u(t)),h,a);e.from==f&&(o=f)}if(o>-1)n={changes:e,selection:S.cursor(e.from+e.insert.length,-1)};else if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!i||i.main.empty&&i.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let a=s.from<e.from?r.sliceDoc(s.from,e.from):"",h=s.to>e.to?r.sliceDoc(e.to,s.to):"";n=r.replaceSelection(t.state.toText(a+e.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let a=r.changes(e),h=i&&i.main.to<=a.newLength?i.main:void 0;if(r.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=s.to+10&&e.to>=s.to-10){let f=t.state.sliceDoc(e.from,e.to),u,c=i&&$l(t,i.main.head);if(c){let p=e.insert.length-(e.to-e.from);u={from:c.from,to:c.to-p}}else u=t.state.doc.lineAt(s.head);let d=s.to-e.to;n=r.changeByRange(p=>{if(p.from==s.from&&p.to==s.to)return{changes:a,range:h||p.map(a)};let g=p.to-d,m=g-f.length;if(t.state.sliceDoc(m,g)!=f||g>=u.from&&m<=u.to)return{range:p};let b=r.changes({from:m,to:g,insert:e.insert}),x=p.to-s.to;return{changes:b,range:h?S.range(Math.max(0,h.anchor+x),Math.max(0,h.head+x)):p.map(b)}})}else n={changes:a,selection:h&&r.selection.replaceRange(h)}}let l="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,l+=".compose",t.inputState.compositionFirstChange&&(l+=".start",t.inputState.compositionFirstChange=!1)),r.update(n,{userEvent:l,scrollIntoView:!0})}function ql(t,e,i,n){let r=Math.min(t.length,e.length),s=0;for(;s<r&&t.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==r&&t.length==e.length)return null;let o=t.length,l=e.length;for(;o>0&&l>0&&t.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(n=="end"){let a=Math.max(0,s-Math.min(o,l));i-=o+a-s}if(o<s&&t.length<e.length){let a=i<=s&&i>=o?s-i:0;s-=a,l=s+(l-o),o=s}else if(l<s){let a=i<=s&&i>=l?s-i:0;s-=a,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function If(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:n,focusNode:r,focusOffset:s}=t.observer.selectionRange;return i&&(e.push(new Ds(i,n)),(r!=i||s!=n)&&e.push(new Ds(r,s))),e}function Lf(t,e){if(t.length==0)return null;let i=t[0].pos,n=t.length==2?t[1].pos:i;return i<0||n<0?null:i==n?S.create([S.cursor(n+e,-1)]):S.single(i+e,n+e)}function sr(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}var Hf=class{setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}constructor(t){this.view=t,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=t.hasFocus,w.safari&&t.contentDOM.addEventListener("input",()=>null),w.gecko&&Zf(t.contentDOM.ownerDocument)}handleEvent(t){!Gf(this.view,t)||this.ignoreDuringComposition(t)||t.type=="keydown"&&this.keydown(t)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(t.type,t)):this.runHandlers(t.type,t))}runHandlers(t,e){let i=this.handlers[t];if(i){for(let n of i.observers)n(this.view,e);for(let n of i.handlers){if(e.defaultPrevented)break;if(n(this.view,e)){e.preventDefault();break}}}}ensureHandlers(t){let e=Ff(t),i=this.handlers,n=this.view.contentDOM;for(let r in e)if(r!="scroll"){let s=!e[r].handlers.length,o=i[r];o&&s!=!o.handlers.length&&(n.removeEventListener(r,this.handleEvent),o=null),o||n.addEventListener(r,this.handleEvent,{passive:s})}for(let r in i)r!="scroll"&&!e[r]&&n.removeEventListener(r,this.handleEvent);this.handlers=e}keydown(t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),t.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&t.keyCode!=27&&Ul.indexOf(t.keyCode)<0&&(this.tabFocusMode=-1),w.android&&w.chrome&&!t.synthetic&&(t.keyCode==13||t.keyCode==8))return this.view.observer.delayAndroidKey(t.key,t.keyCode),!0;if(w.ios&&!t.synthetic&&!t.altKey&&!t.metaKey&&(Gl.some(e=>e.keyCode==t.keyCode)&&!t.ctrlKey||Vf.indexOf(t.key)>-1&&t.ctrlKey)){let e={ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey,shiftKey:t.shiftKey};e.shiftKey&&w.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&Wf(this.view.win)&&(e.shiftKey=!1);let i=this.pendingIOSKey={key:t.key,keyCode:t.keyCode,mods:e};return setTimeout(()=>{this.pendingIOSKey==i&&this.flushIOSKey()},50),!0}return t.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(t){let e=this.pendingIOSKey;return!e||this.view.observer.pendingRecords().length||e.key=="Enter"&&t&&t.from<t.to&&/^\S+$/.test(t.insert.toString())?!1:(this.pendingIOSKey=void 0,kt(this.view.contentDOM,e.key,e.keyCode,e.mods))}ignoreDuringComposition(t){return!/^key/.test(t.type)||t.synthetic?!1:this.composing>0?!0:w.safari&&!w.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.view.observer.update(t),this.mouseSelection&&this.mouseSelection.update(t),this.draggedContent&&t.docChanged&&(this.draggedContent=this.draggedContent.map(t.changes)),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function Wf(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function Ps(t,e){return(i,n)=>{try{return e.call(t,n,i)}catch(r){Pe(i.state,r)}}}function Ff(t){let e=Object.create(null);function i(n){return e[n]||(e[n]={observers:[],handlers:[]})}for(let n of t){let r=n.spec,s=r&&r.plugin.domEventHandlers,o=r&&r.plugin.domEventObservers;if(s)for(let l in s){let a=s[l];a&&i(l).handlers.push(Ps(n.value,a))}if(o)for(let l in o){let a=o[l];a&&i(l).observers.push(Ps(n.value,a))}}for(let n in ye)i(n).handlers.push(ye[n]);for(let n in te)i(n).observers.push(te[n]);return e}var Gl=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Vf="dthko",Ul=[16,17,18,20,91,92,224,225],yi=6;function vi(t){return Math.max(0,t)*.7+8}function $f(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}var jf=class{constructor(t,e,i,n){this.view=t,this.startEvent=e,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParents=ll(t.contentDOM),this.atoms=t.state.facet(li).map(s=>s(t));let r=t.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(U.allowMultipleSelections)&&zf(t,e),this.dragging=qf(t,e)&&Jl(e)==1?null:!1}start(t){this.dragging===!1&&this.select(t)}move(t){if(t.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&$f(this.startEvent,t)<10)return;this.select(this.lastEvent=t);let e=0,i=0,n=0,r=0,s=this.view.win.innerWidth,o=this.view.win.innerHeight;this.scrollParents.x&&({left:n,right:s}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:r,bottom:o}=this.scrollParents.y.getBoundingClientRect());let l=Rl(this.view);t.clientX-l.left<=n+yi?e=-vi(n-t.clientX):t.clientX+l.right>=s-yi&&(e=vi(t.clientX-s)),t.clientY-l.top<=r+yi?i=-vi(r-t.clientY):t.clientY+l.bottom>=o-yi&&(i=vi(t.clientY-o)),this.setScrollSpeed(e,i)}up(t){this.dragging==null&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:t,y:e}=this.scrollSpeed;t&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=t,t=0),e&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=e,e=0),(t||e)&&this.view.win.scrollBy(t,e),this.dragging===!1&&this.select(this.lastEvent)}select(t){let{view:e}=this,i=jl(this.atoms,this.style.get(t,this.extend,this.multiple));(this.mustSelect||!i.eq(e.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){t.transactions.some(e=>e.isUserEvent("input.type"))?this.destroy():this.style.update(t)&&setTimeout(()=>this.select(this.lastEvent),20)}};function zf(t,e){let i=t.state.facet(vl);return i.length?i[0](e):w.mac?e.metaKey:e.ctrlKey}function Kf(t,e){let i=t.state.facet(wl);return i.length?i[0](e):w.mac?!e.altKey:!e.ctrlKey}function qf(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let n=ii(t.root);if(!n||n.rangeCount==0)return!0;let r=n.getRangeAt(0).getClientRects();for(let s=0;s<r.length;s++){let o=r[s];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function Gf(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let i=e.target,n;i!=t.contentDOM;i=i.parentNode)if(!i||i.nodeType==11||(n=G.get(i))&&n.isWidget()&&!n.isHidden&&n.widget.ignoreEvent(e))return!1;return!0}var ye=Object.create(null),te=Object.create(null),Yl=w.ie&&w.ie_version<15||w.ios&&w.webkit_version<604;function Uf(t){let e=t.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout(()=>{t.focus(),i.remove(),_l(t,i.value)},50)}function Qi(t,e,i){for(let n of t.facet(e))i=n(i,t);return i}function _l(t,e){e=Qi(t.state,Nr,e);let{state:i}=t,n,r=1,s=i.toText(e),o=s.lines==i.selection.ranges.length;if(or!=null&&i.selection.ranges.every(l=>l.empty)&&or==s.toString()){let l=-1;n=i.changeByRange(a=>{let h=i.doc.lineAt(a.from);if(h.from==l)return{range:a};l=h.from;let f=i.toText((o?s.line(r++).text:e)+i.lineBreak);return{changes:{from:h.from,insert:f},range:S.cursor(a.from+f.length,-1)}})}else o?n=i.changeByRange(l=>{let a=s.line(r++);return{changes:{from:l.from,to:l.to,insert:a.text},range:S.cursor(l.from+a.length,-1)}}):n=i.replaceSelection(s);t.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}te.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,w.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};te.wheel=te.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()};ye.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1);te.touchstart=(t,e)=>{let i=t.inputState,n=e.targetTouches[0];i.touchActive=!0,i.lastTouchTime=Date.now(),n&&(i.lastTouchX=n.clientX,i.lastTouchY=n.clientY),i.setSelectionOrigin("select.pointer")};te.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")};te.touchend=(t,e)=>{t.inputState.touchActive=!1};ye.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let i=null;for(let n of t.state.facet(xl))if(i=n(t,e),i)break;if(!i&&e.button==0&&(i=_f(t,e)),i){let n=!t.hasFocus;t.inputState.startMouseSelection(new jf(t,e,i,n)),n&&t.observer.ignore(()=>{fl(t.contentDOM);let s=t.root.activeElement;s&&!s.contains(t.contentDOM)&&s.blur()});let r=t.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Bs(t,e,i,n){if(n==1)return S.cursor(e,i);if(n==2)return Sf(t.state,e,i);{let r=t.docView.lineAt(e,i),s=t.state.doc.lineAt(r?r.posAtEnd:e),o=r?r.posAtStart:s.from,l=r?r.posAtEnd:s.to;return l<t.state.doc.length&&l==s.to&&l++,S.undirectionalRange(o,l)}}var Yf=w.ie&&w.ie_version<=11,Es=null,Rs=0,Ns=0;function Jl(t){if(!Yf)return t.detail;let e=Es,i=Ns;return Es=t,Ns=Date.now(),Rs=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Rs+1)%3:1}function _f(t,e){let i=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),n=Jl(e),r=t.state.selection;return{update(s){s.docChanged&&(i.pos=s.changes.mapPos(i.pos),r=r.map(s.changes))},get(s,o,l){let a=t.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),h,f=Bs(t,a.pos,a.assoc,n);if(i.pos!=a.pos&&!o){let u=Bs(t,i.pos,i.assoc,n),c=Math.min(u.from,f.from),d=Math.max(u.to,f.to);f=c<f.from?S.range(c,d,f.assoc):S.range(d,c,f.assoc)}return o?r.replaceRange(r.main.extend(f.from,f.to,f.assoc)):l&&n==1&&r.ranges.length>1&&(h=Jf(r,a.pos))?h:l?r.addRange(f):S.create([f])}}}function Jf(t,e){for(let i=0;i<t.ranges.length;i++){let{from:n,to:r}=t.ranges[i];if(n<=e&&r>=e)return S.create(t.ranges.slice(0,i).concat(t.ranges.slice(i+1)),t.mainIndex==i?0:t.mainIndex-(t.mainIndex>i?1:0))}return null}ye.dragstart=(t,e)=>{let{selection:{main:i}}=t.state;if(e.target.draggable){let r=t.docView.tile.nearest(e.target);if(r&&r.isWidget()){let s=r.posAtStart,o=s+r.length;(s>=i.to||o<=i.from)&&(i=S.undirectionalRange(s,o))}}let{inputState:n}=t;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=i,e.dataTransfer&&(e.dataTransfer.setData("Text",Qi(t.state,Ir,t.state.sliceDoc(i.from,i.to))),e.dataTransfer.effectAllowed="copyMove"),!1};ye.dragend=t=>(t.inputState.draggedContent=null,!1);function Is(t,e,i,n){if(i=Qi(t.state,Nr,i),!i)return;let r=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=t.inputState,o=n&&s&&Kf(t,e)?{from:s.from,to:s.to}:null,l={from:r,insert:i},a=t.state.changes(o?[o,l]:l);t.focus(),t.dispatch({changes:a,selection:{anchor:a.mapPos(r,-1),head:a.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),t.inputState.draggedContent=null}ye.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let i=e.dataTransfer.files;if(i&&i.length){let n=Array(i.length),r=0,s=()=>{++r==i.length&&Is(t,e,n.filter(o=>o!=null).join(t.state.lineBreak),!1)};for(let o=0;o<i.length;o++){let l=new FileReader;l.onerror=s,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(n[o]=l.result),s()},l.readAsText(i[o])}return!0}else{let n=e.dataTransfer.getData("Text");if(n)return Is(t,e,n,!0),!0}return!1};ye.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let i=Yl?null:e.clipboardData;return i?(_l(t,i.getData("text/plain")||i.getData("text/uri-list")),!0):(Uf(t),!1)};function Xf(t,e){let i=t.dom.parentNode;if(!i)return;let n=i.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout(()=>{n.remove(),t.focus()},50)}function Qf(t){let e=[],i=[],n=!1;for(let r of t.selection.ranges)r.empty||(e.push(t.sliceDoc(r.from,r.to)),i.push(r));if(!e.length){let r=-1;for(let{from:s}of t.selection.ranges){let o=t.doc.lineAt(s);o.number>r&&(e.push(o.text),i.push({from:o.from,to:Math.min(t.doc.length,o.to+1)})),r=o.number}n=!0}return{text:Qi(t,Ir,e.join(t.lineBreak)),ranges:i,linewise:n}}var or=null;ye.copy=ye.cut=(t,e)=>{if(!qt(t.contentDOM,t.observer.selectionRange))return!1;let{text:i,ranges:n,linewise:r}=Qf(t.state);if(!i&&!r)return!1;or=r?i:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let s=Yl?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",i),!0):(Xf(t,i),!1)};var Xl=at.define();function Ql(t,e){let i=[];for(let n of t.facet(Cl)){let r=n(t,e);r&&i.push(r)}return i.length?t.update({effects:i,annotations:Xl.of(!0)}):null}function Zl(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=Ql(t.state,e);i?t.dispatch(i):t.update([])}},10)}te.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),Zl(t)};te.blur=t=>{t.observer.clearSelectionRange(),Zl(t)};te.compositionstart=te.compositionupdate=(t,e)=>{if(!t.observer.editContext&&(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0)){let{main:i}=t.state.selection;!i.empty&&t.lineBlockAt(i.from).from!=t.lineBlockAt(i.to).from&&!t.state.readOnly&&t.dispatch({changes:t.state.selection.ranges.filter(n=>!n.empty).map(n=>({from:n.from,to:n.to})),userEvent:"input"}),t.inputState.composing=0}};te.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,w.chrome&&w.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))};te.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()};ye.beforeinput=(t,e)=>{var i,n;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let s=(i=e.dataTransfer)===null||i===void 0?void 0:i.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let l=o[0];return Wr(t,{from:t.posAtDOM(l.startContainer,l.startOffset),to:t.posAtDOM(l.endContainer,l.endOffset),insert:t.state.toText(s)},null),!0}}let r;if(w.chrome&&w.android&&(r=Gl.find(s=>s.inputType==e.inputType))&&(t.observer.delayAndroidKey(r.key,r.keyCode),r.key=="Backspace"||r.key=="Delete")){let s=((n=window.visualViewport)===null||n===void 0?void 0:n.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return w.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),w.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>te.compositionend(t,e),20),!1};var Ls=new Set;function Zf(t){Ls.has(t)||(Ls.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}var Hs=["pre-wrap","normal","pre-line","break-spaces"],Dt=!1;function Ws(){Dt=!1}var eu=class{constructor(t){this.lineWrapping=t,this.doc=I.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(t,e){let i=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(t){return this.lineWrapping?(1+Math.max(0,Math.ceil((t-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return Hs.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let n=t[i];n<0?i++:this.heightSamples[Math.floor(n*10)]||(e=!0,this.heightSamples[Math.floor(n*10)]=!0)}return e}refresh(t,e,i,n,r,s){let o=Hs.indexOf(t)>-1,l=Math.abs(e-this.lineHeight)>.3||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=e,this.charWidth=i,this.textHeight=n,this.lineLength=r,l){this.heightSamples={};for(let a=0;a<s.length;a++){let h=s[a];h<0?a++:this.heightSamples[Math.floor(h*10)]=!0}}return l}},tu=class{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}},We=class ea{constructor(e,i,n,r,s){this.from=e,this.length=i,this.top=n,this.height=r,this._content=s}get type(){return typeof this._content=="number"?ne.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof ti?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let i=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new ea(this.from,this.length+e.length,this.top,this.height+e.height,i)}},W=(function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t})(W||(W={})),Ei=.001,me=class Ri{constructor(e,i,n=2){this.length=e,this.height=i,this.flags=n}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>Ei&&(Dt=!0),this.height=e)}replace(e,i,n){return Ri.of(n)}decomposeLeft(e,i){i.push(this)}decomposeRight(e,i){i.push(this)}applyChanges(e,i,n,r){let s=this,o=n.doc;for(let l=r.length-1;l>=0;l--){let{fromA:a,toA:h,fromB:f,toB:u}=r[l],c=s.lineAt(a,W.ByPosNoHeight,n.setDoc(i),0,0),d=c.to>=h?c:s.lineAt(h,W.ByPosNoHeight,n,0,0);for(u+=d.to-h,h=d.to;l>0&&c.from<=r[l-1].toA;)a=r[l-1].fromA,f=r[l-1].fromB,l--,a<c.from&&(c=s.lineAt(a,W.ByPosNoHeight,n,0,0));f+=c.from-a,a=c.from;let p=su.build(n.setDoc(o),e,f,u);s=zi(s,s.replace(a,h,p))}return s.updateHeight(n,0)}static empty(){return new Me(0,0,0)}static of(e){if(e.length==1)return e[0];let i=0,n=e.length,r=0,s=0;for(;;)if(i==n)if(r>s*2){let l=e[i-1];l.break?e.splice(--i,1,l.left,null,l.right):e.splice(--i,1,l.left,l.right),n+=1+l.break,r-=l.size}else if(s>r*2){let l=e[n];l.break?e.splice(n,1,l.left,null,l.right):e.splice(n,1,l.left,l.right),n+=2+l.break,s-=l.size}else break;else if(r<s){let l=e[i++];l&&(r+=l.size)}else{let l=e[--n];l&&(s+=l.size)}let o=!1;return e[i-1]==null?(o=!0,i--):e[i]==null&&(o=!0,n++),new nu(Ri.of(e.slice(0,i)),o,Ri.of(e.slice(n)))}};function zi(t,e){return t==e?t:(t.constructor!=e.constructor&&(Dt=!0),e)}me.prototype.size=1;var iu=N.replace({}),ta=class extends me{constructor(t,e,i){super(t,e),this.deco=i,this.spaceAbove=0}mainBlock(t,e){return new We(e,this.length,t+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(t,e,i,n){return this.spaceAbove&&t<i+this.spaceAbove?new We(n,0,i,this.spaceAbove,iu):this.mainBlock(i,n)}lineAt(t,e,i,n,r){let s=this.mainBlock(n,r);return this.spaceAbove?this.blockAt(0,i,n,r).join(s):s}forEachLine(t,e,i,n,r,s){t<=r+this.length&&e>=r&&s(this.lineAt(0,W.ByPos,i,n,r))}setMeasuredHeight(t){let e=t.heights[t.index++];e<0?(this.spaceAbove=-e,e=t.heights[t.index++]):this.spaceAbove=0,this.setHeight(e)}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more&&this.setMeasuredHeight(n),this.outdated=!1,this}toString(){return`block(${this.length})`}},Me=class lr extends ta{constructor(e,i,n){super(e,i,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=n}mainBlock(e,i){return new We(i,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,i,n){let r=n[0];return n.length==1&&(r instanceof lr||r instanceof St&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof St?r=new lr(r.length,this.height,this.spaceAbove):r.height=this.height,this.outdated||(r.outdated=!1),r):me.of(n)}updateHeight(e,i=0,n=!1,r){return r&&r.from<=i&&r.more?this.setMeasuredHeight(r):(n||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}},St=class de extends me{constructor(e){super(e,0)}heightMetrics(e,i){let n=e.doc.lineAt(i).number,r=e.doc.lineAt(i+this.length).number,s=r-n+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*s);o=a/s,this.length>s+1&&(l=(this.height-a)/(this.length-s-1))}else o=this.height/s;return{firstLine:n,lastLine:r,perLine:o,perChar:l}}blockAt(e,i,n,r){let{firstLine:s,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(i,r);if(i.lineWrapping){let h=r+(e<i.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),f=i.doc.lineAt(h),u=l+f.length*a,c=Math.max(n,e-u/2);return new We(f.from,f.length,c,u,0)}else{let h=Math.max(0,Math.min(o-s,Math.floor((e-n)/l))),{from:f,length:u}=i.doc.line(s+h);return new We(f,u,n+l*h,l,0)}}lineAt(e,i,n,r,s){if(i==W.ByHeight)return this.blockAt(e,n,r,s);if(i==W.ByPosNoHeight){let{from:d,to:p}=n.doc.lineAt(e);return new We(d,p-d,0,0,0)}let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(n,s),h=n.doc.lineAt(e),f=l+h.length*a,u=h.number-o,c=r+l*u+a*(h.from-s-u);return new We(h.from,h.length,Math.max(r,Math.min(c,r+this.height-f)),f,0)}forEachLine(e,i,n,r,s,o){e=Math.max(e,s),i=Math.min(i,s+this.length);let{firstLine:l,perLine:a,perChar:h}=this.heightMetrics(n,s);for(let f=e,u=r;f<=i;){let c=n.doc.lineAt(f);if(f==e){let p=c.number-l;u+=a*p+h*(e-s-p)}let d=a+h*c.length;o(new We(c.from,c.length,u,d,0)),u+=d,f=c.to+1}}replace(e,i,n){let r=this.length-i;if(r>0){let s=n[n.length-1];s instanceof de?n[n.length-1]=new de(s.length+r):n.push(null,new de(r-1))}if(e>0){let s=n[0];s instanceof de?n[0]=new de(e+s.length):n.unshift(new de(e-1),null)}return me.of(n)}decomposeLeft(e,i){i.push(new de(e-1),null)}decomposeRight(e,i){i.push(null,new de(this.length-e-1))}updateHeight(e,i=0,n=!1,r){let s=i+this.length;if(r&&r.from<=i+this.length&&r.more){let o=[],l=Math.max(i,r.from),a=-1;for(r.from>i&&o.push(new de(r.from-i-1).updateHeight(e,i));l<=s&&r.more;){let f=e.doc.lineAt(l).length;o.length&&o.push(null);let u=r.heights[r.index++],c=0;u<0&&(c=-u,u=r.heights[r.index++]),a==-1?a=u:Math.abs(u-a)>=Ei&&(a=-2);let d=new Me(f,u,c);d.outdated=!1,o.push(d),l+=f+1}l<=s&&o.push(null,new de(s-l).updateHeight(e,l));let h=me.of(o);return(a<0||Math.abs(h.height-this.height)>=Ei||Math.abs(a-this.heightMetrics(e,i).perLine)>=Ei)&&(Dt=!0),zi(this,h)}else(n||this.outdated)&&(this.setHeight(e.heightForGap(i,i+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},nu=class extends me{constructor(t,e,i){super(t.length+(e?1:0)+i.length,t.height+i.height,(e?1:0)|(t.outdated||i.outdated?2:0)),this.left=t,this.right=i,this.size=t.size+i.size}get break(){return this.flags&1}blockAt(t,e,i,n){let r=i+this.left.height;return t<r?this.left.blockAt(t,e,i,n):this.right.blockAt(t,e,r,n+this.left.length+this.break)}lineAt(t,e,i,n,r){let s=n+this.left.height,o=r+this.left.length+this.break,l=e==W.ByHeight?t<s:t<o,a=l?this.left.lineAt(t,e,i,n,r):this.right.lineAt(t,e,i,s,o);if(this.break||(l?a.to<o:a.from>o))return a;let h=e==W.ByPosNoHeight?W.ByPosNoHeight:W.ByPos;return l?a.join(this.right.lineAt(o,h,i,s,o)):this.left.lineAt(o,h,i,n,r).join(a)}forEachLine(t,e,i,n,r,s){let o=n+this.left.height,l=r+this.left.length+this.break;if(this.break)t<l&&this.left.forEachLine(t,e,i,n,r,s),e>=l&&this.right.forEachLine(t,e,i,o,l,s);else{let a=this.lineAt(l,W.ByPos,i,n,r);t<a.from&&this.left.forEachLine(t,Math.min(e,a.from-1),i,n,r,s),a.to>=t&&a.from<=e&&s(a),e>a.to&&this.right.forEachLine(Math.max(t,a.to+1),e,i,o,l,s)}}replace(t,e,i){let n=this.left.length+this.break;if(e<n)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let r=[];t>0&&this.decomposeLeft(t,r);let s=r.length;for(let o of i)r.push(o);if(t>0&&Fs(r,s-1),e<this.length){let o=r.length;this.decomposeRight(e,r),Fs(r,o)}return me.of(r)}decomposeLeft(t,e){let i=this.left.length;if(t<=i)return this.left.decomposeLeft(t,e);e.push(this.left),this.break&&(i++,t>=i&&e.push(null)),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){let i=this.left.length,n=i+this.break;if(t>=n)return this.right.decomposeRight(t-n,e);t<i&&this.left.decomposeRight(t,e),this.break&&t<n&&e.push(null),e.push(this.right)}balanced(t,e){return t.size>2*e.size||e.size>2*t.size?me.of(this.break?[t,null,e]:[t,e]):(this.left=zi(this.left,t),this.right=zi(this.right,e),this.setHeight(t.height+e.height),this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,i=!1,n){let{left:r,right:s}=this,o=e+r.length+this.break,l=null;return n&&n.from<=e+r.length&&n.more?l=r=r.updateHeight(t,e,i,n):r.updateHeight(t,e,i),n&&n.from<=o+s.length&&n.more?l=s=s.updateHeight(t,o,i,n):s.updateHeight(t,o,i),l?this.balanced(r,s):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function Fs(t,e){let i,n;t[e]==null&&(i=t[e-1])instanceof St&&(n=t[e+1])instanceof St&&t.splice(e-1,3,new St(i.length+1+n.length))}var ru=5,su=class ia{constructor(e,i){this.pos=e,this.oracle=i,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,i){if(this.lineStart>-1){let n=Math.min(i,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof Me?r.length+=n-this.pos:(n>this.pos||!this.isCovered)&&this.nodes.push(new Me(n-this.pos,-1,0)),this.writtenTo=n,i>n&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=i}point(e,i,n){if(e<i||n.heightRelevant){let r=n.widget?n.widget.estimatedHeight:0,s=n.widget?n.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let o=i-e;n.block?this.addBlock(new ta(o,r,n)):(o||s||r>=ru)&&this.addLineDeco(r,s,o)}else i>e&&this.span(e,i);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:i}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=i,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new Me(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,i){let n=new St(i-e);return this.oracle.doc.lineAt(e).to==i&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Me)return e;let i=new Me(0,-1,0);return this.nodes.push(i),i}addBlock(e){this.enterLine();let i=e.deco;i&&i.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,i&&i.endSide>0&&(this.covering=e)}addLineDeco(e,i,n){let r=this.ensureLine();r.length+=n,r.collapsed+=n,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=i,this.writtenTo=this.pos=this.pos+n}finish(e){let i=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(i instanceof Me)&&!this.isCovered?this.nodes.push(new Me(0,-1,0)):(this.writtenTo<this.pos||i==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let n=e;for(let r of this.nodes)r instanceof Me&&r.updateHeight(this.oracle,n),n+=r?r.length:1;return this.nodes}static build(e,i,n,r){let s=new ia(n,e);return F.spans(i,n,r,s,0),s.finish(n)}};function ou(t,e,i){let n=new lu;return F.compare(t,e,i,n,0),n.changes}var lu=class{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,n){(t<e||i&&i.heightRelevant||n&&n.heightRelevant)&&xt(t,e,this.changes,5)}};function au(t,e){let i=t.getBoundingClientRect(),n=t.ownerDocument,r=n.defaultView||window,s=Math.max(0,i.left),o=Math.min(r.innerWidth,i.right),l=Math.max(0,i.top),a=Math.min(r.innerHeight,i.bottom);for(let h=t.parentNode;h&&h!=n.body;)if(_(h)){let f=window.getComputedStyle(h);if((h.scrollHeight>h.clientHeight||h.scrollWidth>h.clientWidth)&&f.overflow!="visible"){let u=h.getBoundingClientRect();s=Math.max(s,u.left),o=Math.min(o,u.right),l=Math.max(l,u.top),a=Math.min(h==t.parentNode?r.innerHeight:a,u.bottom)}h=f.position=="absolute"||f.position=="fixed"?h.offsetParent:h.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:s-i.left,right:Math.max(s,o)-i.left,top:l-(i.top+e),bottom:Math.max(l,a)-(i.top+e)}}function hu(t){let e=t.getBoundingClientRect(),i=t.ownerDocument.defaultView||window;return e.left<i.innerWidth&&e.right>0&&e.top<i.innerHeight&&e.bottom>0}function fu(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}var cn=class{constructor(t,e,i,n){this.from=t,this.to=e,this.size=i,this.displaySize=n}static same(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let n=t[i],r=e[i];if(n.from!=r.from||n.to!=r.to||n.size!=r.size)return!1}return!0}draw(t,e){return N.replace({widget:new uu(this.displaySize*(e?t.scaleY:t.scaleX),e)}).range(this.from,this.to)}},uu=class extends et{constructor(t,e){super(),this.size=t,this.vertical=e}eq(t){return t.size==this.size&&t.vertical==this.vertical}toDOM(){let t=document.createElement("div");return this.vertical?t.style.height=this.size+"px":(t.style.width=this.size+"px",t.style.height="2px",t.style.display="inline-block"),t}get estimatedHeight(){return this.vertical?this.size:-1}},Vs=class{constructor(t,e){this.view=t,this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=ar,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=q.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1,this.heightOracle=new eu(e.facet(Lr).some(i=>typeof i!="function"&&i.class=="cm-lineWrapping")),this.stateDeco=$s(e),this.heightMap=me.empty().applyChanges(this.stateDeco,I.empty,this.heightOracle.setDoc(e.doc),[new Fe(0,0,0,e.doc.length)]);for(let i=0;i<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());i++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=N.set(this.lineGaps.map(i=>i.draw(this,!1))),this.scrollParent=t.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:e}=this.state.selection;for(let i=0;i<=1;i++){let n=i?e.head:e.anchor;if(!t.some(({from:r,to:s})=>n>=r&&n<=s)){let{from:r,to:s}=this.lineBlockAt(n);t.push(new wi(r,s))}}return this.viewports=t.sort((i,n)=>i.from-n.from),this.updateScaler()}updateScaler(){let t=this.scaler;return this.scaler=this.heightMap.height<=7e6?ar:pu.get(this.heightOracle,this.heightMap,this.viewports),t.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,t=>{this.viewportLines.push($t(t,this.scaler))})}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=$s(this.state);let n=t.changedRanges,r=Fe.extendWithRanges(n,ou(i,this.stateDeco,t?t.changes:be.empty(this.state.doc.length))),s=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);Ws(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),r),(this.heightMap.height!=s||Dt)&&(t.flags|=2),o?(this.scrollAnchorPos=t.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=s);let l=r.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<l.from||e.range.head>l.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,e));let a=l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,t.flags|=this.updateForViewport(),(a||!t.changes.empty||t.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,t.changes))),t.flags|=this.computeVisibleRanges(t.changes),e&&(this.scrollTarget=e),!this.mustEnforceCursorAssoc&&(t.selectionSet||t.focusChanged)&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&!t.state.facet(Zh)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:t}=this,e=t.contentDOM,i=window.getComputedStyle(e),n=this.heightOracle,r=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?q.RTL:q.LTR;let s=this.heightOracle.mustRefreshForWrapping(r)||this.mustMeasureContent==="refresh",o=e.getBoundingClientRect(),l=s||this.mustMeasureContent||this.contentDOMHeight!=o.height;this.contentDOMHeight=o.height,this.mustMeasureContent=!1;let a=0,h=0;if(o.width&&o.height){let{scaleX:O,scaleY:k}=ol(e,o);(O>.005&&Math.abs(this.scaleX-O)>.005||k>.005&&Math.abs(this.scaleY-k)>.005)&&(this.scaleX=O,this.scaleY=k,a|=16,s=l=!0)}let f=(parseInt(i.paddingTop)||0)*this.scaleY,u=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=u)&&(this.paddingTop=f,this.paddingBottom=u,a|=18),this.editorWidth!=t.scrollDOM.clientWidth&&(n.lineWrapping&&(l=!0),this.editorWidth=t.scrollDOM.clientWidth,a|=16);let c=ll(this.view.contentDOM,!1).y;c!=this.scrollParent&&(this.scrollParent=c,this.scrollAnchorHeight=-1,this.scrollOffset=0);let d=this.getScrollOffset();this.scrollOffset!=d&&(this.scrollAnchorHeight=-1,this.scrollOffset=d),this.scrolledToBottom=ul(this.scrollParent||t.win);let p=(this.printing?fu:au)(e,this.paddingTop),g=p.top-this.pixelViewport.top,m=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let b=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(b!=this.inView&&(this.inView=b,b&&(l=!0)),!this.inView&&!this.scrollTarget&&!hu(t.dom))return 0;let x=o.width;if((this.contentDOMWidth!=x||this.editorHeight!=t.scrollDOM.clientHeight)&&(this.contentDOMWidth=o.width,this.editorHeight=t.scrollDOM.clientHeight,a|=16),l){let O=t.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(O)&&(s=!0),s||n.lineWrapping&&Math.abs(x-this.contentDOMWidth)>n.charWidth){let{lineHeight:k,charWidth:P,textHeight:M}=t.docView.measureTextSize();s=k>0&&n.refresh(r,k,P,M,Math.max(5,x/P),O),s&&(t.docView.minWidth=0,a|=16)}g>0&&m>0?h=Math.max(g,m):g<0&&m<0&&(h=Math.min(g,m)),Ws();for(let k of this.viewports){let P=k.from==this.viewport.from?O:t.docView.measureVisibleLineHeights(k);this.heightMap=(s?me.empty().applyChanges(this.stateDeco,I.empty,this.heightOracle,[new Fe(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(n,0,s,new tu(k.from,P))}Dt&&(a|=2)}let A=!this.viewportIsAppropriate(this.viewport,h)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return A&&(a&2&&(a|=this.updateScaler()),this.viewport=this.getViewport(h,this.scrollTarget),a|=this.updateForViewport()),(a&2||A)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(s?[]:this.lineGaps,t)),a|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),a}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),n=this.heightMap,r=this.heightOracle,{visibleTop:s,visibleBottom:o}=this,l=new wi(n.lineAt(s-i*1e3,W.ByHeight,r,0,0).from,n.lineAt(o+(1-i)*1e3,W.ByHeight,r,0,0).to);if(e){let{head:a}=e.range;if(a<l.from||a>l.to){let h=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=n.lineAt(a,W.ByPos,r,0,0),u;e.y=="center"?u=(f.top+f.bottom)/2-h/2:e.y=="start"||e.y=="nearest"&&a<l.from?u=f.top:u=f.bottom-h,l=new wi(n.lineAt(u-1e3/2,W.ByHeight,r,0,0).from,n.lineAt(u+h+1e3/2,W.ByHeight,r,0,0).to)}}return l}mapViewport(t,e){let i=e.mapPos(t.from,-1),n=e.mapPos(t.to,1);return new wi(this.heightMap.lineAt(i,W.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,W.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(t,W.ByPos,this.heightOracle,0,0),{bottom:r}=this.heightMap.lineAt(e,W.ByPos,this.heightOracle,0,0),{visibleTop:s,visibleBottom:o}=this;return(t==0||n<=s-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||r>=o+Math.max(10,Math.min(i,250)))&&n>s-2*1e3&&r<o+2*1e3}mapLineGaps(t,e){if(!t.length||e.empty)return t;let i=[];for(let n of t)e.touchesRange(n.from,n.to)||i.push(new cn(e.mapPos(n.from),e.mapPos(n.to),n.size,n.displaySize));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,r=n>>1,s=n<<1;if(this.defaultTextDirection!=q.LTR&&!i)return[];let o=[],l=(h,f,u,c)=>{if(f-h<r)return;let d=this.state.selection.main,p=[d.from];d.empty||p.push(d.to);for(let m of p)if(m>h&&m<f){l(h,m-10,u,c),l(m+10,f,u,c);return}let g=du(t,m=>m.from>=u.from&&m.to<=u.to&&Math.abs(m.from-h)<r&&Math.abs(m.to-f)<r&&!p.some(b=>m.from<b&&m.to>b));if(!g){if(f<u.to&&e&&i&&e.visibleRanges.some(b=>b.from<=f&&b.to>=f)){let b=e.moveToLineBoundary(S.cursor(f),!1,!0).head;b>h&&(f=b)}let m=this.gapSize(u,h,f,c);g=new cn(h,f,m,i||m<2e6?m:2e6)}o.push(g)},a=h=>{if(h.length<s||h.type!=ne.Text)return;let f=cu(h.from,h.to,this.stateDeco);if(f.total<s)return;let u=this.scrollTarget?this.scrollTarget.range.head:null,c,d;if(i){let p=n/this.heightOracle.lineLength*this.heightOracle.lineHeight,g,m;if(u!=null){let b=ki(f,u),x=((this.visibleBottom-this.visibleTop)/2+p)/h.height;g=b-x,m=b+x}else g=(this.visibleTop-h.top-p)/h.height,m=(this.visibleBottom-h.top+p)/h.height;c=xi(f,g),d=xi(f,m)}else{let p=f.total*this.heightOracle.charWidth,g=n*this.heightOracle.charWidth,m=0;if(p>2e6)for(let k of t)k.from>=h.from&&k.from<h.to&&k.size!=k.displaySize&&k.from*this.heightOracle.charWidth+m<this.pixelViewport.left&&(m=k.size-k.displaySize);let b=this.pixelViewport.left+m,x=this.pixelViewport.right+m,A,O;if(u!=null){let k=ki(f,u),P=((x-b)/2+g)/p;A=k-P,O=k+P}else A=(b-g)/p,O=(x+g)/p;c=xi(f,A),d=xi(f,O)}c>h.from&&l(h.from,c,h,f),d<h.to&&l(d,h.to,h,f)};for(let h of this.viewportLines)Array.isArray(h.type)?h.type.forEach(a):a(h);return o}gapSize(t,e,i,n){let r=ki(n,i)-ki(n,e);return this.heightOracle.lineWrapping?t.height*r:n.total*this.heightOracle.charWidth*r}updateLineGaps(t){cn.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=N.set(t.map(e=>e.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(t){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let i=[];F.spans(e,this.viewport.from,this.viewport.to,{span(r,s){i.push({from:r,to:s})},point(){}},20);let n=0;if(i.length!=this.visibleRanges.length)n=12;else for(let r=0;r<i.length&&!(n&8);r++){let s=this.visibleRanges[r],o=i[r];(s.from!=o.from||s.to!=o.to)&&(n|=4,t&&t.mapPos(s.from,-1)==o.from&&t.mapPos(s.to,1)==o.to||(n|=8))}return this.visibleRanges=i,n}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find(e=>e.from<=t&&e.to>=t)||$t(this.heightMap.lineAt(t,W.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return t>=this.viewportLines[0].top&&t<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(e=>e.top<=t&&e.bottom>=t)||$t(this.heightMap.lineAt(this.scaler.fromDOM(t),W.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(t){let e=this.lineBlockAtHeight(t+12-this.paddingTop);return e.from>=this.viewport.from||this.viewportLines[0].top-t>200?e:this.viewportLines[0]}elementAtHeight(t){return $t(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},wi=class{constructor(t,e){this.from=t,this.to=e}};function cu(t,e,i){let n=[],r=t,s=0;return F.spans(i,t,e,{span(){},point(o,l){o>r&&(n.push({from:r,to:o}),s+=o-r),r=l}},20),r<e&&(n.push({from:r,to:e}),s+=e-r),{total:s,ranges:n}}function xi({total:t,ranges:e},i){if(i<=0)return e[0].from;if(i>=1)return e[e.length-1].to;let n=Math.floor(t*i);for(let r=0;;r++){let{from:s,to:o}=e[r],l=o-s;if(n<=l)return s+n;n-=l}}function ki(t,e){let i=0;for(let{from:n,to:r}of t.ranges){if(e<=r){i+=e-n;break}i+=r-n}return i/t.total}function du(t,e){for(let i of t)if(e(i))return i}var ar={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function $s(t){let e=t.facet(_i).filter(n=>typeof n!="function"),i=t.facet(Hr).filter(n=>typeof n!="function");return i.length&&e.push(F.join(i)),e}var pu=class hr{constructor(e,i){this.scale=e,this.viewports=i}static get(e,i,n){let r=0,s=0,o=0,l=n.map(({from:h,to:f})=>{let u=i.lineAt(h,W.ByPos,e,0,0).top,c=i.lineAt(f,W.ByPos,e,0,0).bottom;return r+=c-u,{from:h,to:f,top:u,bottom:c,domTop:0,domBottom:0}});if(i.height-r<10)return ar;let a=(7e6-r)/(i.height-r);for(let h of l)h.domTop=o+(h.top-s)*a,o=h.domBottom=h.domTop+(h.bottom-h.top),s=h.bottom;return new hr(a,l)}toDOM(e){for(let i=0,n=0,r=0;;i++){let s=i<this.viewports.length?this.viewports[i]:null;if(!s||e<s.top)return r+(e-n)*this.scale;if(e<=s.bottom)return s.domTop+(e-s.top);n=s.bottom,r=s.domBottom}}fromDOM(e){for(let i=0,n=0,r=0;;i++){let s=i<this.viewports.length?this.viewports[i]:null;if(!s||e<s.domTop)return n+(e-r)/this.scale;if(e<=s.domBottom)return s.top+(e-s.domTop);n=s.bottom,r=s.domBottom}}eq(e){return e instanceof hr?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((i,n)=>i.from==e.viewports[n].from&&i.to==e.viewports[n].to):!1}};function $t(t,e){if(e.scale==1)return t;let i=e.toDOM(t.top),n=e.toDOM(t.bottom);return new We(t.from,t.length,i,n-i,Array.isArray(t._content)?t._content.map(r=>$t(r,e)):t._content)}var Si=C.define({combine:t=>t.join(" ")}),fr=C.define({combine:t=>t.indexOf(!0)>-1}),ur=Ye.newName(),na=Ye.newName(),ra=Ye.newName(),sa={"&light":"."+na,"&dark":"."+ra};function cr(t,e,i){return new Ye(e,{finish(n){return/&/.test(n)?n.replace(/&\w*/,r=>{if(r=="&")return t;if(!i||!i[r])throw new RangeError(`Unsupported selector: ${r}`);return i[r]}):t+" "+n}})}var gu=cr("."+ur,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"baseline",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},sa),mu={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},dn=w.ie&&w.ie_version<=11,bu=class{constructor(t){this.view=t,this.active=!1,this.editContext=null,this.selectionRange=new $h,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver(e=>{for(let i of e)this.queue.push(i);(w.ie&&w.ie_version<=11||w.ios&&t.composing)&&e.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&w.android&&t.constructor.EDIT_CONTEXT!==!1&&!(w.chrome&&w.chrome_version<126)&&(this.editContext=new vu(t),t.state.facet(He)&&(t.contentDOM.editContext=this.editContext.editContext)),dn&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var e;((e=this.view.docView)===null||e===void 0?void 0:e.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(t.scrollDOM)),this.addWindowListeners(this.win=t.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(t){this.view.inputState.runHandlers("scroll",t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(this.pendingRecords().length>0),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(t){(t.type=="change"||!t.type)&&!t.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some((e,i)=>e!=t[i]))){this.gapIntersection.disconnect();for(let e of t)this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(He)?i.root.activeElement!=this.dom:!qt(this.dom,n))return;let r=n.anchorNode&&i.docView.tile.nearest(n.anchorNode);if(r&&r.isWidget()&&r.widget.ignoreEvent(t)){e||(this.selectionChanged=!1);return}(w.ie&&w.ie_version<=11||w.android&&w.chrome)&&!i.state.selection.main.empty&&n.focusNode&&Ut(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=ii(t.root);if(!e)return!1;let i=w.safari&&t.root.nodeType==11&&t.root.activeElement==this.dom&&yu(this.view,e)||e;if(!i||this.selectionRange.eq(i))return!1;let n=qt(this.dom,i);return n&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&zh(this.dom,i)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(i),n&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let i=this.dom;i;)if(_(i))!e&&t<this.scrollTargets.length&&this.scrollTargets[t]==i?t++:e||(e=this.scrollTargets.slice(0,t)),e&&e.push(i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;if(t<this.scrollTargets.length&&!e&&(e=this.scrollTargets.slice(0,t)),e){for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);for(let i of this.scrollTargets=e)i.addEventListener("scroll",this.onScroll)}}ignore(t){if(!this.active)return t();try{return this.stop(),t()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,mu),dn&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),dn&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var i;if(!this.delayedAndroidKey){let n=()=>{let r=this.delayedAndroidKey;r&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=r.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&r.force&&kt(this.dom,r.key,r.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(n)}(!this.delayedAndroidKey||t=="Enter")&&(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(!((i=this.delayedAndroidKey)===null||i===void 0)&&i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,n=!1;for(let r of t){let s=this.readMutation(r);s&&(s.typeOver&&(n=!0),e==-1?{from:e,to:i}=s:(e=Math.min(s.from,e),i=Math.max(s.to,i)))}return{from:e,to:i,typeOver:n}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),n=this.selectionChanged&&qt(this.dom,this.selectionRange);if(t<0&&!n)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new Rf(this.view,t,e,i);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.selectionChanged,i=this.readChange();if(!i)return this.view.requestMeasure(),!1;let n=this.view.state,r=Kl(this.view,i);return this.view.state==n&&(i.domChanged||e)&&this.view.update([]),r}readMutation(t){let e=this.view.docView.tile.nearest(t.target);if(!e||e.isWidget())return null;if(e.markDirty(t.type=="attributes"),t.type=="childList"){let i=js(e,t.previousSibling||t.target.previousSibling,-1),n=js(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:n?e.posBefore(n):e.posAtEnd,typeOver:!1}}else return t.type=="characterData"?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}update(t){this.editContext&&(this.editContext.update(t),t.startState.facet(He)!=t.state.facet(He)&&(t.view.contentDOM.editContext=t.state.facet(He)?this.editContext.editContext:null))}destroy(){var t,e,i;this.stop(),(t=this.intersection)===null||t===void 0||t.disconnect(),(e=this.gapIntersection)===null||e===void 0||e.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}};function js(t,e,i){for(;e;){let n=G.get(e);if(n&&n.parent==t)return n;let r=e.parentNode;e=r!=t.dom?r:i>0?e.nextSibling:e.previousSibling}return null}function zs(t,e){let i=e.startContainer,n=e.startOffset,r=e.endContainer,s=e.endOffset,o=t.docView.domAtPos(t.state.selection.main.anchor,1);return Ut(o.node,o.offset,r,s)&&([i,n,r,s]=[r,s,i,n]),{anchorNode:i,anchorOffset:n,focusNode:r,focusOffset:s}}function yu(t,e){if(e.getComposedRanges){let r=e.getComposedRanges(t.root)[0];if(r)return zs(t,r)}let i=null;function n(r){r.preventDefault(),r.stopImmediatePropagation(),i=r.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",n,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",n,!0),i?zs(t,i):null}var vu=class{constructor(t){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(t.state);let e=this.editContext=new window.EditContext({text:t.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,t.state.selection.main.anchor))),selectionEnd:this.toContextPos(t.state.selection.main.head)});this.handlers.textupdate=i=>{let n=t.state.selection.main,{anchor:r,head:s}=n,o=this.toEditorPos(i.updateRangeStart),l=this.toEditorPos(i.updateRangeEnd);t.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:o,drifted:!1});let a=l-o>i.text.length;o==this.from&&r<this.from?o=r:l==this.to&&r>this.to&&(l=r);let h=ql(t.state.sliceDoc(o,l),i.text,(a?n.from:n.to)-o,a?"end":null);if(!h){let u=S.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));sr(u,n)||t.dispatch({selection:u,userEvent:"select"});return}let f={from:h.from+o,to:h.toA+o,insert:I.of(i.text.slice(h.from,h.toB).split(`
|
|
10
|
+
`))};if((w.mac||w.android)&&f.from==s-1&&/^\. ?$/.test(i.text)&&t.contentDOM.getAttribute("autocorrect")=="off"&&(f={from:o,to:l,insert:I.of([i.text.replace("."," ")])}),this.pendingContextChange=f,!t.state.readOnly){let u=this.to-this.from+(f.to-f.from+f.insert.length);Wr(t,f,S.single(this.toEditorPos(i.selectionStart,u),this.toEditorPos(i.selectionEnd,u)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state)),f.from<f.to&&!f.insert.length&&t.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(e.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(e.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let n=[],r=null;for(let s=this.toEditorPos(i.rangeStart),o=this.toEditorPos(i.rangeEnd);s<o;s++){let l=t.coordsForChar(s);r=l&&new DOMRect(l.left,l.top,l.right-l.left,l.bottom-l.top)||r||new DOMRect,n.push(r)}e.updateCharacterBounds(i.rangeStart,n)},this.handlers.textformatupdate=i=>{let n=[];for(let r of i.getTextFormats()){let s=r.underlineStyle,o=r.underlineThickness;if(!/none/i.test(s)&&!/none/i.test(o)){let l=this.toEditorPos(r.rangeStart),a=this.toEditorPos(r.rangeEnd);if(l<a){let h=`text-decoration: underline ${/^[a-z]/.test(s)?s+" ":s=="Dashed"?"dashed ":s=="Squiggle"?"wavy ":""}${/thin/i.test(o)?1:2}px`;n.push(N.mark({attributes:{style:h}}).range(l,a))}}}t.dispatch({effects:Ol.of(N.set(n))})},this.handlers.compositionstart=()=>{t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(t.inputState.composing=-1,t.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(t.state)}};for(let i in this.handlers)e.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{let n=ii(i.root);n&&n.rangeCount&&this.editContext.updateSelectionBounds(n.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let e=0,i=!1,n=this.pendingContextChange;return t.changes.iterChanges((r,s,o,l,a)=>{if(i)return;let h=a.length-(s-r);if(n&&s>=n.to)if(n.from==r&&n.to==s&&n.insert.eq(a)){n=this.pendingContextChange=null,e+=h,this.to+=h;return}else n=null,this.revertPending(t.state);if(r+=e,s+=e,s<=this.from)this.from+=h,this.to+=h;else if(r<this.to){if(r<this.from||s>this.to||this.to-this.from+a.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(r),this.toContextPos(s),a.toString()),this.to+=h}e+=h}),n&&!i&&this.revertPending(t.state),!i}update(t){let e=this.pendingContextChange,i=t.startState.selection.main;this.composing&&(this.composing.drifted||!t.changes.touchesRange(i.from,i.to)&&t.transactions.some(n=>!n.isUserEvent("input.type")&&n.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=t.changes.mapPos(this.composing.editorBase)):!this.applyEdits(t)||!this.rangeIsValid(t.state)?(this.pendingContextChange=null,this.reset(t.state)):(t.docChanged||t.selectionSet||e)&&this.setSelection(t.state),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:e}=t.selection.main;this.from=Math.max(0,e-1e4),this.to=Math.min(t.doc.length,e+1e4)}reset(t){this.resetRange(t),this.editContext.updateText(0,this.editContext.text.length,t.doc.sliceString(this.from,this.to)),this.setSelection(t)}revertPending(t){let e=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(e.from),this.toContextPos(e.from+e.insert.length),t.doc.sliceString(e.from,e.to))}setSelection(t){let{main:e}=t.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,e.anchor))),n=this.toContextPos(e.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=n)&&this.editContext.updateSelection(i,n)}rangeIsValid(t){let{head:e}=t.selection.main;return!(this.from>0&&e-this.from<500||this.to<t.doc.length&&this.to-e<500||this.to-this.from>1e4*3)}toEditorPos(t,e=this.to-this.from){t=Math.min(t,e);let i=this.composing;return i&&i.drifted?i.editorBase+(t-i.contextBase):t+this.from}toContextPos(t){let e=this.composing;return e&&e.drifted?e.contextBase+(t-e.editorBase):t-this.from}destroy(){for(let t in this.handlers)this.editContext.removeEventListener(t,this.handlers[t])}},D=class Ni{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var i;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.clearAnnouncement=-1,this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;this.dispatchTransactions=e.dispatchTransactions||n&&(r=>r.forEach(s=>n(s,this)))||(r=>this.update(r)),this.dispatch=this.dispatch.bind(this),this._root=e.root||jh(e.parent)||document,this.viewState=new Vs(this,e.state||U.create(e)),e.scrollTo&&e.scrollTo.is(bi)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(dt).map(r=>new ln(r));for(let r of this.plugins)r.update(this);this.observer=new bu(this),this.inputState=new Hf(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Os(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((i=document.fonts)===null||i===void 0)&&i.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let i=e.length==1&&e[0]instanceof he?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(i,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let i=!1,n=!1,r,s=this.state;for(let c of e){if(c.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=c.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,l=0,a=null;e.some(c=>c.annotation(Xl))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Ql(s,o),a||(l=1));let h=this.observer.delayedAndroidKey,f=null;if(h?(this.observer.clearDelayedAndroidKey(),f=this.observer.readChange(),(f&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(f=null)):this.observer.clear(),s.facet(U.phrases)!=this.state.facet(U.phrases))return this.setState(s);r=Cs.create(this,s,e),r.flags|=l;let u=this.viewState.scrollTarget;try{this.updateState=2;for(let c of e){if(u&&(u=u.map(c.changes)),c.scrollIntoView){let{main:d}=c.state.selection,{x:p,y:g}=this.state.facet(Ni.cursorScrollMargin);u=new on(d.empty?d:S.cursor(d.head,d.head>d.anchor?-1:1),"nearest","nearest",g,p)}for(let d of c.effects)d.is(bi)&&(u=d.value.clip(this.state))}this.viewState.update(r,u),this.bidiCache=qs.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),i=this.docView.update(r),this.state.facet(Ft)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(i,e.some(c=>c.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(Si)!=r.state.facet(Si)&&(this.viewState.mustMeasureContent=!0),(i||n||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),i&&this.docViewUpdate(),!r.empty)for(let c of this.state.facet(Zn))try{c(r)}catch(d){Pe(this.state,d,"update listener")}(a||f)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),f&&!Kl(this,f)&&h.force&&kt(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let i=this.hasFocus;try{for(let n of this.plugins)n.destroy(this);this.viewState=new Vs(this,e),this.plugins=e.facet(dt).map(n=>new ln(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView.destroy(),this.docView=new Os(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}i&&this.focus(),this.requestMeasure()}updatePlugins(e){let i=e.startState.facet(dt),n=e.state.facet(dt);if(i!=n){let r=[];for(let s of n){let o=i.indexOf(s);if(o<0)r.push(new ln(s));else{let l=this.plugins[o];l.mustUpdate=e,r.push(l)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r<this.plugins.length;r++)this.plugins[r].update(this);i!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let i=e.value;if(i&&i.docViewUpdate)try{i.docViewUpdate(this)}catch(n){Pe(this.state,n,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let i=null,n=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:o,scaleY:l}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(o<0){if(ul(n||this.win))s=-1,o=this.viewState.heightMap.height/this.viewState.scaleY;else{let p=this.viewState.scrollAnchorAt(r);s=p.from,o=p.top}l=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null||a>5)break;let f=[];h&4||([this.measureRequests,f]=[f,this.measureRequests]);let u=f.map(p=>{try{return p.read(this)}catch(g){return Pe(this.state,g),Ks}}),c=Cs.create(this,this.state,[]),d=!1;c.flags|=h,i?i.flags|=h:i=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),d=this.docView.update(c),d&&this.docViewUpdate());for(let p=0;p<f.length;p++)if(u[p]!=Ks)try{let g=f[p];g.write&&g.write(u[p],this)}catch(g){Pe(this.state,g)}if(d&&this.docView.updateSelection(!0),!c.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let p=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)/this.viewState.scaleY-o/l;if((p>1||p<-1)&&!(w.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(n==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r=r+p,n?s<0?n.scrollTop=n.scrollHeight:n.scrollTop+=p:this.win.scrollBy(0,p),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(i&&!i.empty)for(let a of this.state.facet(Zn))a(i)}get themeClasses(){return ur+" "+(this.state.facet(fr)?ra:na)+" "+this.state.facet(Si)}updateAttrs(){let e=Gs(this,Tl,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),i={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(He)?"true":"false",class:"cm-content",style:`${w.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(i["aria-readonly"]="true"),Gs(this,Lr,i);let n=this.observer.ignore(()=>{let r=vs(this.contentDOM,this.contentAttrs,i),s=vs(this.dom,this.editorAttrs,e);return r||s});return this.editorAttrs=e,this.contentAttrs=i,n}showAnnouncements(e){let i=!0;for(let n of e)for(let r of n.effects)if(r.is(Ni.announce)){i&&(this.announceDOM.textContent="",this.win.clearTimeout(this.clearAnnouncement),this.clearAnnouncement=this.win.setTimeout(()=>{this.announceDOM.textContent=" "},200),i=!1);let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(Ft);let e=this.state.facet(Ni.cspNonce);Ye.mount(this.root,this.styleModules.concat(gu).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let i=0;i<this.measureRequests.length;i++)if(this.measureRequests[i].key===e.key){this.measureRequests[i]=e;return}}this.measureRequests.push(e)}}plugin(e){let i=this.pluginMap.get(e);return(i===void 0||i&&i.plugin!=e)&&this.pluginMap.set(e,i=this.plugins.find(n=>n.plugin==e)||null),i&&i.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,i,n){return un(this,e,Ts(this,e,i,n))}moveByGroup(e,i){return un(this,e,Ts(this,e,i,n=>Of(this,e.head,n)))}visualLineSide(e,i){return i?S.cursor(e.to,1):S.cursor(e.from,-1)}moveToLineBoundary(e,i,n=!0){return Mf(this,e,i,n)}moveVertically(e,i,n){return un(this,e,Tf(this,e,i,n))}domAtPos(e,i=1){return this.docView.domAtPos(e,i)}posAtDOM(e,i=0){return this.docView.posFromDOM(e,i)}posAtCoords(e,i=!0){this.readMeasured();let n=rr(this,e,i);return n&&n.pos}posAndSideAtCoords(e,i=!0){return this.readMeasured(),rr(this,e,i)}coordsAtPos(e,i=1){this.readMeasured();let n=this.state.doc.lineAt(e),r=this.bidiSpans(n),s=r[De.find(r,e-n.from,-1,i)];return n.length&&(e==n.from&&i<0||e==n.to&&i>0)&&s.dir!=this.textDirectionAt(n.from)&&(e==n.to?(e=n.from+s.from,i=1):(e=n.from+s.to,i=-1)),this.docView.coordsAt(e,i,s.dir==q.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(Al)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>wu)return bl(e.length);let i=this.textDirectionAt(e.from),n;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==i&&(s.fresh||ml(s.isolates,n=Ss(this,e))))return s.order;n||(n=Ss(this,e));let r=Jh(e.text,i,n);return this.bidiCache.push(new qs(e.from,e.to,i,n,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||w.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{fl(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.win.clearTimeout(this.clearAnnouncement),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,i={}){var n,r,s,o;return bi.of(new on(typeof e=="number"?S.cursor(e):e,(n=i.y)!==null&&n!==void 0?n:"nearest",(r=i.x)!==null&&r!==void 0?r:"nearest",(s=i.yMargin)!==null&&s!==void 0?s:5,(o=i.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:i}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return bi.of(new on(S.cursor(n.from),"start","start",n.top-e,i,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return Be.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Be.define(()=>({}),{eventObservers:e})}static theme(e,i){let n=Ye.newName(),r=[Si.of(n),Ft.of(cr(`.${n}`,e))];return i&&i.dark&&r.push(fr.of(!0)),r}static baseTheme(e){return oi.lowest(Ft.of(cr("."+ur,e,sa)))}static findFromDOM(e){var i;let n=e.querySelector(".cm-content"),r=n&&G.get(n)||G.get(e);return((i=r?.root)===null||i===void 0?void 0:i.view)||null}};D.styleModule=Ft;D.inputHandler=Sl;D.clipboardInputFilter=Nr;D.clipboardOutputFilter=Ir;D.scrollHandler=Ml;D.focusChangeEffect=Cl;D.perLineTextDirection=Al;D.exceptionSink=kl;D.updateListener=Zn;D.editable=He;D.mouseSelectionStyle=xl;D.dragMovesSelection=wl;D.clickAddsSelectionRange=vl;D.decorations=_i;D.blockWrappers=Dl;D.outerDecorations=Hr;D.atomicRanges=li;D.bidiIsolatedRanges=Pl;D.cursorScrollMargin=C.define({combine:t=>{let e=5,i=5;for(let n of t)typeof n=="number"?e=i=n:{x:e,y:i}=n;return{x:e,y:i}}});D.scrollMargins=El;D.darkTheme=fr;D.cspNonce=C.define({combine:t=>t.length?t[0]:""});D.contentAttributes=Lr;D.editorAttributes=Tl;D.lineWrapping=D.contentAttributes.of({class:"cm-lineWrapping"});D.announce=$.define();var wu=4096,Ks={},qs=class oa{constructor(e,i,n,r,s,o){this.from=e,this.to=i,this.dir=n,this.isolates=r,this.fresh=s,this.order=o}static update(e,i){if(i.empty&&!e.some(s=>s.fresh))return e;let n=[],r=e.length?e[e.length-1].dir:q.LTR;for(let s=Math.max(0,e.length-10);s<e.length;s++){let o=e[s];o.dir==r&&!i.touchesRange(o.from,o.to)&&n.push(new oa(i.mapPos(o.from,1),i.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return n}};function Gs(t,e,i){for(let n=t.state.facet(e),r=n.length-1;r>=0;r--){let s=n[r],o=typeof s=="function"?s(t):s;o&&Dr(o,i)}return i}var xu=w.mac?"mac":w.windows?"win":w.linux?"linux":"key";function ku(t,e){const i=t.split(/-(?!$)/);let n=i[i.length-1];n=="Space"&&(n=" ");let r,s,o,l;for(let a=0;a<i.length-1;++a){const h=i[a];if(/^(cmd|meta|m)$/i.test(h))l=!0;else if(/^a(lt)?$/i.test(h))r=!0;else if(/^(c|ctrl|control)$/i.test(h))s=!0;else if(/^s(hift)?$/i.test(h))o=!0;else if(/^mod$/i.test(h))e=="mac"?l=!0:s=!0;else throw new Error("Unrecognized modifier name: "+h)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),l&&(n="Meta-"+n),o&&(n="Shift-"+n),n}function Ci(t,e,i){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),i!==!1&&e.shiftKey&&(t="Shift-"+t),t}var Su=oi.default(D.domEventHandlers({keydown(t,e){return ha(aa(e.state),t,e,"editor")}})),la=C.define({enables:Su}),Us=new WeakMap;function aa(t){let e=t.facet(la),i=Us.get(e);return i||Us.set(e,i=Mu(e.reduce((n,r)=>n.concat(r),[]))),i}function Cu(t,e,i){return ha(aa(t.state),e,t,i)}var Ke=null,Au=4e3;function Mu(t,e=xu){let i=Object.create(null),n=Object.create(null),r=(o,l)=>{let a=n[o];if(a==null)n[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,l,a,h,f)=>{var u,c;let d=i[o]||(i[o]=Object.create(null)),p=l.split(/ (?!$)/).map(b=>ku(b,e));for(let b=1;b<p.length;b++){let x=p.slice(0,b).join(" ");r(x,!0),d[x]||(d[x]={preventDefault:!0,stopPropagation:!1,run:[A=>{let O=Ke={view:A,prefix:x,scope:o};return setTimeout(()=>{Ke==O&&(Ke=null)},Au),!0}]})}let g=p.join(" ");r(g,!1);let m=d[g]||(d[g]={preventDefault:!1,stopPropagation:!1,run:((c=(u=d._any)===null||u===void 0?void 0:u.run)===null||c===void 0?void 0:c.slice())||[]});a&&m.run.push(a),h&&(m.preventDefault=!0),f&&(m.stopPropagation=!0)};for(let o of t){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let h of l){let f=i[h]||(i[h]=Object.create(null));f._any||(f._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:u}=o;for(let c in f)f[c].run.push(d=>u(d,dr))}let a=o[e]||o.key;if(a)for(let h of l)s(h,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(h,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return i}var dr=null;function ha(t,e,i,n){dr=e;let r=Ih(e),s=Bo(Po(r,0))==r.length&&r!=" ",o="",l=!1,a=!1,h=!1;Ke&&Ke.view==i&&Ke.scope==n&&(o=Ke.prefix+" ",Ul.indexOf(e.keyCode)<0&&(a=!0,Ke=null));let f=new Set,u=g=>{if(g){for(let m of g.run)if(!f.has(m)&&(f.add(m),m(i)))return g.stopPropagation&&(h=!0),!0;g.preventDefault&&(g.stopPropagation&&(h=!0),a=!0)}return!1},c=t[n],d,p;return c&&(u(c[o+Ci(r,e,!s)])?l=!0:s&&(e.altKey||e.metaKey||e.ctrlKey)&&!(w.windows&&e.ctrlKey&&e.altKey)&&!(w.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(d=_e[e.keyCode])&&d!=r?(u(c[o+Ci(d,e,!0)])||e.shiftKey&&(p=ei[e.keyCode])!=r&&p!=d&&u(c[o+Ci(p,e,!1)]))&&(l=!0):s&&e.shiftKey&&u(c[o+Ci(r,e,!0)])&&(l=!0),!l&&u(c._any)&&(l=!0)),a&&(l=!0),l&&h&&e.stopPropagation(),dr=null,l}var Ys=!w.ios,Ou=w.gecko&&w.gecko_version==153?"#ffffff01":"transparent",Wc=oi.highest(D.theme({".cm-line":{...Ys?{"& ::selection, &::selection":{backgroundColor:`${Ou} !important`}}:{},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important",...Ys?{"&::selection, & ::selection":{backgroundColor:"Highlight !important"}}:{}}}})),Fc=/x/.unicode!=null?"gu":"g",Tu=class extends et{constructor(t){super(),this.content=t}toDOM(t){let e=document.createElement("span");return e.className="cm-placeholder",e.style.pointerEvents="none",e.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(t):this.content.cloneNode(!0)),e.setAttribute("aria-hidden","true"),e}coordsAt(t){let e=t.firstChild?Gt(t.firstChild):[];if(!e.length)return null;let i=window.getComputedStyle(t.parentNode),n=ni(e[0],i.direction!="rtl"),r=parseInt(i.lineHeight);return n.bottom-n.top>r*1.5?{left:n.left,right:n.right,top:n.top,bottom:n.top+r}:n}ignoreEvent(){return!1}};function Du(t){let e=Be.fromClass(class{constructor(i){this.view=i,this.placeholder=t?N.set([N.widget({widget:new Tu(t),side:1}).range(0)]):N.none}get decorations(){return this.view.state.doc.length?N.none:this.placeholder}},{decorations:i=>i.decorations});return typeof t=="string"?[e,D.contentAttributes.of({"aria-placeholder":t})]:e}var _s=C.define({combine(t){let e,i;for(let n of t)e=e||n.topContainer,i=i||n.bottomContainer;return{topContainer:e,bottomContainer:i}}});function fa(t,e){let i=t.plugin(ua),n=i?i.specs.indexOf(e):-1;return n>-1?i.panels[n]:null}var ua=Be.fromClass(class{constructor(t){this.input=t.state.facet(Ki),this.specs=this.input.filter(i=>i),this.panels=this.specs.map(i=>i(t));let e=t.state.facet(_s);this.top=new Ai(t,!0,e.topContainer),this.bottom=new Ai(t,!1,e.bottomContainer),this.top.sync(this.panels.filter(i=>i.top)),this.bottom.sync(this.panels.filter(i=>!i.top));for(let i of this.panels)i.dom.classList.add("cm-panel"),i.mount&&i.mount()}update(t){let e=t.state.facet(_s);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Ai(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Ai(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let i=t.state.facet(Ki);if(i!=this.input){let n=i.filter(a=>a),r=[],s=[],o=[],l=[];for(let a of n){let h=this.specs.indexOf(a),f;h<0?(f=a(t.view),l.push(f)):(f=this.panels[h],f.update&&f.update(t)),r.push(f),(f.top?s:o).push(f)}this.specs=n,this.panels=r,this.top.sync(s),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let n of this.panels)n.update&&n.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>D.scrollMargins.of(e=>{let i=e.plugin(t);return i&&{top:i.top.scrollMargin(),bottom:i.bottom.scrollMargin()}})}),Ai=class{constructor(t,e,i){this.view=t,this.top=e,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(t){for(let e of this.panels)e.destroy&&t.indexOf(e)<0&&e.destroy();this.panels=t,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom";let e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let t=this.dom.firstChild;for(let e of this.panels)if(e.dom.parentNode==this.dom){for(;t!=e.dom;)t=Js(t);t=t.nextSibling}else this.dom.insertBefore(e.dom,t);for(;t;)t=Js(t)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}};function Js(t){let e=t.nextSibling;return t.remove(),e}var Ki=C.define({enables:ua});function Pu(t,e){let i,n=new Promise(o=>i=o),r=o=>Eu(o,e,i);t.state.field(Ii,!1)?t.dispatch({effects:ca.of(r)}):t.dispatch({effects:$.appendConfig.of(Ii.init(()=>[r]))});let s=da.of(r);return{close:s,result:n.then(o=>((t.win.queueMicrotask||(l=>t.win.setTimeout(l,10)))(()=>{t.state.field(Ii).indexOf(r)>-1&&t.dispatch({effects:s})}),o))}}function Bu(t,e){let i=t.state.field(Ii,!1)||[];for(let n of i){let r=fa(t,n);if(r&&r.dom.classList.contains(e))return r}return null}var Ii=Ze.define({create(){return[]},update(t,e){for(let i of e.effects)i.is(ca)?t=[i.value].concat(t):i.is(da)&&(t=t.filter(n=>n!=i.value));return t},provide:t=>Ki.computeN([t],e=>e.field(t))}),ca=$.define(),da=$.define();function Eu(t,e,i){let n=e.content?e.content(t,()=>l(null)):null;if(!n){if(n=nt("form"),e.input){let a=nt("input",e.input);/^(text|password|number|email|tel|url)$/.test(a.type)&&a.classList.add("cm-textfield"),a.name||(a.name="input"),n.appendChild(nt("label",(e.label||"")+": ",a))}else n.appendChild(document.createTextNode(e.label||""));n.appendChild(document.createTextNode(" ")),n.appendChild(nt("button",{class:"cm-button",type:"submit"},e.submitLabel||"OK"))}let r=n.nodeName=="FORM"?[n]:n.querySelectorAll("form");for(let a=0;a<r.length;a++){let h=r[a];h.addEventListener("keydown",f=>{f.keyCode==27?(f.preventDefault(),l(null)):f.keyCode==13&&(f.preventDefault(),l(h))}),h.addEventListener("submit",f=>{f.preventDefault(),l(h)})}let s=nt("div",n,nt("button",{onclick:()=>l(null),"aria-label":t.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));e.class&&(s.className=e.class),s.classList.add("cm-dialog");let o=typeof e.focus=="string"?n.querySelector(e.focus):e.focus?n.querySelector("input")||n.querySelector("button"):null;function l(a){s.contains(s.ownerDocument.activeElement)&&t.focus(),i(a)}return{dom:s,top:e.top,mount:()=>{o&&("select"in o?o.select():"focus"in o&&o.focus())},destroy:()=>i(null)}}var Xe=class extends Ue{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}};Xe.prototype.elementClass="";Xe.prototype.toDOM=void 0;Xe.prototype.mapMode=ie.TrackBefore;Xe.prototype.startSide=Xe.prototype.endSide=-1;Xe.prototype.point=!0;var pn=C.define(),Ru=C.define(),Nu={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>F.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},_t=C.define();function Iu(t){return[pa(),_t.of({...Nu,...t})]}var pr=C.define({combine:t=>t.some(e=>e)});function pa(t){let e=[Lu];return t&&t.fixed===!1&&e.push(pr.of(!0)),e}var Lu=Be.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(_t).map(e=>new Qs(t,e)),this.fixed=!t.state.facet(pr);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(t){if(this.updateGutters(t)){let e=this.prevViewport,i=t.view.viewport,n=Math.min(e.to,i.to)-Math.max(e.from,i.from);this.syncGutters(n<(i.to-i.from)*.8)}if(t.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(pr)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let i=F.iter(this.view.state.facet(pn),this.view.viewport.from),n=[],r=this.gutters.map(s=>new Hu(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(n.length&&(n=[]),Array.isArray(s.type)){let o=!0;for(let l of s.type)if(l.type==ne.Text&&o){gr(i,n,l.from);for(let a of r)a.line(this.view,l,n);o=!1}else if(l.widget)for(let a of r)a.widget(this.view,l)}else if(s.type==ne.Text){gr(i,n,s.from);for(let o of r)o.line(this.view,s,n)}else if(s.widget)for(let o of r)o.widget(this.view,s);for(let s of r)s.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(_t),i=t.state.facet(_t),n=t.docChanged||t.heightChanged||t.viewportChanged||!F.eq(t.startState.facet(pn),t.state.facet(pn),t.view.viewport.from,t.view.viewport.to);if(e==i)for(let r of this.gutters)r.update(t)&&(n=!0);else{n=!0;let r=[];for(let s of i){let o=e.indexOf(s);o<0?r.push(new Qs(this.view,s)):(this.gutters[o].update(t),r.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),r.indexOf(s)<0&&s.destroy();for(let s of r)s.config.side=="after"?this.getDOMAfter().appendChild(s.dom):this.dom.appendChild(s.dom);this.gutters=r}return n}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>D.scrollMargins.of(e=>{let i=e.plugin(t);if(!i||i.gutters.length==0||!i.fixed)return null;let n=i.dom.offsetWidth*e.scaleX,r=i.domAfter?i.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==q.LTR?{left:n,right:r}:{right:n,left:r}})});function Xs(t){return Array.isArray(t)?t:[t]}function gr(t,e,i){for(;t.value&&t.from<=i;)t.from==i&&e.push(t.value),t.next()}var Hu=class{constructor(t,e,i){this.gutter=t,this.height=i,this.i=0,this.cursor=F.iter(t.markers,e.from)}addElement(t,e,i){let{gutter:n}=this,r=(e.top-this.height)/t.scaleY,s=e.height/t.scaleY;if(this.i==n.elements.length){let o=new ga(t,s,r,i);n.elements.push(o),n.dom.appendChild(o.dom)}else n.elements[this.i].update(t,s,r,i);this.height=e.bottom,this.i++}line(t,e,i){let n=[];gr(this.cursor,n,e.from),i.length&&(n=n.concat(i));let r=this.gutter.config.lineMarker(t,e,n);r&&n.unshift(r);let s=this.gutter;n.length==0&&!s.config.renderEmptyElements||this.addElement(t,e,n)}widget(t,e){let i=this.gutter.config.widgetMarker(t,e.widget,e),n=i?[i]:null;for(let r of t.state.facet(Ru)){let s=r(t,e.widget,e);s&&(n||(n=[])).push(s)}n&&this.addElement(t,e,n)}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let e=t.elements.pop();t.dom.removeChild(e.dom),e.destroy()}}},Qs=class{constructor(t,e){this.view=t,this.config=e,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in e.domEventHandlers)this.dom.addEventListener(i,n=>{let r=n.target,s;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let l=r.getBoundingClientRect();s=(l.top+l.bottom)/2}else s=n.clientY;let o=t.lineBlockAtHeight(s-t.documentTop);e.domEventHandlers[i](t,o,n)&&n.preventDefault()});this.markers=Xs(e.markers(t)),e.initialSpacer&&(this.spacer=new ga(t,0,0,[e.initialSpacer(t)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(t){let e=this.markers;if(this.markers=Xs(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let n=this.config.updateSpacer(this.spacer.markers[0],t);n!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[n])}let i=t.view.viewport;return!F.eq(this.markers,e,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(t):!1)}destroy(){for(let t of this.elements)t.destroy()}},ga=class{constructor(t,e,i,n){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,e,i,n)}update(t,e,i,n){this.height!=e&&(this.height=e,this.dom.style.height=e+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),Wu(this.markers,n)||this.setMarkers(t,n)}setMarkers(t,e){let i="cm-gutterElement",n=this.dom.firstChild;for(let r=0,s=0;;){let o=s,l=r<e.length?e[r++]:null,a=!1;if(l){let h=l.elementClass;h&&(i+=" "+h);for(let f=s;f<this.markers.length;f++)if(this.markers[f].compare(l)){o=f,a=!0;break}}else o=this.markers.length;for(;s<o;){let h=this.markers[s++];if(h.toDOM){h.destroy(n);let f=n.nextSibling;n.remove(),n=f}}if(!l)break;l.toDOM&&(a?n=n.nextSibling:this.dom.insertBefore(l.toDOM(t),n)),a&&s++}this.dom.className=i,this.markers=e}destroy(){this.setMarkers(null,[])}};function Wu(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(!t[i].compare(e[i]))return!1;return!0}var Fu=C.define(),Vu=C.define(),pt=C.define({combine(t){return Ui(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,i){let n=Object.assign({},e);for(let r in i){let s=n[r],o=i[r];n[r]=s?(l,a,h)=>s(l,a,h)||o(l,a,h):o}return n}})}}),gn=class extends Xe{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}};function mn(t,e){return t.state.facet(pt).formatNumber(e,t.state)}var $u=_t.compute([pt],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Fu)},lineMarker(e,i,n){return n.some(r=>r.toDOM)?null:new gn(mn(e,e.state.doc.lineAt(i.from).number))},widgetMarker:(e,i,n)=>{for(let r of e.state.facet(Vu)){let s=r(e,i,n);if(s)return s}return null},lineMarkerChange:e=>e.startState.facet(pt)!=e.state.facet(pt),initialSpacer(e){return new gn(mn(e,Zs(e.state.doc.lines)))},updateSpacer(e,i){let n=mn(i.view,Zs(i.view.state.doc.lines));return n==e.number?e:new gn(n)},domEventHandlers:t.facet(pt).domEventHandlers,side:"before"}));function ju(t={}){return[pt.of(t),pa(),$u]}function Zs(t){let e=9;for(;e<t;)e=e*10+9;return e}var bn,gt=new B;function ma(t){return C.define({combine:t?e=>e.concat(t):void 0})}var ba=new B,ge=class{constructor(t,e,i=[],n=""){this.data=t,this.name=n,U.prototype.hasOwnProperty("tree")||Object.defineProperty(U.prototype,"tree",{get(){return ve(this)}}),this.parser=e,this.extension=[Qe.of(this),U.languageData.of((r,s,o)=>{let l=eo(r,s,o),a=l.type.prop(gt);if(!a)return[];let h=r.facet(a),f=l.type.prop(ba);if(f){let u=l.resolve(s-l.from,o);for(let c of f)if(c.test(u,r)){let d=r.facet(c.facet);return c.type=="replace"?d:d.concat(h)}}return h})].concat(i)}isActiveAt(t,e,i=-1){return eo(t,e,i).type.prop(gt)==this.data}findRegions(t){let e=t.facet(Qe);if(e?.data==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let i=[],n=(r,s)=>{if(r.prop(gt)==this.data){i.push({from:s,to:s+r.length});return}let o=r.prop(B.mounted);if(o){if(o.tree.prop(gt)==this.data){if(o.overlay)for(let l of o.overlay)i.push({from:l.from+s,to:l.to+s});else i.push({from:s,to:s+r.length});return}else if(o.overlay){let l=i.length;if(n(o.tree,o.overlay[0].from+s),i.length>l)return}}for(let l=0;l<r.children.length;l++){let a=r.children[l];a instanceof Y&&n(a,r.positions[l]+s)}};return n(ve(t),0),i}get allowsNesting(){return!0}};ge.setState=$.define();function eo(t,e,i){let n=t.facet(Qe),r=ve(t).topNode;if(!n||n.allowsNesting)for(let s=r;s;s=s.enter(e,i,R.ExcludeBuffers|R.EnterBracketed))s.type.isTop&&(r=s);return r}var zu=class mr extends ge{constructor(e,i,n){super(e,i,[],n),this.parser=i}static define(e){let i=ma(e.languageData);return new mr(i,e.parser.configure({props:[gt.add(n=>n.isTop?i:void 0)]}),e.name)}configure(e,i){return new mr(this.data,this.parser.configure(e),i||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function ve(t){let e=t.field(ge.state,!1);return e?e.tree:Y.empty}var Ku=class{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let i=this.cursorPos-this.string.length;return t<i||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}},Lt=null,qu=class br{constructor(e,i,n=[],r,s,o,l,a){this.parser=e,this.state=i,this.fragments=n,this.tree=r,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,i,n){return new br(e,i,[],Y.empty,0,n,[],null)}startParse(){return this.parser.startParse(new Ku(this.state.doc),this.fragments)}work(e,i){return i!=null&&i>=this.state.doc.length&&(i=void 0),this.tree!=Y.empty&&this.isDone(i??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),i!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>i)&&i<this.state.doc.length&&this.parse.stopAt(i);;){let r=this.parse.advance();if(r)if(this.fragments=this.withoutTempSkipped(bt.addTree(r,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(n=this.parse.stoppedAt)!==null&&n!==void 0?n:this.state.doc.length,this.tree=r,this.parse=null,this.treeLen<(i??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,i;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(i=this.parse.advance()););}),this.treeLen=e,this.tree=i,this.fragments=this.withoutTempSkipped(bt.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let i=Lt;Lt=this;try{return e()}finally{Lt=i}}withoutTempSkipped(e){for(let i;i=this.tempSkipped.pop();)e=to(e,i.from,i.to);return e}changes(e,i){let{fragments:n,tree:r,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((h,f,u,c)=>a.push({fromA:h,toA:f,fromB:u,toB:c})),n=bt.applyChanges(n,a),r=Y.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let h of this.skipped){let f=e.mapPos(h.from,1),u=e.mapPos(h.to,-1);f<u&&l.push({from:f,to:u})}}}return new br(this.parser,i,n,r,s,o,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let i=this.skipped.length;for(let n=0;n<this.skipped.length;n++){let{from:r,to:s}=this.skipped[n];r<e.to&&s>e.from&&(this.fragments=to(this.fragments,r,s),this.skipped.splice(n--,1))}return this.skipped.length>=i?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,i){this.skipped.push({from:e,to:i})}static getSkippingParser(e){return new class extends bo{createParse(i,n,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let l=Lt;if(l){for(let a of r)l.tempSkipped.push(a);e&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,e]):e)}return this.parsedPos=o,new Y(se.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let i=this.fragments;return this.treeLen>=e&&i.length&&i[0].from==0&&i[0].to>=e}static get(){return Lt}};function to(t,e,i){return bt.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}var yr=class vr{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let i=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),i.viewport.to);return i.work(20,n)||i.takeTree(),new vr(i)}static init(e){let i=Math.min(3e3,e.doc.length),n=qu.create(e.facet(Qe).parser,e,{from:0,to:i});return n.work(20,i)||n.takeTree(),new vr(n)}};ge.state=Ze.define({create:yr.init,update(t,e){for(let i of e.effects)if(i.is(ge.setState))return i.value;return e.startState.facet(Qe)!=e.state.facet(Qe)?yr.init(e.state):t.apply(e)}});var ya=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(ya=t=>{let e=-1,i=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(i):cancelIdleCallback(e)});var yn=typeof navigator<"u"&&(!((bn=navigator.scheduling)===null||bn===void 0)&&bn.isInputPending)?()=>navigator.scheduling.isInputPending():null,Gu=Be.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 i=this.view.state.field(ge.state).context;(i.updateViewport(e.view.viewport)||this.view.viewport.to>i.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(i)}scheduleWork(){if(this.working)return;let{state:e}=this.view,i=e.field(ge.state);(i.tree!=i.context.tree||!i.context.isDone(e.doc.length))&&(this.working=ya(this.work))}work(e){this.working=null;let i=Date.now();if(this.chunkEnd<i&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=i+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:r}}=this.view,s=n.field(ge.state);if(s.tree==s.context.tree&&s.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!yn?Math.max(25,e.timeRemaining()-5):1e9),l=s.context.treeLen<r&&n.doc.length>r+1e3,a=s.context.work(()=>yn&&yn()||Date.now()>o,r+(l?0:1e5));this.chunkBudget-=Date.now()-i,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:ge.setState.of(new yr(s.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(i=>Pe(this.view.state,i)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Qe=C.define({combine(t){return t.length?t[0]:null},enables:t=>[ge.state,Gu,D.contentAttributes.compute([t],e=>{let i=e.facet(t);return i&&i.name?{"data-language":i.name}:{}})]}),Uu=class{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}},Yu=C.define(),Fr=C.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(i=>i!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function va(t){let e=t.facet(Fr);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function wa(t,e){let i="",n=t.tabSize,r=t.facet(Fr)[0];if(r==" "){for(;e>=n;)i+=" ",e-=n;r=" "}for(let s=0;s<e;s++)i+=r;return i}function xa(t,e){t instanceof U&&(t=new Vr(t));for(let n of t.state.facet(Yu)){let r=n(t,e);if(r!==void 0)return r}let i=ve(t.state);return i.length>=e?_u(t,i,e):null}var Vr=class{constructor(t,e={}){this.state=t,this.options=e,this.unit=va(t)}lineAt(t,e=1){let i=this.state.doc.lineAt(t),{simulateBreak:n,simulateDoubleBreak:r}=this.options;return n!=null&&n>=i.from&&n<=i.to?r&&n==t?{text:"",from:t}:(e<0?n<t:n<=t)?{text:i.text.slice(n-i.from),from:n}:{text:i.text.slice(0,n-i.from),from:i.from}:i}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:i,from:n}=this.lineAt(t,e);return i.slice(t-n,Math.min(i.length,t+100-n))}column(t,e=1){let{text:i,from:n}=this.lineAt(t,e),r=this.countColumn(i,t-n),s=this.options.overrideIndentation?this.options.overrideIndentation(n):-1;return s>-1&&(r+=s-this.countColumn(i,i.search(/\S|$/))),r}countColumn(t,e=t.length){return Zo(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:i,from:n}=this.lineAt(t,e),r=this.options.overrideIndentation;if(r){let s=r(n);if(s>-1)return s}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},ka=new B;function _u(t,e,i){let n=e.resolveStack(i),r=e.resolveInner(i,-1).resolve(i,0).enterUnfinishedNodesBefore(i);if(r!=n.node){let s=[];for(let o=r;o&&!(o.from<n.node.from||o.to>n.node.to||o.from==n.node.from&&o.type==n.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)n={node:s[o],next:n}}return Sa(n,t,i)}function Sa(t,e,i){for(let n=t;n;n=n.next){let r=Xu(n.node);if(r)return r(Zu.create(e,i,n))}return 0}function Ju(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function Xu(t){let e=t.type.prop(ka);if(e)return e;let i=t.firstChild,n;if(i&&(n=i.type.prop(B.closedBy))){let r=t.lastChild,s=r&&n.indexOf(r.name)>-1;return o=>Aa(o,!0,1,void 0,s&&!Ju(o)?r.from:void 0)}return t.parent==null?Qu:null}function Qu(){return 0}var Zu=class Ca extends Vr{constructor(e,i,n){super(e.state,e.options),this.base=e,this.pos=i,this.context=n}get node(){return this.context.node}static create(e,i,n){return new Ca(e,i,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let i=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(i.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(ec(n,e))break;i=this.state.doc.lineAt(n.from)}return this.lineIndent(i.from)}continue(){return Sa(this.context.next,this.base,this.pos)}};function ec(t,e){for(let i=e;i;i=i.parent)if(t==i)return!0;return!1}function tc(t){let e=t.node,i=e.childAfter(e.from),n=e.lastChild;if(!i)return null;let r=t.options.simulateBreak,s=t.state.doc.lineAt(i.from),o=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let l=i.to;;){let a=e.childAfter(l);if(!a||a==n)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let h=/^ */.exec(s.text.slice(i.to-s.from))[0].length;return{from:i.from,to:i.to+h}}l=a.to}}function ic({closing:t,align:e=!0,units:i=1}){return n=>Aa(n,e,i,t)}function Aa(t,e,i,n,r){let s=t.textAfter,o=s.match(/^\s*/)[0].length,l=n&&s.slice(o,o+n.length)==n||r==t.pos+o,a=e?tc(t):null;return a?l?t.column(a.from):t.column(a.to):t.baseIndent+(l?0:t.unit*i)}var nc=t=>t.baseIndent;function rc({except:t,units:e=1}={}){return i=>{let n=t&&t.test(i.textAfter);return i.baseIndent+(n?0:e*i.unit)}}var sc=200;function oc(){return U.transactionFilter.of(t=>{if(!t.docChanged||!t.isUserEvent("input.type")&&!t.isUserEvent("input.complete"))return t;let e=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!e.length)return t;let i=t.newDoc,{head:n}=t.newSelection.main,r=i.lineAt(n);if(n>r.from+sc)return t;let s=i.sliceString(r.from,n);if(!e.some(h=>h.test(s)))return t;let{state:o}=t,l=-1,a=[];for(let{head:h}of o.selection.ranges){let f=o.doc.lineAt(h);if(f.from==l)continue;l=f.from;let u=xa(o,f.from);if(u==null)continue;let c=/^\s*/.exec(f.text)[0],d=wa(o,u);c!=d&&a.push({from:f.from,to:f.from+c.length,insert:d})}return a.length?[t,{changes:a,sequential:!0}]:t})}var lc=C.define(),Ma=new B;function ac(t){let e=t.firstChild,i=t.lastChild;return e&&e.to<i.from?{from:e.to,to:i.type.isError?t.to:i.from}:null}function hc(t,e,i){let n=ve(t);if(n.length<i)return null;let r=n.resolveStack(i,1),s=null;for(let o=r;o;o=o.next){let l=o.node;if(l.to<=i||l.from>i)continue;if(s&&l.from<e)break;let a=l.type.prop(Ma);if(a&&(l.to<n.length-50||n.length==t.doc.length||!fc(l))){let h=a(l,t);h&&h.from<=i&&h.from>=e&&h.to>i&&(s=h)}}return s}function fc(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}function qi(t,e,i){for(let n of t.facet(lc)){let r=n(t,e,i);if(r)return r}return hc(t,e,i)}function Oa(t,e){let i=e.mapPos(t.from,1),n=e.mapPos(t.to,-1);return i>=n?void 0:{from:i,to:n}}var Zi=$.define({map:Oa}),ai=$.define({map:Oa});function Ta(t){let e=[];for(let{head:i}of t.state.selection.ranges)e.some(n=>n.from<=i&&n.to>=i)||e.push(t.lineBlockAt(i));return e}var lt=Ze.define({create(){return N.none},update(t,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((n,r)=>t=io(t,n,r)),t=t.map(e.changes);let i=[];for(let n of e.effects)n.is(Zi)&&!uc(t,n.value.from,n.value.to)?i.push(n.value):n.is(ai)&&(t=t.update({filter:(r,s)=>n.value.from!=r||n.value.to!=s,filterFrom:n.value.from,filterTo:n.value.to}));if(i.length){let{preparePlaceholder:n}=e.state.facet($r),r=i.map(s=>(n?N.replace({widget:new yc(n(e.state,s))}):no).range(s.from,s.to));t=t.update({add:r})}return e.selection&&(t=io(t,e.selection.main.head)),t},provide:t=>D.decorations.from(t),toJSON(t,e){let i=[];return t.between(0,e.doc.length,(n,r)=>{i.push(n,r)}),i},fromJSON(t){if(!Array.isArray(t)||t.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let i=0;i<t.length;){let n=t[i++],r=t[i++];if(typeof n!="number"||typeof r!="number")throw new RangeError("Invalid JSON for fold state");e.push(no.range(n,r))}return N.set(e,!0)}});function io(t,e,i=e){let n=!1;return t.between(e,i,(r,s)=>{r<i&&s>e&&(n=!0)}),n?t.update({filterFrom:e,filterTo:i,filter:(r,s)=>r>=i||s<=e}):t}function Gi(t,e,i){var n;let r=null;return(n=t.field(lt,!1))===null||n===void 0||n.between(e,i,(s,o)=>{(!r||r.from>s)&&(r={from:s,to:o})}),r}function uc(t,e,i){let n=!1;return t.between(e,e,(r,s)=>{r==e&&s==i&&(n=!0)}),n}function Da(t,e){return t.field(lt,!1)?e:e.concat($.appendConfig.of(Ba()))}var cc=t=>{for(let e of Ta(t)){let i=qi(t.state,e.from,e.to);if(i)return t.dispatch({effects:Da(t.state,[Zi.of(i),Pa(t,i)])}),!0}return!1},dc=t=>{if(!t.state.field(lt,!1))return!1;let e=[];for(let i of Ta(t)){let n=Gi(t.state,i.from,i.to);n&&e.push(ai.of(n),Pa(t,n,!1))}return e.length&&t.dispatch({effects:e}),e.length>0};function Pa(t,e,i=!0){let n=t.state.doc.lineAt(e.from).number,r=t.state.doc.lineAt(e.to).number;return D.announce.of(`${t.state.phrase(i?"Folded lines":"Unfolded lines")} ${n} ${t.state.phrase("to")} ${r}.`)}var pc=t=>{let{state:e}=t,i=[];for(let n=0;n<e.doc.length;){let r=t.lineBlockAt(n),s=qi(e,r.from,r.to);s&&i.push(Zi.of(s)),n=(s?t.lineBlockAt(s.to):r).to+1}return i.length&&t.dispatch({effects:Da(t.state,i)}),!!i.length},gc=t=>{let e=t.state.field(lt,!1);if(!e||!e.size)return!1;let i=[];return e.between(0,t.state.doc.length,(n,r)=>{i.push(ai.of({from:n,to:r}))}),t.dispatch({effects:i}),!0},mc=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:cc},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:dc},{key:"Ctrl-Alt-[",run:pc},{key:"Ctrl-Alt-]",run:gc}],bc={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},$r=C.define({combine(t){return Ui(t,bc)}});function Ba(t){let e=[lt,xc];return t&&e.push($r.of(t)),e}function Ea(t,e){let{state:i}=t,n=i.facet($r),r=o=>{let l=t.lineBlockAt(t.posAtDOM(o.target)),a=Gi(t.state,l.from,l.to);a&&t.dispatch({effects:ai.of(a)}),o.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(t,r,e);let s=document.createElement("span");return s.textContent=n.placeholderText,s.setAttribute("aria-label",i.phrase("folded code")),s.title=i.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=r,s}var no=N.replace({widget:new class extends et{toDOM(t){return Ea(t,null)}}}),yc=class extends et{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return Ea(t,this.value)}},vc={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1},vn=class extends Xe{constructor(t,e){super(),this.config=t,this.open=e}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let e=document.createElement("span");return e.textContent=this.open?this.config.openText:this.config.closedText,e.title=t.state.phrase(this.open?"Fold line":"Unfold line"),e}};function wc(t={}){let e={...vc,...t},i=new vn(e,!0),n=new vn(e,!1),r=Be.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(Qe)!=o.state.facet(Qe)||o.startState.field(lt,!1)!=o.state.field(lt,!1)||ve(o.startState)!=ve(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let l=new wt;for(let a of o.viewportLineBlocks){let h=Gi(o.state,a.from,a.to)?n:qi(o.state,a.from,a.to)?i:null;h&&l.add(a.from,a.from,h)}return l.finish()}}),{domEventHandlers:s}=e;return[r,Iu({class:"cm-foldGutter",markers(o){var l;return((l=o.plugin(r))===null||l===void 0?void 0:l.markers)||F.empty},initialSpacer(){return new vn(e,!1)},domEventHandlers:{...s,click:(o,l,a)=>{if(s.click&&s.click(o,l,a))return!0;let h=Gi(o.state,l.from,l.to);if(h)return o.dispatch({effects:ai.of(h)}),!0;let f=qi(o.state,l.from,l.to);return f?(o.dispatch({effects:Zi.of(f)}),!0):!1}}}),Ba()]}var xc=D.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"}}),jr=class Ra{constructor(e,i){this.specs=e;let n;function r(l){let a=Ye.newName();return(n||(n=Object.create(null)))["."+a]=l,a}const s=typeof i.all=="string"?i.all:i.all?r(i.all):void 0,o=i.scope;this.scope=o instanceof ge?l=>l.prop(gt)==o.data:o?l=>l==o:void 0,this.style=ko(e.map(l=>({tag:l.tag,class:l.class||r(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=n?new Ye(n):null,this.themeType=i.themeType}static define(e,i){return new Ra(e,i||{})}},wr=C.define(),Na=C.define({combine(t){return t.length?[t[0]]:null}});function wn(t){let e=t.facet(wr);return e.length?e:t.facet(Na)}function kc(t,e){let i=[Cc],n;return t instanceof jr&&(t.module&&i.push(D.styleModule.of(t.module)),n=t.themeType),e?.fallback?i.push(Na.of(t)):n?i.push(wr.computeN([D.darkTheme],r=>r.facet(D.darkTheme)==(n=="dark")?[t]:[])):i.push(wr.of(t)),i}var Sc=class{constructor(t){this.markCache=Object.create(null),this.tree=ve(t.state),this.decorations=this.buildDeco(t,wn(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=ve(t.state),i=wn(t.state),n=i!=wn(t.startState),{viewport:r}=t.view,s=t.changes.mapPos(this.decoratedTo,1);e.length<r.to&&!n&&e.type==this.tree.type&&s>=r.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=s):(e!=this.tree||t.viewportChanged||n)&&(this.tree=e,this.decorations=this.buildDeco(t.view,i),this.decoratedTo=r.to)}buildDeco(t,e){if(!e||!this.tree.length)return N.none;let i=new wt;for(let{from:n,to:r}of t.visibleRanges)lh(this.tree,e,(s,o,l)=>{i.add(s,o,this.markCache[l]||(this.markCache[l]=N.mark({class:l})))},n,r);return i.finish()}},Cc=oi.high(Be.fromClass(Sc,{decorations:t=>t.decorations})),$c=jr.define([{tag:v.meta,color:"#404740"},{tag:v.link,textDecoration:"underline"},{tag:v.heading,textDecoration:"underline",fontWeight:"bold"},{tag:v.emphasis,fontStyle:"italic"},{tag:v.strong,fontWeight:"bold"},{tag:v.strikethrough,textDecoration:"line-through"},{tag:v.keyword,color:"#708"},{tag:[v.atom,v.bool,v.url,v.contentSeparator,v.labelName],color:"#219"},{tag:[v.literal,v.inserted],color:"#164"},{tag:[v.string,v.deleted],color:"#a11"},{tag:[v.regexp,v.escape,v.special(v.string)],color:"#e40"},{tag:v.definition(v.variableName),color:"#00f"},{tag:v.local(v.variableName),color:"#30a"},{tag:[v.typeName,v.namespace],color:"#085"},{tag:v.className,color:"#167"},{tag:[v.special(v.variableName),v.macroName],color:"#256"},{tag:v.definition(v.propertyName),color:"#00c"},{tag:v.comment,color:"#940"},{tag:v.invalid,color:"#f00"}]),Ac=D.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Ia=1e4,La="()[]{}",Ha=C.define({combine(t){return Ui(t,{afterCursor:!0,brackets:La,maxScanDistance:Ia,renderMatch:Tc})}}),Mc=N.mark({class:"cm-matchingBracket"}),Oc=N.mark({class:"cm-nonmatchingBracket"});function Tc(t){let e=[],i=t.matched?Mc:Oc;return e.push(i.range(t.start.from,t.start.to)),t.end&&e.push(i.range(t.end.from,t.end.to)),e}function ro(t){let e=[],i=t.facet(Ha);for(let n of t.selection.ranges){if(!n.empty)continue;let r=jt(t,n.head,-1,i)||n.head>0&&jt(t,n.head-1,1,i)||i.afterCursor&&(jt(t,n.head,1,i)||n.head<t.doc.length&&jt(t,n.head+1,-1,i));r&&(e=e.concat(i.renderMatch(r,t)))}return N.set(e,!0)}var Dc=[Be.fromClass(class{constructor(t){this.paused=!1,this.decorations=ro(t.state)}update(t){(t.docChanged||t.selectionSet||this.paused)&&(t.view.composing?(this.decorations=this.decorations.map(t.changes),this.paused=!0):(this.decorations=ro(t.state),this.paused=!1))}},{decorations:t=>t.decorations}),Ac];function Pc(t={}){return[Ha.of(t),Dc]}var Wa=new B;function xr(t,e,i){let n=t.prop(e<0?B.openedBy:B.closedBy);if(n)return n;if(t.name.length==1){let r=i.indexOf(t.name);if(r>-1&&r%2==(e<0?1:0))return[i[r+e]]}return null}function kr(t){let e=t.type.prop(Wa);return e?e(t.node):t}function jt(t,e,i,n={}){let r=n.maxScanDistance||Ia,s=n.brackets||La,o=ve(t),l=o.resolveInner(e,i);for(let a=l;a;a=a.parent){let h=xr(a.type,i,s);if(h&&a.from<a.to){let f=kr(a);if(f&&(i>0?e>=f.from&&e<f.to:e>f.from&&e<=f.to))return Bc(t,e,i,a,f,h,s)}}return Ec(t,e,i,o,l.type,r,s)}function Bc(t,e,i,n,r,s,o){let l=n.parent,a={from:r.from,to:r.to},h=0,f=l?.cursor();if(f&&(i<0?f.childBefore(n.from):f.childAfter(n.to)))do if(i<0?f.to<=n.from:f.from>=n.to){if(h==0&&s.indexOf(f.type.name)>-1&&f.from<f.to){let u=kr(f);return{start:a,end:u?{from:u.from,to:u.to}:void 0,matched:!0}}else if(xr(f.type,i,o))h++;else if(xr(f.type,-i,o)){if(h==0){let u=kr(f);return{start:a,end:u&&u.from<u.to?{from:u.from,to:u.to}:void 0,matched:!1}}h--}}while(i<0?f.prevSibling():f.nextSibling());return{start:a,matched:!1}}function Ec(t,e,i,n,r,s,o){if(i<0?!e:e==t.doc.length)return null;let l=i<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=i>0)return null;let h={from:i<0?e-1:e,to:i>0?e+1:e},f=t.doc.iterRange(e,i>0?t.doc.length:0),u=0;for(let c=0;!f.next().done&&c<=s;){let d=f.value;i<0&&(c+=d.length);let p=e+c*i;for(let g=i>0?0:d.length-1,m=i>0?d.length:-1;g!=m;g+=i){let b=o.indexOf(d[g]);if(!(b<0||n.resolveInner(p+g,1).type!=r))if(b%2==0==i>0)u++;else{if(u==1)return{start:h,end:{from:p+g,to:p+g+1},matched:b>>1==a>>1};u--}}i>0&&(c+=d.length)}return f.done?{start:h,matched:!1}:null}var Rc=Object.create(null),so=[se.none],oo=[],lo=Object.create(null),Nc=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Nc[t]=Ic(Rc,e);function xn(t,e){oo.indexOf(t)>-1||oo.push(t)}function Ic(t,e){let i=[];for(let l of e.split(" ")){let a=[];for(let h of l.split(".")){let f=t[h]||v[h];f?typeof f=="function"?a.length?a=a.map(f):xn(h,`Modifier ${h} used at start of tag`):a.length?xn(h,`Tag ${h} used as modifier`):a=Array.isArray(f)?f:[f]:xn(h,`Unknown highlighting tag ${h}`)}for(let h of a)i.push(h)}if(!i.length)return 0;let n=e.replace(/ /g,"_"),r=n+" "+i.map(l=>l.id),s=lo[r];if(s)return s.id;let o=lo[r]=se.define({id:so.length,name:n,props:[wo({[n]:i})]});return so.push(o),o.id}var jc={rtl:N.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:q.RTL}),ltr:N.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:q.LTR}),auto:N.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};Object.defineProperty(exports,"Annotation",{enumerable:!0,get:function(){return at}});Object.defineProperty(exports,"ChangeDesc",{enumerable:!0,get:function(){return yt}});Object.defineProperty(exports,"ChangeSet",{enumerable:!0,get:function(){return be}});Object.defineProperty(exports,"CharCategory",{enumerable:!0,get:function(){return Te}});Object.defineProperty(exports,"Compartment",{enumerable:!0,get:function(){return Or}});Object.defineProperty(exports,"Decoration",{enumerable:!0,get:function(){return N}});Object.defineProperty(exports,"DefaultBufferLength",{enumerable:!0,get:function(){return ao}});Object.defineProperty(exports,"Direction",{enumerable:!0,get:function(){return q}});Object.defineProperty(exports,"EditorSelection",{enumerable:!0,get:function(){return S}});Object.defineProperty(exports,"EditorState",{enumerable:!0,get:function(){return U}});Object.defineProperty(exports,"EditorView",{enumerable:!0,get:function(){return D}});Object.defineProperty(exports,"Facet",{enumerable:!0,get:function(){return C}});Object.defineProperty(exports,"HighlightStyle",{enumerable:!0,get:function(){return jr}});Object.defineProperty(exports,"IndentContext",{enumerable:!0,get:function(){return Vr}});Object.defineProperty(exports,"IterMode",{enumerable:!0,get:function(){return R}});Object.defineProperty(exports,"LRLanguage",{enumerable:!0,get:function(){return zu}});Object.defineProperty(exports,"LanguageSupport",{enumerable:!0,get:function(){return Uu}});Object.defineProperty(exports,"MapMode",{enumerable:!0,get:function(){return ie}});Object.defineProperty(exports,"NodeProp",{enumerable:!0,get:function(){return B}});Object.defineProperty(exports,"NodeSet",{enumerable:!0,get:function(){return $a}});Object.defineProperty(exports,"NodeType",{enumerable:!0,get:function(){return se}});Object.defineProperty(exports,"NodeWeakMap",{enumerable:!0,get:function(){return Ua}});Object.defineProperty(exports,"Parser",{enumerable:!0,get:function(){return bo}});Object.defineProperty(exports,"Prec",{enumerable:!0,get:function(){return oi}});Object.defineProperty(exports,"RangeSetBuilder",{enumerable:!0,get:function(){return wt}});Object.defineProperty(exports,"RangeValue",{enumerable:!0,get:function(){return Ue}});Object.defineProperty(exports,"StateEffect",{enumerable:!0,get:function(){return $}});Object.defineProperty(exports,"StateField",{enumerable:!0,get:function(){return Ze}});Object.defineProperty(exports,"Text",{enumerable:!0,get:function(){return I}});Object.defineProperty(exports,"Transaction",{enumerable:!0,get:function(){return he}});Object.defineProperty(exports,"Tree",{enumerable:!0,get:function(){return Y}});Object.defineProperty(exports,"ViewPlugin",{enumerable:!0,get:function(){return Be}});Object.defineProperty(exports,"WidgetType",{enumerable:!0,get:function(){return et}});Object.defineProperty(exports,"bracketMatching",{enumerable:!0,get:function(){return Pc}});Object.defineProperty(exports,"bracketMatchingHandle",{enumerable:!0,get:function(){return Wa}});Object.defineProperty(exports,"codePointAt",{enumerable:!0,get:function(){return Po}});Object.defineProperty(exports,"codePointSize",{enumerable:!0,get:function(){return Bo}});Object.defineProperty(exports,"combineConfig",{enumerable:!0,get:function(){return Ui}});Object.defineProperty(exports,"continuedIndent",{enumerable:!0,get:function(){return rc}});Object.defineProperty(exports,"countColumn",{enumerable:!0,get:function(){return Zo}});Object.defineProperty(exports,"crelt",{enumerable:!0,get:function(){return nt}});Object.defineProperty(exports,"defineLanguageFacet",{enumerable:!0,get:function(){return ma}});Object.defineProperty(exports,"delimitedIndent",{enumerable:!0,get:function(){return ic}});Object.defineProperty(exports,"findClusterBreak",{enumerable:!0,get:function(){return ae}});Object.defineProperty(exports,"flatIndent",{enumerable:!0,get:function(){return nc}});Object.defineProperty(exports,"foldGutter",{enumerable:!0,get:function(){return wc}});Object.defineProperty(exports,"foldInside",{enumerable:!0,get:function(){return ac}});Object.defineProperty(exports,"foldKeymap",{enumerable:!0,get:function(){return mc}});Object.defineProperty(exports,"foldNodeProp",{enumerable:!0,get:function(){return Ma}});Object.defineProperty(exports,"fromCodePoint",{enumerable:!0,get:function(){return bh}});Object.defineProperty(exports,"getDialog",{enumerable:!0,get:function(){return Bu}});Object.defineProperty(exports,"getIndentUnit",{enumerable:!0,get:function(){return va}});Object.defineProperty(exports,"getIndentation",{enumerable:!0,get:function(){return xa}});Object.defineProperty(exports,"getPanel",{enumerable:!0,get:function(){return fa}});Object.defineProperty(exports,"indentNodeProp",{enumerable:!0,get:function(){return ka}});Object.defineProperty(exports,"indentOnInput",{enumerable:!0,get:function(){return oc}});Object.defineProperty(exports,"indentString",{enumerable:!0,get:function(){return wa}});Object.defineProperty(exports,"indentUnit",{enumerable:!0,get:function(){return Fr}});Object.defineProperty(exports,"keymap",{enumerable:!0,get:function(){return la}});Object.defineProperty(exports,"lineNumbers",{enumerable:!0,get:function(){return ju}});Object.defineProperty(exports,"matchBrackets",{enumerable:!0,get:function(){return jt}});Object.defineProperty(exports,"parseMixed",{enumerable:!0,get:function(){return _a}});Object.defineProperty(exports,"placeholder",{enumerable:!0,get:function(){return Du}});Object.defineProperty(exports,"runScopeHandlers",{enumerable:!0,get:function(){return Cu}});Object.defineProperty(exports,"showDialog",{enumerable:!0,get:function(){return Pu}});Object.defineProperty(exports,"showPanel",{enumerable:!0,get:function(){return Ki}});Object.defineProperty(exports,"styleTags",{enumerable:!0,get:function(){return wo}});Object.defineProperty(exports,"sublanguageProp",{enumerable:!0,get:function(){return ba}});Object.defineProperty(exports,"syntaxHighlighting",{enumerable:!0,get:function(){return kc}});Object.defineProperty(exports,"syntaxTree",{enumerable:!0,get:function(){return ve}});Object.defineProperty(exports,"tags",{enumerable:!0,get:function(){return v}});
|