iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
2 lines • 155 kB
JavaScript
(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([[2118],{62118:(t,e,i)=>{"use strict";i.d(e,{m8:()=>c,f$:()=>O,of:()=>w});var n=i(77885),s=i(19753);const r=n.q6.define(),o=n.q6.define(),h=n.r$.define(),l=n.r$.define({combine:t=>(0,n.BO)(t,{minDepth:100,newGroupDelay:500},{minDepth:Math.max,newGroupDelay:Math.min})}),a=n.QQ.define({create:()=>D.empty,update(t,e){let i=e.state.facet(l),s=e.annotation(r);if(s){let n=v.fromTransaction(e),r=s.side,o=0==r?t.undone:t.done;return o=n?y(o,o.length,i.minDepth,n):x(o,e.startState.selection),new D(0==r?s.rest:o,0==r?o:s.rest)}let h=e.annotation(o);if("full"!=h&&"before"!=h||(t=t.isolate()),!1===e.annotation(n.YW.addToHistory))return e.changes.empty?t:t.addMapping(e.changes.desc);let a=v.fromTransaction(e),c=e.annotation(n.YW.time),u=e.annotation(n.YW.userEvent);return a?t=t.addChanges(a,c,u,i.newGroupDelay,i.minDepth):e.selection&&(t=t.addSelection(e.startState.selection,c,u,i.newGroupDelay)),"full"!=h&&"after"!=h||(t=t.isolate()),t},toJSON:t=>({done:t.done.map((t=>t.toJSON())),undone:t.undone.map((t=>t.toJSON()))}),fromJSON:t=>new D(t.done.map(v.fromJSON),t.undone.map(v.fromJSON))});function c(t={}){return[a,l.of(t),s.tk.domEventHandlers({beforeinput:(t,e)=>"historyUndo"==t.inputType?f(e):"historyRedo"==t.inputType&&d(e)})]}function u(t,e){return function({state:i,dispatch:n}){let s=i.field(a,!1);if(!s)return!1;let r=s.pop(t,i,e);return!!r&&(n(r),!0)}}const f=u(0,!1),d=u(1,!1),g=u(0,!0),p=u(1,!0);function m(t){return function(e){let i=e.field(a,!1);if(!i)return 0;let n=0==t?i.done:i.undone;return n.length-(n.length&&!n[0].changes?1:0)}}const w=m(0);m(1);class v{constructor(t,e,i,n,s){this.changes=t,this.effects=e,this.mapped=i,this.startSelection=n,this.selectionsAfter=s}setSelAfter(t){return new v(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,e,i;return{changes:null===(t=this.changes)||void 0===t?void 0:t.toJSON(),mapped:null===(e=this.mapped)||void 0===e?void 0:e.toJSON(),startSelection:null===(i=this.startSelection)||void 0===i?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map((t=>t.toJSON()))}}static fromJSON(t){return new v(t.changes&&n.as.fromJSON(t.changes),[],t.mapped&&n.n0.fromJSON(t.mapped),t.startSelection&&n.jT.fromJSON(t.startSelection),t.selectionsAfter.map(n.jT.fromJSON))}static fromTransaction(t){let e=b;for(let i of t.startState.facet(h)){let n=i(t);n.length&&(e=e.concat(n))}return!e.length&&t.changes.empty?null:new v(t.changes.invert(t.startState.doc),e,void 0,t.startState.selection,b)}static selection(t){return new v(void 0,b,void 0,void 0,t)}}function y(t,e,i,n){let s=e+1>i+20?e-i-1:0,r=t.slice(s,e);return r.push(n),r}function S(t,e){return t.length?e.length?t.concat(e):t:e}const b=[];function x(t,e){if(t.length){let i=t[t.length-1],n=i.selectionsAfter.slice(Math.max(0,i.selectionsAfter.length-200));return n.length&&n[n.length-1].eq(e)?t:(n.push(e),y(t,t.length-1,1e9,i.setSelAfter(n)))}return[v.selection([e])]}function k(t){let e=t[t.length-1],i=t.slice();return i[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),i}function A(t,e){if(!t.length)return t;let i=t.length,n=b;for(;i;){let s=M(t[i-1],e,n);if(s.changes&&!s.changes.empty||s.effects.length){let e=t.slice(0,i);return e[i-1]=s,e}e=s.mapped,i--,n=s.selectionsAfter}return n.length?[v.selection(n)]:b}function M(t,e,i){let s=S(t.selectionsAfter.length?t.selectionsAfter.map((t=>t.map(e))):b,i);if(!t.changes)return v.selection(s);let r=t.changes.map(e),o=e.mapDesc(t.changes,!0),h=t.mapped?t.mapped.composeDesc(o):o;return new v(r,n.Py.mapEffects(t.effects,e),h,t.startSelection.map(o),s)}class D{constructor(t,e,i=0,n){this.done=t,this.undone=e,this.prevTime=i,this.prevUserEvent=n}isolate(){return this.prevTime?new D(this.done,this.undone):this}addChanges(t,e,i,n,s){let r=this.done,o=r[r.length-1];return r=o&&o.changes&&e-this.prevTime<n&&!o.selectionsAfter.length&&!o.changes.empty&&t.changes&&function(t,e){let i=[],n=!1;return t.iterChangedRanges(((t,e)=>i.push(t,e))),e.iterChangedRanges(((t,e,s,r)=>{for(let t=0;t<i.length;){let e=i[t++],o=i[t++];r>=e&&s<=o&&(n=!0)}})),n}(o.changes,t.changes)?y(r,r.length-1,s,new v(t.changes.compose(o.changes),S(t.effects,o.effects),o.mapped,o.startSelection,b)):y(r,r.length,s,t),new D(r,b,e,i)}addSelection(t,e,i,n){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:b;return s.length>0&&e-this.prevTime<n&&"keyboardselection"==i&&this.prevUserEvent==i&&(r=s[s.length-1],o=t,r.ranges.length==o.ranges.length&&0===r.ranges.filter(((t,e)=>t.empty!=o.ranges[e].empty)).length)?this:new D(x(this.done,t),this.undone,e,i);var r,o}addMapping(t){return new D(A(this.done,t),A(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,e,i){let n=0==t?this.done:this.undone;if(0==n.length)return null;let s=n[n.length-1];if(i&&s.selectionsAfter.length)return e.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:r.of({side:t,rest:k(n)})});if(s.changes){let i=1==n.length?b:n.slice(0,n.length-1);return s.mapped&&(i=A(i,s.mapped)),e.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:r.of({side:t,rest:i}),filter:!1})}return null}}D.empty=new D(b,b);const O=[{key:"Mod-z",run:f,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:d,preventDefault:!0},{key:"Mod-u",run:g,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:p,preventDefault:!0}]},13764:(t,e,i)=>{"use strict";i.d(e,{Xs:()=>l,f_:()=>a,uU:()=>s});var n=i(77885);class s{eq(t){return this==t}range(t,e=t){return new r(t,e,this)}}s.prototype.startSide=s.prototype.endSide=0,s.prototype.point=!1,s.prototype.mapMode=n.gc.TrackDel;class r{constructor(t,e,i){this.from=t,this.to=e,this.value=i}}function o(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class h{constructor(t,e,i,n){this.from=t,this.to=e,this.value=i,this.maxPoint=n}get length(){return this.to[this.to.length-1]}findIndex(t,e,i=1e9*e,n=0){if(t<=0)return n;let s=e<0?this.to:this.from;for(let r=n,o=s.length;;){if(r==o)return r;let n=r+o>>1,h=s[n]-t||(e<0?this.value[n].startSide:this.value[n].endSide)-i;if(n==r)return h>=0?r:o;h>=0?o=n:r=n+1}}between(t,e,i,n){for(let s=this.findIndex(e,-1),r=this.findIndex(i,1,void 0,s);s<r;s++)if(!1===n(this.from[s]+t,this.to[s]+t,this.value[s]))return!1}map(t,e){let i=[],n=[],s=[],r=-1,o=-1;for(let h=0;h<this.value.length;h++){let l,a,c=this.value[h],u=this.from[h]+t,f=this.to[h]+t;if(u==f){let t=e.mapPos(u,c.startSide,c.mapMode);if(null==t)continue;l=a=t}else if(l=e.mapPos(u,c.startSide),a=e.mapPos(f,c.endSide),l>a||l==a&&c.startSide>0&&c.endSide<=0)continue;(a-l||c.endSide-c.startSide)<0||(r<0&&(r=l),c.point&&(o=Math.max(o,a-l)),i.push(c),n.push(l-r),s.push(a-r))}return{mapped:i.length?new h(n,s,i,o):null,pos:r}}}class l{constructor(t,e,i=l.empty,n){this.chunkPos=t,this.chunk=e,this.nextLayer=i,this.maxPoint=n}get length(){let t=this.chunk.length-1;return t<0?0:Math.max(this.chunkEnd(t),this.nextLayer.length)}get size(){if(this==l.empty)return 0;let t=this.nextLayer.size;for(let e of this.chunk)t+=e.value.length;return t}chunkEnd(t){return this.chunkPos[t]+this.chunk[t].length}update(t){let{add:e=[],sort:i=!1,filterFrom:n=0,filterTo:s=this.length}=t,h=t.filter;if(0==e.length&&!h)return this;if(i&&e.slice().sort(o),this==l.empty)return e.length?l.of(e):this;let u=new c(this,null,-1).goto(0),f=0,d=[],g=new a;for(;u.value||f<e.length;)if(f<e.length&&(u.from-e[f].from||u.startSide-e[f].value.startSide)>=0){let t=e[f++];g.addInner(t.from,t.to,t.value)||d.push(t)}else 1==u.rangeIndex&&u.chunkIndex<this.chunk.length&&(f==e.length||this.chunkEnd(u.chunkIndex)<e[f].from)&&(!h||n>this.chunkEnd(u.chunkIndex)||s<this.chunkPos[u.chunkIndex])&&g.addChunk(this.chunkPos[u.chunkIndex],this.chunk[u.chunkIndex])?u.nextChunk():((!h||n>u.to||s<u.from||h(u.from,u.to,u.value))&&(g.addInner(u.from,u.to,u.value)||d.push(new r(u.from,u.to,u.value))),u.next());return g.finishInner(this.nextLayer!=l.empty||d.length?this.nextLayer.update({add:d,filter:h,filterFrom:n,filterTo:s}):l.empty)}map(t){if(0==t.length||this==l.empty)return this;let e=[],i=[],n=-1;for(let s=0;s<this.chunk.length;s++){let r=this.chunkPos[s],o=this.chunk[s],h=t.touchesRange(r,r+o.length);if(!1===h)n=Math.max(n,o.maxPoint),e.push(o),i.push(t.mapPos(r));else if(!0===h){let{mapped:s,pos:h}=o.map(r,t);s&&(n=Math.max(n,s.maxPoint),e.push(s),i.push(h))}}let s=this.nextLayer.map(t);return 0==e.length?s:new l(i,e,s,n)}between(t,e,i){if(this!=l.empty){for(let n=0;n<this.chunk.length;n++){let s=this.chunkPos[n],r=this.chunk[n];if(e>=s&&t<=s+r.length&&!1===r.between(s,t-s,e-s,i))return}this.nextLayer.between(t,e,i)}}iter(t=0){return u.from([this]).goto(t)}static iter(t,e=0){return u.from(t).goto(e)}static compare(t,e,i,n,s=-1){let r=t.filter((t=>t.maxPoint>=500||t!=l.empty&&e.indexOf(t)<0&&t.maxPoint>=s)),o=e.filter((e=>e.maxPoint>=500||e!=l.empty&&t.indexOf(e)<0&&e.maxPoint>=s)),h=function(t,e){let i=new Map;for(let e of t)for(let t=0;t<e.chunk.length;t++)e.chunk[t].maxPoint<500&&i.set(e.chunk[t],e.chunkPos[t]);let n=new Set;for(let t of e)for(let e=0;e<t.chunk.length;e++)i.get(t.chunk[e])==t.chunkPos[e]&&n.add(t.chunk[e]);return n}(r,o),a=new d(r,h,s),c=new d(o,h,s);i.iterGaps(((t,e,i)=>g(a,t,c,e,i,n))),i.empty&&0==i.length&&g(a,0,c,0,0,n)}static spans(t,e,i,n,s=-1){let r=new d(t,null,s).goto(e),o=e,h=r.openStart;for(;;){let t=Math.min(r.to,i);if(r.point?(n.point(o,t,r.point,r.activeForPoint(r.to),h),h=r.openEnd(t)+(r.to>t?1:0)):t>o&&(n.span(o,t,r.active,h),h=r.openEnd(t)),r.to>i)break;o=r.to,r.next()}return h}static of(t,e=!1){let i=new a;for(let n of t instanceof r?[t]:e?t.slice().sort(o):t)i.add(n.from,n.to,n.value);return i.finish()}}l.empty=new l([],[],null,-1),l.empty.nextLayer=l.empty;class a{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}finishChunk(t){this.chunks.push(new h(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,t&&(this.from=[],this.to=[],this.value=[])}add(t,e,i){this.addInner(t,e,i)||(this.nextLayer||(this.nextLayer=new a)).add(t,e,i)}addInner(t,e,i){let n=t-this.lastTo||i.startSide-this.last.endSide;if(n<=0&&(t-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(n<0)&&(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=t),this.from.push(t-this.chunkStart),this.to.push(e-this.chunkStart),this.last=i,this.lastFrom=t,this.lastTo=e,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,e-t)),!0)}addChunk(t,e){if((t-this.lastTo||e.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,e.maxPoint),this.chunks.push(e),this.chunkPos.push(t);let i=e.value.length-1;return this.last=e.value[i],this.lastFrom=e.from[i]+t,this.lastTo=e.to[i]+t,!0}finish(){return this.finishInner(l.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=new l(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}class c{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 e=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(e)||this.layer.chunkEnd(this.chunkIndex)<t||e.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}let n=this.chunkIndex==this.layer.chunk.length?0:this.layer.chunk[this.chunkIndex].findIndex(t-this.layer.chunkPos[this.chunkIndex],-1,e);(!i||this.rangeIndex<n)&&(this.rangeIndex=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}{let t=this.layer.chunkPos[this.chunkIndex],e=this.layer.chunk[this.chunkIndex],i=t+e.from[this.rangeIndex];if(this.from=i,this.to=t+e.to[this.rangeIndex],this.value=e.value[this.rangeIndex],++this.rangeIndex==e.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}if(this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.to-t.to||this.endSide-t.endSide}}class u{constructor(t){this.heap=t}static from(t,e=null,i=-1){let n=[];for(let s=0;s<t.length;s++)for(let r=t[s];r!=l.empty;r=r.nextLayer)r.maxPoint>=i&&n.push(new c(r,e,i,s));return 1==n.length?n[0]:new u(n)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(let i of this.heap)i.goto(t,e);for(let t=this.heap.length>>1;t>=0;t--)f(this.heap,t);return this.next(),this}forward(t,e){for(let i of this.heap)i.forward(t,e);for(let t=this.heap.length>>1;t>=0;t--)f(this.heap,t);(this.to-t||this.value.endSide-e)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),f(this.heap,0)}}}function f(t,e){for(let i=t[e];;){let n=1+(e<<1);if(n>=t.length)break;let s=t[n];if(n+1<t.length&&s.compare(t[n+1])>=0&&(s=t[n+1],n++),i.compare(s)<0)break;t[n]=i,t[e]=s,e=n}}class d{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=u.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){m(this.active,t),m(this.activeTo,t),m(this.activeRank,t),this.minActive=v(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:n,rank:s}=this.cursor;for(;e<this.activeRank.length&&this.activeRank[e]<=s;)e++;w(this.active,e,i),w(this.activeTo,e,n),w(this.activeRank,e,s),t&&w(t,e,this.cursor.from),this.minActive=v(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null,n=0;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>t){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),i&&m(i,s)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>t){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}{let s=this.cursor.value;if(s.point){if(!(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to&&s.endSide==this.endSide)){this.point=s,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=s.endSide,this.cursor.from<t&&(n=1),this.cursor.next(),this.to>t&&this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(i),this.cursor.next()}}}if(i){let e=0;for(;e<i.length&&i[e]<t;)e++;this.openStart=e+n}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let i=0;i<this.active.length&&!(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}openEnd(t){let e=0;for(;e<this.activeTo.length&&this.activeTo[e]>t;)e++;return e}}function g(t,e,i,n,s,r){t.goto(e),i.goto(n);let o=n+s,h=n,l=n-e;for(;;){let e=t.to+l-i.to||t.endSide-i.endSide,n=e<0?t.to+l:i.to,s=Math.min(n,o);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))||r.comparePoint(h,s,t.point,i.point):s>h&&!p(t.active,i.active)&&r.compareRange(h,s,t.active,i.active),n>o)break;h=n,e<=0&&t.next(),e>=0&&i.next()}}function p(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(t[i]!=e[i]&&!t[i].eq(e[i]))return!1;return!0}function m(t,e){for(let i=e,n=t.length-1;i<n;i++)t[i]=t[i+1];t.pop()}function w(t,e,i){for(let i=t.length-1;i>=e;i--)t[i+1]=t[i];t[e]=i}function v(t,e){let i=-1,n=1e9;for(let s=0;s<e.length;s++)(e[s]-n||t[s].endSide-t[i].endSide)<0&&(i=s,n=e[s]);return i}},77885:(t,e,i)=>{"use strict";i.d(e,{q6:()=>q,n0:()=>o,as:()=>h,D0:()=>Z,F6:()=>R,jT:()=>p,yy:()=>nt,r$:()=>y,gc:()=>r,Wl:()=>T,Py:()=>J,QQ:()=>A,YW:()=>_,BO:()=>st});var n=i(23414);const s=/\r\n?|\n/;var r=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(r||(r={}));class o{constructor(t){this.sections=t}get length(){let t=0;for(let e=0;e<this.sections.length;e+=2)t+=this.sections[e];return t}get newLength(){let t=0;for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e+1];t+=i<0?this.sections[e]:i}return t}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(t){for(let e=0,i=0,n=0;e<this.sections.length;){let s=this.sections[e++],r=this.sections[e++];r<0?(t(i,n,s),n+=s):n+=r,i+=s}}iterChangedRanges(t,e=!1){c(this,t,e)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];n<0?t.push(i,n):t.push(n,i)}return new o(t)}composeDesc(t){return this.empty?t:t.empty?this:f(this,t)}mapDesc(t,e=!1){return t.empty?this:u(this,t,e)}mapPos(t,e=-1,i=r.Simple){let n=0,s=0;for(let o=0;o<this.sections.length;){let h=this.sections[o++],l=this.sections[o++],a=n+h;if(l<0){if(a>t)return s+(t-n);s+=h}else{if(i!=r.Simple&&a>=t&&(i==r.TrackDel&&n<t&&a>t||i==r.TrackBefore&&n<t||i==r.TrackAfter&&a>t))return null;if(a>t||a==t&&e<0&&!h)return t==n||e<0?s:s+l;s+=l}n=a}if(t>n)throw new RangeError(`Position ${t} is out of range for changeset of length ${n}`);return s}touchesRange(t,e=t){for(let i=0,n=0;i<this.sections.length&&n<=e;){let s=n+this.sections[i++];if(this.sections[i++]>=0&&n<=e&&s>=t)return!(n<t&&s>e)||"cover";n=s}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];t+=(t?" ":"")+i+(n>=0?":"+n:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some((t=>"number"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeDesc");return new o(t)}}class h extends o{constructor(t,e){super(t),this.inserted=e}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return c(this,((e,i,n,s,r)=>t=t.replace(n,n+(i-e),r)),!1),t}mapDesc(t,e=!1){return u(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let s=0,r=0;s<e.length;s+=2){let o=e[s],h=e[s+1];if(h>=0){e[s]=h,e[s+1]=o;let l=s>>1;for(;i.length<l;)i.push(n.xv.empty);i.push(o?t.slice(r,r+o):n.xv.empty)}r+=o}return new h(e,i)}compose(t){return this.empty?t:t.empty?this:f(this,t,!0)}map(t,e=!1){return t.empty?this:u(this,t,e,!0)}iterChanges(t,e=!1){c(this,t,e)}get desc(){return new o(this.sections)}filter(t){let e=[],i=[],n=[],s=new d(this);t:for(let r=0,o=0;;){let h=r==t.length?1e9:t[r++];for(;o<h||o==h&&0==s.len;){if(s.done)break t;let t=Math.min(s.len,h-o);l(n,t,-1);let r=-1==s.ins?-1:0==s.off?s.ins:0;l(e,t,r),r>0&&a(i,e,s.text),s.forward(t),o+=t}let c=t[r++];for(;o<c;){if(s.done)break t;let t=Math.min(s.len,c-o);l(e,t,-1),l(n,t,-1==s.ins?-1:0==s.off?s.ins:0),s.forward(t),o+=t}}return{changes:new h(e,i),filtered:new o(n)}}toJSON(){let t=[];for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e],n=this.sections[e+1];n<0?t.push(i):0==n?t.push([i]):t.push([i].concat(this.inserted[e>>1].toJSON()))}return t}static of(t,e,i){let r=[],o=[],c=0,u=null;function f(t=!1){if(!t&&!r.length)return;c<e&&l(r,e-c,-1);let i=new h(r,o);u=u?u.compose(i.map(u)):i,r=[],o=[],c=0}return function t(d){if(Array.isArray(d))for(let e of d)t(e);else if(d instanceof h){if(d.length!=e)throw new RangeError(`Mismatched change set length (got ${d.length}, expected ${e})`);f(),u=u?u.compose(d.map(u)):d}else{let{from:t,to:h=t,insert:u}=d;if(t>h||t<0||h>e)throw new RangeError(`Invalid change range ${t} to ${h} (in doc of length ${e})`);let g=u?"string"==typeof u?n.xv.of(u.split(i||s)):u:n.xv.empty,p=g.length;if(t==h&&0==p)return;t<c&&f(),t>c&&l(r,t-c,-1),l(r,h-t,p),a(o,r,g),c=h}}(t),f(!u),u}static empty(t){return new h(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],i=[];for(let s=0;s<t.length;s++){let r=t[s];if("number"==typeof r)e.push(r,-1);else{if(!Array.isArray(r)||"number"!=typeof r[0]||r.some(((t,e)=>e&&"string"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==r.length)e.push(r[0],0);else{for(;i.length<s;)i.push(n.xv.empty);i[s]=n.xv.of(r.slice(1)),e.push(r[0],i[s].length)}}}return new h(e,i)}}function l(t,e,i,n=!1){if(0==e&&i<=0)return;let s=t.length-2;s>=0&&i<=0&&i==t[s+1]?t[s]+=e:0==e&&0==t[s]?t[s+1]+=i:n?(t[s]+=e,t[s+1]+=i):t.push(e,i)}function a(t,e,i){if(0==i.length)return;let s=e.length-2>>1;if(s<t.length)t[t.length-1]=t[t.length-1].append(i);else{for(;t.length<s;)t.push(n.xv.empty);t.push(i)}}function c(t,e,i){let s=t.inserted;for(let r=0,o=0,h=0;h<t.sections.length;){let l=t.sections[h++],a=t.sections[h++];if(a<0)r+=l,o+=l;else{let c=r,u=o,f=n.xv.empty;for(;c+=l,u+=a,a&&s&&(f=f.append(s[h-2>>1])),!(i||h==t.sections.length||t.sections[h+1]<0);)l=t.sections[h++],a=t.sections[h++];e(r,c,o,u,f),r=c,o=u}}}function u(t,e,i,n=!1){let s=[],r=n?[]:null,c=new d(t),u=new d(e);for(let t=0,e=0;;)if(-1==c.ins)t+=c.len,c.next();else if(-1==u.ins&&e<t){let i=Math.min(u.len,t-e);u.forward(i),l(s,i,-1),e+=i}else if(u.ins>=0&&(c.done||e<t||e==t&&(u.len<c.len||u.len==c.len&&!i))){for(l(s,u.ins,-1);t>e&&!c.done&&t+c.len<e+u.len;)t+=c.len,c.next();e+=u.len,u.next()}else{if(!(c.ins>=0)){if(c.done&&u.done)return r?new h(s,r):new o(s);throw new Error("Mismatched change set lengths")}{let i=0,n=t+c.len;for(;;)if(u.ins>=0&&e>t&&e+u.len<n)i+=u.ins,e+=u.len,u.next();else{if(!(-1==u.ins&&e<n))break;{let t=Math.min(u.len,n-e);i+=t,u.forward(t),e+=t}}l(s,i,c.ins),r&&a(r,s,c.text),t=n,c.next()}}}function f(t,e,i=!1){let n=[],s=i?[]:null,r=new d(t),c=new d(e);for(let t=!1;;){if(r.done&&c.done)return s?new h(n,s):new o(n);if(0==r.ins)l(n,r.len,0,t),r.next();else if(0!=c.len||c.done){if(r.done||c.done)throw new Error("Mismatched change set lengths");{let e=Math.min(r.len2,c.len),i=n.length;if(-1==r.ins){let i=-1==c.ins?-1:c.off?0:c.ins;l(n,e,i,t),s&&i&&a(s,n,c.text)}else-1==c.ins?(l(n,r.off?0:r.len,e,t),s&&a(s,n,r.textBit(e))):(l(n,r.off?0:r.len,c.off?0:c.ins,t),s&&!c.off&&a(s,n,c.text));t=(r.ins>e||c.ins>=0&&c.len>e)&&(t||n.length>i),r.forward2(e),c.forward(e)}}else l(n,0,c.ins,t),s&&a(s,n,c.text),c.next()}}class d{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i<t.length?(this.len=t[this.i++],this.ins=t[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return-2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:t}=this.set,e=this.i-2>>1;return e>=t.length?n.xv.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?n.xv.empty:e[i].slice(this.off,null==t?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){-1==this.ins?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class g{constructor(t,e,i){this.from=t,this.to=e,this.flags=i}get anchor(){return 16&this.flags?this.to:this.from}get head(){return 16&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 4&this.flags?-1:8&this.flags?1:0}get bidiLevel(){let t=3&this.flags;return 3==t?null:t}get goalColumn(){let t=this.flags>>5;return 33554431==t?void 0:t}map(t,e=-1){let i=t.mapPos(this.from,e),n=t.mapPos(this.to,e);return i==this.from&&n==this.to?this:new g(i,n,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return p.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return p.range(this.anchor,i)}eq(t){return this.anchor==t.anchor&&this.head==t.head}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||"number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid JSON representation for SelectionRange");return p.range(t.anchor,t.head)}}class p{constructor(t,e=0){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:p.create(this.ranges.map((i=>i.map(t,e))),this.mainIndex)}eq(t){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let e=0;e<this.ranges.length;e++)if(!this.ranges[e].eq(t.ranges[e]))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new p([this.main])}addRange(t,e=!0){return p.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,p.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map((t=>t.toJSON())),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||"number"!=typeof t.main||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new p(t.ranges.map((t=>g.fromJSON(t))),t.main)}static single(t,e=t){return new p([p.range(t,e)],0)}static create(t,e=0){if(0==t.length)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;n<t.length;n++){let s=t[n];if(s.empty?s.from<=i:s.from<i)return m(t.slice(),e);i=s.to}return new p(t,e)}static cursor(t,e=0,i,n){return new g(t,t,(0==e?0:e<0?4:8)|(null==i?3:Math.min(2,i))|(null!=n?n:33554431)<<5)}static range(t,e,i){let n=(null!=i?i:33554431)<<5;return e<t?new g(e,t,16|n):new g(t,e,n)}}function m(t,e=0){let i=t[e];t.sort(((t,e)=>t.from-e.from)),e=t.indexOf(i);for(let i=1;i<t.length;i++){let n=t[i],s=t[i-1];if(n.empty?n.from<=s.to:n.from<s.to){let r=s.from,o=Math.max(n.to,s.to);i<=e&&e--,t.splice(--i,2,n.anchor>n.head?p.range(o,r):p.range(r,o))}}return new p(t,e)}function w(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let v=0;class y{constructor(t,e,i,n,s){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.extensions=s,this.id=v++,this.default=t([])}static define(t={}){return new y(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:S),!!t.static,t.enables)}of(t){return new b([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new b(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new b(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],(i=>e(i.field(t))))}}function S(t,e){return t==e||t.length==e.length&&t.every(((t,i)=>t===e[i]))}class b{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=v++}dynamicSlot(t){var e;let i=this.value,n=this.facet.compareInput,s=t[this.id]>>1,r=2==this.type,o=!1,h=!1,l=[];for(let i of this.dependencies)"doc"==i?o=!0:"selection"==i?h=!0:0==(1&(null!==(e=t[i.id])&&void 0!==e?e:1))&&l.push(t[i.id]);return(t,e)=>{if(!e||e.reconfigured)return t.values[s]=i(t),1;{if(!(o&&e.docChanged||h&&(e.docChanged||e.selection)||l.some((e=>(1&B(t,e))>0))))return 0;let a=i(t),c=e.startState.values[s];return(r?function(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}(a,c,n):n(a,c))?0:(t.values[s]=a,1)}}}}function x(t,e,i){let n=i.map((e=>t[e.id])),s=i.map((t=>t.type)),r=n.filter((t=>!(1&t))),o=t[e.id]>>1;return(t,i)=>{let h=i?i.reconfigured?i.startState.config.address[e.id]:o<<1:null,l=null==h;for(let e of r)1&B(t,e)&&(l=!0);if(!l)return 0;let a=[];for(let e=0;e<n.length;e++){let i=N(t,n[e]);if(2==s[e])for(let t of i)a.push(t);else a.push(i)}let c=e.combine(a);return null!=h&&e.compare(c,N(i.startState,h))?0:(t.values[o]=c,1)}}const k=y.define({static:!0});class A{constructor(t,e,i,n,s){this.id=t,this.createF=e,this.updateF=i,this.compareF=n,this.spec=s,this.provides=void 0}static define(t){let e=new A(v++,t.create,t.update,t.compare||((t,e)=>t===e),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet(k).find((t=>t.field==this));return((null==e?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return(t,i)=>{if(!i)return t.values[e]=this.create(t),1;let n,s=0;if(i.reconfigured){let t=function(t,e){let i=t.config.address[e];return null==i?null:i>>1}(i.startState,this.id);n=null==t?this.create(i.startState):i.startState.values[t],s=1}else n=i.startState.values[e];let r=this.updateF(n,i);return s||this.compareF(n,r)||(s=1),s&&(t.values[e]=r),s}}init(t){return[this,k.of({field:this,create:t})]}get extension(){return this}}const M=2,D=1,O=0;function C(t){return e=>new E(e,t)}const T={fallback:C(3),default:C(M),extend:C(D),override:C(O)};class E{constructor(t,e){this.inner=t,this.prec=e}}class R{of(t){return new L(this,t)}reconfigure(t){return R.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class L{constructor(t,e){this.compartment=t,this.inner=e}}class P{constructor(t,e,i,n,s){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=s,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return null==e?t.default:this.staticValues[e>>1]}static resolve(t,e,i){let n=[],s=Object.create(null),r=new Map;for(let i of function(t,e,i){let n=[[],[],[],[]],s=new Map;function r(t,o){let h=s.get(t);if(null!=h){if(h>=o)return;let e=n[h].indexOf(t);e>-1&&n[h].splice(e,1),t instanceof L&&i.delete(t.compartment)}if(s.set(t,o),Array.isArray(t))for(let e of t)r(e,o);else if(t instanceof L){if(i.has(t.compartment))throw new RangeError("Duplicate use of compartment in extensions");let n=e.get(t.compartment)||t.inner;i.set(t.compartment,n),r(n,o)}else if(t instanceof E)r(t.inner,t.prec);else if(t instanceof A)n[o].push(t),t.provides&&r(t.provides,o);else if(t instanceof b)n[o].push(t),t.facet.extensions&&r(t.facet.extensions,o);else{let e=t.extension;if(!e)throw new Error(`Unrecognized extension value in extension set (${t}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(e,o)}}return r(t,M),n.reduce(((t,e)=>t.concat(e)))}(t,e,r))i instanceof A?n.push(i):(s[i.facet.id]||(s[i.facet.id]=[])).push(i);let o=Object.create(null),h=[],l=[];for(let t of n)o[t.id]=l.length<<1,l.push((e=>t.slot(e)));for(let t in s){let e=s[t],n=e[0].facet;if(e.every((t=>0==t.type))){o[n.id]=h.length<<1|1;let t=n.combine(e.map((t=>t.value))),s=i?i.config.address[n.id]:null;if(null!=s){let e=N(i,s);n.compare(t,e)&&(t=e)}h.push(t)}else{for(let t of e)0==t.type?(o[t.id]=h.length<<1|1,h.push(t.value)):(o[t.id]=l.length<<1,l.push((e=>t.dynamicSlot(e))));o[n.id]=l.length<<1,l.push((t=>x(t,n,e)))}}return new P(t,r,l.map((t=>t(o))),o,h)}}function B(t,e){if(1&e)return 2;let i=e>>1,n=t.status[i];if(4==n)throw new Error("Cyclic dependency between fields and/or facets");if(2&n)return n;t.status[i]=4;let s=t.config.dynamicSlots[i](t,t.applying);return t.status[i]=2|s}function N(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const I=y.define(),V=y.define({combine:t=>t.some((t=>t)),static:!0}),H=y.define({combine:t=>t.length?t[0]:void 0,static:!0}),W=y.define(),F=y.define(),z=y.define();class q{constructor(t,e){this.type=t,this.value=e}static define(){return new j}}class j{of(t){return new q(this,t)}}class ${constructor(t){this.map=t}of(t){return new J(this,t)}}class J{constructor(t,e){this.type=t,this.value=e}map(t){let e=this.type.map(this.value,t);return void 0===e?void 0:e==this.value?this:new J(this.type,e)}is(t){return this.type==t}static define(t={}){return new $(t.map||(t=>t))}static mapEffects(t,e){if(!t.length)return t;let i=[];for(let n of t){let t=n.map(e);t&&i.push(t)}return i}}J.reconfigure=J.define(),J.appendConfig=J.define();class _{constructor(t,e,i,n,s,r){this.startState=t,this.changes=e,this.selection=i,this.effects=n,this.annotations=s,this.scrollIntoView=r,this._doc=null,this._state=null,i&&w(i,e.newLength),s.some((t=>t.type==_.time))||(this.annotations=s.concat(_.time.of(Date.now())))}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(t){for(let e of this.annotations)if(e.type==t)return e.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}}function G(t,e){let i=[];for(let n=0,s=0;;){let r,o;if(n<t.length&&(s==e.length||e[s]>=t[n]))r=t[n++],o=t[n++];else{if(!(s<e.length))return i;r=e[s++],o=e[s++]}!i.length||i[i.length-1]<r?i.push(r,o):i[i.length-1]<o&&(i[i.length-1]=o)}}function K(t,e,i){var n;let s,r,o;return i?(s=e.changes,r=h.empty(e.changes.length),o=t.changes.compose(e.changes)):(s=e.changes.map(t.changes),r=t.changes.mapDesc(e.changes,!0),o=t.changes.compose(s)),{changes:o,selection:e.selection?e.selection.map(r):null===(n=t.selection)||void 0===n?void 0:n.map(s),effects:J.mapEffects(t.effects,s).concat(J.mapEffects(e.effects,r)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function U(t,e,i){let n=e.selection;return{changes:e.changes instanceof h?e.changes:h.of(e.changes||[],i,t.facet(H)),selection:n&&(n instanceof p?n:p.single(n.anchor,n.head)),effects:Q(e.effects),annotations:Q(e.annotations),scrollIntoView:!!e.scrollIntoView}}function Y(t,e,i){let n=U(t,e.length?e[0]:{},t.doc.length);e.length&&!1===e[0].filter&&(i=!1);for(let s=1;s<e.length;s++){!1===e[s].filter&&(i=!1);let r=!!e[s].sequential;n=K(n,U(t,e[s],r?n.changes.newLength:t.doc.length),r)}let s=new _(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return function(t){let e=t.startState,i=e.facet(z),n=t;for(let s=i.length-1;s>=0;s--){let r=i[s](t);r&&Object.keys(r).length&&(n=K(t,U(e,r,t.changes.newLength),!0))}return n==t?t:new _(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}(i?function(t){let e=t.startState,i=!0;for(let n of e.facet(W)){let e=n(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:G(i,e))}if(!0!==i){let n,s;if(!1===i)s=t.changes.invertedDesc,n=h.empty(e.doc.length);else{let e=t.changes.filter(i);n=e.changes,s=e.filtered.invertedDesc}t=new _(e,n,t.selection&&t.selection.map(s),J.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let n=e.facet(F);for(let i=n.length-1;i>=0;i--){let s=n[i](t);t=s instanceof _?s:Array.isArray(s)&&1==s.length&&s[0]instanceof _?s[0]:Y(e,Q(s),!1)}return t}(s):s)}_.time=q.define(),_.userEvent=q.define(),_.addToHistory=q.define(),_.remote=q.define();const X=[];function Q(t){return null==t?X:Array.isArray(t)?t:[t]}var Z=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(Z||(Z={}));const tt=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let et;try{et=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(t){}function it(t){return e=>{if(!/\S/.test(e))return Z.Space;if(function(t){if(et)return et.test(t);for(let e=0;e<t.length;e++){let i=t[e];if(/\w/.test(i)||i>""&&(i.toUpperCase()!=i.toLowerCase()||tt.test(i)))return!0}return!1}(e))return Z.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return Z.Word;return Z.Other}}class nt{constructor(t,e,i,n=null){if(this.config=t,this.doc=e,this.selection=i,this.applying=null,this.status=t.statusTemplate.slice(),n&&n.startState.config==t)this.values=n.startState.values.slice();else if(this.values=t.dynamicSlots.map((t=>null)),n)for(let e in t.address){let i=t.address[e],s=n.startState.config.address[e];null!=s&&0==(1&i)&&(this.values[i>>1]=N(n.startState,s))}this.applying=n,n&&(n._state=this);for(let t=0;t<this.config.dynamicSlots.length;t++)B(this,t<<1);this.applying=null}field(t,e=!0){let i=this.config.address[t.id];if(null!=i)return B(this,i),N(this,i);if(e)throw new RangeError("Field is not present in this state")}update(...t){return Y(this,t,!0)}applyTransaction(t){let e=this.config,{base:i,compartments:n}=e;for(let s of t.effects)s.is(R.reconfigure)?(e&&(n=new Map,e.compartments.forEach(((t,e)=>n.set(e,t))),e=null),n.set(s.value.compartment,s.value.extension)):s.is(J.reconfigure)?(e=null,i=s.value):s.is(J.appendConfig)&&(e=null,i=Q(i).concat(s.value));new nt(e||P.resolve(i,n,this),t.newDoc,t.newSelection,t)}replaceSelection(t){return"string"==typeof t&&(t=this.toText(t)),this.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:t},range:p.cursor(e.from+t.length)})))}changeByRange(t){let e=this.selection,i=t(e.ranges[0]),n=this.changes(i.changes),s=[i.range],r=Q(i.effects);for(let i=1;i<e.ranges.length;i++){let o=t(e.ranges[i]),h=this.changes(o.changes),l=h.map(n);for(let t=0;t<i;t++)s[t]=s[t].map(l);let a=n.mapDesc(h,!0);s.push(o.range.map(a)),n=n.compose(l),r=J.mapEffects(r,l).concat(J.mapEffects(Q(o.effects),a))}return{changes:n,selection:p.create(s,e.mainIndex),effects:r}}changes(t=[]){return t instanceof h?t:h.of(t,this.doc.length,this.facet(nt.lineSeparator))}toText(t){return n.xv.of(t.split(this.facet(nt.lineSeparator)||s))}sliceDoc(t=0,e=this.doc.length){return this.doc.sliceString(t,e,this.lineBreak)}facet(t){let e=this.config.address[t.id];return null==e?t.default:(B(this,e),N(this,e))}toJSON(t){let e={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(let i in t){let n=t[i];n instanceof A&&(e[i]=n.spec.toJSON(this.field(t[i]),this))}return e}static fromJSON(t,e={},i){if(!t||"string"!=typeof t.doc)throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(i)for(let e in i){let s=i[e],r=t[e];n.push(s.init((t=>s.spec.fromJSON(r,t))))}return nt.create({doc:t.doc,selection:p.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let e=P.resolve(t.extensions||[],new Map),i=t.doc instanceof n.xv?t.doc:n.xv.of((t.doc||"").split(e.staticFacet(nt.lineSeparator)||s)),r=t.selection?t.selection instanceof p?t.selection:p.single(t.selection.anchor,t.selection.head):p.single(0);return w(r,i.length),e.staticFacet(V)||(r=r.asSingle()),new nt(e,i,r)}get tabSize(){return this.facet(nt.tabSize)}get lineBreak(){return this.facet(nt.lineSeparator)||"\n"}phrase(t){for(let e of this.facet(nt.phrases))if(Object.prototype.hasOwnProperty.call(e,t))return e[t];return t}languageDataAt(t,e){let i=[];for(let n of this.facet(I))for(let s of n(this,e))Object.prototype.hasOwnProperty.call(s,t)&&i.push(s[t]);return i}charCategorizer(t){return it(this.languageDataAt("wordChars",t).join(""))}wordAt(t){let{text:e,from:i,length:s}=this.doc.lineAt(t),r=this.charCategorizer(t),o=t-i,h=t-i;for(;o>0;){let t=(0,n.cp)(e,o,!1);if(r(e.slice(t,o))!=Z.Word)break;o=t}for(;h<s;){let t=(0,n.cp)(e,h);if(r(e.slice(h,t))!=Z.Word)break;h=t}return o==h?p.range(o+i,h+i):null}}function st(t,e,i={}){let n={};for(let e of t)for(let t of Object.keys(e)){let s=e[t],r=n[t];if(void 0===r)n[t]=s;else if(r===s||void 0===s);else{if(!Object.hasOwnProperty.call(i,t))throw new Error("Config merge conflict for field "+t);n[t]=i[t](r,s)}}for(let t in e)void 0===n[t]&&(n[t]=e[t]);return n}nt.allowMultipleSelections=V,nt.tabSize=y.define({combine:t=>t.length?t[0]:4}),nt.lineSeparator=H,nt.phrases=y.define(),nt.languageData=I,nt.changeFilter=W,nt.transactionFilter=F,nt.transactionExtender=z,R.reconfigure=J.define()},23414:(t,e,i)=>{"use strict";i.d(e,{xv:()=>m,gm:()=>u,nZ:()=>d,IS:()=>g,cp:()=>o,Gz:()=>p,bg:()=>f});let n="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map((t=>t?parseInt(t,36):1));for(let t=1;t<n.length;t++)n[t]+=n[t-1];function s(t){for(let e=1;e<n.length;e+=2)if(n[e]>t)return n[e-1]<=t;return!1}function r(t){return t>=127462&&t<=127487}function o(t,e,i=!0){return(i?h:l)(t,e)}function h(t,e){if(e==t.length)return e;e&&a(t.charCodeAt(e))&&c(t.charCodeAt(e-1))&&e--;let i=u(t,e);for(e+=d(i);e<t.length;){let n=u(t,e);if(8205==i||8205==n||s(n))e+=d(n),i=n;else{if(!r(n))break;{let i=0,n=e-2;for(;n>=0&&r(u(t,n));)i++,n-=2;if(i%2==0)break;e+=2}}}return e}function l(t,e){for(;e>0;){let i=h(t,e-2);if(i<e)return i;e--}return 0}function a(t){return t>=56320&&t<57344}function c(t){return t>=55296&&t<56320}function u(t,e){let i=t.charCodeAt(e);if(!c(i)||e+1==t.length)return i;let n=t.charCodeAt(e+1);return a(n)?n-56320+(i-55296<<10)+65536:i}function f(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10),56320+(1023&t)))}function d(t){return t<65536?1:2}function g(t,e,i){for(let n=0;n<t.length;)9==t.charCodeAt(n)?(e+=i-e%i,n++):(e++,n=o(t,n));return e}function p(t,e,i,n){for(let s=0;s<t.length;){if(e>=i)return{offset:s,leftOver:0};e+=9==t.charCodeAt(s)?n-e%n:1,s=o(t,s)}return{offset:t.length,leftOver:i-e}}class m{constructor(){}lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,i){let n=[];return this.decompose(0,t,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(e,this.length,n,1),v.from(n,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){let i=[];return this.decompose(t,e,i,0),v.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=new b(this),i=new b(t);for(;;){if(e.next(),i.next(),e.lineBreak!=i.lineBreak||e.done!=i.done||e.value!=i.value)return!1;if(e.done)return!0}}iter(t=1){return new b(this,t)}iterRange(t,e=this.length){return new x(this,t,e)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}static of(t){if(0==t.length)throw new RangeError("A document must have at least one line");return 1!=t.length||t[0]?t.length<=32?new w(t):v.from(w.split(t,[])):m.empty}}"undefined"!=typeof Symbol&&(m.prototype[Symbol.iterator]=function(){return this.iter()});class w extends m{constructor(t,e=function(t){let e=-1;for(let i of t)e+=i.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.text[s],o=n+r.length;if((e?i:o)>=t)return new k(n,o,i,r);n=o+1,i++}}decompose(t,e,i,n){let s=t<=0&&e>=this.length?this:new w(S(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&n){let t=i.pop(),e=y(s.text,t.text.slice(),0,s.length);if(e.length<=32)i.push(new w(e,t.length+s.length));else{let t=e.length>>1;i.push(new w(e.slice(0,t)),new w(e.slice(t)))}}else i.push(s)}replace(t,e,i){if(!(i instanceof w))return super.replace(t,e,i);let n=y(this.text,y(i.text,S(this.text,0,t)),e),s=this.length+i.length-(e-t);return n.length<=32?new w(n,s):v.from(w.split(n,[]),s)}sliceString(t,e=this.length,i="\n"){let n="";for(let s=0,r=0;s<=e&&r<this.text.length;r++){let o=this.text[r],h=s+o.length;s>t&&r&&(n+=i),t<h&&e>s&&(n+=o.slice(Math.max(0,t-s),e-s)),s=h+1}return n}flatten(t){for(let e of this.text)t.push(e)}static split(t,e){let i=[],n=-1;for(let s of t)i.push(s),n+=s.length+1,32==i.length&&(e.push(new w(i,n)),i=[],n=-1);return n>-1&&e.push(new w(i,n)),e}}class v extends m{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let e of t)this.lines+=e.lines}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.children[s],o=n+r.length,h=i+r.lines-1;if((e?h:o)>=t)return r.lineInner(t,e,i,n);n=o+1,i=h+1}}decompose(t,e,i,n){for(let s=0,r=0;r<=e&&s<this.children.length;s++){let o=this.children[s],h=r+o.length;if(t<=h&&e>=r){let s=n&((r<=t?1:0)|(h>=e?2:0));r>=t&&h<=e&&!s?i.push(o):o.decompose(t-r,e-r,i,s)}r=h+1}}replace(t,e,i){if(i.lines<this.lines)for(let n=0,s=0;n<this.children.length;n++){let r=this.children[n],o=s+r.length;if(t>=s&&e<=o){let h=r.replace(t-s,e-s,i),l=this.lines-r.lines+h.lines;if(h.lines<l>>4&&h.lines>l>>6){let s=this.children.slice();return s[n]=h,new v(s,this.length-(e-t)+i.length)}return super.replace(s,o,h)}s=o+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i="\n"){let n="";for(let s=0,r=0;s<this.children.length&&r<=e;s++){let o=this.children[s],h=r+o.length;r>t&&s&&(n+=i),t<h&&e>r&&(n+=o.sliceString(t-r,e-r,i)),r=h+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}static from(t,e=t.reduce(((t,e)=>t+e.length+1),-1)){let i=0;for(let e of t)i+=e.lines;if(i<32){let i=[];for(let e of t)e.flatten(i);return new w(i,e)}let n=Math.max(32,i>>5),s=n<<1,r=n>>1,o=[],h=0,l=-1,a=[];function c(t){let e;if(t.lines>s&&t instanceof v)for(let e of t.children)c(e);else t.lines>r&&(h>r||!h)?(u(),o.push(t)):t instanceof w&&h&&(e=a[a.length-1])instanceof w&&t.lines+e.lines<=32?(h+=t.lines,l+=t.length+1,a[a.length-1]=new w(e.text.concat(t.text),e.length+1+t.length)):(h+t.lines>n&&u(),h+=t.lines,l+=t.length+1,a.push(t))}function u(){0!=h&&(o.push(1==a.length?a[0]:v.from(a,l)),l=-1,h=a.length=0)}for(let e of t)c(e);return u(),1==o.length?o[0]:new v(o,e)}}function y(t,e,i=0,n=1e9){for(let s=0,r=0,o=!0;r<t.length&&s<=n;r++){let h=t[r],l=s+h.length;l>=i&&(l>n&&(h=h.slice(0,n-s)),s<i&&(h=h.slice(i-s)),o?(e[e.length-1]+=h,o=!1):e.push(h)),s=l+1}return e}function S(t,e,i){return y(t,[""],e,i)}m.empty=new w([""],0);class b{constructor(t,e=1){this.dir=e,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[e>0?0:t instanceof w?t.text.length:t.children.length]}next(t=0){for(;;){let e=this.nodes.length-1;if(e<0)return this.done=!0,this.value="",this.lineBreak=!1,this;let i=this.nodes[e],n=this.offsets[e],s=i instanceof w?i.text.length:i.children.length;if(n==(this.dir>0?s:0))this.nodes.pop(),this.offsets.pop();else if(this.lineBreak||n==(this.dir>0?0:s))if(i instanceof w){let s=i.text[n-(this.dir<0?1:0)];if(this.offsets[e]=n+=this.dir,this.lineBreak=!1,s.length>Math.max(0,t))return this.value=0==t?s:this.dir>0?s.slice(t):s.slice(0,s.length-t),this;t-=s.length}else{let s=i.children[this.dir>0?n:n-1];this.offsets[e]=n+this.dir,this.lineBreak=!1,t>s.length?t-=s.length:(this.nodes.push(s),this.offsets.push(this.dir>0?0:s instanceof w?s.text.length:s.children.length))}else{if(this.lineBreak=!0,0==t)return this.value="\n",this;t--}}}}class x{constructor(t,e,i){this.value="",this.cursor=new b(t,e>i?-1:1),e>i?(this.skip=t.length-e,this.limit=e-i):(this.skip=e,this.limit=i-e)}next(t=0){if(this.limit<=0)this.limit=-1;else{let{value:e,lineBreak:i,done:n}=this.cursor.next(this.skip+t);this.skip=0,this.value=e;let s=i?1:e.length;s>this.limit&&(this.value=this.cursor.dir>0?e.slice(0,this.limit):e.slice(s-this.limit)),n||0==this.value.length?this.limit=-1:this.limit-=this.value.length}return this}get lineBreak(){return this.cursor.lineBreak}get done(){return this.limit<0}}class k{constructor(t,e,i,n){this.from=t,this.to=e,this.number=i,this.text=n}get length(){return this.to-this.from}}},19753:(t,e,i)=>{"use strict";i.d(e,{kH:()=>ut,p:()=>ft,Nm:()=>Xt,tk:()=>Di,BF:()=>Pt,lg:()=>It,Uw:()=>$i,ZO:()=>Qi,$f:()=>Ii,$1:()=>Wi});for(var n=i(77885),s=i(23414),r=i(62038),o=i(13764),h={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:"'",229:"q"},l={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"',229:"Q"},a="undefined"!=typeof navigator&&/Chrome\/(\d+)/.exec(navigator.userAgent),c="undefined"!=typeof navigator&&/Apple Computer/.test(navigator.vendor),u="undefined"!=typeof navigator&&/Gecko\/\d+/.test(navigator.userAgent),f="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),d="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),g=a&&(f||+a[1]<57)||u&&f,p=0;p<10;p++)h[48+p]=h[96+p]=String(p);for(p=1;p<=24;p++)h[p+111]="F"+p;for(p=65;p<=90;p++)h[p]=String.fromCharCode(p+32),l[p]=String.fromCharCode(p);for(var m in h)l.hasOwnProperty(m)||(l[m]=h[m]);function w(t){return t.getSelection?t.getSelection():document.getSelection()}function v(t,e){return!!e&&t.contains(1!=e.nodeType?e.parentNode:e)}function y(t,e){if(!e.anchorNode)return!1;try{return v(t,e.anchorNode)}catch(t){return!1}}function S(t){return 3==t.nodeType?L(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function b(t,e,i,n){return!!i&&(k(t,e,i,n,-1)||k(t,e,i,n,1))}function x(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function k(t,e,i,n,s){for(;;){if(t==i&&e==n)return!0;if(e==(s<0?0:A(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=x(t)+(s<0?0:1),t=i}else{if(1!=t.nodeType)return!1;t=t.childNodes[e+(s<0?-1:0)],e=s<0?A(t):0}}}function A(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}const M={left:0,right:0,top:0,bottom:0};function D(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function O(t){return{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}class C{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}set(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset}}let T,E=null;function R(t){if(t.setActive)return t.setActive();if(E)return t.focus(E);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==E?{get preventScroll(){return E={preventScroll:!0},!0}}:void 0),!E){E=!1;for(let t=0;t<e.length;){let i=e[t++],n=e[t++],s=e[t++];i.scrollTop!=n&&(i.scrollTop=n),i.scrollLeft!=s&&(i.scrollLeft=s)}}}function L(t,e,i=e){let n=T||(T=document.createRange());return n.setEnd(t,i),n.setStart(t,e),n}class P{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new P(t.parentNode,x(t),e)}static after(t,e){return new P(t.parentNode,x(t)+1,e)}}const B=[];class N{constructor(){this.parent=null,this.dom=null,this.dirty=2}get editorView(){if(!this.parent)throw new Error("Accessing view in orphan content view");return this.parent.editorView}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(t){let e=this.posAtStart;for(let i of this.children){if(i==t)return e;e+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}coordsAt(t,e){return null}sync(t){var e;if(2&this.dirty){let i=this.dom,n=null;for(let s of this.children){if(s.dirty){let r=n?n.nextSibling:i.firstChild;s.dom||!r||(null===(e=N.get(r))||void 0===e?void 0:e.parent)||s.reuseDOM(r),s.sync(t),s.dirty=0}t&&t.node==i&&n!=s.dom&&(t.written=!0),V(i,n,s.dom),n=s.dom}let s=n?n.nextSibling:i.firstChild;for(s&&t&&t.node==i&&(t.written=!0);s;)s=I(s)}else if(1&this.dirty)for(let e of this.children)e.dirty&&(e.sync(t),e.dirty=0)}reuseDOM(t){return!1}localPosFromDOM(t,e){let i;if(t==this.dom)i=this.dom.childNodes[e];else{let n=0==A(t)?0:0==e?-1:1;for(;;){let e=t.parentNode;if(e==this.dom)break;0==n&&e.firstChild!=e.lastChild&&(n=t==e.firstChild?-1:1),t=e}i=n<0?t:t.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!N.get(i);)i=i.nextSibling;if(!i)return this.length;for(let t=0,e=0;;t++){let n=this.children[t];if(n.dom==i)return e;e+=n.length+n.breakAfter}}domBoundsAround(t,e,i=0){let n=-1,s=-1,r=-1,o=-1;for(let h=0,l=i,a=i;h<this.children.length;h++){let i=this.children[h],c=l+i.length;if(l<t&&c>e)return i.domBoundsAround(t,e,l);if(c>=t&&-1==n&&(n=h,s=l),l>e&&i.dom.parentNode==this.dom){r=h,o=a;break}a=c,l=c+i.breakAfter}return{from:s,to:o<0?i+this.length:o,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:r<this.children.length&&r>=0?this.children[r].dom:null}}markDirty(t=!1){2&this.dirty||(this.dirty|=2,this.markParentsDirty(t))}markParentsDirty(t){for(let e=this.parent;e;e=e.parent){if(t&&(e.dirty|=2),1&e.dirty)return;e.dirty|=1,t=!1}}setParent(t){this.parent!=t&&(this.parent=t,this.dirty&&this.markParentsDirty(!0))}setDOM(t){this.dom=t,t.cmView=this}get rootView(){for(let t=this;;){let e=t.parent;if(!e)return t;t=e}}replaceChildren(t,e,i=B){this.markDirty();for(let i=t;i<e;i++)this.children[i].parent=null;this.children.splice(t,e-t,...i);for(let t=0;t<i.length;t++)i[t].setParent(this)}ignoreMutation(t){return!1}ignoreEvent(t){return!1}childCursor(t=this.length){return new H(this.children,t,this.children.length)}childPos(t,e=1){return this.childCursor().findPos(t,e)}toString(){let t=this.constructor.name.replace("View","");return t+(this.children.length?"("+this.children.join()+")":this.length?"["+("Text"==t?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(t){return t.cmView}}function I(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}function V(t,e,i){let n=e?e.nextSibling:t.firstChild;if(i.parentNode==t)for(;n!=i;)n=I(n);else t.insertBefore(i,n)}N.prototype.breakAfter=0;class H{constructor(t,e,i){this.children=t,this.pos=e,this.i=i,this.off=0}findPos(t,e=1){for(;;){if(t>this.pos||t==this.pos&&(e>0||0==this.i||this.children[this.i-1].breakAfter))return this.off=t-this.pos,this;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}}let[W,F]="undefined"!=typeof navigator?[navigator,document]:[{userAgent:"",vendor:"",platform:""},{documentElement:{style:{}}}];const z=/Edge\/(\d+)/.exec(W.userAgent),q=/MSIE \d/.test(W.userAgent),j=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(W.userAgent),$=!!(q||j||z),J=!$&&/gecko\/(\d+)/i.test(W.userAgent),_=!$&&/Chrome\/(\d+)/.exec(W.userAgent),G="webkitFontSmoothing"in F.documentElement.style,K=!$&&/Apple Computer/.test(W.vendor);var U={mac:/Mac/.test(W.platform),ie:$,ie_version:q?F.documentMode||6:j?+j[1]:z?+z[1]:0,gecko:J,gecko_version:J?+(/Firefox\/(\d+)/.exec(W.userAgent)||[0,0])[1]:0,chrome:!!_,chrome_version:_?+_[1]:0,ios:K&&(/Mobile\/\w+/.test(W.userAgent)||W.maxTouchPoints>2),android:/Android\b/.test(W.userAgent),webkit:G,safari:K,webkit_version:G?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:null!=F.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};const Y=[];class X extends N{become(t){return!1}getSide(){return 0}}X.prototype.children=Y;class Q extends X{constructor(t){super(),this.text=t}get length(){return this.text.length}createDOM(t){this.setDOM(t||document.createTextNode(this.text))}sync(t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(t){return 3==t.nodeType&&(this.createDOM(t),!0)}merge(t,e,i){return(!i||i instanceof Q&&!(this.length-(e-t)+i.length>256))&&(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}slice(t){return new Q(this.text.slice(t))}localPosFromDOM(t,e){return t==this.dom?e:e?this.text.length:0}domAtPos(t){return new P(this.dom,t)}domBoundsAround(t,e,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(t,e){return tt(this.dom,t,e)}}class Z extends X{constructor(t,e=[],i=0){super(),this.mark=t,this.children=e,this.length=i;for(let t of e)t.setParent(this)}createDOM(){let t=document.createElement(this.mark.tagName);if(this.mark.class&&(t.className=this.mark.class),this.mark.attrs)for(let e in this.mark.attrs)t.setAttribute(e,this.mark.attrs[e]);this.setDOM(t)}sync(t){this.dom||this.createDOM(),super.sync(t)}merge(t,e,i,n,s){return(!i||!(!(i instanceof Z&&i.mark.eq(this.mark))||t&&n<=0||e<this.length&&s<=0))&&(nt(this,t,e,i?i.children:Y,n-1,s-1),this.markDirty(),!0)}slice(t){return new Z(this.mark,function(t,e){let i=[],n=0;for(let s of t){let t=n+s.length;t>e&&i.push(n<e?s.slice(e-n):s),n=t}return i}(this.children,t),this.length-t)}domAtPos(t){return st(this.dom,this.children,t)}coordsAt(t,e){return ot(this,t,e)}}function tt(t,e,i){let n=t.nodeValue.length;e>n&&(e=n);let s=e,r=e,o=0;0==e&&i<0||e==n&&i>=0?U.chrome||U.gecko||(e?(s--,o=1):(r++,o=-1)):i<0?s--:r++;let h=L(t,s,r).getClientRects();if(!h.length)return M;let l=h[(o?o<0:i>=0)?0:h.length-1];return U.safari&&!o&&0==l.width&&(l=Array.prototype.find.call(h,(t=>t.width))||l),o?D(l,o<0):l}class et extends X{constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i}static create(t,e,i){return new(t.customView||et)(t,e,i)}slice(t){return et.create(this.widget,this.length-t,this.side)}sync(){this.dom&&this.widget.updateDOM(this.dom)||(this.setDOM(this.widget.toDOM(this.editorView)),this.dom.contentEditable="false")}getSide(){return this.side}merge(t,e,i,n,s){return!(i&&(!(i instanceof et&&this.widget.compare(i.widget))||t>0&&n<=0||e<this.length&&s<=0))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}become(t){return t.length==this.length&&t instanceof et&&t.side==this.side&&this.widget.constructor==t.widget.constructor&&(this.widget.eq(t.widget)||this.markDirty(!0),this.widget=t.widget,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get overrideDOMText(){if(0==this.length)return s.xv.empty;let t=this;for(;t.parent;)t=t.parent;let e=t.editorView,i=e&&e.state.doc,n=this.posAtStart;return i?i.slice(n,n+this.length):s.xv.empty}domAtPos(t){return 0==t?P.before(this.dom):P.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let i=this.dom.getClientRects(),n=null;if(!i.length)return M;for(let e=t>0?i.length-1:0;n=i[e],!(t>0?0==e:e==i.length-1||n.top<n.bottom);e+=t>0?-1:1);return 0==t&&e>0||t==this.length&&e<=0?n:D(n,0==t)}}class it extends et{domAtPos(t){return new P(this.widget.text,t)}sync(){this.dom||this.setDOM(this.widget.toDOM())}localPosFromDOM(t,e){return e?3==t.nodeType?Math.min(e,this.length):this.length:0}ignoreMutation(){return!1}get overrideDOMText(){return null}coordsAt(t,e){return tt(this.widget.text,t,e)}}function nt(t,e,i,n,s,r){let o=t.childCursor(),{i:h,off:l}=o.findPos(i,1),{i:a,off:c}=o.findPos(e,-1),u=e-i;for(let t of n)u+=t.length;t.length+=u;let{children:f}=t;if(a==h&&c){let t=f[a];if(1==n.length&&t.merge(c,l,n[0],s,r))return;if(0==n.length)return void t.merge(c,l,null,s,r);let e=t.slice(l);e.merge(0,0,n[n.length-1],0,r)?n[n.length-1]=e:n.push(e),h++,r=l=0}if(l){let t=f[h];n.length&&t.merge(0,l,n[n.length-1],0,r)?(n.pop(),r=n.length?0:s):t.merge(0,l,null,0,0)}else h<f.length&&n.length&&f[h].merge(0,0,n[n.length-1],0,r)&&(n.pop(),r=n.length?0:s);if(c){let t=f[a];n.length&&t.merge(c,t.length,n[0],s,0)?(n.shift(),s=n.length?0:r):t.merge(c,t.length,null,0,0),a++}else if(a&&n.length){let t=f[a-1];t.merge(t.length,t.length,n[0],s,0)&&(n.shift(),s=n.length?0:r)}for(;a<h&&n.length&&f[h-1].become(n[n.length-1]);)n.pop(),h--,r=n.length?0:s;for(;a<h&&n.length&&f[a].become(n[0]);)n.shift(),a++,s=n.length?0:r;!n.length&&a&&h<f.length&&s&&r&&f[h].merge(0,0,f[a-1],s,r)&&a--,(n.length||a!=h)&&t.replaceChildren(a,h,n)}function st(t,e,i){let n=0;for(let s=0;n<e.length;n++){let r=e[n],o=s+r.length;if(!(o==s&&r.getSide()<=0)){if(i>s&&i<o&&r.dom.parentNode==t)return r.domAtPos(i-s);if(i<=s)break;s=o}}for(;n>0;n--){let i=e[n-1].dom;if(i.parentNode==t)return P.after(i)}return new P(t,0)}function rt(t,e,i){let n,{children:s}=t;i>0&&e instanceof Z&&s.length&&(n=s[s.length-1])instanceof Z&&n.mark.eq(e.mark)?rt(n,e.children[0],i-1):(s.push(e),e.setParent(t)),t.length+=e.length}function ot(t,e,i){for(let n=0,s=0;s<t.children.length;s++){let r=t.children[s],o=n+r.length;if(!(o==n&&r.getSide()<=0)){if(i<=0||o==t.length?o>=e:o>e)return r.coordsAt(e-n,i);n=o}}let n=t.dom.lastChild;if(!n)return t.dom.getBoundingClientRect();let s=S(n);return s[s.length-1]}function ht(t,e){for(let i in t)"class"==i&&e.class?e.class+=" "+t.class:"style"==i&&e.style?e.style+=";"+t.style:e[i]=t[i];return e}function lt(t,e){if(t==e)return!0;if(!t||!e)return!1;let i=Object.keys(t),n=Object.keys(e);if(i.length!=n.length)return!1;for(let s of i)if(-1==n.indexOf(s)||t[s]!==e[s])return!1;return!0}function at(t,e,i){if(e)for(let n in e)i&&n in i||t.removeAttribute(n);if(i)for(let n in i)e&&e[n]==i[n]||t.setAttribute(n,i[n])}class ct{eq(t){return!1}updateDOM(t){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return-1}ignoreEvent(t){return!0}get customView(){return null}}var ut=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(ut||(ut={}));class ft extends o.uU{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 dt(t)}static widget(t){let e=t.side||0;return t.block&&(e+=200000001*(e>0?1:-1)),new pt(t,e,e,!!t.block,t.widget||null,!1)}static replace(t){let e=!!t.block,{start:i,end:n}=mt(t);return new pt(t,e?-2e8*(i?2:1):1e8*(i?-1:1),e?2e8*(n?2:1):1e8*(n?1:-1),e,t.widget||null,!0)}static line(t){return new gt(t)}static set(t,e=!1){return o.Xs.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}ft.none=o.Xs.empty;class dt extends ft{constructor(t){let{start:e,end:i}=mt(t);super(1e8*(e?-1:1),1e8*(i?1:-1),null,t),this.tagName=t.tagName||"span",this.class=t.class||"",this.attrs=t.attributes||null}eq(t){return this==t||t instanceof dt&&this.tagName==t.tagName&&this.class==t.class&<(this.attrs,t.attrs)}range(t,e=t){if(t>=e)throw new RangeError("Mark decorations may not be empty");return super.range(t,e)}}dt.prototype.point=!1;class gt extends ft{constructor(t){super(-1e8,-1e8,null,t)}eq(t){return t instanceof gt&<(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw new RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}}gt.prototype.mapMode=n.gc.TrackBefore,gt.prototype.point=!0;class pt extends ft{constructor(t,e,i,s,r,o){super(e,i,r,t),this.block=s,this.isReplace=o,this.mapMode=s?e<0?n.gc.TrackBefore:n.gc.TrackAfter:n.gc.TrackDel}get type(){return this.startSide<this.endSide?ut.WidgetRange:this.startSide<0?ut.WidgetBefore:ut.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&this.widget.estimatedHeight>=5}eq(t){return t instanceof pt&&(e=this.widget,i=t.widget,e==i||!!(e&&i&&e.compare(i)))&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide;var e,i}range(t,e=t){if(this.isReplace&&(t>e||t==e&&this.startSide>0&&this.endSide<0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}}function mt(t){let{inclusiveStart:e,inclusiveEnd:i}=t;return null==e&&(e=t.inclusive),null==i&&(i=t.inclusive),{start:e||!1,end:i||!1}}function wt(t,e,i,n=0){let s=i.length-1;s>=0&&i[s]+n>t?i[s]=Math.max(i[s],e):i.push(t,e)}pt.prototype.point=!0;class vt extends N{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(t,e,i,n,s,r){if(i){if(!(i instanceof vt))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),nt(this,t,e,i?i.children:yt,s,r),!0}split(t){let e=new vt;if(e.breakAfter=this.breakAfter,0==this.length)return e;let{i,off:n}=this.childPos(t);n&&(e.append(this.children[i].slice(n),0),this.children[i].merge(n,this.children[i].length,null,0,0),i++);for(let t=i;t<this.children.length;t++)e.append(this.children[t],0);for(;i>0&&0==this.children[i-1].length;)this.children[i-1].parent=null,i--;return this.children.length=i,this.markDirty(),this.length=t,e}transferDOM(t){this.dom&&(t.setDOM(this.dom),t.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(t){lt(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){rt(this,t,e)}addLineDeco(t){let e=t.spec.attributes;e&&(this.attrs=ht(e,this.attrs||{}))}domAtPos(t){return st(this.dom,this.children,t)}sync(t){this.dom||(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),void 0!==this.prevAttrs&&(at(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t);let e=this.dom.lastChild;if(!e||"BR"!=e.nodeName&&N.get(e)instanceof et){let t=document.createElement("BR");t.cmIgnore=!0,this.dom.appendChild(t)}}measureTextSize(){if(0==this.children.length||this.length>20)return null;let t=0;for(let e of this.children){if(!(e instanceof Q))return null;let i=S(e.dom);if(1!=i.length)return null;t+=i[0].width}return{lineHeight:this.dom.getBoundingClientRect().height,charWidth:t/this.length}}coordsAt(t,e){return ot(this,t,e)}match(t){return!1}get type(){return ut.Text}static find(t,e){for(let i=0,n=0;;i++){let s=t.children[i],r=n+s.length;if(r>=e){if(s instanceof vt)return s;if(s.length)return null}n=r+s.breakAfter}}}const yt=[];class St extends N{constructor(t,e,i){super(),this.widget=t,this.length=e,this.type=i,this.breakAfter=0}merge(t,e,i,n,s,r){return!(i&&(!(i instanceof St&&this.widget.compare(i.widget))||t>0&&s<=0||e<this.length&&r<=0))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}domAtPos(t){return 0==t?P.before(this.dom):P.after(this.dom,t==this.length)}split(t){let e=this.length-t;return this.length=t,new St(this.widget,e,this.type)}get children(){return yt}sync(){this.dom&&this.widget.updateDOM(this.dom)||(this.setDOM(this.widget.toDOM(this.editorView)),this.dom.contentEditable="false")}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):s.xv.empty}domBoundsAround(){return null}match(t){return t instanceof St&&t.type==this.type&&t.widget.constructor==this.widget.constructor&&(t.widget.eq(this.widget)||this.markDirty(!0),this.widget=t.widget,this.length=t.length,this.breakAfter=t.breakAfter,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}}class bt{constructor(t,e,i){this.doc=t,this.pos=e,this.end=i,this.content=[],this.curLine=null,this.breakAtStart=0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=t.iter(),this.skip=e}posCovered(){if(0==this.content.length)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let t=this.content[this.content.length-1];return!(t.breakAfter||t instanceof St&&t.type==ut.WidgetBefore)}getLine(){return this.curLine||this.content.push(this.curLine=new vt),this.curLine}addWidget(t){this.curLine=null,this.content.push(t)}finish(){this.posCovered()||this.getLine()}wrapMarks(t,e){for(let i=e.length-1;i>=0;i--)t=new Z(e[i],[t],t.length);return t}buildText(t,e,i){for(;t>0;){if(this.textOff==this.text.length){let{value:e,lineBreak:i,done:n}=this.cursor.next(this.skip);if(this.skip=0,n)throw new Error("Ran out of text content when drawing inline views");if(i){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.curLine=null,t--;continue}this.text=e,this.textOff=0}let n=Math.min(this.text.length-this.textOff,t,512);this.getLine().append(this.wrapMarks(new Q(this.text.slice(this.textOff,this.textOff+n)),e),i),this.textOff+=n,t-=n,i=0}}span(t,e,i,n){this.buildText(e-t,i,n),this.pos=e,this.openStart<0&&(this.openStart=n)}point(t,e,i,n,s){let r=e-t;if(i instanceof pt)if(i.block){let{type:t}=i;t!=ut.WidgetAfter||this.posCovered()||this.getLine(),this.addWidget(new St(i.widget||new xt("div"),r,t))}else{let t=this.wrapMarks(et.create(i.widget||new xt("span"),r,i.startSide),n);this.getLine().append(t,s)}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);r&&(this.textOff+r<=this.text.length?this.textOff+=r:(this.skip+=r-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=e),this.openStart<0&&(this.openStart=s)}static build(t,e,i,n){let s=new bt(t,e,i);return s.openEnd=o.Xs.spans(n,e,i,s),s.openStart<0&&(s.openStart=s.openEnd),s.finish(),s}}class xt extends ct{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}}const kt=[],At=n.r$.define(),Mt=n.r$.define(),Dt=n.r$.define(),Ot=n.r$.define(),Ct=n.r$.define(),Tt=n.r$.define();function Et(t,e,i){let n=t.facet(Ot);n.length?n[0](e):window.onerror?window.onerror(String(e),i,void 0,void 0,e):i?console.error(i+":",e):console.error(e)}const Rt=n.r$.define({combine:t=>!t.length||t[0]});class Lt{constructor(t,e){this.field=t,this.get=e}}class Pt{from(t){return new Lt(this,t)}static define(){return new Pt}}Pt.decorations=Pt.define(),Pt.scrollMargins=Pt.define();let Bt=0;const Nt=n.r$.define();class It{constructor(t,e,i){this.id=t,this.create=e,this.fields=i,this.extension=Nt.of(this)}static define(t,e){let{eventHandlers:i,provide:n,decorations:s}=e||{},r=[];if(n)for(let t of Array.isArray(n)?n:[n])r.push(t);return i&&r.push(Vt.from((t=>({plugin:t,handlers:i})))),s&&r.push(Pt.decorations.from(s)),new It(Bt++,t,r)}static fromClass(t,e){return It.define((e=>new t(e)),e)}}const Vt=Pt.define();class Ht{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}takeField(t,e){for(let{field:i,get:n}of this.spec.fields)i==t&&e.push(n(this.value))}update(t){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,!this.value.update)return this;try{this.value.update(t)}catch(e){if(Et(t.state,e,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(t){}return Ht.dummy}}}else try{this.value=this.spec.create(t)}catch(e){return Et(t.state,e,"CodeMirror plugin crashed"),Ht.dummy}return this}destroy(t){var e;if(null===(e=this.value)||void 0===e?void 0:e.destroy)try{this.value.destroy()}catch(e){Et(t.state,e,"CodeMirror plugin crashed")}}}Ht.dummy=new Ht(It.define((()=>({}))));const Wt=n.r$.define({combine:t=>t.reduce(((t,e)=>ht(e,t)),{})}),Ft=n.r$.define({combine:t=>t.reduce(((t,e)=>ht(e,t)),{})}),zt=n.r$.define(),qt=n.r$.define();class jt{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new jt(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let n=t[e-1];if(!(n.fromA>i.toA)){if(n.toA<i.fromA)break;i=i.join(n),t.splice(e-1,1)}}return t.splice(e,0,i),t}static extendWithRanges(t,e){if(0==e.length)return t;let i=[];for(let n=0,s=0,r=0,o=0;;n++){let h=n==t.length?null:t[n],l=r-o,a=h?h.fromB:1e9;for(;s<e.length&&e[s]<a;){let t=e[s],n=e[s+1],r=Math.max(o,t),h=Math.min(a,n);if(r<=h&&new jt(r+l,h+l,r,h).addToSet(i),n>a)break;s+=2}if(!h)return i;new jt(h.fromA,h.toA,h.fromB,h.toB).addToSet(i),r=h.toA,o=h.toB}}}class $t{constructor(t,e,i=kt){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=n.as.empty(this.startState.doc.length);for(let t of i)this.changes=this.changes.compose(t.changes);let s=[];this.changes.iterChangedRanges(((t,e,i,n)=>s.push(new jt(t,e,i,n)))),this.changedRanges=s;let r=t.hasFocus;r!=t.inputState.notifiedFocused&&(t.inputState.notifiedFocused=r,this.flags|=1),this.docChanged&&(this.flags|=2)}get viewportChanged(){return(4&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(18&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return this.transactions.some((t=>t.docChanged))}get selectionSet(){return this.transactions.some((t=>t.selection))}get empty(){return 0==this.flags&&0==this.transactions.length}}class Jt extends N{constructor(t){super(),this.view=t,this.compositionDeco=ft.none,this.decorations=[],this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.setDOM(t.contentDOM),this.children=[new vt],this.children[0].setParent(this),this.updateInner([new jt(0,0,0,t.state.doc.length)],this.updateDeco(),0)}get root(){return this.view.root}get editorView(){return this.view}get length(){return this.view.state.doc.length}update(t){let e=t.changedRanges;this.minWidth>0&&e.length&&(e.every((({fromA:t,toA:e})=>e<this.minWidthFrom||t>this.minWidthTo))?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=0),this.view.inputState.composing<0?this.compositionDeco=ft.none:t.transactions.length&&(this.compositionDeco=function(t,e){let i=t.observer.selectionRange,n=i.focusNode&&Kt(i.focusNode,i.focusOffset,0);if(!n)return ft.none;let s,r,o=t.docView.nearest(n),h=n;if(o instanceof X){for(;o.parent instanceof X;)o=o.parent;s=o.posAtStart,r=s+o.length,h=o.dom}else{if(!(o instanceof vt))return ft.none;{for(;h.parentNode!=o.dom;)h=h.parentNode;let t=h.previousSibling;for(;t&&!N.get(t);)t=t.previousSibling;s=r=t?N.get(t).posAtEnd:o.posAtStart}}let l=e.mapPos(s,1),a=Math.max(l,e.mapPos(r,-1)),c=n.nodeValue,{state:u}=t;if(a-l<c.length)if(u.sliceDoc(l,Math.min(u.doc.length,l+c.length))==c)a=l+c.length;else{if(u.sliceDoc(Math.max(0,a-c.length),a)!=c)return ft.none;l=a-c.length}else if(u.sliceDoc(l,a)!=c)return ft.none;return ft.set(ft.replace({widget:new Gt(h,n)}).range(l,a))}(this.view,t.changes));let i=(U.ie||U.chrome)&&!this.compositionDeco.size&&t&&t.state.doc.lines!=t.startState.doc.lines,s=this.decorations,r=this.updateDeco(),h=function(t,e,i){let n=new Yt;return o.Xs.compare(t,e,i,n),n.changes}(s,r,t.changes);e=jt.extendWithRanges(e,h);let l=t.transactions.some((t=>"pointerselection"==t.annotation(n.YW.userEvent)));return 0==this.dirty&&0==e.length&&!(12&t.flags)&&t.state.selection.main.from>=this.view.viewport.from&&t.state.selection.main.to<=this.view.viewport.to?(this.updateSelection(i,l),!1):(this.updateInner(e,r,t.startState.doc.length,i,l),!0)}updateInner(t,e,i,n=!1,s=!1){this.updateChildren(t,e,i),this.view.observer.ignore((()=>{this.dom.style.height=this.view.viewState.domHeight+"px",this.dom.style.minWidth=this.minWidth?this.minWidth+"px":"";let t=U.chrome?{node:w(this.view.root).focusNode,written:!1}:void 0;this.sync(t),this.dirty=0,(null==t?void 0:t.written)&&(n=!0),this.updateSelection(n,s),this.dom.style.height=""}))}updateChildren(t,e,i){let n=this.childCursor(i);for(let i=t.length-1;;i--){let s=i>=0?t[i]:null;if(!s)break;let{fromA:r,toA:o,fromB:h,toB:l}=s,{content:a,breakAtStart:c,openStart:u,openEnd:f}=bt.build(this.view.state.doc,h,l,e),{i:d,off:g}=n.findPos(o,1),{i:p,off:m}=n.findPos(r,-1);this.replaceRange(p,m,d,g,a,c,u,f)}}replaceRange(t,e,i,n,s,r,o,h){let l=this.children[t],a=s.length?s[s.length-1]:null,c=a?a.breakAfter:r;if(t==i&&!r&&!c&&s.length<2&&l.merge(e,n,s.length?a:null,0==e,o,h))return;let u=this.children[i];for(n<u.length||u.children.length&&0==u.children[u.children.length-1].length?(t==i&&(u=u.split(n),n=0),!c&&a&&u.merge(0,n,a,!0,0,h)?s[s.length-1]=u:((n||u.children.length&&0==u.children[0].length)&&u.merge(0,n,null,!1,0,h),s.push(u))):u.breakAfter&&(a?a.breakAfter=1:r=1),i++,l.breakAfter=r,e>0&&(!r&&s.length&&l.merge(e,l.length,s[0],!1,o,0)?l.breakAfter=s.shift().breakAfter:(e<l.length||l.children.length&&0==l.children[l.children.length-1].length)&&l.merge(e,l.length,null,!1,o,0),t++);t<i&&s.length;)if(this.children[i-1].match(s[s.length-1]))i--,s.pop();else{if(!this.children[t].match(s[0]))break;t++,s.shift()}(t<i||s.length)&&this.replaceChildren(t,i,s)}updateSelection(t=!1,e=!1){if(!e&&!this.mayControlSelection())return;let i=this.view.state.selection.main,n=this.domAtPos(i.anchor),s=i.empty?n:this.domAtPos(i.head);if(U.gecko&&i.empty&&(1==(r=n).node.nodeType&&r.node.firstChild&&(0==r.offset||"false"==r.node.childNodes[r.offset-1].contentEditable)&&(r.offset<r.node.childNodes.length||"false"==r.node.childNodes[r.offset].contentEditable))){let e=document.createTextNode("");this.view.observer.ignore((()=>n.node.insertBefore(e,n.node.childNodes[n.offset]||null))),n=s=new P(e,0),t=!0}var r;let o=this.view.observer.selectionRange;(t||!o.focusNode||U.gecko&&i.empty&&Ut(o.focusNode,o.focusOffset)||!b(n.node,n.offset,o.anchorNode,o.anchorOffset)||!b(s.node,s.offset,o.focusNode,o.focusOffset))&&(this.view.observer.ignore((()=>{let t=w(this.root);if(i.empty){if(U.gecko){let t=Ut(n.node,n.offset);if(t&&3!=t){let e=Kt(n.node,n.offset,1==t?1:-1);e&&(n=new P(e,1==t?0:e.nodeValue.length))}}t.collapse(n.node,n.offset),null!=i.bidiLevel&&null!=o.cursorBidiLevel&&(o.cursorBidiLevel=i.bidiLevel)}else if(t.extend)t.collapse(n.node,n.offset),t.extend(s.node,s.offset);else{let e=document.createRange();i.anchor>i.head&&([n,s]=[s,n]),e.setEnd(s.node,s.offset),e.setStart(n.node,n.offset),t.removeAllRanges(),t.addRange(e)}})),this.view.observer.setSelectionRange(n,s)),this.impreciseAnchor=n.precise?null:new P(o.anchorNode,o.anchorOffset),this.impreciseHead=s.precise?null:new P(o.focusNode,o.focusOffset)}enforceCursorAssoc(){let t=this.view.state.selection.main,e=w(this.root);if(!t.empty||!t.assoc||!e.modify)return;let i=vt.find(this,t.head);if(!i)return;let n=i.posAtStart;if(t.head==n||t.head==n+i.length)return;let s=this.coordsAt(t.head,-1),r=this.coordsAt(t.head,1);if(!s||!r||s.bottom>r.top)return;let o=this.domAtPos(t.head+t.assoc);e.collapse(o.node,o.offset),e.modify("move",t.assoc<0?"forward":"backward","lineboundary")}mayControlSelection(){return this.view.state.facet(Rt)?this.root.activeElement==this.dom:y(this.dom,this.view.observer.selectionRange)}nearest(t){for(let e=t;e;){let t=N.get(e);if(t&&t.rootView==this)return t;e=e.parentNode}return null}posFromDOM(t,e){let i=this.nearest(t);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(t,e)+i.posAtStart}domAtPos(t){let{i:e,off:i}=this.childCursor().findPos(t,-1);for(;e<this.children.length-1;){let t=this.children[e];if(i<t.length||t instanceof vt)break;e++,i=0}return this.children[e].domAtPos(i)}coordsAt(t,e){for(let i=this.length,n=this.children.length-1;;n--){let s=this.children[n],r=i-s.breakAfter-s.length;if(t>r||t==r&&(s.type==ut.Text||!n||this.children[n-1].breakAfter))return s.coordsAt(t-r,e);i=r}}measureVisibleLineHeights(){let t=[],{from:e,to:i}=this.view.viewState.viewport,n=Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1;for(let s=0,r=0;r<this.children.length;r++){let o=this.children[r],h=s+o.length;if(h>i)break;if(s>=e){t.push(o.dom.getBoundingClientRect().height);let e=o.dom.scrollWidth;e>n&&(this.minWidth=n=e,this.minWidthFrom=s,this.minWidthTo=h)}s=h+o.breakAfter}return t}measureTextSize(){for(let t of this.children)if(t instanceof vt){let e=t.measureTextSize();if(e)return e}let t,e,i=document.createElement("div");return i.className="cm-line",i.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore((()=>{this.dom.appendChild(i);let n=S(i.firstChild)[0];t=i.getBoundingClientRect().height,e=n?n.width/27:7,i.remove()})),{lineHeight:t,charWidth:e}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new H(this.children,t,e)}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let i=0,n=0;;n++){let s=n==e.viewports.length?null:e.viewports[n],r=s?s.from-1:this.length;if(r>i){let n=e.lineAt(r,0).bottom-e.lineAt(i,0).top;t.push(ft.replace({widget:new _t(n),block:!0,inclusive:!0}).range(i,r))}if(!s)break;i=s.to+1}return ft.set(t)}updateDeco(){return this.decorations=[this.computeBlockGapDeco(),this.view.viewState.lineGapDeco,this.compositionDeco,...this.view.state.facet(zt),...this.view.pluginField(Pt.decorations)]}scrollPosIntoView(t,e){let i=this.coordsAt(t,e);if(!i)return;let n=0,s=0,r=0,o=0;for(let t of this.view.pluginField(Pt.scrollMargins))if(t){let{left:e,right:i,top:h,bottom:l}=t;null!=e&&(n=Math.max(n,e)),null!=i&&(s=Math.max(s,i)),null!=h&&(r=Math.max(r,h)),null!=l&&(o=Math.max(o,l))}!function(t,e){let i=t.ownerDocument.defaultView;for(let n=t.parentNode;n;)if(1==n.nodeType){let t,s=n==document.body;if(s)t=O(i);else{if(n.scrollHeight<=n.clientHeight&&n.scrollWidth<=n.clientWidth){n=n.parentNode;continue}let e=n.getBoundingClientRect();t={left:e.left,right:e.left+n.clientWidth,top:e.top,bottom:e.top+n.clientHeight}}let r=0,o=0;if(e.top<t.top?o=-(t.top-e.top+5):e.bottom>t.bottom&&(o=e.bottom-t.bottom+5),e.left<t.left?r=-(t.left-e.left+5):e.right>t.right&&(r=e.right-t.right+5),r||o)if(s)i.scrollBy(r,o);else{if(o){let t=n.scrollTop;n.scrollTop+=o,o=n.scrollTop-t}if(r){let t=n.scrollLeft;n.scrollLeft+=r,r=n.scrollLeft-t}e={left:e.left-r,top:e.top-o,right:e.right-r,bottom:e.bottom-o}}if(s)break;n=n.assignedSlot||n.parentNode}else{if(11!=n.nodeType)break;n=n.host}}(this.dom,{left:i.left-n,top:i.top-r,right:i.right+s,bottom:i.bottom+o})}}class _t extends ct{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}}class Gt extends ct{constructor(t,e){super(),this.top=t,this.text=e}eq(t){return this.top==t.top&&this.text==t.text}toDOM(){return this.top}ignoreEvent(){return!1}get customView(){return it}}function Kt(t,e,i){for(;;){if(3==t.nodeType)return t;if(1==t.nodeType&&e>0&&i<=0)e=A(t=t.childNodes[e-1]);else{if(!(1==t.nodeType&&e<t.childNodes.length&&i>=0))return null;t=t.childNodes[e],e=0}}}function Ut(t,e){return 1!=t.nodeType?0:(e&&"false"==t.childNodes[e-1].contentEditable?1:0)|(e<t.childNodes.length&&"false"==t.childNodes[e].contentEditable?2:0)}class Yt{constructor(){this.changes=[]}compareRange(t,e){wt(t,e,this.changes)}comparePoint(t,e){wt(t,e,this.changes)}}var Xt=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(Xt||(Xt={}));const Qt=Xt.LTR,Zt=Xt.RTL;function te(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}const ee=te("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),ie=te("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),ne=Object.create(null),se=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),i=t.charCodeAt(1);ne[e]=i,ne[i]=-e}const re=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;class oe{constructor(t,e,i){this.from=t,this.to=e,this.level=i}get dir(){return this.level%2?Zt:Qt}side(t,e){return this.dir==e==t?this.to:this.from}static find(t,e,i,n){let s=-1;for(let r=0;r<t.length;r++){let o=t[r];if(o.from<=e&&o.to>=e){if(o.level==i)return r;(s<0||(0!=n?n<0?o.from<e:o.to>e:t[s].level>o.level))&&(s=r)}}if(s<0)throw new RangeError("Index out of range");return s}}const he=[];function le(t,e){let i=t.length,n=e==Qt?1:2,s=e==Qt?2:1;if(!t||1==n&&!re.test(t))return ae(i);for(let e=0,s=n,o=n;e<i;e++){let i=(r=t.charCodeAt(e))<=247?ee[r]:1424<=r&&r<=1524?2:1536<=r&&r<=1785?ie[r-1536]:1774<=r&&r<=2220?4:8192<=r&&r<=8203||8204==r?256:1;512==i?i=s:8==i&&4==o&&(i=16),he[e]=4==i?2:i,7&i&&(o=i),s=i}var r;for(let t=0,e=n,s=n;t<i;t++){let n=he[t];if(128==n)t<i-1&&e==he[t+1]&&24&e?n=he[t]=e:he[t]=256;else if(64==n){let n=t+1;for(;n<i&&64==he[n];)n++;let r=t&&8==e||n<i&&8==he[n]?1==s?1:8:256;for(let e=t;e<n;e++)he[e]=r;t=n-1}else 8==n&&1==s&&(he[t]=1);e=n,7&n&&(s=n)}for(let e,r,o,h=0,l=0,a=0;h<i;h++)if(r=ne[e=t.charCodeAt(h)])if(r<0){for(let t=l-3;t>=0;t-=3)if(se[t+1]==-r){let e=se[t+2],i=2&e?n:4&e?1&e?s:n:0;i&&(he[h]=he[se[t]]=i),l=t;break}}else{if(189==se.length)break;se[l++]=h,se[l++]=e,se[l++]=a}else if(2==(o=he[h])||1==o){let t=o==n;a=t?0:1;for(let e=l-3;e>=0;e-=3){let i=se[e+2];if(2&i)break;if(t)se[e+2]|=2;else{if(4&i)break;se[e+2]|=4}}}for(let t=0;t<i;t++)if(256==he[t]){let e=t+1;for(;e<i&&256==he[e];)e++;let s=1==(t?he[t-1]:n),r=s==(1==(e<i?he[e]:n))?s?1:2:n;for(let i=t;i<e;i++)he[i]=r;t=e-1}let o=[];if(1==n)for(let t=0;t<i;){let e=t,n=1!=he[t++];for(;t<i&&n==(1!=he[t]);)t++;if(n)for(let i=t;i>e;){let t=i,n=2!=he[--i];for(;i>e&&n==(2!=he[i-1]);)i--;o.push(new oe(i,t,n?2:1))}else o.push(new oe(e,t,0))}else for(let t=0;t<i;){let e=t,n=2==he[t++];for(;t<i&&n==(2==he[t]);)t++;o.push(new oe(e,t,n?1:2))}return o}function ae(t){return[new oe(0,t,0)]}let ce="";function ue(t,e,i,r,o){var h;let l=r.head-t.from,a=-1;if(0==l){if(!o||!t.length)return null;e[0].level!=i&&(l=e[0].side(!1,i),a=0)}else if(l==t.length){if(o)return null;let t=e[e.length-1];t.level!=i&&(l=t.side(!0,i),a=e.length-1)}a<0&&(a=oe.find(e,l,null!==(h=r.bidiLevel)&&void 0!==h?h:-1,r.assoc));let c=e[a];l==c.side(o,i)&&(c=e[a+=o?1:-1],l=c.side(!o,i));let u=o==(c.dir==i),f=(0,s.cp)(t.text,l,u);if(ce=t.text.slice(Math.min(l,f),Math.max(l,f)),f!=c.side(o,i))return n.jT.cursor(f+t.from,u?-1:1,c.level);let d=a==(o?e.length-1:0)?null:e[a+(o?1:-1)];return d||c.level==i?d&&d.level<c.level?n.jT.cursor(d.side(!o,i)+t.from,o?1:-1,d.level):n.jT.cursor(f+t.from,o?-1:1,c.level):n.jT.cursor(o?t.to:t.from,o?-1:1,i)}function fe(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function de(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function ge(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function pe(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function me(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function we(t,e,i){let n,s,r,o,h,l,a,c;for(let u=t.firstChild;u;u=u.nextSibling){let t=S(u);for(let f=0;f<t.length;f++){let d=t[f];s&&ge(s,d)&&(d=pe(me(d,s.bottom),s.top));let g=fe(e,d),p=de(i,d);if(0==g&&0==p)return 3==u.nodeType?ve(u,e,i):we(u,e,i);(!n||o>p||o==p&&r>g)&&(n=u,s=d,r=g,o=p),0==g?i>d.bottom&&(!a||a.bottom<d.bottom)?(h=u,a=d):i<d.top&&(!c||c.top>d.top)&&(l=u,c=d):a&&ge(a,d)?a=me(a,d.bottom):c&&ge(c,d)&&(c=pe(c,d.top))}}if(a&&a.bottom>=i?(n=h,s=a):c&&c.top<=i&&(n=l,s=c),!n)return{node:t,offset:0};let u=Math.max(s.left,Math.min(s.right,e));return 3==n.nodeType?ve(n,u,i):r||"true"!=n.contentEditable?{node:t,offset:Array.prototype.indexOf.call(t.childNodes,n)+(e>=(s.left+s.right)/2?1:0)}:we(n,u,i)}function ve(t,e,i){let n=t.nodeValue.length,s=-1,r=1e9,o=0;for(let h=0;h<n;h++){let n=L(t,h,h+1).getClientRects();for(let l=0;l<n.length;l++){let a=n[l];if(a.top==a.bottom)continue;o||(o=e-a.left);let c=(a.top>i?a.top-i:i-a.bottom)-1;if(a.left-1<=e&&a.right+1>=e&&c<r){let i=e>=(a.left+a.right)/2,n=i;if(U.chrome||U.gecko){L(t,h).getBoundingClientRect().left==a.right&&(n=!i)}if(c<=0)return{node:t,offset:h+(n?1:0)};s=h+(n?1:0),r=c}}}return{node:t,offset:s>-1?s:o>0?t.nodeValue.length:0}}function ye(t,{x:e,y:i},n=-1){let s,r=t.contentDOM.getBoundingClientRect(),o=t.defaultLineHeight/2;for(let e=!1;;){if(s=t.blockAtHeight(i,r.top),s.top>i||s.bottom<i){if(n=s.top>i?-1:1,i=Math.min(s.bottom-o,Math.max(s.top+o,i)),e)return-1;e=!0}if(s.type==ut.Text)break;i=n>0?s.bottom+o:s.top-o}let h=s.from;if(h<t.viewport.from)return 0==t.viewport.from?0:null;if(h>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:null;e=Math.max(r.left+1,Math.min(r.right-1,e));let l,a=t.root,c=a.elementFromPoint(e,i),u=-1;if(c&&t.contentDOM.contains(c)&&!(t.docView.nearest(c)instanceof et))if(a.caretPositionFromPoint){let t=a.caretPositionFromPoint(e,i);t&&({offsetNode:l,offset:u}=t)}else if(a.caretRangeFromPoint){let t=a.caretRangeFromPoint(e,i);t&&(({startContainer:l,startOffset:u}=t),U.safari&&function(t,e,i){let n;if(3!=t.nodeType||e!=(n=t.nodeValue.length))return!1;for(let e=t.nextSibling;e;e=t.nextSibling)if(1!=e.nodeType||"BR"!=e.nodeName)return!1;return L(t,n-1,n).getBoundingClientRect().left>i}(l,u,e)&&(l=void 0))}if(!l||!t.docView.dom.contains(l)){let n=vt.find(t.docView,h);({node:l,offset:u}=we(n.dom,e,i))}return t.docView.posFromDOM(l,u)}function Se(t,e,i,s){let r=t.state.doc.lineAt(e.head),o=t.bidiSpans(r);for(let h=e,l=null;;){let e=ue(r,o,t.textDirection,h,i),a=ce;if(!e){if(r.number==(i?t.state.doc.lines:1))return h;a="\n",r=t.state.doc.line(r.number+(i?1:-1)),o=t.bidiSpans(r),e=n.jT.cursor(i?r.from:r.to)}if(l){if(!l(a))return h}else{if(!s)return e;l=s(a)}h=e}}class be{constructor(t){this.lastKeyCode=0,this.lastKeyTime=0,this.lastIOSEnter=0,this.lastIOSBackspace=0,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=0,this.lastContextMenu=0,this.scrollHandlers=[],this.registeredEvents=[],this.customHandlers=[],this.composing=-1,this.compositionEndedAt=0,this.mouseSelection=null;for(let e in Me){let i=Me[e];t.contentDOM.addEventListener(e,(n=>{"keydown"==e&&this.keydown(t,n)||Ae(t,n)&&!this.ignoreDuringComposition(n)&&(this.mustFlushObserver(n)&&t.observer.forceFlush(),this.runCustomHandlers(e,t,n)?n.preventDefault():i(t,n))})),this.registeredEvents.push(e)}this.notifiedFocused=t.hasFocus,this.ensureHandlers(t)}setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}ensureHandlers(t){let e=this.customHandlers=t.pluginField(Vt);for(let i of e)for(let e in i.handlers)this.registeredEvents.indexOf(e)<0&&"scroll"!=e&&(this.registeredEvents.push(e),t.contentDOM.addEventListener(e,(i=>{Ae(t,i)&&this.runCustomHandlers(e,t,i)&&i.preventDefault()})))}runCustomHandlers(t,e,i){for(let n of this.customHandlers){let s=n.handlers[t],r=!1;if(s){try{r=s.call(n.plugin,i,e)}catch(t){Et(e.state,t)}if(r||i.defaultPrevented)return U.android&&"keydown"==t&&13==i.keyCode&&e.observer.flushSoon(),!0}}return!1}runScrollHandlers(t,e){for(let i of this.customHandlers){let n=i.handlers.scroll;if(n)try{n.call(i.plugin,e,t)}catch(e){Et(t.state,e)}}}keydown(t,e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),!this.screenKeyEvent(t,e))return!(!U.ios||13!=e.keyCode&&8!=e.keyCode||e.ctrlKey||e.altKey||e.metaKey||e.synthetic)&&(this[13==e.keyCode?"lastIOSEnter":"lastIOSBackspace"]=Date.now(),!0)}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(this.composing>0||!!(U.safari&&Date.now()-this.compositionEndedAt<500)&&(this.compositionEndedAt=0,!0))}screenKeyEvent(t,e){let i=9==e.keyCode&&Date.now()<this.lastEscPress+2e3;return 27==e.keyCode?this.lastEscPress=Date.now():xe.indexOf(e.keyCode)<0&&(this.lastEscPress=0),i}mustFlushObserver(t){return"keydown"==t.type&&229!=t.keyCode||"compositionend"==t.type&&!U.ios}startMouseSelection(t,e,i){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=new ke(this,t,e,i)}update(t){this.mouseSelection&&this.mouseSelection.update(t),this.lastKeyCode=this.lastSelectionTime=0}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}const xe=[16,17,18,20,91,92,224,225];class ke{constructor(t,e,i,s){this.inputState=t,this.view=e,this.startEvent=i,this.style=s;let r=e.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=i.shiftKey,this.multiple=e.state.facet(n.yy.allowMultipleSelections)&&function(t,e){let i=t.state.facet(At);return i.length?i[0](e):U.mac?e.metaKey:e.ctrlKey}(e,i),this.dragMove=function(t,e){let i=t.state.facet(Mt);return i.length?i[0](e):U.mac?!e.altKey:!e.ctrlKey}(e,i),this.dragging=!!function(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let n=w(t.root);if(0==n.rangeCount)return!0;let s=n.getRangeAt(0).getClientRects();for(let t=0;t<s.length;t++){let i=s[t];if(i.left<=e.clientX&&i.right>=e.clientX&&i.top<=e.clientY&&i.bottom>=e.clientY)return!0}return!1}(e,i)&&null,!1===this.dragging&&(i.preventDefault(),this.select(i))}move(t){if(0==t.buttons)return this.destroy();!1===this.dragging&&this.select(t)}up(t){null==this.dragging&&this.select(this.startEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.inputState.mouseSelection=null}select(t){let e=this.style.get(t,this.extend,this.multiple);e.eq(this.view.state.selection)&&e.main.assoc==this.view.state.selection.main.assoc||this.view.dispatch({selection:e,annotations:n.YW.userEvent.of("pointerselection"),scrollIntoView:!0})}update(t){t.docChanged&&this.dragging&&(this.dragging=this.dragging.map(t.changes)),this.style.update(t)}}function Ae(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let i,n=e.target;n!=t.contentDOM;n=n.parentNode)if(!n||11==n.nodeType||(i=N.get(n))&&i.ignoreEvent(e))return!1;return!0}const Me=Object.create(null),De=U.ie&&U.ie_version<15||U.ios&&U.webkit_version<604;function Oe(t,e){let i,{state:s}=t,r=1,o=s.toText(e),h=o.lines==s.selection.ranges.length;if(He&&s.selection.ranges.every((t=>t.empty))&&He==o.toString()){let t=-1;i=s.changeByRange((i=>{let l=s.doc.lineAt(i.from);if(l.from==t)return{range:i};t=l.from;let a=s.toText((h?o.line(r++).text:e)+s.lineBreak);return{changes:{from:l.from,insert:a},range:n.jT.cursor(i.from+a.length)}}))}else i=h?s.changeByRange((t=>{let e=o.line(r++);return{changes:{from:t.from,to:t.to,insert:e.text},range:n.jT.cursor(t.from+e.length)}})):s.replaceSelection(o);t.dispatch(i,{annotations:n.YW.userEvent.of("paste"),scrollIntoView:!0})}Me.keydown=(t,e)=>{t.inputState.setSelectionOrigin("keyboardselection")};let Ce=0;function Te(t,e,i,r){if(1==r)return n.jT.cursor(e,i);if(2==r)return function(t,e,i=1){let r=t.charCategorizer(e),o=t.doc.lineAt(e),h=e-o.from;if(0==o.length)return n.jT.cursor(e);0==h?i=1:h==o.length&&(i=-1);let l=h,a=h;i<0?l=(0,s.cp)(o.text,h,!1):a=(0,s.cp)(o.text,h);let c=r(o.text.slice(l,a));for(;l>0;){let t=(0,s.cp)(o.text,l,!1);if(r(o.text.slice(t,l))!=c)break;l=t}for(;a<o.length;){let t=(0,s.cp)(o.text,a);if(r(o.text.slice(a,t))!=c)break;a=t}return n.jT.range(l+o.from,a+o.from)}(t.state,e,i);{let i=vt.find(t.docView,e),s=t.state.doc.lineAt(i?i.posAtEnd:e),r=i?i.posAtStart:s.from,o=i?i.posAtEnd:s.to;return o<t.state.doc.length&&o==s.to&&o++,n.jT.range(r,o)}}Me.touchstart=(t,e)=>{Ce=Date.now(),t.inputState.setSelectionOrigin("pointerselection")},Me.touchmove=t=>{t.inputState.setSelectionOrigin("pointerselection")},Me.mousedown=(t,e)=>{if(t.observer.flush(),Ce>Date.now()-2e3)return;let i=null;for(let n of t.state.facet(Dt))if(i=n(t,e),i)break;i||0!=e.button||(i=function(t,e){let i=Pe(t,e),s=function(t){if(!Be)return t.detail;let e=Ne,i=Ve;return Ne=t,Ve=Date.now(),Ie=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Ie+1)%3:1}(e),r=t.state.selection,o=i,h=e;return{update(t){t.changes&&(i&&(i.pos=t.changes.mapPos(i.pos)),r=r.map(t.changes))},get(e,l,a){let c;if(e.clientX==h.clientX&&e.clientY==h.clientY?c=o:(c=o=Pe(t,e),h=e),!c||!i)return r;let u=Te(t,c.pos,c.bias,s);if(i.pos!=c.pos&&!l){let e=Te(t,i.pos,i.bias,s),r=Math.min(e.from,u.from),o=Math.max(e.to,u.to);u=r<u.from?n.jT.range(r,o):n.jT.range(o,r)}return l?r.replaceRange(r.main.extend(u.from,u.to)):a?r.addRange(u):n.jT.create([u])}}}(t,e)),i&&(t.root.activeElement!=t.contentDOM&&t.observer.ignore((()=>R(t.contentDOM))),t.inputState.startMouseSelection(t,e,i))};let Ee=(t,e)=>t>=e.top&&t<=e.bottom,Re=(t,e,i)=>Ee(e,i)&&t>=i.left&&t<=i.right;function Le(t,e,i,n){let s=vt.find(t.docView,e);if(!s)return 1;let r=e-s.posAtStart;if(0==r)return 1;if(r==s.length)return-1;let o=s.coordsAt(r,-1);if(o&&Re(i,n,o))return-1;let h=s.coordsAt(r,1);return h&&Re(i,n,h)?1:o&&Ee(n,o)?-1:1}function Pe(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY});return null==i?null:{pos:i,bias:Le(t,i,e.clientX,e.clientY)}}const Be=U.ie&&U.ie_version<=11;let Ne=null,Ie=0,Ve=0;Me.dragstart=(t,e)=>{let{selection:{main:i}}=t.state,{mouseSelection:n}=t.inputState;n&&(n.dragging=i),e.dataTransfer&&(e.dataTransfer.setData("Text",t.state.sliceDoc(i.from,i.to)),e.dataTransfer.effectAllowed="copyMove")},Me.drop=(t,e)=>{if(!e.dataTransfer||!t.state.facet(Rt))return;let i=t.posAtCoords({x:e.clientX,y:e.clientY}),s=e.dataTransfer.getData("Text");if(null==i||!s)return;e.preventDefault();let{mouseSelection:r}=t.inputState,o=r&&r.dragging&&r.dragMove?{from:r.dragging.from,to:r.dragging.to}:null,h={from:i,insert:s},l=t.state.changes(o?[o,h]:h);t.focus(),t.dispatch({changes:l,selection:{anchor:l.mapPos(i,-1),head:l.mapPos(i,1)},annotations:n.YW.userEvent.of("drop")})},Me.paste=(t,e)=>{if(!t.state.facet(Rt))return;t.observer.flush();let i=De?null:e.clipboardData,n=i&&i.getData("text/plain");n?(Oe(t,n),e.preventDefault()):function(t){let e=t.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout((()=>{t.focus(),i.remove(),Oe(t,i.value)}),50)}(t)};let He=null;function We(t){t.docView.compositionDeco.size&&t.update([])}Me.copy=Me.cut=(t,e)=>{let{text:i,ranges:s,linewise:r}=function(t){let e=[],i=[],n=!1;for(let n of t.selection.ranges)n.empty||(e.push(t.sliceDoc(n.from,n.to)),i.push(n));if(!e.length){let s=-1;for(let{from:n}of t.selection.ranges){let r=t.doc.lineAt(n);r.number>s&&(e.push(r.text),i.push({from:r.from,to:Math.min(t.doc.length,r.to+1)})),s=r.number}n=!0}return{text:e.join(t.lineBreak),ranges:i,linewise:n}}(t.state);if(!i)return;He=r?i:null;let o=De?null:e.clipboardData;o?(e.preventDefault(),o.clearData(),o.setData("text/plain",i)):function(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)}(t,i),"cut"==e.type&&t.state.facet(Rt)&&t.dispatch({changes:s,scrollIntoView:!0,annotations:n.YW.userEvent.of("cut")})},Me.focus=Me.blur=t=>{setTimeout((()=>{t.hasFocus!=t.inputState.notifiedFocused&&t.update([])}),10)},Me.beforeprint=t=>{t.viewState.printing=!0,t.requestMeasure(),setTimeout((()=>{t.viewState.printing=!1,t.requestMeasure()}),2e3)},Me.compositionstart=Me.compositionupdate=t=>{t.inputState.composing<0&&(t.docView.compositionDeco.size&&(t.observer.flush(),We(t)),t.inputState.composing=0)},Me.compositionend=t=>{t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),setTimeout((()=>{t.inputState.composing<0&&We(t)}),50)},Me.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()};const Fe=["pre-wrap","normal","pre-line"];class ze{constructor(){this.doc=s.xv.empty,this.lineWrapping=!1,this.direction=Xt.LTR,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.lineLength=30,this.heightChanged=!1}heightForGap(t,e){let i=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(i+=Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength)),this.lineHeight*i}heightForLine(t){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5))))*this.lineHeight}setDoc(t){return this.doc=t,this}mustRefresh(t,e,i){let n=!1;for(let e=0;e<t.length;e++){let i=t[e];i<0?e++:this.heightSamples[Math.floor(10*i)]||(n=!0,this.heightSamples[Math.floor(10*i)]=!0)}return n||Fe.indexOf(e)>-1!=this.lineWrapping||this.direction!=i}refresh(t,e,i,n,s,r){let o=Fe.indexOf(t)>-1,h=Math.round(i)!=Math.round(this.lineHeight)||this.lineWrapping!=o||this.direction!=e;if(this.lineWrapping=o,this.direction=e,this.lineHeight=i,this.charWidth=n,this.lineLength=s,h){this.heightSamples={};for(let t=0;t<r.length;t++){let e=r[t];e<0?t++:this.heightSamples[Math.floor(10*e)]=!0}}return h}}class qe{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class je{constructor(t,e,i,n,s){this.from=t,this.length=e,this.top=i,this.height=n,this.type=s}get to(){return this.from+this.length}get bottom(){return this.top+this.height}join(t){let e=(Array.isArray(this.type)?this.type:[this]).concat(Array.isArray(t.type)?t.type:[t]);return new je(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var $e=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}($e||($e={}));class Je{constructor(t,e,i=2){this.length=t,this.height=e,this.flags=i}get outdated(){return(2&this.flags)>0}set outdated(t){this.flags=(t?2:0)|-3&this.flags}setHeight(t,e){this.height!=e&&(Math.abs(this.height-e)>1e-4&&(t.heightChanged=!0),this.height=e)}replace(t,e,i){return Je.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,n){let s=this;for(let r=n.length-1;r>=0;r--){let{fromA:o,toA:h,fromB:l,toB:a}=n[r],c=s.lineAt(o,$e.ByPosNoHeight,e,0,0),u=c.to>=h?c:s.lineAt(h,$e.ByPosNoHeight,e,0,0);for(a+=u.to-h,h=u.to;r>0&&c.from<=n[r-1].toA;)o=n[r-1].fromA,l=n[r-1].fromB,r--,o<c.from&&(c=s.lineAt(o,$e.ByPosNoHeight,e,0,0));l+=c.from-o,o=c.from;let f=Xe.build(i,t,l,a);s=s.replace(o,h,f)}return s.updateHeight(i,0)}static empty(){return new Ge(0,0)}static of(t){if(1==t.length)return t[0];let e=0,i=t.length,n=0,s=0;for(;;)if(e==i)if(n>2*s){let s=t[e-1];s.break?t.splice(--e,1,s.left,null,s.right):t.splice(--e,1,s.left,s.right),i+=1+s.break,n-=s.size}else{if(!(s>2*n))break;{let e=t[i];e.break?t.splice(i,1,e.left,null,e.right):t.splice(i,1,e.left,e.right),i+=2+e.break,s-=e.size}}else if(n<s){let i=t[e++];i&&(n+=i.size)}else{let e=t[--i];e&&(s+=e.size)}let r=0;return null==t[e-1]?(r=1,e--):null==t[e]&&(r=1,i++),new Ue(Je.of(t.slice(0,e)),r,Je.of(t.slice(i)))}}Je.prototype.size=1;class _e extends Je{constructor(t,e,i){super(t,e),this.type=i}blockAt(t,e,i,n){return new je(n,this.length,i,this.height,this.type)}lineAt(t,e,i,n,s){return this.blockAt(0,i,n,s)}forEachLine(t,e,i,n,s,r){r(this.blockAt(0,i,n,s))}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more&&this.setHeight(t,n.heights[n.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Ge extends _e{constructor(t,e){super(t,e,ut.Text),this.collapsed=0,this.widgetHeight=0}replace(t,e,i){let n=i[0];return 1==i.length&&(n instanceof Ge||n instanceof Ke&&4&n.flags)&&Math.abs(this.length-n.length)<10?(n instanceof Ke?n=new Ge(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):Je.of(i)}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more?this.setHeight(t,n.heights[n.index++]):(i||this.outdated)&&this.setHeight(t,Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Ke extends Je{constructor(t){super(t,0)}lines(t,e){let i=t.lineAt(e).number,n=t.lineAt(e+this.length).number;return{firstLine:i,lastLine:n,lineHeight:this.height/(n-i+1)}}blockAt(t,e,i,n){let{firstLine:s,lastLine:r,lineHeight:o}=this.lines(e,n),h=Math.max(0,Math.min(r-s,Math.floor((t-i)/o))),{from:l,length:a}=e.line(s+h);return new je(l,a,i+o*h,o,ut.Text)}lineAt(t,e,i,n,s){if(e==$e.ByHeight)return this.blockAt(t,i,n,s);if(e==$e.ByPosNoHeight){let{from:e,to:n}=i.lineAt(t);return new je(e,n-e,0,0,ut.Text)}let{firstLine:r,lineHeight:o}=this.lines(i,s),{from:h,length:l,number:a}=i.lineAt(t);return new je(h,l,n+o*(a-r),o,ut.Text)}forEachLine(t,e,i,n,s,r){let{firstLine:o,lineHeight:h}=this.lines(i,s);for(let l=Math.max(t,s),a=Math.min(s+this.length,e);l<=a;){let e=i.lineAt(l);l==t&&(n+=h*(e.number-o)),r(new je(e.from,e.length,n,h,ut.Text)),n+=h,l=e.to+1}}replace(t,e,i){let n=this.length-e;if(n>0){let t=i[i.length-1];t instanceof Ke?i[i.length-1]=new Ke(t.length+n):i.push(null,new Ke(n-1))}if(t>0){let e=i[0];e instanceof Ke?i[0]=new Ke(t+e.length):i.unshift(new Ke(t-1),null)}return Je.of(i)}decomposeLeft(t,e){e.push(new Ke(t-1),null)}decomposeRight(t,e){e.push(null,new Ke(this.length-t-1))}updateHeight(t,e=0,i=!1,n){let s=e+this.length;if(n&&n.from<=e+this.length&&n.more){let i=[],r=Math.max(e,n.from);for(n.from>e&&i.push(new Ke(n.from-e-1).updateHeight(t,e));r<=s&&n.more;){let e=t.doc.lineAt(r).length;i.length&&i.push(null);let s=new Ge(e,n.heights[n.index++]);s.outdated=!1,i.push(s),r+=e+1}return r<=s&&i.push(null,new Ke(s-r).updateHeight(t,r)),t.heightChanged=!0,Je.of(i)}return(i||this.outdated)&&(this.setHeight(t,t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class Ue extends Je{constructor(t,e,i){super(t.length+e+i.length,t.height+i.height,e|(t.outdated||i.outdated?2:0)),this.left=t,this.right=i,this.size=t.size+i.size}get break(){return 1&this.flags}blockAt(t,e,i,n){let s=i+this.left.height;return t<s||0==this.right.height?this.left.blockAt(t,e,i,n):this.right.blockAt(t,e,s,n+this.left.length+this.break)}lineAt(t,e,i,n,s){let r=n+this.left.height,o=s+this.left.length+this.break,h=e==$e.ByHeight?t<r||0==this.right.height:t<o,l=h?this.left.lineAt(t,e,i,n,s):this.right.lineAt(t,e,i,r,o);if(this.break||(h?l.to<o:l.from>o))return l;let a=e==$e.ByPosNoHeight?$e.ByPosNoHeight:$e.ByPos;return h?l.join(this.right.lineAt(o,a,i,r,o)):this.left.lineAt(o,a,i,n,s).join(l)}forEachLine(t,e,i,n,s,r){let o=n+this.left.height,h=s+this.left.length+this.break;if(this.break)t<h&&this.left.forEachLine(t,e,i,n,s,r),e>=h&&this.right.forEachLine(t,e,i,o,h,r);else{let l=this.lineAt(h,$e.ByPos,i,n,s);t<l.from&&this.left.forEachLine(t,l.from-1,i,n,s,r),l.to>=t&&l.from<=e&&r(l),e>l.to&&this.right.forEachLine(l.to+1,e,i,o,h,r)}}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 s=[];t>0&&this.decomposeLeft(t,s);let r=s.length;for(let t of i)s.push(t);if(t>0&&Ye(s,r-1),e<this.length){let t=s.length;this.decomposeRight(e,s),Ye(s,t)}return Je.of(s)}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?Je.of(this.break?[t,null,e]:[t,e]):(this.left=t,this.right=e,this.height=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:s,right:r}=this,o=e+s.length+this.break,h=null;return n&&n.from<=e+s.length&&n.more?h=s=s.updateHeight(t,e,i,n):s.updateHeight(t,e,i),n&&n.from<=o+r.length&&n.more?h=r=r.updateHeight(t,o,i,n):r.updateHeight(t,o,i),h?this.balanced(s,r):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Ye(t,e){let i,n;null==t[e]&&(i=t[e-1])instanceof Ke&&(n=t[e+1])instanceof Ke&&t.splice(e-1,3,new Ke(i.length+1+n.length))}class Xe{constructor(t,e){this.pos=t,this.oracle=e,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,e){if(this.lineStart>-1){let t=Math.min(e,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof Ge?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new Ge(t-this.pos,-1)),this.writtenTo=t,e>t&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=e}point(t,e,i){if(t<e||i.heightRelevant){let n=i.widget?Math.max(0,i.widget.estimatedHeight):0,s=e-t;i.block?this.addBlock(new _e(s,n,i.type)):(s||n>=5)&&this.addLineDeco(n,s)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=e,this.writtenTo<t&&((this.writtenTo<t-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,t-1)),this.nodes.push(null)),this.pos>t&&this.nodes.push(new Ge(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new Ke(e-t);return this.oracle.doc.lineAt(t).to==e&&(i.flags|=4),i}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof Ge)return t;let e=new Ge(0,-1);return this.nodes.push(e),e}addBlock(t){this.enterLine(),t.type!=ut.WidgetAfter||this.isCovered||this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,t.type!=ut.WidgetBefore&&(this.covering=t)}addLineDeco(t,e){let i=this.ensureLine();i.length+=e,i.collapsed+=e,i.widgetHeight=Math.max(i.widgetHeight,t),this.writtenTo=this.pos=this.pos+e}finish(t){let e=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof Ge||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new Ge(0,-1));let i=t;for(let t of this.nodes)t instanceof Ge&&t.updateHeight(this.oracle,i),i+=t?t.length:1;return this.nodes}static build(t,e,i,n){let s=new Xe(i,t);return o.Xs.spans(e,i,n,s,0),s.finish(i)}}class Qe{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,n){(t<e||i&&i.heightRelevant||n&&n.heightRelevant)&&wt(t,e,this.changes,5)}}class Ze{constructor(t,e,i){this.from=t,this.to=e,this.size=i}static same(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let n=t[i],s=e[i];if(n.from!=s.from||n.to!=s.to||n.size!=s.size)return!1}return!0}draw(t){return ft.replace({widget:new ti(this.size,t)}).range(this.from,this.to)}}class ti extends ct{constructor(t,e){super(),this.size=t,this.vertical=e}eq(t){return t.size==this.size&&t.vertical==this.vertical}toDOM(){let t=document.createElement("div");return this.vertical?t.style.height=this.size+"px":(t.style.width=this.size+"px",t.style.height="2px",t.style.display="inline-block"),t}get estimatedHeight(){return this.vertical?this.size:-1}}class ei{constructor(t){this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentWidth=0,this.heightOracle=new ze,this.scaler=oi,this.scrollTo=null,this.printing=!1,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1,this.heightMap=Je.empty().applyChanges(t.facet(zt),s.xv.empty,this.heightOracle.setDoc(t.doc),[new jt(0,0,0,t.doc.length)]),this.viewport=this.getViewport(0,null),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ft.set(this.lineGaps.map((t=>t.draw(!1)))),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:t,to:e})=>n>=t&&n<=e))){let{from:e,to:i}=this.lineAt(n,0);t.push(new ii(e,i))}}this.viewports=t.sort(((t,e)=>t.from-e.from)),this.scaler=this.heightMap.height<=7e6?oi:new hi(this.heightOracle.doc,this.heightMap,this.viewports)}update(t,e=null){let i=this.state;this.state=t.state;let s=this.state.facet(zt),r=t.changedRanges,h=jt.extendWithRanges(r,function(t,e,i){let n=new Qe;return o.Xs.compare(t,e,i,n,0),n.changes}(t.startState.facet(zt),s,t?t.changes:n.as.empty(this.state.doc.length))),l=this.heightMap.height;this.heightMap=this.heightMap.applyChanges(s,i.doc,this.heightOracle.setDoc(this.state.doc),h),this.heightMap.height!=l&&(t.flags|=2);let a=h.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.head<a.from||e.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,e)),a.eq(this.viewport)||(this.viewport=a,t.flags|=4),this.updateForViewport(),(this.lineGaps.length||this.viewport.to-this.viewport.from>15e3)&&(t.flags|=this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,t.changes)))),this.computeVisibleRanges(),e&&(this.scrollTo=e),!this.mustEnforceCursorAssoc&&t.selectionSet&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&(this.mustEnforceCursorAssoc=!0)}measure(t,e){let i=t.dom,n="",s=Xt.LTR;if(!e){let t=window.getComputedStyle(i);n=t.whiteSpace,s="rtl"==t.direction?Xt.RTL:Xt.LTR,this.paddingTop=parseInt(t.paddingTop)||0,this.paddingBottom=parseInt(t.paddingBottom)||0}let r=this.printing?{top:-1e8,bottom:1e8,left:-1e8,right:1e8}:function(t,e){let i=t.getBoundingClientRect(),n=Math.max(0,i.left),s=Math.min(innerWidth,i.right),r=Math.max(0,i.top),o=Math.min(innerHeight,i.bottom);for(let e=t.parentNode;e;)if(1==e.nodeType){let t=window.getComputedStyle(e);if((e.scrollHeight>e.clientHeight||e.scrollWidth>e.clientWidth)&&"visible"!=t.overflow){let t=e.getBoundingClientRect();n=Math.max(n,t.left),s=Math.min(s,t.right),r=Math.max(r,t.top),o=Math.min(o,t.bottom)}e="absolute"==t.position||"fixed"==t.position?e.offsetParent:e.parentNode}else{if(11!=e.nodeType)break;e=e.host}return{left:n-i.left,right:s-i.left,top:r-(i.top+e),bottom:o-(i.top+e)}}(i,this.paddingTop),o=r.top-this.pixelViewport.top,h=r.bottom-this.pixelViewport.bottom;if(this.pixelViewport=r,this.inView=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left,!this.inView)return 0;let l=t.measureVisibleLineHeights(),a=!1,c=0,u=0,f=this.heightOracle;if(!e){let e=t.dom.clientWidth;if(f.mustRefresh(l,n,s)||f.lineWrapping&&Math.abs(e-this.contentWidth)>f.charWidth){let{lineHeight:i,charWidth:r}=t.measureTextSize();a=f.refresh(n,s,i,r,e/r,l),a&&(t.minWidth=0,u|=16)}this.contentWidth!=e&&(this.contentWidth=e,u|=16),o>0&&h>0?c=Math.max(o,h):o<0&&h<0&&(c=Math.min(o,h))}if(f.heightChanged=!1,this.heightMap=this.heightMap.updateHeight(f,0,a,new qe(this.viewport.from,l)),f.heightChanged&&(u|=2),!this.viewportIsAppropriate(this.viewport,c)||this.scrollTo&&(this.scrollTo.head<this.viewport.from||this.scrollTo.head>this.viewport.to)){let t=this.getViewport(c,this.scrollTo);t.from==this.viewport.from&&t.to==this.viewport.to||(this.viewport=t,u|=4)}return this.updateForViewport(),(this.lineGaps.length||this.viewport.to-this.viewport.from>15e3)&&(u|=this.updateLineGaps(this.ensureLineGaps(a?[]:this.lineGaps))),this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.enforceCursorAssoc()),u}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top,0)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom,0)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),n=this.heightMap,s=this.state.doc,{visibleTop:r,visibleBottom:o}=this,h=new ii(n.lineAt(r-1e3*i,$e.ByHeight,s,0,0).from,n.lineAt(o+1e3*(1-i),$e.ByHeight,s,0,0).to);if(e)if(e.head<h.from){let{top:t}=n.lineAt(e.head,$e.ByPos,s,0,0);h=new ii(n.lineAt(t-500,$e.ByHeight,s,0,0).from,n.lineAt(t+(o-r)+500,$e.ByHeight,s,0,0).to)}else if(e.head>h.to){let{bottom:t}=n.lineAt(e.head,$e.ByPos,s,0,0);h=new ii(n.lineAt(t-(o-r)-500,$e.ByHeight,s,0,0).from,n.lineAt(t+500,$e.ByHeight,s,0,0).to)}return h}mapViewport(t,e){let i=e.mapPos(t.from,-1),n=e.mapPos(t.to,1);return new ii(this.heightMap.lineAt(i,$e.ByPos,this.state.doc,0,0).from,this.heightMap.lineAt(n,$e.ByPos,this.state.doc,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){let{top:n}=this.heightMap.lineAt(t,$e.ByPos,this.state.doc,0,0),{bottom:s}=this.heightMap.lineAt(e,$e.ByPos,this.state.doc,0,0),{visibleTop:r,visibleBottom:o}=this;return(0==t||n<=r-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||s>=o+Math.max(10,Math.min(i,250)))&&n>r-2e3&&s<o+2e3}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 Ze(e.mapPos(n.from),e.mapPos(n.to),n.size));return i}ensureLineGaps(t){let e=[];return this.heightOracle.direction!=Xt.LTR||this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.state.doc,0,0,(i=>{if(i.length<1e4)return;let n,s,r=function(t,e,i){let n=[],s=t,r=0;o.Xs.spans(i.facet(zt),t,e,{span(){},point(t,e){t>s&&(n.push({from:s,to:t}),r+=t-s),s=e}},20),s<e&&(n.push({from:s,to:e}),r+=e-s);return{total:r,ranges:n}}(i.from,i.to,this.state);if(r.total<1e4)return;if(this.heightOracle.lineWrapping)n=i.from!=this.viewport.from?i.from:ni(r,(this.visibleTop-i.top)/i.height),s=i.to!=this.viewport.to?i.to:ni(r,(this.visibleBottom-i.top)/i.height);else{let t=r.total*this.heightOracle.charWidth;n=ni(r,this.pixelViewport.left/t),s=ni(r,this.pixelViewport.right/t)}let h=this.state.selection.main;h.from<=n&&h.to>=i.from&&(n=h.from),h.from<=i.to&&h.to>=s&&(s=h.to);let l=n-1e4,a=s+1e4;l>i.from+5e3&&e.push(ri(t,(t=>t.from==i.from&&t.to>l-5e3&&t.to<l+5e3))||new Ze(i.from,l,this.gapSize(i,l,!0,r))),a<i.to-5e3&&e.push(ri(t,(t=>t.to==i.to&&t.from>a-5e3&&t.from<a+5e3))||new Ze(a,i.to,this.gapSize(i,a,!1,r)))})),e}gapSize(t,e,i,n){if(this.heightOracle.lineWrapping){let s=t.height*si(n,e);return i?s:t.height-s}{let t=si(n,e);return n.total*this.heightOracle.charWidth*(i?t:1-t)}}updateLineGaps(t){return Ze.same(t,this.lineGaps)?0:(this.lineGaps=t,this.lineGapDeco=ft.set(t.map((t=>t.draw(this.heightOracle.lineWrapping)))),8)}computeVisibleRanges(){let t=this.state.facet(zt);this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let e=[];o.Xs.spans(t,this.viewport.from,this.viewport.to,{span(t,i){e.push({from:t,to:i})},point(){}},20),this.visibleRanges=e}lineAt(t,e){return e+=this.paddingTop,li(this.heightMap.lineAt(t,$e.ByPos,this.state.doc,e,0),this.scaler,e)}lineAtHeight(t,e){return e+=this.paddingTop,li(this.heightMap.lineAt(this.scaler.fromDOM(t,e),$e.ByHeight,this.state.doc,e,0),this.scaler,e)}blockAtHeight(t,e){return e+=this.paddingTop,li(this.heightMap.blockAt(this.scaler.fromDOM(t,e),this.state.doc,e,0),this.scaler,e)}forEachLine(t,e,i,n){return n+=this.paddingTop,this.heightMap.forEachLine(t,e,this.state.doc,n,0,1==this.scaler.scale?i:t=>i(li(t,this.scaler,n)))}get contentHeight(){return this.domHeight+this.paddingTop+this.paddingBottom}get domHeight(){return this.scaler.toDOM(this.heightMap.height,this.paddingTop)}}class ii{constructor(t,e){this.from=t,this.to=e}eq(t){return this.from==t.from&&this.to==t.to}}function ni({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 t=0;;t++){let{from:i,to:s}=e[t],r=s-i;if(n<=r)return i+n;n-=r}}function si(t,e){let i=0;for(let{from:n,to:s}of t.ranges){if(e<=s){i+=e-n;break}i+=s-n}return i/t.total}function ri(t,e){for(let i of t)if(e(i))return i}const oi={toDOM:t=>t,fromDOM:t=>t,scale:1};class hi{constructor(t,e,i){let n=0,s=0,r=0;this.viewports=i.map((({from:i,to:s})=>{let r=e.lineAt(i,$e.ByPos,t,0,0).top,o=e.lineAt(s,$e.ByPos,t,0,0).bottom;return n+=o-r,{from:i,to:s,top:r,bottom:o,domTop:0,domBottom:0}})),this.scale=(7e6-n)/(e.height-n);for(let t of this.viewports)t.domTop=r+(t.top-s)*this.scale,r=t.domBottom=t.domTop+(t.bottom-t.top),s=t.bottom}toDOM(t,e){t-=e;for(let i=0,n=0,s=0;;i++){let r=i<this.viewports.length?this.viewports[i]:null;if(!r||t<r.top)return s+(t-n)*this.scale+e;if(t<=r.bottom)return r.domTop+(t-r.top)+e;n=r.bottom,s=r.domBottom}}fromDOM(t,e){t-=e;for(let i=0,n=0,s=0;;i++){let r=i<this.viewports.length?this.viewports[i]:null;if(!r||t<r.domTop)return n+(t-s)/this.scale+e;if(t<=r.domBottom)return r.top+(t-r.domTop)+e;n=r.bottom,s=r.domBottom}}}function li(t,e,i){if(1==e.scale)return t;let n=e.toDOM(t.top,i),s=e.toDOM(t.bottom,i);return new je(t.from,t.length,n,s-n,Array.isArray(t.type)?t.type.map((t=>li(t,e,i))):t.type)}const ai=n.r$.define({combine:t=>t.join(" ")}),ci=n.r$.define({combine:t=>t.indexOf(!0)>-1}),ui=r.V.newName(),fi=r.V.newName(),di=r.V.newName(),gi={"&light":"."+fi,"&dark":"."+di};function pi(t,e,i){return new r.V(e,{finish:e=>/&/.test(e)?e.replace(/&\w*/,(e=>{if("&"==e)return t;if(!i||!i[e])throw new RangeError(`Unsupported selector: ${e}`);return i[e]})):t+" "+e})}const mi=pi("."+ui,{"&":{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},".cm-content":{margin:0,flexGrow:2,minHeight:"100%",display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",padding:"4px 0",outline:"none"},".cm-lineWrapping":{whiteSpace:"pre-wrap",overflowWrap:"anywhere"},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 4px"},".cm-selectionLayer":{zIndex:-1,contain:"size style"},".cm-selectionBackground":{position:"absolute"},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{zIndex:100,contain:"size style",pointerEvents:"none"},"&.cm-focused .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{visibility:"hidden"},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{visibility:"hidden"},"100%":{}},".cm-cursor":{position:"absolute",borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none",display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},"&.cm-focused .cm-cursor":{display:"block"},"&light .cm-activeLine":{backgroundColor:"#f3f9ff"},"&dark .cm-activeLine":{backgroundColor:"#223039"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-placeholder":{color:"#888",display:"inline-block"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"3px"},"&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"}},gi),wi={childList:!0,characterData:!0,subtree:!0,characterDataOldValue:!0},vi=U.ie&&U.ie_version<=11;class yi{constructor(t,e,i){this.view=t,this.onChange=e,this.onScrollChanged=i,this.active=!1,this.ignoreSelection=new C,this.delayedFlush=-1,this.queue=[],this.lastFlush=0,this.scrollTargets=[],this.intersection=null,this.intersecting=!1,this._selectionRange=null,this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver((e=>{for(let t of e)this.queue.push(t);this._selectionRange=null,(U.ie&&U.ie_version<=11||U.ios&&t.composing)&&e.some((t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length))?this.flushSoon():this.flush()})),vi&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.start(),this.onScroll=this.onScroll.bind(this),window.addEventListener("scroll",this.onScroll),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver((t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))}),{}),this.intersection.observe(this.dom)),this.listenForScroll()}onScroll(t){this.intersecting&&this.flush(),this.onScrollChanged(t)}onSelectionChange(t){this.lastFlush<Date.now()-50&&(this._selectionRange=null);let{view:e}=this,i=this.selectionRange;if(e.state.facet(Rt)?e.root.activeElement!=this.dom:!y(e.dom,i))return;let n=i.anchorNode&&e.docView.nearest(i.anchorNode);n&&n.ignoreEvent(t)||(U.ie&&U.ie_version<=11&&!e.state.selection.main.empty&&i.focusNode&&b(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush())}get selectionRange(){if(!this._selectionRange){let{root:t}=this.view,e=w(t);U.safari&&11==t.nodeType&&function(){let t=document.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}()==this.view.contentDOM&&(e=function(t){let e=null;function i(t){t.preventDefault(),t.stopImmediatePropagation(),e=t.getTargetRanges()[0]}if(t.contentDOM.addEventListener("beforeinput",i,!0),document.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",i,!0),!e)return null;let n=e.startContainer,s=e.startOffset,r=e.endContainer,o=e.endOffset,h=t.docView.domAtPos(t.state.selection.main.anchor);b(h.node,h.offset,r,o)&&([n,s,r,o]=[r,o,n,s]);return{anchorNode:n,anchorOffset:s,focusNode:r,focusOffset:o}}(this.view)||e),this._selectionRange=e}return this._selectionRange}setSelectionRange(t,e){var i;(null===(i=this._selectionRange)||void 0===i?void 0:i.type)||(this._selectionRange={anchorNode:t.node,anchorOffset:t.offset,focusNode:e.node,focusOffset:e.offset})}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let i=this.dom;i;)if(1==i.nodeType)!e&&t<this.scrollTargets.length&&this.scrollTargets[t]==i?t++:e||(e=this.scrollTargets.slice(0,t)),e&&e.push(i),i=i.assignedSlot||i.parentNode;else{if(11!=i.nodeType)break;i=i.host}if(t<this.scrollTargets.length&&!e&&(e=this.scrollTargets.slice(0,t)),e){for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);for(let t of this.scrollTargets=e)t.addEventListener("scroll",this.onScroll)}}ignore(t){if(!this.active)return t();try{return this.stop(),t()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,wi),this.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange),vi&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),this.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange),vi&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clearSelection(){this.ignoreSelection.set(this.selectionRange)}clear(){this.observer.takeRecords(),this.queue.length=0,this.clearSelection()}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=window.setTimeout((()=>{this.delayedFlush=-1,this.flush()}),20))}forceFlush(){this.delayedFlush>=0&&(window.clearTimeout(this.delayedFlush),this.delayedFlush=-1,this.flush())}flush(){if(this.delayedFlush>=0)return;this.lastFlush=Date.now();let t=this.queue;for(let e of this.observer.takeRecords())t.push(e);t.length&&(this.queue=[]);let e=this.selectionRange,i=!this.ignoreSelection.eq(e)&&y(this.dom,e);if(0==t.length&&!i)return;let n=-1,s=-1,r=!1;for(let e of t){let t=this.readMutation(e);t&&(t.typeOver&&(r=!0),-1==n?({from:n,to:s}=t):(n=Math.min(t.from,n),s=Math.max(t.to,s)))}let o=this.view.state;(n>-1||i)&&this.onChange(n,s,r),this.view.state==o&&(this.view.docView.dirty&&(this.ignore((()=>this.view.docView.sync())),this.view.docView.dirty=0),this.view.docView.updateSelection()),this.clearSelection()}readMutation(t){let e=this.view.docView.nearest(t.target);if(!e||e.ignoreMutation(t))return null;if(e.markDirty(),"childList"==t.type){let i=Si(e,t.previousSibling||t.target.previousSibling,-1),n=Si(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:n?e.posBefore(n):e.posAtEnd,typeOver:!1}}return{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}}destroy(){this.stop(),this.intersection&&this.intersection.disconnect();for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);window.removeEventListener("scroll",this.onScroll),clearTimeout(this.parentCheck)}}function Si(t,e,i){for(;e;){let n=N.get(e);if(n&&n.parent==t)return n;let s=e.parentNode;e=s!=t.dom?s:i>0?e.nextSibling:e.previousSibling}return null}function bi(t,e,i,s){let r,o,h,l=t.state.selection.main;if(e>-1&&(h=t.docView.domBoundsAround(e,i,0))){let{from:e,to:i}=h,s=t.docView.impreciseHead||t.docView.impreciseAnchor?[]:function(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:n,focusNode:s,focusOffset:r}=t.observer.selectionRange;i&&(e.push(new Ai(i,n)),s==i&&r==n||e.push(new Ai(s,r)));return e}(t),a=new xi(s,t);a.readRange(h.startDOM,h.endDOM),o=function(t,e){if(0==t.length)return null;let i=t[0].pos,s=2==t.length?t[1].pos:i;return i>-1&&s>-1?n.jT.single(i+e,s+e):null}(s,e);let c=l.from,u=null;(8===t.inputState.lastKeyCode&&t.inputState.lastKeyTime>Date.now()-100||U.android&&a.text.length<i-e)&&(c=l.to,u="end");let f=function(t,e,i,n){let s=Math.min(t.length,e.length),r=0;for(;r<s&&t.charCodeAt(r)==e.charCodeAt(r);)r++;if(r==s&&t.length==e.length)return null;let o=t.length,h=e.length;for(;o>0&&h>0&&t.charCodeAt(o-1)==e.charCodeAt(h-1);)o--,h--;if("end"==n){i-=o+Math.max(0,r-Math.min(o,h))-r}if(o<r&&t.length<e.length){r-=i<=r&&i>=o?r-i:0,h=r+(h-o),o=r}else if(h<r){r-=i<=r&&i>=h?r-i:0,o=r+(o-h),h=r}return{from:r,toA:o,toB:h}}(t.state.sliceDoc(e,i),a.text,c-e,u);f&&(r={from:e+f.from,to:e+f.toA,insert:t.state.toText(a.text.slice(f.from,f.toB))})}else if(t.hasFocus||!t.state.facet(Rt)){let e=t.observer.selectionRange,{impreciseHead:i,impreciseAnchor:s}=t.docView,r=i&&i.node==e.focusNode&&i.offset==e.focusOffset||!v(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),h=s&&s.node==e.anchorNode&&s.offset==e.anchorOffset||!v(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset);r==l.head&&h==l.anchor||(o=n.jT.single(h,r))}if(r||o)if(!r&&s&&!l.empty&&o&&o.main.empty?r={from:l.from,to:l.to,insert:t.state.doc.slice(l.from,l.to)}:r&&r.from>=l.from&&r.to<=l.to&&(r.from!=l.from||r.to!=l.to)&&l.to-l.from-(r.to-r.from)<=4&&(r={from:l.from,to:l.to,insert:t.state.doc.slice(l.from,r.from).append(r.insert).append(t.state.doc.slice(r.to,l.to))}),r){let e=t.state;if(U.android&&(r.from==l.from&&r.to==l.to&&1==r.insert.length&&2==r.insert.lines&&Mi(t,"Enter",13)||r.from==l.from-1&&r.to==l.to&&0==r.insert.length&&Mi(t,"Backspace",8)||r.from==l.from&&r.to==l.to+1&&0==r.insert.length&&Mi(t,"Delete",46))||U.ios&&(t.inputState.lastIOSEnter>Date.now()-225&&r.insert.lines>1&&Mi(t,"Enter",13)||t.inputState.lastIOSBackspace>Date.now()-225&&!r.insert.length&&Mi(t,"Backspace",8)))return;let i,s=r.insert.toString();if(t.state.facet(Tt).some((e=>e(t,r.from,r.to,s))))return;if(t.inputState.composing>=0&&t.inputState.composing++,r.from>=l.from&&r.to<=l.to&&r.to-r.from>=(l.to-l.from)/3&&(!o||o.main.empty&&o.main.from==r.from+r.insert.length)){let n=l.from<r.from?e.sliceDoc(l.from,r.from):"",s=l.to>r.to?e.sliceDoc(r.to,l.to):"";i=e.replaceSelection(t.state.toText(n+r.insert.sliceString(0,void 0,t.state.lineBreak)+s))}else{let t=e.changes(r);i={changes:t,selection:o&&!e.selection.main.eq(o.main)&&o.main.to<=t.newLength?e.selection.replaceRange(o.main):void 0}}t.dispatch(i,{scrollIntoView:!0,annotations:n.YW.userEvent.of("input")})}else if(o&&!o.main.eq(l)){let e,i=!1;t.inputState.lastSelectionTime>Date.now()-50&&("keyboardselection"==t.inputState.lastSelectionOrigin?i=!0:e=n.YW.userEvent.of(t.inputState.lastSelectionOrigin)),t.dispatch({selection:o,scrollIntoView:i,annotations:e})}}class xi{constructor(t,e){this.points=t,this.view=e,this.text="",this.lineBreak=e.state.lineBreak}readRange(t,e){if(!t)return;let i=t.parentNode;for(let n=t;;){this.findPointBefore(i,n),this.readNode(n);let t=n.nextSibling;if(t==e)break;let s=N.get(n),r=N.get(t);((s?s.breakAfter:ki(n))||(r?r.breakAfter:ki(t))&&("BR"!=n.nodeName||n.cmIgnore))&&(this.text+=this.lineBreak),n=t}this.findPointBefore(i,e)}readNode(t){if(t.cmIgnore)return;let e,i=N.get(t),n=i&&i.overrideDOMText;null!=n?e=n.sliceString(0,void 0,this.lineBreak):3==t.nodeType?e=t.nodeValue:"BR"==t.nodeName?e=t.nextSibling?this.lineBreak:"":1==t.nodeType&&this.readRange(t.firstChild,null),null!=e&&(this.findPointIn(t,e.length),this.text+=e,U.chrome&&13==this.view.inputState.lastKeyCode&&!t.nextSibling&&/\n\n$/.test(this.text)&&(this.text=this.text.slice(0,-1)))}findPointBefore(t,e){for(let i of this.points)i.node==t&&t.childNodes[i.offset]==e&&(i.pos=this.text.length)}findPointIn(t,e){for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e))}}function ki(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}class Ai{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}function Mi(t,e,i){let n={key:e,code:e,keyCode:i,which:i,cancelable:!0},s=new KeyboardEvent("keydown",n);s.synthetic=!0,t.contentDOM.dispatchEvent(s);let r=new KeyboardEvent("keyup",n);return r.synthetic=!0,t.contentDOM.dispatchEvent(r),s.defaultPrevented||r.defaultPrevented}class Di{constructor(t={}){this.plugins=[],this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.style.cssText="position: absolute; top: -10000px",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),this._dispatch=t.dispatch||(t=>this.update([t])),this.dispatch=this.dispatch.bind(this),this.root=t.root||document,this.viewState=new ei(t.state||n.yy.create()),this.plugins=this.state.facet(Nt).map((t=>new Ht(t).update(this))),this.observer=new yi(this,((t,e,i)=>{bi(this,t,e,i)}),(t=>{this.inputState.runScrollHandlers(this,t),this.observer.intersecting&&this.measure()})),this.inputState=new be(this),this.docView=new Jt(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,window.addEventListener("resize",(()=>{-1==Ti&&(Ti=setTimeout(Ei,50))})),this.requestMeasure(),t.parent&&t.parent.appendChild(this.dom)}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.composing>0}dispatch(...t){this._dispatch(1==t.length&&t[0]instanceof n.YW?t[0]:this.state.update(...t))}update(t){if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let e,i=!1,s=this.state;for(let e of t){if(e.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=e.state}if(s.facet(n.yy.phrases)!=this.state.facet(n.yy.phrases))return this.setState(s);e=new $t(this,s,t);try{this.updateState=2;let n=t.some((t=>t.scrollIntoView))?s.selection.main:null;this.viewState.update(e,n),this.bidiCache=Li.update(this.bidiCache,e.changes),e.empty||this.updatePlugins(e),i=this.docView.update(e),this.state.facet(qt)!=this.styleModules&&this.mountStyles(),this.updateAttrs(),this.showAnnouncements(t)}finally{this.updateState=0}if((i||scrollTo||this.viewState.mustEnforceCursorAssoc)&&this.requestMeasure(),!e.empty)for(let t of this.state.facet(Ct))t(e)}setState(t){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");this.updateState=2;try{for(let t of this.plugins)t.destroy(this);this.viewState=new ei(t),this.plugins=t.facet(Nt).map((t=>new Ht(t).update(this))),this.docView=new Jt(this),this.inputState.ensureHandlers(this),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(Nt),i=t.state.facet(Nt);if(e!=i){let n=[];for(let s of i){let i=e.indexOf(s);if(i<0)n.push(new Ht(s));else{let e=this.plugins[i];e.mustUpdate=t,n.push(e)}}for(let e of this.plugins)e.mustUpdate!=t&&e.destroy(this);this.plugins=n,this.inputState.ensureHandlers(this)}else for(let e of this.plugins)e.mustUpdate=t;for(let t=0;t<this.plugins.length;t++)this.plugins[t]=this.plugins[t].update(this)}measure(){this.measureScheduled>-1&&cancelAnimationFrame(this.measureScheduled),this.measureScheduled=-1;let t=null;try{for(let e=0;;e++){this.updateState=1;let i=this.viewState.measure(this.docView,e>0),n=this.measureRequests;if(!i&&!n.length&&null==this.viewState.scrollTo)break;if(this.measureRequests=[],e>5){console.warn("Viewport failed to stabilize");break}let s=n.map((t=>{try{return t.read(this)}catch(t){return Et(this.state,t),Ri}})),r=new $t(this,this.state);r.flags|=i,t?t.flags|=i:t=r,this.updateState=2,r.empty||this.updatePlugins(r),this.updateAttrs(),i&&this.docView.update(r);for(let t=0;t<n.length;t++)if(s[t]!=Ri)try{n[t].write(s[t],this)}catch(t){Et(this.state,t)}if(this.viewState.scrollTo&&(this.docView.scrollPosIntoView(this.viewState.scrollTo.head,this.viewState.scrollTo.assoc),this.viewState.scrollTo=null),!(4&i)&&0==this.measureRequests.length)break}}finally{this.updateState=0}if(this.measureScheduled=-1,t&&!t.empty)for(let e of this.state.facet(Ct))e(t)}get themeClasses(){return ui+" "+(this.state.facet(ci)?di:fi)+" "+this.state.facet(ai)}updateAttrs(){let t=ht(this.state.facet(Wt),{class:"cm-editor cm-wrap"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses});at(this.dom,this.editorAttrs,t),this.editorAttrs=t;let e=ht(this.state.facet(Ft),{spellcheck:"false",autocorrect:"off",autocapitalize:"off",contenteditable:String(this.state.facet(Rt)),"data-gramm":"false",class:"cm-content",style:`${U.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"});at(this.contentDOM,this.contentAttrs,e),this.contentAttrs=e}showAnnouncements(t){let e=!0;for(let i of t)for(let t of i.effects)if(t.is(Di.announce)){e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(qt),r.V.mount(this.root,this.styleModules.concat(mi).reverse())}readMeasured(){if(2==this.updateState)throw new Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&this.measureScheduled>-1&&this.measure()}requestMeasure(t){if(this.measureScheduled<0&&(this.measureScheduled=requestAnimationFrame((()=>this.measure()))),t){if(null!=t.key)for(let e=0;e<this.measureRequests.length;e++)if(this.measureRequests[e].key===t.key)return void(this.measureRequests[e]=t);this.measureRequests.push(t)}}pluginField(t){let e=[];for(let i of this.plugins)i.update(this).takeField(t,e);return e}plugin(t){for(let e of this.plugins)if(e.spec==t)return e.update(this).value;return null}blockAtHeight(t,e){return this.readMeasured(),this.viewState.blockAtHeight(t,Ci(e,this.contentDOM))}visualLineAtHeight(t,e){return this.readMeasured(),this.viewState.lineAtHeight(t,Ci(e,this.contentDOM))}viewportLines(t,e){let{from:i,to:n}=this.viewport;this.viewState.forEachLine(i,n,t,Ci(e,this.contentDOM))}visualLineAt(t,e=0){return this.viewState.lineAt(t,e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return Se(this,t,e,i)}moveByGroup(t,e){return Se(this,t,e,(e=>function(t,e,i){let s=t.state.charCategorizer(e),r=s(i);return t=>{let e=s(t);return r==n.D0.Space&&(r=e),r==e}}(this,t.head,e)))}moveToLineBoundary(t,e,i=!0){return function(t,e,i,s){let r=t.state.doc.lineAt(e.head),o=s&&t.lineWrapping?t.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head):null;if(o){let e=t.dom.getBoundingClientRect(),s=t.posAtCoords({x:i==(t.textDirection==Xt.LTR)?e.right-1:e.left+1,y:(o.top+o.bottom)/2});if(null!=s)return n.jT.cursor(s,i?-1:1)}let h=vt.find(t.docView,e.head),l=h?i?h.posAtEnd:h.posAtStart:i?r.to:r.from;return n.jT.cursor(l,i?-1:1)}(this,t,e,i)}moveVertically(t,e,i){return function(t,e,i,r){var o;let h=e.head,l=i?1:-1;if(h==(i?t.state.doc.length:0))return n.jT.cursor(h);let a=t.coordsAtPos(h);if(a){let i=t.dom.getBoundingClientRect(),s=null!==(o=e.goalColumn)&&void 0!==o?o:a.left-i.left,c=i.left+s,u=null!=r?r:t.defaultLineHeight>>1;for(let e=l<0?a.top:a.bottom,i=0;i<50;i+=10){let r=ye(t,{x:c,y:e+(u+i)*l},l);if(null==r)break;if(r!=h)return n.jT.cursor(r,void 0,void 0,s)}}let{doc:c}=t.state,u=c.lineAt(h),f=t.state.tabSize,d=e.goalColumn,g=0;if(null==d){for(const t=c.iterRange(u.from,h);!t.next().done;)g=(0,s.IS)(t.value,g,f);d=g*t.defaultCharacterWidth}else g=Math.round(d/t.defaultCharacterWidth);if(l<0&&0==u.from)return n.jT.cursor(0);if(l>0&&u.to==c.length)return n.jT.cursor(u.to);let p=c.line(u.number+l),m=p.from,w=0;for(const t=c.iterRange(p.from,p.to);w>=g&&!t.next().done;){const{offset:e,leftOver:i}=(0,s.Gz)(t.value,w,g,f);w=g-i,m+=e}return n.jT.cursor(m,void 0,void 0,d)}(this,t,e,i)}scrollPosIntoView(t){this.viewState.scrollTo=n.jT.cursor(t),this.requestMeasure()}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t){return this.readMeasured(),ye(this,t)}coordsAtPos(t,e=1){this.readMeasured();let i=this.docView.coordsAt(t,e);if(!i||i.left==i.right)return i;let n=this.state.doc.lineAt(t),s=this.bidiSpans(n);return D(i,s[oe.find(s,t-n.from,-1,e)].dir==Xt.LTR==e>0)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.heightOracle.direction}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>Oi)return ae(t.length);let e=this.textDirection;for(let i of this.bidiCache)if(i.from==t.from&&i.dir==e)return i.order;let i=le(t.text,this.textDirection);return this.bidiCache.push(new Li(t.from,t.to,e,i)),i}get hasFocus(){var t;return(document.hasFocus()||U.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{R(this.contentDOM),this.docView.updateSelection()}))}destroy(){for(let t of this.plugins)t.destroy(this);this.inputState.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&cancelAnimationFrame(this.measureScheduled)}static domEventHandlers(t){return It.define((()=>({})),{eventHandlers:t})}static theme(t,e){let i=r.V.newName(),n=[ai.of(i),qt.of(pi(`.${i}`,t))];return e&&e.dark&&n.push(ci.of(!0)),n}static baseTheme(t){return n.Wl.fallback(qt.of(pi("."+ui,t,gi)))}}Di.styleModule=qt,Di.inputHandler=Tt,Di.exceptionSink=Ot,Di.updateListener=Ct,Di.editable=Rt,Di.mouseSelectionStyle=Dt,Di.dragMovesSelection=Mt,Di.clickAddsSelectionRange=At,Di.decorations=zt,Di.contentAttributes=Ft,Di.editorAttributes=Wt,Di.lineWrapping=Di.contentAttributes.of({class:"cm-lineWrapping"}),Di.announce=n.Py.define();const Oi=4096;function Ci(t,e){return null==t?e.getBoundingClientRect().top:t}let Ti=-1;function Ei(){Ti=-1;let t=document.querySelectorAll(".cm-content");for(let e=0;e<t.length;e++){let i=N.get(t[e]);i&&i.editorView.requestMeasure()}}const Ri={};class Li{constructor(t,e,i,n){this.from=t,this.to=e,this.dir=i,this.order=n}static update(t,e){if(e.empty)return t;let i=[],n=t.length?t[t.length-1].dir:Xt.LTR;for(let s=Math.max(0,t.length-10);s<t.length;s++){let r=t[s];r.dir!=n||e.touchesRange(r.from,r.to)||i.push(new Li(e.mapPos(r.from,1),e.mapPos(r.to,-1),r.dir,r.order))}return i}}const Pi="undefined"==typeof navigator?"key":/Mac/.test(navigator.platform)?"mac":/Win/.test(navigator.platform)?"win":/Linux|X11/.test(navigator.platform)?"linux":"key";function Bi(t,e,i){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),!1!==i&&e.shiftKey&&(t="Shift-"+t),t}const Ni=Di.domEventHandlers({keydown:(t,e)=>zi(Hi(e.state),t,e,"editor")}),Ii=n.r$.define({enables:Ni}),Vi=new WeakMap;function Hi(t){let e=t.facet(Ii),i=Vi.get(e);return i||Vi.set(e,i=function(t,e=Pi){let i=Object.create(null),n=Object.create(null),s=(t,e)=>{let i=n[t];if(null==i)n[t]=e;else if(i!=e)throw new Error("Key binding "+t+" is used both as a regular binding and as a multi-stroke prefix")},r=(t,n,r,o)=>{let h=i[t]||(i[t]=Object.create(null)),l=n.split(/ (?!$)/).map((t=>function(t,e){const i=t.split(/-(?!$)/);let n,s,r,o,h=i[i.length-1];"Space"==h&&(h=" ");for(let t=0;t<i.length-1;++t){const h=i[t];if(/^(cmd|meta|m)$/i.test(h))o=!0;else if(/^a(lt)?$/i.test(h))n=!0;else if(/^(c|ctrl|control)$/i.test(h))s=!0;else if(/^s(hift)?$/i.test(h))r=!0;else{if(!/^mod$/i.test(h))throw new Error("Unrecognized modifier name: "+h);"mac"==e?o=!0:s=!0}}return n&&(h="Alt-"+h),s&&(h="Ctrl-"+h),o&&(h="Meta-"+h),r&&(h="Shift-"+h),h}(t,e)));for(let e=1;e<l.length;e++){let i=l.slice(0,e).join(" ");s(i,!0),h[i]||(h[i]={preventDefault:!0,commands:[e=>{let n=Fi={view:e,prefix:i,scope:t};return setTimeout((()=>{Fi==n&&(Fi=null)}),4e3),!0}]})}let a=l.join(" ");s(a,!1);let c=h[a]||(h[a]={preventDefault:!1,commands:[]});c.commands.push(r),o&&(c.preventDefault=!0)};for(let i of t){let t=i[e]||i.key;if(t)for(let e of i.scope?i.scope.split(" "):["editor"])r(e,t,i.run,i.preventDefault),i.shift&&r(e,"Shift-"+t,i.shift,i.preventDefault)}return i}(e.reduce(((t,e)=>t.concat(e)),[]))),i}function Wi(t,e,i){return zi(Hi(t.state),e,t,i)}let Fi=null;function zi(t,e,i,n){let s=function(t){var e=!(g&&(t.ctrlKey||t.altKey||t.metaKey)||(c||d)&&t.shiftKey&&t.key&&1==t.key.length)&&t.key||(t.shiftKey?l:h)[t.keyCode]||t.key||"Unidentified";return"Esc"==e&&(e="Escape"),"Del"==e&&(e="Delete"),"Left"==e&&(e="ArrowLeft"),"Up"==e&&(e="ArrowUp"),"Right"==e&&(e="ArrowRight"),"Down"==e&&(e="ArrowDown"),e}(e),r=1==s.length&&" "!=s,o="",a=!1;Fi&&Fi.view==i&&Fi.scope==n&&(o=Fi.prefix+" ",(a=xe.indexOf(e.keyCode)<0)&&(Fi=null));let u,f=t=>{if(t){for(let e of t.commands)if(e(i))return!0;t.preventDefault&&(a=!0)}return!1},p=t[n];if(p){if(f(p[o+Bi(s,e,!r)]))return!0;if(r&&(e.shiftKey||e.altKey||e.metaKey)&&(u=h[e.keyCode])&&u!=s){if(f(p[o+Bi(u,e,!0)]))return!0}else if(r&&e.shiftKey&&f(p[o+Bi(s,e,!0)]))return!0}return a}const qi=!U.ios,ji=n.r$.define({combine:t=>(0,n.BO)(t,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,e)=>Math.min(t,e),drawRangeCursor:(t,e)=>t||e})});function $i(t={}){return[ji.of(t),_i,Ki]}class Ji{constructor(t,e,i,n,s){this.left=t,this.top=e,this.width=i,this.height=n,this.className=s}draw(){let t=document.createElement("div");return t.className=this.className,this.adjust(t),t}adjust(t){t.style.left=this.left+"px",t.style.top=this.top+"px",this.width>=0&&(t.style.width=this.width+"px"),t.style.height=this.height+"px"}eq(t){return this.left==t.left&&this.top==t.top&&this.width==t.width&&this.height==t.height&&this.className==t.className}}const _i=It.fromClass(class{constructor(t){this.view=t,this.rangePieces=[],this.cursors=[],this.measureReq={read:this.readPos.bind(this),write:this.drawSel.bind(this)},this.selectionLayer=t.scrollDOM.appendChild(document.createElement("div")),this.selectionLayer.className="cm-selectionLayer",this.selectionLayer.setAttribute("aria-hidden","true"),this.cursorLayer=t.scrollDOM.appendChild(document.createElement("div")),this.cursorLayer.className="cm-cursorLayer",this.cursorLayer.setAttribute("aria-hidden","true"),t.requestMeasure(this.measureReq),this.setBlinkRate()}setBlinkRate(){this.cursorLayer.style.animationDuration=this.view.state.facet(ji).cursorBlinkRate+"ms"}update(t){let e=t.startState.facet(ji)!=t.state.facet(ji);(e||t.selectionSet||t.geometryChanged||t.viewportChanged)&&this.view.requestMeasure(this.measureReq),t.transactions.some((t=>t.scrollIntoView))&&(this.cursorLayer.style.animationName="cm-blink"==this.cursorLayer.style.animationName?"cm-blink2":"cm-blink"),e&&this.setBlinkRate()}readPos(){let{state:t}=this.view,e=t.facet(ji),i=t.selection.ranges.map((t=>t.empty?[]:function(t,e){if(e.to<=t.viewport.from||e.from>=t.viewport.to)return[];let i=Math.max(e.from,t.viewport.from),n=Math.min(e.to,t.viewport.to),s=t.textDirection==Xt.LTR,r=t.contentDOM,o=r.getBoundingClientRect(),h=Ui(t),l=window.getComputedStyle(r.firstChild),a=o.left+parseInt(l.paddingLeft),c=o.right-parseInt(l.paddingRight),u=t.visualLineAt(i),f=t.visualLineAt(n);t.lineWrapping&&(u=Yi(t,i,u),f=Yi(t,n,f));if(u.from==f.from)return g(p(e.from,e.to,u));{let t=p(e.from,null,u),i=p(null,e.to,f),n=[];return u.to<f.from-1?n.push(d(a,t.bottom,c,i.top)):t.bottom<i.top&&i.top-t.bottom<4&&(t.bottom=i.top=(t.bottom+i.top)/2),g(t).concat(n).concat(g(i))}function d(t,e,i,n){return new Ji(t-h.left,e-h.top,i-t,n-e,"cm-selectionBackground")}function g({top:t,bottom:e,horizontal:i}){let n=[];for(let s=0;s<i.length;s+=2)n.push(d(i[s],t,i[s+1],e));return n}function p(e,i,n){let r=1e9,o=-1e9,h=[];function l(e,i,l,u,f){let d=t.coordsAtPos(e,e==n.to?-1:1),g=t.coordsAtPos(l,l==n.from?1:-1);r=Math.min(d.top,g.top,r),o=Math.max(d.bottom,g.bottom,o),f==Xt.LTR?h.push(s&&i?a:d.left,s&&u?c:g.right):h.push(!s&&u?a:g.left,!s&&i?c:d.right)}let u=null!=e?e:n.from,f=null!=i?i:n.to;for(let n of t.visibleRanges)if(n.to>u&&n.from<f)for(let s=Math.max(n.from,u),r=Math.min(n.to,f);;){let n=t.state.doc.lineAt(s);for(let o of t.bidiSpans(n)){let t=o.from+n.from,h=o.to+n.from;if(t>=r)break;h>s&&l(Math.max(t,s),null==e&&t<=u,Math.min(h,r),null==i&&h>=f,o.dir)}if(s=n.to+1,s>=r)break}return 0==h.length&&l(u,null==e,f,null==i,t.textDirection),{top:r,bottom:o,horizontal:h}}}(this.view,t))).reduce(((t,e)=>t.concat(e))),n=[];for(let i of t.selection.ranges){let s=i==t.selection.main;if(i.empty?!s||qi:e.drawRangeCursor){let t=Xi(this.view,i,s);t&&n.push(t)}}return{rangePieces:i,cursors:n}}drawSel({rangePieces:t,cursors:e}){if(t.length!=this.rangePieces.length||t.some(((t,e)=>!t.eq(this.rangePieces[e])))){this.selectionLayer.textContent="";for(let e of t)this.selectionLayer.appendChild(e.draw());this.rangePieces=t}if(e.length!=this.cursors.length||e.some(((t,e)=>!t.eq(this.cursors[e])))){let t=this.cursorLayer.children;if(t.length!==e.length){this.cursorLayer.textContent="";for(const t of e)this.cursorLayer.appendChild(t.draw())}else e.forEach(((e,i)=>e.adjust(t[i])));this.cursors=e}}destroy(){this.selectionLayer.remove(),this.cursorLayer.remove()}}),Gi={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};qi&&(Gi[".cm-line"].caretColor="transparent !important");const Ki=n.Wl.override(Di.theme(Gi));function Ui(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Xt.LTR?e.left:e.right-t.scrollDOM.clientWidth)-t.scrollDOM.scrollLeft,top:e.top-t.scrollDOM.scrollTop}}function Yi(t,e,i){let s=n.jT.cursor(e);return{from:Math.max(i.from,t.moveToLineBoundary(s,!1,!0).from),to:Math.min(i.to,t.moveToLineBoundary(s,!0,!0).from)}}function Xi(t,e,i){let n=t.coordsAtPos(e.head,e.assoc||1);if(!n)return null;let s=Ui(t);return new Ji(n.left-s.left,n.top-s.top,-1,n.bottom-n.top,i?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary")}function Qi(){return tn}const Zi=ft.line({attributes:{class:"cm-activeLine"}}),tn=It.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,i=[];for(let n of t.state.selection.ranges){if(!n.empty)return ft.none;let s=t.visualLineAt(n.head);s.from>e&&(i.push(Zi.range(s.from)),e=s.from)}return ft.set(i)}},{decorations:t=>t.decorations})},62038:(t,e,i)=>{"use strict";i.d(e,{V:()=>o});const n="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),s="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class o{constructor(t,e){this.rules=[];let{finish:i}=e||{};function n(t){return/^@/.test(t)?[t]:t.split(/,\s*/)}function s(t,e,r,o){let h=[],l=/^@(\w+)\b/.exec(t[0]),a=l&&"keyframes"==l[1];if(l&&null==e)return r.push(t[0]+";");for(let i in e){let o=e[i];if(/&/.test(i))s(i.split(/,\s*/).map((e=>t.map((t=>e.replace(/&/,t))))).reduce(((t,e)=>t.concat(e))),o,r);else if(o&&"object"==typeof o){if(!l)throw new RangeError("The value of a property ("+i+") should be a primitive value.");s(n(i),o,h,a)}else null!=o&&h.push(i.replace(/_.*/,"").replace(/[A-Z]/g,(t=>"-"+t.toLowerCase()))+": "+o+";")}(h.length||a)&&r.push((!i||l||o?t:t.map(i)).join(", ")+" {"+h.join(" ")+"}")}for(let e in t)s(n(e),t[e],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let t=r[n]||1;return r[n]=t+1,"ͼ"+t.toString(36)}static mount(t,e){(t[s]||new l(t)).mount(Array.isArray(e)?e:[e])}}let h=null;class l{constructor(t){if(!t.head&&t.adoptedStyleSheets&&"undefined"!=typeof CSSStyleSheet){if(h)return t.adoptedStyleSheets=[h.sheet].concat(t.adoptedStyleSheets),t[s]=h;this.sheet=new CSSStyleSheet,t.adoptedStyleSheets=[this.sheet].concat(t.adoptedStyleSheets),h=this}else{this.styleTag=(t.ownerDocument||t).createElement("style");let e=t.head||t;e.insertBefore(this.styleTag,e.firstChild)}this.modules=[],t[s]=this}mount(t){let e=this.sheet,i=0,n=0;for(let s=0;s<t.length;s++){let r=t[s],o=this.modules.indexOf(r);if(o<n&&o>-1&&(this.modules.splice(o,1),n--,o=-1),-1==o){if(this.modules.splice(n++,0,r),e)for(let t=0;t<r.rules.length;t++)e.insertRule(r.rules[t],i++)}else{for(;n<o;)i+=this.modules[n++].rules.length;i+=r.rules.length,n++}}if(!e){let t="";for(let e=0;e<this.modules.length;e++)t+=this.modules[e].getRules()+"\n";this.styleTag.textContent=t}}}}}]);
//# sourceMappingURL=chunk.e0d5adff691c132bdb9f.js.map