|
|
"use strict";(self["webpackChunkhalo_admin"]=self["webpackChunkhalo_admin"]||[]).push([[788],{26788:function(t,e,i){i.d(e,{Z:function(){return ha}});var n=function(){var t=this,e=t.$createElement,i=t._self._c||e;return i("div",{ref:"codemirrorRef"})},s=[],r=i(23222),o=(i(31875),i(11074),i(41479),i(25117)),l=i(46941);const h=l.q6.define(),a=l.q6.define(),c=l.r$.define(),u=l.r$.define({combine(t){return(0,l.BO)(t,{minDepth:100,newGroupDelay:500},{minDepth:Math.max,newGroupDelay:Math.min})}});function d(t){let e=0;return t.iterChangedRanges(((t,i)=>e=i)),e}const f=l.QQ.define({create(){return R.empty},update(t,e){let i=e.state.facet(u),n=e.annotation(h);if(n){let s=e.docChanged?l.jT.single(d(e.changes)):void 0,r=b.fromTransaction(e,s),o=n.side,h=0==o?t.undone:t.done;return h=r?x(h,h.length,i.minDepth,r):D(h,e.startState.selection),new R(0==o?n.rest:h,0==o?h:n.rest)}let s=e.annotation(a);if("full"!=s&&"before"!=s||(t=t.isolate()),!1===e.annotation(l.YW.addToHistory))return e.changes.empty?t:t.addMapping(e.changes.desc);let r=b.fromTransaction(e),o=e.annotation(l.YW.time),c=e.annotation(l.YW.userEvent);return r?t=t.addChanges(r,o,c,i.newGroupDelay,i.minDepth):e.selection&&(t=t.addSelection(e.startState.selection,o,c,i.newGroupDelay)),"full"!=s&&"after"!=s||(t=t.isolate()),t},toJSON(t){return{done:t.done.map((t=>t.toJSON())),undone:t.undone.map((t=>t.toJSON()))}},fromJSON(t){return new R(t.done.map(b.fromJSON),t.undone.map(b.fromJSON))}});function p(t={}){return[f,u.of(t),o.tk.domEventHandlers({beforeinput(t,e){let i="historyUndo"==t.inputType?m:"historyRedo"==t.inputType?w:null;return!!i&&(t.preventDefault(),i(e))}})]}function g(t,e){return function({state:i,dispatch:n}){if(!e&&i.readOnly)return!1;let s=i.field(f,!1);if(!s)return!1;let r=s.pop(t,i,e);return!!r&&(n(r),!0)}}const m=g(0,!1),w=g(1,!1),v=g(0,!0),y=g(1,!0);class b{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 b(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 b(t.changes&&l.as.fromJSON(t.changes),[],t.mapped&&l.n0.fromJSON(t.mapped),t.startSelection&&l.jT.fromJSON(t.startSelection),t.selectionsAfter.map(l.jT.fromJSON))}static fromTransaction(t,e){let i=M;for(let n of t.startState.facet(c)){let e=n(t);e.length&&(i=i.concat(e))}return!i.length&&t.changes.empty?null:new b(t.changes.invert(t.startState.doc),i,void 0,e||t.startState.selection,M)}static selection(t){return new b(void 0,M,void 0,void 0,t)}}function x(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 k(t,e){let i=[],n=!1;return t.iterChangedRanges(((t,e)=>i.push(t,e))),e.iterChangedRanges(((t,e,s,r)=>{for(let o=0;o<i.length;){let t=i[o++],e=i[o++];r>=t&&s<=e&&(n=!0)}})),n}function S(t,e){return t.ranges.length==e.ranges.length&&0===t.ranges.filter(((t,i)=>t.empty!=e.ranges[i].empty)).length}function A(t,e){return t.length?e.length?t.concat(e):t:e}const M=[],C=200;function D(t,e){if(t.length){let i=t[t.length-1],n=i.selectionsAfter.slice(Math.max(0,i.selectionsAfter.length-C));return n.length&&n[n.length-1].eq(e)?t:(n.push(e),x(t,t.length-1,1e9,i.setSelAfter(n)))}return[b.selection([e])]}function T(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 O(t,e){if(!t.length)return t;let i=t.length,n=M;while(i){let s=E(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?[b.selection(n)]:M}function E(t,e,i){let n=A(t.selectionsAfter.length?t.selectionsAfter.map((t=>t.map(e))):M,i);if(!t.changes)return b.selection(n);let s=t.changes.map(e),r=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(r):r;return new b(s,l.Py.mapEffects(t.effects,e),o,t.startSelection.map(r),n)}const B=/^(input\.type|delete)($|\.)/;class R{constructor(t,e,i=0,n){this.done=t,this.undone=e,this.prevTime=i,this.prevUserEvent=n}isolate(){return this.prevTime?new R(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&&!o.changes.empty&&t.changes&&(!i||B.test(i))&&(!o.selectionsAfter.length&&e-this.prevTime<n&&k(o.changes,t.changes)||"input.type.compose"==i)?x(r,r.length-1,s,new b(t.changes.compose(o.changes),A(t.effects,o.effects),o.mapped,o.startSelection,M)):x(r,r.length,s,t),new R(r,M,e,i)}addSelection(t,e,i,n){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:M;return s.length>0&&e-this.prevTime<n&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&S(s[s.length-1],t)?this:new R(D(this.done,t),this.undone,e,i)}addMapping(t){return new R(O(this.done,t),O(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:h.of({side:t,rest:T(n)}),userEvent:0==t?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let i=1==n.length?M:n.slice(0,n.length-1);return s.mapped&&(i=O(i,s.mapped)),e.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:h.of({side:t,rest:i}),filter:!1,userEvent:0==t?"undo":"redo",scrollIntoView:!0})}return null}}R.empty=new R(M,M);const L=[{key:"Mod-z",run:m,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:w,preventDefault:!0},{key:"Mod-u",run:v,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:y,preventDefault:!0}];var P=i(40405),N=i(96651);class V extends N.uU{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}V.prototype.elementClass="",V.prototype.toDOM=void 0,V.prototype.mapMode=l.gc.TrackBefore,V.prototype.startSide=V.prototype.endSide=-1,V.prototype.point=!0;const I=l.r$.define(),H={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>N.Xs.empty,lineMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},W=l.r$.define();function F(t){return[j(),W.of(Object.assign(Object.assign({},H),t))]}const z=o.tk.baseTheme({".cm-gutters":{display:"flex",height:"100%",boxSizing:"border-box",left:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#999",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"}}),q=l.r$.define({combine:t=>t.some((t=>t))});function j(t){let e=[$,z];return t&&!1===t.fixed&&e.push(q.of(!0)),e}const $=o.lg.fromClass(class{constructor(t){this.view=t,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight+"px",this.gutters=t.state.facet(W).map((e=>new U(t,e)));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!t.state.facet(q),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}update(t){if(this.updateGutters(t)){let e=this.prevViewport,i=t.view.viewport,n=Math.min(e.to,i.to)-Math.max(e.from,i.from);this.syncGutters(n<.8*(i.to-i.from))}t.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight+"px"),this.view.state.facet(q)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&this.dom.remove();let i=N.Xs.iter(this.view.state.facet(I),this.view.viewport.from),n=[],s=this.gutters.map((t=>new G(t,this.view.viewport,-this.view.documentPadding.top)));for(let r of this.view.viewportLineBlocks){let t;if(Array.isArray(r.type)){for(let e of r.type)if(e.type==o.kH.Text){t=e;break}}else t=r.type==o.kH.Text?r:void 0;if(t){n.length&&(n=[]),_(i,n,r.from);for(let e of s)e.line(this.view,t,n)}}for(let r of s)r.finish();t&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(t){let e=t.startState.facet(W),i=t.state.facet(W),n=t.docChanged||t.heightChanged||t.viewportChanged||!N.Xs.eq(t.startState.facet(I),t.state.facet(I),t.view.viewport.from,t.view.viewport.to);if(e==i)for(let s of this.gutters)s.update(t)&&(n=!0);else{n=!0;let s=[];for(let n of i){let i=e.indexOf(n);i<0?s.push(new U(this.view,n)):(this.gutters[i].update(t),s.push(this.gutters[i]))}for(let t of this.gutters)t.dom.remove(),s.indexOf(t)<0&&t.destroy();for(let t of s)this.dom.appendChild(t.dom);this.gutters=s}return n}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove()}},{provide:o.BF.scrollMargins.from((t=>0!=t.gutters.length&&t.fixed?t.view.textDirection==o.Nm.LTR?{left:t.dom.offsetWidth}:{right:t.dom.offsetWidth}:null))});function K(t){return Array.isArray(t)?t:[t]}function _(t,e,i){while(t.value&&t.from<=i)t.from==i&&e.push(t.value),t.next()}class G{constructor(t,e,i){this.gutter=t,this.height=i,this.localMarkers=[],this.i=0,this.cursor=N.Xs.iter(t.markers,e.from)}line(t,e,i){this.localMarkers.length&&(this.localMarkers=[]),_(this.cursor,this.localMarkers,e.from);let n=i.length?this.localMarkers.concat(i):this.localMarkers,s=this.gutter.config.lineMarker(t,e,n);s&&n.unshift(s);let r=this.gutter;if(0==n.length&&!r.config.renderEmptyElements)return;let o=e.top-this.height;if(this.i==r.elements.length){let i=new X(t,e.height,o,n);r.elements.push(i),r.dom.appendChild(i.dom)}else r.elements[this.i].update(t,e.height,o,n);this.height=e.bottom,this.i++}finish(){let t=this.gutter;while(t.elements.length>this.i){let e=t.elements.pop();t.dom.removeChild(e.dom),e.destroy()}}}class U{constructor(t,e){this.view=t,this.config=e,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in e.domEventHandlers)this.dom.addEventListener(i,(n=>{let s=t.lineBlockAtHeight(n.clientY-t.documentTop);e.domEventHandlers[i](t,s,n)&&n.preventDefault()}));this.markers=K(e.markers(t)),e.initialSpacer&&(this.spacer=new X(t,0,0,[e.initialSpacer(t)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(t){let e=this.markers;if(this.markers=K(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let e=this.config.updateSpacer(this.spacer.markers[0],t);e!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[e])}let i=t.view.viewport;return!N.Xs.eq(this.markers,e,i.from,i.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(t)}destroy(){for(let t of this.elements)t.destroy()}}class X{constructor(t,e,i,n){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.update(t,e,i,n)}update(t,e,i,n){this.height!=e&&(this.dom.style.height=(this.height=e)+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),J(this.markers,n)||this.setMarkers(t,n)}setMarkers(t,e){let i="cm-gutterElement",n=this.dom.firstChild;for(let s=0,r=0;;){let o=r,l=s<e.length?e[s++]:null,h=!1;if(l){let t=l.elementClass;t&&(i+=" "+t);for(let e=r;e<this.markers.length;e++)if(this.markers[e].compare(l)){o=e,h=!0;break}}else o=this.markers.length;while(r<o){let t=this.markers[r++];if(t.toDOM){t.destroy(n);let e=n.nextSibling;n.remove(),n=e}}if(!l)break;l.toDOM&&(h?n=n.nextSibling:this.dom.insertBefore(l.toDOM(t),n)),h&&r++}this.dom.className=i,this.markers=e}destroy(){this.setMarkers(null,[])}}function J(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(!t[i].compare(e[i]))return!1;return!0}const Y=l.r$.define(),Q=l.r$.define({combine(t){return(0,l.BO)(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,e){let i=Object.assign({},t);for(let n in e){let t=i[n],s=e[n];i[n]=t?(e,i,n)=>t(e,i,n)||s(e,i,n):s}return i}})}});class Z extends V{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function tt(t,e){return t.state.facet(Q).formatNumber(e,t.state)}const et=W.compute([Q],(t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(Y)},lineMarker(t,e,i){return i.some((t=>t.toDOM))?null:new Z(tt(t,t.state.doc.lineAt(e.from).number))},lineMarkerChange:t=>t.startState.facet(Q)!=t.state.facet(Q),initialSpacer(t){return new Z(tt(t,nt(t.state.doc.lines)))},updateSpacer(t,e){let i=tt(e.view,nt(e.view.state.doc.lines));return i==t.number?t:new Z(i)},domEventHandlers:t.facet(Q).domEventHandlers})));function it(t={}){return[Q.of(t),j(),et]}function nt(t){let e=9;while(e<t)e=10*e+9;return e}const st=new class extends V{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},rt=I.compute(["selection"],(t=>{let e=[],i=-1;for(let n of t.selection.ranges)if(n.empty){let s=t.doc.lineAt(n.head).from;s>i&&(i=s,e.push(st.range(s)))}return N.Xs.of(e)}));function ot(){return rt}function lt(t,e){let i=e.mapPos(t.from,1),n=e.mapPos(t.to,-1);return i>=n?void 0:{from:i,to:n}}const ht=l.Py.define({map:lt}),at=l.Py.define({map:lt});function ct(t){let e=[];for(let{head:i}of t.state.selection.ranges)e.some((t=>t.from<=i&&t.to>=i))||e.push(t.lineBlockAt(i));return e}const ut=l.QQ.define({create(){return o.p.none},update(t,e){t=t.map(e.changes);for(let i of e.effects)i.is(ht)&&!ft(t,i.value.from,i.value.to)?t=t.update({add:[At.range(i.value.from,i.value.to)]}):i.is(at)&&(t=t.update({filter:(t,e)=>i.value.from!=t||i.value.to!=e,filterFrom:i.value.from,filterTo:i.value.to}));if(e.selection){let i=!1,{head:n}=e.selection.main;t.between(n,n,((t,e)=>{t<n&&e>n&&(i=!0)})),i&&(t=t.update({filterFrom:n,filterTo:n,filter:(t,e)=>e<=n||t>=n}))}return t},provide:t=>o.tk.decorations.from(t)});function dt(t,e,i){var n;let s=null;return null===(n=t.field(ut,!1))||void 0===n||n.between(e,i,((t,e)=>{(!s||s.from>t)&&(s={from:t,to:e})})),s}function ft(t,e,i){let n=!1;return t.between(e,e,((t,s)=>{t==e&&s==i&&(n=!0)})),n}function pt(t,e){return t.field(ut,!1)?e:e.concat(l.Py.appendConfig.of(St()))}const gt=t=>{for(let e of ct(t)){let i=(0,P.Fw)(t.state,e.from,e.to);if(i)return t.dispatch({effects:pt(t.state,[ht.of(i),wt(t,i)])}),!0}return!1},mt=t=>{if(!t.state.field(ut,!1))return!1;let e=[];for(let i of ct(t)){let n=dt(t.state,i.from,i.to);n&&e.push(at.of(n),wt(t,n,!1))}return e.length&&t.dispatch({effects:e}),e.length>0};function wt(t,e,i=!0){let n=t.state.doc.lineAt(e.from).number,s=t.state.doc.lineAt(e.to).number;return o.tk.announce.of(`${t.state.phrase(i?"Folded lines":"Unfolded lines")} ${n} ${t.state.phrase("to")} ${s}.`)}const vt=t=>{let{state:e}=t,i=[];for(let n=0;n<e.doc.length;){let s=t.lineBlockAt(n),r=(0,P.Fw)(e,s.from,s.to);r&&i.push(ht.of(r)),n=(r?t.lineBlockAt(r.to):s).to+1}return i.length&&t.dispatch({effects:pt(t.state,i)}),!!i.length},yt=t=>{let e=t.state.field(ut,!1);if(!e||!e.size)return!1;let i=[];return e.between(0,t.state.doc.length,((t,e)=>{i.push(at.of({from:t,to:e}))})),t.dispatch({effects:i}),!0},bt=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:gt},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:mt},{key:"Ctrl-Alt-[",run:vt},{key:"Ctrl-Alt-]",run:yt}],xt={placeholderDOM:null,placeholderText:"…"},kt=l.r$.define({combine(t){return(0,l.BO)(t,xt)}});function St(t){let e=[ut,Tt];return t&&e.push(kt.of(t)),e}const At=o.p.replace({widget:new class extends o.l9{ignoreEvents(){return!1}toDOM(t){let{state:e}=t,i=e.facet(kt),n=e=>{let i=t.lineBlockAt(t.posAtDOM(e.target)),n=dt(t.state,i.from,i.to);n&&t.dispatch({effects:at.of(n)}),e.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(t,n);let s=document.createElement("span");return s.textContent=i.placeholderText,s.setAttribute("aria-label",e.phrase("folded code")),s.title=e.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=n,s}}}),Mt={openText:"⌄",closedText:"›",markerDOM:null};class Ct extends V{constructor(t,e){super(),this.config=t,this.open=e}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let e=document.createElement("span");return e.textContent=this.open?this.config.openText:this.config.closedText,e.title=t.state.phrase(this.open?"Fold line":"Unfold line"),e}}function Dt(t={}){let e=Object.assign(Object.assign({},Mt),t),i=new Ct(e,!0),n=new Ct(e,!1),s=o.lg.fromClass(class{constructor(t){this.from=t.viewport.from,this.markers=this.buildMarkers(t)}update(t){(t.docChanged||t.viewportChanged||t.startState.facet(P.dK)!=t.state.facet(P.dK)||t.startState.field(ut,!1)!=t.state.field(ut,!1))&&(this.markers=this.buildMarkers(t.view))}buildMarkers(t){let e=new N.f_;for(let s of t.viewportLineBlocks){let r=dt(t.state,s.from,s.to)?n:(0,P.Fw)(t.state,s.from,s.to)?i:null;r&&e.add(s.from,s.from,r)}return e.finish()}});return[s,F({class:"cm-foldGutter",markers(t){var e;return(null===(e=t.plugin(s))||void 0===e?void 0:e.markers)||N.Xs.empty},initialSpacer(){return new Ct(e,!1)},domEventHandlers:{click:(t,e)=>{let i=dt(t.state,e.from,e.to);if(i)return t.dispatch({effects:at.of(i)}),!0;let n=(0,P.Fw)(t.state,e.from,e.to);return!!n&&(t.dispatch({effects:ht.of(n)}),!0)}}}),St()]}const Tt=o.tk.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});var Ot=i(76089),Et=i(17918);const Bt=o.tk.baseTheme({".cm-matchingBracket":{backgroundColor:"#328c8252"},".cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Rt=1e4,Lt="()[]{}",Pt=l.r$.define({combine(t){return(0,l.BO)(t,{afterCursor:!0,brackets:Lt,maxScanDistance:Rt})}}),Nt=o.p.mark({class:"cm-matchingBracket"}),Vt=o.p.mark({class:"cm-nonmatchingBracket"}),It=l.QQ.define({create(){return o.p.none},update(t,e){if(!e.docChanged&&!e.selection)return t;let i=[],n=e.state.facet(Pt);for(let s of e.state.selection.ranges){if(!s.empty)continue;let t=zt(e.state,s.head,-1,n)||s.head>0&&zt(e.state,s.head-1,1,n)||n.afterCursor&&(zt(e.state,s.head,1,n)||s.head<e.state.doc.length&&zt(e.state,s.head+1,-1,n));if(!t)continue;let r=t.matched?Nt:Vt;i.push(r.range(t.start.from,t.start.to)),t.end&&i.push(r.range(t.end.from,t.end.to))}return o.p.set(i,!0)},provide:t=>o.tk.decorations.from(t)}),Ht=[It,Bt];function Wt(t={}){return[Pt.of(t),Ht]}function Ft(t,e,i){let n=t.prop(e<0?Et.md.openedBy:Et.md.closedBy);if(n)return n;if(1==t.name.length){let n=i.indexOf(t.name);if(n>-1&&n%2==(e<0?1:0))return[i[n+e]]}return null}function zt(t,e,i,n={}){let s=n.maxScanDistance||Rt,r=n.brackets||Lt,o=(0,P.qz)(t),l=o.resolveInner(e,i);for(let h=l;h;h=h.parent){let n=Ft(h.type,i,r);if(n&&h.from<h.to)return qt(t,e,i,h,n,r)}return jt(t,e,i,o,l.type,s,r)}function qt(t,e,i,n,s,r){let o=n.parent,l={from:n.from,to:n.to},h=0,a=null===o||void 0===o?void 0:o.cursor;if(a&&(i<0?a.childBefore(n.from):a.childAfter(n.to)))do{if(i<0?a.to<=n.from:a.from>=n.to){if(0==h&&s.indexOf(a.type.name)>-1&&a.from<a.to)return{start:l,end:{from:a.from,to:a.to},matched:!0};if(Ft(a.type,i,r))h++;else if(Ft(a.type,-i,r)&&(h--,0==h))return{start:l,end:a.from==a.to?void 0:{from:a.from,to:a.to},matched:!1}}}while(i<0?a.prevSibling():a.nextSibling());return{start:l,matched:!1}}function jt(t,e,i,n,s,r,o){let l=i<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),h=o.indexOf(l);if(h<0||h%2==0!=i>0)return null;let a={from:i<0?e-1:e,to:i>0?e+1:e},c=t.doc.iterRange(e,i>0?t.doc.length:0),u=0;for(let d=0;!c.next().done&&d<=r;){let t=c.value;i<0&&(d+=t.length);let r=e+d*i;for(let e=i>0?0:t.length-1,l=i>0?t.length:-1;e!=l;e+=i){let l=o.indexOf(t[e]);if(!(l<0||n.resolve(r+e,1).type!=s))if(l%2==0==i>0)u++;else{if(1==u)return{start:a,end:{from:r+e,to:r+e+1},matched:l>>1==h>>1};u--}}i>0&&(d+=t.length)}return c.done?{start:a,matched:!1}:null}function $t(t,e){return l.jT.create(t.ranges.map(e),t.mainIndex)}function Kt(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function _t({state:t,dispatch:e},i){let n=$t(t.selection,i);return!n.eq(t.selection)&&(e(Kt(t,n)),!0)}function Gt(t,e){return l.jT.cursor(e?t.to:t.from)}function Ut(t,e){return _t(t,(i=>i.empty?t.moveByChar(i,e):Gt(i,e)))}const Xt=t=>Ut(t,t.textDirection!=o.Nm.LTR),Jt=t=>Ut(t,t.textDirection==o.Nm.LTR);function Yt(t,e){return _t(t,(i=>i.empty?t.moveByGroup(i,e):Gt(i,e)))}const Qt=t=>Yt(t,t.textDirection!=o.Nm.LTR),Zt=t=>Yt(t,t.textDirection==o.Nm.LTR);function te(t,e,i){if(e.type.prop(i))return!0;let n=e.to-e.from;return n&&(n>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function ee(t,e,i){let n=(0,P.qz)(t).resolveInner(e.head),s=i?Et.md.closedBy:Et.md.openedBy;for(let l=e.head;;){let e=i?n.childAfter(l):n.childBefore(l);if(!e)break;te(t,e,s)?n=e:l=i?e.to:e.from}let r,o,h=n.type.prop(s);return o=h&&(r=i?zt(t,n.from,1):zt(t,n.to,-1))&&r.matched?i?r.end.to:r.end.from:i?n.to:n.from,l.jT.cursor(o,i?-1:1)}const ie=t=>_t(t,(e=>ee(t.state,e,t.textDirection!=o.Nm.LTR))),ne=t=>_t(t,(e=>ee(t.state,e,t.textDirection==o.Nm.LTR)));function se(t,e){return _t(t,(i=>{if(!i.empty)return Gt(i,e);let n=t.moveVertically(i,e);return n.head!=i.head?n:t.moveToLineBoundary(i,e)}))}const re=t=>se(t,!1),oe=t=>se(t,!0);function le(t,e){let{state:i}=t,n=$t(i.selection,(i=>i.empty?t.moveVertically(i,e,t.dom.clientHeight):Gt(i,e)));if(n.eq(i.selection))return!1;let s=t.coordsAtPos(i.selection.main.head),r=t.scrollDOM.getBoundingClientRect();return t.dispatch(Kt(i,n),{effects:s&&s.top>r.top&&s.bottom<r.bottom?o.tk.scrollIntoView(n.main.head,{y:"start",yMargin:s.top-r.top}):void 0}),!0}const he=t=>le(t,!1),ae=t=>le(t,!0);function ce(t,e,i){let n=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,i);if(s.head==e.head&&s.head!=(i?n.to:n.from)&&(s=t.moveToLineBoundary(e,i,!1)),!i&&s.head==n.from&&n.length){let i=/^\s*/.exec(t.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;i&&e.head!=n.from+i&&(s=l.jT.cursor(n.from+i))}return s}const ue=t=>_t(t,(e=>ce(t,e,!0))),de=t=>_t(t,(e=>ce(t,e,!1))),fe=t=>_t(t,(e=>l.jT.cursor(t.lineBlockAt(e.head).from,1))),pe=t=>_t(t,(e=>l.jT.cursor(t.lineBlockAt(e.head).to,-1)));function ge(t,e,i){let n=!1,s=$t(t.selection,(e=>{let s=zt(t,e.head,-1)||zt(t,e.head,1)||e.head>0&&zt(t,e.head-1,1)||e.head<t.doc.length&&zt(t,e.head+1,-1);if(!s||!s.end)return e;n=!0;let r=s.start.from==e.head?s.end.to:s.end.from;return i?l.jT.range(e.anchor,r):l.jT.cursor(r)}));return!!n&&(e(Kt(t,s)),!0)}const me=({state:t,dispatch:e})=>ge(t,e,!1);function we(t,e){let i=$t(t.state.selection,(t=>{let i=e(t);return l.jT.range(t.anchor,i.head,i.goalColumn)}));return!i.eq(t.state.selection)&&(t.dispatch(Kt(t.state,i)),!0)}function ve(t,e){return we(t,(i=>t.moveByChar(i,e)))}const ye=t=>ve(t,t.textDirection!=o.Nm.LTR),be=t=>ve(t,t.textDirection==o.Nm.LTR);function xe(t,e){return we(t,(i=>t.moveByGroup(i,e)))}const ke=t=>xe(t,t.textDirection!=o.Nm.LTR),Se=t=>xe(t,t.textDirection==o.Nm.LTR);const Ae=t=>we(t,(e=>ee(t.state,e,t.textDirection!=o.Nm.LTR))),Me=t=>we(t,(e=>ee(t.state,e,t.textDirection==o.Nm.LTR)));function Ce(t,e){return we(t,(i=>t.moveVertically(i,e)))}const De=t=>Ce(t,!1),Te=t=>Ce(t,!0);function Oe(t,e){return we(t,(i=>t.moveVertically(i,e,t.dom.clientHeight)))}const Ee=t=>Oe(t,!1),Be=t=>Oe(t,!0),Re=t=>we(t,(e=>ce(t,e,!0))),Le=t=>we(t,(e=>ce(t,e,!1))),Pe=t=>we(t,(e=>l.jT.cursor(t.lineBlockAt(e.head).from))),Ne=t=>we(t,(e=>l.jT.cursor(t.lineBlockAt(e.head).to))),Ve=({state:t,dispatch:e})=>(e(Kt(t,{anchor:0})),!0),Ie=({state:t,dispatch:e})=>(e(Kt(t,{anchor:t.doc.length})),!0),He=({state:t,dispatch:e})=>(e(Kt(t,{anchor:t.selection.main.anchor,head:0})),!0),We=({state:t,dispatch:e})=>(e(Kt(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),Fe=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),ze=({state:t,dispatch:e})=>{let i=ii(t).map((({from:e,to:i})=>l.jT.range(e,Math.min(i+1,t.doc.length))));return e(t.update({selection:l.jT.create(i),userEvent:"select"})),!0},qe=({state:t,dispatch:e})=>{let i=$t(t.selection,(e=>{var i;let n=(0,P.qz)(t).resolveInner(e.head,1);while(!(n.from<e.from&&n.to>=e.to||n.to>e.to&&n.from<=e.from)&&(null===(i=n.parent)||void 0===i?void 0:i.parent))n=n.parent;return l.jT.range(n.to,n.from)}));return e(Kt(t,i)),!0},je=({state:t,dispatch:e})=>{let i=t.selection,n=null;return i.ranges.length>1?n=l.jT.create([i.main]):i.main.empty||(n=l.jT.create([l.jT.cursor(i.main.head)])),!!n&&(e(Kt(t,n)),!0)};function $e({state:t,dispatch:e},i){if(t.readOnly)return!1;let n="delete.selection",s=t.changeByRange((t=>{let{from:e,to:s}=t;if(e==s){let t=i(e);t<e?n="delete.backward":t>e&&(n="delete.forward"),e=Math.min(e,t),s=Math.max(s,t)}return e==s?{range:t}:{changes:{from:e,to:s},range:l.jT.cursor(e)}}));return!s.changes.empty&&(e(t.update(s,{scrollIntoView:!0,userEvent:n})),!0)}function Ke(t,e,i){if(t instanceof o.tk)for(let n of t.pluginField(o.BF.atomicRanges))n.between(e,e,((t,n)=>{t<e&&n>e&&(e=i?n:t)}));return e}const _e=(t,e)=>$e(t,(i=>{let n,s,{state:r}=t,o=r.doc.lineAt(i);if(!e&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(n=o.text.slice(0,i-o.from))){if("\t"==n[n.length-1])return i-1;let t=(0,Ot.IS)(n,r.tabSize),e=t%(0,P.y1)(r)||(0,P.y1)(r);for(let s=0;s<e&&" "==n[n.length-1-s];s++)i--;s=i}else s=(0,Ot.cp)(o.text,i-o.from,e)+o.from,s==i&&o.number!=(e?r.doc.lines:1)&&(s+=e?1:-1);return Ke(t,s,e)})),Ge=t=>_e(t,!1),Ue=t=>_e(t,!0),Xe=(t,e)=>$e(t,(i=>{let n=i,{state:s}=t,r=s.doc.lineAt(n),o=s.charCategorizer(n);for(let t=null;;){if(n==(e?r.to:r.from)){n==i&&r.number!=(e?s.doc.lines:1)&&(n+=e?1:-1);break}let l=(0,Ot.cp)(r.text,n-r.from,e)+r.from,h=r.text.slice(Math.min(n,l)-r.from,Math.max(n,l)-r.from),a=o(h);if(null!=t&&a!=t)break;" "==h&&n==i||(t=a),n=l}return Ke(t,n,e)})),Je=t=>Xe(t,!1),Ye=t=>Xe(t,!0),Qe=t=>$e(t,(e=>{let i=t.lineBlockAt(e).to;return Ke(t,e<i?i:Math.min(t.state.doc.length,e+1),!0)})),Ze=t=>$e(t,(e=>{let i=t.lineBlockAt(e).from;return Ke(t,e>i?i:Math.max(0,e-1),!1)})),ti=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange((t=>({changes:{from:t.from,to:t.to,insert:Ot.xv.of(["",""])},range:l.jT.cursor(t.from)})));return e(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0},ei=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange((e=>{if(!e.empty||0==e.from||e.from==t.doc.length)return{range:e};let i=e.from,n=t.doc.lineAt(i),s=i==n.from?i-1:(0,Ot.cp)(n.text,i-n.from,!1)+n.from,r=i==n.to?i+1:(0,Ot.cp)(n.text,i-n.from,!0)+n.from;return{changes:{from:s,to:r,insert:t.doc.slice(i,r).append(t.doc.slice(s,i))},range:l.jT.cursor(r)}}));return!i.changes.empty&&(e(t.update(i,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function ii(t){let e=[],i=-1;for(let n of t.selection.ranges){let s=t.doc.lineAt(n.from),r=t.doc.lineAt(n.to);if(n.empty||n.to!=r.from||(r=t.doc.lineAt(n.to-1)),i>=s.number){let t=e[e.length-1];t.to=r.to,t.ranges.push(n)}else e.push({from:s.from,to:r.to,ranges:[n]});i=r.number+1}return e}function ni(t,e,i){if(t.readOnly)return!1;let n=[],s=[];for(let r of ii(t)){if(i?r.to==t.doc.length:0==r.from)continue;let e=t.doc.lineAt(i?r.to+1:r.from-1),o=e.length+1;if(i){n.push({from:r.to,to:e.to},{from:r.from,insert:e.text+t.lineBreak});for(let e of r.ranges)s.push(l.jT.range(Math.min(t.doc.length,e.anchor+o),Math.min(t.doc.length,e.head+o)))}else{n.push({from:e.from,to:r.from},{from:r.to,insert:t.lineBreak+e.text});for(let t of r.ranges)s.push(l.jT.range(t.anchor-o,t.head-o))}}return!!n.length&&(e(t.update({changes:n,scrollIntoView:!0,selection:l.jT.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0)}const si=({state:t,dispatch:e})=>ni(t,e,!1),ri=({state:t,dispatch:e})=>ni(t,e,!0);function oi(t,e,i){if(t.readOnly)return!1;let n=[];for(let s of ii(t))i?n.push({from:s.from,insert:t.doc.slice(s.from,s.to)+t.lineBreak}):n.push({from:s.to,insert:t.lineBreak+t.doc.slice(s.from,s.to)});return e(t.update({changes:n,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const li=({state:t,dispatch:e})=>oi(t,e,!1),hi=({state:t,dispatch:e})=>oi(t,e,!0),ai=t=>{if(t.state.readOnly)return!1;let{state:e}=t,i=e.changes(ii(e).map((({from:t,to:i})=>(t>0?t--:i<e.doc.length&&i++,{from:t,to:i})))),n=$t(e.selection,(e=>t.moveVertically(e,!0))).map(i);return t.dispatch({changes:i,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function ci(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let i,n=(0,P.qz)(t).resolveInner(e),s=n.childBefore(e),r=n.childAfter(e);return s&&r&&s.to<=e&&r.from>=e&&(i=s.type.prop(Et.md.closedBy))&&i.indexOf(r.name)>-1&&t.doc.lineAt(s.to).from==t.doc.lineAt(r.from).from?{from:s.to,to:r.from}:null}const ui=fi(!1),di=fi(!0);function fi(t){return({state:e,dispatch:i})=>{if(e.readOnly)return!1;let n=e.changeByRange((i=>{let{from:n,to:s}=i,r=e.doc.lineAt(n),o=!t&&n==s&&ci(e,n);t&&(n=s=(s<=r.to?r:e.doc.lineAt(s)).to);let h=new P.Gn(e,{simulateBreak:n,simulateDoubleBreak:!!o}),a=(0,P.K0)(h,n);null==a&&(a=/^\s*/.exec(e.doc.lineAt(n).text)[0].length);while(s<r.to&&/\s/.test(r.text[s-r.from]))s++;o?({from:n,to:s}=o):n>r.from&&n<r.from+100&&!/\S/.test(r.text.slice(0,n))&&(n=r.from);let c=["",(0,P.SS)(e,a)];return o&&c.push((0,P.SS)(e,h.lineIndent(r.from,-1))),{changes:{from:n,to:s,insert:Ot.xv.of(c)},range:l.jT.cursor(n+1+c[1].length)}}));return i(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function pi(t,e){let i=-1;return t.changeByRange((n=>{let s=[];for(let o=n.from;o<=n.to;){let r=t.doc.lineAt(o);r.number>i&&(n.empty||n.to>r.from)&&(e(r,s,n),i=r.number),o=r.to+1}let r=t.changes(s);return{changes:s,range:l.jT.range(r.mapPos(n.anchor,1),r.mapPos(n.head,1))}}))}const gi=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=Object.create(null),n=new P.Gn(t,{overrideIndentation:t=>{let e=i[t];return null==e?-1:e}}),s=pi(t,((e,s,r)=>{let o=(0,P.K0)(n,e.from);if(null==o)return;/\S/.test(e.text)||(o=0);let l=/^\s*/.exec(e.text)[0],h=(0,P.SS)(t,o);(l!=h||r.from<e.from+l.length)&&(i[e.from]=o,s.push({from:e.from,to:e.from+l.length,insert:h}))}));return s.changes.empty||e(t.update(s,{userEvent:"indent"})),!0},mi=({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(pi(t,((e,i)=>{i.push({from:e.from,insert:t.facet(P.c)})})),{userEvent:"input.indent"})),!0),wi=({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(pi(t,((e,i)=>{let n=/^\s*/.exec(e.text)[0];if(!n)return;let s=(0,Ot.IS)(n,t.tabSize),r=0,o=(0,P.SS)(t,Math.max(0,s-(0,P.y1)(t)));while(r<n.length&&r<o.length&&n.charCodeAt(r)==o.charCodeAt(r))r++;i.push({from:e.from+r,to:e.from+n.length,insert:o.slice(r)})})),{userEvent:"delete.dedent"})),!0),vi=[{key:"Ctrl-b",run:Xt,shift:ye,preventDefault:!0},{key:"Ctrl-f",run:Jt,shift:be},{key:"Ctrl-p",run:re,shift:De},{key:"Ctrl-n",run:oe,shift:Te},{key:"Ctrl-a",run:fe,shift:Pe},{key:"Ctrl-e",run:pe,shift:Ne},{key:"Ctrl-d",run:Ue},{key:"Ctrl-h",run:Ge},{key:"Ctrl-k",run:Qe},{key:"Ctrl-Alt-h",run:Je},{key:"Ctrl-o",run:ti},{key:"Ctrl-t",run:ei},{key:"Ctrl-v",run:ae},{key:"Alt-v",run:he}],yi=[{key:"ArrowLeft",run:Xt,shift:ye,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Qt,shift:ke},{mac:"Cmd-ArrowLeft",run:de,shift:Le},{key:"ArrowRight",run:Jt,shift:be,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Zt,shift:Se},{mac:"Cmd-ArrowRight",run:ue,shift:Re},{key:"ArrowUp",run:re,shift:De,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Ve,shift:He},{mac:"Ctrl-ArrowUp",run:he,shift:Ee},{key:"ArrowDown",run:oe,shift:Te,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Ie,shift:We},{mac:"Ctrl-ArrowDown",run:ae,shift:Be},{key:"PageUp",run:he,shift:Ee},{key:"PageDown",run:ae,shift:Be},{key:"Home",run:de,shift:Le},{key:"Mod-Home",run:Ve,shift:He},{key:"End",run:ue,shift:Re},{key:"Mod-End",run:Ie,shift:We},{key:"Enter",run:ui},{key:"Mod-a",run:Fe},{key:"Backspace",run:Ge,shift:Ge},{key:"Delete",run:Ue},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Je},{key:"Mod-Delete",mac:"Alt-Delete",run:Ye},{mac:"Mod-Backspace",run:Ze},{mac:"Mod-Delete",run:Qe}].concat(vi.map((t=>({mac:t.key,run:t.run,shift:t.shift})))),bi=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:ie,shift:Ae},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:ne,shift:Me},{key:"Alt-ArrowUp",run:si},{key:"Shift-Alt-ArrowUp",run:li},{key:"Alt-ArrowDown",run:ri},{key:"Shift-Alt-ArrowDown",run:hi},{key:"Escape",run:je},{key:"Mod-Enter",run:di},{key:"Alt-l",mac:"Ctrl-l",run:ze},{key:"Mod-i",run:qe,preventDefault:!0},{key:"Mod-[",run:wi},{key:"Mod-]",run:mi},{key:"Mod-Alt-\\",run:gi},{key:"Shift-Mod-k",run:ai},{key:"Shift-Mod-\\",run:me}].concat(yi),xi={key:"Tab",run:mi,shift:wi},ki={brackets:["(","[","{","'",'"'],before:")]}'\":;>"},Si=l.Py.define({map(t,e){let i=e.mapPos(t,-1,l.gc.TrackAfter);return null==i?void 0:i}}),Ai=l.Py.define({map(t,e){return e.mapPos(t)}}),Mi=new class extends N.uU{};Mi.startSide=1,Mi.endSide=-1;const Ci=l.QQ.define({create(){return N.Xs.empty},update(t,e){if(e.selection){let i=e.state.doc.lineAt(e.selection.main.head).from,n=e.startState.doc.lineAt(e.startState.selection.main.head).from;i!=e.changes.mapPos(n,-1)&&(t=N.Xs.empty)}t=t.map(e.changes);for(let i of e.effects)i.is(Si)?t=t.update({add:[Mi.range(i.value,i.value+1)]}):i.is(Ai)&&(t=t.update({filter:t=>t!=i.value}));return t}});function Di(){return[o.tk.inputHandler.of(Bi),Ci]}const Ti="()[]{}<>";function Oi(t){for(let e=0;e<Ti.length;e+=2)if(Ti.charCodeAt(e)==t)return Ti.charAt(e+1);return(0,Ot.bg)(t<128?t:t+1)}function Ei(t,e){return t.languageDataAt("closeBrackets",e)[0]||ki}function Bi(t,e,i,n){if(t.composing)return!1;let s=t.state.selection.main;if(n.length>2||2==n.length&&1==(0,Ot.nZ)((0,Ot.gm)(n,0))||e!=s.from||i!=s.to)return!1;let r=Pi(t.state,n);return!!r&&(t.dispatch(r),!0)}const Ri=({state:t,dispatch:e})=>{let i=Ei(t,t.selection.main.head),n=i.brackets||ki.brackets,s=null,r=t.changeByRange((e=>{if(e.empty){let i=Ii(t.doc,e.head);for(let s of n)if(s==i&&Vi(t.doc,e.head)==Oi((0,Ot.gm)(s,0)))return{changes:{from:e.head-s.length,to:e.head+s.length},range:l.jT.cursor(e.head-s.length),userEvent:"delete.backward"}}return{range:s=e}}));return s||e(t.update(r,{scrollIntoView:!0})),!s},Li=[{key:"Backspace",run:Ri}];function Pi(t,e){let i=Ei(t,t.selection.main.head),n=i.brackets||ki.brackets;for(let s of n){let r=Oi((0,Ot.gm)(s,0));if(e==s)return r==s?Fi(t,s,n.indexOf(s+s+s)>-1):Hi(t,s,r,i.before||ki.before);if(e==r&&Ni(t,t.selection.main.from))return Wi(t,s,r)}return null}function Ni(t,e){let i=!1;return t.field(Ci).between(0,t.doc.length,(t=>{t==e&&(i=!0)})),i}function Vi(t,e){let i=t.sliceString(e,e+2);return i.slice(0,(0,Ot.nZ)((0,Ot.gm)(i,0)))}function Ii(t,e){let i=t.sliceString(e-2,e);return(0,Ot.nZ)((0,Ot.gm)(i,0))==i.length?i:i.slice(1)}function Hi(t,e,i,n){let s=null,r=t.changeByRange((r=>{if(!r.empty)return{changes:[{insert:e,from:r.from},{insert:i,from:r.to}],effects:Si.of(r.to+e.length),range:l.jT.range(r.anchor+e.length,r.head+e.length)};let o=Vi(t.doc,r.head);return!o||/\s/.test(o)||n.indexOf(o)>-1?{changes:{insert:e+i,from:r.head},effects:Si.of(r.head+e.length),range:l.jT.cursor(r.head+e.length)}:{range:s=r}}));return s?null:t.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function Wi(t,e,i){let n=null,s=t.selection.ranges.map((e=>e.empty&&Vi(t.doc,e.head)==i?l.jT.cursor(e.head+i.length):n=e));return n?null:t.update({selection:l.jT.create(s,t.selection.mainIndex),scrollIntoView:!0,effects:t.selection.ranges.map((({from:t})=>Ai.of(t)))})}function Fi(t,e,i){let n=null,s=t.changeByRange((s=>{if(!s.empty)return{changes:[{insert:e,from:s.from},{insert:e,from:s.to}],effects:Si.of(s.to+e.length),range:l.jT.range(s.anchor+e.length,s.head+e.length)};let r=s.head,o=Vi(t.doc,r);if(o==e){if(zi(t,r))return{changes:{insert:e+e,from:r},effects:Si.of(r+e.length),range:l.jT.cursor(r+e.length)};if(Ni(t,r)){let n=i&&t.sliceDoc(r,r+3*e.length)==e+e+e;return{range:l.jT.cursor(r+e.length*(n?3:1)),effects:Ai.of(r)}}}else{if(i&&t.sliceDoc(r-2*e.length,r)==e+e&&zi(t,r-2*e.length))return{changes:{insert:e+e+e+e,from:r},effects:Si.of(r+e.length),range:l.jT.cursor(r+e.length)};if(t.charCategorizer(r)(o)!=l.D0.Word){let i=t.sliceDoc(r-1,r);if(i!=e&&t.charCategorizer(r)(i)!=l.D0.Word)return{changes:{insert:e+e,from:r},effects:Si.of(r+e.length),range:l.jT.cursor(r+e.length)}}}return{range:n=s}}));return n?null:t.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function zi(t,e){let i=(0,P.qz)(t).resolveInner(e+1);return i.parent&&i.from==e}const qi=l.r$.define({combine(t){let e,i;for(let n of t)e=e||n.topContainer,i=i||n.bottomContainer;return{topContainer:e,bottomContainer:i}}});function ji(t,e){let i=t.plugin($i),n=i?i.specs.indexOf(e):-1;return n>-1?i.panels[n]:null}const $i=o.lg.fromClass(class{constructor(t){this.input=t.state.facet(Ui),this.specs=this.input.filter((t=>t)),this.panels=this.specs.map((e=>e(t)));let e=t.state.facet(qi);this.top=new Ki(t,!0,e.topContainer),this.bottom=new Ki(t,!1,e.bottomContainer),this.top.sync(this.panels.filter((t=>t.top))),this.bottom.sync(this.panels.filter((t=>!t.top)));for(let i of this.panels)i.dom.classList.add("cm-panel"),i.mount&&i.mount()}update(t){let e=t.state.facet(qi);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Ki(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Ki(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let i=t.state.facet(Ui);if(i!=this.input){let e=i.filter((t=>t)),n=[],s=[],r=[],o=[];for(let i of e){let e,l=this.specs.indexOf(i);l<0?(e=i(t.view),o.push(e)):(e=this.panels[l],e.update&&e.update(t)),n.push(e),(e.top?s:r).push(e)}this.specs=e,this.panels=n,this.top.sync(s),this.bottom.sync(r);for(let t of o)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}else for(let n of this.panels)n.update&&n.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:o.BF.scrollMargins.from((t=>({top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()})))});class Ki{constructor(t,e,i){this.view=t,this.top=e,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(t){for(let e of this.panels)e.destroy&&t.indexOf(e)<0&&e.destroy();this.panels=t,this.syncDOM()}syncDOM(){if(0==this.panels.length)return void(this.dom&&(this.dom.remove(),this.dom=void 0));if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let t=this.dom.firstChild;for(let e of this.panels)if(e.dom.parentNode==this.dom){while(t!=e.dom)t=_i(t);t=t.nextSibling}else this.dom.insertBefore(e.dom,t);while(t)t=_i(t)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(this.container&&this.classes!=this.view.themeClasses){for(let t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}}function _i(t){let e=t.nextSibling;return t.remove(),e}const Gi=o.tk.baseTheme({".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"}}),Ui=l.r$.define({enables:[$i,Gi]});function Xi(){var t=arguments[0];"string"==typeof t&&(t=document.createElement(t));var e=1,i=arguments[1];if(i&&"object"==typeof i&&null==i.nodeType&&!Array.isArray(i)){for(var n in i)if(Object.prototype.hasOwnProperty.call(i,n)){var s=i[n];"string"==typeof s?t.setAttribute(n,s):null!=s&&(t[n]=s)}e++}for(;e<arguments.length;e++)Ji(t,arguments[e]);return t}function Ji(t,e){if("string"==typeof e)t.appendChild(document.createTextNode(e));else if(null==e);else if(null!=e.nodeType)t.appendChild(e);else{if(!Array.isArray(e))throw new RangeError("Unsupported child node: "+e);for(var i=0;i<e.length;i++)Ji(t,e[i])}}const Yi="function"==typeof String.prototype.normalize?t=>t.normalize("NFKD"):t=>t;class Qi{constructor(t,e,i=0,n=t.length,s){this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=t.iterRange(i,n),this.bufferStart=i,this.normalize=s?t=>s(Yi(t)):Yi,this.query=this.normalize(e)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return(0,Ot.gm)(this.buffer,this.bufferPos)}next(){while(this.matches.length)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let t=this.peek();if(t<0)return this.done=!0,this;let e=(0,Ot.bg)(t),i=this.bufferStart+this.bufferPos;this.bufferPos+=(0,Ot.nZ)(t);let n=this.normalize(e);for(let s=0,r=i;;s++){let t=n.charCodeAt(s),o=this.match(t,r);if(o)return this.value=o,this;if(s==n.length-1)break;r==i&&s<e.length&&e.charCodeAt(s)==t&&r++}}}match(t,e){let i=null;for(let n=0;n<this.matches.length;n+=2){let s=this.matches[n],r=!1;this.query.charCodeAt(s)==t&&(s==this.query.length-1?i={from:this.matches[n+1],to:e+1}:(this.matches[n]++,r=!0)),r||(this.matches.splice(n,2),n-=2)}return this.query.charCodeAt(0)==t&&(1==this.query.length?i={from:e,to:e+1}:this.matches.push(1,e)),i}}"undefined"!=typeof Symbol&&(Qi.prototype[Symbol.iterator]=function(){return this});const Zi={from:-1,to:-1,match:/.*/.exec("")},tn="gm"+(null==/x/.unicode?"":"u");class en{constructor(t,e,i,n=0,s=t.length){if(this.to=s,this.curLine="",this.done=!1,this.value=Zi,/\\[sWDnr]|\n|\r|\[\^/.test(e))return new rn(t,e,i,n,s);this.re=new RegExp(e,tn+((null===i||void 0===i?void 0:i.ignoreCase)?"i":"")),this.iter=t.iter();let r=t.lineAt(n);this.curLineStart=r.from,this.matchPos=n,this.getLine(this.curLineStart)}getLine(t){this.iter.next(t),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let t=this.matchPos-this.curLineStart;;){this.re.lastIndex=t;let e=this.matchPos<=this.to&&this.re.exec(this.curLine);if(e){let i=this.curLineStart+e.index,n=i+e[0].length;if(this.matchPos=n+(i==n?1:0),i==this.curLine.length&&this.nextLine(),i<n||i>this.value.to)return this.value={from:i,to:n,match:e},this;t=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),t=0}}}}const nn=new WeakMap;class sn{constructor(t,e){this.from=t,this.text=e}get to(){return this.from+this.text.length}static get(t,e,i){let n=nn.get(t);if(!n||n.from>=i||n.to<=e){let n=new sn(e,t.sliceString(e,i));return nn.set(t,n),n}if(n.from==e&&n.to==i)return n;let{text:s,from:r}=n;return r>e&&(s=t.sliceString(e,r)+s,r=e),n.to<i&&(s+=t.sliceString(n.to,i)),nn.set(t,new sn(r,s)),new sn(e,s.slice(e-r,i-r))}}class rn{constructor(t,e,i,n,s){this.text=t,this.to=s,this.done=!1,this.value=Zi,this.matchPos=n,this.re=new RegExp(e,tn+((null===i||void 0===i?void 0:i.ignoreCase)?"i":"")),this.flat=sn.get(t,n,this.chunkEnd(n+5e3))}chunkEnd(t){return t>=this.to?this.to:this.text.lineAt(t).to}next(){for(;;){let t=this.re.lastIndex=this.matchPos-this.flat.from,e=this.re.exec(this.flat.text);if(e&&!e[0]&&e.index==t&&(this.re.lastIndex=t+1,e=this.re.exec(this.flat.text)),e&&this.flat.to<this.to&&e.index+e[0].length>this.flat.text.length-10&&(e=null),e){let t=this.flat.from+e.index,i=t+e[0].length;return this.value={from:t,to:i,match:e},this.matchPos=i+(t==i?1:0),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=sn.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function on(t){try{return new RegExp(t,tn),!0}catch(e){return!1}}function ln(t){let e=Xi("input",{class:"cm-textfield",name:"line"}),i=Xi("form",{class:"cm-gotoLine",onkeydown:e=>{27==e.keyCode?(e.preventDefault(),t.dispatch({effects:hn.of(!1)}),t.focus()):13==e.keyCode&&(e.preventDefault(),n())},onsubmit:t=>{t.preventDefault(),n()}},Xi("label",t.state.phrase("Go to line"),": ",e)," ",Xi("button",{class:"cm-button",type:"submit"},t.state.phrase("go")));function n(){let i=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(e.value);if(!i)return;let{state:n}=t,s=n.doc.lineAt(n.selection.main.head),[,r,o,h,a]=i,c=h?+h.slice(1):0,u=o?+o:s.number;if(o&&a){let t=u/100;r&&(t=t*("-"==r?-1:1)+s.number/n.doc.lines),u=Math.round(n.doc.lines*t)}else o&&r&&(u=u*("-"==r?-1:1)+s.number);let d=n.doc.line(Math.max(1,Math.min(n.doc.lines,u)));t.dispatch({effects:hn.of(!1),selection:l.jT.cursor(d.from+Math.max(0,Math.min(c,d.length))),scrollIntoView:!0}),t.focus()}return{dom:i,pos:-10}}"undefined"!=typeof Symbol&&(en.prototype[Symbol.iterator]=rn.prototype[Symbol.iterator]=function(){return this});const hn=l.Py.define(),an=l.QQ.define({create(){return!0},update(t,e){for(let i of e.effects)i.is(hn)&&(t=i.value);return t},provide:t=>Ui.from(t,(t=>t?ln:null))}),cn=t=>{let e=ji(t,ln);if(!e){let i=[hn.of(!0)];null==t.state.field(an,!1)&&i.push(l.Py.appendConfig.of([an,un])),t.dispatch({effects:i}),e=ji(t,ln)}return e&&e.dom.querySelector("input").focus(),!0},un=o.tk.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),dn={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100},fn=l.r$.define({combine(t){return(0,l.BO)(t,dn,{highlightWordAroundCursor:(t,e)=>t||e,minSelectionLength:Math.min,maxMatches:Math.min})}});function pn(t){let e=[vn,wn];return t&&e.push(fn.of(t)),e}const gn=o.p.mark({class:"cm-selectionMatch"}),mn=o.p.mark({class:"cm-selectionMatch cm-selectionMatch-main"}),wn=o.lg.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.selectionSet||t.docChanged||t.viewportChanged)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=t.state.facet(fn),{state:i}=t,n=i.selection;if(n.ranges.length>1)return o.p.none;let s,r=n.main,h=null;if(r.empty){if(!e.highlightWordAroundCursor)return o.p.none;let t=i.wordAt(r.head);if(!t)return o.p.none;h=i.charCategorizer(r.head),s=i.sliceDoc(t.from,t.to)}else{let t=r.to-r.from;if(t<e.minSelectionLength||t>200)return o.p.none;if(s=i.sliceDoc(r.from,r.to).trim(),!s)return o.p.none}let a=[];for(let c of t.visibleRanges){let t=new Qi(i.doc,s,c.from,c.to);while(!t.next().done){let{from:n,to:s}=t.value;if((!h||(0==n||h(i.sliceDoc(n-1,n))!=l.D0.Word)&&(s==i.doc.length||h(i.sliceDoc(s,s+1))!=l.D0.Word))&&(h&&n<=r.from&&s>=r.to?a.push(mn.range(n,s)):(n>=r.to||s<=r.from)&&a.push(gn.range(n,s)),a.length>e.maxMatches))return o.p.none}}return o.p.set(a)}},{decorations:t=>t.decorations}),vn=o.tk.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),yn=({state:t,dispatch:e})=>{let{selection:i}=t,n=l.jT.create(i.ranges.map((e=>t.wordAt(e.head)||l.jT.cursor(e.head))),i.mainIndex);return!n.eq(i)&&(e(t.update({selection:n})),!0)};function bn(t,e){let{main:i,ranges:n}=t.selection,s=t.wordAt(i.head),r=s&&s.from==i.from&&s.to==i.to;for(let o=!1,l=new Qi(t.doc,e,n[n.length-1].to);;){if(l.next(),!l.done){if(o&&n.some((t=>t.from==l.value.from)))continue;if(r){let e=t.wordAt(l.value.from);if(!e||e.from!=l.value.from||e.to!=l.value.to)continue}return l.value}if(o)return null;l=new Qi(t.doc,e,0,Math.max(0,n[n.length-1].from-1)),o=!0}}const xn=({state:t,dispatch:e})=>{let{ranges:i}=t.selection;if(i.some((t=>t.from===t.to)))return yn({state:t,dispatch:e});let n=t.sliceDoc(i[0].from,i[0].to);if(t.selection.ranges.some((e=>t.sliceDoc(e.from,e.to)!=n)))return!1;let s=bn(t,n);return!!s&&(e(t.update({selection:t.selection.addRange(l.jT.range(s.from,s.to),!1),scrollIntoView:!0})),!0)},kn=l.r$.define({combine(t){var e;return{top:t.reduce(((t,e)=>null!==t&&void 0!==t?t:e.top),void 0)||!1,caseSensitive:t.reduce(((t,e)=>null!==t&&void 0!==t?t:e.caseSensitive||e.matchCase),void 0)||!1,createPanel:(null===(e=t.find((t=>t.createPanel)))||void 0===e?void 0:e.createPanel)||(t=>new _n(t))}}});class Sn{constructor(t){this.search=t.search,this.caseSensitive=!!t.caseSensitive,this.regexp=!!t.regexp,this.replace=t.replace||"",this.valid=!!this.search&&(!this.regexp||on(this.search))}eq(t){return this.search==t.search&&this.replace==t.replace&&this.caseSensitive==t.caseSensitive&&this.regexp==t.regexp}create(){return this.regexp?new Cn(this):new Mn(this)}}class An{constructor(t){this.spec=t}}class Mn extends An{constructor(t){super(t),this.unquoted=t.search.replace(/\\([nrt\\])/g,((t,e)=>"n"==e?"\n":"r"==e?"\r":"t"==e?"\t":"\\"))}cursor(t,e=0,i=t.length){return new Qi(t,this.unquoted,e,i,this.spec.caseSensitive?void 0:t=>t.toLowerCase())}nextMatch(t,e,i){let n=this.cursor(t,i).nextOverlapping();return n.done&&(n=this.cursor(t,0,e).nextOverlapping()),n.done?null:n.value}prevMatchInRange(t,e,i){for(let n=i;;){let i=Math.max(e,n-1e4-this.unquoted.length),s=this.cursor(t,i,n),r=null;while(!s.nextOverlapping().done)r=s.value;if(r)return r;if(i==e)return null;n-=1e4}}prevMatch(t,e,i){return this.prevMatchInRange(t,0,e)||this.prevMatchInRange(t,i,t.length)}getReplacement(t){return this.spec.replace}matchAll(t,e){let i=this.cursor(t),n=[];while(!i.next().done){if(n.length>=e)return null;n.push(i.value)}return n}highlight(t,e,i,n){let s=this.cursor(t,Math.max(0,e-this.unquoted.length),Math.min(i+this.unquoted.length,t.length));while(!s.next().done)n(s.value.from,s.value.to)}}class Cn extends An{cursor(t,e=0,i=t.length){return new en(t,this.spec.search,this.spec.caseSensitive?void 0:{ignoreCase:!0},e,i)}nextMatch(t,e,i){let n=this.cursor(t,i).next();return n.done&&(n=this.cursor(t,0,e).next()),n.done?null:n.value}prevMatchInRange(t,e,i){for(let n=1;;n++){let s=Math.max(e,i-1e4*n),r=this.cursor(t,s,i),o=null;while(!r.next().done)o=r.value;if(o&&(s==e||o.from>s+10))return o;if(s==e)return null}}prevMatch(t,e,i){return this.prevMatchInRange(t,0,e)||this.prevMatchInRange(t,i,t.length)}getReplacement(t){return this.spec.replace.replace(/\$([$&\d+])/g,((e,i)=>"$"==i?"$":"&"==i?t.match[0]:"0"!=i&&+i<t.match.length?t.match[i]:e))}matchAll(t,e){let i=this.cursor(t),n=[];while(!i.next().done){if(n.length>=e)return null;n.push(i.value)}return n}highlight(t,e,i,n){let s=this.cursor(t,Math.max(0,e-250),Math.min(i+250,t.length));while(!s.next().done)n(s.value.from,s.value.to)}}const Dn=l.Py.define(),Tn=l.Py.define(),On=l.QQ.define({create(t){return new En(qn(t).create(),zn)},update(t,e){for(let i of e.effects)i.is(Dn)?t=new En(i.value.create(),t.panel):i.is(Tn)&&(t=new En(t.query,i.value?zn:null));return t},provide:t=>Ui.from(t,(t=>t.panel))});class En{constructor(t,e){this.query=t,this.panel=e}}const Bn=o.p.mark({class:"cm-searchMatch"}),Rn=o.p.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Ln=o.lg.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(On))}update(t){let e=t.state.field(On);(e!=t.startState.field(On)||t.docChanged||t.selectionSet)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return o.p.none;let{view:i}=this,n=new N.f_;for(let s=0,r=i.visibleRanges,o=r.length;s<o;s++){let{from:e,to:l}=r[s];while(s<o-1&&l>r[s+1].from-500)l=r[++s].to;t.highlight(i.state.doc,e,l,((t,e)=>{let s=i.state.selection.ranges.some((i=>i.from==t&&i.to==e));n.add(t,e,s?Rn:Bn)}))}return n.finish()}},{decorations:t=>t.decorations});function Pn(t){return e=>{let i=e.state.field(On,!1);return i&&i.query.spec.valid?t(e,i):jn(e)}}const Nn=Pn(((t,{query:e})=>{let{from:i,to:n}=t.state.selection.main,s=e.nextMatch(t.state.doc,i,n);return!(!s||s.from==i&&s.to==n)&&(t.dispatch({selection:{anchor:s.from,head:s.to},scrollIntoView:!0,effects:Jn(t,s),userEvent:"select.search"}),!0)})),Vn=Pn(((t,{query:e})=>{let{state:i}=t,{from:n,to:s}=i.selection.main,r=e.prevMatch(i.doc,n,s);return!!r&&(t.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:Jn(t,r),userEvent:"select.search"}),!0)})),In=Pn(((t,{query:e})=>{let i=e.matchAll(t.state.doc,1e3);return!(!i||!i.length)&&(t.dispatch({selection:l.jT.create(i.map((t=>l.jT.range(t.from,t.to)))),userEvent:"select.search.matches"}),!0)})),Hn=({state:t,dispatch:e})=>{let i=t.selection;if(i.ranges.length>1||i.main.empty)return!1;let{from:n,to:s}=i.main,r=[],o=0;for(let h=new Qi(t.doc,t.sliceDoc(n,s));!h.next().done;){if(r.length>1e3)return!1;h.value.from==n&&(o=r.length),r.push(l.jT.range(h.value.from,h.value.to))}return e(t.update({selection:l.jT.create(r,o),userEvent:"select.search.matches"})),!0},Wn=Pn(((t,{query:e})=>{let{state:i}=t,{from:n,to:s}=i.selection.main;if(i.readOnly)return!1;let r=e.nextMatch(i.doc,n,n);if(!r)return!1;let o,l,h=[];if(r.from==n&&r.to==s&&(l=i.toText(e.getReplacement(r)),h.push({from:r.from,to:r.to,insert:l}),r=e.nextMatch(i.doc,r.from,r.to)),r){let t=0==h.length||h[0].from>=r.to?0:r.to-r.from-l.length;o={anchor:r.from-t,head:r.to-t}}return t.dispatch({changes:h,selection:o,scrollIntoView:!!o,effects:r?Jn(t,r):void 0,userEvent:"input.replace"}),!0})),Fn=Pn(((t,{query:e})=>{if(t.state.readOnly)return!1;let i=e.matchAll(t.state.doc,1e9).map((t=>{let{from:i,to:n}=t;return{from:i,to:n,insert:e.getReplacement(t)}}));return!!i.length&&(t.dispatch({changes:i,userEvent:"input.replace.all"}),!0)}));function zn(t){return t.state.facet(kn).createPanel(t)}function qn(t,e){var i;let n=t.selection.main,s=n.empty||n.to>n.from+100?"":t.sliceDoc(n.from,n.to),r=null!==(i=null===e||void 0===e?void 0:e.caseSensitive)&&void 0!==i?i:t.facet(kn).caseSensitive;return e&&!s?e:new Sn({search:s.replace(/\n/g,"\\n"),caseSensitive:r})}const jn=t=>{let e=t.state.field(On,!1);if(e&&e.panel){let i=ji(t,zn);if(!i)return!1;let n=i.dom.querySelector("[name=search]");if(n!=t.root.activeElement){let i=qn(t.state,e.query.spec);i.valid&&t.dispatch({effects:Dn.of(i)}),n.focus(),n.select()}}else t.dispatch({effects:[Tn.of(!0),e?Dn.of(qn(t.state,e.query.spec)):l.Py.appendConfig.of(Qn)]});return!0},$n=t=>{let e=t.state.field(On,!1);if(!e||!e.panel)return!1;let i=ji(t,zn);return i&&i.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:Tn.of(!1)}),!0},Kn=[{key:"Mod-f",run:jn,scope:"editor search-panel"},{key:"F3",run:Nn,shift:Vn,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Nn,shift:Vn,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:$n,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Hn},{key:"Alt-g",run:cn},{key:"Mod-d",run:xn,preventDefault:!0}];class _n{constructor(t){this.view=t;let e=this.query=t.state.field(On).query.spec;function i(t,e,i){return Xi("button",{class:"cm-button",name:t,onclick:e,type:"button"},i)}this.commit=this.commit.bind(this),this.searchField=Xi("input",{value:e.search,placeholder:Gn(t,"Find"),"aria-label":Gn(t,"Find"),class:"cm-textfield",name:"search",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Xi("input",{value:e.replace,placeholder:Gn(t,"Replace"),"aria-label":Gn(t,"Replace"),class:"cm-textfield",name:"replace",onchange:this.commit,onkeyup:this.commit}),this.caseField=Xi("input",{type:"checkbox",name:"case",checked:e.caseSensitive,onchange:this.commit}),this.reField=Xi("input",{type:"checkbox",name:"re",checked:e.regexp,onchange:this.commit}),this.dom=Xi("div",{onkeydown:t=>this.keydown(t),class:"cm-search"},[this.searchField,i("next",(()=>Nn(t)),[Gn(t,"next")]),i("prev",(()=>Vn(t)),[Gn(t,"previous")]),i("select",(()=>In(t)),[Gn(t,"all")]),Xi("label",null,[this.caseField,Gn(t,"match case")]),Xi("label",null,[this.reField,Gn(t,"regexp")]),...t.state.readOnly?[]:[Xi("br"),this.replaceField,i("replace",(()=>Wn(t)),[Gn(t,"replace")]),i("replaceAll",(()=>Fn(t)),[Gn(t,"replace all")]),Xi("button",{name:"close",onclick:()=>$n(t),"aria-label":Gn(t,"close"),type:"button"},["×"])]])}commit(){let t=new Sn({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,replace:this.replaceField.value});t.eq(this.query)||(this.query=t,this.view.dispatch({effects:Dn.of(t)}))}keydown(t){(0,o.$1)(this.view,t,"search-panel")?t.preventDefault():13==t.keyCode&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?Vn:Nn)(this.view)):13==t.keyCode&&t.target==this.replaceField&&(t.preventDefault(),Wn(this.view))}update(t){for(let e of t.transactions)for(let t of e.effects)t.is(Dn)&&!t.value.eq(this.query)&&this.setQuery(t.value)}setQuery(t){this.query=t,this.searchField.value=t.search,this.replaceField.value=t.replace,this.caseField.checked=t.caseSensitive,this.reField.checked=t.regexp}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(kn).top}}function Gn(t,e){return t.state.phrase(e)}const Un=30,Xn=/[\s\.,:;?!]/;function Jn(t,{from:e,to:i}){let n=t.state.doc.lineAt(e).from,s=t.state.doc.lineAt(i).to,r=Math.max(n,e-Un),l=Math.min(s,i+Un),h=t.state.sliceDoc(r,l);if(r!=n)for(let o=0;o<Un;o++)if(!Xn.test(h[o+1])&&Xn.test(h[o])){h=h.slice(o);break}if(l!=s)for(let o=h.length-1;o>h.length-Un;o--)if(!Xn.test(h[o-1])&&Xn.test(h[o])){h=h.slice(0,o);break}return o.tk.announce.of(`${t.state.phrase("current match")}. ${h} ${t.state.phrase("on line")} ${t.state.doc.lineAt(e).number}`)}const Yn=o.tk.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),Qn=[On,l.Wl.lowest(Ln),Yn];var Zn=i(26115);const ts=t=>{let e=rs(t.state);return e.line?is(t):!!e.block&&ns(t)};function es(t,e){return({state:i,dispatch:n})=>{let s=t(e,i.selection.ranges,i);return!!s&&(n(i.update(s)),!0)}}const is=es(as,0),ns=es(hs,0),ss=[{key:"Mod-/",run:ts},{key:"Alt-A",run:ns}];function rs(t,e=t.selection.main.head){let i=t.languageDataAt("commentTokens",e);return i.length?i[0]:{}}const os=50;function ls(t,{open:e,close:i},n,s){let r,o,l=t.sliceDoc(n-os,n),h=t.sliceDoc(s,s+os),a=/\s*$/.exec(l)[0].length,c=/^\s*/.exec(h)[0].length,u=l.length-a;if(l.slice(u-e.length,u)==e&&h.slice(c,c+i.length)==i)return{open:{pos:n-a,margin:a&&1},close:{pos:s+c,margin:c&&1}};s-n<=2*os?r=o=t.sliceDoc(n,s):(r=t.sliceDoc(n,n+os),o=t.sliceDoc(s-os,s));let d=/^\s*/.exec(r)[0].length,f=/\s*$/.exec(o)[0].length,p=o.length-f-i.length;return r.slice(d,d+e.length)==e&&o.slice(p,p+i.length)==i?{open:{pos:n+d+e.length,margin:/\s/.test(r.charAt(d+e.length))?1:0},close:{pos:s-f-i.length,margin:/\s/.test(o.charAt(p-1))?1:0}}:null}function hs(t,e,i){let n=e.map((t=>rs(i,t.from).block));if(!n.every((t=>t)))return null;let s=e.map(((t,e)=>ls(i,n[e],t.from,t.to)));if(2!=t&&!s.every((t=>t))){let t=0;return i.changeByRange((e=>{let{open:i,close:r}=n[t++];if(s[t])return{range:e};let o=i.length+1;return{changes:[{from:e.from,insert:i+" "},{from:e.to,insert:" "+r}],range:l.jT.range(e.anchor+o,e.head+o)}}))}if(1!=t&&s.some((t=>t))){let t=[];for(let e,i=0;i<s.length;i++)if(e=s[i]){let s=n[i],{open:r,close:o}=e;t.push({from:r.pos-s.open.length,to:r.pos+r.margin},{from:o.pos-o.margin,to:o.pos+s.close.length})}return{changes:t}}return null}function as(t,e,i){let n=[],s=-1;for(let{from:r,to:o}of e){let t=n.length,e=1e9;for(let l=r;l<=o;){let t=i.doc.lineAt(l);if(t.from>s&&(r==o||o>t.from)){s=t.from;let r=rs(i,l).line;if(!r)continue;let o=/^\s*/.exec(t.text)[0].length,h=o==t.length,a=t.text.slice(o,o+r.length)==r?o:-1;o<t.text.length&&o<e&&(e=o),n.push({line:t,comment:a,token:r,indent:o,empty:h,single:!1})}l=t.to+1}if(e<1e9)for(let i=t;i<n.length;i++)n[i].indent<n[i].line.text.length&&(n[i].indent=e);n.length==t+1&&(n[t].single=!0)}if(2!=t&&n.some((t=>t.comment<0&&(!t.empty||t.single)))){let t=[];for(let{line:i,token:s,indent:r,empty:o,single:l}of n)!l&&o||t.push({from:i.from+r,insert:s+" "});let e=i.changes(t);return{changes:e,selection:i.selection.map(e,1)}}if(1!=t&&n.some((t=>t.comment>=0))){let t=[];for(let{line:e,comment:i,token:s}of n)if(i>=0){let n=e.from+i,r=n+s.length;" "==e.text[r-e.from]&&r++,t.push({from:n,to:r})}return{changes:t}}return null}var cs=i(70876);i(27510);function us(t){let e;return e=11==t.nodeType?t.getSelection?t:t.ownerDocument:t,e.getSelection()}function ds(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function fs(){let t=document.activeElement;while(t&&t.shadowRoot)t=t.shadowRoot.activeElement;return t}function ps(t,e){if(!e.anchorNode)return!1;try{return ds(t,e.anchorNode)}catch(i){return!1}}function gs(t){return 3==t.nodeType?Ts(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function ms(t,e,i,n){return!!i&&(vs(t,e,i,n,-1)||vs(t,e,i,n,1))}function ws(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function vs(t,e,i,n,s){for(;;){if(t==i&&e==n)return!0;if(e==(s<0?0:ys(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=ws(t)+(s<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if(t=t.childNodes[e+(s<0?-1:0)],1==t.nodeType&&"false"==t.contentEditable)return!1;e=s<0?ys(t):0}}}function ys(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}const bs={left:0,right:0,top:0,bottom:0};function xs(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function ks(t){return{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function Ss(t,e,i,n,s,r,o,l){let h=t.ownerDocument,a=h.defaultView;for(let c=t;c;)if(1==c.nodeType){let t,u=c==h.body;if(u)t=ks(a);else{if(c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.parentNode;continue}let e=c.getBoundingClientRect();t={left:e.left,right:e.left+c.clientWidth,top:e.top,bottom:e.top+c.clientHeight}}let d=0,f=0;if("nearest"==s)e.top<t.top?(f=-(t.top-e.top+o),i>0&&e.bottom>t.bottom+f&&(f=e.bottom-t.bottom+f+o)):e.bottom>t.bottom&&(f=e.bottom-t.bottom+o,i<0&&e.top-f<t.top&&(f=-(t.top+f-e.top+o)));else{let n=e.bottom-e.top,r=t.bottom-t.top,l="center"==s&&n<=r?e.top+n/2-r/2:"start"==s||"center"==s&&i<0?e.top-o:e.bottom-r+o;f=l-t.top}if("nearest"==n)e.left<t.left?(d=-(t.left-e.left+r),i>0&&e.right>t.right+d&&(d=e.right-t.right+d+r)):e.right>t.right&&(d=e.right-t.right+r,i<0&&e.left<t.left+d&&(d=-(t.left+d-e.left+r)));else{let i="center"==n?e.left+(e.right-e.left)/2-(t.right-t.left)/2:"start"==n==l?e.left-r:e.right-(t.right-t.left)+r;d=i-t.left}if(d||f)if(u)a.scrollBy(d,f);else{if(f){let t=c.scrollTop;c.scrollTop+=f,f=c.scrollTop-t}if(d){let t=c.scrollLeft;c.scrollLeft+=d,d=c.scrollLeft-t}e={left:e.left-d,top:e.top-f,right:e.right-d,bottom:e.bottom-f}}if(u)break;c=c.assignedSlot||c.parentNode,n=s="nearest"}else{if(11!=c.nodeType)break;c=c.host}}class As{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){this.set(t.anchorNode,t.anchorOffset,t.focusNode,t.focusOffset)}set(t,e,i,n){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=n}}let Ms,Cs=null;function Ds(t){if(t.setActive)return t.setActive();if(Cs)return t.focus(Cs);let e=[];for(let i=t;i;i=i.parentNode)if(e.push(i,i.scrollTop,i.scrollLeft),i==i.ownerDocument)break;if(t.focus(null==Cs?{get preventScroll(){return Cs={preventScroll:!0},!0}}:void 0),!Cs){Cs=!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 Ts(t,e,i=e){let n=Ms||(Ms=document.createRange());return n.setEnd(t,i),n.setStart(t,e),n}function Os(t,e,i){let n={key:e,code:e,keyCode:i,which:i,cancelable:!0},s=new KeyboardEvent("keydown",n);s.synthetic=!0,t.dispatchEvent(s);let r=new KeyboardEvent("keyup",n);return r.synthetic=!0,t.dispatchEvent(r),s.defaultPrevented||r.defaultPrevented}function Es(t){while(t){if(t&&(9==t.nodeType||11==t.nodeType&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function Bs(t){while(t.attributes.length)t.removeAttributeNode(t.attributes[0])}class Rs{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new Rs(t.parentNode,ws(t),e)}static after(t,e){return new Rs(t.parentNode,ws(t)+1,e)}}const Ls=[];class Ps{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){if(2&this.dirty){let e,i=this.dom,n=null;for(let s of this.children){if(s.dirty){if(!s.dom&&(e=n?n.nextSibling:i.firstChild)){let t=Ps.get(e);t&&(t.parent||t.constructor!=s.constructor)||s.reuseDOM(e)}s.sync(t),s.dirty=0}if(e=n?n.nextSibling:i.firstChild,t&&!t.written&&t.node==i&&e!=s.dom&&(t.written=!0),s.dom.parentNode==i)while(e&&e!=s.dom)e=Ns(e);else i.insertBefore(s.dom,e);n=s.dom}e=n?n.nextSibling:i.firstChild,e&&t&&t.node==i&&(t.written=!0);while(e)e=Ns(e)}else if(1&this.dirty)for(let e of this.children)e.dirty&&(e.sync(t),e.dirty=0)}reuseDOM(t){}localPosFromDOM(t,e){let i;if(t==this.dom)i=this.dom.childNodes[e];else{let n=0==ys(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;while(i&&!Ps.get(i))i=i.nextSibling;if(!i)return this.length;for(let n=0,s=0;;n++){let t=this.children[n];if(t.dom==i)return s;s+=t.length+t.breakAfter}}domBoundsAround(t,e,i=0){let n=-1,s=-1,r=-1,o=-1;for(let l=0,h=i,a=i;l<this.children.length;l++){let i=this.children[l],c=h+i.length;if(h<t&&c>e)return i.domBoundsAround(t,e,h);if(c>=t&&-1==n&&(n=l,s=h),h>e&&i.dom.parentNode==this.dom){r=l,o=a;break}a=c,h=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){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&&(this.dom.cmView=null),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=Ls){this.markDirty();for(let n=t;n<e;n++){let t=this.children[n];t.parent==this&&t.destroy()}this.children.splice(t,e-t,...i);for(let n=0;n<i.length;n++)i[n].setParent(this)}ignoreMutation(t){return!1}ignoreEvent(t){return!1}childCursor(t=this.length){return new Vs(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}get isEditable(){return!0}merge(t,e,i,n,s,r){return!1}become(t){return!1}getSide(){return 0}destroy(){this.parent=null}}function Ns(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}Ps.prototype.breakAfter=0;class Vs{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}}}function Is(t,e,i,n,s,r,o,l,h){let{children:a}=t,c=a.length?a[e]:null,u=r.length?r[r.length-1]:null,d=u?u.breakAfter:o;if(!(e==n&&c&&!o&&!d&&r.length<2&&c.merge(i,s,r.length?u:null,0==i,l,h))){if(n<a.length){let t=a[n];t&&s<t.length?(e==n&&(t=t.split(s),s=0),!d&&u&&t.merge(0,s,u,!0,0,h)?r[r.length-1]=t:(s&&t.merge(0,s,null,!1,0,h),r.push(t))):(null===t||void 0===t?void 0:t.breakAfter)&&(u?u.breakAfter=1:o=1),n++}c&&(c.breakAfter=o,i>0&&(!o&&r.length&&c.merge(i,c.length,r[0],!1,l,0)?c.breakAfter=r.shift().breakAfter:(i<c.length||c.children.length&&0==c.children[c.children.length-1].length)&&c.merge(i,c.length,null,!1,l,0),e++));while(e<n&&r.length)if(a[n-1].become(r[r.length-1]))n--,r.pop(),h=r.length?0:l;else{if(!a[e].become(r[0]))break;e++,r.shift(),l=r.length?0:h}!r.length&&e&&n<a.length&&!a[e-1].breakAfter&&a[n].merge(0,0,a[e-1],!1,l,h)&&e--,(e<n||r.length)&&t.replaceChildren(e,n,r)}}function Hs(t,e,i,n,s,r){let o=t.childCursor(),{i:l,off:h}=o.findPos(i,1),{i:a,off:c}=o.findPos(e,-1),u=e-i;for(let d of n)u+=d.length;t.length+=u,Is(t,a,c,l,h,n,0,s,r)}let Ws="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},Fs="undefined"!=typeof document?document:{documentElement:{style:{}}};const zs=/Edge\/(\d+)/.exec(Ws.userAgent),qs=/MSIE \d/.test(Ws.userAgent),js=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ws.userAgent),$s=!!(qs||js||zs),Ks=!$s&&/gecko\/(\d+)/i.test(Ws.userAgent),_s=!$s&&/Chrome\/(\d+)/.exec(Ws.userAgent),Gs="webkitFontSmoothing"in Fs.documentElement.style,Us=!$s&&/Apple Computer/.test(Ws.vendor),Xs=Us&&(/Mobile\/\w+/.test(Ws.userAgent)||Ws.maxTouchPoints>2);var Js={mac:Xs||/Mac/.test(Ws.platform),windows:/Win/.test(Ws.platform),linux:/Linux|X11/.test(Ws.platform),ie:$s,ie_version:qs?Fs.documentMode||6:js?+js[1]:zs?+zs[1]:0,gecko:Ks,gecko_version:Ks?+(/Firefox\/(\d+)/.exec(Ws.userAgent)||[0,0])[1]:0,chrome:!!_s,chrome_version:_s?+_s[1]:0,ios:Xs,android:/Android\b/.test(Ws.userAgent),webkit:Gs,safari:Us,webkit_version:Gs?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:null!=Fs.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};const Ys=256;class Qs extends Ps{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){3==t.nodeType&&this.createDOM(t)}merge(t,e,i){return(!i||i instanceof Qs&&!(this.length-(e-t)+i.length>Ys))&&(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new Qs(this.text.slice(t));return this.text=this.text.slice(0,t),this.markDirty(),e}localPosFromDOM(t,e){return t==this.dom?e:e?this.text.length:0}domAtPos(t){return new Rs(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 tr(this.dom,t,e)}}class Zs extends Ps{constructor(t,e=[],i=0){super(),this.mark=t,this.children=e,this.length=i;for(let n of e)n.setParent(this)}setAttrs(t){if(Bs(t),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]);return t}reuseDOM(t){t.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(t),this.dirty|=6)}sync(t){this.dom?4&this.dirty&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(t)}merge(t,e,i,n,s,r){return(!i||!(!(i instanceof Zs&&i.mark.eq(this.mark))||t&&s<=0||e<this.length&&r<=0))&&(Hs(this,t,e,i?i.children:[],s-1,r-1),this.markDirty(),!0)}split(t){let e=[],i=0,n=-1,s=0;for(let o of this.children){let r=i+o.length;r>t&&e.push(i<t?o.split(t-i):o),n<0&&i>=t&&(n=s),i=r,s++}let r=this.length-t;return this.length=t,n>-1&&(this.children.length=n,this.markDirty()),new Zs(this.mark,e,r)}domAtPos(t){return lr(this.dom,this.children,t)}coordsAt(t,e){return ar(this,t,e)}}function tr(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?Js.chrome||Js.gecko||(e?(s--,o=1):(r++,o=-1)):i<0?s--:r++;let l=Ts(t,s,r).getClientRects();if(!l.length)return bs;let h=l[(o?o<0:i>=0)?0:l.length-1];return Js.safari&&!o&&0==h.width&&(h=Array.prototype.find.call(l,(t=>t.width))||h),o?xs(h,o<0):h||null}class er extends Ps{constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i,this.prevWidget=null}static create(t,e,i){return new(t.customView||er)(t,e,i)}split(t){let e=er.create(this.widget,this.length-t,this.side);return this.length-=t,e}sync(){this.dom&&this.widget.updateDOM(this.dom)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(this.editorView)),this.dom.contentEditable="false")}getSide(){return this.side}merge(t,e,i,n,s,r){return!(i&&(!(i instanceof er&&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)}become(t){return t.length==this.length&&t instanceof er&&t.side==this.side&&this.widget.constructor==t.widget.constructor&&(this.widget.eq(t.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get overrideDOMText(){if(0==this.length)return Ot.xv.empty;let t=this;while(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):Ot.xv.empty}domAtPos(t){return 0==t?Rs.before(this.dom):Rs.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let i=this.dom.getClientRects(),n=null;if(!i.length)return bs;for(let s=t>0?i.length-1:0;;s+=t>0?-1:1)if(n=i[s],t>0?0==s:s==i.length-1||n.top<n.bottom)break;return 0==t&&e>0||t==this.length&&e<=0?n:xs(n,0==t)}get isEditable(){return!1}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class ir extends er{domAtPos(t){let{topView:e,text:i}=this.widget;return e?nr(t,0,e,i,((t,e)=>t.domAtPos(e)),(t=>new Rs(i,Math.min(t,i.nodeValue.length)))):new Rs(i,Math.min(t,i.nodeValue.length))}sync(){this.setDOM(this.widget.toDOM())}localPosFromDOM(t,e){let{topView:i,text:n}=this.widget;return i?sr(t,e,i,n):Math.min(e,this.length)}ignoreMutation(){return!1}get overrideDOMText(){return null}coordsAt(t,e){let{topView:i,text:n}=this.widget;return i?nr(t,e,i,n,((t,e,i)=>t.coordsAt(e,i)),((t,e)=>tr(n,t,e))):tr(n,t,e)}destroy(){var t;super.destroy(),null===(t=this.widget.topView)||void 0===t||t.destroy()}get isEditable(){return!0}}function nr(t,e,i,n,s,r){if(i instanceof Zs){for(let o of i.children){let i=ds(o.dom,n),l=i?n.nodeValue.length:o.length;if(t<l||t==l&&o.getSide()<=0)return i?nr(t,e,o,n,s,r):s(o,t,e);t-=l}return s(i,i.length,-1)}return i.dom==n?r(t,e):s(i,t,e)}function sr(t,e,i,n){if(i instanceof Zs)for(let s of i.children){let i=0,r=ds(s.dom,n);if(ds(s.dom,t))return i+(r?sr(t,e,s,n):s.localPosFromDOM(t,e));i+=r?n.nodeValue.length:s.length}else if(i.dom==n)return Math.min(e,n.nodeValue.length);return i.localPosFromDOM(t,e)}class rr extends Ps{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof rr&&t.side==this.side}split(){return new rr(this.side)}sync(){if(!this.dom){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),this.setDOM(t)}}getSide(){return this.side}domAtPos(t){return Rs.before(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){let e=this.dom.getBoundingClientRect(),i=or(this,this.side>0?-1:1);return i&&i.top<e.bottom&&i.bottom>e.top?{left:e.left,right:e.right,top:i.top,bottom:i.bottom}:e}get overrideDOMText(){return Ot.xv.empty}}function or(t,e){let i=t.parent,n=i?i.children.indexOf(t):-1;while(i&&n>=0)if(e<0?n>0:n<i.children.length){let t=i.children[n+e];if(t instanceof Qs){let i=t.coordsAt(e<0?t.length:0,e);if(i)return i}n+=e}else{if(!(i instanceof Zs&&i.parent)){let t=i.dom.lastChild;if(t&&"BR"==t.nodeName)return t.getClientRects()[0];break}n=i.parent.children.indexOf(i)+(e<0?0:1),i=i.parent}}function lr(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 Rs.after(i)}return new Rs(t,0)}function hr(t,e,i){let n,{children:s}=t;i>0&&e instanceof Zs&&s.length&&(n=s[s.length-1])instanceof Zs&&n.mark.eq(e.mark)?hr(n,e.children[0],i-1):(s.push(e),e.setParent(t)),t.length+=e.length}function ar(t,e,i){for(let r=0,o=0;o<t.children.length;o++){let n,s=t.children[o],l=r+s.length;if((i<=0||l==t.length||s.getSide()>0?l>=e:l>e)&&(e<l||o+1==t.children.length||(n=t.children[o+1]).length||n.getSide()>0)){let t=0;if(l==r){if(s.getSide()<=0)continue;t=i=-s.getSide()}let n=s.coordsAt(Math.max(0,e-r),i);return t&&n?xs(n,i<0):n}r=l}let n=t.dom.lastChild;if(!n)return t.dom.getBoundingClientRect();let s=gs(n);return s[s.length-1]||null}function cr(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 ur(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 dr(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])}Qs.prototype.children=er.prototype.children=rr.prototype.children=Ls;class fr{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}destroy(t){}}var pr=function(t){return t[t["Text"]=0]="Text",t[t["WidgetBefore"]=1]="WidgetBefore",t[t["WidgetAfter"]=2]="WidgetAfter",t[t["WidgetRange"]=3]="WidgetRange",t}(pr||(pr={}));class gr extends N.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 mr(t)}static widget(t){let e=t.side||0,i=!!t.block;return e+=i?e>0?3e8:-4e8:e>0?1e8:-1e8,new vr(t,e,e,i,t.widget||null,!1)}static replace(t){let e,i,n=!!t.block;if(t.isBlockGap)e=-5e8,i=4e8;else{let{start:s,end:r}=yr(t,n);e=(s?n?-3e8:-1:5e8)-1,i=1+(r?n?2e8:1:-6e8)}return new vr(t,e,i,n,t.widget||null,!0)}static line(t){return new wr(t)}static set(t,e=!1){return N.Xs.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}gr.none=N.Xs.empty;class mr extends gr{constructor(t){let{start:e,end:i}=yr(t);super(e?-1:5e8,i?1:-6e8,null,t),this.tagName=t.tagName||"span",this.class=t.class||"",this.attrs=t.attributes||null}eq(t){return this==t||t instanceof mr&&this.tagName==t.tagName&&this.class==t.class&&ur(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)}}mr.prototype.point=!1;class wr extends gr{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof wr&&ur(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)}}wr.prototype.mapMode=l.gc.TrackBefore,wr.prototype.point=!0;class vr extends gr{constructor(t,e,i,n,s,r){super(e,i,s,t),this.block=n,this.isReplace=r,this.mapMode=n?e<=0?l.gc.TrackBefore:l.gc.TrackAfter:l.gc.TrackDel}get type(){return this.startSide<this.endSide?pr.WidgetRange:this.startSide<=0?pr.WidgetBefore:pr.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&this.widget.estimatedHeight>=5}eq(t){return t instanceof vr&&br(this.widget,t.widget)&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}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 yr(t,e=!1){let{inclusiveStart:i,inclusiveEnd:n}=t;return null==i&&(i=t.inclusive),null==n&&(n=t.inclusive),{start:null!==i&&void 0!==i?i:e,end:null!==n&&void 0!==n?n:e}}function br(t,e){return t==e||!!(t&&e&&t.compare(e))}function xr(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)}vr.prototype.point=!0;class kr extends Ps{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 kr))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),Hs(this,t,e,i?i.children:[],s,r),!0}split(t){let e=new kr;if(e.breakAfter=this.breakAfter,0==this.length)return e;let{i:i,off:n}=this.childPos(t);n&&(e.append(this.children[i].split(n),0),this.children[i].merge(n,this.children[i].length,null,!1,0,0),i++);for(let s=i;s<this.children.length;s++)e.append(this.children[s],0);while(i>0&&0==this.children[i-1].length)this.children[--i].destroy();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){ur(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){hr(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=cr(e,this.attrs||{})),i&&(this.attrs=cr({class:i},this.attrs||{}))}domAtPos(t){return lr(this.dom,this.children,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.dirty|=6)}sync(t){var e;this.dom?4&this.dirty&&(Bs(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),void 0!==this.prevAttrs&&(dr(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t);let i=this.dom.lastChild;while(i&&Ps.get(i)instanceof Zs)i=i.lastChild;if(!i||!this.length||"BR"!=i.nodeName&&0==(null===(e=Ps.get(i))||void 0===e?void 0:e.isEditable)&&(!Js.ios||!this.children.some((t=>t instanceof Qs)))){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 Qs))return null;let i=gs(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 ar(this,t,e)}become(t){return!1}get type(){return pr.Text}static find(t,e){for(let i=0,n=0;i<t.children.length;i++){let s=t.children[i],r=n+s.length;if(r>=e){if(s instanceof kr)return s;if(r>e)break}n=r+s.breakAfter}return null}}class Sr extends Ps{constructor(t,e,i){super(),this.widget=t,this.length=e,this.type=i,this.breakAfter=0,this.prevWidget=null}merge(t,e,i,n,s,r){return!(i&&(!(i instanceof Sr&&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?Rs.before(this.dom):Rs.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new Sr(this.widget,e,this.type);return i.breakAfter=this.breakAfter,i}get children(){return Ls}sync(){this.dom&&this.widget.updateDOM(this.dom)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,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):Ot.xv.empty}domBoundsAround(){return null}become(t){return t instanceof Sr&&t.type==this.type&&t.widget.constructor==this.widget.constructor&&(t.widget.eq(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,this.breakAfter=t.breakAfter,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class Ar{constructor(t,e,i,n){this.doc=t,this.pos=e,this.end=i,this.disallowBlockEffectsBelow=n,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.atCursorPos=!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 Sr&&t.type==pr.WidgetBefore)}getLine(){return this.curLine||(this.content.push(this.curLine=new kr),this.atCursorPos=!0),this.curLine}flushBuffer(t){this.pendingBuffer&&(this.curLine.append(Mr(new rr(-1),t),t.length),this.pendingBuffer=0)}addBlockWidget(t){this.flushBuffer([]),this.curLine=null,this.content.push(t)}finish(t){t?this.pendingBuffer=0:this.flushBuffer([]),this.posCovered()||this.getLine()}buildText(t,e,i){while(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.flushBuffer([]),this.curLine=null,t--;continue}this.text=e,this.textOff=0}let n=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(0,i)),this.getLine().append(Mr(new Qs(this.text.slice(this.textOff,this.textOff+n)),e),i),this.atCursorPos=!0,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 vr)if(i.block){let{type:t}=i;t!=pr.WidgetAfter||this.posCovered()||this.getLine(),this.addBlockWidget(new Sr(i.widget||new Cr("div"),r,t))}else{let o=er.create(i.widget||new Cr("span"),r,i.startSide),l=this.atCursorPos&&!o.isEditable&&s<=n.length&&(t<e||i.startSide>0),h=!o.isEditable&&(t<e||i.startSide<=0),a=this.getLine();2!=this.pendingBuffer||l||(this.pendingBuffer=0),this.flushBuffer(n),l&&(a.append(Mr(new rr(1),n),s),s=n.length+Math.max(0,s-n.length)),a.append(Mr(o,n),s),this.atCursorPos=h,this.pendingBuffer=h?t<e?1:2:0}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)}filterPoint(t,e,i,n){if(n<this.disallowBlockEffectsBelow&&i instanceof vr){if(i.block)throw new RangeError("Block decorations may not be specified via plugins");if(e>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}return!0}static build(t,e,i,n,s){let r=new Ar(t,e,i,s);return r.openEnd=N.Xs.spans(n,e,i,r),r.openStart<0&&(r.openStart=r.openEnd),r.finish(r.openEnd),r}}function Mr(t,e){for(let i of e)t=new Zs(i,[t],t.length);return t}class Cr extends fr{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 Dr=[],Tr=l.r$.define(),Or=l.r$.define(),Er=l.r$.define(),Br=l.r$.define(),Rr=l.r$.define(),Lr=l.r$.define(),Pr=l.Py.define({map:(t,e)=>t.map(e)}),Nr=l.Py.define({map:(t,e)=>t.map(e)});class Vr{constructor(t,e="nearest",i="nearest",n=5,s=5){this.range=t,this.y=e,this.x=i,this.yMargin=n,this.xMargin=s}map(t){return t.empty?this:new Vr(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin)}}const Ir=l.Py.define({map:(t,e)=>t.map(e)});function Hr(t,e,i){let n=t.facet(Br);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 Wr=l.r$.define({combine:t=>!t.length||t[0]});class Fr{constructor(t,e){this.field=t,this.get=e}}class zr{from(t){return new Fr(this,t)}static define(){return new zr}}zr.decorations=zr.define(),zr.atomicRanges=zr.define(),zr.scrollMargins=zr.define();let qr=0;const jr=l.r$.define();class $r{constructor(t,e,i){this.id=t,this.create=e,this.fields=i,this.extension=jr.of(this)}static define(t,e){let{eventHandlers:i,provide:n,decorations:s}=e||{},r=[];if(n)for(let o of Array.isArray(n)?n:[n])r.push(o);return i&&r.push(Kr.from((t=>({plugin:t,handlers:i})))),s&&r.push(zr.decorations.from(s)),new $r(qr++,t,r)}static fromClass(t,e){return $r.define((e=>new t(e)),e)}}const Kr=zr.define();class _r{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}takeField(t,e){if(this.spec)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)try{this.value.update(t)}catch(e){if(Hr(t.state,e,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(i){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(t)}catch(e){Hr(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(null===(e=this.value)||void 0===e?void 0:e.destroy)try{this.value.destroy()}catch(i){Hr(t.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Gr=l.r$.define(),Ur=l.r$.define(),Xr=l.r$.define(),Jr=l.r$.define();class Yr{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new Yr(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 l=n==t.length?null:t[n],h=r-o,a=l?l.fromB:1e9;while(s<e.length&&e[s]<a){let t=e[s],n=e[s+1],r=Math.max(o,t),l=Math.min(a,n);if(r<=l&&new Yr(r+h,l+h,r,l).addToSet(i),n>a)break;s+=2}if(!l)return i;new Yr(l.fromA,l.toA,l.fromB,l.toB).addToSet(i),r=l.toA,o=l.toB}}}class Qr{constructor(t,e,i=Dr){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=l.as.empty(this.startState.doc.length);for(let r of i)this.changes=this.changes.compose(r.changes);let n=[];this.changes.iterChangedRanges(((t,e,i,s)=>n.push(new Yr(t,e,i,s)))),this.changedRanges=n;let s=t.hasFocus;s!=t.inputState.notifiedFocused&&(t.inputState.notifiedFocused=s,this.flags|=1)}get viewportChanged(){return(4&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(10&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some((t=>t.selection))}get empty(){return 0==this.flags&&0==this.transactions.length}}var Zr=function(t){return t[t["LTR"]=0]="LTR",t[t["RTL"]=1]="RTL",t}(Zr||(Zr={}));const to=Zr.LTR,eo=Zr.RTL;function io(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}const no=io("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),so=io("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),ro=Object.create(null),oo=[];for(let aa of["()","[]","{}"]){let t=aa.charCodeAt(0),e=aa.charCodeAt(1);ro[t]=e,ro[e]=-t}function lo(t){return t<=247?no[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?so[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8203||8204==t?256:1}const ho=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;class ao{constructor(t,e,i){this.from=t,this.to=e,this.level=i}get dir(){return this.level%2?eo:to}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 co=[];function uo(t,e){let i=t.length,n=e==to?1:2,s=e==to?2:1;if(!t||1==n&&!ho.test(t))return fo(i);for(let o=0,l=n,h=n;o<i;o++){let e=lo(t.charCodeAt(o));512==e?e=l:8==e&&4==h&&(e=16),co[o]=4==e?2:e,7&e&&(h=e),l=e}for(let o=0,l=n,h=n;o<i;o++){let t=co[o];if(128==t)o<i-1&&l==co[o+1]&&24&l?t=co[o]=l:co[o]=256;else if(64==t){let t=o+1;while(t<i&&64==co[t])t++;let e=o&&8==l||t<i&&8==co[t]?1==h?1:8:256;for(let i=o;i<t;i++)co[i]=e;o=t-1}else 8==t&&1==h&&(co[o]=1);l=t,7&t&&(h=t)}for(let o,l,h,a=0,c=0,u=0;a<i;a++)if(l=ro[o=t.charCodeAt(a)])if(l<0){for(let t=c-3;t>=0;t-=3)if(oo[t+1]==-l){let e=oo[t+2],i=2&e?n:4&e?1&e?s:n:0;i&&(co[a]=co[oo[t]]=i),c=t;break}}else{if(189==oo.length)break;oo[c++]=a,oo[c++]=o,oo[c++]=u}else if(2==(h=co[a])||1==h){let t=h==n;u=t?0:1;for(let e=c-3;e>=0;e-=3){let i=oo[e+2];if(2&i)break;if(t)oo[e+2]|=2;else{if(4&i)break;oo[e+2]|=4}}}for(let o=0;o<i;o++)if(256==co[o]){let t=o+1;while(t<i&&256==co[t])t++;let e=1==(o?co[o-1]:n),s=1==(t<i?co[t]:n),r=e==s?e?1:2:n;for(let i=o;i<t;i++)co[i]=r;o=t-1}let r=[];if(1==n)for(let o=0;o<i;){let t=o,e=1!=co[o++];while(o<i&&e==(1!=co[o]))o++;if(e)for(let i=o;i>t;){let e=i,n=2!=co[--i];while(i>t&&n==(2!=co[i-1]))i--;r.push(new ao(i,e,n?2:1))}else r.push(new ao(t,o,0))}else for(let o=0;o<i;){let t=o,e=2==co[o++];while(o<i&&e==(2==co[o]))o++;r.push(new ao(t,o,e?1:2))}return r}function fo(t){return[new ao(0,t,0)]}let po="";function go(t,e,i,n,s){var r;let o=n.head-t.from,h=-1;if(0==o){if(!s||!t.length)return null;e[0].level!=i&&(o=e[0].side(!1,i),h=0)}else if(o==t.length){if(s)return null;let t=e[e.length-1];t.level!=i&&(o=t.side(!0,i),h=e.length-1)}h<0&&(h=ao.find(e,o,null!==(r=n.bidiLevel)&&void 0!==r?r:-1,n.assoc));let a=e[h];o==a.side(s,i)&&(a=e[h+=s?1:-1],o=a.side(!s,i));let c=s==(a.dir==i),u=(0,Ot.cp)(t.text,o,c);if(po=t.text.slice(Math.min(o,u),Math.max(o,u)),u!=a.side(s,i))return l.jT.cursor(u+t.from,c?-1:1,a.level);let d=h==(s?e.length-1:0)?null:e[h+(s?1:-1)];return d||a.level==i?d&&d.level<a.level?l.jT.cursor(d.side(!s,i)+t.from,s?1:-1,d.level):l.jT.cursor(u+t.from,s?-1:1,a.level):l.jT.cursor(s?t.to:t.from,s?-1:1,i)}const mo="";class wo{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(l.yy.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=mo}readRange(t,e){if(!t)return this;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=Ps.get(n),r=Ps.get(t);(s&&r?s.breakAfter:(s?s.breakAfter:vo(n))||vo(t)&&("BR"!=n.nodeName||n.cmIgnore))&&this.lineBreak(),n=t}return this.findPointBefore(i,e),this}readTextNode(t){let e=t.nodeValue;for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e.length));for(let i=0,n=this.lineSeparator?null:/\r\n?|\n/g;;){let s,r=-1,o=1;if(this.lineSeparator?(r=e.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(s=n.exec(e))&&(r=s.index,o=s[0].length),this.append(e.slice(i,r<0?e.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let e of this.points)e.node==t&&e.pos>this.text.length&&(e.pos-=o-1);i=r+o}}readNode(t){if(t.cmIgnore)return;let e=Ps.get(t),i=e&&e.overrideDOMText;if(null!=i){this.findPointInside(t,i.length);for(let t=i.iter();!t.next().done;)t.lineBreak?this.lineBreak():this.append(t.value)}else 3==t.nodeType?this.readTextNode(t):"BR"==t.nodeName?t.nextSibling&&this.lineBreak():1==t.nodeType&&this.readRange(t.firstChild,null)}findPointBefore(t,e){for(let i of this.points)i.node==t&&t.childNodes[i.offset]==e&&(i.pos=this.text.length)}findPointInside(t,e){for(let i of this.points)(3==t.nodeType?i.node==t:t.contains(i.node))&&(i.pos=this.text.length+Math.min(e,i.offset))}}function vo(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}class yo{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class bo extends Ps{constructor(t){super(),this.view=t,this.compositionDeco=gr.none,this.decorations=[],this.pluginDecorationLength=0,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(t.contentDOM),this.children=[new kr],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Yr(0,0,0,t.state.doc.length)],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=this.minWidthFrom=this.minWidthTo=0),this.view.inputState.composing<0?this.compositionDeco=gr.none:(t.transactions.length||this.dirty)&&(this.compositionDeco=Ao(this.view,t.changes)),(Js.ie||Js.chrome)&&!this.compositionDeco.size&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let i=this.decorations,n=this.updateDeco(),s=Oo(i,n,t.changes);return e=Yr.extendWithRanges(e,s),(0!=this.dirty||0!=e.length)&&(this.updateInner(e,t.startState.doc.length),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e){this.view.viewState.mustMeasureContent=!0,this.updateChildren(t,e);let{observer:i}=this.view;i.ignore((()=>{this.dom.style.height=this.view.viewState.contentHeight+"px",this.dom.style.minWidth=this.minWidth?this.minWidth+"px":"";let t=Js.chrome||Js.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.sync(t),this.dirty=0,t&&(t.written||i.selectionRange.focusNode!=t.node)&&(this.forceSelection=!0),this.dom.style.height=""}));let n=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let s of this.children)s instanceof Sr&&s.widget instanceof ko&&n.push(s.dom);i.updateGaps(n)}updateChildren(t,e){let i=this.childCursor(e);for(let n=t.length-1;;n--){let e=n>=0?t[n]:null;if(!e)break;let{fromA:s,toA:r,fromB:o,toB:l}=e,{content:h,breakAtStart:a,openStart:c,openEnd:u}=Ar.build(this.view.state.doc,o,l,this.decorations,this.pluginDecorationLength),{i:d,off:f}=i.findPos(r,1),{i:p,off:g}=i.findPos(s,-1);Is(this,p,g,d,f,h,a,c,u)}}updateSelection(t=!1,e=!1){if(t&&this.view.observer.readSelectionRange(),!e&&!this.mayControlSelection()||Js.ios&&this.view.inputState.rapidCompositionStart)return;let i=this.forceSelection;this.forceSelection=!1;let n=this.view.state.selection.main,s=this.domAtPos(n.anchor),r=n.empty?s:this.domAtPos(n.head);if(Js.gecko&&n.empty&&xo(s)){let t=document.createTextNode("");this.view.observer.ignore((()=>s.node.insertBefore(t,s.node.childNodes[s.offset]||null))),s=r=new Rs(t,0),i=!0}let o=this.view.observer.selectionRange;!i&&o.focusNode&&ms(s.node,s.offset,o.anchorNode,o.anchorOffset)&&ms(r.node,r.offset,o.focusNode,o.focusOffset)||(this.view.observer.ignore((()=>{Js.android&&Js.chrome&&this.dom.contains(o.focusNode)&&Eo(o.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let t=us(this.root);if(n.empty){if(Js.gecko){let t=Do(s.node,s.offset);if(t&&3!=t){let e=Co(s.node,s.offset,1==t?1:-1);e&&(s=new Rs(e,1==t?0:e.nodeValue.length))}}t.collapse(s.node,s.offset),null!=n.bidiLevel&&null!=o.cursorBidiLevel&&(o.cursorBidiLevel=n.bidiLevel)}else if(t.extend)t.collapse(s.node,s.offset),t.extend(r.node,r.offset);else{let e=document.createRange();n.anchor>n.head&&([s,r]=[r,s]),e.setEnd(r.node,r.offset),e.setStart(s.node,s.offset),t.removeAllRanges(),t.addRange(e)}})),this.view.observer.setSelectionRange(s,r)),this.impreciseAnchor=s.precise?null:new Rs(o.anchorNode,o.anchorOffset),this.impreciseHead=r.precise?null:new Rs(o.focusNode,o.focusOffset)}enforceCursorAssoc(){if(this.compositionDeco.size)return;let t=this.view.state.selection.main,e=us(this.root);if(!t.empty||!t.assoc||!e.modify)return;let i=kr.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(Wr)?this.root.activeElement==this.dom:ps(this.dom,this.view.observer.selectionRange)}nearest(t){for(let e=t;e;){let t=Ps.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 kr)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!=pr.WidgetBefore&&s.type!=pr.WidgetAfter&&(!n||2==e||this.children[n-1].breakAfter||this.children[n-1].type==pr.WidgetBefore&&e>-2))return s.coordsAt(t-r,e);i=r}}measureVisibleLineHeights(){let t=[],{from:e,to:i}=this.view.viewState.viewport,n=this.view.contentDOM.clientWidth,s=n>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,r=-1;for(let o=0,l=0;l<this.children.length;l++){let h=this.children[l],a=o+h.length;if(a>i)break;if(o>=e){let e=h.dom.getBoundingClientRect();if(t.push(e.height),s){let t=h.dom.lastChild,i=t?gs(t):[];if(i.length){let t=i[i.length-1],s=this.view.textDirection==Zr.LTR?t.right-e.left:e.right-t.left;s>r&&(r=s,this.minWidth=n,this.minWidthFrom=o,this.minWidthTo=a)}}}o=a+h.breakAfter}return t}measureTextSize(){for(let n of this.children)if(n instanceof kr){let t=n.measureTextSize();if(t)return t}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=gs(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 Vs(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.lineBlockAt(r).bottom-e.lineBlockAt(i).top;t.push(gr.replace({widget:new ko(n),block:!0,inclusive:!0,isBlockGap:!0}).range(i,r))}if(!s)break;i=s.to+1}return gr.set(t)}updateDeco(){let t=this.view.pluginField(zr.decorations);return this.pluginDecorationLength=t.length,this.decorations=[...t,...this.view.state.facet(Xr),this.compositionDeco,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco]}scrollIntoView(t){let e,{range:i}=t,n=this.coordsAt(i.head,i.empty?i.assoc:i.head>i.anchor?-1:1);if(!n)return;!i.empty&&(e=this.coordsAt(i.anchor,i.anchor>i.head?-1:1))&&(n={left:Math.min(n.left,e.left),top:Math.min(n.top,e.top),right:Math.max(n.right,e.right),bottom:Math.max(n.bottom,e.bottom)});let s=0,r=0,o=0,l=0;for(let a of this.view.pluginField(zr.scrollMargins))if(a){let{left:t,right:e,top:i,bottom:n}=a;null!=t&&(s=Math.max(s,t)),null!=e&&(r=Math.max(r,e)),null!=i&&(o=Math.max(o,i)),null!=n&&(l=Math.max(l,n))}let h={left:n.left-s,top:n.top-o,right:n.right+r,bottom:n.bottom+l};Ss(this.view.scrollDOM,h,i.head<i.anchor?-1:1,t.x,t.y,t.xMargin,t.yMargin,this.view.textDirection==Zr.LTR)}}function xo(t){return 1==t.node.nodeType&&t.node.firstChild&&(0==t.offset||"false"==t.node.childNodes[t.offset-1].contentEditable)&&(t.offset==t.node.childNodes.length||"false"==t.node.childNodes[t.offset].contentEditable)}class ko extends fr{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}}function So(t){let e=t.observer.selectionRange,i=e.focusNode&&Co(e.focusNode,e.focusOffset,0);if(!i)return null;let n=t.docView.nearest(i);if(!n)return null;if(n instanceof kr){let t=i;while(t.parentNode!=n.dom)t=t.parentNode;let e=t.previousSibling;while(e&&!Ps.get(e))e=e.previousSibling;let s=e?Ps.get(e).posAtEnd:n.posAtStart;return{from:s,to:s,node:t,text:i}}{for(;;){let{parent:t}=n;if(!t)return null;if(t instanceof kr)break;n=t}let t=n.posAtStart;return{from:t,to:t+n.length,node:n.dom,text:i}}}function Ao(t,e){let i=So(t);if(!i)return gr.none;let{from:n,to:s,node:r,text:o}=i,l=e.mapPos(n,1),h=Math.max(l,e.mapPos(s,-1)),{state:a}=t,c=3==r.nodeType?r.nodeValue:new wo([],a).readRange(r.firstChild,null).text;if(h-l<c.length)if(a.doc.sliceString(l,Math.min(a.doc.length,l+c.length),mo)==c)h=l+c.length;else{if(a.doc.sliceString(Math.max(0,h-c.length),h,mo)!=c)return gr.none;l=h-c.length}else if(a.doc.sliceString(l,h,mo)!=c)return gr.none;let u=Ps.get(r);return u instanceof ir?u=u.widget.topView:u&&(u.parent=null),gr.set(gr.replace({widget:new Mo(r,o,u)}).range(l,h))}class Mo extends fr{constructor(t,e,i){super(),this.top=t,this.text=e,this.topView=i}eq(t){return this.top==t.top&&this.text==t.text}toDOM(){return this.top}ignoreEvent(){return!1}get customView(){return ir}}function Co(t,e,i){for(;;){if(3==t.nodeType)return t;if(1==t.nodeType&&e>0&&i<=0)t=t.childNodes[e-1],e=ys(t);else{if(!(1==t.nodeType&&e<t.childNodes.length&&i>=0))return null;t=t.childNodes[e],e=0}}}function Do(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 To{constructor(){this.changes=[]}compareRange(t,e){xr(t,e,this.changes)}comparePoint(t,e){xr(t,e,this.changes)}}function Oo(t,e,i){let n=new To;return N.Xs.compare(t,e,i,n),n.changes}function Eo(t,e){for(let i=t;i&&i!=e;i=i.assignedSlot||i.parentNode)if(1==i.nodeType&&"false"==i.contentEditable)return!0;return!1}function Bo(t,e,i=1){let n=t.charCategorizer(e),s=t.doc.lineAt(e),r=e-s.from;if(0==s.length)return l.jT.cursor(e);0==r?i=1:r==s.length&&(i=-1);let o=r,h=r;i<0?o=(0,Ot.cp)(s.text,r,!1):h=(0,Ot.cp)(s.text,r);let a=n(s.text.slice(o,h));while(o>0){let t=(0,Ot.cp)(s.text,o,!1);if(n(s.text.slice(t,o))!=a)break;o=t}while(h<s.length){let t=(0,Ot.cp)(s.text,h);if(n(s.text.slice(h,t))!=a)break;h=t}return l.jT.range(o+s.from,h+s.from)}function Ro(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function Lo(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function Po(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function No(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function Vo(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function Io(t,e,i){let n,s,r,o,l,h,a,c;for(let f=t.firstChild;f;f=f.nextSibling){let t=gs(f);for(let u=0;u<t.length;u++){let d=t[u];s&&Po(s,d)&&(d=No(Vo(d,s.bottom),s.top));let p=Ro(e,d),g=Lo(i,d);if(0==p&&0==g)return 3==f.nodeType?Ho(f,e,i):Io(f,e,i);(!n||o>g||o==g&&r>p)&&(n=f,s=d,r=p,o=g),0==p?i>d.bottom&&(!a||a.bottom<d.bottom)?(l=f,a=d):i<d.top&&(!c||c.top>d.top)&&(h=f,c=d):a&&Po(a,d)?a=Vo(a,d.bottom):c&&Po(c,d)&&(c=No(c,d.top))}}if(a&&a.bottom>=i?(n=l,s=a):c&&c.top<=i&&(n=h,s=c),!n)return{node:t,offset:0};let u=Math.max(s.left,Math.min(s.right,e));if(3==n.nodeType)return Ho(n,u,i);if(!r&&"true"==n.contentEditable)return Io(n,u,i);let d=Array.prototype.indexOf.call(t.childNodes,n)+(e>=(s.left+s.right)/2?1:0);return{node:t,offset:d}}function Ho(t,e,i){let n=t.nodeValue.length,s=-1,r=1e9,o=0;for(let l=0;l<n;l++){let n=Ts(t,l,l+1).getClientRects();for(let h=0;h<n.length;h++){let a=n[h];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(Js.chrome||Js.gecko){let e=Ts(t,l).getBoundingClientRect();e.left==a.right&&(n=!i)}if(c<=0)return{node:t,offset:l+(n?1:0)};s=l+(n?1:0),r=c}}}return{node:t,offset:s>-1?s:o>0?t.nodeValue.length:0}}function Wo(t,{x:e,y:i},n,s=-1){var r;let o,l=t.contentDOM.getBoundingClientRect(),h=l.top+t.viewState.paddingTop,{docHeight:a}=t.viewState,c=i-h;if(c<0)return 0;if(c>a)return t.state.doc.length;for(let w=t.defaultLineHeight/2,v=!1;;){if(o=t.elementAtHeight(c),o.type==pr.Text)break;for(;;){if(c=s>0?o.bottom+w:o.top-w,c>=0&&c<=a)break;if(v)return n?null:0;v=!0,s=-s}}i=h+c;let u=o.from;if(u<t.viewport.from)return 0==t.viewport.from?0:n?null:Fo(t,l,o,e,i);if(u>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:n?null:Fo(t,l,o,e,i);let d=t.dom.ownerDocument,f=t.root.elementFromPoint?t.root:d,p=f.elementFromPoint(e,i);p&&!t.contentDOM.contains(p)&&(p=null),p||(e=Math.max(l.left+1,Math.min(l.right-1,e)),p=f.elementFromPoint(e,i),p&&!t.contentDOM.contains(p)&&(p=null));let g,m=-1;if(p&&0!=(null===(r=t.docView.nearest(p))||void 0===r?void 0:r.isEditable))if(d.caretPositionFromPoint){let t=d.caretPositionFromPoint(e,i);t&&({offsetNode:g,offset:m}=t)}else if(d.caretRangeFromPoint){let t=d.caretRangeFromPoint(e,i);t&&(({startContainer:g,startOffset:m}=t),Js.safari&&zo(g,m,e)&&(g=void 0))}if(!g||!t.docView.dom.contains(g)){let n=kr.find(t.docView,u);if(!n)return c>o.top+o.height/2?o.to:o.from;({node:g,offset:m}=Io(n.dom,e,i))}return t.docView.posFromDOM(g,m)}function Fo(t,e,i,n,s){let r=Math.round((n-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>1.5*t.defaultLineHeight){let e=Math.floor((s-i.top)/t.defaultLineHeight);r+=e*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(i.from,i.to);return i.from+(0,Ot.Gz)(o,r,t.state.tabSize)}function zo(t,e,i){let n;if(3!=t.nodeType||e!=(n=t.nodeValue.length))return!1;for(let s=t.nextSibling;s;s=s.nextSibling)if(1!=s.nodeType||"BR"!=s.nodeName)return!1;return Ts(t,n-1,n).getBoundingClientRect().left>i}function qo(t,e,i,n){let s=t.state.doc.lineAt(e.head),r=n&&t.lineWrapping?t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head):null;if(r){let e=t.dom.getBoundingClientRect(),n=t.posAtCoords({x:i==(t.textDirection==Zr.LTR)?e.right-1:e.left+1,y:(r.top+r.bottom)/2});if(null!=n)return l.jT.cursor(n,i?-1:1)}let o=kr.find(t.docView,e.head),h=o?i?o.posAtEnd:o.posAtStart:i?s.to:s.from;return l.jT.cursor(h,i?-1:1)}function jo(t,e,i,n){let s=t.state.doc.lineAt(e.head),r=t.bidiSpans(s);for(let o=e,h=null;;){let e=go(s,r,t.textDirection,o,i),a=po;if(!e){if(s.number==(i?t.state.doc.lines:1))return o;a="\n",s=t.state.doc.line(s.number+(i?1:-1)),r=t.bidiSpans(s),e=l.jT.cursor(i?s.from:s.to)}if(h){if(!h(a))return o}else{if(!n)return e;h=n(a)}o=e}}function $o(t,e,i){let n=t.state.charCategorizer(e),s=n(i);return t=>{let e=n(t);return s==l.D0.Space&&(s=e),s==e}}function Ko(t,e,i,n){let s=e.head,r=i?1:-1;if(s==(i?t.state.doc.length:0))return l.jT.cursor(s,e.assoc);let o,h=e.goalColumn,a=t.contentDOM.getBoundingClientRect(),c=t.coordsAtPos(s),u=t.documentTop;if(c)null==h&&(h=c.left-a.left),o=r<0?c.top:c.bottom;else{let e=t.viewState.lineBlockAt(s-u);null==h&&(h=Math.min(a.right-a.left,t.defaultCharacterWidth*(s-e.from))),o=(r<0?e.top:e.bottom)+u}let d=a.left+h,f=null!==n&&void 0!==n?n:t.defaultLineHeight>>1;for(let p=0;;p+=10){let i=o+(f+p)*r,n=Wo(t,{x:d,y:i},!1,r);if(i<a.top||i>a.bottom||(r<0?n<s:n>s))return l.jT.cursor(n,e.assoc,void 0,h)}}function _o(t,e,i){let n=t.pluginField(zr.atomicRanges);for(;;){let t=!1;for(let s of n)s.between(i.from-1,i.from+1,((n,s,r)=>{i.from>n&&i.from<s&&(i=e.from>i.from?l.jT.cursor(n,1):l.jT.cursor(s,-1),t=!0)}));if(!t)return i}}class Go{constructor(t){this.lastKeyCode=0,this.lastKeyTime=0,this.pendingIOSKey=void 0,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=0,this.lastContextMenu=0,this.scrollHandlers=[],this.registeredEvents=[],this.customHandlers=[],this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.rapidCompositionStart=!1,this.mouseSelection=null;for(let e in el){let i=el[e];t.contentDOM.addEventListener(e,(n=>{tl(t,n)&&!this.ignoreDuringComposition(n)&&("keydown"==e&&this.keydown(t,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),Js.safari&&t.contentDOM.addEventListener("input",(()=>null))}setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}ensureHandlers(t){let e=this.customHandlers=t.pluginField(Kr);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=>{tl(t,i)&&this.runCustomHandlers(e,t,i)&&i.preventDefault()})))}runCustomHandlers(t,e,i){for(let s of this.customHandlers){let r=s.handlers[t];if(r)try{if(r.call(s.plugin,i,e)||i.defaultPrevented)return!0}catch(n){Hr(e.state,n)}}return!1}runScrollHandlers(t,e){for(let n of this.customHandlers){let s=n.handlers.scroll;if(s)try{s.call(n.plugin,e,t)}catch(i){Hr(t.state,i)}}}keydown(t,e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),9==e.keyCode&&Date.now()<this.lastEscPress+2e3)return!0;if(Js.android&&Js.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))return t.observer.delayAndroidKey(e.key,e.keyCode),!0;let i;return!(!Js.ios||!(i=Uo.find((t=>t.keyCode==e.keyCode)))||e.ctrlKey||e.altKey||e.metaKey||e.synthetic)&&(this.pendingIOSKey=i,setTimeout((()=>this.flushIOSKey(t)),250),!0)}flushIOSKey(t){let e=this.pendingIOSKey;return!!e&&(this.pendingIOSKey=void 0,Os(t.contentDOM,e.key,e.keyCode))}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(this.composing>0||!!(Js.safari&&Date.now()-this.compositionEndedAt<500)&&(this.compositionEndedAt=0,!0))}mustFlushObserver(t){return"keydown"==t.type&&229!=t.keyCode||"compositionend"==t.type&&!Js.ios}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.mouseSelection&&this.mouseSelection.update(t),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}const Uo=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Xo=[16,17,18,20,91,92,224,225];class Jo{constructor(t,e,i,n){this.view=t,this.style=i,this.mustSelect=n,this.lastEvent=e;let s=t.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(l.yy.allowMultipleSelections)&&Yo(t,e),this.dragMove=Qo(t,e),this.dragging=!(!Zo(t,e)||1!=gl(e))&&null,!1===this.dragging&&(e.preventDefault(),this.select(e))}move(t){if(0==t.buttons)return this.destroy();!1===this.dragging&&this.select(this.lastEvent=t)}up(t){null==this.dragging&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=null}select(t){let e=this.style.get(t,this.extend,this.multiple);!this.mustSelect&&e.eq(this.view.state.selection)&&e.main.assoc==this.view.state.selection.main.assoc||this.view.dispatch({selection:e,userEvent:"select.pointer",scrollIntoView:!0}),this.mustSelect=!1}update(t){t.docChanged&&this.dragging&&(this.dragging=this.dragging.map(t.changes)),this.style.update(t)&&setTimeout((()=>this.select(this.lastEvent)),20)}}function Yo(t,e){let i=t.state.facet(Tr);return i.length?i[0](e):Js.mac?e.metaKey:e.ctrlKey}function Qo(t,e){let i=t.state.facet(Or);return i.length?i[0](e):Js.mac?!e.altKey:!e.ctrlKey}function Zo(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let n=us(t.root);if(0==n.rangeCount)return!0;let s=n.getRangeAt(0).getClientRects();for(let r=0;r<s.length;r++){let t=s[r];if(t.left<=e.clientX&&t.right>=e.clientX&&t.top<=e.clientY&&t.bottom>=e.clientY)return!0}return!1}function tl(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=Ps.get(n))&&i.ignoreEvent(e))return!1;return!0}const el=Object.create(null),il=Js.ie&&Js.ie_version<15||Js.ios&&Js.webkit_version<604;function nl(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(),sl(t,i.value)}),50)}function sl(t,e){let i,{state:n}=t,s=1,r=n.toText(e),o=r.lines==n.selection.ranges.length,h=null!=bl&&n.selection.ranges.every((t=>t.empty))&&bl==r.toString();if(h){let t=-1;i=n.changeByRange((i=>{let h=n.doc.lineAt(i.from);if(h.from==t)return{range:i};t=h.from;let a=n.toText((o?r.line(s++).text:e)+n.lineBreak);return{changes:{from:h.from,insert:a},range:l.jT.cursor(i.from+a.length)}}))}else i=o?n.changeByRange((t=>{let e=r.line(s++);return{changes:{from:t.from,to:t.to,insert:e.text},range:l.jT.cursor(t.from+e.length)}})):n.replaceSelection(r);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}el.keydown=(t,e)=>{t.inputState.setSelectionOrigin("select"),27==e.keyCode?t.inputState.lastEscPress=Date.now():Xo.indexOf(e.keyCode)<0&&(t.inputState.lastEscPress=0)};let rl=0;function ol(t,e,i,n){if(1==n)return l.jT.cursor(e,i);if(2==n)return Bo(t.state,e,i);{let i=kr.find(t.docView,e),n=t.state.doc.lineAt(i?i.posAtEnd:e),s=i?i.posAtStart:n.from,r=i?i.posAtEnd:n.to;return r<t.state.doc.length&&r==n.to&&r++,l.jT.range(s,r)}}el.touchstart=(t,e)=>{rl=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},el.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},el.mousedown=(t,e)=>{if(t.observer.flush(),rl>Date.now()-2e3&&1==gl(e))return;let i=null;for(let n of t.state.facet(Er))if(i=n(t,e),i)break;if(i||0!=e.button||(i=ml(t,e)),i){let n=t.root.activeElement!=t.contentDOM;n&&t.observer.ignore((()=>Ds(t.contentDOM))),t.inputState.startMouseSelection(new Jo(t,e,i,n))}};let ll=(t,e)=>t>=e.top&&t<=e.bottom,hl=(t,e,i)=>ll(e,i)&&t>=i.left&&t<=i.right;function al(t,e,i,n){let s=kr.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&&hl(i,n,o))return-1;let l=s.coordsAt(r,1);return l&&hl(i,n,l)?1:o&&ll(n,o)?-1:1}function cl(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:al(t,i,e.clientX,e.clientY)}}const ul=Js.ie&&Js.ie_version<=11;let dl=null,fl=0,pl=0;function gl(t){if(!ul)return t.detail;let e=dl,i=pl;return dl=t,pl=Date.now(),fl=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(fl+1)%3:1}function ml(t,e){let i=cl(t,e),n=gl(e),s=t.state.selection,r=i,o=e;return{update(t){t.docChanged&&(i&&(i.pos=t.changes.mapPos(i.pos)),s=s.map(t.changes),o=null)},get(e,h,a){let c;if(o&&e.clientX==o.clientX&&e.clientY==o.clientY?c=r:(c=r=cl(t,e),o=e),!c||!i)return s;let u=ol(t,c.pos,c.bias,n);if(i.pos!=c.pos&&!h){let e=ol(t,i.pos,i.bias,n),s=Math.min(e.from,u.from),r=Math.max(e.to,u.to);u=s<u.from?l.jT.range(s,r):l.jT.range(r,s)}return h?s.replaceRange(s.main.extend(u.from,u.to)):a?s.addRange(u):l.jT.create([u])}}}function wl(t,e,i,n){if(!i)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1);e.preventDefault();let{mouseSelection:r}=t.inputState,o=n&&r&&r.dragging&&r.dragMove?{from:r.dragging.from,to:r.dragging.to}:null,l={from:s,insert:i},h=t.state.changes(o?[o,l]:l);t.focus(),t.dispatch({changes:h,selection:{anchor:h.mapPos(s,-1),head:h.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"})}function vl(t,e){let i=t.dom.parentNode;if(!i)return;let n=i.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout((()=>{n.remove(),t.focus()}),50)}function yl(t){let e=[],i=[],n=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),i.push(s));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}}el.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")},el.drop=(t,e)=>{if(!e.dataTransfer)return;if(t.state.readOnly)return e.preventDefault();let i=e.dataTransfer.files;if(i&&i.length){e.preventDefault();let n=Array(i.length),s=0,r=()=>{++s==i.length&&wl(t,e,n.filter((t=>null!=t)).join(t.state.lineBreak),!1)};for(let t=0;t<i.length;t++){let e=new FileReader;e.onerror=r,e.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(e.result)||(n[t]=e.result),r()},e.readAsText(i[t])}}else wl(t,e,e.dataTransfer.getData("Text"),!0)},el.paste=(t,e)=>{if(t.state.readOnly)return e.preventDefault();t.observer.flush();let i=il?null:e.clipboardData;i?(sl(t,i.getData("text/plain")),e.preventDefault()):nl(t)};let bl=null;function xl(t,e){if(t.docView.compositionDeco.size){t.inputState.rapidCompositionStart=e;try{t.update([])}finally{t.inputState.rapidCompositionStart=!1}}}el.copy=el.cut=(t,e)=>{let{text:i,ranges:n,linewise:s}=yl(t.state);if(!i&&!s)return;bl=s?i:null;let r=il?null:e.clipboardData;r?(e.preventDefault(),r.clearData(),r.setData("text/plain",i)):vl(t,i),"cut"!=e.type||t.state.readOnly||t.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"})},el.focus=el.blur=t=>{setTimeout((()=>{t.hasFocus!=t.inputState.notifiedFocused&&t.update([])}),10)},el.compositionstart=el.compositionupdate=t=>{null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0,t.docView.compositionDeco.size&&(t.observer.flush(),xl(t,!0)))},el.compositionend=t=>{t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionFirstChange=null,setTimeout((()=>{t.inputState.composing<0&&xl(t,!1)}),50)},el.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},el.beforeinput=(t,e)=>{var i;let n;if(Js.chrome&&Js.android&&(n=Uo.find((t=>t.inputType==e.inputType)))&&(t.observer.delayAndroidKey(n.key,n.keyCode),"Backspace"==n.key||"Delete"==n.key)){let e=(null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0;setTimeout((()=>{var i;((null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0)>e+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())}),100)}};const kl=["pre-wrap","normal","pre-line","break-spaces"];class Sl{constructor(){this.doc=Ot.xv.empty,this.lineWrapping=!1,this.direction=Zr.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;let e=1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5)));return e*this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForStyle(t,e){return kl.indexOf(t)>-1!=this.lineWrapping||this.direction!=e}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let n=t[i];n<0?i++:this.heightSamples[Math.floor(10*n)]||(e=!0,this.heightSamples[Math.floor(10*n)]=!0)}return e}refresh(t,e,i,n,s,r){let o=kl.indexOf(t)>-1,l=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,l){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 l}}class Al{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class Ml{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 Ml(this.from,this.length+t.length,this.top,this.height+t.height,e)}moveY(t){return t?new Ml(this.from,this.length,this.top+t,this.height,Array.isArray(this.type)?this.type.map((e=>e.moveY(t))):this.type):this}}var Cl=function(t){return t[t["ByPos"]=0]="ByPos",t[t["ByHeight"]=1]="ByHeight",t[t["ByPosNoHeight"]=2]="ByPosNoHeight",t}(Cl||(Cl={}));const Dl=.001;class Tl{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)>Dl&&(t.heightChanged=!0),this.height=e)}replace(t,e,i){return Tl.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:l,fromB:h,toB:a}=n[r],c=s.lineAt(o,Cl.ByPosNoHeight,e,0,0),u=c.to>=l?c:s.lineAt(l,Cl.ByPosNoHeight,e,0,0);a+=u.to-l,l=u.to;while(r>0&&c.from<=n[r-1].toA)o=n[r-1].fromA,h=n[r-1].fromB,r--,o<c.from&&(c=s.lineAt(o,Cl.ByPosNoHeight,e,0,0));h+=c.from-o,o=c.from;let d=Nl.build(i,t,h,a);s=s.replace(o,l,d)}return s.updateHeight(i,0)}static empty(){return new El(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 Rl(Tl.of(t.slice(0,e)),r,Tl.of(t.slice(i)))}}Tl.prototype.size=1;class Ol extends Tl{constructor(t,e,i){super(t,e),this.type=i}blockAt(t,e,i,n){return new Ml(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 El extends Ol{constructor(t,e){super(t,e,pr.Text),this.collapsed=0,this.widgetHeight=0}replace(t,e,i){let n=i[0];return 1==i.length&&(n instanceof El||n instanceof Bl&&4&n.flags)&&Math.abs(this.length-n.length)<10?(n instanceof Bl?n=new El(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):Tl.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 Bl extends Tl{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),l=Math.max(0,Math.min(r-s,Math.floor((t-i)/o))),{from:h,length:a}=e.line(s+l);return new Ml(h,a,i+o*l,o,pr.Text)}lineAt(t,e,i,n,s){if(e==Cl.ByHeight)return this.blockAt(t,i,n,s);if(e==Cl.ByPosNoHeight){let{from:e,to:n}=i.lineAt(t);return new Ml(e,n-e,0,0,pr.Text)}let{firstLine:r,lineHeight:o}=this.lines(i,s),{from:l,length:h,number:a}=i.lineAt(t);return new Ml(l,h,n+o*(a-r),o,pr.Text)}forEachLine(t,e,i,n,s,r){let{firstLine:o,lineHeight:l}=this.lines(i,s);for(let h=Math.max(t,s),a=Math.min(s+this.length,e);h<=a;){let e=i.lineAt(h);h==t&&(n+=l*(e.number-o)),r(new Ml(e.from,e.length,n,l,pr.Text)),n+=l,h=e.to+1}}replace(t,e,i){let n=this.length-e;if(n>0){let t=i[i.length-1];t instanceof Bl?i[i.length-1]=new Bl(t.length+n):i.push(null,new Bl(n-1))}if(t>0){let e=i[0];e instanceof Bl?i[0]=new Bl(t+e.length):i.unshift(new Bl(t-1),null)}return Tl.of(i)}decomposeLeft(t,e){e.push(new Bl(t-1),null)}decomposeRight(t,e){e.push(null,new Bl(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),o=-1,l=t.heightChanged;n.from>e&&i.push(new Bl(n.from-e-1).updateHeight(t,e));while(r<=s&&n.more){let e=t.doc.lineAt(r).length;i.length&&i.push(null);let s=n.heights[n.index++];-1==o?o=s:Math.abs(s-o)>=Dl&&(o=-2);let l=new El(e,s);l.outdated=!1,i.push(l),r+=e+1}r<=s&&i.push(null,new Bl(s-r).updateHeight(t,r));let h=Tl.of(i);return t.heightChanged=l||o<0||Math.abs(h.height-this.height)>=Dl||Math.abs(o-this.lines(t.doc,e).lineHeight)>=Dl,h}return(i||this.outdated)&&(this.setHeight(t,t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class Rl extends Tl{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?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,l=e==Cl.ByHeight?t<r:t<o,h=l?this.left.lineAt(t,e,i,n,s):this.right.lineAt(t,e,i,r,o);if(this.break||(l?h.to<o:h.from>o))return h;let a=e==Cl.ByPosNoHeight?Cl.ByPosNoHeight:Cl.ByPos;return l?h.join(this.right.lineAt(o,a,i,r,o)):this.left.lineAt(o,a,i,n,s).join(h)}forEachLine(t,e,i,n,s,r){let o=n+this.left.height,l=s+this.left.length+this.break;if(this.break)t<l&&this.left.forEachLine(t,e,i,n,s,r),e>=l&&this.right.forEachLine(t,e,i,o,l,r);else{let h=this.lineAt(l,Cl.ByPos,i,n,s);t<h.from&&this.left.forEachLine(t,h.from-1,i,n,s,r),h.to>=t&&h.from<=e&&r(h),e>h.to&&this.right.forEachLine(h.to+1,e,i,o,l,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 o of i)s.push(o);if(t>0&&Ll(s,r-1),e<this.length){let t=s.length;this.decomposeRight(e,s),Ll(s,t)}return Tl.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?Tl.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,l=null;return n&&n.from<=e+s.length&&n.more?l=s=s.updateHeight(t,e,i,n):s.updateHeight(t,e,i),n&&n.from<=o+r.length&&n.more?l=r=r.updateHeight(t,o,i,n):r.updateHeight(t,o,i),l?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 Ll(t,e){let i,n;null==t[e]&&(i=t[e-1])instanceof Bl&&(n=t[e+1])instanceof Bl&&t.splice(e-1,3,new Bl(i.length+1+n.length))}const Pl=5;class Nl{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 El?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new El(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?i.widget.estimatedHeight:0;n<0&&(n=this.oracle.lineHeight);let s=e-t;i.block?this.addBlock(new Ol(s,n,i.type)):(s||n>=Pl)&&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 El(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new Bl(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 El)return t;let e=new El(0,-1);return this.nodes.push(e),e}addBlock(t){this.enterLine(),t.type!=pr.WidgetAfter||this.isCovered||this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,t.type!=pr.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 El||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new El(0,-1));let i=t;for(let n of this.nodes)n instanceof El&&n.updateHeight(this.oracle,i),i+=n?n.length:1;return this.nodes}static build(t,e,i,n){let s=new Nl(i,t);return N.Xs.spans(e,i,n,s,0),s.finish(i)}}function Vl(t,e,i){let n=new Il;return N.Xs.compare(t,e,i,n,0),n.changes}class Il{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,n){(t<e||i&&i.heightRelevant||n&&n.heightRelevant)&&xr(t,e,this.changes,5)}}function Hl(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),l=t.ownerDocument.body;for(let h=t.parentNode;h&&h!=l;)if(1==h.nodeType){let t=h,e=window.getComputedStyle(t);if((t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)&&"visible"!=e.overflow){let e=t.getBoundingClientRect();n=Math.max(n,e.left),s=Math.min(s,e.right),r=Math.max(r,e.top),o=Math.min(o,e.bottom)}h="absolute"==e.position||"fixed"==e.position?t.offsetParent:t.parentNode}else{if(11!=h.nodeType)break;h=h.host}return{left:n-i.left,right:Math.max(n,s)-i.left,top:r-(i.top+e),bottom:Math.max(r,o)-(i.top+e)}}function Wl(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class Fl{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 gr.replace({widget:new zl(this.size,t)}).range(this.from,this.to)}}class zl extends fr{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 ql{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.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.heightOracle=new Sl,this.scaler=Xl,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1,this.heightMap=Tl.empty().applyChanges(t.facet(Xr),Ot.xv.empty,this.heightOracle.setDoc(t.doc),[new Yr(0,0,0,t.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=gr.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.lineBlockAt(n);t.push(new jl(e,i))}}this.viewports=t.sort(((t,e)=>t.from-e.from)),this.scaler=this.heightMap.height<=7e6?Xl:new Jl(this.heightOracle.doc,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.state.doc,0,0,(t=>{this.viewportLines.push(1==this.scaler.scale?t:Yl(t,this.scaler))}))}update(t,e=null){let i=this.state;this.state=t.state;let n=this.state.facet(Xr),s=t.changedRanges,r=Yr.extendWithRanges(s,Vl(t.startState.facet(Xr),n,t?t.changes:l.as.empty(this.state.doc.length))),o=this.heightMap.height;this.heightMap=this.heightMap.applyChanges(n,i.doc,this.heightOracle.setDoc(this.state.doc),r),this.heightMap.height!=o&&(t.flags|=2);let h=r.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<h.from||e.range.head>h.to)||!this.viewportIsAppropriate(h))&&(h=this.getViewport(0,e));let a=!t.changes.empty||2&t.flags||h.from!=this.viewport.from||h.to!=this.viewport.to;this.viewport=h,this.updateForViewport(),a&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,t.changes))),t.flags|=this.computeVisibleRanges(),e&&(this.scrollTarget=e),!this.mustEnforceCursorAssoc&&t.selectionSet&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),n=this.heightOracle,s=i.whiteSpace,r="rtl"==i.direction?Zr.RTL:Zr.LTR,o=this.heightOracle.mustRefreshForStyle(s,r),l=o||this.mustMeasureContent||this.contentDOMHeight!=e.clientHeight,h=0,a=0;if(this.editorWidth!=t.scrollDOM.clientWidth&&(n.lineWrapping&&(l=!0),this.editorWidth=t.scrollDOM.clientWidth,h|=8),l){this.mustMeasureContent=!1,this.contentDOMHeight=e.clientHeight;let t=parseInt(i.paddingTop)||0,n=parseInt(i.paddingBottom)||0;this.paddingTop==t&&this.paddingBottom==n||(h|=8,this.paddingTop=t,this.paddingBottom=n)}let c=(this.printing?Wl:Hl)(e,this.paddingTop),u=c.top-this.pixelViewport.top,d=c.bottom-this.pixelViewport.bottom;this.pixelViewport=c;let f=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(f!=this.inView&&(this.inView=f,f&&(l=!0)),!this.inView)return 0;let p=e.clientWidth;if(this.contentDOMWidth==p&&this.editorHeight==t.scrollDOM.clientHeight||(this.contentDOMWidth=p,this.editorHeight=t.scrollDOM.clientHeight,h|=8),l){let e=t.docView.measureVisibleLineHeights();if(n.mustRefreshForHeights(e)&&(o=!0),o||n.lineWrapping&&Math.abs(p-this.contentDOMWidth)>n.charWidth){let{lineHeight:i,charWidth:l}=t.docView.measureTextSize();o=n.refresh(s,r,i,l,p/l,e),o&&(t.docView.minWidth=0,h|=8)}u>0&&d>0?a=Math.max(u,d):u<0&&d<0&&(a=Math.min(u,d)),n.heightChanged=!1,this.heightMap=this.heightMap.updateHeight(n,0,o,new Al(this.viewport.from,e)),n.heightChanged&&(h|=2)}let g=!this.viewportIsAppropriate(this.viewport,a)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return g&&(this.viewport=this.getViewport(a,this.scrollTarget)),this.updateForViewport(),(2&h||g)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),n=this.heightMap,s=this.state.doc,{visibleTop:r,visibleBottom:o}=this,l=new jl(n.lineAt(r-1e3*i,Cl.ByHeight,s,0,0).from,n.lineAt(o+1e3*(1-i),Cl.ByHeight,s,0,0).to);if(e){let{head:t}=e.range;if(t<l.from||t>l.to){let i,r=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),o=n.lineAt(t,Cl.ByPos,s,0,0);i="center"==e.y?(o.top+o.bottom)/2-r/2:"start"==e.y||"nearest"==e.y&&t<l.from?o.top:o.bottom-r,l=new jl(n.lineAt(i-500,Cl.ByHeight,s,0,0).from,n.lineAt(i+r+500,Cl.ByHeight,s,0,0).to)}}return l}mapViewport(t,e){let i=e.mapPos(t.from,-1),n=e.mapPos(t.to,1);return new jl(this.heightMap.lineAt(i,Cl.ByPos,this.state.doc,0,0).from,this.heightMap.lineAt(n,Cl.ByPos,this.state.doc,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(t,Cl.ByPos,this.state.doc,0,0),{bottom:s}=this.heightMap.lineAt(e,Cl.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 Fl(e.mapPos(n.from),e.mapPos(n.to),n.size));return i}ensureLineGaps(t){let e=[];if(this.heightOracle.direction!=Zr.LTR)return e;for(let i of this.viewportLines){if(i.length<4e3)continue;let n,s,r=$l(i.from,i.to,this.state);if(r.total<4e3)continue;if(this.heightOracle.lineWrapping){let t=2e3/this.heightOracle.lineLength*this.heightOracle.lineHeight;n=Kl(r,(this.visibleTop-i.top-t)/i.height),s=Kl(r,(this.visibleBottom-i.top+t)/i.height)}else{let t=r.total*this.heightOracle.charWidth,e=2e3*this.heightOracle.charWidth;n=Kl(r,(this.pixelViewport.left-e)/t),s=Kl(r,(this.pixelViewport.right+e)/t)}let o=[];n>i.from&&o.push({from:i.from,to:n}),s<i.to&&o.push({from:s,to:i.to});let l=this.state.selection.main;l.from>=i.from&&l.from<=i.to&&Gl(o,l.from-10,l.from+10),!l.empty&&l.to>=i.from&&l.to<=i.to&&Gl(o,l.to-10,l.to+10);for(let{from:h,to:a}of o)a-h>1e3&&e.push(Ul(t,(t=>t.from>=i.from&&t.to<=i.to&&Math.abs(t.from-h)<1e3&&Math.abs(t.to-a)<1e3))||new Fl(h,a,this.gapSize(i,h,a,r)))}return e}gapSize(t,e,i,n){let s=_l(n,i)-_l(n,e);return this.heightOracle.lineWrapping?t.height*s:n.total*this.heightOracle.charWidth*s}updateLineGaps(t){Fl.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=gr.set(t.map((t=>t.draw(this.heightOracle.lineWrapping)))))}computeVisibleRanges(){let t=this.state.facet(Xr);this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let e=[];N.Xs.spans(t,this.viewport.from,this.viewport.to,{span(t,i){e.push({from:t,to:i})},point(){}},20);let i=e.length!=this.visibleRanges.length||this.visibleRanges.some(((t,i)=>t.from!=e[i].from||t.to!=e[i].to));return this.visibleRanges=e,i?4:0}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find((e=>e.from<=t&&e.to>=t))||Yl(this.heightMap.lineAt(t,Cl.ByPos,this.state.doc,0,0),this.scaler)}lineBlockAtHeight(t){return Yl(this.heightMap.lineAt(this.scaler.fromDOM(t),Cl.ByHeight,this.state.doc,0,0),this.scaler)}elementAtHeight(t){return Yl(this.heightMap.blockAt(this.scaler.fromDOM(t),this.state.doc,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class jl{constructor(t,e){this.from=t,this.to=e}}function $l(t,e,i){let n=[],s=t,r=0;return N.Xs.spans(i.facet(Xr),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),{total:r,ranges:n}}function Kl({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 s=0;;s++){let{from:t,to:i}=e[s],r=i-t;if(n<=r)return t+n;n-=r}}function _l(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 Gl(t,e,i){for(let n=0;n<t.length;n++){let s=t[n];if(s.from<i&&s.to>e){let r=[];s.from<e&&r.push({from:s.from,to:e}),s.to>i&&r.push({from:i,to:s.to}),t.splice(n,1,...r),n+=r.length-1}}}function Ul(t,e){for(let i of t)if(e(i))return i}const Xl={toDOM(t){return t},fromDOM(t){return t},scale:1};class Jl{constructor(t,e,i){let n=0,s=0,r=0;this.viewports=i.map((({from:i,to:s})=>{let r=e.lineAt(i,Cl.ByPos,t,0,0).top,o=e.lineAt(s,Cl.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 o of this.viewports)o.domTop=r+(o.top-s)*this.scale,r=o.domBottom=o.domTop+(o.bottom-o.top),s=o.bottom}toDOM(t){for(let e=0,i=0,n=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.top)return n+(t-i)*this.scale;if(t<=s.bottom)return s.domTop+(t-s.top);i=s.bottom,n=s.domBottom}}fromDOM(t){for(let e=0,i=0,n=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.domTop)return i+(t-n)/this.scale;if(t<=s.domBottom)return s.top+(t-s.domTop);i=s.bottom,n=s.domBottom}}}function Yl(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),n=e.toDOM(t.bottom);return new Ml(t.from,t.length,i,n-i,Array.isArray(t.type)?t.type.map((t=>Yl(t,e))):t.type)}const Ql=l.r$.define({combine:t=>t.join(" ")}),Zl=l.r$.define({combine:t=>t.indexOf(!0)>-1}),th=cs.V.newName(),eh=cs.V.newName(),ih=cs.V.newName(),nh={"&light":"."+eh,"&dark":"."+ih};function sh(t,e,i){return new cs.V(e,{finish(e){return/&/.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 rh=sh("."+th,{"&.cm-editor":{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","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",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, .cm-dropCursor":{position:"absolute",borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{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-widgetBuffer":{verticalAlign:"text-top",height:"1em",display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},nh),oh={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},lh=Js.ie&&Js.ie_version<=11;class hh{constructor(t,e,i){this.view=t,this.onChange=e,this.onScrollChanged=i,this.active=!1,this.selectionRange=new As,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.scrollTargets=[],this.intersection=null,this.resize=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver((e=>{for(let t of e)this.queue.push(t);(Js.ie&&Js.ie_version<=11||Js.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()})),lh&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),window.addEventListener("resize",this.onResize=this.onResize.bind(this)),"function"==typeof ResizeObserver&&(this.resize=new ResizeObserver((()=>{this.view.docView.lastUpdate<Date.now()-75&&this.onResize()})),this.resize.observe(t.scrollDOM)),window.addEventListener("beforeprint",this.onPrint=this.onPrint.bind(this)),this.start(),window.addEventListener("scroll",this.onScroll=this.onScroll.bind(this)),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver((t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&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.gapIntersection=new IntersectionObserver((t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))}),{})),this.listenForScroll(),this.readSelectionRange(),this.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}onScroll(t){this.intersecting&&this.flush(!1),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout((()=>{this.resizeTimeout=-1,this.view.requestMeasure()}),50))}onPrint(){this.view.viewState.printing=!0,this.view.measure(),setTimeout((()=>{this.view.viewState.printing=!1,this.view.requestMeasure()}),500)}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some(((e,i)=>e!=t[i])))){this.gapIntersection.disconnect();for(let e of t)this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:e}=this,i=this.selectionRange;if(e.state.facet(Wr)?e.root.activeElement!=this.dom:!ps(e.dom,i))return;let n=i.anchorNode&&e.docView.nearest(i.anchorNode);n&&n.ignoreEvent(t)||((Js.ie&&Js.ie_version<=11||Js.android&&Js.chrome)&&!e.state.selection.main.empty&&i.focusNode&&ms(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1))}readSelectionRange(){let{root:t}=this.view,e=us(t),i=Js.safari&&11==t.nodeType&&fs()==this.view.contentDOM&&ch(this.view)||e;return!this.selectionRange.eq(i)&&(this.selectionRange.setRange(i),this.selectionChanged=!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}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,oh),lh&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),lh&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){this.delayedAndroidKey||requestAnimationFrame((()=>{let t=this.delayedAndroidKey;this.delayedAndroidKey=null;let e=this.view.state;Os(this.view.contentDOM,t.key,t.keyCode)?this.processRecords():this.flush(),this.view.state==e&&this.view.update([])})),this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e})}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())}processRecords(){let t=this.queue;for(let s of this.observer.takeRecords())t.push(s);t.length&&(this.queue=[]);let e=-1,i=-1,n=!1;for(let s of t){let t=this.readMutation(s);t&&(t.typeOver&&(n=!0),-1==e?({from:e,to:i}=t):(e=Math.min(t.from,e),i=Math.max(t.to,i)))}return{from:e,to:i,typeOver:n}}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return;t&&this.readSelectionRange();let{from:e,to:i,typeOver:n}=this.processRecords(),s=this.selectionChanged&&ps(this.dom,this.selectionRange);if(e<0&&!s)return;this.selectionChanged=!1;let r=this.view.state;this.onChange(e,i,n),this.view.state==r&&this.view.update([])}readMutation(t){let e=this.view.docView.nearest(t.target);if(!e||e.ignoreMutation(t))return null;if(e.markDirty("attributes"==t.type),"attributes"==t.type&&(e.dirty|=4),"childList"==t.type){let i=ah(e,t.previousSibling||t.target.previousSibling,-1),n=ah(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"characterData"==t.type?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}destroy(){var t,e,i;this.stop(),null===(t=this.intersection)||void 0===t||t.disconnect(),null===(e=this.gapIntersection)||void 0===e||e.disconnect(),null===(i=this.resize)||void 0===i||i.disconnect();for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.onResize),window.removeEventListener("beforeprint",this.onPrint),this.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout)}}function ah(t,e,i){while(e){let n=Ps.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 ch(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,l=t.docView.domAtPos(t.state.selection.main.anchor);return ms(l.node,l.offset,r,o)&&([n,s,r,o]=[r,o,n,s]),{anchorNode:n,anchorOffset:s,focusNode:r,focusOffset:o}}function uh(t,e,i,n){let s,r,o=t.state.selection.main;if(e>-1){let n=t.docView.domBoundsAround(e,i,0);if(!n||t.state.readOnly)return;let{from:l,to:h}=n,a=t.docView.impreciseHead||t.docView.impreciseAnchor?[]:fh(t),c=new wo(a,t.state);c.readRange(n.startDOM,n.endDOM);let u=o.from,d=null;(8===t.inputState.lastKeyCode&&t.inputState.lastKeyTime>Date.now()-100||Js.android&&c.text.length<h-l)&&(u=o.to,d="end");let f=dh(t.state.doc.sliceString(l,h,mo),c.text,u-l,d);f&&(Js.chrome&&13==t.inputState.lastKeyCode&&f.toB==f.from+2&&c.text.slice(f.from,f.toB)==mo+mo&&f.toB--,s={from:l+f.from,to:l+f.toA,insert:Ot.xv.of(c.text.slice(f.from,f.toB).split(mo))}),r=ph(a,l)}else if(t.hasFocus||!t.state.facet(Wr)){let e=t.observer.selectionRange,{impreciseHead:i,impreciseAnchor:n}=t.docView,s=i&&i.node==e.focusNode&&i.offset==e.focusOffset||!ds(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),h=n&&n.node==e.anchorNode&&n.offset==e.anchorOffset||!ds(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset);s==o.head&&h==o.anchor||(r=l.jT.single(h,s))}if(s||r)if(!s&&n&&!o.empty&&r&&r.main.empty?s={from:o.from,to:o.to,insert:t.state.doc.slice(o.from,o.to)}:s&&s.from>=o.from&&s.to<=o.to&&(s.from!=o.from||s.to!=o.to)&&o.to-o.from-(s.to-s.from)<=4&&(s={from:o.from,to:o.to,insert:t.state.doc.slice(o.from,s.from).append(s.insert).append(t.state.doc.slice(s.to,o.to))}),s){let e=t.state;if(Js.ios&&t.inputState.flushIOSKey(t))return;if(Js.android&&(s.from==o.from&&s.to==o.to&&1==s.insert.length&&2==s.insert.lines&&Os(t.contentDOM,"Enter",13)||s.from==o.from-1&&s.to==o.to&&0==s.insert.length&&Os(t.contentDOM,"Backspace",8)||s.from==o.from&&s.to==o.to+1&&0==s.insert.length&&Os(t.contentDOM,"Delete",46)))return;let i,n=s.insert.toString();if(t.state.facet(Lr).some((e=>e(t,s.from,s.to,n))))return;if(t.inputState.composing>=0&&t.inputState.composing++,s.from>=o.from&&s.to<=o.to&&s.to-s.from>=(o.to-o.from)/3&&(!r||r.main.empty&&r.main.from==s.from+s.insert.length)&&t.inputState.composing<0){let n=o.from<s.from?e.sliceDoc(o.from,s.from):"",r=o.to>s.to?e.sliceDoc(s.to,o.to):"";i=e.replaceSelection(t.state.toText(n+s.insert.sliceString(0,void 0,t.state.lineBreak)+r))}else{let n=e.changes(s),h=r&&!e.selection.main.eq(r.main)&&r.main.to<=n.newLength?r.main:void 0;if(e.selection.ranges.length>1&&t.inputState.composing>=0&&s.to<=o.to&&s.to>=o.to-10){let r=t.state.sliceDoc(s.from,s.to),a=So(t)||t.state.doc.lineAt(o.head),c=o.to-s.to,u=o.to-o.from;i=e.changeByRange((i=>{if(i.from==o.from&&i.to==o.to)return{changes:n,range:h||i.map(n)};let d=i.to-c,f=d-r.length;if(i.to-i.from!=u||t.state.sliceDoc(f,d)!=r||a&&i.to>=a.from&&i.from<=a.to)return{range:i};let p=e.changes({from:f,to:d,insert:s.insert}),g=i.to-o.to;return{changes:p,range:h?l.jT.range(Math.max(0,h.anchor+g),Math.max(0,h.head+g)):i.map(p)}}))}else i={changes:n,selection:h&&e.selection.replaceRange(h)}}let h="input.type";t.composing&&(h+=".compose",t.inputState.compositionFirstChange&&(h+=".start",t.inputState.compositionFirstChange=!1)),t.dispatch(i,{scrollIntoView:!0,userEvent:h})}else if(r&&!r.main.eq(o)){let e=!1,i="select";t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(e=!0),i=t.inputState.lastSelectionOrigin),t.dispatch({selection:r,scrollIntoView:e,userEvent:i})}}function dh(t,e,i,n){let s=Math.min(t.length,e.length),r=0;while(r<s&&t.charCodeAt(r)==e.charCodeAt(r))r++;if(r==s&&t.length==e.length)return null;let o=t.length,l=e.length;while(o>0&&l>0&&t.charCodeAt(o-1)==e.charCodeAt(l-1))o--,l--;if("end"==n){let t=Math.max(0,r-Math.min(o,l));i-=o+t-r}if(o<r&&t.length<e.length){let t=i<=r&&i>=o?r-i:0;r-=t,l=r+(l-o),o=r}else if(l<r){let t=i<=r&&i>=l?r-i:0;r-=t,o=r+(o-l),l=r}return{from:r,toA:o,toB:l}}function fh(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:n,focusNode:s,focusOffset:r}=t.observer.selectionRange;return i&&(e.push(new yo(i,n)),s==i&&r==n||e.push(new yo(s,r))),e}function ph(t,e){if(0==t.length)return null;let i=t[0].pos,n=2==t.length?t[1].pos:i;return i>-1&&n>-1?l.jT.single(i+e,n+e):null}class gh{constructor(t={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.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||Es(t.parent)||document,this.viewState=new ql(t.state||l.yy.create()),this.plugins=this.state.facet(jr).map((t=>new _r(t)));for(let e of this.plugins)e.update(this);this.observer=new hh(this,((t,e,i)=>{uh(this,t,e,i)}),(t=>{this.inputState.runScrollHandlers(this,t),this.observer.intersecting&&this.measure()})),this.inputState=new Go(this),this.docView=new bo(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,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}get compositionStarted(){return this.inputState.composing>=0}dispatch(...t){this._dispatch(1==t.length&&t[0]instanceof l.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,n=this.state;for(let r of t){if(r.startState!=n)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");n=r.state}if(this.destroyed)return void(this.viewState.state=n);if(n.facet(l.yy.phrases)!=this.state.facet(l.yy.phrases))return this.setState(n);e=new Qr(this,n,t);let s=this.viewState.scrollTarget;try{this.updateState=2;for(let e of t){if(s&&(s=s.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection;s=new Vr(t.empty?t:l.jT.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(Pr)?s=new Vr(t.value):t.is(Nr)?s=new Vr(t.value,"center"):t.is(Ir)&&(s=t.value)}this.viewState.update(e,s),this.bidiCache=yh.update(this.bidiCache,e.changes),e.empty||(this.updatePlugins(e),this.inputState.update(e)),i=this.docView.update(e),this.state.facet(Jr)!=this.styleModules&&this.mountStyles(),this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(i,t.some((t=>t.isUserEvent("select.pointer"))))}finally{this.updateState=0}if(e.startState.facet(Ql)!=e.state.facet(Ql)&&(this.viewState.mustMeasureContent=!0),(i||s||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!e.empty)for(let r of this.state.facet(Rr))r(e)}setState(t){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)return void(this.viewState.state=t);this.updateState=2;let e=this.hasFocus;try{for(let t of this.plugins)t.destroy(this);this.viewState=new ql(t),this.plugins=t.facet(jr).map((t=>new _r(t))),this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView=new bo(this),this.inputState.ensureHandlers(this),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(jr),i=t.state.facet(jr);if(e!=i){let n=[];for(let s of i){let i=e.indexOf(s);if(i<0)n.push(new _r(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.pluginMap.clear(),this.inputState.ensureHandlers(this)}else for(let n of this.plugins)n.mustUpdate=t;for(let n=0;n<this.plugins.length;n++)this.plugins[n].update(this)}measure(t=!0){if(this.destroyed)return;this.measureScheduled>-1&&cancelAnimationFrame(this.measureScheduled),this.measureScheduled=0,t&&this.observer.flush();let e=null;try{for(let t=0;;t++){this.updateState=1;let n=this.viewport,s=this.viewState.measure(this);if(!s&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(t>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let r=[];4&s||([this.measureRequests,r]=[r,this.measureRequests]);let o=r.map((t=>{try{return t.read(this)}catch(e){return Hr(this.state,e),vh}})),l=new Qr(this,this.state),h=!1,a=!1;l.flags|=s,e?e.flags|=s:e=l,this.updateState=2,l.empty||(this.updatePlugins(l),this.inputState.update(l),this.updateAttrs(),h=this.docView.update(l));for(let t=0;t<r.length;t++)if(o[t]!=vh)try{let e=r[t];e.write&&e.write(o[t],this)}catch(i){Hr(this.state,i)}if(this.viewState.scrollTarget&&(this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,a=!0),h&&this.docView.updateSelection(!0),this.viewport.from==n.from&&this.viewport.to==n.to&&!a&&0==this.measureRequests.length)break}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let n of this.state.facet(Rr))n(e)}get themeClasses(){return th+" "+(this.state.facet(Zl)?ih:eh)+" "+this.state.facet(Ql)}updateAttrs(){let t=bh(this,Gr,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(Wr)?"true":"false",class:"cm-content",style:`${Js.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),bh(this,Ur,e),this.observer.ignore((()=>{dr(this.contentDOM,this.contentAttrs,e),dr(this.dom,this.editorAttrs,t)})),this.editorAttrs=t,this.contentAttrs=e}showAnnouncements(t){let e=!0;for(let i of t)for(let t of i.effects)if(t.is(gh.announce)){e&&(this.announceDOM.textContent=""),e=!1;let i=this.announceDOM.appendChild(document.createElement("div"));i.textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(Jr),cs.V.mount(this.root,this.styleModules.concat(rh).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(!1)}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){let e=this.pluginMap.get(t);return(void 0===e||e&&e.spec!=t)&&this.pluginMap.set(t,e=this.plugins.find((e=>e.spec==t))||null),e&&e.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}blockAtHeight(t,e){let i=wh(e,this);return this.elementAtHeight(t-i).moveY(i)}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}visualLineAtHeight(t,e){let i=wh(e,this);return this.lineBlockAtHeight(t-i).moveY(i)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}viewportLines(t,e){let i=wh(e,this);for(let n of this.viewportLineBlocks)t(n.moveY(i))}get viewportLineBlocks(){return this.viewState.viewportLines}visualLineAt(t,e=0){return this.lineBlockAt(t).moveY(e+this.viewState.paddingTop)}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return _o(this,t,jo(this,t,e,i))}moveByGroup(t,e){return _o(this,t,jo(this,t,e,(e=>$o(this,t.head,e))))}moveToLineBoundary(t,e,i=!0){return qo(this,t,e,i)}moveVertically(t,e,i){return _o(this,t,Ko(this,t,e,i))}scrollPosIntoView(t){this.dispatch({effects:Pr.of(l.jT.cursor(t))})}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){return this.readMeasured(),Wo(this,t,e)}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),r=s[ao.find(s,t-n.from,-1,e)];return xs(i,r.dir==Zr.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>mh)return fo(t.length);let e=this.textDirection;for(let n of this.bidiCache)if(n.from==t.from&&n.dir==e)return n.order;let i=uo(t.text,this.textDirection);return this.bidiCache.push(new yh(t.from,t.to,e,i)),i}get hasFocus(){var t;return(document.hasFocus()||Js.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{Ds(this.contentDOM),this.docView.updateSelection()}))}destroy(){for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return Ir.of(new Vr("number"==typeof t?l.jT.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}static domEventHandlers(t){return $r.define((()=>({})),{eventHandlers:t})}static theme(t,e){let i=cs.V.newName(),n=[Ql.of(i),Jr.of(sh(`.${i}`,t))];return e&&e.dark&&n.push(Zl.of(!0)),n}static baseTheme(t){return l.Wl.lowest(Jr.of(sh("."+th,t,nh)))}}gh.scrollTo=Pr,gh.centerOn=Nr,gh.styleModule=Jr,gh.inputHandler=Lr,gh.exceptionSink=Br,gh.updateListener=Rr,gh.editable=Wr,gh.mouseSelectionStyle=Er,gh.dragMovesSelection=Or,gh.clickAddsSelectionRange=Tr,gh.decorations=Xr,gh.darkTheme=Zl,gh.contentAttributes=Ur,gh.editorAttributes=Gr,gh.lineWrapping=gh.contentAttributes.of({class:"cm-lineWrapping"}),gh.announce=l.Py.define();const mh=4096;function wh(t,e){return(null==t?e.contentDOM.getBoundingClientRect().top:t)+e.viewState.paddingTop}const vh={};class yh{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:Zr.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 yh(e.mapPos(r.from,1),e.mapPos(r.to,-1),r.dir,r.order))}return i}}function bh(t,e,i){for(let n=t.state.facet(e),s=n.length-1;s>=0;s--){let e=n[s],r="function"==typeof e?e(t):e;r&&cr(r,i)}return i}Js.mac||Js.windows||Js.linux;const xh=!Js.ios;const kh={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};xh&&(kh[".cm-line"].caretColor="transparent !important");const Sh=2e3;function Ah(t,e,i){let n=Math.min(e.line,i.line),s=Math.max(e.line,i.line),r=[];if(e.off>Sh||i.off>Sh||e.col<0||i.col<0){let o=Math.min(e.off,i.off),h=Math.max(e.off,i.off);for(let e=n;e<=s;e++){let i=t.doc.line(e);i.length<=h&&r.push(l.jT.range(i.from+o,i.to+h))}}else{let o=Math.min(e.col,i.col),h=Math.max(e.col,i.col);for(let e=n;e<=s;e++){let i=t.doc.line(e),n=(0,Ot.Gz)(i.text,o,t.tabSize,!0);if(n>-1){let e=(0,Ot.Gz)(i.text,h,t.tabSize);r.push(l.jT.range(i.from+n,i.from+e))}}}return r}function Mh(t,e){let i=t.coordsAtPos(t.viewport.from);return i?Math.round(Math.abs((i.left-e)/t.defaultCharacterWidth)):-1}function Ch(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1),n=t.state.doc.lineAt(i),s=i-n.from,r=s>Sh?-1:s==n.length?Mh(t,e.clientX):(0,Ot.IS)(n.text,t.state.tabSize,i-n.from);return{line:n.number,col:r,off:s}}function Dh(t,e){let i=Ch(t,e),n=t.state.selection;return i?{update(t){if(t.docChanged){let e=t.changes.mapPos(t.startState.doc.line(i.line).from),s=t.state.doc.lineAt(e);i={line:s.number,col:i.col,off:Math.min(i.off,s.length)},n=n.map(t.changes)}},get(e,s,r){let o=Ch(t,e);if(!o)return n;let h=Ah(t.state,i,o);return h.length?r?l.jT.create(h.concat(n.ranges)):l.jT.create(h):n}}:null}function Th(t){let e=(null===t||void 0===t?void 0:t.eventFilter)||(t=>t.altKey&&0==t.button);return gh.mouseSelectionStyle.of(((t,i)=>e(i)?Dh(t,i):null))}const Oh={Alt:[18,t=>t.altKey],Control:[17,t=>t.ctrlKey],Shift:[16,t=>t.shiftKey],Meta:[91,t=>t.metaKey]},Eh={style:"cursor: crosshair"};function Bh(t={}){let[e,i]=Oh[t.key||"Alt"],n=$r.fromClass(class{constructor(t){this.view=t,this.isDown=!1}set(t){this.isDown!=t&&(this.isDown=t,this.view.update([]))}},{eventHandlers:{keydown(t){this.set(t.keyCode==e||i(t))},keyup(t){t.keyCode!=e&&i(t)||this.set(!1)}}});return[n,gh.contentAttributes.of((t=>{var e;return(null===(e=t.plugin(n))||void 0===e?void 0:e.isDown)?Eh:null}))]}var Rh=i(97428),Lh=i(2903);class Ph{constructor(t,e,i){this.from=t,this.to=e,this.diagnostic=i}}class Nh{constructor(t,e,i){this.diagnostics=t,this.panel=e,this.selected=i}static init(t,e,i){let n=o.p.set(t.map((t=>t.from==t.to||t.from==t.to-1&&i.doc.lineAt(t.from).to==t.from?o.p.widget({widget:new Yh(t),diagnostic:t}).range(t.from):o.p.mark({attributes:{class:"cm-lintRange cm-lintRange-"+t.severity},diagnostic:t}).range(t.from,t.to))),!0);return new Nh(n,e,Vh(n))}}function Vh(t,e=null,i=0){let n=null;return t.between(i,1e9,((t,i,{spec:s})=>{if(!e||s.diagnostic==e)return n=new Ph(t,i,s.diagnostic),!1})),n}function Ih(t,e){return t.field(zh,!1)?e:e.concat(l.Py.appendConfig.of([zh,o.tk.decorations.compute([zh],(t=>{let{selected:e,panel:i}=t.field(zh);return e&&i&&e.from!=e.to?o.p.set([qh.range(e.from,e.to)]):o.p.none})),(0,Lh.bF)(jh),ia]))}const Hh=l.Py.define(),Wh=l.Py.define(),Fh=l.Py.define(),zh=l.QQ.define({create(){return new Nh(o.p.none,null,null)},update(t,e){if(e.docChanged){let i=t.diagnostics.map(e.changes),n=null;if(t.selected){let s=e.changes.mapPos(t.selected.from,1);n=Vh(i,t.selected.diagnostic,s)||Vh(i,null,s)}t=new Nh(i,t.panel,n)}for(let i of e.effects)i.is(Hh)?t=Nh.init(i.value,t.panel,e.state):i.is(Wh)?t=new Nh(t.diagnostics,i.value?Zh.open:null,t.selected):i.is(Fh)&&(t=new Nh(t.diagnostics,t.panel,i.value));return t},provide:t=>[Ui.from(t,(t=>t.panel)),o.tk.decorations.from(t,(t=>t.diagnostics))]});const qh=o.p.mark({class:"cm-lintRange cm-lintRange-active"});function jh(t,e,i){let{diagnostics:n}=t.state.field(zh),s=[],r=2e8,o=0;return n.between(e-(i<0?1:0),e+(i>0?1:0),((t,n,{spec:l})=>{e>=t&&e<=n&&(t==n||(e>t||i>0)&&(e<n||i<0))&&(s.push(l.diagnostic),r=Math.min(t,r),o=Math.max(n,o))})),s.length?{pos:r,end:o,above:t.state.doc.lineAt(r).to<o,create(){return{dom:$h(t,s)}}}:null}function $h(t,e){return Xi("ul",{class:"cm-tooltip-lint"},e.map((e=>Jh(t,e,!1))))}const Kh=t=>{let e=t.state.field(zh,!1);e&&e.panel||t.dispatch({effects:Ih(t.state,[Wh.of(!0)])});let i=ji(t,Zh.open);return i&&i.dom.querySelector(".cm-panel-lint ul").focus(),!0},_h=t=>{let e=t.state.field(zh,!1);return!(!e||!e.panel)&&(t.dispatch({effects:Wh.of(!1)}),!0)},Gh=t=>{let e=t.state.field(zh,!1);if(!e)return!1;let i=t.state.selection.main,n=e.diagnostics.iter(i.to+1);return!(!n.value&&(n=e.diagnostics.iter(0),!n.value||n.from==i.from&&n.to==i.to))&&(t.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0}),!0)},Uh=[{key:"Mod-Shift-m",run:Kh},{key:"F8",run:Gh}];function Xh(t){let e=[];if(t)t:for(let{name:i}of t){for(let t=0;t<i.length;t++){let n=i[t];if(/[a-zA-Z]/.test(n)&&!e.some((t=>t.toLowerCase()==n.toLowerCase()))){e.push(n);continue t}}e.push("")}return e}function Jh(t,e,i){var n;let s=i?Xh(e.actions):[];return Xi("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},Xi("span",{class:"cm-diagnosticText"},e.message),null===(n=e.actions)||void 0===n?void 0:n.map(((i,n)=>{let r=n=>{n.preventDefault();let s=Vh(t.state.field(zh).diagnostics,e);s&&i.apply(t,s.from,s.to)},{name:o}=i,l=s[n]?o.indexOf(s[n]):-1,h=l<0?o:[o.slice(0,l),Xi("u",o.slice(l,l+1)),o.slice(l+1)];return Xi("button",{type:"button",class:"cm-diagnosticAction",onclick:r,onmousedown:r,"aria-label":` Action: ${o}${l<0?"":` (access key "${s[n]})"`}.`},h)})),e.source&&Xi("div",{class:"cm-diagnosticSource"},e.source))}class Yh extends o.l9{constructor(t){super(),this.diagnostic=t}eq(t){return t.diagnostic==this.diagnostic}toDOM(){return Xi("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}}class Qh{constructor(t,e){this.diagnostic=e,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=Jh(t,e,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Zh{constructor(t){this.view=t,this.items=[];let e=e=>{if(27==e.keyCode)_h(this.view),this.view.focus();else if(38==e.keyCode||33==e.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==e.keyCode||34==e.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==e.keyCode)this.moveSelection(0);else if(35==e.keyCode)this.moveSelection(this.items.length-1);else if(13==e.keyCode)this.view.focus();else{if(!(e.keyCode>=65&&e.keyCode<=90&&this.selectedIndex>=0))return;{let{diagnostic:i}=this.items[this.selectedIndex],n=Xh(i.actions);for(let s=0;s<n.length;s++)if(n[s].toUpperCase().charCodeAt(0)==e.keyCode){let e=Vh(this.view.state.field(zh).diagnostics,i);e&&i.actions[s].apply(t,e.from,e.to)}}}e.preventDefault()},i=t=>{for(let e=0;e<this.items.length;e++)this.items[e].dom.contains(t.target)&&this.moveSelection(e)};this.list=Xi("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:e,onclick:i}),this.dom=Xi("div",{class:"cm-panel-lint"},this.list,Xi("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>_h(this.view)},"×")),this.update()}get selectedIndex(){let t=this.view.state.field(zh).selected;if(!t)return-1;for(let e=0;e<this.items.length;e++)if(this.items[e].diagnostic==t.diagnostic)return e;return-1}update(){let{diagnostics:t,selected:e}=this.view.state.field(zh),i=0,n=!1,s=null;t.between(0,this.view.state.doc.length,((t,r,{spec:o})=>{let l,h=-1;for(let e=i;e<this.items.length;e++)if(this.items[e].diagnostic==o.diagnostic){h=e;break}h<0?(l=new Qh(this.view,o.diagnostic),this.items.splice(i,0,l),n=!0):(l=this.items[h],h>i&&(this.items.splice(i,h-i),n=!0)),e&&l.diagnostic==e.diagnostic?l.dom.hasAttribute("aria-selected")||(l.dom.setAttribute("aria-selected","true"),s=l):l.dom.hasAttribute("aria-selected")&&l.dom.removeAttribute("aria-selected"),i++}));while(i<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0))n=!0,this.items.pop();0==this.items.length&&(this.items.push(new Qh(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),n=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:()=>({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:t,panel:e})=>{t.top<e.top?this.list.scrollTop-=e.top-t.top:t.bottom>e.bottom&&(this.list.scrollTop+=t.bottom-e.bottom)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),n&&this.sync()}sync(){let t=this.list.firstChild;function e(){let e=t;t=e.nextSibling,e.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){while(t!=i.dom)e();t=i.dom.nextSibling}else this.list.insertBefore(i.dom,t);while(t)e()}moveSelection(t){if(this.selectedIndex<0)return;let e=this.view.state.field(zh),i=Vh(e.diagnostics,this.items[t].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:Fh.of(i)})}static open(t){return new Zh(t)}}function ta(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}function ea(t){return ta(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const ia=o.tk.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:ea("#d11")},".cm-lintRange-warning":{backgroundImage:ea("orange")},".cm-lintRange-info":{backgroundImage:ea("#999")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});const na=[it(),ot(),(0,o.AE)(),p(),Dt(),(0,o.Uw)(),(0,o.qr)(),l.yy.allowMultipleSelections.of(!0),(0,P.nY)(),Rh.R_.fallback,Wt(),Di(),(0,Zn.ys)(),Th(),Bh(),(0,o.ZO)(),pn(),o.$f.of([...Li,...bi,...Kn,...L,...bt,...ss,...Zn.B1,...Uh])];var sa={name:"Codemirror",model:{prop:"value",event:"update:value"},props:{value:{type:String,default:""},extensions:{type:Array,default:function(){return[]}},height:{type:String,default:"500px"}},data:function(){return{codemirrorState:null,codemirrorView:null}},mounted:function(){this.handleInitCodemirror()},beforeDestroy:function(){this.codemirrorView&&this.codemirrorView.destroy()},methods:{handleInitCodemirror:function(){var t=this;this.codemirrorView&&this.codemirrorView.destroy();var e=this.$refs.codemirrorRef,i=o.tk.updateListener.of((function(e){if(e.docChanged){var i=e.state.doc;t.$emit("update:value",i.toString())}})),n=o.tk.theme({"&":{height:this.height}});this.codemirrorState=l.yy.create({doc:this.value,extensions:[na,i,o.$f.of([xi]),n].concat((0,r.Z)(this.extensions))}),this.codemirrorView=new o.tk({state:this.codemirrorState,parent:e})}}},ra=sa,oa=i(70739),la=(0,oa.Z)(ra,n,s,!1,null,null,null),ha=la.exports},26115:function(t,e,i){i.d(e,{ys:function(){return At},Mb:function(){return u},B1:function(){return Mt},eC:function(){return d},Gn:function(){return kt}});var n=i(46941),s=i(76089),r=i(25117),o=i(2903),l=i(40405);class h{constructor(t,e,i){this.state=t,this.pos=e,this.explicit=i,this.abortListeners=[]}tokenBefore(t){let e=(0,l.qz)(this.state).resolveInner(this.pos,-1);while(e&&t.indexOf(e.name)<0)e=e.parent;return e?{from:e.from,to:this.pos,text:this.state.sliceDoc(e.from,this.pos),type:e.type}:null}matchBefore(t){let e=this.state.doc.lineAt(this.pos),i=Math.max(e.from,this.pos-250),n=e.text.slice(i-e.from,this.pos-e.from),s=n.search(g(t,!1));return s<0?null:{from:i+s,to:this.pos,text:n.slice(s)}}get aborted(){return null==this.abortListeners}addEventListener(t,e){"abort"==t&&this.abortListeners&&this.abortListeners.push(e)}}function a(t){let e=Object.keys(t).join(""),i=/\w/.test(e);return i&&(e=e.replace(/\w/g,"")),`[${i?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function c(t){let e=Object.create(null),i=Object.create(null);for(let{label:s}of t){e[s[0]]=!0;for(let t=1;t<s.length;t++)i[s[t]]=!0}let n=a(e)+a(i)+"*$";return[new RegExp("^"+n),new RegExp(n)]}function u(t){let e=t.map((t=>"string"==typeof t?{label:t}:t)),[i,n]=e.every((t=>/^\w+$/.test(t.label)))?[/\w*$/,/\w+$/]:c(e);return t=>{let s=t.matchBefore(n);return s||t.explicit?{from:s?s.from:t.pos,options:e,span:i}:null}}function d(t,e){return i=>{for(let e=(0,l.qz)(i.state).resolveInner(i.pos,-1);e;e=e.parent)if(t.indexOf(e.name)>-1)return null;return e(i)}}class f{constructor(t,e,i){this.completion=t,this.source=e,this.match=i}}function p(t){return t.selection.main.head}function g(t,e){var i;let{source:n}=t,s=e&&"^"!=n[0],r="$"!=n[n.length-1];return s||r?new RegExp(`${s?"^":""}(?:${n})${r?"$":""}`,null!==(i=t.flags)&&void 0!==i?i:t.ignoreCase?"i":""):t}const m=n.q6.define();function w(t,e){let i=e.completion.apply||e.completion.label,n=e.source;"string"==typeof i?t.dispatch({changes:{from:n.from,to:n.to,insert:i},selection:{anchor:n.from+i.length},userEvent:"input.complete",annotations:m.of(e.completion)}):i(t,e.completion,n.from,n.to)}const v=new WeakMap;function y(t){if(!Array.isArray(t))return t;let e=v.get(t);return e||v.set(t,e=u(t)),e}class b{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[];for(let e=0;e<t.length;){let i=(0,s.gm)(t,e),n=(0,s.nZ)(i);this.chars.push(i);let r=t.slice(e,e+n),o=r.toUpperCase();this.folded.push((0,s.gm)(o==r?r.toLowerCase():o,0)),e+=n}this.astral=t.length!=this.chars.length}match(t){if(0==this.pattern.length)return[0];if(t.length<this.pattern.length)return null;let{chars:e,folded:i,any:n,precise:r,byWord:o}=this;if(1==e.length){let n=(0,s.gm)(t,0);return n==e[0]?[0,0,(0,s.nZ)(n)]:n==i[0]?[-200,0,(0,s.nZ)(n)]:null}let l=t.indexOf(this.pattern);if(0==l)return[0,0,this.pattern.length];let h=e.length,a=0;if(l<0){for(let r=0,o=Math.min(t.length,200);r<o&&a<h;){let o=(0,s.gm)(t,r);o!=e[a]&&o!=i[a]||(n[a++]=r),r+=(0,s.nZ)(o)}if(a<h)return null}let c=0,u=0,d=!1,f=0,p=-1,g=-1,m=/[a-z]/.test(t),w=!0;for(let v=0,y=Math.min(t.length,200),b=0;v<y&&u<h;){let n=(0,s.gm)(t,v);l<0&&(c<h&&n==e[c]&&(r[c++]=v),f<h&&(n==e[f]||n==i[f]?(0==f&&(p=v),g=v+1,f++):f=0));let a,y=n<255?n>=48&&n<=57||n>=97&&n<=122?2:n>=65&&n<=90?1:0:(a=(0,s.bg)(n))!=a.toLowerCase()?1:a!=a.toUpperCase()?2:0;(!v||1==y&&m||0==b&&0!=y)&&(e[u]==n||i[u]==n&&(d=!0)?o[u++]=v:o.length&&(w=!1)),b=y,v+=(0,s.nZ)(n)}return u==h&&0==o[0]&&w?this.result((d?-200:0)-100,o,t):f==h&&0==p?[-200-t.length,0,g]:l>-1?[-700-t.length,l,l+this.pattern.length]:f==h?[-900-t.length,p,g]:u==h?this.result((d?-200:0)-100-700+(w?0:-1100),o,t):2==e.length?null:this.result((n[0]?-700:0)-200-1100,n,t)}result(t,e,i){let n=[t-i.length],r=1;for(let o of e){let t=o+(this.astral?(0,s.nZ)((0,s.gm)(i,o)):1);r>1&&n[r-1]==o?n[r-1]=t:(n[r++]=o,n[r++]=t)}return n}}const x=n.r$.define({combine(t){return(0,n.BO)(t,{activateOnTyping:!0,override:null,maxRenderedOptions:100,defaultKeymap:!0,optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[]},{defaultKeymap:(t,e)=>t&&e,icons:(t,e)=>t&&e,optionClass:(t,e)=>i=>k(t(i),e(i)),addToOptions:(t,e)=>t.concat(e)})}});function k(t,e){return t?e?t+" "+e:t:e}function S(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(t){let e=document.createElement("div");return e.classList.add("cm-completionIcon"),t.type&&e.classList.add(...t.type.split(/\s+/g).map((t=>"cm-completionIcon-"+t))),e.setAttribute("aria-hidden","true"),e},position:20}),e.push({render(t,e,i){let n=document.createElement("span");n.className="cm-completionLabel";let{label:s}=t,r=0;for(let o=1;o<i.length;){let t=i[o++],e=i[o++];t>r&&n.appendChild(document.createTextNode(s.slice(r,t)));let l=n.appendChild(document.createElement("span"));l.appendChild(document.createTextNode(s.slice(t,e))),l.className="cm-completionMatchedText",r=e}return r<s.length&&n.appendChild(document.createTextNode(s.slice(r))),n},position:50},{render(t){if(!t.detail)return null;let e=document.createElement("span");return e.className="cm-completionDetail",e.textContent=t.detail,e},position:80}),e.sort(((t,e)=>t.position-e.position)).map((t=>t.render))}function A(t,e){let i=document.createElement("div");i.className="cm-tooltip cm-completionInfo";let{info:n}=t.completion;if("string"==typeof n)i.textContent=n;else{let s=n(t.completion);s.then?s.then((t=>i.appendChild(t)),(t=>(0,r.OO)(e.state,t,"completion info"))):i.appendChild(s)}return i}function M(t,e,i){if(t<=i)return{from:0,to:t};if(e<=t>>1){let t=Math.floor(e/i);return{from:t*i,to:(t+1)*i}}let n=Math.floor((t-e)/i);return{from:t-(n+1)*i,to:t-n*i}}class C{constructor(t,e){this.view=t,this.stateField=e,this.info=null,this.placeInfo={read:()=>this.measureInfo(),write:t=>this.positionInfo(t),key:this};let i=t.state.field(e),{options:n,selected:s}=i.open,r=t.state.facet(x);this.optionContent=S(r),this.optionClass=r.optionClass,this.range=M(n.length,s,r.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.dom.addEventListener("mousedown",(e=>{for(let i,s=e.target;s&&s!=this.dom;s=s.parentNode)if("LI"==s.nodeName&&(i=/-(\d+)$/.exec(s.id))&&+i[1]<n.length)return w(t,n[+i[1]]),void e.preventDefault()})),this.list=this.dom.appendChild(this.createListBox(n,i.id,this.range)),this.list.addEventListener("scroll",(()=>{this.info&&this.view.requestMeasure(this.placeInfo)}))}mount(){this.updateSel()}update(t){t.state.field(this.stateField)!=t.startState.field(this.stateField)&&this.updateSel()}positioned(){this.info&&this.view.requestMeasure(this.placeInfo)}updateSel(){let t=this.view.state.field(this.stateField),e=t.open;if((e.selected<this.range.from||e.selected>=this.range.to)&&(this.range=M(e.options.length,e.selected,this.view.state.facet(x).maxRenderedOptions),this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e.options,t.id,this.range)),this.list.addEventListener("scroll",(()=>{this.info&&this.view.requestMeasure(this.placeInfo)}))),this.updateSelectedOption(e.selected)){this.info&&(this.info.remove(),this.info=null);let t=e.options[e.selected];t.completion.info&&(this.info=this.dom.appendChild(A(t,this.view)),this.view.requestMeasure(this.placeInfo))}}updateSelectedOption(t){let e=null;for(let i=this.list.firstChild,n=this.range.from;i;i=i.nextSibling,n++)n==t?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),e=i):i.hasAttribute("aria-selected")&&i.removeAttribute("aria-selected");return e&&T(this.list,e),e}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let e=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),n=t.getBoundingClientRect();if(n.top>Math.min(innerHeight,e.bottom)-10||n.bottom<Math.max(0,e.top)+10)return null;let s=Math.max(0,Math.min(n.top,innerHeight-i.height))-e.top,o=this.view.textDirection==r.Nm.RTL,l=e.left,h=innerWidth-e.right;return o&&l<Math.min(i.width,h)?o=!1:!o&&h<Math.min(i.width,l)&&(o=!0),{top:s,left:o}}positionInfo(t){this.info&&(this.info.style.top=(t?t.top:-1e6)+"px",t&&(this.info.classList.toggle("cm-completionInfo-left",t.left),this.info.classList.toggle("cm-completionInfo-right",!t.left)))}createListBox(t,e,i){const n=document.createElement("ul");n.id=e,n.setAttribute("role","listbox");for(let s=i.from;s<i.to;s++){let{completion:i,match:r}=t[s];const o=n.appendChild(document.createElement("li"));o.id=e+"-"+s,o.setAttribute("role","option");let l=this.optionClass(i);l&&(o.className=l);for(let t of this.optionContent){let e=t(i,this.view.state,r);e&&o.appendChild(e)}}return i.from&&n.classList.add("cm-completionListIncompleteTop"),i.to<t.length&&n.classList.add("cm-completionListIncompleteBottom"),n}}function D(t){return e=>new C(e,t)}function T(t,e){let i=t.getBoundingClientRect(),n=e.getBoundingClientRect();n.top<i.top?t.scrollTop-=i.top-n.top:n.bottom>i.bottom&&(t.scrollTop+=n.bottom-i.bottom)}const O=300;function E(t){return 100*(t.boost||0)+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}function B(t,e){let i=[],n=0;for(let o of t)if(o.hasResult())if(!1===o.result.filter)for(let t of o.result.options)i.push(new f(t,o,[1e9-n++]));else{let t,n=new b(e.sliceDoc(o.from,o.to));for(let e of o.result.options)(t=n.match(e.label))&&(null!=e.boost&&(t[0]+=e.boost),i.push(new f(e,o,t)))}i.sort(H);let s=[],r=null;for(let o of i.sort(H)){if(s.length==O)break;r&&r.label==o.completion.label&&r.detail==o.completion.detail&&r.type==o.completion.type&&r.apply==o.completion.apply?E(o.completion)>E(r)&&(s[s.length-1]=o):s.push(o),r=o.completion}return s}class R{constructor(t,e,i,n,s){this.options=t,this.attrs=e,this.tooltip=i,this.timestamp=n,this.selected=s}setSelected(t,e){return t==this.selected||t>=this.options.length?this:new R(this.options,V(e,t),this.tooltip,this.timestamp,t)}static build(t,e,i,n,s){let r=B(t,e);if(!r.length)return null;let o=0;if(n&&n.selected){let t=n.options[n.selected].completion;for(let e=0;e<r.length&&!o;e++)r[e].completion==t&&(o=e)}return new R(r,V(i,o),{pos:t.reduce(((t,e)=>e.hasResult()?Math.min(t,e.from):t),1e8),create:D(_),above:s.aboveCursor},n?n.timestamp:Date.now(),o)}map(t){return new R(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:t.mapPos(this.tooltip.pos)}),this.timestamp,this.selected)}}class L{constructor(t,e,i){this.active=t,this.id=e,this.open=i}static start(){return new L(I,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(t){let{state:e}=t,i=e.facet(x),n=i.override||e.languageDataAt("autocomplete",p(e)).map(y),s=n.map((e=>{let n=this.active.find((t=>t.source==e))||new F(e,this.active.some((t=>0!=t.state))?1:0);return n.update(t,i)}));s.length==this.active.length&&s.every(((t,e)=>t==this.active[e]))&&(s=this.active);let r=t.selection||s.some((e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to)))||!P(s,this.active)?R.build(s,e,this.id,this.open,i):this.open&&t.docChanged?this.open.map(t.changes):this.open;!r&&s.every((t=>1!=t.state))&&s.some((t=>t.hasResult()))&&(s=s.map((t=>t.hasResult()?new F(t.source,0):t)));for(let o of t.effects)o.is(K)&&(r=r&&r.setSelected(o.value,this.id));return s==this.active&&r==this.open?this:new L(s,this.id,r)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:N}}function P(t,e){if(t==e)return!0;for(let i=0,n=0;;){while(i<t.length&&!t[i].hasResult)i++;while(n<e.length&&!e[n].hasResult)n++;let s=i==t.length,r=n==e.length;if(s||r)return s==r;if(t[i++].result!=e[n++].result)return!1}}const N={"aria-autocomplete":"list","aria-expanded":"false"};function V(t,e){return{"aria-autocomplete":"list","aria-expanded":"true","aria-activedescendant":t+"-"+e,"aria-controls":t}}const I=[];function H(t,e){let i=e.match[0]-t.match[0];return i||t.completion.label.localeCompare(e.completion.label)}function W(t){return t.isUserEvent("input.type")?"input":t.isUserEvent("delete.backward")?"delete":null}class F{constructor(t,e,i=-1){this.source=t,this.state=e,this.explicitPos=i}hasResult(){return!1}update(t,e){let i=W(t),n=this;i?n=n.handleUserEvent(t,i,e):t.docChanged?n=n.handleChange(t):t.selection&&0!=n.state&&(n=new F(n.source,0));for(let s of t.effects)if(s.is(q))n=new F(n.source,1,s.value?p(t.state):-1);else if(s.is(j))n=new F(n.source,0);else if(s.is($))for(let t of s.value)t.source==n.source&&(n=t);return n}handleUserEvent(t,e,i){return"delete"!=e&&i.activateOnTyping?new F(this.source,1):this.map(t.changes)}handleChange(t){return t.changes.touchesRange(p(t.startState))?new F(this.source,0):this.map(t.changes)}map(t){return t.empty||this.explicitPos<0?this:new F(this.source,this.state,t.mapPos(this.explicitPos))}}class z extends F{constructor(t,e,i,n,s,r){super(t,2,e),this.result=i,this.from=n,this.to=s,this.span=r}hasResult(){return!0}handleUserEvent(t,e,i){let n=t.changes.mapPos(this.from),s=t.changes.mapPos(this.to,1),r=p(t.state);if((this.explicitPos>-1?r<n:r<=n)||r>s)return new F(this.source,"input"==e&&i.activateOnTyping?1:0);let o=this.explicitPos<0?-1:t.changes.mapPos(this.explicitPos);return this.span&&(n==s||this.span.test(t.state.sliceDoc(n,s)))?new z(this.source,o,this.result,n,s,this.span):new F(this.source,1,o)}handleChange(t){return t.changes.touchesRange(this.from,this.to)?new F(this.source,0):this.map(t.changes)}map(t){return t.empty?this:new z(this.source,this.explicitPos<0?-1:t.mapPos(this.explicitPos),this.result,t.mapPos(this.from),t.mapPos(this.to,1),this.span)}}const q=n.Py.define(),j=n.Py.define(),$=n.Py.define({map(t,e){return t.map((t=>t.map(e)))}}),K=n.Py.define(),_=n.QQ.define({create(){return L.start()},update(t,e){return t.update(e)},provide:t=>[o.hJ.from(t,(t=>t.tooltip)),r.tk.contentAttributes.from(t,(t=>t.attrs))]}),G=75;function U(t,e="option"){return i=>{let n=i.state.field(_,!1);if(!n||!n.open||Date.now()-n.open.timestamp<G)return!1;let s,r=1;"page"==e&&(s=(0,o.gB)(i,n.open.tooltip))&&(r=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let l=n.open.selected+r*(t?1:-1),{length:h}=n.open.options;return l<0?l="page"==e?0:h-1:l>=h&&(l="page"==e?h-1:0),i.dispatch({effects:K.of(l)}),!0}}const X=t=>{let e=t.state.field(_,!1);return!(t.state.readOnly||!e||!e.open||Date.now()-e.open.timestamp<G)&&(w(t,e.open.options[e.open.selected]),!0)},J=t=>{let e=t.state.field(_,!1);return!!e&&(t.dispatch({effects:q.of(!0)}),!0)},Y=t=>{let e=t.state.field(_,!1);return!(!e||!e.active.some((t=>0!=t.state)))&&(t.dispatch({effects:j.of(null)}),!0)};class Q{constructor(t,e){this.active=t,this.context=e,this.time=Date.now(),this.updates=[],this.done=void 0}}const Z=50,tt=50,et=1e3,it=r.lg.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.composing=0;for(let e of t.state.field(_).active)1==e.state&&this.startQuery(e)}update(t){let e=t.state.field(_);if(!t.selectionSet&&!t.docChanged&&t.startState.field(_)==e)return;let i=t.transactions.some((t=>(t.selection||t.docChanged)&&!W(t)));for(let s=0;s<this.running.length;s++){let e=this.running[s];if(i||e.updates.length+t.transactions.length>tt&&e.time-Date.now()>et){for(let t of e.context.abortListeners)try{t()}catch(n){(0,r.OO)(this.view.state,n)}e.context.abortListeners=null,this.running.splice(s--,1)}else e.updates.push(...t.transactions)}if(this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),this.debounceUpdate=e.active.some((t=>1==t.state&&!this.running.some((e=>e.active.source==t.source))))?setTimeout((()=>this.startUpdate()),Z):-1,0!=this.composing)for(let s of t.transactions)"input"==W(s)?this.composing=2:2==this.composing&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1;let{state:t}=this.view,e=t.field(_);for(let i of e.active)1!=i.state||this.running.some((t=>t.active.source==i.source))||this.startQuery(i)}startQuery(t){let{state:e}=this.view,i=p(e),n=new h(e,i,t.explicitPos==i),s=new Q(t,n);this.running.push(s),Promise.resolve(t.source(n)).then((t=>{s.context.aborted||(s.done=t||null,this.scheduleAccept())}),(t=>{this.view.dispatch({effects:j.of(null)}),(0,r.OO)(this.view.state,t)}))}scheduleAccept(){this.running.every((t=>void 0!==t.done))?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout((()=>this.accept()),Z))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],i=this.view.state.facet(x);for(let n=0;n<this.running.length;n++){let s=this.running[n];if(void 0===s.done)continue;if(this.running.splice(n--,1),s.done){let n=new z(s.active.source,s.active.explicitPos,s.done,s.done.from,null!==(t=s.done.to)&&void 0!==t?t:p(s.updates.length?s.updates[0].startState:this.view.state),s.done.span&&!1!==s.done.filter?g(s.done.span,!0):null);for(let t of s.updates)n=n.update(t,i);if(n.hasResult()){e.push(n);continue}}let r=this.view.state.field(_).active.find((t=>t.source==s.active.source));if(r&&1==r.state)if(null==s.done){let t=new F(s.active.source,0);for(let e of s.updates)t=t.update(e,i);1!=t.state&&e.push(t)}else this.startQuery(r)}e.length&&this.view.dispatch({effects:$.of(e)})}},{eventHandlers:{compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout((()=>this.view.dispatch({effects:q.of(!1)})),20),this.composing=0}}}),nt=r.tk.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",listStyle:"none",margin:0,padding:0,"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer",padding:"1px 3px",lineHeight:1.2}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"300px"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class st{constructor(t,e,i,n){this.field=t,this.line=e,this.from=i,this.to=n}}class rt{constructor(t,e,i){this.field=t,this.from=e,this.to=i}map(t){return new rt(this.field,t.mapPos(this.from,-1),t.mapPos(this.to,1))}}class ot{constructor(t,e){this.lines=t,this.fieldPositions=e}instantiate(t,e){let i=[],n=[e],s=t.doc.lineAt(e),r=/^\s*/.exec(s.text)[0];for(let h of this.lines){if(i.length){let i=r,s=/^\t*/.exec(h)[0].length;for(let e=0;e<s;e++)i+=t.facet(l.c);n.push(e+i.length-s),h=i+h.slice(s)}i.push(h),e+=h.length+1}let o=this.fieldPositions.map((t=>new rt(t.field,n[t.line]+t.from,n[t.line]+t.to)));return{text:i,ranges:o}}static parse(t){let e,i=[],n=[],s=[];for(let r of t.split(/\r\n?|\n/)){while(e=/[#$]\{(?:(\d+)(?::([^}]*))?|([^}]*))\}/.exec(r)){let t=e[1]?+e[1]:null,o=e[2]||e[3]||"",l=-1;for(let e=0;e<i.length;e++)(null!=t?i[e].seq==t:o&&i[e].name==o)&&(l=e);if(l<0){let e=0;while(e<i.length&&(null==t||null!=i[e].seq&&i[e].seq<t))e++;i.splice(e,0,{seq:t,name:o}),l=e;for(let t of s)t.field>=l&&t.field++}s.push(new st(l,n.length,e.index,e.index+o.length)),r=r.slice(0,e.index)+o+r.slice(e.index+e[0].length)}n.push(r)}return new ot(n,s)}}let lt=r.p.widget({widget:new class extends r.l9{toDOM(){let t=document.createElement("span");return t.className="cm-snippetFieldPosition",t}ignoreEvent(){return!1}}}),ht=r.p.mark({class:"cm-snippetField"});class at{constructor(t,e){this.ranges=t,this.active=e,this.deco=r.p.set(t.map((t=>(t.from==t.to?lt:ht).range(t.from,t.to))))}map(t){return new at(this.ranges.map((e=>e.map(t))),this.active)}selectionInsideField(t){return t.ranges.every((t=>this.ranges.some((e=>e.field==this.active&&e.from<=t.from&&e.to>=t.to))))}}const ct=n.Py.define({map(t,e){return t&&t.map(e)}}),ut=n.Py.define(),dt=n.QQ.define({create(){return null},update(t,e){for(let i of e.effects){if(i.is(ct))return i.value;if(i.is(ut)&&t)return new at(t.ranges,i.value)}return t&&e.docChanged&&(t=t.map(e.changes)),t&&e.selection&&!t.selectionInsideField(e.selection)&&(t=null),t},provide:t=>r.tk.decorations.from(t,(t=>t?t.deco:r.p.none))});function ft(t,e){return n.jT.create(t.filter((t=>t.field==e)).map((t=>n.jT.range(t.from,t.to))))}function pt(t){let e=ot.parse(t);return(t,i,r,o)=>{let{text:l,ranges:h}=e.instantiate(t.state,r),a={changes:{from:r,to:o,insert:s.xv.of(l)}};if(h.length&&(a.selection=ft(h,0)),h.length>1){let e=new at(h,0),i=a.effects=[ct.of(e)];void 0===t.state.field(dt,!1)&&i.push(n.Py.appendConfig.of([dt,xt,St,nt]))}t.dispatch(t.state.update(a))}}function gt(t){return({state:e,dispatch:i})=>{let n=e.field(dt,!1);if(!n||t<0&&0==n.active)return!1;let s=n.active+t,r=t>0&&!n.ranges.some((e=>e.field==s+t));return i(e.update({selection:ft(n.ranges,s),effects:ct.of(r?null:new at(n.ranges,s))})),!0}}const mt=({state:t,dispatch:e})=>{let i=t.field(dt,!1);return!!i&&(e(t.update({effects:ct.of(null)})),!0)},wt=gt(1),vt=gt(-1),yt=[{key:"Tab",run:wt,shift:vt},{key:"Escape",run:mt}],bt=n.r$.define({combine(t){return t.length?t[0]:yt}}),xt=n.Wl.highest(r.$f.compute([bt],(t=>t.facet(bt))));function kt(t,e){return Object.assign(Object.assign({},e),{apply:pt(t)})}const St=r.tk.domEventHandlers({mousedown(t,e){let i,n=e.state.field(dt,!1);if(!n||null==(i=e.posAtCoords({x:t.clientX,y:t.clientY})))return!1;let s=n.ranges.find((t=>t.from<=i&&t.to>=i));return!(!s||s.field==n.active)&&(e.dispatch({selection:ft(n.ranges,s.field),effects:ct.of(n.ranges.some((t=>t.field>s.field))?new at(n.ranges,s.field):null)}),!0)}});function At(t={}){return[_,x.of(t),it,Ct,nt]}const Mt=[{key:"Ctrl-Space",run:J},{key:"Escape",run:Y},{key:"ArrowDown",run:U(!0)},{key:"ArrowUp",run:U(!1)},{key:"PageDown",run:U(!0,"page")},{key:"PageUp",run:U(!1,"page")},{key:"Enter",run:X}],Ct=n.Wl.highest(r.$f.computeN([x],(t=>t.facet(x).defaultKeymap?[Mt]:[])))},97428:function(t,e,i){i.d(e,{R_:function(){return $},Gv:function(){return g},pJ:function(){return j}});var n=i(17918),s=i(70876),r=i(25117),o=i(46941),l=i(40405),h=i(96651);let a=0;class c{constructor(t,e,i){this.set=t,this.base=e,this.modified=i,this.id=a++}static define(t){if(null===t||void 0===t?void 0:t.base)throw new Error("Can not derive from a modified tag");let e=new c([],null,[]);if(e.set.push(e),t)for(let i of t.set)e.set.push(i);return e}static defineModifier(){let t=new d;return e=>e.modified.indexOf(t)>-1?e:d.get(e.base||e,e.modified.concat(t).sort(((t,e)=>t.id-e.id)))}}let u=0;class d{constructor(){this.instances=[],this.id=u++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find((i=>i.base==t&&f(e,i.modified)));if(i)return i;let n=[],s=new c(n,t,e);for(let o of e)o.instances.push(s);let r=p(e);for(let o of t.set)for(let t of r)n.push(d.get(o,t));return s}}function f(t,e){return t.length==e.length&&t.every(((t,i)=>t==e[i]))}function p(t){let e=[t];for(let i=0;i<t.length;i++)for(let n of p(t.slice(0,i).concat(t.slice(i+1))))e.push(n);return e}function g(t){let e=Object.create(null);for(let i in t){let n=t[i];Array.isArray(n)||(n=[n]);for(let t of i.split(" "))if(t){let i=[],s=2,r=t;for(let e=0;;){if("..."==r&&e>0&&e+3==t.length){s=1;break}let n=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(r);if(!n)throw new RangeError("Invalid path: "+t);if(i.push("*"==n[0]?null:'"'==n[0][0]?JSON.parse(n[0]):n[0]),e+=n[0].length,e==t.length)break;let o=t[e++];if(e==t.length&&"!"==o){s=0;break}if("/"!=o)throw new RangeError("Invalid path: "+t);r=t.slice(e)}let o=i.length-1,l=i[o];if(!l)throw new RangeError("Invalid path: "+t);let h=new b(n,s,o>0?i.slice(0,o):null);e[l]=h.sort(e[l])}}return m.add(e)}const m=new n.md,w=o.r$.define({combine(t){return t.length?x.combinedMatch(t):null}}),v=o.r$.define({combine(t){return t.length?t[0].match:null}});function y(t){return t.facet(w)||t.facet(v)}class b{constructor(t,e,i,n){this.tags=t,this.mode=e,this.context=i,this.next=n}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}}class x{constructor(t,e){let i;function n(t){let e=s.V.newName();return(i||(i=Object.create(null)))["."+e]=t,e}this.map=Object.create(null),this.all="string"==typeof e.all?e.all:e.all?n(e.all):null;for(let s of t){let t=(s.class||n(Object.assign({},s,{tag:null})))+(this.all?" "+this.all:""),e=s.tag;if(Array.isArray(e))for(let i of e)this.map[i.id]=t;else this.map[e.id]=t}this.module=i?new s.V(i):null,this.scope=e.scope||null,this.match=this.match.bind(this);let o=[S];this.module&&o.push(r.tk.styleModule.of(this.module)),this.extension=o.concat(w.of(this)),this.fallback=o.concat(v.of(this))}match(t,e){if(this.scope&&e!=this.scope)return null;for(let i of t.set){let e=this.map[i.id];if(void 0!==e)return i!=t&&(this.map[t.id]=e),e}return this.map[t.id]=this.all}static combinedMatch(t){if(1==t.length)return t[0].match;let e=t.some((t=>t.scope))?void 0:Object.create(null);return(i,n)=>{let s=e&&e[i.id];if(void 0!==s)return s;let r=null;for(let e of t){let t=e.match(i,n);t&&(r=r?r+" "+t:t)}return e&&(e[i.id]=r),r}}static define(t,e){return new x(t,e||{})}static get(t,e,i){let s=y(t);return s&&s(e,i||n.Jq.none)}}class k{constructor(t){this.markCache=Object.create(null),this.tree=(0,l.qz)(t.state),this.decorations=this.buildDeco(t,y(t.state))}update(t){let e=(0,l.qz)(t.state),i=y(t.state),n=i!=t.startState.facet(w);e.length<t.view.viewport.to&&!n&&e.type==this.tree.type?this.decorations=this.decorations.map(t.changes):(e!=this.tree||t.viewportChanged||n)&&(this.tree=e,this.decorations=this.buildDeco(t.view,i))}buildDeco(t,e){if(!e||!this.tree.length)return r.p.none;let i=new h.f_;for(let{from:n,to:s}of t.visibleRanges)C(this.tree,n,s,e,((t,e,n)=>{i.add(t,e,this.markCache[n]||(this.markCache[n]=r.p.mark({class:n})))}));return i.finish()}}const S=o.Wl.high(r.lg.fromClass(k,{decorations:t=>t.decorations})),A=[""];class M{constructor(t,e,i){this.at=t,this.style=e,this.span=i,this.class=""}startSpan(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,e,i,s,r,o){let{type:l,from:h,to:a}=t;if(h>=i||a<=e)return;A[r]=l.name,l.isTop&&(o=l);let c=s,u=l.prop(m),d=!1;while(u){if(!u.context||D(u.context,A,r)){for(let t of u.tags){let e=this.style(t,o);e&&(c&&(c+=" "),c+=e,1==u.mode?s+=(s?" ":"")+e:0==u.mode&&(d=!0))}break}u=u.next}if(this.startSpan(t.from,c),d)return;let f=t.tree&&t.tree.prop(n.md.mounted);if(f&&f.overlay){let n=t.node.enter(f.overlay[0].from+h,1),l=t.firstChild();for(let u=0,d=h;;u++){let p=u<f.overlay.length?f.overlay[u]:null,g=p?p.from+h:a,m=Math.max(e,d),w=Math.min(i,g);if(m<w&&l)while(t.from<w)if(this.highlightRange(t,m,w,s,r+1,o),this.startSpan(Math.min(i,t.to),c),t.to>=g||!t.nextSibling())break;if(!p||g>i)break;d=p.to+h,d>e&&(this.highlightRange(n.cursor,Math.max(e,p.from+h),Math.min(i,d),s,r,f.tree.type),this.startSpan(d,c))}l&&t.parent()}else if(t.firstChild()){do{if(!(t.to<=e)){if(t.from>=i)break;this.highlightRange(t,e,i,s,r+1,o),this.startSpan(Math.min(i,t.to),c)}}while(t.nextSibling());t.parent()}}}function C(t,e,i,n,s){let r=new M(e,n,s);r.highlightRange(t.cursor(),e,i,"",0,t.type),r.flush(i)}function D(t,e,i){if(t.length>i-1)return!1;for(let n=i-1,s=t.length-1;s>=0;s--,n--){let i=t[s];if(i&&i!=e[n])return!1}return!0}const T=c.define,O=T(),E=T(),B=T(E),R=T(E),L=T(),P=T(L),N=T(L),V=T(),I=T(V),H=T(),W=T(),F=T(),z=T(F),q=T(),j={comment:O,lineComment:T(O),blockComment:T(O),docComment:T(O),name:E,variableName:T(E),typeName:B,tagName:T(B),propertyName:R,attributeName:T(R),className:T(E),labelName:T(E),namespace:T(E),macroName:T(E),literal:L,string:P,docString:T(P),character:T(P),attributeValue:T(P),number:N,integer:T(N),float:T(N),bool:T(L),regexp:T(L),escape:T(L),color:T(L),url:T(L),keyword:H,self:T(H),null:T(H),atom:T(H),unit:T(H),modifier:T(H),operatorKeyword:T(H),controlKeyword:T(H),definitionKeyword:T(H),moduleKeyword:T(H),operator:W,derefOperator:T(W),arithmeticOperator:T(W),logicOperator:T(W),bitwiseOperator:T(W),compareOperator:T(W),updateOperator:T(W),definitionOperator:T(W),typeOperator:T(W),controlOperator:T(W),punctuation:F,separator:T(F),bracket:z,angleBracket:T(z),squareBracket:T(z),paren:T(z),brace:T(z),content:V,heading:I,heading1:T(I),heading2:T(I),heading3:T(I),heading4:T(I),heading5:T(I),heading6:T(I),contentSeparator:T(V),list:T(V),quote:T(V),emphasis:T(V),strong:T(V),link:T(V),monospace:T(V),strikethrough:T(V),inserted:T(),deleted:T(),changed:T(),invalid:T(),meta:q,documentMeta:T(q),annotation:T(q),processingInstruction:T(q),definition:c.defineModifier(),constant:c.defineModifier(),function:c.defineModifier(),standard:c.defineModifier(),local:c.defineModifier(),special:c.defineModifier()},$=x.define([{tag:j.link,textDecoration:"underline"},{tag:j.heading,textDecoration:"underline",fontWeight:"bold"},{tag:j.emphasis,fontStyle:"italic"},{tag:j.strong,fontWeight:"bold"},{tag:j.strikethrough,textDecoration:"line-through"},{tag:j.keyword,color:"#708"},{tag:[j.atom,j.bool,j.url,j.contentSeparator,j.labelName],color:"#219"},{tag:[j.literal,j.inserted],color:"#164"},{tag:[j.string,j.deleted],color:"#a11"},{tag:[j.regexp,j.escape,j.special(j.string)],color:"#e40"},{tag:j.definition(j.variableName),color:"#00f"},{tag:j.local(j.variableName),color:"#30a"},{tag:[j.typeName,j.namespace],color:"#085"},{tag:j.className,color:"#167"},{tag:[j.special(j.variableName),j.macroName],color:"#256"},{tag:j.definition(j.propertyName),color:"#00c"},{tag:j.comment,color:"#940"},{tag:j.meta,color:"#7a757a"},{tag:j.invalid,color:"#f00"}]);j.link,j.heading,j.emphasis,j.strong,j.keyword,j.atom,j.bool,j.url,j.labelName,j.inserted,j.deleted,j.literal,j.string,j.number,j.regexp,j.escape,j.string,j.variableName,j.variableName,j.variableName,j.variableName,j.propertyName,j.typeName,j.namespace,j.className,j.macroName,j.propertyName,j.operator,j.comment,j.meta,j.invalid,j.punctuation},40405:function(t,e,i){i.d(e,{Gn:function(){return D},qp:function(){return u},ri:function(){return x},tC:function(){return F},vw:function(){return I},ze:function(){return W},Dv:function(){return K},x0:function(){return $},Fw:function(){return G},y1:function(){return A},K0:function(){return C},uj:function(){return T},nY:function(){return q},SS:function(){return M},c:function(){return S},dK:function(){return b},qz:function(){return d}});var n=i(17918),s=i(46941),r=i(25117),o=i(76089);const l=new n.md;function h(t){return s.r$.define({combine:t?e=>e.concat(t):void 0})}class a{constructor(t,e,i,n=[]){this.data=t,this.topNode=i,s.yy.prototype.hasOwnProperty("tree")||Object.defineProperty(s.yy.prototype,"tree",{get(){return d(this)}}),this.parser=e,this.extension=[b.of(this),s.yy.languageData.of(((t,e,i)=>t.facet(c(t,e,i))))].concat(n)}isActiveAt(t,e,i=-1){return c(t,e,i)==this.data}findRegions(t){let e=t.facet(b);if((null===e||void 0===e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let i=[],s=(t,e)=>{if(t.prop(l)==this.data)return void i.push({from:e,to:e+t.length});let r=t.prop(n.md.mounted);if(r){if(r.tree.prop(l)==this.data){if(r.overlay)for(let t of r.overlay)i.push({from:t.from+e,to:t.to+e});else i.push({from:e,to:e+t.length});return}if(r.overlay){let t=i.length;if(s(r.tree,r.overlay[0].from+e),i.length>t)return}}for(let i=0;i<t.children.length;i++){let r=t.children[i];r instanceof n.mp&&s(r,t.positions[i]+e)}};return s(d(t),0),i}get allowsNesting(){return!0}}function c(t,e,i){let n=t.facet(b);if(!n)return null;let s=n.data;if(n.allowsNesting)for(let r=d(t).topNode;r;r=r.enter(e,i,!0,!1))s=r.type.prop(l)||s;return s}a.setState=s.Py.define();class u extends a{constructor(t,e){super(t,e,e.topNode),this.parser=e}static define(t){let e=h(t.languageData);return new u(e,t.parser.configure({props:[l.add((t=>t.isTop?e:void 0))]}))}configure(t){return new u(this.data,this.parser.configure(t))}get allowsNesting(){return this.parser.wrappers.length>0}}function d(t){let e=t.field(a.state,!1);return e?e.tree:n.mp.empty}class f{constructor(t,e=t.length){this.doc=t,this.length=e,this.cursorPos=0,this.string="",this.cursor=t.iter()}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let i=this.cursorPos-this.string.length;return t<i||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}}let p=null;class g{constructor(t,e,i=[],n,s,r,o,l){this.parser=t,this.state=e,this.fragments=i,this.tree=n,this.treeLen=s,this.viewport=r,this.skipped=o,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}startParse(){return this.parser.startParse(new f(this.state.doc),this.fragments)}work(t,e){return null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=n.mp.empty&&this.isDone(null!==e&&void 0!==e?e:this.state.doc.length)?(this.takeTree(),!0):this.withContext((()=>{var i;let s=Date.now()+t;for(this.parse||(this.parse=this.startParse()),null!=e&&(null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&e<this.state.doc.length&&this.parse.stopAt(e);;){let t=this.parse.advance();if(t){if(this.fragments=this.withoutTempSkipped(n.i9.addTree(t,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(i=this.parse.stoppedAt)&&void 0!==i?i:this.state.doc.length,this.tree=t,this.parse=null,!(this.treeLen<(null!==e&&void 0!==e?e:this.state.doc.length)))return!0;this.parse=this.startParse()}if(Date.now()>s)return!1}}))}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext((()=>{while(!(e=this.parse.advance()));})),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(n.i9.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=p;p=this;try{return t()}finally{p=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=m(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:s,treeLen:r,viewport:o,skipped:l}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges(((t,i,n,s)=>e.push({fromA:t,toA:i,fromB:n,toB:s}))),i=n.i9.applyChanges(i,e),s=n.mp.empty,r=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){l=[];for(let e of this.skipped){let i=t.mapPos(e.from,1),n=t.mapPos(e.to,-1);i<n&&l.push({from:i,to:n})}}}return new g(this.parser,e,i,s,r,o,l,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:e,to:n}=this.skipped[i];e<t.to&&n>t.from&&(this.fragments=m(this.fragments,e,n),this.skipped.splice(i--,1))}return!(this.skipped.length>=e)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends n._b{createParse(e,i,s){let r=s[0].from,o=s[s.length-1].to,l={parsedPos:r,advance(){let e=p;if(e){for(let t of s)e.tempSkipped.push(t);t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}return this.parsedPos=o,new n.mp(n.Jq.none,[],[],o-r)},stoppedAt:null,stopAt(){}};return l}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&0==e[0].from&&e[0].to>=t}static get(){return p}}function m(t,e,i){return n.i9.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}class w{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged)return this;let e=this.context.changes(t.changes,t.state),i=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,i)||e.takeTree(),new w(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=new g(t.facet(b).parser,t,[],n.mp.empty,0,{from:0,to:e},[],null);return i.work(20,e)||i.takeTree(),new w(i)}}a.state=s.QQ.define({create:w.init,update(t,e){for(let i of e.effects)if(i.is(a.setState))return i.value;return e.startState.facet(b)!=e.state.facet(b)?w.init(e.state):t.apply(e)}});let v=t=>{let e=setTimeout((()=>t()),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&(v=t=>{let e=-1,i=setTimeout((()=>{e=requestIdleCallback(t,{timeout:400})}),100);return()=>e<0?clearTimeout(i):cancelIdleCallback(e)});const y=r.lg.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(a.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),t.docChanged&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(a.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=v(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:n}}=this.view,s=i.field(a.state);if(s.tree==s.context.tree&&s.context.isDone(n+1e5))return;let r=Math.min(this.chunkBudget,100,t?Math.max(25,t.timeRemaining()-5):1e9),o=s.context.treeLen<n&&i.doc.length>n+1e3,l=s.context.work(r,n+(o?0:1e5));this.chunkBudget-=Date.now()-e,(l||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:a.setState.of(new w(s.context))})),this.chunkBudget>0&&(!l||o)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then((()=>this.scheduleWork())).catch((t=>(0,r.OO)(this.view.state,t))).then((()=>this.workScheduled--)),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return this.working||this.workScheduled>0}},{eventHandlers:{focus(){this.scheduleWork()}}}),b=s.r$.define({combine(t){return t.length?t[0]:null},enables:[a.state,y]});class x{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}const k=s.r$.define(),S=s.r$.define({combine:t=>{if(!t.length)return" ";if(!/^(?: +|\t+)$/.test(t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return t[0]}});function A(t){let e=t.facet(S);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function M(t,e){let i="",n=t.tabSize;if(9==t.facet(S).charCodeAt(0))while(e>=n)i+="\t",e-=n;for(let s=0;s<e;s++)i+=" ";return i}function C(t,e){t instanceof s.yy&&(t=new D(t));for(let n of t.state.facet(k)){let i=n(t,e);if(null!=i)return i}let i=d(t.state);return i?O(t,i,e):null}class D{constructor(t,e={}){this.state=t,this.options=e,this.unit=A(t)}lineAt(t,e=1){let i=this.state.doc.lineAt(t),{simulateBreak:n}=this.options;return null!=n&&n>=i.from&&n<=i.to?(e<0?n<t:n<=t)?{text:i.text.slice(n-i.from),from:n}:{text:i.text.slice(0,n-i.from),from:i.from}:i}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:i,from:n}=this.lineAt(t,e);return i.slice(t-n,Math.min(i.length,t+100-n))}column(t,e=1){let{text:i,from:n}=this.lineAt(t,e),s=this.countColumn(i,t-n),r=this.options.overrideIndentation?this.options.overrideIndentation(n):-1;return r>-1&&(s+=r-this.countColumn(i,i.search(/\S|$/))),s}countColumn(t,e=t.length){return(0,o.IS)(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:i,from:n}=this.lineAt(t,e),s=this.options.overrideIndentation;if(s){let t=s(n);if(t>-1)return t}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const T=new n.md;function O(t,e,i){return R(e.resolveInner(i).enterUnfinishedNodesBefore(i),i,t)}function E(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function B(t){let e=t.type.prop(T);if(e)return e;let i,s=t.firstChild;if(s&&(i=s.type.prop(n.md.closedBy))){let e=t.lastChild,n=e&&i.indexOf(e.name)>-1;return t=>H(t,!0,1,void 0,n&&!E(t)?e.from:void 0)}return null==t.parent?L:null}function R(t,e,i){for(;t;t=t.parent){let n=B(t);if(n)return n(new P(i,e,t))}return null}function L(){return 0}class P extends D{constructor(t,e,i){super(t.state,t.options),this.base=t,this.pos=e,this.node=i}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){let t=this.state.doc.lineAt(this.node.from);for(;;){let e=this.node.resolve(t.from);while(e.parent&&e.parent.from==e.from)e=e.parent;if(N(e,this.node))break;t=this.state.doc.lineAt(e.from)}return this.lineIndent(t.from)}continue(){let t=this.node.parent;return t?R(t,this.pos,this.base):0}}function N(t,e){for(let i=e;i;i=i.parent)if(t==i)return!0;return!1}function V(t){let e=t.node,i=e.childAfter(e.from),n=e.lastChild;if(!i)return null;let s=t.options.simulateBreak,r=t.state.doc.lineAt(i.from),o=null==s||s<=r.from?r.to:Math.min(r.to,s);for(let l=i.to;;){let t=e.childAfter(l);if(!t||t==n)return null;if(!t.type.isSkipped)return t.from<o?i:null;l=t.to}}function I({closing:t,align:e=!0,units:i=1}){return n=>H(n,e,i,t)}function H(t,e,i,n,s){let r=t.textAfter,o=r.match(/^\s*/)[0].length,l=n&&r.slice(o,o+n.length)==n||s==t.pos+o,h=e?V(t):null;return h?l?t.column(h.from):t.column(h.to):t.baseIndent+(l?0:t.unit*i)}const W=t=>t.baseIndent;function F({except:t,units:e=1}={}){return i=>{let n=t&&t.test(i.textAfter);return i.baseIndent+(n?0:e*i.unit)}}const z=200;function q(){return s.yy.transactionFilter.of((t=>{if(!t.docChanged||!t.isUserEvent("input.type"))return t;let e=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!e.length)return t;let i=t.newDoc,{head:n}=t.newSelection.main,s=i.lineAt(n);if(n>s.from+z)return t;let r=i.sliceString(s.from,n);if(!e.some((t=>t.test(r))))return t;let{state:o}=t,l=-1,h=[];for(let{head:a}of o.selection.ranges){let t=o.doc.lineAt(a);if(t.from==l)continue;l=t.from;let e=C(o,t.from);if(null==e)continue;let i=/^\s*/.exec(t.text)[0],n=M(o,e);i!=n&&h.push({from:t.from,to:t.from+i.length,insert:n})}return h.length?[t,{changes:h,sequential:!0}]:t}))}const j=s.r$.define(),$=new n.md;function K(t){let e=t.firstChild,i=t.lastChild;return e&&e.to<i.from?{from:e.to,to:i.type.isError?t.to:i.from}:null}function _(t,e,i){let n=d(t);if(0==n.length)return null;let s=n.resolveInner(i),r=null;for(let o=s;o;o=o.parent){if(o.to<=i||o.from>i)continue;if(r&&o.from<e)break;let n=o.type.prop($);if(n){let s=n(o,t);s&&s.from<=i&&s.from>=e&&s.to>i&&(r=s)}}return r}function G(t,e,i){for(let n of t.facet(j)){let s=n(t,e,i);if(s)return s}return _(t,e,i)}},96651:function(t,e,i){i.d(e,{Xs:function(){return h},f_:function(){return c},uU:function(){return s}});var n=i(46941);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 l{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,n=0){let s=i?this.to:this.from;for(let r=n,o=s.length;;){if(r==o)return r;let n=r+o>>1,l=s[n]-t||(i?this.value[n].endSide:this.value[n].startSide)-e;if(n==r)return l>=0?r:o;l>=0?o=n:r=n+1}}between(t,e,i,n){for(let s=this.findIndex(e,-1e9,!0),r=this.findIndex(i,1e9,!1,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 l=0;l<this.value.length;l++){let h,a,c=this.value[l],u=this.from[l]+t,d=this.to[l]+t;if(u==d){let t=e.mapPos(u,c.startSide,c.mapMode);if(null==t)continue;if(h=a=t,c.startSide!=c.endSide&&(a=e.mapPos(u,c.endSide),a<h))continue}else if(h=e.mapPos(u,c.startSide),a=e.mapPos(d,c.endSide),h>a||h==a&&c.startSide>0&&c.endSide<=0)continue;(a-h||c.endSide-c.startSide)<0||(r<0&&(r=h),c.point&&(o=Math.max(o,a-h)),i.push(c),n.push(h-r),s.push(a-r))}return{mapped:i.length?new l(n,s,i,o):null,pos:r}}}class h{constructor(t,e,i=h.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.isEmpty)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,l=t.filter;if(0==e.length&&!l)return this;if(i&&e.slice().sort(o),this.isEmpty)return e.length?h.of(e):this;let a=new d(this,null,-1).goto(0),u=0,f=[],p=new c;while(a.value||u<e.length)if(u<e.length&&(a.from-e[u].from||a.startSide-e[u].value.startSide)>=0){let t=e[u++];p.addInner(t.from,t.to,t.value)||f.push(t)}else 1==a.rangeIndex&&a.chunkIndex<this.chunk.length&&(u==e.length||this.chunkEnd(a.chunkIndex)<e[u].from)&&(!l||n>this.chunkEnd(a.chunkIndex)||s<this.chunkPos[a.chunkIndex])&&p.addChunk(this.chunkPos[a.chunkIndex],this.chunk[a.chunkIndex])?a.nextChunk():((!l||n>a.to||s<a.from||l(a.from,a.to,a.value))&&(p.addInner(a.from,a.to,a.value)||f.push(new r(a.from,a.to,a.value))),a.next());return p.finishInner(this.nextLayer.isEmpty&&!f.length?h.empty:this.nextLayer.update({add:f,filter:l,filterFrom:n,filterTo:s}))}map(t){if(0==t.length||this.isEmpty)return this;let e=[],i=[],n=-1;for(let r=0;r<this.chunk.length;r++){let s=this.chunkPos[r],o=this.chunk[r],l=t.touchesRange(s,s+o.length);if(!1===l)n=Math.max(n,o.maxPoint),e.push(o),i.push(t.mapPos(s));else if(!0===l){let{mapped:r,pos:l}=o.map(s,t);r&&(n=Math.max(n,r.maxPoint),e.push(r),i.push(l))}}let s=this.nextLayer.map(t);return 0==e.length?s:new h(i,e,s,n)}between(t,e,i){if(!this.isEmpty){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 f.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return f.from(t).goto(e)}static compare(t,e,i,n,s=-1){let r=t.filter((t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=s)),o=e.filter((t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=s)),l=u(r,o,i),h=new g(r,l,s),a=new g(o,l,s);i.iterGaps(((t,e,i)=>m(h,t,a,e,i,n))),i.empty&&0==i.length&&m(h,0,a,0,0,n)}static eq(t,e,i=0,n){null==n&&(n=1e9);let s=t.filter((t=>!t.isEmpty&&e.indexOf(t)<0)),r=e.filter((e=>!e.isEmpty&&t.indexOf(e)<0));if(s.length!=r.length)return!1;if(!s.length)return!0;let o=u(s,r),l=new g(s,o,0).goto(i),h=new g(r,o,0).goto(i);for(;;){if(l.to!=h.to||!w(l.active,h.active)||l.point&&(!h.point||!l.point.eq(h.point)))return!1;if(l.to>n)return!0;l.next(),h.next()}}static spans(t,e,i,n,s=-1){var r;let o=new g(t,null,s,null===(r=n.filterPoint)||void 0===r?void 0:r.bind(n)).goto(e),l=e,h=o.openStart;for(;;){let t=Math.min(o.to,i);if(o.point?(n.point(l,t,o.point,o.activeForPoint(o.to),h),h=o.openEnd(t)+(o.to>t?1:0)):t>l&&(n.span(l,t,o.active,h),h=o.openEnd(t)),o.to>i)break;l=o.to,o.next()}return h}static of(t,e=!1){let i=new c;for(let n of t instanceof r?[t]:e?a(t):t)i.add(n.from,n.to,n.value);return i.finish()}}function a(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let n=t[i];if(o(e,n)>0)return t.slice().sort(o);e=n}return t}h.empty=new h([],[],null,-1),h.empty.nextLayer=h.empty;class c{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 l(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 c)).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(h.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=new h(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function u(t,e,i){let n=new Map;for(let r of t)for(let t=0;t<r.chunk.length;t++)r.chunk[t].maxPoint<=0&&n.set(r.chunk[t],r.chunkPos[t]);let s=new Set;for(let r of e)for(let t=0;t<r.chunk.length;t++){let e=n.get(r.chunk[t]);null==e||(i?i.mapPos(e):e)!=r.chunkPos[t]||(null===i||void 0===i?void 0:i.touchesRange(e,e+r.chunk[t].length))||s.add(r.chunk[t])}return s}class d{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){while(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}if(this.chunkIndex<this.layer.chunk.length){let n=this.layer.chunk[this.chunkIndex].findIndex(t-this.layer.chunkPos[this.chunkIndex],e,!0);(!i||this.rangeIndex<n)&&this.setRangeIndex(n)}this.next()}forward(t,e){(this.to-t||this.endSide-e)<0&&this.gotoInner(t,e,!0)}next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}{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.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}}setRangeIndex(t){if(t==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)while(this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]))this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=t}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.to-t.to||this.endSide-t.endSide}}class f{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.isEmpty;r=r.nextLayer)r.maxPoint>=i&&n.push(new d(r,e,i,s));return 1==n.length?n[0]:new f(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 i=this.heap.length>>1;i>=0;i--)p(this.heap,i);return this.next(),this}forward(t,e){for(let i of this.heap)i.forward(t,e);for(let i=this.heap.length>>1;i>=0;i--)p(this.heap,i);(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(),p(this.heap,0)}}}function p(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 g{constructor(t,e,i,n=(()=>!0)){this.minPoint=i,this.filterPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=f.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){while(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){v(this.active,t),v(this.activeTo,t),v(this.activeRank,t),this.minActive=b(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:n,rank:s}=this.cursor;while(e<this.activeRank.length&&this.activeRank[e]<=s)e++;y(this.active,e,i),y(this.activeTo,e,n),y(this.activeRank,e,s),t&&y(t,e,this.cursor.from),this.minActive=b(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&&v(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)this.cursor.next();else{if(this.filterPoint(this.cursor.from,this.cursor.to,this.cursor.value,this.cursor.rank)){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;while(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=this.active.length-1;i>=0;i--){if(this.activeRank[i]<this.pointRank)break;(this.activeTo[i]>t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&e.push(this.active[i])}return e.reverse()}openEnd(t){let e=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)e++;return e}}function m(t,e,i,n,s,r){t.goto(e),i.goto(n);let o=n+s,l=n,h=n-e;for(;;){let e=t.to+h-i.to||t.endSide-i.endSide,n=e<0?t.to+h: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))&&w(t.activeForPoint(t.to+h),i.activeForPoint(i.to))||r.comparePoint(l,s,t.point,i.point):s>l&&!w(t.active,i.active)&&r.compareRange(l,s,t.active,i.active),n>o)break;l=n,e<=0&&t.next(),e>=0&&i.next()}}function w(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 v(t,e){for(let i=e,n=t.length-1;i<n;i++)t[i]=t[i+1];t.pop()}function y(t,e,i){for(let n=t.length-1;n>=e;n--)t[n+1]=t[n];t[e]=i}function b(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}},46941:function(t,e,i){i.d(e,{q6:function(){return $},n0:function(){return o},as:function(){return l},D0:function(){return nt},jT:function(){return g},yy:function(){return ht},r$:function(){return y},gc:function(){return r},Wl:function(){return T},Py:function(){return G},QQ:function(){return M},YW:function(){return U},BO:function(){return at}});var n=i(76089);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:d(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 l=this.sections[o++],h=this.sections[o++],a=n+l;if(h<0){if(a>t)return s+(t-n);s+=l}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&&!l)return t==n||e<0?s:s+h;s+=h}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=this.sections[i++],r=this.sections[i++],o=n+s;if(r>=0&&n<=e&&o>=t)return!(n<t&&o>e)||"cover";n=o}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 l 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],l=e[s+1];if(l>=0){e[s]=l,e[s+1]=o;let h=s>>1;while(i.length<h)i.push(n.xv.empty);i.push(o?t.slice(r,r+o):n.xv.empty)}r+=o}return new l(e,i)}compose(t){return this.empty?t:t.empty?this:d(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 f(this);t:for(let r=0,o=0;;){let l=r==t.length?1e9:t[r++];while(o<l||o==l&&0==s.len){if(s.done)break t;let t=Math.min(s.len,l-o);h(n,t,-1);let r=-1==s.ins?-1:0==s.off?s.ins:0;h(e,t,r),r>0&&a(i,e,s.text),s.forward(t),o+=t}let c=t[r++];while(o<c){if(s.done)break t;let t=Math.min(s.len,c-o);h(e,t,-1),h(n,t,-1==s.ins?-1:0==s.off?s.ins:0),s.forward(t),o+=t}}return{changes:new l(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 d(t=!1){if(!t&&!r.length)return;c<e&&h(r,e-c,-1);let i=new l(r,o);u=u?u.compose(i.map(u)):i,r=[],o=[],c=0}function f(t){if(Array.isArray(t))for(let e of t)f(e);else if(t instanceof l){if(t.length!=e)throw new RangeError(`Mismatched change set length (got ${t.length}, expected ${e})`);d(),u=u?u.compose(t.map(u)):t}else{let{from:l,to:u=l,insert:f}=t;if(l>u||l<0||u>e)throw new RangeError(`Invalid change range ${l} to ${u} (in doc of length ${e})`);let p=f?"string"==typeof f?n.xv.of(f.split(i||s)):f:n.xv.empty,g=p.length;if(l==u&&0==g)return;l<c&&d(),l>c&&h(r,l-c,-1),h(r,u-l,g),a(o,r,p),c=u}}return f(t),d(!u),u}static empty(t){return new l(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{while(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 l(e,i)}}function h(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{while(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,l=0;l<t.sections.length;){let h=t.sections[l++],a=t.sections[l++];if(a<0)r+=h,o+=h;else{let c=r,u=o,d=n.xv.empty;for(;;){if(c+=h,u+=a,a&&s&&(d=d.append(s[l-2>>1])),i||l==t.sections.length||t.sections[l+1]<0)break;h=t.sections[l++],a=t.sections[l++]}e(r,c,o,u,d),r=c,o=u}}}function u(t,e,i,n=!1){let s=[],r=n?[]:null,c=new f(t),u=new f(e);for(let d=0,f=0;;)if(-1==c.ins)d+=c.len,c.next();else if(-1==u.ins&&f<d){let t=Math.min(u.len,d-f);u.forward(t),h(s,t,-1),f+=t}else if(u.ins>=0&&(c.done||f<d||f==d&&(u.len<c.len||u.len==c.len&&!i))){h(s,u.ins,-1);while(d>f&&!c.done&&d+c.len<f+u.len)d+=c.len,c.next();f+=u.len,u.next()}else{if(!(c.ins>=0)){if(c.done&&u.done)return r?new l(s,r):new o(s);throw new Error("Mismatched change set lengths")}{let t=0,e=d+c.len;for(;;)if(u.ins>=0&&f>d&&f+u.len<e)t+=u.ins,f+=u.len,u.next();else{if(!(-1==u.ins&&f<e))break;{let i=Math.min(u.len,e-f);t+=i,u.forward(i),f+=i}}h(s,t,c.ins),r&&a(r,s,c.text),d=e,c.next()}}}function d(t,e,i=!1){let n=[],s=i?[]:null,r=new f(t),c=new f(e);for(let u=!1;;){if(r.done&&c.done)return s?new l(n,s):new o(n);if(0==r.ins)h(n,r.len,0,u),r.next();else if(0!=c.len||c.done){if(r.done||c.done)throw new Error("Mismatched change set lengths");{let t=Math.min(r.len2,c.len),e=n.length;if(-1==r.ins){let e=-1==c.ins?-1:c.off?0:c.ins;h(n,t,e,u),s&&e&&a(s,n,c.text)}else-1==c.ins?(h(n,r.off?0:r.len,t,u),s&&a(s,n,r.textBit(t))):(h(n,r.off?0:r.len,c.off?0:c.ins,u),s&&!c.off&&a(s,n,c.text));u=(r.ins>t||c.ins>=0&&c.len>t)&&(u||n.length>e),r.forward2(t),c.forward(t)}}else h(n,0,c.ins,u),s&&a(s,n,c.text),c.next()}}class f{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 p{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 p(i,n,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return g.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return g.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 g.range(t.anchor,t.head)}}class g{constructor(t,e=0){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:g.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 g([this.main])}addRange(t,e=!0){return g.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,g.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 g(t.ranges.map((t=>p.fromJSON(t))),t.main)}static single(t,e=t){return new g([g.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 g(t,e)}static cursor(t,e=0,i,n){return new p(t,t,(0==e?0:e<0?4:8)|(null==i?3:Math.min(2,i))|(null!==n&&void 0!==n?n:33554431)<<5)}static range(t,e,i){let n=(null!==i&&void 0!==i?i:33554431)<<5;return e<t?new p(e,t,16|n):new p(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 n=1;n<t.length;n++){let i=t[n],s=t[n-1];if(i.empty?i.from<=s.to:i.from<s.to){let r=s.from,o=Math.max(i.to,s.to);n<=e&&e--,t.splice(--n,2,i.anchor>i.head?g.range(o,r):g.range(r,o))}}return new g(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:b),!!t.static,t.enables)}of(t){return new x([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new x(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new x(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],(i=>e(i.field(t))))}}function b(t,e){return t==e||t.length==e.length&&t.every(((t,i)=>t===e[i]))}class x{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,l=!1,h=[];for(let a of this.dependencies)"doc"==a?o=!0:"selection"==a?l=!0:0==(1&(null!==(e=t[a.id])&&void 0!==e?e:1))&&h.push(t[a.id]);return(t,e)=>{let a=t.values[s];if(a===P)return t.values[s]=i(t),1;if(e){let c=o&&e.docChanged||l&&(e.docChanged||e.selection)||h.some((e=>(1&N(t,e))>0));if(c){let e=i(t);if(r?!k(e,a,n):!n(e,a))return t.values[s]=e,1}}return 0}}}function k(t,e,i){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!i(t[n],e[n]))return!1;return!0}function S(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 l=t.values[o],h=l===P||!i;for(let e of r)1&N(t,e)&&(h=!0);if(!h)return 0;let a=[];for(let e=0;e<n.length;e++){let i=V(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 l!==P&&e.compare(c,l)?0:(t.values[o]=c,1)}}const A=y.define({static:!0});class M{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 M(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(A).find((t=>t.field==this));return((null===e||void 0===e?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return(t,i)=>{let n=t.values[e];if(n===P)return t.values[e]=this.create(t),1;if(i){let s=this.updateF(n,i);if(!this.compareF(n,s))return t.values[e]=s,1}return 0}}init(t){return[this,A.of({field:this,create:t})]}get extension(){return this}}const C={lowest:4,low:3,default:2,high:1,highest:0};function D(t){return e=>new O(e,t)}const T={lowest:D(C.lowest),low:D(C.low),default:D(C.default),high:D(C.high),highest:D(C.highest),fallback:D(C.lowest),extend:D(C.high),override:D(C.highest)};class O{constructor(t,e){this.inner=t,this.prec=e}}class E{of(t){return new B(this,t)}reconfigure(t){return E.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class B{constructor(t,e){this.compartment=t,this.inner=e}}class R{constructor(t,e,i,n,s){this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=s,this.statusTemplate=[];while(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 u of L(t,e,r))u instanceof M?n.push(u):(s[u.facet.id]||(s[u.facet.id]=[])).push(u);let o=Object.create(null),l=[],h=[],a=[];for(let u of n)o[u.id]=h.length<<1,h.push((t=>u.slot(t))),a.push([]);for(let u in s){let t=s[u],e=t[0].facet;if(t.every((t=>0==t.type))){o[e.id]=l.length<<1|1;let n=e.combine(t.map((t=>t.value))),s=i?i.config.address[e.id]:null;if(null!=s){let t=V(i,s);e.compare(n,t)&&(n=t)}l.push(n)}else{for(let e of t)0==e.type?(o[e.id]=l.length<<1|1,l.push(e.value)):(o[e.id]=h.length<<1,h.push((t=>e.dynamicSlot(t))),a.push(e.dependencies.filter((t=>"string"!=typeof t)).map((t=>t.id))));o[e.id]=h.length<<1,h.push((i=>S(i,e,t))),a.push(t.filter((t=>0!=t.type)).map((t=>t.id)))}}let c=h.map((t=>P));if(i){let t=(e,n)=>{if(n>7)return!1;let s=o[e];if(!(1&s))return a[s>>1].every((e=>t(e,n+1)));let r=i.config.address[e];return null!=r&&V(i,r)==l[s>>1]};for(let e in o){let n=o[e],s=i.config.address[e];null!=s&&0==(1&n)&&t(+e,0)&&(c[n>>1]=V(i,s))}}return{configuration:new R(t,r,h.map((t=>t(o))),o,l),values:c}}}function L(t,e,i){let n=[[],[],[],[],[]],s=new Map;function r(t,o){let l=s.get(t);if(null!=l){if(l>=o)return;let e=n[l].indexOf(t);e>-1&&n[l].splice(e,1),t instanceof B&&i.delete(t.compartment)}if(s.set(t,o),Array.isArray(t))for(let e of t)r(e,o);else if(t instanceof B){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 O)r(t.inner,t.prec);else if(t instanceof M)n[o].push(t),t.provides&&r(t.provides,o);else if(t instanceof x)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,C.default),n.reduce(((t,e)=>t.concat(e)))}const P={};function N(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 V(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const I=y.define(),H=y.define({combine:t=>t.some((t=>t)),static:!0}),W=y.define({combine:t=>t.length?t[0]:void 0,static:!0}),F=y.define(),z=y.define(),q=y.define(),j=y.define({combine:t=>!!t.length&&t[0]});class ${constructor(t,e){this.type=t,this.value=e}static define(){return new K}}class K{of(t){return new $(this,t)}}class _{constructor(t){this.map=t}of(t){return new G(this,t)}}class G{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 G(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}}G.reconfigure=G.define(),G.appendConfig=G.define();class U{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==U.time))||(this.annotations=s.concat(U.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}isUserEvent(t){let e=this.annotation(U.userEvent);return!(!e||!(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function X(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 J(t,e,i){var n;let s,r,o;return i?(s=e.changes,r=l.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:G.mapEffects(t.effects,s).concat(G.mapEffects(e.effects,r)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function Y(t,e,i){let n=e.selection,s=it(e.annotations);return e.userEvent&&(s=s.concat(U.userEvent.of(e.userEvent))),{changes:e.changes instanceof l?e.changes:l.of(e.changes||[],i,t.facet(W)),selection:n&&(n instanceof g?n:g.single(n.anchor,n.head)),effects:it(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function Q(t,e,i){let n=Y(t,e.length?e[0]:{},t.doc.length);e.length&&!1===e[0].filter&&(i=!1);for(let r=1;r<e.length;r++){!1===e[r].filter&&(i=!1);let s=!!e[r].sequential;n=J(n,Y(t,e[r],s?n.changes.newLength:t.doc.length),s)}let s=new U(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return tt(i?Z(s):s)}function Z(t){let e=t.startState,i=!0;for(let s of e.facet(F)){let e=s(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:X(i,e))}if(!0!==i){let n,s;if(!1===i)s=t.changes.invertedDesc,n=l.empty(e.doc.length);else{let e=t.changes.filter(i);n=e.changes,s=e.filtered.invertedDesc}t=new U(e,n,t.selection&&t.selection.map(s),G.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let n=e.facet(z);for(let s=n.length-1;s>=0;s--){let i=n[s](t);t=i instanceof U?i:Array.isArray(i)&&1==i.length&&i[0]instanceof U?i[0]:Q(e,it(i),!1)}return t}function tt(t){let e=t.startState,i=e.facet(q),n=t;for(let s=i.length-1;s>=0;s--){let r=i[s](t);r&&Object.keys(r).length&&(n=J(t,Y(e,r,t.changes.newLength),!0))}return n==t?t:new U(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}U.time=$.define(),U.userEvent=$.define(),U.addToHistory=$.define(),U.remote=$.define();const et=[];function it(t){return null==t?et:Array.isArray(t)?t:[t]}var nt=function(t){return t[t["Word"]=0]="Word",t[t["Space"]=1]="Space",t[t["Other"]=2]="Other",t}(nt||(nt={}));const st=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let rt;try{rt=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(ct){}function ot(t){if(rt)return rt.test(t);for(let e=0;e<t.length;e++){let i=t[e];if(/\w/.test(i)||i>""&&(i.toUpperCase()!=i.toLowerCase()||st.test(i)))return!0}return!1}function lt(t){return e=>{if(!/\S/.test(e))return nt.Space;if(ot(e))return nt.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return nt.Word;return nt.Other}}class ht{constructor(t,e,i,n,s=null){this.config=t,this.doc=e,this.selection=i,this.values=n,this.applying=null,this.status=t.statusTemplate.slice(),this.applying=s,s&&(s._state=this);for(let r=0;r<this.config.dynamicSlots.length;r++)N(this,r<<1);this.applying=null}field(t,e=!0){let i=this.config.address[t.id];if(null!=i)return N(this,i),V(this,i);if(e)throw new RangeError("Field is not present in this state")}update(...t){return Q(this,t,!0)}applyTransaction(t){let e,i=this.config,{base:n,compartments:s}=i;for(let r of t.effects)r.is(E.reconfigure)?(i&&(s=new Map,i.compartments.forEach(((t,e)=>s.set(e,t))),i=null),s.set(r.value.compartment,r.value.extension)):r.is(G.reconfigure)?(i=null,n=r.value):r.is(G.appendConfig)&&(i=null,n=it(n).concat(r.value));if(i)e=t.startState.values.slice();else{let t=R.resolve(n,s,this);i=t.configuration;let r=new ht(i,this.doc,this.selection,t.values,null);e=r.values}new ht(i,t.newDoc,t.newSelection,e,t)}replaceSelection(t){return"string"==typeof t&&(t=this.toText(t)),this.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:t},range:g.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=it(i.effects);for(let o=1;o<e.ranges.length;o++){let i=t(e.ranges[o]),l=this.changes(i.changes),h=l.map(n);for(let t=0;t<o;t++)s[t]=s[t].map(h);let a=n.mapDesc(l,!0);s.push(i.range.map(a)),n=n.compose(h),r=G.mapEffects(r,h).concat(G.mapEffects(it(i.effects),a))}return{changes:n,selection:g.create(s,e.mainIndex),effects:r}}changes(t=[]){return t instanceof l?t:l.of(t,this.doc.length,this.facet(ht.lineSeparator))}toText(t){return n.xv.of(t.split(this.facet(ht.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:(N(this,e),V(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 M&&(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 s in i){let e=i[s],r=t[s];n.push(e.init((t=>e.spec.fromJSON(r,t))))}return ht.create({doc:t.doc,selection:g.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let{configuration:e,values:i}=R.resolve(t.extensions||[],new Map),r=t.doc instanceof n.xv?t.doc:n.xv.of((t.doc||"").split(e.staticFacet(ht.lineSeparator)||s)),o=t.selection?t.selection instanceof g?t.selection:g.single(t.selection.anchor,t.selection.head):g.single(0);return w(o,r.length),e.staticFacet(H)||(o=o.asSingle()),new ht(e,r,o,i)}get tabSize(){return this.facet(ht.tabSize)}get lineBreak(){return this.facet(ht.lineSeparator)||"\n"}get readOnly(){return this.facet(j)}phrase(t){for(let e of this.facet(ht.phrases))if(Object.prototype.hasOwnProperty.call(e,t))return e[t];return t}languageDataAt(t,e,i=-1){let n=[];for(let s of this.facet(I))for(let r of s(this,e,i))Object.prototype.hasOwnProperty.call(r,t)&&n.push(r[t]);return n}charCategorizer(t){return lt(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,l=t-i;while(o>0){let t=(0,n.cp)(e,o,!1);if(r(e.slice(t,o))!=nt.Word)break;o=t}while(l<s){let t=(0,n.cp)(e,l);if(r(e.slice(l,t))!=nt.Word)break;l=t}return o==l?null:g.range(o+i,l+i)}}function at(t,e,i={}){let n={};for(let s of t)for(let t of Object.keys(s)){let e=s[t],r=n[t];if(void 0===r)n[t]=e;else if(r===e||void 0===e);else{if(!Object.hasOwnProperty.call(i,t))throw new Error("Config merge conflict for field "+t);n[t]=i[t](r,e)}}for(let s in e)void 0===n[s]&&(n[s]=e[s]);return n}ht.allowMultipleSelections=H,ht.tabSize=y.define({combine:t=>t.length?t[0]:4}),ht.lineSeparator=W,ht.readOnly=j,ht.phrases=y.define(),ht.languageData=I,ht.changeFilter=F,ht.transactionFilter=z,ht.transactionExtender=q,E.reconfigure=G.define()},76089:function(t,e,i){i.d(e,{xv:function(){return w},gm:function(){return d},nZ:function(){return p},IS:function(){return g},cp:function(){return l},Gz:function(){return m},bg:function(){return 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 D=1;D<n.length;D++)n[D]+=n[D-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}const o=8205;function l(t,e,i=!0,n=!0){return(i?h:a)(t,e,n)}function h(t,e,i){if(e==t.length)return e;e&&c(t.charCodeAt(e))&&u(t.charCodeAt(e-1))&&e--;let n=d(t,e);e+=p(n);while(e<t.length){let l=d(t,e);if(n==o||l==o||i&&s(l))e+=p(l),n=l;else{if(!r(l))break;{let i=0,n=e-2;while(n>=0&&r(d(t,n)))i++,n-=2;if(i%2==0)break;e+=2}}}return e}function a(t,e,i){while(e>0){let n=h(t,e-2,i);if(n<e)return n;e--}return 0}function c(t){return t>=56320&&t<57344}function u(t){return t>=55296&&t<56320}function d(t,e){let i=t.charCodeAt(e);if(!u(i)||e+1==t.length)return i;let n=t.charCodeAt(e+1);return c(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 p(t){return t<65536?1:2}function g(t,e,i=t.length){let n=0;for(let s=0;s<i;)9==t.charCodeAt(s)?(n+=e-n%e,s++):(n++,s=l(t,s));return n}function m(t,e,i,n){for(let s=0,r=0;;){if(r>=e)return s;if(s==t.length)break;r+=9==t.charCodeAt(s)?i-r%i:1,s=l(t,s)}return!0===n?-1:t.length}class w{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),y.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),y.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),i=this.length-this.scanIdentical(t,-1),n=new S(this),s=new S(t);for(let r=e,o=e;;){if(n.next(r),s.next(r),r=0,n.lineBreak!=s.lineBreak||n.done!=s.done||n.value!=s.value)return!1;if(o+=n.value.length,n.done||o>=i)return!0}}iter(t=1){return new S(this,t)}iterRange(t,e=this.length){return new A(this,t,e)}iterLines(t,e){let i;if(null==t)i=this.iter();else{null==e&&(e=this.lines+1);let n=this.line(t).from;i=this.iterRange(n,Math.max(n,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new M(i)}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 v(t):y.from(v.split(t,[])):w.empty}}class v extends w{constructor(t,e=b(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 C(n,o,i,r);n=o+1,i++}}decompose(t,e,i,n){let s=t<=0&&e>=this.length?this:new v(k(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&n){let t=i.pop(),e=x(s.text,t.text.slice(),0,s.length);if(e.length<=32)i.push(new v(e,t.length+s.length));else{let t=e.length>>1;i.push(new v(e.slice(0,t)),new v(e.slice(t)))}}else i.push(s)}replace(t,e,i){if(!(i instanceof v))return super.replace(t,e,i);let n=x(this.text,x(i.text,k(this.text,0,t)),e),s=this.length+i.length-(e-t);return n.length<=32?new v(n,s):y.from(v.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],l=s+o.length;s>t&&r&&(n+=i),t<l&&e>s&&(n+=o.slice(Math.max(0,t-s),e-s)),s=l+1}return n}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}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 v(i,n)),i=[],n=-1);return n>-1&&e.push(new v(i,n)),e}}class y extends w{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let i of t)this.lines+=i.lines}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.children[s],o=n+r.length,l=i+r.lines-1;if((e?l:o)>=t)return r.lineInner(t,e,i,n);n=o+1,i=l+1}}decompose(t,e,i,n){for(let s=0,r=0;r<=e&&s<this.children.length;s++){let o=this.children[s],l=r+o.length;if(t<=l&&e>=r){let s=n&((r<=t?1:0)|(l>=e?2:0));r>=t&&l<=e&&!s?i.push(o):o.decompose(t-r,e-r,i,s)}r=l+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 l=r.replace(t-s,e-s,i),h=this.lines-r.lines+l.lines;if(l.lines<h>>4&&l.lines>h>>6){let s=this.children.slice();return s[n]=l,new y(s,this.length-(e-t)+i.length)}return super.replace(s,o,l)}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],l=r+o.length;r>t&&s&&(n+=i),t<l&&e>r&&(n+=o.sliceString(t-r,e-r,i)),r=l+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof y))return 0;let i=0,[n,s,r,o]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;n+=e,s+=e){if(n==r||s==o)return i;let l=this.children[n],h=t.children[s];if(l!=h)return i+l.scanIdentical(h,e);i+=l.length+1}}static from(t,e=t.reduce(((t,e)=>t+e.length+1),-1)){let i=0;for(let d of t)i+=d.lines;if(i<32){let i=[];for(let e of t)e.flatten(i);return new v(i,e)}let n=Math.max(32,i>>5),s=n<<1,r=n>>1,o=[],l=0,h=-1,a=[];function c(t){let e;if(t.lines>s&&t instanceof y)for(let i of t.children)c(i);else t.lines>r&&(l>r||!l)?(u(),o.push(t)):t instanceof v&&l&&(e=a[a.length-1])instanceof v&&t.lines+e.lines<=32?(l+=t.lines,h+=t.length+1,a[a.length-1]=new v(e.text.concat(t.text),e.length+1+t.length)):(l+t.lines>n&&u(),l+=t.lines,h+=t.length+1,a.push(t))}function u(){0!=l&&(o.push(1==a.length?a[0]:y.from(a,h)),h=-1,l=a.length=0)}for(let d of t)c(d);return u(),1==o.length?o[0]:new y(o,e)}}function b(t){let e=-1;for(let i of t)e+=i.length+1;return e}function x(t,e,i=0,n=1e9){for(let s=0,r=0,o=!0;r<t.length&&s<=n;r++){let l=t[r],h=s+l.length;h>=i&&(h>n&&(l=l.slice(0,n-s)),s<i&&(l=l.slice(i-s)),o?(e[e.length-1]+=l,o=!1):e.push(l)),s=h+1}return e}function k(t,e,i){return x(t,[""],e,i)}w.empty=new v([""],0);class S{constructor(t,e=1){this.dir=e,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[e>0?1:(t instanceof v?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],s=this.offsets[i],r=s>>1,o=n instanceof v?n.text.length:n.children.length;if(r==(e>0?o:0)){if(0==i)return this.done=!0,this.value="",this;e>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&s)==(e>0?0:1)){if(this.offsets[i]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(n instanceof v){let s=n.text[r+(e<0?-1:0)];if(this.offsets[i]+=e,s.length>Math.max(0,t))return this.value=0==t?s:e>0?s.slice(t):s.slice(0,s.length-t),this;t-=s.length}else{let s=n.children[r+(e<0?-1:0)];t>s.length?(t-=s.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(s),this.offsets.push(e>0?1:(s instanceof v?s.text.length:s.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class A{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new S(t,e>i?-1:1),this.pos=e>i?t.length:0,this.from=Math.min(e,i),this.to=Math.max(e,i)}nextInner(t,e){if(e<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;t+=Math.max(0,e<0?this.pos-this.to:this.from-this.pos);let i=e<0?this.pos-this.from:this.to-this.pos;t>i&&(t=i),i-=t;let{value:n}=this.cursor.next(t);return this.pos+=(n.length+t)*e,this.value=n.length<=i?n:e<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(t=0){return t<0?t=Math.max(t,this.from-this.pos):t>0&&(t=Math.min(t,this.to-this.pos)),this.nextInner(t,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class M{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:n}=this.inner.next(t);return e?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(w.prototype[Symbol.iterator]=function(){return this.iter()},S.prototype[Symbol.iterator]=A.prototype[Symbol.iterator]=M.prototype[Symbol.iterator]=function(){return this});class C{constructor(t,e,i,n){this.from=t,this.to=e,this.number=i,this.text=n}get length(){return this.to-this.from}}},2903:function(t,e,i){i.d(e,{gB:function(){return x},bF:function(){return b},hJ:function(){return f}});var n=i(25117),s=i(46941);const r="undefined"!=typeof navigator&&!/Edge\/(\d+)/.exec(navigator.userAgent)&&/Apple Computer/.test(navigator.vendor)&&(/Mobile\/\w+/.test(navigator.userAgent)||navigator.maxTouchPoints>2),o="-10000px";class l{constructor(t,e,i){this.facet=e,this.createTooltipView=i,this.input=t.state.facet(e),this.tooltips=this.input.filter((t=>t)),this.tooltipViews=this.tooltips.map(i)}update(t){let e=t.state.facet(this.facet),i=e.filter((t=>t));if(e===this.input){for(let e of this.tooltipViews)e.update&&e.update(t);return!1}let n=[];for(let s=0;s<i.length;s++){let e=i[s],r=-1;if(e){for(let t=0;t<this.tooltips.length;t++){let i=this.tooltips[t];i&&i.create==e.create&&(r=t)}if(r<0)n[s]=this.createTooltipView(e);else{let e=n[s]=this.tooltipViews[r];e.update&&e.update(t)}}}for(let s of this.tooltipViews)n.indexOf(s)<0&&s.dom.remove();return this.input=e,this.tooltips=i,this.tooltipViews=n,!0}}function h(){return{top:0,left:0,bottom:innerHeight,right:innerWidth}}const a=s.r$.define({combine:t=>{var e,i,n;return{position:r?"absolute":(null===(e=t.find((t=>t.position)))||void 0===e?void 0:e.position)||"fixed",parent:(null===(i=t.find((t=>t.parent)))||void 0===i?void 0:i.parent)||null,tooltipSpace:(null===(n=t.find((t=>t.tooltipSpace)))||void 0===n?void 0:n.tooltipSpace)||h}}}),c=n.lg.fromClass(class{constructor(t){var e;this.view=t,this.inView=!0,this.lastTransaction=0,this.measureTimeout=-1;let i=t.state.facet(a);this.position=i.position,this.parent=i.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.manager=new l(t,f,(t=>this.createTooltip(t))),this.intersectionObserver="function"==typeof IntersectionObserver?new IntersectionObserver((t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()}),{threshold:[1]}):null,this.observeIntersection(),null===(e=t.dom.ownerDocument.defaultView)||void 0===e||e.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let t of this.manager.tooltipViews)this.intersectionObserver.observe(t.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout((()=>{this.measureTimeout=-1,this.maybeMeasure()}),50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t);e&&this.observeIntersection();let i=e||t.geometryChanged,n=t.state.facet(a);if(n.position!=this.position){this.position=n.position;for(let t of this.manager.tooltipViews)t.dom.style.position=this.position;i=!0}if(n.parent!=this.parent){this.parent&&this.container.remove(),this.parent=n.parent,this.createContainer();for(let t of this.manager.tooltipViews)this.container.appendChild(t.dom);i=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);i&&this.maybeMeasure()}createTooltip(t){let e=t.create(this.view);if(e.dom.classList.add("cm-tooltip"),t.arrow&&!e.dom.querySelector("cm-tooltip > cm-tooltip-arrow")){let t=document.createElement("div");t.className="cm-tooltip-arrow",e.dom.appendChild(t)}return e.dom.style.position=this.position,e.dom.style.top=o,this.container.appendChild(e.dom),e.mount&&e.mount(this.view),e}destroy(){var t,e;null===(t=this.view.dom.ownerDocument.defaultView)||void 0===t||t.removeEventListener("resize",this.measureSoon);for(let{dom:i}of this.manager.tooltipViews)i.remove();null===(e=this.intersectionObserver)||void 0===e||e.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=this.view.dom.getBoundingClientRect();return{editor:t,parent:this.parent?this.container.getBoundingClientRect():t,pos:this.manager.tooltips.map((t=>this.view.coordsAtPos(t.pos))),size:this.manager.tooltipViews.map((({dom:t})=>t.getBoundingClientRect())),space:this.view.state.facet(a).tooltipSpace(this.view)}}writeMeasure(t){let{editor:e,space:i}=t,s=[];for(let r=0;r<this.manager.tooltips.length;r++){let l=this.manager.tooltips[r],h=this.manager.tooltipViews[r],{dom:a}=h,c=t.pos[r],u=t.size[r];if(!c||c.bottom<=Math.max(e.top,i.top)||c.top>=Math.min(e.bottom,i.bottom)||c.right<=Math.max(e.left,i.left)||c.left>=Math.min(e.right,i.right)){a.style.top=o;continue}let f=l.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,p=f?7:0,g=u.right-u.left,m=u.bottom-u.top,w=h.offset||d,v=this.view.textDirection==n.Nm.LTR,y=u.width>i.right-i.left?v?i.left:i.right-u.width:v?Math.min(c.left-(f?14:0)+w.x,i.right-g):Math.max(i.left,c.left-g+(f?14:0)-w.x),b=!!l.above;!l.strictSide&&(b?c.top-(u.bottom-u.top)-w.y<i.top:c.bottom+(u.bottom-u.top)+w.y>i.bottom)&&b==i.bottom-c.bottom>c.top-i.top&&(b=!b);let x=b?c.top-m-p-w.y:c.bottom+p+w.y,k=y+g;if(!0!==h.overlap)for(let t of s)t.left<k&&t.right>y&&t.top<x+m&&t.bottom>x&&(x=b?t.top-m-2-p:t.bottom+p+2);"absolute"==this.position?(a.style.top=x-t.parent.top+"px",a.style.left=y-t.parent.left+"px"):(a.style.top=x+"px",a.style.left=y+"px"),f&&(f.style.left=c.left+(v?w.x:-w.x)-(y+14-7)+"px"),!0!==h.overlap&&s.push({left:y,top:x,right:k,bottom:x+m}),a.classList.toggle("cm-tooltip-above",b),a.classList.toggle("cm-tooltip-below",!b),h.positioned&&h.positioned()}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let t of this.manager.tooltipViews)t.dom.style.top=o}},{eventHandlers:{scroll(){this.maybeMeasure()}}}),u=n.tk.baseTheme({".cm-tooltip":{zIndex:100},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),d={x:0,y:0},f=s.r$.define({enables:[c,u]}),p=s.r$.define();class g{constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new l(t,p,(t=>this.createHostedView(t)))}static create(t){return new g(t)}createHostedView(t){let e=t.create(this.view);return e.dom.classList.add("cm-tooltip-section"),this.dom.appendChild(e.dom),this.mounted&&e.mount&&e.mount(this.view),e}mount(t){for(let e of this.manager.tooltipViews)e.mount&&e.mount(t);this.mounted=!0}positioned(){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned()}update(t){this.manager.update(t)}}const m=f.compute([p],(t=>{let e=t.facet(p).filter((t=>t));return 0===e.length?null:{pos:Math.min(...e.map((t=>t.pos))),end:Math.max(...e.filter((t=>null!=t.end)).map((t=>t.end))),create:g.create,above:e[0].above,arrow:e.some((t=>t.arrow))}}));class w{constructor(t,e,i,n,s){this.view=t,this.source=e,this.field=i,this.setHover=n,this.hoverTime=s,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:t.dom,time:0},this.checkHover=this.checkHover.bind(this),t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),t.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout((()=>this.startHover()),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active)return;let t=Date.now()-this.lastMove.time;t<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-t):this.startHover()}startHover(){var t;clearTimeout(this.restartTimeout);let{lastMove:e}=this,i=this.view.contentDOM.contains(e.target)?this.view.posAtCoords(e):null;if(null==i)return;let s=this.view.coordsAtPos(i);if(null==s||e.y<s.top||e.y>s.bottom||e.x<s.left-this.view.defaultCharacterWidth||e.x>s.right+this.view.defaultCharacterWidth)return;let r=this.view.bidiSpans(this.view.state.doc.lineAt(i)).find((t=>t.from<=i&&t.to>=i)),o=r&&r.dir==n.Nm.RTL?-1:1,l=this.source(this.view,i,e.x<s.left?-o:o);if(null===(t=l)||void 0===t?void 0:t.then){let t=this.pending={pos:i};l.then((e=>{this.pending==t&&(this.pending=null,e&&this.view.dispatch({effects:this.setHover.of(e)}))}),(t=>(0,n.OO)(this.view.state,t,"hover tooltip")))}else l&&this.view.dispatch({effects:this.setHover.of(l)})}mousemove(t){var e;this.lastMove={x:t.clientX,y:t.clientY,target:t.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let i=this.active;if(i&&!v(this.lastMove.target)||this.pending){let{pos:n}=i||this.pending,s=null!==(e=null===i||void 0===i?void 0:i.end)&&void 0!==e?e:n;(n==s?this.view.posAtCoords(this.lastMove)==n:y(this.view,n,s,t.clientX,t.clientY,6))||(this.view.dispatch({effects:this.setHover.of(null)}),this.pending=null)}}mouseleave(){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1,this.active&&this.view.dispatch({effects:this.setHover.of(null)})}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}function v(t){for(let e=t;e;e=e.parentNode)if(1==e.nodeType&&e.classList.contains("cm-tooltip"))return!0;return!1}function y(t,e,i,n,s,r){let o=document.createRange(),l=t.domAtPos(e),h=t.domAtPos(i);o.setEnd(h.node,h.offset),o.setStart(l.node,l.offset);let a=o.getClientRects();o.detach();for(let c=0;c<a.length;c++){let t=a[c],e=Math.max(t.top-s,s-t.bottom,t.left-n,n-t.right);if(e<=r)return!0}return!1}function b(t,e={}){let i=s.Py.define(),r=s.QQ.define({create(){return null},update(t,n){if(t&&e.hideOnChange&&(n.docChanged||n.selection))return null;for(let e of n.effects){if(e.is(i))return e.value;if(e.is(k))return null}if(t&&n.docChanged){let e=n.changes.mapPos(t.pos,-1,s.gc.TrackDel);if(null==e)return null;let i=Object.assign(Object.create(null),t);return i.pos=e,null!=t.end&&(i.end=n.changes.mapPos(t.end)),i}return t},provide:t=>p.from(t)}),o=e.hoverTime||600;return[r,n.lg.define((e=>new w(e,t,r,i,o))),m]}function x(t,e){let i=t.plugin(c);if(!i)return null;let n=i.manager.tooltips.indexOf(e);return n<0?null:i.manager.tooltipViews[n]}const k=s.Py.define()},25117:function(t,e,i){i.d(e,{kH:function(){return at},p:function(){return ct},Nm:function(){return Ut},tk:function(){return hn},BF:function(){return Vt},lg:function(){return Wt},l9:function(){return ht},Uw:function(){return Bn},qr:function(){return $n},ZO:function(){return ls},AE:function(){return ts},$f:function(){return xn},OO:function(){return Lt},$1:function(){return An}});var n=i(46941),s=i(76089),r=i(70876),o=i(96651),l=i(27510);function h(t){let e;return e=11==t.nodeType?t.getSelection?t:t.ownerDocument:t,e.getSelection()}function a(t,e){return!!e&&t.contains(1!=e.nodeType?e.parentNode:e)}function c(){let t=document.activeElement;while(t&&t.shadowRoot)t=t.shadowRoot.activeElement;return t}function u(t,e){if(!e.anchorNode)return!1;try{return a(t,e.anchorNode)}catch(i){return!1}}function d(t){return 3==t.nodeType?M(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function f(t,e,i,n){return!!i&&(g(t,e,i,n,-1)||g(t,e,i,n,1))}function p(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function g(t,e,i,n,s){for(;;){if(t==i&&e==n)return!0;if(e==(s<0?0:m(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=p(t)+(s<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if(t=t.childNodes[e+(s<0?-1:0)],1==t.nodeType&&"false"==t.contentEditable)return!1;e=s<0?m(t):0}}}function m(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}const w={left:0,right:0,top:0,bottom:0};function v(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function y(t){return{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function b(t,e,i,n,s,r,o,l){let h=t.ownerDocument,a=h.defaultView;for(let c=t;c;)if(1==c.nodeType){let t,u=c==h.body;if(u)t=y(a);else{if(c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.parentNode;continue}let e=c.getBoundingClientRect();t={left:e.left,right:e.left+c.clientWidth,top:e.top,bottom:e.top+c.clientHeight}}let d=0,f=0;if("nearest"==s)e.top<t.top?(f=-(t.top-e.top+o),i>0&&e.bottom>t.bottom+f&&(f=e.bottom-t.bottom+f+o)):e.bottom>t.bottom&&(f=e.bottom-t.bottom+o,i<0&&e.top-f<t.top&&(f=-(t.top+f-e.top+o)));else{let n=e.bottom-e.top,r=t.bottom-t.top,l="center"==s&&n<=r?e.top+n/2-r/2:"start"==s||"center"==s&&i<0?e.top-o:e.bottom-r+o;f=l-t.top}if("nearest"==n)e.left<t.left?(d=-(t.left-e.left+r),i>0&&e.right>t.right+d&&(d=e.right-t.right+d+r)):e.right>t.right&&(d=e.right-t.right+r,i<0&&e.left<t.left+d&&(d=-(t.left+d-e.left+r)));else{let i="center"==n?e.left+(e.right-e.left)/2-(t.right-t.left)/2:"start"==n==l?e.left-r:e.right-(t.right-t.left)+r;d=i-t.left}if(d||f)if(u)a.scrollBy(d,f);else{if(f){let t=c.scrollTop;c.scrollTop+=f,f=c.scrollTop-t}if(d){let t=c.scrollLeft;c.scrollLeft+=d,d=c.scrollLeft-t}e={left:e.left-d,top:e.top-f,right:e.right-d,bottom:e.bottom-f}}if(u)break;c=c.assignedSlot||c.parentNode,n=s="nearest"}else{if(11!=c.nodeType)break;c=c.host}}class x{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){this.set(t.anchorNode,t.anchorOffset,t.focusNode,t.focusOffset)}set(t,e,i,n){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=n}}let k,S=null;function A(t){if(t.setActive)return t.setActive();if(S)return t.focus(S);let e=[];for(let i=t;i;i=i.parentNode)if(e.push(i,i.scrollTop,i.scrollLeft),i==i.ownerDocument)break;if(t.focus(null==S?{get preventScroll(){return S={preventScroll:!0},!0}}:void 0),!S){S=!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 M(t,e,i=e){let n=k||(k=document.createRange());return n.setEnd(t,i),n.setStart(t,e),n}function C(t,e,i){let n={key:e,code:e,keyCode:i,which:i,cancelable:!0},s=new KeyboardEvent("keydown",n);s.synthetic=!0,t.dispatchEvent(s);let r=new KeyboardEvent("keyup",n);return r.synthetic=!0,t.dispatchEvent(r),s.defaultPrevented||r.defaultPrevented}function D(t){while(t){if(t&&(9==t.nodeType||11==t.nodeType&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function T(t){while(t.attributes.length)t.removeAttributeNode(t.attributes[0])}class O{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new O(t.parentNode,p(t),e)}static after(t,e){return new O(t.parentNode,p(t)+1,e)}}const E=[];class B{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){if(2&this.dirty){let e=this.dom,i=e.firstChild;for(let n of this.children){if(n.dirty){if(!n.dom&&i){let t=B.get(i);t&&(t.parent||t.constructor!=n.constructor)||n.reuseDOM(i)}n.sync(t),n.dirty=0}if(t&&!t.written&&t.node==e&&i!=n.dom&&(t.written=!0),n.dom.parentNode==e){while(i&&i!=n.dom)i=R(i);i=n.dom.nextSibling}else e.insertBefore(n.dom,i)}i&&t&&t.node==e&&(t.written=!0);while(i)i=R(i)}else if(1&this.dirty)for(let e of this.children)e.dirty&&(e.sync(t),e.dirty=0)}reuseDOM(t){}localPosFromDOM(t,e){let i;if(t==this.dom)i=this.dom.childNodes[e];else{let n=0==m(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;while(i&&!B.get(i))i=i.nextSibling;if(!i)return this.length;for(let n=0,s=0;;n++){let t=this.children[n];if(t.dom==i)return s;s+=t.length+t.breakAfter}}domBoundsAround(t,e,i=0){let n=-1,s=-1,r=-1,o=-1;for(let l=0,h=i,a=i;l<this.children.length;l++){let i=this.children[l],c=h+i.length;if(h<t&&c>e)return i.domBoundsAround(t,e,h);if(c>=t&&-1==n&&(n=l,s=h),h>e&&i.dom.parentNode==this.dom){r=l,o=a;break}a=c,h=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){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&&(this.dom.cmView=null),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=E){this.markDirty();for(let n=t;n<e;n++){let t=this.children[n];t.parent==this&&t.destroy()}this.children.splice(t,e-t,...i);for(let n=0;n<i.length;n++)i[n].setParent(this)}ignoreMutation(t){return!1}ignoreEvent(t){return!1}childCursor(t=this.length){return new L(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}get isEditable(){return!0}merge(t,e,i,n,s,r){return!1}become(t){return!1}getSide(){return 0}destroy(){this.parent=null}}function R(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}B.prototype.breakAfter=0;class L{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}}}function P(t,e,i,n,s,r,o,l,h){let{children:a}=t,c=a.length?a[e]:null,u=r.length?r[r.length-1]:null,d=u?u.breakAfter:o;if(!(e==n&&c&&!o&&!d&&r.length<2&&c.merge(i,s,r.length?u:null,0==i,l,h))){if(n<a.length){let t=a[n];t&&s<t.length?(e==n&&(t=t.split(s),s=0),!d&&u&&t.merge(0,s,u,!0,0,h)?r[r.length-1]=t:(s&&t.merge(0,s,null,!1,0,h),r.push(t))):(null===t||void 0===t?void 0:t.breakAfter)&&(u?u.breakAfter=1:o=1),n++}c&&(c.breakAfter=o,i>0&&(!o&&r.length&&c.merge(i,c.length,r[0],!1,l,0)?c.breakAfter=r.shift().breakAfter:(i<c.length||c.children.length&&0==c.children[c.children.length-1].length)&&c.merge(i,c.length,null,!1,l,0),e++));while(e<n&&r.length)if(a[n-1].become(r[r.length-1]))n--,r.pop(),h=r.length?0:l;else{if(!a[e].become(r[0]))break;e++,r.shift(),l=r.length?0:h}!r.length&&e&&n<a.length&&!a[e-1].breakAfter&&a[n].merge(0,0,a[e-1],!1,l,h)&&e--,(e<n||r.length)&&t.replaceChildren(e,n,r)}}function N(t,e,i,n,s,r){let o=t.childCursor(),{i:l,off:h}=o.findPos(i,1),{i:a,off:c}=o.findPos(e,-1),u=e-i;for(let d of n)u+=d.length;t.length+=u,P(t,a,c,l,h,n,0,s,r)}let[V,I]="undefined"!=typeof navigator?[navigator,document]:[{userAgent:"",vendor:"",platform:""},{documentElement:{style:{}}}];const H=/Edge\/(\d+)/.exec(V.userAgent),W=/MSIE \d/.test(V.userAgent),F=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(V.userAgent),z=!!(W||F||H),q=!z&&/gecko\/(\d+)/i.test(V.userAgent),j=!z&&/Chrome\/(\d+)/.exec(V.userAgent),$="webkitFontSmoothing"in I.documentElement.style,K=!z&&/Apple Computer/.test(V.vendor),_=K&&(/Mobile\/\w+/.test(V.userAgent)||V.maxTouchPoints>2);var G={mac:_||/Mac/.test(V.platform),windows:/Win/.test(V.platform),linux:/Linux|X11/.test(V.platform),ie:z,ie_version:W?I.documentMode||6:F?+F[1]:H?+H[1]:0,gecko:q,gecko_version:q?+(/Firefox\/(\d+)/.exec(V.userAgent)||[0,0])[1]:0,chrome:!!j,chrome_version:j?+j[1]:0,ios:_,android:/Android\b/.test(V.userAgent),webkit:$,safari:K,webkit_version:$?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:null!=I.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};const U=256;class X extends B{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){3==t.nodeType&&this.createDOM(t)}merge(t,e,i){return(!i||i instanceof X&&!(this.length-(e-t)+i.length>U))&&(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new X(this.text.slice(t));return this.text=this.text.slice(0,t),this.markDirty(),e}localPosFromDOM(t,e){return t==this.dom?e:e?this.text.length:0}domAtPos(t){return new O(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 Y(this.dom,t,e)}}class J extends B{constructor(t,e=[],i=0){super(),this.mark=t,this.children=e,this.length=i;for(let n of e)n.setParent(this)}setAttrs(t){if(T(t),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]);return t}reuseDOM(t){t.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(t),this.dirty|=6)}sync(t){this.dom?4&this.dirty&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(t)}merge(t,e,i,n,s,r){return(!i||!(!(i instanceof J&&i.mark.eq(this.mark))||t&&s<=0||e<this.length&&r<=0))&&(N(this,t,e,i?i.children:[],s-1,r-1),this.markDirty(),!0)}split(t){let e=[],i=0,n=-1,s=0;for(let o of this.children){let r=i+o.length;r>t&&e.push(i<t?o.split(t-i):o),n<0&&i>=t&&(n=s),i=r,s++}let r=this.length-t;return this.length=t,n>-1&&(this.children.length=n,this.markDirty()),new J(this.mark,e,r)}domAtPos(t){return it(this.dom,this.children,t)}coordsAt(t,e){return st(this,t,e)}}function Y(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?G.chrome||G.gecko||(e?(s--,o=1):(r++,o=-1)):i<0?s--:r++;let l=M(t,s,r).getClientRects();if(!l.length)return w;let h=l[(o?o<0:i>=0)?0:l.length-1];return G.safari&&!o&&0==h.width&&(h=Array.prototype.find.call(l,(t=>t.width))||h),o?v(h,o<0):h||null}class Q extends B{constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i}static create(t,e,i){return new(t.customView||Q)(t,e,i)}split(t){let e=Q.create(this.widget,this.length-t,this.side);return this.length-=t,e}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,r){return!(i&&(!(i instanceof Q&&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)}become(t){return t.length==this.length&&t instanceof Q&&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;while(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?O.before(this.dom):O.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let i=this.dom.getClientRects(),n=null;if(!i.length)return w;for(let s=t>0?i.length-1:0;;s+=t>0?-1:1)if(n=i[s],t>0?0==s:s==i.length-1||n.top<n.bottom)break;return 0==t&&e>0||t==this.length&&e<=0?n:v(n,0==t)}get isEditable(){return!1}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class Z extends Q{domAtPos(t){return new O(this.widget.text,t)}sync(){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 Y(this.widget.text,t,e)}get isEditable(){return!0}}const tt=G.android?"":"";class et extends B{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof et&&t.side==this.side}split(){return new et(this.side)}sync(){this.dom?this.dirty&&this.dom.nodeValue!=tt&&(this.dom.nodeValue=tt):this.setDOM(document.createTextNode(tt))}getSide(){return this.side}domAtPos(t){return O.before(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){let e=d(this.dom);return e[e.length-1]||null}get overrideDOMText(){return s.xv.of([this.dom.nodeValue.replace(/\u200b/g,"")])}}function it(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 O.after(i)}return new O(t,0)}function nt(t,e,i){let n,{children:s}=t;i>0&&e instanceof J&&s.length&&(n=s[s.length-1])instanceof J&&n.mark.eq(e.mark)?nt(n,e.children[0],i-1):(s.push(e),e.setParent(t)),t.length+=e.length}function st(t,e,i){for(let r=0,o=0;o<t.children.length;o++){let n,s=t.children[o],l=r+s.length;if((i<=0||l==t.length||s.getSide()>0?l>=e:l>e)&&(e<l||o+1==t.children.length||(n=t.children[o+1]).length||n.getSide()>0)){let t=0;if(l==r){if(s.getSide()<=0)continue;t=i=-s.getSide()}let n=s.coordsAt(e-r,i);return t&&n?v(n,i<0):n}r=l}let n=t.dom.lastChild;if(!n)return t.dom.getBoundingClientRect();let s=d(n);return s[s.length-1]||null}function rt(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 ot(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 lt(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])}X.prototype.children=Q.prototype.children=et.prototype.children=E;class ht{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}destroy(t){}}var at=function(t){return t[t["Text"]=0]="Text",t[t["WidgetBefore"]=1]="WidgetBefore",t[t["WidgetAfter"]=2]="WidgetAfter",t[t["WidgetRange"]=3]="WidgetRange",t}(at||(at={}));class ct 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 ut(t)}static widget(t){let e=t.side||0,i=!!t.block;return e+=i?e>0?3e8:-4e8:e>0?1e8:-1e8,new ft(t,e,e,i,t.widget||null,!1)}static replace(t){let e=!!t.block,{start:i,end:n}=pt(t,e),s=e?i?-3e8:-1:4e8,r=e?n?2e8:1:-5e8;return new ft(t,s,r,e,t.widget||null,!0)}static line(t){return new dt(t)}static set(t,e=!1){return o.Xs.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}ct.none=o.Xs.empty;class ut extends ct{constructor(t){let{start:e,end:i}=pt(t);super(e?-1:4e8,i?1:-5e8,null,t),this.tagName=t.tagName||"span",this.class=t.class||"",this.attrs=t.attributes||null}eq(t){return this==t||t instanceof ut&&this.tagName==t.tagName&&this.class==t.class&&ot(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)}}ut.prototype.point=!1;class dt extends ct{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof dt&&ot(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)}}dt.prototype.mapMode=n.gc.TrackBefore,dt.prototype.point=!0;class ft extends ct{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?at.WidgetRange:this.startSide<=0?at.WidgetBefore:at.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&this.widget.estimatedHeight>=5}eq(t){return t instanceof ft&>(this.widget,t.widget)&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}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 pt(t,e=!1){let{inclusiveStart:i,inclusiveEnd:n}=t;return null==i&&(i=t.inclusive),null==n&&(n=t.inclusive),{start:null!==i&&void 0!==i?i:e,end:null!==n&&void 0!==n?n:e}}function gt(t,e){return t==e||!!(t&&e&&t.compare(e))}function mt(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)}ft.prototype.point=!0;class wt extends B{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 wt))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),N(this,t,e,i?i.children:[],s,r),!0}split(t){let e=new wt;if(e.breakAfter=this.breakAfter,0==this.length)return e;let{i:i,off:n}=this.childPos(t);n&&(e.append(this.children[i].split(n),0),this.children[i].merge(n,this.children[i].length,null,!1,0,0),i++);for(let s=i;s<this.children.length;s++)e.append(this.children[s],0);while(i>0&&0==this.children[i-1].length)this.children[--i].destroy();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){ot(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){nt(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=rt(e,this.attrs||{})),i&&(this.attrs=rt({class:i},this.attrs||{}))}domAtPos(t){return it(this.dom,this.children,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.dirty|=6)}sync(t){var e;this.dom?4&this.dirty&&(T(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),void 0!==this.prevAttrs&&(lt(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t);let i=this.dom.lastChild;while(i&&B.get(i)instanceof J)i=i.lastChild;if(!i||"BR"!=i.nodeName&&0==(null===(e=B.get(i))||void 0===e?void 0:e.isEditable)&&(!G.ios||!this.children.some((t=>t instanceof X)))){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 X))return null;let i=d(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 st(this,t,e)}become(t){return!1}get type(){return at.Text}static find(t,e){for(let i=0,n=0;i<t.children.length;i++){let s=t.children[i],r=n+s.length;if(r>=e){if(s instanceof wt)return s;if(r>e)break}n=r+s.breakAfter}return null}}class vt extends B{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 vt&&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?O.before(this.dom):O.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new vt(this.widget,e,this.type);return i.breakAfter=this.breakAfter,i}get children(){return E}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}become(t){return t instanceof vt&&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)}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class yt{constructor(t,e,i,n){this.doc=t,this.pos=e,this.end=i,this.disallowBlockEffectsBelow=n,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.atCursorPos=!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 vt&&t.type==at.WidgetBefore)}getLine(){return this.curLine||(this.content.push(this.curLine=new wt),this.atCursorPos=!0),this.curLine}flushBuffer(t){this.pendingBuffer&&(this.curLine.append(bt(new et(-1),t),t.length),this.pendingBuffer=0)}addBlockWidget(t){this.flushBuffer([]),this.curLine=null,this.content.push(t)}finish(t){t?this.pendingBuffer=0:this.flushBuffer([]),this.posCovered()||this.getLine()}buildText(t,e,i){while(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.flushBuffer([]),this.curLine=null,t--;continue}this.text=e,this.textOff=0}let n=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(0,i)),this.getLine().append(bt(new X(this.text.slice(this.textOff,this.textOff+n)),e),i),this.atCursorPos=!0,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 ft)if(i.block){let{type:t}=i;t!=at.WidgetAfter||this.posCovered()||this.getLine(),this.addBlockWidget(new vt(i.widget||new xt("div"),r,t))}else{let o=Q.create(i.widget||new xt("span"),r,i.startSide),l=this.atCursorPos&&!o.isEditable&&s<=n.length&&(t<e||i.startSide>0),h=!o.isEditable&&(t<e||i.startSide<=0),a=this.getLine();2!=this.pendingBuffer||l||(this.pendingBuffer=0),this.flushBuffer(n),l&&(a.append(bt(new et(1),n),s),s=n.length+Math.max(0,s-n.length)),a.append(bt(o,n),s),this.atCursorPos=h,this.pendingBuffer=h?t<e?1:2:0}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)}filterPoint(t,e,i,n){if(n>=this.disallowBlockEffectsBelow||!(i instanceof ft))return!0;if(i.block)throw new RangeError("Block decorations may not be specified via plugins");return e<=this.doc.lineAt(this.pos).to}static build(t,e,i,n,s){let r=new yt(t,e,i,s);return r.openEnd=o.Xs.spans(n,e,i,r),r.openStart<0&&(r.openStart=r.openEnd),r.finish(r.openEnd),r}}function bt(t,e){for(let i of e)t=new J(i,[t],t.length);return t}class xt extends ht{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=[],St=n.r$.define(),At=n.r$.define(),Mt=n.r$.define(),Ct=n.r$.define(),Dt=n.r$.define(),Tt=n.r$.define(),Ot=n.Py.define({map:(t,e)=>t.map(e)}),Et=n.Py.define({map:(t,e)=>t.map(e)});class Bt{constructor(t,e="nearest",i="nearest",n=5,s=5){this.range=t,this.y=e,this.x=i,this.yMargin=n,this.xMargin=s}map(t){return t.empty?this:new Bt(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin)}}const Rt=n.Py.define({map:(t,e)=>t.map(e)});function Lt(t,e,i){let n=t.facet(Ct);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 Pt=n.r$.define({combine:t=>!t.length||t[0]});class Nt{constructor(t,e){this.field=t,this.get=e}}class Vt{from(t){return new Nt(this,t)}static define(){return new Vt}}Vt.decorations=Vt.define(),Vt.atomicRanges=Vt.define(),Vt.scrollMargins=Vt.define();let It=0;const Ht=n.r$.define();class Wt{constructor(t,e,i){this.id=t,this.create=e,this.fields=i,this.extension=Ht.of(this)}static define(t,e){let{eventHandlers:i,provide:n,decorations:s}=e||{},r=[];if(n)for(let o of Array.isArray(n)?n:[n])r.push(o);return i&&r.push(Ft.from((t=>({plugin:t,handlers:i})))),s&&r.push(Vt.decorations.from(s)),new Wt(It++,t,r)}static fromClass(t,e){return Wt.define((e=>new t(e)),e)}}const Ft=Vt.define();class zt{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}takeField(t,e){if(this.spec)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)try{this.value.update(t)}catch(e){if(Lt(t.state,e,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(i){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(t)}catch(e){Lt(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(null===(e=this.value)||void 0===e?void 0:e.destroy)try{this.value.destroy()}catch(i){Lt(t.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const qt=n.r$.define(),jt=n.r$.define(),$t=n.r$.define(),Kt=n.r$.define();class _t{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new _t(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 l=n==t.length?null:t[n],h=r-o,a=l?l.fromB:1e9;while(s<e.length&&e[s]<a){let t=e[s],n=e[s+1],r=Math.max(o,t),l=Math.min(a,n);if(r<=l&&new _t(r+h,l+h,r,l).addToSet(i),n>a)break;s+=2}if(!l)return i;new _t(l.fromA,l.toA,l.fromB,l.toB).addToSet(i),r=l.toA,o=l.toB}}}class Gt{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 n of i)this.changes=this.changes.compose(n.changes);let s=[];this.changes.iterChangedRanges(((t,e,i,n)=>s.push(new _t(t,e,i,n)))),this.changedRanges=s;let r=t.hasFocus;r!=t.inputState.notifiedFocused&&(t.inputState.notifiedFocused=r,this.flags|=1)}get viewportChanged(){return(4&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(10&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some((t=>t.selection))}get empty(){return 0==this.flags&&0==this.transactions.length}}var Ut=function(t){return t[t["LTR"]=0]="LTR",t[t["RTL"]=1]="RTL",t}(Ut||(Ut={}));const Xt=Ut.LTR,Jt=Ut.RTL;function Yt(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}const Qt=Yt("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Zt=Yt("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),te=Object.create(null),ee=[];for(let cs of["()","[]","{}"]){let t=cs.charCodeAt(0),e=cs.charCodeAt(1);te[t]=e,te[e]=-t}function ie(t){return t<=247?Qt[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?Zt[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8203||8204==t?256:1}const ne=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;class se{constructor(t,e,i){this.from=t,this.to=e,this.level=i}get dir(){return this.level%2?Jt:Xt}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 re=[];function oe(t,e){let i=t.length,n=e==Xt?1:2,s=e==Xt?2:1;if(!t||1==n&&!ne.test(t))return le(i);for(let o=0,l=n,h=n;o<i;o++){let e=ie(t.charCodeAt(o));512==e?e=l:8==e&&4==h&&(e=16),re[o]=4==e?2:e,7&e&&(h=e),l=e}for(let o=0,l=n,h=n;o<i;o++){let t=re[o];if(128==t)o<i-1&&l==re[o+1]&&24&l?t=re[o]=l:re[o]=256;else if(64==t){let t=o+1;while(t<i&&64==re[t])t++;let e=o&&8==l||t<i&&8==re[t]?1==h?1:8:256;for(let i=o;i<t;i++)re[i]=e;o=t-1}else 8==t&&1==h&&(re[o]=1);l=t,7&t&&(h=t)}for(let o,l,h,a=0,c=0,u=0;a<i;a++)if(l=te[o=t.charCodeAt(a)])if(l<0){for(let t=c-3;t>=0;t-=3)if(ee[t+1]==-l){let e=ee[t+2],i=2&e?n:4&e?1&e?s:n:0;i&&(re[a]=re[ee[t]]=i),c=t;break}}else{if(189==ee.length)break;ee[c++]=a,ee[c++]=o,ee[c++]=u}else if(2==(h=re[a])||1==h){let t=h==n;u=t?0:1;for(let e=c-3;e>=0;e-=3){let i=ee[e+2];if(2&i)break;if(t)ee[e+2]|=2;else{if(4&i)break;ee[e+2]|=4}}}for(let o=0;o<i;o++)if(256==re[o]){let t=o+1;while(t<i&&256==re[t])t++;let e=1==(o?re[o-1]:n),s=1==(t<i?re[t]:n),r=e==s?e?1:2:n;for(let i=o;i<t;i++)re[i]=r;o=t-1}let r=[];if(1==n)for(let o=0;o<i;){let t=o,e=1!=re[o++];while(o<i&&e==(1!=re[o]))o++;if(e)for(let i=o;i>t;){let e=i,n=2!=re[--i];while(i>t&&n==(2!=re[i-1]))i--;r.push(new se(i,e,n?2:1))}else r.push(new se(t,o,0))}else for(let o=0;o<i;){let t=o,e=2==re[o++];while(o<i&&e==(2==re[o]))o++;r.push(new se(t,o,e?1:2))}return r}function le(t){return[new se(0,t,0)]}let he="";function ae(t,e,i,r,o){var l;let h=r.head-t.from,a=-1;if(0==h){if(!o||!t.length)return null;e[0].level!=i&&(h=e[0].side(!1,i),a=0)}else if(h==t.length){if(o)return null;let t=e[e.length-1];t.level!=i&&(h=t.side(!0,i),a=e.length-1)}a<0&&(a=se.find(e,h,null!==(l=r.bidiLevel)&&void 0!==l?l:-1,r.assoc));let c=e[a];h==c.side(o,i)&&(c=e[a+=o?1:-1],h=c.side(!o,i));let u=o==(c.dir==i),d=(0,s.cp)(t.text,h,u);if(he=t.text.slice(Math.min(h,d),Math.max(h,d)),d!=c.side(o,i))return n.jT.cursor(d+t.from,u?-1:1,c.level);let f=a==(o?e.length-1:0)?null:e[a+(o?1:-1)];return f||c.level==i?f&&f.level<c.level?n.jT.cursor(f.side(!o,i)+t.from,o?1:-1,f.level):n.jT.cursor(d+t.from,o?-1:1,c.level):n.jT.cursor(o?t.to:t.from,o?-1:1,i)}class ce{constructor(t,e){this.points=t,this.view=e,this.text="",this.lineBreak=e.state.lineBreak}readRange(t,e){if(!t)return this;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=B.get(n),r=B.get(t);(s&&r?s.breakAfter:(s?s.breakAfter:ue(n))||ue(t)&&("BR"!=n.nodeName||n.cmIgnore))&&(this.text+=this.lineBreak),n=t}return this.findPointBefore(i,e),this}readTextNode(t){var e,i;let n=t.nodeValue;return/^\u200b/.test(n)&&"false"==(null===(e=t.previousSibling)||void 0===e?void 0:e.contentEditable)&&(n=n.slice(1)),/\u200b$/.test(n)&&"false"==(null===(i=t.nextSibling)||void 0===i?void 0:i.contentEditable)&&(n=n.slice(0,n.length-1)),n}readNode(t){if(t.cmIgnore)return;let e,i=B.get(t),n=i&&i.overrideDOMText;null!=n?e=n.sliceString(0,void 0,this.lineBreak):3==t.nodeType?e=this.readTextNode(t):"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,G.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 ue(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}class de{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class fe extends B{constructor(t){super(),this.view=t,this.compositionDeco=ct.none,this.decorations=[],this.pluginDecorationLength=0,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(t.contentDOM),this.children=[new wt],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new _t(0,0,0,t.state.doc.length)],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=this.minWidthFrom=this.minWidthTo=0),this.view.inputState.composing<0?this.compositionDeco=ct.none:(t.transactions.length||this.dirty)&&(this.compositionDeco=we(this.view,t.changes)),(G.ie||G.chrome)&&!this.compositionDeco.size&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let i=this.decorations,n=this.updateDeco(),s=ke(i,n,t.changes);return e=_t.extendWithRanges(e,s),(0!=this.dirty||0!=e.length)&&(this.updateInner(e,t.startState.doc.length),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e){this.view.viewState.mustMeasureContent=!0,this.updateChildren(t,e);let{observer:i}=this.view;i.ignore((()=>{this.dom.style.height=this.view.viewState.contentHeight+"px",this.dom.style.minWidth=this.minWidth?this.minWidth+"px":"";let t=G.chrome||G.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.sync(t),this.dirty=0,t&&(t.written||i.selectionRange.focusNode!=t.node)&&(this.forceSelection=!0),this.dom.style.height=""}));let n=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let s of this.children)s instanceof vt&&s.widget instanceof ge&&n.push(s.dom);i.updateGaps(n)}updateChildren(t,e){let i=this.childCursor(e);for(let n=t.length-1;;n--){let e=n>=0?t[n]:null;if(!e)break;let{fromA:s,toA:r,fromB:o,toB:l}=e,{content:h,breakAtStart:a,openStart:c,openEnd:u}=yt.build(this.view.state.doc,o,l,this.decorations,this.pluginDecorationLength),{i:d,off:f}=i.findPos(r,1),{i:p,off:g}=i.findPos(s,-1);P(this,p,g,d,f,h,a,c,u)}}updateSelection(t=!1,e=!1){if(t&&this.view.observer.readSelectionRange(),!e&&!this.mayControlSelection()||G.ios&&this.view.inputState.rapidCompositionStart)return;let i=this.forceSelection;this.forceSelection=!1;let n=this.view.state.selection.main,s=this.domAtPos(n.anchor),r=n.empty?s:this.domAtPos(n.head);if(G.gecko&&n.empty&&pe(s)){let t=document.createTextNode("");this.view.observer.ignore((()=>s.node.insertBefore(t,s.node.childNodes[s.offset]||null))),s=r=new O(t,0),i=!0}let o=this.view.observer.selectionRange;!i&&o.focusNode&&f(s.node,s.offset,o.anchorNode,o.anchorOffset)&&f(r.node,r.offset,o.focusNode,o.focusOffset)||(this.view.observer.ignore((()=>{G.android&&G.chrome&&this.dom.contains(o.focusNode)&&Se(o.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let t=h(this.root);if(n.empty){if(G.gecko){let t=be(s.node,s.offset);if(t&&3!=t){let e=ye(s.node,s.offset,1==t?1:-1);e&&(s=new O(e,1==t?0:e.nodeValue.length))}}t.collapse(s.node,s.offset),null!=n.bidiLevel&&null!=o.cursorBidiLevel&&(o.cursorBidiLevel=n.bidiLevel)}else if(t.extend)t.collapse(s.node,s.offset),t.extend(r.node,r.offset);else{let e=document.createRange();n.anchor>n.head&&([s,r]=[r,s]),e.setEnd(r.node,r.offset),e.setStart(s.node,s.offset),t.removeAllRanges(),t.addRange(e)}})),this.view.observer.setSelectionRange(s,r)),this.impreciseAnchor=s.precise?null:new O(o.anchorNode,o.anchorOffset),this.impreciseHead=r.precise?null:new O(o.focusNode,o.focusOffset)}enforceCursorAssoc(){if(this.compositionDeco.size)return;let t=this.view.state.selection.main,e=h(this.root);if(!t.empty||!t.assoc||!e.modify)return;let i=wt.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(Pt)?this.root.activeElement==this.dom:u(this.dom,this.view.observer.selectionRange)}nearest(t){for(let e=t;e;){let t=B.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 wt)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!=at.WidgetBefore&&s.type!=at.WidgetAfter&&(!n||2==e||this.children[n-1].breakAfter||this.children[n-1].type==at.WidgetBefore&&e>-2))return s.coordsAt(t-r,e);i=r}}measureVisibleLineHeights(){let t=[],{from:e,to:i}=this.view.viewState.viewport,n=this.view.contentDOM.clientWidth,s=n>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,r=-1;for(let o=0,l=0;l<this.children.length;l++){let h=this.children[l],a=o+h.length;if(a>i)break;if(o>=e){let e=h.dom.getBoundingClientRect();if(t.push(e.height),s){let t=h.dom.lastChild,i=t?d(t):[];if(i.length){let t=i[i.length-1],s=this.view.textDirection==Ut.LTR?t.right-e.left:e.right-t.left;s>r&&(r=s,this.minWidth=n,this.minWidthFrom=o,this.minWidthTo=a)}}}o=a+h.breakAfter}return t}measureTextSize(){for(let n of this.children)if(n instanceof wt){let t=n.measureTextSize();if(t)return t}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=d(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 L(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.lineBlockAt(r).bottom-e.lineBlockAt(i).top;t.push(ct.replace({widget:new ge(n),block:!0,inclusive:!0}).range(i,r))}if(!s)break;i=s.to+1}return ct.set(t)}updateDeco(){let t=this.view.pluginField(Vt.decorations);return this.pluginDecorationLength=t.length,this.decorations=[...t,...this.view.state.facet($t),this.compositionDeco,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco]}scrollIntoView(t){let e,{range:i}=t,n=this.coordsAt(i.head,i.empty?i.assoc:i.head>i.anchor?-1:1);if(!n)return;!i.empty&&(e=this.coordsAt(i.anchor,i.anchor>i.head?-1:1))&&(n={left:Math.min(n.left,e.left),top:Math.min(n.top,e.top),right:Math.max(n.right,e.right),bottom:Math.max(n.bottom,e.bottom)});let s=0,r=0,o=0,l=0;for(let a of this.view.pluginField(Vt.scrollMargins))if(a){let{left:t,right:e,top:i,bottom:n}=a;null!=t&&(s=Math.max(s,t)),null!=e&&(r=Math.max(r,e)),null!=i&&(o=Math.max(o,i)),null!=n&&(l=Math.max(l,n))}let h={left:n.left-s,top:n.top-o,right:n.right+r,bottom:n.bottom+l};b(this.view.scrollDOM,h,i.head<i.anchor?-1:1,t.x,t.y,t.xMargin,t.yMargin,this.view.textDirection==Ut.LTR)}}function pe(t){return 1==t.node.nodeType&&t.node.firstChild&&(0==t.offset||"false"==t.node.childNodes[t.offset-1].contentEditable)&&(t.offset==t.node.childNodes.length||"false"==t.node.childNodes[t.offset].contentEditable)}class ge extends ht{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}}function me(t){let e=t.observer.selectionRange,i=e.focusNode&&ye(e.focusNode,e.focusOffset,0);if(!i)return null;let n=t.docView.nearest(i);if(!n)return null;if(n instanceof wt){let t=i;while(t.parentNode!=n.dom)t=t.parentNode;let e=t.previousSibling;while(e&&!B.get(e))e=e.previousSibling;let s=e?B.get(e).posAtEnd:n.posAtStart;return{from:s,to:s,node:t,text:i}}{for(;;){let{parent:t}=n;if(!t)return null;if(t instanceof wt)break;n=t}let t=n.posAtStart;return{from:t,to:t+n.length,node:n.dom,text:i}}}function we(t,e){let i=me(t);if(!i)return ct.none;let{from:n,to:s,node:r,text:o}=i,l=e.mapPos(n,1),h=Math.max(l,e.mapPos(s,-1)),{state:a}=t,c=3==r.nodeType?r.nodeValue:new ce([],t).readRange(r.firstChild,null).text;if(h-l<c.length)if(a.sliceDoc(l,Math.min(a.doc.length,l+c.length))==c)h=l+c.length;else{if(a.sliceDoc(Math.max(0,h-c.length),h)!=c)return ct.none;l=h-c.length}else if(a.sliceDoc(l,h)!=c)return ct.none;return ct.set(ct.replace({widget:new ve(r,o)}).range(l,h))}class ve extends ht{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 Z}}function ye(t,e,i){for(;;){if(3==t.nodeType)return t;if(1==t.nodeType&&e>0&&i<=0)t=t.childNodes[e-1],e=m(t);else{if(!(1==t.nodeType&&e<t.childNodes.length&&i>=0))return null;t=t.childNodes[e],e=0}}}function be(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 xe{constructor(){this.changes=[]}compareRange(t,e){mt(t,e,this.changes)}comparePoint(t,e){mt(t,e,this.changes)}}function ke(t,e,i){let n=new xe;return o.Xs.compare(t,e,i,n),n.changes}function Se(t,e){for(let i=t;i&&i!=e;i=i.assignedSlot||i.parentNode)if(1==i.nodeType&&"false"==i.contentEditable)return!0;return!1}function Ae(t,e,i=1){let r=t.charCategorizer(e),o=t.doc.lineAt(e),l=e-o.from;if(0==o.length)return n.jT.cursor(e);0==l?i=1:l==o.length&&(i=-1);let h=l,a=l;i<0?h=(0,s.cp)(o.text,l,!1):a=(0,s.cp)(o.text,l);let c=r(o.text.slice(h,a));while(h>0){let t=(0,s.cp)(o.text,h,!1);if(r(o.text.slice(t,h))!=c)break;h=t}while(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(h+o.from,a+o.from)}function Me(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function Ce(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function De(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function Te(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function Oe(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function Ee(t,e,i){let n,s,r,o,l,h,a,c;for(let p=t.firstChild;p;p=p.nextSibling){let t=d(p);for(let u=0;u<t.length;u++){let d=t[u];s&&De(s,d)&&(d=Te(Oe(d,s.bottom),s.top));let f=Me(e,d),g=Ce(i,d);if(0==f&&0==g)return 3==p.nodeType?Be(p,e,i):Ee(p,e,i);(!n||o>g||o==g&&r>f)&&(n=p,s=d,r=f,o=g),0==f?i>d.bottom&&(!a||a.bottom<d.bottom)?(l=p,a=d):i<d.top&&(!c||c.top>d.top)&&(h=p,c=d):a&&De(a,d)?a=Oe(a,d.bottom):c&&De(c,d)&&(c=Te(c,d.top))}}if(a&&a.bottom>=i?(n=l,s=a):c&&c.top<=i&&(n=h,s=c),!n)return{node:t,offset:0};let u=Math.max(s.left,Math.min(s.right,e));if(3==n.nodeType)return Be(n,u,i);if(!r&&"true"==n.contentEditable)return Ee(n,u,i);let f=Array.prototype.indexOf.call(t.childNodes,n)+(e>=(s.left+s.right)/2?1:0);return{node:t,offset:f}}function Be(t,e,i){let n=t.nodeValue.length,s=-1,r=1e9,o=0;for(let l=0;l<n;l++){let n=M(t,l,l+1).getClientRects();for(let h=0;h<n.length;h++){let a=n[h];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(G.chrome||G.gecko){let e=M(t,l).getBoundingClientRect();e.left==a.right&&(n=!i)}if(c<=0)return{node:t,offset:l+(n?1:0)};s=l+(n?1:0),r=c}}}return{node:t,offset:s>-1?s:o>0?t.nodeValue.length:0}}function Re(t,{x:e,y:i},n,s=-1){var r;let o,l=t.contentDOM.getBoundingClientRect(),h=l.top+t.viewState.paddingTop,{docHeight:a}=t.viewState,c=i-h;if(c<0)return 0;if(c>a)return t.state.doc.length;for(let w=t.defaultLineHeight/2,v=!1;;){if(o=t.elementAtHeight(c),o.type==at.Text)break;for(;;){if(c=s>0?o.bottom+w:o.top-w,c>=0&&c<=a)break;if(v)return n?null:0;v=!0,s=-s}}i=h+c;let u=o.from;if(u<t.viewport.from)return 0==t.viewport.from?0:n?null:Le(t,l,o,e,i);if(u>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:n?null:Le(t,l,o,e,i);let d=t.dom.ownerDocument,f=t.root.elementFromPoint?t.root:d,p=f.elementFromPoint(e,i);p&&!t.contentDOM.contains(p)&&(p=null),p||(e=Math.max(l.left+1,Math.min(l.right-1,e)),p=f.elementFromPoint(e,i),p&&!t.contentDOM.contains(p)&&(p=null));let g,m=-1;if(p&&0!=(null===(r=t.docView.nearest(p))||void 0===r?void 0:r.isEditable))if(d.caretPositionFromPoint){let t=d.caretPositionFromPoint(e,i);t&&({offsetNode:g,offset:m}=t)}else if(d.caretRangeFromPoint){let t=d.caretRangeFromPoint(e,i);t&&(({startContainer:g,startOffset:m}=t),G.safari&&Pe(g,m,e)&&(g=void 0))}if(!g||!t.docView.dom.contains(g)){let n=wt.find(t.docView,u);if(!n)return c>o.top+o.height/2?o.to:o.from;({node:g,offset:m}=Ee(n.dom,e,i))}return t.docView.posFromDOM(g,m)}function Le(t,e,i,n,r){let o=Math.round((n-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>1.5*t.defaultLineHeight){let e=Math.floor((r-i.top)/t.defaultLineHeight);o+=e*t.viewState.heightOracle.lineLength}let l=t.state.sliceDoc(i.from,i.to);return i.from+(0,s.Gz)(l,o,t.state.tabSize)}function Pe(t,e,i){let n;if(3!=t.nodeType||e!=(n=t.nodeValue.length))return!1;for(let s=t.nextSibling;s;s=s.nextSibling)if(1!=s.nodeType||"BR"!=s.nodeName)return!1;return M(t,n-1,n).getBoundingClientRect().left>i}function Ne(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==Ut.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 l=wt.find(t.docView,e.head),h=l?i?l.posAtEnd:l.posAtStart:i?r.to:r.from;return n.jT.cursor(h,i?-1:1)}function Ve(t,e,i,s){let r=t.state.doc.lineAt(e.head),o=t.bidiSpans(r);for(let l=e,h=null;;){let e=ae(r,o,t.textDirection,l,i),a=he;if(!e){if(r.number==(i?t.state.doc.lines:1))return l;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(h){if(!h(a))return l}else{if(!s)return e;h=s(a)}l=e}}function Ie(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}}function He(t,e,i,s){let r=e.head,o=i?1:-1;if(r==(i?t.state.doc.length:0))return n.jT.cursor(r,e.assoc);let l,h=e.goalColumn,a=t.contentDOM.getBoundingClientRect(),c=t.coordsAtPos(r),u=t.documentTop;if(c)null==h&&(h=c.left-a.left),l=o<0?c.top:c.bottom;else{let e=t.viewState.lineBlockAt(r-u);null==h&&(h=Math.min(a.right-a.left,t.defaultCharacterWidth*(r-e.from))),l=(o<0?e.top:e.bottom)+u}let d=a.left+h,f=null!==s&&void 0!==s?s:t.defaultLineHeight>>1;for(let p=0;;p+=10){let i=l+(f+p)*o,s=Re(t,{x:d,y:i},!1,o);if(i<a.top||i>a.bottom||(o<0?s<r:s>r))return n.jT.cursor(s,e.assoc,void 0,h)}}function We(t,e,i){let s=t.pluginField(Vt.atomicRanges);for(;;){let t=!1;for(let r of s)r.between(i.from-1,i.from+1,((s,r,o)=>{i.from>s&&i.from<r&&(i=e.from>i.from?n.jT.cursor(s,1):n.jT.cursor(r,-1),t=!0)}));if(!t)return i}}class Fe{constructor(t){this.lastKeyCode=0,this.lastKeyTime=0,this.pendingIOSKey=void 0,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=0,this.lastContextMenu=0,this.scrollHandlers=[],this.registeredEvents=[],this.customHandlers=[],this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.rapidCompositionStart=!1,this.mouseSelection=null;for(let e in Ue){let i=Ue[e];t.contentDOM.addEventListener(e,(n=>{"keydown"==e&&this.keydown(t,n)||Ge(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),G.safari&&t.contentDOM.addEventListener("input",(()=>null))}setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}ensureHandlers(t){let e=this.customHandlers=t.pluginField(Ft);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=>{Ge(t,i)&&this.runCustomHandlers(e,t,i)&&i.preventDefault()})))}runCustomHandlers(t,e,i){for(let s of this.customHandlers){let r=s.handlers[t];if(r)try{if(r.call(s.plugin,i,e)||i.defaultPrevented)return!0}catch(n){Lt(e.state,n)}}return!1}runScrollHandlers(t,e){for(let n of this.customHandlers){let s=n.handlers.scroll;if(s)try{s.call(n.plugin,e,t)}catch(i){Lt(t.state,i)}}}keydown(t,e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),this.screenKeyEvent(t,e))return!0;if(G.android&&G.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))return t.observer.delayAndroidKey(e.key,e.keyCode),!0;let i;return!(!G.ios||!(i=ze.find((t=>t.keyCode==e.keyCode)))||e.ctrlKey||e.altKey||e.metaKey||e.synthetic)&&(this.pendingIOSKey=i,setTimeout((()=>this.flushIOSKey(t)),250),!0)}flushIOSKey(t){let e=this.pendingIOSKey;return!!e&&(this.pendingIOSKey=void 0,C(t.contentDOM,e.key,e.keyCode))}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(this.composing>0||!!(G.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():qe.indexOf(e.keyCode)<0&&(this.lastEscPress=0),i}mustFlushObserver(t){return"keydown"==t.type&&229!=t.keyCode||"compositionend"==t.type&&!G.ios}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.mouseSelection&&this.mouseSelection.update(t),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}const ze=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],qe=[16,17,18,20,91,92,224,225];class je{constructor(t,e,i,s){this.view=t,this.style=i,this.mustSelect=s,this.lastEvent=e;let r=t.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(n.yy.allowMultipleSelections)&&$e(t,e),this.dragMove=Ke(t,e),this.dragging=!(!_e(t,e)||1!=hi(e))&&null,!1===this.dragging&&(e.preventDefault(),this.select(e))}move(t){if(0==t.buttons)return this.destroy();!1===this.dragging&&this.select(this.lastEvent=t)}up(t){null==this.dragging&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=null}select(t){let e=this.style.get(t,this.extend,this.multiple);!this.mustSelect&&e.eq(this.view.state.selection)&&e.main.assoc==this.view.state.selection.main.assoc||this.view.dispatch({selection:e,userEvent:"select.pointer",scrollIntoView:!0}),this.mustSelect=!1}update(t){t.docChanged&&this.dragging&&(this.dragging=this.dragging.map(t.changes)),this.style.update(t)&&setTimeout((()=>this.select(this.lastEvent)),20)}}function $e(t,e){let i=t.state.facet(St);return i.length?i[0](e):G.mac?e.metaKey:e.ctrlKey}function Ke(t,e){let i=t.state.facet(At);return i.length?i[0](e):G.mac?!e.altKey:!e.ctrlKey}function _e(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let n=h(t.root);if(0==n.rangeCount)return!0;let s=n.getRangeAt(0).getClientRects();for(let r=0;r<s.length;r++){let t=s[r];if(t.left<=e.clientX&&t.right>=e.clientX&&t.top<=e.clientY&&t.bottom>=e.clientY)return!0}return!1}function Ge(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=B.get(n))&&i.ignoreEvent(e))return!1;return!0}const Ue=Object.create(null),Xe=G.ie&&G.ie_version<15||G.ios&&G.webkit_version<604;function Je(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(),Ye(t,i.value)}),50)}function Ye(t,e){let i,{state:s}=t,r=1,o=s.toText(e),l=o.lines==s.selection.ranges.length,h=null!=fi&&s.selection.ranges.every((t=>t.empty))&&fi==o.toString();if(h){let t=-1;i=s.changeByRange((i=>{let h=s.doc.lineAt(i.from);if(h.from==t)return{range:i};t=h.from;let a=s.toText((l?o.line(r++).text:e)+s.lineBreak);return{changes:{from:h.from,insert:a},range:n.jT.cursor(i.from+a.length)}}))}else i=l?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,{userEvent:"input.paste",scrollIntoView:!0})}Ue.keydown=(t,e)=>{t.inputState.setSelectionOrigin("select")};let Qe=0;function Ze(t,e,i,s){if(1==s)return n.jT.cursor(e,i);if(2==s)return Ae(t.state,e,i);{let i=wt.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)}}Ue.touchstart=(t,e)=>{Qe=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},Ue.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},Ue.mousedown=(t,e)=>{if(t.observer.flush(),Qe>Date.now()-2e3&&1==hi(e))return;let i=null;for(let n of t.state.facet(Mt))if(i=n(t,e),i)break;if(i||0!=e.button||(i=ai(t,e)),i){let n=t.root.activeElement!=t.contentDOM;n&&t.observer.ignore((()=>A(t.contentDOM))),t.inputState.startMouseSelection(new je(t,e,i,n))}};let ti=(t,e)=>t>=e.top&&t<=e.bottom,ei=(t,e,i)=>ti(e,i)&&t>=i.left&&t<=i.right;function ii(t,e,i,n){let s=wt.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&&ei(i,n,o))return-1;let l=s.coordsAt(r,1);return l&&ei(i,n,l)?1:o&&ti(n,o)?-1:1}function ni(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:ii(t,i,e.clientX,e.clientY)}}const si=G.ie&&G.ie_version<=11;let ri=null,oi=0,li=0;function hi(t){if(!si)return t.detail;let e=ri,i=li;return ri=t,li=Date.now(),oi=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(oi+1)%3:1}function ai(t,e){let i=ni(t,e),s=hi(e),r=t.state.selection,o=i,l=e;return{update(t){t.docChanged&&(i&&(i.pos=t.changes.mapPos(i.pos)),r=r.map(t.changes),l=null)},get(e,h,a){let c;if(l&&e.clientX==l.clientX&&e.clientY==l.clientY?c=o:(c=o=ni(t,e),l=e),!c||!i)return r;let u=Ze(t,c.pos,c.bias,s);if(i.pos!=c.pos&&!h){let e=Ze(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 h?r.replaceRange(r.main.extend(u.from,u.to)):a?r.addRange(u):n.jT.create([u])}}}function ci(t,e,i,n){if(!i)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1);e.preventDefault();let{mouseSelection:r}=t.inputState,o=n&&r&&r.dragging&&r.dragMove?{from:r.dragging.from,to:r.dragging.to}:null,l={from:s,insert:i},h=t.state.changes(o?[o,l]:l);t.focus(),t.dispatch({changes:h,selection:{anchor:h.mapPos(s,-1),head:h.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"})}function ui(t,e){let i=t.dom.parentNode;if(!i)return;let n=i.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout((()=>{n.remove(),t.focus()}),50)}function di(t){let e=[],i=[],n=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),i.push(s));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}}Ue.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")},Ue.drop=(t,e)=>{if(!e.dataTransfer)return;if(t.state.readOnly)return e.preventDefault();let i=e.dataTransfer.files;if(i&&i.length){e.preventDefault();let n=Array(i.length),s=0,r=()=>{++s==i.length&&ci(t,e,n.filter((t=>null!=t)).join(t.state.lineBreak),!1)};for(let t=0;t<i.length;t++){let e=new FileReader;e.onerror=r,e.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(e.result)||(n[t]=e.result),r()},e.readAsText(i[t])}}else ci(t,e,e.dataTransfer.getData("Text"),!0)},Ue.paste=(t,e)=>{if(t.state.readOnly)return e.preventDefault();t.observer.flush();let i=Xe?null:e.clipboardData;i?(Ye(t,i.getData("text/plain")),e.preventDefault()):Je(t)};let fi=null;function pi(t,e){if(t.docView.compositionDeco.size){t.inputState.rapidCompositionStart=e;try{t.update([])}finally{t.inputState.rapidCompositionStart=!1}}}Ue.copy=Ue.cut=(t,e)=>{let{text:i,ranges:n,linewise:s}=di(t.state);if(!i&&!s)return;fi=s?i:null;let r=Xe?null:e.clipboardData;r?(e.preventDefault(),r.clearData(),r.setData("text/plain",i)):ui(t,i),"cut"!=e.type||t.state.readOnly||t.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"})},Ue.focus=Ue.blur=t=>{setTimeout((()=>{t.hasFocus!=t.inputState.notifiedFocused&&t.update([])}),10)},Ue.beforeprint=t=>{t.viewState.printing=!0,t.requestMeasure(),setTimeout((()=>{t.viewState.printing=!1,t.requestMeasure()}),2e3)},Ue.compositionstart=Ue.compositionupdate=t=>{null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0,t.docView.compositionDeco.size&&(t.observer.flush(),pi(t,!0)))},Ue.compositionend=t=>{t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionFirstChange=null,setTimeout((()=>{t.inputState.composing<0&&pi(t,!1)}),50)},Ue.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Ue.beforeinput=(t,e)=>{var i;let n;if(G.chrome&&G.android&&(n=ze.find((t=>t.inputType==e.inputType)))&&(t.observer.delayAndroidKey(n.key,n.keyCode),"Backspace"==n.key||"Delete"==n.key)){let e=(null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0;setTimeout((()=>{var i;((null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0)>e+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())}),100)}};const gi=["pre-wrap","normal","pre-line","break-spaces"];class mi{constructor(){this.doc=s.xv.empty,this.lineWrapping=!1,this.direction=Ut.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;let e=1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5)));return e*this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForStyle(t,e){return gi.indexOf(t)>-1!=this.lineWrapping||this.direction!=e}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let n=t[i];n<0?i++:this.heightSamples[Math.floor(10*n)]||(e=!0,this.heightSamples[Math.floor(10*n)]=!0)}return e}refresh(t,e,i,n,s,r){let o=gi.indexOf(t)>-1,l=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,l){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 l}}class wi{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class vi{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 vi(this.from,this.length+t.length,this.top,this.height+t.height,e)}moveY(t){return t?new vi(this.from,this.length,this.top+t,this.height,Array.isArray(this.type)?this.type.map((e=>e.moveY(t))):this.type):this}}var yi=function(t){return t[t["ByPos"]=0]="ByPos",t[t["ByHeight"]=1]="ByHeight",t[t["ByPosNoHeight"]=2]="ByPosNoHeight",t}(yi||(yi={}));const bi=.001;class xi{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)>bi&&(t.heightChanged=!0),this.height=e)}replace(t,e,i){return xi.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:l,fromB:h,toB:a}=n[r],c=s.lineAt(o,yi.ByPosNoHeight,e,0,0),u=c.to>=l?c:s.lineAt(l,yi.ByPosNoHeight,e,0,0);a+=u.to-l,l=u.to;while(r>0&&c.from<=n[r-1].toA)o=n[r-1].fromA,h=n[r-1].fromB,r--,o<c.from&&(c=s.lineAt(o,yi.ByPosNoHeight,e,0,0));h+=c.from-o,o=c.from;let d=Ti.build(i,t,h,a);s=s.replace(o,l,d)}return s.updateHeight(i,0)}static empty(){return new Si(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 Mi(xi.of(t.slice(0,e)),r,xi.of(t.slice(i)))}}xi.prototype.size=1;class ki extends xi{constructor(t,e,i){super(t,e),this.type=i}blockAt(t,e,i,n){return new vi(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 Si extends ki{constructor(t,e){super(t,e,at.Text),this.collapsed=0,this.widgetHeight=0}replace(t,e,i){let n=i[0];return 1==i.length&&(n instanceof Si||n instanceof Ai&&4&n.flags)&&Math.abs(this.length-n.length)<10?(n instanceof Ai?n=new Si(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):xi.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 Ai extends xi{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),l=Math.max(0,Math.min(r-s,Math.floor((t-i)/o))),{from:h,length:a}=e.line(s+l);return new vi(h,a,i+o*l,o,at.Text)}lineAt(t,e,i,n,s){if(e==yi.ByHeight)return this.blockAt(t,i,n,s);if(e==yi.ByPosNoHeight){let{from:e,to:n}=i.lineAt(t);return new vi(e,n-e,0,0,at.Text)}let{firstLine:r,lineHeight:o}=this.lines(i,s),{from:l,length:h,number:a}=i.lineAt(t);return new vi(l,h,n+o*(a-r),o,at.Text)}forEachLine(t,e,i,n,s,r){let{firstLine:o,lineHeight:l}=this.lines(i,s);for(let h=Math.max(t,s),a=Math.min(s+this.length,e);h<=a;){let e=i.lineAt(h);h==t&&(n+=l*(e.number-o)),r(new vi(e.from,e.length,n,l,at.Text)),n+=l,h=e.to+1}}replace(t,e,i){let n=this.length-e;if(n>0){let t=i[i.length-1];t instanceof Ai?i[i.length-1]=new Ai(t.length+n):i.push(null,new Ai(n-1))}if(t>0){let e=i[0];e instanceof Ai?i[0]=new Ai(t+e.length):i.unshift(new Ai(t-1),null)}return xi.of(i)}decomposeLeft(t,e){e.push(new Ai(t-1),null)}decomposeRight(t,e){e.push(null,new Ai(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),o=-1,l=t.heightChanged;n.from>e&&i.push(new Ai(n.from-e-1).updateHeight(t,e));while(r<=s&&n.more){let e=t.doc.lineAt(r).length;i.length&&i.push(null);let s=n.heights[n.index++];-1==o?o=s:Math.abs(s-o)>=bi&&(o=-2);let l=new Si(e,s);l.outdated=!1,i.push(l),r+=e+1}r<=s&&i.push(null,new Ai(s-r).updateHeight(t,r));let h=xi.of(i);return t.heightChanged=l||o<0||Math.abs(h.height-this.height)>=bi||Math.abs(o-this.lines(t.doc,e).lineHeight)>=bi,h}return(i||this.outdated)&&(this.setHeight(t,t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class Mi extends xi{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?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,l=e==yi.ByHeight?t<r:t<o,h=l?this.left.lineAt(t,e,i,n,s):this.right.lineAt(t,e,i,r,o);if(this.break||(l?h.to<o:h.from>o))return h;let a=e==yi.ByPosNoHeight?yi.ByPosNoHeight:yi.ByPos;return l?h.join(this.right.lineAt(o,a,i,r,o)):this.left.lineAt(o,a,i,n,s).join(h)}forEachLine(t,e,i,n,s,r){let o=n+this.left.height,l=s+this.left.length+this.break;if(this.break)t<l&&this.left.forEachLine(t,e,i,n,s,r),e>=l&&this.right.forEachLine(t,e,i,o,l,r);else{let h=this.lineAt(l,yi.ByPos,i,n,s);t<h.from&&this.left.forEachLine(t,h.from-1,i,n,s,r),h.to>=t&&h.from<=e&&r(h),e>h.to&&this.right.forEachLine(h.to+1,e,i,o,l,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 o of i)s.push(o);if(t>0&&Ci(s,r-1),e<this.length){let t=s.length;this.decomposeRight(e,s),Ci(s,t)}return xi.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?xi.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,l=null;return n&&n.from<=e+s.length&&n.more?l=s=s.updateHeight(t,e,i,n):s.updateHeight(t,e,i),n&&n.from<=o+r.length&&n.more?l=r=r.updateHeight(t,o,i,n):r.updateHeight(t,o,i),l?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 Ci(t,e){let i,n;null==t[e]&&(i=t[e-1])instanceof Ai&&(n=t[e+1])instanceof Ai&&t.splice(e-1,3,new Ai(i.length+1+n.length))}const Di=5;class Ti{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 Si?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new Si(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?i.widget.estimatedHeight:0;n<0&&(n=this.oracle.lineHeight);let s=e-t;i.block?this.addBlock(new ki(s,n,i.type)):(s||n>=Di)&&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 Si(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new Ai(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 Si)return t;let e=new Si(0,-1);return this.nodes.push(e),e}addBlock(t){this.enterLine(),t.type!=at.WidgetAfter||this.isCovered||this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,t.type!=at.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 Si||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new Si(0,-1));let i=t;for(let n of this.nodes)n instanceof Si&&n.updateHeight(this.oracle,i),i+=n?n.length:1;return this.nodes}static build(t,e,i,n){let s=new Ti(i,t);return o.Xs.spans(e,i,n,s,0),s.finish(i)}}function Oi(t,e,i){let n=new Ei;return o.Xs.compare(t,e,i,n,0),n.changes}class Ei{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,n){(t<e||i&&i.heightRelevant||n&&n.heightRelevant)&&mt(t,e,this.changes,5)}}function Bi(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),l=t.ownerDocument.body;for(let h=t.parentNode;h&&h!=l;)if(1==h.nodeType){let t=h,e=window.getComputedStyle(t);if((t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)&&"visible"!=e.overflow){let e=t.getBoundingClientRect();n=Math.max(n,e.left),s=Math.min(s,e.right),r=Math.max(r,e.top),o=Math.min(o,e.bottom)}h="absolute"==e.position||"fixed"==e.position?t.offsetParent:t.parentNode}else{if(11!=h.nodeType)break;h=h.host}return{left:n-i.left,right:Math.max(n,s)-i.left,top:r-(i.top+e),bottom:Math.max(r,o)-(i.top+e)}}class Ri{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 ct.replace({widget:new Li(this.size,t)}).range(this.from,this.to)}}class Li extends ht{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 Pi{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.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.heightOracle=new mi,this.scaler=zi,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1,this.heightMap=xi.empty().applyChanges(t.facet($t),s.xv.empty,this.heightOracle.setDoc(t.doc),[new _t(0,0,0,t.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ct.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.lineBlockAt(n);t.push(new Ni(e,i))}}this.viewports=t.sort(((t,e)=>t.from-e.from)),this.scaler=this.heightMap.height<=7e6?zi:new qi(this.heightOracle.doc,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.state.doc,0,0,(t=>{this.viewportLines.push(1==this.scaler.scale?t:ji(t,this.scaler))}))}update(t,e=null){let i=this.state;this.state=t.state;let s=this.state.facet($t),r=t.changedRanges,o=_t.extendWithRanges(r,Oi(t.startState.facet($t),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),o),this.heightMap.height!=l&&(t.flags|=2);let h=o.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<h.from||e.range.head>h.to)||!this.viewportIsAppropriate(h))&&(h=this.getViewport(0,e));let a=!t.changes.empty||2&t.flags||h.from!=this.viewport.from||h.to!=this.viewport.to;this.viewport=h,this.updateForViewport(),a&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,t.changes))),t.flags|=this.computeVisibleRanges(),e&&(this.scrollTarget=e),!this.mustEnforceCursorAssoc&&t.selectionSet&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),n=this.heightOracle,s=i.whiteSpace,r="rtl"==i.direction?Ut.RTL:Ut.LTR,o=this.heightOracle.mustRefreshForStyle(s,r),l=o||this.mustMeasureContent||this.contentDOMHeight!=e.clientHeight,h=0,a=0;if(l){this.mustMeasureContent=!1,this.contentDOMHeight=e.clientHeight;let t=parseInt(i.paddingTop)||0,n=parseInt(i.paddingBottom)||0;this.paddingTop==t&&this.paddingBottom==n||(h|=8,this.paddingTop=t,this.paddingBottom=n)}let c=this.printing?{top:-1e8,bottom:1e8,left:-1e8,right:1e8}:Bi(e,this.paddingTop),u=c.top-this.pixelViewport.top,d=c.bottom-this.pixelViewport.bottom;this.pixelViewport=c;let f=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(f!=this.inView&&(this.inView=f,f&&(l=!0)),!this.inView)return 0;let p=e.clientWidth;if(this.contentDOMWidth==p&&this.editorHeight==t.scrollDOM.clientHeight&&this.editorWidth==t.scrollDOM.clientWidth||(this.contentDOMWidth=p,this.editorHeight=t.scrollDOM.clientHeight,this.editorWidth=t.scrollDOM.clientWidth,h|=8),l){let e=t.docView.measureVisibleLineHeights();if(n.mustRefreshForHeights(e)&&(o=!0),o||n.lineWrapping&&Math.abs(p-this.contentDOMWidth)>n.charWidth){let{lineHeight:i,charWidth:l}=t.docView.measureTextSize();o=n.refresh(s,r,i,l,p/l,e),o&&(t.docView.minWidth=0,h|=8)}u>0&&d>0?a=Math.max(u,d):u<0&&d<0&&(a=Math.min(u,d)),n.heightChanged=!1,this.heightMap=this.heightMap.updateHeight(n,0,o,new wi(this.viewport.from,e)),n.heightChanged&&(h|=2)}let g=!this.viewportIsAppropriate(this.viewport,a)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return g&&(this.viewport=this.getViewport(a,this.scrollTarget)),this.updateForViewport(),(2&h||g)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),n=this.heightMap,s=this.state.doc,{visibleTop:r,visibleBottom:o}=this,l=new Ni(n.lineAt(r-1e3*i,yi.ByHeight,s,0,0).from,n.lineAt(o+1e3*(1-i),yi.ByHeight,s,0,0).to);if(e){let{head:t}=e.range,i=this.editorHeight;if(t<l.from||t>l.to){let r,o=n.lineAt(t,yi.ByPos,s,0,0);r="center"==e.y?(o.top+o.bottom)/2-i/2:"start"==e.y||"nearest"==e.y&&t<l.from?o.top:o.bottom-i,l=new Ni(n.lineAt(r-500,yi.ByHeight,s,0,0).from,n.lineAt(r+i+500,yi.ByHeight,s,0,0).to)}}return l}mapViewport(t,e){let i=e.mapPos(t.from,-1),n=e.mapPos(t.to,1);return new Ni(this.heightMap.lineAt(i,yi.ByPos,this.state.doc,0,0).from,this.heightMap.lineAt(n,yi.ByPos,this.state.doc,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(t,yi.ByPos,this.state.doc,0,0),{bottom:s}=this.heightMap.lineAt(e,yi.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 Ri(e.mapPos(n.from),e.mapPos(n.to),n.size));return i}ensureLineGaps(t){let e=[];if(this.heightOracle.direction!=Ut.LTR)return e;for(let i of this.viewportLines){if(i.length<4e3)continue;let n,s,r=Vi(i.from,i.to,this.state);if(r.total<4e3)continue;if(this.heightOracle.lineWrapping){let t=2e3/this.heightOracle.lineLength*this.heightOracle.lineHeight;n=Ii(r,(this.visibleTop-i.top-t)/i.height),s=Ii(r,(this.visibleBottom-i.top+t)/i.height)}else{let t=r.total*this.heightOracle.charWidth,e=2e3*this.heightOracle.charWidth;n=Ii(r,(this.pixelViewport.left-e)/t),s=Ii(r,(this.pixelViewport.right+e)/t)}let o=[];n>i.from&&o.push({from:i.from,to:n}),s<i.to&&o.push({from:s,to:i.to});let l=this.state.selection.main;l.from>=i.from&&l.from<=i.to&&Wi(o,l.from-10,l.from+10),!l.empty&&l.to>=i.from&&l.to<=i.to&&Wi(o,l.to-10,l.to+10);for(let{from:h,to:a}of o)a-h>1e3&&e.push(Fi(t,(t=>t.from>=i.from&&t.to<=i.to&&Math.abs(t.from-h)<1e3&&Math.abs(t.to-a)<1e3))||new Ri(h,a,this.gapSize(i,h,a,r)))}return e}gapSize(t,e,i,n){let s=Hi(n,i)-Hi(n,e);return this.heightOracle.lineWrapping?t.height*s:n.total*this.heightOracle.charWidth*s}updateLineGaps(t){Ri.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=ct.set(t.map((t=>t.draw(this.heightOracle.lineWrapping)))))}computeVisibleRanges(){let t=this.state.facet($t);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);let i=e.length!=this.visibleRanges.length||this.visibleRanges.some(((t,i)=>t.from!=e[i].from||t.to!=e[i].to));return this.visibleRanges=e,i?4:0}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find((e=>e.from<=t&&e.to>=t))||ji(this.heightMap.lineAt(t,yi.ByPos,this.state.doc,0,0),this.scaler)}lineBlockAtHeight(t){return ji(this.heightMap.lineAt(this.scaler.fromDOM(t),yi.ByHeight,this.state.doc,0,0),this.scaler)}elementAtHeight(t){return ji(this.heightMap.blockAt(this.scaler.fromDOM(t),this.state.doc,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Ni{constructor(t,e){this.from=t,this.to=e}}function Vi(t,e,i){let n=[],s=t,r=0;return o.Xs.spans(i.facet($t),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),{total:r,ranges:n}}function Ii({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 s=0;;s++){let{from:t,to:i}=e[s],r=i-t;if(n<=r)return t+n;n-=r}}function Hi(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 Wi(t,e,i){for(let n=0;n<t.length;n++){let s=t[n];if(s.from<i&&s.to>e){let r=[];s.from<e&&r.push({from:s.from,to:e}),s.to>i&&r.push({from:i,to:s.to}),t.splice(n,1,...r),n+=r.length-1}}}function Fi(t,e){for(let i of t)if(e(i))return i}const zi={toDOM(t){return t},fromDOM(t){return t},scale:1};class qi{constructor(t,e,i){let n=0,s=0,r=0;this.viewports=i.map((({from:i,to:s})=>{let r=e.lineAt(i,yi.ByPos,t,0,0).top,o=e.lineAt(s,yi.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 o of this.viewports)o.domTop=r+(o.top-s)*this.scale,r=o.domBottom=o.domTop+(o.bottom-o.top),s=o.bottom}toDOM(t){for(let e=0,i=0,n=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.top)return n+(t-i)*this.scale;if(t<=s.bottom)return s.domTop+(t-s.top);i=s.bottom,n=s.domBottom}}fromDOM(t){for(let e=0,i=0,n=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.domTop)return i+(t-n)/this.scale;if(t<=s.domBottom)return s.top+(t-s.domTop);i=s.bottom,n=s.domBottom}}}function ji(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),n=e.toDOM(t.bottom);return new vi(t.from,t.length,i,n-i,Array.isArray(t.type)?t.type.map((t=>ji(t,e))):t.type)}const $i=n.r$.define({combine:t=>t.join(" ")}),Ki=n.r$.define({combine:t=>t.indexOf(!0)>-1}),_i=r.V.newName(),Gi=r.V.newName(),Ui=r.V.newName(),Xi={"&light":"."+Gi,"&dark":"."+Ui};function Ji(t,e,i){return new r.V(e,{finish(e){return/&/.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 Yi=Ji("."+_i,{"&.cm-editor":{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","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",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, .cm-dropCursor":{position:"absolute",borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{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",verticalAlign:"top"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Xi),Qi={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Zi=G.ie&&G.ie_version<=11;class tn{constructor(t,e,i){this.view=t,this.onChange=e,this.onScrollChanged=i,this.active=!1,this.selectionRange=new x,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.scrollTargets=[],this.intersection=null,this.resize=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver((e=>{for(let t of e)this.queue.push(t);(G.ie&&G.ie_version<=11||G.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()})),Zi&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),"function"==typeof ResizeObserver&&(this.resize=new ResizeObserver((()=>{this.view.docView.lastUpdate<Date.now()-75&&this.resizeTimeout<0&&(this.resizeTimeout=setTimeout((()=>{this.resizeTimeout=-1,this.view.requestMeasure()}),50))})),this.resize.observe(t.scrollDOM)),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.length>0&&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.gapIntersection=new IntersectionObserver((t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))}),{})),this.listenForScroll(),this.readSelectionRange(),this.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}onScroll(t){this.intersecting&&this.flush(!1),this.onScrollChanged(t)}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some(((e,i)=>e!=t[i])))){this.gapIntersection.disconnect();for(let e of t)this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:e}=this,i=this.selectionRange;if(e.state.facet(Pt)?e.root.activeElement!=this.dom:!u(e.dom,i))return;let n=i.anchorNode&&e.docView.nearest(i.anchorNode);n&&n.ignoreEvent(t)||((G.ie&&G.ie_version<=11||G.android&&G.chrome)&&!e.state.selection.main.empty&&i.focusNode&&f(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1))}readSelectionRange(){let{root:t}=this.view,e=h(t),i=G.safari&&11==t.nodeType&&c()==this.view.contentDOM&&nn(this.view)||e;return!this.selectionRange.eq(i)&&(this.selectionRange.setRange(i),this.selectionChanged=!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}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,Qi),Zi&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Zi&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.observer.takeRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){this.delayedAndroidKey||requestAnimationFrame((()=>{let t=this.delayedAndroidKey;this.delayedAndroidKey=null;let e=this.view.state;C(this.view.contentDOM,t.key,t.keyCode)?this.processRecords():this.flush(),this.view.state==e&&this.view.update([])})),this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e})}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())}processRecords(){let t=this.queue;for(let s of this.observer.takeRecords())t.push(s);t.length&&(this.queue=[]);let e=-1,i=-1,n=!1;for(let s of t){let t=this.readMutation(s);t&&(t.typeOver&&(n=!0),-1==e?({from:e,to:i}=t):(e=Math.min(t.from,e),i=Math.max(t.to,i)))}return{from:e,to:i,typeOver:n}}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return;t&&this.readSelectionRange();let{from:e,to:i,typeOver:n}=this.processRecords(),s=this.selectionChanged&&u(this.dom,this.selectionRange);if(e<0&&!s)return;this.selectionChanged=!1;let r=this.view.state;this.onChange(e,i,n),this.view.state==r&&this.view.update([])}readMutation(t){let e=this.view.docView.nearest(t.target);if(!e||e.ignoreMutation(t))return null;if(e.markDirty("attributes"==t.type),"attributes"==t.type&&(e.dirty|=4),"childList"==t.type){let i=en(e,t.previousSibling||t.target.previousSibling,-1),n=en(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"characterData"==t.type?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}destroy(){var t,e,i;this.stop(),null===(t=this.intersection)||void 0===t||t.disconnect(),null===(e=this.gapIntersection)||void 0===e||e.disconnect(),null===(i=this.resize)||void 0===i||i.disconnect();for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);window.removeEventListener("scroll",this.onScroll),this.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout)}}function en(t,e,i){while(e){let n=B.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 nn(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,l=t.docView.domAtPos(t.state.selection.main.anchor);return f(l.node,l.offset,r,o)&&([n,s,r,o]=[r,o,n,s]),{anchorNode:n,anchorOffset:s,focusNode:r,focusOffset:o}}function sn(t,e,i,s){let r,o,l=t.state.selection.main;if(e>-1){let n=t.docView.domBoundsAround(e,i,0);if(!n||t.state.readOnly)return;let{from:s,to:h}=n,a=t.docView.impreciseHead||t.docView.impreciseAnchor?[]:on(t),c=new ce(a,t);c.readRange(n.startDOM,n.endDOM),o=ln(a,s);let u=l.from,d=null;(8===t.inputState.lastKeyCode&&t.inputState.lastKeyTime>Date.now()-100||G.android&&c.text.length<h-s)&&(u=l.to,d="end");let f=rn(t.state.sliceDoc(s,h),c.text,u-s,d);f&&(r={from:s+f.from,to:s+f.toA,insert:t.state.toText(c.text.slice(f.from,f.toB))})}else if(t.hasFocus||!t.state.facet(Pt)){let e=t.observer.selectionRange,{impreciseHead:i,impreciseAnchor:s}=t.docView,r=i&&i.node==e.focusNode&&i.offset==e.focusOffset||!a(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||!a(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(G.ios&&t.inputState.flushIOSKey(t))return;if(G.android&&(r.from==l.from&&r.to==l.to&&1==r.insert.length&&2==r.insert.lines&&C(t.contentDOM,"Enter",13)||r.from==l.from-1&&r.to==l.to&&0==r.insert.length&&C(t.contentDOM,"Backspace",8)||r.from==l.from&&r.to==l.to+1&&0==r.insert.length&&C(t.contentDOM,"Delete",46)))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)&&t.inputState.composing<0){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 s=e.changes(r),h=o&&!e.selection.main.eq(o.main)&&o.main.to<=s.newLength?o.main:void 0;if(e.selection.ranges.length>1&&t.inputState.composing>=0&&r.to<=l.to&&r.to>=l.to-10){let o=t.state.sliceDoc(r.from,r.to),a=me(t)||t.state.doc.lineAt(l.head),c=l.to-r.to,u=l.to-l.from;i=e.changeByRange((i=>{if(i.from==l.from&&i.to==l.to)return{changes:s,range:h||i.map(s)};let d=i.to-c,f=d-o.length;if(i.to-i.from!=u||t.state.sliceDoc(f,d)!=o||a&&i.to>=a.from&&i.from<=a.to)return{range:i};let p=e.changes({from:f,to:d,insert:r.insert}),g=i.to-l.to;return{changes:p,range:h?n.jT.range(Math.max(0,h.anchor+g),Math.max(0,h.head+g)):i.map(p)}}))}else i={changes:s,selection:h&&e.selection.replaceRange(h)}}let h="input.type";t.composing&&(h+=".compose",t.inputState.compositionFirstChange&&(h+=".start",t.inputState.compositionFirstChange=!1)),t.dispatch(i,{scrollIntoView:!0,userEvent:h})}else if(o&&!o.main.eq(l)){let e=!1,i="select";t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(e=!0),i=t.inputState.lastSelectionOrigin),t.dispatch({selection:o,scrollIntoView:e,userEvent:i})}}function rn(t,e,i,n){let s=Math.min(t.length,e.length),r=0;while(r<s&&t.charCodeAt(r)==e.charCodeAt(r))r++;if(r==s&&t.length==e.length)return null;let o=t.length,l=e.length;while(o>0&&l>0&&t.charCodeAt(o-1)==e.charCodeAt(l-1))o--,l--;if("end"==n){let t=Math.max(0,r-Math.min(o,l));i-=o+t-r}if(o<r&&t.length<e.length){let t=i<=r&&i>=o?r-i:0;r-=t,l=r+(l-o),o=r}else if(l<r){let t=i<=r&&i>=l?r-i:0;r-=t,o=r+(o-l),l=r}return{from:r,toA:o,toB:l}}function on(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:n,focusNode:s,focusOffset:r}=t.observer.selectionRange;return i&&(e.push(new de(i,n)),s==i&&r==n||e.push(new de(s,r))),e}function ln(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}class hn{constructor(t={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.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||D(t.parent)||document,this.viewState=new Pi(t.state||n.yy.create()),this.plugins=this.state.facet(Ht).map((t=>new zt(t)));for(let e of this.plugins)e.update(this);this.observer=new tn(this,((t,e,i)=>{sn(this,t,e,i)}),(t=>{this.inputState.runScrollHandlers(this,t),this.observer.intersecting&&this.measure()})),this.inputState=new Fe(this),this.docView=new fe(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,dn(),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 n of t){if(n.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=n.state}if(this.destroyed)return void(this.viewState.state=s);if(s.facet(n.yy.phrases)!=this.state.facet(n.yy.phrases))return this.setState(s);e=new Gt(this,s,t);let r=this.viewState.scrollTarget;try{this.updateState=2;for(let e of t){if(r&&(r=r.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection;r=new Bt(t.empty?t:n.jT.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(Ot)?r=new Bt(t.value):t.is(Et)?r=new Bt(t.value,"center"):t.is(Rt)&&(r=t.value)}this.viewState.update(e,r),this.bidiCache=gn.update(this.bidiCache,e.changes),e.empty||(this.updatePlugins(e),this.inputState.update(e)),i=this.docView.update(e),this.state.facet(Kt)!=this.styleModules&&this.mountStyles(),this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(i,t.some((t=>t.isUserEvent("select.pointer"))))}finally{this.updateState=0}if((i||r||this.viewState.mustEnforceCursorAssoc)&&this.requestMeasure(),!e.empty)for(let n of this.state.facet(Dt))n(e)}setState(t){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)return void(this.viewState.state=t);this.updateState=2;let e=this.hasFocus;try{for(let t of this.plugins)t.destroy(this);this.viewState=new Pi(t),this.plugins=t.facet(Ht).map((t=>new zt(t))),this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView=new fe(this),this.inputState.ensureHandlers(this),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(Ht),i=t.state.facet(Ht);if(e!=i){let n=[];for(let s of i){let i=e.indexOf(s);if(i<0)n.push(new zt(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.pluginMap.clear(),this.inputState.ensureHandlers(this)}else for(let n of this.plugins)n.mustUpdate=t;for(let n=0;n<this.plugins.length;n++)this.plugins[n].update(this)}measure(t=!0){if(this.destroyed)return;this.measureScheduled>-1&&cancelAnimationFrame(this.measureScheduled),this.measureScheduled=0,t&&this.observer.flush();let e=null;try{for(let t=0;;t++){this.updateState=1;let n=this.viewport,s=this.viewState.measure(this);if(!s&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(t>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let r=[];4&s||([this.measureRequests,r]=[r,this.measureRequests]);let o=r.map((t=>{try{return t.read(this)}catch(e){return Lt(this.state,e),pn}})),l=new Gt(this,this.state),h=!1,a=!1;l.flags|=s,e?e.flags|=s:e=l,this.updateState=2,l.empty||(this.updatePlugins(l),this.inputState.update(l),this.updateAttrs(),h=this.docView.update(l));for(let t=0;t<r.length;t++)if(o[t]!=pn)try{let e=r[t];e.write&&e.write(o[t],this)}catch(i){Lt(this.state,i)}if(this.viewState.scrollTarget&&(this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,a=!0),h&&this.docView.updateSelection(!0),this.viewport.from==n.from&&this.viewport.to==n.to&&!a&&0==this.measureRequests.length)break}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let n of this.state.facet(Dt))n(e)}get themeClasses(){return _i+" "+(this.state.facet(Ki)?Ui:Gi)+" "+this.state.facet($i)}updateAttrs(){let t=mn(this,qt,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(Pt)?"true":"false",class:"cm-content",style:`${G.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),mn(this,jt,e),this.observer.ignore((()=>{lt(this.contentDOM,this.contentAttrs,e),lt(this.dom,this.editorAttrs,t)})),this.editorAttrs=t,this.contentAttrs=e}showAnnouncements(t){let e=!0;for(let i of t)for(let t of i.effects)if(t.is(hn.announce)){e&&(this.announceDOM.textContent=""),e=!1;let i=this.announceDOM.appendChild(document.createElement("div"));i.textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(Kt),r.V.mount(this.root,this.styleModules.concat(Yi).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(!1)}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){let e=this.pluginMap.get(t);return(void 0===e||e&&e.spec!=t)&&this.pluginMap.set(t,e=this.plugins.find((e=>e.spec==t))||null),e&&e.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}blockAtHeight(t,e){let i=cn(e,this);return this.elementAtHeight(t-i).moveY(i)}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}visualLineAtHeight(t,e){let i=cn(e,this);return this.lineBlockAtHeight(t-i).moveY(i)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}viewportLines(t,e){let i=cn(e,this);for(let n of this.viewportLineBlocks)t(n.moveY(i))}get viewportLineBlocks(){return this.viewState.viewportLines}visualLineAt(t,e=0){return this.lineBlockAt(t).moveY(e+this.viewState.paddingTop)}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return We(this,t,Ve(this,t,e,i))}moveByGroup(t,e){return We(this,t,Ve(this,t,e,(e=>Ie(this,t.head,e))))}moveToLineBoundary(t,e,i=!0){return Ne(this,t,e,i)}moveVertically(t,e,i){return We(this,t,He(this,t,e,i))}scrollPosIntoView(t){this.dispatch({effects:Ot.of(n.jT.cursor(t))})}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){return this.readMeasured(),Re(this,t,e)}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),r=s[se.find(s,t-n.from,-1,e)];return v(i,r.dir==Ut.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>an)return le(t.length);let e=this.textDirection;for(let n of this.bidiCache)if(n.from==t.from&&n.dir==e)return n.order;let i=oe(t.text,this.textDirection);return this.bidiCache.push(new gn(t.from,t.to,e,i)),i}get hasFocus(){var t;return(document.hasFocus()||G.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{A(this.contentDOM),this.docView.updateSelection()}))}destroy(){for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return Rt.of(new Bt("number"==typeof t?n.jT.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}static domEventHandlers(t){return Wt.define((()=>({})),{eventHandlers:t})}static theme(t,e){let i=r.V.newName(),n=[$i.of(i),Kt.of(Ji(`.${i}`,t))];return e&&e.dark&&n.push(Ki.of(!0)),n}static baseTheme(t){return n.Wl.lowest(Kt.of(Ji("."+_i,t,Xi)))}}hn.scrollTo=Ot,hn.centerOn=Et,hn.styleModule=Kt,hn.inputHandler=Tt,hn.exceptionSink=Ct,hn.updateListener=Dt,hn.editable=Pt,hn.mouseSelectionStyle=Mt,hn.dragMovesSelection=At,hn.clickAddsSelectionRange=St,hn.decorations=$t,hn.darkTheme=Ki,hn.contentAttributes=jt,hn.editorAttributes=qt,hn.lineWrapping=hn.contentAttributes.of({class:"cm-lineWrapping"}),hn.announce=n.Py.define();const an=4096;function cn(t,e){return(null==t?e.contentDOM.getBoundingClientRect().top:t)+e.viewState.paddingTop}let un=-1;function dn(){window.addEventListener("resize",(()=>{-1==un&&(un=setTimeout(fn,50))}))}function fn(){un=-1;let t=document.querySelectorAll(".cm-content");for(let e=0;e<t.length;e++){let i=B.get(t[e]);i&&i.editorView.requestMeasure()}}const pn={};class gn{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:Ut.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 gn(e.mapPos(r.from,1),e.mapPos(r.to,-1),r.dir,r.order))}return i}}function mn(t,e,i){for(let n=t.state.facet(e),s=n.length-1;s>=0;s--){let e=n[s],r="function"==typeof e?e(t):e;r&&rt(r,i)}return i}const wn=G.mac?"mac":G.windows?"win":G.linux?"linux":"key";function vn(t,e){const i=t.split(/-(?!$)/);let n,s,r,o,l=i[i.length-1];"Space"==l&&(l=" ");for(let h=0;h<i.length-1;++h){const t=i[h];if(/^(cmd|meta|m)$/i.test(t))o=!0;else if(/^a(lt)?$/i.test(t))n=!0;else if(/^(c|ctrl|control)$/i.test(t))s=!0;else if(/^s(hift)?$/i.test(t))r=!0;else{if(!/^mod$/i.test(t))throw new Error("Unrecognized modifier name: "+t);"mac"==e?o=!0:s=!0}}return n&&(l="Alt-"+l),s&&(l="Ctrl-"+l),o&&(l="Meta-"+l),r&&(l="Shift-"+l),l}function yn(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 bn=hn.domEventHandlers({keydown(t,e){return Tn(Sn(e.state),t,e,"editor")}}),xn=n.r$.define({enables:bn}),kn=new WeakMap;function Sn(t){let e=t.facet(xn),i=kn.get(e);return i||kn.set(e,i=Dn(e.reduce(((t,e)=>t.concat(e)),[]))),i}function An(t,e,i){return Tn(Sn(t.state),e,t,i)}let Mn=null;const Cn=4e3;function Dn(t,e=wn){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 l=i[t]||(i[t]=Object.create(null)),h=n.split(/ (?!$)/).map((t=>vn(t,e)));for(let e=1;e<h.length;e++){let i=h.slice(0,e).join(" ");s(i,!0),l[i]||(l[i]={preventDefault:!0,commands:[e=>{let n=Mn={view:e,prefix:i,scope:t};return setTimeout((()=>{Mn==n&&(Mn=null)}),Cn),!0}]})}let a=h.join(" ");s(a,!1);let c=l[a]||(l[a]={preventDefault:!1,commands:[]});c.commands.push(r),o&&(c.preventDefault=!0)};for(let o of t){let t=o[e]||o.key;if(t)for(let e of o.scope?o.scope.split(" "):["editor"])r(e,t,o.run,o.preventDefault),o.shift&&r(e,"Shift-"+t,o.shift,o.preventDefault)}return i}function Tn(t,e,i,n){let s=(0,l.YG)(e),r=1==s.length&&" "!=s,o="",h=!1;Mn&&Mn.view==i&&Mn.scope==n&&(o=Mn.prefix+" ",(h=qe.indexOf(e.keyCode)<0)&&(Mn=null));let a,c=t=>{if(t){for(let e of t.commands)if(e(i))return!0;t.preventDefault&&(h=!0)}return!1},u=t[n];if(u){if(c(u[o+yn(s,e,!r)]))return!0;if(r&&(e.shiftKey||e.altKey||e.metaKey)&&(a=l.ue[e.keyCode])&&a!=s){if(c(u[o+yn(a,e,!0)]))return!0}else if(r&&e.shiftKey&&c(u[o+yn(s,e,!0)]))return!0}return h}const On=!G.ios,En=n.r$.define({combine(t){return(0,n.BO)(t,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,e)=>Math.min(t,e),drawRangeCursor:(t,e)=>t||e})}});function Bn(t={}){return[En.of(t),Ln,Nn]}class Rn{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 Ln=Wt.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(En).cursorBlinkRate+"ms"}update(t){let e=t.startState.facet(En)!=t.state.facet(En);(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(En),i=t.selection.ranges.map((t=>t.empty?[]:Wn(this.view,t))).reduce(((t,e)=>t.concat(e))),n=[];for(let s of t.selection.ranges){let i=s==t.selection.main;if(s.empty?!i||On:e.drawRangeCursor){let t=Fn(this.view,s,i);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()}}),Pn={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};On&&(Pn[".cm-line"].caretColor="transparent !important");const Nn=n.Wl.highest(hn.theme(Pn));function Vn(t){let e=t.scrollDOM.getBoundingClientRect(),i=t.textDirection==Ut.LTR?e.left:e.right-t.scrollDOM.clientWidth;return{left:i-t.scrollDOM.scrollLeft,top:e.top-t.scrollDOM.scrollTop}}function In(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),type:at.Text}}function Hn(t,e){let i=t.lineBlockAt(e);if(Array.isArray(i.type))for(let n of i.type)if(n.to>e||n.to==e&&(n.to==i.to||n.type==at.Text))return n;return i}function Wn(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==Ut.LTR,r=t.contentDOM,o=r.getBoundingClientRect(),l=Vn(t),h=window.getComputedStyle(r.firstChild),a=o.left+parseInt(h.paddingLeft)+Math.min(0,parseInt(h.textIndent)),c=o.right-parseInt(h.paddingRight),u=Hn(t,i),d=Hn(t,n),f=u.type==at.Text?u:null,p=d.type==at.Text?d:null;if(t.lineWrapping&&(f&&(f=In(t,i,f)),p&&(p=In(t,n,p))),f&&p&&f.from==p.from)return m(w(e.from,e.to,f));{let i=f?w(e.from,null,f):v(u,!1),n=p?w(null,e.to,p):v(d,!0),s=[];return(f||u).to<(p||d).from-1?s.push(g(a,i.bottom,c,n.top)):i.bottom<n.top&&t.elementAtHeight((i.bottom+n.top)/2).type==at.Text&&(i.bottom=n.top=(i.bottom+n.top)/2),m(i).concat(s).concat(m(n))}function g(t,e,i,n){return new Rn(t-l.left,e-l.top-.01,i-t,n-e+.01,"cm-selectionBackground")}function m({top:t,bottom:e,horizontal:i}){let n=[];for(let s=0;s<i.length;s+=2)n.push(g(i[s],t,i[s+1],e));return n}function w(e,i,n){let r=1e9,o=-1e9,l=[];function h(e,i,h,u,d){let f=t.coordsAtPos(e,e==n.to?-2:2),p=t.coordsAtPos(h,h==n.from?2:-2);r=Math.min(f.top,p.top,r),o=Math.max(f.bottom,p.bottom,o),d==Ut.LTR?l.push(s&&i?a:f.left,s&&u?c:p.right):l.push(!s&&u?a:p.left,!s&&i?c:f.right)}let u=null!==e&&void 0!==e?e:n.from,d=null!==i&&void 0!==i?i:n.to;for(let s of t.visibleRanges)if(s.to>u&&s.from<d)for(let n=Math.max(s.from,u),r=Math.min(s.to,d);;){let s=t.state.doc.lineAt(n);for(let o of t.bidiSpans(s)){let t=o.from+s.from,l=o.to+s.from;if(t>=r)break;l>n&&h(Math.max(t,n),null==e&&t<=u,Math.min(l,r),null==i&&l>=d,o.dir)}if(n=s.to+1,n>=r)break}return 0==l.length&&h(u,null==e,d,null==i,t.textDirection),{top:r,bottom:o,horizontal:l}}function v(t,e){let i=o.top+(e?t.top:t.bottom);return{top:i,bottom:i,horizontal:[]}}}function Fn(t,e,i){let n=t.coordsAtPos(e.head,e.assoc||1);if(!n)return null;let s=Vn(t);return new Rn(n.left-s.left,n.top-s.top,-1,n.bottom-n.top,i?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary")}const zn=n.Py.define({map(t,e){return null==t?null:e.mapPos(t)}}),qn=n.QQ.define({create(){return null},update(t,e){return null!=t&&(t=e.changes.mapPos(t)),e.effects.reduce(((t,e)=>e.is(zn)?e.value:t),t)}}),jn=Wt.fromClass(class{constructor(t){this.view=t,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(t){var e;let i=t.state.field(qn);null==i?null!=this.cursor&&(null===(e=this.cursor)||void 0===e||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(t.startState.field(qn)!=i||t.docChanged||t.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let t=this.view.state.field(qn),e=null!=t&&this.view.coordsAtPos(t);if(!e)return null;let i=this.view.scrollDOM.getBoundingClientRect();return{left:e.left-i.left+this.view.scrollDOM.scrollLeft,top:e.top-i.top+this.view.scrollDOM.scrollTop,height:e.bottom-e.top}}drawCursor(t){this.cursor&&(t?(this.cursor.style.left=t.left+"px",this.cursor.style.top=t.top+"px",this.cursor.style.height=t.height+"px"):this.cursor.style.left="-100000px")}destroy(){this.cursor&&this.cursor.remove()}setDropPos(t){this.view.state.field(qn)!=t&&this.view.dispatch({effects:zn.of(t)})}},{eventHandlers:{dragover(t){this.setDropPos(this.view.posAtCoords({x:t.clientX,y:t.clientY}))},dragleave(t){t.target!=this.view.contentDOM&&this.view.contentDOM.contains(t.relatedTarget)||this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function $n(){return[qn,jn]}function Kn(t,e,i,n,s){e.lastIndex=0;for(let r,o=t.iterRange(i,n),l=i;!o.next().done;l+=o.value.length)if(!o.lineBreak)while(r=e.exec(o.value))s(l+r.index,l+r.index+r[0].length,r)}function _n(t,e){let i=t.visibleRanges;if(1==i.length&&i[0].from==t.viewport.from&&i[0].to==t.viewport.to)return i;let n=[];for(let{from:s,to:r}of i)s=Math.max(t.state.doc.lineAt(s).from,s-e),r=Math.min(t.state.doc.lineAt(r).to,r+e),n.length&&n[n.length-1].to>=s?n[n.length-1].to=r:n.push({from:s,to:r});return n}class Gn{constructor(t){let{regexp:e,decoration:i,boundary:n,maxLength:s=1e3}=t;if(!e.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");this.regexp=e,this.getDeco="function"==typeof i?i:()=>i,this.boundary=n,this.maxLength=s}createDeco(t){let e=new o.f_;for(let{from:i,to:n}of _n(t,this.maxLength))Kn(t.state.doc,this.regexp,i,n,((i,n,s)=>e.add(i,n,this.getDeco(s,t,i))));return e.finish()}updateDeco(t,e){let i=1e9,n=-1;return t.docChanged&&t.changes.iterChanges(((e,s,r,o)=>{o>t.view.viewport.from&&r<t.view.viewport.to&&(i=Math.min(r,i),n=Math.max(o,n))})),t.viewportChanged||n-i>1e3?this.createDeco(t.view):n>-1?this.updateRange(t.view,e.map(t.changes),i,n):e}updateRange(t,e,i,n){for(let s of t.visibleRanges){let r=Math.max(s.from,i),o=Math.min(s.to,n);if(o>r){let i=t.state.doc.lineAt(r),n=i.to<o?t.state.doc.lineAt(o):i,l=Math.max(s.from,i.from),h=Math.min(s.to,n.to);if(this.boundary){for(;r>i.from;r--)if(this.boundary.test(i.text[r-1-i.from])){l=r;break}for(;o<n.to;o++)if(this.boundary.test(n.text[o-n.from])){h=o;break}}let a,c=[];if(i==n){this.regexp.lastIndex=l-i.from;while((a=this.regexp.exec(i.text))&&a.index<h-i.from){let e=a.index+i.from;c.push(this.getDeco(a,t,e).range(e,e+a[0].length))}}else Kn(t.state.doc,this.regexp,l,h,((e,i,n)=>c.push(this.getDeco(n,t,e).range(e,i))));e=e.update({filterFrom:l,filterTo:h,filter:(t,e)=>t<l||e>h,add:c})}}return e}}const Un=null!=/x/.unicode?"gu":"g",Xn=new RegExp("[\0-\b\n--\u2028\u2029\ufeff-]",Un),Jn={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let Yn=null;function Qn(){var t;if(null==Yn&&"undefined"!=typeof document&&document.body){let e=document.body.style;Yn=null!=(null!==(t=e.tabSize)&&void 0!==t?t:e.MozTabSize)}return Yn||!1}const Zn=n.r$.define({combine(t){let e=(0,n.BO)(t,{render:null,specialChars:Xn,addSpecialChars:null});return(e.replaceTabs=!Qn())&&(e.specialChars=new RegExp("\t|"+e.specialChars.source,Un)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,Un)),e}});function ts(t={}){return[Zn.of(t),is()]}let es=null;function is(){return es||(es=Wt.fromClass(class{constructor(t){this.view=t,this.decorations=ct.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(t.state.facet(Zn)),this.decorations=this.decorator.createDeco(t)}makeDecorator(t){return new Gn({regexp:t.specialChars,decoration:(e,i,n)=>{let{doc:r}=i.state,o=(0,s.gm)(e[0],0);if(9==o){let t=r.lineAt(n),e=i.state.tabSize,o=(0,s.IS)(t.text,e,n-t.from);return ct.replace({widget:new os((e-o%e)*this.view.defaultCharacterWidth)})}return this.decorationCache[o]||(this.decorationCache[o]=ct.replace({widget:new rs(t,o)}))},boundary:t.replaceTabs?void 0:/[^]/})}update(t){let e=t.state.facet(Zn);t.startState.facet(Zn)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(t.view)):this.decorations=this.decorator.updateDeco(t,this.decorations)}},{decorations:t=>t.decorations}))}const ns="•";function ss(t){return t>=32?ns:10==t?"":String.fromCharCode(9216+t)}class rs extends ht{constructor(t,e){super(),this.options=t,this.code=e}eq(t){return t.code==this.code}toDOM(t){let e=ss(this.code),i=t.state.phrase("Control character")+" "+(Jn[this.code]||"0x"+this.code.toString(16)),n=this.options.render&&this.options.render(this.code,i,e);if(n)return n;let s=document.createElement("span");return s.textContent=e,s.title=i,s.setAttribute("aria-label",i),s.className="cm-specialChar",s}ignoreEvent(){return!1}}class os extends ht{constructor(t){super(),this.width=t}eq(t){return t.width==this.width}toDOM(){let t=document.createElement("span");return t.textContent="\t",t.className="cm-tab",t.style.width=this.width+"px",t}ignoreEvent(){return!1}}function ls(){return as}const hs=ct.line({class:"cm-activeLine"}),as=Wt.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 ct.none;let s=t.lineBlockAt(n.head);s.from>e&&(i.push(hs.range(s.from)),e=s.from)}return ct.set(i)}},{decorations:t=>t.decorations})},17918:function(t,e,i){i.d(e,{L3:function(){return n},md:function(){return o},Lj:function(){return c},Jq:function(){return a},_b:function(){return E},mp:function(){return f},i9:function(){return O},FE:function(){return R}});const n=1024;let s=0;class r{constructor(t,e){this.from=t,this.to=e}}class o{constructor(t={}){this.id=s++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=a.match(t)),e=>{let i=t(e);return void 0===i?null:[this,i]}}}o.closedBy=new o({deserialize:t=>t.split(" ")}),o.openedBy=new o({deserialize:t=>t.split(" ")}),o.group=new o({deserialize:t=>t.split(" ")}),o.contextHash=new o({perNode:!0}),o.lookAhead=new o({perNode:!0}),o.mounted=new o({perNode:!0});class l{constructor(t,e,i){this.tree=t,this.overlay=e,this.parser=i}}const h=Object.create(null);class a{constructor(t,e,i,n=0){this.name=t,this.props=e,this.id=i,this.flags=n}static define(t){let e=t.props&&t.props.length?Object.create(null):h,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=new a(t.name||"",e,t.id,i);if(t.props)for(let s of t.props)if(Array.isArray(s)||(s=s(n)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[s[0].id]=s[1]}return n}prop(t){return this.props[t.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(t){if("string"==typeof t){if(this.name==t)return!0;let e=this.prop(o.group);return!!e&&e.indexOf(t)>-1}return this.id==t}static match(t){let e=Object.create(null);for(let i in t)for(let n of i.split(" "))e[n]=t[i];return t=>{for(let i=t.prop(o.group),n=-1;n<(i?i.length:0);n++){let s=e[n<0?t.name:i[n]];if(s)return s}}}}a.none=new a("",Object.create(null),0,8);class c{constructor(t){this.types=t;for(let e=0;e<t.length;e++)if(t[e].id!=e)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let e=[];for(let i of this.types){let n=null;for(let e of t){let t=e(i);t&&(n||(n=Object.assign({},i.props)),n[t[0].id]=t[1])}e.push(n?new a(i.name,n,i.id,i.flags):i)}return new c(e)}}const u=new WeakMap,d=new WeakMap;class f{constructor(t,e,i,n,s){if(this.type=t,this.children=e,this.positions=i,this.length=n,this.props=null,s&&s.length){this.props=Object.create(null);for(let[t,e]of s)this.props["number"==typeof t?t:t.id]=e}}toString(){let t=this.prop(o.mounted);if(t&&!t.overlay)return t.tree.toString();let e="";for(let i of this.children){let t=i.toString();t&&(e&&(e+=","),e+=t)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t,e=0){let i=null!=t&&u.get(this)||this.topNode,n=new S(i);return null!=t&&(n.moveTo(t,e),u.set(this,n._tree)),n}fullCursor(){return new S(this.topNode,1)}get topNode(){return new y(this,0,0,null)}resolve(t,e=0){let i=v(u.get(this)||this.topNode,t,e,!1);return u.set(this,i),i}resolveInner(t,e=0){let i=v(d.get(this)||this.topNode,t,e,!0);return d.set(this,i),i}iterate(t){let{enter:e,leave:i,from:n=0,to:s=this.length}=t;for(let r=this.cursor(),o=()=>r.node;;){let t=!1;if(r.from<=s&&r.to>=n&&(r.type.isAnonymous||!1!==e(r.type,r.from,r.to,o))){if(r.firstChild())continue;r.type.isAnonymous||(t=!0)}for(;;){if(t&&i&&i(r.type,r.from,r.to,o),t=r.type.isAnonymous,r.nextSibling())break;if(!r.parent())return;t=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:T(a.none,this.children,this.positions,0,this.children.length,0,this.length,((t,e,i)=>new f(this.type,t,e,i,this.propValues)),t.makeTree||((t,e,i)=>new f(a.none,t,e,i)))}static build(t){return M(t)}}f.empty=new f(a.none,[],[],0);class p{constructor(t,e){this.buffer=t,this.index=e}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new p(this.buffer,this.index)}}class g{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return a.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],i=this.buffer[t+3],n=this.set.types[e],s=n.name;if(/\W/.test(s)&&!n.isError&&(s=JSON.stringify(s)),t+=4,i==t)return s;let r=[];while(t<i)r.push(this.childString(t)),t=this.buffer[t+3];return s+"("+r.join(",")+")"}findChild(t,e,i,n,s){let{buffer:r}=this,o=-1;for(let l=t;l!=e;l=r[l+3])if(m(s,n,r[l+1],r[l+2])&&(o=l,i>0))break;return o}slice(t,e,i,n){let s=this.buffer,r=new Uint16Array(e-t);for(let o=t,l=0;o<e;)r[l++]=s[o++],r[l++]=s[o++]-i,r[l++]=s[o++]-i,r[l++]=s[o++]-t;return new g(r,n-i,this.set)}}function m(t,e,i,n){switch(t){case-2:return i<e;case-1:return n>=e&&i<e;case 0:return i<e&&n>e;case 1:return i<=e&&n>e;case 2:return n>e;case 4:return!0}}function w(t,e){let i=t.childBefore(e);while(i){let e=i.lastChild;if(!e||e.to!=i.to)break;e.type.isError&&e.from==e.to?(t=i,i=e.prevSibling):i=e}return t}function v(t,e,i,n){var s;while(t.from==t.to||(i<1?t.from>=e:t.from>e)||(i>-1?t.to<=e:t.to<e)){let e=!n&&t instanceof y&&t.index<0?null:t.parent;if(!e)return t;t=e}if(n)for(let r=t,o=r.parent;o;r=o,o=r.parent)r instanceof y&&r.index<0&&(null===(s=o.enter(e,i,!0))||void 0===s?void 0:s.from)!=r.from&&(t=o);for(;;){let s=t.enter(e,i,n);if(!s)return t;t=s}}class y{constructor(t,e,i,n){this.node=t,this._from=e,this.index=i,this._parent=n}get type(){return this.node.type}get name(){return this.node.type.name}get from(){return this._from}get to(){return this._from+this.node.length}nextChild(t,e,i,n,s=0){for(let r=this;;){for(let{children:l,positions:h}=r.node,a=e>0?l.length:-1;t!=a;t+=e){let a=l[t],c=h[t]+r._from;if(m(n,i,c,c+a.length))if(a instanceof g){if(2&s)continue;let o=a.findChild(0,a.buffer.length,e,i-c,n);if(o>-1)return new k(new x(r,a,t,c),null,o)}else if(1&s||!a.type.isAnonymous||A(a)){let l;if(!(1&s)&&a.props&&(l=a.prop(o.mounted))&&!l.overlay)return new y(l.tree,c,t,r);let h=new y(a,c,t,r);return 1&s||!h.type.isAnonymous?h:h.nextChild(e<0?a.children.length-1:0,e,i,n)}}if(1&s||!r.type.isAnonymous)return null;if(t=r.index>=0?r.index+e:e<0?-1:r._parent.node.children.length,r=r._parent,!r)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this.node.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this.node.children.length-1,-1,t,-2)}enter(t,e,i=!0,n=!0){let s;if(i&&(s=this.node.prop(o.mounted))&&s.overlay){let i=t-this.from;for(let{from:t,to:n}of s.overlay)if((e>0?t<=i:t<i)&&(e<0?n>=i:n>i))return new y(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,n?0:2)}nextSignificantParent(){let t=this;while(t.type.isAnonymous&&t._parent)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get cursor(){return new S(this)}get tree(){return this.node}toTree(){return this.node}resolve(t,e=0){return v(this,t,e,!1)}resolveInner(t,e=0){return v(this,t,e,!0)}enterUnfinishedNodesBefore(t){return w(this,t)}getChild(t,e=null,i=null){let n=b(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return b(this,t,e,i)}toString(){return this.node.toString()}}function b(t,e,i,n){let s=t.cursor,r=[];if(!s.firstChild())return r;if(null!=i)while(!s.type.is(i))if(!s.nextSibling())return r;for(;;){if(null!=n&&s.type.is(n))return r;if(s.type.is(e)&&r.push(s.node),!s.nextSibling())return null==n?r:[]}}class x{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}}class k{constructor(t,e,i){this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}child(t,e,i){let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.context.start,i);return s<0?null:new k(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}enter(t,e,i,n=!0){if(!n)return null;let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return r<0?null:new k(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new k(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new k(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get cursor(){return new S(this)}get tree(){return null}toTree(){let t=[],e=[],{buffer:i}=this.context,n=this.index+4,s=i.buffer[this.index+3];if(s>n){let r=i.buffer[this.index+1],o=i.buffer[this.index+2];t.push(i.slice(n,s,r,o)),e.push(0)}return new f(this.type,t,e,this.to-this.from)}resolve(t,e=0){return v(this,t,e,!1)}resolveInner(t,e=0){return v(this,t,e,!0)}enterUnfinishedNodesBefore(t){return w(this,t)}toString(){return this.context.buffer.childString(this.index)}getChild(t,e=null,i=null){let n=b(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return b(this,t,e,i)}}class S{constructor(t,e=0){if(this.mode=e,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof y)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let e=t._parent;e;e=e._parent)this.stack.unshift(e.index);this.bufferNode=t,this.yieldBuf(t.index)}}get name(){return this.type.name}yieldNode(t){return!!t&&(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0)}yieldBuf(t,e){this.index=t;let{start:i,buffer:n}=this.buffer;return this.type=e||n.set.types[n.buffer[t]],this.from=i+n.buffer[t+1],this.to=i+n.buffer[t+2],!0}yield(t){return!!t&&(t instanceof y?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,i){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree.node.children.length-1:0,t,e,i,this.mode));let{buffer:n}=this.buffer,s=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.buffer.start,i);return!(s<0)&&(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,i=!0,n=!0){return this.buffer?!!n&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i&&!(1&this.mode),n))}parent(){if(!this.buffer)return this.yieldNode(1&this.mode?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=1&this.mode?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode));let{buffer:e}=this.buffer,i=this.stack.length-1;if(t<0){let t=i<0?0:this.stack[i]+4;if(this.index!=t)return this.yieldBuf(e.findChild(t,this.index,-1,0,4))}else{let t=e.buffer[this.index+3];if(t<(i<0?e.buffer.length:e.buffer[this.stack[i]+3]))return this.yieldBuf(t)}return i<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,i,{buffer:n}=this;if(n){if(t>0){if(this.index<n.buffer.buffer.length)return!1}else for(let t=0;t<this.index;t++)if(n.buffer.buffer[t+3]<this.index)return!1;({index:e,parent:i}=n)}else({index:e,_parent:i}=this._tree);for(;i;({index:e,_parent:i}=i))if(e>-1)for(let n=e+t,s=t<0?-1:i.node.children.length;n!=s;n+=t){let t=i.node.children[n];if(1&this.mode||t instanceof g||!t.type.isAnonymous||A(t))return!1}return!0}move(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){while(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))if(!this.parent())break;while(this.enterChild(1,t,e));return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,i=0;if(t&&t.context==this.buffer)t:for(let n=this.index,s=this.stack.length;s>=0;){for(let r=t;r;r=r._parent)if(r.index==n){if(n==this.index)return r;e=r,i=s+1;break t}n=this.stack[--s]}for(let n=i;n<this.stack.length;n++)e=new k(this.buffer,e,this.stack[n]);return this.bufferNode=new k(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree.node}}function A(t){return t.children.some((t=>t instanceof g||!t.type.isAnonymous||A(t)))}function M(t){var e;let{buffer:i,nodeSet:s,maxBufferLength:r=n,reused:l=[],minRepeatType:h=s.types.length}=t,a=Array.isArray(i)?new p(i,i.length):i,c=s.types,u=0,d=0;function m(t,e,i,n,o){let{id:f,start:p,end:k,size:S}=a,A=d;while(S<0){if(a.next(),-1==S){let e=l[f];return i.push(e),void n.push(p-t)}if(-3==S)return void(u=f);if(-4==S)return void(d=f);throw new RangeError(`Unrecognized record size: ${S}`)}let M,C,D=c[f],O=p-t;if(k-p<=r&&(C=b(a.pos-e,o))){let e=new Uint16Array(C.size-C.skip),i=a.pos-C.size,n=e.length;while(a.pos>i)n=x(C.start,e,n);M=new g(e,k-C.start,s),O=C.start-t}else{let t=a.pos-S;a.next();let e=[],i=[],n=f>=h?f:-1,s=0,o=k;while(a.pos>t)n>=0&&a.id==n&&a.size>=0?(a.end<=o-r&&(v(e,i,p,s,a.end,o,n,A),s=e.length,o=a.end),a.next()):m(p,t,e,i,n);if(n>=0&&s>0&&s<e.length&&v(e,i,p,s,p,o,n,A),e.reverse(),i.reverse(),n>-1&&s>0){let t=w(D);M=T(D,e,i,0,e.length,0,k-p,t,t)}else M=y(D,e,i,k-p,A-k)}i.push(M),n.push(O)}function w(t){return(e,i,n)=>{let s,r,l=0,h=e.length-1;if(h>=0&&(s=e[h])instanceof f){if(!h&&s.type==t&&s.length==n)return s;(r=s.prop(o.lookAhead))&&(l=i[h]+s.length+r)}return y(t,e,i,n,l)}}function v(t,e,i,n,r,o,l,h){let a=[],c=[];while(t.length>n)a.push(t.pop()),c.push(e.pop()+i-r);t.push(y(s.types[l],a,c,o-r,h-o)),e.push(r-i)}function y(t,e,i,n,s=0,r){if(u){let t=[o.contextHash,u];r=r?[t].concat(r):[t]}if(s>25){let t=[o.lookAhead,s];r=r?[t].concat(r):[t]}return new f(t,e,i,n,r)}function b(t,e){let i=a.fork(),n=0,s=0,o=0,l=i.end-r,c={size:0,start:0,skip:0};t:for(let r=i.pos-t;i.pos>r;){let t=i.size;if(i.id==e&&t>=0){c.size=n,c.start=s,c.skip=o,o+=4,n+=4,i.next();continue}let a=i.pos-t;if(t<0||a<r||i.start<l)break;let u=i.id>=h?4:0,d=i.start;i.next();while(i.pos>a){if(i.size<0){if(-3!=i.size)break t;u+=4}else i.id>=h&&(u+=4);i.next()}s=d,n+=t,o+=u}return(e<0||n==t)&&(c.size=n,c.start=s,c.skip=o),c.size>4?c:void 0}function x(t,e,i){let{id:n,start:s,end:r,size:o}=a;if(a.next(),o>=0&&n<h){let l=i;if(o>4){let n=a.pos-(o-4);while(a.pos>n)i=x(t,e,i)}e[--i]=l,e[--i]=r-t,e[--i]=s-t,e[--i]=n}else-3==o?u=n:-4==o&&(d=n);return i}let k=[],S=[];while(a.pos>0)m(t.start||0,t.bufferStart||0,k,S,-1);let A=null!==(e=t.length)&&void 0!==e?e:k.length?S[0]+k[0].length:0;return new f(c[t.topID],k.reverse(),S.reverse(),A)}const C=new WeakMap;function D(t,e){if(!t.isAnonymous||e instanceof g||e.type!=t)return 1;let i=C.get(e);if(null==i){i=1;for(let n of e.children){if(n.type!=t||!(n instanceof f)){i=1;break}i+=D(t,n)}C.set(e,i)}return i}function T(t,e,i,n,s,r,o,l,h){let a=0;for(let p=n;p<s;p++)a+=D(t,e[p]);let c=Math.ceil(1.5*a/8),u=[],d=[];function f(e,i,n,s,o){for(let l=n;l<s;){let n=l,a=i[l],p=D(t,e[l]);for(l++;l<s;l++){let i=D(t,e[l]);if(p+i>=c)break;p+=i}if(l==n+1){if(p>c){let t=e[n];f(t.children,t.positions,0,t.children.length,i[n]+o);continue}u.push(e[n])}else{let s=i[l-1]+e[l-1].length-a;u.push(T(t,e,i,n,l,a,s,null,h))}d.push(a+o-r)}}return f(e,i,n,s,0),(l||h)(u,d,o)}class O{constructor(t,e,i,n,s=!1,r=!1){this.from=t,this.to=e,this.tree=i,this.offset=n,this.open=(s?1:0)|(r?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(t,e=[],i=!1){let n=[new O(0,t.length,t,0,!1,i)];for(let s of e)s.to>t.length&&n.push(s);return n}static applyChanges(t,e,i=128){if(!e.length)return t;let n=[],s=1,r=t.length?t[0]:null;for(let o=0,l=0,h=0;;o++){let a=o<e.length?e[o]:null,c=a?a.fromA:1e9;if(c-l>=i)while(r&&r.from<c){let e=r;if(l>=e.from||c<=e.to||h){let t=Math.max(e.from,l)-h,i=Math.min(e.to,c)-h;e=t>=i?null:new O(t,i,e.tree,e.offset+h,o>0,!!a)}if(e&&n.push(e),r.to>c)break;r=s<t.length?t[s++]:null}if(!a)break;l=a.toA,h=a.toA-a.toB}return n}}class E{startParse(t,e,i){return"string"==typeof t&&(t=new B(t)),i=i?i.length?i.map((t=>new r(t.from,t.to))):[new r(0,0)]:[new r(0,t.length)],this.createParse(t,e||[],i)}parse(t,e,i){let n=this.startParse(t,e,i);for(;;){let t=n.advance();if(t)return t}}}class B{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}}function R(t){return(e,i,n,s)=>new V(e,t,i,n,s)}class L{constructor(t,e,i,n,s){this.parser=t,this.parse=e,this.overlay=i,this.target=n,this.ranges=s}}class P{constructor(t,e,i,n,s,r,o){this.parser=t,this.predicate=e,this.mounts=i,this.index=n,this.start=s,this.target=r,this.prev=o,this.depth=0,this.ranges=[]}}const N=new o({perNode:!0});class V{constructor(t,e,i,n,s){this.nest=e,this.input=i,this.fragments=n,this.ranges=s,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=t}advance(){if(this.baseParse){let t=this.baseParse.advance();if(!t)return null;if(this.baseParse=null,this.baseTree=t,this.startInner(),null!=this.stoppedAt)for(let e of this.inner)e.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let t=this.baseTree;return null!=this.stoppedAt&&(t=new f(t.type,t.children,t.positions,t.length,t.propValues.concat([[N,this.stoppedAt]]))),t}let t=this.inner[this.innerDone],e=t.parse.advance();if(e){this.innerDone++;let i=Object.assign(Object.create(null),t.target.props);i[o.mounted.id]=new l(e,t.overlay,t.parser),t.target.props=i}return null}get parsedPos(){if(this.baseParse)return 0;let t=this.input.length;for(let e=this.innerDone;e<this.inner.length;e++)this.inner[e].ranges[0].from<t&&(t=Math.min(t,this.inner[e].parse.parsedPos));return t}stopAt(t){if(this.stoppedAt=t,this.baseParse)this.baseParse.stopAt(t);else for(let e=this.innerDone;e<this.inner.length;e++)this.inner[e].parse.stopAt(t)}startInner(){let t=new z(this.fragments),e=null,i=null,n=new S(new y(this.baseTree,this.ranges[0].from,0,null),1);t:for(let s,o;null==this.stoppedAt||n.from<this.stoppedAt;){let l,h=!0;if(t.hasNode(n)){if(e){let t=e.mounts.find((t=>t.frag.from<=n.from&&t.frag.to>=n.to&&t.mount.overlay));if(t)for(let i of t.mount.overlay){let s=i.from+t.pos,r=i.to+t.pos;s>=n.from&&r<=n.to&&e.ranges.push({from:s,to:r})}}h=!1}else if(i&&(o=I(i.ranges,n.from,n.to)))h=2!=o;else if(!n.type.isAnonymous&&n.from<n.to&&(s=this.nest(n,this.input))){n.tree||W(n);let o=t.findMounts(n.from,s.parser);if("function"==typeof s.overlay)e=new P(s.parser,s.overlay,o,this.inner.length,n.from,n.tree,e);else{let t=q(this.ranges,s.overlay||[new r(n.from,n.to)]);t.length&&this.inner.push(new L(s.parser,s.parser.startParse(this.input,$(o,t),t),s.overlay?s.overlay.map((t=>new r(t.from-n.from,t.to-n.from))):null,n.tree,t)),s.overlay?t.length&&(i={ranges:t,depth:0,prev:i}):h=!1}}else e&&(l=e.predicate(n))&&(!0===l&&(l=new r(n.from,n.to)),l.from<l.to&&e.ranges.push(l));if(h&&n.firstChild())e&&e.depth++,i&&i.depth++;else for(;;){if(n.nextSibling())break;if(!n.parent())break t;if(e&&!--e.depth){let t=q(this.ranges,e.ranges);t.length&&this.inner.splice(e.index,0,new L(e.parser,e.parser.startParse(this.input,$(e.mounts,t),t),e.ranges.map((t=>new r(t.from-e.start,t.to-e.start))),e.target,t)),e=e.prev}i&&!--i.depth&&(i=i.prev)}}}}function I(t,e,i){for(let n of t){if(n.from>=i)break;if(n.to>e)return n.from<=e&&n.to>=i?2:1}return 0}function H(t,e,i,n,s,r){if(e<i){let o=t.buffer[e+1],l=t.buffer[i-2];n.push(t.slice(e,i,o,l)),s.push(o-r)}}function W(t){let{node:e}=t,i=0;do{t.parent(),i++}while(!t.tree);let n=0,s=t.tree,r=0;for(;;n++)if(r=s.positions[n]+t.from,r<=e.from&&r+s.children[n].length>=e.to)break;let o=s.children[n],l=o.buffer;function h(t,i,n,s,a){let c=t;while(l[c+2]+r<=e.from)c=l[c+3];let u=[],d=[];H(o,t,c,u,d,s);let p=l[c+1],g=l[c+2],m=p+r==e.from&&g+r==e.to&&l[c]==e.type.id;return u.push(m?e.toTree():h(c+4,l[c+3],o.set.types[l[c]],p,g-p)),d.push(p-s),H(o,l[c+3],i,u,d,s),new f(n,u,d,a)}s.children[n]=h(0,l.length,a.none,0,o.length);for(let a=0;a<=i;a++)t.childAfter(e.from)}class F{constructor(t,e){this.offset=e,this.done=!1,this.cursor=t.fullCursor()}moveTo(t){let{cursor:e}=this,i=t-this.offset;while(!this.done&&e.from<i)e.to>=t&&e.enter(i,1,!1,!1)||e.next(!1)||(this.done=!0)}hasNode(t){if(this.moveTo(t.from),!this.done&&this.cursor.from+this.offset==t.from&&this.cursor.tree)for(let e=this.cursor.tree;;){if(e==t.tree)return!0;if(!(e.children.length&&0==e.positions[0]&&e.children[0]instanceof f))break;e=e.children[0]}return!1}}class z{constructor(t){var e;if(this.fragments=t,this.curTo=0,this.fragI=0,t.length){let i=this.curFrag=t[0];this.curTo=null!==(e=i.tree.prop(N))&&void 0!==e?e:i.to,this.inner=new F(i.tree,-i.offset)}else this.curFrag=this.inner=null}hasNode(t){while(this.curFrag&&t.from>=this.curTo)this.nextFrag();return this.curFrag&&this.curFrag.from<=t.from&&this.curTo>=t.to&&this.inner.hasNode(t)}nextFrag(){var t;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let e=this.curFrag=this.fragments[this.fragI];this.curTo=null!==(t=e.tree.prop(N))&&void 0!==t?t:e.to,this.inner=new F(e.tree,-e.offset)}}findMounts(t,e){var i;let n=[];if(this.inner){this.inner.cursor.moveTo(t,1);for(let t=this.inner.cursor.node;t;t=t.parent){let s=null===(i=t.tree)||void 0===i?void 0:i.prop(o.mounted);if(s&&s.parser==e)for(let e=this.fragI;e<this.fragments.length;e++){let i=this.fragments[e];if(i.from>=t.to)break;i.tree==this.curFrag.tree&&n.push({frag:i,pos:t.from-i.offset,mount:s})}}}return n}}function q(t,e){let i=null,n=e;for(let s=1,o=0;s<t.length;s++){let l=t[s-1].to,h=t[s].from;for(;o<n.length;o++){let t=n[o];if(t.from>=h)break;t.to<=l||(i||(n=i=e.slice()),t.from<l?(i[o]=new r(t.from,l),t.to>h&&i.splice(o+1,0,new r(h,t.to))):t.to>h?i[o--]=new r(h,t.to):i.splice(o--,1))}}return n}function j(t,e,i,n){let s=0,o=0,l=!1,h=!1,a=-1e9,c=[];for(;;){let u=s==t.length?1e9:l?t[s].to:t[s].from,d=o==e.length?1e9:h?e[o].to:e[o].from;if(l!=h){let t=Math.max(a,i),e=Math.min(u,d,n);t<e&&c.push(new r(t,e))}if(a=Math.min(u,d),1e9==a)break;u==a&&(l?(l=!1,s++):l=!0),d==a&&(h?(h=!1,o++):h=!0)}return c}function $(t,e){let i=[];for(let{pos:n,mount:s,frag:o}of t){let t=n+(s.overlay?s.overlay[0].from:0),l=t+s.tree.length,h=Math.max(o.from,t),a=Math.min(o.to,l);if(s.overlay){let l=s.overlay.map((t=>new r(t.from+n,t.to+n))),c=j(e,l,h,a);for(let e=0,n=h;;e++){let r=e==c.length,l=r?a:c[e].from;if(l>n&&i.push(new O(n,l,s.tree,-t,o.from>=n,o.to<=l)),r)break;n=c[e].to}}else i.push(new O(h,a,s.tree,-t,o.from>=t,o.to<=l))}return i}},70876:function(t,e,i){i.d(e,{V:function(){return l}});const n="ͼ",s="undefined"==typeof Symbol?"__"+n:Symbol.for(n),r="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class l{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 l=[],h=/^@(\w+)\b/.exec(t[0]),a=h&&"keyframes"==h[1];if(h&&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(!h)throw new RangeError("The value of a property ("+i+") should be a primitive value.");s(n(i),o,l,a)}else null!=o&&l.push(i.replace(/_.*/,"").replace(/[A-Z]/g,(t=>"-"+t.toLowerCase()))+": "+o+";")}(l.length||a)&&r.push((!i||h||o?t:t.map(i)).join(", ")+" {"+l.join(" ")+"}")}for(let r in t)s(n(r),t[r],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let t=o[s]||1;return o[s]=t+1,n+t.toString(36)}static mount(t,e){(t[r]||new a(t)).mount(Array.isArray(e)?e:[e])}}let h=null;class a{constructor(t){if(!t.head&&t.adoptedStyleSheets&&"undefined"!=typeof CSSStyleSheet){if(h)return t.adoptedStyleSheets=[h.sheet].concat(t.adoptedStyleSheets),t[r]=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[r]=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{while(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}}}},27510:function(t,e,i){i.d(e,{ue:function(){return n},YG:function(){return f}});for(var n={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"},s={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"},r="undefined"!=typeof navigator&&/Chrome\/(\d+)/.exec(navigator.userAgent),o="undefined"!=typeof navigator&&/Apple Computer/.test(navigator.vendor),l="undefined"!=typeof navigator&&/Gecko\/\d+/.test(navigator.userAgent),h="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),a="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),c=r&&(h||+r[1]<57)||l&&h,u=0;u<10;u++)n[48+u]=n[96+u]=String(u);for(u=1;u<=24;u++)n[u+111]="F"+u;for(u=65;u<=90;u++)n[u]=String.fromCharCode(u+32),s[u]=String.fromCharCode(u);for(var d in n)s.hasOwnProperty(d)||(s[d]=n[d]);function f(t){var e=c&&(t.ctrlKey||t.altKey||t.metaKey)||(o||a)&&t.shiftKey&&t.key&&1==t.key.length,i=!e&&t.key||(t.shiftKey?s:n)[t.keyCode]||t.key||"Unidentified";return"Esc"==i&&(i="Escape"),"Del"==i&&(i="Delete"),"Left"==i&&(i="ArrowLeft"),"Up"==i&&(i="ArrowUp"),"Right"==i&&(i="ArrowRight"),"Down"==i&&(i="ArrowDown"),i}}}]); |