Files
2026-01-30 23:31:00 -06:00

2 lines
1.6 MiB
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"use strict";(self.webpackChunkhacs_frontend=self.webpackChunkhacs_frontend||[]).push([["868"],{17743:function(t,e,i){var n=i(13053);t.exports=function(t,e,i){for(var s=0,r=arguments.length>2?i:n(e),o=new t(r);r>s;)o[s]=e[s++];return o}},37595:function(t,e,i){var n=i(31269),s=i(72878),r=i(25091),o=i(12360),h=i(70273),l=i(13053),a=i(72309),c=i(17743),u=Array,f=s([].push);t.exports=function(t,e,i,s){for(var d,g,p,m=o(t),w=r(m),v=n(e,i),y=a(null),b=l(w),x=0;b>x;x++)p=w[x],(g=h(v(p,x,m)))in y?f(y[g],p):y[g]=[p];if(s&&(d=s(m))!==u)for(g in y)y[g]=c(d,y[g]);return y}},81646:function(t){var e=RangeError;t.exports=function(t){if(t==t)return t;throw new e("NaN is not allowed")}},63434:function(t,e,i){var n=i(40810),s=i(12360),r=i(13053),o=i(88045),h=i(35709);n({target:"Array",proto:!0},{at:function(t){var e=s(this),i=r(e),n=o(t),h=n>=0?n:i+n;return h<0||h>=i?void 0:e[h]}}),h("at")},2480:function(t,e,i){var n=i(40810),s=i(97934),r=i(71998),o=i(4576),h=i(81646),l=i(31922),a=i(79995),c=i(92288),u=a((function(){for(var t,e=this.iterator,i=this.next;this.remaining;)if(this.remaining--,t=r(s(i,e)),this.done=!!t.done)return;if(t=r(s(i,e)),!(this.done=!!t.done))return t.value}));n({target:"Iterator",proto:!0,real:!0,forced:c},{drop:function(t){r(this);var e=l(h(+t));return new u(o(this),{remaining:e})}})},68107:function(t,e,i){var n=i(40810),s=i(73994),r=i(63983),o=i(71998),h=i(4576);n({target:"Iterator",proto:!0,real:!0},{every:function(t){o(this),r(t);var e=h(this),i=0;return!s(e,(function(e,n){if(!t(e,i++))return n()}),{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})},32517:function(t,e,i){var n=i(1569),s=i(85779),r=i(27803),o=i(31126),h=i(29660),l=n.RegExp,a=l.prototype;s&&h((function(){var t=!0;try{l(".","d")}catch(h){t=!1}var e={},i="",n=t?"dgimsy":"gimsy",s=function(t,n){Object.defineProperty(e,t,{get:function(){return i+=n,!0}})},r={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var o in t&&(r.hasIndices="d"),r)s(o,r[o]);return Object.getOwnPropertyDescriptor(a,"flags").get.call(e)!==n||i!==n}))&&r(a,"flags",{configurable:!0,get:o})},96829:function(t,e,i){var n=i(40810),s=i(72878),r=i(95011),o=i(88045),h=i(72616),l=i(29660),a=s("".charAt);n({target:"String",proto:!0,forced:l((function(){return"\ud842"!=="𠮷".at(-2)}))},{at:function(t){var e=h(r(this)),i=e.length,n=o(t),s=n>=0?n:i+n;return s<0||s>=i?void 0:a(e,s)}})},64706:function(t,e,i){var n=i(40810),s=i(97934),r=i(87915),o=i(33723),h=i(78996),l=i(95011),a=i(82065),c=i(72616),u=i(71998),f=i(56737),d=i(36313),g=i(12523),p=i(40262),m=i(22861),w=i(99473),v=i(29660),y=i(27847),b=i(16593),x=i(41848),S=i(3182),k=i(84238),A=i(92288),M=y("matchAll"),C="RegExp String",O=C+" Iterator",T=k.set,D=k.getterFor(O),E=RegExp.prototype,R=TypeError,B=r("".indexOf),P=r("".matchAll),L=!!P&&!v((function(){P("a",/./)})),N=o((function(t,e,i,n){T(this,{type:O,regexp:t,string:e,global:i,unicode:n,done:!1})}),C,(function(){var t=D(this);if(t.done)return h(void 0,!0);var e=t.regexp,i=t.string,n=S(e,i);return null===n?(t.done=!0,h(void 0,!0)):t.global?(""===c(n[0])&&(e.lastIndex=x(i,a(e.lastIndex),t.unicode)),h(n,!1)):(t.done=!0,h(n,!1))})),I=function(t){var e,i,n,s=u(this),r=c(t),o=b(s,RegExp),h=c(p(s));return e=new o(o===RegExp?s.source:s,h),i=!!~B(h,"g"),n=!!~B(h,"u"),e.lastIndex=a(s.lastIndex),new N(e,r,i,n)};n({target:"String",proto:!0,forced:L},{matchAll:function(t){var e,i,n,r,o=l(this);if(f(t)){if(L)return P(o,t)}else{if(g(t)&&(e=c(l(p(t))),!~B(e,"g")))throw new R("`.matchAll` does not allow non-global regexes");if(L)return P(o,t);if(void 0===(n=m(t,M))&&A&&"RegExp"===d(t)&&(n=I),n)return s(n,t,o)}return i=c(o),r=new RegExp(t,"g"),A?s(I,r,i):r[M](i)}}),A||M in E||w(E,M,I)},16132:function(t,e,i){i(13492)("Uint16",(function(t){return function(e,i,n){return t(this,e,i,n)}}))},22139:function(t,e,i){var n=i(40810),s=i(37595),r=i(35709);n({target:"Array",proto:!0},{group:function(t){return s(this,t,arguments.length>1?arguments[1]:void 0)}}),r("group")},37210:function(t,e,i){i(2480)},92181:function(t,e,i){i(68107)},14688:function(t,e,i){i.a(t,(async function(t,n){try{i.d(e,{ys:function(){return lt}});i(71695),i(92745),i(52805),i(61893),i(19423),i(40251),i(69235),i(12385),i(19134),i(32517),i(5740),i(11740),i(44495),i(97003),i(47706),i(32114),i(46692),i(39527),i(92181),i(99790),i(67670),i(13334),i(34595),i(36993),i(47021);var s=i(16708),r=i(45037),o=i(29590),h=t([o,r]);[o,r]=h.then?(await h)():h;class a{constructor(t,e,i,n){this.state=t,this.pos=e,this.explicit=i,this.view=n,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let e=(0,o.qz)(this.state).resolveInner(this.pos,-1);for(;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(p(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,i){"abort"==t&&this.abortListeners&&(this.abortListeners.push(e),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function c(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 u(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=c(e)+c(i)+"*$";return[new RegExp("^"+n),new RegExp(n)]}function f(t){let e=t.map((t=>"string"==typeof t?{label:t}:t)),[i,n]=e.every((t=>/^\w+$/.test(t.label)))?[/\w*$/,/\w+$/]:u(e);return t=>{let s=t.matchBefore(n);return s||t.explicit?{from:s?s.from:t.pos,options:e,validFor:i}:null}}class d{constructor(t,e,i,n){this.completion=t,this.source=e,this.match=i,this.score=n}}function g(t){return t.selection.main.from}function p(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=s.q6.define();function w(t,e,i,n){let{main:r}=t.selection,o=i-r.from,h=n-r.from;return Object.assign(Object.assign({},t.changeByRange((l=>{if(l!=r&&i!=n&&t.sliceDoc(l.from+o,l.from+h)!=t.sliceDoc(i,n))return{range:l};let a=t.toText(e);return{changes:{from:l.from+o,to:n==r.from?l.to:l.from+h,insert:a},range:s.jT.cursor(l.from+o+a.length)}}))),{scrollIntoView:!0,userEvent:"input.complete"})}const v=new WeakMap;function y(t){if(!Array.isArray(t))return t;let e=v.get(t);return e||v.set(t,e=f(t)),e}const b=s.Py.define(),x=s.Py.define();class S{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];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}ret(t,e){return this.score=t,this.matched=e,this}match(t){if(0==this.pattern.length)return this.ret(-100,[]);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),r=(0,s.nZ)(n),o=r==t.length?0:-100;if(n==e[0]);else{if(n!=i[0])return null;o+=-200}return this.ret(o,[0,r])}let h=t.indexOf(this.pattern);if(0==h)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=e.length,a=0;if(h<0){for(let r=0,o=Math.min(t.length,200);r<o&&a<l;){let o=(0,s.gm)(t,r);o!=e[a]&&o!=i[a]||(n[a++]=r),r+=(0,s.nZ)(o)}if(a<l)return null}let c=0,u=0,f=!1,d=0,g=-1,p=-1,m=/[a-z]/.test(t),w=!0;for(let v=0,y=Math.min(t.length,200),b=0;v<y&&u<l;){let n=(0,s.gm)(t,v);h<0&&(c<l&&n==e[c]&&(r[c++]=v),d<l&&(n==e[d]||n==i[d]?(0==d&&(g=v),p=v+1,d++):d=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&&(f=!0)?o[u++]=v:o.length&&(w=!1)),b=y,v+=(0,s.nZ)(n)}return u==l&&0==o[0]&&w?this.result((f?-200:0)-100,o,t):d==l&&0==g?this.ret(-200-t.length+(p==t.length?0:-100),[0,p]):h>-1?this.ret(-700-t.length,[h,h+this.pattern.length]):d==l?this.ret(-900-t.length,[g,p]):u==l?this.result((f?-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=[],r=0;for(let o of e){let t=o+(this.astral?(0,s.nZ)((0,s.gm)(i,o)):1);r&&n[r-1]==o?n[r-1]=t:(n[r++]=o,n[r++]=t)}return this.ret(t-i.length,n)}}class k{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length<this.pattern.length)return null;let e=t.slice(0,this.pattern.length),i=e==this.pattern?0:e.toLowerCase()==this.folded?-200:null;return null==i?null:(this.matched=[0,e.length],this.score=i+(t.length==this.pattern.length?0:-100),this)}}const A=s.r$.define({combine(t){return(0,s.BO)(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:C,filterStrict:!1,compareCompletions:(t,e)=>t.label.localeCompare(e.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,e)=>t&&e,closeOnBlur:(t,e)=>t&&e,icons:(t,e)=>t&&e,tooltipClass:(t,e)=>i=>M(t(i),e(i)),optionClass:(t,e)=>i=>M(t(i),e(i)),addToOptions:(t,e)=>t.concat(e),filterStrict:(t,e)=>t||e})}});function M(t,e){return t?e?t+" "+e:t:e}function C(t,e,i,n,s,o){let h,l,a=t.textDirection==r.Nm.RTL,c=a,u=!1,f="top",d=e.left-s.left,g=s.right-e.right,p=n.right-n.left,m=n.bottom-n.top;if(c&&d<Math.min(p,g)?c=!1:!c&&g<Math.min(p,d)&&(c=!0),p<=(c?d:g))h=Math.max(s.top,Math.min(i.top,s.bottom-m))-e.top,l=Math.min(400,c?d:g);else{u=!0,l=Math.min(400,(a?e.right:s.right-e.left)-30);let t=s.bottom-e.bottom;t>=m||t>e.top?h=i.bottom-e.top:(f="bottom",h=e.bottom-i.top)}return{style:`${f}: ${h/((e.bottom-e.top)/o.offsetHeight)}px; max-width: ${l/((e.right-e.left)/o.offsetWidth)}px`,class:"cm-completionInfo-"+(u?a?"left-narrow":"right-narrow":c?"left":"right")}}function O(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,n){let s=document.createElement("span");s.className="cm-completionLabel";let r=t.displayLabel||t.label,o=0;for(let h=0;h<n.length;){let t=n[h++],e=n[h++];t>o&&s.appendChild(document.createTextNode(r.slice(o,t)));let i=s.appendChild(document.createElement("span"));i.appendChild(document.createTextNode(r.slice(t,e))),i.className="cm-completionMatchedText",o=e}return o<r.length&&s.appendChild(document.createTextNode(r.slice(o))),s},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 T(t,e,i){if(t<=i)return{from:0,to:t};if(e<0&&(e=0),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 D{constructor(t,e,i){this.view=t,this.stateField=e,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:t=>this.placeInfo(t),key:this},this.space=null,this.currentClass="";let n=t.state.field(e),{options:s,selected:r}=n.open,o=t.state.facet(A);this.optionContent=O(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=T(s.length,r,o.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",(i=>{let{options:n}=t.state.field(e).open;for(let e,s=i.target;s&&s!=this.dom;s=s.parentNode)if("LI"==s.nodeName&&(e=/-(\d+)$/.exec(s.id))&&+e[1]<n.length)return this.applyCompletion(t,n[+e[1]]),void i.preventDefault()})),this.dom.addEventListener("focusout",(e=>{let i=t.state.field(this.stateField,!1);i&&i.tooltip&&t.state.facet(A).closeOnBlur&&e.relatedTarget!=t.contentDOM&&t.dispatch({effects:x.of(null)})})),this.showOptions(s,n.id)}mount(){this.updateSel()}showOptions(t,e){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,e,this.range)),this.list.addEventListener("scroll",(()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)}))}update(t){var e;let i=t.state.field(this.stateField),n=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),i!=n){let{options:s,selected:r,disabled:o}=i.open;n.open&&n.open.options==s||(this.range=T(s.length,r,t.state.facet(A).maxRenderedOptions),this.showOptions(s,i.id)),this.updateSel(),o!=(null===(e=n.open)||void 0===e?void 0:e.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!o)}}updateTooltipClass(t){let e=this.tooltipClass(t);if(e!=this.currentClass){for(let t of this.currentClass.split(" "))t&&this.dom.classList.remove(t);for(let t of e.split(" "))t&&this.dom.classList.add(t);this.currentClass=e}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),e=t.open;if((e.selected>-1&&e.selected<this.range.from||e.selected>=this.range.to)&&(this.range=T(e.options.length,e.selected,this.view.state.facet(A).maxRenderedOptions),this.showOptions(e.options,t.id)),this.updateSelectedOption(e.selected)){this.destroyInfo();let{completion:i}=e.options[e.selected],{info:n}=i;if(!n)return;let s="string"==typeof n?document.createTextNode(n):n(i);if(!s)return;"then"in s?s.then((e=>{e&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(e,i)})).catch((t=>(0,r.OO)(this.view.state,t,"completion info"))):this.addInfoPane(s,i)}}addInfoPane(t,e){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",null!=t.nodeType)i.appendChild(t),this.infoDestroy=null;else{let{dom:e,destroy:n}=t;i.appendChild(e),this.infoDestroy=n||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let e=null;for(let i=this.list.firstChild,n=this.range.from;i;i=i.nextSibling,n++)"LI"==i.nodeName&&i.id?n==t?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),e=i):i.hasAttribute("aria-selected")&&i.removeAttribute("aria-selected"):n--;return e&&R(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(),s=this.space;if(!s){let t=this.dom.ownerDocument.defaultView||window;s={left:0,top:0,right:t.innerWidth,bottom:t.innerHeight}}return n.top>Math.min(s.bottom,e.bottom)-10||n.bottom<Math.max(s.top,e.top)+10?null:this.view.state.facet(A).positionInfo(this.view,e,n,i,s,this.dom)}placeInfo(t){this.info&&(t?(t.style&&(this.info.style.cssText=t.style),this.info.className="cm-tooltip cm-completionInfo "+(t.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(t,e,i){const n=document.createElement("ul");n.id=e,n.setAttribute("role","listbox"),n.setAttribute("aria-expanded","true"),n.setAttribute("aria-label",this.view.state.phrase("Completions"));let s=null;for(let r=i.from;r<i.to;r++){let{completion:o,match:h}=t[r],{section:l}=o;if(l){let t="string"==typeof l?l:l.name;if(t!=s&&(r>i.from||0==i.from))if(s=t,"string"!=typeof l&&l.header)n.appendChild(l.header(l));else{n.appendChild(document.createElement("completion-section")).textContent=t}}const a=n.appendChild(document.createElement("li"));a.id=e+"-"+r,a.setAttribute("role","option");let c=this.optionClass(o);c&&(a.className=c);for(let t of this.optionContent){let e=t(o,this.view.state,this.view,h);e&&a.appendChild(e)}}return i.from&&n.classList.add("cm-completionListIncompleteTop"),i.to<t.length&&n.classList.add("cm-completionListIncompleteBottom"),n}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function E(t,e){return i=>new D(i,t,e)}function R(t,e){let i=t.getBoundingClientRect(),n=e.getBoundingClientRect(),s=i.height/t.offsetHeight;n.top<i.top?t.scrollTop-=(i.top-n.top)/s:n.bottom>i.bottom&&(t.scrollTop+=(n.bottom-i.bottom)/s)}function B(t){return 100*(t.boost||0)+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}function P(t,e){let i=[],n=null,s=t=>{i.push(t);let{section:e}=t.completion;if(e){n||(n=[]);let t="string"==typeof e?e:e.name;n.some((e=>e.name==t))||n.push("string"==typeof e?{name:t}:e)}},r=e.facet(A);for(let a of t)if(a.hasResult()){let t=a.result.getMatch;if(!1===a.result.filter)for(let e of a.result.options)s(new d(e,a.source,t?t(e):[],1e9-i.length));else{let i,n=e.sliceDoc(a.from,a.to),o=r.filterStrict?new k(n):new S(n);for(let e of a.result.options)if(i=o.match(e.label)){let n=e.displayLabel?t?t(e,i.matched):[]:i.matched;s(new d(e,a.source,n,i.score+(e.boost||0)))}}}if(n){let t=Object.create(null),e=0,s=(t,e)=>{var i,n;return(null!==(i=t.rank)&&void 0!==i?i:1e9)-(null!==(n=e.rank)&&void 0!==n?n:1e9)||(t.name<e.name?-1:1)};for(let i of n.sort(s))e-=1e5,t[i.name]=e;for(let n of i){let{section:e}=n.completion;e&&(n.score+=t["string"==typeof e?e:e.name])}}let o=[],h=null,l=r.compareCompletions;for(let a of i.sort(((t,e)=>e.score-t.score||l(t.completion,e.completion)))){let t=a.completion;!h||h.label!=t.label||h.detail!=t.detail||null!=h.type&&null!=t.type&&h.type!=t.type||h.apply!=t.apply||h.boost!=t.boost?o.push(a):B(a.completion)>B(h)&&(o[o.length-1]=a),h=a.completion}return o}class L{constructor(t,e,i,n,s,r){this.options=t,this.attrs=e,this.tooltip=i,this.timestamp=n,this.selected=s,this.disabled=r}setSelected(t,e){return t==this.selected||t>=this.options.length?this:new L(this.options,W(e,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,e,i,n,s,r){if(n&&!r&&t.some((t=>t.isPending)))return n.setDisabled();let o=P(t,e);if(!o.length)return n&&t.some((t=>t.isPending))?n.setDisabled():null;let h=e.facet(A).selectOnOpen?0:-1;if(n&&n.selected!=h&&-1!=n.selected){let t=n.options[n.selected].completion;for(let e=0;e<o.length;e++)if(o[e].completion==t){h=e;break}}return new L(o,W(i,h),{pos:t.reduce(((t,e)=>e.hasResult()?Math.min(t,e.from):t),1e8),create:U,above:s.aboveCursor},n?n.timestamp:Date.now(),h,!1)}map(t){return new L(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:t.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}setDisabled(){return new L(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class N{constructor(t,e,i){this.active=t,this.id=e,this.open=i}static start(){return new N(F,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(t){let{state:e}=t,i=e.facet(A),n=(i.override||e.languageDataAt("autocomplete",g(e)).map(y)).map((e=>(this.active.find((t=>t.source==e))||new _(e,this.active.some((t=>0!=t.state))?1:0)).update(t,i)));n.length==this.active.length&&n.every(((t,e)=>t==this.active[e]))&&(n=this.active);let s=this.open,r=t.effects.some((t=>t.is($)));s&&t.docChanged&&(s=s.map(t.changes)),t.selection||n.some((e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to)))||!I(n,this.active)||r?s=L.build(n,e,this.id,s,i,r):s&&s.disabled&&!n.some((t=>t.isPending))&&(s=null),!s&&n.every((t=>!t.isPending))&&n.some((t=>t.hasResult()))&&(n=n.map((t=>t.hasResult()?new _(t.source,0):t)));for(let o of t.effects)o.is(K)&&(s=s&&s.setSelected(o.value,this.id));return n==this.active&&s==this.open?this:new N(n,this.id,s)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?V:H}}function I(t,e){if(t==e)return!0;for(let i=0,n=0;;){for(;i<t.length&&!t[i].hasResult();)i++;for(;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 V={"aria-autocomplete":"list"},H={};function W(t,e){let i={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(i["aria-activedescendant"]=t+"-"+e),i}const F=[];function z(t,e){if(t.isUserEvent("input.complete")){let i=t.annotation(m);if(i&&e.activateOnCompletion(i))return 12}let i=t.isUserEvent("input.type");return i&&e.activateOnTyping?5:i?1:t.isUserEvent("delete.backward")?2:t.selection?8:t.docChanged?16:0}class _{constructor(t,e,i=!1){this.source=t,this.state=e,this.explicit=i}hasResult(){return!1}get isPending(){return 1==this.state}update(t,e){let i=z(t,e),n=this;(8&i||16&i&&this.touches(t))&&(n=new _(n.source,0)),4&i&&0==n.state&&(n=new _(this.source,1)),n=n.updateFor(t,i);for(let s of t.effects)if(s.is(b))n=new _(n.source,1,s.value);else if(s.is(x))n=new _(n.source,0);else if(s.is($))for(let t of s.value)t.source==n.source&&(n=t);return n}updateFor(t,e){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(g(t.state))}}class j extends _{constructor(t,e,i,n,s,r){super(t,3,e),this.limit=i,this.result=n,this.from=s,this.to=r}hasResult(){return!0}updateFor(t,e){var i;if(!(3&e))return this.map(t.changes);let n=this.result;n.map&&!t.changes.empty&&(n=n.map(n,t.changes));let s=t.changes.mapPos(this.from),r=t.changes.mapPos(this.to,1),o=g(t.state);if(o>r||!n||2&e&&(g(t.startState)==this.from||o<this.limit))return new _(this.source,4&e?1:0);let h=t.changes.mapPos(this.limit);return q(n.validFor,t.state,s,r)?new j(this.source,this.explicit,h,n,s,r):n.update&&(n=n.update(n,s,r,new a(t.state,o,!1)))?new j(this.source,this.explicit,h,n,n.from,null!==(i=n.to)&&void 0!==i?i:g(t.state)):new _(this.source,1,this.explicit)}map(t){if(t.empty)return this;return(this.result.map?this.result.map(this.result,t):this.result)?new j(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new _(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function q(t,e,i,n){if(!t)return!1;let s=e.sliceDoc(i,n);return"function"==typeof t?t(s,i,n,e):p(t,!0).test(s)}const $=s.Py.define({map(t,e){return t.map((t=>t.map(e)))}}),K=s.Py.define(),J=s.QQ.define({create(){return N.start()},update(t,e){return t.update(e)},provide:t=>[r.hJ.from(t,(t=>t.tooltip)),r.tk.contentAttributes.from(t,(t=>t.attrs))]});function G(t,e){const i=e.completion.apply||e.completion.label;let n=t.state.field(J).active.find((t=>t.source==e.source));return n instanceof j&&("string"==typeof i?t.dispatch(Object.assign(Object.assign({},w(t.state,i,n.from,n.to)),{annotations:m.of(e.completion)})):i(t,e.completion,n.from,n.to),!0)}const U=E(J,G);function X(t,e="option"){return i=>{let n=i.state.field(J,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp<i.state.facet(A).interactionDelay)return!1;let s,o=1;"page"==e&&(s=(0,r.gB)(i,n.open.tooltip))&&(o=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:h}=n.open.options,l=n.open.selected>-1?n.open.selected+o*(t?1:-1):t?0:h-1;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 Y=t=>{let e=t.state.field(J,!1);return!(t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(A).interactionDelay)&&G(t,e.open.options[e.open.selected])},Q=t=>!!t.state.field(J,!1)&&(t.dispatch({effects:b.of(!0)}),!0),Z=t=>{let e=t.state.field(J,!1);return!(!e||!e.active.some((t=>0!=t.state)))&&(t.dispatch({effects:x.of(null)}),!0)};class tt{constructor(t,e){this.active=t,this.context=e,this.time=Date.now(),this.updates=[],this.done=void 0}}const et=50,it=1e3,nt=r.lg.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field(J).active)e.isPending&&this.startQuery(e)}update(t){let e=t.state.field(J),i=t.state.facet(A);if(!t.selectionSet&&!t.docChanged&&t.startState.field(J)==e)return;let n=t.transactions.some((t=>{let e=z(t,i);return 8&e||(t.selection||t.docChanged)&&!(3&e)}));for(let h=0;h<this.running.length;h++){let e=this.running[h];if(n||e.context.abortOnDocChange&&t.docChanged||e.updates.length+t.transactions.length>et&&Date.now()-e.time>it){for(let t of e.context.abortListeners)try{t()}catch(o){(0,r.OO)(this.view.state,o)}e.context.abortListeners=null,this.running.splice(h--,1)}else e.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some((t=>t.effects.some((t=>t.is(b)))))&&(this.pendingStart=!0);let s=this.pendingStart?50:i.activateOnTypingDelay;if(this.debounceUpdate=e.active.some((t=>t.isPending&&!this.running.some((e=>e.active.source==t.source))))?setTimeout((()=>this.startUpdate()),s):-1,0!=this.composing)for(let r of t.transactions)r.isUserEvent("input.type")?this.composing=2:2==this.composing&&r.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(J);for(let i of e.active)i.isPending&&!this.running.some((t=>t.active.source==i.source))&&this.startQuery(i);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout((()=>this.accept()),this.view.state.facet(A).updateSyncTime))}startQuery(t){let{state:e}=this.view,i=g(e),n=new a(e,i,t.explicit,this.view),s=new tt(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:x.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()),this.view.state.facet(A).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],i=this.view.state.facet(A),n=this.view.state.field(J);for(let s=0;s<this.running.length;s++){let r=this.running[s];if(void 0===r.done)continue;if(this.running.splice(s--,1),r.done){let n=g(r.updates.length?r.updates[0].startState:this.view.state),s=Math.min(n,r.done.from+(r.active.explicit?0:1)),o=new j(r.active.source,r.active.explicit,s,r.done,r.done.from,null!==(t=r.done.to)&&void 0!==t?t:n);for(let t of r.updates)o=o.update(t,i);if(o.hasResult()){e.push(o);continue}}let o=n.active.find((t=>t.source==r.active.source));if(o&&o.isPending)if(null==r.done){let t=new _(r.active.source,0);for(let e of r.updates)t=t.update(e,i);t.isPending||e.push(t)}else this.startQuery(o)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:$.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(J,!1);if(e&&e.tooltip&&this.view.state.facet(A).closeOnBlur){let i=e.open&&(0,r.gB)(this.view,e.open.tooltip);i&&i.dom.contains(t.relatedTarget)||setTimeout((()=>this.view.dispatch({effects:x.of(null)})),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout((()=>this.view.dispatch({effects:b.of(!1)})),20),this.composing=0}}}),st="object"==typeof navigator&&/Win/.test(navigator.platform),rt=s.Wl.highest(r.tk.domEventHandlers({keydown(t,e){let i=e.state.field(J,!1);if(!i||!i.open||i.open.disabled||i.open.selected<0||t.key.length>1||t.ctrlKey&&(!st||!t.altKey)||t.metaKey)return!1;let n=i.open.options[i.open.selected],s=i.active.find((t=>t.source==n.source)),r=n.completion.commitCharacters||s.result.commitCharacters;return r&&r.indexOf(t.key)>-1&&G(e,n),!1}})),ot=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",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".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:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",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",boxSizing:"content-box"},".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"}}});const ht=new class extends s.uU{};ht.startSide=1,ht.endSide=-1;"object"==typeof navigator&&navigator.userAgent;function lt(t={}){return[rt,J,A.of(t),nt,ct,ot]}const at=[{key:"Ctrl-Space",run:Q},{mac:"Alt-`",run:Q},{key:"Escape",run:Z},{key:"ArrowDown",run:X(!0)},{key:"ArrowUp",run:X(!1)},{key:"PageDown",run:X(!0,"page")},{key:"PageUp",run:X(!1,"page")},{key:"Enter",run:Y}],ct=s.Wl.highest(r.$f.computeN([A],(t=>t.facet(A).defaultKeymap?[at]:[])));n()}catch(l){n(l)}}))},29590:function(t,e,i){i.a(t,(async function(t,n){try{i.d(e,{qz:function(){return m}});i(52247),i(71695),i(92745),i(77439),i(19423),i(40251),i(69235),i(12385),i(19134),i(5740),i(11740),i(44495),i(97003),i(47706),i(46692),i(39527),i(13334),i(36993),i(47021);var s,r=i(70585),o=i(16708),h=i(84873),l=i(67084),a=i(29933),c=t([h]);h=(c.then?(await c)():c)[0];const f=new r.md;const d=new r.md;class g{constructor(t,e,i=[],n=""){this.data=t,this.name=n,o.yy.prototype.hasOwnProperty("tree")||Object.defineProperty(o.yy.prototype,"tree",{get(){return m(this)}}),this.parser=e,this.extension=[M.of(this),o.yy.languageData.of(((t,e,i)=>{let n=p(t,e,i),s=n.type.prop(f);if(!s)return[];let r=t.facet(s),o=n.type.prop(d);if(o){let s=n.resolve(e-n.from,i);for(let e of o)if(e.test(s,t)){let i=t.facet(e.facet);return"replace"==e.type?i:i.concat(r)}}return r}))].concat(i)}isActiveAt(t,e,i=-1){return p(t,e,i).type.prop(f)==this.data}findRegions(t){let e=t.facet(M);if((null==e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let i=[],n=(t,e)=>{if(t.prop(f)==this.data)return void i.push({from:e,to:e+t.length});let s=t.prop(r.md.mounted);if(s){if(s.tree.prop(f)==this.data){if(s.overlay)for(let t of s.overlay)i.push({from:t.from+e,to:t.to+e});else i.push({from:e,to:e+t.length});return}if(s.overlay){let t=i.length;if(n(s.tree,s.overlay[0].from+e),i.length>t)return}}for(let i=0;i<t.children.length;i++){let s=t.children[i];s instanceof r.mp&&n(s,t.positions[i]+e)}};return n(m(t),0),i}get allowsNesting(){return!0}}function p(t,e,i){let n=t.facet(M),s=m(t).topNode;if(!n||n.allowsNesting)for(let o=s;o;o=o.enter(e,i,r.vj.ExcludeBuffers))o.type.isTop&&(s=o);return s}g.setState=o.Py.define();function m(t){let e=t.field(g.state,!1);return e?e.tree:r.mp.empty}class w{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let i=this.cursorPos-this.string.length;return t<i||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}}let v=null;class y{constructor(t,e,i=[],n,s,r,o,h){this.parser=t,this.state=e,this.fragments=i,this.tree=n,this.treeLen=s,this.viewport=r,this.skipped=o,this.scheduleOn=h,this.parse=null,this.tempSkipped=[]}static create(t,e,i){return new y(t,e,[],r.mp.empty,0,i,[],null)}startParse(){return this.parser.startParse(new w(this.state.doc),this.fragments)}work(t,e){return null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=r.mp.empty&&this.isDone(null!=e?e:this.state.doc.length)?(this.takeTree(),!0):this.withContext((()=>{var i;if("number"==typeof t){let e=Date.now()+t;t=()=>Date.now()>e}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 n=this.parse.advance();if(n){if(this.fragments=this.withoutTempSkipped(r.i9.addTree(n,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(i=this.parse.stoppedAt)&&void 0!==i?i:this.state.doc.length,this.tree=n,this.parse=null,!(this.treeLen<(null!=e?e:this.state.doc.length)))return!0;this.parse=this.startParse()}if(t())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((()=>{for(;!(e=this.parse.advance()););})),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(r.i9.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=v;v=this;try{return t()}finally{v=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=b(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:n,treeLen:s,viewport:o,skipped:h}=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=r.i9.applyChanges(i,e),n=r.mp.empty,s=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){h=[];for(let e of this.skipped){let i=t.mapPos(e.from,1),n=t.mapPos(e.to,-1);i<n&&h.push({from:i,to:n})}}}return new y(this.parser,e,i,n,s,o,h,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=b(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 r._b{createParse(e,i,n){let s=n[0].from,o=n[n.length-1].to;return{parsedPos:s,advance(){let e=v;if(e){for(let t of n)e.tempSkipped.push(t);t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}return this.parsedPos=o,new r.mp(r.Jq.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}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 v}}function b(t,e,i){return r.i9.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}class x{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)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 x(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=y.create(t.facet(M).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new x(i)}}g.state=o.QQ.define({create:x.init,update(t,e){for(let i of e.effects)if(i.is(g.setState))return i.value;return e.startState.facet(M)!=e.state.facet(M)?x.init(e.state):t.apply(e)}});let S=t=>{let e=setTimeout((()=>t()),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&(S=t=>{let e=-1,i=setTimeout((()=>{e=requestIdleCallback(t,{timeout:400})}),100);return()=>e<0?clearTimeout(i):cancelIdleCallback(e)});const k="undefined"!=typeof navigator&&(null===(s=navigator.scheduling)||void 0===s?void 0:s.isInputPending)?()=>navigator.scheduling.isInputPending():null,A=h.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(g.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(g.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=S(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(g.state);if(s.tree==s.context.tree&&s.context.isDone(n+1e5))return;let r=Date.now()+Math.min(this.chunkBudget,100,t&&!k?Math.max(25,t.timeRemaining()-5):1e9),o=s.context.treeLen<n&&i.doc.length>n+1e3,h=s.context.work((()=>k&&k()||Date.now()>r),n+(o?0:1e5));this.chunkBudget-=Date.now()-e,(h||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:g.setState.of(new x(s.context))})),this.chunkBudget>0&&(!h||o)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then((()=>this.scheduleWork())).catch((t=>(0,h.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()}}}),M=o.r$.define({combine(t){return t.length?t[0]:null},enables:t=>[g.state,A,h.tk.contentAttributes.compute([t],(e=>{let i=e.facet(t);return i&&i.name?{"data-language":i.name}:{}}))]});h.SJ;class C{constructor(t,e){let i;function n(t){let e=a.V.newName();return(i||Object.create(null))["."+e]=t,e}this.specs=t;const s="string"==typeof e.all?e.all:e.all?n(e.all):void 0,r=e.scope;this.scope=r instanceof g?t=>t.prop(f)==r.data:r?t=>t==r:void 0,this.style=(0,l.QR)(t.map((t=>({tag:t.tag,class:t.class||n(Object.assign({},t,{tag:null}))}))),{all:s}).style,this.module=i?new a.V(i):null,this.themeType=e.themeType}static define(t,e){return new C(t,e||{})}}l.pJ.meta,l.pJ.link,l.pJ.heading,l.pJ.emphasis,l.pJ.strong,l.pJ.strikethrough,l.pJ.keyword,l.pJ.atom,l.pJ.bool,l.pJ.url,l.pJ.contentSeparator,l.pJ.labelName,l.pJ.literal,l.pJ.inserted,l.pJ.string,l.pJ.deleted,l.pJ.regexp,l.pJ.escape,l.pJ.string,l.pJ.variableName,l.pJ.variableName,l.pJ.typeName,l.pJ.namespace,l.pJ.className,l.pJ.variableName,l.pJ.macroName,l.pJ.propertyName,l.pJ.comment,l.pJ.invalid;const O=Object.create(null),T=[r.Jq.none],D=[],E=Object.create(null);for(let[P,L]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])E[P]=B(O,L);function R(t,e){D.indexOf(t)>-1||(D.push(t),console.warn(e))}function B(t,e){let i=null;for(let r of e.split(".")){let e=t[r]||l.pJ[r];e?"function"==typeof e?i?i=e(i):R(r,`Modifier ${r} used at start of tag`):i?R(r,`Tag ${r} used as modifier`):i=e:R(r,`Unknown highlighting tag ${r}`)}if(!i)return 0;let n=e.replace(/ /g,"_"),s=r.Jq.define({id:T.length,name:n,props:[(0,l.Gv)({[n]:i})]});return T.push(s),s.id}n()}catch(u){n(u)}}))},84873:function(t,e,i){i.a(t,(async function(t,n){try{i.d(e,{OO:function(){return Ft},SJ:function(){return Dn},l9:function(){return wt},lg:function(){return qt},p:function(){return vt},tk:function(){return Sn}});var s=i(31948),r=(i(52247),i(71695),i(92745),i(52805),i(61495),i(61893),i(84283),i(19423),i(23669),i(40251),i(69235),i(12385),i(19134),i(32517),i(5740),i(11740),i(92519),i(42179),i(89256),i(24931),i(88463),i(57449),i(19814),i(97003),i(32114),i(46692),i(39527),i(37210),i(92181),i(99790),i(67670),i(13334),i(34595),i(36993),i(47021),i(16708)),o=i(29933),h=(i(96318),t([s]));function d(t){let e;return e=11==t.nodeType?t.getSelection?t:t.ownerDocument:t,e.getSelection()}function g(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function p(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function m(t,e){if(!e.anchorNode)return!1;try{return g(t,e.anchorNode)}catch(i){return!1}}function w(t){return 3==t.nodeType?E(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function v(t,e,i,n){return!!i&&(b(t,e,i,n,-1)||b(t,e,i,n,1))}function y(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function b(t,e,i,n,s){for(;;){if(t==i&&e==n)return!0;if(e==(s<0?0:x(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=y(t)+(s<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if(1==(t=t.childNodes[e+(s<0?-1:0)]).nodeType&&"false"==t.contentEditable)return!1;e=s<0?x(t):0}}}function x(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function S(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function k(t){return{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function A(t,e,i,n,s,r,o,h){let l=t.ownerDocument,a=l.defaultView||window;for(let c=t;c;)if(1==c.nodeType){let t,u=c==l.body;if(u)t=k(a);else{if(c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||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 f=0,d=0;if("nearest"==s)e.top<t.top?(d=-(t.top-e.top+o),i>0&&e.bottom>t.bottom+d&&(d=e.bottom-t.bottom+d+o)):e.bottom>t.bottom&&(d=e.bottom-t.bottom+o,i<0&&e.top-d<t.top&&(d=-(t.top+d-e.top+o)));else{let n=e.bottom-e.top,r=t.bottom-t.top;d=("center"==s&&n<=r?e.top+n/2-r/2:"start"==s||"center"==s&&i<0?e.top-o:e.bottom-r+o)-t.top}if("nearest"==n)e.left<t.left?(f=-(t.left-e.left+r),i>0&&e.right>t.right+f&&(f=e.right-t.right+f+r)):e.right>t.right&&(f=e.right-t.right+r,i<0&&e.left<t.left+f&&(f=-(t.left+f-e.left+r)));else{f=("center"==n?e.left+(e.right-e.left)/2-(t.right-t.left)/2:"start"==n==h?e.left-r:e.right-(t.right-t.left)+r)-t.left}if(f||d)if(u)a.scrollBy(f,d);else{let t=0,i=0;if(d){let t=c.scrollTop;c.scrollTop+=d,i=c.scrollTop-t}if(f){let e=c.scrollLeft;c.scrollLeft+=f,t=c.scrollLeft-e}e={left:e.left-t,top:e.top-i,right:e.right-t,bottom:e.bottom-i},t&&Math.abs(t-f)<1&&(n="nearest"),i&&Math.abs(i-d)<1&&(s="nearest")}if(u)break;c=c.assignedSlot||c.parentNode}else{if(11!=c.nodeType)break;c=c.host}}function M(t){let e=t.ownerDocument;for(let i=t.parentNode;i&&i!=e.body;)if(1==i.nodeType){if(i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)return i;i=i.assignedSlot||i.parentNode}else{if(11!=i.nodeType)break;i=i.host}return null}s=(h.then?(await h)():h)[0];class C{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:i}=t;this.set(e,Math.min(t.anchorOffset,e?x(e):0),i,Math.min(t.focusOffset,i?x(i):0))}set(t,e,i,n){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=n}}let O,T=null;function D(t){if(t.setActive)return t.setActive();if(T)return t.focus(T);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==T?{get preventScroll(){return T={preventScroll:!0},!0}}:void 0),!T){T=!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 E(t,e,i=e){let n=O||(O=document.createRange());return n.setEnd(t,i),n.setStart(t,e),n}function R(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 B(t){for(;t;){if(t&&(9==t.nodeType||11==t.nodeType&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function P(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}function L(t,e){let i=e.focusNode,n=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=n)return!1;for(n=Math.min(n,x(i));;)if(n){if(1!=i.nodeType)return!1;let t=i.childNodes[n-1];"false"==t.contentEditable?n--:(i=t,n=x(i))}else{if(i==t)return!0;n=y(i),i=i.parentNode}}class N{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new N(t.parentNode,y(t),e)}static after(t,e){return new N(t.parentNode,y(t)+1,e)}}const I=[];class V{constructor(){this.parent=null,this.dom=null,this.dirty=2}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}sync(t,e){if(2&this.dirty){let i,n=this.dom,s=null;for(let r of this.children){if(r.dirty){if(!r.dom&&(i=s?s.nextSibling:n.firstChild)){let t=V.get(i);(!t||!t.parent&&t.canReuseDOM(r))&&r.reuseDOM(i)}r.sync(t,e),r.dirty=0}if(i=s?s.nextSibling:n.firstChild,e&&!e.written&&e.node==n&&i!=r.dom&&(e.written=!0),r.dom.parentNode==n)for(;i&&i!=r.dom;)i=H(i);else n.insertBefore(r.dom,i);s=r.dom}for(i=s?s.nextSibling:n.firstChild,i&&e&&e.node==n&&(e.written=!0);i;)i=H(i)}else if(1&this.dirty)for(let i of this.children)i.dirty&&(i.sync(t,e),i.dirty=0)}reuseDOM(t){}localPosFromDOM(t,e){let i;if(t==this.dom)i=this.dom.childNodes[e];else{let n=0==x(t)?0:0==e?-1:1;for(;;){let e=t.parentNode;if(e==this.dom)break;0==n&&e.firstChild!=e.lastChild&&(n=t==e.firstChild?-1:1),t=e}i=n<0?t:t.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!V.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 h=0,l=i,a=i;h<this.children.length;h++){let i=this.children[h],c=l+i.length;if(l<t&&c>e)return i.domBoundsAround(t,e,l);if(c>=t&&-1==n&&(n=h,s=l),l>e&&i.dom.parentNode==this.dom){r=h,o=a;break}a=c,l=c+i.breakAfter}return{from:s,to:o<0?i+this.length:o,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:r<this.children.length&&r>=0?this.children[r].dom:null}}markDirty(t=!1){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=I){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 W(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}get isWidget(){return!1}get isHidden(){return!1}merge(t,e,i,n,s,r){return!1}become(t){return!1}canReuseDOM(t){return t.constructor==this.constructor}getSide(){return 0}destroy(){this.parent=null}}function H(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}V.prototype.breakAfter=0;class W{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 F(t,e,i,n,s,r,o,h,l){let{children:a}=t,c=a.length?a[e]:null,u=r.length?r[r.length-1]:null,f=u?u.breakAfter:o;if(!(e==n&&c&&!o&&!f&&r.length<2&&c.merge(i,s,r.length?u:null,0==i,h,l))){if(n<a.length){let t=a[n];t&&s<t.length?(e==n&&(t=t.split(s),s=0),!f&&u&&t.merge(0,s,u,!0,0,l)?r[r.length-1]=t:(s&&t.merge(0,s,null,!1,0,l),r.push(t))):(null==t?void 0:t.breakAfter)&&(u?u.breakAfter=1:o=1),n++}for(c&&(c.breakAfter=o,i>0&&(!o&&r.length&&c.merge(i,c.length,r[0],!1,h,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,h,0),e++));e<n&&r.length;)if(a[n-1].become(r[r.length-1]))n--,r.pop(),l=r.length?0:h;else{if(!a[e].become(r[0]))break;e++,r.shift(),h=r.length?0:l}!r.length&&e&&n<a.length&&!a[e-1].breakAfter&&a[n].merge(0,0,a[e-1],!1,h,l)&&e--,(e<n||r.length)&&t.replaceChildren(e,n,r)}}function z(t,e,i,n,s,r){let o=t.childCursor(),{i:h,off:l}=o.findPos(i,1),{i:a,off:c}=o.findPos(e,-1),u=e-i;for(let f of n)u+=f.length;t.length+=u,F(t,a,c,h,l,n,0,s,r)}let _="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},j="undefined"!=typeof document?document:{documentElement:{style:{}}};const q=/Edge\/(\d+)/.exec(_.userAgent),$=/MSIE \d/.test(_.userAgent),K=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(_.userAgent),J=!!($||K||q),G=!J&&/gecko\/(\d+)/i.test(_.userAgent),U=!J&&/Chrome\/(\d+)/.exec(_.userAgent),X="webkitFontSmoothing"in j.documentElement.style,Y=!J&&/Apple Computer/.test(_.vendor),Q=Y&&(/Mobile\/\w+/.test(_.userAgent)||_.maxTouchPoints>2);var l={mac:Q||/Mac/.test(_.platform),windows:/Win/.test(_.platform),linux:/Linux|X11/.test(_.platform),ie:J,ie_version:$?j.documentMode||6:K?+K[1]:q?+q[1]:0,gecko:G,gecko_version:G?+(/Firefox\/(\d+)/.exec(_.userAgent)||[0,0])[1]:0,chrome:!!U,chrome_version:U?+U[1]:0,ios:Q,android:/Android\b/.test(_.userAgent),webkit:X,safari:Y,webkit_version:X?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:null!=j.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};const Z=256;class tt extends V{constructor(t){super(),this.text=t}get length(){return this.text.length}createDOM(t){this.setDOM(t||document.createTextNode(this.text))}sync(t,e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(t){3==t.nodeType&&this.createDOM(t)}merge(t,e,i){return(!i||i instanceof tt&&!(this.length-(e-t)+i.length>Z))&&(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new tt(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 N(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 it(this.dom,t,e)}}class et extends V{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(P(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,e){this.dom?4&this.dirty&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(t,e)}merge(t,e,i,n,s,r){return(!i||!(!(i instanceof et&&i.mark.eq(this.mark))||t&&s<=0||e<this.length&&r<=0))&&(z(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 et(this.mark,e,r)}domAtPos(t){return ct(this,t)}coordsAt(t,e){return ft(this,t,e)}}function it(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?l.chrome||l.gecko||(e?(s--,o=1):r<n&&(r++,o=-1)):i<0?s--:r<n&&r++;let h=E(t,s,r).getClientRects();if(!h.length)return null;let a=h[(o?o<0:i>=0)?0:h.length-1];return l.safari&&!o&&0==a.width&&(a=Array.prototype.find.call(h,(t=>t.width))||a),o?S(a,o<0):a||null}class nt extends V{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||nt)(t,e,i)}split(t){let e=nt.create(this.widget,this.length-t,this.side);return this.length-=t,e}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.dom.contentEditable="false")}getSide(){return this.side}merge(t,e,i,n,s,r){return!(i&&(!(i instanceof nt&&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 instanceof nt&&t.side==this.side&&this.widget.constructor==t.widget.constructor&&(this.widget.compare(t.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get overrideDOMText(){if(0==this.length)return r.xv.empty;let t=this;for(;t.parent;)t=t.parent;let{view:e}=t,i=e&&e.state.doc,n=this.posAtStart;return i?i.slice(n,n+this.length):r.xv.empty}domAtPos(t){return(this.length?0==t:this.side>0)?N.before(this.dom):N.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let i=this.widget.coordsAt(this.dom,t,e);if(i)return i;let n=this.dom.getClientRects(),s=null;if(!n.length)return null;let r=this.side?this.side<0:t>0;for(let o=r?n.length-1:0;s=n[o],!(t>0?0==o:o==n.length-1||s.top<s.bottom);o+=r?-1:1);return S(s,!r)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class st extends nt{domAtPos(t){let{topView:e,text:i}=this.widget;return e?rt(t,0,e,i,this.length-e.length,((t,e)=>t.domAtPos(e)),((t,e)=>new N(t,Math.min(e,t.nodeValue.length)))):new N(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?ht(t,e,i,n,this.length-i.length):Math.min(e,this.length)}ignoreMutation(){return!1}get overrideDOMText(){return null}coordsAt(t,e){let{topView:i,text:n}=this.widget;return i?rt(t,e,i,n,this.length-i.length,((t,e,i)=>t.coordsAt(e,i)),((t,e,i)=>it(t,e,i))):it(n,t,e)}destroy(){var t;super.destroy(),null===(t=this.widget.topView)||void 0===t||t.destroy()}get isEditable(){return!0}canReuseDOM(){return!0}}function rt(t,e,i,n,s,r,o){if(i instanceof et){for(let h=i.dom.firstChild;h;h=h.nextSibling){let i=V.get(h);if(i){let l=g(h,n),a=i.length+(l?s:0);if(t<a||t==a&&i.getSide()<=0)return l?rt(t,e,i,n,s,r,o):r(i,t,e);t-=a}else{let i=ot(t,e,h,o);if("number"!=typeof i)return i;t=i}}return r(i,i.length,-1)}return i.dom==n?o(n,t,e):r(i,t,e)}function ot(t,e,i,n){if(3==i.nodeType){let s=i.nodeValue.length;if(t<=s)return n(i,t,e);t-=s}else if(1==i.nodeType&&"false"!=i.contentEditable)for(let s=i.firstChild;s;s=s.nextSibling){let i=ot(t,e,s,n);if("number"!=typeof i)return i;t=i}return t}function ht(t,e,i,n,s){if(i instanceof et){let r=0;for(let o=i.dom.firstChild;o;o=o.nextSibling){let i=V.get(o);if(i){let h=g(o,n);if(g(o,t))return r+(h?ht(t,e,i,n,s):i.localPosFromDOM(t,e));r+=i.length+(h?s:0)}else{let i=lt(t,e,o);if(null!=i.result)return r+i.result;r+=i.size}}}else if(i.dom==n)return Math.min(e,n.nodeValue.length);return i.localPosFromDOM(t,e)}function lt(t,e,i){if(3==i.nodeType)return t==i?{result:e}:{size:i.nodeValue.length};if(1!=i.nodeType||"false"==i.contentEditable)return i.contains(t)?{result:0}:{size:0};{let n=0;for(let s=i.firstChild,r=0;;s=s.nextSibling,r++){if(t==i&&r==e)return{result:n};if(!s)return{size:n};let o=lt(t,e,s);if(null!=o.result)return{result:e+o.result};n+=o.size}}}class at extends V{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof at&&t.side==this.side}split(){return new at(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 this.side>0?N.before(this.dom):N.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return r.xv.empty}get isHidden(){return!0}}function ct(t,e){let i=t.dom,{children:n}=t,s=0;for(let r=0;s<n.length;s++){let t=n[s],o=r+t.length;if(!(o==r&&t.getSide()<=0)){if(e>r&&e<o&&t.dom.parentNode==i)return t.domAtPos(e-r);if(e<=r)break;r=o}}for(let r=s;r>0;r--){let t=n[r-1];if(t.dom.parentNode==i)return t.domAtPos(t.length)}for(let r=s;r<n.length;r++){let t=n[r];if(t.dom.parentNode==i)return t.domAtPos(0)}return new N(i,0)}function ut(t,e,i){let n,{children:s}=t;i>0&&e instanceof et&&s.length&&(n=s[s.length-1])instanceof et&&n.mark.eq(e.mark)?ut(n,e.children[0],i-1):(s.push(e),e.setParent(t)),t.length+=e.length}function ft(t,e,i){let n=null,s=-1,r=null,o=-1;!function t(e,h){for(let l=0,a=0;l<e.children.length&&a<=h;l++){let c=e.children[l],u=a+c.length;u>=h&&(c.children.length?t(c,h-a):(!r||r.isHidden&&i>0)&&(u>h||a==u&&c.getSide()>0)?(r=c,o=h-a):(a<h||a==u&&c.getSide()<0&&!c.isHidden)&&(n=c,s=h-a)),a=u}}(t,e);let h=(i<0?n:r)||n||r;return h?h.coordsAt(Math.max(0,h==n?s:o),i):dt(t)}function dt(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=w(e);return i[i.length-1]||null}function gt(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 pt(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 mt(t,e,i){let n=null;if(e)for(let s in e)i&&s in i||t.removeAttribute(n=s);if(i)for(let s in i)e&&e[s]==i[s]||t.setAttribute(n=s,i[s]);return!!n}tt.prototype.children=nt.prototype.children=at.prototype.children=I;class wt{eq(t){return!1}updateDOM(t,e){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(t){return!0}coordsAt(t,e,i){return null}get customView(){return null}get isHidden(){return!1}destroy(t){}}var a=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(a||(a={}));class vt extends r.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 yt(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),i=!!t.block;return e+=i&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8,new xt(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}=St(t,n);e=(s?n?-3e8:-1:5e8)-1,i=1+(r?n?2e8:1:-6e8)}return new xt(t,e,i,n,t.widget||null,!0)}static line(t){return new bt(t)}static set(t,e=!1){return r.Xs.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}vt.none=r.Xs.empty;class yt extends vt{constructor(t){let{start:e,end:i}=St(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 yt&&this.tagName==t.tagName&&this.class==t.class&&pt(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)}}yt.prototype.point=!1;class bt extends vt{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof bt&&this.spec.class==t.spec.class&&pt(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)}}bt.prototype.mapMode=r.gc.TrackBefore,bt.prototype.point=!0;class xt extends vt{constructor(t,e,i,n,s,o){super(e,i,s,t),this.block=n,this.isReplace=o,this.mapMode=n?e<=0?r.gc.TrackBefore:r.gc.TrackAfter:r.gc.TrackDel}get type(){return this.startSide<this.endSide?a.WidgetRange:this.startSide<=0?a.WidgetBefore:a.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof xt&&(e=this.widget,i=t.widget,e==i||!!(e&&i&&e.compare(i)))&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide;var e,i}range(t,e=t){if(this.isReplace&&(t>e||t==e&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}}function St(t,e=!1){let{inclusiveStart:i,inclusiveEnd:n}=t;return null==i&&(i=t.inclusive),null==n&&(n=t.inclusive),{start:null!=i?i:e,end:null!=n?n:e}}function kt(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)}xt.prototype.point=!0;class At extends V{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 At))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),z(this,t,e,i?i.children:[],s,r),!0}split(t){let e=new At;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);for(;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&&(this.markDirty(),t.setDOM(this.dom),t.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(t){pt(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){ut(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=gt(e,this.attrs||{})),i&&(this.attrs=gt({class:i},this.attrs||{}))}domAtPos(t){return ct(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.dirty|=6)}sync(t,e){var i;this.dom?4&this.dirty&&(P(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&&(mt(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t,e);let n=this.dom.lastChild;for(;n&&V.get(n)instanceof et;)n=n.lastChild;if(!(n&&this.length&&("BR"==n.nodeName||0!=(null===(i=V.get(n))||void 0===i?void 0:i.isEditable)||l.ios&&this.children.some((t=>t instanceof tt))))){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,e=0;for(let i of this.children){if(!(i instanceof tt)||/[^ -~]/.test(i.text))return null;let n=w(i.dom);if(1!=n.length)return null;e+=n[0].width,t=n[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(t,e){let i=ft(this,t,e);if(!this.children.length&&i&&this.parent){let{heightOracle:t}=this.parent.view.viewState,e=i.bottom-i.top;if(Math.abs(e-t.lineHeight)<2&&t.textHeight<e){let n=(e-t.textHeight)/2;return{top:i.top+n,bottom:i.bottom-n,left:i.left,right:i.left}}}return i}become(t){return!1}get type(){return a.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 At)return s;if(r>e)break}n=r+s.breakAfter}return null}}class Mt extends V{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 Mt&&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?N.before(this.dom):N.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new Mt(this.widget,e,this.type);return i.breakAfter=this.breakAfter,i}get children(){return I}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.dom.contentEditable="false")}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):r.xv.empty}domBoundsAround(){return null}become(t){return t instanceof Mt&&t.widget.constructor==this.widget.constructor&&(t.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,this.type=t.type,this.breakAfter=t.breakAfter,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(t,e){return this.widget.coordsAt(this.dom,t,e)}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class Ct{constructor(t,e,i,n){this.doc=t,this.pos=e,this.end=i,this.disallowBlockEffectsFor=n,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],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 Mt&&t.type==a.WidgetBefore)}getLine(){return this.curLine||(this.content.push(this.curLine=new At),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(Ot(new at(-1),t),t.length),this.pendingBuffer=0)}addBlockWidget(t){this.flushBuffer(),this.curLine=null,this.content.push(t)}finish(t){this.pendingBuffer&&t<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||this.getLine()}buildText(t,e,i){for(;t>0;){if(this.textOff==this.text.length){let{value:e,lineBreak:i,done:n}=this.cursor.next(this.skip);if(this.skip=0,n)throw new Error("Ran out of text content when drawing inline views");if(i){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,t--;continue}this.text=e,this.textOff=0}let n=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(e.length-i)),this.getLine().append(Ot(new tt(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,r){if(this.disallowBlockEffectsFor[r]&&i instanceof xt){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")}let o=e-t;if(i instanceof xt)if(i.block){let{type:t}=i;t!=a.WidgetAfter||this.posCovered()||this.getLine(),this.addBlockWidget(new Mt(i.widget||new Tt("div"),o,t))}else{let r=nt.create(i.widget||new Tt("span"),o,o?0:i.startSide),h=this.atCursorPos&&!r.isEditable&&s<=n.length&&(t<e||i.startSide>0),l=!r.isEditable&&(t<e||s>n.length||i.startSide<=0),a=this.getLine();2!=this.pendingBuffer||h||r.isEditable||(this.pendingBuffer=0),this.flushBuffer(n),h&&(a.append(Ot(new at(1),n),s),s=n.length+Math.max(0,s-n.length)),a.append(Ot(r,n),s),this.atCursorPos=l,this.pendingBuffer=l?t<e||s>n.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=n.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);o&&(this.textOff+o<=this.text.length?this.textOff+=o:(this.skip+=o-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=e),this.openStart<0&&(this.openStart=s)}static build(t,e,i,n,s){let o=new Ct(t,e,i,s);return o.openEnd=r.Xs.spans(n,e,i,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}}function Ot(t,e){for(let i of e)t=new et(i,[t],t.length);return t}class Tt extends wt{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}const Dt=r.r$.define(),Et=r.r$.define(),Rt=r.r$.define(),Bt=r.r$.define(),Pt=r.r$.define(),Lt=r.r$.define(),Nt=r.r$.define(),It=r.r$.define({combine:t=>t.some((t=>t))}),Vt=r.r$.define({combine:t=>t.some((t=>t))});class Ht{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 Ht(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin)}}const Wt=r.Py.define({map:(t,e)=>t.map(e)});function Ft(t,e,i){let n=t.facet(Bt);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 zt=r.r$.define({combine:t=>!t.length||t[0]});let _t=0;const jt=r.r$.define();class qt{constructor(t,e,i,n){this.id=t,this.create=e,this.domEventHandlers=i,this.extension=n(this)}static define(t,e){const{eventHandlers:i,provide:n,decorations:s}=e||{};return new qt(_t++,t,i,(t=>{let e=[jt.of(t)];return s&&e.push(Gt.of((e=>{let i=e.plugin(t);return i?s(i):vt.none}))),n&&e.push(n(t)),e}))}static fromClass(t,e){return qt.define((e=>new t(e)),e)}}class $t{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}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(Ft(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){Ft(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){Ft(t.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Kt=r.r$.define(),Jt=r.r$.define(),Gt=r.r$.define(),Ut=r.r$.define(),Xt=r.r$.define();function Yt(t){let e=0,i=0,n=0,s=0;for(let r of t.state.facet(Xt)){let o=r(t);o&&(null!=o.left&&(e=Math.max(e,o.left)),null!=o.right&&(i=Math.max(i,o.right)),null!=o.top&&(n=Math.max(n,o.top)),null!=o.bottom&&(s=Math.max(s,o.bottom)))}return{left:e,right:i,top:n,bottom:s}}const Qt=r.r$.define();class Zt{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new Zt(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let n=t[e-1];if(!(n.fromA>i.toA)){if(n.toA<i.fromA)break;i=i.join(n),t.splice(e-1,1)}}return t.splice(e,0,i),t}static extendWithRanges(t,e){if(0==e.length)return t;let i=[];for(let n=0,s=0,r=0,o=0;;n++){let h=n==t.length?null:t[n],l=r-o,a=h?h.fromB:1e9;for(;s<e.length&&e[s]<a;){let t=e[s],n=e[s+1],r=Math.max(o,t),h=Math.min(a,n);if(r<=h&&new Zt(r+l,h+l,r,h).addToSet(i),n>a)break;s+=2}if(!h)return i;new Zt(h.fromA,h.toA,h.fromB,h.toB).addToSet(i),r=h.toA,o=h.toB}}}class te{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=r.as.empty(this.startState.doc.length);for(let s of i)this.changes=this.changes.compose(s.changes);let n=[];this.changes.iterChangedRanges(((t,e,i,s)=>n.push(new Zt(t,e,i,s)))),this.changedRanges=n}static create(t,e,i){return new te(t,e,i)}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 c=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(c||(c={}));const ee=c.LTR,ie=c.RTL;function ne(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}const se=ne("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),re=ne("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),oe=Object.create(null),he=[];for(let En of["()","[]","{}"]){let Rn=En.charCodeAt(0),Bn=En.charCodeAt(1);oe[Rn]=Bn,oe[Bn]=-Rn}const le=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class ae{constructor(t,e,i){this.from=t,this.to=e,this.level=i}get dir(){return this.level%2?ie:ee}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 ce=[];function ue(t,e){let i=t.length,n=e==ee?1:2,s=e==ee?2:1;if(!t||1==n&&!le.test(t))return fe(i);for(let h=0,l=n,a=n;h<i;h++){let e=(r=t.charCodeAt(h))<=247?se[r]:1424<=r&&r<=1524?2:1536<=r&&r<=1785?re[r-1536]:1774<=r&&r<=2220?4:8192<=r&&r<=8203?256:64336<=r&&r<=65023?4:8204==r?256:1;512==e?e=l:8==e&&4==a&&(e=16),ce[h]=4==e?2:e,7&e&&(a=e),l=e}var r;for(let h=0,l=n,a=n;h<i;h++){let t=ce[h];if(128==t)h<i-1&&l==ce[h+1]&&24&l?t=ce[h]=l:ce[h]=256;else if(64==t){let t=h+1;for(;t<i&&64==ce[t];)t++;let e=h&&8==l||t<i&&8==ce[t]?1==a?1:8:256;for(let i=h;i<t;i++)ce[i]=e;h=t-1}else 8==t&&1==a&&(ce[h]=1);l=t,7&t&&(a=t)}for(let h,l,a,c=0,u=0,f=0;c<i;c++)if(l=oe[h=t.charCodeAt(c)])if(l<0){for(let t=u-3;t>=0;t-=3)if(he[t+1]==-l){let e=he[t+2],i=2&e?n:4&e?1&e?s:n:0;i&&(ce[c]=ce[he[t]]=i),u=t;break}}else{if(189==he.length)break;he[u++]=c,he[u++]=h,he[u++]=f}else if(2==(a=ce[c])||1==a){let t=a==n;f=t?0:1;for(let e=u-3;e>=0;e-=3){let i=he[e+2];if(2&i)break;if(t)he[e+2]|=2;else{if(4&i)break;he[e+2]|=4}}}for(let h=0;h<i;h++)if(256==ce[h]){let t=h+1;for(;t<i&&256==ce[t];)t++;let e=1==(h?ce[h-1]:n),s=e==(1==(t<i?ce[t]:n))?e?1:2:n;for(let i=h;i<t;i++)ce[i]=s;h=t-1}let o=[];if(1==n)for(let h=0;h<i;){let t=h,e=1!=ce[h++];for(;h<i&&e==(1!=ce[h]);)h++;if(e)for(let i=h;i>t;){let e=i,n=2!=ce[--i];for(;i>t&&n==(2!=ce[i-1]);)i--;o.push(new ae(i,e,n?2:1))}else o.push(new ae(t,h,0))}else for(let h=0;h<i;){let t=h,e=2==ce[h++];for(;h<i&&e==(2==ce[h]);)h++;o.push(new ae(t,h,e?1:2))}return o}function fe(t){return[new ae(0,t,0)]}let de="";function ge(t,e,i,n,s){var o;let h=n.head-t.from,l=-1;if(0==h){if(!s||!t.length)return null;e[0].level!=i&&(h=e[0].side(!1,i),l=0)}else if(h==t.length){if(s)return null;let t=e[e.length-1];t.level!=i&&(h=t.side(!0,i),l=e.length-1)}l<0&&(l=ae.find(e,h,null!==(o=n.bidiLevel)&&void 0!==o?o:-1,n.assoc));let a=e[l];h==a.side(s,i)&&(a=e[l+=s?1:-1],h=a.side(!s,i));let c=s==(a.dir==i),u=(0,r.cp)(t.text,h,c);if(de=t.text.slice(Math.min(h,u),Math.max(h,u)),u!=a.side(s,i))return r.jT.cursor(u+t.from,c?-1:1,a.level);let f=l==(s?e.length-1:0)?null:e[l+(s?1:-1)];return f||a.level==i?f&&f.level<a.level?r.jT.cursor(f.side(!s,i)+t.from,s?1:-1,f.level):r.jT.cursor(u+t.from,s?-1:1,a.level):r.jT.cursor(s?t.to:t.from,s?-1:1,i)}const pe="￿";class me{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(r.yy.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=pe}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let n=t;;){this.findPointBefore(i,n);let t=this.text.length;this.readNode(n);let s=n.nextSibling;if(s==e)break;let r=V.get(n),o=V.get(s);(r&&o?r.breakAfter:(r?r.breakAfter:we(n))||we(s)&&("BR"!=n.nodeName||n.cmIgnore)&&this.text.length>t)&&this.lineBreak(),n=s}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=V.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 we(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}class ve{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class ye extends V{constructor(t){super(),this.view=t,this.compositionDeco=vt.none,this.decorations=[],this.dynamicDecorationMap=[],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 At],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Zt(0,0,0,t.state.doc.length)],0)}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=vt.none:(t.transactions.length||this.dirty)&&(this.compositionDeco=Se(this.view,t.changes)),(l.ie||l.chrome)&&!this.compositionDeco.size&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let i=Oe(this.decorations,this.updateDeco(),t.changes);return e=Zt.extendWithRanges(e,i),(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.flexBasis=this.minWidth?this.minWidth+"px":"";let t=l.chrome||l.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,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 Mt&&s.widget instanceof be&&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:h}=e,{content:l,breakAtStart:a,openStart:c,openEnd:u}=Ct.build(this.view.state.doc,o,h,this.decorations,this.dynamicDecorationMap),{i:f,off:d}=i.findPos(r,1),{i:g,off:p}=i.findPos(s,-1);F(this,g,p,f,d,l,a,c,u)}}updateSelection(t=!1,e=!1){!t&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let i=this.view.root.activeElement,n=i==this.dom,s=!n&&m(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(n||e||s))return;let r=this.forceSelection;this.forceSelection=!1;let o=this.view.state.selection.main,h=this.domAtPos(o.anchor),a=o.empty?h:this.domAtPos(o.head);if(l.gecko&&o.empty&&!this.compositionDeco.size&&(1==(c=h).node.nodeType&&c.node.firstChild&&(0==c.offset||"false"==c.node.childNodes[c.offset-1].contentEditable)&&(c.offset==c.node.childNodes.length||"false"==c.node.childNodes[c.offset].contentEditable))){let t=document.createTextNode("");this.view.observer.ignore((()=>h.node.insertBefore(t,h.node.childNodes[h.offset]||null))),h=a=new N(t,0),r=!0}var c;let u=this.view.observer.selectionRange;!r&&u.focusNode&&v(h.node,h.offset,u.anchorNode,u.anchorOffset)&&v(a.node,a.offset,u.focusNode,u.focusOffset)||(this.view.observer.ignore((()=>{l.android&&l.chrome&&this.dom.contains(u.focusNode)&&Te(u.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let t=d(this.view.root);if(t)if(o.empty){if(l.gecko){let t=Me(h.node,h.offset);if(t&&3!=t){let e=Ae(h.node,h.offset,1==t?1:-1);e&&(h=new N(e,1==t?0:e.nodeValue.length))}}t.collapse(h.node,h.offset),null!=o.bidiLevel&&null!=u.cursorBidiLevel&&(u.cursorBidiLevel=o.bidiLevel)}else if(t.extend){t.collapse(h.node,h.offset);try{t.extend(a.node,a.offset)}catch(e){}}else{let e=document.createRange();o.anchor>o.head&&([h,a]=[a,h]),e.setEnd(a.node,a.offset),e.setStart(h.node,h.offset),t.removeAllRanges(),t.addRange(e)}else;s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())})),this.view.observer.setSelectionRange(h,a)),this.impreciseAnchor=h.precise?null:new N(u.anchorNode,u.anchorOffset),this.impreciseHead=a.precise?null:new N(u.focusNode,u.focusOffset)}enforceCursorAssoc(){if(this.compositionDeco.size)return;let{view:t}=this,e=t.state.selection.main,i=d(t.root),{anchorNode:n,anchorOffset:s}=t.observer.selectionRange;if(!(i&&e.empty&&e.assoc&&i.modify))return;let r=At.find(this,e.head);if(!r)return;let o=r.posAtStart;if(e.head==o||e.head==o+r.length)return;let h=this.coordsAt(e.head,-1),l=this.coordsAt(e.head,1);if(!h||!l||h.bottom>l.top)return;let a=this.domAtPos(e.head+e.assoc);i.collapse(a.node,a.offset),i.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let c=t.observer.selectionRange;t.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=e.from&&i.collapse(n,s)}nearest(t){for(let e=t;e;){let t=V.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 At)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!=a.WidgetBefore&&s.type!=a.WidgetAfter&&(!n||2==e||this.children[n-1].breakAfter||this.children[n-1].type==a.WidgetBefore&&e>-2))return s.coordsAt(t-r,e);i=r}}measureVisibleLineHeights(t){let e=[],{from:i,to:n}=t,s=this.view.contentDOM.clientWidth,r=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,h=this.view.textDirection==c.LTR;for(let l=0,a=0;a<this.children.length;a++){let t=this.children[a],c=l+t.length;if(c>n)break;if(l>=i){let i=t.dom.getBoundingClientRect();if(e.push(i.height),r){let e=t.dom.lastChild,n=e?w(e):[];if(n.length){let t=n[n.length-1],e=h?t.right-i.left:i.right-t.left;e>o&&(o=e,this.minWidth=s,this.minWidthFrom=l,this.minWidthTo=c)}}}l=c+t.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?c.RTL:c.LTR}measureTextSize(){for(let s of this.children)if(s instanceof At){let t=s.measureTextSize();if(t)return t}let t,e,i,n=document.createElement("div");return n.className="cm-line",n.style.width="99999px",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore((()=>{this.dom.appendChild(n);let s=w(n.firstChild)[0];t=n.getBoundingClientRect().height,e=s?s.width/27:7,i=s?s.height:t,n.remove()})),{lineHeight:t,charWidth:e,textHeight:i}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new W(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(vt.replace({widget:new be(n),block:!0,inclusive:!0,isBlockGap:!0}).range(i,r))}if(!s)break;i=s.to+1}return vt.set(t)}updateDeco(){let t=this.view.state.facet(Gt).map(((t,e)=>(this.dynamicDecorationMap[e]="function"==typeof t)?t(this.view):t));for(let e=t.length;e<t.length+3;e++)this.dynamicDecorationMap[e]=!1;return this.decorations=[...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=Yt(this.view),r={left:n.left-s.left,top:n.top-s.top,right:n.right+s.right,bottom:n.bottom+s.bottom};A(this.view.scrollDOM,r,i.head<i.anchor?-1:1,t.x,t.y,t.xMargin,t.yMargin,this.view.textDirection==c.LTR)}}class be extends wt{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 xe(t){let e=t.observer.selectionRange,i=e.focusNode&&Ae(e.focusNode,e.focusOffset,0);if(!i)return null;let n=t.docView.nearest(i);if(!n)return null;if(n instanceof At){let t=i;for(;t.parentNode!=n.dom;)t=t.parentNode;let e=t.previousSibling;for(;e&&!V.get(e);)e=e.previousSibling;let s=e?V.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 At)break;n=t}let t=n.posAtStart;return{from:t,to:t+n.length,node:n.dom,text:i}}}function Se(t,e){let i=xe(t);if(!i)return vt.none;let{from:n,to:s,node:r,text:o}=i,h=e.mapPos(n,1),l=Math.max(h,e.mapPos(s,-1)),{state:a}=t,c=new me([],a);3==r.nodeType?c.readTextNode(r):c.readRange(r.firstChild,null);let{text:u}=c;if(u.indexOf(pe)>-1)return vt.none;if(l-h<u.length)if(a.doc.sliceString(h,Math.min(a.doc.length,h+u.length))==u)l=h+u.length;else{if(a.doc.sliceString(Math.max(0,l-u.length),l)!=u)return vt.none;h=l-u.length}else if(a.doc.sliceString(h,l)!=u)return vt.none;let f=V.get(r);return f instanceof st?f=f.widget.topView:f&&(f.parent=null),vt.set(vt.replace({widget:new ke(r,o,f),inclusive:!0}).range(h,l))}class ke extends wt{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 st}}function Ae(t,e,i){if(i<=0)for(let n=t,s=e;;){if(3==n.nodeType)return n;if(!(1==n.nodeType&&s>0))break;n=n.childNodes[s-1],s=x(n)}if(i>=0)for(let n=t,s=e;;){if(3==n.nodeType)return n;if(!(1==n.nodeType&&s<n.childNodes.length&&i>=0))break;n=n.childNodes[s],s=0}return null}function Me(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 Ce{constructor(){this.changes=[]}compareRange(t,e){kt(t,e,this.changes)}comparePoint(t,e){kt(t,e,this.changes)}}function Oe(t,e,i){let n=new Ce;return r.Xs.compare(t,e,i,n),n.changes}function Te(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 De(t,e,i=1){let n=t.charCategorizer(e),s=t.doc.lineAt(e),o=e-s.from;if(0==s.length)return r.jT.cursor(e);0==o?i=1:o==s.length&&(i=-1);let h=o,l=o;i<0?h=(0,r.cp)(s.text,o,!1):l=(0,r.cp)(s.text,o);let a=n(s.text.slice(h,l));for(;h>0;){let t=(0,r.cp)(s.text,h,!1);if(n(s.text.slice(t,h))!=a)break;h=t}for(;l<s.length;){let t=(0,r.cp)(s.text,l);if(n(s.text.slice(l,t))!=a)break;l=t}return r.jT.range(h+s.from,l+s.from)}function Ee(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function Re(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function Be(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function Pe(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function Le(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function Ne(t,e,i){let n,s,r,o,h,l,a,c,u=!1;for(let d=t.firstChild;d;d=d.nextSibling){let t=w(d);for(let f=0;f<t.length;f++){let g=t[f];s&&Be(s,g)&&(g=Pe(Le(g,s.bottom),s.top));let p=Ee(e,g),m=Re(i,g);if(0==p&&0==m)return 3==d.nodeType?Ie(d,e,i):Ne(d,e,i);if(!n||o>m||o==m&&r>p){n=d,s=g,r=p,o=m;let h=m?i<g.top?-1:1:p?e<g.left?-1:1:0;u=!h||(h>0?f<t.length-1:f>0)}0==p?i>g.bottom&&(!a||a.bottom<g.bottom)?(h=d,a=g):i<g.top&&(!c||c.top>g.top)&&(l=d,c=g):a&&Be(a,g)?a=Le(a,g.bottom):c&&Be(c,g)&&(c=Pe(c,g.top))}}if(a&&a.bottom>=i?(n=h,s=a):c&&c.top<=i&&(n=l,s=c),!n)return{node:t,offset:0};let f=Math.max(s.left,Math.min(s.right,e));return 3==n.nodeType?Ie(n,f,i):u&&"false"!=n.contentEditable?Ne(n,f,i):{node:t,offset:Array.prototype.indexOf.call(t.childNodes,n)+(e>=(s.left+s.right)/2?1:0)}}function Ie(t,e,i){let n=t.nodeValue.length,s=-1,r=1e9,o=0;for(let h=0;h<n;h++){let n=E(t,h,h+1).getClientRects();for(let a=0;a<n.length;a++){let c=n[a];if(c.top==c.bottom)continue;o||(o=e-c.left);let u=(c.top>i?c.top-i:i-c.bottom)-1;if(c.left-1<=e&&c.right+1>=e&&u<r){let i=e>=(c.left+c.right)/2,n=i;if(l.chrome||l.gecko){E(t,h).getBoundingClientRect().left==c.right&&(n=!i)}if(u<=0)return{node:t,offset:h+(n?1:0)};s=h+(n?1:0),r=u}}}return{node:t,offset:s>-1?s:o>0?t.nodeValue.length:0}}function Ve(t,e,i,n=-1){var s,r;let o,h=t.contentDOM.getBoundingClientRect(),c=h.top+t.viewState.paddingTop,{docHeight:u}=t.viewState,{x:f,y:d}=e,g=d-c;if(g<0)return 0;if(g>u)return t.state.doc.length;for(let l=t.viewState.heightOracle.textHeight/2,S=!1;o=t.elementAtHeight(g),o.type!=a.Text;)for(;g=n>0?o.bottom+l:o.top-l,!(g>=0&&g<=u);){if(S)return i?null:0;S=!0,n=-n}d=c+g;let p=o.from;if(p<t.viewport.from)return 0==t.viewport.from?0:i?null:He(t,h,o,f,d);if(p>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:He(t,h,o,f,d);let m=t.dom.ownerDocument,w=t.root.elementFromPoint?t.root:m,v=w.elementFromPoint(f,d);v&&!t.contentDOM.contains(v)&&(v=null),v||(f=Math.max(h.left+1,Math.min(h.right-1,f)),v=w.elementFromPoint(f,d),v&&!t.contentDOM.contains(v)&&(v=null));let y,b=-1;if(v&&0!=(null===(s=t.docView.nearest(v))||void 0===s?void 0:s.isEditable))if(m.caretPositionFromPoint){let t=m.caretPositionFromPoint(f,d);t&&({offsetNode:y,offset:b}=t)}else if(m.caretRangeFromPoint){let e=m.caretRangeFromPoint(f,d);e&&(({startContainer:y,startOffset:b}=e),(!t.contentDOM.contains(y)||l.safari&&We(y,b,f)||l.chrome&&Fe(y,b,f))&&(y=void 0))}if(!y||!t.docView.dom.contains(y)){let e=At.find(t.docView,p);if(!e)return g>o.top+o.height/2?o.to:o.from;({node:y,offset:b}=Ne(e.dom,f,d))}let x=t.docView.nearest(y);if(!x)return null;if(x.isWidget&&1==(null===(r=x.dom)||void 0===r?void 0:r.nodeType)){let t=x.dom.getBoundingClientRect();return e.y<t.top||e.y<=t.bottom&&e.x<=(t.left+t.right)/2?x.posAtStart:x.posAtEnd}return x.localPosFromDOM(y,b)+x.posAtStart}function He(t,e,i,n,s){let o=Math.round((n-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>1.5*t.defaultLineHeight){let e=t.viewState.heightOracle.textHeight;o+=Math.floor((s-i.top-.5*(t.defaultLineHeight-e))/e)*t.viewState.heightOracle.lineLength}let h=t.state.sliceDoc(i.from,i.to);return i.from+(0,r.Gz)(h,o,t.state.tabSize)}function We(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 E(t,n-1,n).getBoundingClientRect().left>i}function Fe(t,e,i){if(0!=e)return!1;for(let n=t;;){let t=n.parentNode;if(!t||1!=t.nodeType||t.firstChild!=n)return!1;if(t.classList.contains("cm-line"))break;n=t}return i-(1==t.nodeType?t.getBoundingClientRect():E(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect()).left>5}function ze(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==a.Text))return n;return i}function _e(t,e,i,n){let s=ze(t,e.head),o=n&&s.type==a.Text&&(t.lineWrapping||s.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head):null;if(o){let e=t.dom.getBoundingClientRect(),n=t.textDirectionAt(s.from),h=t.posAtCoords({x:i==(n==c.LTR)?e.right-1:e.left+1,y:(o.top+o.bottom)/2});if(null!=h)return r.jT.cursor(h,i?-1:1)}return r.jT.cursor(i?s.to:s.from,i?-1:1)}function je(t,e,i,n){let s=t.state.doc.lineAt(e.head),o=t.bidiSpans(s),h=t.textDirectionAt(s.from);for(let l=e,a=null;;){let e=ge(s,o,h,l,i),c=de;if(!e){if(s.number==(i?t.state.doc.lines:1))return l;c="\n",s=t.state.doc.line(s.number+(i?1:-1)),o=t.bidiSpans(s),e=r.jT.cursor(i?s.from:s.to)}if(a){if(!a(c))return l}else{if(!n)return e;a=n(c)}l=e}}function qe(t,e,i){let n=t.state.charCategorizer(e),s=n(i);return t=>{let e=n(t);return s==r.D0.Space&&(s=e),s==e}}function $e(t,e,i,n){let s=e.head,o=i?1:-1;if(s==(i?t.state.doc.length:0))return r.jT.cursor(s,e.assoc);let h,l=e.goalColumn,a=t.contentDOM.getBoundingClientRect(),c=t.coordsAtPos(s),u=t.documentTop;if(c)null==l&&(l=c.left-a.left),h=o<0?c.top:c.bottom;else{let e=t.viewState.lineBlockAt(s);null==l&&(l=Math.min(a.right-a.left,t.defaultCharacterWidth*(s-e.from))),h=(o<0?e.top:e.bottom)+u}let f=a.left+l,d=null!=n?n:t.viewState.heightOracle.textHeight>>1;for(let g=0;;g+=10){let i=h+(d+g)*o,n=Ve(t,{x:f,y:i},!1,o);if(i<a.top||i>a.bottom||(o<0?n<s:n>s))return r.jT.cursor(n,e.assoc,void 0,l)}}function Ke(t,e,i){for(;;){let n=0;for(let s of t)s.between(e-1,e+1,((t,s,r)=>{if(e>t&&e<s){let r=n||i||(e-t<s-e?-1:1);e=r<0?t:s,n=r}}));if(!n)return e}}function Je(t,e,i){let n=Ke(t.state.facet(Ut).map((e=>e(t))),i.from,e.head>i.from?-1:1);return n==i.from?i:r.jT.cursor(n,n<i.from?1:-1)}class Ge{constructor(t){this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.chromeScrollHack=-1,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.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null;let e=(e,i)=>{this.ignoreDuringComposition(i)||"keydown"==i.type&&this.keydown(t,i)||(this.mustFlushObserver(i)&&t.observer.forceFlush(),this.runCustomHandlers(i.type,t,i)?i.preventDefault():e(t,i))};for(let i in ri){let n=ri[i];t.contentDOM.addEventListener(i,(i=>{si(t,i)&&e(n,i)}),oi[i]),this.registeredEvents.push(i)}t.scrollDOM.addEventListener("mousedown",(i=>{if(i.target==t.scrollDOM&&i.clientY>t.contentDOM.getBoundingClientRect().bottom&&(e(ri.mousedown,i),!i.defaultPrevented&&2==i.button)){let e=t.contentDOM.style.minHeight;t.contentDOM.style.minHeight="100%",setTimeout((()=>t.contentDOM.style.minHeight=e),200)}})),t.scrollDOM.addEventListener("drop",(i=>{i.target==t.scrollDOM&&i.clientY>t.contentDOM.getBoundingClientRect().bottom&&e(ri.drop,i)})),l.chrome&&102==l.chrome_version&&t.scrollDOM.addEventListener("wheel",(()=>{this.chromeScrollHack<0?t.contentDOM.style.pointerEvents="none":window.clearTimeout(this.chromeScrollHack),this.chromeScrollHack=setTimeout((()=>{this.chromeScrollHack=-1,t.contentDOM.style.pointerEvents=""}),100)}),{passive:!0}),this.notifiedFocused=t.hasFocus,l.safari&&t.contentDOM.addEventListener("input",(()=>null))}setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}ensureHandlers(t,e){var i;let n;this.customHandlers=[];for(let s of e)if(n=null===(i=s.update(t).spec)||void 0===i?void 0:i.domEventHandlers){this.customHandlers.push({plugin:s.value,handlers:n});for(let e in n)this.registeredEvents.indexOf(e)<0&&"scroll"!=e&&(this.registeredEvents.push(e),t.contentDOM.addEventListener(e,(i=>{si(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){Ft(e.state,n)}}return!1}runScrollHandlers(t,e){this.lastScrollTop=t.scrollDOM.scrollTop,this.lastScrollLeft=t.scrollDOM.scrollLeft;for(let n of this.customHandlers){let s=n.handlers.scroll;if(s)try{s.call(n.plugin,e,t)}catch(i){Ft(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(27!=e.keyCode&&Ye.indexOf(e.keyCode)<0&&(t.inputState.lastEscPress=0),l.android&&l.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))return t.observer.delayAndroidKey(e.key,e.keyCode),!0;let i;return!(!l.ios||e.synthetic||e.altKey||e.metaKey||!((i=Ue.find((t=>t.keyCode==e.keyCode)))&&!e.ctrlKey||Xe.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey))&&(this.pendingIOSKey=i||e,setTimeout((()=>this.flushIOSKey(t)),250),!0)}flushIOSKey(t){let e=this.pendingIOSKey;return!!e&&(this.pendingIOSKey=void 0,R(t.contentDOM,e.key,e.keyCode))}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(this.composing>0||!!(l.safari&&!l.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}mustFlushObserver(t){return"keydown"==t.type&&229!=t.keyCode}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 Ue=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Xe="dthko",Ye=[16,17,18,20,91,92,224,225],Qe=6;function Ze(t){return.7*Math.max(0,t)+8}class ti{constructor(t,e,i,n){this.view=t,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParent=M(t.contentDOM),this.atoms=t.state.facet(Ut).map((e=>e(t)));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(r.yy.allowMultipleSelections)&&ei(t,e),this.dragging=!(!ni(t,e)||1!=yi(e))&&null}start(t){!1===this.dragging&&(t.preventDefault(),this.select(t))}move(t){var e;if(0==t.buttons)return this.destroy();if(!1!==this.dragging)return;this.select(this.lastEvent=t);let i=0,n=0,s=(null===(e=this.scrollParent)||void 0===e?void 0:e.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},r=Yt(this.view);t.clientX-r.left<=s.left+Qe?i=-Ze(s.left-t.clientX):t.clientX+r.right>=s.right-Qe&&(i=Ze(t.clientX-s.right)),t.clientY-r.top<=s.top+Qe?n=-Ze(s.top-t.clientY):t.clientY+r.bottom>=s.bottom-Qe&&(n=Ze(t.clientY-s.bottom)),this.setScrollSpeed(i,n)}up(t){null==this.dragging&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval((()=>this.scroll()),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),!1===this.dragging&&this.select(this.lastEvent)}skipAtoms(t){let e=null;for(let i=0;i<t.ranges.length;i++){let n=t.ranges[i],s=null;if(n.empty){let t=Ke(this.atoms,n.from,0);t!=n.from&&(s=r.jT.cursor(t,-1))}else{let t=Ke(this.atoms,n.from,-1),e=Ke(this.atoms,n.to,1);t==n.from&&e==n.to||(s=r.jT.range(n.from==n.anchor?t:e,n.from==n.head?t:e))}s&&(e||(e=t.ranges.slice()),e[i]=s)}return e?r.jT.create(e,t.mainIndex):t}select(t){let{view:e}=this,i=this.skipAtoms(this.style.get(t,this.extend,this.multiple));!this.mustSelect&&i.eq(e.state.selection)&&i.main.assoc==e.state.selection.main.assoc||this.view.dispatch({selection:i,userEvent:"select.pointer"}),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 ei(t,e){let i=t.state.facet(Dt);return i.length?i[0](e):l.mac?e.metaKey:e.ctrlKey}function ii(t,e){let i=t.state.facet(Et);return i.length?i[0](e):l.mac?!e.altKey:!e.ctrlKey}function ni(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let n=d(t.root);if(!n||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 si(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=V.get(n))&&i.ignoreEvent(e))return!1;return!0}const ri=Object.create(null),oi=Object.create(null),hi=l.ie&&l.ie_version<15||l.ios&&l.webkit_version<604;function li(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(),ai(t,i.value)}),50)}function ai(t,e){let i,{state:n}=t,s=1,o=n.toText(e),h=o.lines==n.selection.ranges.length;if(null!=Mi&&n.selection.ranges.every((t=>t.empty))&&Mi==o.toString()){let t=-1;i=n.changeByRange((i=>{let l=n.doc.lineAt(i.from);if(l.from==t)return{range:i};t=l.from;let a=n.toText((h?o.line(s++).text:e)+n.lineBreak);return{changes:{from:l.from,insert:a},range:r.jT.cursor(i.from+a.length)}}))}else i=h?n.changeByRange((t=>{let e=o.line(s++);return{changes:{from:t.from,to:t.to,insert:e.text},range:r.jT.cursor(t.from+e.length)}})):n.replaceSelection(o);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function ci(t,e,i,n){if(1==n)return r.jT.cursor(e,i);if(2==n)return De(t.state,e,i);{let i=At.find(t.docView,e),n=t.state.doc.lineAt(i?i.posAtEnd:e),s=i?i.posAtStart:n.from,o=i?i.posAtEnd:n.to;return o<t.state.doc.length&&o==n.to&&o++,r.jT.range(s,o)}}ri.keydown=(t,e)=>{t.inputState.setSelectionOrigin("select"),27==e.keyCode&&(t.inputState.lastEscPress=Date.now())},ri.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},ri.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},oi.touchstart=oi.touchmove={passive:!0},ri.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return;let i=null;for(let n of t.state.facet(Rt))if(i=n(t,e),i)break;if(i||0!=e.button||(i=bi(t,e)),i){let n=t.root.activeElement!=t.contentDOM;t.inputState.startMouseSelection(new ti(t,e,i,n)),n&&t.observer.ignore((()=>D(t.contentDOM))),t.inputState.mouseSelection&&t.inputState.mouseSelection.start(e)}};let ui=(t,e)=>t>=e.top&&t<=e.bottom,fi=(t,e,i)=>ui(e,i)&&t>=i.left&&t<=i.right;function di(t,e,i,n){let s=At.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&&fi(i,n,o))return-1;let h=s.coordsAt(r,1);return h&&fi(i,n,h)?1:o&&ui(n,o)?-1:1}function gi(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:di(t,i,e.clientX,e.clientY)}}const pi=l.ie&&l.ie_version<=11;let mi=null,wi=0,vi=0;function yi(t){if(!pi)return t.detail;let e=mi,i=vi;return mi=t,vi=Date.now(),wi=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(wi+1)%3:1}function bi(t,e){let i=gi(t,e),n=yi(e),s=t.state.selection;return{update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),s=s.map(t.changes))},get(e,o,h){let l,a=gi(t,e),c=ci(t,a.pos,a.bias,n);if(i.pos!=a.pos&&!o){let e=ci(t,i.pos,i.bias,n),s=Math.min(e.from,c.from),o=Math.max(e.to,c.to);c=s<c.from?r.jT.range(s,o):r.jT.range(o,s)}return o?s.replaceRange(s.main.extend(c.from,c.to)):h&&1==n&&s.ranges.length>1&&(l=xi(s,a.pos))?l:h?s.addRange(c):r.jT.create([c])}}}function xi(t,e){for(let i=0;i<t.ranges.length;i++){let{from:n,to:s}=t.ranges[i];if(n<=e&&s>=e)return r.jT.create(t.ranges.slice(0,i).concat(t.ranges.slice(i+1)),t.mainIndex==i?0:t.mainIndex-(t.mainIndex>i?1:0))}return null}function Si(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&&ii(t,e)?{from:r.dragging.from,to:r.dragging.to}:null,h={from:s,insert:i},l=t.state.changes(o?[o,h]:h);t.focus(),t.dispatch({changes:l,selection:{anchor:l.mapPos(s,-1),head:l.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"})}function ki(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 Ai(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}}ri.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")},ri.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&&Si(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 Si(t,e,e.dataTransfer.getData("Text"),!0)},ri.paste=(t,e)=>{if(t.state.readOnly)return e.preventDefault();t.observer.flush();let i=hi?null:e.clipboardData;i?(ai(t,i.getData("text/plain")||i.getData("text/uri-text")),e.preventDefault()):li(t)};let Mi=null;ri.copy=ri.cut=(t,e)=>{let{text:i,ranges:n,linewise:s}=Ai(t.state);if(!i&&!s)return;Mi=s?i:null;let r=hi?null:e.clipboardData;r?(e.preventDefault(),r.clearData(),r.setData("text/plain",i)):ki(t,i),"cut"!=e.type||t.state.readOnly||t.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"})};const Ci=r.q6.define();function Oi(t,e){let i=[];for(let n of t.facet(Nt)){let s=n(t,e);s&&i.push(s)}return i?t.update({effects:i,annotations:Ci.of(!0)}):null}function Ti(t){setTimeout((()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=Oi(t.state,e);i?t.dispatch(i):t.update([])}}),10)}ri.focus=t=>{t.inputState.lastFocusTime=Date.now(),t.scrollDOM.scrollTop||!t.inputState.lastScrollTop&&!t.inputState.lastScrollLeft||(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),Ti(t)},ri.blur=t=>{t.observer.clearSelectionRange(),Ti(t)},ri.compositionstart=ri.compositionupdate=t=>{null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0)},ri.compositionend=t=>{t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,l.chrome&&l.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then((()=>t.observer.flush())):setTimeout((()=>{t.inputState.composing<0&&t.docView.compositionDeco.size&&t.update([])}),50)},ri.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},ri.beforeinput=(t,e)=>{var i;let n;if(l.chrome&&l.android&&(n=Ue.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 Di=["pre-wrap","normal","pre-line","break-spaces"];class Ei{constructor(t){this.lineWrapping=t,this.doc=r.xv.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,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.max(0,Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(t){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5))))*this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return Di.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let n=t[i];n<0?i++:this.heightSamples[Math.floor(10*n)]||(e=!0,this.heightSamples[Math.floor(10*n)]=!0)}return e}refresh(t,e,i,n,s,r){let o=Di.indexOf(t)>-1,h=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=e,this.charWidth=i,this.textHeight=n,this.lineLength=s,h){this.heightSamples={};for(let t=0;t<r.length;t++){let e=r[t];e<0?t++:this.heightSamples[Math.floor(10*e)]=!0}}return h}}class Ri{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class Bi{constructor(t,e,i,n,s){this.from=t,this.length=e,this.top=i,this.height=n,this._content=s}get type(){return"number"==typeof this._content?a.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof xt?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(t){let e=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new Bi(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var u=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}(u||(u={}));const Pi=.001;class Li{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)>Pi&&(t.heightChanged=!0),this.height=e)}replace(t,e,i){return Li.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,n){let s=this,r=i.doc;for(let o=n.length-1;o>=0;o--){let{fromA:h,toA:l,fromB:a,toB:c}=n[o],f=s.lineAt(h,u.ByPosNoHeight,i.setDoc(e),0,0),d=f.to>=l?f:s.lineAt(l,u.ByPosNoHeight,i,0,0);for(c+=d.to-l,l=d.to;o>0&&f.from<=n[o-1].toA;)h=n[o-1].fromA,a=n[o-1].fromB,o--,h<f.from&&(f=s.lineAt(h,u.ByPosNoHeight,i,0,0));a+=f.from-h,h=f.from;let g=zi.build(i.setDoc(r),t,a,c);s=s.replace(h,l,g)}return s.updateHeight(i,0)}static empty(){return new Ii(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 Hi(Li.of(t.slice(0,e)),r,Li.of(t.slice(i)))}}Li.prototype.size=1;class Ni extends Li{constructor(t,e,i){super(t,e),this.deco=i}blockAt(t,e,i,n){return new Bi(n,this.length,i,this.height,this.deco||0)}lineAt(t,e,i,n,s){return this.blockAt(0,i,n,s)}forEachLine(t,e,i,n,s,r){t<=s+this.length&&e>=s&&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 Ii extends Ni{constructor(t,e){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(t,e,i,n){return new Bi(n,this.length,i,this.height,this.breaks)}replace(t,e,i){let n=i[0];return 1==i.length&&(n instanceof Ii||n instanceof Vi&&4&n.flags)&&Math.abs(this.length-n.length)<10?(n instanceof Vi?n=new Ii(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):Li.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.breaks*t.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Vi extends Li{constructor(t){super(t,0)}heightMetrics(t,e){let i,n=t.doc.lineAt(e).number,s=t.doc.lineAt(e+this.length).number,r=s-n+1,o=0;if(t.lineWrapping){let e=Math.min(this.height,t.lineHeight*r);i=e/r,this.length>r+1&&(o=(this.height-e)/(this.length-r-1))}else i=this.height/r;return{firstLine:n,lastLine:s,perLine:i,perChar:o}}blockAt(t,e,i,n){let{firstLine:s,lastLine:r,perLine:o,perChar:h}=this.heightMetrics(e,n);if(e.lineWrapping){let s=n+Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length),r=e.doc.lineAt(s),l=o+r.length*h,a=Math.max(i,t-l/2);return new Bi(r.from,r.length,a,l,0)}{let n=Math.max(0,Math.min(r-s,Math.floor((t-i)/o))),{from:h,length:l}=e.doc.line(s+n);return new Bi(h,l,i+o*n,o,0)}}lineAt(t,e,i,n,s){if(e==u.ByHeight)return this.blockAt(t,i,n,s);if(e==u.ByPosNoHeight){let{from:e,to:n}=i.doc.lineAt(t);return new Bi(e,n-e,0,0,0)}let{firstLine:r,perLine:o,perChar:h}=this.heightMetrics(i,s),l=i.doc.lineAt(t),a=o+l.length*h,c=l.number-r,f=n+o*c+h*(l.from-s-c);return new Bi(l.from,l.length,Math.max(n,Math.min(f,n+this.height-a)),a,0)}forEachLine(t,e,i,n,s,r){t=Math.max(t,s),e=Math.min(e,s+this.length);let{firstLine:o,perLine:h,perChar:l}=this.heightMetrics(i,s);for(let a=t,c=n;a<=e;){let e=i.doc.lineAt(a);if(a==t){let i=e.number-o;c+=h*i+l*(t-s-i)}let n=h+l*e.length;r(new Bi(e.from,e.length,c,n,0)),c+=n,a=e.to+1}}replace(t,e,i){let n=this.length-e;if(n>0){let t=i[i.length-1];t instanceof Vi?i[i.length-1]=new Vi(t.length+n):i.push(null,new Vi(n-1))}if(t>0){let e=i[0];e instanceof Vi?i[0]=new Vi(t+e.length):i.unshift(new Vi(t-1),null)}return Li.of(i)}decomposeLeft(t,e){e.push(new Vi(t-1),null)}decomposeRight(t,e){e.push(null,new Vi(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;for(n.from>e&&i.push(new Vi(n.from-e-1).updateHeight(t,e));r<=s&&n.more;){let e=t.doc.lineAt(r).length;i.length&&i.push(null);let s=n.heights[n.index++];-1==o?o=s:Math.abs(s-o)>=Pi&&(o=-2);let h=new Ii(e,s);h.outdated=!1,i.push(h),r+=e+1}r<=s&&i.push(null,new Vi(s-r).updateHeight(t,r));let h=Li.of(i);return(o<0||Math.abs(h.height-this.height)>=Pi||Math.abs(o-this.heightMetrics(t,e).perLine)>=Pi)&&(t.heightChanged=!0),h}return(i||this.outdated)&&(this.setHeight(t,t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class Hi extends Li{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,h=e==u.ByHeight?t<r:t<o,l=h?this.left.lineAt(t,e,i,n,s):this.right.lineAt(t,e,i,r,o);if(this.break||(h?l.to<o:l.from>o))return l;let a=e==u.ByPosNoHeight?u.ByPosNoHeight:u.ByPos;return h?l.join(this.right.lineAt(o,a,i,r,o)):this.left.lineAt(o,a,i,n,s).join(l)}forEachLine(t,e,i,n,s,r){let o=n+this.left.height,h=s+this.left.length+this.break;if(this.break)t<h&&this.left.forEachLine(t,e,i,n,s,r),e>=h&&this.right.forEachLine(t,e,i,o,h,r);else{let l=this.lineAt(h,u.ByPos,i,n,s);t<l.from&&this.left.forEachLine(t,l.from-1,i,n,s,r),l.to>=t&&l.from<=e&&r(l),e>l.to&&this.right.forEachLine(l.to+1,e,i,o,h,r)}}replace(t,e,i){let n=this.left.length+this.break;if(e<n)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let s=[];t>0&&this.decomposeLeft(t,s);let r=s.length;for(let o of i)s.push(o);if(t>0&&Wi(s,r-1),e<this.length){let t=s.length;this.decomposeRight(e,s),Wi(s,t)}return Li.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?Li.of(this.break?[t,null,e]:[t,e]):(this.left=t,this.right=e,this.height=t.height+e.height,this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,i=!1,n){let{left:s,right:r}=this,o=e+s.length+this.break,h=null;return n&&n.from<=e+s.length&&n.more?h=s=s.updateHeight(t,e,i,n):s.updateHeight(t,e,i),n&&n.from<=o+r.length&&n.more?h=r=r.updateHeight(t,o,i,n):r.updateHeight(t,o,i),h?this.balanced(s,r):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Wi(t,e){let i,n;null==t[e]&&(i=t[e-1])instanceof Vi&&(n=t[e+1])instanceof Vi&&t.splice(e-1,3,new Vi(i.length+1+n.length))}const Fi=5;class zi{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 Ii?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new Ii(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,s=i.widget?i.widget.lineBreaks:0;n<0&&(n=this.oracle.lineHeight);let r=e-t;i.block?this.addBlock(new Ni(r,n,i)):(r||s||n>=Fi)&&this.addLineDeco(n,s,r)}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 Ii(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new Vi(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 Ii)return t;let e=new Ii(0,-1);return this.nodes.push(e),e}addBlock(t){var e;this.enterLine();let i=null===(e=t.deco)||void 0===e?void 0:e.type;i!=a.WidgetAfter||this.isCovered||this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,i!=a.WidgetBefore&&(this.covering=t)}addLineDeco(t,e,i){let n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,t),n.breaks+=e,this.writtenTo=this.pos=this.pos+i}finish(t){let e=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof Ii||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new Ii(0,-1));let i=t;for(let n of this.nodes)n instanceof Ii&&n.updateHeight(this.oracle,i),i+=n?n.length:1;return this.nodes}static build(t,e,i,n){let s=new zi(i,t);return r.Xs.spans(e,i,n,s,0),s.finish(i)}}function _i(t,e,i){let n=new ji;return r.Xs.compare(t,e,i,n,0),n.changes}class ji{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,n){(t<e||i&&i.heightRelevant||n&&n.heightRelevant)&&kt(t,e,this.changes,5)}}function qi(t,e){let i=t.getBoundingClientRect(),n=t.ownerDocument,s=n.defaultView||window,r=Math.max(0,i.left),o=Math.min(s.innerWidth,i.right),h=Math.max(0,i.top),l=Math.min(s.innerHeight,i.bottom);for(let a=t.parentNode;a&&a!=n.body;)if(1==a.nodeType){let e=a,i=window.getComputedStyle(e);if((e.scrollHeight>e.clientHeight||e.scrollWidth>e.clientWidth)&&"visible"!=i.overflow){let i=e.getBoundingClientRect();r=Math.max(r,i.left),o=Math.min(o,i.right),h=Math.max(h,i.top),l=a==t.parentNode?i.bottom:Math.min(l,i.bottom)}a="absolute"==i.position||"fixed"==i.position?e.offsetParent:e.parentNode}else{if(11!=a.nodeType)break;a=a.host}return{left:r-i.left,right:Math.max(r,o)-i.left,top:h-(i.top+e),bottom:Math.max(h,l)-(i.top+e)}}function $i(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class Ki{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 vt.replace({widget:new Ji(this.size,t)}).range(this.from,this.to)}}class Ji extends wt{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 Gi{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.scrollTop=0,this.scrolledToBottom=!0,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=tn,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=c.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let e=t.facet(Jt).some((t=>"function"!=typeof t&&"cm-lineWrapping"==t.class));this.heightOracle=new Ei(e),this.stateDeco=t.facet(Gt).filter((t=>"function"!=typeof t)),this.heightMap=Li.empty().applyChanges(this.stateDeco,r.xv.empty,this.heightOracle.setDoc(t.doc),[new Zt(0,0,0,t.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=vt.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 Ui(e,i))}}this.viewports=t.sort(((t,e)=>t.from-e.from)),this.scaler=this.heightMap.height<=7e6?tn:new en(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,(t=>{this.viewportLines.push(1==this.scaler.scale?t:nn(t,this.scaler))}))}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(Gt).filter((t=>"function"!=typeof t));let n=t.changedRanges,s=Zt.extendWithRanges(n,_i(i,this.stateDeco,t?t.changes:r.as.empty(this.state.doc.length))),o=this.heightMap.height,h=this.scrolledToBottom?null:this.lineBlockAtHeight(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),s),this.heightMap.height!=o&&(t.flags|=2),h?(this.scrollAnchorPos=t.changes.mapPos(h.from,-1),this.scrollAnchorHeight=h.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let l=s.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<l.from||e.range.head>l.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,e));let a=!t.changes.empty||2&t.flags||l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,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&&!t.state.facet(Vt)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),n=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?c.RTL:c.LTR;let o=this.heightOracle.mustRefreshForWrapping(s),h=e.getBoundingClientRect(),l=o||this.mustMeasureContent||this.contentDOMHeight!=h.height;this.contentDOMHeight=h.height,this.mustMeasureContent=!1;let a=0,u=0,f=parseInt(i.paddingTop)||0,d=parseInt(i.paddingBottom)||0;this.paddingTop==f&&this.paddingBottom==d||(this.paddingTop=f,this.paddingBottom=d,a|=10),this.editorWidth!=t.scrollDOM.clientWidth&&(n.lineWrapping&&(l=!0),this.editorWidth=t.scrollDOM.clientWidth,a|=8),this.scrollTop!=t.scrollDOM.scrollTop&&(this.scrollAnchorHeight=-1,this.scrollTop=t.scrollDOM.scrollTop),this.scrolledToBottom=this.scrollTop>t.scrollDOM.scrollHeight-t.scrollDOM.clientHeight-4;let g=(this.printing?$i:qi)(e,this.paddingTop),p=g.top-this.pixelViewport.top,m=g.bottom-this.pixelViewport.bottom;this.pixelViewport=g;let w=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(w!=this.inView&&(this.inView=w,w&&(l=!0)),!this.inView&&!this.scrollTarget)return 0;let v=h.width;if(this.contentDOMWidth==v&&this.editorHeight==t.scrollDOM.clientHeight||(this.contentDOMWidth=h.width,this.editorHeight=t.scrollDOM.clientHeight,a|=8),l){let e=t.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(e)&&(o=!0),o||n.lineWrapping&&Math.abs(v-this.contentDOMWidth)>n.charWidth){let{lineHeight:i,charWidth:r,textHeight:h}=t.docView.measureTextSize();o=i>0&&n.refresh(s,i,r,h,v/r,e),o&&(t.docView.minWidth=0,a|=8)}p>0&&m>0?u=Math.max(p,m):p<0&&m<0&&(u=Math.min(p,m)),n.heightChanged=!1;for(let i of this.viewports){let s=i.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(i);this.heightMap=(o?Li.empty().applyChanges(this.stateDeco,r.xv.empty,this.heightOracle,[new Zt(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(n,0,o,new Ri(i.from,s))}n.heightChanged&&(a|=2)}let y=!this.viewportIsAppropriate(this.viewport,u)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return y&&(this.viewport=this.getViewport(u,this.scrollTarget)),this.updateForViewport(),(2&a||y)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,t)),a|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),a}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),n=this.heightMap,s=this.heightOracle,{visibleTop:r,visibleBottom:o}=this,h=new Ui(n.lineAt(r-1e3*i,u.ByHeight,s,0,0).from,n.lineAt(o+1e3*(1-i),u.ByHeight,s,0,0).to);if(e){let{head:t}=e.range;if(t<h.from||t>h.to){let i,r=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),o=n.lineAt(t,u.ByPos,s,0,0);i="center"==e.y?(o.top+o.bottom)/2-r/2:"start"==e.y||"nearest"==e.y&&t<h.from?o.top:o.bottom-r,h=new Ui(n.lineAt(i-500,u.ByHeight,s,0,0).from,n.lineAt(i+r+500,u.ByHeight,s,0,0).to)}}return h}mapViewport(t,e){let i=e.mapPos(t.from,-1),n=e.mapPos(t.to,1);return new Ui(this.heightMap.lineAt(i,u.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,u.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(t,u.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(e,u.ByPos,this.heightOracle,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 Ki(e.mapPos(n.from),e.mapPos(n.to),n.size));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,s=n>>1,o=n<<1;if(this.defaultTextDirection!=c.LTR&&!i)return[];let h=[],l=(n,o,a,c)=>{if(o-n<s)return;let u=this.state.selection.main,f=[u.from];u.empty||f.push(u.to);for(let t of f)if(t>n&&t<o)return l(n,t-10,a,c),void l(t+10,o,a,c);let d=Zi(t,(t=>t.from>=a.from&&t.to<=a.to&&Math.abs(t.from-n)<s&&Math.abs(t.to-o)<s&&!f.some((e=>t.from<e&&t.to>e))));if(!d){if(o<a.to&&e&&i&&e.visibleRanges.some((t=>t.from<=o&&t.to>=o))){let t=e.moveToLineBoundary(r.jT.cursor(o),!1,!0).head;t>n&&(o=t)}d=new Ki(n,o,this.gapSize(a,n,o,c))}h.push(d)};for(let r of this.viewportLines){if(r.length<o)continue;let t=Xi(r.from,r.to,this.stateDeco);if(t.total<o)continue;let e,s,h=this.scrollTarget?this.scrollTarget.range.head:null;if(i){let i,o,l=n/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=h){let e=Qi(t,h),n=((this.visibleBottom-this.visibleTop)/2+l)/r.height;i=e-n,o=e+n}else i=(this.visibleTop-r.top-l)/r.height,o=(this.visibleBottom-r.top+l)/r.height;e=Yi(t,i),s=Yi(t,o)}else{let i,r,o=t.total*this.heightOracle.charWidth,l=n*this.heightOracle.charWidth;if(null!=h){let e=Qi(t,h),n=((this.pixelViewport.right-this.pixelViewport.left)/2+l)/o;i=e-n,r=e+n}else i=(this.pixelViewport.left-l)/o,r=(this.pixelViewport.right+l)/o;e=Yi(t,i),s=Yi(t,r)}e>r.from&&l(r.from,e,r,t),s<r.to&&l(s,r.to,r,t)}return h}gapSize(t,e,i,n){let s=Qi(n,i)-Qi(n,e);return this.heightOracle.lineWrapping?t.height*s:n.total*this.heightOracle.charWidth*s}updateLineGaps(t){Ki.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=vt.set(t.map((t=>t.draw(this.heightOracle.lineWrapping)))))}computeVisibleRanges(){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let e=[];r.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))||nn(this.heightMap.lineAt(t,u.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return nn(this.heightMap.lineAt(this.scaler.fromDOM(t),u.ByHeight,this.heightOracle,0,0),this.scaler)}elementAtHeight(t){return nn(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Ui{constructor(t,e){this.from=t,this.to=e}}function Xi(t,e,i){let n=[],s=t,o=0;return r.Xs.spans(i,t,e,{span(){},point(t,e){t>s&&(n.push({from:s,to:t}),o+=t-s),s=e}},20),s<e&&(n.push({from:s,to:e}),o+=e-s),{total:o,ranges:n}}function Yi({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 Qi(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 Zi(t,e){for(let i of t)if(e(i))return i}const tn={toDOM(t){return t},fromDOM(t){return t},scale:1};class en{constructor(t,e,i){let n=0,s=0,r=0;this.viewports=i.map((({from:i,to:s})=>{let r=e.lineAt(i,u.ByPos,t,0,0).top,o=e.lineAt(s,u.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 nn(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),n=e.toDOM(t.bottom);return new Bi(t.from,t.length,i,n-i,Array.isArray(t._content)?t._content.map((t=>nn(t,e))):t._content)}const sn=r.r$.define({combine:t=>t.join(" ")}),rn=r.r$.define({combine:t=>t.indexOf(!0)>-1}),on=o.V.newName(),hn=o.V.newName(),ln=o.V.newName(),an={"&light":"."+hn,"&dark":"."+ln};function cn(t,e,i){return new o.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 un=cn("."+on,{"&":{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,flexShrink:0,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",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",left:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",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"},".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"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},an);class fn{constructor(t,e,i,n){this.typeOver=n,this.bounds=null,this.text="";let{impreciseHead:s,impreciseAnchor:o}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let e=s||o?[]:pn(t),i=new me(e,t.state);i.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=i.text,this.newSel=mn(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=s&&s.node==e.focusNode&&s.offset==e.focusOffset||!g(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),n=o&&o.node==e.anchorNode&&o.offset==e.anchorOffset||!g(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset);this.newSel=r.jT.single(n,i)}}}function dn(t,e){let i,{newSel:n}=e,s=t.state.selection.main,o=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:n,to:h}=e.bounds,a=s.from,c=null;(8===o||l.android&&e.text.length<h-n)&&(a=s.to,c="end");let u=gn(t.state.doc.sliceString(n,h,pe),e.text,a-n,c);u&&(l.chrome&&13==o&&u.toB==u.from+2&&e.text.slice(u.from,u.toB)==pe+pe&&u.toB--,i={from:n+u.from,to:n+u.toA,insert:r.xv.of(e.text.slice(u.from,u.toB).split(pe))})}else n&&(!t.hasFocus&&t.state.facet(zt)||n.main.eq(s))&&(n=null);if(!i&&!n)return!1;if(!i&&e.typeOver&&!s.empty&&n&&n.main.empty?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,s.to)}:i&&i.from>=s.from&&i.to<=s.to&&(i.from!=s.from||i.to!=s.to)&&s.to-s.from-(i.to-i.from)<=4?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,s.to))}:(l.mac||l.android)&&i&&i.from==i.to&&i.from==s.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(n&&2==i.insert.length&&(n=r.jT.single(n.main.anchor-1,n.main.head-1)),i={from:s.from,to:s.to,insert:r.xv.of([" "])}):l.chrome&&i&&i.from==i.to&&i.from==s.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(n&&(n=r.jT.single(n.main.anchor-1,n.main.head-1)),i={from:s.from,to:s.to,insert:r.xv.of([" "])}),i){let e=t.state;if(l.ios&&t.inputState.flushIOSKey(t))return!0;if(l.android&&(i.from==s.from&&i.to==s.to&&1==i.insert.length&&2==i.insert.lines&&R(t.contentDOM,"Enter",13)||(i.from==s.from-1&&i.to==s.to&&0==i.insert.length||8==o&&i.insert.length<i.to-i.from)&&R(t.contentDOM,"Backspace",8)||i.from==s.from&&i.to==s.to+1&&0==i.insert.length&&R(t.contentDOM,"Delete",46)))return!0;let h,a=i.insert.toString();if(t.state.facet(Lt).some((e=>e(t,i.from,i.to,a))))return!0;if(t.inputState.composing>=0&&t.inputState.composing++,i.from>=s.from&&i.to<=s.to&&i.to-i.from>=(s.to-s.from)/3&&(!n||n.main.empty&&n.main.from==i.from+i.insert.length)&&t.inputState.composing<0){let n=s.from<i.from?e.sliceDoc(s.from,i.from):"",r=s.to>i.to?e.sliceDoc(i.to,s.to):"";h=e.replaceSelection(t.state.toText(n+i.insert.sliceString(0,void 0,t.state.lineBreak)+r))}else{let o=e.changes(i),l=n&&n.main.to<=o.newLength?n.main:void 0;if(e.selection.ranges.length>1&&t.inputState.composing>=0&&i.to<=s.to&&i.to>=s.to-10){let n=t.state.sliceDoc(i.from,i.to),a=xe(t)||t.state.doc.lineAt(s.head),c=s.to-i.to,u=s.to-s.from;h=e.changeByRange((h=>{if(h.from==s.from&&h.to==s.to)return{changes:o,range:l||h.map(o)};let f=h.to-c,d=f-n.length;if(h.to-h.from!=u||t.state.sliceDoc(d,f)!=n||a&&h.to>=a.from&&h.from<=a.to)return{range:h};let g=e.changes({from:d,to:f,insert:i.insert}),p=h.to-s.to;return{changes:g,range:l?r.jT.range(Math.max(0,l.anchor+p),Math.max(0,l.head+p)):h.map(g)}}))}else h={changes:o,selection:l&&e.selection.replaceRange(l)}}let c="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,c+=".compose",t.inputState.compositionFirstChange&&(c+=".start",t.inputState.compositionFirstChange=!1)),t.dispatch(h,{scrollIntoView:!0,userEvent:c}),!0}if(n&&!n.main.eq(s)){let e=!1,i="select";return t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(e=!0),i=t.inputState.lastSelectionOrigin),t.dispatch({selection:n,scrollIntoView:e,userEvent:i}),!0}return!1}function gn(t,e,i,n){let s=Math.min(t.length,e.length),r=0;for(;r<s&&t.charCodeAt(r)==e.charCodeAt(r);)r++;if(r==s&&t.length==e.length)return null;let o=t.length,h=e.length;for(;o>0&&h>0&&t.charCodeAt(o-1)==e.charCodeAt(h-1);)o--,h--;if("end"==n){i-=o+Math.max(0,r-Math.min(o,h))-r}if(o<r&&t.length<e.length){r-=i<=r&&i>=o?r-i:0,h=r+(h-o),o=r}else if(h<r){r-=i<=r&&i>=h?r-i:0,o=r+(o-h),h=r}return{from:r,toA:o,toB:h}}function pn(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 ve(i,n)),s==i&&r==n||e.push(new ve(s,r))),e}function mn(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?r.jT.single(i+e,n+e):null}const wn={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},vn=l.ie&&l.ie_version<=11;class yn{constructor(t){this.view=t,this.active=!1,this.selectionRange=new C,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.resizeContent=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);(l.ie&&l.ie_version<=11||l.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()})),vn&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver((()=>{var t;(null===(t=this.view.docView)||void 0===t?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()})),this.resizeScroll.observe(t.scrollDOM),this.resizeContent=new ResizeObserver((()=>this.view.requestMeasure())),this.resizeContent.observe(t.contentDOM)),this.addWindowListeners(this.win=t.win),this.start(),"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")))}),{threshold:[0,.001]}),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()}onScrollChanged(t){this.view.inputState.runScrollHandlers(this.view,t),this.intersecting&&this.view.measure()}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){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(zt)?i.root.activeElement!=this.dom:!m(i.dom,n))return;let s=n.anchorNode&&i.docView.nearest(n.anchorNode);s&&s.ignoreEvent(t)?e||(this.selectionChanged=!1):(l.ie&&l.ie_version<=11||l.android&&l.chrome)&&!i.state.selection.main.empty&&n.focusNode&&v(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=l.safari&&11==t.root.nodeType&&p(this.dom.ownerDocument)==this.dom&&xn(this.view)||d(t.root);if(!e||this.selectionRange.eq(e))return!1;let i=m(this.dom,e);return i&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&L(this.dom,e)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(e),i&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let i=this.dom;i;)if(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,wn),vn&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),vn&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var i;if(!this.delayedAndroidKey){let t=()=>{let t=this.delayedAndroidKey;if(t){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=t.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&t.force&&R(this.dom,t.key,t.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(t)}this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(null===(i=this.delayedAndroidKey)||void 0===i?void 0:i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame((()=>{this.delayedFlush=-1,this.flush()})))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,n=!1;for(let 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}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),n=this.selectionChanged&&m(this.dom,this.selectionRange);return t<0&&!n?null:(t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1,new fn(this.view,t,e,i))}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return!1;let i=this.view.state,n=dn(this.view,e);return this.view.state==i&&this.view.update([]),n}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=bn(e,t.previousSibling||t.target.previousSibling,-1),n=bn(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}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var t,e,i,n;this.stop(),null===(t=this.intersection)||void 0===t||t.disconnect(),null===(e=this.gapIntersection)||void 0===e||e.disconnect(),null===(i=this.resizeScroll)||void 0===i||i.disconnect(),null===(n=this.resizeContent)||void 0===n||n.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}}function bn(t,e,i){for(;e;){let n=V.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 xn(t){let e=null;function i(t){t.preventDefault(),t.stopImmediatePropagation(),e=t.getTargetRanges()[0]}if(t.contentDOM.addEventListener("beforeinput",i,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",i,!0),!e)return null;let n=e.startContainer,s=e.startOffset,r=e.endContainer,o=e.endOffset,h=t.docView.domAtPos(t.state.selection.main.anchor);return v(h.node,h.offset,r,o)&&([n,s,r,o]=[r,o,n,s]),{anchorNode:n,anchorOffset:s,focusNode:r,focusOffset:o}}class Sn{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: fixed; 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||B(t.parent)||document,this.viewState=new Gi(t.state||r.yy.create(t)),this.plugins=this.state.facet(jt).map((t=>new $t(t)));for(let e of this.plugins)e.update(this);this.observer=new yn(this),this.inputState=new Ge(this),this.inputState.ensureHandlers(this,this.plugins),this.docView=new ye(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}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}dispatch(...t){let e=1==t.length&&t[0]instanceof r.YW?t[0]:this.state.update(...t);this._dispatch(e,this)}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=!1,s=this.state;for(let r of t){if(r.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=r.state}if(this.destroyed)return void(this.viewState.state=s);let o=this.hasFocus,h=0,l=null;t.some((t=>t.annotation(Ci)))?(this.inputState.notifiedFocused=o,h=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=Oi(s,o),l||(h=1));let a=this.observer.delayedAndroidKey,c=null;if(a?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(c=null)):this.observer.clear(),s.facet(r.yy.phrases)!=this.state.facet(r.yy.phrases))return this.setState(s);e=te.create(this,s,t),e.flags|=h;let u=this.viewState.scrollTarget;try{this.updateState=2;for(let e of t){if(u&&(u=u.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection;u=new Ht(t.empty?t:r.jT.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(Wt)&&(u=t.value)}this.viewState.update(e,u),this.bidiCache=Mn.update(this.bidiCache,e.changes),e.empty||(this.updatePlugins(e),this.inputState.update(e)),i=this.docView.update(e),this.state.facet(Qt)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(i,t.some((t=>t.isUserEvent("select.pointer"))))}finally{this.updateState=0}if(e.startState.facet(sn)!=e.state.facet(sn)&&(this.viewState.mustMeasureContent=!0),(i||n||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!e.empty)for(let r of this.state.facet(Pt))r(e);(l||c)&&Promise.resolve().then((()=>{l&&this.state==l.startState&&this.dispatch(l),c&&!dn(this,c)&&a.force&&R(this.contentDOM,a.key,a.keyCode)}))}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 Gi(t),this.plugins=t.facet(jt).map((t=>new $t(t))),this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView=new ye(this),this.inputState.ensureHandlers(this,this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(jt),i=t.state.facet(jt);if(e!=i){let n=[];for(let s of i){let i=e.indexOf(s);if(i<0)n.push(new $t(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,this.plugins)}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&&this.win.cancelAnimationFrame(this.measureScheduled),this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,i=this.scrollDOM,{scrollTop:n}=i,{scrollAnchorPos:s,scrollAnchorHeight:r}=this.viewState;if(this.viewState.scrollAnchorHeight=-1,r<0||n!=this.viewState.scrollTop)if(n>i.scrollHeight-i.clientHeight-4)s=-1,r=this.viewState.heightMap.height;else{let t=this.viewState.lineBlockAtHeight(n);s=t.from,r=t.top}try{for(let t=0;;t++){this.updateState=1;let h=this.viewport,l=this.viewState.measure(this);if(!l&&!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 a=[];4&l||([this.measureRequests,a]=[a,this.measureRequests]);let c=a.map((t=>{try{return t.read(this)}catch(e){return Ft(this.state,e),An}})),u=te.create(this,this.state,[]),f=!1,d=!1;u.flags|=l,e?e.flags|=l:e=u,this.updateState=2,u.empty||(this.updatePlugins(u),this.inputState.update(u),this.updateAttrs(),f=this.docView.update(u));for(let t=0;t<a.length;t++)if(c[t]!=An)try{let e=a[t];e.write&&e.write(c[t],this)}catch(o){Ft(this.state,o)}if(this.viewState.editorHeight)if(this.viewState.scrollTarget)this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,d=!0;else if(r>-1){let t=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-r;(t>1||t<-1)&&(i.scrollTop=n+t,d=!0)}if(f&&this.docView.updateSelection(!0),this.viewport.from==h.from&&this.viewport.to==h.to&&!d&&0==this.measureRequests.length)break;r=-1}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let h of this.state.facet(Pt))h(e)}get themeClasses(){return on+" "+(this.state.facet(rn)?ln:hn)+" "+this.state.facet(sn)}updateAttrs(){let t=Cn(this,Kt,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(zt)?"true":"false",class:"cm-content",style:`${l.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),Cn(this,Jt,e);let i=this.observer.ignore((()=>{let i=mt(this.contentDOM,this.contentAttrs,e),n=mt(this.dom,this.editorAttrs,t);return i||n}));return this.editorAttrs=t,this.contentAttrs=e,i}showAnnouncements(t){let e=!0;for(let i of t)for(let t of i.effects)if(t.is(Sn.announce)){e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(Qt),o.V.mount(this.root,this.styleModules.concat(un).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=this.win.requestAnimationFrame((()=>this.measure()))),t){if(this.measureRequests.indexOf(t)>-1)return;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)}}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}}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return Je(this,t,je(this,t,e,i))}moveByGroup(t,e){return Je(this,t,je(this,t,e,(e=>qe(this,t.head,e))))}moveToLineBoundary(t,e,i=!0){return _e(this,t,e,i)}moveVertically(t,e,i){return Je(this,t,$e(this,t,e,i))}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){return this.readMeasured(),Ve(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);return S(i,s[ae.find(s,t-n.from,-1,e)].dir==c.LTR==e>0)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(It)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>kn)return fe(t.length);let e=this.textDirectionAt(t.from);for(let n of this.bidiCache)if(n.from==t.from&&n.dir==e)return n.order;let i=ue(t.text,e);return this.bidiCache.push(new Mn(t.from,t.to,e,i)),i}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||l.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{D(this.contentDOM),this.docView.updateSelection()}))}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((9==t.nodeType?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return Wt.of(new Ht("number"==typeof t?r.jT.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}static domEventHandlers(t){return qt.define((()=>({})),{eventHandlers:t})}static theme(t,e){let i=o.V.newName(),n=[sn.of(i),Qt.of(cn(`.${i}`,t))];return e&&e.dark&&n.push(rn.of(!0)),n}static baseTheme(t){return r.Wl.lowest(Qt.of(cn("."+on,t,an)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),n=i&&V.get(i)||V.get(t);return(null===(e=null==n?void 0:n.rootView)||void 0===e?void 0:e.view)||null}}Sn.styleModule=Qt,Sn.inputHandler=Lt,Sn.focusChangeEffect=Nt,Sn.perLineTextDirection=It,Sn.exceptionSink=Bt,Sn.updateListener=Pt,Sn.editable=zt,Sn.mouseSelectionStyle=Rt,Sn.dragMovesSelection=Et,Sn.clickAddsSelectionRange=Dt,Sn.decorations=Gt,Sn.atomicRanges=Ut,Sn.scrollMargins=Xt,Sn.darkTheme=rn,Sn.contentAttributes=Jt,Sn.editorAttributes=Kt,Sn.lineWrapping=Sn.contentAttributes.of({class:"cm-lineWrapping"}),Sn.announce=r.Py.define();const kn=4096,An={};class Mn{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:c.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 Mn(e.mapPos(r.from,1),e.mapPos(r.to,-1),r.dir,r.order))}return i}}function Cn(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&&gt(r,i)}return i}const On=!l.ios;const Tn={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};On&&(Tn[".cm-line"].caretColor="transparent !important");class Dn extends r.uU{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Dn.prototype.elementClass="",Dn.prototype.toDOM=void 0,Dn.prototype.mapMode=r.gc.TrackBefore,Dn.prototype.startSide=Dn.prototype.endSide=-1,Dn.prototype.point=!0;n()}catch(f){n(f)}}))},16708:function(t,e,i){i.d(e,{BO:function(){return Ot},D0:function(){return St},Gz:function(){return $t},IS:function(){return qt},Py:function(){return gt},QQ:function(){return $},Wl:function(){return Y},Xs:function(){return Bt},YW:function(){return pt},as:function(){return O},bg:function(){return S},cp:function(){return m},f_:function(){return Pt},gc:function(){return M},gm:function(){return x},jT:function(){return N},nZ:function(){return k},q6:function(){return ut},r$:function(){return H},uU:function(){return Tt},xv:function(){return n},yy:function(){return Ct}});i(63721),i(52247),i(71695),i(92745),i(52805),i(61495),i(61893),i(23669),i(69235),i(12385),i(19134),i(32517),i(5740),i(11740),i(92519),i(42179),i(89256),i(24931),i(88463),i(57449),i(19814),i(97003),i(32114),i(39527),i(92181),i(99790),i(67670),i(41360),i(13334),i(34595),i(36993),i(47021);class n{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),r.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),r.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 l(this),s=new l(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 l(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 c(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}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 s(t):r.from(s.split(t,[])):n.empty}}class s extends n{constructor(t,e=function(t){let e=-1;for(let i of t)e+=i.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.text[s],o=n+r.length;if((e?i:o)>=t)return new u(n,o,i,r);n=o+1,i++}}decompose(t,e,i,n){let r=t<=0&&e>=this.length?this:new s(h(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&n){let t=i.pop(),e=o(r.text,t.text.slice(),0,r.length);if(e.length<=32)i.push(new s(e,t.length+r.length));else{let t=e.length>>1;i.push(new s(e.slice(0,t)),new s(e.slice(t)))}}else i.push(r)}replace(t,e,i){if(!(i instanceof s))return super.replace(t,e,i);let n=o(this.text,o(i.text,h(this.text,0,t)),e),l=this.length+i.length-(e-t);return n.length<=32?new s(n,l):r.from(s.split(n,[]),l)}sliceString(t,e=this.length,i="\n"){let n="";for(let s=0,r=0;s<=e&&r<this.text.length;r++){let o=this.text[r],h=s+o.length;s>t&&r&&(n+=i),t<h&&e>s&&(n+=o.slice(Math.max(0,t-s),e-s)),s=h+1}return n}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],n=-1;for(let r of t)i.push(r),n+=r.length+1,32==i.length&&(e.push(new s(i,n)),i=[],n=-1);return n>-1&&e.push(new s(i,n)),e}}class r extends n{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,h=i+r.lines-1;if((e?h:o)>=t)return r.lineInner(t,e,i,n);n=o+1,i=h+1}}decompose(t,e,i,n){for(let s=0,r=0;r<=e&&s<this.children.length;s++){let o=this.children[s],h=r+o.length;if(t<=h&&e>=r){let s=n&((r<=t?1:0)|(h>=e?2:0));r>=t&&h<=e&&!s?i.push(o):o.decompose(t-r,e-r,i,s)}r=h+1}}replace(t,e,i){if(i.lines<this.lines)for(let n=0,s=0;n<this.children.length;n++){let o=this.children[n],h=s+o.length;if(t>=s&&e<=h){let l=o.replace(t-s,e-s,i),a=this.lines-o.lines+l.lines;if(l.lines<a>>4&&l.lines>a>>6){let s=this.children.slice();return s[n]=l,new r(s,this.length-(e-t)+i.length)}return super.replace(s,h,l)}s=h+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i="\n"){let n="";for(let s=0,r=0;s<this.children.length&&r<=e;s++){let o=this.children[s],h=r+o.length;r>t&&s&&(n+=i),t<h&&e>r&&(n+=o.sliceString(t-r,e-r,i)),r=h+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof r))return 0;let i=0,[n,s,o,h]=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==o||s==h)return i;let r=this.children[n],l=t.children[s];if(r!=l)return i+r.scanIdentical(l,e);i+=r.length+1}}static from(t,e=t.reduce(((t,e)=>t+e.length+1),-1)){let i=0;for(let s of t)i+=s.lines;if(i<32){let i=[];for(let e of t)e.flatten(i);return new s(i,e)}let n=Math.max(32,i>>5),o=n<<1,h=n>>1,l=[],a=0,c=-1,u=[];function f(t){let e;if(t.lines>o&&t instanceof r)for(let i of t.children)f(i);else t.lines>h&&(a>h||!a)?(d(),l.push(t)):t instanceof s&&a&&(e=u[u.length-1])instanceof s&&t.lines+e.lines<=32?(a+=t.lines,c+=t.length+1,u[u.length-1]=new s(e.text.concat(t.text),e.length+1+t.length)):(a+t.lines>n&&d(),a+=t.lines,c+=t.length+1,u.push(t))}function d(){0!=a&&(l.push(1==u.length?u[0]:r.from(u,c)),c=-1,a=u.length=0)}for(let s of t)f(s);return d(),1==l.length?l[0]:new r(l,e)}}function o(t,e,i=0,n=1e9){for(let s=0,r=0,o=!0;r<t.length&&s<=n;r++){let h=t[r],l=s+h.length;l>=i&&(l>n&&(h=h.slice(0,n-s)),s<i&&(h=h.slice(i-s)),o?(e[e.length-1]+=h,o=!1):e.push(h)),s=l+1}return e}function h(t,e,i){return o(t,[""],e,i)}n.empty=new s([""],0);class l{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 s?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],r=this.offsets[i],o=r>>1,h=n instanceof s?n.text.length:n.children.length;if(o==(e>0?h: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&r)==(e>0?0:1)){if(this.offsets[i]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(n instanceof s){let s=n.text[o+(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 r=n.children[o+(e<0?-1:0)];t>r.length?(t-=r.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(r),this.offsets.push(e>0?1:(r instanceof s?r.text.length:r.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 l(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 c{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&&(n.prototype[Symbol.iterator]=function(){return this.iter()},l.prototype[Symbol.iterator]=a.prototype[Symbol.iterator]=c.prototype[Symbol.iterator]=function(){return this});class u{constructor(t,e,i,n){this.from=t,this.to=e,this.number=i,this.text=n}get length(){return this.to-this.from}}let f="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 Jt=1;Jt<f.length;Jt++)f[Jt]+=f[Jt-1];function d(t){for(let e=1;e<f.length;e+=2)if(f[e]>t)return f[e-1]<=t;return!1}function g(t){return t>=127462&&t<=127487}const p=8205;function m(t,e,i=!0,n=!0){return(i?w:v)(t,e,n)}function w(t,e,i){if(e==t.length)return e;e&&y(t.charCodeAt(e))&&b(t.charCodeAt(e-1))&&e--;let n=x(t,e);for(e+=k(n);e<t.length;){let s=x(t,e);if(n==p||s==p||i&&d(s))e+=k(s),n=s;else{if(!g(s))break;{let i=0,n=e-2;for(;n>=0&&g(x(t,n));)i++,n-=2;if(i%2==0)break;e+=2}}}return e}function v(t,e,i){for(;e>0;){let n=w(t,e-2,i);if(n<e)return n;e--}return 0}function y(t){return t>=56320&&t<57344}function b(t){return t>=55296&&t<56320}function x(t,e){let i=t.charCodeAt(e);if(!b(i)||e+1==t.length)return i;let n=t.charCodeAt(e+1);return y(n)?n-56320+(i-55296<<10)+65536:i}function S(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10),56320+(1023&t)))}function k(t){return t<65536?1:2}const A=/\r\n?|\n/;var M=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(M||(M={}));class C{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){E(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 C(t)}composeDesc(t){return this.empty?t:t.empty?this:B(this,t)}mapDesc(t,e=!1){return t.empty?this:R(this,t,e)}mapPos(t,e=-1,i=M.Simple){let n=0,s=0;for(let r=0;r<this.sections.length;){let o=this.sections[r++],h=this.sections[r++],l=n+o;if(h<0){if(l>t)return s+(t-n);s+=o}else{if(i!=M.Simple&&l>=t&&(i==M.TrackDel&&n<t&&l>t||i==M.TrackBefore&&n<t||i==M.TrackAfter&&l>t))return null;if(l>t||l==t&&e<0&&!o)return t==n||e<0?s:s+h;s+=h}n=l}if(t>n)throw new RangeError(`Position ${t} is out of range for changeset of length ${n}`);return s}touchesRange(t,e=t){for(let i=0,n=0;i<this.sections.length&&n<=e;){let s=n+this.sections[i++];if(this.sections[i++]>=0&&n<=e&&s>=t)return!(n<t&&s>e)||"cover";n=s}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];t+=(t?" ":"")+i+(n>=0?":"+n:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some((t=>"number"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeDesc");return new C(t)}static create(t){return new C(t)}}class O extends C{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 E(this,((e,i,n,s,r)=>t=t.replace(n,n+(i-e),r)),!1),t}mapDesc(t,e=!1){return R(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let s=0,r=0;s<e.length;s+=2){let o=e[s],h=e[s+1];if(h>=0){e[s]=h,e[s+1]=o;let l=s>>1;for(;i.length<l;)i.push(n.empty);i.push(o?t.slice(r,r+o):n.empty)}r+=o}return new O(e,i)}compose(t){return this.empty?t:t.empty?this:B(this,t,!0)}map(t,e=!1){return t.empty?this:R(this,t,e,!0)}iterChanges(t,e=!1){E(this,t,e)}get desc(){return C.create(this.sections)}filter(t){let e=[],i=[],n=[],s=new P(this);t:for(let r=0,o=0;;){let h=r==t.length?1e9:t[r++];for(;o<h||o==h&&0==s.len;){if(s.done)break t;let t=Math.min(s.len,h-o);T(n,t,-1);let r=-1==s.ins?-1:0==s.off?s.ins:0;T(e,t,r),r>0&&D(i,e,s.text),s.forward(t),o+=t}let l=t[r++];for(;o<l;){if(s.done)break t;let t=Math.min(s.len,l-o);T(e,t,-1),T(n,t,-1==s.ins?-1:0==s.off?s.ins:0),s.forward(t),o+=t}}return{changes:new O(e,i),filtered:C.create(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 s=[],r=[],o=0,h=null;function l(t=!1){if(!t&&!s.length)return;o<e&&T(s,e-o,-1);let i=new O(s,r);h=h?h.compose(i.map(h)):i,s=[],r=[],o=0}return function t(a){if(Array.isArray(a))for(let e of a)t(e);else if(a instanceof O){if(a.length!=e)throw new RangeError(`Mismatched change set length (got ${a.length}, expected ${e})`);l(),h=h?h.compose(a.map(h)):a}else{let{from:t,to:h=t,insert:c}=a;if(t>h||t<0||h>e)throw new RangeError(`Invalid change range ${t} to ${h} (in doc of length ${e})`);let u=c?"string"==typeof c?n.of(c.split(i||A)):c:n.empty,f=u.length;if(t==h&&0==f)return;t<o&&l(),t>o&&T(s,t-o,-1),T(s,h-t,f),D(r,s,u),o=h}}(t),l(!h),h}static empty(t){return new O(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],i=[];for(let s=0;s<t.length;s++){let r=t[s];if("number"==typeof r)e.push(r,-1);else{if(!Array.isArray(r)||"number"!=typeof r[0]||r.some(((t,e)=>e&&"string"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==r.length)e.push(r[0],0);else{for(;i.length<s;)i.push(n.empty);i[s]=n.of(r.slice(1)),e.push(r[0],i[s].length)}}}return new O(e,i)}static createSet(t,e){return new O(t,e)}}function T(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 D(t,e,i){if(0==i.length)return;let s=e.length-2>>1;if(s<t.length)t[t.length-1]=t[t.length-1].append(i);else{for(;t.length<s;)t.push(n.empty);t.push(i)}}function E(t,e,i){let s=t.inserted;for(let r=0,o=0,h=0;h<t.sections.length;){let l=t.sections[h++],a=t.sections[h++];if(a<0)r+=l,o+=l;else{let c=r,u=o,f=n.empty;for(;c+=l,u+=a,a&&s&&(f=f.append(s[h-2>>1])),!(i||h==t.sections.length||t.sections[h+1]<0);)l=t.sections[h++],a=t.sections[h++];e(r,c,o,u,f),r=c,o=u}}}function R(t,e,i,n=!1){let s=[],r=n?[]:null,o=new P(t),h=new P(e);for(let l=-1;;)if(-1==o.ins&&-1==h.ins){let t=Math.min(o.len,h.len);T(s,t,-1),o.forward(t),h.forward(t)}else if(h.ins>=0&&(o.ins<0||l==o.i||0==o.off&&(h.len<o.len||h.len==o.len&&!i))){let t=h.len;for(T(s,h.ins,-1);t;){let e=Math.min(o.len,t);o.ins>=0&&l<o.i&&o.len<=e&&(T(s,0,o.ins),r&&D(r,s,o.text),l=o.i),o.forward(e),t-=e}h.next()}else{if(!(o.ins>=0)){if(o.done&&h.done)return r?O.createSet(s,r):C.create(s);throw new Error("Mismatched change set lengths")}{let t=0,e=o.len;for(;e;)if(-1==h.ins){let i=Math.min(e,h.len);t+=i,e-=i,h.forward(i)}else{if(!(0==h.ins&&h.len<e))break;e-=h.len,h.next()}T(s,t,l<o.i?o.ins:0),r&&l<o.i&&D(r,s,o.text),l=o.i,o.forward(o.len-e)}}}function B(t,e,i=!1){let n=[],s=i?[]:null,r=new P(t),o=new P(e);for(let h=!1;;){if(r.done&&o.done)return s?O.createSet(n,s):C.create(n);if(0==r.ins)T(n,r.len,0,h),r.next();else if(0!=o.len||o.done){if(r.done||o.done)throw new Error("Mismatched change set lengths");{let t=Math.min(r.len2,o.len),e=n.length;if(-1==r.ins){let e=-1==o.ins?-1:o.off?0:o.ins;T(n,t,e,h),s&&e&&D(s,n,o.text)}else-1==o.ins?(T(n,r.off?0:r.len,t,h),s&&D(s,n,r.textBit(t))):(T(n,r.off?0:r.len,o.off?0:o.ins,h),s&&!o.off&&D(s,n,o.text));h=(r.ins>t||o.ins>=0&&o.len>t)&&(h||n.length>e),r.forward2(t),o.forward(t)}}else T(n,0,o.ins,h),s&&D(s,n,o.text),o.next()}}class P{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.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?n.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 L{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,n;return this.empty?i=n=t.mapPos(this.from,e):(i=t.mapPos(this.from,1),n=t.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new L(i,n,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return N.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return N.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 N.range(t.anchor,t.head)}static create(t,e,i){return new L(t,e,i)}}class N{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:N.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 N([this.main],0)}addRange(t,e=!0){return N.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,N.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 N(t.ranges.map((t=>L.fromJSON(t))),t.main)}static single(t,e=t){return new N([N.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 N.normalized(t.slice(),e);i=s.to}return new N(t,e)}static cursor(t,e=0,i,n){return L.create(t,t,(0==e?0:e<0?4:8)|(null==i?3:Math.min(2,i))|(null!=n?n:33554431)<<5)}static range(t,e,i,n){let s=(null!=i?i:33554431)<<5|(null==n?3:Math.min(2,n));return e<t?L.create(e,t,24|s):L.create(t,e,(e>t?4:0)|s)}static normalized(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?N.range(o,r):N.range(r,o))}}return new N(t,e)}}function I(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let V=0;class H{constructor(t,e,i,n,s){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=V++,this.default=t([]),this.extensions="function"==typeof s?s(this):s}static define(t={}){return new H(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:W),!!t.static,t.enables)}of(t){return new F([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new F(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new F(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],(i=>e(i.field(t))))}}function W(t,e){return t==e||t.length==e.length&&t.every(((t,i)=>t===e[i]))}class F{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=this.id,r=t[s]>>1,o=2==this.type,h=!1,l=!1,a=[];for(let c of this.dependencies)"doc"==c?h=!0:"selection"==c?l=!0:1&(null!==(e=t[c.id])&&void 0!==e?e:1)||a.push(t[c.id]);return{create(t){return t.values[r]=i(t),1},update(t,e){if(h&&e.docChanged||l&&(e.docChanged||e.selection)||_(t,a)){let e=i(t);if(o?!z(e,t.values[r],n):!n(e,t.values[r]))return t.values[r]=e,1}return 0},reconfigure:(t,e)=>{let h,l=e.config.address[s];if(null!=l){let s=nt(e,l);if(this.dependencies.every((i=>i instanceof H?e.facet(i)===t.facet(i):!(i instanceof $)||e.field(i,!1)==t.field(i,!1)))||(o?z(h=i(t),s,n):n(h=i(t),s)))return t.values[r]=s,0}else h=i(t);return t.values[r]=h,1}}}}function z(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 _(t,e){let i=!1;for(let n of e)1&it(t,n)&&(i=!0);return i}function j(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;function h(t){let i=[];for(let e=0;e<n.length;e++){let r=nt(t,n[e]);if(2==s[e])for(let t of r)i.push(t);else i.push(r)}return e.combine(i)}return{create(t){for(let e of n)it(t,e);return t.values[o]=h(t),1},update(t,i){if(!_(t,r))return 0;let n=h(t);return e.compare(n,t.values[o])?0:(t.values[o]=n,1)},reconfigure(t,s){let r=_(t,n),l=s.config.facets[e.id],a=s.facet(e);if(l&&!r&&W(i,l))return t.values[o]=a,0;let c=h(t);return e.compare(c,a)?(t.values[o]=a,0):(t.values[o]=c,1)}}}const q=H.define({static:!0});class ${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 $(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(q).find((t=>t.field==this));return((null==e?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:t=>(t.values[e]=this.create(t),1),update:(t,i)=>{let n=t.values[e],s=this.updateF(n,i);return this.compareF(n,s)?0:(t.values[e]=s,1)},reconfigure:(t,i)=>null!=i.config.address[this.id]?(t.values[e]=i.field(this),0):(t.values[e]=this.create(t),1)}}init(t){return[this,q.of({field:this,create:t})]}get extension(){return this}}const K=4,J=3,G=2,U=1;function X(t){return e=>new Q(e,t)}const Y={highest:X(0),high:X(U),default:X(G),low:X(J),lowest:X(K)};class Q{constructor(t,e){this.inner=t,this.prec=e}}class Z{of(t){return new tt(this,t)}reconfigure(t){return Z.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class tt{constructor(t,e){this.compartment=t,this.inner=e}}class et{constructor(t,e,i,n,s,r){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=s,this.facets=r,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return null==e?t.default:this.staticValues[e>>1]}static resolve(t,e,i){let n=[],s=Object.create(null),r=new Map;for(let u of function(t,e,i){let n=[[],[],[],[],[]],s=new Map;function r(t,o){let h=s.get(t);if(null!=h){if(h<=o)return;let e=n[h].indexOf(t);e>-1&&n[h].splice(e,1),t instanceof tt&&i.delete(t.compartment)}if(s.set(t,o),Array.isArray(t))for(let e of t)r(e,o);else if(t instanceof tt){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 Q)r(t.inner,t.prec);else if(t instanceof $)n[o].push(t),t.provides&&r(t.provides,o);else if(t instanceof F)n[o].push(t),t.facet.extensions&&r(t.facet.extensions,G);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,G),n.reduce(((t,e)=>t.concat(e)))}(t,e,r))u instanceof $?n.push(u):(s[u.facet.id]||(s[u.facet.id]=[])).push(u);let o=Object.create(null),h=[],l=[];for(let u of n)o[u.id]=l.length<<1,l.push((t=>u.slot(t)));let a=null==i?void 0:i.config.facets;for(let u in s){let t=s[u],e=t[0].facet,n=a&&a[u]||[];if(t.every((t=>0==t.type)))if(o[e.id]=h.length<<1|1,W(n,t))h.push(i.facet(e));else{let n=e.combine(t.map((t=>t.value)));h.push(i&&e.compare(n,i.facet(e))?i.facet(e):n)}else{for(let e of t)0==e.type?(o[e.id]=h.length<<1|1,h.push(e.value)):(o[e.id]=l.length<<1,l.push((t=>e.dynamicSlot(t))));o[e.id]=l.length<<1,l.push((i=>j(i,e,t)))}}let c=l.map((t=>t(o)));return new et(t,r,c,o,h,s)}}function it(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.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|s}function nt(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const st=H.define(),rt=H.define({combine:t=>t.some((t=>t)),static:!0}),ot=H.define({combine:t=>t.length?t[0]:void 0,static:!0}),ht=H.define(),lt=H.define(),at=H.define(),ct=H.define({combine:t=>!!t.length&&t[0]});class ut{constructor(t,e){this.type=t,this.value=e}static define(){return new ft}}class ft{of(t){return new ut(this,t)}}class dt{constructor(t){this.map=t}of(t){return new gt(this,t)}}class gt{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 gt(this.type,e)}is(t){return this.type==t}static define(t={}){return new dt(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}}gt.reconfigure=gt.define(),gt.appendConfig=gt.define();class pt{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&&I(i,e.newLength),s.some((t=>t.type==pt.time))||(this.annotations=s.concat(pt.time.of(Date.now())))}static create(t,e,i,n,s,r){return new pt(t,e,i,n,s,r)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(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(pt.userEvent);return!(!e||!(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function mt(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 wt(t,e,i){var n;let s,r,o;return i?(s=e.changes,r=O.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:gt.mapEffects(t.effects,s).concat(gt.mapEffects(e.effects,r)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function vt(t,e,i){let n=e.selection,s=xt(e.annotations);return e.userEvent&&(s=s.concat(pt.userEvent.of(e.userEvent))),{changes:e.changes instanceof O?e.changes:O.of(e.changes||[],i,t.facet(ot)),selection:n&&(n instanceof N?n:N.single(n.anchor,n.head)),effects:xt(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function yt(t,e,i){let n=vt(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=wt(n,vt(t,e[r],s?n.changes.newLength:t.doc.length),s)}let s=pt.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return function(t){let e=t.startState,i=e.facet(at),n=t;for(let s=i.length-1;s>=0;s--){let r=i[s](t);r&&Object.keys(r).length&&(n=wt(n,vt(e,r,t.changes.newLength),!0))}return n==t?t:pt.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}(i?function(t){let e=t.startState,i=!0;for(let s of e.facet(ht)){let e=s(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:mt(i,e))}if(!0!==i){let n,s;if(!1===i)s=t.changes.invertedDesc,n=O.empty(e.doc.length);else{let e=t.changes.filter(i);n=e.changes,s=e.filtered.mapDesc(e.changes).invertedDesc}t=pt.create(e,n,t.selection&&t.selection.map(s),gt.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let n=e.facet(lt);for(let s=n.length-1;s>=0;s--){let i=n[s](t);t=i instanceof pt?i:Array.isArray(i)&&1==i.length&&i[0]instanceof pt?i[0]:yt(e,xt(i),!1)}return t}(s):s)}pt.time=ut.define(),pt.userEvent=ut.define(),pt.addToHistory=ut.define(),pt.remote=ut.define();const bt=[];function xt(t){return null==t?bt:Array.isArray(t)?t:[t]}var St=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(St||(St={}));const kt=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let At;try{At=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(Kt){}function Mt(t){return e=>{if(!/\S/.test(e))return St.Space;if(function(t){if(At)return At.test(t);for(let e=0;e<t.length;e++){let i=t[e];if(/\w/.test(i)||i>"€"&&(i.toUpperCase()!=i.toLowerCase()||kt.test(i)))return!0}return!1}(e))return St.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return St.Word;return St.Other}}class Ct{constructor(t,e,i,n,s,r){this.config=t,this.doc=e,this.selection=i,this.values=n,this.status=t.statusTemplate.slice(),this.computeSlot=s,r&&(r._state=this);for(let o=0;o<this.config.dynamicSlots.length;o++)it(this,o<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(null!=i)return it(this,i),nt(this,i);if(e)throw new RangeError("Field is not present in this state")}update(...t){return yt(this,t,!0)}applyTransaction(t){let e,i=this.config,{base:n,compartments:s}=i;for(let r of t.effects)r.is(Z.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(gt.reconfigure)?(i=null,n=r.value):r.is(gt.appendConfig)&&(i=null,n=xt(n).concat(r.value));if(i)e=t.startState.values.slice();else{i=et.resolve(n,s,this),e=new Ct(i,this.doc,this.selection,i.dynamicSlots.map((()=>null)),((t,e)=>e.reconfigure(t,this)),null).values}new Ct(i,t.newDoc,t.newSelection,e,((e,i)=>i.update(e,t)),t)}replaceSelection(t){return"string"==typeof t&&(t=this.toText(t)),this.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:t},range:N.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=xt(i.effects);for(let o=1;o<e.ranges.length;o++){let i=t(e.ranges[o]),h=this.changes(i.changes),l=h.map(n);for(let t=0;t<o;t++)s[t]=s[t].map(l);let a=n.mapDesc(h,!0);s.push(i.range.map(a)),n=n.compose(l),r=gt.mapEffects(r,l).concat(gt.mapEffects(xt(i.effects),a))}return{changes:n,selection:N.create(s,e.mainIndex),effects:r}}changes(t=[]){return t instanceof O?t:O.of(t,this.doc.length,this.facet(Ct.lineSeparator))}toText(t){return n.of(t.split(this.facet(Ct.lineSeparator)||A))}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:(it(this,e),nt(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 $&&null!=this.config.address[n.id]&&(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)if(Object.prototype.hasOwnProperty.call(t,s)){let e=i[s],r=t[s];n.push(e.init((t=>e.spec.fromJSON(r,t))))}return Ct.create({doc:t.doc,selection:N.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let e=et.resolve(t.extensions||[],new Map),i=t.doc instanceof n?t.doc:n.of((t.doc||"").split(e.staticFacet(Ct.lineSeparator)||A)),s=t.selection?t.selection instanceof N?t.selection:N.single(t.selection.anchor,t.selection.head):N.single(0);return I(s,i.length),e.staticFacet(rt)||(s=s.asSingle()),new Ct(e,i,s,e.dynamicSlots.map((()=>null)),((t,e)=>e.create(t)),null)}get tabSize(){return this.facet(Ct.tabSize)}get lineBreak(){return this.facet(Ct.lineSeparator)||"\n"}get readOnly(){return this.facet(ct)}phrase(t,...e){for(let i of this.facet(Ct.phrases))if(Object.prototype.hasOwnProperty.call(i,t)){t=i[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,((t,i)=>{if("$"==i)return"$";let n=+(i||1);return!n||n>e.length?t:e[n-1]}))),t}languageDataAt(t,e,i=-1){let n=[];for(let s of this.facet(st))for(let r of s(this,e,i))Object.prototype.hasOwnProperty.call(r,t)&&n.push(r[t]);return n}charCategorizer(t){return Mt(this.languageDataAt("wordChars",t).join(""))}wordAt(t){let{text:e,from:i,length:n}=this.doc.lineAt(t),s=this.charCategorizer(t),r=t-i,o=t-i;for(;r>0;){let t=m(e,r,!1);if(s(e.slice(t,r))!=St.Word)break;r=t}for(;o<n;){let t=m(e,o);if(s(e.slice(o,t))!=St.Word)break;o=t}return r==o?null:N.range(r+i,o+i)}}function Ot(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}Ct.allowMultipleSelections=rt,Ct.tabSize=H.define({combine:t=>t.length?t[0]:4}),Ct.lineSeparator=ot,Ct.readOnly=ct,Ct.phrases=H.define({compare(t,e){let i=Object.keys(t),n=Object.keys(e);return i.length==n.length&&i.every((i=>t[i]==e[i]))}}),Ct.languageData=st,Ct.changeFilter=ht,Ct.transactionFilter=lt,Ct.transactionExtender=at,Z.reconfigure=gt.define();class Tt{eq(t){return this==t}range(t,e=t){return Dt.create(t,e,this)}}Tt.prototype.startSide=Tt.prototype.endSide=0,Tt.prototype.point=!1,Tt.prototype.mapMode=M.TrackDel;class Dt{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new Dt(t,e,i)}}function Et(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Rt{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,h=s[n]-t||(i?this.value[n].endSide:this.value[n].startSide)-e;if(n==r)return h>=0?r:o;h>=0?o=n:r=n+1}}between(t,e,i,n){for(let s=this.findIndex(e,-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 h=0;h<this.value.length;h++){let l,a,c=this.value[h],u=this.from[h]+t,f=this.to[h]+t;if(u==f){let t=e.mapPos(u,c.startSide,c.mapMode);if(null==t)continue;if(l=a=t,c.startSide!=c.endSide&&(a=e.mapPos(u,c.endSide),a<l))continue}else if(l=e.mapPos(u,c.startSide),a=e.mapPos(f,c.endSide),l>a||l==a&&c.startSide>0&&c.endSide<=0)continue;(a-l||c.endSide-c.startSide)<0||(r<0&&(r=l),c.point&&(o=Math.max(o,a-l)),i.push(c),n.push(l-r),s.push(a-r))}return{mapped:i.length?new Rt(n,s,i,o):null,pos:r}}}class Bt{constructor(t,e,i,n){this.chunkPos=t,this.chunk=e,this.nextLayer=i,this.maxPoint=n}static create(t,e,i,n){return new Bt(t,e,i,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,r=t.filter;if(0==e.length&&!r)return this;if(i&&(e=e.slice().sort(Et)),this.isEmpty)return e.length?Bt.of(e):this;let o=new Nt(this,null,-1).goto(0),h=0,l=[],a=new Pt;for(;o.value||h<e.length;)if(h<e.length&&(o.from-e[h].from||o.startSide-e[h].value.startSide)>=0){let t=e[h++];a.addInner(t.from,t.to,t.value)||l.push(t)}else 1==o.rangeIndex&&o.chunkIndex<this.chunk.length&&(h==e.length||this.chunkEnd(o.chunkIndex)<e[h].from)&&(!r||n>this.chunkEnd(o.chunkIndex)||s<this.chunkPos[o.chunkIndex])&&a.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!r||n>o.to||s<o.from||r(o.from,o.to,o.value))&&(a.addInner(o.from,o.to,o.value)||l.push(Dt.create(o.from,o.to,o.value))),o.next());return a.finishInner(this.nextLayer.isEmpty&&!l.length?Bt.empty:this.nextLayer.update({add:l,filter:r,filterFrom:n,filterTo:s}))}map(t){if(t.empty||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],h=t.touchesRange(s,s+o.length);if(!1===h)n=Math.max(n,o.maxPoint),e.push(o),i.push(t.mapPos(s));else if(!0===h){let{mapped:r,pos:h}=o.map(s,t);r&&(n=Math.max(n,r.maxPoint),e.push(r),i.push(h))}}let s=this.nextLayer.map(t);return 0==e.length?s:new Bt(i,e,s||Bt.empty,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 It.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return It.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)),h=Lt(r,o,i),l=new Ht(r,h,s),a=new Ht(o,h,s);i.iterGaps(((t,e,i)=>Wt(l,t,a,e,i,n))),i.empty&&0==i.length&&Wt(l,0,a,0,0,n)}static eq(t,e,i=0,n){null==n&&(n=999999999);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=Lt(s,r),h=new Ht(s,o,0).goto(i),l=new Ht(r,o,0).goto(i);for(;;){if(h.to!=l.to||!Ft(h.active,l.active)||h.point&&(!l.point||!h.point.eq(l.point)))return!1;if(h.to>n)return!0;h.next(),l.next()}}static spans(t,e,i,n,s=-1){let r=new Ht(t,null,s).goto(e),o=e,h=r.openStart;for(;;){let t=Math.min(r.to,i);if(r.point){let i=r.activeForPoint(r.to),s=r.pointFrom<e?i.length+1:Math.min(i.length,h);n.point(o,t,r.point,i,s,r.pointRank),h=Math.min(r.openEnd(t),i.length)}else t>o&&(n.span(o,t,r.active,h),h=r.openEnd(t));if(r.to>i)return h+(r.point&&r.to>i?1:0);o=r.to,r.next()}}static of(t,e=!1){let i=new Pt;for(let n of t instanceof Dt?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let n=t[i];if(Et(e,n)>0)return t.slice().sort(Et);e=n}return t}(t):t)i.add(n.from,n.to,n.value);return i.finish()}}Bt.empty=new Bt([],[],null,-1),Bt.empty.nextLayer=Bt.empty;class Pt{finishChunk(t){this.chunks.push(new Rt(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=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(t,e,i){this.addInner(t,e,i)||(this.nextLayer||(this.nextLayer=new Pt)).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(Bt.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=Bt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function Lt(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.touchesRange(e,e+r.chunk[t].length))||s.add(r.chunk[t])}return s}class Nt{constructor(t,e,i,n=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex<this.layer.chunk.length;){let e=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(e)||this.layer.chunkEnd(this.chunkIndex)<t||e.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}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)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=t}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.rank-t.rank||this.to-t.to||this.endSide-t.endSide}}class It{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 Nt(r,e,i,s));return 1==n.length?n[0]:new It(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--)Vt(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--)Vt(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(),Vt(this.heap,0)}}}function Vt(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 Ht{constructor(t,e,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=It.from(t,e,i)}goto(t,e=-1e9){return this.cursor.goto(t,e),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=t,this.endSide=e,this.openStart=-1,this.next(),this}forward(t,e){for(;this.minActive>-1&&(this.activeTo[this.minActive]-t||this.active[this.minActive].endSide-e)<0;)this.removeActive(this.minActive);this.cursor.forward(t,e)}removeActive(t){zt(this.active,t),zt(this.activeTo,t),zt(this.activeRank,t),this.minActive=jt(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:n,rank:s}=this.cursor;for(;e<this.activeRank.length&&this.activeRank[e]<=s;)e++;_t(this.active,e,i),_t(this.activeTo,e,n),_t(this.activeRank,e,s),t&&_t(t,e,this.cursor.from),this.minActive=jt(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>t){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&zt(i,n)}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 t=this.cursor.value;if(t.point){if(!(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=t,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=t.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(i),this.cursor.next()}}}if(i){this.openStart=0;for(let e=i.length-1;e>=0&&i[e]<t;e--)this.openStart++}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&e.push(this.active[i]);return e.reverse()}openEnd(t){let e=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)e++;return e}}function Wt(t,e,i,n,s,r){t.goto(e),i.goto(n);let o=n+s,h=n,l=n-e;for(;;){let e=t.to+l-i.to||t.endSide-i.endSide,n=e<0?t.to+l:i.to,s=Math.min(n,o);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))&&Ft(t.activeForPoint(t.to),i.activeForPoint(i.to))||r.comparePoint(h,s,t.point,i.point):s>h&&!Ft(t.active,i.active)&&r.compareRange(h,s,t.active,i.active),n>o)break;h=n,e<=0&&t.next(),e>=0&&i.next()}}function Ft(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 zt(t,e){for(let i=e,n=t.length-1;i<n;i++)t[i]=t[i+1];t.pop()}function _t(t,e,i){for(let n=t.length-1;n>=e;n--)t[n+1]=t[n];t[e]=i}function jt(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}function qt(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=m(t,s));return n}function $t(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=m(t,s)}return!0===n?-1:t.length}},45037:function(t,e,i){i.a(t,(async function(t,n){try{i.d(e,{$f:function(){return Gn},Nm:function(){return u},OO:function(){return le},gB:function(){return fs},hJ:function(){return us},l9:function(){return yt},lg:function(){return fe},p:function(){return bt},tk:function(){return Wn}});var s=i(31948),r=(i(52247),i(71695),i(92745),i(52805),i(61495),i(61893),i(84283),i(19423),i(23669),i(40251),i(69235),i(12385),i(19134),i(32517),i(5740),i(11740),i(92519),i(42179),i(89256),i(24931),i(88463),i(57449),i(19814),i(97003),i(32114),i(46692),i(39527),i(37210),i(92181),i(99790),i(67670),i(41360),i(13334),i(34595),i(36993),i(47021),i(91274)),o=i(88938),h=i(96318),l=t([s]);function g(t){let e;return e=11==t.nodeType?t.getSelection?t:t.ownerDocument:t,e.getSelection()}function p(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function m(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function w(t,e){if(!e.anchorNode)return!1;try{return p(t,e.anchorNode)}catch(i){return!1}}function v(t){return 3==t.nodeType?B(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function y(t,e,i,n){return!!i&&(x(t,e,i,n,-1)||x(t,e,i,n,1))}function b(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function x(t,e,i,n,s){for(;;){if(t==i&&e==n)return!0;if(e==(s<0?0:S(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=b(t)+(s<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if(1==(t=t.childNodes[e+(s<0?-1:0)]).nodeType&&"false"==t.contentEditable)return!1;e=s<0?S(t):0}}}function S(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function k(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function A(t){return{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function M(t,e){let i=e.width/t.offsetWidth,n=e.height/t.offsetHeight;return(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.width-t.offsetWidth)<1)&&(i=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.height-t.offsetHeight)<1)&&(n=1),{scaleX:i,scaleY:n}}function C(t,e,i,n,s,r,o,h){let l=t.ownerDocument,a=l.defaultView||window;for(let c=t,u=!1;c&&!u;)if(1==c.nodeType){let t,f=c==l.body,d=1,g=1;if(f)t=A(a);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(u=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let e=c.getBoundingClientRect();({scaleX:d,scaleY:g}=M(c,e)),t={left:e.left,right:e.left+c.clientWidth*d,top:e.top,bottom:e.top+c.clientHeight*g}}let p=0,m=0;if("nearest"==s)e.top<t.top?(m=-(t.top-e.top+o),i>0&&e.bottom>t.bottom+m&&(m=e.bottom-t.bottom+m+o)):e.bottom>t.bottom&&(m=e.bottom-t.bottom+o,i<0&&e.top-m<t.top&&(m=-(t.top+m-e.top+o)));else{let n=e.bottom-e.top,r=t.bottom-t.top;m=("center"==s&&n<=r?e.top+n/2-r/2:"start"==s||"center"==s&&i<0?e.top-o:e.bottom-r+o)-t.top}if("nearest"==n)e.left<t.left?(p=-(t.left-e.left+r),i>0&&e.right>t.right+p&&(p=e.right-t.right+p+r)):e.right>t.right&&(p=e.right-t.right+r,i<0&&e.left<t.left+p&&(p=-(t.left+p-e.left+r)));else{p=("center"==n?e.left+(e.right-e.left)/2-(t.right-t.left)/2:"start"==n==h?e.left-r:e.right-(t.right-t.left)+r)-t.left}if(p||m)if(f)a.scrollBy(p,m);else{let t=0,i=0;if(m){let t=c.scrollTop;c.scrollTop+=m/g,i=(c.scrollTop-t)*g}if(p){let e=c.scrollLeft;c.scrollLeft+=p/d,t=(c.scrollLeft-e)*d}e={left:e.left-t,top:e.top-i,right:e.right-t,bottom:e.bottom-i},t&&Math.abs(t-p)<1&&(n="nearest"),i&&Math.abs(i-m)<1&&(s="nearest")}if(f)break;c=c.assignedSlot||c.parentNode}else{if(11!=c.nodeType)break;c=c.host}}function O(t){let e=t.ownerDocument;for(let i=t.parentNode;i&&i!=e.body;)if(1==i.nodeType){if(i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)return i;i=i.assignedSlot||i.parentNode}else{if(11!=i.nodeType)break;i=i.host}return null}s=(l.then?(await l)():l)[0];class T{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:i}=t;this.set(e,Math.min(t.anchorOffset,e?S(e):0),i,Math.min(t.focusOffset,i?S(i):0))}set(t,e,i,n){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=n}}let D,E=null;function R(t){if(t.setActive)return t.setActive();if(E)return t.focus(E);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==E?{get preventScroll(){return E={preventScroll:!0},!0}}:void 0),!E){E=!1;for(let t=0;t<e.length;){let i=e[t++],n=e[t++],s=e[t++];i.scrollTop!=n&&(i.scrollTop=n),i.scrollLeft!=s&&(i.scrollLeft=s)}}}function B(t,e,i=e){let n=D||(D=document.createRange());return n.setEnd(t,i),n.setStart(t,e),n}function P(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 L(t){for(;t;){if(t&&(9==t.nodeType||11==t.nodeType&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function N(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}function I(t,e){let i=e.focusNode,n=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=n)return!1;for(n=Math.min(n,S(i));;)if(n){if(1!=i.nodeType)return!1;let t=i.childNodes[n-1];"false"==t.contentEditable?n--:(i=t,n=S(i))}else{if(i==t)return!0;n=b(i),i=i.parentNode}}function V(t){return t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}class H{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new H(t.parentNode,b(t),e)}static after(t,e){return new H(t.parentNode,b(t)+1,e)}}const W=[];class F{constructor(){this.parent=null,this.dom=null,this.flags=2}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}sync(t,e){if(2&this.flags){let i,n=this.dom,s=null;for(let r of this.children){if(7&r.flags){if(!r.dom&&(i=s?s.nextSibling:n.firstChild)){let t=F.get(i);(!t||!t.parent&&t.canReuseDOM(r))&&r.reuseDOM(i)}r.sync(t,e),r.flags&=-8}if(i=s?s.nextSibling:n.firstChild,e&&!e.written&&e.node==n&&i!=r.dom&&(e.written=!0),r.dom.parentNode==n)for(;i&&i!=r.dom;)i=z(i);else n.insertBefore(r.dom,i);s=r.dom}for(i=s?s.nextSibling:n.firstChild,i&&e&&e.node==n&&(e.written=!0);i;)i=z(i)}else if(1&this.flags)for(let i of this.children)7&i.flags&&(i.sync(t,e),i.flags&=-8)}reuseDOM(t){}localPosFromDOM(t,e){let i;if(t==this.dom)i=this.dom.childNodes[e];else{let n=0==S(t)?0:0==e?-1:1;for(;;){let e=t.parentNode;if(e==this.dom)break;0==n&&e.firstChild!=e.lastChild&&(n=t==e.firstChild?-1:1),t=e}i=n<0?t:t.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!F.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 h=0,l=i,a=i;h<this.children.length;h++){let i=this.children[h],c=l+i.length;if(l<t&&c>e)return i.domBoundsAround(t,e,l);if(c>=t&&-1==n&&(n=h,s=l),l>e&&i.dom.parentNode==this.dom){r=h,o=a;break}a=c,l=c+i.breakAfter}return{from:s,to:o<0?i+this.length:o,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:r<this.children.length&&r>=0?this.children[r].dom:null}}markDirty(t=!1){this.flags|=2,this.markParentsDirty(t)}markParentsDirty(t){for(let e=this.parent;e;e=e.parent){if(t&&(e.flags|=2),1&e.flags)return;e.flags|=1,t=!1}}setParent(t){this.parent!=t&&(this.parent=t,7&this.flags&&this.markParentsDirty(!0))}setDOM(t){this.dom!=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=W){this.markDirty();for(let n=t;n<e;n++){let t=this.children[n];t.parent==this&&i.indexOf(t)<0&&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 _(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}get isWidget(){return!1}get isHidden(){return!1}merge(t,e,i,n,s,r){return!1}become(t){return!1}canReuseDOM(t){return t.constructor==this.constructor&&!(8&(this.flags|t.flags))}getSide(){return 0}destroy(){for(let t of this.children)t.parent==this&&t.destroy();this.parent=null}}function z(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}F.prototype.breakAfter=0;class _{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 j(t,e,i,n,s,r,o,h,l){let{children:a}=t,c=a.length?a[e]:null,u=r.length?r[r.length-1]:null,f=u?u.breakAfter:o;if(!(e==n&&c&&!o&&!f&&r.length<2&&c.merge(i,s,r.length?u:null,0==i,h,l))){if(n<a.length){let t=a[n];t&&(s<t.length||t.breakAfter&&(null==u?void 0:u.breakAfter))?(e==n&&(t=t.split(s),s=0),!f&&u&&t.merge(0,s,u,!0,0,l)?r[r.length-1]=t:((s||t.children.length&&!t.children[0].length)&&t.merge(0,s,null,!1,0,l),r.push(t))):(null==t?void 0:t.breakAfter)&&(u?u.breakAfter=1:o=1),n++}for(c&&(c.breakAfter=o,i>0&&(!o&&r.length&&c.merge(i,c.length,r[0],!1,h,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,h,0),e++));e<n&&r.length;)if(a[n-1].become(r[r.length-1]))n--,r.pop(),l=r.length?0:h;else{if(!a[e].become(r[0]))break;e++,r.shift(),h=r.length?0:l}!r.length&&e&&n<a.length&&!a[e-1].breakAfter&&a[n].merge(0,0,a[e-1],!1,h,l)&&e--,(e<n||r.length)&&t.replaceChildren(e,n,r)}}function q(t,e,i,n,s,r){let o=t.childCursor(),{i:h,off:l}=o.findPos(i,1),{i:a,off:c}=o.findPos(e,-1),u=e-i;for(let f of n)u+=f.length;t.length+=u,j(t,a,c,h,l,n,0,s,r)}let $="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},K="undefined"!=typeof document?document:{documentElement:{style:{}}};const J=/Edge\/(\d+)/.exec($.userAgent),G=/MSIE \d/.test($.userAgent),U=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec($.userAgent),X=!!(G||U||J),Y=!X&&/gecko\/(\d+)/i.test($.userAgent),Q=!X&&/Chrome\/(\d+)/.exec($.userAgent),Z="webkitFontSmoothing"in K.documentElement.style,tt=!X&&/Apple Computer/.test($.vendor),et=tt&&(/Mobile\/\w+/.test($.userAgent)||$.maxTouchPoints>2);var a={mac:et||/Mac/.test($.platform),windows:/Win/.test($.platform),linux:/Linux|X11/.test($.platform),ie:X,ie_version:G?K.documentMode||6:U?+U[1]:J?+J[1]:0,gecko:Y,gecko_version:Y?+(/Firefox\/(\d+)/.exec($.userAgent)||[0,0])[1]:0,chrome:!!Q,chrome_version:Q?+Q[1]:0,ios:et,android:/Android\b/.test($.userAgent),webkit:Z,safari:tt,webkit_version:Z?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:null!=K.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};const it=256;class nt extends F{constructor(t){super(),this.text=t}get length(){return this.text.length}createDOM(t){this.setDOM(t||document.createTextNode(this.text))}sync(t,e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(t){3==t.nodeType&&this.createDOM(t)}merge(t,e,i){return!(8&this.flags||i&&(!(i instanceof nt)||this.length-(e-t)+i.length>it||8&i.flags))&&(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new nt(this.text.slice(t));return this.text=this.text.slice(0,t),this.markDirty(),e.flags|=8&this.flags,e}localPosFromDOM(t,e){return t==this.dom?e:e?this.text.length:0}domAtPos(t){return new H(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 rt(this.dom,t,e)}}class st extends F{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(N(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}canReuseDOM(t){return super.canReuseDOM(t)&&!(8&(this.flags|t.flags))}reuseDOM(t){t.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(t),this.flags|=6)}sync(t,e){this.dom?4&this.flags&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(t,e)}merge(t,e,i,n,s,r){return(!i||!(!(i instanceof st&&i.mark.eq(this.mark))||t&&s<=0||e<this.length&&r<=0))&&(q(this,t,e,i?i.children.slice():[],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 st(this.mark,e,r)}domAtPos(t){return lt(this,t)}coordsAt(t,e){return ct(this,t,e)}}function rt(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?a.chrome||a.gecko||(e?(s--,o=1):r<n&&(r++,o=-1)):i<0?s--:r<n&&r++;let h=B(t,s,r).getClientRects();if(!h.length)return null;let l=h[(o?o<0:i>=0)?0:h.length-1];return a.safari&&!o&&0==l.width&&(l=Array.prototype.find.call(h,(t=>t.width))||l),o?k(l,o<0):l||null}class ot extends F{static create(t,e,i){return new ot(t,e,i)}constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i,this.prevWidget=null}split(t){let e=ot.create(this.widget,this.length-t,this.side);return this.length-=t,e}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(t,e,i,n,s,r){return!(i&&(!(i instanceof ot&&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 instanceof ot&&t.side==this.side&&this.widget.constructor==t.widget.constructor&&(this.widget.compare(t.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get overrideDOMText(){if(0==this.length)return r.xv.empty;let t=this;for(;t.parent;)t=t.parent;let{view:e}=t,i=e&&e.state.doc,n=this.posAtStart;return i?i.slice(n,n+this.length):r.xv.empty}domAtPos(t){return(this.length?0==t:this.side>0)?H.before(this.dom):H.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let i=this.widget.coordsAt(this.dom,t,e);if(i)return i;let n=this.dom.getClientRects(),s=null;if(!n.length)return null;let r=this.side?this.side<0:t>0;for(let o=r?n.length-1:0;s=n[o],!(t>0?0==o:o==n.length-1||s.top<s.bottom);o+=r?-1:1);return k(s,!r)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class ht extends F{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof ht&&t.side==this.side}split(){return new ht(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 this.side>0?H.before(this.dom):H.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return r.xv.empty}get isHidden(){return!0}}function lt(t,e){let i=t.dom,{children:n}=t,s=0;for(let r=0;s<n.length;s++){let t=n[s],o=r+t.length;if(!(o==r&&t.getSide()<=0)){if(e>r&&e<o&&t.dom.parentNode==i)return t.domAtPos(e-r);if(e<=r)break;r=o}}for(let r=s;r>0;r--){let t=n[r-1];if(t.dom.parentNode==i)return t.domAtPos(t.length)}for(let r=s;r<n.length;r++){let t=n[r];if(t.dom.parentNode==i)return t.domAtPos(0)}return new H(i,0)}function at(t,e,i){let n,{children:s}=t;i>0&&e instanceof st&&s.length&&(n=s[s.length-1])instanceof st&&n.mark.eq(e.mark)?at(n,e.children[0],i-1):(s.push(e),e.setParent(t)),t.length+=e.length}function ct(t,e,i){let n=null,s=-1,r=null,o=-1;!function t(e,h){for(let l=0,a=0;l<e.children.length&&a<=h;l++){let c=e.children[l],u=a+c.length;u>=h&&(c.children.length?t(c,h-a):(!r||r.isHidden&&i>0)&&(u>h||a==u&&c.getSide()>0)?(r=c,o=h-a):(a<h||a==u&&c.getSide()<0&&!c.isHidden)&&(n=c,s=h-a)),a=u}}(t,e);let h=(i<0?n:r)||n||r;return h?h.coordsAt(Math.max(0,h==n?s:o),i):ut(t)}function ut(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=v(e);return i[i.length-1]||null}function ft(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}nt.prototype.children=ot.prototype.children=ht.prototype.children=W;const dt=Object.create(null);function gt(t,e,i){if(t==e)return!0;t||(t=dt),e||(e=dt);let n=Object.keys(t),s=Object.keys(e);if(n.length-(i&&n.indexOf(i)>-1?1:0)!=s.length-(i&&s.indexOf(i)>-1?1:0))return!1;for(let r of n)if(r!=i&&(-1==s.indexOf(r)||t[r]!==e[r]))return!1;return!0}function pt(t,e,i){let n=!1;if(e)for(let s in e)i&&s in i||(n=!0,"style"==s?t.style.cssText="":t.removeAttribute(s));if(i)for(let s in i)e&&e[s]==i[s]||(n=!0,"style"==s?t.style.cssText=i[s]:t.setAttribute(s,i[s]));return n}function mt(t){let e=Object.create(null);for(let i=0;i<t.attributes.length;i++){let n=t.attributes[i];e[n.name]=n.value}return e}class wt extends F{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),q(this,t,e,i?i.children.slice():[],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);for(;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&&(this.markDirty(),t.setDOM(this.dom),t.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(t){gt(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){at(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=ft(e,this.attrs||{})),i&&(this.attrs=ft({class:i},this.attrs||{}))}domAtPos(t){return lt(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.flags|=6)}sync(t,e){var i;this.dom?4&this.flags&&(N(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&&(pt(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t,e);let n=this.dom.lastChild;for(;n&&F.get(n)instanceof st;)n=n.lastChild;if(!(n&&this.length&&("BR"==n.nodeName||0!=(null===(i=F.get(n))||void 0===i?void 0:i.isEditable)||a.ios&&this.children.some((t=>t instanceof nt))))){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,e=0;for(let i of this.children){if(!(i instanceof nt)||/[^ -~]/.test(i.text))return null;let n=v(i.dom);if(1!=n.length)return null;e+=n[0].width,t=n[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(t,e){let i=ct(this,t,e);if(!this.children.length&&i&&this.parent){let{heightOracle:t}=this.parent.view.viewState,e=i.bottom-i.top;if(Math.abs(e-t.lineHeight)<2&&t.textHeight<e){let n=(e-t.textHeight)/2;return{top:i.top+n,bottom:i.bottom-n,left:i.left,right:i.left}}}return i}become(t){return!1}covers(){return!0}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 F{constructor(t,e,i){super(),this.widget=t,this.length=e,this.deco=i,this.breakAfter=0,this.prevWidget=null}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?H.before(this.dom):H.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new vt(this.widget,e,this.deco);return i.breakAfter=this.breakAfter,i}get children(){return W}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):r.xv.empty}domBoundsAround(){return null}become(t){return t instanceof vt&&t.widget.constructor==this.widget.constructor&&(t.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,this.deco=t.deco,this.breakAfter=t.breakAfter,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(t,e){return this.widget.coordsAt(this.dom,t,e)}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(t){let{startSide:e,endSide:i}=this.deco;return e!=i&&(t<0?e<0:i>0)}}class yt{eq(t){return!1}updateDOM(t,e){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(t){return!0}coordsAt(t,e,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(t){}}var c=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(c||(c={}));class bt extends r.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 xt(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),i=!!t.block;return e+=i&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8,new kt(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}=At(t,n);e=(s?n?-3e8:-1:5e8)-1,i=1+(r?n?2e8:1:-6e8)}return new kt(t,e,i,n,t.widget||null,!0)}static line(t){return new St(t)}static set(t,e=!1){return r.Xs.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}bt.none=r.Xs.empty;class xt extends bt{constructor(t){let{start:e,end:i}=At(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){var e,i;return this==t||t instanceof xt&&this.tagName==t.tagName&&(this.class||(null===(e=this.attrs)||void 0===e?void 0:e.class))==(t.class||(null===(i=t.attrs)||void 0===i?void 0:i.class))&&gt(this.attrs,t.attrs,"class")}range(t,e=t){if(t>=e)throw new RangeError("Mark decorations may not be empty");return super.range(t,e)}}xt.prototype.point=!1;class St extends bt{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof St&&this.spec.class==t.spec.class&&gt(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw new RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}}St.prototype.mapMode=r.gc.TrackBefore,St.prototype.point=!0;class kt extends bt{constructor(t,e,i,n,s,o){super(e,i,s,t),this.block=n,this.isReplace=o,this.mapMode=n?e<=0?r.gc.TrackBefore:r.gc.TrackAfter:r.gc.TrackDel}get type(){return this.startSide!=this.endSide?c.WidgetRange:this.startSide<=0?c.WidgetBefore:c.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof kt&&(e=this.widget,i=t.widget,e==i||!!(e&&i&&e.compare(i)))&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide;var e,i}range(t,e=t){if(this.isReplace&&(t>e||t==e&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}}function At(t,e=!1){let{inclusiveStart:i,inclusiveEnd:n}=t;return null==i&&(i=t.inclusive),null==n&&(n=t.inclusive),{start:null!=i?i:e,end:null!=n?n: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)}kt.prototype.point=!0;class Ct{constructor(t,e,i,n){this.doc=t,this.pos=e,this.end=i,this.disallowBlockEffectsFor=n,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],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.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new wt),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(Ot(new ht(-1),t),t.length),this.pendingBuffer=0)}addBlockWidget(t){this.flushBuffer(),this.curLine=null,this.content.push(t)}finish(t){this.pendingBuffer&&t<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||t&&this.content.length&&this.content[this.content.length-1]instanceof vt||this.getLine()}buildText(t,e,i){for(;t>0;){if(this.textOff==this.text.length){let{value:e,lineBreak:i,done:n}=this.cursor.next(this.skip);if(this.skip=0,n)throw new Error("Ran out of text content when drawing inline views");if(i){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,t--;continue}this.text=e,this.textOff=0}let n=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(e.length-i)),this.getLine().append(Ot(new nt(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,r){if(this.disallowBlockEffectsFor[r]&&i instanceof kt){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")}let o=e-t;if(i instanceof kt)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new vt(i.widget||new Tt("div"),o,i));else{let r=ot.create(i.widget||new Tt("span"),o,o?0:i.startSide),h=this.atCursorPos&&!r.isEditable&&s<=n.length&&(t<e||i.startSide>0),l=!r.isEditable&&(t<e||s>n.length||i.startSide<=0),a=this.getLine();2!=this.pendingBuffer||h||r.isEditable||(this.pendingBuffer=0),this.flushBuffer(n),h&&(a.append(Ot(new ht(1),n),s),s=n.length+Math.max(0,s-n.length)),a.append(Ot(r,n),s),this.atCursorPos=l,this.pendingBuffer=l?t<e||s>n.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=n.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);o&&(this.textOff+o<=this.text.length?this.textOff+=o:(this.skip+=o-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=e),this.openStart<0&&(this.openStart=s)}static build(t,e,i,n,s){let o=new Ct(t,e,i,s);return o.openEnd=r.Xs.spans(n,e,i,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}}function Ot(t,e){for(let i of e)t=new st(i,[t],t.length);return t}class Tt extends yt{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}var u=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(u||(u={}));const Dt=u.LTR,Et=u.RTL;function Rt(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}const Bt=Rt("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Pt=Rt("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Lt=Object.create(null),Nt=[];for(let gs of["()","[]","{}"]){let ps=gs.charCodeAt(0),ms=gs.charCodeAt(1);Lt[ps]=ms,Lt[ms]=-ps}function It(t){return t<=247?Bt[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?Pt[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8204?256:64336<=t&&t<=65023?4:1}const Vt=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Ht{get dir(){return this.level%2?Et:Dt}constructor(t,e,i){this.from=t,this.to=e,this.level=i}side(t,e){return this.dir==e==t?this.to:this.from}forward(t,e){return t==(this.dir==e)}static find(t,e,i,n){let 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}}function Wt(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.direction!=s.direction||!Wt(n.inner,s.inner))return!1}return!0}const Ft=[];function zt(t,e,i,n,s){for(let r=0;r<=n.length;r++){let o=r?n[r-1].to:e,h=r<n.length?n[r].from:i,l=r?256:s;for(let e=o,i=l,n=l;e<h;e++){let s=It(t.charCodeAt(e));512==s?s=i:8==s&&4==n&&(s=16),Ft[e]=4==s?2:s,7&s&&(n=s),i=s}for(let t=o,e=l,n=l;t<h;t++){let s=Ft[t];if(128==s)t<h-1&&e==Ft[t+1]&&24&e?s=Ft[t]=e:Ft[t]=256;else if(64==s){let s=t+1;for(;s<h&&64==Ft[s];)s++;let r=t&&8==e||s<i&&8==Ft[s]?1==n?1:8:256;for(let e=t;e<s;e++)Ft[e]=r;t=s-1}else 8==s&&1==n&&(Ft[t]=1);e=s,7&s&&(n=s)}}}function _t(t,e,i,n,s){let r=1==s?2:1;for(let o=0,h=0,l=0;o<=n.length;o++){let a=o?n[o-1].to:e,c=o<n.length?n[o].from:i;for(let e,i,n,o=a;o<c;o++)if(i=Lt[e=t.charCodeAt(o)])if(i<0){for(let t=h-3;t>=0;t-=3)if(Nt[t+1]==-i){let e=Nt[t+2],i=2&e?s:4&e?1&e?r:s:0;i&&(Ft[o]=Ft[Nt[t]]=i),h=t;break}}else{if(189==Nt.length)break;Nt[h++]=o,Nt[h++]=e,Nt[h++]=l}else if(2==(n=Ft[o])||1==n){let t=n==s;l=t?0:1;for(let e=h-3;e>=0;e-=3){let i=Nt[e+2];if(2&i)break;if(t)Nt[e+2]|=2;else{if(4&i)break;Nt[e+2]|=4}}}}}function jt(t,e,i,n){for(let s=0,r=n;s<=i.length;s++){let o=s?i[s-1].to:t,h=s<i.length?i[s].from:e;for(let l=o;l<h;){let o=Ft[l];if(256==o){let o=l+1;for(;;)if(o==h){if(s==i.length)break;o=i[s++].to,h=s<i.length?i[s].from:e}else{if(256!=Ft[o])break;o++}let a=1==r,c=a==(1==(o<e?Ft[o]:n))?a?1:2:n;for(let e=o,n=s,r=n?i[n-1].to:t;e>l;)e==r&&(e=i[--n].from,r=n?i[n-1].to:t),Ft[--e]=c;l=o}else r=o,l++}}}function qt(t,e,i,n,s,r,o){let h=n%2?2:1;if(n%2==s%2)for(let l=e,a=0;l<i;){let e=!0,c=!1;if(a==r.length||l<r[a].from){let t=Ft[l];t!=h&&(e=!1,c=16==t)}let u=e||1!=h?null:[],f=e?n:n+1,d=l;t:for(;;)if(a<r.length&&d==r[a].from){if(c)break t;let g=r[a];if(!e)for(let t=g.to,e=a+1;;){if(t==i)break t;if(!(e<r.length&&r[e].from==t)){if(Ft[t]==h)break t;break}t=r[e++].to}if(a++,u)u.push(g);else{g.from>l&&o.push(new Ht(l,g.from,f)),$t(t,g.direction==Dt!=!(f%2)?n+1:n,s,g.inner,g.from,g.to,o),l=g.to}d=g.to}else{if(d==i||(e?Ft[d]!=h:Ft[d]==h))break;d++}u?qt(t,l,d,n+1,s,u,o):l<d&&o.push(new Ht(l,d,f)),l=d}else for(let l=i,a=r.length;l>e;){let i=!0,c=!1;if(!a||l>r[a-1].to){let t=Ft[l-1];t!=h&&(i=!1,c=16==t)}let u=i||1!=h?null:[],f=i?n:n+1,d=l;t:for(;;)if(a&&d==r[a-1].to){if(c)break t;let g=r[--a];if(!i)for(let t=g.from,i=a;;){if(t==e)break t;if(!i||r[i-1].to!=t){if(Ft[t-1]==h)break t;break}t=r[--i].from}if(u)u.push(g);else{g.to<l&&o.push(new Ht(g.to,l,f)),$t(t,g.direction==Dt!=!(f%2)?n+1:n,s,g.inner,g.from,g.to,o),l=g.from}d=g.from}else{if(d==e||(i?Ft[d-1]!=h:Ft[d-1]==h))break;d--}u?qt(t,d,l,n+1,s,u,o):d<l&&o.push(new Ht(d,l,f)),l=d}}function $t(t,e,i,n,s,r,o){let h=e%2?2:1;zt(t,s,r,n,h),_t(t,s,r,n,h),jt(s,r,n,h),qt(t,s,r,e,i,n,o)}function Kt(t,e,i){if(!t)return[new Ht(0,0,e==Et?1:0)];if(e==Dt&&!i.length&&!Vt.test(t))return Jt(t.length);if(i.length)for(;t.length>Ft.length;)Ft[Ft.length]=256;let n=[],s=e==Dt?0:1;return $t(t,s,s,i,0,t.length,n),n}function Jt(t){return[new Ht(0,t,0)]}let Gt="";function Ut(t,e,i,n,s){var o;let h=n.head-t.from,l=Ht.find(e,h,null!==(o=n.bidiLevel)&&void 0!==o?o:-1,n.assoc),a=e[l],c=a.side(s,i);if(h==c){let t=l+=s?1:-1;if(t<0||t>=e.length)return null;a=e[l=t],h=a.side(!s,i),c=a.side(s,i)}let u=(0,r.cp)(t.text,h,a.forward(s,i));(u<a.from||u>a.to)&&(u=c),Gt=t.text.slice(Math.min(h,u),Math.max(h,u));let f=l==(s?e.length-1:0)?null:e[l+(s?1:-1)];return f&&u==c&&f.level+(s?0:1)<a.level?r.jT.cursor(f.side(!s,i)+t.from,f.forward(s,i)?1:-1,f.level):r.jT.cursor(u+t.from,a.forward(s,i)?-1:1,a.level)}function Xt(t,e,i){for(let n=e;n<i;n++){let e=It(t.charCodeAt(n));if(1==e)return Dt;if(2==e||4==e)return Et}return Dt}const Yt=r.r$.define(),Qt=r.r$.define(),Zt=r.r$.define(),te=r.r$.define(),ee=r.r$.define(),ie=r.r$.define(),ne=r.r$.define(),se=r.r$.define({combine:t=>t.some((t=>t))}),re=r.r$.define({combine:t=>t.some((t=>t))});class oe{constructor(t,e="nearest",i="nearest",n=5,s=5,r=!1){this.range=t,this.y=e,this.x=i,this.yMargin=n,this.xMargin=s,this.isSnapshot=r}map(t){return t.empty?this:new oe(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new oe(r.jT.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const he=r.Py.define({map:(t,e)=>t.map(e)});function le(t,e,i){let n=t.facet(te);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 ae=r.r$.define({combine:t=>!t.length||t[0]});let ce=0;const ue=r.r$.define();class fe{constructor(t,e,i,n,s){this.id=t,this.create=e,this.domEventHandlers=i,this.domEventObservers=n,this.extension=s(this)}static define(t,e){const{eventHandlers:i,eventObservers:n,provide:s,decorations:r}=e||{};return new fe(ce++,t,i,n,(t=>{let e=[ue.of(t)];return r&&e.push(me.of((e=>{let i=e.plugin(t);return i?r(i):bt.none}))),s&&e.push(s(t)),e}))}static fromClass(t,e){return fe.define((e=>new t(e)),e)}}class de{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}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(le(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){le(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){le(t.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const ge=r.r$.define(),pe=r.r$.define(),me=r.r$.define(),we=r.r$.define(),ve=r.r$.define(),ye=r.r$.define();function be(t,e){let i=t.state.facet(ye);if(!i.length)return i;let n=i.map((e=>e instanceof Function?e(t):e)),s=[];return r.Xs.spans(n,e.from,e.to,{point(){},span(t,i,n,r){let o=t-e.from,h=i-e.from,l=s;for(let s=n.length-1;s>=0;s--,r--){let t,i=n[s].spec.bidiIsolate;if(null==i&&(i=Xt(e.text,o,h)),r>0&&l.length&&(t=l[l.length-1]).to==o&&t.direction==i)t.to=h,l=t.inner;else{let t={from:o,to:h,direction:i,inner:[]};l.push(t),l=t.inner}}}}),s}const xe=r.r$.define();function Se(t){let e=0,i=0,n=0,s=0;for(let r of t.state.facet(xe)){let o=r(t);o&&(null!=o.left&&(e=Math.max(e,o.left)),null!=o.right&&(i=Math.max(i,o.right)),null!=o.top&&(n=Math.max(n,o.top)),null!=o.bottom&&(s=Math.max(s,o.bottom)))}return{left:e,right:i,top:n,bottom:s}}const ke=r.r$.define();class Ae{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new Ae(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let n=t[e-1];if(!(n.fromA>i.toA)){if(n.toA<i.fromA)break;i=i.join(n),t.splice(e-1,1)}}return t.splice(e,0,i),t}static extendWithRanges(t,e){if(0==e.length)return t;let i=[];for(let n=0,s=0,r=0,o=0;;n++){let h=n==t.length?null:t[n],l=r-o,a=h?h.fromB:1e9;for(;s<e.length&&e[s]<a;){let t=e[s],n=e[s+1],r=Math.max(o,t),h=Math.min(a,n);if(r<=h&&new Ae(r+l,h+l,r,h).addToSet(i),n>a)break;s+=2}if(!h)return i;new Ae(h.fromA,h.toA,h.fromB,h.toB).addToSet(i),r=h.toA,o=h.toB}}}class Me{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=r.as.empty(this.startState.doc.length);for(let s of i)this.changes=this.changes.compose(s.changes);let n=[];this.changes.iterChangedRanges(((t,e,i,s)=>n.push(new Ae(t,e,i,s)))),this.changedRanges=n}static create(t,e,i){return new Me(t,e,i)}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}}class Ce extends F{get length(){return this.view.state.doc.length}constructor(t){super(),this.view=t,this.decorations=[],this.dynamicDecorationMap=[],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,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 Ae(0,0,0,t.state.doc.length)],0,null)}update(t){var e;let i=t.changedRanges;this.minWidth>0&&i.length&&(i.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);let n=-1;this.view.inputState.composing>=0&&((null===(e=this.domChanged)||void 0===e?void 0:e.newSel)?n=this.domChanged.newSel.head:Ne(t.changes,this.hasComposition)||t.selectionSet||(n=t.state.selection.main.head));let s=n>-1?De(this.view,t.changes,n):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:e,to:n}=this.hasComposition;i=new Ae(e,n,t.changes.mapPos(e,-1),t.changes.mapPos(n,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(a.ie||a.chrome)&&!s&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let r=Pe(this.decorations,this.updateDeco(),t.changes);return i=Ae.extendWithRanges(i,r),!!(7&this.flags||0!=i.length)&&(this.updateInner(i,t.startState.doc.length,s),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e,i){this.view.viewState.mustMeasureContent=!0,this.updateChildren(t,e,i);let{observer:n}=this.view;n.ignore((()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let t=a.chrome||a.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,t),this.flags&=-8,t&&(t.written||n.selectionRange.focusNode!=t.node)&&(this.forceSelection=!0),this.dom.style.height=""})),this.markedForComposition.forEach((t=>t.flags&=-9));let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let r of this.children)r instanceof vt&&r.widget instanceof Oe&&s.push(r.dom);n.updateGaps(s)}updateChildren(t,e,i){let n=i?i.range.addToSet(t.slice()):t,s=this.childCursor(e);for(let r=n.length-1;;r--){let t=r>=0?n[r]:null;if(!t)break;let e,o,h,l,{fromA:a,toA:c,fromB:u,toB:f}=t;if(i&&i.range.fromB<f&&i.range.toB>u){let t=Ct.build(this.view.state.doc,u,i.range.fromB,this.decorations,this.dynamicDecorationMap),n=Ct.build(this.view.state.doc,i.range.toB,f,this.decorations,this.dynamicDecorationMap);o=t.breakAtStart,h=t.openStart,l=n.openEnd;let s=this.compositionView(i);n.breakAtStart?s.breakAfter=1:n.content.length&&s.merge(s.length,s.length,n.content[0],!1,n.openStart,0)&&(s.breakAfter=n.content[0].breakAfter,n.content.shift()),t.content.length&&s.merge(0,0,t.content[t.content.length-1],!0,0,t.openEnd)&&t.content.pop(),e=t.content.concat(s).concat(n.content)}else({content:e,breakAtStart:o,openStart:h,openEnd:l}=Ct.build(this.view.state.doc,u,f,this.decorations,this.dynamicDecorationMap));let{i:d,off:g}=s.findPos(c,1),{i:p,off:m}=s.findPos(a,-1);j(this,p,m,d,g,e,o,h,l)}i&&this.fixCompositionDOM(i)}compositionView(t){let e=new nt(t.text.nodeValue);e.flags|=8;for(let{deco:n}of t.marks)e=new st(n,[e],e.length);let i=new wt;return i.append(e,0),i}fixCompositionDOM(t){let e=(t,e)=>{e.flags|=8|(e.children.some((t=>7&t.flags))?1:0),this.markedForComposition.add(e);let i=F.get(t);i&&i!=e&&(i.dom=null),e.setDOM(t)},i=this.childPos(t.range.fromB,1),n=this.children[i.i];e(t.line,n);for(let s=t.marks.length-1;s>=-1;s--)i=n.childPos(i.off,1),n=n.children[i.i],e(s>=0?t.marks[s].node:t.text,n)}updateSelection(t=!1,e=!1){!t&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let i=this.view.root.activeElement,n=i==this.dom,s=!n&&w(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(n||e||s))return;let r=this.forceSelection;this.forceSelection=!1;let o=this.view.state.selection.main,h=this.moveToLine(this.domAtPos(o.anchor)),l=o.empty?h:this.moveToLine(this.domAtPos(o.head));if(a.gecko&&o.empty&&!this.hasComposition&&(1==(c=h).node.nodeType&&c.node.firstChild&&(0==c.offset||"false"==c.node.childNodes[c.offset-1].contentEditable)&&(c.offset==c.node.childNodes.length||"false"==c.node.childNodes[c.offset].contentEditable))){let t=document.createTextNode("");this.view.observer.ignore((()=>h.node.insertBefore(t,h.node.childNodes[h.offset]||null))),h=l=new H(t,0),r=!0}var c;let u=this.view.observer.selectionRange;!r&&u.focusNode&&(y(h.node,h.offset,u.anchorNode,u.anchorOffset)&&y(l.node,l.offset,u.focusNode,u.focusOffset)||this.suppressWidgetCursorChange(u,o))||(this.view.observer.ignore((()=>{a.android&&a.chrome&&this.dom.contains(u.focusNode)&&Le(u.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let t=g(this.view.root);if(t)if(o.empty){if(a.gecko){let t=Re(h.node,h.offset);if(t&&3!=t){let e=Ee(h.node,h.offset,1==t?1:-1);e&&(h=new H(e.node,e.offset))}}t.collapse(h.node,h.offset),null!=o.bidiLevel&&void 0!==t.caretBidiLevel&&(t.caretBidiLevel=o.bidiLevel)}else if(t.extend){t.collapse(h.node,h.offset);try{t.extend(l.node,l.offset)}catch(e){}}else{let e=document.createRange();o.anchor>o.head&&([h,l]=[l,h]),e.setEnd(l.node,l.offset),e.setStart(h.node,h.offset),t.removeAllRanges(),t.addRange(e)}else;s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())})),this.view.observer.setSelectionRange(h,l)),this.impreciseAnchor=h.precise?null:new H(u.anchorNode,u.anchorOffset),this.impreciseHead=l.precise?null:new H(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&y(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)&&this.posFromDOM(t.focusNode,t.focusOffset)==e.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:t}=this,e=t.state.selection.main,i=g(t.root),{anchorNode:n,anchorOffset:s}=t.observer.selectionRange;if(!(i&&e.empty&&e.assoc&&i.modify))return;let r=wt.find(this,e.head);if(!r)return;let o=r.posAtStart;if(e.head==o||e.head==o+r.length)return;let h=this.coordsAt(e.head,-1),l=this.coordsAt(e.head,1);if(!h||!l||h.bottom>l.top)return;let a=this.domAtPos(e.head+e.assoc);i.collapse(a.node,a.offset),i.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let c=t.observer.selectionRange;t.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=e.from&&i.collapse(n,s)}moveToLine(t){let e,i=this.dom;if(t.node!=i)return t;for(let n=t.offset;!e&&n<i.childNodes.length;n++){let t=F.get(i.childNodes[n]);t instanceof wt&&(e=t.domAtPos(0))}for(let n=t.offset-1;!e&&n>=0;n--){let t=F.get(i.childNodes[n]);t instanceof wt&&(e=t.domAtPos(t.length))}return e?new H(e.node,e.offset,!0):t}nearest(t){for(let e=t;e;){let t=F.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){let i=null,n=0;for(let s=this.length,r=this.children.length-1;r>=0;r--){let o=this.children[r],h=s-o.breakAfter,l=h-o.length;if(h<t)break;l<=t&&(l<t||o.covers(-1))&&(h>t||o.covers(1))&&(!i||o instanceof wt&&!(i instanceof wt&&e>=0))&&(i=o,n=l),s=l}return i?i.coordsAt(t-n,e):null}coordsForChar(t){let{i:e,off:i}=this.childPos(t,1),n=this.children[e];if(!(n instanceof wt))return null;for(;n.children.length;){let{i:t,off:e}=n.childPos(i,1);for(;;t++){if(t==n.children.length)return null;if((n=n.children[t]).length)break}i=e}if(!(n instanceof nt))return null;let s=(0,r.cp)(n.text,i);if(s==i)return null;let o=B(n.dom,i,s).getClientRects();for(let r=0;r<o.length;r++){let t=o[r];if(r==o.length-1||t.top<t.bottom&&t.left<t.right)return t}return null}measureVisibleLineHeights(t){let e=[],{from:i,to:n}=t,s=this.view.contentDOM.clientWidth,r=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,h=this.view.textDirection==u.LTR;for(let l=0,a=0;a<this.children.length;a++){let t=this.children[a],c=l+t.length;if(c>n)break;if(l>=i){let i=t.dom.getBoundingClientRect();if(e.push(i.height),r){let e=t.dom.lastChild,n=e?v(e):[];if(n.length){let t=n[n.length-1],e=h?t.right-i.left:i.right-t.left;e>o&&(o=e,this.minWidth=s,this.minWidthFrom=l,this.minWidthTo=c)}}}l=c+t.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?u.RTL:u.LTR}measureTextSize(){for(let s of this.children)if(s instanceof wt){let t=s.measureTextSize();if(t)return t}let t,e,i,n=document.createElement("div");return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore((()=>{this.dom.appendChild(n);let s=v(n.firstChild)[0];t=n.getBoundingClientRect().height,e=s?s.width/27:7,i=s?s.height:t,n.remove()})),{lineHeight:t,charWidth:e,textHeight:i}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new _(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)/this.view.scaleY;t.push(bt.replace({widget:new Oe(n),block:!0,inclusive:!0,isBlockGap:!0}).range(i,r))}if(!s)break;i=s.to+1}return bt.set(t)}updateDeco(){let t=this.view.state.facet(me).map(((t,e)=>(this.dynamicDecorationMap[e]="function"==typeof t)?t(this.view):t)),e=!1,i=this.view.state.facet(we).map(((t,i)=>{let n="function"==typeof t;return n&&(e=!0),n?t(this.view):t}));i.length&&(this.dynamicDecorationMap[t.length]=e,t.push(r.Xs.join(i)));for(let n=t.length;n<t.length+3;n++)this.dynamicDecorationMap[n]=!1;return this.decorations=[...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco]}scrollIntoView(t){if(t.isSnapshot){let e=this.view.viewState.lineBlockAt(t.range.head);return this.view.scrollDOM.scrollTop=e.top-t.yMargin,void(this.view.scrollDOM.scrollLeft=t.xMargin)}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=Se(this.view),r={left:n.left-s.left,top:n.top-s.top,right:n.right+s.right,bottom:n.bottom+s.bottom},{offsetWidth:o,offsetHeight:h}=this.view.scrollDOM;C(this.view.scrollDOM,r,i.head<i.anchor?-1:1,t.x,t.y,Math.max(Math.min(t.xMargin,o),-o),Math.max(Math.min(t.yMargin,h),-h),this.view.textDirection==u.LTR)}}class Oe extends yt{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return t.className="cm-gap",this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}}function Te(t,e){let i=t.observer.selectionRange,n=i.focusNode&&Ee(i.focusNode,i.focusOffset,0);if(!n)return null;let s=e-n.offset;return{from:s,to:s+n.node.nodeValue.length,node:n.node}}function De(t,e,i){let n=Te(t,i);if(!n)return null;let{node:s,from:r,to:o}=n,h=s.nodeValue;if(/[\n\r]/.test(h))return null;if(t.state.doc.sliceString(n.from,n.to)!=h)return null;let l=e.invertedDesc,a=new Ae(l.mapPos(r),l.mapPos(o),r,o),c=[];for(let u=s.parentNode;;u=u.parentNode){let e=F.get(u);if(e instanceof st)c.push({node:u,deco:e.mark});else{if(e instanceof wt||"DIV"==u.nodeName&&u.parentNode==t.contentDOM)return{range:a,text:s,marks:c,line:u};if(u==t.contentDOM)return null;c.push({node:u,deco:new xt({inclusive:!0,attributes:mt(u),tagName:u.tagName.toLowerCase()})})}}}function Ee(t,e,i){if(i<=0)for(let n=t,s=e;;){if(3==n.nodeType)return{node:n,offset:s};if(!(1==n.nodeType&&s>0))break;n=n.childNodes[s-1],s=S(n)}if(i>=0)for(let n=t,s=e;;){if(3==n.nodeType)return{node:n,offset:s};if(!(1==n.nodeType&&s<n.childNodes.length&&i>=0))break;n=n.childNodes[s],s=0}return null}function Re(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)}let Be=class{constructor(){this.changes=[]}compareRange(t,e){Mt(t,e,this.changes)}comparePoint(t,e){Mt(t,e,this.changes)}};function Pe(t,e,i){let n=new Be;return r.Xs.compare(t,e,i,n),n.changes}function Le(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 Ne(t,e){let i=!1;return e&&t.iterChangedRanges(((t,n)=>{t<e.to&&n>e.from&&(i=!0)})),i}function Ie(t,e,i=1){let n=t.charCategorizer(e),s=t.doc.lineAt(e),o=e-s.from;if(0==s.length)return r.jT.cursor(e);0==o?i=1:o==s.length&&(i=-1);let h=o,l=o;i<0?h=(0,r.cp)(s.text,o,!1):l=(0,r.cp)(s.text,o);let a=n(s.text.slice(h,l));for(;h>0;){let t=(0,r.cp)(s.text,h,!1);if(n(s.text.slice(t,h))!=a)break;h=t}for(;l<s.length;){let t=(0,r.cp)(s.text,l);if(n(s.text.slice(l,t))!=a)break;l=t}return r.jT.range(h+s.from,l+s.from)}function Ve(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function He(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function We(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function Fe(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function ze(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function _e(t,e,i){let n,s,r,o,h,l,a,c,u=!1;for(let d=t.firstChild;d;d=d.nextSibling){let t=v(d);for(let f=0;f<t.length;f++){let g=t[f];s&&We(s,g)&&(g=Fe(ze(g,s.bottom),s.top));let p=Ve(e,g),m=He(i,g);if(0==p&&0==m)return 3==d.nodeType?je(d,e,i):_e(d,e,i);if(!n||o>m||o==m&&r>p){n=d,s=g,r=p,o=m;let h=m?i<g.top?-1:1:p?e<g.left?-1:1:0;u=!h||(h>0?f<t.length-1:f>0)}0==p?i>g.bottom&&(!a||a.bottom<g.bottom)?(h=d,a=g):i<g.top&&(!c||c.top>g.top)&&(l=d,c=g):a&&We(a,g)?a=ze(a,g.bottom):c&&We(c,g)&&(c=Fe(c,g.top))}}if(a&&a.bottom>=i?(n=h,s=a):c&&c.top<=i&&(n=l,s=c),!n)return{node:t,offset:0};let f=Math.max(s.left,Math.min(s.right,e));return 3==n.nodeType?je(n,f,i):u&&"false"!=n.contentEditable?_e(n,f,i):{node:t,offset:Array.prototype.indexOf.call(t.childNodes,n)+(e>=(s.left+s.right)/2?1:0)}}function je(t,e,i){let n=t.nodeValue.length,s=-1,r=1e9,o=0;for(let h=0;h<n;h++){let n=B(t,h,h+1).getClientRects();for(let l=0;l<n.length;l++){let c=n[l];if(c.top==c.bottom)continue;o||(o=e-c.left);let u=(c.top>i?c.top-i:i-c.bottom)-1;if(c.left-1<=e&&c.right+1>=e&&u<r){let i=e>=(c.left+c.right)/2,n=i;if(a.chrome||a.gecko){B(t,h).getBoundingClientRect().left==c.right&&(n=!i)}if(u<=0)return{node:t,offset:h+(n?1:0)};s=h+(n?1:0),r=u}}}return{node:t,offset:s>-1?s:o>0?t.nodeValue.length:0}}function qe(t,e,i,n=-1){var s,r;let o,h=t.contentDOM.getBoundingClientRect(),l=h.top+t.viewState.paddingTop,{docHeight:u}=t.viewState,{x:f,y:d}=e,g=d-l;if(g<0)return 0;if(g>u)return t.state.doc.length;for(let a=t.viewState.heightOracle.textHeight/2,S=!1;o=t.elementAtHeight(g),o.type!=c.Text;)for(;g=n>0?o.bottom+a:o.top-a,!(g>=0&&g<=u);){if(S)return i?null:0;S=!0,n=-n}d=l+g;let p=o.from;if(p<t.viewport.from)return 0==t.viewport.from?0:i?null:$e(t,h,o,f,d);if(p>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:$e(t,h,o,f,d);let m=t.dom.ownerDocument,w=t.root.elementFromPoint?t.root:m,v=w.elementFromPoint(f,d);v&&!t.contentDOM.contains(v)&&(v=null),v||(f=Math.max(h.left+1,Math.min(h.right-1,f)),v=w.elementFromPoint(f,d),v&&!t.contentDOM.contains(v)&&(v=null));let y,b=-1;if(v&&0!=(null===(s=t.docView.nearest(v))||void 0===s?void 0:s.isEditable))if(m.caretPositionFromPoint){let t=m.caretPositionFromPoint(f,d);t&&({offsetNode:y,offset:b}=t)}else if(m.caretRangeFromPoint){let e=m.caretRangeFromPoint(f,d);e&&(({startContainer:y,startOffset:b}=e),(!t.contentDOM.contains(y)||a.safari&&Ke(y,b,f)||a.chrome&&Je(y,b,f))&&(y=void 0))}if(!y||!t.docView.dom.contains(y)){let e=wt.find(t.docView,p);if(!e)return g>o.top+o.height/2?o.to:o.from;({node:y,offset:b}=_e(e.dom,f,d))}let x=t.docView.nearest(y);if(!x)return null;if(x.isWidget&&1==(null===(r=x.dom)||void 0===r?void 0:r.nodeType)){let t=x.dom.getBoundingClientRect();return e.y<t.top||e.y<=t.bottom&&e.x<=(t.left+t.right)/2?x.posAtStart:x.posAtEnd}return x.localPosFromDOM(y,b)+x.posAtStart}function $e(t,e,i,n,s){let o=Math.round((n-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>1.5*t.defaultLineHeight){let e=t.viewState.heightOracle.textHeight;o+=Math.floor((s-i.top-.5*(t.defaultLineHeight-e))/e)*t.viewState.heightOracle.lineLength}let h=t.state.sliceDoc(i.from,i.to);return i.from+(0,r.Gz)(h,o,t.state.tabSize)}function Ke(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 B(t,n-1,n).getBoundingClientRect().left>i}function Je(t,e,i){if(0!=e)return!1;for(let n=t;;){let t=n.parentNode;if(!t||1!=t.nodeType||t.firstChild!=n)return!1;if(t.classList.contains("cm-line"))break;n=t}return i-(1==t.nodeType?t.getBoundingClientRect():B(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect()).left>5}function Ge(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==c.Text))return n;return i}function Ue(t,e,i,n){let s=Ge(t,e.head),o=n&&s.type==c.Text&&(t.lineWrapping||s.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head):null;if(o){let e=t.dom.getBoundingClientRect(),n=t.textDirectionAt(s.from),h=t.posAtCoords({x:i==(n==u.LTR)?e.right-1:e.left+1,y:(o.top+o.bottom)/2});if(null!=h)return r.jT.cursor(h,i?-1:1)}return r.jT.cursor(i?s.to:s.from,i?-1:1)}function Xe(t,e,i,n){let s=t.state.doc.lineAt(e.head),r=t.bidiSpans(s),o=t.textDirectionAt(s.from);for(let h=e,l=null;;){let e=Ut(s,r,o,h,i),a=Gt;if(!e){if(s.number==(i?t.state.doc.lines:1))return h;a="\n",s=t.state.doc.line(s.number+(i?1:-1)),r=t.bidiSpans(s),e=t.visualLineSide(s,!i)}if(l){if(!l(a))return h}else{if(!n)return e;l=n(a)}h=e}}function Ye(t,e,i){let n=t.state.charCategorizer(e),s=n(i);return t=>{let e=n(t);return s==r.D0.Space&&(s=e),s==e}}function Qe(t,e,i,n){let s=e.head,o=i?1:-1;if(s==(i?t.state.doc.length:0))return r.jT.cursor(s,e.assoc);let h,l=e.goalColumn,a=t.contentDOM.getBoundingClientRect(),c=t.coordsAtPos(s,e.assoc||-1),u=t.documentTop;if(c)null==l&&(l=c.left-a.left),h=o<0?c.top:c.bottom;else{let e=t.viewState.lineBlockAt(s);null==l&&(l=Math.min(a.right-a.left,t.defaultCharacterWidth*(s-e.from))),h=(o<0?e.top:e.bottom)+u}let f=a.left+l,d=null!=n?n:t.viewState.heightOracle.textHeight>>1;for(let g=0;;g+=10){let e=h+(d+g)*o,i=qe(t,{x:f,y:e},!1,o);if(e<a.top||e>a.bottom||(o<0?i<s:i>s)){let n=t.docView.coordsForChar(i),s=!n||e<n.top?-1:1;return r.jT.cursor(i,s,void 0,l)}}}function Ze(t,e,i){for(;;){let n=0;for(let s of t)s.between(e-1,e+1,((t,s,r)=>{if(e>t&&e<s){let r=n||i||(e-t<s-e?-1:1);e=r<0?t:s,n=r}}));if(!n)return e}}function ti(t,e,i){let n=Ze(t.state.facet(ve).map((e=>e(t))),i.from,e.head>i.from?-1:1);return n==i.from?i:r.jT.cursor(n,n<i.from?1:-1)}class ei{setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}constructor(t){this.view=t,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=t.hasFocus,a.safari&&t.contentDOM.addEventListener("input",(()=>null)),a.gecko&&Wi(t.contentDOM.ownerDocument)}handleEvent(t){di(this.view,t)&&!this.ignoreDuringComposition(t)&&("keydown"==t.type&&this.keydown(t)||this.runHandlers(t.type,t))}runHandlers(t,e){let i=this.handlers[t];if(i){for(let t of i.observers)t(this.view,e);for(let t of i.handlers){if(e.defaultPrevented)break;if(t(this.view,e)){e.preventDefault();break}}}}ensureHandlers(t){let e=ni(t),i=this.handlers,n=this.view.contentDOM;for(let s in e)if("scroll"!=s){let t=!e[s].handlers.length,r=i[s];r&&t!=!r.handlers.length&&(n.removeEventListener(s,this.handleEvent),r=null),r||n.addEventListener(s,this.handleEvent,{passive:t})}for(let s in i)"scroll"==s||e[s]||n.removeEventListener(s,this.handleEvent);this.handlers=e}keydown(t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),9==t.keyCode&&Date.now()<this.lastEscPress+2e3)return!0;if(27!=t.keyCode&&oi.indexOf(t.keyCode)<0&&(this.view.inputState.lastEscPress=0),a.android&&a.chrome&&!t.synthetic&&(13==t.keyCode||8==t.keyCode))return this.view.observer.delayAndroidKey(t.key,t.keyCode),!0;let e;return!a.ios||t.synthetic||t.altKey||t.metaKey||!((e=si.find((e=>e.keyCode==t.keyCode)))&&!t.ctrlKey||ri.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)?(229!=t.keyCode&&this.view.observer.forceFlush(),!1):(this.pendingIOSKey=e||t,setTimeout((()=>this.flushIOSKey()),250),!0)}flushIOSKey(){let t=this.pendingIOSKey;return!!t&&(this.pendingIOSKey=void 0,P(this.view.contentDOM,t.key,t.keyCode))}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(this.composing>0||!!(a.safari&&!a.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.mouseSelection&&this.mouseSelection.update(t),this.draggedContent&&t.docChanged&&(this.draggedContent=this.draggedContent.map(t.changes)),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function ii(t,e){return(i,n)=>{try{return e.call(t,n,i)}catch(s){le(i.state,s)}}}function ni(t){let e=Object.create(null);function i(t){return e[t]||(e[t]={observers:[],handlers:[]})}for(let n of t){let t=n.spec;if(t&&t.domEventHandlers)for(let e in t.domEventHandlers){let s=t.domEventHandlers[e];s&&i(e).handlers.push(ii(n.value,s))}if(t&&t.domEventObservers)for(let e in t.domEventObservers){let s=t.domEventObservers[e];s&&i(e).observers.push(ii(n.value,s))}}for(let n in gi)i(n).handlers.push(gi[n]);for(let n in pi)i(n).observers.push(pi[n]);return e}const si=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],ri="dthko",oi=[16,17,18,20,91,92,224,225],hi=6;function li(t){return.7*Math.max(0,t)+8}class ai{constructor(t,e,i,n){this.view=t,this.startEvent=e,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParent=O(t.contentDOM),this.atoms=t.state.facet(ve).map((e=>e(t)));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(r.yy.allowMultipleSelections)&&ci(t,e),this.dragging=!(!fi(t,e)||1!=Ti(e))&&null}start(t){!1===this.dragging&&this.select(t)}move(t){var e,i,n;if(0==t.buttons)return this.destroy();if(this.dragging||null==this.dragging&&(i=this.startEvent,n=t,Math.max(Math.abs(i.clientX-n.clientX),Math.abs(i.clientY-n.clientY))<10))return;this.select(this.lastEvent=t);let s=0,r=0,o=(null===(e=this.scrollParent)||void 0===e?void 0:e.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},h=Se(this.view);t.clientX-h.left<=o.left+hi?s=-li(o.left-t.clientX):t.clientX+h.right>=o.right-hi&&(s=li(t.clientX-o.right)),t.clientY-h.top<=o.top+hi?r=-li(o.top-t.clientY):t.clientY+h.bottom>=o.bottom-hi&&(r=li(t.clientY-o.bottom)),this.setScrollSpeed(s,r)}up(t){null==this.dragging&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval((()=>this.scroll()),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),!1===this.dragging&&this.select(this.lastEvent)}skipAtoms(t){let e=null;for(let i=0;i<t.ranges.length;i++){let n=t.ranges[i],s=null;if(n.empty){let t=Ze(this.atoms,n.from,0);t!=n.from&&(s=r.jT.cursor(t,-1))}else{let t=Ze(this.atoms,n.from,-1),e=Ze(this.atoms,n.to,1);t==n.from&&e==n.to||(s=r.jT.range(n.from==n.anchor?t:e,n.from==n.head?t:e))}s&&(e||(e=t.ranges.slice()),e[i]=s)}return e?r.jT.create(e,t.mainIndex):t}select(t){let{view:e}=this,i=this.skipAtoms(this.style.get(t,this.extend,this.multiple));!this.mustSelect&&i.eq(e.state.selection,!1===this.dragging)||this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){this.style.update(t)&&setTimeout((()=>this.select(this.lastEvent)),20)}}function ci(t,e){let i=t.state.facet(Yt);return i.length?i[0](e):a.mac?e.metaKey:e.ctrlKey}function ui(t,e){let i=t.state.facet(Qt);return i.length?i[0](e):a.mac?!e.altKey:!e.ctrlKey}function fi(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let n=g(t.root);if(!n||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 di(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=F.get(n))&&i.ignoreEvent(e))return!1;return!0}const gi=Object.create(null),pi=Object.create(null),mi=a.ie&&a.ie_version<15||a.ios&&a.webkit_version<604;function wi(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(),vi(t,i.value)}),50)}function vi(t,e){let i,{state:n}=t,s=1,o=n.toText(e),h=o.lines==n.selection.ranges.length;if(null!=Li&&n.selection.ranges.every((t=>t.empty))&&Li==o.toString()){let t=-1;i=n.changeByRange((i=>{let l=n.doc.lineAt(i.from);if(l.from==t)return{range:i};t=l.from;let a=n.toText((h?o.line(s++).text:e)+n.lineBreak);return{changes:{from:l.from,insert:a},range:r.jT.cursor(i.from+a.length)}}))}else i=h?n.changeByRange((t=>{let e=o.line(s++);return{changes:{from:t.from,to:t.to,insert:e.text},range:r.jT.cursor(t.from+e.length)}})):n.replaceSelection(o);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function yi(t,e,i,n){if(1==n)return r.jT.cursor(e,i);if(2==n)return Ie(t.state,e,i);{let i=wt.find(t.docView,e),n=t.state.doc.lineAt(i?i.posAtEnd:e),s=i?i.posAtStart:n.from,o=i?i.posAtEnd:n.to;return o<t.state.doc.length&&o==n.to&&o++,r.jT.range(s,o)}}pi.scroll=t=>{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft},gi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),27==e.keyCode&&(t.inputState.lastEscPress=Date.now()),!1),pi.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},pi.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},gi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let i=null;for(let n of t.state.facet(Zt))if(i=n(t,e),i)break;if(i||0!=e.button||(i=Di(t,e)),i){let n=!t.hasFocus;t.inputState.startMouseSelection(new ai(t,e,i,n)),n&&t.observer.ignore((()=>R(t.contentDOM)));let s=t.inputState.mouseSelection;if(s)return s.start(e),!1===s.dragging}return!1};let bi=(t,e)=>t>=e.top&&t<=e.bottom,xi=(t,e,i)=>bi(e,i)&&t>=i.left&&t<=i.right;function Si(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&&xi(i,n,o))return-1;let h=s.coordsAt(r,1);return h&&xi(i,n,h)?1:o&&bi(n,o)?-1:1}function ki(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:Si(t,i,e.clientX,e.clientY)}}const Ai=a.ie&&a.ie_version<=11;let Mi=null,Ci=0,Oi=0;function Ti(t){if(!Ai)return t.detail;let e=Mi,i=Oi;return Mi=t,Oi=Date.now(),Ci=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Ci+1)%3:1}function Di(t,e){let i=ki(t,e),n=Ti(e),s=t.state.selection;return{update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),s=s.map(t.changes))},get(e,o,h){let l,a=ki(t,e),c=yi(t,a.pos,a.bias,n);if(i.pos!=a.pos&&!o){let e=yi(t,i.pos,i.bias,n),s=Math.min(e.from,c.from),o=Math.max(e.to,c.to);c=s<c.from?r.jT.range(s,o):r.jT.range(o,s)}return o?s.replaceRange(s.main.extend(c.from,c.to)):h&&1==n&&s.ranges.length>1&&(l=Ei(s,a.pos))?l:h?s.addRange(c):r.jT.create([c])}}}function Ei(t,e){for(let i=0;i<t.ranges.length;i++){let{from:n,to:s}=t.ranges[i];if(n<=e&&s>=e)return r.jT.create(t.ranges.slice(0,i).concat(t.ranges.slice(i+1)),t.mainIndex==i?0:t.mainIndex-(t.mainIndex>i?1:0))}return null}function Ri(t,e,i,n){if(!i)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=t.inputState,o=n&&r&&ui(t,e)?{from:r.from,to:r.to}:null,h={from:s,insert:i},l=t.state.changes(o?[o,h]:h);t.focus(),t.dispatch({changes:l,selection:{anchor:l.mapPos(s,-1),head:l.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"}),t.inputState.draggedContent=null}function Bi(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 Pi(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}}gi.dragstart=(t,e)=>{let{selection:{main:i}}=t.state;if(e.target.draggable){let n=t.docView.nearest(e.target);if(n&&n.isWidget){let t=n.posAtStart,e=t+n.length;(t>=i.to||e<=i.from)&&(i=r.jT.range(t,e))}}let{inputState:n}=t;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=i,e.dataTransfer&&(e.dataTransfer.setData("Text",t.state.sliceDoc(i.from,i.to)),e.dataTransfer.effectAllowed="copyMove"),!1},gi.dragend=t=>(t.inputState.draggedContent=null,!1),gi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let i=e.dataTransfer.files;if(i&&i.length){let n=Array(i.length),s=0,r=()=>{++s==i.length&&Ri(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])}return!0}{let i=e.dataTransfer.getData("Text");if(i)return Ri(t,e,i,!0),!0}return!1},gi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let i=mi?null:e.clipboardData;return i?(vi(t,i.getData("text/plain")||i.getData("text/uri-text")),!0):(wi(t),!1)};let Li=null;gi.copy=gi.cut=(t,e)=>{let{text:i,ranges:n,linewise:s}=Pi(t.state);if(!i&&!s)return!1;Li=s?i:null,"cut"!=e.type||t.state.readOnly||t.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let r=mi?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",i),!0):(Bi(t,i),!1)};const Ni=r.q6.define();function Ii(t,e){let i=[];for(let n of t.facet(ne)){let s=n(t,e);s&&i.push(s)}return i?t.update({effects:i,annotations:Ni.of(!0)}):null}function Vi(t){setTimeout((()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=Ii(t.state,e);i?t.dispatch(i):t.update([])}}),10)}pi.focus=t=>{t.inputState.lastFocusTime=Date.now(),t.scrollDOM.scrollTop||!t.inputState.lastScrollTop&&!t.inputState.lastScrollLeft||(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),Vi(t)},pi.blur=t=>{t.observer.clearSelectionRange(),Vi(t)},pi.compositionstart=pi.compositionupdate=t=>{null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0)},pi.compositionend=t=>{t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,a.chrome&&a.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then((()=>t.observer.flush())):setTimeout((()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])}),50)},pi.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},gi.beforeinput=(t,e)=>{var i;let n;if(a.chrome&&a.android&&(n=si.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)}return!1};const Hi=new Set;function Wi(t){Hi.has(t)||(Hi.add(t),t.addEventListener("copy",(()=>{})),t.addEventListener("cut",(()=>{})))}const Fi=["pre-wrap","normal","pre-line","break-spaces"];class zi{constructor(t){this.lineWrapping=t,this.doc=r.xv.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,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.max(0,Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(t){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5))))*this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return Fi.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let n=t[i];n<0?i++:this.heightSamples[Math.floor(10*n)]||(e=!0,this.heightSamples[Math.floor(10*n)]=!0)}return e}refresh(t,e,i,n,s,r){let o=Fi.indexOf(t)>-1,h=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=e,this.charWidth=i,this.textHeight=n,this.lineLength=s,h){this.heightSamples={};for(let t=0;t<r.length;t++){let e=r[t];e<0?t++:this.heightSamples[Math.floor(10*e)]=!0}}return h}}class _i{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class ji{constructor(t,e,i,n,s){this.from=t,this.length=e,this.top=i,this.height=n,this._content=s}get type(){return"number"==typeof this._content?c.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof kt?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(t){let e=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new ji(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var f=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}(f||(f={}));const qi=.001;class $i{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)>qi&&(t.heightChanged=!0),this.height=e)}replace(t,e,i){return $i.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,n){let s=this,r=i.doc;for(let o=n.length-1;o>=0;o--){let{fromA:h,toA:l,fromB:a,toB:c}=n[o],u=s.lineAt(h,f.ByPosNoHeight,i.setDoc(e),0,0),d=u.to>=l?u:s.lineAt(l,f.ByPosNoHeight,i,0,0);for(c+=d.to-l,l=d.to;o>0&&u.from<=n[o-1].toA;)h=n[o-1].fromA,a=n[o-1].fromB,o--,h<u.from&&(u=s.lineAt(h,f.ByPosNoHeight,i,0,0));a+=u.from-h,h=u.from;let g=Qi.build(i.setDoc(r),t,a,c);s=s.replace(h,l,g)}return s.updateHeight(i,0)}static empty(){return new Ji(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 Ui($i.of(t.slice(0,e)),r,$i.of(t.slice(i)))}}$i.prototype.size=1;class Ki extends $i{constructor(t,e,i){super(t,e),this.deco=i}blockAt(t,e,i,n){return new ji(n,this.length,i,this.height,this.deco||0)}lineAt(t,e,i,n,s){return this.blockAt(0,i,n,s)}forEachLine(t,e,i,n,s,r){t<=s+this.length&&e>=s&&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 Ji extends Ki{constructor(t,e){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(t,e,i,n){return new ji(n,this.length,i,this.height,this.breaks)}replace(t,e,i){let n=i[0];return 1==i.length&&(n instanceof Ji||n instanceof Gi&&4&n.flags)&&Math.abs(this.length-n.length)<10?(n instanceof Gi?n=new Ji(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):$i.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.breaks*t.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Gi extends $i{constructor(t){super(t,0)}heightMetrics(t,e){let i,n=t.doc.lineAt(e).number,s=t.doc.lineAt(e+this.length).number,r=s-n+1,o=0;if(t.lineWrapping){let e=Math.min(this.height,t.lineHeight*r);i=e/r,this.length>r+1&&(o=(this.height-e)/(this.length-r-1))}else i=this.height/r;return{firstLine:n,lastLine:s,perLine:i,perChar:o}}blockAt(t,e,i,n){let{firstLine:s,lastLine:r,perLine:o,perChar:h}=this.heightMetrics(e,n);if(e.lineWrapping){let s=n+Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length),r=e.doc.lineAt(s),l=o+r.length*h,a=Math.max(i,t-l/2);return new ji(r.from,r.length,a,l,0)}{let n=Math.max(0,Math.min(r-s,Math.floor((t-i)/o))),{from:h,length:l}=e.doc.line(s+n);return new ji(h,l,i+o*n,o,0)}}lineAt(t,e,i,n,s){if(e==f.ByHeight)return this.blockAt(t,i,n,s);if(e==f.ByPosNoHeight){let{from:e,to:n}=i.doc.lineAt(t);return new ji(e,n-e,0,0,0)}let{firstLine:r,perLine:o,perChar:h}=this.heightMetrics(i,s),l=i.doc.lineAt(t),a=o+l.length*h,c=l.number-r,u=n+o*c+h*(l.from-s-c);return new ji(l.from,l.length,Math.max(n,Math.min(u,n+this.height-a)),a,0)}forEachLine(t,e,i,n,s,r){t=Math.max(t,s),e=Math.min(e,s+this.length);let{firstLine:o,perLine:h,perChar:l}=this.heightMetrics(i,s);for(let a=t,c=n;a<=e;){let e=i.doc.lineAt(a);if(a==t){let i=e.number-o;c+=h*i+l*(t-s-i)}let n=h+l*e.length;r(new ji(e.from,e.length,c,n,0)),c+=n,a=e.to+1}}replace(t,e,i){let n=this.length-e;if(n>0){let t=i[i.length-1];t instanceof Gi?i[i.length-1]=new Gi(t.length+n):i.push(null,new Gi(n-1))}if(t>0){let e=i[0];e instanceof Gi?i[0]=new Gi(t+e.length):i.unshift(new Gi(t-1),null)}return $i.of(i)}decomposeLeft(t,e){e.push(new Gi(t-1),null)}decomposeRight(t,e){e.push(null,new Gi(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;for(n.from>e&&i.push(new Gi(n.from-e-1).updateHeight(t,e));r<=s&&n.more;){let e=t.doc.lineAt(r).length;i.length&&i.push(null);let s=n.heights[n.index++];-1==o?o=s:Math.abs(s-o)>=qi&&(o=-2);let h=new Ji(e,s);h.outdated=!1,i.push(h),r+=e+1}r<=s&&i.push(null,new Gi(s-r).updateHeight(t,r));let h=$i.of(i);return(o<0||Math.abs(h.height-this.height)>=qi||Math.abs(o-this.heightMetrics(t,e).perLine)>=qi)&&(t.heightChanged=!0),h}return(i||this.outdated)&&(this.setHeight(t,t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class Ui extends $i{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,h=e==f.ByHeight?t<r:t<o,l=h?this.left.lineAt(t,e,i,n,s):this.right.lineAt(t,e,i,r,o);if(this.break||(h?l.to<o:l.from>o))return l;let a=e==f.ByPosNoHeight?f.ByPosNoHeight:f.ByPos;return h?l.join(this.right.lineAt(o,a,i,r,o)):this.left.lineAt(o,a,i,n,s).join(l)}forEachLine(t,e,i,n,s,r){let o=n+this.left.height,h=s+this.left.length+this.break;if(this.break)t<h&&this.left.forEachLine(t,e,i,n,s,r),e>=h&&this.right.forEachLine(t,e,i,o,h,r);else{let l=this.lineAt(h,f.ByPos,i,n,s);t<l.from&&this.left.forEachLine(t,l.from-1,i,n,s,r),l.to>=t&&l.from<=e&&r(l),e>l.to&&this.right.forEachLine(l.to+1,e,i,o,h,r)}}replace(t,e,i){let n=this.left.length+this.break;if(e<n)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let s=[];t>0&&this.decomposeLeft(t,s);let r=s.length;for(let o of i)s.push(o);if(t>0&&Xi(s,r-1),e<this.length){let t=s.length;this.decomposeRight(e,s),Xi(s,t)}return $i.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?$i.of(this.break?[t,null,e]:[t,e]):(this.left=t,this.right=e,this.height=t.height+e.height,this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,i=!1,n){let{left:s,right:r}=this,o=e+s.length+this.break,h=null;return n&&n.from<=e+s.length&&n.more?h=s=s.updateHeight(t,e,i,n):s.updateHeight(t,e,i),n&&n.from<=o+r.length&&n.more?h=r=r.updateHeight(t,o,i,n):r.updateHeight(t,o,i),h?this.balanced(s,r):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Xi(t,e){let i,n;null==t[e]&&(i=t[e-1])instanceof Gi&&(n=t[e+1])instanceof Gi&&t.splice(e-1,3,new Gi(i.length+1+n.length))}const Yi=5;class Qi{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 Ji?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new Ji(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,s=i.widget?i.widget.lineBreaks:0;n<0&&(n=this.oracle.lineHeight);let r=e-t;i.block?this.addBlock(new Ki(r,n,i)):(r||s||n>=Yi)&&this.addLineDeco(n,s,r)}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 Ji(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new Gi(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 Ji)return t;let e=new Ji(0,-1);return this.nodes.push(e),e}addBlock(t){this.enterLine();let e=t.deco;e&&e.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,e&&e.endSide>0&&(this.covering=t)}addLineDeco(t,e,i){let n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,t),n.breaks+=e,this.writtenTo=this.pos=this.pos+i}finish(t){let e=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof Ji||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new Ji(0,-1));let i=t;for(let n of this.nodes)n instanceof Ji&&n.updateHeight(this.oracle,i),i+=n?n.length:1;return this.nodes}static build(t,e,i,n){let s=new Qi(i,t);return r.Xs.spans(e,i,n,s,0),s.finish(i)}}function Zi(t,e,i){let n=new tn;return r.Xs.compare(t,e,i,n,0),n.changes}class tn{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,n){(t<e||i&&i.heightRelevant||n&&n.heightRelevant)&&Mt(t,e,this.changes,5)}}function en(t,e){let i=t.getBoundingClientRect(),n=t.ownerDocument,s=n.defaultView||window,r=Math.max(0,i.left),o=Math.min(s.innerWidth,i.right),h=Math.max(0,i.top),l=Math.min(s.innerHeight,i.bottom);for(let a=t.parentNode;a&&a!=n.body;)if(1==a.nodeType){let e=a,i=window.getComputedStyle(e);if((e.scrollHeight>e.clientHeight||e.scrollWidth>e.clientWidth)&&"visible"!=i.overflow){let i=e.getBoundingClientRect();r=Math.max(r,i.left),o=Math.min(o,i.right),h=Math.max(h,i.top),l=a==t.parentNode?i.bottom:Math.min(l,i.bottom)}a="absolute"==i.position||"fixed"==i.position?e.offsetParent:e.parentNode}else{if(11!=a.nodeType)break;a=a.host}return{left:r-i.left,right:Math.max(r,o)-i.left,top:h-(i.top+e),bottom:Math.max(h,l)-(i.top+e)}}function nn(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class sn{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,e){return bt.replace({widget:new rn(this.size*(e?t.scaleY:t.scaleX),e)}).range(this.from,this.to)}}class rn extends yt{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 on{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.scrollTop=0,this.scrolledToBottom=!0,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=fn,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=u.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let e=t.facet(pe).some((t=>"function"!=typeof t&&"cm-lineWrapping"==t.class));this.heightOracle=new zi(e),this.stateDeco=t.facet(me).filter((t=>"function"!=typeof t)),this.heightMap=$i.empty().applyChanges(this.stateDeco,r.xv.empty,this.heightOracle.setDoc(t.doc),[new Ae(0,0,0,t.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=bt.set(this.lineGaps.map((t=>t.draw(this,!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 hn(e,i))}}this.viewports=t.sort(((t,e)=>t.from-e.from)),this.scaler=this.heightMap.height<=7e6?fn:new dn(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,(t=>{this.viewportLines.push(1==this.scaler.scale?t:gn(t,this.scaler))}))}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(me).filter((t=>"function"!=typeof t));let n=t.changedRanges,s=Ae.extendWithRanges(n,Zi(i,this.stateDeco,t?t.changes:r.as.empty(this.state.doc.length))),o=this.heightMap.height,h=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),s),this.heightMap.height!=o&&(t.flags|=2),h?(this.scrollAnchorPos=t.changes.mapPos(h.from,-1),this.scrollAnchorHeight=h.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let l=s.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<l.from||e.range.head>l.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,e));let a=!t.changes.empty||2&t.flags||l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,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&&!t.state.facet(re)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),n=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?u.RTL:u.LTR;let o=this.heightOracle.mustRefreshForWrapping(s),h=e.getBoundingClientRect(),l=o||this.mustMeasureContent||this.contentDOMHeight!=h.height;this.contentDOMHeight=h.height,this.mustMeasureContent=!1;let a=0,c=0;if(h.width&&h.height){let{scaleX:t,scaleY:i}=M(e,h);this.scaleX==t&&this.scaleY==i||(this.scaleX=t,this.scaleY=i,a|=8,o=l=!0)}let f=(parseInt(i.paddingTop)||0)*this.scaleY,d=(parseInt(i.paddingBottom)||0)*this.scaleY;this.paddingTop==f&&this.paddingBottom==d||(this.paddingTop=f,this.paddingBottom=d,a|=10),this.editorWidth!=t.scrollDOM.clientWidth&&(n.lineWrapping&&(l=!0),this.editorWidth=t.scrollDOM.clientWidth,a|=8);let g=t.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=g&&(this.scrollAnchorHeight=-1,this.scrollTop=g),this.scrolledToBottom=V(t.scrollDOM);let p=(this.printing?nn:en)(e,this.paddingTop),m=p.top-this.pixelViewport.top,w=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let v=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(v!=this.inView&&(this.inView=v,v&&(l=!0)),!this.inView&&!this.scrollTarget)return 0;let y=h.width;if(this.contentDOMWidth==y&&this.editorHeight==t.scrollDOM.clientHeight||(this.contentDOMWidth=h.width,this.editorHeight=t.scrollDOM.clientHeight,a|=8),l){let e=t.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(e)&&(o=!0),o||n.lineWrapping&&Math.abs(y-this.contentDOMWidth)>n.charWidth){let{lineHeight:i,charWidth:r,textHeight:h}=t.docView.measureTextSize();o=i>0&&n.refresh(s,i,r,h,y/r,e),o&&(t.docView.minWidth=0,a|=8)}m>0&&w>0?c=Math.max(m,w):m<0&&w<0&&(c=Math.min(m,w)),n.heightChanged=!1;for(let i of this.viewports){let s=i.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(i);this.heightMap=(o?$i.empty().applyChanges(this.stateDeco,r.xv.empty,this.heightOracle,[new Ae(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(n,0,o,new _i(i.from,s))}n.heightChanged&&(a|=2)}let b=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return b&&(this.viewport=this.getViewport(c,this.scrollTarget)),this.updateForViewport(),(2&a||b)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,t)),a|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),a}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),n=this.heightMap,s=this.heightOracle,{visibleTop:r,visibleBottom:o}=this,h=new hn(n.lineAt(r-1e3*i,f.ByHeight,s,0,0).from,n.lineAt(o+1e3*(1-i),f.ByHeight,s,0,0).to);if(e){let{head:t}=e.range;if(t<h.from||t>h.to){let i,r=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),o=n.lineAt(t,f.ByPos,s,0,0);i="center"==e.y?(o.top+o.bottom)/2-r/2:"start"==e.y||"nearest"==e.y&&t<h.from?o.top:o.bottom-r,h=new hn(n.lineAt(i-500,f.ByHeight,s,0,0).from,n.lineAt(i+r+500,f.ByHeight,s,0,0).to)}}return h}mapViewport(t,e){let i=e.mapPos(t.from,-1),n=e.mapPos(t.to,1);return new hn(this.heightMap.lineAt(i,f.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,f.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(t,f.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(e,f.ByPos,this.heightOracle,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 sn(e.mapPos(n.from),e.mapPos(n.to),n.size));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,s=n>>1,o=n<<1;if(this.defaultTextDirection!=u.LTR&&!i)return[];let h=[],l=(n,o,a,c)=>{if(o-n<s)return;let u=this.state.selection.main,f=[u.from];u.empty||f.push(u.to);for(let t of f)if(t>n&&t<o)return l(n,t-10,a,c),void l(t+10,o,a,c);let d=un(t,(t=>t.from>=a.from&&t.to<=a.to&&Math.abs(t.from-n)<s&&Math.abs(t.to-o)<s&&!f.some((e=>t.from<e&&t.to>e))));if(!d){if(o<a.to&&e&&i&&e.visibleRanges.some((t=>t.from<=o&&t.to>=o))){let t=e.moveToLineBoundary(r.jT.cursor(o),!1,!0).head;t>n&&(o=t)}d=new sn(n,o,this.gapSize(a,n,o,c))}h.push(d)};for(let r of this.viewportLines){if(r.length<o)continue;let t=ln(r.from,r.to,this.stateDeco);if(t.total<o)continue;let e,s,h=this.scrollTarget?this.scrollTarget.range.head:null;if(i){let i,o,l=n/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=h){let e=cn(t,h),n=((this.visibleBottom-this.visibleTop)/2+l)/r.height;i=e-n,o=e+n}else i=(this.visibleTop-r.top-l)/r.height,o=(this.visibleBottom-r.top+l)/r.height;e=an(t,i),s=an(t,o)}else{let i,r,o=t.total*this.heightOracle.charWidth,l=n*this.heightOracle.charWidth;if(null!=h){let e=cn(t,h),n=((this.pixelViewport.right-this.pixelViewport.left)/2+l)/o;i=e-n,r=e+n}else i=(this.pixelViewport.left-l)/o,r=(this.pixelViewport.right+l)/o;e=an(t,i),s=an(t,r)}e>r.from&&l(r.from,e,r,t),s<r.to&&l(s,r.to,r,t)}return h}gapSize(t,e,i,n){let s=cn(n,i)-cn(n,e);return this.heightOracle.lineWrapping?t.height*s:n.total*this.heightOracle.charWidth*s}updateLineGaps(t){sn.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=bt.set(t.map((t=>t.draw(this,this.heightOracle.lineWrapping)))))}computeVisibleRanges(){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let e=[];r.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))||gn(this.heightMap.lineAt(t,f.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return gn(this.heightMap.lineAt(this.scaler.fromDOM(t),f.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(t){let e=this.lineBlockAtHeight(t+8);return e.from>=this.viewport.from||this.viewportLines[0].top-t>200?e:this.viewportLines[0]}elementAtHeight(t){return gn(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class hn{constructor(t,e){this.from=t,this.to=e}}function ln(t,e,i){let n=[],s=t,o=0;return r.Xs.spans(i,t,e,{span(){},point(t,e){t>s&&(n.push({from:s,to:t}),o+=t-s),s=e}},20),s<e&&(n.push({from:s,to:e}),o+=e-s),{total:o,ranges:n}}function an({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 cn(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 un(t,e){for(let i of t)if(e(i))return i}const fn={toDOM(t){return t},fromDOM(t){return t},scale:1};class dn{constructor(t,e,i){let n=0,s=0,r=0;this.viewports=i.map((({from:i,to:s})=>{let r=e.lineAt(i,f.ByPos,t,0,0).top,o=e.lineAt(s,f.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 gn(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),n=e.toDOM(t.bottom);return new ji(t.from,t.length,i,n-i,Array.isArray(t._content)?t._content.map((t=>gn(t,e))):t._content)}const pn=r.r$.define({combine:t=>t.join(" ")}),mn=r.r$.define({combine:t=>t.indexOf(!0)>-1}),wn=o.V.newName(),vn=o.V.newName(),yn=o.V.newName(),bn={"&light":"."+vn,"&dark":"."+yn};function xn(t,e,i){return new o.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 Sn=xn("."+wn,{"&":{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,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",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"},".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"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},bn),kn="￿";class An{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(r.yy.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=kn}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let n=t;;){this.findPointBefore(i,n);let t=this.text.length;this.readNode(n);let s=n.nextSibling;if(s==e)break;let r=F.get(n),o=F.get(s);(r&&o?r.breakAfter:(r?r.breakAfter:Cn(n))||Cn(s)&&("BR"!=n.nodeName||n.cmIgnore)&&this.text.length>t)&&this.lineBreak(),n=s}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=F.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+(Mn(t,i.node,i.offset)?e:0))}}function Mn(t,e,i){for(;;){if(!e||i<S(e))return!1;if(e==t)return!0;i=b(e)+1,e=e.parentNode}}function Cn(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}class On{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class Tn{constructor(t,e,i,n){this.typeOver=n,this.bounds=null,this.text="";let{impreciseHead:s,impreciseAnchor:o}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let e=s||o?[]:Bn(t),i=new An(e,t.state);i.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=i.text,this.newSel=Pn(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=s&&s.node==e.focusNode&&s.offset==e.focusOffset||!p(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),n=o&&o.node==e.anchorNode&&o.offset==e.anchorOffset||!p(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset),h=t.viewport;if(a.ios&&t.state.selection.main.empty&&i!=n&&(h.from>0||h.to<t.state.doc.length)){let e=h.from-Math.min(i,n),s=h.to-Math.max(i,n);0!=e&&1!=e||0!=s&&-1!=s||(i=0,n=t.state.doc.length)}this.newSel=r.jT.single(n,i)}}}function Dn(t,e){let i,{newSel:n}=e,s=t.state.selection.main,o=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:n,to:h}=e.bounds,l=s.from,c=null;(8===o||a.android&&e.text.length<h-n)&&(l=s.to,c="end");let u=Rn(t.state.doc.sliceString(n,h,kn),e.text,l-n,c);u&&(a.chrome&&13==o&&u.toB==u.from+2&&e.text.slice(u.from,u.toB)==kn+kn&&u.toB--,i={from:n+u.from,to:n+u.toA,insert:r.xv.of(e.text.slice(u.from,u.toB).split(kn))})}else n&&(!t.hasFocus&&t.state.facet(ae)||n.main.eq(s))&&(n=null);if(!i&&!n)return!1;if(!i&&e.typeOver&&!s.empty&&n&&n.main.empty?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,s.to)}:i&&i.from>=s.from&&i.to<=s.to&&(i.from!=s.from||i.to!=s.to)&&s.to-s.from-(i.to-i.from)<=4?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,s.to))}:(a.mac||a.android)&&i&&i.from==i.to&&i.from==s.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(n&&2==i.insert.length&&(n=r.jT.single(n.main.anchor-1,n.main.head-1)),i={from:s.from,to:s.to,insert:r.xv.of([" "])}):a.chrome&&i&&i.from==i.to&&i.from==s.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(n&&(n=r.jT.single(n.main.anchor-1,n.main.head-1)),i={from:s.from,to:s.to,insert:r.xv.of([" "])}),i){if(a.ios&&t.inputState.flushIOSKey())return!0;if(a.android&&(i.from==s.from&&i.to==s.to&&1==i.insert.length&&2==i.insert.lines&&P(t.contentDOM,"Enter",13)||(i.from==s.from-1&&i.to==s.to&&0==i.insert.length||8==o&&i.insert.length<i.to-i.from&&i.to>s.head)&&P(t.contentDOM,"Backspace",8)||i.from==s.from&&i.to==s.to+1&&0==i.insert.length&&P(t.contentDOM,"Delete",46)))return!0;let e,r=i.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let h=()=>e||(e=En(t,i,n));return t.state.facet(ie).some((e=>e(t,i.from,i.to,r,h)))||t.dispatch(h()),!0}if(n&&!n.main.eq(s)){let e=!1,i="select";return t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(e=!0),i=t.inputState.lastSelectionOrigin),t.dispatch({selection:n,scrollIntoView:e,userEvent:i}),!0}return!1}function En(t,e,i){let n,s=t.state,o=s.selection.main;if(e.from>=o.from&&e.to<=o.to&&e.to-e.from>=(o.to-o.from)/3&&(!i||i.main.empty&&i.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let i=o.from<e.from?s.sliceDoc(o.from,e.from):"",r=o.to>e.to?s.sliceDoc(e.to,o.to):"";n=s.replaceSelection(t.state.toText(i+e.insert.sliceString(0,void 0,t.state.lineBreak)+r))}else{let h=s.changes(e),l=i&&i.main.to<=h.newLength?i.main:void 0;if(s.selection.ranges.length>1&&t.inputState.composing>=0&&e.to<=o.to&&e.to>=o.to-10){let a,c=t.state.sliceDoc(e.from,e.to),u=i&&Te(t,i.main.head);if(u){let t=e.insert.length-(e.to-e.from);a={from:u.from,to:u.to-t}}else a=t.state.doc.lineAt(o.head);let f=o.to-e.to,d=o.to-o.from;n=s.changeByRange((i=>{if(i.from==o.from&&i.to==o.to)return{changes:h,range:l||i.map(h)};let n=i.to-f,u=n-c.length;if(i.to-i.from!=d||t.state.sliceDoc(u,n)!=c||i.to>=a.from&&i.from<=a.to)return{range:i};let g=s.changes({from:u,to:n,insert:e.insert}),p=i.to-o.to;return{changes:g,range:l?r.jT.range(Math.max(0,l.anchor+p),Math.max(0,l.head+p)):i.map(g)}}))}else n={changes:h,selection:l&&s.selection.replaceRange(l)}}let h="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,h+=".compose",t.inputState.compositionFirstChange&&(h+=".start",t.inputState.compositionFirstChange=!1)),s.update(n,{userEvent:h,scrollIntoView:!0})}function Rn(t,e,i,n){let s=Math.min(t.length,e.length),r=0;for(;r<s&&t.charCodeAt(r)==e.charCodeAt(r);)r++;if(r==s&&t.length==e.length)return null;let o=t.length,h=e.length;for(;o>0&&h>0&&t.charCodeAt(o-1)==e.charCodeAt(h-1);)o--,h--;if("end"==n){i-=o+Math.max(0,r-Math.min(o,h))-r}if(o<r&&t.length<e.length){r-=i<=r&&i>=o?r-i:0,h=r+(h-o),o=r}else if(h<r){r-=i<=r&&i>=h?r-i:0,o=r+(o-h),h=r}return{from:r,toA:o,toB:h}}function Bn(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 On(i,n)),s==i&&r==n||e.push(new On(s,r))),e}function Pn(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?r.jT.single(i+e,n+e):null}const Ln={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Nn=a.ie&&a.ie_version<=11;class In{constructor(t){this.view=t,this.active=!1,this.selectionRange=new T,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver((e=>{for(let t of e)this.queue.push(t);(a.ie&&a.ie_version<=11||a.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()})),Nn&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver((()=>{var t;(null===(t=this.view.docView)||void 0===t?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()})),this.resizeScroll.observe(t.scrollDOM)),this.addWindowListeners(this.win=t.win),this.start(),"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")))}),{threshold:[0,.001]}),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()}onScrollChanged(t){this.view.inputState.runHandlers("scroll",t),this.intersecting&&this.view.measure()}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){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(ae)?i.root.activeElement!=this.dom:!w(i.dom,n))return;let s=n.anchorNode&&i.docView.nearest(n.anchorNode);s&&s.ignoreEvent(t)?e||(this.selectionChanged=!1):(a.ie&&a.ie_version<=11||a.android&&a.chrome)&&!i.state.selection.main.empty&&n.focusNode&&y(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=a.safari&&11==t.root.nodeType&&m(this.dom.ownerDocument)==this.dom&&Hn(this.view)||g(t.root);if(!e||this.selectionRange.eq(e))return!1;let i=w(this.dom,e);return i&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&I(this.dom,e)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(e),i&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let i=this.dom;i;)if(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,Ln),Nn&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Nn&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var i;if(!this.delayedAndroidKey){let t=()=>{let t=this.delayedAndroidKey;if(t){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=t.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&t.force&&P(this.dom,t.key,t.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(t)}this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(null===(i=this.delayedAndroidKey)||void 0===i?void 0:i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame((()=>{this.delayedFlush=-1,this.flush()})))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,n=!1;for(let 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}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),n=this.selectionChanged&&w(this.dom,this.selectionRange);if(t<0&&!n)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new Tn(this.view,t,e,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return this.view.requestMeasure(),!1;let i=this.view.state,n=Dn(this.view,e);return this.view.state==i&&this.view.update([]),n}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.flags|=4),"childList"==t.type){let i=Vn(e,t.previousSibling||t.target.previousSibling,-1),n=Vn(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}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}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.resizeScroll)||void 0===i||i.disconnect();for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}}function Vn(t,e,i){for(;e;){let n=F.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 Hn(t){let e=null;function i(t){t.preventDefault(),t.stopImmediatePropagation(),e=t.getTargetRanges()[0]}if(t.contentDOM.addEventListener("beforeinput",i,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",i,!0),!e)return null;let n=e.startContainer,s=e.startOffset,r=e.endContainer,o=e.endOffset,h=t.docView.domAtPos(t.state.selection.main.anchor);return y(h.node,h.offset,r,o)&&([n,s,r,o]=[r,o,n,s]),{anchorNode:n,anchorOffset:s,focusNode:r,focusOffset:o}}class Wn{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}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}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.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:e}=t;this.dispatchTransactions=t.dispatchTransactions||e&&(t=>t.forEach((t=>e(t,this))))||(t=>this.update(t)),this.dispatch=this.dispatch.bind(this),this._root=t.root||L(t.parent)||document,this.viewState=new on(t.state||r.yy.create(t)),t.scrollTo&&t.scrollTo.is(he)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(ue).map((t=>new de(t)));for(let i of this.plugins)i.update(this);this.observer=new In(this),this.inputState=new ei(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Ce(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure()}dispatch(...t){let e=1==t.length&&t[0]instanceof r.YW?t:1==t.length&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(e,this)}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=!1,s=this.state;for(let r of t){if(r.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=r.state}if(this.destroyed)return void(this.viewState.state=s);let o=this.hasFocus,h=0,l=null;t.some((t=>t.annotation(Ni)))?(this.inputState.notifiedFocused=o,h=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=Ii(s,o),l||(h=1));let a=this.observer.delayedAndroidKey,c=null;if(a?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(c=null)):this.observer.clear(),s.facet(r.yy.phrases)!=this.state.facet(r.yy.phrases))return this.setState(s);e=Me.create(this,s,t),e.flags|=h;let u=this.viewState.scrollTarget;try{this.updateState=2;for(let e of t){if(u&&(u=u.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection;u=new oe(t.empty?t:r.jT.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(he)&&(u=t.value.clip(this.state))}this.viewState.update(e,u),this.bidiCache=_n.update(this.bidiCache,e.changes),e.empty||(this.updatePlugins(e),this.inputState.update(e)),i=this.docView.update(e),this.state.facet(ke)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(i,t.some((t=>t.isUserEvent("select.pointer"))))}finally{this.updateState=0}if(e.startState.facet(pn)!=e.state.facet(pn)&&(this.viewState.mustMeasureContent=!0),(i||n||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!e.empty)for(let r of this.state.facet(ee))try{r(e)}catch(f){le(this.state,f,"update listener")}(l||c)&&Promise.resolve().then((()=>{l&&this.state==l.startState&&this.dispatch(l),c&&!Dn(this,c)&&a.force&&P(this.contentDOM,a.key,a.keyCode)}))}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 on(t),this.plugins=t.facet(ue).map((t=>new de(t))),this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView.destroy(),this.docView=new Ce(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(ue),i=t.state.facet(ue);if(e!=i){let n=[];for(let s of i){let i=e.indexOf(s);if(i<0)n.push(new de(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()}else for(let n of this.plugins)n.mustUpdate=t;for(let n=0;n<this.plugins.length;n++)this.plugins[n].update(this);e!=i&&this.inputState.ensureHandlers(this.plugins)}measure(t=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey)return this.measureScheduled=-1,void this.requestMeasure();this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,i=this.scrollDOM,n=i.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:r}=this.viewState;Math.abs(n-this.viewState.scrollTop)>1&&(r=-1),this.viewState.scrollAnchorHeight=-1;try{for(let t=0;;t++){if(r<0)if(V(i))s=-1,r=this.viewState.heightMap.height;else{let t=this.viewState.scrollAnchorAt(n);s=t.from,r=t.top}this.updateState=1;let h=this.viewState.measure(this);if(!h&&!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 l=[];4&h||([this.measureRequests,l]=[l,this.measureRequests]);let a=l.map((t=>{try{return t.read(this)}catch(e){return le(this.state,e),zn}})),c=Me.create(this,this.state,[]),u=!1;c.flags|=h,e?e.flags|=h:e=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),u=this.docView.update(c));for(let t=0;t<l.length;t++)if(a[t]!=zn)try{let e=l[t];e.write&&e.write(a[t],this)}catch(o){le(this.state,o)}if(u&&this.docView.updateSelection(!0),!c.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,r=-1;continue}{let t=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-r;if(t>1||t<-1){n+=t,i.scrollTop=n/this.scaleY,r=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let h of this.state.facet(ee))h(e)}get themeClasses(){return wn+" "+(this.state.facet(mn)?yn:vn)+" "+this.state.facet(pn)}updateAttrs(){let t=jn(this,ge,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(ae)?"true":"false",class:"cm-content",style:`${a.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),jn(this,pe,e);let i=this.observer.ignore((()=>{let i=pt(this.contentDOM,this.contentAttrs,e),n=pt(this.dom,this.editorAttrs,t);return i||n}));return this.editorAttrs=t,this.contentAttrs=e,i}showAnnouncements(t){let e=!0;for(let i of t)for(let t of i.effects)if(t.is(Wn.announce)){e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(ke);let t=this.state.facet(Wn.cspNonce);o.V.mount(this.root,this.styleModules.concat(Sn).reverse(),t?{nonce:t}:void 0)}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=this.win.requestAnimationFrame((()=>this.measure()))),t){if(this.measureRequests.indexOf(t)>-1)return;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)}}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}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return ti(this,t,Xe(this,t,e,i))}moveByGroup(t,e){return ti(this,t,Xe(this,t,e,(e=>Ye(this,t.head,e))))}visualLineSide(t,e){let i=this.bidiSpans(t),n=this.textDirectionAt(t.from),s=i[e?i.length-1:0];return r.jT.cursor(s.side(e,n)+t.from,s.forward(!e,n)?1:-1)}moveToLineBoundary(t,e,i=!0){return Ue(this,t,e,i)}moveVertically(t,e,i){return ti(this,t,Qe(this,t,e,i))}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){return this.readMeasured(),qe(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);return k(i,s[Ht.find(s,t-n.from,-1,e)].dir==u.LTR==e>0)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(se)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>Fn)return Jt(t.length);let e,i=this.textDirectionAt(t.from);for(let s of this.bidiCache)if(s.from==t.from&&s.dir==i&&(s.fresh||Wt(s.isolates,e=be(this,t))))return s.order;e||(e=be(this,t));let n=Kt(t.text,i,e);return this.bidiCache.push(new _n(t.from,t.to,i,e,!0,n)),n}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||a.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{R(this.contentDOM),this.docView.updateSelection()}))}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((9==t.nodeType?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return he.of(new oe("number"==typeof t?r.jT.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}scrollSnapshot(){let{scrollTop:t,scrollLeft:e}=this.scrollDOM,i=this.viewState.scrollAnchorAt(t);return he.of(new oe(r.jT.cursor(i.from),"start","start",i.top-t,e,!0))}static domEventHandlers(t){return fe.define((()=>({})),{eventHandlers:t})}static domEventObservers(t){return fe.define((()=>({})),{eventObservers:t})}static theme(t,e){let i=o.V.newName(),n=[pn.of(i),ke.of(xn(`.${i}`,t))];return e&&e.dark&&n.push(mn.of(!0)),n}static baseTheme(t){return r.Wl.lowest(ke.of(xn("."+wn,t,bn)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),n=i&&F.get(i)||F.get(t);return(null===(e=null==n?void 0:n.rootView)||void 0===e?void 0:e.view)||null}}Wn.styleModule=ke,Wn.inputHandler=ie,Wn.focusChangeEffect=ne,Wn.perLineTextDirection=se,Wn.exceptionSink=te,Wn.updateListener=ee,Wn.editable=ae,Wn.mouseSelectionStyle=Zt,Wn.dragMovesSelection=Qt,Wn.clickAddsSelectionRange=Yt,Wn.decorations=me,Wn.outerDecorations=we,Wn.atomicRanges=ve,Wn.bidiIsolatedRanges=ye,Wn.scrollMargins=xe,Wn.darkTheme=mn,Wn.cspNonce=r.r$.define({combine:t=>t.length?t[0]:""}),Wn.contentAttributes=pe,Wn.editorAttributes=ge,Wn.lineWrapping=Wn.contentAttributes.of({class:"cm-lineWrapping"}),Wn.announce=r.Py.define();const Fn=4096,zn={};class _n{constructor(t,e,i,n,s,r){this.from=t,this.to=e,this.dir=i,this.isolates=n,this.fresh=s,this.order=r}static update(t,e){if(e.empty&&!t.some((t=>t.fresh)))return t;let i=[],n=t.length?t[t.length-1].dir:u.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 _n(e.mapPos(r.from,1),e.mapPos(r.to,-1),r.dir,r.isolates,!1,r.order))}return i}}function jn(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&&ft(r,i)}return i}const qn=a.mac?"mac":a.windows?"win":a.linux?"linux":"key";function $n(t,e){const i=t.split(/-(?!$)/);let n,s,r,o,h=i[i.length-1];"Space"==h&&(h=" ");for(let l=0;l<i.length-1;++l){const t=i[l];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&&(h="Alt-"+h),s&&(h="Ctrl-"+h),o&&(h="Meta-"+h),r&&(h="Shift-"+h),h}function Kn(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 Jn=r.Wl.default(Wn.domEventHandlers({keydown(t,e){return ts(Xn(e.state),t,e,"editor")}})),Gn=r.r$.define({enables:Jn}),Un=new WeakMap;function Xn(t){let e=t.facet(Gn),i=Un.get(e);return i||Un.set(e,i=Zn(e.reduce(((t,e)=>t.concat(e)),[]))),i}let Yn=null;const Qn=4e3;function Zn(t,e=qn){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,h)=>{var l,a;let c=i[t]||(i[t]=Object.create(null)),u=n.split(/ (?!$)/).map((t=>$n(t,e)));for(let e=1;e<u.length;e++){let i=u.slice(0,e).join(" ");s(i,!0),c[i]||(c[i]={preventDefault:!0,stopPropagation:!1,run:[e=>{let n=Yn={view:e,prefix:i,scope:t};return setTimeout((()=>{Yn==n&&(Yn=null)}),Qn),!0}]})}let f=u.join(" ");s(f,!1);let d=c[f]||(c[f]={preventDefault:!1,stopPropagation:!1,run:(null===(a=null===(l=c._any)||void 0===l?void 0:l.run)||void 0===a?void 0:a.slice())||[]});r&&d.run.push(r),o&&(d.preventDefault=!0),h&&(d.stopPropagation=!0)};for(let o of t){let t=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let e of t){let t=i[e]||(i[e]=Object.create(null));t._any||(t._any={preventDefault:!1,stopPropagation:!1,run:[]});for(let e in t)t[e].run.push(o.any)}let n=o[e]||o.key;if(n)for(let e of t)r(e,n,o.run,o.preventDefault,o.stopPropagation),o.shift&&r(e,"Shift-"+n,o.shift,o.preventDefault,o.stopPropagation)}return i}function ts(t,e,i,n){let s=(0,h.YG)(e),o=(0,r.gm)(s,0),l=(0,r.nZ)(o)==s.length&&" "!=s,c="",u=!1,f=!1,d=!1;Yn&&Yn.view==i&&Yn.scope==n&&(c=Yn.prefix+" ",oi.indexOf(e.keyCode)<0&&(f=!0,Yn=null));let g,p,m=new Set,w=t=>{if(t){for(let n of t.run)if(!m.has(n)&&(m.add(n),n(i,e)))return t.stopPropagation&&(d=!0),!0;t.preventDefault&&(t.stopPropagation&&(d=!0),f=!0)}return!1},v=t[n];return v&&(w(v[c+Kn(s,e,!l)])?u=!0:l&&(e.altKey||e.metaKey||e.ctrlKey)&&!(a.windows&&e.ctrlKey&&e.altKey)&&(g=h.ue[e.keyCode])&&g!=s?(w(v[c+Kn(g,e,!0)])||e.shiftKey&&(p=h.uY[e.keyCode])!=s&&p!=g&&w(v[c+Kn(p,e,!1)]))&&(u=!0):l&&e.shiftKey&&w(v[c+Kn(s,e,!0)])&&(u=!0),!u&&w(v._any)&&(u=!0)),f&&(u=!0),u&&d&&e.stopPropagation(),u}const es=!a.ios;const is={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};es&&(is[".cm-line"].caretColor="transparent !important",is[".cm-content"]={caretColor:"transparent !important"});const ns="-10000px";class ss{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,e){var i;let n=t.state.facet(this.facet),s=n.filter((t=>t));if(n===this.input){for(let e of this.tooltipViews)e.update&&e.update(t);return!1}let r=[],o=e?[]:null;for(let h=0;h<s.length;h++){let i=s[h],n=-1;if(i){for(let t=0;t<this.tooltips.length;t++){let e=this.tooltips[t];e&&e.create==i.create&&(n=t)}if(n<0)r[h]=this.createTooltipView(i),o&&(o[h]=!!i.above);else{let i=r[h]=this.tooltipViews[n];o&&(o[h]=e[n]),i.update&&i.update(t)}}}for(let h of this.tooltipViews)r.indexOf(h)<0&&(h.dom.remove(),null===(i=h.destroy)||void 0===i||i.call(h));return e&&(o.forEach(((t,i)=>e[i]=t)),e.length=o.length),this.input=n,this.tooltips=s,this.tooltipViews=r,!0}}function rs(t){let{win:e}=t;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}const os=r.r$.define({combine:t=>{var e,i,n;return{position:a.ios?"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)||rs}}}),hs=new WeakMap,ls=fe.fromClass(class{constructor(t){this.view=t,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(os);this.position=e.position,this.parent=e.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.manager=new ss(t,us,(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(),t.win.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,this.above);e&&this.observeIntersection();let i=e||t.geometryChanged,n=t.state.facet(os);if(n.position!=this.position&&!this.madeAbsolute){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=ns,e.dom.style.left="0px",this.container.appendChild(e.dom),e.mount&&e.mount(this.view),e}destroy(){var t,e;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),null===(t=i.destroy)||void 0===t||t.call(i);this.parent&&this.container.remove(),null===(e=this.intersectionObserver)||void 0===e||e.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=this.view.dom.getBoundingClientRect(),e=1,i=1,n=!1;if("fixed"==this.position&&this.manager.tooltipViews.length){let{dom:t}=this.manager.tooltipViews[0];if(a.gecko)n=t.offsetParent!=this.container.ownerDocument.body;else if(t.style.top==ns&&"0px"==t.style.left){let e=t.getBoundingClientRect();n=Math.abs(e.top+1e4)>1||Math.abs(e.left)>1}}if(n||"absolute"==this.position)if(this.parent){let t=this.parent.getBoundingClientRect();t.width&&t.height&&(e=t.width/this.parent.offsetWidth,i=t.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:i}=this.view.viewState);return{editor:t,parent:this.parent?this.container.getBoundingClientRect():t,pos:this.manager.tooltips.map(((t,e)=>{let i=this.manager.tooltipViews[e];return i.getCoords?i.getCoords(t.pos):this.view.coordsAtPos(t.pos)})),size:this.manager.tooltipViews.map((({dom:t})=>t.getBoundingClientRect())),space:this.view.state.facet(os).tooltipSpace(this.view),scaleX:e,scaleY:i,makeAbsolute:n}}writeMeasure(t){var e;if(t.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let t of this.manager.tooltipViews)t.dom.style.position="absolute"}let{editor:i,space:n,scaleX:s,scaleY:r}=t,o=[];for(let h=0;h<this.manager.tooltips.length;h++){let l=this.manager.tooltips[h],a=this.manager.tooltipViews[h],{dom:c}=a,f=t.pos[h],d=t.size[h];if(!f||f.bottom<=Math.max(i.top,n.top)||f.top>=Math.min(i.bottom,n.bottom)||f.right<Math.max(i.left,n.left)-.1||f.left>Math.min(i.right,n.right)+.1){c.style.top=ns;continue}let g=l.arrow?a.dom.querySelector(".cm-tooltip-arrow"):null,p=g?7:0,m=d.right-d.left,w=null!==(e=hs.get(a))&&void 0!==e?e:d.bottom-d.top,v=a.offset||cs,y=this.view.textDirection==u.LTR,b=d.width>n.right-n.left?y?n.left:n.right-d.width:y?Math.min(f.left-(g?14:0)+v.x,n.right-m):Math.max(n.left,f.left-m+(g?14:0)-v.x),x=this.above[h];!l.strictSide&&(x?f.top-(d.bottom-d.top)-v.y<n.top:f.bottom+(d.bottom-d.top)+v.y>n.bottom)&&x==n.bottom-f.bottom>f.top-n.top&&(x=this.above[h]=!x);let S=(x?f.top-n.top:n.bottom-f.bottom)-p;if(S<w&&!1!==a.resize){if(S<this.view.defaultLineHeight){c.style.top=ns;continue}hs.set(a,w),c.style.height=(w=S)/r+"px"}else c.style.height&&(c.style.height="");let k=x?f.top-w-p-v.y:f.bottom+p+v.y,A=b+m;if(!0!==a.overlap)for(let t of o)t.left<A&&t.right>b&&t.top<k+w&&t.bottom>k&&(k=x?t.top-w-2-p:t.bottom+p+2);if("absolute"==this.position?(c.style.top=(k-t.parent.top)/r+"px",c.style.left=(b-t.parent.left)/s+"px"):(c.style.top=k/r+"px",c.style.left=b/s+"px"),g){let t=f.left+(y?v.x:-v.x)-(b+14-7);g.style.left=t/s+"px"}!0!==a.overlap&&o.push({left:b,top:k,right:A,bottom:k+w}),c.classList.toggle("cm-tooltip-above",x),c.classList.toggle("cm-tooltip-below",!x),a.positioned&&a.positioned(t.space)}}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=ns}},{eventObservers:{scroll(){this.maybeMeasure()}}}),as=Wn.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&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"}}}),cs={x:0,y:0},us=r.r$.define({enables:[ls,as]});function fs(t,e){let i=t.plugin(ls);if(!i)return null;let n=i.manager.tooltips.indexOf(e);return n<0?null:i.manager.tooltipViews[n]}class ds extends r.uU{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}ds.prototype.elementClass="",ds.prototype.toDOM=void 0,ds.prototype.mapMode=r.gc.TrackBefore,ds.prototype.startSide=ds.prototype.endSide=-1,ds.prototype.point=!0;n()}catch(d){n(d)}}))},91274:function(t,e,i){i.d(e,{D0:function(){return St},Gz:function(){return jt},Py:function(){return gt},Wl:function(){return Y},Xs:function(){return Rt},YW:function(){return pt},as:function(){return O},cp:function(){return w},f_:function(){return Bt},gc:function(){return M},gm:function(){return S},jT:function(){return N},nZ:function(){return k},q6:function(){return ut},r$:function(){return H},uU:function(){return Ot},xv:function(){return n},yy:function(){return Ct}});i(63721),i(52247),i(71695),i(92745),i(52805),i(61495),i(61893),i(23669),i(69235),i(12385),i(19134),i(32517),i(5740),i(11740),i(92519),i(42179),i(89256),i(24931),i(88463),i(57449),i(19814),i(97003),i(32114),i(39527),i(92181),i(99790),i(67670),i(41360),i(13334),i(34595),i(36993),i(47021);class n{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){[t,e]=f(this,t,e);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),r.from(n,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){[t,e]=f(this,t,e);let i=[];return this.decompose(t,e,i,0),r.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 l(this),s=new l(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 l(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 c(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}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 s(t):r.from(s.split(t,[])):n.empty}}class s extends n{constructor(t,e=function(t){let e=-1;for(let i of t)e+=i.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.text[s],o=n+r.length;if((e?i:o)>=t)return new u(n,o,i,r);n=o+1,i++}}decompose(t,e,i,n){let r=t<=0&&e>=this.length?this:new s(h(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&n){let t=i.pop(),e=o(r.text,t.text.slice(),0,r.length);if(e.length<=32)i.push(new s(e,t.length+r.length));else{let t=e.length>>1;i.push(new s(e.slice(0,t)),new s(e.slice(t)))}}else i.push(r)}replace(t,e,i){if(!(i instanceof s))return super.replace(t,e,i);[t,e]=f(this,t,e);let n=o(this.text,o(i.text,h(this.text,0,t)),e),l=this.length+i.length-(e-t);return n.length<=32?new s(n,l):r.from(s.split(n,[]),l)}sliceString(t,e=this.length,i="\n"){[t,e]=f(this,t,e);let n="";for(let s=0,r=0;s<=e&&r<this.text.length;r++){let o=this.text[r],h=s+o.length;s>t&&r&&(n+=i),t<h&&e>s&&(n+=o.slice(Math.max(0,t-s),e-s)),s=h+1}return n}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],n=-1;for(let r of t)i.push(r),n+=r.length+1,32==i.length&&(e.push(new s(i,n)),i=[],n=-1);return n>-1&&e.push(new s(i,n)),e}}class r extends n{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,h=i+r.lines-1;if((e?h:o)>=t)return r.lineInner(t,e,i,n);n=o+1,i=h+1}}decompose(t,e,i,n){for(let s=0,r=0;r<=e&&s<this.children.length;s++){let o=this.children[s],h=r+o.length;if(t<=h&&e>=r){let s=n&((r<=t?1:0)|(h>=e?2:0));r>=t&&h<=e&&!s?i.push(o):o.decompose(t-r,e-r,i,s)}r=h+1}}replace(t,e,i){if([t,e]=f(this,t,e),i.lines<this.lines)for(let n=0,s=0;n<this.children.length;n++){let o=this.children[n],h=s+o.length;if(t>=s&&e<=h){let l=o.replace(t-s,e-s,i),a=this.lines-o.lines+l.lines;if(l.lines<a>>4&&l.lines>a>>6){let s=this.children.slice();return s[n]=l,new r(s,this.length-(e-t)+i.length)}return super.replace(s,h,l)}s=h+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i="\n"){[t,e]=f(this,t,e);let n="";for(let s=0,r=0;s<this.children.length&&r<=e;s++){let o=this.children[s],h=r+o.length;r>t&&s&&(n+=i),t<h&&e>r&&(n+=o.sliceString(t-r,e-r,i)),r=h+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof r))return 0;let i=0,[n,s,o,h]=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==o||s==h)return i;let r=this.children[n],l=t.children[s];if(r!=l)return i+r.scanIdentical(l,e);i+=r.length+1}}static from(t,e=t.reduce(((t,e)=>t+e.length+1),-1)){let i=0;for(let s of t)i+=s.lines;if(i<32){let i=[];for(let e of t)e.flatten(i);return new s(i,e)}let n=Math.max(32,i>>5),o=n<<1,h=n>>1,l=[],a=0,c=-1,u=[];function f(t){let e;if(t.lines>o&&t instanceof r)for(let i of t.children)f(i);else t.lines>h&&(a>h||!a)?(d(),l.push(t)):t instanceof s&&a&&(e=u[u.length-1])instanceof s&&t.lines+e.lines<=32?(a+=t.lines,c+=t.length+1,u[u.length-1]=new s(e.text.concat(t.text),e.length+1+t.length)):(a+t.lines>n&&d(),a+=t.lines,c+=t.length+1,u.push(t))}function d(){0!=a&&(l.push(1==u.length?u[0]:r.from(u,c)),c=-1,a=u.length=0)}for(let s of t)f(s);return d(),1==l.length?l[0]:new r(l,e)}}function o(t,e,i=0,n=1e9){for(let s=0,r=0,o=!0;r<t.length&&s<=n;r++){let h=t[r],l=s+h.length;l>=i&&(l>n&&(h=h.slice(0,n-s)),s<i&&(h=h.slice(i-s)),o?(e[e.length-1]+=h,o=!1):e.push(h)),s=l+1}return e}function h(t,e,i){return o(t,[""],e,i)}n.empty=new s([""],0);class l{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 s?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],r=this.offsets[i],o=r>>1,h=n instanceof s?n.text.length:n.children.length;if(o==(e>0?h: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&r)==(e>0?0:1)){if(this.offsets[i]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(n instanceof s){let s=n.text[o+(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 r=n.children[o+(e<0?-1:0)];t>r.length?(t-=r.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(r),this.offsets.push(e>0?1:(r instanceof s?r.text.length:r.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 l(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 c{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:n}=this.inner.next(t);return e&&this.afterBreak?(this.value="",this.afterBreak=!1):e?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(n.prototype[Symbol.iterator]=function(){return this.iter()},l.prototype[Symbol.iterator]=a.prototype[Symbol.iterator]=c.prototype[Symbol.iterator]=function(){return this});class u{constructor(t,e,i,n){this.from=t,this.to=e,this.number=i,this.text=n}get length(){return this.to-this.from}}function f(t,e,i){return[e=Math.max(0,Math.min(t.length,e)),Math.max(e,Math.min(t.length,i))]}let d="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map((t=>t?parseInt(t,36):1));for(let $t=1;$t<d.length;$t++)d[$t]+=d[$t-1];function g(t){for(let e=1;e<d.length;e+=2)if(d[e]>t)return d[e-1]<=t;return!1}function p(t){return t>=127462&&t<=127487}const m=8205;function w(t,e,i=!0,n=!0){return(i?v:y)(t,e,n)}function v(t,e,i){if(e==t.length)return e;e&&b(t.charCodeAt(e))&&x(t.charCodeAt(e-1))&&e--;let n=S(t,e);for(e+=k(n);e<t.length;){let s=S(t,e);if(n==m||s==m||i&&g(s))e+=k(s),n=s;else{if(!p(s))break;{let i=0,n=e-2;for(;n>=0&&p(S(t,n));)i++,n-=2;if(i%2==0)break;e+=2}}}return e}function y(t,e,i){for(;e>0;){let n=v(t,e-2,i);if(n<e)return n;e--}return 0}function b(t){return t>=56320&&t<57344}function x(t){return t>=55296&&t<56320}function S(t,e){let i=t.charCodeAt(e);if(!x(i)||e+1==t.length)return i;let n=t.charCodeAt(e+1);return b(n)?n-56320+(i-55296<<10)+65536:i}function k(t){return t<65536?1:2}const A=/\r\n?|\n/;var M=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(M||(M={}));class C{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){E(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 C(t)}composeDesc(t){return this.empty?t:t.empty?this:B(this,t)}mapDesc(t,e=!1){return t.empty?this:R(this,t,e)}mapPos(t,e=-1,i=M.Simple){let n=0,s=0;for(let r=0;r<this.sections.length;){let o=this.sections[r++],h=this.sections[r++],l=n+o;if(h<0){if(l>t)return s+(t-n);s+=o}else{if(i!=M.Simple&&l>=t&&(i==M.TrackDel&&n<t&&l>t||i==M.TrackBefore&&n<t||i==M.TrackAfter&&l>t))return null;if(l>t||l==t&&e<0&&!o)return t==n||e<0?s:s+h;s+=h}n=l}if(t>n)throw new RangeError(`Position ${t} is out of range for changeset of length ${n}`);return s}touchesRange(t,e=t){for(let i=0,n=0;i<this.sections.length&&n<=e;){let s=n+this.sections[i++];if(this.sections[i++]>=0&&n<=e&&s>=t)return!(n<t&&s>e)||"cover";n=s}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];t+=(t?" ":"")+i+(n>=0?":"+n:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some((t=>"number"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeDesc");return new C(t)}static create(t){return new C(t)}}class O extends C{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 E(this,((e,i,n,s,r)=>t=t.replace(n,n+(i-e),r)),!1),t}mapDesc(t,e=!1){return R(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let s=0,r=0;s<e.length;s+=2){let o=e[s],h=e[s+1];if(h>=0){e[s]=h,e[s+1]=o;let l=s>>1;for(;i.length<l;)i.push(n.empty);i.push(o?t.slice(r,r+o):n.empty)}r+=o}return new O(e,i)}compose(t){return this.empty?t:t.empty?this:B(this,t,!0)}map(t,e=!1){return t.empty?this:R(this,t,e,!0)}iterChanges(t,e=!1){E(this,t,e)}get desc(){return C.create(this.sections)}filter(t){let e=[],i=[],n=[],s=new P(this);t:for(let r=0,o=0;;){let h=r==t.length?1e9:t[r++];for(;o<h||o==h&&0==s.len;){if(s.done)break t;let t=Math.min(s.len,h-o);T(n,t,-1);let r=-1==s.ins?-1:0==s.off?s.ins:0;T(e,t,r),r>0&&D(i,e,s.text),s.forward(t),o+=t}let l=t[r++];for(;o<l;){if(s.done)break t;let t=Math.min(s.len,l-o);T(e,t,-1),T(n,t,-1==s.ins?-1:0==s.off?s.ins:0),s.forward(t),o+=t}}return{changes:new O(e,i),filtered:C.create(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 s=[],r=[],o=0,h=null;function l(t=!1){if(!t&&!s.length)return;o<e&&T(s,e-o,-1);let i=new O(s,r);h=h?h.compose(i.map(h)):i,s=[],r=[],o=0}return function t(a){if(Array.isArray(a))for(let e of a)t(e);else if(a instanceof O){if(a.length!=e)throw new RangeError(`Mismatched change set length (got ${a.length}, expected ${e})`);l(),h=h?h.compose(a.map(h)):a}else{let{from:t,to:h=t,insert:c}=a;if(t>h||t<0||h>e)throw new RangeError(`Invalid change range ${t} to ${h} (in doc of length ${e})`);let u=c?"string"==typeof c?n.of(c.split(i||A)):c:n.empty,f=u.length;if(t==h&&0==f)return;t<o&&l(),t>o&&T(s,t-o,-1),T(s,h-t,f),D(r,s,u),o=h}}(t),l(!h),h}static empty(t){return new O(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],i=[];for(let s=0;s<t.length;s++){let r=t[s];if("number"==typeof r)e.push(r,-1);else{if(!Array.isArray(r)||"number"!=typeof r[0]||r.some(((t,e)=>e&&"string"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==r.length)e.push(r[0],0);else{for(;i.length<s;)i.push(n.empty);i[s]=n.of(r.slice(1)),e.push(r[0],i[s].length)}}}return new O(e,i)}static createSet(t,e){return new O(t,e)}}function T(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 D(t,e,i){if(0==i.length)return;let s=e.length-2>>1;if(s<t.length)t[t.length-1]=t[t.length-1].append(i);else{for(;t.length<s;)t.push(n.empty);t.push(i)}}function E(t,e,i){let s=t.inserted;for(let r=0,o=0,h=0;h<t.sections.length;){let l=t.sections[h++],a=t.sections[h++];if(a<0)r+=l,o+=l;else{let c=r,u=o,f=n.empty;for(;c+=l,u+=a,a&&s&&(f=f.append(s[h-2>>1])),!(i||h==t.sections.length||t.sections[h+1]<0);)l=t.sections[h++],a=t.sections[h++];e(r,c,o,u,f),r=c,o=u}}}function R(t,e,i,n=!1){let s=[],r=n?[]:null,o=new P(t),h=new P(e);for(let l=-1;;)if(-1==o.ins&&-1==h.ins){let t=Math.min(o.len,h.len);T(s,t,-1),o.forward(t),h.forward(t)}else if(h.ins>=0&&(o.ins<0||l==o.i||0==o.off&&(h.len<o.len||h.len==o.len&&!i))){let t=h.len;for(T(s,h.ins,-1);t;){let e=Math.min(o.len,t);o.ins>=0&&l<o.i&&o.len<=e&&(T(s,0,o.ins),r&&D(r,s,o.text),l=o.i),o.forward(e),t-=e}h.next()}else{if(!(o.ins>=0)){if(o.done&&h.done)return r?O.createSet(s,r):C.create(s);throw new Error("Mismatched change set lengths")}{let t=0,e=o.len;for(;e;)if(-1==h.ins){let i=Math.min(e,h.len);t+=i,e-=i,h.forward(i)}else{if(!(0==h.ins&&h.len<e))break;e-=h.len,h.next()}T(s,t,l<o.i?o.ins:0),r&&l<o.i&&D(r,s,o.text),l=o.i,o.forward(o.len-e)}}}function B(t,e,i=!1){let n=[],s=i?[]:null,r=new P(t),o=new P(e);for(let h=!1;;){if(r.done&&o.done)return s?O.createSet(n,s):C.create(n);if(0==r.ins)T(n,r.len,0,h),r.next();else if(0!=o.len||o.done){if(r.done||o.done)throw new Error("Mismatched change set lengths");{let t=Math.min(r.len2,o.len),e=n.length;if(-1==r.ins){let e=-1==o.ins?-1:o.off?0:o.ins;T(n,t,e,h),s&&e&&D(s,n,o.text)}else-1==o.ins?(T(n,r.off?0:r.len,t,h),s&&D(s,n,r.textBit(t))):(T(n,r.off?0:r.len,o.off?0:o.ins,h),s&&!o.off&&D(s,n,o.text));h=(r.ins>t||o.ins>=0&&o.len>t)&&(h||n.length>e),r.forward2(t),o.forward(t)}}else T(n,0,o.ins,h),s&&D(s,n,o.text),o.next()}}class P{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.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?n.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 L{constructor(t,e,i){this.from=t,this.to=e,this.flags=i}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let t=7&this.flags;return 7==t?null:t}get goalColumn(){let t=this.flags>>6;return 16777215==t?void 0:t}map(t,e=-1){let i,n;return this.empty?i=n=t.mapPos(this.from,e):(i=t.mapPos(this.from,1),n=t.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new L(i,n,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return N.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return N.range(this.anchor,i)}eq(t,e=!1){return!(this.anchor!=t.anchor||this.head!=t.head||e&&this.empty&&this.assoc!=t.assoc)}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 N.range(t.anchor,t.head)}static create(t,e,i){return new L(t,e,i)}}class N{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:N.create(this.ranges.map((i=>i.map(t,e))),this.mainIndex)}eq(t,e=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(t.ranges[i],e))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new N([this.main],0)}addRange(t,e=!0){return N.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,N.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 N(t.ranges.map((t=>L.fromJSON(t))),t.main)}static single(t,e=t){return new N([N.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 N.normalized(t.slice(),e);i=s.to}return new N(t,e)}static cursor(t,e=0,i,n){return L.create(t,t,(0==e?0:e<0?8:16)|(null==i?7:Math.min(6,i))|(null!=n?n:16777215)<<6)}static range(t,e,i,n){let s=(null!=i?i:16777215)<<6|(null==n?7:Math.min(6,n));return e<t?L.create(e,t,48|s):L.create(t,e,(e>t?8:0)|s)}static normalized(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?N.range(o,r):N.range(r,o))}}return new N(t,e)}}function I(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let V=0;class H{constructor(t,e,i,n,s){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=V++,this.default=t([]),this.extensions="function"==typeof s?s(this):s}get reader(){return this}static define(t={}){return new H(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:W),!!t.static,t.enables)}of(t){return new F([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new F(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new F(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],(i=>e(i.field(t))))}}function W(t,e){return t==e||t.length==e.length&&t.every(((t,i)=>t===e[i]))}class F{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=this.id,r=t[s]>>1,o=2==this.type,h=!1,l=!1,a=[];for(let c of this.dependencies)"doc"==c?h=!0:"selection"==c?l=!0:1&(null!==(e=t[c.id])&&void 0!==e?e:1)||a.push(t[c.id]);return{create(t){return t.values[r]=i(t),1},update(t,e){if(h&&e.docChanged||l&&(e.docChanged||e.selection)||_(t,a)){let e=i(t);if(o?!z(e,t.values[r],n):!n(e,t.values[r]))return t.values[r]=e,1}return 0},reconfigure:(t,e)=>{let h,l=e.config.address[s];if(null!=l){let s=nt(e,l);if(this.dependencies.every((i=>i instanceof H?e.facet(i)===t.facet(i):!(i instanceof $)||e.field(i,!1)==t.field(i,!1)))||(o?z(h=i(t),s,n):n(h=i(t),s)))return t.values[r]=s,0}else h=i(t);return t.values[r]=h,1}}}}function z(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 _(t,e){let i=!1;for(let n of e)1&it(t,n)&&(i=!0);return i}function j(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;function h(t){let i=[];for(let e=0;e<n.length;e++){let r=nt(t,n[e]);if(2==s[e])for(let t of r)i.push(t);else i.push(r)}return e.combine(i)}return{create(t){for(let e of n)it(t,e);return t.values[o]=h(t),1},update(t,i){if(!_(t,r))return 0;let n=h(t);return e.compare(n,t.values[o])?0:(t.values[o]=n,1)},reconfigure(t,s){let r=_(t,n),l=s.config.facets[e.id],a=s.facet(e);if(l&&!r&&W(i,l))return t.values[o]=a,0;let c=h(t);return e.compare(c,a)?(t.values[o]=a,0):(t.values[o]=c,1)}}}const q=H.define({static:!0});class ${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 $(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(q).find((t=>t.field==this));return((null==e?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:t=>(t.values[e]=this.create(t),1),update:(t,i)=>{let n=t.values[e],s=this.updateF(n,i);return this.compareF(n,s)?0:(t.values[e]=s,1)},reconfigure:(t,i)=>null!=i.config.address[this.id]?(t.values[e]=i.field(this),0):(t.values[e]=this.create(t),1)}}init(t){return[this,q.of({field:this,create:t})]}get extension(){return this}}const K=4,J=3,G=2,U=1;function X(t){return e=>new Q(e,t)}const Y={highest:X(0),high:X(U),default:X(G),low:X(J),lowest:X(K)};class Q{constructor(t,e){this.inner=t,this.prec=e}}class Z{of(t){return new tt(this,t)}reconfigure(t){return Z.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class tt{constructor(t,e){this.compartment=t,this.inner=e}}class et{constructor(t,e,i,n,s,r){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=s,this.facets=r,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return null==e?t.default:this.staticValues[e>>1]}static resolve(t,e,i){let n=[],s=Object.create(null),r=new Map;for(let u of function(t,e,i){let n=[[],[],[],[],[]],s=new Map;function r(t,o){let h=s.get(t);if(null!=h){if(h<=o)return;let e=n[h].indexOf(t);e>-1&&n[h].splice(e,1),t instanceof tt&&i.delete(t.compartment)}if(s.set(t,o),Array.isArray(t))for(let e of t)r(e,o);else if(t instanceof tt){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 Q)r(t.inner,t.prec);else if(t instanceof $)n[o].push(t),t.provides&&r(t.provides,o);else if(t instanceof F)n[o].push(t),t.facet.extensions&&r(t.facet.extensions,G);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,G),n.reduce(((t,e)=>t.concat(e)))}(t,e,r))u instanceof $?n.push(u):(s[u.facet.id]||(s[u.facet.id]=[])).push(u);let o=Object.create(null),h=[],l=[];for(let u of n)o[u.id]=l.length<<1,l.push((t=>u.slot(t)));let a=null==i?void 0:i.config.facets;for(let u in s){let t=s[u],e=t[0].facet,n=a&&a[u]||[];if(t.every((t=>0==t.type)))if(o[e.id]=h.length<<1|1,W(n,t))h.push(i.facet(e));else{let n=e.combine(t.map((t=>t.value)));h.push(i&&e.compare(n,i.facet(e))?i.facet(e):n)}else{for(let e of t)0==e.type?(o[e.id]=h.length<<1|1,h.push(e.value)):(o[e.id]=l.length<<1,l.push((t=>e.dynamicSlot(t))));o[e.id]=l.length<<1,l.push((i=>j(i,e,t)))}}let c=l.map((t=>t(o)));return new et(t,r,c,o,h,s)}}function it(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.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|s}function nt(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const st=H.define(),rt=H.define({combine:t=>t.some((t=>t)),static:!0}),ot=H.define({combine:t=>t.length?t[0]:void 0,static:!0}),ht=H.define(),lt=H.define(),at=H.define(),ct=H.define({combine:t=>!!t.length&&t[0]});class ut{constructor(t,e){this.type=t,this.value=e}static define(){return new ft}}class ft{of(t){return new ut(this,t)}}class dt{constructor(t){this.map=t}of(t){return new gt(this,t)}}class gt{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 gt(this.type,e)}is(t){return this.type==t}static define(t={}){return new dt(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}}gt.reconfigure=gt.define(),gt.appendConfig=gt.define();class pt{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&&I(i,e.newLength),s.some((t=>t.type==pt.time))||(this.annotations=s.concat(pt.time.of(Date.now())))}static create(t,e,i,n,s,r){return new pt(t,e,i,n,s,r)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(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(pt.userEvent);return!(!e||!(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function mt(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 wt(t,e,i){var n;let s,r,o;return i?(s=e.changes,r=O.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:gt.mapEffects(t.effects,s).concat(gt.mapEffects(e.effects,r)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function vt(t,e,i){let n=e.selection,s=xt(e.annotations);return e.userEvent&&(s=s.concat(pt.userEvent.of(e.userEvent))),{changes:e.changes instanceof O?e.changes:O.of(e.changes||[],i,t.facet(ot)),selection:n&&(n instanceof N?n:N.single(n.anchor,n.head)),effects:xt(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function yt(t,e,i){let n=vt(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=wt(n,vt(t,e[r],s?n.changes.newLength:t.doc.length),s)}let s=pt.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return function(t){let e=t.startState,i=e.facet(at),n=t;for(let s=i.length-1;s>=0;s--){let r=i[s](t);r&&Object.keys(r).length&&(n=wt(n,vt(e,r,t.changes.newLength),!0))}return n==t?t:pt.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}(i?function(t){let e=t.startState,i=!0;for(let s of e.facet(ht)){let e=s(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:mt(i,e))}if(!0!==i){let n,s;if(!1===i)s=t.changes.invertedDesc,n=O.empty(e.doc.length);else{let e=t.changes.filter(i);n=e.changes,s=e.filtered.mapDesc(e.changes).invertedDesc}t=pt.create(e,n,t.selection&&t.selection.map(s),gt.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let n=e.facet(lt);for(let s=n.length-1;s>=0;s--){let i=n[s](t);t=i instanceof pt?i:Array.isArray(i)&&1==i.length&&i[0]instanceof pt?i[0]:yt(e,xt(i),!1)}return t}(s):s)}pt.time=ut.define(),pt.userEvent=ut.define(),pt.addToHistory=ut.define(),pt.remote=ut.define();const bt=[];function xt(t){return null==t?bt:Array.isArray(t)?t:[t]}var St=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(St||(St={}));const kt=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let At;try{At=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(qt){}function Mt(t){return e=>{if(!/\S/.test(e))return St.Space;if(function(t){if(At)return At.test(t);for(let e=0;e<t.length;e++){let i=t[e];if(/\w/.test(i)||i>"€"&&(i.toUpperCase()!=i.toLowerCase()||kt.test(i)))return!0}return!1}(e))return St.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return St.Word;return St.Other}}class Ct{constructor(t,e,i,n,s,r){this.config=t,this.doc=e,this.selection=i,this.values=n,this.status=t.statusTemplate.slice(),this.computeSlot=s,r&&(r._state=this);for(let o=0;o<this.config.dynamicSlots.length;o++)it(this,o<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(null!=i)return it(this,i),nt(this,i);if(e)throw new RangeError("Field is not present in this state")}update(...t){return yt(this,t,!0)}applyTransaction(t){let e,i=this.config,{base:n,compartments:s}=i;for(let o of t.effects)o.is(Z.reconfigure)?(i&&(s=new Map,i.compartments.forEach(((t,e)=>s.set(e,t))),i=null),s.set(o.value.compartment,o.value.extension)):o.is(gt.reconfigure)?(i=null,n=o.value):o.is(gt.appendConfig)&&(i=null,n=xt(n).concat(o.value));if(i)e=t.startState.values.slice();else{i=et.resolve(n,s,this),e=new Ct(i,this.doc,this.selection,i.dynamicSlots.map((()=>null)),((t,e)=>e.reconfigure(t,this)),null).values}let r=t.startState.facet(rt)?t.newSelection:t.newSelection.asSingle();new Ct(i,t.newDoc,r,e,((e,i)=>i.update(e,t)),t)}replaceSelection(t){return"string"==typeof t&&(t=this.toText(t)),this.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:t},range:N.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=xt(i.effects);for(let o=1;o<e.ranges.length;o++){let i=t(e.ranges[o]),h=this.changes(i.changes),l=h.map(n);for(let t=0;t<o;t++)s[t]=s[t].map(l);let a=n.mapDesc(h,!0);s.push(i.range.map(a)),n=n.compose(l),r=gt.mapEffects(r,l).concat(gt.mapEffects(xt(i.effects),a))}return{changes:n,selection:N.create(s,e.mainIndex),effects:r}}changes(t=[]){return t instanceof O?t:O.of(t,this.doc.length,this.facet(Ct.lineSeparator))}toText(t){return n.of(t.split(this.facet(Ct.lineSeparator)||A))}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:(it(this,e),nt(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 $&&null!=this.config.address[n.id]&&(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)if(Object.prototype.hasOwnProperty.call(t,s)){let e=i[s],r=t[s];n.push(e.init((t=>e.spec.fromJSON(r,t))))}return Ct.create({doc:t.doc,selection:N.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let e=et.resolve(t.extensions||[],new Map),i=t.doc instanceof n?t.doc:n.of((t.doc||"").split(e.staticFacet(Ct.lineSeparator)||A)),s=t.selection?t.selection instanceof N?t.selection:N.single(t.selection.anchor,t.selection.head):N.single(0);return I(s,i.length),e.staticFacet(rt)||(s=s.asSingle()),new Ct(e,i,s,e.dynamicSlots.map((()=>null)),((t,e)=>e.create(t)),null)}get tabSize(){return this.facet(Ct.tabSize)}get lineBreak(){return this.facet(Ct.lineSeparator)||"\n"}get readOnly(){return this.facet(ct)}phrase(t,...e){for(let i of this.facet(Ct.phrases))if(Object.prototype.hasOwnProperty.call(i,t)){t=i[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,((t,i)=>{if("$"==i)return"$";let n=+(i||1);return!n||n>e.length?t:e[n-1]}))),t}languageDataAt(t,e,i=-1){let n=[];for(let s of this.facet(st))for(let r of s(this,e,i))Object.prototype.hasOwnProperty.call(r,t)&&n.push(r[t]);return n}charCategorizer(t){return Mt(this.languageDataAt("wordChars",t).join(""))}wordAt(t){let{text:e,from:i,length:n}=this.doc.lineAt(t),s=this.charCategorizer(t),r=t-i,o=t-i;for(;r>0;){let t=w(e,r,!1);if(s(e.slice(t,r))!=St.Word)break;r=t}for(;o<n;){let t=w(e,o);if(s(e.slice(o,t))!=St.Word)break;o=t}return r==o?null:N.range(r+i,o+i)}}Ct.allowMultipleSelections=rt,Ct.tabSize=H.define({combine:t=>t.length?t[0]:4}),Ct.lineSeparator=ot,Ct.readOnly=ct,Ct.phrases=H.define({compare(t,e){let i=Object.keys(t),n=Object.keys(e);return i.length==n.length&&i.every((i=>t[i]==e[i]))}}),Ct.languageData=st,Ct.changeFilter=ht,Ct.transactionFilter=lt,Ct.transactionExtender=at,Z.reconfigure=gt.define();class Ot{eq(t){return this==t}range(t,e=t){return Tt.create(t,e,this)}}Ot.prototype.startSide=Ot.prototype.endSide=0,Ot.prototype.point=!1,Ot.prototype.mapMode=M.TrackDel;class Tt{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new Tt(t,e,i)}}function Dt(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Et{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,h=s[n]-t||(i?this.value[n].endSide:this.value[n].startSide)-e;if(n==r)return h>=0?r:o;h>=0?o=n:r=n+1}}between(t,e,i,n){for(let s=this.findIndex(e,-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 h=0;h<this.value.length;h++){let l,a,c=this.value[h],u=this.from[h]+t,f=this.to[h]+t;if(u==f){let t=e.mapPos(u,c.startSide,c.mapMode);if(null==t)continue;if(l=a=t,c.startSide!=c.endSide&&(a=e.mapPos(u,c.endSide),a<l))continue}else if(l=e.mapPos(u,c.startSide),a=e.mapPos(f,c.endSide),l>a||l==a&&c.startSide>0&&c.endSide<=0)continue;(a-l||c.endSide-c.startSide)<0||(r<0&&(r=l),c.point&&(o=Math.max(o,a-l)),i.push(c),n.push(l-r),s.push(a-r))}return{mapped:i.length?new Et(n,s,i,o):null,pos:r}}}class Rt{constructor(t,e,i,n){this.chunkPos=t,this.chunk=e,this.nextLayer=i,this.maxPoint=n}static create(t,e,i,n){return new Rt(t,e,i,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,r=t.filter;if(0==e.length&&!r)return this;if(i&&(e=e.slice().sort(Dt)),this.isEmpty)return e.length?Rt.of(e):this;let o=new Lt(this,null,-1).goto(0),h=0,l=[],a=new Bt;for(;o.value||h<e.length;)if(h<e.length&&(o.from-e[h].from||o.startSide-e[h].value.startSide)>=0){let t=e[h++];a.addInner(t.from,t.to,t.value)||l.push(t)}else 1==o.rangeIndex&&o.chunkIndex<this.chunk.length&&(h==e.length||this.chunkEnd(o.chunkIndex)<e[h].from)&&(!r||n>this.chunkEnd(o.chunkIndex)||s<this.chunkPos[o.chunkIndex])&&a.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!r||n>o.to||s<o.from||r(o.from,o.to,o.value))&&(a.addInner(o.from,o.to,o.value)||l.push(Tt.create(o.from,o.to,o.value))),o.next());return a.finishInner(this.nextLayer.isEmpty&&!l.length?Rt.empty:this.nextLayer.update({add:l,filter:r,filterFrom:n,filterTo:s}))}map(t){if(t.empty||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],h=t.touchesRange(s,s+o.length);if(!1===h)n=Math.max(n,o.maxPoint),e.push(o),i.push(t.mapPos(s));else if(!0===h){let{mapped:r,pos:h}=o.map(s,t);r&&(n=Math.max(n,r.maxPoint),e.push(r),i.push(h))}}let s=this.nextLayer.map(t);return 0==e.length?s:new Rt(i,e,s||Rt.empty,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 Nt.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return Nt.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)),h=Pt(r,o,i),l=new Vt(r,h,s),a=new Vt(o,h,s);i.iterGaps(((t,e,i)=>Ht(l,t,a,e,i,n))),i.empty&&0==i.length&&Ht(l,0,a,0,0,n)}static eq(t,e,i=0,n){null==n&&(n=999999999);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=Pt(s,r),h=new Vt(s,o,0).goto(i),l=new Vt(r,o,0).goto(i);for(;;){if(h.to!=l.to||!Wt(h.active,l.active)||h.point&&(!l.point||!h.point.eq(l.point)))return!1;if(h.to>n)return!0;h.next(),l.next()}}static spans(t,e,i,n,s=-1){let r=new Vt(t,null,s).goto(e),o=e,h=r.openStart;for(;;){let t=Math.min(r.to,i);if(r.point){let i=r.activeForPoint(r.to),s=r.pointFrom<e?i.length+1:Math.min(i.length,h);n.point(o,t,r.point,i,s,r.pointRank),h=Math.min(r.openEnd(t),i.length)}else t>o&&(n.span(o,t,r.active,h),h=r.openEnd(t));if(r.to>i)return h+(r.point&&r.to>i?1:0);o=r.to,r.next()}}static of(t,e=!1){let i=new Bt;for(let n of t instanceof Tt?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let n=t[i];if(Dt(e,n)>0)return t.slice().sort(Dt);e=n}return t}(t):t)i.add(n.from,n.to,n.value);return i.finish()}static join(t){if(!t.length)return Rt.empty;let e=t[t.length-1];for(let i=t.length-2;i>=0;i--)for(let n=t[i];n!=Rt.empty;n=n.nextLayer)e=new Rt(n.chunkPos,n.chunk,e,Math.max(n.maxPoint,e.maxPoint));return e}}Rt.empty=new Rt([],[],null,-1),Rt.empty.nextLayer=Rt.empty;class Bt{finishChunk(t){this.chunks.push(new Et(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=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(t,e,i){this.addInner(t,e,i)||(this.nextLayer||(this.nextLayer=new Bt)).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(Rt.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=Rt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function Pt(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.touchesRange(e,e+r.chunk[t].length))||s.add(r.chunk[t])}return s}class Lt{constructor(t,e,i,n=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex<this.layer.chunk.length;){let e=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(e)||this.layer.chunkEnd(this.chunkIndex)<t||e.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}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)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=t}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.rank-t.rank||this.to-t.to||this.endSide-t.endSide}}class Nt{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 Lt(r,e,i,s));return 1==n.length?n[0]:new Nt(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--)It(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--)It(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(),It(this.heap,0)}}}function It(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 Vt{constructor(t,e,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Nt.from(t,e,i)}goto(t,e=-1e9){return this.cursor.goto(t,e),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=t,this.endSide=e,this.openStart=-1,this.next(),this}forward(t,e){for(;this.minActive>-1&&(this.activeTo[this.minActive]-t||this.active[this.minActive].endSide-e)<0;)this.removeActive(this.minActive);this.cursor.forward(t,e)}removeActive(t){Ft(this.active,t),Ft(this.activeTo,t),Ft(this.activeRank,t),this.minActive=_t(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:n,rank:s}=this.cursor;for(;e<this.activeRank.length&&(s-this.activeRank[e]||n-this.activeTo[e])>0;)e++;zt(this.active,e,i),zt(this.activeTo,e,n),zt(this.activeRank,e,s),t&&zt(t,e,this.cursor.from),this.minActive=_t(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>t){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&Ft(i,n)}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 t=this.cursor.value;if(t.point){if(!(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=t,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=t.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(i),this.cursor.next()}}}if(i){this.openStart=0;for(let e=i.length-1;e>=0&&i[e]<t;e--)this.openStart++}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&e.push(this.active[i]);return e.reverse()}openEnd(t){let e=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)e++;return e}}function Ht(t,e,i,n,s,r){t.goto(e),i.goto(n);let o=n+s,h=n,l=n-e;for(;;){let e=t.to+l-i.to||t.endSide-i.endSide,n=e<0?t.to+l:i.to,s=Math.min(n,o);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))&&Wt(t.activeForPoint(t.to),i.activeForPoint(i.to))||r.comparePoint(h,s,t.point,i.point):s>h&&!Wt(t.active,i.active)&&r.compareRange(h,s,t.active,i.active),n>o)break;h=n,e<=0&&t.next(),e>=0&&i.next()}}function Wt(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 Ft(t,e){for(let i=e,n=t.length-1;i<n;i++)t[i]=t[i+1];t.pop()}function zt(t,e,i){for(let n=t.length-1;n>=e;n--)t[n+1]=t[n];t[e]=i}function _t(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}function jt(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=w(t,s)}return!0===n?-1:t.length}},88938:function(t,e,i){i.d(e,{V:function(){return o}});i(63721),i(52247),i(71695),i(92745),i(52805),i(43451),i(19134),i(5740),i(11740),i(97003),i(32114),i(39527),i(13334),i(34595),i(47021);const n="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),s="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class o{constructor(t,e){this.rules=[];let{finish:i}=e||{};function n(t){return/^@/.test(t)?[t]:t.split(/,\s*/)}function s(t,e,r,o){let h=[],l=/^@(\w+)\b/.exec(t[0]),a=l&&"keyframes"==l[1];if(l&&null==e)return r.push(t[0]+";");for(let i in e){let o=e[i];if(/&/.test(i))s(i.split(/,\s*/).map((e=>t.map((t=>e.replace(/&/,t))))).reduce(((t,e)=>t.concat(e))),o,r);else if(o&&"object"==typeof o){if(!l)throw new RangeError("The value of a property ("+i+") should be a primitive value.");s(n(i),o,h,a)}else null!=o&&h.push(i.replace(/_.*/,"").replace(/[A-Z]/g,(t=>"-"+t.toLowerCase()))+": "+o+";")}(h.length||a)&&r.push((!i||l||o?t:t.map(i)).join(", ")+" {"+h.join(" ")+"}")}for(let r in t)s(n(r),t[r],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let t=r[n]||1;return r[n]=t+1,"ͼ"+t.toString(36)}static mount(t,e,i){let n=t[s],r=i&&i.nonce;n?r&&n.setNonce(r):n=new l(t,r),n.mount(Array.isArray(e)?e:[e])}}let h=new Map;class l{constructor(t,e){let i=t.ownerDocument||t,n=i.defaultView;if(!t.head&&t.adoptedStyleSheets&&n.CSSStyleSheet){let e=h.get(i);if(e)return t.adoptedStyleSheets=[e.sheet,...t.adoptedStyleSheets],t[s]=e;this.sheet=new n.CSSStyleSheet,t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets],h.set(i,this)}else{this.styleTag=i.createElement("style"),e&&this.styleTag.setAttribute("nonce",e);let n=t.head||t;n.insertBefore(this.styleTag,n.firstChild)}this.modules=[],t[s]=this}mount(t){let e=this.sheet,i=0,n=0;for(let s=0;s<t.length;s++){let r=t[s],o=this.modules.indexOf(r);if(o<n&&o>-1&&(this.modules.splice(o,1),n--,o=-1),-1==o){if(this.modules.splice(n++,0,r),e)for(let t=0;t<r.rules.length;t++)e.insertRule(r.rules[t],i++)}else{for(;n<o;)i+=this.modules[n++].rules.length;i+=r.rules.length,n++}}if(!e){let t="";for(let e=0;e<this.modules.length;e++)t+=this.modules[e].getRules()+"\n";this.styleTag.textContent=t}}setNonce(t){this.styleTag&&this.styleTag.getAttribute("nonce")!=t&&this.styleTag.setAttribute("nonce",t)}}},67084:function(t,e,i){i.d(e,{Gv:function(){return l},QR:function(){return u},pJ:function(){return O}});i(52247),i(63434),i(71695),i(92745),i(61893),i(19134),i(96829),i(39527),i(92181),i(99790),i(67670),i(88972),i(47021);var n=i(70585);let s=0;class r{constructor(t,e,i){this.set=t,this.base=e,this.modified=i,this.id=s++}static define(t){if(null==t?void 0:t.base)throw new Error("Can not derive from a modified tag");let e=new r([],null,[]);if(e.set.push(e),t)for(let i of t.set)e.set.push(i);return e}static defineModifier(){let t=new h;return e=>e.modified.indexOf(t)>-1?e:h.get(e.base||e,e.modified.concat(t).sort(((t,e)=>t.id-e.id)))}}let o=0;class h{constructor(){this.instances=[],this.id=o++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find((i=>{return i.base==t&&(n=e,s=i.modified,n.length==s.length&&n.every(((t,e)=>t==s[e])));var n,s}));if(i)return i;let n=[],s=new r(n,t,e);for(let r of e)r.instances.push(s);let o=function(t){let e=[[]];for(let i=0;i<t.length;i++)for(let n=0,s=e.length;n<s;n++)e.push(e[n].concat(t[i]));return e.sort(((t,e)=>e.length-t.length))}(e);for(let r of t.set)if(!r.modified.length)for(let t of o)n.push(h.get(r,t));return s}}function l(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]?"":'"'==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,h=i[o];if(!h)throw new RangeError("Invalid path: "+t);let l=new c(n,s,o>0?i.slice(0,o):null);e[h]=l.sort(e[h])}}return a.add(e)}const a=new n.md;class c{constructor(t,e,i,n){this.tags=t,this.mode=e,this.context=i,this.next=n}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}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}}function u(t,e){let i=Object.create(null);for(let r of t)if(Array.isArray(r.tag))for(let t of r.tag)i[t.id]=r.class;else i[r.tag.id]=r.class;let{scope:n,all:s=null}=e||{};return{style:t=>{let e=s;for(let n of t)for(let t of n.set){let n=i[t.id];if(n){e=e?e+" "+n:n;break}}return e},scope:n}}c.empty=new c([],2,null);const f=r.define,d=f(),g=f(),p=f(g),m=f(g),w=f(),v=f(w),y=f(w),b=f(),x=f(b),S=f(),k=f(),A=f(),M=f(A),C=f(),O={comment:d,lineComment:f(d),blockComment:f(d),docComment:f(d),name:g,variableName:f(g),typeName:p,tagName:f(p),propertyName:m,attributeName:f(m),className:f(g),labelName:f(g),namespace:f(g),macroName:f(g),literal:w,string:v,docString:f(v),character:f(v),attributeValue:f(v),number:y,integer:f(y),float:f(y),bool:f(w),regexp:f(w),escape:f(w),color:f(w),url:f(w),keyword:S,self:f(S),null:f(S),atom:f(S),unit:f(S),modifier:f(S),operatorKeyword:f(S),controlKeyword:f(S),definitionKeyword:f(S),moduleKeyword:f(S),operator:k,derefOperator:f(k),arithmeticOperator:f(k),logicOperator:f(k),bitwiseOperator:f(k),compareOperator:f(k),updateOperator:f(k),definitionOperator:f(k),typeOperator:f(k),controlOperator:f(k),punctuation:A,separator:f(A),bracket:M,angleBracket:f(M),squareBracket:f(M),paren:f(M),brace:f(M),content:b,heading:x,heading1:f(x),heading2:f(x),heading3:f(x),heading4:f(x),heading5:f(x),heading6:f(x),contentSeparator:f(b),list:f(b),quote:f(b),emphasis:f(b),strong:f(b),link:f(b),monospace:f(b),strikethrough:f(b),inserted:f(),deleted:f(),changed:f(),invalid:f(),meta:C,documentMeta:f(C),annotation:f(C),processingInstruction:f(C),definition:r.defineModifier(),constant:r.defineModifier(),function:r.defineModifier(),standard:r.defineModifier(),local:r.defineModifier(),special:r.defineModifier()};u([{tag:O.link,class:"tok-link"},{tag:O.heading,class:"tok-heading"},{tag:O.emphasis,class:"tok-emphasis"},{tag:O.strong,class:"tok-strong"},{tag:O.keyword,class:"tok-keyword"},{tag:O.atom,class:"tok-atom"},{tag:O.bool,class:"tok-bool"},{tag:O.url,class:"tok-url"},{tag:O.labelName,class:"tok-labelName"},{tag:O.inserted,class:"tok-inserted"},{tag:O.deleted,class:"tok-deleted"},{tag:O.literal,class:"tok-literal"},{tag:O.string,class:"tok-string"},{tag:O.number,class:"tok-number"},{tag:[O.regexp,O.escape,O.special(O.string)],class:"tok-string2"},{tag:O.variableName,class:"tok-variableName"},{tag:O.local(O.variableName),class:"tok-variableName tok-local"},{tag:O.definition(O.variableName),class:"tok-variableName tok-definition"},{tag:O.special(O.variableName),class:"tok-variableName2"},{tag:O.definition(O.propertyName),class:"tok-propertyName tok-definition"},{tag:O.typeName,class:"tok-typeName"},{tag:O.namespace,class:"tok-namespace"},{tag:O.className,class:"tok-className"},{tag:O.macroName,class:"tok-macroName"},{tag:O.propertyName,class:"tok-propertyName"},{tag:O.operator,class:"tok-operator"},{tag:O.comment,class:"tok-comment"},{tag:O.meta,class:"tok-meta"},{tag:O.invalid,class:"tok-invalid"},{tag:O.punctuation,class:"tok-punctuation"}])},8877:function(t,e,i){i.a(t,(async function(t,n){try{i.d(e,{at:function(){return Se},f$:function(){return q},m8:function(){return C},wQ:function(){return Ae},xi:function(){return ke}});i(71695),i(92745),i(19134),i(5740),i(47706),i(39527),i(92181),i(99790),i(13334),i(36993),i(47021);var s=i(73928),r=i(70081),o=i(52806),h=i(28648),l=t([r,o]);[r,o]=l.then?(await l)():l;const c=t=>{let{state:e}=t,i=e.doc.lineAt(e.selection.main.from),n=p(t.state,i.from);return n.line?f(t):!!n.block&&g(t)};function u(t,e){return({state:i,dispatch:n})=>{if(i.readOnly)return!1;let s=t(e,i);return!!s&&(n(i.update(s)),!0)}}const f=u(b,0),d=u(y,0),g=u(((t,e)=>y(t,e,v(e))),0);function p(t,e){let i=t.languageDataAt("commentTokens",e);return i.length?i[0]:{}}const m=50;function w(t,{open:e,close:i},n,s){let r,o,h=t.sliceDoc(n-m,n),l=t.sliceDoc(s,s+m),a=/\s*$/.exec(h)[0].length,c=/^\s*/.exec(l)[0].length,u=h.length-a;if(h.slice(u-e.length,u)==e&&l.slice(c,c+i.length)==i)return{open:{pos:n-a,margin:a&&1},close:{pos:s+c,margin:c&&1}};s-n<=2*m?r=o=t.sliceDoc(n,s):(r=t.sliceDoc(n,n+m),o=t.sliceDoc(s-m,s));let f=/^\s*/.exec(r)[0].length,d=/\s*$/.exec(o)[0].length,g=o.length-d-i.length;return r.slice(f,f+e.length)==e&&o.slice(g,g+i.length)==i?{open:{pos:n+f+e.length,margin:/\s/.test(r.charAt(f+e.length))?1:0},close:{pos:s-d-i.length,margin:/\s/.test(o.charAt(g-1))?1:0}}:null}function v(t){let e=[];for(let i of t.selection.ranges){let n=t.doc.lineAt(i.from),s=i.to<=n.to?n:t.doc.lineAt(i.to);s.from>n.from&&s.from==i.to&&(s=i.to==n.to+1?n:t.doc.lineAt(i.to-1));let r=e.length-1;r>=0&&e[r].to>n.from?e[r].to=s.to:e.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:s.to})}return e}function y(t,e,i=e.selection.ranges){let n=i.map((t=>p(e,t.from).block));if(!n.every((t=>t)))return null;let s=i.map(((t,i)=>w(e,n[i],t.from,t.to)));if(2!=t&&!s.every((t=>t)))return{changes:e.changes(i.map(((t,e)=>s[e]?[]:[{from:t.from,insert:n[e].open+" "},{from:t.to,insert:" "+n[e].close}])))};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 b(t,e,i=e.selection.ranges){let n=[],s=-1;for(let{from:r,to:o}of i){let t=n.length,i=1e9,h=p(e,r).line;if(h){for(let t=r;t<=o;){let l=e.doc.lineAt(t);if(l.from>s&&(r==o||o>l.from)){s=l.from;let t=/^\s*/.exec(l.text)[0].length,e=t==l.length,r=l.text.slice(t,t+h.length)==h?t:-1;t<l.text.length&&t<i&&(i=t),n.push({line:l,comment:r,token:h,indent:t,empty:e,single:!1})}t=l.to+1}if(i<1e9)for(let e=t;e<n.length;e++)n[e].indent<n[e].line.text.length&&(n[e].indent=i);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:e,token:s,indent:r,empty:o,single:h}of n)!h&&o||t.push({from:e.from+r,insert:s+" "});let i=e.changes(t);return{changes:i,selection:e.selection.map(i,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}const x=s.q6.define(),S=s.q6.define(),k=s.r$.define(),A=s.r$.define({combine(t){return(0,s.BO)(t,{minDepth:100,newGroupDelay:500,joinToEvent:(t,e)=>e},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,e)=>(i,n)=>t(i,n)||e(i,n)})}}),M=s.QQ.define({create(){return j.empty},update(t,e){let i=e.state.facet(A),n=e.annotation(x);if(n){let s=B.fromTransaction(e,n.selection),r=n.side,o=0==r?t.undone:t.done;return o=s?P(o,o.length,i.minDepth,s):H(o,e.startState.selection),new j(0==r?n.rest:o,0==r?o:n.rest)}let r=e.annotation(S);if("full"!=r&&"before"!=r||(t=t.isolate()),!1===e.annotation(s.YW.addToHistory))return e.changes.empty?t:t.addMapping(e.changes.desc);let o=B.fromTransaction(e),h=e.annotation(s.YW.time),l=e.annotation(s.YW.userEvent);return o?t=t.addChanges(o,h,l,i,e):e.selection&&(t=t.addSelection(e.startState.selection,h,l,i.newGroupDelay)),"full"!=r&&"after"!=r||(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 j(t.done.map(B.fromJSON),t.undone.map(B.fromJSON))}});function C(t={}){return[M,A.of(t),r.tk.domEventHandlers({beforeinput(t,e){let i="historyUndo"==t.inputType?T:"historyRedo"==t.inputType?D:null;return!!i&&(t.preventDefault(),i(e))}})]}function O(t,e){return function({state:i,dispatch:n}){if(!e&&i.readOnly)return!1;let s=i.field(M,!1);if(!s)return!1;let r=s.pop(t,i,e);return!!r&&(n(r),!0)}}const T=O(0,!1),D=O(1,!1),E=O(0,!0),R=O(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&&s.as.fromJSON(t.changes),[],t.mapped&&s.n0.fromJSON(t.mapped),t.startSelection&&s.jT.fromJSON(t.startSelection),t.selectionsAfter.map(s.jT.fromJSON))}static fromTransaction(t,e){let i=I;for(let n of t.startState.facet(k)){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,I)}static selection(t){return new B(void 0,I,void 0,void 0,t)}}function P(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 L(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 N(t,e){return t.length?e.length?t.concat(e):t:e}const I=[],V=200;function H(t,e){if(t.length){let i=t[t.length-1],n=i.selectionsAfter.slice(Math.max(0,i.selectionsAfter.length-V));return n.length&&n[n.length-1].eq(e)?t:(n.push(e),P(t,t.length-1,1e9,i.setSelAfter(n)))}return[B.selection([e])]}function W(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 F(t,e){if(!t.length)return t;let i=t.length,n=I;for(;i;){let s=z(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)]:I}function z(t,e,i){let n=N(t.selectionsAfter.length?t.selectionsAfter.map((t=>t.map(e))):I,i);if(!t.changes)return B.selection(n);let r=t.changes.map(e),o=e.mapDesc(t.changes,!0),h=t.mapped?t.mapped.composeDesc(o):o;return new B(r,s.Py.mapEffects(t.effects,e),h,t.startSelection.map(o),n)}const _=/^(input\.type|delete)($|\.)/;class j{constructor(t,e,i=0,n=void 0){this.done=t,this.undone=e,this.prevTime=i,this.prevUserEvent=n}isolate(){return this.prevTime?new j(this.done,this.undone):this}addChanges(t,e,i,n,r){let o=this.done,h=o[o.length-1];return o=h&&h.changes&&!h.changes.empty&&t.changes&&(!i||_.test(i))&&(!h.selectionsAfter.length&&e-this.prevTime<n.newGroupDelay&&n.joinToEvent(r,L(h.changes,t.changes))||"input.type.compose"==i)?P(o,o.length-1,n.minDepth,new B(t.changes.compose(h.changes),N(s.Py.mapEffects(t.effects,h.changes),h.effects),h.mapped,h.startSelection,I)):P(o,o.length,n.minDepth,t),new j(o,I,e,i)}addSelection(t,e,i,n){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:I;return s.length>0&&e-this.prevTime<n&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&(r=s[s.length-1],o=t,r.ranges.length==o.ranges.length&&0===r.ranges.filter(((t,e)=>t.empty!=o.ranges[e].empty)).length)?this:new j(H(this.done,t),this.undone,e,i);var r,o}addMapping(t){return new j(F(this.done,t),F(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],r=s.selectionsAfter[0]||e.selection;if(i&&s.selectionsAfter.length)return e.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:x.of({side:t,rest:W(n),selection:r}),userEvent:0==t?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let i=1==n.length?I:n.slice(0,n.length-1);return s.mapped&&(i=F(i,s.mapped)),e.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:x.of({side:t,rest:i,selection:r}),filter:!1,userEvent:0==t?"undo":"redo",scrollIntoView:!0})}return null}}j.empty=new j(I,I);const q=[{key:"Mod-z",run:T,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:D,preventDefault:!0},{linux:"Ctrl-Shift-z",run:D,preventDefault:!0},{key:"Mod-u",run:E,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:R,preventDefault:!0}];function $(t,e){return s.jT.create(t.ranges.map(e),t.mainIndex)}function K(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function J({state:t,dispatch:e},i){let n=$(t.selection,i);return!n.eq(t.selection,!0)&&(e(K(t,n)),!0)}function G(t,e){return s.jT.cursor(e?t.to:t.from)}function U(t,e){return J(t,(i=>i.empty?t.moveByChar(i,e):G(i,e)))}function X(t){return t.textDirectionAt(t.state.selection.main.head)==r.Nm.LTR}const Y=t=>U(t,!X(t)),Q=t=>U(t,X(t));function Z(t,e){return J(t,(i=>i.empty?t.moveByGroup(i,e):G(i,e)))}const tt=t=>Z(t,!X(t)),et=t=>Z(t,X(t));"undefined"!=typeof Intl&&Intl.Segmenter;function it(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 nt(t,e,i){let n,r,l=(0,o.qz)(t).resolveInner(e.head),a=i?h.md.closedBy:h.md.openedBy;for(let s=e.head;;){let e=i?l.childAfter(s):l.childBefore(s);if(!e)break;it(t,e,a)?l=e:s=i?e.to:e.from}return r=l.type.prop(a)&&(n=i?(0,o.Um)(t,l.from,1):(0,o.Um)(t,l.to,-1))&&n.matched?i?n.end.to:n.end.from:i?l.to:l.from,s.jT.cursor(r,i?-1:1)}const st=t=>J(t,(e=>nt(t.state,e,!X(t)))),rt=t=>J(t,(e=>nt(t.state,e,X(t))));function ot(t,e){return J(t,(i=>{if(!i.empty)return G(i,e);let n=t.moveVertically(i,e);return n.head!=i.head?n:t.moveToLineBoundary(i,e)}))}const ht=t=>ot(t,!1),lt=t=>ot(t,!0);function at(t){let e,i=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,n=0,s=0;if(i){for(let e of t.state.facet(r.tk.scrollMargins)){let i=e(t);(null==i?void 0:i.top)&&(n=Math.max(null==i?void 0:i.top,n)),(null==i?void 0:i.bottom)&&(s=Math.max(null==i?void 0:i.bottom,s))}e=t.scrollDOM.clientHeight-n-s}else e=(t.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:s,selfScroll:i,height:Math.max(t.defaultLineHeight,e-5)}}function ct(t,e){let i,n=at(t),{state:s}=t,o=$(s.selection,(i=>i.empty?t.moveVertically(i,e,n.height):G(i,e)));if(o.eq(s.selection))return!1;if(n.selfScroll){let e=t.coordsAtPos(s.selection.main.head),h=t.scrollDOM.getBoundingClientRect(),l=h.top+n.marginTop,a=h.bottom-n.marginBottom;e&&e.top>l&&e.bottom<a&&(i=r.tk.scrollIntoView(o.main.head,{y:"start",yMargin:e.top-l}))}return t.dispatch(K(s,o),{effects:i}),!0}const ut=t=>ct(t,!1),ft=t=>ct(t,!0);function dt(t,e,i){let n=t.lineBlockAt(e.head),r=t.moveToLineBoundary(e,i);if(r.head==e.head&&r.head!=(i?n.to:n.from)&&(r=t.moveToLineBoundary(e,i,!1)),!i&&r.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&&(r=s.jT.cursor(n.from+i))}return r}const gt=t=>J(t,(e=>dt(t,e,!0))),pt=t=>J(t,(e=>dt(t,e,!1))),mt=t=>J(t,(e=>dt(t,e,!X(t)))),wt=t=>J(t,(e=>dt(t,e,X(t)))),vt=t=>J(t,(e=>s.jT.cursor(t.lineBlockAt(e.head).from,1))),yt=t=>J(t,(e=>s.jT.cursor(t.lineBlockAt(e.head).to,-1)));function bt(t,e,i){let n=!1,r=$(t.selection,(e=>{let r=(0,o.Um)(t,e.head,-1)||(0,o.Um)(t,e.head,1)||e.head>0&&(0,o.Um)(t,e.head-1,1)||e.head<t.doc.length&&(0,o.Um)(t,e.head+1,-1);if(!r||!r.end)return e;n=!0;let h=r.start.from==e.head?r.end.to:r.end.from;return i?s.jT.range(e.anchor,h):s.jT.cursor(h)}));return!!n&&(e(K(t,r)),!0)}const xt=({state:t,dispatch:e})=>bt(t,e,!1);function St(t,e){let i=$(t.state.selection,(t=>{let i=e(t);return s.jT.range(t.anchor,i.head,i.goalColumn,i.bidiLevel||void 0)}));return!i.eq(t.state.selection)&&(t.dispatch(K(t.state,i)),!0)}function kt(t,e){return St(t,(i=>t.moveByChar(i,e)))}const At=t=>kt(t,!X(t)),Mt=t=>kt(t,X(t));function Ct(t,e){return St(t,(i=>t.moveByGroup(i,e)))}const Ot=t=>Ct(t,!X(t)),Tt=t=>Ct(t,X(t));const Dt=t=>St(t,(e=>nt(t.state,e,!X(t)))),Et=t=>St(t,(e=>nt(t.state,e,X(t))));function Rt(t,e){return St(t,(i=>t.moveVertically(i,e)))}const Bt=t=>Rt(t,!1),Pt=t=>Rt(t,!0);function Lt(t,e){return St(t,(i=>t.moveVertically(i,e,at(t).height)))}const Nt=t=>Lt(t,!1),It=t=>Lt(t,!0),Vt=t=>St(t,(e=>dt(t,e,!0))),Ht=t=>St(t,(e=>dt(t,e,!1))),Wt=t=>St(t,(e=>dt(t,e,!X(t)))),Ft=t=>St(t,(e=>dt(t,e,X(t)))),zt=t=>St(t,(e=>s.jT.cursor(t.lineBlockAt(e.head).from))),_t=t=>St(t,(e=>s.jT.cursor(t.lineBlockAt(e.head).to))),jt=({state:t,dispatch:e})=>(e(K(t,{anchor:0})),!0),qt=({state:t,dispatch:e})=>(e(K(t,{anchor:t.doc.length})),!0),$t=({state:t,dispatch:e})=>(e(K(t,{anchor:t.selection.main.anchor,head:0})),!0),Kt=({state:t,dispatch:e})=>(e(K(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),Jt=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),Gt=({state:t,dispatch:e})=>{let i=ce(t).map((({from:e,to:i})=>s.jT.range(e,Math.min(i+1,t.doc.length))));return e(t.update({selection:s.jT.create(i),userEvent:"select"})),!0},Ut=({state:t,dispatch:e})=>{let i=$(t.selection,(e=>{let i=(0,o.qz)(t),n=i.resolveStack(e.from,1);if(e.empty){let t=i.resolveStack(e.from,-1);t.node.from>=n.node.from&&t.node.to<=n.node.to&&(n=t)}for(let t=n;t;t=t.next){let{node:i}=t;if((i.from<e.from&&i.to>=e.to||i.to>e.to&&i.from<=e.from)&&t.next)return s.jT.range(i.to,i.from)}return e}));return!i.eq(t.selection)&&(e(K(t,i)),!0)},Xt=({state:t,dispatch:e})=>{let i=t.selection,n=null;return i.ranges.length>1?n=s.jT.create([i.main]):i.main.empty||(n=s.jT.create([s.jT.cursor(i.main.head)])),!!n&&(e(K(t,n)),!0)};function Yt(t,e){if(t.state.readOnly)return!1;let i="delete.selection",{state:n}=t,o=n.changeByRange((n=>{let{from:r,to:o}=n;if(r==o){let s=e(n);s<r?(i="delete.backward",s=Qt(t,s,!1)):s>r&&(i="delete.forward",s=Qt(t,s,!0)),r=Math.min(r,s),o=Math.max(o,s)}else r=Qt(t,r,!1),o=Qt(t,o,!0);return r==o?{range:n}:{changes:{from:r,to:o},range:s.jT.cursor(r,r<n.head?-1:1)}}));return!o.changes.empty&&(t.dispatch(n.update(o,{scrollIntoView:!0,userEvent:i,effects:"delete.selection"==i?r.tk.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function Qt(t,e,i){if(t instanceof r.tk)for(let n of t.state.facet(r.tk.atomicRanges).map((e=>e(t))))n.between(e,e,((t,n)=>{t<e&&n>e&&(e=i?n:t)}));return e}const Zt=(t,e,i)=>Yt(t,(n=>{let r,h,l=n.from,{state:a}=t,c=a.doc.lineAt(l);if(i&&!e&&l>c.from&&l<c.from+200&&!/[^ \t]/.test(r=c.text.slice(0,l-c.from))){if("\t"==r[r.length-1])return l-1;let t=(0,s.IS)(r,a.tabSize)%(0,o.y1)(a)||(0,o.y1)(a);for(let e=0;e<t&&" "==r[r.length-1-e];e++)l--;h=l}else h=(0,s.cp)(c.text,l-c.from,e,e)+c.from,h==l&&c.number!=(e?a.doc.lines:1)?h+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(c.text.slice(h-c.from,l-c.from))&&(h=(0,s.cp)(c.text,h-c.from,!1,!1)+c.from);return h})),te=t=>Zt(t,!1,!0),ee=t=>Zt(t,!0,!1),ie=(t,e)=>Yt(t,(i=>{let n=i.head,{state:r}=t,o=r.doc.lineAt(n),h=r.charCategorizer(n);for(let t=null;;){if(n==(e?o.to:o.from)){n==i.head&&o.number!=(e?r.doc.lines:1)&&(n+=e?1:-1);break}let l=(0,s.cp)(o.text,n-o.from,e)+o.from,a=o.text.slice(Math.min(n,l)-o.from,Math.max(n,l)-o.from),c=h(a);if(null!=t&&c!=t)break;" "==a&&n==i.head||(t=c),n=l}return n})),ne=t=>ie(t,!1),se=t=>ie(t,!0),re=t=>Yt(t,(e=>{let i=t.lineBlockAt(e.head).to;return e.head<i?i:Math.min(t.state.doc.length,e.head+1)})),oe=t=>Yt(t,(e=>{let i=t.moveToLineBoundary(e,!1).head;return e.head>i?i:Math.max(0,e.head-1)})),he=t=>Yt(t,(e=>{let i=t.moveToLineBoundary(e,!0).head;return e.head<i?i:Math.min(t.state.doc.length,e.head+1)})),le=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange((t=>({changes:{from:t.from,to:t.to,insert:s.xv.of(["",""])},range:s.jT.cursor(t.from)})));return e(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0},ae=({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),r=i==n.from?i-1:(0,s.cp)(n.text,i-n.from,!1)+n.from,o=i==n.to?i+1:(0,s.cp)(n.text,i-n.from,!0)+n.from;return{changes:{from:r,to:o,insert:t.doc.slice(i,o).append(t.doc.slice(r,i))},range:s.jT.cursor(o)}}));return!i.changes.empty&&(e(t.update(i,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function ce(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 ue(t,e,i){if(t.readOnly)return!1;let n=[],r=[];for(let o of ce(t)){if(i?o.to==t.doc.length:0==o.from)continue;let e=t.doc.lineAt(i?o.to+1:o.from-1),h=e.length+1;if(i){n.push({from:o.to,to:e.to},{from:o.from,insert:e.text+t.lineBreak});for(let e of o.ranges)r.push(s.jT.range(Math.min(t.doc.length,e.anchor+h),Math.min(t.doc.length,e.head+h)))}else{n.push({from:e.from,to:o.from},{from:o.to,insert:t.lineBreak+e.text});for(let t of o.ranges)r.push(s.jT.range(t.anchor-h,t.head-h))}}return!!n.length&&(e(t.update({changes:n,scrollIntoView:!0,selection:s.jT.create(r,t.selection.mainIndex),userEvent:"move.line"})),!0)}const fe=({state:t,dispatch:e})=>ue(t,e,!1),de=({state:t,dispatch:e})=>ue(t,e,!0);function ge(t,e,i){if(t.readOnly)return!1;let n=[];for(let s of ce(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 pe=({state:t,dispatch:e})=>ge(t,e,!1),me=({state:t,dispatch:e})=>ge(t,e,!0),we=t=>{if(t.state.readOnly)return!1;let{state:e}=t,i=e.changes(ce(e).map((({from:t,to:i})=>(t>0?t--:i<e.doc.length&&i++,{from:t,to:i})))),n=$(e.selection,(e=>{let i;if(t.lineWrapping){let n=t.lineBlockAt(e.head),s=t.coordsAtPos(e.head,e.assoc||1);s&&(i=n.bottom+t.documentTop-s.bottom+t.defaultLineHeight/2)}return t.moveVertically(e,!0,i)})).map(i);return t.dispatch({changes:i,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function ve(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let i,n=(0,o.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(h.md.closedBy))&&i.indexOf(r.name)>-1&&t.doc.lineAt(s.to).from==t.doc.lineAt(r.from).from&&!/\S/.test(t.sliceDoc(s.to,r.from))?{from:s.to,to:r.from}:null}const ye=be(!1);function be(t){return({state:e,dispatch:i})=>{if(e.readOnly)return!1;let n=e.changeByRange((i=>{let{from:n,to:r}=i,h=e.doc.lineAt(n),l=!t&&n==r&&ve(e,n);t&&(n=r=(r<=h.to?h:e.doc.lineAt(r)).to);let a=new o.Gn(e,{simulateBreak:n,simulateDoubleBreak:!!l}),c=(0,o.K0)(a,n);for(null==c&&(c=(0,s.IS)(/^\s*/.exec(e.doc.lineAt(n).text)[0],e.tabSize));r<h.to&&/\s/.test(h.text[r-h.from]);)r++;l?({from:n,to:r}=l):n>h.from&&n<h.from+100&&!/\S/.test(h.text.slice(0,n))&&(n=h.from);let u=["",(0,o.SS)(e,c)];return l&&u.push((0,o.SS)(e,a.lineIndent(h.from,-1))),{changes:{from:n,to:r,insert:s.xv.of(u)},range:s.jT.cursor(n+1+u[1].length)}}));return i(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function xe(t,e){let i=-1;return t.changeByRange((n=>{let r=[];for(let s=n.from;s<=n.to;){let o=t.doc.lineAt(s);o.number>i&&(n.empty||n.to>o.from)&&(e(o,r,n),i=o.number),s=o.to+1}let o=t.changes(r);return{changes:r,range:s.jT.range(o.mapPos(n.anchor,1),o.mapPos(n.head,1))}}))}const Se=({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(xe(t,((e,i)=>{i.push({from:e.from,insert:t.facet(o.c)})})),{userEvent:"input.indent"})),!0),ke=({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(xe(t,((e,i)=>{let n=/^\s*/.exec(e.text)[0];if(!n)return;let r=(0,s.IS)(n,t.tabSize),h=0,l=(0,o.SS)(t,Math.max(0,r-(0,o.y1)(t)));for(;h<n.length&&h<l.length&&n.charCodeAt(h)==l.charCodeAt(h);)h++;i.push({from:e.from+h,to:e.from+n.length,insert:l.slice(h)})})),{userEvent:"delete.dedent"})),!0),Ae=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:st,shift:Dt},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:rt,shift:Et},{key:"Alt-ArrowUp",run:fe},{key:"Shift-Alt-ArrowUp",run:pe},{key:"Alt-ArrowDown",run:de},{key:"Shift-Alt-ArrowDown",run:me},{key:"Escape",run:Xt},{key:"Mod-Enter",run:be(!0)},{key:"Alt-l",mac:"Ctrl-l",run:Gt},{key:"Mod-i",run:Ut,preventDefault:!0},{key:"Mod-[",run:ke},{key:"Mod-]",run:Se},{key:"Mod-Alt-\\",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=Object.create(null),n=new o.Gn(t,{overrideIndentation:t=>{let e=i[t];return null==e?-1:e}}),s=xe(t,((e,s,r)=>{let h=(0,o.K0)(n,e.from);if(null==h)return;/\S/.test(e.text)||(h=0);let l=/^\s*/.exec(e.text)[0],a=(0,o.SS)(t,h);(l!=a||r.from<e.from+l.length)&&(i[e.from]=h,s.push({from:e.from,to:e.from+l.length,insert:a}))}));return s.changes.empty||e(t.update(s,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:we},{key:"Shift-Mod-\\",run:xt},{key:"Mod-/",run:c},{key:"Alt-A",run:d},{key:"Ctrl-m",mac:"Shift-Alt-m",run:t=>(t.setTabFocusMode(),!0)}].concat([{key:"ArrowLeft",run:Y,shift:At,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:tt,shift:Ot,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:mt,shift:Wt,preventDefault:!0},{key:"ArrowRight",run:Q,shift:Mt,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:et,shift:Tt,preventDefault:!0},{mac:"Cmd-ArrowRight",run:wt,shift:Ft,preventDefault:!0},{key:"ArrowUp",run:ht,shift:Bt,preventDefault:!0},{mac:"Cmd-ArrowUp",run:jt,shift:$t},{mac:"Ctrl-ArrowUp",run:ut,shift:Nt},{key:"ArrowDown",run:lt,shift:Pt,preventDefault:!0},{mac:"Cmd-ArrowDown",run:qt,shift:Kt},{mac:"Ctrl-ArrowDown",run:ft,shift:It},{key:"PageUp",run:ut,shift:Nt},{key:"PageDown",run:ft,shift:It},{key:"Home",run:pt,shift:Ht,preventDefault:!0},{key:"Mod-Home",run:jt,shift:$t},{key:"End",run:gt,shift:Vt,preventDefault:!0},{key:"Mod-End",run:qt,shift:Kt},{key:"Enter",run:ye,shift:ye},{key:"Mod-a",run:Jt},{key:"Backspace",run:te,shift:te},{key:"Delete",run:ee},{key:"Mod-Backspace",mac:"Alt-Backspace",run:ne},{key:"Mod-Delete",mac:"Alt-Delete",run:se},{mac:"Mod-Backspace",run:oe},{mac:"Mod-Delete",run:he}].concat([{key:"Ctrl-b",run:Y,shift:At,preventDefault:!0},{key:"Ctrl-f",run:Q,shift:Mt},{key:"Ctrl-p",run:ht,shift:Bt},{key:"Ctrl-n",run:lt,shift:Pt},{key:"Ctrl-a",run:vt,shift:zt},{key:"Ctrl-e",run:yt,shift:_t},{key:"Ctrl-d",run:ee},{key:"Ctrl-h",run:te},{key:"Ctrl-k",run:re},{key:"Ctrl-Alt-h",run:ne},{key:"Ctrl-o",run:le},{key:"Ctrl-t",run:ae},{key:"Ctrl-v",run:ft}].map((t=>({mac:t.key,run:t.run,shift:t.shift})))));n()}catch(a){n(a)}}))},52806:function(t,e,i){i.a(t,(async function(t,n){try{i.d(e,{Gn:function(){return R},K0:function(){return E},SS:function(){return D},Um:function(){return G},c:function(){return O},qz:function(){return m},y1:function(){return T}});i(52247),i(71695),i(92745),i(77439),i(19423),i(40251),i(69235),i(12385),i(19134),i(5740),i(11740),i(44495),i(97003),i(47706),i(46692),i(39527),i(13334),i(36993),i(47021);var s,r=i(99173),o=i(95652),h=i(68857),l=i(97219),a=i(29933),c=t([h]);h=(c.then?(await c)():c)[0];const f=new r.md;const d=new r.md;class g{constructor(t,e,i=[],n=""){this.data=t,this.name=n,o.yy.prototype.hasOwnProperty("tree")||Object.defineProperty(o.yy.prototype,"tree",{get(){return m(this)}}),this.parser=e,this.extension=[M.of(this),o.yy.languageData.of(((t,e,i)=>{let n=p(t,e,i),s=n.type.prop(f);if(!s)return[];let r=t.facet(s),o=n.type.prop(d);if(o){let s=n.resolve(e-n.from,i);for(let e of o)if(e.test(s,t)){let i=t.facet(e.facet);return"replace"==e.type?i:i.concat(r)}}return r}))].concat(i)}isActiveAt(t,e,i=-1){return p(t,e,i).type.prop(f)==this.data}findRegions(t){let e=t.facet(M);if((null==e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let i=[],n=(t,e)=>{if(t.prop(f)==this.data)return void i.push({from:e,to:e+t.length});let s=t.prop(r.md.mounted);if(s){if(s.tree.prop(f)==this.data){if(s.overlay)for(let t of s.overlay)i.push({from:t.from+e,to:t.to+e});else i.push({from:e,to:e+t.length});return}if(s.overlay){let t=i.length;if(n(s.tree,s.overlay[0].from+e),i.length>t)return}}for(let i=0;i<t.children.length;i++){let s=t.children[i];s instanceof r.mp&&n(s,t.positions[i]+e)}};return n(m(t),0),i}get allowsNesting(){return!0}}function p(t,e,i){let n=t.facet(M),s=m(t).topNode;if(!n||n.allowsNesting)for(let o=s;o;o=o.enter(e,i,r.vj.ExcludeBuffers))o.type.isTop&&(s=o);return s}g.setState=o.Py.define();function m(t){let e=t.field(g.state,!1);return e?e.tree:r.mp.empty}class w{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let i=this.cursorPos-this.string.length;return t<i||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}}let v=null;class y{constructor(t,e,i=[],n,s,r,o,h){this.parser=t,this.state=e,this.fragments=i,this.tree=n,this.treeLen=s,this.viewport=r,this.skipped=o,this.scheduleOn=h,this.parse=null,this.tempSkipped=[]}static create(t,e,i){return new y(t,e,[],r.mp.empty,0,i,[],null)}startParse(){return this.parser.startParse(new w(this.state.doc),this.fragments)}work(t,e){return null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=r.mp.empty&&this.isDone(null!=e?e:this.state.doc.length)?(this.takeTree(),!0):this.withContext((()=>{var i;if("number"==typeof t){let e=Date.now()+t;t=()=>Date.now()>e}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 n=this.parse.advance();if(n){if(this.fragments=this.withoutTempSkipped(r.i9.addTree(n,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(i=this.parse.stoppedAt)&&void 0!==i?i:this.state.doc.length,this.tree=n,this.parse=null,!(this.treeLen<(null!=e?e:this.state.doc.length)))return!0;this.parse=this.startParse()}if(t())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((()=>{for(;!(e=this.parse.advance()););})),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(r.i9.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=v;v=this;try{return t()}finally{v=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=b(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:n,treeLen:s,viewport:o,skipped:h}=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=r.i9.applyChanges(i,e),n=r.mp.empty,s=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){h=[];for(let e of this.skipped){let i=t.mapPos(e.from,1),n=t.mapPos(e.to,-1);i<n&&h.push({from:i,to:n})}}}return new y(this.parser,e,i,n,s,o,h,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=b(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 r._b{createParse(e,i,n){let s=n[0].from,o=n[n.length-1].to;return{parsedPos:s,advance(){let e=v;if(e){for(let t of n)e.tempSkipped.push(t);t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}return this.parsedPos=o,new r.mp(r.Jq.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}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 v}}function b(t,e,i){return r.i9.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}class x{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)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 x(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=y.create(t.facet(M).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new x(i)}}g.state=o.QQ.define({create:x.init,update(t,e){for(let i of e.effects)if(i.is(g.setState))return i.value;return e.startState.facet(M)!=e.state.facet(M)?x.init(e.state):t.apply(e)}});let S=t=>{let e=setTimeout((()=>t()),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&(S=t=>{let e=-1,i=setTimeout((()=>{e=requestIdleCallback(t,{timeout:400})}),100);return()=>e<0?clearTimeout(i):cancelIdleCallback(e)});const k="undefined"!=typeof navigator&&(null===(s=navigator.scheduling)||void 0===s?void 0:s.isInputPending)?()=>navigator.scheduling.isInputPending():null,A=h.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(g.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(g.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=S(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(g.state);if(s.tree==s.context.tree&&s.context.isDone(n+1e5))return;let r=Date.now()+Math.min(this.chunkBudget,100,t&&!k?Math.max(25,t.timeRemaining()-5):1e9),o=s.context.treeLen<n&&i.doc.length>n+1e3,h=s.context.work((()=>k&&k()||Date.now()>r),n+(o?0:1e5));this.chunkBudget-=Date.now()-e,(h||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:g.setState.of(new x(s.context))})),this.chunkBudget>0&&(!h||o)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then((()=>this.scheduleWork())).catch((t=>(0,h.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()}}}),M=o.r$.define({combine(t){return t.length?t[0]:null},enables:t=>[g.state,A,h.tk.contentAttributes.compute([t],(e=>{let i=e.facet(t);return i&&i.name?{"data-language":i.name}:{}}))]});const C=o.r$.define(),O=o.r$.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some((t=>t!=e[0])))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function T(t){let e=t.facet(O);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function D(t,e){let i="",n=t.tabSize,s=t.facet(O)[0];if("\t"==s){for(;e>=n;)i+="\t",e-=n;s=" "}for(let r=0;r<e;r++)i+=s;return i}function E(t,e){t instanceof o.yy&&(t=new R(t));for(let n of t.state.facet(C)){let i=n(t,e);if(void 0!==i)return i}let i=m(t.state);return i?P(t,i,e):null}class R{constructor(t,e={}){this.state=t,this.options=e,this.unit=T(t)}lineAt(t,e=1){let i=this.state.doc.lineAt(t),{simulateBreak:n,simulateDoubleBreak:s}=this.options;return null!=n&&n>=i.from&&n<=i.to?s&&n==t?{text:"",from:t}:(e<0?n<t:n<=t)?{text:i.text.slice(n-i.from),from:n}:{text:i.text.slice(0,n-i.from),from:i.from}:i}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:i,from:n}=this.lineAt(t,e);return i.slice(t-n,Math.min(i.length,t+100-n))}column(t,e=1){let{text:i,from:n}=this.lineAt(t,e),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 B=new r.md;function P(t,e,i){return I(e.resolveInner(i).enterUnfinishedNodesBefore(i),i,t)}function L(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function N(t){let e=t.type.prop(B);if(e)return e;let i,n=t.firstChild;if(n&&(i=n.type.prop(r.md.closedBy))){let e=t.lastChild,n=e&&i.indexOf(e.name)>-1;return t=>z(t,!0,1,void 0,n&&!L(t)?e.from:void 0)}return null==t.parent?V:null}function I(t,e,i){for(;t;t=t.parent){let n=N(t);if(n)return n(H.create(i,e,t))}return null}function V(){return 0}class H extends R{constructor(t,e,i){super(t.state,t.options),this.base=t,this.pos=e,this.node=i}static create(t,e,i){return new H(t,e,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let e=this.state.doc.lineAt(t.from);for(;;){let i=t.resolve(e.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(W(i,t))break;e=this.state.doc.lineAt(i.from)}return this.lineIndent(e.from)}continue(){let t=this.node.parent;return t?I(t,this.pos,this.base):0}}function W(t,e){for(let i=e;i;i=i.parent)if(t==i)return!0;return!1}function F(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 h=i.to;;){let t=e.childAfter(h);if(!t||t==n)return null;if(!t.type.isSkipped)return t.from<o?i:null;h=t.to}}function z(t,e,i,n,s){let r=t.textAfter,o=r.match(/^\s*/)[0].length,h=n&&r.slice(o,o+n.length)==n||s==t.pos+o,l=e?F(t):null;return l?h?t.column(l.from):t.column(l.to):t.baseIndent+(h?0:t.unit*i)}h.SJ;class _{constructor(t,e){let i;function n(t){let e=a.V.newName();return(i||Object.create(null))["."+e]=t,e}this.specs=t;const s="string"==typeof e.all?e.all:e.all?n(e.all):void 0,r=e.scope;this.scope=r instanceof g?t=>t.prop(f)==r.data:r?t=>t==r:void 0,this.style=(0,l.QR)(t.map((t=>({tag:t.tag,class:t.class||n(Object.assign({},t,{tag:null}))}))),{all:s}).style,this.module=i?new a.V(i):null,this.themeType=e.themeType}static define(t,e){return new _(t,e||{})}}l.pJ.meta,l.pJ.link,l.pJ.heading,l.pJ.emphasis,l.pJ.strong,l.pJ.strikethrough,l.pJ.keyword,l.pJ.atom,l.pJ.bool,l.pJ.url,l.pJ.contentSeparator,l.pJ.labelName,l.pJ.literal,l.pJ.inserted,l.pJ.string,l.pJ.deleted,l.pJ.regexp,l.pJ.escape,l.pJ.string,l.pJ.variableName,l.pJ.variableName,l.pJ.typeName,l.pJ.namespace,l.pJ.className,l.pJ.variableName,l.pJ.macroName,l.pJ.propertyName,l.pJ.comment,l.pJ.invalid;const j=1e4,q="()[]{}";const $=new r.md;function K(t,e,i){let n=t.prop(e<0?r.md.openedBy:r.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 J(t){let e=t.type.prop($);return e?e(t.node):t}function G(t,e,i,n={}){let s=n.maxScanDistance||j,r=n.brackets||q,o=m(t),h=o.resolveInner(e,i);for(let l=h;l;l=l.parent){let n=K(l.type,i,r);if(n&&l.from<l.to){let s=J(l);if(s&&(i>0?e>=s.from&&e<s.to:e>s.from&&e<=s.to))return U(t,e,i,l,s,n,r)}}return X(t,e,i,o,h.type,s,r)}function U(t,e,i,n,s,r,o){let h=n.parent,l={from:s.from,to:s.to},a=0,c=null==h?void 0:h.cursor();if(c&&(i<0?c.childBefore(n.from):c.childAfter(n.to)))do{if(i<0?c.to<=n.from:c.from>=n.to){if(0==a&&r.indexOf(c.type.name)>-1&&c.from<c.to){let t=J(c);return{start:l,end:t?{from:t.from,to:t.to}:void 0,matched:!0}}if(K(c.type,i,o))a++;else if(K(c.type,-i,o)){if(0==a){let t=J(c);return{start:l,end:t&&t.from<t.to?{from:t.from,to:t.to}:void 0,matched:!1}}a--}}}while(i<0?c.prevSibling():c.nextSibling());return{start:l,matched:!1}}function X(t,e,i,n,s,r,o){let h=i<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),l=o.indexOf(h);if(l<0||l%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 f=0;!c.next().done&&f<=r;){let t=c.value;i<0&&(f+=t.length);let r=e+f*i;for(let e=i>0?0:t.length-1,h=i>0?t.length:-1;e!=h;e+=i){let h=o.indexOf(t[e]);if(!(h<0||n.resolveInner(r+e,1).type!=s))if(h%2==0==i>0)u++;else{if(1==u)return{start:a,end:{from:r+e,to:r+e+1},matched:h>>1==l>>1};u--}}i>0&&(f+=t.length)}return c.done?{start:a,matched:!1}:null}const Y=Object.create(null),Q=[r.Jq.none],Z=[],tt=Object.create(null);for(let[nt,st]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])tt[nt]=it(Y,st);function et(t,e){Z.indexOf(t)>-1||(Z.push(t),console.warn(e))}function it(t,e){let i=null;for(let r of e.split(".")){let e=t[r]||l.pJ[r];e?"function"==typeof e?i?i=e(i):et(r,`Modifier ${r} used at start of tag`):i?et(r,`Tag ${r} used as modifier`):i=e:et(r,`Unknown highlighting tag ${r}`)}if(!i)return 0;let n=e.replace(/ /g,"_"),s=r.Jq.define({id:Q.length,name:n,props:[(0,l.Gv)({[n]:i})]});return Q.push(s),s.id}n()}catch(u){n(u)}}))},95652:function(t,e,i){i.d(e,{BO:function(){return Ct},D0:function(){return xt},Gz:function(){return qt},IS:function(){return jt},Py:function(){return dt},QQ:function(){return q},Wl:function(){return X},Xs:function(){return Rt},YW:function(){return gt},as:function(){return C},cp:function(){return m},f_:function(){return Bt},gc:function(){return A},jT:function(){return L},q6:function(){return ct},r$:function(){return V},uU:function(){return Ot},xv:function(){return n},yy:function(){return Mt}});i(63721),i(52247),i(71695),i(92745),i(52805),i(61495),i(61893),i(23669),i(69235),i(12385),i(19134),i(32517),i(5740),i(11740),i(92519),i(42179),i(89256),i(24931),i(88463),i(57449),i(19814),i(97003),i(32114),i(39527),i(92181),i(99790),i(67670),i(41360),i(13334),i(34595),i(36993),i(47021);class n{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),r.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),r.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 l(this),s=new l(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 l(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 c(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}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 s(t):r.from(s.split(t,[])):n.empty}}class s extends n{constructor(t,e=function(t){let e=-1;for(let i of t)e+=i.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.text[s],o=n+r.length;if((e?i:o)>=t)return new u(n,o,i,r);n=o+1,i++}}decompose(t,e,i,n){let r=t<=0&&e>=this.length?this:new s(h(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&n){let t=i.pop(),e=o(r.text,t.text.slice(),0,r.length);if(e.length<=32)i.push(new s(e,t.length+r.length));else{let t=e.length>>1;i.push(new s(e.slice(0,t)),new s(e.slice(t)))}}else i.push(r)}replace(t,e,i){if(!(i instanceof s))return super.replace(t,e,i);let n=o(this.text,o(i.text,h(this.text,0,t)),e),l=this.length+i.length-(e-t);return n.length<=32?new s(n,l):r.from(s.split(n,[]),l)}sliceString(t,e=this.length,i="\n"){let n="";for(let s=0,r=0;s<=e&&r<this.text.length;r++){let o=this.text[r],h=s+o.length;s>t&&r&&(n+=i),t<h&&e>s&&(n+=o.slice(Math.max(0,t-s),e-s)),s=h+1}return n}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],n=-1;for(let r of t)i.push(r),n+=r.length+1,32==i.length&&(e.push(new s(i,n)),i=[],n=-1);return n>-1&&e.push(new s(i,n)),e}}class r extends n{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,h=i+r.lines-1;if((e?h:o)>=t)return r.lineInner(t,e,i,n);n=o+1,i=h+1}}decompose(t,e,i,n){for(let s=0,r=0;r<=e&&s<this.children.length;s++){let o=this.children[s],h=r+o.length;if(t<=h&&e>=r){let s=n&((r<=t?1:0)|(h>=e?2:0));r>=t&&h<=e&&!s?i.push(o):o.decompose(t-r,e-r,i,s)}r=h+1}}replace(t,e,i){if(i.lines<this.lines)for(let n=0,s=0;n<this.children.length;n++){let o=this.children[n],h=s+o.length;if(t>=s&&e<=h){let l=o.replace(t-s,e-s,i),a=this.lines-o.lines+l.lines;if(l.lines<a>>4&&l.lines>a>>6){let s=this.children.slice();return s[n]=l,new r(s,this.length-(e-t)+i.length)}return super.replace(s,h,l)}s=h+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i="\n"){let n="";for(let s=0,r=0;s<this.children.length&&r<=e;s++){let o=this.children[s],h=r+o.length;r>t&&s&&(n+=i),t<h&&e>r&&(n+=o.sliceString(t-r,e-r,i)),r=h+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof r))return 0;let i=0,[n,s,o,h]=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==o||s==h)return i;let r=this.children[n],l=t.children[s];if(r!=l)return i+r.scanIdentical(l,e);i+=r.length+1}}static from(t,e=t.reduce(((t,e)=>t+e.length+1),-1)){let i=0;for(let s of t)i+=s.lines;if(i<32){let i=[];for(let e of t)e.flatten(i);return new s(i,e)}let n=Math.max(32,i>>5),o=n<<1,h=n>>1,l=[],a=0,c=-1,u=[];function f(t){let e;if(t.lines>o&&t instanceof r)for(let i of t.children)f(i);else t.lines>h&&(a>h||!a)?(d(),l.push(t)):t instanceof s&&a&&(e=u[u.length-1])instanceof s&&t.lines+e.lines<=32?(a+=t.lines,c+=t.length+1,u[u.length-1]=new s(e.text.concat(t.text),e.length+1+t.length)):(a+t.lines>n&&d(),a+=t.lines,c+=t.length+1,u.push(t))}function d(){0!=a&&(l.push(1==u.length?u[0]:r.from(u,c)),c=-1,a=u.length=0)}for(let s of t)f(s);return d(),1==l.length?l[0]:new r(l,e)}}function o(t,e,i=0,n=1e9){for(let s=0,r=0,o=!0;r<t.length&&s<=n;r++){let h=t[r],l=s+h.length;l>=i&&(l>n&&(h=h.slice(0,n-s)),s<i&&(h=h.slice(i-s)),o?(e[e.length-1]+=h,o=!1):e.push(h)),s=l+1}return e}function h(t,e,i){return o(t,[""],e,i)}n.empty=new s([""],0);class l{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 s?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],r=this.offsets[i],o=r>>1,h=n instanceof s?n.text.length:n.children.length;if(o==(e>0?h: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&r)==(e>0?0:1)){if(this.offsets[i]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(n instanceof s){let s=n.text[o+(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 r=n.children[o+(e<0?-1:0)];t>r.length?(t-=r.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(r),this.offsets.push(e>0?1:(r instanceof s?r.text.length:r.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 l(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 c{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&&(n.prototype[Symbol.iterator]=function(){return this.iter()},l.prototype[Symbol.iterator]=a.prototype[Symbol.iterator]=c.prototype[Symbol.iterator]=function(){return this});class u{constructor(t,e,i,n){this.from=t,this.to=e,this.number=i,this.text=n}get length(){return this.to-this.from}}let f="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 Kt=1;Kt<f.length;Kt++)f[Kt]+=f[Kt-1];function d(t){for(let e=1;e<f.length;e+=2)if(f[e]>t)return f[e-1]<=t;return!1}function g(t){return t>=127462&&t<=127487}const p=8205;function m(t,e,i=!0,n=!0){return(i?w:v)(t,e,n)}function w(t,e,i){if(e==t.length)return e;e&&y(t.charCodeAt(e))&&b(t.charCodeAt(e-1))&&e--;let n=x(t,e);for(e+=S(n);e<t.length;){let s=x(t,e);if(n==p||s==p||i&&d(s))e+=S(s),n=s;else{if(!g(s))break;{let i=0,n=e-2;for(;n>=0&&g(x(t,n));)i++,n-=2;if(i%2==0)break;e+=2}}}return e}function v(t,e,i){for(;e>0;){let n=w(t,e-2,i);if(n<e)return n;e--}return 0}function y(t){return t>=56320&&t<57344}function b(t){return t>=55296&&t<56320}function x(t,e){let i=t.charCodeAt(e);if(!b(i)||e+1==t.length)return i;let n=t.charCodeAt(e+1);return y(n)?n-56320+(i-55296<<10)+65536:i}function S(t){return t<65536?1:2}const k=/\r\n?|\n/;var A=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(A||(A={}));class M{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){D(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 M(t)}composeDesc(t){return this.empty?t:t.empty?this:R(this,t)}mapDesc(t,e=!1){return t.empty?this:E(this,t,e)}mapPos(t,e=-1,i=A.Simple){let n=0,s=0;for(let r=0;r<this.sections.length;){let o=this.sections[r++],h=this.sections[r++],l=n+o;if(h<0){if(l>t)return s+(t-n);s+=o}else{if(i!=A.Simple&&l>=t&&(i==A.TrackDel&&n<t&&l>t||i==A.TrackBefore&&n<t||i==A.TrackAfter&&l>t))return null;if(l>t||l==t&&e<0&&!o)return t==n||e<0?s:s+h;s+=h}n=l}if(t>n)throw new RangeError(`Position ${t} is out of range for changeset of length ${n}`);return s}touchesRange(t,e=t){for(let i=0,n=0;i<this.sections.length&&n<=e;){let s=n+this.sections[i++];if(this.sections[i++]>=0&&n<=e&&s>=t)return!(n<t&&s>e)||"cover";n=s}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];t+=(t?" ":"")+i+(n>=0?":"+n:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some((t=>"number"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeDesc");return new M(t)}static create(t){return new M(t)}}class C extends M{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 D(this,((e,i,n,s,r)=>t=t.replace(n,n+(i-e),r)),!1),t}mapDesc(t,e=!1){return E(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let s=0,r=0;s<e.length;s+=2){let o=e[s],h=e[s+1];if(h>=0){e[s]=h,e[s+1]=o;let l=s>>1;for(;i.length<l;)i.push(n.empty);i.push(o?t.slice(r,r+o):n.empty)}r+=o}return new C(e,i)}compose(t){return this.empty?t:t.empty?this:R(this,t,!0)}map(t,e=!1){return t.empty?this:E(this,t,e,!0)}iterChanges(t,e=!1){D(this,t,e)}get desc(){return M.create(this.sections)}filter(t){let e=[],i=[],n=[],s=new B(this);t:for(let r=0,o=0;;){let h=r==t.length?1e9:t[r++];for(;o<h||o==h&&0==s.len;){if(s.done)break t;let t=Math.min(s.len,h-o);O(n,t,-1);let r=-1==s.ins?-1:0==s.off?s.ins:0;O(e,t,r),r>0&&T(i,e,s.text),s.forward(t),o+=t}let l=t[r++];for(;o<l;){if(s.done)break t;let t=Math.min(s.len,l-o);O(e,t,-1),O(n,t,-1==s.ins?-1:0==s.off?s.ins:0),s.forward(t),o+=t}}return{changes:new C(e,i),filtered:M.create(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 s=[],r=[],o=0,h=null;function l(t=!1){if(!t&&!s.length)return;o<e&&O(s,e-o,-1);let i=new C(s,r);h=h?h.compose(i.map(h)):i,s=[],r=[],o=0}return function t(a){if(Array.isArray(a))for(let e of a)t(e);else if(a instanceof C){if(a.length!=e)throw new RangeError(`Mismatched change set length (got ${a.length}, expected ${e})`);l(),h=h?h.compose(a.map(h)):a}else{let{from:t,to:h=t,insert:c}=a;if(t>h||t<0||h>e)throw new RangeError(`Invalid change range ${t} to ${h} (in doc of length ${e})`);let u=c?"string"==typeof c?n.of(c.split(i||k)):c:n.empty,f=u.length;if(t==h&&0==f)return;t<o&&l(),t>o&&O(s,t-o,-1),O(s,h-t,f),T(r,s,u),o=h}}(t),l(!h),h}static empty(t){return new C(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],i=[];for(let s=0;s<t.length;s++){let r=t[s];if("number"==typeof r)e.push(r,-1);else{if(!Array.isArray(r)||"number"!=typeof r[0]||r.some(((t,e)=>e&&"string"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==r.length)e.push(r[0],0);else{for(;i.length<s;)i.push(n.empty);i[s]=n.of(r.slice(1)),e.push(r[0],i[s].length)}}}return new C(e,i)}static createSet(t,e){return new C(t,e)}}function O(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 T(t,e,i){if(0==i.length)return;let s=e.length-2>>1;if(s<t.length)t[t.length-1]=t[t.length-1].append(i);else{for(;t.length<s;)t.push(n.empty);t.push(i)}}function D(t,e,i){let s=t.inserted;for(let r=0,o=0,h=0;h<t.sections.length;){let l=t.sections[h++],a=t.sections[h++];if(a<0)r+=l,o+=l;else{let c=r,u=o,f=n.empty;for(;c+=l,u+=a,a&&s&&(f=f.append(s[h-2>>1])),!(i||h==t.sections.length||t.sections[h+1]<0);)l=t.sections[h++],a=t.sections[h++];e(r,c,o,u,f),r=c,o=u}}}function E(t,e,i,n=!1){let s=[],r=n?[]:null,o=new B(t),h=new B(e);for(let l=-1;;)if(-1==o.ins&&-1==h.ins){let t=Math.min(o.len,h.len);O(s,t,-1),o.forward(t),h.forward(t)}else if(h.ins>=0&&(o.ins<0||l==o.i||0==o.off&&(h.len<o.len||h.len==o.len&&!i))){let t=h.len;for(O(s,h.ins,-1);t;){let e=Math.min(o.len,t);o.ins>=0&&l<o.i&&o.len<=e&&(O(s,0,o.ins),r&&T(r,s,o.text),l=o.i),o.forward(e),t-=e}h.next()}else{if(!(o.ins>=0)){if(o.done&&h.done)return r?C.createSet(s,r):M.create(s);throw new Error("Mismatched change set lengths")}{let t=0,e=o.len;for(;e;)if(-1==h.ins){let i=Math.min(e,h.len);t+=i,e-=i,h.forward(i)}else{if(!(0==h.ins&&h.len<e))break;e-=h.len,h.next()}O(s,t,l<o.i?o.ins:0),r&&l<o.i&&T(r,s,o.text),l=o.i,o.forward(o.len-e)}}}function R(t,e,i=!1){let n=[],s=i?[]:null,r=new B(t),o=new B(e);for(let h=!1;;){if(r.done&&o.done)return s?C.createSet(n,s):M.create(n);if(0==r.ins)O(n,r.len,0,h),r.next();else if(0!=o.len||o.done){if(r.done||o.done)throw new Error("Mismatched change set lengths");{let t=Math.min(r.len2,o.len),e=n.length;if(-1==r.ins){let e=-1==o.ins?-1:o.off?0:o.ins;O(n,t,e,h),s&&e&&T(s,n,o.text)}else-1==o.ins?(O(n,r.off?0:r.len,t,h),s&&T(s,n,r.textBit(t))):(O(n,r.off?0:r.len,o.off?0:o.ins,h),s&&!o.off&&T(s,n,o.text));h=(r.ins>t||o.ins>=0&&o.len>t)&&(h||n.length>e),r.forward2(t),o.forward(t)}}else O(n,0,o.ins,h),s&&T(s,n,o.text),o.next()}}class B{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.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?n.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,n;return this.empty?i=n=t.mapPos(this.from,e):(i=t.mapPos(this.from,1),n=t.mapPos(this.to,-1)),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 L.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return L.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 L.range(t.anchor,t.head)}static create(t,e,i){return new P(t,e,i)}}class L{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:L.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 L([this.main],0)}addRange(t,e=!0){return L.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,L.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 L(t.ranges.map((t=>P.fromJSON(t))),t.main)}static single(t,e=t){return new L([L.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 L.normalized(t.slice(),e);i=s.to}return new L(t,e)}static cursor(t,e=0,i,n){return P.create(t,t,(0==e?0:e<0?4:8)|(null==i?3:Math.min(2,i))|(null!=n?n:33554431)<<5)}static range(t,e,i,n){let s=(null!=i?i:33554431)<<5|(null==n?3:Math.min(2,n));return e<t?P.create(e,t,24|s):P.create(t,e,(e>t?4:0)|s)}static normalized(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?L.range(o,r):L.range(r,o))}}return new L(t,e)}}function N(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let I=0;class V{constructor(t,e,i,n,s){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=I++,this.default=t([]),this.extensions="function"==typeof s?s(this):s}static define(t={}){return new V(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:H),!!t.static,t.enables)}of(t){return new W([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new W(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new W(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],(i=>e(i.field(t))))}}function H(t,e){return t==e||t.length==e.length&&t.every(((t,i)=>t===e[i]))}class W{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=I++}dynamicSlot(t){var e;let i=this.value,n=this.facet.compareInput,s=this.id,r=t[s]>>1,o=2==this.type,h=!1,l=!1,a=[];for(let c of this.dependencies)"doc"==c?h=!0:"selection"==c?l=!0:1&(null!==(e=t[c.id])&&void 0!==e?e:1)||a.push(t[c.id]);return{create(t){return t.values[r]=i(t),1},update(t,e){if(h&&e.docChanged||l&&(e.docChanged||e.selection)||z(t,a)){let e=i(t);if(o?!F(e,t.values[r],n):!n(e,t.values[r]))return t.values[r]=e,1}return 0},reconfigure:(t,e)=>{let h,l=e.config.address[s];if(null!=l){let s=it(e,l);if(this.dependencies.every((i=>i instanceof V?e.facet(i)===t.facet(i):!(i instanceof q)||e.field(i,!1)==t.field(i,!1)))||(o?F(h=i(t),s,n):n(h=i(t),s)))return t.values[r]=s,0}else h=i(t);return t.values[r]=h,1}}}}function F(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 z(t,e){let i=!1;for(let n of e)1&et(t,n)&&(i=!0);return i}function _(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;function h(t){let i=[];for(let e=0;e<n.length;e++){let r=it(t,n[e]);if(2==s[e])for(let t of r)i.push(t);else i.push(r)}return e.combine(i)}return{create(t){for(let e of n)et(t,e);return t.values[o]=h(t),1},update(t,i){if(!z(t,r))return 0;let n=h(t);return e.compare(n,t.values[o])?0:(t.values[o]=n,1)},reconfigure(t,s){let r=z(t,n),l=s.config.facets[e.id],a=s.facet(e);if(l&&!r&&H(i,l))return t.values[o]=a,0;let c=h(t);return e.compare(c,a)?(t.values[o]=a,0):(t.values[o]=c,1)}}}const j=V.define({static:!0});class q{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 q(I++,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(j).find((t=>t.field==this));return((null==e?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:t=>(t.values[e]=this.create(t),1),update:(t,i)=>{let n=t.values[e],s=this.updateF(n,i);return this.compareF(n,s)?0:(t.values[e]=s,1)},reconfigure:(t,i)=>null!=i.config.address[this.id]?(t.values[e]=i.field(this),0):(t.values[e]=this.create(t),1)}}init(t){return[this,j.of({field:this,create:t})]}get extension(){return this}}const $=4,K=3,J=2,G=1;function U(t){return e=>new Y(e,t)}const X={highest:U(0),high:U(G),default:U(J),low:U(K),lowest:U($)};class Y{constructor(t,e){this.inner=t,this.prec=e}}class Q{of(t){return new Z(this,t)}reconfigure(t){return Q.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class Z{constructor(t,e){this.compartment=t,this.inner=e}}class tt{constructor(t,e,i,n,s,r){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=s,this.facets=r,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return null==e?t.default:this.staticValues[e>>1]}static resolve(t,e,i){let n=[],s=Object.create(null),r=new Map;for(let u of function(t,e,i){let n=[[],[],[],[],[]],s=new Map;function r(t,o){let h=s.get(t);if(null!=h){if(h<=o)return;let e=n[h].indexOf(t);e>-1&&n[h].splice(e,1),t instanceof Z&&i.delete(t.compartment)}if(s.set(t,o),Array.isArray(t))for(let e of t)r(e,o);else if(t instanceof Z){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 Y)r(t.inner,t.prec);else if(t instanceof q)n[o].push(t),t.provides&&r(t.provides,o);else if(t instanceof W)n[o].push(t),t.facet.extensions&&r(t.facet.extensions,J);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,J),n.reduce(((t,e)=>t.concat(e)))}(t,e,r))u instanceof q?n.push(u):(s[u.facet.id]||(s[u.facet.id]=[])).push(u);let o=Object.create(null),h=[],l=[];for(let u of n)o[u.id]=l.length<<1,l.push((t=>u.slot(t)));let a=null==i?void 0:i.config.facets;for(let u in s){let t=s[u],e=t[0].facet,n=a&&a[u]||[];if(t.every((t=>0==t.type)))if(o[e.id]=h.length<<1|1,H(n,t))h.push(i.facet(e));else{let n=e.combine(t.map((t=>t.value)));h.push(i&&e.compare(n,i.facet(e))?i.facet(e):n)}else{for(let e of t)0==e.type?(o[e.id]=h.length<<1|1,h.push(e.value)):(o[e.id]=l.length<<1,l.push((t=>e.dynamicSlot(t))));o[e.id]=l.length<<1,l.push((i=>_(i,e,t)))}}let c=l.map((t=>t(o)));return new tt(t,r,c,o,h,s)}}function et(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.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|s}function it(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const nt=V.define(),st=V.define({combine:t=>t.some((t=>t)),static:!0}),rt=V.define({combine:t=>t.length?t[0]:void 0,static:!0}),ot=V.define(),ht=V.define(),lt=V.define(),at=V.define({combine:t=>!!t.length&&t[0]});class ct{constructor(t,e){this.type=t,this.value=e}static define(){return new ut}}class ut{of(t){return new ct(this,t)}}class ft{constructor(t){this.map=t}of(t){return new dt(this,t)}}class dt{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 dt(this.type,e)}is(t){return this.type==t}static define(t={}){return new ft(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}}dt.reconfigure=dt.define(),dt.appendConfig=dt.define();class gt{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&&N(i,e.newLength),s.some((t=>t.type==gt.time))||(this.annotations=s.concat(gt.time.of(Date.now())))}static create(t,e,i,n,s,r){return new gt(t,e,i,n,s,r)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(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(gt.userEvent);return!(!e||!(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function pt(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 mt(t,e,i){var n;let s,r,o;return i?(s=e.changes,r=C.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:dt.mapEffects(t.effects,s).concat(dt.mapEffects(e.effects,r)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function wt(t,e,i){let n=e.selection,s=bt(e.annotations);return e.userEvent&&(s=s.concat(gt.userEvent.of(e.userEvent))),{changes:e.changes instanceof C?e.changes:C.of(e.changes||[],i,t.facet(rt)),selection:n&&(n instanceof L?n:L.single(n.anchor,n.head)),effects:bt(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function vt(t,e,i){let n=wt(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=mt(n,wt(t,e[r],s?n.changes.newLength:t.doc.length),s)}let s=gt.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return function(t){let e=t.startState,i=e.facet(lt),n=t;for(let s=i.length-1;s>=0;s--){let r=i[s](t);r&&Object.keys(r).length&&(n=mt(n,wt(e,r,t.changes.newLength),!0))}return n==t?t:gt.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}(i?function(t){let e=t.startState,i=!0;for(let s of e.facet(ot)){let e=s(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:pt(i,e))}if(!0!==i){let n,s;if(!1===i)s=t.changes.invertedDesc,n=C.empty(e.doc.length);else{let e=t.changes.filter(i);n=e.changes,s=e.filtered.mapDesc(e.changes).invertedDesc}t=gt.create(e,n,t.selection&&t.selection.map(s),dt.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let n=e.facet(ht);for(let s=n.length-1;s>=0;s--){let i=n[s](t);t=i instanceof gt?i:Array.isArray(i)&&1==i.length&&i[0]instanceof gt?i[0]:vt(e,bt(i),!1)}return t}(s):s)}gt.time=ct.define(),gt.userEvent=ct.define(),gt.addToHistory=ct.define(),gt.remote=ct.define();const yt=[];function bt(t){return null==t?yt:Array.isArray(t)?t:[t]}var xt=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(xt||(xt={}));const St=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let kt;try{kt=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch($t){}function At(t){return e=>{if(!/\S/.test(e))return xt.Space;if(function(t){if(kt)return kt.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}(e))return xt.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return xt.Word;return xt.Other}}class Mt{constructor(t,e,i,n,s,r){this.config=t,this.doc=e,this.selection=i,this.values=n,this.status=t.statusTemplate.slice(),this.computeSlot=s,r&&(r._state=this);for(let o=0;o<this.config.dynamicSlots.length;o++)et(this,o<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(null!=i)return et(this,i),it(this,i);if(e)throw new RangeError("Field is not present in this state")}update(...t){return vt(this,t,!0)}applyTransaction(t){let e,i=this.config,{base:n,compartments:s}=i;for(let r of t.effects)r.is(Q.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(dt.reconfigure)?(i=null,n=r.value):r.is(dt.appendConfig)&&(i=null,n=bt(n).concat(r.value));if(i)e=t.startState.values.slice();else{i=tt.resolve(n,s,this),e=new Mt(i,this.doc,this.selection,i.dynamicSlots.map((()=>null)),((t,e)=>e.reconfigure(t,this)),null).values}new Mt(i,t.newDoc,t.newSelection,e,((e,i)=>i.update(e,t)),t)}replaceSelection(t){return"string"==typeof t&&(t=this.toText(t)),this.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:t},range:L.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=bt(i.effects);for(let o=1;o<e.ranges.length;o++){let i=t(e.ranges[o]),h=this.changes(i.changes),l=h.map(n);for(let t=0;t<o;t++)s[t]=s[t].map(l);let a=n.mapDesc(h,!0);s.push(i.range.map(a)),n=n.compose(l),r=dt.mapEffects(r,l).concat(dt.mapEffects(bt(i.effects),a))}return{changes:n,selection:L.create(s,e.mainIndex),effects:r}}changes(t=[]){return t instanceof C?t:C.of(t,this.doc.length,this.facet(Mt.lineSeparator))}toText(t){return n.of(t.split(this.facet(Mt.lineSeparator)||k))}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:(et(this,e),it(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 q&&null!=this.config.address[n.id]&&(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)if(Object.prototype.hasOwnProperty.call(t,s)){let e=i[s],r=t[s];n.push(e.init((t=>e.spec.fromJSON(r,t))))}return Mt.create({doc:t.doc,selection:L.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let e=tt.resolve(t.extensions||[],new Map),i=t.doc instanceof n?t.doc:n.of((t.doc||"").split(e.staticFacet(Mt.lineSeparator)||k)),s=t.selection?t.selection instanceof L?t.selection:L.single(t.selection.anchor,t.selection.head):L.single(0);return N(s,i.length),e.staticFacet(st)||(s=s.asSingle()),new Mt(e,i,s,e.dynamicSlots.map((()=>null)),((t,e)=>e.create(t)),null)}get tabSize(){return this.facet(Mt.tabSize)}get lineBreak(){return this.facet(Mt.lineSeparator)||"\n"}get readOnly(){return this.facet(at)}phrase(t,...e){for(let i of this.facet(Mt.phrases))if(Object.prototype.hasOwnProperty.call(i,t)){t=i[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,((t,i)=>{if("$"==i)return"$";let n=+(i||1);return!n||n>e.length?t:e[n-1]}))),t}languageDataAt(t,e,i=-1){let n=[];for(let s of this.facet(nt))for(let r of s(this,e,i))Object.prototype.hasOwnProperty.call(r,t)&&n.push(r[t]);return n}charCategorizer(t){return At(this.languageDataAt("wordChars",t).join(""))}wordAt(t){let{text:e,from:i,length:n}=this.doc.lineAt(t),s=this.charCategorizer(t),r=t-i,o=t-i;for(;r>0;){let t=m(e,r,!1);if(s(e.slice(t,r))!=xt.Word)break;r=t}for(;o<n;){let t=m(e,o);if(s(e.slice(o,t))!=xt.Word)break;o=t}return r==o?null:L.range(r+i,o+i)}}function Ct(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}Mt.allowMultipleSelections=st,Mt.tabSize=V.define({combine:t=>t.length?t[0]:4}),Mt.lineSeparator=rt,Mt.readOnly=at,Mt.phrases=V.define({compare(t,e){let i=Object.keys(t),n=Object.keys(e);return i.length==n.length&&i.every((i=>t[i]==e[i]))}}),Mt.languageData=nt,Mt.changeFilter=ot,Mt.transactionFilter=ht,Mt.transactionExtender=lt,Q.reconfigure=dt.define();class Ot{eq(t){return this==t}range(t,e=t){return Tt.create(t,e,this)}}Ot.prototype.startSide=Ot.prototype.endSide=0,Ot.prototype.point=!1,Ot.prototype.mapMode=A.TrackDel;class Tt{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new Tt(t,e,i)}}function Dt(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Et{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,h=s[n]-t||(i?this.value[n].endSide:this.value[n].startSide)-e;if(n==r)return h>=0?r:o;h>=0?o=n:r=n+1}}between(t,e,i,n){for(let s=this.findIndex(e,-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 h=0;h<this.value.length;h++){let l,a,c=this.value[h],u=this.from[h]+t,f=this.to[h]+t;if(u==f){let t=e.mapPos(u,c.startSide,c.mapMode);if(null==t)continue;if(l=a=t,c.startSide!=c.endSide&&(a=e.mapPos(u,c.endSide),a<l))continue}else if(l=e.mapPos(u,c.startSide),a=e.mapPos(f,c.endSide),l>a||l==a&&c.startSide>0&&c.endSide<=0)continue;(a-l||c.endSide-c.startSide)<0||(r<0&&(r=l),c.point&&(o=Math.max(o,a-l)),i.push(c),n.push(l-r),s.push(a-r))}return{mapped:i.length?new Et(n,s,i,o):null,pos:r}}}class Rt{constructor(t,e,i,n){this.chunkPos=t,this.chunk=e,this.nextLayer=i,this.maxPoint=n}static create(t,e,i,n){return new Rt(t,e,i,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,r=t.filter;if(0==e.length&&!r)return this;if(i&&(e=e.slice().sort(Dt)),this.isEmpty)return e.length?Rt.of(e):this;let o=new Lt(this,null,-1).goto(0),h=0,l=[],a=new Bt;for(;o.value||h<e.length;)if(h<e.length&&(o.from-e[h].from||o.startSide-e[h].value.startSide)>=0){let t=e[h++];a.addInner(t.from,t.to,t.value)||l.push(t)}else 1==o.rangeIndex&&o.chunkIndex<this.chunk.length&&(h==e.length||this.chunkEnd(o.chunkIndex)<e[h].from)&&(!r||n>this.chunkEnd(o.chunkIndex)||s<this.chunkPos[o.chunkIndex])&&a.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!r||n>o.to||s<o.from||r(o.from,o.to,o.value))&&(a.addInner(o.from,o.to,o.value)||l.push(Tt.create(o.from,o.to,o.value))),o.next());return a.finishInner(this.nextLayer.isEmpty&&!l.length?Rt.empty:this.nextLayer.update({add:l,filter:r,filterFrom:n,filterTo:s}))}map(t){if(t.empty||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],h=t.touchesRange(s,s+o.length);if(!1===h)n=Math.max(n,o.maxPoint),e.push(o),i.push(t.mapPos(s));else if(!0===h){let{mapped:r,pos:h}=o.map(s,t);r&&(n=Math.max(n,r.maxPoint),e.push(r),i.push(h))}}let s=this.nextLayer.map(t);return 0==e.length?s:new Rt(i,e,s||Rt.empty,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 Nt.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return Nt.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)),h=Pt(r,o,i),l=new Vt(r,h,s),a=new Vt(o,h,s);i.iterGaps(((t,e,i)=>Ht(l,t,a,e,i,n))),i.empty&&0==i.length&&Ht(l,0,a,0,0,n)}static eq(t,e,i=0,n){null==n&&(n=999999999);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=Pt(s,r),h=new Vt(s,o,0).goto(i),l=new Vt(r,o,0).goto(i);for(;;){if(h.to!=l.to||!Wt(h.active,l.active)||h.point&&(!l.point||!h.point.eq(l.point)))return!1;if(h.to>n)return!0;h.next(),l.next()}}static spans(t,e,i,n,s=-1){let r=new Vt(t,null,s).goto(e),o=e,h=r.openStart;for(;;){let t=Math.min(r.to,i);if(r.point){let i=r.activeForPoint(r.to),s=r.pointFrom<e?i.length+1:Math.min(i.length,h);n.point(o,t,r.point,i,s,r.pointRank),h=Math.min(r.openEnd(t),i.length)}else t>o&&(n.span(o,t,r.active,h),h=r.openEnd(t));if(r.to>i)return h+(r.point&&r.to>i?1:0);o=r.to,r.next()}}static of(t,e=!1){let i=new Bt;for(let n of t instanceof Tt?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let n=t[i];if(Dt(e,n)>0)return t.slice().sort(Dt);e=n}return t}(t):t)i.add(n.from,n.to,n.value);return i.finish()}}Rt.empty=new Rt([],[],null,-1),Rt.empty.nextLayer=Rt.empty;class Bt{finishChunk(t){this.chunks.push(new Et(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=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(t,e,i){this.addInner(t,e,i)||(this.nextLayer||(this.nextLayer=new Bt)).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(Rt.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=Rt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function Pt(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.touchesRange(e,e+r.chunk[t].length))||s.add(r.chunk[t])}return s}class Lt{constructor(t,e,i,n=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex<this.layer.chunk.length;){let e=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(e)||this.layer.chunkEnd(this.chunkIndex)<t||e.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}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)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=t}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.rank-t.rank||this.to-t.to||this.endSide-t.endSide}}class Nt{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 Lt(r,e,i,s));return 1==n.length?n[0]:new Nt(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--)It(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--)It(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(),It(this.heap,0)}}}function It(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 Vt{constructor(t,e,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Nt.from(t,e,i)}goto(t,e=-1e9){return this.cursor.goto(t,e),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=t,this.endSide=e,this.openStart=-1,this.next(),this}forward(t,e){for(;this.minActive>-1&&(this.activeTo[this.minActive]-t||this.active[this.minActive].endSide-e)<0;)this.removeActive(this.minActive);this.cursor.forward(t,e)}removeActive(t){Ft(this.active,t),Ft(this.activeTo,t),Ft(this.activeRank,t),this.minActive=_t(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:n,rank:s}=this.cursor;for(;e<this.activeRank.length&&this.activeRank[e]<=s;)e++;zt(this.active,e,i),zt(this.activeTo,e,n),zt(this.activeRank,e,s),t&&zt(t,e,this.cursor.from),this.minActive=_t(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>t){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&Ft(i,n)}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 t=this.cursor.value;if(t.point){if(!(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=t,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=t.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(i),this.cursor.next()}}}if(i){this.openStart=0;for(let e=i.length-1;e>=0&&i[e]<t;e--)this.openStart++}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&e.push(this.active[i]);return e.reverse()}openEnd(t){let e=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)e++;return e}}function Ht(t,e,i,n,s,r){t.goto(e),i.goto(n);let o=n+s,h=n,l=n-e;for(;;){let e=t.to+l-i.to||t.endSide-i.endSide,n=e<0?t.to+l:i.to,s=Math.min(n,o);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))&&Wt(t.activeForPoint(t.to),i.activeForPoint(i.to))||r.comparePoint(h,s,t.point,i.point):s>h&&!Wt(t.active,i.active)&&r.compareRange(h,s,t.active,i.active),n>o)break;h=n,e<=0&&t.next(),e>=0&&i.next()}}function Wt(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 Ft(t,e){for(let i=e,n=t.length-1;i<n;i++)t[i]=t[i+1];t.pop()}function zt(t,e,i){for(let n=t.length-1;n>=e;n--)t[n+1]=t[n];t[e]=i}function _t(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}function jt(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=m(t,s));return n}function qt(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=m(t,s)}return!0===n?-1:t.length}},68857:function(t,e,i){i.a(t,(async function(t,n){try{i.d(e,{OO:function(){return Ft},SJ:function(){return Dn},l9:function(){return wt},lg:function(){return qt},p:function(){return vt},tk:function(){return Sn}});var s=i(31948),r=(i(52247),i(71695),i(92745),i(52805),i(61495),i(61893),i(84283),i(19423),i(23669),i(40251),i(69235),i(12385),i(19134),i(32517),i(5740),i(11740),i(92519),i(42179),i(89256),i(24931),i(88463),i(57449),i(19814),i(97003),i(32114),i(46692),i(39527),i(37210),i(92181),i(99790),i(67670),i(13334),i(34595),i(36993),i(47021),i(95652)),o=i(29933),h=(i(96318),t([s]));function d(t){let e;return e=11==t.nodeType?t.getSelection?t:t.ownerDocument:t,e.getSelection()}function g(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function p(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function m(t,e){if(!e.anchorNode)return!1;try{return g(t,e.anchorNode)}catch(i){return!1}}function w(t){return 3==t.nodeType?E(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function v(t,e,i,n){return!!i&&(b(t,e,i,n,-1)||b(t,e,i,n,1))}function y(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function b(t,e,i,n,s){for(;;){if(t==i&&e==n)return!0;if(e==(s<0?0:x(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=y(t)+(s<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if(1==(t=t.childNodes[e+(s<0?-1:0)]).nodeType&&"false"==t.contentEditable)return!1;e=s<0?x(t):0}}}function x(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function S(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function k(t){return{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function A(t,e,i,n,s,r,o,h){let l=t.ownerDocument,a=l.defaultView||window;for(let c=t;c;)if(1==c.nodeType){let t,u=c==l.body;if(u)t=k(a);else{if(c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||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 f=0,d=0;if("nearest"==s)e.top<t.top?(d=-(t.top-e.top+o),i>0&&e.bottom>t.bottom+d&&(d=e.bottom-t.bottom+d+o)):e.bottom>t.bottom&&(d=e.bottom-t.bottom+o,i<0&&e.top-d<t.top&&(d=-(t.top+d-e.top+o)));else{let n=e.bottom-e.top,r=t.bottom-t.top;d=("center"==s&&n<=r?e.top+n/2-r/2:"start"==s||"center"==s&&i<0?e.top-o:e.bottom-r+o)-t.top}if("nearest"==n)e.left<t.left?(f=-(t.left-e.left+r),i>0&&e.right>t.right+f&&(f=e.right-t.right+f+r)):e.right>t.right&&(f=e.right-t.right+r,i<0&&e.left<t.left+f&&(f=-(t.left+f-e.left+r)));else{f=("center"==n?e.left+(e.right-e.left)/2-(t.right-t.left)/2:"start"==n==h?e.left-r:e.right-(t.right-t.left)+r)-t.left}if(f||d)if(u)a.scrollBy(f,d);else{let t=0,i=0;if(d){let t=c.scrollTop;c.scrollTop+=d,i=c.scrollTop-t}if(f){let e=c.scrollLeft;c.scrollLeft+=f,t=c.scrollLeft-e}e={left:e.left-t,top:e.top-i,right:e.right-t,bottom:e.bottom-i},t&&Math.abs(t-f)<1&&(n="nearest"),i&&Math.abs(i-d)<1&&(s="nearest")}if(u)break;c=c.assignedSlot||c.parentNode}else{if(11!=c.nodeType)break;c=c.host}}function M(t){let e=t.ownerDocument;for(let i=t.parentNode;i&&i!=e.body;)if(1==i.nodeType){if(i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)return i;i=i.assignedSlot||i.parentNode}else{if(11!=i.nodeType)break;i=i.host}return null}s=(h.then?(await h)():h)[0];class C{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:i}=t;this.set(e,Math.min(t.anchorOffset,e?x(e):0),i,Math.min(t.focusOffset,i?x(i):0))}set(t,e,i,n){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=n}}let O,T=null;function D(t){if(t.setActive)return t.setActive();if(T)return t.focus(T);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==T?{get preventScroll(){return T={preventScroll:!0},!0}}:void 0),!T){T=!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 E(t,e,i=e){let n=O||(O=document.createRange());return n.setEnd(t,i),n.setStart(t,e),n}function R(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 B(t){for(;t;){if(t&&(9==t.nodeType||11==t.nodeType&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function P(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}function L(t,e){let i=e.focusNode,n=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=n)return!1;for(n=Math.min(n,x(i));;)if(n){if(1!=i.nodeType)return!1;let t=i.childNodes[n-1];"false"==t.contentEditable?n--:(i=t,n=x(i))}else{if(i==t)return!0;n=y(i),i=i.parentNode}}class N{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new N(t.parentNode,y(t),e)}static after(t,e){return new N(t.parentNode,y(t)+1,e)}}const I=[];class V{constructor(){this.parent=null,this.dom=null,this.dirty=2}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}sync(t,e){if(2&this.dirty){let i,n=this.dom,s=null;for(let r of this.children){if(r.dirty){if(!r.dom&&(i=s?s.nextSibling:n.firstChild)){let t=V.get(i);(!t||!t.parent&&t.canReuseDOM(r))&&r.reuseDOM(i)}r.sync(t,e),r.dirty=0}if(i=s?s.nextSibling:n.firstChild,e&&!e.written&&e.node==n&&i!=r.dom&&(e.written=!0),r.dom.parentNode==n)for(;i&&i!=r.dom;)i=H(i);else n.insertBefore(r.dom,i);s=r.dom}for(i=s?s.nextSibling:n.firstChild,i&&e&&e.node==n&&(e.written=!0);i;)i=H(i)}else if(1&this.dirty)for(let i of this.children)i.dirty&&(i.sync(t,e),i.dirty=0)}reuseDOM(t){}localPosFromDOM(t,e){let i;if(t==this.dom)i=this.dom.childNodes[e];else{let n=0==x(t)?0:0==e?-1:1;for(;;){let e=t.parentNode;if(e==this.dom)break;0==n&&e.firstChild!=e.lastChild&&(n=t==e.firstChild?-1:1),t=e}i=n<0?t:t.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!V.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 h=0,l=i,a=i;h<this.children.length;h++){let i=this.children[h],c=l+i.length;if(l<t&&c>e)return i.domBoundsAround(t,e,l);if(c>=t&&-1==n&&(n=h,s=l),l>e&&i.dom.parentNode==this.dom){r=h,o=a;break}a=c,l=c+i.breakAfter}return{from:s,to:o<0?i+this.length:o,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:r<this.children.length&&r>=0?this.children[r].dom:null}}markDirty(t=!1){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=I){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 W(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}get isWidget(){return!1}get isHidden(){return!1}merge(t,e,i,n,s,r){return!1}become(t){return!1}canReuseDOM(t){return t.constructor==this.constructor}getSide(){return 0}destroy(){this.parent=null}}function H(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}V.prototype.breakAfter=0;class W{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 F(t,e,i,n,s,r,o,h,l){let{children:a}=t,c=a.length?a[e]:null,u=r.length?r[r.length-1]:null,f=u?u.breakAfter:o;if(!(e==n&&c&&!o&&!f&&r.length<2&&c.merge(i,s,r.length?u:null,0==i,h,l))){if(n<a.length){let t=a[n];t&&s<t.length?(e==n&&(t=t.split(s),s=0),!f&&u&&t.merge(0,s,u,!0,0,l)?r[r.length-1]=t:(s&&t.merge(0,s,null,!1,0,l),r.push(t))):(null==t?void 0:t.breakAfter)&&(u?u.breakAfter=1:o=1),n++}for(c&&(c.breakAfter=o,i>0&&(!o&&r.length&&c.merge(i,c.length,r[0],!1,h,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,h,0),e++));e<n&&r.length;)if(a[n-1].become(r[r.length-1]))n--,r.pop(),l=r.length?0:h;else{if(!a[e].become(r[0]))break;e++,r.shift(),h=r.length?0:l}!r.length&&e&&n<a.length&&!a[e-1].breakAfter&&a[n].merge(0,0,a[e-1],!1,h,l)&&e--,(e<n||r.length)&&t.replaceChildren(e,n,r)}}function z(t,e,i,n,s,r){let o=t.childCursor(),{i:h,off:l}=o.findPos(i,1),{i:a,off:c}=o.findPos(e,-1),u=e-i;for(let f of n)u+=f.length;t.length+=u,F(t,a,c,h,l,n,0,s,r)}let _="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},j="undefined"!=typeof document?document:{documentElement:{style:{}}};const q=/Edge\/(\d+)/.exec(_.userAgent),$=/MSIE \d/.test(_.userAgent),K=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(_.userAgent),J=!!($||K||q),G=!J&&/gecko\/(\d+)/i.test(_.userAgent),U=!J&&/Chrome\/(\d+)/.exec(_.userAgent),X="webkitFontSmoothing"in j.documentElement.style,Y=!J&&/Apple Computer/.test(_.vendor),Q=Y&&(/Mobile\/\w+/.test(_.userAgent)||_.maxTouchPoints>2);var l={mac:Q||/Mac/.test(_.platform),windows:/Win/.test(_.platform),linux:/Linux|X11/.test(_.platform),ie:J,ie_version:$?j.documentMode||6:K?+K[1]:q?+q[1]:0,gecko:G,gecko_version:G?+(/Firefox\/(\d+)/.exec(_.userAgent)||[0,0])[1]:0,chrome:!!U,chrome_version:U?+U[1]:0,ios:Q,android:/Android\b/.test(_.userAgent),webkit:X,safari:Y,webkit_version:X?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:null!=j.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};const Z=256;class tt extends V{constructor(t){super(),this.text=t}get length(){return this.text.length}createDOM(t){this.setDOM(t||document.createTextNode(this.text))}sync(t,e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(t){3==t.nodeType&&this.createDOM(t)}merge(t,e,i){return(!i||i instanceof tt&&!(this.length-(e-t)+i.length>Z))&&(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new tt(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 N(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 it(this.dom,t,e)}}class et extends V{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(P(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,e){this.dom?4&this.dirty&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(t,e)}merge(t,e,i,n,s,r){return(!i||!(!(i instanceof et&&i.mark.eq(this.mark))||t&&s<=0||e<this.length&&r<=0))&&(z(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 et(this.mark,e,r)}domAtPos(t){return ct(this,t)}coordsAt(t,e){return ft(this,t,e)}}function it(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?l.chrome||l.gecko||(e?(s--,o=1):r<n&&(r++,o=-1)):i<0?s--:r<n&&r++;let h=E(t,s,r).getClientRects();if(!h.length)return null;let a=h[(o?o<0:i>=0)?0:h.length-1];return l.safari&&!o&&0==a.width&&(a=Array.prototype.find.call(h,(t=>t.width))||a),o?S(a,o<0):a||null}class nt extends V{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||nt)(t,e,i)}split(t){let e=nt.create(this.widget,this.length-t,this.side);return this.length-=t,e}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.dom.contentEditable="false")}getSide(){return this.side}merge(t,e,i,n,s,r){return!(i&&(!(i instanceof nt&&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 instanceof nt&&t.side==this.side&&this.widget.constructor==t.widget.constructor&&(this.widget.compare(t.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get overrideDOMText(){if(0==this.length)return r.xv.empty;let t=this;for(;t.parent;)t=t.parent;let{view:e}=t,i=e&&e.state.doc,n=this.posAtStart;return i?i.slice(n,n+this.length):r.xv.empty}domAtPos(t){return(this.length?0==t:this.side>0)?N.before(this.dom):N.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let i=this.widget.coordsAt(this.dom,t,e);if(i)return i;let n=this.dom.getClientRects(),s=null;if(!n.length)return null;let r=this.side?this.side<0:t>0;for(let o=r?n.length-1:0;s=n[o],!(t>0?0==o:o==n.length-1||s.top<s.bottom);o+=r?-1:1);return S(s,!r)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class st extends nt{domAtPos(t){let{topView:e,text:i}=this.widget;return e?rt(t,0,e,i,this.length-e.length,((t,e)=>t.domAtPos(e)),((t,e)=>new N(t,Math.min(e,t.nodeValue.length)))):new N(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?ht(t,e,i,n,this.length-i.length):Math.min(e,this.length)}ignoreMutation(){return!1}get overrideDOMText(){return null}coordsAt(t,e){let{topView:i,text:n}=this.widget;return i?rt(t,e,i,n,this.length-i.length,((t,e,i)=>t.coordsAt(e,i)),((t,e,i)=>it(t,e,i))):it(n,t,e)}destroy(){var t;super.destroy(),null===(t=this.widget.topView)||void 0===t||t.destroy()}get isEditable(){return!0}canReuseDOM(){return!0}}function rt(t,e,i,n,s,r,o){if(i instanceof et){for(let h=i.dom.firstChild;h;h=h.nextSibling){let i=V.get(h);if(i){let l=g(h,n),a=i.length+(l?s:0);if(t<a||t==a&&i.getSide()<=0)return l?rt(t,e,i,n,s,r,o):r(i,t,e);t-=a}else{let i=ot(t,e,h,o);if("number"!=typeof i)return i;t=i}}return r(i,i.length,-1)}return i.dom==n?o(n,t,e):r(i,t,e)}function ot(t,e,i,n){if(3==i.nodeType){let s=i.nodeValue.length;if(t<=s)return n(i,t,e);t-=s}else if(1==i.nodeType&&"false"!=i.contentEditable)for(let s=i.firstChild;s;s=s.nextSibling){let i=ot(t,e,s,n);if("number"!=typeof i)return i;t=i}return t}function ht(t,e,i,n,s){if(i instanceof et){let r=0;for(let o=i.dom.firstChild;o;o=o.nextSibling){let i=V.get(o);if(i){let h=g(o,n);if(g(o,t))return r+(h?ht(t,e,i,n,s):i.localPosFromDOM(t,e));r+=i.length+(h?s:0)}else{let i=lt(t,e,o);if(null!=i.result)return r+i.result;r+=i.size}}}else if(i.dom==n)return Math.min(e,n.nodeValue.length);return i.localPosFromDOM(t,e)}function lt(t,e,i){if(3==i.nodeType)return t==i?{result:e}:{size:i.nodeValue.length};if(1!=i.nodeType||"false"==i.contentEditable)return i.contains(t)?{result:0}:{size:0};{let n=0;for(let s=i.firstChild,r=0;;s=s.nextSibling,r++){if(t==i&&r==e)return{result:n};if(!s)return{size:n};let o=lt(t,e,s);if(null!=o.result)return{result:e+o.result};n+=o.size}}}class at extends V{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof at&&t.side==this.side}split(){return new at(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 this.side>0?N.before(this.dom):N.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return r.xv.empty}get isHidden(){return!0}}function ct(t,e){let i=t.dom,{children:n}=t,s=0;for(let r=0;s<n.length;s++){let t=n[s],o=r+t.length;if(!(o==r&&t.getSide()<=0)){if(e>r&&e<o&&t.dom.parentNode==i)return t.domAtPos(e-r);if(e<=r)break;r=o}}for(let r=s;r>0;r--){let t=n[r-1];if(t.dom.parentNode==i)return t.domAtPos(t.length)}for(let r=s;r<n.length;r++){let t=n[r];if(t.dom.parentNode==i)return t.domAtPos(0)}return new N(i,0)}function ut(t,e,i){let n,{children:s}=t;i>0&&e instanceof et&&s.length&&(n=s[s.length-1])instanceof et&&n.mark.eq(e.mark)?ut(n,e.children[0],i-1):(s.push(e),e.setParent(t)),t.length+=e.length}function ft(t,e,i){let n=null,s=-1,r=null,o=-1;!function t(e,h){for(let l=0,a=0;l<e.children.length&&a<=h;l++){let c=e.children[l],u=a+c.length;u>=h&&(c.children.length?t(c,h-a):(!r||r.isHidden&&i>0)&&(u>h||a==u&&c.getSide()>0)?(r=c,o=h-a):(a<h||a==u&&c.getSide()<0&&!c.isHidden)&&(n=c,s=h-a)),a=u}}(t,e);let h=(i<0?n:r)||n||r;return h?h.coordsAt(Math.max(0,h==n?s:o),i):dt(t)}function dt(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=w(e);return i[i.length-1]||null}function gt(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 pt(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 mt(t,e,i){let n=null;if(e)for(let s in e)i&&s in i||t.removeAttribute(n=s);if(i)for(let s in i)e&&e[s]==i[s]||t.setAttribute(n=s,i[s]);return!!n}tt.prototype.children=nt.prototype.children=at.prototype.children=I;class wt{eq(t){return!1}updateDOM(t,e){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(t){return!0}coordsAt(t,e,i){return null}get customView(){return null}get isHidden(){return!1}destroy(t){}}var a=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(a||(a={}));class vt extends r.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 yt(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),i=!!t.block;return e+=i&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8,new xt(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}=St(t,n);e=(s?n?-3e8:-1:5e8)-1,i=1+(r?n?2e8:1:-6e8)}return new xt(t,e,i,n,t.widget||null,!0)}static line(t){return new bt(t)}static set(t,e=!1){return r.Xs.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}vt.none=r.Xs.empty;class yt extends vt{constructor(t){let{start:e,end:i}=St(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 yt&&this.tagName==t.tagName&&this.class==t.class&&pt(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)}}yt.prototype.point=!1;class bt extends vt{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof bt&&this.spec.class==t.spec.class&&pt(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)}}bt.prototype.mapMode=r.gc.TrackBefore,bt.prototype.point=!0;class xt extends vt{constructor(t,e,i,n,s,o){super(e,i,s,t),this.block=n,this.isReplace=o,this.mapMode=n?e<=0?r.gc.TrackBefore:r.gc.TrackAfter:r.gc.TrackDel}get type(){return this.startSide<this.endSide?a.WidgetRange:this.startSide<=0?a.WidgetBefore:a.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof xt&&(e=this.widget,i=t.widget,e==i||!!(e&&i&&e.compare(i)))&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide;var e,i}range(t,e=t){if(this.isReplace&&(t>e||t==e&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}}function St(t,e=!1){let{inclusiveStart:i,inclusiveEnd:n}=t;return null==i&&(i=t.inclusive),null==n&&(n=t.inclusive),{start:null!=i?i:e,end:null!=n?n:e}}function kt(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)}xt.prototype.point=!0;class At extends V{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 At))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),z(this,t,e,i?i.children:[],s,r),!0}split(t){let e=new At;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);for(;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&&(this.markDirty(),t.setDOM(this.dom),t.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(t){pt(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){ut(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=gt(e,this.attrs||{})),i&&(this.attrs=gt({class:i},this.attrs||{}))}domAtPos(t){return ct(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.dirty|=6)}sync(t,e){var i;this.dom?4&this.dirty&&(P(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&&(mt(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t,e);let n=this.dom.lastChild;for(;n&&V.get(n)instanceof et;)n=n.lastChild;if(!(n&&this.length&&("BR"==n.nodeName||0!=(null===(i=V.get(n))||void 0===i?void 0:i.isEditable)||l.ios&&this.children.some((t=>t instanceof tt))))){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,e=0;for(let i of this.children){if(!(i instanceof tt)||/[^ -~]/.test(i.text))return null;let n=w(i.dom);if(1!=n.length)return null;e+=n[0].width,t=n[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(t,e){let i=ft(this,t,e);if(!this.children.length&&i&&this.parent){let{heightOracle:t}=this.parent.view.viewState,e=i.bottom-i.top;if(Math.abs(e-t.lineHeight)<2&&t.textHeight<e){let n=(e-t.textHeight)/2;return{top:i.top+n,bottom:i.bottom-n,left:i.left,right:i.left}}}return i}become(t){return!1}get type(){return a.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 At)return s;if(r>e)break}n=r+s.breakAfter}return null}}class Mt extends V{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 Mt&&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?N.before(this.dom):N.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new Mt(this.widget,e,this.type);return i.breakAfter=this.breakAfter,i}get children(){return I}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.dom.contentEditable="false")}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):r.xv.empty}domBoundsAround(){return null}become(t){return t instanceof Mt&&t.widget.constructor==this.widget.constructor&&(t.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,this.type=t.type,this.breakAfter=t.breakAfter,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(t,e){return this.widget.coordsAt(this.dom,t,e)}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class Ct{constructor(t,e,i,n){this.doc=t,this.pos=e,this.end=i,this.disallowBlockEffectsFor=n,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],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 Mt&&t.type==a.WidgetBefore)}getLine(){return this.curLine||(this.content.push(this.curLine=new At),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(Ot(new at(-1),t),t.length),this.pendingBuffer=0)}addBlockWidget(t){this.flushBuffer(),this.curLine=null,this.content.push(t)}finish(t){this.pendingBuffer&&t<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||this.getLine()}buildText(t,e,i){for(;t>0;){if(this.textOff==this.text.length){let{value:e,lineBreak:i,done:n}=this.cursor.next(this.skip);if(this.skip=0,n)throw new Error("Ran out of text content when drawing inline views");if(i){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,t--;continue}this.text=e,this.textOff=0}let n=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(e.length-i)),this.getLine().append(Ot(new tt(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,r){if(this.disallowBlockEffectsFor[r]&&i instanceof xt){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")}let o=e-t;if(i instanceof xt)if(i.block){let{type:t}=i;t!=a.WidgetAfter||this.posCovered()||this.getLine(),this.addBlockWidget(new Mt(i.widget||new Tt("div"),o,t))}else{let r=nt.create(i.widget||new Tt("span"),o,o?0:i.startSide),h=this.atCursorPos&&!r.isEditable&&s<=n.length&&(t<e||i.startSide>0),l=!r.isEditable&&(t<e||s>n.length||i.startSide<=0),a=this.getLine();2!=this.pendingBuffer||h||r.isEditable||(this.pendingBuffer=0),this.flushBuffer(n),h&&(a.append(Ot(new at(1),n),s),s=n.length+Math.max(0,s-n.length)),a.append(Ot(r,n),s),this.atCursorPos=l,this.pendingBuffer=l?t<e||s>n.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=n.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);o&&(this.textOff+o<=this.text.length?this.textOff+=o:(this.skip+=o-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=e),this.openStart<0&&(this.openStart=s)}static build(t,e,i,n,s){let o=new Ct(t,e,i,s);return o.openEnd=r.Xs.spans(n,e,i,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}}function Ot(t,e){for(let i of e)t=new et(i,[t],t.length);return t}class Tt extends wt{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}const Dt=r.r$.define(),Et=r.r$.define(),Rt=r.r$.define(),Bt=r.r$.define(),Pt=r.r$.define(),Lt=r.r$.define(),Nt=r.r$.define(),It=r.r$.define({combine:t=>t.some((t=>t))}),Vt=r.r$.define({combine:t=>t.some((t=>t))});class Ht{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 Ht(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin)}}const Wt=r.Py.define({map:(t,e)=>t.map(e)});function Ft(t,e,i){let n=t.facet(Bt);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 zt=r.r$.define({combine:t=>!t.length||t[0]});let _t=0;const jt=r.r$.define();class qt{constructor(t,e,i,n){this.id=t,this.create=e,this.domEventHandlers=i,this.extension=n(this)}static define(t,e){const{eventHandlers:i,provide:n,decorations:s}=e||{};return new qt(_t++,t,i,(t=>{let e=[jt.of(t)];return s&&e.push(Gt.of((e=>{let i=e.plugin(t);return i?s(i):vt.none}))),n&&e.push(n(t)),e}))}static fromClass(t,e){return qt.define((e=>new t(e)),e)}}class $t{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}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(Ft(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){Ft(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){Ft(t.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Kt=r.r$.define(),Jt=r.r$.define(),Gt=r.r$.define(),Ut=r.r$.define(),Xt=r.r$.define();function Yt(t){let e=0,i=0,n=0,s=0;for(let r of t.state.facet(Xt)){let o=r(t);o&&(null!=o.left&&(e=Math.max(e,o.left)),null!=o.right&&(i=Math.max(i,o.right)),null!=o.top&&(n=Math.max(n,o.top)),null!=o.bottom&&(s=Math.max(s,o.bottom)))}return{left:e,right:i,top:n,bottom:s}}const Qt=r.r$.define();class Zt{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new Zt(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let n=t[e-1];if(!(n.fromA>i.toA)){if(n.toA<i.fromA)break;i=i.join(n),t.splice(e-1,1)}}return t.splice(e,0,i),t}static extendWithRanges(t,e){if(0==e.length)return t;let i=[];for(let n=0,s=0,r=0,o=0;;n++){let h=n==t.length?null:t[n],l=r-o,a=h?h.fromB:1e9;for(;s<e.length&&e[s]<a;){let t=e[s],n=e[s+1],r=Math.max(o,t),h=Math.min(a,n);if(r<=h&&new Zt(r+l,h+l,r,h).addToSet(i),n>a)break;s+=2}if(!h)return i;new Zt(h.fromA,h.toA,h.fromB,h.toB).addToSet(i),r=h.toA,o=h.toB}}}class te{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=r.as.empty(this.startState.doc.length);for(let s of i)this.changes=this.changes.compose(s.changes);let n=[];this.changes.iterChangedRanges(((t,e,i,s)=>n.push(new Zt(t,e,i,s)))),this.changedRanges=n}static create(t,e,i){return new te(t,e,i)}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 c=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(c||(c={}));const ee=c.LTR,ie=c.RTL;function ne(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}const se=ne("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),re=ne("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),oe=Object.create(null),he=[];for(let En of["()","[]","{}"]){let Rn=En.charCodeAt(0),Bn=En.charCodeAt(1);oe[Rn]=Bn,oe[Bn]=-Rn}const le=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class ae{constructor(t,e,i){this.from=t,this.to=e,this.level=i}get dir(){return this.level%2?ie:ee}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 ce=[];function ue(t,e){let i=t.length,n=e==ee?1:2,s=e==ee?2:1;if(!t||1==n&&!le.test(t))return fe(i);for(let h=0,l=n,a=n;h<i;h++){let e=(r=t.charCodeAt(h))<=247?se[r]:1424<=r&&r<=1524?2:1536<=r&&r<=1785?re[r-1536]:1774<=r&&r<=2220?4:8192<=r&&r<=8203?256:64336<=r&&r<=65023?4:8204==r?256:1;512==e?e=l:8==e&&4==a&&(e=16),ce[h]=4==e?2:e,7&e&&(a=e),l=e}var r;for(let h=0,l=n,a=n;h<i;h++){let t=ce[h];if(128==t)h<i-1&&l==ce[h+1]&&24&l?t=ce[h]=l:ce[h]=256;else if(64==t){let t=h+1;for(;t<i&&64==ce[t];)t++;let e=h&&8==l||t<i&&8==ce[t]?1==a?1:8:256;for(let i=h;i<t;i++)ce[i]=e;h=t-1}else 8==t&&1==a&&(ce[h]=1);l=t,7&t&&(a=t)}for(let h,l,a,c=0,u=0,f=0;c<i;c++)if(l=oe[h=t.charCodeAt(c)])if(l<0){for(let t=u-3;t>=0;t-=3)if(he[t+1]==-l){let e=he[t+2],i=2&e?n:4&e?1&e?s:n:0;i&&(ce[c]=ce[he[t]]=i),u=t;break}}else{if(189==he.length)break;he[u++]=c,he[u++]=h,he[u++]=f}else if(2==(a=ce[c])||1==a){let t=a==n;f=t?0:1;for(let e=u-3;e>=0;e-=3){let i=he[e+2];if(2&i)break;if(t)he[e+2]|=2;else{if(4&i)break;he[e+2]|=4}}}for(let h=0;h<i;h++)if(256==ce[h]){let t=h+1;for(;t<i&&256==ce[t];)t++;let e=1==(h?ce[h-1]:n),s=e==(1==(t<i?ce[t]:n))?e?1:2:n;for(let i=h;i<t;i++)ce[i]=s;h=t-1}let o=[];if(1==n)for(let h=0;h<i;){let t=h,e=1!=ce[h++];for(;h<i&&e==(1!=ce[h]);)h++;if(e)for(let i=h;i>t;){let e=i,n=2!=ce[--i];for(;i>t&&n==(2!=ce[i-1]);)i--;o.push(new ae(i,e,n?2:1))}else o.push(new ae(t,h,0))}else for(let h=0;h<i;){let t=h,e=2==ce[h++];for(;h<i&&e==(2==ce[h]);)h++;o.push(new ae(t,h,e?1:2))}return o}function fe(t){return[new ae(0,t,0)]}let de="";function ge(t,e,i,n,s){var o;let h=n.head-t.from,l=-1;if(0==h){if(!s||!t.length)return null;e[0].level!=i&&(h=e[0].side(!1,i),l=0)}else if(h==t.length){if(s)return null;let t=e[e.length-1];t.level!=i&&(h=t.side(!0,i),l=e.length-1)}l<0&&(l=ae.find(e,h,null!==(o=n.bidiLevel)&&void 0!==o?o:-1,n.assoc));let a=e[l];h==a.side(s,i)&&(a=e[l+=s?1:-1],h=a.side(!s,i));let c=s==(a.dir==i),u=(0,r.cp)(t.text,h,c);if(de=t.text.slice(Math.min(h,u),Math.max(h,u)),u!=a.side(s,i))return r.jT.cursor(u+t.from,c?-1:1,a.level);let f=l==(s?e.length-1:0)?null:e[l+(s?1:-1)];return f||a.level==i?f&&f.level<a.level?r.jT.cursor(f.side(!s,i)+t.from,s?1:-1,f.level):r.jT.cursor(u+t.from,s?-1:1,a.level):r.jT.cursor(s?t.to:t.from,s?-1:1,i)}const pe="￿";class me{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(r.yy.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=pe}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let n=t;;){this.findPointBefore(i,n);let t=this.text.length;this.readNode(n);let s=n.nextSibling;if(s==e)break;let r=V.get(n),o=V.get(s);(r&&o?r.breakAfter:(r?r.breakAfter:we(n))||we(s)&&("BR"!=n.nodeName||n.cmIgnore)&&this.text.length>t)&&this.lineBreak(),n=s}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=V.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 we(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}class ve{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class ye extends V{constructor(t){super(),this.view=t,this.compositionDeco=vt.none,this.decorations=[],this.dynamicDecorationMap=[],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 At],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Zt(0,0,0,t.state.doc.length)],0)}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=vt.none:(t.transactions.length||this.dirty)&&(this.compositionDeco=Se(this.view,t.changes)),(l.ie||l.chrome)&&!this.compositionDeco.size&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let i=Oe(this.decorations,this.updateDeco(),t.changes);return e=Zt.extendWithRanges(e,i),(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.flexBasis=this.minWidth?this.minWidth+"px":"";let t=l.chrome||l.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,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 Mt&&s.widget instanceof be&&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:h}=e,{content:l,breakAtStart:a,openStart:c,openEnd:u}=Ct.build(this.view.state.doc,o,h,this.decorations,this.dynamicDecorationMap),{i:f,off:d}=i.findPos(r,1),{i:g,off:p}=i.findPos(s,-1);F(this,g,p,f,d,l,a,c,u)}}updateSelection(t=!1,e=!1){!t&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let i=this.view.root.activeElement,n=i==this.dom,s=!n&&m(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(n||e||s))return;let r=this.forceSelection;this.forceSelection=!1;let o=this.view.state.selection.main,h=this.domAtPos(o.anchor),a=o.empty?h:this.domAtPos(o.head);if(l.gecko&&o.empty&&!this.compositionDeco.size&&(1==(c=h).node.nodeType&&c.node.firstChild&&(0==c.offset||"false"==c.node.childNodes[c.offset-1].contentEditable)&&(c.offset==c.node.childNodes.length||"false"==c.node.childNodes[c.offset].contentEditable))){let t=document.createTextNode("");this.view.observer.ignore((()=>h.node.insertBefore(t,h.node.childNodes[h.offset]||null))),h=a=new N(t,0),r=!0}var c;let u=this.view.observer.selectionRange;!r&&u.focusNode&&v(h.node,h.offset,u.anchorNode,u.anchorOffset)&&v(a.node,a.offset,u.focusNode,u.focusOffset)||(this.view.observer.ignore((()=>{l.android&&l.chrome&&this.dom.contains(u.focusNode)&&Te(u.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let t=d(this.view.root);if(t)if(o.empty){if(l.gecko){let t=Me(h.node,h.offset);if(t&&3!=t){let e=Ae(h.node,h.offset,1==t?1:-1);e&&(h=new N(e,1==t?0:e.nodeValue.length))}}t.collapse(h.node,h.offset),null!=o.bidiLevel&&null!=u.cursorBidiLevel&&(u.cursorBidiLevel=o.bidiLevel)}else if(t.extend){t.collapse(h.node,h.offset);try{t.extend(a.node,a.offset)}catch(e){}}else{let e=document.createRange();o.anchor>o.head&&([h,a]=[a,h]),e.setEnd(a.node,a.offset),e.setStart(h.node,h.offset),t.removeAllRanges(),t.addRange(e)}else;s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())})),this.view.observer.setSelectionRange(h,a)),this.impreciseAnchor=h.precise?null:new N(u.anchorNode,u.anchorOffset),this.impreciseHead=a.precise?null:new N(u.focusNode,u.focusOffset)}enforceCursorAssoc(){if(this.compositionDeco.size)return;let{view:t}=this,e=t.state.selection.main,i=d(t.root),{anchorNode:n,anchorOffset:s}=t.observer.selectionRange;if(!(i&&e.empty&&e.assoc&&i.modify))return;let r=At.find(this,e.head);if(!r)return;let o=r.posAtStart;if(e.head==o||e.head==o+r.length)return;let h=this.coordsAt(e.head,-1),l=this.coordsAt(e.head,1);if(!h||!l||h.bottom>l.top)return;let a=this.domAtPos(e.head+e.assoc);i.collapse(a.node,a.offset),i.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let c=t.observer.selectionRange;t.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=e.from&&i.collapse(n,s)}nearest(t){for(let e=t;e;){let t=V.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 At)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!=a.WidgetBefore&&s.type!=a.WidgetAfter&&(!n||2==e||this.children[n-1].breakAfter||this.children[n-1].type==a.WidgetBefore&&e>-2))return s.coordsAt(t-r,e);i=r}}measureVisibleLineHeights(t){let e=[],{from:i,to:n}=t,s=this.view.contentDOM.clientWidth,r=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,h=this.view.textDirection==c.LTR;for(let l=0,a=0;a<this.children.length;a++){let t=this.children[a],c=l+t.length;if(c>n)break;if(l>=i){let i=t.dom.getBoundingClientRect();if(e.push(i.height),r){let e=t.dom.lastChild,n=e?w(e):[];if(n.length){let t=n[n.length-1],e=h?t.right-i.left:i.right-t.left;e>o&&(o=e,this.minWidth=s,this.minWidthFrom=l,this.minWidthTo=c)}}}l=c+t.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?c.RTL:c.LTR}measureTextSize(){for(let s of this.children)if(s instanceof At){let t=s.measureTextSize();if(t)return t}let t,e,i,n=document.createElement("div");return n.className="cm-line",n.style.width="99999px",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore((()=>{this.dom.appendChild(n);let s=w(n.firstChild)[0];t=n.getBoundingClientRect().height,e=s?s.width/27:7,i=s?s.height:t,n.remove()})),{lineHeight:t,charWidth:e,textHeight:i}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new W(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(vt.replace({widget:new be(n),block:!0,inclusive:!0,isBlockGap:!0}).range(i,r))}if(!s)break;i=s.to+1}return vt.set(t)}updateDeco(){let t=this.view.state.facet(Gt).map(((t,e)=>(this.dynamicDecorationMap[e]="function"==typeof t)?t(this.view):t));for(let e=t.length;e<t.length+3;e++)this.dynamicDecorationMap[e]=!1;return this.decorations=[...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=Yt(this.view),r={left:n.left-s.left,top:n.top-s.top,right:n.right+s.right,bottom:n.bottom+s.bottom};A(this.view.scrollDOM,r,i.head<i.anchor?-1:1,t.x,t.y,t.xMargin,t.yMargin,this.view.textDirection==c.LTR)}}class be extends wt{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 xe(t){let e=t.observer.selectionRange,i=e.focusNode&&Ae(e.focusNode,e.focusOffset,0);if(!i)return null;let n=t.docView.nearest(i);if(!n)return null;if(n instanceof At){let t=i;for(;t.parentNode!=n.dom;)t=t.parentNode;let e=t.previousSibling;for(;e&&!V.get(e);)e=e.previousSibling;let s=e?V.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 At)break;n=t}let t=n.posAtStart;return{from:t,to:t+n.length,node:n.dom,text:i}}}function Se(t,e){let i=xe(t);if(!i)return vt.none;let{from:n,to:s,node:r,text:o}=i,h=e.mapPos(n,1),l=Math.max(h,e.mapPos(s,-1)),{state:a}=t,c=new me([],a);3==r.nodeType?c.readTextNode(r):c.readRange(r.firstChild,null);let{text:u}=c;if(u.indexOf(pe)>-1)return vt.none;if(l-h<u.length)if(a.doc.sliceString(h,Math.min(a.doc.length,h+u.length))==u)l=h+u.length;else{if(a.doc.sliceString(Math.max(0,l-u.length),l)!=u)return vt.none;h=l-u.length}else if(a.doc.sliceString(h,l)!=u)return vt.none;let f=V.get(r);return f instanceof st?f=f.widget.topView:f&&(f.parent=null),vt.set(vt.replace({widget:new ke(r,o,f),inclusive:!0}).range(h,l))}class ke extends wt{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 st}}function Ae(t,e,i){if(i<=0)for(let n=t,s=e;;){if(3==n.nodeType)return n;if(!(1==n.nodeType&&s>0))break;n=n.childNodes[s-1],s=x(n)}if(i>=0)for(let n=t,s=e;;){if(3==n.nodeType)return n;if(!(1==n.nodeType&&s<n.childNodes.length&&i>=0))break;n=n.childNodes[s],s=0}return null}function Me(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 Ce{constructor(){this.changes=[]}compareRange(t,e){kt(t,e,this.changes)}comparePoint(t,e){kt(t,e,this.changes)}}function Oe(t,e,i){let n=new Ce;return r.Xs.compare(t,e,i,n),n.changes}function Te(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 De(t,e,i=1){let n=t.charCategorizer(e),s=t.doc.lineAt(e),o=e-s.from;if(0==s.length)return r.jT.cursor(e);0==o?i=1:o==s.length&&(i=-1);let h=o,l=o;i<0?h=(0,r.cp)(s.text,o,!1):l=(0,r.cp)(s.text,o);let a=n(s.text.slice(h,l));for(;h>0;){let t=(0,r.cp)(s.text,h,!1);if(n(s.text.slice(t,h))!=a)break;h=t}for(;l<s.length;){let t=(0,r.cp)(s.text,l);if(n(s.text.slice(l,t))!=a)break;l=t}return r.jT.range(h+s.from,l+s.from)}function Ee(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function Re(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function Be(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function Pe(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function Le(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function Ne(t,e,i){let n,s,r,o,h,l,a,c,u=!1;for(let d=t.firstChild;d;d=d.nextSibling){let t=w(d);for(let f=0;f<t.length;f++){let g=t[f];s&&Be(s,g)&&(g=Pe(Le(g,s.bottom),s.top));let p=Ee(e,g),m=Re(i,g);if(0==p&&0==m)return 3==d.nodeType?Ie(d,e,i):Ne(d,e,i);if(!n||o>m||o==m&&r>p){n=d,s=g,r=p,o=m;let h=m?i<g.top?-1:1:p?e<g.left?-1:1:0;u=!h||(h>0?f<t.length-1:f>0)}0==p?i>g.bottom&&(!a||a.bottom<g.bottom)?(h=d,a=g):i<g.top&&(!c||c.top>g.top)&&(l=d,c=g):a&&Be(a,g)?a=Le(a,g.bottom):c&&Be(c,g)&&(c=Pe(c,g.top))}}if(a&&a.bottom>=i?(n=h,s=a):c&&c.top<=i&&(n=l,s=c),!n)return{node:t,offset:0};let f=Math.max(s.left,Math.min(s.right,e));return 3==n.nodeType?Ie(n,f,i):u&&"false"!=n.contentEditable?Ne(n,f,i):{node:t,offset:Array.prototype.indexOf.call(t.childNodes,n)+(e>=(s.left+s.right)/2?1:0)}}function Ie(t,e,i){let n=t.nodeValue.length,s=-1,r=1e9,o=0;for(let h=0;h<n;h++){let n=E(t,h,h+1).getClientRects();for(let a=0;a<n.length;a++){let c=n[a];if(c.top==c.bottom)continue;o||(o=e-c.left);let u=(c.top>i?c.top-i:i-c.bottom)-1;if(c.left-1<=e&&c.right+1>=e&&u<r){let i=e>=(c.left+c.right)/2,n=i;if(l.chrome||l.gecko){E(t,h).getBoundingClientRect().left==c.right&&(n=!i)}if(u<=0)return{node:t,offset:h+(n?1:0)};s=h+(n?1:0),r=u}}}return{node:t,offset:s>-1?s:o>0?t.nodeValue.length:0}}function Ve(t,e,i,n=-1){var s,r;let o,h=t.contentDOM.getBoundingClientRect(),c=h.top+t.viewState.paddingTop,{docHeight:u}=t.viewState,{x:f,y:d}=e,g=d-c;if(g<0)return 0;if(g>u)return t.state.doc.length;for(let l=t.viewState.heightOracle.textHeight/2,S=!1;o=t.elementAtHeight(g),o.type!=a.Text;)for(;g=n>0?o.bottom+l:o.top-l,!(g>=0&&g<=u);){if(S)return i?null:0;S=!0,n=-n}d=c+g;let p=o.from;if(p<t.viewport.from)return 0==t.viewport.from?0:i?null:He(t,h,o,f,d);if(p>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:He(t,h,o,f,d);let m=t.dom.ownerDocument,w=t.root.elementFromPoint?t.root:m,v=w.elementFromPoint(f,d);v&&!t.contentDOM.contains(v)&&(v=null),v||(f=Math.max(h.left+1,Math.min(h.right-1,f)),v=w.elementFromPoint(f,d),v&&!t.contentDOM.contains(v)&&(v=null));let y,b=-1;if(v&&0!=(null===(s=t.docView.nearest(v))||void 0===s?void 0:s.isEditable))if(m.caretPositionFromPoint){let t=m.caretPositionFromPoint(f,d);t&&({offsetNode:y,offset:b}=t)}else if(m.caretRangeFromPoint){let e=m.caretRangeFromPoint(f,d);e&&(({startContainer:y,startOffset:b}=e),(!t.contentDOM.contains(y)||l.safari&&We(y,b,f)||l.chrome&&Fe(y,b,f))&&(y=void 0))}if(!y||!t.docView.dom.contains(y)){let e=At.find(t.docView,p);if(!e)return g>o.top+o.height/2?o.to:o.from;({node:y,offset:b}=Ne(e.dom,f,d))}let x=t.docView.nearest(y);if(!x)return null;if(x.isWidget&&1==(null===(r=x.dom)||void 0===r?void 0:r.nodeType)){let t=x.dom.getBoundingClientRect();return e.y<t.top||e.y<=t.bottom&&e.x<=(t.left+t.right)/2?x.posAtStart:x.posAtEnd}return x.localPosFromDOM(y,b)+x.posAtStart}function He(t,e,i,n,s){let o=Math.round((n-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>1.5*t.defaultLineHeight){let e=t.viewState.heightOracle.textHeight;o+=Math.floor((s-i.top-.5*(t.defaultLineHeight-e))/e)*t.viewState.heightOracle.lineLength}let h=t.state.sliceDoc(i.from,i.to);return i.from+(0,r.Gz)(h,o,t.state.tabSize)}function We(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 E(t,n-1,n).getBoundingClientRect().left>i}function Fe(t,e,i){if(0!=e)return!1;for(let n=t;;){let t=n.parentNode;if(!t||1!=t.nodeType||t.firstChild!=n)return!1;if(t.classList.contains("cm-line"))break;n=t}return i-(1==t.nodeType?t.getBoundingClientRect():E(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect()).left>5}function ze(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==a.Text))return n;return i}function _e(t,e,i,n){let s=ze(t,e.head),o=n&&s.type==a.Text&&(t.lineWrapping||s.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head):null;if(o){let e=t.dom.getBoundingClientRect(),n=t.textDirectionAt(s.from),h=t.posAtCoords({x:i==(n==c.LTR)?e.right-1:e.left+1,y:(o.top+o.bottom)/2});if(null!=h)return r.jT.cursor(h,i?-1:1)}return r.jT.cursor(i?s.to:s.from,i?-1:1)}function je(t,e,i,n){let s=t.state.doc.lineAt(e.head),o=t.bidiSpans(s),h=t.textDirectionAt(s.from);for(let l=e,a=null;;){let e=ge(s,o,h,l,i),c=de;if(!e){if(s.number==(i?t.state.doc.lines:1))return l;c="\n",s=t.state.doc.line(s.number+(i?1:-1)),o=t.bidiSpans(s),e=r.jT.cursor(i?s.from:s.to)}if(a){if(!a(c))return l}else{if(!n)return e;a=n(c)}l=e}}function qe(t,e,i){let n=t.state.charCategorizer(e),s=n(i);return t=>{let e=n(t);return s==r.D0.Space&&(s=e),s==e}}function $e(t,e,i,n){let s=e.head,o=i?1:-1;if(s==(i?t.state.doc.length:0))return r.jT.cursor(s,e.assoc);let h,l=e.goalColumn,a=t.contentDOM.getBoundingClientRect(),c=t.coordsAtPos(s),u=t.documentTop;if(c)null==l&&(l=c.left-a.left),h=o<0?c.top:c.bottom;else{let e=t.viewState.lineBlockAt(s);null==l&&(l=Math.min(a.right-a.left,t.defaultCharacterWidth*(s-e.from))),h=(o<0?e.top:e.bottom)+u}let f=a.left+l,d=null!=n?n:t.viewState.heightOracle.textHeight>>1;for(let g=0;;g+=10){let i=h+(d+g)*o,n=Ve(t,{x:f,y:i},!1,o);if(i<a.top||i>a.bottom||(o<0?n<s:n>s))return r.jT.cursor(n,e.assoc,void 0,l)}}function Ke(t,e,i){for(;;){let n=0;for(let s of t)s.between(e-1,e+1,((t,s,r)=>{if(e>t&&e<s){let r=n||i||(e-t<s-e?-1:1);e=r<0?t:s,n=r}}));if(!n)return e}}function Je(t,e,i){let n=Ke(t.state.facet(Ut).map((e=>e(t))),i.from,e.head>i.from?-1:1);return n==i.from?i:r.jT.cursor(n,n<i.from?1:-1)}class Ge{constructor(t){this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.chromeScrollHack=-1,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.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null;let e=(e,i)=>{this.ignoreDuringComposition(i)||"keydown"==i.type&&this.keydown(t,i)||(this.mustFlushObserver(i)&&t.observer.forceFlush(),this.runCustomHandlers(i.type,t,i)?i.preventDefault():e(t,i))};for(let i in ri){let n=ri[i];t.contentDOM.addEventListener(i,(i=>{si(t,i)&&e(n,i)}),oi[i]),this.registeredEvents.push(i)}t.scrollDOM.addEventListener("mousedown",(i=>{if(i.target==t.scrollDOM&&i.clientY>t.contentDOM.getBoundingClientRect().bottom&&(e(ri.mousedown,i),!i.defaultPrevented&&2==i.button)){let e=t.contentDOM.style.minHeight;t.contentDOM.style.minHeight="100%",setTimeout((()=>t.contentDOM.style.minHeight=e),200)}})),t.scrollDOM.addEventListener("drop",(i=>{i.target==t.scrollDOM&&i.clientY>t.contentDOM.getBoundingClientRect().bottom&&e(ri.drop,i)})),l.chrome&&102==l.chrome_version&&t.scrollDOM.addEventListener("wheel",(()=>{this.chromeScrollHack<0?t.contentDOM.style.pointerEvents="none":window.clearTimeout(this.chromeScrollHack),this.chromeScrollHack=setTimeout((()=>{this.chromeScrollHack=-1,t.contentDOM.style.pointerEvents=""}),100)}),{passive:!0}),this.notifiedFocused=t.hasFocus,l.safari&&t.contentDOM.addEventListener("input",(()=>null))}setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}ensureHandlers(t,e){var i;let n;this.customHandlers=[];for(let s of e)if(n=null===(i=s.update(t).spec)||void 0===i?void 0:i.domEventHandlers){this.customHandlers.push({plugin:s.value,handlers:n});for(let e in n)this.registeredEvents.indexOf(e)<0&&"scroll"!=e&&(this.registeredEvents.push(e),t.contentDOM.addEventListener(e,(i=>{si(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){Ft(e.state,n)}}return!1}runScrollHandlers(t,e){this.lastScrollTop=t.scrollDOM.scrollTop,this.lastScrollLeft=t.scrollDOM.scrollLeft;for(let n of this.customHandlers){let s=n.handlers.scroll;if(s)try{s.call(n.plugin,e,t)}catch(i){Ft(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(27!=e.keyCode&&Ye.indexOf(e.keyCode)<0&&(t.inputState.lastEscPress=0),l.android&&l.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))return t.observer.delayAndroidKey(e.key,e.keyCode),!0;let i;return!(!l.ios||e.synthetic||e.altKey||e.metaKey||!((i=Ue.find((t=>t.keyCode==e.keyCode)))&&!e.ctrlKey||Xe.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey))&&(this.pendingIOSKey=i||e,setTimeout((()=>this.flushIOSKey(t)),250),!0)}flushIOSKey(t){let e=this.pendingIOSKey;return!!e&&(this.pendingIOSKey=void 0,R(t.contentDOM,e.key,e.keyCode))}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(this.composing>0||!!(l.safari&&!l.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}mustFlushObserver(t){return"keydown"==t.type&&229!=t.keyCode}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 Ue=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Xe="dthko",Ye=[16,17,18,20,91,92,224,225],Qe=6;function Ze(t){return.7*Math.max(0,t)+8}class ti{constructor(t,e,i,n){this.view=t,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParent=M(t.contentDOM),this.atoms=t.state.facet(Ut).map((e=>e(t)));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(r.yy.allowMultipleSelections)&&ei(t,e),this.dragging=!(!ni(t,e)||1!=yi(e))&&null}start(t){!1===this.dragging&&(t.preventDefault(),this.select(t))}move(t){var e;if(0==t.buttons)return this.destroy();if(!1!==this.dragging)return;this.select(this.lastEvent=t);let i=0,n=0,s=(null===(e=this.scrollParent)||void 0===e?void 0:e.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},r=Yt(this.view);t.clientX-r.left<=s.left+Qe?i=-Ze(s.left-t.clientX):t.clientX+r.right>=s.right-Qe&&(i=Ze(t.clientX-s.right)),t.clientY-r.top<=s.top+Qe?n=-Ze(s.top-t.clientY):t.clientY+r.bottom>=s.bottom-Qe&&(n=Ze(t.clientY-s.bottom)),this.setScrollSpeed(i,n)}up(t){null==this.dragging&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval((()=>this.scroll()),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),!1===this.dragging&&this.select(this.lastEvent)}skipAtoms(t){let e=null;for(let i=0;i<t.ranges.length;i++){let n=t.ranges[i],s=null;if(n.empty){let t=Ke(this.atoms,n.from,0);t!=n.from&&(s=r.jT.cursor(t,-1))}else{let t=Ke(this.atoms,n.from,-1),e=Ke(this.atoms,n.to,1);t==n.from&&e==n.to||(s=r.jT.range(n.from==n.anchor?t:e,n.from==n.head?t:e))}s&&(e||(e=t.ranges.slice()),e[i]=s)}return e?r.jT.create(e,t.mainIndex):t}select(t){let{view:e}=this,i=this.skipAtoms(this.style.get(t,this.extend,this.multiple));!this.mustSelect&&i.eq(e.state.selection)&&i.main.assoc==e.state.selection.main.assoc||this.view.dispatch({selection:i,userEvent:"select.pointer"}),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 ei(t,e){let i=t.state.facet(Dt);return i.length?i[0](e):l.mac?e.metaKey:e.ctrlKey}function ii(t,e){let i=t.state.facet(Et);return i.length?i[0](e):l.mac?!e.altKey:!e.ctrlKey}function ni(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let n=d(t.root);if(!n||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 si(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=V.get(n))&&i.ignoreEvent(e))return!1;return!0}const ri=Object.create(null),oi=Object.create(null),hi=l.ie&&l.ie_version<15||l.ios&&l.webkit_version<604;function li(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(),ai(t,i.value)}),50)}function ai(t,e){let i,{state:n}=t,s=1,o=n.toText(e),h=o.lines==n.selection.ranges.length;if(null!=Mi&&n.selection.ranges.every((t=>t.empty))&&Mi==o.toString()){let t=-1;i=n.changeByRange((i=>{let l=n.doc.lineAt(i.from);if(l.from==t)return{range:i};t=l.from;let a=n.toText((h?o.line(s++).text:e)+n.lineBreak);return{changes:{from:l.from,insert:a},range:r.jT.cursor(i.from+a.length)}}))}else i=h?n.changeByRange((t=>{let e=o.line(s++);return{changes:{from:t.from,to:t.to,insert:e.text},range:r.jT.cursor(t.from+e.length)}})):n.replaceSelection(o);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function ci(t,e,i,n){if(1==n)return r.jT.cursor(e,i);if(2==n)return De(t.state,e,i);{let i=At.find(t.docView,e),n=t.state.doc.lineAt(i?i.posAtEnd:e),s=i?i.posAtStart:n.from,o=i?i.posAtEnd:n.to;return o<t.state.doc.length&&o==n.to&&o++,r.jT.range(s,o)}}ri.keydown=(t,e)=>{t.inputState.setSelectionOrigin("select"),27==e.keyCode&&(t.inputState.lastEscPress=Date.now())},ri.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},ri.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},oi.touchstart=oi.touchmove={passive:!0},ri.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return;let i=null;for(let n of t.state.facet(Rt))if(i=n(t,e),i)break;if(i||0!=e.button||(i=bi(t,e)),i){let n=t.root.activeElement!=t.contentDOM;t.inputState.startMouseSelection(new ti(t,e,i,n)),n&&t.observer.ignore((()=>D(t.contentDOM))),t.inputState.mouseSelection&&t.inputState.mouseSelection.start(e)}};let ui=(t,e)=>t>=e.top&&t<=e.bottom,fi=(t,e,i)=>ui(e,i)&&t>=i.left&&t<=i.right;function di(t,e,i,n){let s=At.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&&fi(i,n,o))return-1;let h=s.coordsAt(r,1);return h&&fi(i,n,h)?1:o&&ui(n,o)?-1:1}function gi(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:di(t,i,e.clientX,e.clientY)}}const pi=l.ie&&l.ie_version<=11;let mi=null,wi=0,vi=0;function yi(t){if(!pi)return t.detail;let e=mi,i=vi;return mi=t,vi=Date.now(),wi=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(wi+1)%3:1}function bi(t,e){let i=gi(t,e),n=yi(e),s=t.state.selection;return{update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),s=s.map(t.changes))},get(e,o,h){let l,a=gi(t,e),c=ci(t,a.pos,a.bias,n);if(i.pos!=a.pos&&!o){let e=ci(t,i.pos,i.bias,n),s=Math.min(e.from,c.from),o=Math.max(e.to,c.to);c=s<c.from?r.jT.range(s,o):r.jT.range(o,s)}return o?s.replaceRange(s.main.extend(c.from,c.to)):h&&1==n&&s.ranges.length>1&&(l=xi(s,a.pos))?l:h?s.addRange(c):r.jT.create([c])}}}function xi(t,e){for(let i=0;i<t.ranges.length;i++){let{from:n,to:s}=t.ranges[i];if(n<=e&&s>=e)return r.jT.create(t.ranges.slice(0,i).concat(t.ranges.slice(i+1)),t.mainIndex==i?0:t.mainIndex-(t.mainIndex>i?1:0))}return null}function Si(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&&ii(t,e)?{from:r.dragging.from,to:r.dragging.to}:null,h={from:s,insert:i},l=t.state.changes(o?[o,h]:h);t.focus(),t.dispatch({changes:l,selection:{anchor:l.mapPos(s,-1),head:l.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"})}function ki(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 Ai(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}}ri.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")},ri.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&&Si(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 Si(t,e,e.dataTransfer.getData("Text"),!0)},ri.paste=(t,e)=>{if(t.state.readOnly)return e.preventDefault();t.observer.flush();let i=hi?null:e.clipboardData;i?(ai(t,i.getData("text/plain")||i.getData("text/uri-text")),e.preventDefault()):li(t)};let Mi=null;ri.copy=ri.cut=(t,e)=>{let{text:i,ranges:n,linewise:s}=Ai(t.state);if(!i&&!s)return;Mi=s?i:null;let r=hi?null:e.clipboardData;r?(e.preventDefault(),r.clearData(),r.setData("text/plain",i)):ki(t,i),"cut"!=e.type||t.state.readOnly||t.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"})};const Ci=r.q6.define();function Oi(t,e){let i=[];for(let n of t.facet(Nt)){let s=n(t,e);s&&i.push(s)}return i?t.update({effects:i,annotations:Ci.of(!0)}):null}function Ti(t){setTimeout((()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=Oi(t.state,e);i?t.dispatch(i):t.update([])}}),10)}ri.focus=t=>{t.inputState.lastFocusTime=Date.now(),t.scrollDOM.scrollTop||!t.inputState.lastScrollTop&&!t.inputState.lastScrollLeft||(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),Ti(t)},ri.blur=t=>{t.observer.clearSelectionRange(),Ti(t)},ri.compositionstart=ri.compositionupdate=t=>{null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0)},ri.compositionend=t=>{t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,l.chrome&&l.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then((()=>t.observer.flush())):setTimeout((()=>{t.inputState.composing<0&&t.docView.compositionDeco.size&&t.update([])}),50)},ri.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},ri.beforeinput=(t,e)=>{var i;let n;if(l.chrome&&l.android&&(n=Ue.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 Di=["pre-wrap","normal","pre-line","break-spaces"];class Ei{constructor(t){this.lineWrapping=t,this.doc=r.xv.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,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.max(0,Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(t){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5))))*this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return Di.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let n=t[i];n<0?i++:this.heightSamples[Math.floor(10*n)]||(e=!0,this.heightSamples[Math.floor(10*n)]=!0)}return e}refresh(t,e,i,n,s,r){let o=Di.indexOf(t)>-1,h=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=e,this.charWidth=i,this.textHeight=n,this.lineLength=s,h){this.heightSamples={};for(let t=0;t<r.length;t++){let e=r[t];e<0?t++:this.heightSamples[Math.floor(10*e)]=!0}}return h}}class Ri{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class Bi{constructor(t,e,i,n,s){this.from=t,this.length=e,this.top=i,this.height=n,this._content=s}get type(){return"number"==typeof this._content?a.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof xt?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(t){let e=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new Bi(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var u=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}(u||(u={}));const Pi=.001;class Li{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)>Pi&&(t.heightChanged=!0),this.height=e)}replace(t,e,i){return Li.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,n){let s=this,r=i.doc;for(let o=n.length-1;o>=0;o--){let{fromA:h,toA:l,fromB:a,toB:c}=n[o],f=s.lineAt(h,u.ByPosNoHeight,i.setDoc(e),0,0),d=f.to>=l?f:s.lineAt(l,u.ByPosNoHeight,i,0,0);for(c+=d.to-l,l=d.to;o>0&&f.from<=n[o-1].toA;)h=n[o-1].fromA,a=n[o-1].fromB,o--,h<f.from&&(f=s.lineAt(h,u.ByPosNoHeight,i,0,0));a+=f.from-h,h=f.from;let g=zi.build(i.setDoc(r),t,a,c);s=s.replace(h,l,g)}return s.updateHeight(i,0)}static empty(){return new Ii(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 Hi(Li.of(t.slice(0,e)),r,Li.of(t.slice(i)))}}Li.prototype.size=1;class Ni extends Li{constructor(t,e,i){super(t,e),this.deco=i}blockAt(t,e,i,n){return new Bi(n,this.length,i,this.height,this.deco||0)}lineAt(t,e,i,n,s){return this.blockAt(0,i,n,s)}forEachLine(t,e,i,n,s,r){t<=s+this.length&&e>=s&&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 Ii extends Ni{constructor(t,e){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(t,e,i,n){return new Bi(n,this.length,i,this.height,this.breaks)}replace(t,e,i){let n=i[0];return 1==i.length&&(n instanceof Ii||n instanceof Vi&&4&n.flags)&&Math.abs(this.length-n.length)<10?(n instanceof Vi?n=new Ii(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):Li.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.breaks*t.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Vi extends Li{constructor(t){super(t,0)}heightMetrics(t,e){let i,n=t.doc.lineAt(e).number,s=t.doc.lineAt(e+this.length).number,r=s-n+1,o=0;if(t.lineWrapping){let e=Math.min(this.height,t.lineHeight*r);i=e/r,this.length>r+1&&(o=(this.height-e)/(this.length-r-1))}else i=this.height/r;return{firstLine:n,lastLine:s,perLine:i,perChar:o}}blockAt(t,e,i,n){let{firstLine:s,lastLine:r,perLine:o,perChar:h}=this.heightMetrics(e,n);if(e.lineWrapping){let s=n+Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length),r=e.doc.lineAt(s),l=o+r.length*h,a=Math.max(i,t-l/2);return new Bi(r.from,r.length,a,l,0)}{let n=Math.max(0,Math.min(r-s,Math.floor((t-i)/o))),{from:h,length:l}=e.doc.line(s+n);return new Bi(h,l,i+o*n,o,0)}}lineAt(t,e,i,n,s){if(e==u.ByHeight)return this.blockAt(t,i,n,s);if(e==u.ByPosNoHeight){let{from:e,to:n}=i.doc.lineAt(t);return new Bi(e,n-e,0,0,0)}let{firstLine:r,perLine:o,perChar:h}=this.heightMetrics(i,s),l=i.doc.lineAt(t),a=o+l.length*h,c=l.number-r,f=n+o*c+h*(l.from-s-c);return new Bi(l.from,l.length,Math.max(n,Math.min(f,n+this.height-a)),a,0)}forEachLine(t,e,i,n,s,r){t=Math.max(t,s),e=Math.min(e,s+this.length);let{firstLine:o,perLine:h,perChar:l}=this.heightMetrics(i,s);for(let a=t,c=n;a<=e;){let e=i.doc.lineAt(a);if(a==t){let i=e.number-o;c+=h*i+l*(t-s-i)}let n=h+l*e.length;r(new Bi(e.from,e.length,c,n,0)),c+=n,a=e.to+1}}replace(t,e,i){let n=this.length-e;if(n>0){let t=i[i.length-1];t instanceof Vi?i[i.length-1]=new Vi(t.length+n):i.push(null,new Vi(n-1))}if(t>0){let e=i[0];e instanceof Vi?i[0]=new Vi(t+e.length):i.unshift(new Vi(t-1),null)}return Li.of(i)}decomposeLeft(t,e){e.push(new Vi(t-1),null)}decomposeRight(t,e){e.push(null,new Vi(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;for(n.from>e&&i.push(new Vi(n.from-e-1).updateHeight(t,e));r<=s&&n.more;){let e=t.doc.lineAt(r).length;i.length&&i.push(null);let s=n.heights[n.index++];-1==o?o=s:Math.abs(s-o)>=Pi&&(o=-2);let h=new Ii(e,s);h.outdated=!1,i.push(h),r+=e+1}r<=s&&i.push(null,new Vi(s-r).updateHeight(t,r));let h=Li.of(i);return(o<0||Math.abs(h.height-this.height)>=Pi||Math.abs(o-this.heightMetrics(t,e).perLine)>=Pi)&&(t.heightChanged=!0),h}return(i||this.outdated)&&(this.setHeight(t,t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class Hi extends Li{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,h=e==u.ByHeight?t<r:t<o,l=h?this.left.lineAt(t,e,i,n,s):this.right.lineAt(t,e,i,r,o);if(this.break||(h?l.to<o:l.from>o))return l;let a=e==u.ByPosNoHeight?u.ByPosNoHeight:u.ByPos;return h?l.join(this.right.lineAt(o,a,i,r,o)):this.left.lineAt(o,a,i,n,s).join(l)}forEachLine(t,e,i,n,s,r){let o=n+this.left.height,h=s+this.left.length+this.break;if(this.break)t<h&&this.left.forEachLine(t,e,i,n,s,r),e>=h&&this.right.forEachLine(t,e,i,o,h,r);else{let l=this.lineAt(h,u.ByPos,i,n,s);t<l.from&&this.left.forEachLine(t,l.from-1,i,n,s,r),l.to>=t&&l.from<=e&&r(l),e>l.to&&this.right.forEachLine(l.to+1,e,i,o,h,r)}}replace(t,e,i){let n=this.left.length+this.break;if(e<n)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let s=[];t>0&&this.decomposeLeft(t,s);let r=s.length;for(let o of i)s.push(o);if(t>0&&Wi(s,r-1),e<this.length){let t=s.length;this.decomposeRight(e,s),Wi(s,t)}return Li.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?Li.of(this.break?[t,null,e]:[t,e]):(this.left=t,this.right=e,this.height=t.height+e.height,this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,i=!1,n){let{left:s,right:r}=this,o=e+s.length+this.break,h=null;return n&&n.from<=e+s.length&&n.more?h=s=s.updateHeight(t,e,i,n):s.updateHeight(t,e,i),n&&n.from<=o+r.length&&n.more?h=r=r.updateHeight(t,o,i,n):r.updateHeight(t,o,i),h?this.balanced(s,r):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Wi(t,e){let i,n;null==t[e]&&(i=t[e-1])instanceof Vi&&(n=t[e+1])instanceof Vi&&t.splice(e-1,3,new Vi(i.length+1+n.length))}const Fi=5;class zi{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 Ii?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new Ii(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,s=i.widget?i.widget.lineBreaks:0;n<0&&(n=this.oracle.lineHeight);let r=e-t;i.block?this.addBlock(new Ni(r,n,i)):(r||s||n>=Fi)&&this.addLineDeco(n,s,r)}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 Ii(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new Vi(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 Ii)return t;let e=new Ii(0,-1);return this.nodes.push(e),e}addBlock(t){var e;this.enterLine();let i=null===(e=t.deco)||void 0===e?void 0:e.type;i!=a.WidgetAfter||this.isCovered||this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,i!=a.WidgetBefore&&(this.covering=t)}addLineDeco(t,e,i){let n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,t),n.breaks+=e,this.writtenTo=this.pos=this.pos+i}finish(t){let e=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof Ii||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new Ii(0,-1));let i=t;for(let n of this.nodes)n instanceof Ii&&n.updateHeight(this.oracle,i),i+=n?n.length:1;return this.nodes}static build(t,e,i,n){let s=new zi(i,t);return r.Xs.spans(e,i,n,s,0),s.finish(i)}}function _i(t,e,i){let n=new ji;return r.Xs.compare(t,e,i,n,0),n.changes}class ji{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,n){(t<e||i&&i.heightRelevant||n&&n.heightRelevant)&&kt(t,e,this.changes,5)}}function qi(t,e){let i=t.getBoundingClientRect(),n=t.ownerDocument,s=n.defaultView||window,r=Math.max(0,i.left),o=Math.min(s.innerWidth,i.right),h=Math.max(0,i.top),l=Math.min(s.innerHeight,i.bottom);for(let a=t.parentNode;a&&a!=n.body;)if(1==a.nodeType){let e=a,i=window.getComputedStyle(e);if((e.scrollHeight>e.clientHeight||e.scrollWidth>e.clientWidth)&&"visible"!=i.overflow){let i=e.getBoundingClientRect();r=Math.max(r,i.left),o=Math.min(o,i.right),h=Math.max(h,i.top),l=a==t.parentNode?i.bottom:Math.min(l,i.bottom)}a="absolute"==i.position||"fixed"==i.position?e.offsetParent:e.parentNode}else{if(11!=a.nodeType)break;a=a.host}return{left:r-i.left,right:Math.max(r,o)-i.left,top:h-(i.top+e),bottom:Math.max(h,l)-(i.top+e)}}function $i(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class Ki{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 vt.replace({widget:new Ji(this.size,t)}).range(this.from,this.to)}}class Ji extends wt{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 Gi{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.scrollTop=0,this.scrolledToBottom=!0,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=tn,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=c.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let e=t.facet(Jt).some((t=>"function"!=typeof t&&"cm-lineWrapping"==t.class));this.heightOracle=new Ei(e),this.stateDeco=t.facet(Gt).filter((t=>"function"!=typeof t)),this.heightMap=Li.empty().applyChanges(this.stateDeco,r.xv.empty,this.heightOracle.setDoc(t.doc),[new Zt(0,0,0,t.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=vt.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 Ui(e,i))}}this.viewports=t.sort(((t,e)=>t.from-e.from)),this.scaler=this.heightMap.height<=7e6?tn:new en(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,(t=>{this.viewportLines.push(1==this.scaler.scale?t:nn(t,this.scaler))}))}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(Gt).filter((t=>"function"!=typeof t));let n=t.changedRanges,s=Zt.extendWithRanges(n,_i(i,this.stateDeco,t?t.changes:r.as.empty(this.state.doc.length))),o=this.heightMap.height,h=this.scrolledToBottom?null:this.lineBlockAtHeight(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),s),this.heightMap.height!=o&&(t.flags|=2),h?(this.scrollAnchorPos=t.changes.mapPos(h.from,-1),this.scrollAnchorHeight=h.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let l=s.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<l.from||e.range.head>l.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,e));let a=!t.changes.empty||2&t.flags||l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,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&&!t.state.facet(Vt)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),n=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?c.RTL:c.LTR;let o=this.heightOracle.mustRefreshForWrapping(s),h=e.getBoundingClientRect(),l=o||this.mustMeasureContent||this.contentDOMHeight!=h.height;this.contentDOMHeight=h.height,this.mustMeasureContent=!1;let a=0,u=0,f=parseInt(i.paddingTop)||0,d=parseInt(i.paddingBottom)||0;this.paddingTop==f&&this.paddingBottom==d||(this.paddingTop=f,this.paddingBottom=d,a|=10),this.editorWidth!=t.scrollDOM.clientWidth&&(n.lineWrapping&&(l=!0),this.editorWidth=t.scrollDOM.clientWidth,a|=8),this.scrollTop!=t.scrollDOM.scrollTop&&(this.scrollAnchorHeight=-1,this.scrollTop=t.scrollDOM.scrollTop),this.scrolledToBottom=this.scrollTop>t.scrollDOM.scrollHeight-t.scrollDOM.clientHeight-4;let g=(this.printing?$i:qi)(e,this.paddingTop),p=g.top-this.pixelViewport.top,m=g.bottom-this.pixelViewport.bottom;this.pixelViewport=g;let w=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(w!=this.inView&&(this.inView=w,w&&(l=!0)),!this.inView&&!this.scrollTarget)return 0;let v=h.width;if(this.contentDOMWidth==v&&this.editorHeight==t.scrollDOM.clientHeight||(this.contentDOMWidth=h.width,this.editorHeight=t.scrollDOM.clientHeight,a|=8),l){let e=t.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(e)&&(o=!0),o||n.lineWrapping&&Math.abs(v-this.contentDOMWidth)>n.charWidth){let{lineHeight:i,charWidth:r,textHeight:h}=t.docView.measureTextSize();o=i>0&&n.refresh(s,i,r,h,v/r,e),o&&(t.docView.minWidth=0,a|=8)}p>0&&m>0?u=Math.max(p,m):p<0&&m<0&&(u=Math.min(p,m)),n.heightChanged=!1;for(let i of this.viewports){let s=i.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(i);this.heightMap=(o?Li.empty().applyChanges(this.stateDeco,r.xv.empty,this.heightOracle,[new Zt(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(n,0,o,new Ri(i.from,s))}n.heightChanged&&(a|=2)}let y=!this.viewportIsAppropriate(this.viewport,u)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return y&&(this.viewport=this.getViewport(u,this.scrollTarget)),this.updateForViewport(),(2&a||y)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,t)),a|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),a}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),n=this.heightMap,s=this.heightOracle,{visibleTop:r,visibleBottom:o}=this,h=new Ui(n.lineAt(r-1e3*i,u.ByHeight,s,0,0).from,n.lineAt(o+1e3*(1-i),u.ByHeight,s,0,0).to);if(e){let{head:t}=e.range;if(t<h.from||t>h.to){let i,r=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),o=n.lineAt(t,u.ByPos,s,0,0);i="center"==e.y?(o.top+o.bottom)/2-r/2:"start"==e.y||"nearest"==e.y&&t<h.from?o.top:o.bottom-r,h=new Ui(n.lineAt(i-500,u.ByHeight,s,0,0).from,n.lineAt(i+r+500,u.ByHeight,s,0,0).to)}}return h}mapViewport(t,e){let i=e.mapPos(t.from,-1),n=e.mapPos(t.to,1);return new Ui(this.heightMap.lineAt(i,u.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,u.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(t,u.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(e,u.ByPos,this.heightOracle,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 Ki(e.mapPos(n.from),e.mapPos(n.to),n.size));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,s=n>>1,o=n<<1;if(this.defaultTextDirection!=c.LTR&&!i)return[];let h=[],l=(n,o,a,c)=>{if(o-n<s)return;let u=this.state.selection.main,f=[u.from];u.empty||f.push(u.to);for(let t of f)if(t>n&&t<o)return l(n,t-10,a,c),void l(t+10,o,a,c);let d=Zi(t,(t=>t.from>=a.from&&t.to<=a.to&&Math.abs(t.from-n)<s&&Math.abs(t.to-o)<s&&!f.some((e=>t.from<e&&t.to>e))));if(!d){if(o<a.to&&e&&i&&e.visibleRanges.some((t=>t.from<=o&&t.to>=o))){let t=e.moveToLineBoundary(r.jT.cursor(o),!1,!0).head;t>n&&(o=t)}d=new Ki(n,o,this.gapSize(a,n,o,c))}h.push(d)};for(let r of this.viewportLines){if(r.length<o)continue;let t=Xi(r.from,r.to,this.stateDeco);if(t.total<o)continue;let e,s,h=this.scrollTarget?this.scrollTarget.range.head:null;if(i){let i,o,l=n/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=h){let e=Qi(t,h),n=((this.visibleBottom-this.visibleTop)/2+l)/r.height;i=e-n,o=e+n}else i=(this.visibleTop-r.top-l)/r.height,o=(this.visibleBottom-r.top+l)/r.height;e=Yi(t,i),s=Yi(t,o)}else{let i,r,o=t.total*this.heightOracle.charWidth,l=n*this.heightOracle.charWidth;if(null!=h){let e=Qi(t,h),n=((this.pixelViewport.right-this.pixelViewport.left)/2+l)/o;i=e-n,r=e+n}else i=(this.pixelViewport.left-l)/o,r=(this.pixelViewport.right+l)/o;e=Yi(t,i),s=Yi(t,r)}e>r.from&&l(r.from,e,r,t),s<r.to&&l(s,r.to,r,t)}return h}gapSize(t,e,i,n){let s=Qi(n,i)-Qi(n,e);return this.heightOracle.lineWrapping?t.height*s:n.total*this.heightOracle.charWidth*s}updateLineGaps(t){Ki.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=vt.set(t.map((t=>t.draw(this.heightOracle.lineWrapping)))))}computeVisibleRanges(){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let e=[];r.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))||nn(this.heightMap.lineAt(t,u.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return nn(this.heightMap.lineAt(this.scaler.fromDOM(t),u.ByHeight,this.heightOracle,0,0),this.scaler)}elementAtHeight(t){return nn(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Ui{constructor(t,e){this.from=t,this.to=e}}function Xi(t,e,i){let n=[],s=t,o=0;return r.Xs.spans(i,t,e,{span(){},point(t,e){t>s&&(n.push({from:s,to:t}),o+=t-s),s=e}},20),s<e&&(n.push({from:s,to:e}),o+=e-s),{total:o,ranges:n}}function Yi({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 Qi(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 Zi(t,e){for(let i of t)if(e(i))return i}const tn={toDOM(t){return t},fromDOM(t){return t},scale:1};class en{constructor(t,e,i){let n=0,s=0,r=0;this.viewports=i.map((({from:i,to:s})=>{let r=e.lineAt(i,u.ByPos,t,0,0).top,o=e.lineAt(s,u.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 nn(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),n=e.toDOM(t.bottom);return new Bi(t.from,t.length,i,n-i,Array.isArray(t._content)?t._content.map((t=>nn(t,e))):t._content)}const sn=r.r$.define({combine:t=>t.join(" ")}),rn=r.r$.define({combine:t=>t.indexOf(!0)>-1}),on=o.V.newName(),hn=o.V.newName(),ln=o.V.newName(),an={"&light":"."+hn,"&dark":"."+ln};function cn(t,e,i){return new o.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 un=cn("."+on,{"&":{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,flexShrink:0,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",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",left:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",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"},".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"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},an);class fn{constructor(t,e,i,n){this.typeOver=n,this.bounds=null,this.text="";let{impreciseHead:s,impreciseAnchor:o}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let e=s||o?[]:pn(t),i=new me(e,t.state);i.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=i.text,this.newSel=mn(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=s&&s.node==e.focusNode&&s.offset==e.focusOffset||!g(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),n=o&&o.node==e.anchorNode&&o.offset==e.anchorOffset||!g(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset);this.newSel=r.jT.single(n,i)}}}function dn(t,e){let i,{newSel:n}=e,s=t.state.selection.main,o=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:n,to:h}=e.bounds,a=s.from,c=null;(8===o||l.android&&e.text.length<h-n)&&(a=s.to,c="end");let u=gn(t.state.doc.sliceString(n,h,pe),e.text,a-n,c);u&&(l.chrome&&13==o&&u.toB==u.from+2&&e.text.slice(u.from,u.toB)==pe+pe&&u.toB--,i={from:n+u.from,to:n+u.toA,insert:r.xv.of(e.text.slice(u.from,u.toB).split(pe))})}else n&&(!t.hasFocus&&t.state.facet(zt)||n.main.eq(s))&&(n=null);if(!i&&!n)return!1;if(!i&&e.typeOver&&!s.empty&&n&&n.main.empty?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,s.to)}:i&&i.from>=s.from&&i.to<=s.to&&(i.from!=s.from||i.to!=s.to)&&s.to-s.from-(i.to-i.from)<=4?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,s.to))}:(l.mac||l.android)&&i&&i.from==i.to&&i.from==s.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(n&&2==i.insert.length&&(n=r.jT.single(n.main.anchor-1,n.main.head-1)),i={from:s.from,to:s.to,insert:r.xv.of([" "])}):l.chrome&&i&&i.from==i.to&&i.from==s.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(n&&(n=r.jT.single(n.main.anchor-1,n.main.head-1)),i={from:s.from,to:s.to,insert:r.xv.of([" "])}),i){let e=t.state;if(l.ios&&t.inputState.flushIOSKey(t))return!0;if(l.android&&(i.from==s.from&&i.to==s.to&&1==i.insert.length&&2==i.insert.lines&&R(t.contentDOM,"Enter",13)||(i.from==s.from-1&&i.to==s.to&&0==i.insert.length||8==o&&i.insert.length<i.to-i.from)&&R(t.contentDOM,"Backspace",8)||i.from==s.from&&i.to==s.to+1&&0==i.insert.length&&R(t.contentDOM,"Delete",46)))return!0;let h,a=i.insert.toString();if(t.state.facet(Lt).some((e=>e(t,i.from,i.to,a))))return!0;if(t.inputState.composing>=0&&t.inputState.composing++,i.from>=s.from&&i.to<=s.to&&i.to-i.from>=(s.to-s.from)/3&&(!n||n.main.empty&&n.main.from==i.from+i.insert.length)&&t.inputState.composing<0){let n=s.from<i.from?e.sliceDoc(s.from,i.from):"",r=s.to>i.to?e.sliceDoc(i.to,s.to):"";h=e.replaceSelection(t.state.toText(n+i.insert.sliceString(0,void 0,t.state.lineBreak)+r))}else{let o=e.changes(i),l=n&&n.main.to<=o.newLength?n.main:void 0;if(e.selection.ranges.length>1&&t.inputState.composing>=0&&i.to<=s.to&&i.to>=s.to-10){let n=t.state.sliceDoc(i.from,i.to),a=xe(t)||t.state.doc.lineAt(s.head),c=s.to-i.to,u=s.to-s.from;h=e.changeByRange((h=>{if(h.from==s.from&&h.to==s.to)return{changes:o,range:l||h.map(o)};let f=h.to-c,d=f-n.length;if(h.to-h.from!=u||t.state.sliceDoc(d,f)!=n||a&&h.to>=a.from&&h.from<=a.to)return{range:h};let g=e.changes({from:d,to:f,insert:i.insert}),p=h.to-s.to;return{changes:g,range:l?r.jT.range(Math.max(0,l.anchor+p),Math.max(0,l.head+p)):h.map(g)}}))}else h={changes:o,selection:l&&e.selection.replaceRange(l)}}let c="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,c+=".compose",t.inputState.compositionFirstChange&&(c+=".start",t.inputState.compositionFirstChange=!1)),t.dispatch(h,{scrollIntoView:!0,userEvent:c}),!0}if(n&&!n.main.eq(s)){let e=!1,i="select";return t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(e=!0),i=t.inputState.lastSelectionOrigin),t.dispatch({selection:n,scrollIntoView:e,userEvent:i}),!0}return!1}function gn(t,e,i,n){let s=Math.min(t.length,e.length),r=0;for(;r<s&&t.charCodeAt(r)==e.charCodeAt(r);)r++;if(r==s&&t.length==e.length)return null;let o=t.length,h=e.length;for(;o>0&&h>0&&t.charCodeAt(o-1)==e.charCodeAt(h-1);)o--,h--;if("end"==n){i-=o+Math.max(0,r-Math.min(o,h))-r}if(o<r&&t.length<e.length){r-=i<=r&&i>=o?r-i:0,h=r+(h-o),o=r}else if(h<r){r-=i<=r&&i>=h?r-i:0,o=r+(o-h),h=r}return{from:r,toA:o,toB:h}}function pn(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 ve(i,n)),s==i&&r==n||e.push(new ve(s,r))),e}function mn(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?r.jT.single(i+e,n+e):null}const wn={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},vn=l.ie&&l.ie_version<=11;class yn{constructor(t){this.view=t,this.active=!1,this.selectionRange=new C,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.resizeContent=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);(l.ie&&l.ie_version<=11||l.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()})),vn&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver((()=>{var t;(null===(t=this.view.docView)||void 0===t?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()})),this.resizeScroll.observe(t.scrollDOM),this.resizeContent=new ResizeObserver((()=>this.view.requestMeasure())),this.resizeContent.observe(t.contentDOM)),this.addWindowListeners(this.win=t.win),this.start(),"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")))}),{threshold:[0,.001]}),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()}onScrollChanged(t){this.view.inputState.runScrollHandlers(this.view,t),this.intersecting&&this.view.measure()}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){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(zt)?i.root.activeElement!=this.dom:!m(i.dom,n))return;let s=n.anchorNode&&i.docView.nearest(n.anchorNode);s&&s.ignoreEvent(t)?e||(this.selectionChanged=!1):(l.ie&&l.ie_version<=11||l.android&&l.chrome)&&!i.state.selection.main.empty&&n.focusNode&&v(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=l.safari&&11==t.root.nodeType&&p(this.dom.ownerDocument)==this.dom&&xn(this.view)||d(t.root);if(!e||this.selectionRange.eq(e))return!1;let i=m(this.dom,e);return i&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&L(this.dom,e)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(e),i&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let i=this.dom;i;)if(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,wn),vn&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),vn&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var i;if(!this.delayedAndroidKey){let t=()=>{let t=this.delayedAndroidKey;if(t){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=t.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&t.force&&R(this.dom,t.key,t.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(t)}this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(null===(i=this.delayedAndroidKey)||void 0===i?void 0:i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame((()=>{this.delayedFlush=-1,this.flush()})))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,n=!1;for(let 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}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),n=this.selectionChanged&&m(this.dom,this.selectionRange);return t<0&&!n?null:(t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1,new fn(this.view,t,e,i))}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return!1;let i=this.view.state,n=dn(this.view,e);return this.view.state==i&&this.view.update([]),n}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=bn(e,t.previousSibling||t.target.previousSibling,-1),n=bn(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}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var t,e,i,n;this.stop(),null===(t=this.intersection)||void 0===t||t.disconnect(),null===(e=this.gapIntersection)||void 0===e||e.disconnect(),null===(i=this.resizeScroll)||void 0===i||i.disconnect(),null===(n=this.resizeContent)||void 0===n||n.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}}function bn(t,e,i){for(;e;){let n=V.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 xn(t){let e=null;function i(t){t.preventDefault(),t.stopImmediatePropagation(),e=t.getTargetRanges()[0]}if(t.contentDOM.addEventListener("beforeinput",i,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",i,!0),!e)return null;let n=e.startContainer,s=e.startOffset,r=e.endContainer,o=e.endOffset,h=t.docView.domAtPos(t.state.selection.main.anchor);return v(h.node,h.offset,r,o)&&([n,s,r,o]=[r,o,n,s]),{anchorNode:n,anchorOffset:s,focusNode:r,focusOffset:o}}class Sn{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: fixed; 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||B(t.parent)||document,this.viewState=new Gi(t.state||r.yy.create(t)),this.plugins=this.state.facet(jt).map((t=>new $t(t)));for(let e of this.plugins)e.update(this);this.observer=new yn(this),this.inputState=new Ge(this),this.inputState.ensureHandlers(this,this.plugins),this.docView=new ye(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}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}dispatch(...t){let e=1==t.length&&t[0]instanceof r.YW?t[0]:this.state.update(...t);this._dispatch(e,this)}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=!1,s=this.state;for(let r of t){if(r.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=r.state}if(this.destroyed)return void(this.viewState.state=s);let o=this.hasFocus,h=0,l=null;t.some((t=>t.annotation(Ci)))?(this.inputState.notifiedFocused=o,h=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=Oi(s,o),l||(h=1));let a=this.observer.delayedAndroidKey,c=null;if(a?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(c=null)):this.observer.clear(),s.facet(r.yy.phrases)!=this.state.facet(r.yy.phrases))return this.setState(s);e=te.create(this,s,t),e.flags|=h;let u=this.viewState.scrollTarget;try{this.updateState=2;for(let e of t){if(u&&(u=u.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection;u=new Ht(t.empty?t:r.jT.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(Wt)&&(u=t.value)}this.viewState.update(e,u),this.bidiCache=Mn.update(this.bidiCache,e.changes),e.empty||(this.updatePlugins(e),this.inputState.update(e)),i=this.docView.update(e),this.state.facet(Qt)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(i,t.some((t=>t.isUserEvent("select.pointer"))))}finally{this.updateState=0}if(e.startState.facet(sn)!=e.state.facet(sn)&&(this.viewState.mustMeasureContent=!0),(i||n||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!e.empty)for(let r of this.state.facet(Pt))r(e);(l||c)&&Promise.resolve().then((()=>{l&&this.state==l.startState&&this.dispatch(l),c&&!dn(this,c)&&a.force&&R(this.contentDOM,a.key,a.keyCode)}))}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 Gi(t),this.plugins=t.facet(jt).map((t=>new $t(t))),this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView=new ye(this),this.inputState.ensureHandlers(this,this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(jt),i=t.state.facet(jt);if(e!=i){let n=[];for(let s of i){let i=e.indexOf(s);if(i<0)n.push(new $t(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,this.plugins)}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&&this.win.cancelAnimationFrame(this.measureScheduled),this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,i=this.scrollDOM,{scrollTop:n}=i,{scrollAnchorPos:s,scrollAnchorHeight:r}=this.viewState;if(this.viewState.scrollAnchorHeight=-1,r<0||n!=this.viewState.scrollTop)if(n>i.scrollHeight-i.clientHeight-4)s=-1,r=this.viewState.heightMap.height;else{let t=this.viewState.lineBlockAtHeight(n);s=t.from,r=t.top}try{for(let t=0;;t++){this.updateState=1;let h=this.viewport,l=this.viewState.measure(this);if(!l&&!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 a=[];4&l||([this.measureRequests,a]=[a,this.measureRequests]);let c=a.map((t=>{try{return t.read(this)}catch(e){return Ft(this.state,e),An}})),u=te.create(this,this.state,[]),f=!1,d=!1;u.flags|=l,e?e.flags|=l:e=u,this.updateState=2,u.empty||(this.updatePlugins(u),this.inputState.update(u),this.updateAttrs(),f=this.docView.update(u));for(let t=0;t<a.length;t++)if(c[t]!=An)try{let e=a[t];e.write&&e.write(c[t],this)}catch(o){Ft(this.state,o)}if(this.viewState.editorHeight)if(this.viewState.scrollTarget)this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,d=!0;else if(r>-1){let t=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-r;(t>1||t<-1)&&(i.scrollTop=n+t,d=!0)}if(f&&this.docView.updateSelection(!0),this.viewport.from==h.from&&this.viewport.to==h.to&&!d&&0==this.measureRequests.length)break;r=-1}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let h of this.state.facet(Pt))h(e)}get themeClasses(){return on+" "+(this.state.facet(rn)?ln:hn)+" "+this.state.facet(sn)}updateAttrs(){let t=Cn(this,Kt,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(zt)?"true":"false",class:"cm-content",style:`${l.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),Cn(this,Jt,e);let i=this.observer.ignore((()=>{let i=mt(this.contentDOM,this.contentAttrs,e),n=mt(this.dom,this.editorAttrs,t);return i||n}));return this.editorAttrs=t,this.contentAttrs=e,i}showAnnouncements(t){let e=!0;for(let i of t)for(let t of i.effects)if(t.is(Sn.announce)){e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(Qt),o.V.mount(this.root,this.styleModules.concat(un).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=this.win.requestAnimationFrame((()=>this.measure()))),t){if(this.measureRequests.indexOf(t)>-1)return;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)}}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}}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return Je(this,t,je(this,t,e,i))}moveByGroup(t,e){return Je(this,t,je(this,t,e,(e=>qe(this,t.head,e))))}moveToLineBoundary(t,e,i=!0){return _e(this,t,e,i)}moveVertically(t,e,i){return Je(this,t,$e(this,t,e,i))}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){return this.readMeasured(),Ve(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);return S(i,s[ae.find(s,t-n.from,-1,e)].dir==c.LTR==e>0)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(It)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>kn)return fe(t.length);let e=this.textDirectionAt(t.from);for(let n of this.bidiCache)if(n.from==t.from&&n.dir==e)return n.order;let i=ue(t.text,e);return this.bidiCache.push(new Mn(t.from,t.to,e,i)),i}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||l.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{D(this.contentDOM),this.docView.updateSelection()}))}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((9==t.nodeType?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return Wt.of(new Ht("number"==typeof t?r.jT.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}static domEventHandlers(t){return qt.define((()=>({})),{eventHandlers:t})}static theme(t,e){let i=o.V.newName(),n=[sn.of(i),Qt.of(cn(`.${i}`,t))];return e&&e.dark&&n.push(rn.of(!0)),n}static baseTheme(t){return r.Wl.lowest(Qt.of(cn("."+on,t,an)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),n=i&&V.get(i)||V.get(t);return(null===(e=null==n?void 0:n.rootView)||void 0===e?void 0:e.view)||null}}Sn.styleModule=Qt,Sn.inputHandler=Lt,Sn.focusChangeEffect=Nt,Sn.perLineTextDirection=It,Sn.exceptionSink=Bt,Sn.updateListener=Pt,Sn.editable=zt,Sn.mouseSelectionStyle=Rt,Sn.dragMovesSelection=Et,Sn.clickAddsSelectionRange=Dt,Sn.decorations=Gt,Sn.atomicRanges=Ut,Sn.scrollMargins=Xt,Sn.darkTheme=rn,Sn.contentAttributes=Jt,Sn.editorAttributes=Kt,Sn.lineWrapping=Sn.contentAttributes.of({class:"cm-lineWrapping"}),Sn.announce=r.Py.define();const kn=4096,An={};class Mn{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:c.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 Mn(e.mapPos(r.from,1),e.mapPos(r.to,-1),r.dir,r.order))}return i}}function Cn(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&&gt(r,i)}return i}const On=!l.ios;const Tn={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};On&&(Tn[".cm-line"].caretColor="transparent !important");class Dn extends r.uU{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Dn.prototype.elementClass="",Dn.prototype.toDOM=void 0,Dn.prototype.mapMode=r.gc.TrackBefore,Dn.prototype.startSide=Dn.prototype.endSide=-1,Dn.prototype.point=!0;n()}catch(f){n(f)}}))},99173:function(t,e,i){i.d(e,{Jq:function(){return l},Lj:function(){return a},_b:function(){return E},i9:function(){return D},md:function(){return o},mp:function(){return d},vj:function(){return f}});i(52247),i(71695),i(92745),i(61495),i(84283),i(82328),i(55751),i(26200),i(25754),i(22246),i(77439),i(19423),i(19134),i(32517),i(5740),i(11740),i(44495),i(16132),i(36810),i(14953),i(58402),i(31503),i(16440),i(2213),i(57385),i(71375),i(15524),i(20267),i(46692),i(22139),i(39527),i(67670),i(13334),i(36993),i(47021);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=l.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});const h=Object.create(null);class l{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 l(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}}}}l.none=new l("",Object.create(null),0,8);class a{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 l(i.name,n,i.id,i.flags):i)}return new a(e)}}const c=new WeakMap,u=new WeakMap;var f;!function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"}(f||(f={}));class d{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=0){return new A(this.topNode,t)}cursorAt(t,e=0,i=0){let n=c.get(this)||this.topNode,s=new A(n);return s.moveTo(t,e),c.set(this,s._tree),s}get topNode(){return new y(this,0,0,null)}resolve(t,e=0){let i=v(c.get(this)||this.topNode,t,e,!1);return c.set(this,i),i}resolveInner(t,e=0){let i=v(u.get(this)||this.topNode,t,e,!0);return u.set(this,i),i}iterate(t){let{enter:e,leave:i,from:n=0,to:s=this.length}=t,r=t.mode||0,o=(r&f.IncludeAnonymous)>0;for(let h=this.cursor(r|f.IncludeAnonymous);;){let t=!1;if(h.from<=s&&h.to>=n&&(!o&&h.type.isAnonymous||!1!==e(h))){if(h.firstChild())continue;t=!0}for(;t&&i&&(o||!h.type.isAnonymous)&&i(h),!h.nextSibling();){if(!h.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(l.none,this.children,this.positions,0,this.children.length,0,this.length,((t,e,i)=>new d(this.type,t,e,i,this.propValues)),t.makeTree||((t,e,i)=>new d(l.none,t,e,i)))}static build(t){return function(t){var e;let{buffer:i,nodeSet:s,maxBufferLength:r=n,reused:h=[],minRepeatType:l=s.types.length}=t,a=Array.isArray(i)?new g(i,i.length):i,c=s.types,u=0,f=0;function m(t,e,i,n,o){let{id:d,start:g,end:S,size:k}=a,A=f;for(;k<0;){if(a.next(),-1==k){let e=h[d];return i.push(e),void n.push(g-t)}if(-3==k)return void(u=d);if(-4==k)return void(f=d);throw new RangeError(`Unrecognized record size: ${k}`)}let M,C,O=c[d],D=g-t;if(S-g<=r&&(C=b(a.pos-e,o))){let e=new Uint16Array(C.size-C.skip),i=a.pos-C.size,n=e.length;for(;a.pos>i;)n=x(C.start,e,n);M=new p(e,S-C.start,s),D=C.start-t}else{let t=a.pos-k;a.next();let e=[],i=[],n=d>=l?d:-1,s=0,o=S;for(;a.pos>t;)n>=0&&a.id==n&&a.size>=0?(a.end<=o-r&&(v(e,i,g,s,a.end,o,n,A),s=e.length,o=a.end),a.next()):m(g,t,e,i,n);if(n>=0&&s>0&&s<e.length&&v(e,i,g,s,g,o,n,A),e.reverse(),i.reverse(),n>-1&&s>0){let t=w(O);M=T(O,e,i,0,e.length,0,S-g,t,t)}else M=y(O,e,i,S-g,A-S)}i.push(M),n.push(D)}function w(t){return(e,i,n)=>{let s,r,h=0,l=e.length-1;if(l>=0&&(s=e[l])instanceof d){if(!l&&s.type==t&&s.length==n)return s;(r=s.prop(o.lookAhead))&&(h=i[l]+s.length+r)}return y(t,e,i,n,h)}}function v(t,e,i,n,r,o,h,l){let a=[],c=[];for(;t.length>n;)a.push(t.pop()),c.push(e.pop()+i-r);t.push(y(s.types[h],a,c,o-r,l-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 d(t,e,i,n,r)}function b(t,e){let i=a.fork(),n=0,s=0,o=0,h=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<h)break;let u=i.id>=l?4:0,f=i.start;for(i.next();i.pos>a;){if(i.size<0){if(-3!=i.size)break t;u+=4}else i.id>=l&&(u+=4);i.next()}s=f,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<l){let h=i;if(o>4){let n=a.pos-(o-4);for(;a.pos>n;)i=x(t,e,i)}e[--i]=h,e[--i]=r-t,e[--i]=s-t,e[--i]=n}else-3==o?u=n:-4==o&&(f=n);return i}let S=[],k=[];for(;a.pos>0;)m(t.start||0,t.bufferStart||0,S,k,-1);let A=null!==(e=t.length)&&void 0!==e?e:S.length?k[0]+S[0].length:0;return new d(c[t.topID],S.reverse(),k.reverse(),A)}(t)}}d.empty=new d(l.none,[],[],0);class g{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 g(this.buffer,this.index)}}class p{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return l.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)),i==(t+=4))return s;let r=[];for(;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 h=t;h!=e&&!(m(s,n,r[h+1],r[h+2])&&(o=h,i>0));h=r[h+3]);return o}slice(t,e,i){let n=this.buffer,s=new Uint16Array(e-t),r=0;for(let o=t,h=0;o<e;){s[h++]=n[o++],s[h++]=n[o++]-i;let e=s[h++]=n[o++]-i;s[h++]=n[o++]-t,r=Math.max(r,e)}return new p(s,r,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);for(;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){for(var s;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}let r=n?0:f.IgnoreOverlays;if(n)for(let o=t,h=o.parent;h;o=h,h=o.parent)o instanceof y&&o.index<0&&(null===(s=h.enter(e,i,r))||void 0===s?void 0:s.from)!=o.from&&(t=h);for(;;){let n=t.enter(e,i,r);if(!n)return t;t=n}}class y{constructor(t,e,i,n){this._tree=t,this.from=e,this.index=i,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,i,n,s=0){for(let r=this;;){for(let{children:h,positions:l}=r._tree,a=e>0?h.length:-1;t!=a;t+=e){let a=h[t],c=l[t]+r.from;if(m(n,i,c,c+a.length))if(a instanceof p){if(s&f.ExcludeBuffers)continue;let o=a.findChild(0,a.buffer.length,e,i-c,n);if(o>-1)return new k(new S(r,a,t,c),null,o)}else if(s&f.IncludeAnonymous||!a.type.isAnonymous||M(a)){let h;if(!(s&f.IgnoreMounts)&&a.props&&(h=a.prop(o.mounted))&&!h.overlay)return new y(h.tree,c,t,r);let l=new y(a,c,t,r);return s&f.IncludeAnonymous||!l.type.isAnonymous?l:l.nextChild(e<0?a.children.length-1:0,e,i,n)}}if(s&f.IncludeAnonymous||!r.type.isAnonymous)return null;if(t=r.index>=0?r.index+e:e<0?-1:r._parent._tree.children.length,r=r._parent,!r)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}enter(t,e,i=0){let n;if(!(i&f.IgnoreOverlays)&&(n=this._tree.prop(o.mounted))&&n.overlay){let i=t-this.from;for(let{from:t,to:s}of n.overlay)if((e>0?t<=i:t<i)&&(e<0?s>=i:s>i))return new y(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;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}cursor(t=0){return new A(this,t)}get tree(){return this._tree}toTree(){return this._tree}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._tree.toString()}get node(){return this}matchContext(t){return x(this,t)}}function b(t,e,i,n){let s=t.cursor(),r=[];if(!s.firstChild())return r;if(null!=i)for(;!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:[]}}function x(t,e,i=e.length-1){for(let n=t.parent;i>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[i]&&e[i]!=n.name)return!1;i--}}return!0}class S{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}}class k{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,i){this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}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=0){if(i&f.ExcludeBuffers)return null;let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return s<0?null:new k(this.context,this,s)}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))}cursor(t=0){return new A(this,t)}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];t.push(i.slice(n,s,r)),e.push(0)}return new d(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)}get node(){return this}matchContext(t){return x(this,t)}}class A{get name(){return this.type.name}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)}}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._tree.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=this.mode){return this.buffer?!(i&f.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&f.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&f.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode));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._tree.children.length;n!=s;n+=t){let t=i._tree.children[n];if(this.mode&f.IncludeAnonymous||t instanceof p||!t.type.isAnonymous||M(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){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,i=0;if(t&&t.context==this.buffer)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._tree}iterate(t,e){for(let i=0;;){let n=!1;if(this.type.isAnonymous||!1!==t(this)){if(this.firstChild()){i++;continue}this.type.isAnonymous||(n=!0)}for(;n&&e&&e(this),n=this.type.isAnonymous,!this.nextSibling();){if(!i)return;this.parent(),i--,n=!0}}}matchContext(t){if(!this.buffer)return x(this.node,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let n=t.length-1,s=this.stack.length-1;n>=0;s--){if(s<0)return x(this.node,t,n);let r=i[e.buffer[this.stack[s]]];if(!r.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}}function M(t){return t.children.some((t=>t instanceof p||!t.type.isAnonymous||M(t)))}const C=new WeakMap;function O(t,e){if(!t.isAnonymous||e instanceof p||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 d)){i=1;break}i+=O(t,n)}C.set(e,i)}return i}function T(t,e,i,n,s,r,o,h,l){let a=0;for(let d=n;d<s;d++)a+=O(t,e[d]);let c=Math.ceil(1.5*a/8),u=[],f=[];return function e(i,n,s,o,h){for(let a=s;a<o;){let s=a,d=n[a],g=O(t,i[a]);for(a++;a<o;a++){let e=O(t,i[a]);if(g+e>=c)break;g+=e}if(a==s+1){if(g>c){let t=i[s];e(t.children,t.positions,0,t.children.length,n[s]+h);continue}u.push(i[s])}else{let e=n[a-1]+i[a-1].length-d;u.push(T(t,i,n,s,a,d,e,null,l))}f.push(d+h-r)}}(e,i,n,s,0),(h||l)(u,f,o)}class D{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 D(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,h=0,l=0;;o++){let a=o<e.length?e[o]:null,c=a?a.fromA:1e9;if(c-h>=i)for(;r&&r.from<c;){let e=r;if(h>=e.from||c<=e.to||l){let t=Math.max(e.from,h)-l,i=Math.min(e.to,c)-l;e=t>=i?null:new D(t,i,e.tree,e.offset+l,o>0,!!a)}if(e&&n.push(e),r.to>c)break;r=s<t.length?t[s++]:null}if(!a)break;h=a.toA,l=a.toA-a.toB}return n}}class E{startParse(t,e,i){return"string"==typeof t&&(t=new R(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 R{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)}}new o({perNode:!0})},73928:function(t,e,i){i.d(e,{BO:function(){return Ot},D0:function(){return St},Gz:function(){return $t},IS:function(){return qt},Py:function(){return gt},QQ:function(){return $},Wl:function(){return Y},Xs:function(){return Bt},YW:function(){return pt},as:function(){return O},cp:function(){return w},f_:function(){return Pt},gc:function(){return M},jT:function(){return N},n0:function(){return C},q6:function(){return ut},r$:function(){return H},uU:function(){return Tt},xv:function(){return n},yy:function(){return Ct}});i(63721),i(52247),i(71695),i(92745),i(52805),i(61495),i(61893),i(23669),i(69235),i(12385),i(19134),i(32517),i(5740),i(11740),i(92519),i(42179),i(89256),i(24931),i(88463),i(57449),i(19814),i(97003),i(32114),i(39527),i(92181),i(99790),i(67670),i(41360),i(13334),i(34595),i(36993),i(47021);class n{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){[t,e]=f(this,t,e);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),r.from(n,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){[t,e]=f(this,t,e);let i=[];return this.decompose(t,e,i,0),r.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 l(this),s=new l(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 l(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 c(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}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 s(t):r.from(s.split(t,[])):n.empty}}class s extends n{constructor(t,e=function(t){let e=-1;for(let i of t)e+=i.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.text[s],o=n+r.length;if((e?i:o)>=t)return new u(n,o,i,r);n=o+1,i++}}decompose(t,e,i,n){let r=t<=0&&e>=this.length?this:new s(h(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&n){let t=i.pop(),e=o(r.text,t.text.slice(),0,r.length);if(e.length<=32)i.push(new s(e,t.length+r.length));else{let t=e.length>>1;i.push(new s(e.slice(0,t)),new s(e.slice(t)))}}else i.push(r)}replace(t,e,i){if(!(i instanceof s))return super.replace(t,e,i);[t,e]=f(this,t,e);let n=o(this.text,o(i.text,h(this.text,0,t)),e),l=this.length+i.length-(e-t);return n.length<=32?new s(n,l):r.from(s.split(n,[]),l)}sliceString(t,e=this.length,i="\n"){[t,e]=f(this,t,e);let n="";for(let s=0,r=0;s<=e&&r<this.text.length;r++){let o=this.text[r],h=s+o.length;s>t&&r&&(n+=i),t<h&&e>s&&(n+=o.slice(Math.max(0,t-s),e-s)),s=h+1}return n}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],n=-1;for(let r of t)i.push(r),n+=r.length+1,32==i.length&&(e.push(new s(i,n)),i=[],n=-1);return n>-1&&e.push(new s(i,n)),e}}class r extends n{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,h=i+r.lines-1;if((e?h:o)>=t)return r.lineInner(t,e,i,n);n=o+1,i=h+1}}decompose(t,e,i,n){for(let s=0,r=0;r<=e&&s<this.children.length;s++){let o=this.children[s],h=r+o.length;if(t<=h&&e>=r){let s=n&((r<=t?1:0)|(h>=e?2:0));r>=t&&h<=e&&!s?i.push(o):o.decompose(t-r,e-r,i,s)}r=h+1}}replace(t,e,i){if([t,e]=f(this,t,e),i.lines<this.lines)for(let n=0,s=0;n<this.children.length;n++){let o=this.children[n],h=s+o.length;if(t>=s&&e<=h){let l=o.replace(t-s,e-s,i),a=this.lines-o.lines+l.lines;if(l.lines<a>>4&&l.lines>a>>6){let s=this.children.slice();return s[n]=l,new r(s,this.length-(e-t)+i.length)}return super.replace(s,h,l)}s=h+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i="\n"){[t,e]=f(this,t,e);let n="";for(let s=0,r=0;s<this.children.length&&r<=e;s++){let o=this.children[s],h=r+o.length;r>t&&s&&(n+=i),t<h&&e>r&&(n+=o.sliceString(t-r,e-r,i)),r=h+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof r))return 0;let i=0,[n,s,o,h]=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==o||s==h)return i;let r=this.children[n],l=t.children[s];if(r!=l)return i+r.scanIdentical(l,e);i+=r.length+1}}static from(t,e=t.reduce(((t,e)=>t+e.length+1),-1)){let i=0;for(let s of t)i+=s.lines;if(i<32){let i=[];for(let e of t)e.flatten(i);return new s(i,e)}let n=Math.max(32,i>>5),o=n<<1,h=n>>1,l=[],a=0,c=-1,u=[];function f(t){let e;if(t.lines>o&&t instanceof r)for(let i of t.children)f(i);else t.lines>h&&(a>h||!a)?(d(),l.push(t)):t instanceof s&&a&&(e=u[u.length-1])instanceof s&&t.lines+e.lines<=32?(a+=t.lines,c+=t.length+1,u[u.length-1]=new s(e.text.concat(t.text),e.length+1+t.length)):(a+t.lines>n&&d(),a+=t.lines,c+=t.length+1,u.push(t))}function d(){0!=a&&(l.push(1==u.length?u[0]:r.from(u,c)),c=-1,a=u.length=0)}for(let s of t)f(s);return d(),1==l.length?l[0]:new r(l,e)}}function o(t,e,i=0,n=1e9){for(let s=0,r=0,o=!0;r<t.length&&s<=n;r++){let h=t[r],l=s+h.length;l>=i&&(l>n&&(h=h.slice(0,n-s)),s<i&&(h=h.slice(i-s)),o?(e[e.length-1]+=h,o=!1):e.push(h)),s=l+1}return e}function h(t,e,i){return o(t,[""],e,i)}n.empty=new s([""],0);class l{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 s?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],r=this.offsets[i],o=r>>1,h=n instanceof s?n.text.length:n.children.length;if(o==(e>0?h: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&r)==(e>0?0:1)){if(this.offsets[i]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(n instanceof s){let s=n.text[o+(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 r=n.children[o+(e<0?-1:0)];t>r.length?(t-=r.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(r),this.offsets.push(e>0?1:(r instanceof s?r.text.length:r.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 l(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 c{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:n}=this.inner.next(t);return e&&this.afterBreak?(this.value="",this.afterBreak=!1):e?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(n.prototype[Symbol.iterator]=function(){return this.iter()},l.prototype[Symbol.iterator]=a.prototype[Symbol.iterator]=c.prototype[Symbol.iterator]=function(){return this});class u{constructor(t,e,i,n){this.from=t,this.to=e,this.number=i,this.text=n}get length(){return this.to-this.from}}function f(t,e,i){return[e=Math.max(0,Math.min(t.length,e)),Math.max(e,Math.min(t.length,i))]}let d="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 Jt=1;Jt<d.length;Jt++)d[Jt]+=d[Jt-1];function g(t){for(let e=1;e<d.length;e+=2)if(d[e]>t)return d[e-1]<=t;return!1}function p(t){return t>=127462&&t<=127487}const m=8205;function w(t,e,i=!0,n=!0){return(i?v:y)(t,e,n)}function v(t,e,i){if(e==t.length)return e;e&&b(t.charCodeAt(e))&&x(t.charCodeAt(e-1))&&e--;let n=S(t,e);for(e+=k(n);e<t.length;){let s=S(t,e);if(n==m||s==m||i&&g(s))e+=k(s),n=s;else{if(!p(s))break;{let i=0,n=e-2;for(;n>=0&&p(S(t,n));)i++,n-=2;if(i%2==0)break;e+=2}}}return e}function y(t,e,i){for(;e>0;){let n=v(t,e-2,i);if(n<e)return n;e--}return 0}function b(t){return t>=56320&&t<57344}function x(t){return t>=55296&&t<56320}function S(t,e){let i=t.charCodeAt(e);if(!x(i)||e+1==t.length)return i;let n=t.charCodeAt(e+1);return b(n)?n-56320+(i-55296<<10)+65536:i}function k(t){return t<65536?1:2}const A=/\r\n?|\n/;var M=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(M||(M={}));class C{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){E(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 C(t)}composeDesc(t){return this.empty?t:t.empty?this:B(this,t)}mapDesc(t,e=!1){return t.empty?this:R(this,t,e)}mapPos(t,e=-1,i=M.Simple){let n=0,s=0;for(let r=0;r<this.sections.length;){let o=this.sections[r++],h=this.sections[r++],l=n+o;if(h<0){if(l>t)return s+(t-n);s+=o}else{if(i!=M.Simple&&l>=t&&(i==M.TrackDel&&n<t&&l>t||i==M.TrackBefore&&n<t||i==M.TrackAfter&&l>t))return null;if(l>t||l==t&&e<0&&!o)return t==n||e<0?s:s+h;s+=h}n=l}if(t>n)throw new RangeError(`Position ${t} is out of range for changeset of length ${n}`);return s}touchesRange(t,e=t){for(let i=0,n=0;i<this.sections.length&&n<=e;){let s=n+this.sections[i++];if(this.sections[i++]>=0&&n<=e&&s>=t)return!(n<t&&s>e)||"cover";n=s}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];t+=(t?" ":"")+i+(n>=0?":"+n:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some((t=>"number"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeDesc");return new C(t)}static create(t){return new C(t)}}class O extends C{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 E(this,((e,i,n,s,r)=>t=t.replace(n,n+(i-e),r)),!1),t}mapDesc(t,e=!1){return R(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let s=0,r=0;s<e.length;s+=2){let o=e[s],h=e[s+1];if(h>=0){e[s]=h,e[s+1]=o;let l=s>>1;for(;i.length<l;)i.push(n.empty);i.push(o?t.slice(r,r+o):n.empty)}r+=o}return new O(e,i)}compose(t){return this.empty?t:t.empty?this:B(this,t,!0)}map(t,e=!1){return t.empty?this:R(this,t,e,!0)}iterChanges(t,e=!1){E(this,t,e)}get desc(){return C.create(this.sections)}filter(t){let e=[],i=[],n=[],s=new P(this);t:for(let r=0,o=0;;){let h=r==t.length?1e9:t[r++];for(;o<h||o==h&&0==s.len;){if(s.done)break t;let t=Math.min(s.len,h-o);T(n,t,-1);let r=-1==s.ins?-1:0==s.off?s.ins:0;T(e,t,r),r>0&&D(i,e,s.text),s.forward(t),o+=t}let l=t[r++];for(;o<l;){if(s.done)break t;let t=Math.min(s.len,l-o);T(e,t,-1),T(n,t,-1==s.ins?-1:0==s.off?s.ins:0),s.forward(t),o+=t}}return{changes:new O(e,i),filtered:C.create(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 s=[],r=[],o=0,h=null;function l(t=!1){if(!t&&!s.length)return;o<e&&T(s,e-o,-1);let i=new O(s,r);h=h?h.compose(i.map(h)):i,s=[],r=[],o=0}return function t(a){if(Array.isArray(a))for(let e of a)t(e);else if(a instanceof O){if(a.length!=e)throw new RangeError(`Mismatched change set length (got ${a.length}, expected ${e})`);l(),h=h?h.compose(a.map(h)):a}else{let{from:t,to:h=t,insert:c}=a;if(t>h||t<0||h>e)throw new RangeError(`Invalid change range ${t} to ${h} (in doc of length ${e})`);let u=c?"string"==typeof c?n.of(c.split(i||A)):c:n.empty,f=u.length;if(t==h&&0==f)return;t<o&&l(),t>o&&T(s,t-o,-1),T(s,h-t,f),D(r,s,u),o=h}}(t),l(!h),h}static empty(t){return new O(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],i=[];for(let s=0;s<t.length;s++){let r=t[s];if("number"==typeof r)e.push(r,-1);else{if(!Array.isArray(r)||"number"!=typeof r[0]||r.some(((t,e)=>e&&"string"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==r.length)e.push(r[0],0);else{for(;i.length<s;)i.push(n.empty);i[s]=n.of(r.slice(1)),e.push(r[0],i[s].length)}}}return new O(e,i)}static createSet(t,e){return new O(t,e)}}function T(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 D(t,e,i){if(0==i.length)return;let s=e.length-2>>1;if(s<t.length)t[t.length-1]=t[t.length-1].append(i);else{for(;t.length<s;)t.push(n.empty);t.push(i)}}function E(t,e,i){let s=t.inserted;for(let r=0,o=0,h=0;h<t.sections.length;){let l=t.sections[h++],a=t.sections[h++];if(a<0)r+=l,o+=l;else{let c=r,u=o,f=n.empty;for(;c+=l,u+=a,a&&s&&(f=f.append(s[h-2>>1])),!(i||h==t.sections.length||t.sections[h+1]<0);)l=t.sections[h++],a=t.sections[h++];e(r,c,o,u,f),r=c,o=u}}}function R(t,e,i,n=!1){let s=[],r=n?[]:null,o=new P(t),h=new P(e);for(let l=-1;;)if(-1==o.ins&&-1==h.ins){let t=Math.min(o.len,h.len);T(s,t,-1),o.forward(t),h.forward(t)}else if(h.ins>=0&&(o.ins<0||l==o.i||0==o.off&&(h.len<o.len||h.len==o.len&&!i))){let t=h.len;for(T(s,h.ins,-1);t;){let e=Math.min(o.len,t);o.ins>=0&&l<o.i&&o.len<=e&&(T(s,0,o.ins),r&&D(r,s,o.text),l=o.i),o.forward(e),t-=e}h.next()}else{if(!(o.ins>=0)){if(o.done&&h.done)return r?O.createSet(s,r):C.create(s);throw new Error("Mismatched change set lengths")}{let t=0,e=o.len;for(;e;)if(-1==h.ins){let i=Math.min(e,h.len);t+=i,e-=i,h.forward(i)}else{if(!(0==h.ins&&h.len<e))break;e-=h.len,h.next()}T(s,t,l<o.i?o.ins:0),r&&l<o.i&&D(r,s,o.text),l=o.i,o.forward(o.len-e)}}}function B(t,e,i=!1){let n=[],s=i?[]:null,r=new P(t),o=new P(e);for(let h=!1;;){if(r.done&&o.done)return s?O.createSet(n,s):C.create(n);if(0==r.ins)T(n,r.len,0,h),r.next();else if(0!=o.len||o.done){if(r.done||o.done)throw new Error("Mismatched change set lengths");{let t=Math.min(r.len2,o.len),e=n.length;if(-1==r.ins){let e=-1==o.ins?-1:o.off?0:o.ins;T(n,t,e,h),s&&e&&D(s,n,o.text)}else-1==o.ins?(T(n,r.off?0:r.len,t,h),s&&D(s,n,r.textBit(t))):(T(n,r.off?0:r.len,o.off?0:o.ins,h),s&&!o.off&&D(s,n,o.text));h=(r.ins>t||o.ins>=0&&o.len>t)&&(h||n.length>e),r.forward2(t),o.forward(t)}}else T(n,0,o.ins,h),s&&D(s,n,o.text),o.next()}}class P{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.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?n.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 L{constructor(t,e,i){this.from=t,this.to=e,this.flags=i}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let t=7&this.flags;return 7==t?null:t}get goalColumn(){let t=this.flags>>6;return 16777215==t?void 0:t}map(t,e=-1){let i,n;return this.empty?i=n=t.mapPos(this.from,e):(i=t.mapPos(this.from,1),n=t.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new L(i,n,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return N.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return N.range(this.anchor,i)}eq(t,e=!1){return!(this.anchor!=t.anchor||this.head!=t.head||e&&this.empty&&this.assoc!=t.assoc)}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 N.range(t.anchor,t.head)}static create(t,e,i){return new L(t,e,i)}}class N{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:N.create(this.ranges.map((i=>i.map(t,e))),this.mainIndex)}eq(t,e=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(t.ranges[i],e))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new N([this.main],0)}addRange(t,e=!0){return N.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,N.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 N(t.ranges.map((t=>L.fromJSON(t))),t.main)}static single(t,e=t){return new N([N.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 N.normalized(t.slice(),e);i=s.to}return new N(t,e)}static cursor(t,e=0,i,n){return L.create(t,t,(0==e?0:e<0?8:16)|(null==i?7:Math.min(6,i))|(null!=n?n:16777215)<<6)}static range(t,e,i,n){let s=(null!=i?i:16777215)<<6|(null==n?7:Math.min(6,n));return e<t?L.create(e,t,48|s):L.create(t,e,(e>t?8:0)|s)}static normalized(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?N.range(o,r):N.range(r,o))}}return new N(t,e)}}function I(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let V=0;class H{constructor(t,e,i,n,s){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=V++,this.default=t([]),this.extensions="function"==typeof s?s(this):s}get reader(){return this}static define(t={}){return new H(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:W),!!t.static,t.enables)}of(t){return new F([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new F(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new F(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],(i=>e(i.field(t))))}}function W(t,e){return t==e||t.length==e.length&&t.every(((t,i)=>t===e[i]))}class F{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=this.id,r=t[s]>>1,o=2==this.type,h=!1,l=!1,a=[];for(let c of this.dependencies)"doc"==c?h=!0:"selection"==c?l=!0:1&(null!==(e=t[c.id])&&void 0!==e?e:1)||a.push(t[c.id]);return{create(t){return t.values[r]=i(t),1},update(t,e){if(h&&e.docChanged||l&&(e.docChanged||e.selection)||_(t,a)){let e=i(t);if(o?!z(e,t.values[r],n):!n(e,t.values[r]))return t.values[r]=e,1}return 0},reconfigure:(t,e)=>{let h,l=e.config.address[s];if(null!=l){let s=nt(e,l);if(this.dependencies.every((i=>i instanceof H?e.facet(i)===t.facet(i):!(i instanceof $)||e.field(i,!1)==t.field(i,!1)))||(o?z(h=i(t),s,n):n(h=i(t),s)))return t.values[r]=s,0}else h=i(t);return t.values[r]=h,1}}}}function z(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 _(t,e){let i=!1;for(let n of e)1&it(t,n)&&(i=!0);return i}function j(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;function h(t){let i=[];for(let e=0;e<n.length;e++){let r=nt(t,n[e]);if(2==s[e])for(let t of r)i.push(t);else i.push(r)}return e.combine(i)}return{create(t){for(let e of n)it(t,e);return t.values[o]=h(t),1},update(t,i){if(!_(t,r))return 0;let n=h(t);return e.compare(n,t.values[o])?0:(t.values[o]=n,1)},reconfigure(t,s){let r=_(t,n),l=s.config.facets[e.id],a=s.facet(e);if(l&&!r&&W(i,l))return t.values[o]=a,0;let c=h(t);return e.compare(c,a)?(t.values[o]=a,0):(t.values[o]=c,1)}}}const q=H.define({static:!0});class ${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 $(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(q).find((t=>t.field==this));return((null==e?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:t=>(t.values[e]=this.create(t),1),update:(t,i)=>{let n=t.values[e],s=this.updateF(n,i);return this.compareF(n,s)?0:(t.values[e]=s,1)},reconfigure:(t,i)=>null!=i.config.address[this.id]?(t.values[e]=i.field(this),0):(t.values[e]=this.create(t),1)}}init(t){return[this,q.of({field:this,create:t})]}get extension(){return this}}const K=4,J=3,G=2,U=1;function X(t){return e=>new Q(e,t)}const Y={highest:X(0),high:X(U),default:X(G),low:X(J),lowest:X(K)};class Q{constructor(t,e){this.inner=t,this.prec=e}}class Z{of(t){return new tt(this,t)}reconfigure(t){return Z.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class tt{constructor(t,e){this.compartment=t,this.inner=e}}class et{constructor(t,e,i,n,s,r){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=s,this.facets=r,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return null==e?t.default:this.staticValues[e>>1]}static resolve(t,e,i){let n=[],s=Object.create(null),r=new Map;for(let u of function(t,e,i){let n=[[],[],[],[],[]],s=new Map;function r(t,o){let h=s.get(t);if(null!=h){if(h<=o)return;let e=n[h].indexOf(t);e>-1&&n[h].splice(e,1),t instanceof tt&&i.delete(t.compartment)}if(s.set(t,o),Array.isArray(t))for(let e of t)r(e,o);else if(t instanceof tt){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 Q)r(t.inner,t.prec);else if(t instanceof $)n[o].push(t),t.provides&&r(t.provides,o);else if(t instanceof F)n[o].push(t),t.facet.extensions&&r(t.facet.extensions,G);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,G),n.reduce(((t,e)=>t.concat(e)))}(t,e,r))u instanceof $?n.push(u):(s[u.facet.id]||(s[u.facet.id]=[])).push(u);let o=Object.create(null),h=[],l=[];for(let u of n)o[u.id]=l.length<<1,l.push((t=>u.slot(t)));let a=null==i?void 0:i.config.facets;for(let u in s){let t=s[u],e=t[0].facet,n=a&&a[u]||[];if(t.every((t=>0==t.type)))if(o[e.id]=h.length<<1|1,W(n,t))h.push(i.facet(e));else{let n=e.combine(t.map((t=>t.value)));h.push(i&&e.compare(n,i.facet(e))?i.facet(e):n)}else{for(let e of t)0==e.type?(o[e.id]=h.length<<1|1,h.push(e.value)):(o[e.id]=l.length<<1,l.push((t=>e.dynamicSlot(t))));o[e.id]=l.length<<1,l.push((i=>j(i,e,t)))}}let c=l.map((t=>t(o)));return new et(t,r,c,o,h,s)}}function it(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.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|s}function nt(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const st=H.define(),rt=H.define({combine:t=>t.some((t=>t)),static:!0}),ot=H.define({combine:t=>t.length?t[0]:void 0,static:!0}),ht=H.define(),lt=H.define(),at=H.define(),ct=H.define({combine:t=>!!t.length&&t[0]});class ut{constructor(t,e){this.type=t,this.value=e}static define(){return new ft}}class ft{of(t){return new ut(this,t)}}class dt{constructor(t){this.map=t}of(t){return new gt(this,t)}}class gt{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 gt(this.type,e)}is(t){return this.type==t}static define(t={}){return new dt(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}}gt.reconfigure=gt.define(),gt.appendConfig=gt.define();class pt{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&&I(i,e.newLength),s.some((t=>t.type==pt.time))||(this.annotations=s.concat(pt.time.of(Date.now())))}static create(t,e,i,n,s,r){return new pt(t,e,i,n,s,r)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(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(pt.userEvent);return!(!e||!(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function mt(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 wt(t,e,i){var n;let s,r,o;return i?(s=e.changes,r=O.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:gt.mapEffects(t.effects,s).concat(gt.mapEffects(e.effects,r)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function vt(t,e,i){let n=e.selection,s=xt(e.annotations);return e.userEvent&&(s=s.concat(pt.userEvent.of(e.userEvent))),{changes:e.changes instanceof O?e.changes:O.of(e.changes||[],i,t.facet(ot)),selection:n&&(n instanceof N?n:N.single(n.anchor,n.head)),effects:xt(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function yt(t,e,i){let n=vt(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=wt(n,vt(t,e[r],s?n.changes.newLength:t.doc.length),s)}let s=pt.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return function(t){let e=t.startState,i=e.facet(at),n=t;for(let s=i.length-1;s>=0;s--){let r=i[s](t);r&&Object.keys(r).length&&(n=wt(n,vt(e,r,t.changes.newLength),!0))}return n==t?t:pt.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}(i?function(t){let e=t.startState,i=!0;for(let s of e.facet(ht)){let e=s(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:mt(i,e))}if(!0!==i){let n,s;if(!1===i)s=t.changes.invertedDesc,n=O.empty(e.doc.length);else{let e=t.changes.filter(i);n=e.changes,s=e.filtered.mapDesc(e.changes).invertedDesc}t=pt.create(e,n,t.selection&&t.selection.map(s),gt.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let n=e.facet(lt);for(let s=n.length-1;s>=0;s--){let i=n[s](t);t=i instanceof pt?i:Array.isArray(i)&&1==i.length&&i[0]instanceof pt?i[0]:yt(e,xt(i),!1)}return t}(s):s)}pt.time=ut.define(),pt.userEvent=ut.define(),pt.addToHistory=ut.define(),pt.remote=ut.define();const bt=[];function xt(t){return null==t?bt:Array.isArray(t)?t:[t]}var St=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(St||(St={}));const kt=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let At;try{At=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(Kt){}function Mt(t){return e=>{if(!/\S/.test(e))return St.Space;if(function(t){if(At)return At.test(t);for(let e=0;e<t.length;e++){let i=t[e];if(/\w/.test(i)||i>"€"&&(i.toUpperCase()!=i.toLowerCase()||kt.test(i)))return!0}return!1}(e))return St.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return St.Word;return St.Other}}class Ct{constructor(t,e,i,n,s,r){this.config=t,this.doc=e,this.selection=i,this.values=n,this.status=t.statusTemplate.slice(),this.computeSlot=s,r&&(r._state=this);for(let o=0;o<this.config.dynamicSlots.length;o++)it(this,o<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(null!=i)return it(this,i),nt(this,i);if(e)throw new RangeError("Field is not present in this state")}update(...t){return yt(this,t,!0)}applyTransaction(t){let e,i=this.config,{base:n,compartments:s}=i;for(let o of t.effects)o.is(Z.reconfigure)?(i&&(s=new Map,i.compartments.forEach(((t,e)=>s.set(e,t))),i=null),s.set(o.value.compartment,o.value.extension)):o.is(gt.reconfigure)?(i=null,n=o.value):o.is(gt.appendConfig)&&(i=null,n=xt(n).concat(o.value));if(i)e=t.startState.values.slice();else{i=et.resolve(n,s,this),e=new Ct(i,this.doc,this.selection,i.dynamicSlots.map((()=>null)),((t,e)=>e.reconfigure(t,this)),null).values}let r=t.startState.facet(rt)?t.newSelection:t.newSelection.asSingle();new Ct(i,t.newDoc,r,e,((e,i)=>i.update(e,t)),t)}replaceSelection(t){return"string"==typeof t&&(t=this.toText(t)),this.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:t},range:N.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=xt(i.effects);for(let o=1;o<e.ranges.length;o++){let i=t(e.ranges[o]),h=this.changes(i.changes),l=h.map(n);for(let t=0;t<o;t++)s[t]=s[t].map(l);let a=n.mapDesc(h,!0);s.push(i.range.map(a)),n=n.compose(l),r=gt.mapEffects(r,l).concat(gt.mapEffects(xt(i.effects),a))}return{changes:n,selection:N.create(s,e.mainIndex),effects:r}}changes(t=[]){return t instanceof O?t:O.of(t,this.doc.length,this.facet(Ct.lineSeparator))}toText(t){return n.of(t.split(this.facet(Ct.lineSeparator)||A))}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:(it(this,e),nt(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 $&&null!=this.config.address[n.id]&&(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)if(Object.prototype.hasOwnProperty.call(t,s)){let e=i[s],r=t[s];n.push(e.init((t=>e.spec.fromJSON(r,t))))}return Ct.create({doc:t.doc,selection:N.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let e=et.resolve(t.extensions||[],new Map),i=t.doc instanceof n?t.doc:n.of((t.doc||"").split(e.staticFacet(Ct.lineSeparator)||A)),s=t.selection?t.selection instanceof N?t.selection:N.single(t.selection.anchor,t.selection.head):N.single(0);return I(s,i.length),e.staticFacet(rt)||(s=s.asSingle()),new Ct(e,i,s,e.dynamicSlots.map((()=>null)),((t,e)=>e.create(t)),null)}get tabSize(){return this.facet(Ct.tabSize)}get lineBreak(){return this.facet(Ct.lineSeparator)||"\n"}get readOnly(){return this.facet(ct)}phrase(t,...e){for(let i of this.facet(Ct.phrases))if(Object.prototype.hasOwnProperty.call(i,t)){t=i[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,((t,i)=>{if("$"==i)return"$";let n=+(i||1);return!n||n>e.length?t:e[n-1]}))),t}languageDataAt(t,e,i=-1){let n=[];for(let s of this.facet(st))for(let r of s(this,e,i))Object.prototype.hasOwnProperty.call(r,t)&&n.push(r[t]);return n}charCategorizer(t){return Mt(this.languageDataAt("wordChars",t).join(""))}wordAt(t){let{text:e,from:i,length:n}=this.doc.lineAt(t),s=this.charCategorizer(t),r=t-i,o=t-i;for(;r>0;){let t=w(e,r,!1);if(s(e.slice(t,r))!=St.Word)break;r=t}for(;o<n;){let t=w(e,o);if(s(e.slice(o,t))!=St.Word)break;o=t}return r==o?null:N.range(r+i,o+i)}}function Ot(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}Ct.allowMultipleSelections=rt,Ct.tabSize=H.define({combine:t=>t.length?t[0]:4}),Ct.lineSeparator=ot,Ct.readOnly=ct,Ct.phrases=H.define({compare(t,e){let i=Object.keys(t),n=Object.keys(e);return i.length==n.length&&i.every((i=>t[i]==e[i]))}}),Ct.languageData=st,Ct.changeFilter=ht,Ct.transactionFilter=lt,Ct.transactionExtender=at,Z.reconfigure=gt.define();class Tt{eq(t){return this==t}range(t,e=t){return Dt.create(t,e,this)}}Tt.prototype.startSide=Tt.prototype.endSide=0,Tt.prototype.point=!1,Tt.prototype.mapMode=M.TrackDel;class Dt{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new Dt(t,e,i)}}function Et(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Rt{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,h=s[n]-t||(i?this.value[n].endSide:this.value[n].startSide)-e;if(n==r)return h>=0?r:o;h>=0?o=n:r=n+1}}between(t,e,i,n){for(let s=this.findIndex(e,-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 h=0;h<this.value.length;h++){let l,a,c=this.value[h],u=this.from[h]+t,f=this.to[h]+t;if(u==f){let t=e.mapPos(u,c.startSide,c.mapMode);if(null==t)continue;if(l=a=t,c.startSide!=c.endSide&&(a=e.mapPos(u,c.endSide),a<l))continue}else if(l=e.mapPos(u,c.startSide),a=e.mapPos(f,c.endSide),l>a||l==a&&c.startSide>0&&c.endSide<=0)continue;(a-l||c.endSide-c.startSide)<0||(r<0&&(r=l),c.point&&(o=Math.max(o,a-l)),i.push(c),n.push(l-r),s.push(a-r))}return{mapped:i.length?new Rt(n,s,i,o):null,pos:r}}}class Bt{constructor(t,e,i,n){this.chunkPos=t,this.chunk=e,this.nextLayer=i,this.maxPoint=n}static create(t,e,i,n){return new Bt(t,e,i,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,r=t.filter;if(0==e.length&&!r)return this;if(i&&(e=e.slice().sort(Et)),this.isEmpty)return e.length?Bt.of(e):this;let o=new Nt(this,null,-1).goto(0),h=0,l=[],a=new Pt;for(;o.value||h<e.length;)if(h<e.length&&(o.from-e[h].from||o.startSide-e[h].value.startSide)>=0){let t=e[h++];a.addInner(t.from,t.to,t.value)||l.push(t)}else 1==o.rangeIndex&&o.chunkIndex<this.chunk.length&&(h==e.length||this.chunkEnd(o.chunkIndex)<e[h].from)&&(!r||n>this.chunkEnd(o.chunkIndex)||s<this.chunkPos[o.chunkIndex])&&a.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!r||n>o.to||s<o.from||r(o.from,o.to,o.value))&&(a.addInner(o.from,o.to,o.value)||l.push(Dt.create(o.from,o.to,o.value))),o.next());return a.finishInner(this.nextLayer.isEmpty&&!l.length?Bt.empty:this.nextLayer.update({add:l,filter:r,filterFrom:n,filterTo:s}))}map(t){if(t.empty||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],h=t.touchesRange(s,s+o.length);if(!1===h)n=Math.max(n,o.maxPoint),e.push(o),i.push(t.mapPos(s));else if(!0===h){let{mapped:r,pos:h}=o.map(s,t);r&&(n=Math.max(n,r.maxPoint),e.push(r),i.push(h))}}let s=this.nextLayer.map(t);return 0==e.length?s:new Bt(i,e,s||Bt.empty,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 It.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return It.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)),h=Lt(r,o,i),l=new Ht(r,h,s),a=new Ht(o,h,s);i.iterGaps(((t,e,i)=>Wt(l,t,a,e,i,n))),i.empty&&0==i.length&&Wt(l,0,a,0,0,n)}static eq(t,e,i=0,n){null==n&&(n=999999999);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=Lt(s,r),h=new Ht(s,o,0).goto(i),l=new Ht(r,o,0).goto(i);for(;;){if(h.to!=l.to||!Ft(h.active,l.active)||h.point&&(!l.point||!h.point.eq(l.point)))return!1;if(h.to>n)return!0;h.next(),l.next()}}static spans(t,e,i,n,s=-1){let r=new Ht(t,null,s).goto(e),o=e,h=r.openStart;for(;;){let t=Math.min(r.to,i);if(r.point){let i=r.activeForPoint(r.to),s=r.pointFrom<e?i.length+1:Math.min(i.length,h);n.point(o,t,r.point,i,s,r.pointRank),h=Math.min(r.openEnd(t),i.length)}else t>o&&(n.span(o,t,r.active,h),h=r.openEnd(t));if(r.to>i)return h+(r.point&&r.to>i?1:0);o=r.to,r.next()}}static of(t,e=!1){let i=new Pt;for(let n of t instanceof Dt?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let n=t[i];if(Et(e,n)>0)return t.slice().sort(Et);e=n}return t}(t):t)i.add(n.from,n.to,n.value);return i.finish()}static join(t){if(!t.length)return Bt.empty;let e=t[t.length-1];for(let i=t.length-2;i>=0;i--)for(let n=t[i];n!=Bt.empty;n=n.nextLayer)e=new Bt(n.chunkPos,n.chunk,e,Math.max(n.maxPoint,e.maxPoint));return e}}Bt.empty=new Bt([],[],null,-1),Bt.empty.nextLayer=Bt.empty;class Pt{finishChunk(t){this.chunks.push(new Rt(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=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(t,e,i){this.addInner(t,e,i)||(this.nextLayer||(this.nextLayer=new Pt)).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(Bt.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=Bt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function Lt(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.touchesRange(e,e+r.chunk[t].length))||s.add(r.chunk[t])}return s}class Nt{constructor(t,e,i,n=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex<this.layer.chunk.length;){let e=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(e)||this.layer.chunkEnd(this.chunkIndex)<t||e.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}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)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=t}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.rank-t.rank||this.to-t.to||this.endSide-t.endSide}}class It{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 Nt(r,e,i,s));return 1==n.length?n[0]:new It(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--)Vt(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--)Vt(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(),Vt(this.heap,0)}}}function Vt(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 Ht{constructor(t,e,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=It.from(t,e,i)}goto(t,e=-1e9){return this.cursor.goto(t,e),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=t,this.endSide=e,this.openStart=-1,this.next(),this}forward(t,e){for(;this.minActive>-1&&(this.activeTo[this.minActive]-t||this.active[this.minActive].endSide-e)<0;)this.removeActive(this.minActive);this.cursor.forward(t,e)}removeActive(t){zt(this.active,t),zt(this.activeTo,t),zt(this.activeRank,t),this.minActive=jt(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:n,rank:s}=this.cursor;for(;e<this.activeRank.length&&(s-this.activeRank[e]||n-this.activeTo[e])>0;)e++;_t(this.active,e,i),_t(this.activeTo,e,n),_t(this.activeRank,e,s),t&&_t(t,e,this.cursor.from),this.minActive=jt(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>t){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&zt(i,n)}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 t=this.cursor.value;if(t.point){if(!(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=t,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=t.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(i),this.cursor.next()}}}if(i){this.openStart=0;for(let e=i.length-1;e>=0&&i[e]<t;e--)this.openStart++}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&e.push(this.active[i]);return e.reverse()}openEnd(t){let e=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)e++;return e}}function Wt(t,e,i,n,s,r){t.goto(e),i.goto(n);let o=n+s,h=n,l=n-e;for(;;){let e=t.to+l-i.to||t.endSide-i.endSide,n=e<0?t.to+l:i.to,s=Math.min(n,o);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))&&Ft(t.activeForPoint(t.to),i.activeForPoint(i.to))||r.comparePoint(h,s,t.point,i.point):s>h&&!Ft(t.active,i.active)&&r.compareRange(h,s,t.active,i.active),n>o)break;h=n,e<=0&&t.next(),e>=0&&i.next()}}function Ft(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 zt(t,e){for(let i=e,n=t.length-1;i<n;i++)t[i]=t[i+1];t.pop()}function _t(t,e,i){for(let n=t.length-1;n>=e;n--)t[n+1]=t[n];t[e]=i}function jt(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}function qt(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=w(t,s));return n}function $t(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=w(t,s)}return!0===n?-1:t.length}},70081:function(t,e,i){i.a(t,(async function(t,n){try{i.d(e,{Nm:function(){return c},tk:function(){return qn}});var s=i(31948),r=(i(52247),i(71695),i(92745),i(52805),i(61495),i(61893),i(84283),i(19423),i(23669),i(40251),i(69235),i(12385),i(19134),i(32517),i(5740),i(11740),i(92519),i(42179),i(89256),i(24931),i(88463),i(57449),i(19814),i(97003),i(32114),i(46692),i(39527),i(37210),i(92181),i(99790),i(67670),i(41360),i(13334),i(34595),i(36993),i(47021),i(73928)),o=i(78305),h=(i(96318),t([s]));function d(t){let e;return e=11==t.nodeType?t.getSelection?t:t.ownerDocument:t,e.getSelection()}function g(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function p(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function m(t,e){if(!e.anchorNode)return!1;try{return g(t,e.anchorNode)}catch(i){return!1}}function w(t){return 3==t.nodeType?B(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function v(t,e,i,n){return!!i&&(x(t,e,i,n,-1)||x(t,e,i,n,1))}function y(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function b(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function x(t,e,i,n,s){for(;;){if(t==i&&e==n)return!0;if(e==(s<0?0:S(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=y(t)+(s<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if(1==(t=t.childNodes[e+(s<0?-1:0)]).nodeType&&"false"==t.contentEditable)return!1;e=s<0?S(t):0}}}function S(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function k(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function A(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function M(t,e){let i=e.width/t.offsetWidth,n=e.height/t.offsetHeight;return(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.width-t.offsetWidth)<1)&&(i=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.height-t.offsetHeight)<1)&&(n=1),{scaleX:i,scaleY:n}}function C(t,e,i,n,s,r,o,h){let l=t.ownerDocument,a=l.defaultView||window;for(let c=t,u=!1;c&&!u;)if(1==c.nodeType){let t,f=c==l.body,d=1,g=1;if(f)t=A(a);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(u=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let e=c.getBoundingClientRect();({scaleX:d,scaleY:g}=M(c,e)),t={left:e.left,right:e.left+c.clientWidth*d,top:e.top,bottom:e.top+c.clientHeight*g}}let p=0,m=0;if("nearest"==s)e.top<t.top?(m=-(t.top-e.top+o),i>0&&e.bottom>t.bottom+m&&(m=e.bottom-t.bottom+m+o)):e.bottom>t.bottom&&(m=e.bottom-t.bottom+o,i<0&&e.top-m<t.top&&(m=-(t.top+m-e.top+o)));else{let n=e.bottom-e.top,r=t.bottom-t.top;m=("center"==s&&n<=r?e.top+n/2-r/2:"start"==s||"center"==s&&i<0?e.top-o:e.bottom-r+o)-t.top}if("nearest"==n)e.left<t.left?(p=-(t.left-e.left+r),i>0&&e.right>t.right+p&&(p=e.right-t.right+p+r)):e.right>t.right&&(p=e.right-t.right+r,i<0&&e.left<t.left+p&&(p=-(t.left+p-e.left+r)));else{p=("center"==n?e.left+(e.right-e.left)/2-(t.right-t.left)/2:"start"==n==h?e.left-r:e.right-(t.right-t.left)+r)-t.left}if(p||m)if(f)a.scrollBy(p,m);else{let t=0,i=0;if(m){let t=c.scrollTop;c.scrollTop+=m/g,i=(c.scrollTop-t)*g}if(p){let e=c.scrollLeft;c.scrollLeft+=p/d,t=(c.scrollLeft-e)*d}e={left:e.left-t,top:e.top-i,right:e.right-t,bottom:e.bottom-i},t&&Math.abs(t-p)<1&&(n="nearest"),i&&Math.abs(i-m)<1&&(s="nearest")}if(f)break;c=c.assignedSlot||c.parentNode}else{if(11!=c.nodeType)break;c=c.host}}function O(t){let e=t.ownerDocument;for(let i=t.parentNode;i&&i!=e.body;)if(1==i.nodeType){if(i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)return i;i=i.assignedSlot||i.parentNode}else{if(11!=i.nodeType)break;i=i.host}return null}s=(h.then?(await h)():h)[0];class T{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:i}=t;this.set(e,Math.min(t.anchorOffset,e?S(e):0),i,Math.min(t.focusOffset,i?S(i):0))}set(t,e,i,n){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=n}}let D,E=null;function R(t){if(t.setActive)return t.setActive();if(E)return t.focus(E);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==E?{get preventScroll(){return E={preventScroll:!0},!0}}:void 0),!E){E=!1;for(let t=0;t<e.length;){let i=e[t++],n=e[t++],s=e[t++];i.scrollTop!=n&&(i.scrollTop=n),i.scrollLeft!=s&&(i.scrollLeft=s)}}}function B(t,e,i=e){let n=D||(D=document.createRange());return n.setEnd(t,i),n.setStart(t,e),n}function P(t,e,i,n){let s={key:e,code:e,keyCode:i,which:i,cancelable:!0};n&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=n);let r=new KeyboardEvent("keydown",s);r.synthetic=!0,t.dispatchEvent(r);let o=new KeyboardEvent("keyup",s);return o.synthetic=!0,t.dispatchEvent(o),r.defaultPrevented||o.defaultPrevented}function L(t){for(;t;){if(t&&(9==t.nodeType||11==t.nodeType&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function N(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}function I(t,e){let i=e.focusNode,n=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=n)return!1;for(n=Math.min(n,S(i));;)if(n){if(1!=i.nodeType)return!1;let t=i.childNodes[n-1];"false"==t.contentEditable?n--:(i=t,n=S(i))}else{if(i==t)return!0;n=y(i),i=i.parentNode}}function V(t){return t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function H(t,e){for(let i=t,n=e;;){if(3==i.nodeType&&n>0)return{node:i,offset:n};if(1==i.nodeType&&n>0){if("false"==i.contentEditable)return null;i=i.childNodes[n-1],n=S(i)}else{if(!i.parentNode||b(i))return null;n=y(i),i=i.parentNode}}}function W(t,e){for(let i=t,n=e;;){if(3==i.nodeType&&n<i.nodeValue.length)return{node:i,offset:n};if(1==i.nodeType&&n<i.childNodes.length){if("false"==i.contentEditable)return null;i=i.childNodes[n],n=0}else{if(!i.parentNode||b(i))return null;n=y(i)+1,i=i.parentNode}}}class F{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new F(t.parentNode,y(t),e)}static after(t,e){return new F(t.parentNode,y(t)+1,e)}}const z=[];class _{constructor(){this.parent=null,this.dom=null,this.flags=2}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}sync(t,e){if(2&this.flags){let i,n=this.dom,s=null;for(let r of this.children){if(7&r.flags){if(!r.dom&&(i=s?s.nextSibling:n.firstChild)){let t=_.get(i);(!t||!t.parent&&t.canReuseDOM(r))&&r.reuseDOM(i)}r.sync(t,e),r.flags&=-8}if(i=s?s.nextSibling:n.firstChild,e&&!e.written&&e.node==n&&i!=r.dom&&(e.written=!0),r.dom.parentNode==n)for(;i&&i!=r.dom;)i=j(i);else n.insertBefore(r.dom,i);s=r.dom}for(i=s?s.nextSibling:n.firstChild,i&&e&&e.node==n&&(e.written=!0);i;)i=j(i)}else if(1&this.flags)for(let i of this.children)7&i.flags&&(i.sync(t,e),i.flags&=-8)}reuseDOM(t){}localPosFromDOM(t,e){let i;if(t==this.dom)i=this.dom.childNodes[e];else{let n=0==S(t)?0:0==e?-1:1;for(;;){let e=t.parentNode;if(e==this.dom)break;0==n&&e.firstChild!=e.lastChild&&(n=t==e.firstChild?-1:1),t=e}i=n<0?t:t.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!_.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 h=0,l=i,a=i;h<this.children.length;h++){let i=this.children[h],c=l+i.length;if(l<t&&c>e)return i.domBoundsAround(t,e,l);if(c>=t&&-1==n&&(n=h,s=l),l>e&&i.dom.parentNode==this.dom){r=h,o=a;break}a=c,l=c+i.breakAfter}return{from:s,to:o<0?i+this.length:o,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:r<this.children.length&&r>=0?this.children[r].dom:null}}markDirty(t=!1){this.flags|=2,this.markParentsDirty(t)}markParentsDirty(t){for(let e=this.parent;e;e=e.parent){if(t&&(e.flags|=2),1&e.flags)return;e.flags|=1,t=!1}}setParent(t){this.parent!=t&&(this.parent=t,7&this.flags&&this.markParentsDirty(!0))}setDOM(t){this.dom!=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=z){this.markDirty();for(let n=t;n<e;n++){let t=this.children[n];t.parent==this&&i.indexOf(t)<0&&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 q(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}get isWidget(){return!1}get isHidden(){return!1}merge(t,e,i,n,s,r){return!1}become(t){return!1}canReuseDOM(t){return t.constructor==this.constructor&&!(8&(this.flags|t.flags))}getSide(){return 0}destroy(){for(let t of this.children)t.parent==this&&t.destroy();this.parent=null}}function j(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}_.prototype.breakAfter=0;class q{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 $(t,e,i,n,s,r,o,h,l){let{children:a}=t,c=a.length?a[e]:null,u=r.length?r[r.length-1]:null,f=u?u.breakAfter:o;if(!(e==n&&c&&!o&&!f&&r.length<2&&c.merge(i,s,r.length?u:null,0==i,h,l))){if(n<a.length){let t=a[n];t&&(s<t.length||t.breakAfter&&(null==u?void 0:u.breakAfter))?(e==n&&(t=t.split(s),s=0),!f&&u&&t.merge(0,s,u,!0,0,l)?r[r.length-1]=t:((s||t.children.length&&!t.children[0].length)&&t.merge(0,s,null,!1,0,l),r.push(t))):(null==t?void 0:t.breakAfter)&&(u?u.breakAfter=1:o=1),n++}for(c&&(c.breakAfter=o,i>0&&(!o&&r.length&&c.merge(i,c.length,r[0],!1,h,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,h,0),e++));e<n&&r.length;)if(a[n-1].become(r[r.length-1]))n--,r.pop(),l=r.length?0:h;else{if(!a[e].become(r[0]))break;e++,r.shift(),h=r.length?0:l}!r.length&&e&&n<a.length&&!a[e-1].breakAfter&&a[n].merge(0,0,a[e-1],!1,h,l)&&e--,(e<n||r.length)&&t.replaceChildren(e,n,r)}}function K(t,e,i,n,s,r){let o=t.childCursor(),{i:h,off:l}=o.findPos(i,1),{i:a,off:c}=o.findPos(e,-1),u=e-i;for(let f of n)u+=f.length;t.length+=u,$(t,a,c,h,l,n,0,s,r)}let J="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},G="undefined"!=typeof document?document:{documentElement:{style:{}}};const U=/Edge\/(\d+)/.exec(J.userAgent),X=/MSIE \d/.test(J.userAgent),Y=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(J.userAgent),Q=!!(X||Y||U),Z=!Q&&/gecko\/(\d+)/i.test(J.userAgent),tt=!Q&&/Chrome\/(\d+)/.exec(J.userAgent),et="webkitFontSmoothing"in G.documentElement.style,it=!Q&&/Apple Computer/.test(J.vendor),nt=it&&(/Mobile\/\w+/.test(J.userAgent)||J.maxTouchPoints>2);var l={mac:nt||/Mac/.test(J.platform),windows:/Win/.test(J.platform),linux:/Linux|X11/.test(J.platform),ie:Q,ie_version:X?G.documentMode||6:Y?+Y[1]:U?+U[1]:0,gecko:Z,gecko_version:Z?+(/Firefox\/(\d+)/.exec(J.userAgent)||[0,0])[1]:0,chrome:!!tt,chrome_version:tt?+tt[1]:0,ios:nt,android:/Android\b/.test(J.userAgent),webkit:et,safari:it,webkit_version:et?+(/\bAppleWebKit\/(\d+)/.exec(J.userAgent)||[0,0])[1]:0,tabSize:null!=G.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};const st=256;class rt extends _{constructor(t){super(),this.text=t}get length(){return this.text.length}createDOM(t){this.setDOM(t||document.createTextNode(this.text))}sync(t,e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(t){3==t.nodeType&&this.createDOM(t)}merge(t,e,i){return!(8&this.flags||i&&(!(i instanceof rt)||this.length-(e-t)+i.length>st||8&i.flags))&&(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new rt(this.text.slice(t));return this.text=this.text.slice(0,t),this.markDirty(),e.flags|=8&this.flags,e}localPosFromDOM(t,e){return t==this.dom?e:e?this.text.length:0}domAtPos(t){return new F(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 ht(this.dom,t,e)}}class ot extends _{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(N(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}canReuseDOM(t){return super.canReuseDOM(t)&&!(8&(this.flags|t.flags))}reuseDOM(t){t.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(t),this.flags|=6)}sync(t,e){this.dom?4&this.flags&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(t,e)}merge(t,e,i,n,s,r){return(!i||!(!(i instanceof ot&&i.mark.eq(this.mark))||t&&s<=0||e<this.length&&r<=0))&&(K(this,t,e,i?i.children.slice():[],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 ot(this.mark,e,r)}domAtPos(t){return ct(this,t)}coordsAt(t,e){return ft(this,t,e)}}function ht(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?l.chrome||l.gecko||(e?(s--,o=1):r<n&&(r++,o=-1)):i<0?s--:r<n&&r++;let h=B(t,s,r).getClientRects();if(!h.length)return null;let a=h[(o?o<0:i>=0)?0:h.length-1];return l.safari&&!o&&0==a.width&&(a=Array.prototype.find.call(h,(t=>t.width))||a),o?k(a,o<0):a||null}class lt extends _{static create(t,e,i){return new lt(t,e,i)}constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i,this.prevWidget=null}split(t){let e=lt.create(this.widget,this.length-t,this.side);return this.length-=t,e}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(t,e,i,n,s,r){return!(i&&(!(i instanceof lt&&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 instanceof lt&&t.side==this.side&&this.widget.constructor==t.widget.constructor&&(this.widget.compare(t.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get overrideDOMText(){if(0==this.length)return r.xv.empty;let t=this;for(;t.parent;)t=t.parent;let{view:e}=t,i=e&&e.state.doc,n=this.posAtStart;return i?i.slice(n,n+this.length):r.xv.empty}domAtPos(t){return(this.length?0==t:this.side>0)?F.before(this.dom):F.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let i=this.widget.coordsAt(this.dom,t,e);if(i)return i;let n=this.dom.getClientRects(),s=null;if(!n.length)return null;let r=this.side?this.side<0:t>0;for(let o=r?n.length-1:0;s=n[o],!(t>0?0==o:o==n.length-1||s.top<s.bottom);o+=r?-1:1);return k(s,!r)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class at extends _{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof at&&t.side==this.side}split(){return new at(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 this.side>0?F.before(this.dom):F.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return r.xv.empty}get isHidden(){return!0}}function ct(t,e){let i=t.dom,{children:n}=t,s=0;for(let r=0;s<n.length;s++){let t=n[s],o=r+t.length;if(!(o==r&&t.getSide()<=0)){if(e>r&&e<o&&t.dom.parentNode==i)return t.domAtPos(e-r);if(e<=r)break;r=o}}for(let r=s;r>0;r--){let t=n[r-1];if(t.dom.parentNode==i)return t.domAtPos(t.length)}for(let r=s;r<n.length;r++){let t=n[r];if(t.dom.parentNode==i)return t.domAtPos(0)}return new F(i,0)}function ut(t,e,i){let n,{children:s}=t;i>0&&e instanceof ot&&s.length&&(n=s[s.length-1])instanceof ot&&n.mark.eq(e.mark)?ut(n,e.children[0],i-1):(s.push(e),e.setParent(t)),t.length+=e.length}function ft(t,e,i){let n=null,s=-1,r=null,o=-1;!function t(e,h){for(let l=0,a=0;l<e.children.length&&a<=h;l++){let c=e.children[l],u=a+c.length;u>=h&&(c.children.length?t(c,h-a):(!r||r.isHidden&&i>0)&&(u>h||a==u&&c.getSide()>0)?(r=c,o=h-a):(a<h||a==u&&c.getSide()<0&&!c.isHidden)&&(n=c,s=h-a)),a=u}}(t,e);let h=(i<0?n:r)||n||r;return h?h.coordsAt(Math.max(0,h==n?s:o),i):dt(t)}function dt(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=w(e);return i[i.length-1]||null}function gt(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}rt.prototype.children=lt.prototype.children=at.prototype.children=z;const pt=Object.create(null);function mt(t,e,i){if(t==e)return!0;t||(t=pt),e||(e=pt);let n=Object.keys(t),s=Object.keys(e);if(n.length-(i&&n.indexOf(i)>-1?1:0)!=s.length-(i&&s.indexOf(i)>-1?1:0))return!1;for(let r of n)if(r!=i&&(-1==s.indexOf(r)||t[r]!==e[r]))return!1;return!0}function wt(t,e,i){let n=!1;if(e)for(let s in e)i&&s in i||(n=!0,"style"==s?t.style.cssText="":t.removeAttribute(s));if(i)for(let s in i)e&&e[s]==i[s]||(n=!0,"style"==s?t.style.cssText=i[s]:t.setAttribute(s,i[s]));return n}function vt(t){let e=Object.create(null);for(let i=0;i<t.attributes.length;i++){let n=t.attributes[i];e[n.name]=n.value}return e}class yt extends _{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 yt))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),K(this,t,e,i?i.children.slice():[],s,r),!0}split(t){let e=new yt;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);for(;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&&(this.markDirty(),t.setDOM(this.dom),t.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(t){mt(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){ut(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=gt(e,this.attrs||{})),i&&(this.attrs=gt({class:i},this.attrs||{}))}domAtPos(t){return ct(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.flags|=6)}sync(t,e){var i;this.dom?4&this.flags&&(N(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&&(wt(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t,e);let n=this.dom.lastChild;for(;n&&_.get(n)instanceof ot;)n=n.lastChild;if(!(n&&this.length&&("BR"==n.nodeName||0!=(null===(i=_.get(n))||void 0===i?void 0:i.isEditable)||l.ios&&this.children.some((t=>t instanceof rt))))){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,e=0;for(let i of this.children){if(!(i instanceof rt)||/[^ -~]/.test(i.text))return null;let n=w(i.dom);if(1!=n.length)return null;e+=n[0].width,t=n[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(t,e){let i=ft(this,t,e);if(!this.children.length&&i&&this.parent){let{heightOracle:t}=this.parent.view.viewState,e=i.bottom-i.top;if(Math.abs(e-t.lineHeight)<2&&t.textHeight<e){let n=(e-t.textHeight)/2;return{top:i.top+n,bottom:i.bottom-n,left:i.left,right:i.left}}}return i}become(t){return t instanceof yt&&0==this.children.length&&0==t.children.length&&mt(this.attrs,t.attrs)&&this.breakAfter==t.breakAfter}covers(){return!0}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 yt)return s;if(r>e)break}n=r+s.breakAfter}return null}}class bt extends _{constructor(t,e,i){super(),this.widget=t,this.length=e,this.deco=i,this.breakAfter=0,this.prevWidget=null}merge(t,e,i,n,s,r){return!(i&&(!(i instanceof bt&&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?F.before(this.dom):F.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new bt(this.widget,e,this.deco);return i.breakAfter=this.breakAfter,i}get children(){return z}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):r.xv.empty}domBoundsAround(){return null}become(t){return t instanceof bt&&t.widget.constructor==this.widget.constructor&&(t.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,this.deco=t.deco,this.breakAfter=t.breakAfter,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(t,e){return this.widget.coordsAt(this.dom,t,e)}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(t){let{startSide:e,endSide:i}=this.deco;return e!=i&&(t<0?e<0:i>0)}}class xt{eq(t){return!1}updateDOM(t,e){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(t){return!0}coordsAt(t,e,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(t){}}var a=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(a||(a={}));class St extends r.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 kt(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),i=!!t.block;return e+=i&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8,new Mt(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}=Ct(t,n);e=(s?n?-3e8:-1:5e8)-1,i=1+(r?n?2e8:1:-6e8)}return new Mt(t,e,i,n,t.widget||null,!0)}static line(t){return new At(t)}static set(t,e=!1){return r.Xs.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}St.none=r.Xs.empty;class kt extends St{constructor(t){let{start:e,end:i}=Ct(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){var e,i;return this==t||t instanceof kt&&this.tagName==t.tagName&&(this.class||(null===(e=this.attrs)||void 0===e?void 0:e.class))==(t.class||(null===(i=t.attrs)||void 0===i?void 0:i.class))&&mt(this.attrs,t.attrs,"class")}range(t,e=t){if(t>=e)throw new RangeError("Mark decorations may not be empty");return super.range(t,e)}}kt.prototype.point=!1;class At extends St{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof At&&this.spec.class==t.spec.class&&mt(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)}}At.prototype.mapMode=r.gc.TrackBefore,At.prototype.point=!0;class Mt extends St{constructor(t,e,i,n,s,o){super(e,i,s,t),this.block=n,this.isReplace=o,this.mapMode=n?e<=0?r.gc.TrackBefore:r.gc.TrackAfter:r.gc.TrackDel}get type(){return this.startSide!=this.endSide?a.WidgetRange:this.startSide<=0?a.WidgetBefore:a.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof Mt&&(e=this.widget,i=t.widget,e==i||!!(e&&i&&e.compare(i)))&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide;var e,i}range(t,e=t){if(this.isReplace&&(t>e||t==e&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}}function Ct(t,e=!1){let{inclusiveStart:i,inclusiveEnd:n}=t;return null==i&&(i=t.inclusive),null==n&&(n=t.inclusive),{start:null!=i?i:e,end:null!=n?n:e}}function Ot(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)}Mt.prototype.point=!0;class Tt{constructor(t,e,i,n){this.doc=t,this.pos=e,this.end=i,this.disallowBlockEffectsFor=n,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],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 bt&&t.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new yt),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(Dt(new at(-1),t),t.length),this.pendingBuffer=0)}addBlockWidget(t){this.flushBuffer(),this.curLine=null,this.content.push(t)}finish(t){this.pendingBuffer&&t<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||t&&this.content.length&&this.content[this.content.length-1]instanceof bt||this.getLine()}buildText(t,e,i){for(;t>0;){if(this.textOff==this.text.length){let{value:e,lineBreak:i,done:n}=this.cursor.next(this.skip);if(this.skip=0,n)throw new Error("Ran out of text content when drawing inline views");if(i){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,t--;continue}this.text=e,this.textOff=0}let n=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(e.length-i)),this.getLine().append(Dt(new rt(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,r){if(this.disallowBlockEffectsFor[r]&&i instanceof Mt){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")}let o=e-t;if(i instanceof Mt)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new bt(i.widget||Et.block,o,i));else{let r=lt.create(i.widget||Et.inline,o,o?0:i.startSide),h=this.atCursorPos&&!r.isEditable&&s<=n.length&&(t<e||i.startSide>0),l=!r.isEditable&&(t<e||s>n.length||i.startSide<=0),a=this.getLine();2!=this.pendingBuffer||h||r.isEditable||(this.pendingBuffer=0),this.flushBuffer(n),h&&(a.append(Dt(new at(1),n),s),s=n.length+Math.max(0,s-n.length)),a.append(Dt(r,n),s),this.atCursorPos=l,this.pendingBuffer=l?t<e||s>n.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=n.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);o&&(this.textOff+o<=this.text.length?this.textOff+=o:(this.skip+=o-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=e),this.openStart<0&&(this.openStart=s)}static build(t,e,i,n,s){let o=new Tt(t,e,i,s);return o.openEnd=r.Xs.spans(n,e,i,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}}function Dt(t,e){for(let i of e)t=new ot(i,[t],t.length);return t}class Et extends xt{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}Et.inline=new Et("span"),Et.block=new Et("div");var c=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(c||(c={}));const Rt=c.LTR,Bt=c.RTL;function Pt(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}const Lt=Pt("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Nt=Pt("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),It=Object.create(null),Vt=[];for(let Qn of["()","[]","{}"]){let Zn=Qn.charCodeAt(0),ts=Qn.charCodeAt(1);It[Zn]=ts,It[ts]=-Zn}function Ht(t){return t<=247?Lt[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?Nt[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8204?256:64336<=t&&t<=65023?4:1}const Wt=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Ft{get dir(){return this.level%2?Bt:Rt}constructor(t,e,i){this.from=t,this.to=e,this.level=i}side(t,e){return this.dir==e==t?this.to:this.from}forward(t,e){return t==(this.dir==e)}static find(t,e,i,n){let 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}}function zt(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.direction!=s.direction||!zt(n.inner,s.inner))return!1}return!0}const _t=[];function jt(t,e,i,n,s){for(let r=0;r<=n.length;r++){let o=r?n[r-1].to:e,h=r<n.length?n[r].from:i,l=r?256:s;for(let e=o,i=l,n=l;e<h;e++){let s=Ht(t.charCodeAt(e));512==s?s=i:8==s&&4==n&&(s=16),_t[e]=4==s?2:s,7&s&&(n=s),i=s}for(let t=o,e=l,n=l;t<h;t++){let s=_t[t];if(128==s)t<h-1&&e==_t[t+1]&&24&e?s=_t[t]=e:_t[t]=256;else if(64==s){let s=t+1;for(;s<h&&64==_t[s];)s++;let r=t&&8==e||s<i&&8==_t[s]?1==n?1:8:256;for(let e=t;e<s;e++)_t[e]=r;t=s-1}else 8==s&&1==n&&(_t[t]=1);e=s,7&s&&(n=s)}}}function qt(t,e,i,n,s){let r=1==s?2:1;for(let o=0,h=0,l=0;o<=n.length;o++){let a=o?n[o-1].to:e,c=o<n.length?n[o].from:i;for(let e,i,n,o=a;o<c;o++)if(i=It[e=t.charCodeAt(o)])if(i<0){for(let t=h-3;t>=0;t-=3)if(Vt[t+1]==-i){let e=Vt[t+2],i=2&e?s:4&e?1&e?r:s:0;i&&(_t[o]=_t[Vt[t]]=i),h=t;break}}else{if(189==Vt.length)break;Vt[h++]=o,Vt[h++]=e,Vt[h++]=l}else if(2==(n=_t[o])||1==n){let t=n==s;l=t?0:1;for(let e=h-3;e>=0;e-=3){let i=Vt[e+2];if(2&i)break;if(t)Vt[e+2]|=2;else{if(4&i)break;Vt[e+2]|=4}}}}}function $t(t,e,i,n){for(let s=0,r=n;s<=i.length;s++){let o=s?i[s-1].to:t,h=s<i.length?i[s].from:e;for(let l=o;l<h;){let o=_t[l];if(256==o){let o=l+1;for(;;)if(o==h){if(s==i.length)break;o=i[s++].to,h=s<i.length?i[s].from:e}else{if(256!=_t[o])break;o++}let a=1==r,c=a==(1==(o<e?_t[o]:n))?a?1:2:n;for(let e=o,n=s,r=n?i[n-1].to:t;e>l;)e==r&&(e=i[--n].from,r=n?i[n-1].to:t),_t[--e]=c;l=o}else r=o,l++}}}function Kt(t,e,i,n,s,r,o){let h=n%2?2:1;if(n%2==s%2)for(let l=e,a=0;l<i;){let e=!0,c=!1;if(a==r.length||l<r[a].from){let t=_t[l];t!=h&&(e=!1,c=16==t)}let u=e||1!=h?null:[],f=e?n:n+1,d=l;t:for(;;)if(a<r.length&&d==r[a].from){if(c)break t;let g=r[a];if(!e)for(let t=g.to,e=a+1;;){if(t==i)break t;if(!(e<r.length&&r[e].from==t)){if(_t[t]==h)break t;break}t=r[e++].to}if(a++,u)u.push(g);else{g.from>l&&o.push(new Ft(l,g.from,f)),Jt(t,g.direction==Rt!=!(f%2)?n+1:n,s,g.inner,g.from,g.to,o),l=g.to}d=g.to}else{if(d==i||(e?_t[d]!=h:_t[d]==h))break;d++}u?Kt(t,l,d,n+1,s,u,o):l<d&&o.push(new Ft(l,d,f)),l=d}else for(let l=i,a=r.length;l>e;){let i=!0,c=!1;if(!a||l>r[a-1].to){let t=_t[l-1];t!=h&&(i=!1,c=16==t)}let u=i||1!=h?null:[],f=i?n:n+1,d=l;t:for(;;)if(a&&d==r[a-1].to){if(c)break t;let g=r[--a];if(!i)for(let t=g.from,i=a;;){if(t==e)break t;if(!i||r[i-1].to!=t){if(_t[t-1]==h)break t;break}t=r[--i].from}if(u)u.push(g);else{g.to<l&&o.push(new Ft(g.to,l,f)),Jt(t,g.direction==Rt!=!(f%2)?n+1:n,s,g.inner,g.from,g.to,o),l=g.from}d=g.from}else{if(d==e||(i?_t[d-1]!=h:_t[d-1]==h))break;d--}u?Kt(t,d,l,n+1,s,u,o):d<l&&o.push(new Ft(d,l,f)),l=d}}function Jt(t,e,i,n,s,r,o){let h=e%2?2:1;jt(t,s,r,n,h),qt(t,s,r,n,h),$t(s,r,n,h),Kt(t,s,r,e,i,n,o)}function Gt(t,e,i){if(!t)return[new Ft(0,0,e==Bt?1:0)];if(e==Rt&&!i.length&&!Wt.test(t))return Ut(t.length);if(i.length)for(;t.length>_t.length;)_t[_t.length]=256;let n=[],s=e==Rt?0:1;return Jt(t,s,s,i,0,t.length,n),n}function Ut(t){return[new Ft(0,t,0)]}let Xt="";function Yt(t,e,i,n,s){var o;let h=n.head-t.from,l=Ft.find(e,h,null!==(o=n.bidiLevel)&&void 0!==o?o:-1,n.assoc),a=e[l],c=a.side(s,i);if(h==c){let t=l+=s?1:-1;if(t<0||t>=e.length)return null;a=e[l=t],h=a.side(!s,i),c=a.side(s,i)}let u=(0,r.cp)(t.text,h,a.forward(s,i));(u<a.from||u>a.to)&&(u=c),Xt=t.text.slice(Math.min(h,u),Math.max(h,u));let f=l==(s?e.length-1:0)?null:e[l+(s?1:-1)];return f&&u==c&&f.level+(s?0:1)<a.level?r.jT.cursor(f.side(!s,i)+t.from,f.forward(s,i)?1:-1,f.level):r.jT.cursor(u+t.from,a.forward(s,i)?-1:1,a.level)}function Qt(t,e,i){for(let n=e;n<i;n++){let e=Ht(t.charCodeAt(n));if(1==e)return Rt;if(2==e||4==e)return Bt}return Rt}const Zt=r.r$.define(),te=r.r$.define(),ee=r.r$.define(),ie=r.r$.define(),ne=r.r$.define(),se=r.r$.define(),re=r.r$.define(),oe=r.r$.define({combine:t=>t.some((t=>t))}),he=r.r$.define({combine:t=>t.some((t=>t))}),le=r.r$.define();class ae{constructor(t,e="nearest",i="nearest",n=5,s=5,r=!1){this.range=t,this.y=e,this.x=i,this.yMargin=n,this.xMargin=s,this.isSnapshot=r}map(t){return t.empty?this:new ae(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new ae(r.jT.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const ce=r.Py.define({map:(t,e)=>t.map(e)}),ue=r.Py.define();function fe(t,e,i){let n=t.facet(ie);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 de=r.r$.define({combine:t=>!t.length||t[0]});let ge=0;const pe=r.r$.define();class me{constructor(t,e,i,n,s){this.id=t,this.create=e,this.domEventHandlers=i,this.domEventObservers=n,this.extension=s(this)}static define(t,e){const{eventHandlers:i,eventObservers:n,provide:s,decorations:r}=e||{};return new me(ge++,t,i,n,(t=>{let e=[pe.of(t)];return r&&e.push(be.of((e=>{let i=e.plugin(t);return i?r(i):St.none}))),s&&e.push(s(t)),e}))}static fromClass(t,e){return me.define((e=>new t(e)),e)}}class we{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}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(fe(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){fe(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){fe(t.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const ve=r.r$.define(),ye=r.r$.define(),be=r.r$.define(),xe=r.r$.define(),Se=r.r$.define(),ke=r.r$.define();function Ae(t,e){let i=t.state.facet(ke);if(!i.length)return i;let n=i.map((e=>e instanceof Function?e(t):e)),s=[];return r.Xs.spans(n,e.from,e.to,{point(){},span(t,i,n,r){let o=t-e.from,h=i-e.from,l=s;for(let s=n.length-1;s>=0;s--,r--){let t,i=n[s].spec.bidiIsolate;if(null==i&&(i=Qt(e.text,o,h)),r>0&&l.length&&(t=l[l.length-1]).to==o&&t.direction==i)t.to=h,l=t.inner;else{let t={from:o,to:h,direction:i,inner:[]};l.push(t),l=t.inner}}}}),s}const Me=r.r$.define();function Ce(t){let e=0,i=0,n=0,s=0;for(let r of t.state.facet(Me)){let o=r(t);o&&(null!=o.left&&(e=Math.max(e,o.left)),null!=o.right&&(i=Math.max(i,o.right)),null!=o.top&&(n=Math.max(n,o.top)),null!=o.bottom&&(s=Math.max(s,o.bottom)))}return{left:e,right:i,top:n,bottom:s}}const Oe=r.r$.define();class Te{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new Te(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let n=t[e-1];if(!(n.fromA>i.toA)){if(n.toA<i.fromA)break;i=i.join(n),t.splice(e-1,1)}}return t.splice(e,0,i),t}static extendWithRanges(t,e){if(0==e.length)return t;let i=[];for(let n=0,s=0,r=0,o=0;;n++){let h=n==t.length?null:t[n],l=r-o,a=h?h.fromB:1e9;for(;s<e.length&&e[s]<a;){let t=e[s],n=e[s+1],r=Math.max(o,t),h=Math.min(a,n);if(r<=h&&new Te(r+l,h+l,r,h).addToSet(i),n>a)break;s+=2}if(!h)return i;new Te(h.fromA,h.toA,h.fromB,h.toB).addToSet(i),r=h.toA,o=h.toB}}}class De{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=r.as.empty(this.startState.doc.length);for(let s of i)this.changes=this.changes.compose(s.changes);let n=[];this.changes.iterChangedRanges(((t,e,i,s)=>n.push(new Te(t,e,i,s)))),this.changedRanges=n}static create(t,e,i){return new De(t,e,i)}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}}class Ee extends _{get length(){return this.view.state.doc.length}constructor(t){super(),this.view=t,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=St.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(t.contentDOM),this.children=[new yt],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Te(0,0,0,t.state.doc.length)],0,null)}update(t){var e;let i=t.changedRanges;this.minWidth>0&&i.length&&(i.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.updateEditContextFormatting(t);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&((null===(e=this.domChanged)||void 0===e?void 0:e.newSel)?n=this.domChanged.newSel.head:He(t.changes,this.hasComposition)||t.selectionSet||(n=t.state.selection.main.head));let s=n>-1?Pe(this.view,t.changes,n):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:e,to:n}=this.hasComposition;i=new Te(e,n,t.changes.mapPos(e,-1),t.changes.mapPos(n,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(l.ie||l.chrome)&&!s&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let r=Ie(this.decorations,this.updateDeco(),t.changes);return i=Te.extendWithRanges(i,r),!!(7&this.flags||0!=i.length)&&(this.updateInner(i,t.startState.doc.length,s),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e,i){this.view.viewState.mustMeasureContent=!0,this.updateChildren(t,e,i);let{observer:n}=this.view;n.ignore((()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let t=l.chrome||l.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,t),this.flags&=-8,t&&(t.written||n.selectionRange.focusNode!=t.node)&&(this.forceSelection=!0),this.dom.style.height=""})),this.markedForComposition.forEach((t=>t.flags&=-9));let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let r of this.children)r instanceof bt&&r.widget instanceof Re&&s.push(r.dom);n.updateGaps(s)}updateChildren(t,e,i){let n=i?i.range.addToSet(t.slice()):t,s=this.childCursor(e);for(let r=n.length-1;;r--){let t=r>=0?n[r]:null;if(!t)break;let e,o,h,l,{fromA:a,toA:c,fromB:u,toB:f}=t;if(i&&i.range.fromB<f&&i.range.toB>u){let t=Tt.build(this.view.state.doc,u,i.range.fromB,this.decorations,this.dynamicDecorationMap),n=Tt.build(this.view.state.doc,i.range.toB,f,this.decorations,this.dynamicDecorationMap);o=t.breakAtStart,h=t.openStart,l=n.openEnd;let s=this.compositionView(i);n.breakAtStart?s.breakAfter=1:n.content.length&&s.merge(s.length,s.length,n.content[0],!1,n.openStart,0)&&(s.breakAfter=n.content[0].breakAfter,n.content.shift()),t.content.length&&s.merge(0,0,t.content[t.content.length-1],!0,0,t.openEnd)&&t.content.pop(),e=t.content.concat(s).concat(n.content)}else({content:e,breakAtStart:o,openStart:h,openEnd:l}=Tt.build(this.view.state.doc,u,f,this.decorations,this.dynamicDecorationMap));let{i:d,off:g}=s.findPos(c,1),{i:p,off:m}=s.findPos(a,-1);$(this,p,m,d,g,e,o,h,l)}i&&this.fixCompositionDOM(i)}updateEditContextFormatting(t){this.editContextFormatting=this.editContextFormatting.map(t.changes);for(let e of t.transactions)for(let t of e.effects)t.is(ue)&&(this.editContextFormatting=t.value)}compositionView(t){let e=new rt(t.text.nodeValue);e.flags|=8;for(let{deco:n}of t.marks)e=new ot(n,[e],e.length);let i=new yt;return i.append(e,0),i}fixCompositionDOM(t){let e=(t,e)=>{e.flags|=8|(e.children.some((t=>7&t.flags))?1:0),this.markedForComposition.add(e);let i=_.get(t);i&&i!=e&&(i.dom=null),e.setDOM(t)},i=this.childPos(t.range.fromB,1),n=this.children[i.i];e(t.line,n);for(let s=t.marks.length-1;s>=-1;s--)i=n.childPos(i.off,1),n=n.children[i.i],e(s>=0?t.marks[s].node:t.text,n)}updateSelection(t=!1,e=!1){!t&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let i=this.view.root.activeElement,n=i==this.dom,s=!n&&m(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(n||e||s))return;let r=this.forceSelection;this.forceSelection=!1;let o=this.view.state.selection.main,h=this.moveToLine(this.domAtPos(o.anchor)),a=o.empty?h:this.moveToLine(this.domAtPos(o.head));if(l.gecko&&o.empty&&!this.hasComposition&&(1==(c=h).node.nodeType&&c.node.firstChild&&(0==c.offset||"false"==c.node.childNodes[c.offset-1].contentEditable)&&(c.offset==c.node.childNodes.length||"false"==c.node.childNodes[c.offset].contentEditable))){let t=document.createTextNode("");this.view.observer.ignore((()=>h.node.insertBefore(t,h.node.childNodes[h.offset]||null))),h=a=new F(t,0),r=!0}var c;let u=this.view.observer.selectionRange;!r&&u.focusNode&&(v(h.node,h.offset,u.anchorNode,u.anchorOffset)&&v(a.node,a.offset,u.focusNode,u.focusOffset)||this.suppressWidgetCursorChange(u,o))||(this.view.observer.ignore((()=>{l.android&&l.chrome&&this.dom.contains(u.focusNode)&&Ve(u.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let t=d(this.view.root);if(t)if(o.empty){if(l.gecko){let t=Le(h.node,h.offset);if(t&&3!=t){let e=(1==t?H:W)(h.node,h.offset);e&&(h=new F(e.node,e.offset))}}t.collapse(h.node,h.offset),null!=o.bidiLevel&&void 0!==t.caretBidiLevel&&(t.caretBidiLevel=o.bidiLevel)}else if(t.extend){t.collapse(h.node,h.offset);try{t.extend(a.node,a.offset)}catch(e){}}else{let e=document.createRange();o.anchor>o.head&&([h,a]=[a,h]),e.setEnd(a.node,a.offset),e.setStart(h.node,h.offset),t.removeAllRanges(),t.addRange(e)}else;s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())})),this.view.observer.setSelectionRange(h,a)),this.impreciseAnchor=h.precise?null:new F(u.anchorNode,u.anchorOffset),this.impreciseHead=a.precise?null:new F(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&v(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)&&this.posFromDOM(t.focusNode,t.focusOffset)==e.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:t}=this,e=t.state.selection.main,i=d(t.root),{anchorNode:n,anchorOffset:s}=t.observer.selectionRange;if(!(i&&e.empty&&e.assoc&&i.modify))return;let r=yt.find(this,e.head);if(!r)return;let o=r.posAtStart;if(e.head==o||e.head==o+r.length)return;let h=this.coordsAt(e.head,-1),l=this.coordsAt(e.head,1);if(!h||!l||h.bottom>l.top)return;let a=this.domAtPos(e.head+e.assoc);i.collapse(a.node,a.offset),i.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let c=t.observer.selectionRange;t.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=e.from&&i.collapse(n,s)}moveToLine(t){let e,i=this.dom;if(t.node!=i)return t;for(let n=t.offset;!e&&n<i.childNodes.length;n++){let t=_.get(i.childNodes[n]);t instanceof yt&&(e=t.domAtPos(0))}for(let n=t.offset-1;!e&&n>=0;n--){let t=_.get(i.childNodes[n]);t instanceof yt&&(e=t.domAtPos(t.length))}return e?new F(e.node,e.offset,!0):t}nearest(t){for(let e=t;e;){let t=_.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 yt)break;e++,i=0}return this.children[e].domAtPos(i)}coordsAt(t,e){let i=null,n=0;for(let s=this.length,r=this.children.length-1;r>=0;r--){let o=this.children[r],h=s-o.breakAfter,l=h-o.length;if(h<t)break;if(l<=t&&(l<t||o.covers(-1))&&(h>t||o.covers(1))&&(!i||o instanceof yt&&!(i instanceof yt&&e>=0)))i=o,n=l;else if(i&&l==t&&h==t&&o instanceof bt&&Math.abs(e)<2){if(o.deco.startSide<0)break;r&&(i=null)}s=l}return i?i.coordsAt(t-n,e):null}coordsForChar(t){let{i:e,off:i}=this.childPos(t,1),n=this.children[e];if(!(n instanceof yt))return null;for(;n.children.length;){let{i:t,off:e}=n.childPos(i,1);for(;;t++){if(t==n.children.length)return null;if((n=n.children[t]).length)break}i=e}if(!(n instanceof rt))return null;let s=(0,r.cp)(n.text,i);if(s==i)return null;let o=B(n.dom,i,s).getClientRects();for(let r=0;r<o.length;r++){let t=o[r];if(r==o.length-1||t.top<t.bottom&&t.left<t.right)return t}return null}measureVisibleLineHeights(t){let e=[],{from:i,to:n}=t,s=this.view.contentDOM.clientWidth,r=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,h=this.view.textDirection==c.LTR;for(let l=0,a=0;a<this.children.length;a++){let t=this.children[a],c=l+t.length;if(c>n)break;if(l>=i){let i=t.dom.getBoundingClientRect();if(e.push(i.height),r){let e=t.dom.lastChild,n=e?w(e):[];if(n.length){let t=n[n.length-1],e=h?t.right-i.left:i.right-t.left;e>o&&(o=e,this.minWidth=s,this.minWidthFrom=l,this.minWidthTo=c)}}}l=c+t.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?c.RTL:c.LTR}measureTextSize(){for(let s of this.children)if(s instanceof yt){let t=s.measureTextSize();if(t)return t}let t,e,i,n=document.createElement("div");return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore((()=>{this.dom.appendChild(n);let s=w(n.firstChild)[0];t=n.getBoundingClientRect().height,e=s?s.width/27:7,i=s?s.height:t,n.remove()})),{lineHeight:t,charWidth:e,textHeight:i}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new q(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)/this.view.scaleY;t.push(St.replace({widget:new Re(n),block:!0,inclusive:!0,isBlockGap:!0}).range(i,r))}if(!s)break;i=s.to+1}return St.set(t)}updateDeco(){let t=1,e=this.view.state.facet(be).map((e=>(this.dynamicDecorationMap[t++]="function"==typeof e)?e(this.view):e)),i=!1,n=this.view.state.facet(xe).map(((t,e)=>{let n="function"==typeof t;return n&&(i=!0),n?t(this.view):t}));for(n.length&&(this.dynamicDecorationMap[t++]=i,e.push(r.Xs.join(n))),this.decorations=[this.editContextFormatting,...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];t<this.decorations.length;)this.dynamicDecorationMap[t++]=!1;return this.decorations}scrollIntoView(t){if(t.isSnapshot){let e=this.view.viewState.lineBlockAt(t.range.head);return this.view.scrollDOM.scrollTop=e.top-t.yMargin,void(this.view.scrollDOM.scrollLeft=t.xMargin)}for(let a of this.view.state.facet(le))try{if(a(this.view,t.range,t))return!0}catch(l){fe(this.view.state,l,"scroll handler")}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=Ce(this.view),r={left:n.left-s.left,top:n.top-s.top,right:n.right+s.right,bottom:n.bottom+s.bottom},{offsetWidth:o,offsetHeight:h}=this.view.scrollDOM;C(this.view.scrollDOM,r,i.head<i.anchor?-1:1,t.x,t.y,Math.max(Math.min(t.xMargin,o),-o),Math.max(Math.min(t.yMargin,h),-h),this.view.textDirection==c.LTR)}}class Re extends xt{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return t.className="cm-gap",this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function Be(t,e){let i=t.observer.selectionRange;if(!i.focusNode)return null;let n=H(i.focusNode,i.focusOffset),s=W(i.focusNode,i.focusOffset),r=n||s;if(s&&n&&s.node!=n.node){let e=_.get(s.node);if(!e||e instanceof rt&&e.text!=s.node.nodeValue)r=s;else if(t.docView.lastCompositionAfterCursor){let t=_.get(n.node);!t||t instanceof rt&&t.text!=n.node.nodeValue||(r=s)}}if(t.docView.lastCompositionAfterCursor=r!=n,!r)return null;let o=e-r.offset;return{from:o,to:o+r.node.nodeValue.length,node:r.node}}function Pe(t,e,i){let n=Be(t,i);if(!n)return null;let{node:s,from:r,to:o}=n,h=s.nodeValue;if(/[\n\r]/.test(h))return null;if(t.state.doc.sliceString(n.from,n.to)!=h)return null;let l=e.invertedDesc,a=new Te(l.mapPos(r),l.mapPos(o),r,o),c=[];for(let u=s.parentNode;;u=u.parentNode){let e=_.get(u);if(e instanceof ot)c.push({node:u,deco:e.mark});else{if(e instanceof yt||"DIV"==u.nodeName&&u.parentNode==t.contentDOM)return{range:a,text:s,marks:c,line:u};if(u==t.contentDOM)return null;c.push({node:u,deco:new kt({inclusive:!0,attributes:vt(u),tagName:u.tagName.toLowerCase()})})}}}function Le(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)}let Ne=class{constructor(){this.changes=[]}compareRange(t,e){Ot(t,e,this.changes)}comparePoint(t,e){Ot(t,e,this.changes)}};function Ie(t,e,i){let n=new Ne;return r.Xs.compare(t,e,i,n),n.changes}function Ve(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 He(t,e){let i=!1;return e&&t.iterChangedRanges(((t,n)=>{t<e.to&&n>e.from&&(i=!0)})),i}function We(t,e,i=1){let n=t.charCategorizer(e),s=t.doc.lineAt(e),o=e-s.from;if(0==s.length)return r.jT.cursor(e);0==o?i=1:o==s.length&&(i=-1);let h=o,l=o;i<0?h=(0,r.cp)(s.text,o,!1):l=(0,r.cp)(s.text,o);let a=n(s.text.slice(h,l));for(;h>0;){let t=(0,r.cp)(s.text,h,!1);if(n(s.text.slice(t,h))!=a)break;h=t}for(;l<s.length;){let t=(0,r.cp)(s.text,l);if(n(s.text.slice(l,t))!=a)break;l=t}return r.jT.range(h+s.from,l+s.from)}function Fe(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function ze(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function _e(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function je(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function qe(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function $e(t,e,i){let n,s,r,o,h,l,a,c,u=!1;for(let d=t.firstChild;d;d=d.nextSibling){let t=w(d);for(let f=0;f<t.length;f++){let g=t[f];s&&_e(s,g)&&(g=je(qe(g,s.bottom),s.top));let p=Fe(e,g),m=ze(i,g);if(0==p&&0==m)return 3==d.nodeType?Ke(d,e,i):$e(d,e,i);if(!n||o>m||o==m&&r>p){n=d,s=g,r=p,o=m;let h=m?i<g.top?-1:1:p?e<g.left?-1:1:0;u=!h||(h>0?f<t.length-1:f>0)}0==p?i>g.bottom&&(!a||a.bottom<g.bottom)?(h=d,a=g):i<g.top&&(!c||c.top>g.top)&&(l=d,c=g):a&&_e(a,g)?a=qe(a,g.bottom):c&&_e(c,g)&&(c=je(c,g.top))}}if(a&&a.bottom>=i?(n=h,s=a):c&&c.top<=i&&(n=l,s=c),!n)return{node:t,offset:0};let f=Math.max(s.left,Math.min(s.right,e));return 3==n.nodeType?Ke(n,f,i):u&&"false"!=n.contentEditable?$e(n,f,i):{node:t,offset:Array.prototype.indexOf.call(t.childNodes,n)+(e>=(s.left+s.right)/2?1:0)}}function Ke(t,e,i){let n=t.nodeValue.length,s=-1,r=1e9,o=0;for(let h=0;h<n;h++){let n=B(t,h,h+1).getClientRects();for(let a=0;a<n.length;a++){let c=n[a];if(c.top==c.bottom)continue;o||(o=e-c.left);let u=(c.top>i?c.top-i:i-c.bottom)-1;if(c.left-1<=e&&c.right+1>=e&&u<r){let i=e>=(c.left+c.right)/2,n=i;if(l.chrome||l.gecko){B(t,h).getBoundingClientRect().left==c.right&&(n=!i)}if(u<=0)return{node:t,offset:h+(n?1:0)};s=h+(n?1:0),r=u}}}return{node:t,offset:s>-1?s:o>0?t.nodeValue.length:0}}function Je(t,e,i,n=-1){var s,r;let o,h=t.contentDOM.getBoundingClientRect(),c=h.top+t.viewState.paddingTop,{docHeight:u}=t.viewState,{x:f,y:d}=e,g=d-c;if(g<0)return 0;if(g>u)return t.state.doc.length;for(let l=t.viewState.heightOracle.textHeight/2,S=!1;o=t.elementAtHeight(g),o.type!=a.Text;)for(;g=n>0?o.bottom+l:o.top-l,!(g>=0&&g<=u);){if(S)return i?null:0;S=!0,n=-n}d=c+g;let p=o.from;if(p<t.viewport.from)return 0==t.viewport.from?0:i?null:Ge(t,h,o,f,d);if(p>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:Ge(t,h,o,f,d);let m=t.dom.ownerDocument,w=t.root.elementFromPoint?t.root:m,v=w.elementFromPoint(f,d);v&&!t.contentDOM.contains(v)&&(v=null),v||(f=Math.max(h.left+1,Math.min(h.right-1,f)),v=w.elementFromPoint(f,d),v&&!t.contentDOM.contains(v)&&(v=null));let y,b=-1;if(v&&0!=(null===(s=t.docView.nearest(v))||void 0===s?void 0:s.isEditable))if(m.caretPositionFromPoint){let t=m.caretPositionFromPoint(f,d);t&&({offsetNode:y,offset:b}=t)}else if(m.caretRangeFromPoint){let e=m.caretRangeFromPoint(f,d);e&&(({startContainer:y,startOffset:b}=e),(!t.contentDOM.contains(y)||l.safari&&Ue(y,b,f)||l.chrome&&Xe(y,b,f))&&(y=void 0))}if(!y||!t.docView.dom.contains(y)){let e=yt.find(t.docView,p);if(!e)return g>o.top+o.height/2?o.to:o.from;({node:y,offset:b}=$e(e.dom,f,d))}let x=t.docView.nearest(y);if(!x)return null;if(x.isWidget&&1==(null===(r=x.dom)||void 0===r?void 0:r.nodeType)){let t=x.dom.getBoundingClientRect();return e.y<t.top||e.y<=t.bottom&&e.x<=(t.left+t.right)/2?x.posAtStart:x.posAtEnd}return x.localPosFromDOM(y,b)+x.posAtStart}function Ge(t,e,i,n,s){let o=Math.round((n-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>1.5*t.defaultLineHeight){let e=t.viewState.heightOracle.textHeight;o+=Math.floor((s-i.top-.5*(t.defaultLineHeight-e))/e)*t.viewState.heightOracle.lineLength}let h=t.state.sliceDoc(i.from,i.to);return i.from+(0,r.Gz)(h,o,t.state.tabSize)}function Ue(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 B(t,n-1,n).getBoundingClientRect().left>i}function Xe(t,e,i){if(0!=e)return!1;for(let n=t;;){let t=n.parentNode;if(!t||1!=t.nodeType||t.firstChild!=n)return!1;if(t.classList.contains("cm-line"))break;n=t}return i-(1==t.nodeType?t.getBoundingClientRect():B(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect()).left>5}function Ye(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==a.Text))return n;return i}function Qe(t,e,i,n){let s=Ye(t,e.head),o=n&&s.type==a.Text&&(t.lineWrapping||s.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head):null;if(o){let e=t.dom.getBoundingClientRect(),n=t.textDirectionAt(s.from),h=t.posAtCoords({x:i==(n==c.LTR)?e.right-1:e.left+1,y:(o.top+o.bottom)/2});if(null!=h)return r.jT.cursor(h,i?-1:1)}return r.jT.cursor(i?s.to:s.from,i?-1:1)}function Ze(t,e,i,n){let s=t.state.doc.lineAt(e.head),r=t.bidiSpans(s),o=t.textDirectionAt(s.from);for(let h=e,l=null;;){let e=Yt(s,r,o,h,i),a=Xt;if(!e){if(s.number==(i?t.state.doc.lines:1))return h;a="\n",s=t.state.doc.line(s.number+(i?1:-1)),r=t.bidiSpans(s),e=t.visualLineSide(s,!i)}if(l){if(!l(a))return h}else{if(!n)return e;l=n(a)}h=e}}function ti(t,e,i){let n=t.state.charCategorizer(e),s=n(i);return t=>{let e=n(t);return s==r.D0.Space&&(s=e),s==e}}function ei(t,e,i,n){let s=e.head,o=i?1:-1;if(s==(i?t.state.doc.length:0))return r.jT.cursor(s,e.assoc);let h,l=e.goalColumn,a=t.contentDOM.getBoundingClientRect(),c=t.coordsAtPos(s,e.assoc||-1),u=t.documentTop;if(c)null==l&&(l=c.left-a.left),h=o<0?c.top:c.bottom;else{let e=t.viewState.lineBlockAt(s);null==l&&(l=Math.min(a.right-a.left,t.defaultCharacterWidth*(s-e.from))),h=(o<0?e.top:e.bottom)+u}let f=a.left+l,d=null!=n?n:t.viewState.heightOracle.textHeight>>1;for(let g=0;;g+=10){let e=h+(d+g)*o,i=Je(t,{x:f,y:e},!1,o);if(e<a.top||e>a.bottom||(o<0?i<s:i>s)){let n=t.docView.coordsForChar(i),s=!n||e<n.top?-1:1;return r.jT.cursor(i,s,void 0,l)}}}function ii(t,e,i){for(;;){let n=0;for(let s of t)s.between(e-1,e+1,((t,s,r)=>{if(e>t&&e<s){let r=n||i||(e-t<s-e?-1:1);e=r<0?t:s,n=r}}));if(!n)return e}}function ni(t,e,i){let n=ii(t.state.facet(Se).map((e=>e(t))),i.from,e.head>i.from?-1:1);return n==i.from?i:r.jT.cursor(n,n<i.from?1:-1)}class si{setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}constructor(t){this.view=t,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=t.hasFocus,l.safari&&t.contentDOM.addEventListener("input",(()=>null)),l.gecko&&_i(t.contentDOM.ownerDocument)}handleEvent(t){mi(this.view,t)&&!this.ignoreDuringComposition(t)&&("keydown"==t.type&&this.keydown(t)||this.runHandlers(t.type,t))}runHandlers(t,e){let i=this.handlers[t];if(i){for(let t of i.observers)t(this.view,e);for(let t of i.handlers){if(e.defaultPrevented)break;if(t(this.view,e)){e.preventDefault();break}}}}ensureHandlers(t){let e=oi(t),i=this.handlers,n=this.view.contentDOM;for(let s in e)if("scroll"!=s){let t=!e[s].handlers.length,r=i[s];r&&t!=!r.handlers.length&&(n.removeEventListener(s,this.handleEvent),r=null),r||n.addEventListener(s,this.handleEvent,{passive:t})}for(let s in i)"scroll"==s||e[s]||n.removeEventListener(s,this.handleEvent);this.handlers=e}keydown(t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),9==t.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&27!=t.keyCode&&ai.indexOf(t.keyCode)<0&&(this.tabFocusMode=-1),l.android&&l.chrome&&!t.synthetic&&(13==t.keyCode||8==t.keyCode))return this.view.observer.delayAndroidKey(t.key,t.keyCode),!0;let e;return!l.ios||t.synthetic||t.altKey||t.metaKey||!((e=hi.find((e=>e.keyCode==t.keyCode)))&&!t.ctrlKey||li.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)?(229!=t.keyCode&&this.view.observer.forceFlush(),!1):(this.pendingIOSKey=e||t,setTimeout((()=>this.flushIOSKey()),250),!0)}flushIOSKey(t){let e=this.pendingIOSKey;return!!e&&(!("Enter"==e.key&&t&&t.from<t.to&&/^\S+$/.test(t.insert.toString()))&&(this.pendingIOSKey=void 0,P(this.view.contentDOM,e.key,e.keyCode,e instanceof KeyboardEvent?e:void 0)))}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(this.composing>0||!!(l.safari&&!l.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.view.observer.update(t),this.mouseSelection&&this.mouseSelection.update(t),this.draggedContent&&t.docChanged&&(this.draggedContent=this.draggedContent.map(t.changes)),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function ri(t,e){return(i,n)=>{try{return e.call(t,n,i)}catch(s){fe(i.state,s)}}}function oi(t){let e=Object.create(null);function i(t){return e[t]||(e[t]={observers:[],handlers:[]})}for(let n of t){let t=n.spec;if(t&&t.domEventHandlers)for(let e in t.domEventHandlers){let s=t.domEventHandlers[e];s&&i(e).handlers.push(ri(n.value,s))}if(t&&t.domEventObservers)for(let e in t.domEventObservers){let s=t.domEventObservers[e];s&&i(e).observers.push(ri(n.value,s))}}for(let n in wi)i(n).handlers.push(wi[n]);for(let n in vi)i(n).observers.push(vi[n]);return e}const hi=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],li="dthko",ai=[16,17,18,20,91,92,224,225],ci=6;function ui(t){return.7*Math.max(0,t)+8}class fi{constructor(t,e,i,n){this.view=t,this.startEvent=e,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParent=O(t.contentDOM),this.atoms=t.state.facet(Se).map((e=>e(t)));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(r.yy.allowMultipleSelections)&&di(t,e),this.dragging=!(!pi(t,e)||1!=Ri(e))&&null}start(t){!1===this.dragging&&this.select(t)}move(t){var e,i,n;if(0==t.buttons)return this.destroy();if(this.dragging||null==this.dragging&&(i=this.startEvent,n=t,Math.max(Math.abs(i.clientX-n.clientX),Math.abs(i.clientY-n.clientY))<10))return;this.select(this.lastEvent=t);let s=0,r=0,o=(null===(e=this.scrollParent)||void 0===e?void 0:e.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},h=Ce(this.view);t.clientX-h.left<=o.left+ci?s=-ui(o.left-t.clientX):t.clientX+h.right>=o.right-ci&&(s=ui(t.clientX-o.right)),t.clientY-h.top<=o.top+ci?r=-ui(o.top-t.clientY):t.clientY+h.bottom>=o.bottom-ci&&(r=ui(t.clientY-o.bottom)),this.setScrollSpeed(s,r)}up(t){null==this.dragging&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval((()=>this.scroll()),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),!1===this.dragging&&this.select(this.lastEvent)}skipAtoms(t){let e=null;for(let i=0;i<t.ranges.length;i++){let n=t.ranges[i],s=null;if(n.empty){let t=ii(this.atoms,n.from,0);t!=n.from&&(s=r.jT.cursor(t,-1))}else{let t=ii(this.atoms,n.from,-1),e=ii(this.atoms,n.to,1);t==n.from&&e==n.to||(s=r.jT.range(n.from==n.anchor?t:e,n.from==n.head?t:e))}s&&(e||(e=t.ranges.slice()),e[i]=s)}return e?r.jT.create(e,t.mainIndex):t}select(t){let{view:e}=this,i=this.skipAtoms(this.style.get(t,this.extend,this.multiple));!this.mustSelect&&i.eq(e.state.selection,!1===this.dragging)||this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){t.transactions.some((t=>t.isUserEvent("input.type")))?this.destroy():this.style.update(t)&&setTimeout((()=>this.select(this.lastEvent)),20)}}function di(t,e){let i=t.state.facet(Zt);return i.length?i[0](e):l.mac?e.metaKey:e.ctrlKey}function gi(t,e){let i=t.state.facet(te);return i.length?i[0](e):l.mac?!e.altKey:!e.ctrlKey}function pi(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let n=d(t.root);if(!n||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 mi(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=_.get(n))&&i.ignoreEvent(e))return!1;return!0}const wi=Object.create(null),vi=Object.create(null),yi=l.ie&&l.ie_version<15||l.ios&&l.webkit_version<604;function bi(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(),xi(t,i.value)}),50)}function xi(t,e){let i,{state:n}=t,s=1,o=n.toText(e),h=o.lines==n.selection.ranges.length;if(null!=Vi&&n.selection.ranges.every((t=>t.empty))&&Vi==o.toString()){let t=-1;i=n.changeByRange((i=>{let l=n.doc.lineAt(i.from);if(l.from==t)return{range:i};t=l.from;let a=n.toText((h?o.line(s++).text:e)+n.lineBreak);return{changes:{from:l.from,insert:a},range:r.jT.cursor(i.from+a.length)}}))}else i=h?n.changeByRange((t=>{let e=o.line(s++);return{changes:{from:t.from,to:t.to,insert:e.text},range:r.jT.cursor(t.from+e.length)}})):n.replaceSelection(o);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function Si(t,e,i,n){if(1==n)return r.jT.cursor(e,i);if(2==n)return We(t.state,e,i);{let i=yt.find(t.docView,e),n=t.state.doc.lineAt(i?i.posAtEnd:e),s=i?i.posAtStart:n.from,o=i?i.posAtEnd:n.to;return o<t.state.doc.length&&o==n.to&&o++,r.jT.range(s,o)}}vi.scroll=t=>{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft},wi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),27==e.keyCode&&0!=t.inputState.tabFocusMode&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),vi.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},vi.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},wi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let i=null;for(let n of t.state.facet(ee))if(i=n(t,e),i)break;if(i||0!=e.button||(i=Bi(t,e)),i){let n=!t.hasFocus;t.inputState.startMouseSelection(new fi(t,e,i,n)),n&&t.observer.ignore((()=>{R(t.contentDOM);let e=t.root.activeElement;e&&!e.contains(t.contentDOM)&&e.blur()}));let s=t.inputState.mouseSelection;if(s)return s.start(e),!1===s.dragging}return!1};let ki=(t,e)=>t>=e.top&&t<=e.bottom,Ai=(t,e,i)=>ki(e,i)&&t>=i.left&&t<=i.right;function Mi(t,e,i,n){let s=yt.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&&Ai(i,n,o))return-1;let h=s.coordsAt(r,1);return h&&Ai(i,n,h)?1:o&&ki(n,o)?-1:1}function Ci(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:Mi(t,i,e.clientX,e.clientY)}}const Oi=l.ie&&l.ie_version<=11;let Ti=null,Di=0,Ei=0;function Ri(t){if(!Oi)return t.detail;let e=Ti,i=Ei;return Ti=t,Ei=Date.now(),Di=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Di+1)%3:1}function Bi(t,e){let i=Ci(t,e),n=Ri(e),s=t.state.selection;return{update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),s=s.map(t.changes))},get(e,o,h){let l,a=Ci(t,e),c=Si(t,a.pos,a.bias,n);if(i.pos!=a.pos&&!o){let e=Si(t,i.pos,i.bias,n),s=Math.min(e.from,c.from),o=Math.max(e.to,c.to);c=s<c.from?r.jT.range(s,o):r.jT.range(o,s)}return o?s.replaceRange(s.main.extend(c.from,c.to)):h&&1==n&&s.ranges.length>1&&(l=Pi(s,a.pos))?l:h?s.addRange(c):r.jT.create([c])}}}function Pi(t,e){for(let i=0;i<t.ranges.length;i++){let{from:n,to:s}=t.ranges[i];if(n<=e&&s>=e)return r.jT.create(t.ranges.slice(0,i).concat(t.ranges.slice(i+1)),t.mainIndex==i?0:t.mainIndex-(t.mainIndex>i?1:0))}return null}function Li(t,e,i,n){if(!i)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=t.inputState,o=n&&r&&gi(t,e)?{from:r.from,to:r.to}:null,h={from:s,insert:i},l=t.state.changes(o?[o,h]:h);t.focus(),t.dispatch({changes:l,selection:{anchor:l.mapPos(s,-1),head:l.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"}),t.inputState.draggedContent=null}function Ni(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 Ii(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}}wi.dragstart=(t,e)=>{let{selection:{main:i}}=t.state;if(e.target.draggable){let n=t.docView.nearest(e.target);if(n&&n.isWidget){let t=n.posAtStart,e=t+n.length;(t>=i.to||e<=i.from)&&(i=r.jT.range(t,e))}}let{inputState:n}=t;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=i,e.dataTransfer&&(e.dataTransfer.setData("Text",t.state.sliceDoc(i.from,i.to)),e.dataTransfer.effectAllowed="copyMove"),!1},wi.dragend=t=>(t.inputState.draggedContent=null,!1),wi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let i=e.dataTransfer.files;if(i&&i.length){let n=Array(i.length),s=0,r=()=>{++s==i.length&&Li(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])}return!0}{let i=e.dataTransfer.getData("Text");if(i)return Li(t,e,i,!0),!0}return!1},wi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let i=yi?null:e.clipboardData;return i?(xi(t,i.getData("text/plain")||i.getData("text/uri-list")),!0):(bi(t),!1)};let Vi=null;wi.copy=wi.cut=(t,e)=>{let{text:i,ranges:n,linewise:s}=Ii(t.state);if(!i&&!s)return!1;Vi=s?i:null,"cut"!=e.type||t.state.readOnly||t.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let r=yi?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",i),!0):(Ni(t,i),!1)};const Hi=r.q6.define();function Wi(t,e){let i=[];for(let n of t.facet(re)){let s=n(t,e);s&&i.push(s)}return i?t.update({effects:i,annotations:Hi.of(!0)}):null}function Fi(t){setTimeout((()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=Wi(t.state,e);i?t.dispatch(i):t.update([])}}),10)}vi.focus=t=>{t.inputState.lastFocusTime=Date.now(),t.scrollDOM.scrollTop||!t.inputState.lastScrollTop&&!t.inputState.lastScrollLeft||(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),Fi(t)},vi.blur=t=>{t.observer.clearSelectionRange(),Fi(t)},vi.compositionstart=vi.compositionupdate=t=>{t.observer.editContext||(null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},vi.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,l.chrome&&l.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then((()=>t.observer.flush())):setTimeout((()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])}),50))},vi.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},wi.beforeinput=(t,e)=>{var i;let n;if(l.chrome&&l.android&&(n=hi.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)}return l.ios&&"deleteContentForward"==e.inputType&&t.observer.flushSoon(),l.safari&&"insertText"==e.inputType&&t.inputState.composing>=0&&setTimeout((()=>vi.compositionend(t,e)),20),!1};const zi=new Set;function _i(t){zi.has(t)||(zi.add(t),t.addEventListener("copy",(()=>{})),t.addEventListener("cut",(()=>{})))}const ji=["pre-wrap","normal","pre-line","break-spaces"];class qi{constructor(t){this.lineWrapping=t,this.doc=r.xv.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,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.max(0,Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(t){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5))))*this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return ji.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let n=t[i];n<0?i++:this.heightSamples[Math.floor(10*n)]||(e=!0,this.heightSamples[Math.floor(10*n)]=!0)}return e}refresh(t,e,i,n,s,r){let o=ji.indexOf(t)>-1,h=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=e,this.charWidth=i,this.textHeight=n,this.lineLength=s,h){this.heightSamples={};for(let t=0;t<r.length;t++){let e=r[t];e<0?t++:this.heightSamples[Math.floor(10*e)]=!0}}return h}}class $i{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class Ki{constructor(t,e,i,n,s){this.from=t,this.length=e,this.top=i,this.height=n,this._content=s}get type(){return"number"==typeof this._content?a.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof Mt?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(t){let e=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new Ki(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var u=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}(u||(u={}));const Ji=.001;class Gi{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)>Ji&&(t.heightChanged=!0),this.height=e)}replace(t,e,i){return Gi.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,n){let s=this,r=i.doc;for(let o=n.length-1;o>=0;o--){let{fromA:h,toA:l,fromB:a,toB:c}=n[o],f=s.lineAt(h,u.ByPosNoHeight,i.setDoc(e),0,0),d=f.to>=l?f:s.lineAt(l,u.ByPosNoHeight,i,0,0);for(c+=d.to-l,l=d.to;o>0&&f.from<=n[o-1].toA;)h=n[o-1].fromA,a=n[o-1].fromB,o--,h<f.from&&(f=s.lineAt(h,u.ByPosNoHeight,i,0,0));a+=f.from-h,h=f.from;let g=en.build(i.setDoc(r),t,a,c);s=s.replace(h,l,g)}return s.updateHeight(i,0)}static empty(){return new Xi(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 Qi(Gi.of(t.slice(0,e)),r,Gi.of(t.slice(i)))}}Gi.prototype.size=1;class Ui extends Gi{constructor(t,e,i){super(t,e),this.deco=i}blockAt(t,e,i,n){return new Ki(n,this.length,i,this.height,this.deco||0)}lineAt(t,e,i,n,s){return this.blockAt(0,i,n,s)}forEachLine(t,e,i,n,s,r){t<=s+this.length&&e>=s&&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 Xi extends Ui{constructor(t,e){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(t,e,i,n){return new Ki(n,this.length,i,this.height,this.breaks)}replace(t,e,i){let n=i[0];return 1==i.length&&(n instanceof Xi||n instanceof Yi&&4&n.flags)&&Math.abs(this.length-n.length)<10?(n instanceof Yi?n=new Xi(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):Gi.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.breaks*t.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Yi extends Gi{constructor(t){super(t,0)}heightMetrics(t,e){let i,n=t.doc.lineAt(e).number,s=t.doc.lineAt(e+this.length).number,r=s-n+1,o=0;if(t.lineWrapping){let e=Math.min(this.height,t.lineHeight*r);i=e/r,this.length>r+1&&(o=(this.height-e)/(this.length-r-1))}else i=this.height/r;return{firstLine:n,lastLine:s,perLine:i,perChar:o}}blockAt(t,e,i,n){let{firstLine:s,lastLine:r,perLine:o,perChar:h}=this.heightMetrics(e,n);if(e.lineWrapping){let s=n+(t<e.lineHeight?0:Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length)),r=e.doc.lineAt(s),l=o+r.length*h,a=Math.max(i,t-l/2);return new Ki(r.from,r.length,a,l,0)}{let n=Math.max(0,Math.min(r-s,Math.floor((t-i)/o))),{from:h,length:l}=e.doc.line(s+n);return new Ki(h,l,i+o*n,o,0)}}lineAt(t,e,i,n,s){if(e==u.ByHeight)return this.blockAt(t,i,n,s);if(e==u.ByPosNoHeight){let{from:e,to:n}=i.doc.lineAt(t);return new Ki(e,n-e,0,0,0)}let{firstLine:r,perLine:o,perChar:h}=this.heightMetrics(i,s),l=i.doc.lineAt(t),a=o+l.length*h,c=l.number-r,f=n+o*c+h*(l.from-s-c);return new Ki(l.from,l.length,Math.max(n,Math.min(f,n+this.height-a)),a,0)}forEachLine(t,e,i,n,s,r){t=Math.max(t,s),e=Math.min(e,s+this.length);let{firstLine:o,perLine:h,perChar:l}=this.heightMetrics(i,s);for(let a=t,c=n;a<=e;){let e=i.doc.lineAt(a);if(a==t){let i=e.number-o;c+=h*i+l*(t-s-i)}let n=h+l*e.length;r(new Ki(e.from,e.length,c,n,0)),c+=n,a=e.to+1}}replace(t,e,i){let n=this.length-e;if(n>0){let t=i[i.length-1];t instanceof Yi?i[i.length-1]=new Yi(t.length+n):i.push(null,new Yi(n-1))}if(t>0){let e=i[0];e instanceof Yi?i[0]=new Yi(t+e.length):i.unshift(new Yi(t-1),null)}return Gi.of(i)}decomposeLeft(t,e){e.push(new Yi(t-1),null)}decomposeRight(t,e){e.push(null,new Yi(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;for(n.from>e&&i.push(new Yi(n.from-e-1).updateHeight(t,e));r<=s&&n.more;){let e=t.doc.lineAt(r).length;i.length&&i.push(null);let s=n.heights[n.index++];-1==o?o=s:Math.abs(s-o)>=Ji&&(o=-2);let h=new Xi(e,s);h.outdated=!1,i.push(h),r+=e+1}r<=s&&i.push(null,new Yi(s-r).updateHeight(t,r));let h=Gi.of(i);return(o<0||Math.abs(h.height-this.height)>=Ji||Math.abs(o-this.heightMetrics(t,e).perLine)>=Ji)&&(t.heightChanged=!0),h}return(i||this.outdated)&&(this.setHeight(t,t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class Qi extends Gi{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,h=e==u.ByHeight?t<r:t<o,l=h?this.left.lineAt(t,e,i,n,s):this.right.lineAt(t,e,i,r,o);if(this.break||(h?l.to<o:l.from>o))return l;let a=e==u.ByPosNoHeight?u.ByPosNoHeight:u.ByPos;return h?l.join(this.right.lineAt(o,a,i,r,o)):this.left.lineAt(o,a,i,n,s).join(l)}forEachLine(t,e,i,n,s,r){let o=n+this.left.height,h=s+this.left.length+this.break;if(this.break)t<h&&this.left.forEachLine(t,e,i,n,s,r),e>=h&&this.right.forEachLine(t,e,i,o,h,r);else{let l=this.lineAt(h,u.ByPos,i,n,s);t<l.from&&this.left.forEachLine(t,l.from-1,i,n,s,r),l.to>=t&&l.from<=e&&r(l),e>l.to&&this.right.forEachLine(l.to+1,e,i,o,h,r)}}replace(t,e,i){let n=this.left.length+this.break;if(e<n)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let s=[];t>0&&this.decomposeLeft(t,s);let r=s.length;for(let o of i)s.push(o);if(t>0&&Zi(s,r-1),e<this.length){let t=s.length;this.decomposeRight(e,s),Zi(s,t)}return Gi.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?Gi.of(this.break?[t,null,e]:[t,e]):(this.left=t,this.right=e,this.height=t.height+e.height,this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,i=!1,n){let{left:s,right:r}=this,o=e+s.length+this.break,h=null;return n&&n.from<=e+s.length&&n.more?h=s=s.updateHeight(t,e,i,n):s.updateHeight(t,e,i),n&&n.from<=o+r.length&&n.more?h=r=r.updateHeight(t,o,i,n):r.updateHeight(t,o,i),h?this.balanced(s,r):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Zi(t,e){let i,n;null==t[e]&&(i=t[e-1])instanceof Yi&&(n=t[e+1])instanceof Yi&&t.splice(e-1,3,new Yi(i.length+1+n.length))}const tn=5;class en{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 Xi?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new Xi(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,s=i.widget?i.widget.lineBreaks:0;n<0&&(n=this.oracle.lineHeight);let r=e-t;i.block?this.addBlock(new Ui(r,n,i)):(r||s||n>=tn)&&this.addLineDeco(n,s,r)}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 Xi(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new Yi(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 Xi)return t;let e=new Xi(0,-1);return this.nodes.push(e),e}addBlock(t){this.enterLine();let e=t.deco;e&&e.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,e&&e.endSide>0&&(this.covering=t)}addLineDeco(t,e,i){let n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,t),n.breaks+=e,this.writtenTo=this.pos=this.pos+i}finish(t){let e=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof Xi||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new Xi(0,-1));let i=t;for(let n of this.nodes)n instanceof Xi&&n.updateHeight(this.oracle,i),i+=n?n.length:1;return this.nodes}static build(t,e,i,n){let s=new en(i,t);return r.Xs.spans(e,i,n,s,0),s.finish(i)}}function nn(t,e,i){let n=new sn;return r.Xs.compare(t,e,i,n,0),n.changes}class sn{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,n){(t<e||i&&i.heightRelevant||n&&n.heightRelevant)&&Ot(t,e,this.changes,5)}}function rn(t,e){let i=t.getBoundingClientRect(),n=t.ownerDocument,s=n.defaultView||window,r=Math.max(0,i.left),o=Math.min(s.innerWidth,i.right),h=Math.max(0,i.top),l=Math.min(s.innerHeight,i.bottom);for(let a=t.parentNode;a&&a!=n.body;)if(1==a.nodeType){let e=a,i=window.getComputedStyle(e);if((e.scrollHeight>e.clientHeight||e.scrollWidth>e.clientWidth)&&"visible"!=i.overflow){let i=e.getBoundingClientRect();r=Math.max(r,i.left),o=Math.min(o,i.right),h=Math.max(h,i.top),l=a==t.parentNode?i.bottom:Math.min(l,i.bottom)}a="absolute"==i.position||"fixed"==i.position?e.offsetParent:e.parentNode}else{if(11!=a.nodeType)break;a=a.host}return{left:r-i.left,right:Math.max(r,o)-i.left,top:h-(i.top+e),bottom:Math.max(h,l)-(i.top+e)}}function on(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class hn{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,e){return St.replace({widget:new ln(this.size*(e?t.scaleY:t.scaleX),e)}).range(this.from,this.to)}}class ln extends xt{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 an{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.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=pn,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=c.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let e=t.facet(ye).some((t=>"function"!=typeof t&&"cm-lineWrapping"==t.class));this.heightOracle=new qi(e),this.stateDeco=t.facet(be).filter((t=>"function"!=typeof t)),this.heightMap=Gi.empty().applyChanges(this.stateDeco,r.xv.empty,this.heightOracle.setDoc(t.doc),[new Te(0,0,0,t.doc.length)]);for(let i=0;i<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());i++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=St.set(this.lineGaps.map((t=>t.draw(this,!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 cn(e,i))}}return this.viewports=t.sort(((t,e)=>t.from-e.from)),this.updateScaler()}updateScaler(){let t=this.scaler;return this.scaler=this.heightMap.height<=7e6?pn:new mn(this.heightOracle,this.heightMap,this.viewports),t.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,(t=>{this.viewportLines.push(wn(t,this.scaler))}))}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(be).filter((t=>"function"!=typeof t));let n=t.changedRanges,s=Te.extendWithRanges(n,nn(i,this.stateDeco,t?t.changes:r.as.empty(this.state.doc.length))),o=this.heightMap.height,h=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),s),this.heightMap.height!=o&&(t.flags|=2),h?(this.scrollAnchorPos=t.changes.mapPos(h.from,-1),this.scrollAnchorHeight=h.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let l=s.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<l.from||e.range.head>l.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,e));let a=l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,t.flags|=this.updateForViewport(),(a||!t.changes.empty||2&t.flags)&&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&&!t.state.facet(he)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),n=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?c.RTL:c.LTR;let o=this.heightOracle.mustRefreshForWrapping(s),h=e.getBoundingClientRect(),l=o||this.mustMeasureContent||this.contentDOMHeight!=h.height;this.contentDOMHeight=h.height,this.mustMeasureContent=!1;let a=0,u=0;if(h.width&&h.height){let{scaleX:t,scaleY:i}=M(e,h);(t>.005&&Math.abs(this.scaleX-t)>.005||i>.005&&Math.abs(this.scaleY-i)>.005)&&(this.scaleX=t,this.scaleY=i,a|=8,o=l=!0)}let f=(parseInt(i.paddingTop)||0)*this.scaleY,d=(parseInt(i.paddingBottom)||0)*this.scaleY;this.paddingTop==f&&this.paddingBottom==d||(this.paddingTop=f,this.paddingBottom=d,a|=10),this.editorWidth!=t.scrollDOM.clientWidth&&(n.lineWrapping&&(l=!0),this.editorWidth=t.scrollDOM.clientWidth,a|=8);let g=t.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=g&&(this.scrollAnchorHeight=-1,this.scrollTop=g),this.scrolledToBottom=V(t.scrollDOM);let p=(this.printing?on:rn)(e,this.paddingTop),m=p.top-this.pixelViewport.top,w=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let v=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(v!=this.inView&&(this.inView=v,v&&(l=!0)),!this.inView&&!this.scrollTarget)return 0;let y=h.width;if(this.contentDOMWidth==y&&this.editorHeight==t.scrollDOM.clientHeight||(this.contentDOMWidth=h.width,this.editorHeight=t.scrollDOM.clientHeight,a|=8),l){let e=t.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(e)&&(o=!0),o||n.lineWrapping&&Math.abs(y-this.contentDOMWidth)>n.charWidth){let{lineHeight:i,charWidth:r,textHeight:h}=t.docView.measureTextSize();o=i>0&&n.refresh(s,i,r,h,y/r,e),o&&(t.docView.minWidth=0,a|=8)}m>0&&w>0?u=Math.max(m,w):m<0&&w<0&&(u=Math.min(m,w)),n.heightChanged=!1;for(let i of this.viewports){let s=i.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(i);this.heightMap=(o?Gi.empty().applyChanges(this.stateDeco,r.xv.empty,this.heightOracle,[new Te(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(n,0,o,new $i(i.from,s))}n.heightChanged&&(a|=2)}let b=!this.viewportIsAppropriate(this.viewport,u)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return b&&(2&a&&(a|=this.updateScaler()),this.viewport=this.getViewport(u,this.scrollTarget),a|=this.updateForViewport()),(2&a||b)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,t)),a|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),a}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),n=this.heightMap,s=this.heightOracle,{visibleTop:r,visibleBottom:o}=this,h=new cn(n.lineAt(r-1e3*i,u.ByHeight,s,0,0).from,n.lineAt(o+1e3*(1-i),u.ByHeight,s,0,0).to);if(e){let{head:t}=e.range;if(t<h.from||t>h.to){let i,r=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),o=n.lineAt(t,u.ByPos,s,0,0);i="center"==e.y?(o.top+o.bottom)/2-r/2:"start"==e.y||"nearest"==e.y&&t<h.from?o.top:o.bottom-r,h=new cn(n.lineAt(i-500,u.ByHeight,s,0,0).from,n.lineAt(i+r+500,u.ByHeight,s,0,0).to)}}return h}mapViewport(t,e){let i=e.mapPos(t.from,-1),n=e.mapPos(t.to,1);return new cn(this.heightMap.lineAt(i,u.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,u.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(t,u.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(e,u.ByPos,this.heightOracle,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 hn(e.mapPos(n.from),e.mapPos(n.to),n.size));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,s=n>>1,o=n<<1;if(this.defaultTextDirection!=c.LTR&&!i)return[];let h=[],l=(n,o,a,c)=>{if(o-n<s)return;let u=this.state.selection.main,f=[u.from];u.empty||f.push(u.to);for(let t of f)if(t>n&&t<o)return l(n,t-10,a,c),void l(t+10,o,a,c);let d=gn(t,(t=>t.from>=a.from&&t.to<=a.to&&Math.abs(t.from-n)<s&&Math.abs(t.to-o)<s&&!f.some((e=>t.from<e&&t.to>e))));if(!d){if(o<a.to&&e&&i&&e.visibleRanges.some((t=>t.from<=o&&t.to>=o))){let t=e.moveToLineBoundary(r.jT.cursor(o),!1,!0).head;t>n&&(o=t)}d=new hn(n,o,this.gapSize(a,n,o,c))}h.push(d)},u=t=>{if(t.length<o||t.type!=a.Text)return;let e=un(t.from,t.to,this.stateDeco);if(e.total<o)return;let s,r,h=this.scrollTarget?this.scrollTarget.range.head:null;if(i){let i,o,l=n/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=h){let n=dn(e,h),s=((this.visibleBottom-this.visibleTop)/2+l)/t.height;i=n-s,o=n+s}else i=(this.visibleTop-t.top-l)/t.height,o=(this.visibleBottom-t.top+l)/t.height;s=fn(e,i),r=fn(e,o)}else{let t,i,o=e.total*this.heightOracle.charWidth,l=n*this.heightOracle.charWidth;if(null!=h){let n=dn(e,h),s=((this.pixelViewport.right-this.pixelViewport.left)/2+l)/o;t=n-s,i=n+s}else t=(this.pixelViewport.left-l)/o,i=(this.pixelViewport.right+l)/o;s=fn(e,t),r=fn(e,i)}s>t.from&&l(t.from,s,t,e),r<t.to&&l(r,t.to,t,e)};for(let r of this.viewportLines)Array.isArray(r.type)?r.type.forEach(u):u(r);return h}gapSize(t,e,i,n){let s=dn(n,i)-dn(n,e);return this.heightOracle.lineWrapping?t.height*s:n.total*this.heightOracle.charWidth*s}updateLineGaps(t){hn.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=St.set(t.map((t=>t.draw(this,this.heightOracle.lineWrapping)))))}computeVisibleRanges(){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let e=[];r.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))||wn(this.heightMap.lineAt(t,u.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return t>=this.viewportLines[0].top&&t<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find((e=>e.top<=t&&e.bottom>=t))||wn(this.heightMap.lineAt(this.scaler.fromDOM(t),u.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(t){let e=this.lineBlockAtHeight(t+8);return e.from>=this.viewport.from||this.viewportLines[0].top-t>200?e:this.viewportLines[0]}elementAtHeight(t){return wn(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class cn{constructor(t,e){this.from=t,this.to=e}}function un(t,e,i){let n=[],s=t,o=0;return r.Xs.spans(i,t,e,{span(){},point(t,e){t>s&&(n.push({from:s,to:t}),o+=t-s),s=e}},20),s<e&&(n.push({from:s,to:e}),o+=e-s),{total:o,ranges:n}}function fn({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 dn(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 gn(t,e){for(let i of t)if(e(i))return i}const pn={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};class mn{constructor(t,e,i){let n=0,s=0,r=0;this.viewports=i.map((({from:i,to:s})=>{let r=e.lineAt(i,u.ByPos,t,0,0).top,o=e.lineAt(s,u.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}}eq(t){return t instanceof mn&&(this.scale==t.scale&&this.viewports.length==t.viewports.length&&this.viewports.every(((e,i)=>e.from==t.viewports[i].from&&e.to==t.viewports[i].to)))}}function wn(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),n=e.toDOM(t.bottom);return new Ki(t.from,t.length,i,n-i,Array.isArray(t._content)?t._content.map((t=>wn(t,e))):t._content)}const vn=r.r$.define({combine:t=>t.join(" ")}),yn=r.r$.define({combine:t=>t.indexOf(!0)>-1}),bn=o.V.newName(),xn=o.V.newName(),Sn=o.V.newName(),kn={"&light":"."+xn,"&dark":"."+Sn};function An(t,e,i){return new o.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 Mn=An("."+bn,{"&":{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,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",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"},".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"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},kn),Cn="￿";class On{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(r.yy.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=Cn}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let n=t;;){this.findPointBefore(i,n);let t=this.text.length;this.readNode(n);let s=n.nextSibling;if(s==e)break;let r=_.get(n),o=_.get(s);(r&&o?r.breakAfter:(r?r.breakAfter:b(n))||b(s)&&("BR"!=n.nodeName||n.cmIgnore)&&this.text.length>t)&&this.lineBreak(),n=s}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=_.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+(Tn(t,i.node,i.offset)?e:0))}}function Tn(t,e,i){for(;;){if(!e||i<S(e))return!1;if(e==t)return!0;i=y(e)+1,e=e.parentNode}}class Dn{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class En{constructor(t,e,i,n){this.typeOver=n,this.bounds=null,this.text="",this.domChanged=e>-1;let{impreciseHead:s,impreciseAnchor:o}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let e=s||o?[]:Nn(t),i=new On(e,t.state);i.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=i.text,this.newSel=In(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=s&&s.node==e.focusNode&&s.offset==e.focusOffset||!g(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),n=o&&o.node==e.anchorNode&&o.offset==e.anchorOffset||!g(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset),h=t.viewport;if((l.ios||l.chrome)&&t.state.selection.main.empty&&i!=n&&(h.from>0||h.to<t.state.doc.length)){let e=Math.min(i,n),s=Math.max(i,n),r=h.from-e,o=h.to-s;0!=r&&1!=r&&0!=e||0!=o&&-1!=o&&s!=t.state.doc.length||(i=0,n=t.state.doc.length)}this.newSel=r.jT.single(n,i)}}}function Rn(t,e){let i,{newSel:n}=e,s=t.state.selection.main,o=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:n,to:h}=e.bounds,a=s.from,c=null;(8===o||l.android&&e.text.length<h-n)&&(a=s.to,c="end");let u=Ln(t.state.doc.sliceString(n,h,Cn),e.text,a-n,c);u&&(l.chrome&&13==o&&u.toB==u.from+2&&e.text.slice(u.from,u.toB)==Cn+Cn&&u.toB--,i={from:n+u.from,to:n+u.toA,insert:r.xv.of(e.text.slice(u.from,u.toB).split(Cn))})}else n&&(!t.hasFocus&&t.state.facet(de)||n.main.eq(s))&&(n=null);if(!i&&!n)return!1;if(!i&&e.typeOver&&!s.empty&&n&&n.main.empty?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,s.to)}:i&&i.from>=s.from&&i.to<=s.to&&(i.from!=s.from||i.to!=s.to)&&s.to-s.from-(i.to-i.from)<=4?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,s.to))}:(l.mac||l.android)&&i&&i.from==i.to&&i.from==s.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(n&&2==i.insert.length&&(n=r.jT.single(n.main.anchor-1,n.main.head-1)),i={from:s.from,to:s.to,insert:r.xv.of([" "])}):l.chrome&&i&&i.from==i.to&&i.from==s.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(n&&(n=r.jT.single(n.main.anchor-1,n.main.head-1)),i={from:s.from,to:s.to,insert:r.xv.of([" "])}),i)return Bn(t,i,n,o);if(n&&!n.main.eq(s)){let e=!1,i="select";return t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(e=!0),i=t.inputState.lastSelectionOrigin),t.dispatch({selection:n,scrollIntoView:e,userEvent:i}),!0}return!1}function Bn(t,e,i,n=-1){if(l.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(l.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&" "==t.state.sliceDoc(e.from,s.from))&&1==e.insert.length&&2==e.insert.lines&&P(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&0==e.insert.length||8==n&&e.insert.length<e.to-e.from&&e.to>s.head)&&P(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&0==e.insert.length&&P(t.contentDOM,"Delete",46)))return!0;let r,o=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let h=()=>r||(r=Pn(t,e,i));return t.state.facet(se).some((i=>i(t,e.from,e.to,o,h)))||t.dispatch(h()),!0}function Pn(t,e,i){let n,s=t.state,o=s.selection.main;if(e.from>=o.from&&e.to<=o.to&&e.to-e.from>=(o.to-o.from)/3&&(!i||i.main.empty&&i.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let i=o.from<e.from?s.sliceDoc(o.from,e.from):"",r=o.to>e.to?s.sliceDoc(e.to,o.to):"";n=s.replaceSelection(t.state.toText(i+e.insert.sliceString(0,void 0,t.state.lineBreak)+r))}else{let h=s.changes(e),l=i&&i.main.to<=h.newLength?i.main:void 0;if(s.selection.ranges.length>1&&t.inputState.composing>=0&&e.to<=o.to&&e.to>=o.to-10){let a,c=t.state.sliceDoc(e.from,e.to),u=i&&Be(t,i.main.head);if(u){let t=e.insert.length-(e.to-e.from);a={from:u.from,to:u.to-t}}else a=t.state.doc.lineAt(o.head);let f=o.to-e.to,d=o.to-o.from;n=s.changeByRange((i=>{if(i.from==o.from&&i.to==o.to)return{changes:h,range:l||i.map(h)};let n=i.to-f,u=n-c.length;if(i.to-i.from!=d||t.state.sliceDoc(u,n)!=c||i.to>=a.from&&i.from<=a.to)return{range:i};let g=s.changes({from:u,to:n,insert:e.insert}),p=i.to-o.to;return{changes:g,range:l?r.jT.range(Math.max(0,l.anchor+p),Math.max(0,l.head+p)):i.map(g)}}))}else n={changes:h,selection:l&&s.selection.replaceRange(l)}}let h="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,h+=".compose",t.inputState.compositionFirstChange&&(h+=".start",t.inputState.compositionFirstChange=!1)),s.update(n,{userEvent:h,scrollIntoView:!0})}function Ln(t,e,i,n){let s=Math.min(t.length,e.length),r=0;for(;r<s&&t.charCodeAt(r)==e.charCodeAt(r);)r++;if(r==s&&t.length==e.length)return null;let o=t.length,h=e.length;for(;o>0&&h>0&&t.charCodeAt(o-1)==e.charCodeAt(h-1);)o--,h--;if("end"==n){i-=o+Math.max(0,r-Math.min(o,h))-r}if(o<r&&t.length<e.length){r-=i<=r&&i>=o?r-i:0,h=r+(h-o),o=r}else if(h<r){r-=i<=r&&i>=h?r-i:0,o=r+(o-h),h=r}return{from:r,toA:o,toB:h}}function Nn(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 Dn(i,n)),s==i&&r==n||e.push(new Dn(s,r))),e}function In(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?r.jT.single(i+e,n+e):null}const Vn={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Hn=l.ie&&l.ie_version<=11;class Wn{constructor(t){this.view=t,this.active=!1,this.editContext=null,this.selectionRange=new T,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver((e=>{for(let t of e)this.queue.push(t);(l.ie&&l.ie_version<=11||l.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()})),!window.EditContext||!1===t.constructor.EDIT_CONTEXT||l.chrome&&l.chrome_version<126||(this.editContext=new jn(t),t.state.facet(de)&&(t.contentDOM.editContext=this.editContext.editContext)),Hn&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver((()=>{var t;(null===(t=this.view.docView)||void 0===t?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()})),this.resizeScroll.observe(t.scrollDOM)),this.addWindowListeners(this.win=t.win),this.start(),"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")))}),{threshold:[0,.001]}),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()}onScrollChanged(t){this.view.inputState.runHandlers("scroll",t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout((()=>{this.resizeTimeout=-1,this.view.requestMeasure()}),50))}onPrint(t){("change"!=t.type||t.matches)&&(this.view.viewState.printing=!0,this.view.measure(),setTimeout((()=>{this.view.viewState.printing=!1,this.view.requestMeasure()}),500))}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some(((e,i)=>e!=t[i])))){this.gapIntersection.disconnect();for(let e of t)this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(de)?i.root.activeElement!=this.dom:!m(i.dom,n))return;let s=n.anchorNode&&i.docView.nearest(n.anchorNode);s&&s.ignoreEvent(t)?e||(this.selectionChanged=!1):(l.ie&&l.ie_version<=11||l.android&&l.chrome)&&!i.state.selection.main.empty&&n.focusNode&&v(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=d(t.root);if(!e)return!1;let i=l.safari&&11==t.root.nodeType&&p(this.dom.ownerDocument)==this.dom&&_n(this.view,e)||e;if(!i||this.selectionRange.eq(i))return!1;let n=m(this.dom,i);return n&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&I(this.dom,i)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(i),n&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let i=this.dom;i;)if(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,Vn),Hn&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Hn&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var i;if(!this.delayedAndroidKey){let t=()=>{let t=this.delayedAndroidKey;if(t){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=t.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&t.force&&P(this.dom,t.key,t.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(t)}this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(null===(i=this.delayedAndroidKey)||void 0===i?void 0:i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame((()=>{this.delayedFlush=-1,this.flush()})))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,n=!1;for(let 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}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),n=this.selectionChanged&&m(this.dom,this.selectionRange);if(t<0&&!n)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new En(this.view,t,e,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return this.view.requestMeasure(),!1;let i=this.view.state,n=Rn(this.view,e);return this.view.state==i&&(e.domChanged||e.newSel&&!e.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),n}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.flags|=4),"childList"==t.type){let i=Fn(e,t.previousSibling||t.target.previousSibling,-1),n=Fn(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}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener("change",this.onPrint):t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener("change",this.onPrint):t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}update(t){this.editContext&&(this.editContext.update(t),t.startState.facet(de)!=t.state.facet(de)&&(t.view.contentDOM.editContext=t.state.facet(de)?this.editContext.editContext: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.resizeScroll)||void 0===i||i.disconnect();for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}}function Fn(t,e,i){for(;e;){let n=_.get(e);if(n&&n.parent==t)return n;let s=e.parentNode;e=s!=t.dom?s:i>0?e.nextSibling:e.previousSibling}return null}function zn(t,e){let i=e.startContainer,n=e.startOffset,s=e.endContainer,r=e.endOffset,o=t.docView.domAtPos(t.state.selection.main.anchor);return v(o.node,o.offset,s,r)&&([i,n,s,r]=[s,r,i,n]),{anchorNode:i,anchorOffset:n,focusNode:s,focusOffset:r}}function _n(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return zn(t,i)}let i=null;function n(t){t.preventDefault(),t.stopImmediatePropagation(),i=t.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",n,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",n,!0),i?zn(t,i):null}class jn{constructor(t){this.from=0,this.to=0,this.pendingContextChange=null,this.resetRange(t.state);let e=this.editContext=new window.EditContext({text:t.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,t.state.selection.main.anchor))),selectionEnd:this.toContextPos(t.state.selection.main.head)});e.addEventListener("textupdate",(e=>{let{anchor:i}=t.state.selection.main,n={from:this.toEditorPos(e.updateRangeStart),to:this.toEditorPos(e.updateRangeEnd),insert:r.xv.of(e.text.split("\n"))};n.from==this.from&&i<this.from?n.from=i:n.to==this.to&&i>this.to&&(n.to=i),(n.from!=n.to||n.insert.length)&&(this.pendingContextChange=n,Bn(t,n,r.jT.single(this.toEditorPos(e.selectionStart),this.toEditorPos(e.selectionEnd))),this.pendingContextChange&&this.revertPending(t.state))})),e.addEventListener("characterboundsupdate",(i=>{let n=[],s=null;for(let e=this.toEditorPos(i.rangeStart),r=this.toEditorPos(i.rangeEnd);e<r;e++){let i=t.coordsForChar(e);s=i&&new DOMRect(i.left,i.top,i.right-i.left,i.bottom-i.top)||s||new DOMRect,n.push(s)}e.updateCharacterBounds(i.rangeStart,n)})),e.addEventListener("textformatupdate",(e=>{let i=[];for(let t of e.getTextFormats()){let e=t.underlineStyle,n=t.underlineThickness;if("None"!=e&&"None"!=n){let s=`text-decoration: underline ${"Dashed"==e?"dashed ":"Squiggle"==e?"wavy ":""}${"Thin"==n?1:2}px`;i.push(St.mark({attributes:{style:s}}).range(this.toEditorPos(t.rangeStart),this.toEditorPos(t.rangeEnd)))}}t.dispatch({effects:ue.of(St.set(i))})})),e.addEventListener("compositionstart",(()=>{t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)})),e.addEventListener("compositionend",(()=>{t.inputState.composing=-1,t.inputState.compositionFirstChange=null})),this.measureReq={read:t=>{this.editContext.updateControlBounds(t.contentDOM.getBoundingClientRect());let e=d(t.root);e&&e.rangeCount&&this.editContext.updateSelectionBounds(e.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let e=0,i=!1,n=this.pendingContextChange;return t.changes.iterChanges(((s,r,o,h,l)=>{if(i)return;let a=l.length-(r-s);if(n&&r>=n.to){if(n.from==s&&n.to==r&&n.insert.eq(l))return n=this.pendingContextChange=null,void(e+=a);n=null,this.revertPending(t.state)}if(s+=e,(r+=e)<=this.from)this.from+=a,this.to+=a;else if(s<this.to){if(s<this.from||r>this.to||this.to-this.from+l.length>3e4)return void(i=!0);this.editContext.updateText(this.toContextPos(s),this.toContextPos(r),l.toString()),this.to+=a}e+=a})),n&&!i&&this.revertPending(t.state),!i}update(t){this.applyEdits(t)&&this.rangeIsValid(t.state)?(t.docChanged||t.selectionSet)&&this.setSelection(t.state):(this.pendingContextChange=null,this.resetRange(t.state),this.editContext.updateText(0,this.editContext.text.length,t.state.doc.sliceString(this.from,this.to)),this.setSelection(t.state)),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:e}=t.selection.main;this.from=Math.max(0,e-1e4),this.to=Math.min(t.doc.length,e+1e4)}revertPending(t){let e=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(e.from),this.toContextPos(e.to+e.insert.length),t.doc.sliceString(e.from,e.to))}setSelection(t){let{main:e}=t.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,e.anchor))),n=this.toContextPos(e.head);this.editContext.selectionStart==i&&this.editContext.selectionEnd==n||this.editContext.updateSelection(i,n)}rangeIsValid(t){let{head:e}=t.selection.main;return!(this.from>0&&e-this.from<500||this.to<t.doc.length&&this.to-e<500||this.to-this.from>3e4)}toEditorPos(t){return t+this.from}toContextPos(t){return t-this.from}}class qn{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}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}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.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:e}=t;this.dispatchTransactions=t.dispatchTransactions||e&&(t=>t.forEach((t=>e(t,this))))||(t=>this.update(t)),this.dispatch=this.dispatch.bind(this),this._root=t.root||L(t.parent)||document,this.viewState=new an(t.state||r.yy.create(t)),t.scrollTo&&t.scrollTo.is(ce)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(pe).map((t=>new we(t)));for(let i of this.plugins)i.update(this);this.observer=new Wn(this),this.inputState=new si(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Ee(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure()}dispatch(...t){let e=1==t.length&&t[0]instanceof r.YW?t:1==t.length&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(e,this)}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=!1,s=this.state;for(let r of t){if(r.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=r.state}if(this.destroyed)return void(this.viewState.state=s);let o=this.hasFocus,h=0,l=null;t.some((t=>t.annotation(Hi)))?(this.inputState.notifiedFocused=o,h=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=Wi(s,o),l||(h=1));let a=this.observer.delayedAndroidKey,c=null;if(a?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(c=null)):this.observer.clear(),s.facet(r.yy.phrases)!=this.state.facet(r.yy.phrases))return this.setState(s);e=De.create(this,s,t),e.flags|=h;let u=this.viewState.scrollTarget;try{this.updateState=2;for(let e of t){if(u&&(u=u.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection;u=new ae(t.empty?t:r.jT.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(ce)&&(u=t.value.clip(this.state))}this.viewState.update(e,u),this.bidiCache=Jn.update(this.bidiCache,e.changes),e.empty||(this.updatePlugins(e),this.inputState.update(e)),i=this.docView.update(e),this.state.facet(Oe)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(i,t.some((t=>t.isUserEvent("select.pointer"))))}finally{this.updateState=0}if(e.startState.facet(vn)!=e.state.facet(vn)&&(this.viewState.mustMeasureContent=!0),(i||n||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),i&&this.docViewUpdate(),!e.empty)for(let r of this.state.facet(ne))try{r(e)}catch(f){fe(this.state,f,"update listener")}(l||c)&&Promise.resolve().then((()=>{l&&this.state==l.startState&&this.dispatch(l),c&&!Rn(this,c)&&a.force&&P(this.contentDOM,a.key,a.keyCode)}))}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 an(t),this.plugins=t.facet(pe).map((t=>new we(t))),this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView.destroy(),this.docView=new Ee(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(pe),i=t.state.facet(pe);if(e!=i){let n=[];for(let s of i){let i=e.indexOf(s);if(i<0)n.push(new we(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()}else for(let n of this.plugins)n.mustUpdate=t;for(let n=0;n<this.plugins.length;n++)this.plugins[n].update(this);e!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let i=e.value;if(i&&i.docViewUpdate)try{i.docViewUpdate(this)}catch(t){fe(this.state,t,"doc view update listener")}}}measure(t=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey)return this.measureScheduled=-1,void this.requestMeasure();this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,i=this.scrollDOM,n=i.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:r}=this.viewState;Math.abs(n-this.viewState.scrollTop)>1&&(r=-1),this.viewState.scrollAnchorHeight=-1;try{for(let t=0;;t++){if(r<0)if(V(i))s=-1,r=this.viewState.heightMap.height;else{let t=this.viewState.scrollAnchorAt(n);s=t.from,r=t.top}this.updateState=1;let h=this.viewState.measure(this);if(!h&&!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 l=[];4&h||([this.measureRequests,l]=[l,this.measureRequests]);let a=l.map((t=>{try{return t.read(this)}catch(e){return fe(this.state,e),Kn}})),c=De.create(this,this.state,[]),u=!1;c.flags|=h,e?e.flags|=h:e=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),u=this.docView.update(c),u&&this.docViewUpdate());for(let t=0;t<l.length;t++)if(a[t]!=Kn)try{let e=l[t];e.write&&e.write(a[t],this)}catch(o){fe(this.state,o)}if(u&&this.docView.updateSelection(!0),!c.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,r=-1;continue}{let t=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-r;if(t>1||t<-1){n+=t,i.scrollTop=n/this.scaleY,r=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let h of this.state.facet(ne))h(e)}get themeClasses(){return bn+" "+(this.state.facet(yn)?Sn:xn)+" "+this.state.facet(vn)}updateAttrs(){let t=Gn(this,ve,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(de)?"true":"false",class:"cm-content",style:`${l.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),Gn(this,ye,e);let i=this.observer.ignore((()=>{let i=wt(this.contentDOM,this.contentAttrs,e),n=wt(this.dom,this.editorAttrs,t);return i||n}));return this.editorAttrs=t,this.contentAttrs=e,i}showAnnouncements(t){let e=!0;for(let i of t)for(let t of i.effects)if(t.is(qn.announce)){e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(Oe);let t=this.state.facet(qn.cspNonce);o.V.mount(this.root,this.styleModules.concat(Mn).reverse(),t?{nonce:t}:void 0)}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=this.win.requestAnimationFrame((()=>this.measure()))),t){if(this.measureRequests.indexOf(t)>-1)return;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)}}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}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return ni(this,t,Ze(this,t,e,i))}moveByGroup(t,e){return ni(this,t,Ze(this,t,e,(e=>ti(this,t.head,e))))}visualLineSide(t,e){let i=this.bidiSpans(t),n=this.textDirectionAt(t.from),s=i[e?i.length-1:0];return r.jT.cursor(s.side(e,n)+t.from,s.forward(!e,n)?1:-1)}moveToLineBoundary(t,e,i=!0){return Qe(this,t,e,i)}moveVertically(t,e,i){return ni(this,t,ei(this,t,e,i))}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){return this.readMeasured(),Je(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);return k(i,s[Ft.find(s,t-n.from,-1,e)].dir==c.LTR==e>0)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(oe)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>$n)return Ut(t.length);let e,i=this.textDirectionAt(t.from);for(let s of this.bidiCache)if(s.from==t.from&&s.dir==i&&(s.fresh||zt(s.isolates,e=Ae(this,t))))return s.order;e||(e=Ae(this,t));let n=Gt(t.text,i,e);return this.bidiCache.push(new Jn(t.from,t.to,i,e,!0,n)),n}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||l.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{R(this.contentDOM),this.docView.updateSelection()}))}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((9==t.nodeType?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return ce.of(new ae("number"==typeof t?r.jT.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}scrollSnapshot(){let{scrollTop:t,scrollLeft:e}=this.scrollDOM,i=this.viewState.scrollAnchorAt(t);return ce.of(new ae(r.jT.cursor(i.from),"start","start",i.top-t,e,!0))}setTabFocusMode(t){null==t?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof t?this.inputState.tabFocusMode=t?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return me.define((()=>({})),{eventHandlers:t})}static domEventObservers(t){return me.define((()=>({})),{eventObservers:t})}static theme(t,e){let i=o.V.newName(),n=[vn.of(i),Oe.of(An(`.${i}`,t))];return e&&e.dark&&n.push(yn.of(!0)),n}static baseTheme(t){return r.Wl.lowest(Oe.of(An("."+bn,t,kn)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),n=i&&_.get(i)||_.get(t);return(null===(e=null==n?void 0:n.rootView)||void 0===e?void 0:e.view)||null}}qn.styleModule=Oe,qn.inputHandler=se,qn.scrollHandler=le,qn.focusChangeEffect=re,qn.perLineTextDirection=oe,qn.exceptionSink=ie,qn.updateListener=ne,qn.editable=de,qn.mouseSelectionStyle=ee,qn.dragMovesSelection=te,qn.clickAddsSelectionRange=Zt,qn.decorations=be,qn.outerDecorations=xe,qn.atomicRanges=Se,qn.bidiIsolatedRanges=ke,qn.scrollMargins=Me,qn.darkTheme=yn,qn.cspNonce=r.r$.define({combine:t=>t.length?t[0]:""}),qn.contentAttributes=ye,qn.editorAttributes=ve,qn.lineWrapping=qn.contentAttributes.of({class:"cm-lineWrapping"}),qn.announce=r.Py.define();const $n=4096,Kn={};class Jn{constructor(t,e,i,n,s,r){this.from=t,this.to=e,this.dir=i,this.isolates=n,this.fresh=s,this.order=r}static update(t,e){if(e.empty&&!t.some((t=>t.fresh)))return t;let i=[],n=t.length?t[t.length-1].dir:c.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 Jn(e.mapPos(r.from,1),e.mapPos(r.to,-1),r.dir,r.isolates,!1,r.order))}return i}}function Gn(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&&gt(r,i)}return i}const Un=!l.ios;const Xn={".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"}},".cm-content":{"& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}};Un&&(Xn[".cm-line"].caretColor=Xn[".cm-content"].caretColor="transparent !important");class Yn extends r.uU{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Yn.prototype.elementClass="",Yn.prototype.toDOM=void 0,Yn.prototype.mapMode=r.gc.TrackBefore,Yn.prototype.startSide=Yn.prototype.endSide=-1,Yn.prototype.point=!0;n()}catch(f){n(f)}}))},78305:function(t,e,i){i.d(e,{V:function(){return o}});i(63721),i(52247),i(71695),i(92745),i(52805),i(43451),i(19134),i(5740),i(11740),i(97003),i(32114),i(39527),i(13334),i(34595),i(47021);const n="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),s="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class o{constructor(t,e){this.rules=[];let{finish:i}=e||{};function n(t){return/^@/.test(t)?[t]:t.split(/,\s*/)}function s(t,e,r,o){let h=[],l=/^@(\w+)\b/.exec(t[0]),a=l&&"keyframes"==l[1];if(l&&null==e)return r.push(t[0]+";");for(let i in e){let o=e[i];if(/&/.test(i))s(i.split(/,\s*/).map((e=>t.map((t=>e.replace(/&/,t))))).reduce(((t,e)=>t.concat(e))),o,r);else if(o&&"object"==typeof o){if(!l)throw new RangeError("The value of a property ("+i+") should be a primitive value.");s(n(i),o,h,a)}else null!=o&&h.push(i.replace(/_.*/,"").replace(/[A-Z]/g,(t=>"-"+t.toLowerCase()))+": "+o+";")}(h.length||a)&&r.push((!i||l||o?t:t.map(i)).join(", ")+" {"+h.join(" ")+"}")}for(let r in t)s(n(r),t[r],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let t=r[n]||1;return r[n]=t+1,"ͼ"+t.toString(36)}static mount(t,e,i){let n=t[s],r=i&&i.nonce;n?r&&n.setNonce(r):n=new l(t,r),n.mount(Array.isArray(e)?e:[e])}}let h=new Map;class l{constructor(t,e){let i=t.ownerDocument||t,n=i.defaultView;if(!t.head&&t.adoptedStyleSheets&&n.CSSStyleSheet){let e=h.get(i);if(e)return t.adoptedStyleSheets=[e.sheet,...t.adoptedStyleSheets],t[s]=e;this.sheet=new n.CSSStyleSheet,t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets],h.set(i,this)}else{this.styleTag=i.createElement("style"),e&&this.styleTag.setAttribute("nonce",e);let n=t.head||t;n.insertBefore(this.styleTag,n.firstChild)}this.modules=[],t[s]=this}mount(t){let e=this.sheet,i=0,n=0;for(let s=0;s<t.length;s++){let r=t[s],o=this.modules.indexOf(r);if(o<n&&o>-1&&(this.modules.splice(o,1),n--,o=-1),-1==o){if(this.modules.splice(n++,0,r),e)for(let t=0;t<r.rules.length;t++)e.insertRule(r.rules[t],i++)}else{for(;n<o;)i+=this.modules[n++].rules.length;i+=r.rules.length,n++}}if(!e){let t="";for(let e=0;e<this.modules.length;e++)t+=this.modules[e].getRules()+"\n";this.styleTag.textContent=t}}setNonce(t){this.styleTag&&this.styleTag.getAttribute("nonce")!=t&&this.styleTag.setAttribute("nonce",t)}}},28648:function(t,e,i){i.d(e,{md:function(){return r}});i(52247),i(71695),i(92745),i(61495),i(84283),i(82328),i(55751),i(26200),i(25754),i(22246),i(77439),i(19423),i(19134),i(32517),i(5740),i(11740),i(44495),i(16132),i(36810),i(14953),i(58402),i(31503),i(16440),i(2213),i(57385),i(71375),i(15524),i(20267),i(46692),i(22139),i(39527),i(67670),i(13334),i(36993),i(47021);const n=1024;let s=0;class r{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=l.match(t)),e=>{let i=t(e);return void 0===i?null:[this,i]}}}r.closedBy=new r({deserialize:t=>t.split(" ")}),r.openedBy=new r({deserialize:t=>t.split(" ")}),r.group=new r({deserialize:t=>t.split(" ")}),r.isolate=new r({deserialize:t=>{if(t&&"rtl"!=t&&"ltr"!=t&&"auto"!=t)throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),r.contextHash=new r({perNode:!0}),r.lookAhead=new r({perNode:!0}),r.mounted=new r({perNode:!0});class o{constructor(t,e,i){this.tree=t,this.overlay=e,this.parser=i}static get(t){return t&&t.props&&t.props[r.mounted.id]}}const h=Object.create(null);class l{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 l(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(r.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(r.group),n=-1;n<(i?i.length:0);n++){let s=e[n<0?t.name:i[n]];if(s)return s}}}}l.none=new l("",Object.create(null),0,8);const a=new WeakMap,c=new WeakMap;var u;!function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"}(u||(u={}));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=o.get(this);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=0){return new M(this.topNode,t)}cursorAt(t,e=0,i=0){let n=a.get(this)||this.topNode,s=new M(n);return s.moveTo(t,e),a.set(this,s._tree),s}get topNode(){return new v(this,0,0,null)}resolve(t,e=0){let i=m(a.get(this)||this.topNode,t,e,!1);return a.set(this,i),i}resolveInner(t,e=0){let i=m(c.get(this)||this.topNode,t,e,!0);return c.set(this,i),i}resolveStack(t,e=0){return function(t,e,i){let n=t.resolveInner(e,i),s=null;for(let r=n instanceof v?n:n.context.parent;r;r=r.parent)if(r.index<0){let t=r.parent;(s||(s=[n])).push(t.resolve(e,i)),r=t}else{let t=o.get(r.tree);if(t&&t.overlay&&t.overlay[0].from<=e&&t.overlay[t.overlay.length-1].to>=e){let o=new v(t.tree,t.overlay[0].from+r.from,-1,r);(s||(s=[n])).push(m(o,e,i,!1))}}return s?k(s):n}(this,t,e)}iterate(t){let{enter:e,leave:i,from:n=0,to:s=this.length}=t,r=t.mode||0,o=(r&u.IncludeAnonymous)>0;for(let h=this.cursor(r|u.IncludeAnonymous);;){let t=!1;if(h.from<=s&&h.to>=n&&(!o&&h.type.isAnonymous||!1!==e(h))){if(h.firstChild())continue;t=!0}for(;t&&i&&(o||!h.type.isAnonymous)&&i(h),!h.nextSibling();){if(!h.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:D(l.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(l.none,t,e,i)))}static build(t){return function(t){var e;let{buffer:i,nodeSet:s,maxBufferLength:o=n,reused:h=[],minRepeatType:l=s.types.length}=t,a=Array.isArray(i)?new d(i,i.length):i,c=s.types,u=0,p=0;function m(t,e,i,n,r,f){let{id:d,start:k,end:A,size:M}=a,C=p;for(;M<0;){if(a.next(),-1==M){let e=h[d];return i.push(e),void n.push(k-t)}if(-3==M)return void(u=d);if(-4==M)return void(p=d);throw new RangeError(`Unrecognized record size: ${M}`)}let O,T,E=c[d],R=k-t;if(A-k<=o&&(T=x(a.pos-e,r))){let e=new Uint16Array(T.size-T.skip),i=a.pos-T.size,n=e.length;for(;a.pos>i;)n=S(T.start,e,n);O=new g(e,A-T.start,s),R=T.start-t}else{let t=a.pos-M;a.next();let e=[],i=[],n=d>=l?d:-1,s=0,r=A;for(;a.pos>t;)n>=0&&a.id==n&&a.size>=0?(a.end<=r-o&&(y(e,i,k,s,a.end,r,n,C),s=e.length,r=a.end),a.next()):f>2500?w(k,t,e,i):m(k,t,e,i,n,f+1);if(n>=0&&s>0&&s<e.length&&y(e,i,k,s,k,r,n,C),e.reverse(),i.reverse(),n>-1&&s>0){let t=v(E);O=D(E,e,i,0,e.length,0,A-k,t,t)}else O=b(E,e,i,A-k,C-A)}i.push(O),n.push(R)}function w(t,e,i,n){let r=[],h=0,l=-1;for(;a.pos>e;){let{id:t,start:e,end:i,size:n}=a;if(n>4)a.next();else{if(l>-1&&e<l)break;l<0&&(l=i-o),r.push(t,e,i),h++,a.next()}}if(h){let e=new Uint16Array(4*h),o=r[r.length-2];for(let t=r.length-3,i=0;t>=0;t-=3)e[i++]=r[t],e[i++]=r[t+1]-o,e[i++]=r[t+2]-o,e[i++]=i;i.push(new g(e,r[2]-o,s)),n.push(o-t)}}function v(t){return(e,i,n)=>{let s,o,h=0,l=e.length-1;if(l>=0&&(s=e[l])instanceof f){if(!l&&s.type==t&&s.length==n)return s;(o=s.prop(r.lookAhead))&&(h=i[l]+s.length+o)}return b(t,e,i,n,h)}}function y(t,e,i,n,r,o,h,l){let a=[],c=[];for(;t.length>n;)a.push(t.pop()),c.push(e.pop()+i-r);t.push(b(s.types[h],a,c,o-r,l-o)),e.push(r-i)}function b(t,e,i,n,s=0,o){if(u){let t=[r.contextHash,u];o=o?[t].concat(o):[t]}if(s>25){let t=[r.lookAhead,s];o=o?[t].concat(o):[t]}return new f(t,e,i,n,o)}function x(t,e){let i=a.fork(),n=0,s=0,r=0,h=i.end-o,c={size:0,start:0,skip:0};t:for(let o=i.pos-t;i.pos>o;){let t=i.size;if(i.id==e&&t>=0){c.size=n,c.start=s,c.skip=r,r+=4,n+=4,i.next();continue}let a=i.pos-t;if(t<0||a<o||i.start<h)break;let u=i.id>=l?4:0,f=i.start;for(i.next();i.pos>a;){if(i.size<0){if(-3!=i.size)break t;u+=4}else i.id>=l&&(u+=4);i.next()}s=f,n+=t,r+=u}return(e<0||n==t)&&(c.size=n,c.start=s,c.skip=r),c.size>4?c:void 0}function S(t,e,i){let{id:n,start:s,end:r,size:o}=a;if(a.next(),o>=0&&n<l){let h=i;if(o>4){let n=a.pos-(o-4);for(;a.pos>n;)i=S(t,e,i)}e[--i]=h,e[--i]=r-t,e[--i]=s-t,e[--i]=n}else-3==o?u=n:-4==o&&(p=n);return i}let k=[],A=[];for(;a.pos>0;)m(t.start||0,t.bufferStart||0,k,A,-1,0);let M=null!==(e=t.length)&&void 0!==e?e:k.length?A[0]+k[0].length:0;return new f(c[t.topID],k.reverse(),A.reverse(),M)}(t)}}f.empty=new f(l.none,[],[],0);class d{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 d(this.buffer,this.index)}}class g{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return l.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)),i==(t+=4))return s;let r=[];for(;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 h=t;h!=e&&!(p(s,n,r[h+1],r[h+2])&&(o=h,i>0));h=r[h+3]);return o}slice(t,e,i){let n=this.buffer,s=new Uint16Array(e-t),r=0;for(let o=t,h=0;o<e;){s[h++]=n[o++],s[h++]=n[o++]-i;let e=s[h++]=n[o++]-i;s[h++]=n[o++]-t,r=Math.max(r,e)}return new g(s,r,this.set)}}function p(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 m(t,e,i,n){for(var s;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 v&&t.index<0?null:t.parent;if(!e)return t;t=e}let r=n?0:u.IgnoreOverlays;if(n)for(let o=t,h=o.parent;h;o=h,h=o.parent)o instanceof v&&o.index<0&&(null===(s=h.enter(e,i,r))||void 0===s?void 0:s.from)!=o.from&&(t=h);for(;;){let n=t.enter(e,i,r);if(!n)return t;t=n}}class w{cursor(t=0){return new M(this,t)}getChild(t,e=null,i=null){let n=y(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return y(this,t,e,i)}resolve(t,e=0){return m(this,t,e,!1)}resolveInner(t,e=0){return m(this,t,e,!0)}matchContext(t){return b(this,t)}enterUnfinishedNodesBefore(t){let e=this.childBefore(t),i=this;for(;e;){let t=e.lastChild;if(!t||t.to!=e.to)break;t.type.isError&&t.from==t.to?(i=e,e=t.prevSibling):e=t}return i}get node(){return this}get next(){return this.parent}}class v extends w{constructor(t,e,i,n){super(),this._tree=t,this.from=e,this.index=i,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,i,n,s=0){for(let r=this;;){for(let{children:h,positions:l}=r._tree,a=e>0?h.length:-1;t!=a;t+=e){let a=h[t],c=l[t]+r.from;if(p(n,i,c,c+a.length))if(a instanceof g){if(s&u.ExcludeBuffers)continue;let o=a.findChild(0,a.buffer.length,e,i-c,n);if(o>-1)return new S(new x(r,a,t,c),null,o)}else if(s&u.IncludeAnonymous||!a.type.isAnonymous||C(a)){let h;if(!(s&u.IgnoreMounts)&&(h=o.get(a))&&!h.overlay)return new v(h.tree,c,t,r);let l=new v(a,c,t,r);return s&u.IncludeAnonymous||!l.type.isAnonymous?l:l.nextChild(e<0?a.children.length-1:0,e,i,n)}}if(s&u.IncludeAnonymous||!r.type.isAnonymous)return null;if(t=r.index>=0?r.index+e:e<0?-1:r._parent._tree.children.length,r=r._parent,!r)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}enter(t,e,i=0){let n;if(!(i&u.IgnoreOverlays)&&(n=o.get(this._tree))&&n.overlay){let i=t-this.from;for(let{from:t,to:s}of n.overlay)if((e>0?t<=i:t<i)&&(e<0?s>=i:s>i))return new v(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;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 tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function y(t,e,i,n){let s=t.cursor(),r=[];if(!s.firstChild())return r;if(null!=i)for(;!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:[]}}function b(t,e,i=e.length-1){for(let n=t.parent;i>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[i]&&e[i]!=n.name)return!1;i--}}return!0}class x{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}}class S extends w{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,i){super(),this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}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 S(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=0){if(i&u.ExcludeBuffers)return null;let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return s<0?null:new S(this.context,this,s)}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 S(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 S(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}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];t.push(i.slice(n,s,r)),e.push(0)}return new f(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function k(t){if(!t.length)return null;let e=0,i=t[0];for(let r=1;r<t.length;r++){let n=t[r];(n.from>i.from||n.to<i.to)&&(i=n,e=r)}let n=i instanceof v&&i.index<0?null:i.parent,s=t.slice();return n?s[e]=n:s.splice(e,1),new A(s,i)}class A{constructor(t,e){this.heads=t,this.node=e}get next(){return k(this.heads)}}class M{get name(){return this.type.name}constructor(t,e=0){if(this.mode=e,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof v)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)}}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 v?(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._tree.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=this.mode){return this.buffer?!(i&u.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&u.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&u.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode));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._tree.children.length;n!=s;n+=t){let t=i._tree.children[n];if(this.mode&u.IncludeAnonymous||t instanceof g||!t.type.isAnonymous||C(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){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,i=0;if(t&&t.context==this.buffer)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 S(this.buffer,e,this.stack[n]);return this.bufferNode=new S(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let i=0;;){let n=!1;if(this.type.isAnonymous||!1!==t(this)){if(this.firstChild()){i++;continue}this.type.isAnonymous||(n=!0)}for(;n&&e&&e(this),n=this.type.isAnonymous,!this.nextSibling();){if(!i)return;this.parent(),i--,n=!0}}}matchContext(t){if(!this.buffer)return b(this.node,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let n=t.length-1,s=this.stack.length-1;n>=0;s--){if(s<0)return b(this.node,t,n);let r=i[e.buffer[this.stack[s]]];if(!r.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}}function C(t){return t.children.some((t=>t instanceof g||!t.type.isAnonymous||C(t)))}const O=new WeakMap;function T(t,e){if(!t.isAnonymous||e instanceof g||e.type!=t)return 1;let i=O.get(e);if(null==i){i=1;for(let n of e.children){if(n.type!=t||!(n instanceof f)){i=1;break}i+=T(t,n)}O.set(e,i)}return i}function D(t,e,i,n,s,r,o,h,l){let a=0;for(let d=n;d<s;d++)a+=T(t,e[d]);let c=Math.ceil(1.5*a/8),u=[],f=[];return function e(i,n,s,o,h){for(let a=s;a<o;){let s=a,d=n[a],g=T(t,i[a]);for(a++;a<o;a++){let e=T(t,i[a]);if(g+e>=c)break;g+=e}if(a==s+1){if(g>c){let t=i[s];e(t.children,t.positions,0,t.children.length,n[s]+h);continue}u.push(i[s])}else{let e=n[a-1]+i[a-1].length-d;u.push(D(t,i,n,s,a,d,e,null,l))}f.push(d+h-r)}}(e,i,n,s,0),(h||l)(u,f,o)}new r({perNode:!0})},97219:function(t,e,i){i.d(e,{QR:()=>N,Gv:()=>B,pJ:()=>Y});i("52247"),i("63434"),i("71695"),i("92745"),i("61893"),i("19134"),i("96829"),i("39527"),i("92181"),i("99790"),i("67670"),i("88972"),i("47021"),i("61495"),i("84283"),i("82328"),i("55751"),i("26200"),i("25754"),i("22246"),i("77439"),i("19423"),i("32517"),i("5740"),i("11740"),i("44495"),i("16132"),i("36810"),i("14953"),i("58402"),i("31503"),i("16440"),i("2213"),i("57385"),i("71375"),i("15524"),i("20267"),i("46692"),i("22139"),i("13334"),i("36993");const n=1024;let s=0;class r{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=h.match(t)),e=>{let i=t(e);return void 0===i?null:[this,i]}}}r.closedBy=new r({deserialize:t=>t.split(" ")}),r.openedBy=new r({deserialize:t=>t.split(" ")}),r.group=new r({deserialize:t=>t.split(" ")}),r.contextHash=new r({perNode:!0}),r.lookAhead=new r({perNode:!0}),r.mounted=new r({perNode:!0});const o=Object.create(null);class h{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):o,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=new h(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(r.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(r.group),n=-1;n<(i?i.length:0);n++){let s=e[n<0?t.name:i[n]];if(s)return s}}}}h.none=new h("",Object.create(null),0,8);const l=new WeakMap,a=new WeakMap;var c,u;(u=c||(c={}))[u.ExcludeBuffers=1]="ExcludeBuffers",u[u.IncludeAnonymous=2]="IncludeAnonymous",u[u.IgnoreMounts=4]="IgnoreMounts",u[u.IgnoreOverlays=8]="IgnoreOverlays";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(r.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=0){return new k(this.topNode,t)}cursorAt(t,e=0,i=0){let n=l.get(this)||this.topNode,s=new k(n);return s.moveTo(t,e),l.set(this,s._tree),s}get topNode(){return new v(this,0,0,null)}resolve(t,e=0){let i=w(l.get(this)||this.topNode,t,e,!1);return l.set(this,i),i}resolveInner(t,e=0){let i=w(a.get(this)||this.topNode,t,e,!0);return a.set(this,i),i}iterate(t){let{enter:e,leave:i,from:n=0,to:s=this.length}=t,r=t.mode||0,o=(r&c.IncludeAnonymous)>0;for(let h=this.cursor(r|c.IncludeAnonymous);;){let t=!1;if(h.from<=s&&h.to>=n&&(!o&&h.type.isAnonymous||!1!==e(h))){if(h.firstChild())continue;t=!0}for(;t&&i&&(o||!h.type.isAnonymous)&&i(h),!h.nextSibling();){if(!h.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:O(h.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(h.none,t,e,i)))}static build(t){return function(t){var e;let{buffer:i,nodeSet:s,maxBufferLength:o=n,reused:h=[],minRepeatType:l=s.types.length}=t,a=Array.isArray(i)?new d(i,i.length):i,c=s.types,u=0,p=0;function m(t,e,i,n,r){let{id:f,start:d,end:S,size:k}=a,A=p;for(;k<0;){if(a.next(),-1==k){let e=h[f];return i.push(e),void n.push(d-t)}if(-3==k)return void(u=f);if(-4==k)return void(p=f);throw new RangeError(`Unrecognized record size: ${k}`)}let M,C,T=c[f],D=d-t;if(S-d<=o&&(C=b(a.pos-e,r))){let e=new Uint16Array(C.size-C.skip),i=a.pos-C.size,n=e.length;for(;a.pos>i;)n=x(C.start,e,n);M=new g(e,S-C.start,s),D=C.start-t}else{let t=a.pos-k;a.next();let e=[],i=[],n=f>=l?f:-1,s=0,r=S;for(;a.pos>t;)n>=0&&a.id==n&&a.size>=0?(a.end<=r-o&&(v(e,i,d,s,a.end,r,n,A),s=e.length,r=a.end),a.next()):m(d,t,e,i,n);if(n>=0&&s>0&&s<e.length&&v(e,i,d,s,d,r,n,A),e.reverse(),i.reverse(),n>-1&&s>0){let t=w(T);M=O(T,e,i,0,e.length,0,S-d,t,t)}else M=y(T,e,i,S-d,A-S)}i.push(M),n.push(D)}function w(t){return(e,i,n)=>{let s,o,h=0,l=e.length-1;if(l>=0&&(s=e[l])instanceof f){if(!l&&s.type==t&&s.length==n)return s;(o=s.prop(r.lookAhead))&&(h=i[l]+s.length+o)}return y(t,e,i,n,h)}}function v(t,e,i,n,r,o,h,l){let a=[],c=[];for(;t.length>n;)a.push(t.pop()),c.push(e.pop()+i-r);t.push(y(s.types[h],a,c,o-r,l-o)),e.push(r-i)}function y(t,e,i,n,s=0,o){if(u){let t=[r.contextHash,u];o=o?[t].concat(o):[t]}if(s>25){let t=[r.lookAhead,s];o=o?[t].concat(o):[t]}return new f(t,e,i,n,o)}function b(t,e){let i=a.fork(),n=0,s=0,r=0,h=i.end-o,c={size:0,start:0,skip:0};t:for(let o=i.pos-t;i.pos>o;){let t=i.size;if(i.id==e&&t>=0){c.size=n,c.start=s,c.skip=r,r+=4,n+=4,i.next();continue}let a=i.pos-t;if(t<0||a<o||i.start<h)break;let u=i.id>=l?4:0,f=i.start;for(i.next();i.pos>a;){if(i.size<0){if(-3!=i.size)break t;u+=4}else i.id>=l&&(u+=4);i.next()}s=f,n+=t,r+=u}return(e<0||n==t)&&(c.size=n,c.start=s,c.skip=r),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<l){let h=i;if(o>4){let n=a.pos-(o-4);for(;a.pos>n;)i=x(t,e,i)}e[--i]=h,e[--i]=r-t,e[--i]=s-t,e[--i]=n}else-3==o?u=n:-4==o&&(p=n);return i}let S=[],k=[];for(;a.pos>0;)m(t.start||0,t.bufferStart||0,S,k,-1);let A=null!==(e=t.length)&&void 0!==e?e:S.length?k[0]+S[0].length:0;return new f(c[t.topID],S.reverse(),k.reverse(),A)}(t)}}f.empty=new f(h.none,[],[],0);class d{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 d(this.buffer,this.index)}}class g{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return h.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)),i==(t+=4))return s;let r=[];for(;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 h=t;h!=e&&!(p(s,n,r[h+1],r[h+2])&&(o=h,i>0));h=r[h+3]);return o}slice(t,e,i){let n=this.buffer,s=new Uint16Array(e-t),r=0;for(let o=t,h=0;o<e;){s[h++]=n[o++],s[h++]=n[o++]-i;let e=s[h++]=n[o++]-i;s[h++]=n[o++]-t,r=Math.max(r,e)}return new g(s,r,this.set)}}function p(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 m(t,e){let i=t.childBefore(e);for(;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 w(t,e,i,n){for(var s;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 v&&t.index<0?null:t.parent;if(!e)return t;t=e}let r=n?0:c.IgnoreOverlays;if(n)for(let o=t,h=o.parent;h;o=h,h=o.parent)o instanceof v&&o.index<0&&(null===(s=h.enter(e,i,r))||void 0===s?void 0:s.from)!=o.from&&(t=h);for(;;){let n=t.enter(e,i,r);if(!n)return t;t=n}}class v{constructor(t,e,i,n){this._tree=t,this.from=e,this.index=i,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,i,n,s=0){for(let o=this;;){for(let{children:h,positions:l}=o._tree,a=e>0?h.length:-1;t!=a;t+=e){let a=h[t],u=l[t]+o.from;if(p(n,i,u,u+a.length))if(a instanceof g){if(s&c.ExcludeBuffers)continue;let r=a.findChild(0,a.buffer.length,e,i-u,n);if(r>-1)return new S(new x(o,a,t,u),null,r)}else if(s&c.IncludeAnonymous||!a.type.isAnonymous||A(a)){let h;if(!(s&c.IgnoreMounts)&&a.props&&(h=a.prop(r.mounted))&&!h.overlay)return new v(h.tree,u,t,o);let l=new v(a,u,t,o);return s&c.IncludeAnonymous||!l.type.isAnonymous?l:l.nextChild(e<0?a.children.length-1:0,e,i,n)}}if(s&c.IncludeAnonymous||!o.type.isAnonymous)return null;if(t=o.index>=0?o.index+e:e<0?-1:o._parent._tree.children.length,o=o._parent,!o)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}enter(t,e,i=0){let n;if(!(i&c.IgnoreOverlays)&&(n=this._tree.prop(r.mounted))&&n.overlay){let i=t-this.from;for(let{from:t,to:s}of n.overlay)if((e>0?t<=i:t<i)&&(e<0?s>=i:s>i))return new v(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;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}cursor(t=0){return new k(this,t)}get tree(){return this._tree}toTree(){return this._tree}resolve(t,e=0){return w(this,t,e,!1)}resolveInner(t,e=0){return w(this,t,e,!0)}enterUnfinishedNodesBefore(t){return m(this,t)}getChild(t,e=null,i=null){let n=y(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return y(this,t,e,i)}toString(){return this._tree.toString()}get node(){return this}matchContext(t){return b(this,t)}}function y(t,e,i,n){let s=t.cursor(),r=[];if(!s.firstChild())return r;if(null!=i)for(;!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:[]}}function b(t,e,i=e.length-1){for(let n=t.parent;i>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[i]&&e[i]!=n.name)return!1;i--}}return!0}class x{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}}class S{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,i){this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}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 S(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=0){if(i&c.ExcludeBuffers)return null;let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return s<0?null:new S(this.context,this,s)}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 S(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 S(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}cursor(t=0){return new k(this,t)}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];t.push(i.slice(n,s,r)),e.push(0)}return new f(this.type,t,e,this.to-this.from)}resolve(t,e=0){return w(this,t,e,!1)}resolveInner(t,e=0){return w(this,t,e,!0)}enterUnfinishedNodesBefore(t){return m(this,t)}toString(){return this.context.buffer.childString(this.index)}getChild(t,e=null,i=null){let n=y(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return y(this,t,e,i)}get node(){return this}matchContext(t){return b(this,t)}}class k{get name(){return this.type.name}constructor(t,e=0){if(this.mode=e,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof v)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)}}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 v?(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._tree.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=this.mode){return this.buffer?!(i&c.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&c.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&c.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode));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._tree.children.length;n!=s;n+=t){let t=i._tree.children[n];if(this.mode&c.IncludeAnonymous||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){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,i=0;if(t&&t.context==this.buffer)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 S(this.buffer,e,this.stack[n]);return this.bufferNode=new S(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let i=0;;){let n=!1;if(this.type.isAnonymous||!1!==t(this)){if(this.firstChild()){i++;continue}this.type.isAnonymous||(n=!0)}for(;n&&e&&e(this),n=this.type.isAnonymous,!this.nextSibling();){if(!i)return;this.parent(),i--,n=!0}}}matchContext(t){if(!this.buffer)return b(this.node,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let n=t.length-1,s=this.stack.length-1;n>=0;s--){if(s<0)return b(this.node,t,n);let r=i[e.buffer[this.stack[s]]];if(!r.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}}function A(t){return t.children.some((t=>t instanceof g||!t.type.isAnonymous||A(t)))}const M=new WeakMap;function C(t,e){if(!t.isAnonymous||e instanceof g||e.type!=t)return 1;let i=M.get(e);if(null==i){i=1;for(let n of e.children){if(n.type!=t||!(n instanceof f)){i=1;break}i+=C(t,n)}M.set(e,i)}return i}function O(t,e,i,n,s,r,o,h,l){let a=0;for(let d=n;d<s;d++)a+=C(t,e[d]);let c=Math.ceil(1.5*a/8),u=[],f=[];return function e(i,n,s,o,h){for(let a=s;a<o;){let s=a,d=n[a],g=C(t,i[a]);for(a++;a<o;a++){let e=C(t,i[a]);if(g+e>=c)break;g+=e}if(a==s+1){if(g>c){let t=i[s];e(t.children,t.positions,0,t.children.length,n[s]+h);continue}u.push(i[s])}else{let e=n[a-1]+i[a-1].length-d;u.push(O(t,i,n,s,a,d,e,null,l))}f.push(d+h-r)}}(e,i,n,s,0),(h||l)(u,f,o)}new r({perNode:!0});let T=0;class D{constructor(t,e,i){this.set=t,this.base=e,this.modified=i,this.id=T++}static define(t){if(null==t?void 0:t.base)throw new Error("Can not derive from a modified tag");let e=new D([],null,[]);if(e.set.push(e),t)for(let i of t.set)e.set.push(i);return e}static defineModifier(){let t=new R;return e=>e.modified.indexOf(t)>-1?e:R.get(e.base||e,e.modified.concat(t).sort(((t,e)=>t.id-e.id)))}}let E=0;class R{constructor(){this.instances=[],this.id=E++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find((i=>{return i.base==t&&(n=e,s=i.modified,n.length==s.length&&n.every(((t,e)=>t==s[e])));var n,s}));if(i)return i;let n=[],s=new D(n,t,e);for(let o of e)o.instances.push(s);let r=function(t){let e=[[]];for(let i=0;i<t.length;i++)for(let n=0,s=e.length;n<s;n++)e.push(e[n].concat(t[i]));return e.sort(((t,e)=>e.length-t.length))}(e);for(let o of t.set)if(!o.modified.length)for(let t of r)n.push(R.get(o,t));return s}}function B(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]?"":'"'==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,h=i[o];if(!h)throw new RangeError("Invalid path: "+t);let l=new L(n,s,o>0?i.slice(0,o):null);e[h]=l.sort(e[h])}}return P.add(e)}const P=new r;class L{constructor(t,e,i,n){this.tags=t,this.mode=e,this.context=i,this.next=n}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}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}}function N(t,e){let i=Object.create(null);for(let r of t)if(Array.isArray(r.tag))for(let t of r.tag)i[t.id]=r.class;else i[r.tag.id]=r.class;let{scope:n,all:s=null}=e||{};return{style:t=>{let e=s;for(let n of t)for(let t of n.set){let n=i[t.id];if(n){e=e?e+" "+n:n;break}}return e},scope:n}}L.empty=new L([],2,null);const I=D.define,V=I(),H=I(),W=I(H),F=I(H),z=I(),_=I(z),j=I(z),q=I(),$=I(q),K=I(),J=I(),G=I(),U=I(G),X=I(),Y={comment:V,lineComment:I(V),blockComment:I(V),docComment:I(V),name:H,variableName:I(H),typeName:W,tagName:I(W),propertyName:F,attributeName:I(F),className:I(H),labelName:I(H),namespace:I(H),macroName:I(H),literal:z,string:_,docString:I(_),character:I(_),attributeValue:I(_),number:j,integer:I(j),float:I(j),bool:I(z),regexp:I(z),escape:I(z),color:I(z),url:I(z),keyword:K,self:I(K),null:I(K),atom:I(K),unit:I(K),modifier:I(K),operatorKeyword:I(K),controlKeyword:I(K),definitionKeyword:I(K),moduleKeyword:I(K),operator:J,derefOperator:I(J),arithmeticOperator:I(J),logicOperator:I(J),bitwiseOperator:I(J),compareOperator:I(J),updateOperator:I(J),definitionOperator:I(J),typeOperator:I(J),controlOperator:I(J),punctuation:G,separator:I(G),bracket:U,angleBracket:I(U),squareBracket:I(U),paren:I(U),brace:I(U),content:q,heading:$,heading1:I($),heading2:I($),heading3:I($),heading4:I($),heading5:I($),heading6:I($),contentSeparator:I(q),list:I(q),quote:I(q),emphasis:I(q),strong:I(q),link:I(q),monospace:I(q),strikethrough:I(q),inserted:I(),deleted:I(),changed:I(),invalid:I(),meta:X,documentMeta:I(X),annotation:I(X),processingInstruction:I(X),definition:D.defineModifier(),constant:D.defineModifier(),function:D.defineModifier(),standard:D.defineModifier(),local:D.defineModifier(),special:D.defineModifier()};N([{tag:Y.link,class:"tok-link"},{tag:Y.heading,class:"tok-heading"},{tag:Y.emphasis,class:"tok-emphasis"},{tag:Y.strong,class:"tok-strong"},{tag:Y.keyword,class:"tok-keyword"},{tag:Y.atom,class:"tok-atom"},{tag:Y.bool,class:"tok-bool"},{tag:Y.url,class:"tok-url"},{tag:Y.labelName,class:"tok-labelName"},{tag:Y.inserted,class:"tok-inserted"},{tag:Y.deleted,class:"tok-deleted"},{tag:Y.literal,class:"tok-literal"},{tag:Y.string,class:"tok-string"},{tag:Y.number,class:"tok-number"},{tag:[Y.regexp,Y.escape,Y.special(Y.string)],class:"tok-string2"},{tag:Y.variableName,class:"tok-variableName"},{tag:Y.local(Y.variableName),class:"tok-variableName tok-local"},{tag:Y.definition(Y.variableName),class:"tok-variableName tok-definition"},{tag:Y.special(Y.variableName),class:"tok-variableName2"},{tag:Y.definition(Y.propertyName),class:"tok-propertyName tok-definition"},{tag:Y.typeName,class:"tok-typeName"},{tag:Y.namespace,class:"tok-namespace"},{tag:Y.className,class:"tok-className"},{tag:Y.macroName,class:"tok-macroName"},{tag:Y.propertyName,class:"tok-propertyName"},{tag:Y.operator,class:"tok-operator"},{tag:Y.comment,class:"tok-comment"},{tag:Y.meta,class:"tok-meta"},{tag:Y.invalid,class:"tok-invalid"},{tag:Y.punctuation,class:"tok-punctuation"}])},51801:function(t,e,i){i.a(t,(async function(t,n){try{i.d(e,{QN:function(){return it},Qf:function(){return Y},il:function(){return at},mi:function(){return U},nF:function(){return et},rs:function(){return E},y1:function(){return T}});i(52247),i(71695),i(92745),i(77439),i(19423),i(40251),i(69235),i(12385),i(19134),i(5740),i(11740),i(44495),i(97003),i(47706),i(46692),i(39527),i(13334),i(36993),i(47021);var s,r=i(29341),o=i(63228),h=i(45539),l=i(12482),a=i(29933),c=t([h]);h=(c.then?(await c)():c)[0];const f=new r.md;function d(t){return o.r$.define({combine:t?e=>e.concat(t):void 0})}const g=new r.md;class p{constructor(t,e,i=[],n=""){this.data=t,this.name=n,o.yy.prototype.hasOwnProperty("tree")||Object.defineProperty(o.yy.prototype,"tree",{get(){return w(this)}}),this.parser=e,this.extension=[C.of(this),o.yy.languageData.of(((t,e,i)=>{let n=m(t,e,i),s=n.type.prop(f);if(!s)return[];let r=t.facet(s),o=n.type.prop(g);if(o){let s=n.resolve(e-n.from,i);for(let e of o)if(e.test(s,t)){let i=t.facet(e.facet);return"replace"==e.type?i:i.concat(r)}}return r}))].concat(i)}isActiveAt(t,e,i=-1){return m(t,e,i).type.prop(f)==this.data}findRegions(t){let e=t.facet(C);if((null==e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let i=[],n=(t,e)=>{if(t.prop(f)==this.data)return void i.push({from:e,to:e+t.length});let s=t.prop(r.md.mounted);if(s){if(s.tree.prop(f)==this.data){if(s.overlay)for(let t of s.overlay)i.push({from:t.from+e,to:t.to+e});else i.push({from:e,to:e+t.length});return}if(s.overlay){let t=i.length;if(n(s.tree,s.overlay[0].from+e),i.length>t)return}}for(let i=0;i<t.children.length;i++){let s=t.children[i];s instanceof r.mp&&n(s,t.positions[i]+e)}};return n(w(t),0),i}get allowsNesting(){return!0}}function m(t,e,i){let n=t.facet(C),s=w(t).topNode;if(!n||n.allowsNesting)for(let o=s;o;o=o.enter(e,i,r.vj.ExcludeBuffers))o.type.isTop&&(s=o);return s}p.setState=o.Py.define();function w(t){let e=t.field(p.state,!1);return e?e.tree:r.mp.empty}class v{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let i=this.cursorPos-this.string.length;return t<i||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}}let y=null;class b{constructor(t,e,i=[],n,s,r,o,h){this.parser=t,this.state=e,this.fragments=i,this.tree=n,this.treeLen=s,this.viewport=r,this.skipped=o,this.scheduleOn=h,this.parse=null,this.tempSkipped=[]}static create(t,e,i){return new b(t,e,[],r.mp.empty,0,i,[],null)}startParse(){return this.parser.startParse(new v(this.state.doc),this.fragments)}work(t,e){return null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=r.mp.empty&&this.isDone(null!=e?e:this.state.doc.length)?(this.takeTree(),!0):this.withContext((()=>{var i;if("number"==typeof t){let e=Date.now()+t;t=()=>Date.now()>e}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 n=this.parse.advance();if(n){if(this.fragments=this.withoutTempSkipped(r.i9.addTree(n,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(i=this.parse.stoppedAt)&&void 0!==i?i:this.state.doc.length,this.tree=n,this.parse=null,!(this.treeLen<(null!=e?e:this.state.doc.length)))return!0;this.parse=this.startParse()}if(t())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((()=>{for(;!(e=this.parse.advance()););})),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(r.i9.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=y;y=this;try{return t()}finally{y=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=x(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:n,treeLen:s,viewport:o,skipped:h}=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=r.i9.applyChanges(i,e),n=r.mp.empty,s=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){h=[];for(let e of this.skipped){let i=t.mapPos(e.from,1),n=t.mapPos(e.to,-1);i<n&&h.push({from:i,to:n})}}}return new b(this.parser,e,i,n,s,o,h,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=x(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 r._b{createParse(e,i,n){let s=n[0].from,o=n[n.length-1].to;return{parsedPos:s,advance(){let e=y;if(e){for(let t of n)e.tempSkipped.push(t);t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}return this.parsedPos=o,new r.mp(r.Jq.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}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 y}}function x(t,e,i){return r.i9.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}class S{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)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 S(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=b.create(t.facet(C).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new S(i)}}p.state=o.QQ.define({create:S.init,update(t,e){for(let i of e.effects)if(i.is(p.setState))return i.value;return e.startState.facet(C)!=e.state.facet(C)?S.init(e.state):t.apply(e)}});let k=t=>{let e=setTimeout((()=>t()),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&(k=t=>{let e=-1,i=setTimeout((()=>{e=requestIdleCallback(t,{timeout:400})}),100);return()=>e<0?clearTimeout(i):cancelIdleCallback(e)});const A="undefined"!=typeof navigator&&(null===(s=navigator.scheduling)||void 0===s?void 0:s.isInputPending)?()=>navigator.scheduling.isInputPending():null,M=h.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(p.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(p.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=k(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(p.state);if(s.tree==s.context.tree&&s.context.isDone(n+1e5))return;let r=Date.now()+Math.min(this.chunkBudget,100,t&&!A?Math.max(25,t.timeRemaining()-5):1e9),o=s.context.treeLen<n&&i.doc.length>n+1e3,h=s.context.work((()=>A&&A()||Date.now()>r),n+(o?0:1e5));this.chunkBudget-=Date.now()-e,(h||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:p.setState.of(new S(s.context))})),this.chunkBudget>0&&(!h||o)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then((()=>this.scheduleWork())).catch((t=>(0,h.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()}}}),C=o.r$.define({combine(t){return t.length?t[0]:null},enables:t=>[p.state,M,h.tk.contentAttributes.compute([t],(e=>{let i=e.facet(t);return i&&i.name?{"data-language":i.name}:{}}))]});const O=o.r$.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some((t=>t!=e[0])))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function T(t){let e=t.facet(O);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}const D=new r.md;const E=o.r$.define(),R=new r.md;function B(t,e,i){let n=w(t);if(n.length<i)return null;let s=null;for(let r=n.resolveStack(i,1);r;r=r.next){let o=r.node;if(o.to<=i||o.from>i)continue;if(s&&o.from<e)break;let h=o.type.prop(R);if(h&&(o.to<n.length-50||n.length==t.doc.length||!P(o))){let n=h(o,t);n&&n.from<=i&&n.from>=e&&n.to>i&&(s=n)}}return s}function P(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}function L(t,e,i){for(let n of t.facet(E)){let s=n(t,e,i);if(s)return s}return B(t,e,i)}function N(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 I=o.Py.define({map:N}),V=o.Py.define({map:N});const H=o.QQ.define({create(){return h.p.none},update(t,e){t=t.map(e.changes);for(let i of e.effects)if(i.is(I)&&!F(t,i.value.from,i.value.to)){let{preparePlaceholder:n}=e.state.facet(_),s=n?h.p.replace({widget:new K(n(e.state,i.value))}):$;t=t.update({add:[s.range(i.value.from,i.value.to)]})}else i.is(V)&&(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=>h.tk.decorations.from(t),toJSON(t,e){let i=[];return t.between(0,e.doc.length,((t,e)=>{i.push(t,e)})),i},fromJSON(t){if(!Array.isArray(t)||t.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let i=0;i<t.length;){let n=t[i++],s=t[i++];if("number"!=typeof n||"number"!=typeof s)throw new RangeError("Invalid JSON for fold state");e.push($.range(n,s))}return h.p.set(e,!0)}});function W(t,e,i){var n;let s=null;return null===(n=t.field(H,!1))||void 0===n||n.between(e,i,((t,e)=>{(!s||s.from>t)&&(s={from:t,to:e})})),s}function F(t,e,i){let n=!1;return t.between(e,e,((t,s)=>{t==e&&s==i&&(n=!0)})),n}const z={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},_=o.r$.define({combine(t){return(0,o.BO)(t,z)}});function j(t){let e=[H,X];return t&&e.push(_.of(t)),e}function q(t,e){let{state:i}=t,n=i.facet(_),s=e=>{let i=t.lineBlockAt(t.posAtDOM(e.target)),n=W(t.state,i.from,i.to);n&&t.dispatch({effects:V.of(n)}),e.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(t,s,e);let r=document.createElement("span");return r.textContent=n.placeholderText,r.setAttribute("aria-label",i.phrase("folded code")),r.title=i.phrase("unfold"),r.className="cm-foldPlaceholder",r.onclick=s,r}const $=h.p.replace({widget:new class extends h.l9{toDOM(t){return q(t,null)}}});class K extends h.l9{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return q(t,this.value)}}const J={openText:"⌄",closedText:"",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class G extends h.SJ{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 U(t={}){let e=Object.assign(Object.assign({},J),t),i=new G(e,!0),n=new G(e,!1),s=h.lg.fromClass(class{constructor(t){this.from=t.viewport.from,this.markers=this.buildMarkers(t)}update(t){(t.docChanged||t.viewportChanged||t.startState.facet(C)!=t.state.facet(C)||t.startState.field(H,!1)!=t.state.field(H,!1)||w(t.startState)!=w(t.state)||e.foldingChanged(t))&&(this.markers=this.buildMarkers(t.view))}buildMarkers(t){let e=new o.f_;for(let s of t.viewportLineBlocks){let r=W(t.state,s.from,s.to)?n:L(t.state,s.from,s.to)?i:null;r&&e.add(s.from,s.from,r)}return e.finish()}}),{domEventHandlers:r}=e;return[s,(0,h.v5)({class:"cm-foldGutter",markers(t){var e;return(null===(e=t.plugin(s))||void 0===e?void 0:e.markers)||o.Xs.empty},initialSpacer(){return new G(e,!1)},domEventHandlers:Object.assign(Object.assign({},r),{click:(t,e,i)=>{if(r.click&&r.click(t,e,i))return!0;let n=W(t.state,e.from,e.to);if(n)return t.dispatch({effects:V.of(n)}),!0;let s=L(t.state,e.from,e.to);return!!s&&(t.dispatch({effects:I.of(s)}),!0)}})}),j()]}const X=h.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"}});class Y{constructor(t,e){let i;function n(t){let e=a.V.newName();return(i||(i=Object.create(null)))["."+e]=t,e}this.specs=t;const s="string"==typeof e.all?e.all:e.all?n(e.all):void 0,r=e.scope;this.scope=r instanceof p?t=>t.prop(f)==r.data:r?t=>t==r:void 0,this.style=(0,l.QR)(t.map((t=>({tag:t.tag,class:t.class||n(Object.assign({},t,{tag:null}))}))),{all:s}).style,this.module=i?new a.V(i):null,this.themeType=e.themeType}static define(t,e){return new Y(t,e||{})}}const Q=o.r$.define(),Z=o.r$.define({combine(t){return t.length?[t[0]]:null}});function tt(t){let e=t.facet(Q);return e.length?e:t.facet(Z)}function et(t,e){let i,n=[st];return t instanceof Y&&(t.module&&n.push(h.tk.styleModule.of(t.module)),i=t.themeType),(null==e?void 0:e.fallback)?n.push(Z.of(t)):i?n.push(Q.computeN([h.tk.darkTheme],(e=>e.facet(h.tk.darkTheme)==("dark"==i)?[t]:[]))):n.push(Q.of(t)),n}function it(t,e,i){let n=tt(t),s=null;if(n)for(let r of n)if(!r.scope||i&&r.scope(i)){let t=r.style(e);t&&(s=s?s+" "+t:t)}return s}class nt{constructor(t){this.markCache=Object.create(null),this.tree=w(t.state),this.decorations=this.buildDeco(t,tt(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=w(t.state),i=tt(t.state),n=i!=tt(t.startState),{viewport:s}=t.view,r=t.changes.mapPos(this.decoratedTo,1);e.length<s.to&&!n&&e.type==this.tree.type&&r>=s.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=r):(e!=this.tree||t.viewportChanged||n)&&(this.tree=e,this.decorations=this.buildDeco(t.view,i),this.decoratedTo=s.to)}buildDeco(t,e){if(!e||!this.tree.length)return h.p.none;let i=new o.f_;for(let{from:n,to:s}of t.visibleRanges)(0,l.bW)(this.tree,e,((t,e,n)=>{i.add(t,e,this.markCache[n]||(this.markCache[n]=h.p.mark({class:n})))}),n,s);return i.finish()}}const st=o.Wl.high(h.lg.fromClass(nt,{decorations:t=>t.decorations}));l.pJ.meta,l.pJ.link,l.pJ.heading,l.pJ.emphasis,l.pJ.strong,l.pJ.strikethrough,l.pJ.keyword,l.pJ.atom,l.pJ.bool,l.pJ.url,l.pJ.contentSeparator,l.pJ.labelName,l.pJ.literal,l.pJ.inserted,l.pJ.string,l.pJ.deleted,l.pJ.regexp,l.pJ.escape,l.pJ.string,l.pJ.variableName,l.pJ.variableName,l.pJ.typeName,l.pJ.namespace,l.pJ.className,l.pJ.variableName,l.pJ.macroName,l.pJ.propertyName,l.pJ.comment,l.pJ.invalid;function rt(t,e,i,n=0,s=0){null==e&&-1==(e=t.search(/[^\s\u00a0]/))&&(e=t.length);let r=s;for(let o=n;o<e;o++)9==t.charCodeAt(o)?r+=i-r%i:r++;return r}class ot{constructor(t,e,i,n){this.string=t,this.tabSize=e,this.indentUnit=i,this.overrideIndent=n,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return 0==this.pos}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(t){let e,i=this.string.charAt(this.pos);if(e="string"==typeof t?i==t:i&&(t instanceof RegExp?t.test(i):t(i)),e)return++this.pos,i}eatWhile(t){let e=this.pos;for(;this.eat(t););return this.pos>e}eatSpace(){let t=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>t}skipToEnd(){this.pos=this.string.length}skipTo(t){let e=this.string.indexOf(t,this.pos);if(e>-1)return this.pos=e,!0}backUp(t){this.pos-=t}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=rt(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var t;return null!==(t=this.overrideIndent)&&void 0!==t?t:rt(this.string,null,this.tabSize)}match(t,e,i){if("string"==typeof t){let n=t=>i?t.toLowerCase():t;return n(this.string.substr(this.pos,t.length))==n(t)?(!1!==e&&(this.pos+=t.length),!0):null}{let i=this.string.slice(this.pos).match(t);return i&&i.index>0?null:(i&&!1!==e&&(this.pos+=i[0].length),i)}}current(){return this.string.slice(this.start,this.pos)}}function ht(t){if("object"!=typeof t)return t;let e={};for(let i in t){let n=t[i];e[i]=n instanceof Array?n.slice():n}return e}const lt=new WeakMap;class at extends p{constructor(t){let e,i=d(t.languageData),n={name:(s=t).name||"",token:s.token,blankLine:s.blankLine||(()=>{}),startState:s.startState||(()=>!0),copyState:s.copyState||ht,indent:s.indent||(()=>null),languageData:s.languageData||{},tokenTable:s.tokenTable||pt};var s;super(i,new class extends r._b{createParse(t,i,n){return new dt(e,t,i,n)}},[],t.name),this.topNode=Mt(i,this),e=this,this.streamParser=n,this.stateAfter=new r.md({perNode:!0}),this.tokenTable=t.tokenTable?new xt(n.tokenTable):St}static define(t){return new at(t)}getIndent(t){let e,{overrideIndentation:i}=t.options;i&&(e=lt.get(t.state),null!=e&&e<t.pos-1e4&&(e=void 0));let n,s,r=ct(this,t.node.tree,t.node.from,t.node.from,null!=e?e:t.pos);if(r?(s=r.state,n=r.pos+1):(s=this.streamParser.startState(t.unit),n=t.node.from),t.pos-n>1e4)return null;for(;n<t.pos;){let e=t.state.doc.lineAt(n),r=Math.min(t.pos,e.to);if(e.length){let n=i?i(e.from):-1,o=new ot(e.text,t.state.tabSize,t.unit,n<0?void 0:n);for(;o.pos<r-e.from;)gt(this.streamParser.token,o,s)}else this.streamParser.blankLine(s,t.unit);if(r==t.pos)break;n=e.to+1}let o=t.lineAt(t.pos);return i&&null==e&&lt.set(t.state,o.from),this.streamParser.indent(s,/^\s*(.*)/.exec(o.text)[1],t)}get allowsNesting(){return!1}}function ct(t,e,i,n,s){let o=i>=n&&i+e.length<=s&&e.prop(t.stateAfter);if(o)return{state:t.streamParser.copyState(o),pos:i+e.length};for(let h=e.children.length-1;h>=0;h--){let o=e.children[h],l=i+e.positions[h],a=o instanceof r.mp&&l<s&&ct(t,o,l,n,s);if(a)return a}return null}function ut(t,e,i,n,s){if(s&&i<=0&&n>=e.length)return e;s||0!=i||e.type!=t.topNode||(s=!0);for(let o=e.children.length-1;o>=0;o--){let h,l=e.positions[o],a=e.children[o];if(l<n&&a instanceof r.mp){if(!(h=ut(t,a,i-l,n-l,s)))break;return s?new r.mp(e.type,e.children.slice(0,o).concat(h),e.positions.slice(0,o+1),l+h.length):h}}return null}function ft(t,e,i,n,s){for(let r of e){let e,s=r.from+(r.openStart?25:0),o=r.to-(r.openEnd?25:0),h=s<=i&&o>i&&ct(t,r.tree,0-r.offset,i,o);if(h&&h.pos<=n&&(e=ut(t,r.tree,i+r.offset,h.pos+r.offset,!1)))return{state:h.state,tree:e}}return{state:t.streamParser.startState(s?T(s):4),tree:r.mp.empty}}class dt{constructor(t,e,i,n){this.lang=t,this.input=e,this.fragments=i,this.ranges=n,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=n[n.length-1].to;let s=b.get(),r=n[0].from,{state:o,tree:h}=ft(t,i,r,this.to,null==s?void 0:s.state);this.state=o,this.parsedPos=this.chunkStart=r+h.length;for(let l=0;l<h.children.length;l++)this.chunks.push(h.children[l]),this.chunkPos.push(h.positions[l]);s&&this.parsedPos<s.viewport.from-1e5&&n.some((t=>t.from<=s.viewport.from&&t.to>=s.viewport.from))&&(this.state=this.lang.streamParser.startState(T(s.state)),s.skipUntilInView(this.parsedPos,s.viewport.from),this.parsedPos=s.viewport.from),this.moveRangeIndex()}advance(){let t=b.get(),e=null==this.stoppedAt?this.to:Math.min(this.to,this.stoppedAt),i=Math.min(e,this.chunkStart+2048);for(t&&(i=Math.min(i,t.viewport.to));this.parsedPos<i;)this.parseLine(t);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=e?this.finish():t&&this.parsedPos>=t.viewport.to?(t.skipUntilInView(this.parsedPos,e),this.finish()):null}stopAt(t){this.stoppedAt=t}lineAfter(t){let e=this.input.chunk(t);if(this.input.lineChunks)"\n"==e&&(e="");else{let t=e.indexOf("\n");t>-1&&(e=e.slice(0,t))}return t+e.length<=this.to?e:e.slice(0,this.to-t)}nextLine(){let t=this.parsedPos,e=this.lineAfter(t),i=t+e.length;for(let n=this.rangeIndex;;){let t=this.ranges[n].to;if(t>=i)break;if(e=e.slice(0,t-(i-e.length)),n++,n==this.ranges.length)break;let s=this.ranges[n].from,r=this.lineAfter(s);e+=r,i=s+r.length}return{line:e,end:i}}skipGapsTo(t,e,i){for(;;){let n=this.ranges[this.rangeIndex].to,s=t+e;if(i>0?n>s:n>=s)break;e+=this.ranges[++this.rangeIndex].from-n}return e}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(t,e,i,n){let s=4;if(this.ranges.length>1){e+=n=this.skipGapsTo(e,n,1);let t=this.chunk.length;i+=n=this.skipGapsTo(i,n,-1),s+=this.chunk.length-t}let r=this.chunk.length-4;return 4==s&&r>=0&&this.chunk[r]==t&&this.chunk[r+2]==e?this.chunk[r+2]=i:this.chunk.push(t,e,i,s),n}parseLine(t){let{line:e,end:i}=this.nextLine(),n=0,{streamParser:s}=this.lang,r=new ot(e,t?t.state.tabSize:4,t?T(t.state):2);if(r.eol())s.blankLine(this.state,r.indentUnit);else for(;!r.eol();){let t=gt(s.token,r,this.state);if(t&&(n=this.emitToken(this.lang.tokenTable.resolve(t),this.parsedPos+r.start,this.parsedPos+r.pos,n)),r.start>1e4)break}this.parsedPos=i,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let t=r.mp.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:wt,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new r.mp(t.type,t.children,t.positions,t.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(t),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new r.mp(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}}function gt(t,e,i){e.start=e.pos;for(let n=0;n<10;n++){let n=t(e,i);if(e.pos>e.start)return n}throw new Error("Stream parser failed to advance stream.")}const pt=Object.create(null),mt=[r.Jq.none],wt=new r.Lj(mt),vt=[],yt=Object.create(null),bt=Object.create(null);for(let[Ct,Ot]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])bt[Ct]=At(pt,Ot);class xt{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),bt)}resolve(t){return t?this.table[t]||(this.table[t]=At(this.extra,t)):0}}const St=new xt(pt);function kt(t,e){vt.indexOf(t)>-1||(vt.push(t),console.warn(e))}function At(t,e){let i=[];for(let r of e.split(" ")){let e=[];for(let i of r.split(".")){let n=t[i]||l.pJ[i];n?"function"==typeof n?e.length?e=e.map(n):kt(i,`Modifier ${i} used at start of tag`):e.length?kt(i,`Tag ${i} used as modifier`):e=Array.isArray(n)?n:[n]:kt(i,`Unknown highlighting tag ${i}`)}for(let t of e)i.push(t)}if(!i.length)return 0;let n=e.replace(/ /g,"_"),s=n+" "+i.map((t=>t.id)),o=yt[s];if(o)return o.id;let h=yt[s]=r.Jq.define({id:mt.length,name:n,props:[(0,l.Gv)({[n]:i})]});return mt.push(h),h.id}function Mt(t,e){let i=r.Jq.define({id:mt.length,name:"Document",props:[f.add((()=>t)),D.add((()=>t=>e.getIndent(t)))],top:!0});return mt.push(i),i}h.Nm.RTL,h.Nm.LTR;n()}catch(u){n(u)}}))},63228:function(t,e,i){i.d(e,{BO:function(){return Ct},IS:function(){return jt},Py:function(){return dt},QQ:function(){return q},Wl:function(){return X},Xs:function(){return Rt},f_:function(){return Bt},r$:function(){return V},yy:function(){return Mt}});i(63721),i(52247),i(71695),i(92745),i(52805),i(61495),i(61893),i(23669),i(69235),i(12385),i(19134),i(32517),i(5740),i(11740),i(92519),i(42179),i(89256),i(24931),i(88463),i(57449),i(19814),i(97003),i(32114),i(39527),i(92181),i(99790),i(67670),i(41360),i(13334),i(34595),i(36993),i(47021);class n{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),r.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),r.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 l(this),s=new l(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 l(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 c(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}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 s(t):r.from(s.split(t,[])):n.empty}}class s extends n{constructor(t,e=function(t){let e=-1;for(let i of t)e+=i.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.text[s],o=n+r.length;if((e?i:o)>=t)return new u(n,o,i,r);n=o+1,i++}}decompose(t,e,i,n){let r=t<=0&&e>=this.length?this:new s(h(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&n){let t=i.pop(),e=o(r.text,t.text.slice(),0,r.length);if(e.length<=32)i.push(new s(e,t.length+r.length));else{let t=e.length>>1;i.push(new s(e.slice(0,t)),new s(e.slice(t)))}}else i.push(r)}replace(t,e,i){if(!(i instanceof s))return super.replace(t,e,i);let n=o(this.text,o(i.text,h(this.text,0,t)),e),l=this.length+i.length-(e-t);return n.length<=32?new s(n,l):r.from(s.split(n,[]),l)}sliceString(t,e=this.length,i="\n"){let n="";for(let s=0,r=0;s<=e&&r<this.text.length;r++){let o=this.text[r],h=s+o.length;s>t&&r&&(n+=i),t<h&&e>s&&(n+=o.slice(Math.max(0,t-s),e-s)),s=h+1}return n}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],n=-1;for(let r of t)i.push(r),n+=r.length+1,32==i.length&&(e.push(new s(i,n)),i=[],n=-1);return n>-1&&e.push(new s(i,n)),e}}class r extends n{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,h=i+r.lines-1;if((e?h:o)>=t)return r.lineInner(t,e,i,n);n=o+1,i=h+1}}decompose(t,e,i,n){for(let s=0,r=0;r<=e&&s<this.children.length;s++){let o=this.children[s],h=r+o.length;if(t<=h&&e>=r){let s=n&((r<=t?1:0)|(h>=e?2:0));r>=t&&h<=e&&!s?i.push(o):o.decompose(t-r,e-r,i,s)}r=h+1}}replace(t,e,i){if(i.lines<this.lines)for(let n=0,s=0;n<this.children.length;n++){let o=this.children[n],h=s+o.length;if(t>=s&&e<=h){let l=o.replace(t-s,e-s,i),a=this.lines-o.lines+l.lines;if(l.lines<a>>4&&l.lines>a>>6){let s=this.children.slice();return s[n]=l,new r(s,this.length-(e-t)+i.length)}return super.replace(s,h,l)}s=h+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i="\n"){let n="";for(let s=0,r=0;s<this.children.length&&r<=e;s++){let o=this.children[s],h=r+o.length;r>t&&s&&(n+=i),t<h&&e>r&&(n+=o.sliceString(t-r,e-r,i)),r=h+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof r))return 0;let i=0,[n,s,o,h]=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==o||s==h)return i;let r=this.children[n],l=t.children[s];if(r!=l)return i+r.scanIdentical(l,e);i+=r.length+1}}static from(t,e=t.reduce(((t,e)=>t+e.length+1),-1)){let i=0;for(let s of t)i+=s.lines;if(i<32){let i=[];for(let e of t)e.flatten(i);return new s(i,e)}let n=Math.max(32,i>>5),o=n<<1,h=n>>1,l=[],a=0,c=-1,u=[];function f(t){let e;if(t.lines>o&&t instanceof r)for(let i of t.children)f(i);else t.lines>h&&(a>h||!a)?(d(),l.push(t)):t instanceof s&&a&&(e=u[u.length-1])instanceof s&&t.lines+e.lines<=32?(a+=t.lines,c+=t.length+1,u[u.length-1]=new s(e.text.concat(t.text),e.length+1+t.length)):(a+t.lines>n&&d(),a+=t.lines,c+=t.length+1,u.push(t))}function d(){0!=a&&(l.push(1==u.length?u[0]:r.from(u,c)),c=-1,a=u.length=0)}for(let s of t)f(s);return d(),1==l.length?l[0]:new r(l,e)}}function o(t,e,i=0,n=1e9){for(let s=0,r=0,o=!0;r<t.length&&s<=n;r++){let h=t[r],l=s+h.length;l>=i&&(l>n&&(h=h.slice(0,n-s)),s<i&&(h=h.slice(i-s)),o?(e[e.length-1]+=h,o=!1):e.push(h)),s=l+1}return e}function h(t,e,i){return o(t,[""],e,i)}n.empty=new s([""],0);class l{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 s?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],r=this.offsets[i],o=r>>1,h=n instanceof s?n.text.length:n.children.length;if(o==(e>0?h: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&r)==(e>0?0:1)){if(this.offsets[i]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(n instanceof s){let s=n.text[o+(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 r=n.children[o+(e<0?-1:0)];t>r.length?(t-=r.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(r),this.offsets.push(e>0?1:(r instanceof s?r.text.length:r.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 l(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 c{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&&(n.prototype[Symbol.iterator]=function(){return this.iter()},l.prototype[Symbol.iterator]=a.prototype[Symbol.iterator]=c.prototype[Symbol.iterator]=function(){return this});class u{constructor(t,e,i,n){this.from=t,this.to=e,this.number=i,this.text=n}get length(){return this.to-this.from}}let f="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map((t=>t?parseInt(t,36):1));for(let $t=1;$t<f.length;$t++)f[$t]+=f[$t-1];function d(t){for(let e=1;e<f.length;e+=2)if(f[e]>t)return f[e-1]<=t;return!1}function g(t){return t>=127462&&t<=127487}const p=8205;function m(t,e,i=!0,n=!0){return(i?w:v)(t,e,n)}function w(t,e,i){if(e==t.length)return e;e&&y(t.charCodeAt(e))&&b(t.charCodeAt(e-1))&&e--;let n=x(t,e);for(e+=S(n);e<t.length;){let s=x(t,e);if(n==p||s==p||i&&d(s))e+=S(s),n=s;else{if(!g(s))break;{let i=0,n=e-2;for(;n>=0&&g(x(t,n));)i++,n-=2;if(i%2==0)break;e+=2}}}return e}function v(t,e,i){for(;e>0;){let n=w(t,e-2,i);if(n<e)return n;e--}return 0}function y(t){return t>=56320&&t<57344}function b(t){return t>=55296&&t<56320}function x(t,e){let i=t.charCodeAt(e);if(!b(i)||e+1==t.length)return i;let n=t.charCodeAt(e+1);return y(n)?n-56320+(i-55296<<10)+65536:i}function S(t){return t<65536?1:2}const k=/\r\n?|\n/;var A=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(A||(A={}));class M{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){D(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 M(t)}composeDesc(t){return this.empty?t:t.empty?this:R(this,t)}mapDesc(t,e=!1){return t.empty?this:E(this,t,e)}mapPos(t,e=-1,i=A.Simple){let n=0,s=0;for(let r=0;r<this.sections.length;){let o=this.sections[r++],h=this.sections[r++],l=n+o;if(h<0){if(l>t)return s+(t-n);s+=o}else{if(i!=A.Simple&&l>=t&&(i==A.TrackDel&&n<t&&l>t||i==A.TrackBefore&&n<t||i==A.TrackAfter&&l>t))return null;if(l>t||l==t&&e<0&&!o)return t==n||e<0?s:s+h;s+=h}n=l}if(t>n)throw new RangeError(`Position ${t} is out of range for changeset of length ${n}`);return s}touchesRange(t,e=t){for(let i=0,n=0;i<this.sections.length&&n<=e;){let s=n+this.sections[i++];if(this.sections[i++]>=0&&n<=e&&s>=t)return!(n<t&&s>e)||"cover";n=s}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];t+=(t?" ":"")+i+(n>=0?":"+n:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some((t=>"number"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeDesc");return new M(t)}static create(t){return new M(t)}}class C extends M{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 D(this,((e,i,n,s,r)=>t=t.replace(n,n+(i-e),r)),!1),t}mapDesc(t,e=!1){return E(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let s=0,r=0;s<e.length;s+=2){let o=e[s],h=e[s+1];if(h>=0){e[s]=h,e[s+1]=o;let l=s>>1;for(;i.length<l;)i.push(n.empty);i.push(o?t.slice(r,r+o):n.empty)}r+=o}return new C(e,i)}compose(t){return this.empty?t:t.empty?this:R(this,t,!0)}map(t,e=!1){return t.empty?this:E(this,t,e,!0)}iterChanges(t,e=!1){D(this,t,e)}get desc(){return M.create(this.sections)}filter(t){let e=[],i=[],n=[],s=new B(this);t:for(let r=0,o=0;;){let h=r==t.length?1e9:t[r++];for(;o<h||o==h&&0==s.len;){if(s.done)break t;let t=Math.min(s.len,h-o);O(n,t,-1);let r=-1==s.ins?-1:0==s.off?s.ins:0;O(e,t,r),r>0&&T(i,e,s.text),s.forward(t),o+=t}let l=t[r++];for(;o<l;){if(s.done)break t;let t=Math.min(s.len,l-o);O(e,t,-1),O(n,t,-1==s.ins?-1:0==s.off?s.ins:0),s.forward(t),o+=t}}return{changes:new C(e,i),filtered:M.create(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 s=[],r=[],o=0,h=null;function l(t=!1){if(!t&&!s.length)return;o<e&&O(s,e-o,-1);let i=new C(s,r);h=h?h.compose(i.map(h)):i,s=[],r=[],o=0}return function t(a){if(Array.isArray(a))for(let e of a)t(e);else if(a instanceof C){if(a.length!=e)throw new RangeError(`Mismatched change set length (got ${a.length}, expected ${e})`);l(),h=h?h.compose(a.map(h)):a}else{let{from:t,to:h=t,insert:c}=a;if(t>h||t<0||h>e)throw new RangeError(`Invalid change range ${t} to ${h} (in doc of length ${e})`);let u=c?"string"==typeof c?n.of(c.split(i||k)):c:n.empty,f=u.length;if(t==h&&0==f)return;t<o&&l(),t>o&&O(s,t-o,-1),O(s,h-t,f),T(r,s,u),o=h}}(t),l(!h),h}static empty(t){return new C(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],i=[];for(let s=0;s<t.length;s++){let r=t[s];if("number"==typeof r)e.push(r,-1);else{if(!Array.isArray(r)||"number"!=typeof r[0]||r.some(((t,e)=>e&&"string"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==r.length)e.push(r[0],0);else{for(;i.length<s;)i.push(n.empty);i[s]=n.of(r.slice(1)),e.push(r[0],i[s].length)}}}return new C(e,i)}static createSet(t,e){return new C(t,e)}}function O(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 T(t,e,i){if(0==i.length)return;let s=e.length-2>>1;if(s<t.length)t[t.length-1]=t[t.length-1].append(i);else{for(;t.length<s;)t.push(n.empty);t.push(i)}}function D(t,e,i){let s=t.inserted;for(let r=0,o=0,h=0;h<t.sections.length;){let l=t.sections[h++],a=t.sections[h++];if(a<0)r+=l,o+=l;else{let c=r,u=o,f=n.empty;for(;c+=l,u+=a,a&&s&&(f=f.append(s[h-2>>1])),!(i||h==t.sections.length||t.sections[h+1]<0);)l=t.sections[h++],a=t.sections[h++];e(r,c,o,u,f),r=c,o=u}}}function E(t,e,i,n=!1){let s=[],r=n?[]:null,o=new B(t),h=new B(e);for(let l=-1;;)if(-1==o.ins&&-1==h.ins){let t=Math.min(o.len,h.len);O(s,t,-1),o.forward(t),h.forward(t)}else if(h.ins>=0&&(o.ins<0||l==o.i||0==o.off&&(h.len<o.len||h.len==o.len&&!i))){let t=h.len;for(O(s,h.ins,-1);t;){let e=Math.min(o.len,t);o.ins>=0&&l<o.i&&o.len<=e&&(O(s,0,o.ins),r&&T(r,s,o.text),l=o.i),o.forward(e),t-=e}h.next()}else{if(!(o.ins>=0)){if(o.done&&h.done)return r?C.createSet(s,r):M.create(s);throw new Error("Mismatched change set lengths")}{let t=0,e=o.len;for(;e;)if(-1==h.ins){let i=Math.min(e,h.len);t+=i,e-=i,h.forward(i)}else{if(!(0==h.ins&&h.len<e))break;e-=h.len,h.next()}O(s,t,l<o.i?o.ins:0),r&&l<o.i&&T(r,s,o.text),l=o.i,o.forward(o.len-e)}}}function R(t,e,i=!1){let n=[],s=i?[]:null,r=new B(t),o=new B(e);for(let h=!1;;){if(r.done&&o.done)return s?C.createSet(n,s):M.create(n);if(0==r.ins)O(n,r.len,0,h),r.next();else if(0!=o.len||o.done){if(r.done||o.done)throw new Error("Mismatched change set lengths");{let t=Math.min(r.len2,o.len),e=n.length;if(-1==r.ins){let e=-1==o.ins?-1:o.off?0:o.ins;O(n,t,e,h),s&&e&&T(s,n,o.text)}else-1==o.ins?(O(n,r.off?0:r.len,t,h),s&&T(s,n,r.textBit(t))):(O(n,r.off?0:r.len,o.off?0:o.ins,h),s&&!o.off&&T(s,n,o.text));h=(r.ins>t||o.ins>=0&&o.len>t)&&(h||n.length>e),r.forward2(t),o.forward(t)}}else O(n,0,o.ins,h),s&&T(s,n,o.text),o.next()}}class B{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.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?n.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,n;return this.empty?i=n=t.mapPos(this.from,e):(i=t.mapPos(this.from,1),n=t.mapPos(this.to,-1)),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 L.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return L.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 L.range(t.anchor,t.head)}static create(t,e,i){return new P(t,e,i)}}class L{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:L.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 L([this.main],0)}addRange(t,e=!0){return L.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,L.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 L(t.ranges.map((t=>P.fromJSON(t))),t.main)}static single(t,e=t){return new L([L.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 L.normalized(t.slice(),e);i=s.to}return new L(t,e)}static cursor(t,e=0,i,n){return P.create(t,t,(0==e?0:e<0?4:8)|(null==i?3:Math.min(2,i))|(null!=n?n:33554431)<<5)}static range(t,e,i,n){let s=(null!=i?i:33554431)<<5|(null==n?3:Math.min(2,n));return e<t?P.create(e,t,24|s):P.create(t,e,(e>t?4:0)|s)}static normalized(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?L.range(o,r):L.range(r,o))}}return new L(t,e)}}function N(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let I=0;class V{constructor(t,e,i,n,s){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=I++,this.default=t([]),this.extensions="function"==typeof s?s(this):s}static define(t={}){return new V(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:H),!!t.static,t.enables)}of(t){return new W([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new W(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new W(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],(i=>e(i.field(t))))}}function H(t,e){return t==e||t.length==e.length&&t.every(((t,i)=>t===e[i]))}class W{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=I++}dynamicSlot(t){var e;let i=this.value,n=this.facet.compareInput,s=this.id,r=t[s]>>1,o=2==this.type,h=!1,l=!1,a=[];for(let c of this.dependencies)"doc"==c?h=!0:"selection"==c?l=!0:1&(null!==(e=t[c.id])&&void 0!==e?e:1)||a.push(t[c.id]);return{create(t){return t.values[r]=i(t),1},update(t,e){if(h&&e.docChanged||l&&(e.docChanged||e.selection)||z(t,a)){let e=i(t);if(o?!F(e,t.values[r],n):!n(e,t.values[r]))return t.values[r]=e,1}return 0},reconfigure:(t,e)=>{let h,l=e.config.address[s];if(null!=l){let s=it(e,l);if(this.dependencies.every((i=>i instanceof V?e.facet(i)===t.facet(i):!(i instanceof q)||e.field(i,!1)==t.field(i,!1)))||(o?F(h=i(t),s,n):n(h=i(t),s)))return t.values[r]=s,0}else h=i(t);return t.values[r]=h,1}}}}function F(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 z(t,e){let i=!1;for(let n of e)1&et(t,n)&&(i=!0);return i}function _(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;function h(t){let i=[];for(let e=0;e<n.length;e++){let r=it(t,n[e]);if(2==s[e])for(let t of r)i.push(t);else i.push(r)}return e.combine(i)}return{create(t){for(let e of n)et(t,e);return t.values[o]=h(t),1},update(t,i){if(!z(t,r))return 0;let n=h(t);return e.compare(n,t.values[o])?0:(t.values[o]=n,1)},reconfigure(t,s){let r=z(t,n),l=s.config.facets[e.id],a=s.facet(e);if(l&&!r&&H(i,l))return t.values[o]=a,0;let c=h(t);return e.compare(c,a)?(t.values[o]=a,0):(t.values[o]=c,1)}}}const j=V.define({static:!0});class q{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 q(I++,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(j).find((t=>t.field==this));return((null==e?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:t=>(t.values[e]=this.create(t),1),update:(t,i)=>{let n=t.values[e],s=this.updateF(n,i);return this.compareF(n,s)?0:(t.values[e]=s,1)},reconfigure:(t,i)=>null!=i.config.address[this.id]?(t.values[e]=i.field(this),0):(t.values[e]=this.create(t),1)}}init(t){return[this,j.of({field:this,create:t})]}get extension(){return this}}const $=4,K=3,J=2,G=1;function U(t){return e=>new Y(e,t)}const X={highest:U(0),high:U(G),default:U(J),low:U(K),lowest:U($)};class Y{constructor(t,e){this.inner=t,this.prec=e}}class Q{of(t){return new Z(this,t)}reconfigure(t){return Q.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class Z{constructor(t,e){this.compartment=t,this.inner=e}}class tt{constructor(t,e,i,n,s,r){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=s,this.facets=r,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return null==e?t.default:this.staticValues[e>>1]}static resolve(t,e,i){let n=[],s=Object.create(null),r=new Map;for(let u of function(t,e,i){let n=[[],[],[],[],[]],s=new Map;function r(t,o){let h=s.get(t);if(null!=h){if(h<=o)return;let e=n[h].indexOf(t);e>-1&&n[h].splice(e,1),t instanceof Z&&i.delete(t.compartment)}if(s.set(t,o),Array.isArray(t))for(let e of t)r(e,o);else if(t instanceof Z){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 Y)r(t.inner,t.prec);else if(t instanceof q)n[o].push(t),t.provides&&r(t.provides,o);else if(t instanceof W)n[o].push(t),t.facet.extensions&&r(t.facet.extensions,J);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,J),n.reduce(((t,e)=>t.concat(e)))}(t,e,r))u instanceof q?n.push(u):(s[u.facet.id]||(s[u.facet.id]=[])).push(u);let o=Object.create(null),h=[],l=[];for(let u of n)o[u.id]=l.length<<1,l.push((t=>u.slot(t)));let a=null==i?void 0:i.config.facets;for(let u in s){let t=s[u],e=t[0].facet,n=a&&a[u]||[];if(t.every((t=>0==t.type)))if(o[e.id]=h.length<<1|1,H(n,t))h.push(i.facet(e));else{let n=e.combine(t.map((t=>t.value)));h.push(i&&e.compare(n,i.facet(e))?i.facet(e):n)}else{for(let e of t)0==e.type?(o[e.id]=h.length<<1|1,h.push(e.value)):(o[e.id]=l.length<<1,l.push((t=>e.dynamicSlot(t))));o[e.id]=l.length<<1,l.push((i=>_(i,e,t)))}}let c=l.map((t=>t(o)));return new tt(t,r,c,o,h,s)}}function et(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.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|s}function it(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const nt=V.define(),st=V.define({combine:t=>t.some((t=>t)),static:!0}),rt=V.define({combine:t=>t.length?t[0]:void 0,static:!0}),ot=V.define(),ht=V.define(),lt=V.define(),at=V.define({combine:t=>!!t.length&&t[0]});class ct{constructor(t,e){this.type=t,this.value=e}static define(){return new ut}}class ut{of(t){return new ct(this,t)}}class ft{constructor(t){this.map=t}of(t){return new dt(this,t)}}class dt{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 dt(this.type,e)}is(t){return this.type==t}static define(t={}){return new ft(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}}dt.reconfigure=dt.define(),dt.appendConfig=dt.define();class gt{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&&N(i,e.newLength),s.some((t=>t.type==gt.time))||(this.annotations=s.concat(gt.time.of(Date.now())))}static create(t,e,i,n,s,r){return new gt(t,e,i,n,s,r)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(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(gt.userEvent);return!(!e||!(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function pt(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 mt(t,e,i){var n;let s,r,o;return i?(s=e.changes,r=C.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:dt.mapEffects(t.effects,s).concat(dt.mapEffects(e.effects,r)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function wt(t,e,i){let n=e.selection,s=bt(e.annotations);return e.userEvent&&(s=s.concat(gt.userEvent.of(e.userEvent))),{changes:e.changes instanceof C?e.changes:C.of(e.changes||[],i,t.facet(rt)),selection:n&&(n instanceof L?n:L.single(n.anchor,n.head)),effects:bt(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function vt(t,e,i){let n=wt(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=mt(n,wt(t,e[r],s?n.changes.newLength:t.doc.length),s)}let s=gt.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return function(t){let e=t.startState,i=e.facet(lt),n=t;for(let s=i.length-1;s>=0;s--){let r=i[s](t);r&&Object.keys(r).length&&(n=mt(n,wt(e,r,t.changes.newLength),!0))}return n==t?t:gt.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}(i?function(t){let e=t.startState,i=!0;for(let s of e.facet(ot)){let e=s(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:pt(i,e))}if(!0!==i){let n,s;if(!1===i)s=t.changes.invertedDesc,n=C.empty(e.doc.length);else{let e=t.changes.filter(i);n=e.changes,s=e.filtered.mapDesc(e.changes).invertedDesc}t=gt.create(e,n,t.selection&&t.selection.map(s),dt.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let n=e.facet(ht);for(let s=n.length-1;s>=0;s--){let i=n[s](t);t=i instanceof gt?i:Array.isArray(i)&&1==i.length&&i[0]instanceof gt?i[0]:vt(e,bt(i),!1)}return t}(s):s)}gt.time=ct.define(),gt.userEvent=ct.define(),gt.addToHistory=ct.define(),gt.remote=ct.define();const yt=[];function bt(t){return null==t?yt:Array.isArray(t)?t:[t]}var xt=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(xt||(xt={}));const St=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let kt;try{kt=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(qt){}function At(t){return e=>{if(!/\S/.test(e))return xt.Space;if(function(t){if(kt)return kt.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}(e))return xt.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return xt.Word;return xt.Other}}class Mt{constructor(t,e,i,n,s,r){this.config=t,this.doc=e,this.selection=i,this.values=n,this.status=t.statusTemplate.slice(),this.computeSlot=s,r&&(r._state=this);for(let o=0;o<this.config.dynamicSlots.length;o++)et(this,o<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(null!=i)return et(this,i),it(this,i);if(e)throw new RangeError("Field is not present in this state")}update(...t){return vt(this,t,!0)}applyTransaction(t){let e,i=this.config,{base:n,compartments:s}=i;for(let r of t.effects)r.is(Q.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(dt.reconfigure)?(i=null,n=r.value):r.is(dt.appendConfig)&&(i=null,n=bt(n).concat(r.value));if(i)e=t.startState.values.slice();else{i=tt.resolve(n,s,this),e=new Mt(i,this.doc,this.selection,i.dynamicSlots.map((()=>null)),((t,e)=>e.reconfigure(t,this)),null).values}new Mt(i,t.newDoc,t.newSelection,e,((e,i)=>i.update(e,t)),t)}replaceSelection(t){return"string"==typeof t&&(t=this.toText(t)),this.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:t},range:L.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=bt(i.effects);for(let o=1;o<e.ranges.length;o++){let i=t(e.ranges[o]),h=this.changes(i.changes),l=h.map(n);for(let t=0;t<o;t++)s[t]=s[t].map(l);let a=n.mapDesc(h,!0);s.push(i.range.map(a)),n=n.compose(l),r=dt.mapEffects(r,l).concat(dt.mapEffects(bt(i.effects),a))}return{changes:n,selection:L.create(s,e.mainIndex),effects:r}}changes(t=[]){return t instanceof C?t:C.of(t,this.doc.length,this.facet(Mt.lineSeparator))}toText(t){return n.of(t.split(this.facet(Mt.lineSeparator)||k))}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:(et(this,e),it(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 q&&null!=this.config.address[n.id]&&(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)if(Object.prototype.hasOwnProperty.call(t,s)){let e=i[s],r=t[s];n.push(e.init((t=>e.spec.fromJSON(r,t))))}return Mt.create({doc:t.doc,selection:L.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let e=tt.resolve(t.extensions||[],new Map),i=t.doc instanceof n?t.doc:n.of((t.doc||"").split(e.staticFacet(Mt.lineSeparator)||k)),s=t.selection?t.selection instanceof L?t.selection:L.single(t.selection.anchor,t.selection.head):L.single(0);return N(s,i.length),e.staticFacet(st)||(s=s.asSingle()),new Mt(e,i,s,e.dynamicSlots.map((()=>null)),((t,e)=>e.create(t)),null)}get tabSize(){return this.facet(Mt.tabSize)}get lineBreak(){return this.facet(Mt.lineSeparator)||"\n"}get readOnly(){return this.facet(at)}phrase(t,...e){for(let i of this.facet(Mt.phrases))if(Object.prototype.hasOwnProperty.call(i,t)){t=i[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,((t,i)=>{if("$"==i)return"$";let n=+(i||1);return!n||n>e.length?t:e[n-1]}))),t}languageDataAt(t,e,i=-1){let n=[];for(let s of this.facet(nt))for(let r of s(this,e,i))Object.prototype.hasOwnProperty.call(r,t)&&n.push(r[t]);return n}charCategorizer(t){return At(this.languageDataAt("wordChars",t).join(""))}wordAt(t){let{text:e,from:i,length:n}=this.doc.lineAt(t),s=this.charCategorizer(t),r=t-i,o=t-i;for(;r>0;){let t=m(e,r,!1);if(s(e.slice(t,r))!=xt.Word)break;r=t}for(;o<n;){let t=m(e,o);if(s(e.slice(o,t))!=xt.Word)break;o=t}return r==o?null:L.range(r+i,o+i)}}function Ct(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}Mt.allowMultipleSelections=st,Mt.tabSize=V.define({combine:t=>t.length?t[0]:4}),Mt.lineSeparator=rt,Mt.readOnly=at,Mt.phrases=V.define({compare(t,e){let i=Object.keys(t),n=Object.keys(e);return i.length==n.length&&i.every((i=>t[i]==e[i]))}}),Mt.languageData=nt,Mt.changeFilter=ot,Mt.transactionFilter=ht,Mt.transactionExtender=lt,Q.reconfigure=dt.define();class Ot{eq(t){return this==t}range(t,e=t){return Tt.create(t,e,this)}}Ot.prototype.startSide=Ot.prototype.endSide=0,Ot.prototype.point=!1,Ot.prototype.mapMode=A.TrackDel;class Tt{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new Tt(t,e,i)}}function Dt(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Et{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,h=s[n]-t||(i?this.value[n].endSide:this.value[n].startSide)-e;if(n==r)return h>=0?r:o;h>=0?o=n:r=n+1}}between(t,e,i,n){for(let s=this.findIndex(e,-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 h=0;h<this.value.length;h++){let l,a,c=this.value[h],u=this.from[h]+t,f=this.to[h]+t;if(u==f){let t=e.mapPos(u,c.startSide,c.mapMode);if(null==t)continue;if(l=a=t,c.startSide!=c.endSide&&(a=e.mapPos(u,c.endSide),a<l))continue}else if(l=e.mapPos(u,c.startSide),a=e.mapPos(f,c.endSide),l>a||l==a&&c.startSide>0&&c.endSide<=0)continue;(a-l||c.endSide-c.startSide)<0||(r<0&&(r=l),c.point&&(o=Math.max(o,a-l)),i.push(c),n.push(l-r),s.push(a-r))}return{mapped:i.length?new Et(n,s,i,o):null,pos:r}}}class Rt{constructor(t,e,i,n){this.chunkPos=t,this.chunk=e,this.nextLayer=i,this.maxPoint=n}static create(t,e,i,n){return new Rt(t,e,i,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,r=t.filter;if(0==e.length&&!r)return this;if(i&&(e=e.slice().sort(Dt)),this.isEmpty)return e.length?Rt.of(e):this;let o=new Lt(this,null,-1).goto(0),h=0,l=[],a=new Bt;for(;o.value||h<e.length;)if(h<e.length&&(o.from-e[h].from||o.startSide-e[h].value.startSide)>=0){let t=e[h++];a.addInner(t.from,t.to,t.value)||l.push(t)}else 1==o.rangeIndex&&o.chunkIndex<this.chunk.length&&(h==e.length||this.chunkEnd(o.chunkIndex)<e[h].from)&&(!r||n>this.chunkEnd(o.chunkIndex)||s<this.chunkPos[o.chunkIndex])&&a.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!r||n>o.to||s<o.from||r(o.from,o.to,o.value))&&(a.addInner(o.from,o.to,o.value)||l.push(Tt.create(o.from,o.to,o.value))),o.next());return a.finishInner(this.nextLayer.isEmpty&&!l.length?Rt.empty:this.nextLayer.update({add:l,filter:r,filterFrom:n,filterTo:s}))}map(t){if(t.empty||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],h=t.touchesRange(s,s+o.length);if(!1===h)n=Math.max(n,o.maxPoint),e.push(o),i.push(t.mapPos(s));else if(!0===h){let{mapped:r,pos:h}=o.map(s,t);r&&(n=Math.max(n,r.maxPoint),e.push(r),i.push(h))}}let s=this.nextLayer.map(t);return 0==e.length?s:new Rt(i,e,s||Rt.empty,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 Nt.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return Nt.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)),h=Pt(r,o,i),l=new Vt(r,h,s),a=new Vt(o,h,s);i.iterGaps(((t,e,i)=>Ht(l,t,a,e,i,n))),i.empty&&0==i.length&&Ht(l,0,a,0,0,n)}static eq(t,e,i=0,n){null==n&&(n=999999999);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=Pt(s,r),h=new Vt(s,o,0).goto(i),l=new Vt(r,o,0).goto(i);for(;;){if(h.to!=l.to||!Wt(h.active,l.active)||h.point&&(!l.point||!h.point.eq(l.point)))return!1;if(h.to>n)return!0;h.next(),l.next()}}static spans(t,e,i,n,s=-1){let r=new Vt(t,null,s).goto(e),o=e,h=r.openStart;for(;;){let t=Math.min(r.to,i);if(r.point){let i=r.activeForPoint(r.to),s=r.pointFrom<e?i.length+1:Math.min(i.length,h);n.point(o,t,r.point,i,s,r.pointRank),h=Math.min(r.openEnd(t),i.length)}else t>o&&(n.span(o,t,r.active,h),h=r.openEnd(t));if(r.to>i)return h+(r.point&&r.to>i?1:0);o=r.to,r.next()}}static of(t,e=!1){let i=new Bt;for(let n of t instanceof Tt?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let n=t[i];if(Dt(e,n)>0)return t.slice().sort(Dt);e=n}return t}(t):t)i.add(n.from,n.to,n.value);return i.finish()}}Rt.empty=new Rt([],[],null,-1),Rt.empty.nextLayer=Rt.empty;class Bt{finishChunk(t){this.chunks.push(new Et(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=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(t,e,i){this.addInner(t,e,i)||(this.nextLayer||(this.nextLayer=new Bt)).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(Rt.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=Rt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function Pt(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.touchesRange(e,e+r.chunk[t].length))||s.add(r.chunk[t])}return s}class Lt{constructor(t,e,i,n=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex<this.layer.chunk.length;){let e=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(e)||this.layer.chunkEnd(this.chunkIndex)<t||e.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}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)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=t}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.rank-t.rank||this.to-t.to||this.endSide-t.endSide}}class Nt{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 Lt(r,e,i,s));return 1==n.length?n[0]:new Nt(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--)It(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--)It(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(),It(this.heap,0)}}}function It(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 Vt{constructor(t,e,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Nt.from(t,e,i)}goto(t,e=-1e9){return this.cursor.goto(t,e),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=t,this.endSide=e,this.openStart=-1,this.next(),this}forward(t,e){for(;this.minActive>-1&&(this.activeTo[this.minActive]-t||this.active[this.minActive].endSide-e)<0;)this.removeActive(this.minActive);this.cursor.forward(t,e)}removeActive(t){Ft(this.active,t),Ft(this.activeTo,t),Ft(this.activeRank,t),this.minActive=_t(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:n,rank:s}=this.cursor;for(;e<this.activeRank.length&&this.activeRank[e]<=s;)e++;zt(this.active,e,i),zt(this.activeTo,e,n),zt(this.activeRank,e,s),t&&zt(t,e,this.cursor.from),this.minActive=_t(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>t){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&Ft(i,n)}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 t=this.cursor.value;if(t.point){if(!(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=t,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=t.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(i),this.cursor.next()}}}if(i){this.openStart=0;for(let e=i.length-1;e>=0&&i[e]<t;e--)this.openStart++}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&e.push(this.active[i]);return e.reverse()}openEnd(t){let e=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)e++;return e}}function Ht(t,e,i,n,s,r){t.goto(e),i.goto(n);let o=n+s,h=n,l=n-e;for(;;){let e=t.to+l-i.to||t.endSide-i.endSide,n=e<0?t.to+l:i.to,s=Math.min(n,o);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))&&Wt(t.activeForPoint(t.to),i.activeForPoint(i.to))||r.comparePoint(h,s,t.point,i.point):s>h&&!Wt(t.active,i.active)&&r.compareRange(h,s,t.active,i.active),n>o)break;h=n,e<=0&&t.next(),e>=0&&i.next()}}function Wt(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 Ft(t,e){for(let i=e,n=t.length-1;i<n;i++)t[i]=t[i+1];t.pop()}function zt(t,e,i){for(let n=t.length-1;n>=e;n--)t[n+1]=t[n];t[e]=i}function _t(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}function jt(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=m(t,s));return n}},45539:function(t,e,i){i.a(t,(async function(t,n){try{i.d(e,{Nm:function(){return c},OO:function(){return he},SJ:function(){return $n},l9:function(){return vt},lg:function(){return ue},p:function(){return yt},tk:function(){return Hn},v5:function(){return Un}});var s=i(31948),r=(i(52247),i(71695),i(92745),i(52805),i(61495),i(61893),i(84283),i(19423),i(23669),i(40251),i(69235),i(12385),i(19134),i(32517),i(5740),i(11740),i(92519),i(42179),i(89256),i(24931),i(88463),i(57449),i(19814),i(97003),i(32114),i(46692),i(39527),i(37210),i(92181),i(99790),i(67670),i(41360),i(13334),i(34595),i(36993),i(47021),i(29754)),o=i(16806),h=(i(96318),t([s]));function d(t){let e;return e=11==t.nodeType?t.getSelection?t:t.ownerDocument:t,e.getSelection()}function g(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function p(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function m(t,e){if(!e.anchorNode)return!1;try{return g(t,e.anchorNode)}catch(i){return!1}}function w(t){return 3==t.nodeType?R(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function v(t,e,i,n){return!!i&&(b(t,e,i,n,-1)||b(t,e,i,n,1))}function y(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function b(t,e,i,n,s){for(;;){if(t==i&&e==n)return!0;if(e==(s<0?0:x(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=y(t)+(s<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if(1==(t=t.childNodes[e+(s<0?-1:0)]).nodeType&&"false"==t.contentEditable)return!1;e=s<0?x(t):0}}}function x(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function S(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function k(t){return{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function A(t,e){let i=e.width/t.offsetWidth,n=e.height/t.offsetHeight;return(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.width-t.offsetWidth)<1)&&(i=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.height-t.offsetHeight)<1)&&(n=1),{scaleX:i,scaleY:n}}function M(t,e,i,n,s,r,o,h){let l=t.ownerDocument,a=l.defaultView||window;for(let c=t,u=!1;c&&!u;)if(1==c.nodeType){let t,f=c==l.body,d=1,g=1;if(f)t=k(a);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(u=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let e=c.getBoundingClientRect();({scaleX:d,scaleY:g}=A(c,e)),t={left:e.left,right:e.left+c.clientWidth*d,top:e.top,bottom:e.top+c.clientHeight*g}}let p=0,m=0;if("nearest"==s)e.top<t.top?(m=-(t.top-e.top+o),i>0&&e.bottom>t.bottom+m&&(m=e.bottom-t.bottom+m+o)):e.bottom>t.bottom&&(m=e.bottom-t.bottom+o,i<0&&e.top-m<t.top&&(m=-(t.top+m-e.top+o)));else{let n=e.bottom-e.top,r=t.bottom-t.top;m=("center"==s&&n<=r?e.top+n/2-r/2:"start"==s||"center"==s&&i<0?e.top-o:e.bottom-r+o)-t.top}if("nearest"==n)e.left<t.left?(p=-(t.left-e.left+r),i>0&&e.right>t.right+p&&(p=e.right-t.right+p+r)):e.right>t.right&&(p=e.right-t.right+r,i<0&&e.left<t.left+p&&(p=-(t.left+p-e.left+r)));else{p=("center"==n?e.left+(e.right-e.left)/2-(t.right-t.left)/2:"start"==n==h?e.left-r:e.right-(t.right-t.left)+r)-t.left}if(p||m)if(f)a.scrollBy(p,m);else{let t=0,i=0;if(m){let t=c.scrollTop;c.scrollTop+=m/g,i=(c.scrollTop-t)*g}if(p){let e=c.scrollLeft;c.scrollLeft+=p/d,t=(c.scrollLeft-e)*d}e={left:e.left-t,top:e.top-i,right:e.right-t,bottom:e.bottom-i},t&&Math.abs(t-p)<1&&(n="nearest"),i&&Math.abs(i-m)<1&&(s="nearest")}if(f)break;c=c.assignedSlot||c.parentNode}else{if(11!=c.nodeType)break;c=c.host}}function C(t){let e=t.ownerDocument;for(let i=t.parentNode;i&&i!=e.body;)if(1==i.nodeType){if(i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)return i;i=i.assignedSlot||i.parentNode}else{if(11!=i.nodeType)break;i=i.host}return null}s=(h.then?(await h)():h)[0];class O{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:i}=t;this.set(e,Math.min(t.anchorOffset,e?x(e):0),i,Math.min(t.focusOffset,i?x(i):0))}set(t,e,i,n){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=n}}let T,D=null;function E(t){if(t.setActive)return t.setActive();if(D)return t.focus(D);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==D?{get preventScroll(){return D={preventScroll:!0},!0}}:void 0),!D){D=!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 R(t,e,i=e){let n=T||(T=document.createRange());return n.setEnd(t,i),n.setStart(t,e),n}function B(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 P(t){for(;t;){if(t&&(9==t.nodeType||11==t.nodeType&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function L(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}function N(t,e){let i=e.focusNode,n=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=n)return!1;for(n=Math.min(n,x(i));;)if(n){if(1!=i.nodeType)return!1;let t=i.childNodes[n-1];"false"==t.contentEditable?n--:(i=t,n=x(i))}else{if(i==t)return!0;n=y(i),i=i.parentNode}}function I(t){return t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}class V{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new V(t.parentNode,y(t),e)}static after(t,e){return new V(t.parentNode,y(t)+1,e)}}const H=[];class W{constructor(){this.parent=null,this.dom=null,this.flags=2}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}sync(t,e){if(2&this.flags){let i,n=this.dom,s=null;for(let r of this.children){if(7&r.flags){if(!r.dom&&(i=s?s.nextSibling:n.firstChild)){let t=W.get(i);(!t||!t.parent&&t.canReuseDOM(r))&&r.reuseDOM(i)}r.sync(t,e),r.flags&=-8}if(i=s?s.nextSibling:n.firstChild,e&&!e.written&&e.node==n&&i!=r.dom&&(e.written=!0),r.dom.parentNode==n)for(;i&&i!=r.dom;)i=F(i);else n.insertBefore(r.dom,i);s=r.dom}for(i=s?s.nextSibling:n.firstChild,i&&e&&e.node==n&&(e.written=!0);i;)i=F(i)}else if(1&this.flags)for(let i of this.children)7&i.flags&&(i.sync(t,e),i.flags&=-8)}reuseDOM(t){}localPosFromDOM(t,e){let i;if(t==this.dom)i=this.dom.childNodes[e];else{let n=0==x(t)?0:0==e?-1:1;for(;;){let e=t.parentNode;if(e==this.dom)break;0==n&&e.firstChild!=e.lastChild&&(n=t==e.firstChild?-1:1),t=e}i=n<0?t:t.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!W.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 h=0,l=i,a=i;h<this.children.length;h++){let i=this.children[h],c=l+i.length;if(l<t&&c>e)return i.domBoundsAround(t,e,l);if(c>=t&&-1==n&&(n=h,s=l),l>e&&i.dom.parentNode==this.dom){r=h,o=a;break}a=c,l=c+i.breakAfter}return{from:s,to:o<0?i+this.length:o,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:r<this.children.length&&r>=0?this.children[r].dom:null}}markDirty(t=!1){this.flags|=2,this.markParentsDirty(t)}markParentsDirty(t){for(let e=this.parent;e;e=e.parent){if(t&&(e.flags|=2),1&e.flags)return;e.flags|=1,t=!1}}setParent(t){this.parent!=t&&(this.parent=t,7&this.flags&&this.markParentsDirty(!0))}setDOM(t){this.dom!=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=H){this.markDirty();for(let n=t;n<e;n++){let t=this.children[n];t.parent==this&&i.indexOf(t)<0&&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 z(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}get isWidget(){return!1}get isHidden(){return!1}merge(t,e,i,n,s,r){return!1}become(t){return!1}canReuseDOM(t){return t.constructor==this.constructor&&!(8&(this.flags|t.flags))}getSide(){return 0}destroy(){for(let t of this.children)t.parent==this&&t.destroy();this.parent=null}}function F(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}W.prototype.breakAfter=0;class z{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 _(t,e,i,n,s,r,o,h,l){let{children:a}=t,c=a.length?a[e]:null,u=r.length?r[r.length-1]:null,f=u?u.breakAfter:o;if(!(e==n&&c&&!o&&!f&&r.length<2&&c.merge(i,s,r.length?u:null,0==i,h,l))){if(n<a.length){let t=a[n];t&&(s<t.length||t.breakAfter&&(null==u?void 0:u.breakAfter))?(e==n&&(t=t.split(s),s=0),!f&&u&&t.merge(0,s,u,!0,0,l)?r[r.length-1]=t:((s||t.children.length&&!t.children[0].length)&&t.merge(0,s,null,!1,0,l),r.push(t))):(null==t?void 0:t.breakAfter)&&(u?u.breakAfter=1:o=1),n++}for(c&&(c.breakAfter=o,i>0&&(!o&&r.length&&c.merge(i,c.length,r[0],!1,h,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,h,0),e++));e<n&&r.length;)if(a[n-1].become(r[r.length-1]))n--,r.pop(),l=r.length?0:h;else{if(!a[e].become(r[0]))break;e++,r.shift(),h=r.length?0:l}!r.length&&e&&n<a.length&&!a[e-1].breakAfter&&a[n].merge(0,0,a[e-1],!1,h,l)&&e--,(e<n||r.length)&&t.replaceChildren(e,n,r)}}function j(t,e,i,n,s,r){let o=t.childCursor(),{i:h,off:l}=o.findPos(i,1),{i:a,off:c}=o.findPos(e,-1),u=e-i;for(let f of n)u+=f.length;t.length+=u,_(t,a,c,h,l,n,0,s,r)}let q="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},$="undefined"!=typeof document?document:{documentElement:{style:{}}};const K=/Edge\/(\d+)/.exec(q.userAgent),J=/MSIE \d/.test(q.userAgent),G=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(q.userAgent),U=!!(J||G||K),X=!U&&/gecko\/(\d+)/i.test(q.userAgent),Y=!U&&/Chrome\/(\d+)/.exec(q.userAgent),Q="webkitFontSmoothing"in $.documentElement.style,Z=!U&&/Apple Computer/.test(q.vendor),tt=Z&&(/Mobile\/\w+/.test(q.userAgent)||q.maxTouchPoints>2);var l={mac:tt||/Mac/.test(q.platform),windows:/Win/.test(q.platform),linux:/Linux|X11/.test(q.platform),ie:U,ie_version:J?$.documentMode||6:G?+G[1]:K?+K[1]:0,gecko:X,gecko_version:X?+(/Firefox\/(\d+)/.exec(q.userAgent)||[0,0])[1]:0,chrome:!!Y,chrome_version:Y?+Y[1]:0,ios:tt,android:/Android\b/.test(q.userAgent),webkit:Q,safari:Z,webkit_version:Q?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:null!=$.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};const et=256;class it extends W{constructor(t){super(),this.text=t}get length(){return this.text.length}createDOM(t){this.setDOM(t||document.createTextNode(this.text))}sync(t,e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(t){3==t.nodeType&&this.createDOM(t)}merge(t,e,i){return!(8&this.flags||i&&(!(i instanceof it)||this.length-(e-t)+i.length>et||8&i.flags))&&(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new it(this.text.slice(t));return this.text=this.text.slice(0,t),this.markDirty(),e.flags|=8&this.flags,e}localPosFromDOM(t,e){return t==this.dom?e:e?this.text.length:0}domAtPos(t){return new V(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 st(this.dom,t,e)}}class nt extends W{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(L(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}canReuseDOM(t){return super.canReuseDOM(t)&&!(8&(this.flags|t.flags))}reuseDOM(t){t.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(t),this.flags|=6)}sync(t,e){this.dom?4&this.flags&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(t,e)}merge(t,e,i,n,s,r){return(!i||!(!(i instanceof nt&&i.mark.eq(this.mark))||t&&s<=0||e<this.length&&r<=0))&&(j(this,t,e,i?i.children.slice():[],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 nt(this.mark,e,r)}domAtPos(t){return ht(this,t)}coordsAt(t,e){return at(this,t,e)}}function st(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?l.chrome||l.gecko||(e?(s--,o=1):r<n&&(r++,o=-1)):i<0?s--:r<n&&r++;let h=R(t,s,r).getClientRects();if(!h.length)return null;let a=h[(o?o<0:i>=0)?0:h.length-1];return l.safari&&!o&&0==a.width&&(a=Array.prototype.find.call(h,(t=>t.width))||a),o?S(a,o<0):a||null}class rt extends W{static create(t,e,i){return new rt(t,e,i)}constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i,this.prevWidget=null}split(t){let e=rt.create(this.widget,this.length-t,this.side);return this.length-=t,e}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(t,e,i,n,s,r){return!(i&&(!(i instanceof rt&&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 instanceof rt&&t.side==this.side&&this.widget.constructor==t.widget.constructor&&(this.widget.compare(t.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get overrideDOMText(){if(0==this.length)return r.xv.empty;let t=this;for(;t.parent;)t=t.parent;let{view:e}=t,i=e&&e.state.doc,n=this.posAtStart;return i?i.slice(n,n+this.length):r.xv.empty}domAtPos(t){return(this.length?0==t:this.side>0)?V.before(this.dom):V.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let i=this.widget.coordsAt(this.dom,t,e);if(i)return i;let n=this.dom.getClientRects(),s=null;if(!n.length)return null;let r=this.side?this.side<0:t>0;for(let o=r?n.length-1:0;s=n[o],!(t>0?0==o:o==n.length-1||s.top<s.bottom);o+=r?-1:1);return S(s,!r)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class ot extends W{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof ot&&t.side==this.side}split(){return new ot(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 this.side>0?V.before(this.dom):V.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return r.xv.empty}get isHidden(){return!0}}function ht(t,e){let i=t.dom,{children:n}=t,s=0;for(let r=0;s<n.length;s++){let t=n[s],o=r+t.length;if(!(o==r&&t.getSide()<=0)){if(e>r&&e<o&&t.dom.parentNode==i)return t.domAtPos(e-r);if(e<=r)break;r=o}}for(let r=s;r>0;r--){let t=n[r-1];if(t.dom.parentNode==i)return t.domAtPos(t.length)}for(let r=s;r<n.length;r++){let t=n[r];if(t.dom.parentNode==i)return t.domAtPos(0)}return new V(i,0)}function lt(t,e,i){let n,{children:s}=t;i>0&&e instanceof nt&&s.length&&(n=s[s.length-1])instanceof nt&&n.mark.eq(e.mark)?lt(n,e.children[0],i-1):(s.push(e),e.setParent(t)),t.length+=e.length}function at(t,e,i){let n=null,s=-1,r=null,o=-1;!function t(e,h){for(let l=0,a=0;l<e.children.length&&a<=h;l++){let c=e.children[l],u=a+c.length;u>=h&&(c.children.length?t(c,h-a):(!r||r.isHidden&&i>0)&&(u>h||a==u&&c.getSide()>0)?(r=c,o=h-a):(a<h||a==u&&c.getSide()<0&&!c.isHidden)&&(n=c,s=h-a)),a=u}}(t,e);let h=(i<0?n:r)||n||r;return h?h.coordsAt(Math.max(0,h==n?s:o),i):ct(t)}function ct(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=w(e);return i[i.length-1]||null}function ut(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}it.prototype.children=rt.prototype.children=ot.prototype.children=H;const ft=Object.create(null);function dt(t,e,i){if(t==e)return!0;t||(t=ft),e||(e=ft);let n=Object.keys(t),s=Object.keys(e);if(n.length-(i&&n.indexOf(i)>-1?1:0)!=s.length-(i&&s.indexOf(i)>-1?1:0))return!1;for(let r of n)if(r!=i&&(-1==s.indexOf(r)||t[r]!==e[r]))return!1;return!0}function gt(t,e,i){let n=!1;if(e)for(let s in e)i&&s in i||(n=!0,"style"==s?t.style.cssText="":t.removeAttribute(s));if(i)for(let s in i)e&&e[s]==i[s]||(n=!0,"style"==s?t.style.cssText=i[s]:t.setAttribute(s,i[s]));return n}function pt(t){let e=Object.create(null);for(let i=0;i<t.attributes.length;i++){let n=t.attributes[i];e[n.name]=n.value}return e}class mt extends W{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 mt))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),j(this,t,e,i?i.children.slice():[],s,r),!0}split(t){let e=new mt;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);for(;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&&(this.markDirty(),t.setDOM(this.dom),t.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(t){dt(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){lt(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=ut(e,this.attrs||{})),i&&(this.attrs=ut({class:i},this.attrs||{}))}domAtPos(t){return ht(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.flags|=6)}sync(t,e){var i;this.dom?4&this.flags&&(L(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&&(gt(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t,e);let n=this.dom.lastChild;for(;n&&W.get(n)instanceof nt;)n=n.lastChild;if(!(n&&this.length&&("BR"==n.nodeName||0!=(null===(i=W.get(n))||void 0===i?void 0:i.isEditable)||l.ios&&this.children.some((t=>t instanceof it))))){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,e=0;for(let i of this.children){if(!(i instanceof it)||/[^ -~]/.test(i.text))return null;let n=w(i.dom);if(1!=n.length)return null;e+=n[0].width,t=n[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(t,e){let i=at(this,t,e);if(!this.children.length&&i&&this.parent){let{heightOracle:t}=this.parent.view.viewState,e=i.bottom-i.top;if(Math.abs(e-t.lineHeight)<2&&t.textHeight<e){let n=(e-t.textHeight)/2;return{top:i.top+n,bottom:i.bottom-n,left:i.left,right:i.left}}}return i}become(t){return!1}covers(){return!0}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 mt)return s;if(r>e)break}n=r+s.breakAfter}return null}}class wt extends W{constructor(t,e,i){super(),this.widget=t,this.length=e,this.deco=i,this.breakAfter=0,this.prevWidget=null}merge(t,e,i,n,s,r){return!(i&&(!(i instanceof wt&&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?V.before(this.dom):V.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new wt(this.widget,e,this.deco);return i.breakAfter=this.breakAfter,i}get children(){return H}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):r.xv.empty}domBoundsAround(){return null}become(t){return t instanceof wt&&t.widget.constructor==this.widget.constructor&&(t.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,this.deco=t.deco,this.breakAfter=t.breakAfter,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(t,e){return this.widget.coordsAt(this.dom,t,e)}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(t){let{startSide:e,endSide:i}=this.deco;return e!=i&&(t<0?e<0:i>0)}}class vt{eq(t){return!1}updateDOM(t,e){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(t){return!0}coordsAt(t,e,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(t){}}var a=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(a||(a={}));class yt extends r.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 bt(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),i=!!t.block;return e+=i&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8,new St(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}=kt(t,n);e=(s?n?-3e8:-1:5e8)-1,i=1+(r?n?2e8:1:-6e8)}return new St(t,e,i,n,t.widget||null,!0)}static line(t){return new xt(t)}static set(t,e=!1){return r.Xs.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}yt.none=r.Xs.empty;class bt extends yt{constructor(t){let{start:e,end:i}=kt(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){var e,i;return this==t||t instanceof bt&&this.tagName==t.tagName&&(this.class||(null===(e=this.attrs)||void 0===e?void 0:e.class))==(t.class||(null===(i=t.attrs)||void 0===i?void 0:i.class))&&dt(this.attrs,t.attrs,"class")}range(t,e=t){if(t>=e)throw new RangeError("Mark decorations may not be empty");return super.range(t,e)}}bt.prototype.point=!1;class xt extends yt{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof xt&&this.spec.class==t.spec.class&&dt(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)}}xt.prototype.mapMode=r.gc.TrackBefore,xt.prototype.point=!0;class St extends yt{constructor(t,e,i,n,s,o){super(e,i,s,t),this.block=n,this.isReplace=o,this.mapMode=n?e<=0?r.gc.TrackBefore:r.gc.TrackAfter:r.gc.TrackDel}get type(){return this.startSide!=this.endSide?a.WidgetRange:this.startSide<=0?a.WidgetBefore:a.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof St&&(e=this.widget,i=t.widget,e==i||!!(e&&i&&e.compare(i)))&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide;var e,i}range(t,e=t){if(this.isReplace&&(t>e||t==e&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}}function kt(t,e=!1){let{inclusiveStart:i,inclusiveEnd:n}=t;return null==i&&(i=t.inclusive),null==n&&(n=t.inclusive),{start:null!=i?i:e,end:null!=n?n:e}}function At(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)}St.prototype.point=!0;class Mt{constructor(t,e,i,n){this.doc=t,this.pos=e,this.end=i,this.disallowBlockEffectsFor=n,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],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 wt&&t.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new mt),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(Ct(new ot(-1),t),t.length),this.pendingBuffer=0)}addBlockWidget(t){this.flushBuffer(),this.curLine=null,this.content.push(t)}finish(t){this.pendingBuffer&&t<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||t&&this.content.length&&this.content[this.content.length-1]instanceof wt||this.getLine()}buildText(t,e,i){for(;t>0;){if(this.textOff==this.text.length){let{value:e,lineBreak:i,done:n}=this.cursor.next(this.skip);if(this.skip=0,n)throw new Error("Ran out of text content when drawing inline views");if(i){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,t--;continue}this.text=e,this.textOff=0}let n=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(e.length-i)),this.getLine().append(Ct(new it(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,r){if(this.disallowBlockEffectsFor[r]&&i instanceof St){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")}let o=e-t;if(i instanceof St)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new wt(i.widget||new Ot("div"),o,i));else{let r=rt.create(i.widget||new Ot("span"),o,o?0:i.startSide),h=this.atCursorPos&&!r.isEditable&&s<=n.length&&(t<e||i.startSide>0),l=!r.isEditable&&(t<e||s>n.length||i.startSide<=0),a=this.getLine();2!=this.pendingBuffer||h||r.isEditable||(this.pendingBuffer=0),this.flushBuffer(n),h&&(a.append(Ct(new ot(1),n),s),s=n.length+Math.max(0,s-n.length)),a.append(Ct(r,n),s),this.atCursorPos=l,this.pendingBuffer=l?t<e||s>n.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=n.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);o&&(this.textOff+o<=this.text.length?this.textOff+=o:(this.skip+=o-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=e),this.openStart<0&&(this.openStart=s)}static build(t,e,i,n,s){let o=new Mt(t,e,i,s);return o.openEnd=r.Xs.spans(n,e,i,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}}function Ct(t,e){for(let i of e)t=new nt(i,[t],t.length);return t}class Ot extends vt{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}var c=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(c||(c={}));const Tt=c.LTR,Dt=c.RTL;function Et(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}const Rt=Et("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Bt=Et("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Pt=Object.create(null),Lt=[];for(let rs of["()","[]","{}"]){let os=rs.charCodeAt(0),hs=rs.charCodeAt(1);Pt[os]=hs,Pt[hs]=-os}function Nt(t){return t<=247?Rt[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?Bt[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8204?256:64336<=t&&t<=65023?4:1}const It=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Vt{get dir(){return this.level%2?Dt:Tt}constructor(t,e,i){this.from=t,this.to=e,this.level=i}side(t,e){return this.dir==e==t?this.to:this.from}forward(t,e){return t==(this.dir==e)}static find(t,e,i,n){let 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}}function Ht(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.direction!=s.direction||!Ht(n.inner,s.inner))return!1}return!0}const Wt=[];function Ft(t,e,i,n,s){for(let r=0;r<=n.length;r++){let o=r?n[r-1].to:e,h=r<n.length?n[r].from:i,l=r?256:s;for(let e=o,i=l,n=l;e<h;e++){let s=Nt(t.charCodeAt(e));512==s?s=i:8==s&&4==n&&(s=16),Wt[e]=4==s?2:s,7&s&&(n=s),i=s}for(let t=o,e=l,n=l;t<h;t++){let s=Wt[t];if(128==s)t<h-1&&e==Wt[t+1]&&24&e?s=Wt[t]=e:Wt[t]=256;else if(64==s){let s=t+1;for(;s<h&&64==Wt[s];)s++;let r=t&&8==e||s<i&&8==Wt[s]?1==n?1:8:256;for(let e=t;e<s;e++)Wt[e]=r;t=s-1}else 8==s&&1==n&&(Wt[t]=1);e=s,7&s&&(n=s)}}}function zt(t,e,i,n,s){let r=1==s?2:1;for(let o=0,h=0,l=0;o<=n.length;o++){let a=o?n[o-1].to:e,c=o<n.length?n[o].from:i;for(let e,i,n,o=a;o<c;o++)if(i=Pt[e=t.charCodeAt(o)])if(i<0){for(let t=h-3;t>=0;t-=3)if(Lt[t+1]==-i){let e=Lt[t+2],i=2&e?s:4&e?1&e?r:s:0;i&&(Wt[o]=Wt[Lt[t]]=i),h=t;break}}else{if(189==Lt.length)break;Lt[h++]=o,Lt[h++]=e,Lt[h++]=l}else if(2==(n=Wt[o])||1==n){let t=n==s;l=t?0:1;for(let e=h-3;e>=0;e-=3){let i=Lt[e+2];if(2&i)break;if(t)Lt[e+2]|=2;else{if(4&i)break;Lt[e+2]|=4}}}}}function _t(t,e,i,n){for(let s=0,r=n;s<=i.length;s++){let o=s?i[s-1].to:t,h=s<i.length?i[s].from:e;for(let l=o;l<h;){let o=Wt[l];if(256==o){let o=l+1;for(;;)if(o==h){if(s==i.length)break;o=i[s++].to,h=s<i.length?i[s].from:e}else{if(256!=Wt[o])break;o++}let a=1==r,c=a==(1==(o<e?Wt[o]:n))?a?1:2:n;for(let e=o,n=s,r=n?i[n-1].to:t;e>l;)e==r&&(e=i[--n].from,r=n?i[n-1].to:t),Wt[--e]=c;l=o}else r=o,l++}}}function jt(t,e,i,n,s,r,o){let h=n%2?2:1;if(n%2==s%2)for(let l=e,a=0;l<i;){let e=!0,c=!1;if(a==r.length||l<r[a].from){let t=Wt[l];t!=h&&(e=!1,c=16==t)}let u=e||1!=h?null:[],f=e?n:n+1,d=l;t:for(;;)if(a<r.length&&d==r[a].from){if(c)break t;let g=r[a];if(!e)for(let t=g.to,e=a+1;;){if(t==i)break t;if(!(e<r.length&&r[e].from==t)){if(Wt[t]==h)break t;break}t=r[e++].to}if(a++,u)u.push(g);else{g.from>l&&o.push(new Vt(l,g.from,f)),qt(t,g.direction==Tt!=!(f%2)?n+1:n,s,g.inner,g.from,g.to,o),l=g.to}d=g.to}else{if(d==i||(e?Wt[d]!=h:Wt[d]==h))break;d++}u?jt(t,l,d,n+1,s,u,o):l<d&&o.push(new Vt(l,d,f)),l=d}else for(let l=i,a=r.length;l>e;){let i=!0,c=!1;if(!a||l>r[a-1].to){let t=Wt[l-1];t!=h&&(i=!1,c=16==t)}let u=i||1!=h?null:[],f=i?n:n+1,d=l;t:for(;;)if(a&&d==r[a-1].to){if(c)break t;let g=r[--a];if(!i)for(let t=g.from,i=a;;){if(t==e)break t;if(!i||r[i-1].to!=t){if(Wt[t-1]==h)break t;break}t=r[--i].from}if(u)u.push(g);else{g.to<l&&o.push(new Vt(g.to,l,f)),qt(t,g.direction==Tt!=!(f%2)?n+1:n,s,g.inner,g.from,g.to,o),l=g.from}d=g.from}else{if(d==e||(i?Wt[d-1]!=h:Wt[d-1]==h))break;d--}u?jt(t,d,l,n+1,s,u,o):d<l&&o.push(new Vt(d,l,f)),l=d}}function qt(t,e,i,n,s,r,o){let h=e%2?2:1;Ft(t,s,r,n,h),zt(t,s,r,n,h),_t(s,r,n,h),jt(t,s,r,e,i,n,o)}function $t(t,e,i){if(!t)return[new Vt(0,0,e==Dt?1:0)];if(e==Tt&&!i.length&&!It.test(t))return Kt(t.length);if(i.length)for(;t.length>Wt.length;)Wt[Wt.length]=256;let n=[],s=e==Tt?0:1;return qt(t,s,s,i,0,t.length,n),n}function Kt(t){return[new Vt(0,t,0)]}let Jt="";function Gt(t,e,i,n,s){var o;let h=n.head-t.from,l=Vt.find(e,h,null!==(o=n.bidiLevel)&&void 0!==o?o:-1,n.assoc),a=e[l],c=a.side(s,i);if(h==c){let t=l+=s?1:-1;if(t<0||t>=e.length)return null;a=e[l=t],h=a.side(!s,i),c=a.side(s,i)}let u=(0,r.cp)(t.text,h,a.forward(s,i));(u<a.from||u>a.to)&&(u=c),Jt=t.text.slice(Math.min(h,u),Math.max(h,u));let f=l==(s?e.length-1:0)?null:e[l+(s?1:-1)];return f&&u==c&&f.level+(s?0:1)<a.level?r.jT.cursor(f.side(!s,i)+t.from,f.forward(s,i)?1:-1,f.level):r.jT.cursor(u+t.from,a.forward(s,i)?-1:1,a.level)}function Ut(t,e,i){for(let n=e;n<i;n++){let e=Nt(t.charCodeAt(n));if(1==e)return Tt;if(2==e||4==e)return Dt}return Tt}const Xt=r.r$.define(),Yt=r.r$.define(),Qt=r.r$.define(),Zt=r.r$.define(),te=r.r$.define(),ee=r.r$.define(),ie=r.r$.define(),ne=r.r$.define({combine:t=>t.some((t=>t))}),se=r.r$.define({combine:t=>t.some((t=>t))});class re{constructor(t,e="nearest",i="nearest",n=5,s=5,r=!1){this.range=t,this.y=e,this.x=i,this.yMargin=n,this.xMargin=s,this.isSnapshot=r}map(t){return t.empty?this:new re(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new re(r.jT.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const oe=r.Py.define({map:(t,e)=>t.map(e)});function he(t,e,i){let n=t.facet(Zt);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 le=r.r$.define({combine:t=>!t.length||t[0]});let ae=0;const ce=r.r$.define();class ue{constructor(t,e,i,n,s){this.id=t,this.create=e,this.domEventHandlers=i,this.domEventObservers=n,this.extension=s(this)}static define(t,e){const{eventHandlers:i,eventObservers:n,provide:s,decorations:r}=e||{};return new ue(ae++,t,i,n,(t=>{let e=[ce.of(t)];return r&&e.push(pe.of((e=>{let i=e.plugin(t);return i?r(i):yt.none}))),s&&e.push(s(t)),e}))}static fromClass(t,e){return ue.define((e=>new t(e)),e)}}class fe{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}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(he(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){he(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){he(t.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const de=r.r$.define(),ge=r.r$.define(),pe=r.r$.define(),me=r.r$.define(),we=r.r$.define(),ve=r.r$.define();function ye(t,e){let i=t.state.facet(ve);if(!i.length)return i;let n=i.map((e=>e instanceof Function?e(t):e)),s=[];return r.Xs.spans(n,e.from,e.to,{point(){},span(t,i,n,r){let o=t-e.from,h=i-e.from,l=s;for(let s=n.length-1;s>=0;s--,r--){let t,i=n[s].spec.bidiIsolate;if(null==i&&(i=Ut(e.text,o,h)),r>0&&l.length&&(t=l[l.length-1]).to==o&&t.direction==i)t.to=h,l=t.inner;else{let t={from:o,to:h,direction:i,inner:[]};l.push(t),l=t.inner}}}}),s}const be=r.r$.define();function xe(t){let e=0,i=0,n=0,s=0;for(let r of t.state.facet(be)){let o=r(t);o&&(null!=o.left&&(e=Math.max(e,o.left)),null!=o.right&&(i=Math.max(i,o.right)),null!=o.top&&(n=Math.max(n,o.top)),null!=o.bottom&&(s=Math.max(s,o.bottom)))}return{left:e,right:i,top:n,bottom:s}}const Se=r.r$.define();class ke{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new ke(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let n=t[e-1];if(!(n.fromA>i.toA)){if(n.toA<i.fromA)break;i=i.join(n),t.splice(e-1,1)}}return t.splice(e,0,i),t}static extendWithRanges(t,e){if(0==e.length)return t;let i=[];for(let n=0,s=0,r=0,o=0;;n++){let h=n==t.length?null:t[n],l=r-o,a=h?h.fromB:1e9;for(;s<e.length&&e[s]<a;){let t=e[s],n=e[s+1],r=Math.max(o,t),h=Math.min(a,n);if(r<=h&&new ke(r+l,h+l,r,h).addToSet(i),n>a)break;s+=2}if(!h)return i;new ke(h.fromA,h.toA,h.fromB,h.toB).addToSet(i),r=h.toA,o=h.toB}}}class Ae{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=r.as.empty(this.startState.doc.length);for(let s of i)this.changes=this.changes.compose(s.changes);let n=[];this.changes.iterChangedRanges(((t,e,i,s)=>n.push(new ke(t,e,i,s)))),this.changedRanges=n}static create(t,e,i){return new Ae(t,e,i)}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}}class Me extends W{get length(){return this.view.state.doc.length}constructor(t){super(),this.view=t,this.decorations=[],this.dynamicDecorationMap=[],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,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 mt],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new ke(0,0,0,t.state.doc.length)],0,null)}update(t){var e;let i=t.changedRanges;this.minWidth>0&&i.length&&(i.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);let n=-1;this.view.inputState.composing>=0&&((null===(e=this.domChanged)||void 0===e?void 0:e.newSel)?n=this.domChanged.newSel.head:Le(t.changes,this.hasComposition)||t.selectionSet||(n=t.state.selection.main.head));let s=n>-1?Te(this.view,t.changes,n):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:e,to:n}=this.hasComposition;i=new ke(e,n,t.changes.mapPos(e,-1),t.changes.mapPos(n,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(l.ie||l.chrome)&&!s&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let r=Be(this.decorations,this.updateDeco(),t.changes);return i=ke.extendWithRanges(i,r),!!(7&this.flags||0!=i.length)&&(this.updateInner(i,t.startState.doc.length,s),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e,i){this.view.viewState.mustMeasureContent=!0,this.updateChildren(t,e,i);let{observer:n}=this.view;n.ignore((()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let t=l.chrome||l.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,t),this.flags&=-8,t&&(t.written||n.selectionRange.focusNode!=t.node)&&(this.forceSelection=!0),this.dom.style.height=""})),this.markedForComposition.forEach((t=>t.flags&=-9));let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let r of this.children)r instanceof wt&&r.widget instanceof Ce&&s.push(r.dom);n.updateGaps(s)}updateChildren(t,e,i){let n=i?i.range.addToSet(t.slice()):t,s=this.childCursor(e);for(let r=n.length-1;;r--){let t=r>=0?n[r]:null;if(!t)break;let e,o,h,l,{fromA:a,toA:c,fromB:u,toB:f}=t;if(i&&i.range.fromB<f&&i.range.toB>u){let t=Mt.build(this.view.state.doc,u,i.range.fromB,this.decorations,this.dynamicDecorationMap),n=Mt.build(this.view.state.doc,i.range.toB,f,this.decorations,this.dynamicDecorationMap);o=t.breakAtStart,h=t.openStart,l=n.openEnd;let s=this.compositionView(i);n.breakAtStart?s.breakAfter=1:n.content.length&&s.merge(s.length,s.length,n.content[0],!1,n.openStart,0)&&(s.breakAfter=n.content[0].breakAfter,n.content.shift()),t.content.length&&s.merge(0,0,t.content[t.content.length-1],!0,0,t.openEnd)&&t.content.pop(),e=t.content.concat(s).concat(n.content)}else({content:e,breakAtStart:o,openStart:h,openEnd:l}=Mt.build(this.view.state.doc,u,f,this.decorations,this.dynamicDecorationMap));let{i:d,off:g}=s.findPos(c,1),{i:p,off:m}=s.findPos(a,-1);_(this,p,m,d,g,e,o,h,l)}i&&this.fixCompositionDOM(i)}compositionView(t){let e=new it(t.text.nodeValue);e.flags|=8;for(let{deco:n}of t.marks)e=new nt(n,[e],e.length);let i=new mt;return i.append(e,0),i}fixCompositionDOM(t){let e=(t,e)=>{e.flags|=8|(e.children.some((t=>7&t.flags))?1:0),this.markedForComposition.add(e);let i=W.get(t);i&&i!=e&&(i.dom=null),e.setDOM(t)},i=this.childPos(t.range.fromB,1),n=this.children[i.i];e(t.line,n);for(let s=t.marks.length-1;s>=-1;s--)i=n.childPos(i.off,1),n=n.children[i.i],e(s>=0?t.marks[s].node:t.text,n)}updateSelection(t=!1,e=!1){!t&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let i=this.view.root.activeElement,n=i==this.dom,s=!n&&m(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(n||e||s))return;let r=this.forceSelection;this.forceSelection=!1;let o=this.view.state.selection.main,h=this.moveToLine(this.domAtPos(o.anchor)),a=o.empty?h:this.moveToLine(this.domAtPos(o.head));if(l.gecko&&o.empty&&!this.hasComposition&&(1==(c=h).node.nodeType&&c.node.firstChild&&(0==c.offset||"false"==c.node.childNodes[c.offset-1].contentEditable)&&(c.offset==c.node.childNodes.length||"false"==c.node.childNodes[c.offset].contentEditable))){let t=document.createTextNode("");this.view.observer.ignore((()=>h.node.insertBefore(t,h.node.childNodes[h.offset]||null))),h=a=new V(t,0),r=!0}var c;let u=this.view.observer.selectionRange;!r&&u.focusNode&&(v(h.node,h.offset,u.anchorNode,u.anchorOffset)&&v(a.node,a.offset,u.focusNode,u.focusOffset)||this.suppressWidgetCursorChange(u,o))||(this.view.observer.ignore((()=>{l.android&&l.chrome&&this.dom.contains(u.focusNode)&&Pe(u.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let t=d(this.view.root);if(t)if(o.empty){if(l.gecko){let t=Ee(h.node,h.offset);if(t&&3!=t){let e=De(h.node,h.offset,1==t?1:-1);e&&(h=new V(e.node,e.offset))}}t.collapse(h.node,h.offset),null!=o.bidiLevel&&void 0!==t.caretBidiLevel&&(t.caretBidiLevel=o.bidiLevel)}else if(t.extend){t.collapse(h.node,h.offset);try{t.extend(a.node,a.offset)}catch(e){}}else{let e=document.createRange();o.anchor>o.head&&([h,a]=[a,h]),e.setEnd(a.node,a.offset),e.setStart(h.node,h.offset),t.removeAllRanges(),t.addRange(e)}else;s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())})),this.view.observer.setSelectionRange(h,a)),this.impreciseAnchor=h.precise?null:new V(u.anchorNode,u.anchorOffset),this.impreciseHead=a.precise?null:new V(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&v(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)&&this.posFromDOM(t.focusNode,t.focusOffset)==e.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:t}=this,e=t.state.selection.main,i=d(t.root),{anchorNode:n,anchorOffset:s}=t.observer.selectionRange;if(!(i&&e.empty&&e.assoc&&i.modify))return;let r=mt.find(this,e.head);if(!r)return;let o=r.posAtStart;if(e.head==o||e.head==o+r.length)return;let h=this.coordsAt(e.head,-1),l=this.coordsAt(e.head,1);if(!h||!l||h.bottom>l.top)return;let a=this.domAtPos(e.head+e.assoc);i.collapse(a.node,a.offset),i.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let c=t.observer.selectionRange;t.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=e.from&&i.collapse(n,s)}moveToLine(t){let e,i=this.dom;if(t.node!=i)return t;for(let n=t.offset;!e&&n<i.childNodes.length;n++){let t=W.get(i.childNodes[n]);t instanceof mt&&(e=t.domAtPos(0))}for(let n=t.offset-1;!e&&n>=0;n--){let t=W.get(i.childNodes[n]);t instanceof mt&&(e=t.domAtPos(t.length))}return e?new V(e.node,e.offset,!0):t}nearest(t){for(let e=t;e;){let t=W.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 mt)break;e++,i=0}return this.children[e].domAtPos(i)}coordsAt(t,e){let i=null,n=0;for(let s=this.length,r=this.children.length-1;r>=0;r--){let o=this.children[r],h=s-o.breakAfter,l=h-o.length;if(h<t)break;l<=t&&(l<t||o.covers(-1))&&(h>t||o.covers(1))&&(!i||o instanceof mt&&!(i instanceof mt&&e>=0))&&(i=o,n=l),s=l}return i?i.coordsAt(t-n,e):null}coordsForChar(t){let{i:e,off:i}=this.childPos(t,1),n=this.children[e];if(!(n instanceof mt))return null;for(;n.children.length;){let{i:t,off:e}=n.childPos(i,1);for(;;t++){if(t==n.children.length)return null;if((n=n.children[t]).length)break}i=e}if(!(n instanceof it))return null;let s=(0,r.cp)(n.text,i);if(s==i)return null;let o=R(n.dom,i,s).getClientRects();for(let r=0;r<o.length;r++){let t=o[r];if(r==o.length-1||t.top<t.bottom&&t.left<t.right)return t}return null}measureVisibleLineHeights(t){let e=[],{from:i,to:n}=t,s=this.view.contentDOM.clientWidth,r=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,h=this.view.textDirection==c.LTR;for(let l=0,a=0;a<this.children.length;a++){let t=this.children[a],c=l+t.length;if(c>n)break;if(l>=i){let i=t.dom.getBoundingClientRect();if(e.push(i.height),r){let e=t.dom.lastChild,n=e?w(e):[];if(n.length){let t=n[n.length-1],e=h?t.right-i.left:i.right-t.left;e>o&&(o=e,this.minWidth=s,this.minWidthFrom=l,this.minWidthTo=c)}}}l=c+t.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?c.RTL:c.LTR}measureTextSize(){for(let s of this.children)if(s instanceof mt){let t=s.measureTextSize();if(t)return t}let t,e,i,n=document.createElement("div");return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore((()=>{this.dom.appendChild(n);let s=w(n.firstChild)[0];t=n.getBoundingClientRect().height,e=s?s.width/27:7,i=s?s.height:t,n.remove()})),{lineHeight:t,charWidth:e,textHeight:i}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new z(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)/this.view.scaleY;t.push(yt.replace({widget:new Ce(n),block:!0,inclusive:!0,isBlockGap:!0}).range(i,r))}if(!s)break;i=s.to+1}return yt.set(t)}updateDeco(){let t=this.view.state.facet(pe).map(((t,e)=>(this.dynamicDecorationMap[e]="function"==typeof t)?t(this.view):t)),e=!1,i=this.view.state.facet(me).map(((t,i)=>{let n="function"==typeof t;return n&&(e=!0),n?t(this.view):t}));i.length&&(this.dynamicDecorationMap[t.length]=e,t.push(r.Xs.join(i)));for(let n=t.length;n<t.length+3;n++)this.dynamicDecorationMap[n]=!1;return this.decorations=[...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco]}scrollIntoView(t){if(t.isSnapshot){let e=this.view.viewState.lineBlockAt(t.range.head);return this.view.scrollDOM.scrollTop=e.top-t.yMargin,void(this.view.scrollDOM.scrollLeft=t.xMargin)}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=xe(this.view),r={left:n.left-s.left,top:n.top-s.top,right:n.right+s.right,bottom:n.bottom+s.bottom},{offsetWidth:o,offsetHeight:h}=this.view.scrollDOM;M(this.view.scrollDOM,r,i.head<i.anchor?-1:1,t.x,t.y,Math.max(Math.min(t.xMargin,o),-o),Math.max(Math.min(t.yMargin,h),-h),this.view.textDirection==c.LTR)}}class Ce extends vt{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return t.className="cm-gap",this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}}function Oe(t,e){let i=t.observer.selectionRange,n=i.focusNode&&De(i.focusNode,i.focusOffset,0);if(!n)return null;let s=e-n.offset;return{from:s,to:s+n.node.nodeValue.length,node:n.node}}function Te(t,e,i){let n=Oe(t,i);if(!n)return null;let{node:s,from:r,to:o}=n,h=s.nodeValue;if(/[\n\r]/.test(h))return null;if(t.state.doc.sliceString(n.from,n.to)!=h)return null;let l=e.invertedDesc,a=new ke(l.mapPos(r),l.mapPos(o),r,o),c=[];for(let u=s.parentNode;;u=u.parentNode){let e=W.get(u);if(e instanceof nt)c.push({node:u,deco:e.mark});else{if(e instanceof mt||"DIV"==u.nodeName&&u.parentNode==t.contentDOM)return{range:a,text:s,marks:c,line:u};if(u==t.contentDOM)return null;c.push({node:u,deco:new bt({inclusive:!0,attributes:pt(u),tagName:u.tagName.toLowerCase()})})}}}function De(t,e,i){if(i<=0)for(let n=t,s=e;;){if(3==n.nodeType)return{node:n,offset:s};if(!(1==n.nodeType&&s>0))break;n=n.childNodes[s-1],s=x(n)}if(i>=0)for(let n=t,s=e;;){if(3==n.nodeType)return{node:n,offset:s};if(!(1==n.nodeType&&s<n.childNodes.length&&i>=0))break;n=n.childNodes[s],s=0}return null}function Ee(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)}let Re=class{constructor(){this.changes=[]}compareRange(t,e){At(t,e,this.changes)}comparePoint(t,e){At(t,e,this.changes)}};function Be(t,e,i){let n=new Re;return r.Xs.compare(t,e,i,n),n.changes}function Pe(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 Le(t,e){let i=!1;return e&&t.iterChangedRanges(((t,n)=>{t<e.to&&n>e.from&&(i=!0)})),i}function Ne(t,e,i=1){let n=t.charCategorizer(e),s=t.doc.lineAt(e),o=e-s.from;if(0==s.length)return r.jT.cursor(e);0==o?i=1:o==s.length&&(i=-1);let h=o,l=o;i<0?h=(0,r.cp)(s.text,o,!1):l=(0,r.cp)(s.text,o);let a=n(s.text.slice(h,l));for(;h>0;){let t=(0,r.cp)(s.text,h,!1);if(n(s.text.slice(t,h))!=a)break;h=t}for(;l<s.length;){let t=(0,r.cp)(s.text,l);if(n(s.text.slice(l,t))!=a)break;l=t}return r.jT.range(h+s.from,l+s.from)}function Ie(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function Ve(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function He(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function We(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function Fe(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function ze(t,e,i){let n,s,r,o,h,l,a,c,u=!1;for(let d=t.firstChild;d;d=d.nextSibling){let t=w(d);for(let f=0;f<t.length;f++){let g=t[f];s&&He(s,g)&&(g=We(Fe(g,s.bottom),s.top));let p=Ie(e,g),m=Ve(i,g);if(0==p&&0==m)return 3==d.nodeType?_e(d,e,i):ze(d,e,i);if(!n||o>m||o==m&&r>p){n=d,s=g,r=p,o=m;let h=m?i<g.top?-1:1:p?e<g.left?-1:1:0;u=!h||(h>0?f<t.length-1:f>0)}0==p?i>g.bottom&&(!a||a.bottom<g.bottom)?(h=d,a=g):i<g.top&&(!c||c.top>g.top)&&(l=d,c=g):a&&He(a,g)?a=Fe(a,g.bottom):c&&He(c,g)&&(c=We(c,g.top))}}if(a&&a.bottom>=i?(n=h,s=a):c&&c.top<=i&&(n=l,s=c),!n)return{node:t,offset:0};let f=Math.max(s.left,Math.min(s.right,e));return 3==n.nodeType?_e(n,f,i):u&&"false"!=n.contentEditable?ze(n,f,i):{node:t,offset:Array.prototype.indexOf.call(t.childNodes,n)+(e>=(s.left+s.right)/2?1:0)}}function _e(t,e,i){let n=t.nodeValue.length,s=-1,r=1e9,o=0;for(let h=0;h<n;h++){let n=R(t,h,h+1).getClientRects();for(let a=0;a<n.length;a++){let c=n[a];if(c.top==c.bottom)continue;o||(o=e-c.left);let u=(c.top>i?c.top-i:i-c.bottom)-1;if(c.left-1<=e&&c.right+1>=e&&u<r){let i=e>=(c.left+c.right)/2,n=i;if(l.chrome||l.gecko){R(t,h).getBoundingClientRect().left==c.right&&(n=!i)}if(u<=0)return{node:t,offset:h+(n?1:0)};s=h+(n?1:0),r=u}}}return{node:t,offset:s>-1?s:o>0?t.nodeValue.length:0}}function je(t,e,i,n=-1){var s,r;let o,h=t.contentDOM.getBoundingClientRect(),c=h.top+t.viewState.paddingTop,{docHeight:u}=t.viewState,{x:f,y:d}=e,g=d-c;if(g<0)return 0;if(g>u)return t.state.doc.length;for(let l=t.viewState.heightOracle.textHeight/2,S=!1;o=t.elementAtHeight(g),o.type!=a.Text;)for(;g=n>0?o.bottom+l:o.top-l,!(g>=0&&g<=u);){if(S)return i?null:0;S=!0,n=-n}d=c+g;let p=o.from;if(p<t.viewport.from)return 0==t.viewport.from?0:i?null:qe(t,h,o,f,d);if(p>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:qe(t,h,o,f,d);let m=t.dom.ownerDocument,w=t.root.elementFromPoint?t.root:m,v=w.elementFromPoint(f,d);v&&!t.contentDOM.contains(v)&&(v=null),v||(f=Math.max(h.left+1,Math.min(h.right-1,f)),v=w.elementFromPoint(f,d),v&&!t.contentDOM.contains(v)&&(v=null));let y,b=-1;if(v&&0!=(null===(s=t.docView.nearest(v))||void 0===s?void 0:s.isEditable))if(m.caretPositionFromPoint){let t=m.caretPositionFromPoint(f,d);t&&({offsetNode:y,offset:b}=t)}else if(m.caretRangeFromPoint){let e=m.caretRangeFromPoint(f,d);e&&(({startContainer:y,startOffset:b}=e),(!t.contentDOM.contains(y)||l.safari&&$e(y,b,f)||l.chrome&&Ke(y,b,f))&&(y=void 0))}if(!y||!t.docView.dom.contains(y)){let e=mt.find(t.docView,p);if(!e)return g>o.top+o.height/2?o.to:o.from;({node:y,offset:b}=ze(e.dom,f,d))}let x=t.docView.nearest(y);if(!x)return null;if(x.isWidget&&1==(null===(r=x.dom)||void 0===r?void 0:r.nodeType)){let t=x.dom.getBoundingClientRect();return e.y<t.top||e.y<=t.bottom&&e.x<=(t.left+t.right)/2?x.posAtStart:x.posAtEnd}return x.localPosFromDOM(y,b)+x.posAtStart}function qe(t,e,i,n,s){let o=Math.round((n-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>1.5*t.defaultLineHeight){let e=t.viewState.heightOracle.textHeight;o+=Math.floor((s-i.top-.5*(t.defaultLineHeight-e))/e)*t.viewState.heightOracle.lineLength}let h=t.state.sliceDoc(i.from,i.to);return i.from+(0,r.Gz)(h,o,t.state.tabSize)}function $e(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 R(t,n-1,n).getBoundingClientRect().left>i}function Ke(t,e,i){if(0!=e)return!1;for(let n=t;;){let t=n.parentNode;if(!t||1!=t.nodeType||t.firstChild!=n)return!1;if(t.classList.contains("cm-line"))break;n=t}return i-(1==t.nodeType?t.getBoundingClientRect():R(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect()).left>5}function Je(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==a.Text))return n;return i}function Ge(t,e,i,n){let s=Je(t,e.head),o=n&&s.type==a.Text&&(t.lineWrapping||s.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head):null;if(o){let e=t.dom.getBoundingClientRect(),n=t.textDirectionAt(s.from),h=t.posAtCoords({x:i==(n==c.LTR)?e.right-1:e.left+1,y:(o.top+o.bottom)/2});if(null!=h)return r.jT.cursor(h,i?-1:1)}return r.jT.cursor(i?s.to:s.from,i?-1:1)}function Ue(t,e,i,n){let s=t.state.doc.lineAt(e.head),r=t.bidiSpans(s),o=t.textDirectionAt(s.from);for(let h=e,l=null;;){let e=Gt(s,r,o,h,i),a=Jt;if(!e){if(s.number==(i?t.state.doc.lines:1))return h;a="\n",s=t.state.doc.line(s.number+(i?1:-1)),r=t.bidiSpans(s),e=t.visualLineSide(s,!i)}if(l){if(!l(a))return h}else{if(!n)return e;l=n(a)}h=e}}function Xe(t,e,i){let n=t.state.charCategorizer(e),s=n(i);return t=>{let e=n(t);return s==r.D0.Space&&(s=e),s==e}}function Ye(t,e,i,n){let s=e.head,o=i?1:-1;if(s==(i?t.state.doc.length:0))return r.jT.cursor(s,e.assoc);let h,l=e.goalColumn,a=t.contentDOM.getBoundingClientRect(),c=t.coordsAtPos(s,e.assoc||-1),u=t.documentTop;if(c)null==l&&(l=c.left-a.left),h=o<0?c.top:c.bottom;else{let e=t.viewState.lineBlockAt(s);null==l&&(l=Math.min(a.right-a.left,t.defaultCharacterWidth*(s-e.from))),h=(o<0?e.top:e.bottom)+u}let f=a.left+l,d=null!=n?n:t.viewState.heightOracle.textHeight>>1;for(let g=0;;g+=10){let e=h+(d+g)*o,i=je(t,{x:f,y:e},!1,o);if(e<a.top||e>a.bottom||(o<0?i<s:i>s)){let n=t.docView.coordsForChar(i),s=!n||e<n.top?-1:1;return r.jT.cursor(i,s,void 0,l)}}}function Qe(t,e,i){for(;;){let n=0;for(let s of t)s.between(e-1,e+1,((t,s,r)=>{if(e>t&&e<s){let r=n||i||(e-t<s-e?-1:1);e=r<0?t:s,n=r}}));if(!n)return e}}function Ze(t,e,i){let n=Qe(t.state.facet(we).map((e=>e(t))),i.from,e.head>i.from?-1:1);return n==i.from?i:r.jT.cursor(n,n<i.from?1:-1)}class ti{setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}constructor(t){this.view=t,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=t.hasFocus,l.safari&&t.contentDOM.addEventListener("input",(()=>null)),l.gecko&&Hi(t.contentDOM.ownerDocument)}handleEvent(t){fi(this.view,t)&&!this.ignoreDuringComposition(t)&&("keydown"==t.type&&this.keydown(t)||this.runHandlers(t.type,t))}runHandlers(t,e){let i=this.handlers[t];if(i){for(let t of i.observers)t(this.view,e);for(let t of i.handlers){if(e.defaultPrevented)break;if(t(this.view,e)){e.preventDefault();break}}}}ensureHandlers(t){let e=ii(t),i=this.handlers,n=this.view.contentDOM;for(let s in e)if("scroll"!=s){let t=!e[s].handlers.length,r=i[s];r&&t!=!r.handlers.length&&(n.removeEventListener(s,this.handleEvent),r=null),r||n.addEventListener(s,this.handleEvent,{passive:t})}for(let s in i)"scroll"==s||e[s]||n.removeEventListener(s,this.handleEvent);this.handlers=e}keydown(t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),9==t.keyCode&&Date.now()<this.lastEscPress+2e3)return!0;if(27!=t.keyCode&&ri.indexOf(t.keyCode)<0&&(this.view.inputState.lastEscPress=0),l.android&&l.chrome&&!t.synthetic&&(13==t.keyCode||8==t.keyCode))return this.view.observer.delayAndroidKey(t.key,t.keyCode),!0;let e;return!l.ios||t.synthetic||t.altKey||t.metaKey||!((e=ni.find((e=>e.keyCode==t.keyCode)))&&!t.ctrlKey||si.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)?(229!=t.keyCode&&this.view.observer.forceFlush(),!1):(this.pendingIOSKey=e||t,setTimeout((()=>this.flushIOSKey()),250),!0)}flushIOSKey(){let t=this.pendingIOSKey;return!!t&&(this.pendingIOSKey=void 0,B(this.view.contentDOM,t.key,t.keyCode))}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(this.composing>0||!!(l.safari&&!l.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.mouseSelection&&this.mouseSelection.update(t),this.draggedContent&&t.docChanged&&(this.draggedContent=this.draggedContent.map(t.changes)),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function ei(t,e){return(i,n)=>{try{return e.call(t,n,i)}catch(s){he(i.state,s)}}}function ii(t){let e=Object.create(null);function i(t){return e[t]||(e[t]={observers:[],handlers:[]})}for(let n of t){let t=n.spec;if(t&&t.domEventHandlers)for(let e in t.domEventHandlers){let s=t.domEventHandlers[e];s&&i(e).handlers.push(ei(n.value,s))}if(t&&t.domEventObservers)for(let e in t.domEventObservers){let s=t.domEventObservers[e];s&&i(e).observers.push(ei(n.value,s))}}for(let n in di)i(n).handlers.push(di[n]);for(let n in gi)i(n).observers.push(gi[n]);return e}const ni=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],si="dthko",ri=[16,17,18,20,91,92,224,225],oi=6;function hi(t){return.7*Math.max(0,t)+8}class li{constructor(t,e,i,n){this.view=t,this.startEvent=e,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParent=C(t.contentDOM),this.atoms=t.state.facet(we).map((e=>e(t)));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(r.yy.allowMultipleSelections)&&ai(t,e),this.dragging=!(!ui(t,e)||1!=Oi(e))&&null}start(t){!1===this.dragging&&this.select(t)}move(t){var e,i,n;if(0==t.buttons)return this.destroy();if(this.dragging||null==this.dragging&&(i=this.startEvent,n=t,Math.max(Math.abs(i.clientX-n.clientX),Math.abs(i.clientY-n.clientY))<10))return;this.select(this.lastEvent=t);let s=0,r=0,o=(null===(e=this.scrollParent)||void 0===e?void 0:e.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},h=xe(this.view);t.clientX-h.left<=o.left+oi?s=-hi(o.left-t.clientX):t.clientX+h.right>=o.right-oi&&(s=hi(t.clientX-o.right)),t.clientY-h.top<=o.top+oi?r=-hi(o.top-t.clientY):t.clientY+h.bottom>=o.bottom-oi&&(r=hi(t.clientY-o.bottom)),this.setScrollSpeed(s,r)}up(t){null==this.dragging&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval((()=>this.scroll()),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),!1===this.dragging&&this.select(this.lastEvent)}skipAtoms(t){let e=null;for(let i=0;i<t.ranges.length;i++){let n=t.ranges[i],s=null;if(n.empty){let t=Qe(this.atoms,n.from,0);t!=n.from&&(s=r.jT.cursor(t,-1))}else{let t=Qe(this.atoms,n.from,-1),e=Qe(this.atoms,n.to,1);t==n.from&&e==n.to||(s=r.jT.range(n.from==n.anchor?t:e,n.from==n.head?t:e))}s&&(e||(e=t.ranges.slice()),e[i]=s)}return e?r.jT.create(e,t.mainIndex):t}select(t){let{view:e}=this,i=this.skipAtoms(this.style.get(t,this.extend,this.multiple));!this.mustSelect&&i.eq(e.state.selection,!1===this.dragging)||this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){this.style.update(t)&&setTimeout((()=>this.select(this.lastEvent)),20)}}function ai(t,e){let i=t.state.facet(Xt);return i.length?i[0](e):l.mac?e.metaKey:e.ctrlKey}function ci(t,e){let i=t.state.facet(Yt);return i.length?i[0](e):l.mac?!e.altKey:!e.ctrlKey}function ui(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let n=d(t.root);if(!n||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 fi(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=W.get(n))&&i.ignoreEvent(e))return!1;return!0}const di=Object.create(null),gi=Object.create(null),pi=l.ie&&l.ie_version<15||l.ios&&l.webkit_version<604;function mi(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(),wi(t,i.value)}),50)}function wi(t,e){let i,{state:n}=t,s=1,o=n.toText(e),h=o.lines==n.selection.ranges.length;if(null!=Pi&&n.selection.ranges.every((t=>t.empty))&&Pi==o.toString()){let t=-1;i=n.changeByRange((i=>{let l=n.doc.lineAt(i.from);if(l.from==t)return{range:i};t=l.from;let a=n.toText((h?o.line(s++).text:e)+n.lineBreak);return{changes:{from:l.from,insert:a},range:r.jT.cursor(i.from+a.length)}}))}else i=h?n.changeByRange((t=>{let e=o.line(s++);return{changes:{from:t.from,to:t.to,insert:e.text},range:r.jT.cursor(t.from+e.length)}})):n.replaceSelection(o);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function vi(t,e,i,n){if(1==n)return r.jT.cursor(e,i);if(2==n)return Ne(t.state,e,i);{let i=mt.find(t.docView,e),n=t.state.doc.lineAt(i?i.posAtEnd:e),s=i?i.posAtStart:n.from,o=i?i.posAtEnd:n.to;return o<t.state.doc.length&&o==n.to&&o++,r.jT.range(s,o)}}gi.scroll=t=>{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft},di.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),27==e.keyCode&&(t.inputState.lastEscPress=Date.now()),!1),gi.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},gi.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},di.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let i=null;for(let n of t.state.facet(Qt))if(i=n(t,e),i)break;if(i||0!=e.button||(i=Ti(t,e)),i){let n=!t.hasFocus;t.inputState.startMouseSelection(new li(t,e,i,n)),n&&t.observer.ignore((()=>E(t.contentDOM)));let s=t.inputState.mouseSelection;if(s)return s.start(e),!1===s.dragging}return!1};let yi=(t,e)=>t>=e.top&&t<=e.bottom,bi=(t,e,i)=>yi(e,i)&&t>=i.left&&t<=i.right;function xi(t,e,i,n){let s=mt.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&&bi(i,n,o))return-1;let h=s.coordsAt(r,1);return h&&bi(i,n,h)?1:o&&yi(n,o)?-1:1}function Si(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:xi(t,i,e.clientX,e.clientY)}}const ki=l.ie&&l.ie_version<=11;let Ai=null,Mi=0,Ci=0;function Oi(t){if(!ki)return t.detail;let e=Ai,i=Ci;return Ai=t,Ci=Date.now(),Mi=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Mi+1)%3:1}function Ti(t,e){let i=Si(t,e),n=Oi(e),s=t.state.selection;return{update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),s=s.map(t.changes))},get(e,o,h){let l,a=Si(t,e),c=vi(t,a.pos,a.bias,n);if(i.pos!=a.pos&&!o){let e=vi(t,i.pos,i.bias,n),s=Math.min(e.from,c.from),o=Math.max(e.to,c.to);c=s<c.from?r.jT.range(s,o):r.jT.range(o,s)}return o?s.replaceRange(s.main.extend(c.from,c.to)):h&&1==n&&s.ranges.length>1&&(l=Di(s,a.pos))?l:h?s.addRange(c):r.jT.create([c])}}}function Di(t,e){for(let i=0;i<t.ranges.length;i++){let{from:n,to:s}=t.ranges[i];if(n<=e&&s>=e)return r.jT.create(t.ranges.slice(0,i).concat(t.ranges.slice(i+1)),t.mainIndex==i?0:t.mainIndex-(t.mainIndex>i?1:0))}return null}function Ei(t,e,i,n){if(!i)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=t.inputState,o=n&&r&&ci(t,e)?{from:r.from,to:r.to}:null,h={from:s,insert:i},l=t.state.changes(o?[o,h]:h);t.focus(),t.dispatch({changes:l,selection:{anchor:l.mapPos(s,-1),head:l.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"}),t.inputState.draggedContent=null}function Ri(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 Bi(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}}di.dragstart=(t,e)=>{let{selection:{main:i}}=t.state;if(e.target.draggable){let n=t.docView.nearest(e.target);if(n&&n.isWidget){let t=n.posAtStart,e=t+n.length;(t>=i.to||e<=i.from)&&(i=r.jT.range(t,e))}}let{inputState:n}=t;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=i,e.dataTransfer&&(e.dataTransfer.setData("Text",t.state.sliceDoc(i.from,i.to)),e.dataTransfer.effectAllowed="copyMove"),!1},di.dragend=t=>(t.inputState.draggedContent=null,!1),di.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let i=e.dataTransfer.files;if(i&&i.length){let n=Array(i.length),s=0,r=()=>{++s==i.length&&Ei(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])}return!0}{let i=e.dataTransfer.getData("Text");if(i)return Ei(t,e,i,!0),!0}return!1},di.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let i=pi?null:e.clipboardData;return i?(wi(t,i.getData("text/plain")||i.getData("text/uri-text")),!0):(mi(t),!1)};let Pi=null;di.copy=di.cut=(t,e)=>{let{text:i,ranges:n,linewise:s}=Bi(t.state);if(!i&&!s)return!1;Pi=s?i:null,"cut"!=e.type||t.state.readOnly||t.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let r=pi?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",i),!0):(Ri(t,i),!1)};const Li=r.q6.define();function Ni(t,e){let i=[];for(let n of t.facet(ie)){let s=n(t,e);s&&i.push(s)}return i?t.update({effects:i,annotations:Li.of(!0)}):null}function Ii(t){setTimeout((()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=Ni(t.state,e);i?t.dispatch(i):t.update([])}}),10)}gi.focus=t=>{t.inputState.lastFocusTime=Date.now(),t.scrollDOM.scrollTop||!t.inputState.lastScrollTop&&!t.inputState.lastScrollLeft||(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),Ii(t)},gi.blur=t=>{t.observer.clearSelectionRange(),Ii(t)},gi.compositionstart=gi.compositionupdate=t=>{null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0)},gi.compositionend=t=>{t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,l.chrome&&l.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then((()=>t.observer.flush())):setTimeout((()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])}),50)},gi.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},di.beforeinput=(t,e)=>{var i;let n;if(l.chrome&&l.android&&(n=ni.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)}return!1};const Vi=new Set;function Hi(t){Vi.has(t)||(Vi.add(t),t.addEventListener("copy",(()=>{})),t.addEventListener("cut",(()=>{})))}const Wi=["pre-wrap","normal","pre-line","break-spaces"];class Fi{constructor(t){this.lineWrapping=t,this.doc=r.xv.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,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.max(0,Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(t){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5))))*this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return Wi.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let n=t[i];n<0?i++:this.heightSamples[Math.floor(10*n)]||(e=!0,this.heightSamples[Math.floor(10*n)]=!0)}return e}refresh(t,e,i,n,s,r){let o=Wi.indexOf(t)>-1,h=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=e,this.charWidth=i,this.textHeight=n,this.lineLength=s,h){this.heightSamples={};for(let t=0;t<r.length;t++){let e=r[t];e<0?t++:this.heightSamples[Math.floor(10*e)]=!0}}return h}}class zi{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class _i{constructor(t,e,i,n,s){this.from=t,this.length=e,this.top=i,this.height=n,this._content=s}get type(){return"number"==typeof this._content?a.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof St?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(t){let e=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new _i(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var u=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}(u||(u={}));const ji=.001;class qi{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)>ji&&(t.heightChanged=!0),this.height=e)}replace(t,e,i){return qi.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,n){let s=this,r=i.doc;for(let o=n.length-1;o>=0;o--){let{fromA:h,toA:l,fromB:a,toB:c}=n[o],f=s.lineAt(h,u.ByPosNoHeight,i.setDoc(e),0,0),d=f.to>=l?f:s.lineAt(l,u.ByPosNoHeight,i,0,0);for(c+=d.to-l,l=d.to;o>0&&f.from<=n[o-1].toA;)h=n[o-1].fromA,a=n[o-1].fromB,o--,h<f.from&&(f=s.lineAt(h,u.ByPosNoHeight,i,0,0));a+=f.from-h,h=f.from;let g=Yi.build(i.setDoc(r),t,a,c);s=s.replace(h,l,g)}return s.updateHeight(i,0)}static empty(){return new Ki(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 Gi(qi.of(t.slice(0,e)),r,qi.of(t.slice(i)))}}qi.prototype.size=1;class $i extends qi{constructor(t,e,i){super(t,e),this.deco=i}blockAt(t,e,i,n){return new _i(n,this.length,i,this.height,this.deco||0)}lineAt(t,e,i,n,s){return this.blockAt(0,i,n,s)}forEachLine(t,e,i,n,s,r){t<=s+this.length&&e>=s&&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 Ki extends $i{constructor(t,e){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(t,e,i,n){return new _i(n,this.length,i,this.height,this.breaks)}replace(t,e,i){let n=i[0];return 1==i.length&&(n instanceof Ki||n instanceof Ji&&4&n.flags)&&Math.abs(this.length-n.length)<10?(n instanceof Ji?n=new Ki(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):qi.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.breaks*t.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Ji extends qi{constructor(t){super(t,0)}heightMetrics(t,e){let i,n=t.doc.lineAt(e).number,s=t.doc.lineAt(e+this.length).number,r=s-n+1,o=0;if(t.lineWrapping){let e=Math.min(this.height,t.lineHeight*r);i=e/r,this.length>r+1&&(o=(this.height-e)/(this.length-r-1))}else i=this.height/r;return{firstLine:n,lastLine:s,perLine:i,perChar:o}}blockAt(t,e,i,n){let{firstLine:s,lastLine:r,perLine:o,perChar:h}=this.heightMetrics(e,n);if(e.lineWrapping){let s=n+Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length),r=e.doc.lineAt(s),l=o+r.length*h,a=Math.max(i,t-l/2);return new _i(r.from,r.length,a,l,0)}{let n=Math.max(0,Math.min(r-s,Math.floor((t-i)/o))),{from:h,length:l}=e.doc.line(s+n);return new _i(h,l,i+o*n,o,0)}}lineAt(t,e,i,n,s){if(e==u.ByHeight)return this.blockAt(t,i,n,s);if(e==u.ByPosNoHeight){let{from:e,to:n}=i.doc.lineAt(t);return new _i(e,n-e,0,0,0)}let{firstLine:r,perLine:o,perChar:h}=this.heightMetrics(i,s),l=i.doc.lineAt(t),a=o+l.length*h,c=l.number-r,f=n+o*c+h*(l.from-s-c);return new _i(l.from,l.length,Math.max(n,Math.min(f,n+this.height-a)),a,0)}forEachLine(t,e,i,n,s,r){t=Math.max(t,s),e=Math.min(e,s+this.length);let{firstLine:o,perLine:h,perChar:l}=this.heightMetrics(i,s);for(let a=t,c=n;a<=e;){let e=i.doc.lineAt(a);if(a==t){let i=e.number-o;c+=h*i+l*(t-s-i)}let n=h+l*e.length;r(new _i(e.from,e.length,c,n,0)),c+=n,a=e.to+1}}replace(t,e,i){let n=this.length-e;if(n>0){let t=i[i.length-1];t instanceof Ji?i[i.length-1]=new Ji(t.length+n):i.push(null,new Ji(n-1))}if(t>0){let e=i[0];e instanceof Ji?i[0]=new Ji(t+e.length):i.unshift(new Ji(t-1),null)}return qi.of(i)}decomposeLeft(t,e){e.push(new Ji(t-1),null)}decomposeRight(t,e){e.push(null,new Ji(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;for(n.from>e&&i.push(new Ji(n.from-e-1).updateHeight(t,e));r<=s&&n.more;){let e=t.doc.lineAt(r).length;i.length&&i.push(null);let s=n.heights[n.index++];-1==o?o=s:Math.abs(s-o)>=ji&&(o=-2);let h=new Ki(e,s);h.outdated=!1,i.push(h),r+=e+1}r<=s&&i.push(null,new Ji(s-r).updateHeight(t,r));let h=qi.of(i);return(o<0||Math.abs(h.height-this.height)>=ji||Math.abs(o-this.heightMetrics(t,e).perLine)>=ji)&&(t.heightChanged=!0),h}return(i||this.outdated)&&(this.setHeight(t,t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class Gi extends qi{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,h=e==u.ByHeight?t<r:t<o,l=h?this.left.lineAt(t,e,i,n,s):this.right.lineAt(t,e,i,r,o);if(this.break||(h?l.to<o:l.from>o))return l;let a=e==u.ByPosNoHeight?u.ByPosNoHeight:u.ByPos;return h?l.join(this.right.lineAt(o,a,i,r,o)):this.left.lineAt(o,a,i,n,s).join(l)}forEachLine(t,e,i,n,s,r){let o=n+this.left.height,h=s+this.left.length+this.break;if(this.break)t<h&&this.left.forEachLine(t,e,i,n,s,r),e>=h&&this.right.forEachLine(t,e,i,o,h,r);else{let l=this.lineAt(h,u.ByPos,i,n,s);t<l.from&&this.left.forEachLine(t,l.from-1,i,n,s,r),l.to>=t&&l.from<=e&&r(l),e>l.to&&this.right.forEachLine(l.to+1,e,i,o,h,r)}}replace(t,e,i){let n=this.left.length+this.break;if(e<n)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let s=[];t>0&&this.decomposeLeft(t,s);let r=s.length;for(let o of i)s.push(o);if(t>0&&Ui(s,r-1),e<this.length){let t=s.length;this.decomposeRight(e,s),Ui(s,t)}return qi.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?qi.of(this.break?[t,null,e]:[t,e]):(this.left=t,this.right=e,this.height=t.height+e.height,this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,i=!1,n){let{left:s,right:r}=this,o=e+s.length+this.break,h=null;return n&&n.from<=e+s.length&&n.more?h=s=s.updateHeight(t,e,i,n):s.updateHeight(t,e,i),n&&n.from<=o+r.length&&n.more?h=r=r.updateHeight(t,o,i,n):r.updateHeight(t,o,i),h?this.balanced(s,r):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Ui(t,e){let i,n;null==t[e]&&(i=t[e-1])instanceof Ji&&(n=t[e+1])instanceof Ji&&t.splice(e-1,3,new Ji(i.length+1+n.length))}const Xi=5;class Yi{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 Ki?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new Ki(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,s=i.widget?i.widget.lineBreaks:0;n<0&&(n=this.oracle.lineHeight);let r=e-t;i.block?this.addBlock(new $i(r,n,i)):(r||s||n>=Xi)&&this.addLineDeco(n,s,r)}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 Ki(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new Ji(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 Ki)return t;let e=new Ki(0,-1);return this.nodes.push(e),e}addBlock(t){this.enterLine();let e=t.deco;e&&e.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,e&&e.endSide>0&&(this.covering=t)}addLineDeco(t,e,i){let n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,t),n.breaks+=e,this.writtenTo=this.pos=this.pos+i}finish(t){let e=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof Ki||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new Ki(0,-1));let i=t;for(let n of this.nodes)n instanceof Ki&&n.updateHeight(this.oracle,i),i+=n?n.length:1;return this.nodes}static build(t,e,i,n){let s=new Yi(i,t);return r.Xs.spans(e,i,n,s,0),s.finish(i)}}function Qi(t,e,i){let n=new Zi;return r.Xs.compare(t,e,i,n,0),n.changes}class Zi{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,n){(t<e||i&&i.heightRelevant||n&&n.heightRelevant)&&At(t,e,this.changes,5)}}function tn(t,e){let i=t.getBoundingClientRect(),n=t.ownerDocument,s=n.defaultView||window,r=Math.max(0,i.left),o=Math.min(s.innerWidth,i.right),h=Math.max(0,i.top),l=Math.min(s.innerHeight,i.bottom);for(let a=t.parentNode;a&&a!=n.body;)if(1==a.nodeType){let e=a,i=window.getComputedStyle(e);if((e.scrollHeight>e.clientHeight||e.scrollWidth>e.clientWidth)&&"visible"!=i.overflow){let i=e.getBoundingClientRect();r=Math.max(r,i.left),o=Math.min(o,i.right),h=Math.max(h,i.top),l=a==t.parentNode?i.bottom:Math.min(l,i.bottom)}a="absolute"==i.position||"fixed"==i.position?e.offsetParent:e.parentNode}else{if(11!=a.nodeType)break;a=a.host}return{left:r-i.left,right:Math.max(r,o)-i.left,top:h-(i.top+e),bottom:Math.max(h,l)-(i.top+e)}}function en(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class nn{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,e){return yt.replace({widget:new sn(this.size*(e?t.scaleY:t.scaleX),e)}).range(this.from,this.to)}}class sn extends vt{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 rn{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.scrollTop=0,this.scrolledToBottom=!0,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=un,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=c.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let e=t.facet(ge).some((t=>"function"!=typeof t&&"cm-lineWrapping"==t.class));this.heightOracle=new Fi(e),this.stateDeco=t.facet(pe).filter((t=>"function"!=typeof t)),this.heightMap=qi.empty().applyChanges(this.stateDeco,r.xv.empty,this.heightOracle.setDoc(t.doc),[new ke(0,0,0,t.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=yt.set(this.lineGaps.map((t=>t.draw(this,!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 on(e,i))}}this.viewports=t.sort(((t,e)=>t.from-e.from)),this.scaler=this.heightMap.height<=7e6?un:new fn(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,(t=>{this.viewportLines.push(1==this.scaler.scale?t:dn(t,this.scaler))}))}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(pe).filter((t=>"function"!=typeof t));let n=t.changedRanges,s=ke.extendWithRanges(n,Qi(i,this.stateDeco,t?t.changes:r.as.empty(this.state.doc.length))),o=this.heightMap.height,h=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),s),this.heightMap.height!=o&&(t.flags|=2),h?(this.scrollAnchorPos=t.changes.mapPos(h.from,-1),this.scrollAnchorHeight=h.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let l=s.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<l.from||e.range.head>l.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,e));let a=!t.changes.empty||2&t.flags||l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,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&&!t.state.facet(se)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),n=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?c.RTL:c.LTR;let o=this.heightOracle.mustRefreshForWrapping(s),h=e.getBoundingClientRect(),l=o||this.mustMeasureContent||this.contentDOMHeight!=h.height;this.contentDOMHeight=h.height,this.mustMeasureContent=!1;let a=0,u=0;if(h.width&&h.height){let{scaleX:t,scaleY:i}=A(e,h);this.scaleX==t&&this.scaleY==i||(this.scaleX=t,this.scaleY=i,a|=8,o=l=!0)}let f=(parseInt(i.paddingTop)||0)*this.scaleY,d=(parseInt(i.paddingBottom)||0)*this.scaleY;this.paddingTop==f&&this.paddingBottom==d||(this.paddingTop=f,this.paddingBottom=d,a|=10),this.editorWidth!=t.scrollDOM.clientWidth&&(n.lineWrapping&&(l=!0),this.editorWidth=t.scrollDOM.clientWidth,a|=8);let g=t.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=g&&(this.scrollAnchorHeight=-1,this.scrollTop=g),this.scrolledToBottom=I(t.scrollDOM);let p=(this.printing?en:tn)(e,this.paddingTop),m=p.top-this.pixelViewport.top,w=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let v=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(v!=this.inView&&(this.inView=v,v&&(l=!0)),!this.inView&&!this.scrollTarget)return 0;let y=h.width;if(this.contentDOMWidth==y&&this.editorHeight==t.scrollDOM.clientHeight||(this.contentDOMWidth=h.width,this.editorHeight=t.scrollDOM.clientHeight,a|=8),l){let e=t.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(e)&&(o=!0),o||n.lineWrapping&&Math.abs(y-this.contentDOMWidth)>n.charWidth){let{lineHeight:i,charWidth:r,textHeight:h}=t.docView.measureTextSize();o=i>0&&n.refresh(s,i,r,h,y/r,e),o&&(t.docView.minWidth=0,a|=8)}m>0&&w>0?u=Math.max(m,w):m<0&&w<0&&(u=Math.min(m,w)),n.heightChanged=!1;for(let i of this.viewports){let s=i.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(i);this.heightMap=(o?qi.empty().applyChanges(this.stateDeco,r.xv.empty,this.heightOracle,[new ke(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(n,0,o,new zi(i.from,s))}n.heightChanged&&(a|=2)}let b=!this.viewportIsAppropriate(this.viewport,u)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return b&&(this.viewport=this.getViewport(u,this.scrollTarget)),this.updateForViewport(),(2&a||b)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,t)),a|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),a}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),n=this.heightMap,s=this.heightOracle,{visibleTop:r,visibleBottom:o}=this,h=new on(n.lineAt(r-1e3*i,u.ByHeight,s,0,0).from,n.lineAt(o+1e3*(1-i),u.ByHeight,s,0,0).to);if(e){let{head:t}=e.range;if(t<h.from||t>h.to){let i,r=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),o=n.lineAt(t,u.ByPos,s,0,0);i="center"==e.y?(o.top+o.bottom)/2-r/2:"start"==e.y||"nearest"==e.y&&t<h.from?o.top:o.bottom-r,h=new on(n.lineAt(i-500,u.ByHeight,s,0,0).from,n.lineAt(i+r+500,u.ByHeight,s,0,0).to)}}return h}mapViewport(t,e){let i=e.mapPos(t.from,-1),n=e.mapPos(t.to,1);return new on(this.heightMap.lineAt(i,u.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,u.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(t,u.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(e,u.ByPos,this.heightOracle,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 nn(e.mapPos(n.from),e.mapPos(n.to),n.size));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,s=n>>1,o=n<<1;if(this.defaultTextDirection!=c.LTR&&!i)return[];let h=[],l=(n,o,a,c)=>{if(o-n<s)return;let u=this.state.selection.main,f=[u.from];u.empty||f.push(u.to);for(let t of f)if(t>n&&t<o)return l(n,t-10,a,c),void l(t+10,o,a,c);let d=cn(t,(t=>t.from>=a.from&&t.to<=a.to&&Math.abs(t.from-n)<s&&Math.abs(t.to-o)<s&&!f.some((e=>t.from<e&&t.to>e))));if(!d){if(o<a.to&&e&&i&&e.visibleRanges.some((t=>t.from<=o&&t.to>=o))){let t=e.moveToLineBoundary(r.jT.cursor(o),!1,!0).head;t>n&&(o=t)}d=new nn(n,o,this.gapSize(a,n,o,c))}h.push(d)};for(let r of this.viewportLines){if(r.length<o)continue;let t=hn(r.from,r.to,this.stateDeco);if(t.total<o)continue;let e,s,h=this.scrollTarget?this.scrollTarget.range.head:null;if(i){let i,o,l=n/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=h){let e=an(t,h),n=((this.visibleBottom-this.visibleTop)/2+l)/r.height;i=e-n,o=e+n}else i=(this.visibleTop-r.top-l)/r.height,o=(this.visibleBottom-r.top+l)/r.height;e=ln(t,i),s=ln(t,o)}else{let i,r,o=t.total*this.heightOracle.charWidth,l=n*this.heightOracle.charWidth;if(null!=h){let e=an(t,h),n=((this.pixelViewport.right-this.pixelViewport.left)/2+l)/o;i=e-n,r=e+n}else i=(this.pixelViewport.left-l)/o,r=(this.pixelViewport.right+l)/o;e=ln(t,i),s=ln(t,r)}e>r.from&&l(r.from,e,r,t),s<r.to&&l(s,r.to,r,t)}return h}gapSize(t,e,i,n){let s=an(n,i)-an(n,e);return this.heightOracle.lineWrapping?t.height*s:n.total*this.heightOracle.charWidth*s}updateLineGaps(t){nn.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=yt.set(t.map((t=>t.draw(this,this.heightOracle.lineWrapping)))))}computeVisibleRanges(){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let e=[];r.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))||dn(this.heightMap.lineAt(t,u.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return dn(this.heightMap.lineAt(this.scaler.fromDOM(t),u.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(t){let e=this.lineBlockAtHeight(t+8);return e.from>=this.viewport.from||this.viewportLines[0].top-t>200?e:this.viewportLines[0]}elementAtHeight(t){return dn(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class on{constructor(t,e){this.from=t,this.to=e}}function hn(t,e,i){let n=[],s=t,o=0;return r.Xs.spans(i,t,e,{span(){},point(t,e){t>s&&(n.push({from:s,to:t}),o+=t-s),s=e}},20),s<e&&(n.push({from:s,to:e}),o+=e-s),{total:o,ranges:n}}function ln({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 an(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 cn(t,e){for(let i of t)if(e(i))return i}const un={toDOM(t){return t},fromDOM(t){return t},scale:1};class fn{constructor(t,e,i){let n=0,s=0,r=0;this.viewports=i.map((({from:i,to:s})=>{let r=e.lineAt(i,u.ByPos,t,0,0).top,o=e.lineAt(s,u.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 dn(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),n=e.toDOM(t.bottom);return new _i(t.from,t.length,i,n-i,Array.isArray(t._content)?t._content.map((t=>dn(t,e))):t._content)}const gn=r.r$.define({combine:t=>t.join(" ")}),pn=r.r$.define({combine:t=>t.indexOf(!0)>-1}),mn=o.V.newName(),wn=o.V.newName(),vn=o.V.newName(),yn={"&light":"."+wn,"&dark":"."+vn};function bn(t,e,i){return new o.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 xn=bn("."+mn,{"&":{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,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",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"},".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"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},yn),Sn="￿";class kn{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(r.yy.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=Sn}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let n=t;;){this.findPointBefore(i,n);let t=this.text.length;this.readNode(n);let s=n.nextSibling;if(s==e)break;let r=W.get(n),o=W.get(s);(r&&o?r.breakAfter:(r?r.breakAfter:Mn(n))||Mn(s)&&("BR"!=n.nodeName||n.cmIgnore)&&this.text.length>t)&&this.lineBreak(),n=s}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=W.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+(An(t,i.node,i.offset)?e:0))}}function An(t,e,i){for(;;){if(!e||i<x(e))return!1;if(e==t)return!0;i=y(e)+1,e=e.parentNode}}function Mn(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}class Cn{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class On{constructor(t,e,i,n){this.typeOver=n,this.bounds=null,this.text="";let{impreciseHead:s,impreciseAnchor:o}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let e=s||o?[]:Rn(t),i=new kn(e,t.state);i.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=i.text,this.newSel=Bn(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=s&&s.node==e.focusNode&&s.offset==e.focusOffset||!g(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),n=o&&o.node==e.anchorNode&&o.offset==e.anchorOffset||!g(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset),h=t.viewport;if(l.ios&&t.state.selection.main.empty&&i!=n&&(h.from>0||h.to<t.state.doc.length)){let e=h.from-Math.min(i,n),s=h.to-Math.max(i,n);0!=e&&1!=e||0!=s&&-1!=s||(i=0,n=t.state.doc.length)}this.newSel=r.jT.single(n,i)}}}function Tn(t,e){let i,{newSel:n}=e,s=t.state.selection.main,o=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:n,to:h}=e.bounds,a=s.from,c=null;(8===o||l.android&&e.text.length<h-n)&&(a=s.to,c="end");let u=En(t.state.doc.sliceString(n,h,Sn),e.text,a-n,c);u&&(l.chrome&&13==o&&u.toB==u.from+2&&e.text.slice(u.from,u.toB)==Sn+Sn&&u.toB--,i={from:n+u.from,to:n+u.toA,insert:r.xv.of(e.text.slice(u.from,u.toB).split(Sn))})}else n&&(!t.hasFocus&&t.state.facet(le)||n.main.eq(s))&&(n=null);if(!i&&!n)return!1;if(!i&&e.typeOver&&!s.empty&&n&&n.main.empty?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,s.to)}:i&&i.from>=s.from&&i.to<=s.to&&(i.from!=s.from||i.to!=s.to)&&s.to-s.from-(i.to-i.from)<=4?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,s.to))}:(l.mac||l.android)&&i&&i.from==i.to&&i.from==s.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(n&&2==i.insert.length&&(n=r.jT.single(n.main.anchor-1,n.main.head-1)),i={from:s.from,to:s.to,insert:r.xv.of([" "])}):l.chrome&&i&&i.from==i.to&&i.from==s.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(n&&(n=r.jT.single(n.main.anchor-1,n.main.head-1)),i={from:s.from,to:s.to,insert:r.xv.of([" "])}),i){if(l.ios&&t.inputState.flushIOSKey())return!0;if(l.android&&(i.from==s.from&&i.to==s.to&&1==i.insert.length&&2==i.insert.lines&&B(t.contentDOM,"Enter",13)||(i.from==s.from-1&&i.to==s.to&&0==i.insert.length||8==o&&i.insert.length<i.to-i.from&&i.to>s.head)&&B(t.contentDOM,"Backspace",8)||i.from==s.from&&i.to==s.to+1&&0==i.insert.length&&B(t.contentDOM,"Delete",46)))return!0;let e,r=i.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let h=()=>e||(e=Dn(t,i,n));return t.state.facet(ee).some((e=>e(t,i.from,i.to,r,h)))||t.dispatch(h()),!0}if(n&&!n.main.eq(s)){let e=!1,i="select";return t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(e=!0),i=t.inputState.lastSelectionOrigin),t.dispatch({selection:n,scrollIntoView:e,userEvent:i}),!0}return!1}function Dn(t,e,i){let n,s=t.state,o=s.selection.main;if(e.from>=o.from&&e.to<=o.to&&e.to-e.from>=(o.to-o.from)/3&&(!i||i.main.empty&&i.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let i=o.from<e.from?s.sliceDoc(o.from,e.from):"",r=o.to>e.to?s.sliceDoc(e.to,o.to):"";n=s.replaceSelection(t.state.toText(i+e.insert.sliceString(0,void 0,t.state.lineBreak)+r))}else{let h=s.changes(e),l=i&&i.main.to<=h.newLength?i.main:void 0;if(s.selection.ranges.length>1&&t.inputState.composing>=0&&e.to<=o.to&&e.to>=o.to-10){let a,c=t.state.sliceDoc(e.from,e.to),u=i&&Oe(t,i.main.head);if(u){let t=e.insert.length-(e.to-e.from);a={from:u.from,to:u.to-t}}else a=t.state.doc.lineAt(o.head);let f=o.to-e.to,d=o.to-o.from;n=s.changeByRange((i=>{if(i.from==o.from&&i.to==o.to)return{changes:h,range:l||i.map(h)};let n=i.to-f,u=n-c.length;if(i.to-i.from!=d||t.state.sliceDoc(u,n)!=c||i.to>=a.from&&i.from<=a.to)return{range:i};let g=s.changes({from:u,to:n,insert:e.insert}),p=i.to-o.to;return{changes:g,range:l?r.jT.range(Math.max(0,l.anchor+p),Math.max(0,l.head+p)):i.map(g)}}))}else n={changes:h,selection:l&&s.selection.replaceRange(l)}}let h="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,h+=".compose",t.inputState.compositionFirstChange&&(h+=".start",t.inputState.compositionFirstChange=!1)),s.update(n,{userEvent:h,scrollIntoView:!0})}function En(t,e,i,n){let s=Math.min(t.length,e.length),r=0;for(;r<s&&t.charCodeAt(r)==e.charCodeAt(r);)r++;if(r==s&&t.length==e.length)return null;let o=t.length,h=e.length;for(;o>0&&h>0&&t.charCodeAt(o-1)==e.charCodeAt(h-1);)o--,h--;if("end"==n){i-=o+Math.max(0,r-Math.min(o,h))-r}if(o<r&&t.length<e.length){r-=i<=r&&i>=o?r-i:0,h=r+(h-o),o=r}else if(h<r){r-=i<=r&&i>=h?r-i:0,o=r+(o-h),h=r}return{from:r,toA:o,toB:h}}function Rn(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 Cn(i,n)),s==i&&r==n||e.push(new Cn(s,r))),e}function Bn(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?r.jT.single(i+e,n+e):null}const Pn={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Ln=l.ie&&l.ie_version<=11;class Nn{constructor(t){this.view=t,this.active=!1,this.selectionRange=new O,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver((e=>{for(let t of e)this.queue.push(t);(l.ie&&l.ie_version<=11||l.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()})),Ln&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver((()=>{var t;(null===(t=this.view.docView)||void 0===t?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()})),this.resizeScroll.observe(t.scrollDOM)),this.addWindowListeners(this.win=t.win),this.start(),"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")))}),{threshold:[0,.001]}),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()}onScrollChanged(t){this.view.inputState.runHandlers("scroll",t),this.intersecting&&this.view.measure()}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){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(le)?i.root.activeElement!=this.dom:!m(i.dom,n))return;let s=n.anchorNode&&i.docView.nearest(n.anchorNode);s&&s.ignoreEvent(t)?e||(this.selectionChanged=!1):(l.ie&&l.ie_version<=11||l.android&&l.chrome)&&!i.state.selection.main.empty&&n.focusNode&&v(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=l.safari&&11==t.root.nodeType&&p(this.dom.ownerDocument)==this.dom&&Vn(this.view)||d(t.root);if(!e||this.selectionRange.eq(e))return!1;let i=m(this.dom,e);return i&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&N(this.dom,e)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(e),i&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let i=this.dom;i;)if(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,Pn),Ln&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Ln&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var i;if(!this.delayedAndroidKey){let t=()=>{let t=this.delayedAndroidKey;if(t){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=t.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&t.force&&B(this.dom,t.key,t.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(t)}this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(null===(i=this.delayedAndroidKey)||void 0===i?void 0:i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame((()=>{this.delayedFlush=-1,this.flush()})))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,n=!1;for(let 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}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),n=this.selectionChanged&&m(this.dom,this.selectionRange);if(t<0&&!n)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new On(this.view,t,e,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return this.view.requestMeasure(),!1;let i=this.view.state,n=Tn(this.view,e);return this.view.state==i&&this.view.update([]),n}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.flags|=4),"childList"==t.type){let i=In(e,t.previousSibling||t.target.previousSibling,-1),n=In(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}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}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.resizeScroll)||void 0===i||i.disconnect();for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}}function In(t,e,i){for(;e;){let n=W.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 Vn(t){let e=null;function i(t){t.preventDefault(),t.stopImmediatePropagation(),e=t.getTargetRanges()[0]}if(t.contentDOM.addEventListener("beforeinput",i,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",i,!0),!e)return null;let n=e.startContainer,s=e.startOffset,r=e.endContainer,o=e.endOffset,h=t.docView.domAtPos(t.state.selection.main.anchor);return v(h.node,h.offset,r,o)&&([n,s,r,o]=[r,o,n,s]),{anchorNode:n,anchorOffset:s,focusNode:r,focusOffset:o}}class Hn{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}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}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.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:e}=t;this.dispatchTransactions=t.dispatchTransactions||e&&(t=>t.forEach((t=>e(t,this))))||(t=>this.update(t)),this.dispatch=this.dispatch.bind(this),this._root=t.root||P(t.parent)||document,this.viewState=new rn(t.state||r.yy.create(t)),t.scrollTo&&t.scrollTo.is(oe)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(ce).map((t=>new fe(t)));for(let i of this.plugins)i.update(this);this.observer=new Nn(this),this.inputState=new ti(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Me(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure()}dispatch(...t){let e=1==t.length&&t[0]instanceof r.YW?t:1==t.length&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(e,this)}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=!1,s=this.state;for(let r of t){if(r.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=r.state}if(this.destroyed)return void(this.viewState.state=s);let o=this.hasFocus,h=0,l=null;t.some((t=>t.annotation(Li)))?(this.inputState.notifiedFocused=o,h=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=Ni(s,o),l||(h=1));let a=this.observer.delayedAndroidKey,c=null;if(a?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(c=null)):this.observer.clear(),s.facet(r.yy.phrases)!=this.state.facet(r.yy.phrases))return this.setState(s);e=Ae.create(this,s,t),e.flags|=h;let u=this.viewState.scrollTarget;try{this.updateState=2;for(let e of t){if(u&&(u=u.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection;u=new re(t.empty?t:r.jT.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(oe)&&(u=t.value.clip(this.state))}this.viewState.update(e,u),this.bidiCache=zn.update(this.bidiCache,e.changes),e.empty||(this.updatePlugins(e),this.inputState.update(e)),i=this.docView.update(e),this.state.facet(Se)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(i,t.some((t=>t.isUserEvent("select.pointer"))))}finally{this.updateState=0}if(e.startState.facet(gn)!=e.state.facet(gn)&&(this.viewState.mustMeasureContent=!0),(i||n||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!e.empty)for(let r of this.state.facet(te))try{r(e)}catch(f){he(this.state,f,"update listener")}(l||c)&&Promise.resolve().then((()=>{l&&this.state==l.startState&&this.dispatch(l),c&&!Tn(this,c)&&a.force&&B(this.contentDOM,a.key,a.keyCode)}))}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 rn(t),this.plugins=t.facet(ce).map((t=>new fe(t))),this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView.destroy(),this.docView=new Me(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(ce),i=t.state.facet(ce);if(e!=i){let n=[];for(let s of i){let i=e.indexOf(s);if(i<0)n.push(new fe(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()}else for(let n of this.plugins)n.mustUpdate=t;for(let n=0;n<this.plugins.length;n++)this.plugins[n].update(this);e!=i&&this.inputState.ensureHandlers(this.plugins)}measure(t=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey)return this.measureScheduled=-1,void this.requestMeasure();this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,i=this.scrollDOM,n=i.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:r}=this.viewState;Math.abs(n-this.viewState.scrollTop)>1&&(r=-1),this.viewState.scrollAnchorHeight=-1;try{for(let t=0;;t++){if(r<0)if(I(i))s=-1,r=this.viewState.heightMap.height;else{let t=this.viewState.scrollAnchorAt(n);s=t.from,r=t.top}this.updateState=1;let h=this.viewState.measure(this);if(!h&&!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 l=[];4&h||([this.measureRequests,l]=[l,this.measureRequests]);let a=l.map((t=>{try{return t.read(this)}catch(e){return he(this.state,e),Fn}})),c=Ae.create(this,this.state,[]),u=!1;c.flags|=h,e?e.flags|=h:e=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),u=this.docView.update(c));for(let t=0;t<l.length;t++)if(a[t]!=Fn)try{let e=l[t];e.write&&e.write(a[t],this)}catch(o){he(this.state,o)}if(u&&this.docView.updateSelection(!0),!c.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,r=-1;continue}{let t=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-r;if(t>1||t<-1){n+=t,i.scrollTop=n/this.scaleY,r=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let h of this.state.facet(te))h(e)}get themeClasses(){return mn+" "+(this.state.facet(pn)?vn:wn)+" "+this.state.facet(gn)}updateAttrs(){let t=_n(this,de,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(le)?"true":"false",class:"cm-content",style:`${l.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),_n(this,ge,e);let i=this.observer.ignore((()=>{let i=gt(this.contentDOM,this.contentAttrs,e),n=gt(this.dom,this.editorAttrs,t);return i||n}));return this.editorAttrs=t,this.contentAttrs=e,i}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,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(Se);let t=this.state.facet(Hn.cspNonce);o.V.mount(this.root,this.styleModules.concat(xn).reverse(),t?{nonce:t}:void 0)}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=this.win.requestAnimationFrame((()=>this.measure()))),t){if(this.measureRequests.indexOf(t)>-1)return;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)}}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}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return Ze(this,t,Ue(this,t,e,i))}moveByGroup(t,e){return Ze(this,t,Ue(this,t,e,(e=>Xe(this,t.head,e))))}visualLineSide(t,e){let i=this.bidiSpans(t),n=this.textDirectionAt(t.from),s=i[e?i.length-1:0];return r.jT.cursor(s.side(e,n)+t.from,s.forward(!e,n)?1:-1)}moveToLineBoundary(t,e,i=!0){return Ge(this,t,e,i)}moveVertically(t,e,i){return Ze(this,t,Ye(this,t,e,i))}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){return this.readMeasured(),je(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);return S(i,s[Vt.find(s,t-n.from,-1,e)].dir==c.LTR==e>0)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(ne)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>Wn)return Kt(t.length);let e,i=this.textDirectionAt(t.from);for(let s of this.bidiCache)if(s.from==t.from&&s.dir==i&&(s.fresh||Ht(s.isolates,e=ye(this,t))))return s.order;e||(e=ye(this,t));let n=$t(t.text,i,e);return this.bidiCache.push(new zn(t.from,t.to,i,e,!0,n)),n}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||l.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{E(this.contentDOM),this.docView.updateSelection()}))}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((9==t.nodeType?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return oe.of(new re("number"==typeof t?r.jT.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}scrollSnapshot(){let{scrollTop:t,scrollLeft:e}=this.scrollDOM,i=this.viewState.scrollAnchorAt(t);return oe.of(new re(r.jT.cursor(i.from),"start","start",i.top-t,e,!0))}static domEventHandlers(t){return ue.define((()=>({})),{eventHandlers:t})}static domEventObservers(t){return ue.define((()=>({})),{eventObservers:t})}static theme(t,e){let i=o.V.newName(),n=[gn.of(i),Se.of(bn(`.${i}`,t))];return e&&e.dark&&n.push(pn.of(!0)),n}static baseTheme(t){return r.Wl.lowest(Se.of(bn("."+mn,t,yn)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),n=i&&W.get(i)||W.get(t);return(null===(e=null==n?void 0:n.rootView)||void 0===e?void 0:e.view)||null}}Hn.styleModule=Se,Hn.inputHandler=ee,Hn.focusChangeEffect=ie,Hn.perLineTextDirection=ne,Hn.exceptionSink=Zt,Hn.updateListener=te,Hn.editable=le,Hn.mouseSelectionStyle=Qt,Hn.dragMovesSelection=Yt,Hn.clickAddsSelectionRange=Xt,Hn.decorations=pe,Hn.outerDecorations=me,Hn.atomicRanges=we,Hn.bidiIsolatedRanges=ve,Hn.scrollMargins=be,Hn.darkTheme=pn,Hn.cspNonce=r.r$.define({combine:t=>t.length?t[0]:""}),Hn.contentAttributes=ge,Hn.editorAttributes=de,Hn.lineWrapping=Hn.contentAttributes.of({class:"cm-lineWrapping"}),Hn.announce=r.Py.define();const Wn=4096,Fn={};class zn{constructor(t,e,i,n,s,r){this.from=t,this.to=e,this.dir=i,this.isolates=n,this.fresh=s,this.order=r}static update(t,e){if(e.empty&&!t.some((t=>t.fresh)))return t;let i=[],n=t.length?t[t.length-1].dir:c.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 zn(e.mapPos(r.from,1),e.mapPos(r.to,-1),r.dir,r.isolates,!1,r.order))}return i}}function _n(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&&ut(r,i)}return i}const jn=!l.ios;const qn={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};jn&&(qn[".cm-line"].caretColor="transparent !important",qn[".cm-content"]={caretColor:"transparent !important"});class $n extends r.uU{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}$n.prototype.elementClass="",$n.prototype.toDOM=void 0,$n.prototype.mapMode=r.gc.TrackBefore,$n.prototype.startSide=$n.prototype.endSide=-1,$n.prototype.point=!0;const Kn=r.r$.define(),Jn={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>r.Xs.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},Gn=r.r$.define();function Un(t){return[Yn(),Gn.of(Object.assign(Object.assign({},Jn),t))]}const Xn=r.r$.define({combine:t=>t.some((t=>t))});function Yn(t){let e=[Qn];return t&&!1===t.fixed&&e.push(Xn.of(!0)),e}const Qn=ue.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/this.view.scaleY+"px",this.gutters=t.state.facet(Gn).map((e=>new is(t,e)));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!t.state.facet(Xn),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(Xn)!=!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=r.Xs.iter(this.view.state.facet(Kn),this.view.viewport.from),n=[],s=this.gutters.map((t=>new es(t,this.view.viewport,-this.view.documentPadding.top)));for(let r of this.view.viewportLineBlocks)if(n.length&&(n=[]),Array.isArray(r.type)){let t=!0;for(let e of r.type)if(e.type==a.Text&&t){ts(i,n,e.from);for(let t of s)t.line(this.view,e,n);t=!1}else if(e.widget)for(let t of s)t.widget(this.view,e)}else if(r.type==a.Text){ts(i,n,r.from);for(let t of s)t.line(this.view,r,n)}else if(r.widget)for(let t of s)t.widget(this.view,r);for(let r of s)r.finish();t&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(t){let e=t.startState.facet(Gn),i=t.state.facet(Gn),n=t.docChanged||t.heightChanged||t.viewportChanged||!r.Xs.eq(t.startState.facet(Kn),t.state.facet(Kn),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 is(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:t=>Hn.scrollMargins.of((e=>{let i=e.plugin(t);return i&&0!=i.gutters.length&&i.fixed?e.textDirection==c.LTR?{left:i.dom.offsetWidth*e.scaleX}:{right:i.dom.offsetWidth*e.scaleX}:null}))});function Zn(t){return Array.isArray(t)?t:[t]}function ts(t,e,i){for(;t.value&&t.from<=i;)t.from==i&&e.push(t.value),t.next()}class es{constructor(t,e,i){this.gutter=t,this.height=i,this.i=0,this.cursor=r.Xs.iter(t.markers,e.from)}addElement(t,e,i){let{gutter:n}=this,s=(e.top-this.height)/t.scaleY,r=e.height/t.scaleY;if(this.i==n.elements.length){let e=new ns(t,r,s,i);n.elements.push(e),n.dom.appendChild(e.dom)}else n.elements[this.i].update(t,r,s,i);this.height=e.bottom,this.i++}line(t,e,i){let n=[];ts(this.cursor,n,e.from),i.length&&(n=n.concat(i));let s=this.gutter.config.lineMarker(t,e,n);s&&n.unshift(s);let r=this.gutter;(0!=n.length||r.config.renderEmptyElements)&&this.addElement(t,e,n)}widget(t,e){let i=this.gutter.config.widgetMarker(t,e.widget,e);i&&this.addElement(t,e,[i])}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let e=t.elements.pop();t.dom.removeChild(e.dom),e.destroy()}}}class is{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,r=n.target;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let t=r.getBoundingClientRect();s=(t.top+t.bottom)/2}else s=n.clientY;let o=t.lineBlockAtHeight(s-t.documentTop);e.domEventHandlers[i](t,o,n)&&n.preventDefault()}));this.markers=Zn(e.markers(t)),e.initialSpacer&&(this.spacer=new ns(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=Zn(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!r.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 ns{constructor(t,e,i,n){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,e,i,n)}update(t,e,i,n){this.height!=e&&(this.height=e,this.dom.style.height=e+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),ss(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,h=s<e.length?e[s++]:null,l=!1;if(h){let t=h.elementClass;t&&(i+=" "+t);for(let e=r;e<this.markers.length;e++)if(this.markers[e].compare(h)){o=e,l=!0;break}}else o=this.markers.length;for(;r<o;){let t=this.markers[r++];if(t.toDOM){t.destroy(n);let e=n.nextSibling;n.remove(),n=e}}if(!h)break;h.toDOM&&(l?n=n.nextSibling:this.dom.insertBefore(h.toDOM(t),n)),l&&r++}this.dom.className=i,this.markers=e}destroy(){this.setMarkers(null,[])}}function ss(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}n()}catch(f){n(f)}}))},29754:function(t,e,i){i.d(e,{D0:function(){return St},Gz:function(){return jt},Py:function(){return gt},Wl:function(){return Y},Xs:function(){return Rt},YW:function(){return pt},as:function(){return O},cp:function(){return w},f_:function(){return Bt},gc:function(){return M},jT:function(){return N},q6:function(){return ut},r$:function(){return H},uU:function(){return Ot},xv:function(){return n},yy:function(){return Ct}});i(63721),i(52247),i(71695),i(92745),i(52805),i(61495),i(61893),i(23669),i(69235),i(12385),i(19134),i(32517),i(5740),i(11740),i(92519),i(42179),i(89256),i(24931),i(88463),i(57449),i(19814),i(97003),i(32114),i(39527),i(92181),i(99790),i(67670),i(41360),i(13334),i(34595),i(36993),i(47021);class n{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){[t,e]=f(this,t,e);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),r.from(n,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){[t,e]=f(this,t,e);let i=[];return this.decompose(t,e,i,0),r.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 l(this),s=new l(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 l(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 c(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}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 s(t):r.from(s.split(t,[])):n.empty}}class s extends n{constructor(t,e=function(t){let e=-1;for(let i of t)e+=i.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.text[s],o=n+r.length;if((e?i:o)>=t)return new u(n,o,i,r);n=o+1,i++}}decompose(t,e,i,n){let r=t<=0&&e>=this.length?this:new s(h(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&n){let t=i.pop(),e=o(r.text,t.text.slice(),0,r.length);if(e.length<=32)i.push(new s(e,t.length+r.length));else{let t=e.length>>1;i.push(new s(e.slice(0,t)),new s(e.slice(t)))}}else i.push(r)}replace(t,e,i){if(!(i instanceof s))return super.replace(t,e,i);[t,e]=f(this,t,e);let n=o(this.text,o(i.text,h(this.text,0,t)),e),l=this.length+i.length-(e-t);return n.length<=32?new s(n,l):r.from(s.split(n,[]),l)}sliceString(t,e=this.length,i="\n"){[t,e]=f(this,t,e);let n="";for(let s=0,r=0;s<=e&&r<this.text.length;r++){let o=this.text[r],h=s+o.length;s>t&&r&&(n+=i),t<h&&e>s&&(n+=o.slice(Math.max(0,t-s),e-s)),s=h+1}return n}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],n=-1;for(let r of t)i.push(r),n+=r.length+1,32==i.length&&(e.push(new s(i,n)),i=[],n=-1);return n>-1&&e.push(new s(i,n)),e}}class r extends n{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,h=i+r.lines-1;if((e?h:o)>=t)return r.lineInner(t,e,i,n);n=o+1,i=h+1}}decompose(t,e,i,n){for(let s=0,r=0;r<=e&&s<this.children.length;s++){let o=this.children[s],h=r+o.length;if(t<=h&&e>=r){let s=n&((r<=t?1:0)|(h>=e?2:0));r>=t&&h<=e&&!s?i.push(o):o.decompose(t-r,e-r,i,s)}r=h+1}}replace(t,e,i){if([t,e]=f(this,t,e),i.lines<this.lines)for(let n=0,s=0;n<this.children.length;n++){let o=this.children[n],h=s+o.length;if(t>=s&&e<=h){let l=o.replace(t-s,e-s,i),a=this.lines-o.lines+l.lines;if(l.lines<a>>4&&l.lines>a>>6){let s=this.children.slice();return s[n]=l,new r(s,this.length-(e-t)+i.length)}return super.replace(s,h,l)}s=h+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i="\n"){[t,e]=f(this,t,e);let n="";for(let s=0,r=0;s<this.children.length&&r<=e;s++){let o=this.children[s],h=r+o.length;r>t&&s&&(n+=i),t<h&&e>r&&(n+=o.sliceString(t-r,e-r,i)),r=h+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof r))return 0;let i=0,[n,s,o,h]=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==o||s==h)return i;let r=this.children[n],l=t.children[s];if(r!=l)return i+r.scanIdentical(l,e);i+=r.length+1}}static from(t,e=t.reduce(((t,e)=>t+e.length+1),-1)){let i=0;for(let s of t)i+=s.lines;if(i<32){let i=[];for(let e of t)e.flatten(i);return new s(i,e)}let n=Math.max(32,i>>5),o=n<<1,h=n>>1,l=[],a=0,c=-1,u=[];function f(t){let e;if(t.lines>o&&t instanceof r)for(let i of t.children)f(i);else t.lines>h&&(a>h||!a)?(d(),l.push(t)):t instanceof s&&a&&(e=u[u.length-1])instanceof s&&t.lines+e.lines<=32?(a+=t.lines,c+=t.length+1,u[u.length-1]=new s(e.text.concat(t.text),e.length+1+t.length)):(a+t.lines>n&&d(),a+=t.lines,c+=t.length+1,u.push(t))}function d(){0!=a&&(l.push(1==u.length?u[0]:r.from(u,c)),c=-1,a=u.length=0)}for(let s of t)f(s);return d(),1==l.length?l[0]:new r(l,e)}}function o(t,e,i=0,n=1e9){for(let s=0,r=0,o=!0;r<t.length&&s<=n;r++){let h=t[r],l=s+h.length;l>=i&&(l>n&&(h=h.slice(0,n-s)),s<i&&(h=h.slice(i-s)),o?(e[e.length-1]+=h,o=!1):e.push(h)),s=l+1}return e}function h(t,e,i){return o(t,[""],e,i)}n.empty=new s([""],0);class l{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 s?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],r=this.offsets[i],o=r>>1,h=n instanceof s?n.text.length:n.children.length;if(o==(e>0?h: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&r)==(e>0?0:1)){if(this.offsets[i]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(n instanceof s){let s=n.text[o+(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 r=n.children[o+(e<0?-1:0)];t>r.length?(t-=r.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(r),this.offsets.push(e>0?1:(r instanceof s?r.text.length:r.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 l(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 c{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:n}=this.inner.next(t);return e&&this.afterBreak?(this.value="",this.afterBreak=!1):e?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(n.prototype[Symbol.iterator]=function(){return this.iter()},l.prototype[Symbol.iterator]=a.prototype[Symbol.iterator]=c.prototype[Symbol.iterator]=function(){return this});class u{constructor(t,e,i,n){this.from=t,this.to=e,this.number=i,this.text=n}get length(){return this.to-this.from}}function f(t,e,i){return[e=Math.max(0,Math.min(t.length,e)),Math.max(e,Math.min(t.length,i))]}let d="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map((t=>t?parseInt(t,36):1));for(let $t=1;$t<d.length;$t++)d[$t]+=d[$t-1];function g(t){for(let e=1;e<d.length;e+=2)if(d[e]>t)return d[e-1]<=t;return!1}function p(t){return t>=127462&&t<=127487}const m=8205;function w(t,e,i=!0,n=!0){return(i?v:y)(t,e,n)}function v(t,e,i){if(e==t.length)return e;e&&b(t.charCodeAt(e))&&x(t.charCodeAt(e-1))&&e--;let n=S(t,e);for(e+=k(n);e<t.length;){let s=S(t,e);if(n==m||s==m||i&&g(s))e+=k(s),n=s;else{if(!p(s))break;{let i=0,n=e-2;for(;n>=0&&p(S(t,n));)i++,n-=2;if(i%2==0)break;e+=2}}}return e}function y(t,e,i){for(;e>0;){let n=v(t,e-2,i);if(n<e)return n;e--}return 0}function b(t){return t>=56320&&t<57344}function x(t){return t>=55296&&t<56320}function S(t,e){let i=t.charCodeAt(e);if(!x(i)||e+1==t.length)return i;let n=t.charCodeAt(e+1);return b(n)?n-56320+(i-55296<<10)+65536:i}function k(t){return t<65536?1:2}const A=/\r\n?|\n/;var M=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(M||(M={}));class C{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){E(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 C(t)}composeDesc(t){return this.empty?t:t.empty?this:B(this,t)}mapDesc(t,e=!1){return t.empty?this:R(this,t,e)}mapPos(t,e=-1,i=M.Simple){let n=0,s=0;for(let r=0;r<this.sections.length;){let o=this.sections[r++],h=this.sections[r++],l=n+o;if(h<0){if(l>t)return s+(t-n);s+=o}else{if(i!=M.Simple&&l>=t&&(i==M.TrackDel&&n<t&&l>t||i==M.TrackBefore&&n<t||i==M.TrackAfter&&l>t))return null;if(l>t||l==t&&e<0&&!o)return t==n||e<0?s:s+h;s+=h}n=l}if(t>n)throw new RangeError(`Position ${t} is out of range for changeset of length ${n}`);return s}touchesRange(t,e=t){for(let i=0,n=0;i<this.sections.length&&n<=e;){let s=n+this.sections[i++];if(this.sections[i++]>=0&&n<=e&&s>=t)return!(n<t&&s>e)||"cover";n=s}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];t+=(t?" ":"")+i+(n>=0?":"+n:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some((t=>"number"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeDesc");return new C(t)}static create(t){return new C(t)}}class O extends C{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 E(this,((e,i,n,s,r)=>t=t.replace(n,n+(i-e),r)),!1),t}mapDesc(t,e=!1){return R(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let s=0,r=0;s<e.length;s+=2){let o=e[s],h=e[s+1];if(h>=0){e[s]=h,e[s+1]=o;let l=s>>1;for(;i.length<l;)i.push(n.empty);i.push(o?t.slice(r,r+o):n.empty)}r+=o}return new O(e,i)}compose(t){return this.empty?t:t.empty?this:B(this,t,!0)}map(t,e=!1){return t.empty?this:R(this,t,e,!0)}iterChanges(t,e=!1){E(this,t,e)}get desc(){return C.create(this.sections)}filter(t){let e=[],i=[],n=[],s=new P(this);t:for(let r=0,o=0;;){let h=r==t.length?1e9:t[r++];for(;o<h||o==h&&0==s.len;){if(s.done)break t;let t=Math.min(s.len,h-o);T(n,t,-1);let r=-1==s.ins?-1:0==s.off?s.ins:0;T(e,t,r),r>0&&D(i,e,s.text),s.forward(t),o+=t}let l=t[r++];for(;o<l;){if(s.done)break t;let t=Math.min(s.len,l-o);T(e,t,-1),T(n,t,-1==s.ins?-1:0==s.off?s.ins:0),s.forward(t),o+=t}}return{changes:new O(e,i),filtered:C.create(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 s=[],r=[],o=0,h=null;function l(t=!1){if(!t&&!s.length)return;o<e&&T(s,e-o,-1);let i=new O(s,r);h=h?h.compose(i.map(h)):i,s=[],r=[],o=0}return function t(a){if(Array.isArray(a))for(let e of a)t(e);else if(a instanceof O){if(a.length!=e)throw new RangeError(`Mismatched change set length (got ${a.length}, expected ${e})`);l(),h=h?h.compose(a.map(h)):a}else{let{from:t,to:h=t,insert:c}=a;if(t>h||t<0||h>e)throw new RangeError(`Invalid change range ${t} to ${h} (in doc of length ${e})`);let u=c?"string"==typeof c?n.of(c.split(i||A)):c:n.empty,f=u.length;if(t==h&&0==f)return;t<o&&l(),t>o&&T(s,t-o,-1),T(s,h-t,f),D(r,s,u),o=h}}(t),l(!h),h}static empty(t){return new O(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],i=[];for(let s=0;s<t.length;s++){let r=t[s];if("number"==typeof r)e.push(r,-1);else{if(!Array.isArray(r)||"number"!=typeof r[0]||r.some(((t,e)=>e&&"string"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==r.length)e.push(r[0],0);else{for(;i.length<s;)i.push(n.empty);i[s]=n.of(r.slice(1)),e.push(r[0],i[s].length)}}}return new O(e,i)}static createSet(t,e){return new O(t,e)}}function T(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 D(t,e,i){if(0==i.length)return;let s=e.length-2>>1;if(s<t.length)t[t.length-1]=t[t.length-1].append(i);else{for(;t.length<s;)t.push(n.empty);t.push(i)}}function E(t,e,i){let s=t.inserted;for(let r=0,o=0,h=0;h<t.sections.length;){let l=t.sections[h++],a=t.sections[h++];if(a<0)r+=l,o+=l;else{let c=r,u=o,f=n.empty;for(;c+=l,u+=a,a&&s&&(f=f.append(s[h-2>>1])),!(i||h==t.sections.length||t.sections[h+1]<0);)l=t.sections[h++],a=t.sections[h++];e(r,c,o,u,f),r=c,o=u}}}function R(t,e,i,n=!1){let s=[],r=n?[]:null,o=new P(t),h=new P(e);for(let l=-1;;)if(-1==o.ins&&-1==h.ins){let t=Math.min(o.len,h.len);T(s,t,-1),o.forward(t),h.forward(t)}else if(h.ins>=0&&(o.ins<0||l==o.i||0==o.off&&(h.len<o.len||h.len==o.len&&!i))){let t=h.len;for(T(s,h.ins,-1);t;){let e=Math.min(o.len,t);o.ins>=0&&l<o.i&&o.len<=e&&(T(s,0,o.ins),r&&D(r,s,o.text),l=o.i),o.forward(e),t-=e}h.next()}else{if(!(o.ins>=0)){if(o.done&&h.done)return r?O.createSet(s,r):C.create(s);throw new Error("Mismatched change set lengths")}{let t=0,e=o.len;for(;e;)if(-1==h.ins){let i=Math.min(e,h.len);t+=i,e-=i,h.forward(i)}else{if(!(0==h.ins&&h.len<e))break;e-=h.len,h.next()}T(s,t,l<o.i?o.ins:0),r&&l<o.i&&D(r,s,o.text),l=o.i,o.forward(o.len-e)}}}function B(t,e,i=!1){let n=[],s=i?[]:null,r=new P(t),o=new P(e);for(let h=!1;;){if(r.done&&o.done)return s?O.createSet(n,s):C.create(n);if(0==r.ins)T(n,r.len,0,h),r.next();else if(0!=o.len||o.done){if(r.done||o.done)throw new Error("Mismatched change set lengths");{let t=Math.min(r.len2,o.len),e=n.length;if(-1==r.ins){let e=-1==o.ins?-1:o.off?0:o.ins;T(n,t,e,h),s&&e&&D(s,n,o.text)}else-1==o.ins?(T(n,r.off?0:r.len,t,h),s&&D(s,n,r.textBit(t))):(T(n,r.off?0:r.len,o.off?0:o.ins,h),s&&!o.off&&D(s,n,o.text));h=(r.ins>t||o.ins>=0&&o.len>t)&&(h||n.length>e),r.forward2(t),o.forward(t)}}else T(n,0,o.ins,h),s&&D(s,n,o.text),o.next()}}class P{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.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?n.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 L{constructor(t,e,i){this.from=t,this.to=e,this.flags=i}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let t=7&this.flags;return 7==t?null:t}get goalColumn(){let t=this.flags>>6;return 16777215==t?void 0:t}map(t,e=-1){let i,n;return this.empty?i=n=t.mapPos(this.from,e):(i=t.mapPos(this.from,1),n=t.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new L(i,n,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return N.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return N.range(this.anchor,i)}eq(t,e=!1){return!(this.anchor!=t.anchor||this.head!=t.head||e&&this.empty&&this.assoc!=t.assoc)}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 N.range(t.anchor,t.head)}static create(t,e,i){return new L(t,e,i)}}class N{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:N.create(this.ranges.map((i=>i.map(t,e))),this.mainIndex)}eq(t,e=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(t.ranges[i],e))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new N([this.main],0)}addRange(t,e=!0){return N.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,N.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 N(t.ranges.map((t=>L.fromJSON(t))),t.main)}static single(t,e=t){return new N([N.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 N.normalized(t.slice(),e);i=s.to}return new N(t,e)}static cursor(t,e=0,i,n){return L.create(t,t,(0==e?0:e<0?8:16)|(null==i?7:Math.min(6,i))|(null!=n?n:16777215)<<6)}static range(t,e,i,n){let s=(null!=i?i:16777215)<<6|(null==n?7:Math.min(6,n));return e<t?L.create(e,t,48|s):L.create(t,e,(e>t?8:0)|s)}static normalized(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?N.range(o,r):N.range(r,o))}}return new N(t,e)}}function I(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let V=0;class H{constructor(t,e,i,n,s){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=V++,this.default=t([]),this.extensions="function"==typeof s?s(this):s}get reader(){return this}static define(t={}){return new H(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:W),!!t.static,t.enables)}of(t){return new F([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new F(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new F(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],(i=>e(i.field(t))))}}function W(t,e){return t==e||t.length==e.length&&t.every(((t,i)=>t===e[i]))}class F{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=this.id,r=t[s]>>1,o=2==this.type,h=!1,l=!1,a=[];for(let c of this.dependencies)"doc"==c?h=!0:"selection"==c?l=!0:1&(null!==(e=t[c.id])&&void 0!==e?e:1)||a.push(t[c.id]);return{create(t){return t.values[r]=i(t),1},update(t,e){if(h&&e.docChanged||l&&(e.docChanged||e.selection)||_(t,a)){let e=i(t);if(o?!z(e,t.values[r],n):!n(e,t.values[r]))return t.values[r]=e,1}return 0},reconfigure:(t,e)=>{let h,l=e.config.address[s];if(null!=l){let s=nt(e,l);if(this.dependencies.every((i=>i instanceof H?e.facet(i)===t.facet(i):!(i instanceof $)||e.field(i,!1)==t.field(i,!1)))||(o?z(h=i(t),s,n):n(h=i(t),s)))return t.values[r]=s,0}else h=i(t);return t.values[r]=h,1}}}}function z(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 _(t,e){let i=!1;for(let n of e)1&it(t,n)&&(i=!0);return i}function j(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;function h(t){let i=[];for(let e=0;e<n.length;e++){let r=nt(t,n[e]);if(2==s[e])for(let t of r)i.push(t);else i.push(r)}return e.combine(i)}return{create(t){for(let e of n)it(t,e);return t.values[o]=h(t),1},update(t,i){if(!_(t,r))return 0;let n=h(t);return e.compare(n,t.values[o])?0:(t.values[o]=n,1)},reconfigure(t,s){let r=_(t,n),l=s.config.facets[e.id],a=s.facet(e);if(l&&!r&&W(i,l))return t.values[o]=a,0;let c=h(t);return e.compare(c,a)?(t.values[o]=a,0):(t.values[o]=c,1)}}}const q=H.define({static:!0});class ${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 $(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(q).find((t=>t.field==this));return((null==e?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:t=>(t.values[e]=this.create(t),1),update:(t,i)=>{let n=t.values[e],s=this.updateF(n,i);return this.compareF(n,s)?0:(t.values[e]=s,1)},reconfigure:(t,i)=>null!=i.config.address[this.id]?(t.values[e]=i.field(this),0):(t.values[e]=this.create(t),1)}}init(t){return[this,q.of({field:this,create:t})]}get extension(){return this}}const K=4,J=3,G=2,U=1;function X(t){return e=>new Q(e,t)}const Y={highest:X(0),high:X(U),default:X(G),low:X(J),lowest:X(K)};class Q{constructor(t,e){this.inner=t,this.prec=e}}class Z{of(t){return new tt(this,t)}reconfigure(t){return Z.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class tt{constructor(t,e){this.compartment=t,this.inner=e}}class et{constructor(t,e,i,n,s,r){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=s,this.facets=r,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return null==e?t.default:this.staticValues[e>>1]}static resolve(t,e,i){let n=[],s=Object.create(null),r=new Map;for(let u of function(t,e,i){let n=[[],[],[],[],[]],s=new Map;function r(t,o){let h=s.get(t);if(null!=h){if(h<=o)return;let e=n[h].indexOf(t);e>-1&&n[h].splice(e,1),t instanceof tt&&i.delete(t.compartment)}if(s.set(t,o),Array.isArray(t))for(let e of t)r(e,o);else if(t instanceof tt){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 Q)r(t.inner,t.prec);else if(t instanceof $)n[o].push(t),t.provides&&r(t.provides,o);else if(t instanceof F)n[o].push(t),t.facet.extensions&&r(t.facet.extensions,G);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,G),n.reduce(((t,e)=>t.concat(e)))}(t,e,r))u instanceof $?n.push(u):(s[u.facet.id]||(s[u.facet.id]=[])).push(u);let o=Object.create(null),h=[],l=[];for(let u of n)o[u.id]=l.length<<1,l.push((t=>u.slot(t)));let a=null==i?void 0:i.config.facets;for(let u in s){let t=s[u],e=t[0].facet,n=a&&a[u]||[];if(t.every((t=>0==t.type)))if(o[e.id]=h.length<<1|1,W(n,t))h.push(i.facet(e));else{let n=e.combine(t.map((t=>t.value)));h.push(i&&e.compare(n,i.facet(e))?i.facet(e):n)}else{for(let e of t)0==e.type?(o[e.id]=h.length<<1|1,h.push(e.value)):(o[e.id]=l.length<<1,l.push((t=>e.dynamicSlot(t))));o[e.id]=l.length<<1,l.push((i=>j(i,e,t)))}}let c=l.map((t=>t(o)));return new et(t,r,c,o,h,s)}}function it(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.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|s}function nt(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const st=H.define(),rt=H.define({combine:t=>t.some((t=>t)),static:!0}),ot=H.define({combine:t=>t.length?t[0]:void 0,static:!0}),ht=H.define(),lt=H.define(),at=H.define(),ct=H.define({combine:t=>!!t.length&&t[0]});class ut{constructor(t,e){this.type=t,this.value=e}static define(){return new ft}}class ft{of(t){return new ut(this,t)}}class dt{constructor(t){this.map=t}of(t){return new gt(this,t)}}class gt{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 gt(this.type,e)}is(t){return this.type==t}static define(t={}){return new dt(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}}gt.reconfigure=gt.define(),gt.appendConfig=gt.define();class pt{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&&I(i,e.newLength),s.some((t=>t.type==pt.time))||(this.annotations=s.concat(pt.time.of(Date.now())))}static create(t,e,i,n,s,r){return new pt(t,e,i,n,s,r)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(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(pt.userEvent);return!(!e||!(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function mt(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 wt(t,e,i){var n;let s,r,o;return i?(s=e.changes,r=O.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:gt.mapEffects(t.effects,s).concat(gt.mapEffects(e.effects,r)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function vt(t,e,i){let n=e.selection,s=xt(e.annotations);return e.userEvent&&(s=s.concat(pt.userEvent.of(e.userEvent))),{changes:e.changes instanceof O?e.changes:O.of(e.changes||[],i,t.facet(ot)),selection:n&&(n instanceof N?n:N.single(n.anchor,n.head)),effects:xt(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function yt(t,e,i){let n=vt(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=wt(n,vt(t,e[r],s?n.changes.newLength:t.doc.length),s)}let s=pt.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return function(t){let e=t.startState,i=e.facet(at),n=t;for(let s=i.length-1;s>=0;s--){let r=i[s](t);r&&Object.keys(r).length&&(n=wt(n,vt(e,r,t.changes.newLength),!0))}return n==t?t:pt.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}(i?function(t){let e=t.startState,i=!0;for(let s of e.facet(ht)){let e=s(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:mt(i,e))}if(!0!==i){let n,s;if(!1===i)s=t.changes.invertedDesc,n=O.empty(e.doc.length);else{let e=t.changes.filter(i);n=e.changes,s=e.filtered.mapDesc(e.changes).invertedDesc}t=pt.create(e,n,t.selection&&t.selection.map(s),gt.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let n=e.facet(lt);for(let s=n.length-1;s>=0;s--){let i=n[s](t);t=i instanceof pt?i:Array.isArray(i)&&1==i.length&&i[0]instanceof pt?i[0]:yt(e,xt(i),!1)}return t}(s):s)}pt.time=ut.define(),pt.userEvent=ut.define(),pt.addToHistory=ut.define(),pt.remote=ut.define();const bt=[];function xt(t){return null==t?bt:Array.isArray(t)?t:[t]}var St=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(St||(St={}));const kt=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let At;try{At=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(qt){}function Mt(t){return e=>{if(!/\S/.test(e))return St.Space;if(function(t){if(At)return At.test(t);for(let e=0;e<t.length;e++){let i=t[e];if(/\w/.test(i)||i>"€"&&(i.toUpperCase()!=i.toLowerCase()||kt.test(i)))return!0}return!1}(e))return St.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return St.Word;return St.Other}}class Ct{constructor(t,e,i,n,s,r){this.config=t,this.doc=e,this.selection=i,this.values=n,this.status=t.statusTemplate.slice(),this.computeSlot=s,r&&(r._state=this);for(let o=0;o<this.config.dynamicSlots.length;o++)it(this,o<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(null!=i)return it(this,i),nt(this,i);if(e)throw new RangeError("Field is not present in this state")}update(...t){return yt(this,t,!0)}applyTransaction(t){let e,i=this.config,{base:n,compartments:s}=i;for(let o of t.effects)o.is(Z.reconfigure)?(i&&(s=new Map,i.compartments.forEach(((t,e)=>s.set(e,t))),i=null),s.set(o.value.compartment,o.value.extension)):o.is(gt.reconfigure)?(i=null,n=o.value):o.is(gt.appendConfig)&&(i=null,n=xt(n).concat(o.value));if(i)e=t.startState.values.slice();else{i=et.resolve(n,s,this),e=new Ct(i,this.doc,this.selection,i.dynamicSlots.map((()=>null)),((t,e)=>e.reconfigure(t,this)),null).values}let r=t.startState.facet(rt)?t.newSelection:t.newSelection.asSingle();new Ct(i,t.newDoc,r,e,((e,i)=>i.update(e,t)),t)}replaceSelection(t){return"string"==typeof t&&(t=this.toText(t)),this.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:t},range:N.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=xt(i.effects);for(let o=1;o<e.ranges.length;o++){let i=t(e.ranges[o]),h=this.changes(i.changes),l=h.map(n);for(let t=0;t<o;t++)s[t]=s[t].map(l);let a=n.mapDesc(h,!0);s.push(i.range.map(a)),n=n.compose(l),r=gt.mapEffects(r,l).concat(gt.mapEffects(xt(i.effects),a))}return{changes:n,selection:N.create(s,e.mainIndex),effects:r}}changes(t=[]){return t instanceof O?t:O.of(t,this.doc.length,this.facet(Ct.lineSeparator))}toText(t){return n.of(t.split(this.facet(Ct.lineSeparator)||A))}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:(it(this,e),nt(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 $&&null!=this.config.address[n.id]&&(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)if(Object.prototype.hasOwnProperty.call(t,s)){let e=i[s],r=t[s];n.push(e.init((t=>e.spec.fromJSON(r,t))))}return Ct.create({doc:t.doc,selection:N.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let e=et.resolve(t.extensions||[],new Map),i=t.doc instanceof n?t.doc:n.of((t.doc||"").split(e.staticFacet(Ct.lineSeparator)||A)),s=t.selection?t.selection instanceof N?t.selection:N.single(t.selection.anchor,t.selection.head):N.single(0);return I(s,i.length),e.staticFacet(rt)||(s=s.asSingle()),new Ct(e,i,s,e.dynamicSlots.map((()=>null)),((t,e)=>e.create(t)),null)}get tabSize(){return this.facet(Ct.tabSize)}get lineBreak(){return this.facet(Ct.lineSeparator)||"\n"}get readOnly(){return this.facet(ct)}phrase(t,...e){for(let i of this.facet(Ct.phrases))if(Object.prototype.hasOwnProperty.call(i,t)){t=i[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,((t,i)=>{if("$"==i)return"$";let n=+(i||1);return!n||n>e.length?t:e[n-1]}))),t}languageDataAt(t,e,i=-1){let n=[];for(let s of this.facet(st))for(let r of s(this,e,i))Object.prototype.hasOwnProperty.call(r,t)&&n.push(r[t]);return n}charCategorizer(t){return Mt(this.languageDataAt("wordChars",t).join(""))}wordAt(t){let{text:e,from:i,length:n}=this.doc.lineAt(t),s=this.charCategorizer(t),r=t-i,o=t-i;for(;r>0;){let t=w(e,r,!1);if(s(e.slice(t,r))!=St.Word)break;r=t}for(;o<n;){let t=w(e,o);if(s(e.slice(o,t))!=St.Word)break;o=t}return r==o?null:N.range(r+i,o+i)}}Ct.allowMultipleSelections=rt,Ct.tabSize=H.define({combine:t=>t.length?t[0]:4}),Ct.lineSeparator=ot,Ct.readOnly=ct,Ct.phrases=H.define({compare(t,e){let i=Object.keys(t),n=Object.keys(e);return i.length==n.length&&i.every((i=>t[i]==e[i]))}}),Ct.languageData=st,Ct.changeFilter=ht,Ct.transactionFilter=lt,Ct.transactionExtender=at,Z.reconfigure=gt.define();class Ot{eq(t){return this==t}range(t,e=t){return Tt.create(t,e,this)}}Ot.prototype.startSide=Ot.prototype.endSide=0,Ot.prototype.point=!1,Ot.prototype.mapMode=M.TrackDel;class Tt{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new Tt(t,e,i)}}function Dt(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Et{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,h=s[n]-t||(i?this.value[n].endSide:this.value[n].startSide)-e;if(n==r)return h>=0?r:o;h>=0?o=n:r=n+1}}between(t,e,i,n){for(let s=this.findIndex(e,-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 h=0;h<this.value.length;h++){let l,a,c=this.value[h],u=this.from[h]+t,f=this.to[h]+t;if(u==f){let t=e.mapPos(u,c.startSide,c.mapMode);if(null==t)continue;if(l=a=t,c.startSide!=c.endSide&&(a=e.mapPos(u,c.endSide),a<l))continue}else if(l=e.mapPos(u,c.startSide),a=e.mapPos(f,c.endSide),l>a||l==a&&c.startSide>0&&c.endSide<=0)continue;(a-l||c.endSide-c.startSide)<0||(r<0&&(r=l),c.point&&(o=Math.max(o,a-l)),i.push(c),n.push(l-r),s.push(a-r))}return{mapped:i.length?new Et(n,s,i,o):null,pos:r}}}class Rt{constructor(t,e,i,n){this.chunkPos=t,this.chunk=e,this.nextLayer=i,this.maxPoint=n}static create(t,e,i,n){return new Rt(t,e,i,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,r=t.filter;if(0==e.length&&!r)return this;if(i&&(e=e.slice().sort(Dt)),this.isEmpty)return e.length?Rt.of(e):this;let o=new Lt(this,null,-1).goto(0),h=0,l=[],a=new Bt;for(;o.value||h<e.length;)if(h<e.length&&(o.from-e[h].from||o.startSide-e[h].value.startSide)>=0){let t=e[h++];a.addInner(t.from,t.to,t.value)||l.push(t)}else 1==o.rangeIndex&&o.chunkIndex<this.chunk.length&&(h==e.length||this.chunkEnd(o.chunkIndex)<e[h].from)&&(!r||n>this.chunkEnd(o.chunkIndex)||s<this.chunkPos[o.chunkIndex])&&a.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!r||n>o.to||s<o.from||r(o.from,o.to,o.value))&&(a.addInner(o.from,o.to,o.value)||l.push(Tt.create(o.from,o.to,o.value))),o.next());return a.finishInner(this.nextLayer.isEmpty&&!l.length?Rt.empty:this.nextLayer.update({add:l,filter:r,filterFrom:n,filterTo:s}))}map(t){if(t.empty||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],h=t.touchesRange(s,s+o.length);if(!1===h)n=Math.max(n,o.maxPoint),e.push(o),i.push(t.mapPos(s));else if(!0===h){let{mapped:r,pos:h}=o.map(s,t);r&&(n=Math.max(n,r.maxPoint),e.push(r),i.push(h))}}let s=this.nextLayer.map(t);return 0==e.length?s:new Rt(i,e,s||Rt.empty,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 Nt.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return Nt.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)),h=Pt(r,o,i),l=new Vt(r,h,s),a=new Vt(o,h,s);i.iterGaps(((t,e,i)=>Ht(l,t,a,e,i,n))),i.empty&&0==i.length&&Ht(l,0,a,0,0,n)}static eq(t,e,i=0,n){null==n&&(n=999999999);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=Pt(s,r),h=new Vt(s,o,0).goto(i),l=new Vt(r,o,0).goto(i);for(;;){if(h.to!=l.to||!Wt(h.active,l.active)||h.point&&(!l.point||!h.point.eq(l.point)))return!1;if(h.to>n)return!0;h.next(),l.next()}}static spans(t,e,i,n,s=-1){let r=new Vt(t,null,s).goto(e),o=e,h=r.openStart;for(;;){let t=Math.min(r.to,i);if(r.point){let i=r.activeForPoint(r.to),s=r.pointFrom<e?i.length+1:Math.min(i.length,h);n.point(o,t,r.point,i,s,r.pointRank),h=Math.min(r.openEnd(t),i.length)}else t>o&&(n.span(o,t,r.active,h),h=r.openEnd(t));if(r.to>i)return h+(r.point&&r.to>i?1:0);o=r.to,r.next()}}static of(t,e=!1){let i=new Bt;for(let n of t instanceof Tt?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let n=t[i];if(Dt(e,n)>0)return t.slice().sort(Dt);e=n}return t}(t):t)i.add(n.from,n.to,n.value);return i.finish()}static join(t){if(!t.length)return Rt.empty;let e=t[t.length-1];for(let i=t.length-2;i>=0;i--)for(let n=t[i];n!=Rt.empty;n=n.nextLayer)e=new Rt(n.chunkPos,n.chunk,e,Math.max(n.maxPoint,e.maxPoint));return e}}Rt.empty=new Rt([],[],null,-1),Rt.empty.nextLayer=Rt.empty;class Bt{finishChunk(t){this.chunks.push(new Et(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=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(t,e,i){this.addInner(t,e,i)||(this.nextLayer||(this.nextLayer=new Bt)).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(Rt.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=Rt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function Pt(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.touchesRange(e,e+r.chunk[t].length))||s.add(r.chunk[t])}return s}class Lt{constructor(t,e,i,n=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex<this.layer.chunk.length;){let e=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(e)||this.layer.chunkEnd(this.chunkIndex)<t||e.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}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)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=t}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.rank-t.rank||this.to-t.to||this.endSide-t.endSide}}class Nt{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 Lt(r,e,i,s));return 1==n.length?n[0]:new Nt(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--)It(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--)It(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(),It(this.heap,0)}}}function It(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 Vt{constructor(t,e,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Nt.from(t,e,i)}goto(t,e=-1e9){return this.cursor.goto(t,e),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=t,this.endSide=e,this.openStart=-1,this.next(),this}forward(t,e){for(;this.minActive>-1&&(this.activeTo[this.minActive]-t||this.active[this.minActive].endSide-e)<0;)this.removeActive(this.minActive);this.cursor.forward(t,e)}removeActive(t){Ft(this.active,t),Ft(this.activeTo,t),Ft(this.activeRank,t),this.minActive=_t(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:n,rank:s}=this.cursor;for(;e<this.activeRank.length&&(s-this.activeRank[e]||n-this.activeTo[e])>0;)e++;zt(this.active,e,i),zt(this.activeTo,e,n),zt(this.activeRank,e,s),t&&zt(t,e,this.cursor.from),this.minActive=_t(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>t){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&Ft(i,n)}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 t=this.cursor.value;if(t.point){if(!(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=t,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=t.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(i),this.cursor.next()}}}if(i){this.openStart=0;for(let e=i.length-1;e>=0&&i[e]<t;e--)this.openStart++}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&e.push(this.active[i]);return e.reverse()}openEnd(t){let e=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)e++;return e}}function Ht(t,e,i,n,s,r){t.goto(e),i.goto(n);let o=n+s,h=n,l=n-e;for(;;){let e=t.to+l-i.to||t.endSide-i.endSide,n=e<0?t.to+l:i.to,s=Math.min(n,o);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))&&Wt(t.activeForPoint(t.to),i.activeForPoint(i.to))||r.comparePoint(h,s,t.point,i.point):s>h&&!Wt(t.active,i.active)&&r.compareRange(h,s,t.active,i.active),n>o)break;h=n,e<=0&&t.next(),e>=0&&i.next()}}function Wt(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 Ft(t,e){for(let i=e,n=t.length-1;i<n;i++)t[i]=t[i+1];t.pop()}function zt(t,e,i){for(let n=t.length-1;n>=e;n--)t[n+1]=t[n];t[e]=i}function _t(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}function jt(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=w(t,s)}return!0===n?-1:t.length}},16806:function(t,e,i){i.d(e,{V:function(){return o}});i(63721),i(52247),i(71695),i(92745),i(52805),i(43451),i(19134),i(5740),i(11740),i(97003),i(32114),i(39527),i(13334),i(34595),i(47021);const n="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),s="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class o{constructor(t,e){this.rules=[];let{finish:i}=e||{};function n(t){return/^@/.test(t)?[t]:t.split(/,\s*/)}function s(t,e,r,o){let h=[],l=/^@(\w+)\b/.exec(t[0]),a=l&&"keyframes"==l[1];if(l&&null==e)return r.push(t[0]+";");for(let i in e){let o=e[i];if(/&/.test(i))s(i.split(/,\s*/).map((e=>t.map((t=>e.replace(/&/,t))))).reduce(((t,e)=>t.concat(e))),o,r);else if(o&&"object"==typeof o){if(!l)throw new RangeError("The value of a property ("+i+") should be a primitive value.");s(n(i),o,h,a)}else null!=o&&h.push(i.replace(/_.*/,"").replace(/[A-Z]/g,(t=>"-"+t.toLowerCase()))+": "+o+";")}(h.length||a)&&r.push((!i||l||o?t:t.map(i)).join(", ")+" {"+h.join(" ")+"}")}for(let r in t)s(n(r),t[r],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let t=r[n]||1;return r[n]=t+1,"ͼ"+t.toString(36)}static mount(t,e,i){let n=t[s],r=i&&i.nonce;n?r&&n.setNonce(r):n=new l(t,r),n.mount(Array.isArray(e)?e:[e])}}let h=new Map;class l{constructor(t,e){let i=t.ownerDocument||t,n=i.defaultView;if(!t.head&&t.adoptedStyleSheets&&n.CSSStyleSheet){let e=h.get(i);if(e)return t.adoptedStyleSheets=[e.sheet,...t.adoptedStyleSheets],t[s]=e;this.sheet=new n.CSSStyleSheet,t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets],h.set(i,this)}else{this.styleTag=i.createElement("style"),e&&this.styleTag.setAttribute("nonce",e);let n=t.head||t;n.insertBefore(this.styleTag,n.firstChild)}this.modules=[],t[s]=this}mount(t){let e=this.sheet,i=0,n=0;for(let s=0;s<t.length;s++){let r=t[s],o=this.modules.indexOf(r);if(o<n&&o>-1&&(this.modules.splice(o,1),n--,o=-1),-1==o){if(this.modules.splice(n++,0,r),e)for(let t=0;t<r.rules.length;t++)e.insertRule(r.rules[t],i++)}else{for(;n<o;)i+=this.modules[n++].rules.length;i+=r.rules.length,n++}}if(!e){let t="";for(let e=0;e<this.modules.length;e++)t+=this.modules[e].getRules()+"\n";this.styleTag.textContent=t}}setNonce(t){this.styleTag&&this.styleTag.getAttribute("nonce")!=t&&this.styleTag.setAttribute("nonce",t)}}},29341:function(t,e,i){i.d(e,{Jq:function(){return a},Lj:function(){return c},_b:function(){return P},i9:function(){return B},md:function(){return o},mp:function(){return g},vj:function(){return d}});i(52247),i(71695),i(92745),i(61495),i(84283),i(82328),i(55751),i(26200),i(25754),i(22246),i(77439),i(19423),i(19134),i(32517),i(5740),i(11740),i(44495),i(16132),i(36810),i(14953),i(58402),i(31503),i(16440),i(2213),i(57385),i(71375),i(15524),i(20267),i(46692),i(22139),i(39527),i(67670),i(13334),i(36993),i(47021);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.isolate=new o({deserialize:t=>{if(t&&"rtl"!=t&&"ltr"!=t&&"auto"!=t)throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),o.contextHash=new o({perNode:!0}),o.lookAhead=new o({perNode:!0}),o.mounted=new o({perNode:!0});class h{constructor(t,e,i){this.tree=t,this.overlay=e,this.parser=i}static get(t){return t&&t.props&&t.props[o.mounted.id]}}const l=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):l,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,f=new WeakMap;var d;!function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"}(d||(d={}));class g{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=h.get(this);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=0){return new O(this.topNode,t)}cursorAt(t,e=0,i=0){let n=u.get(this)||this.topNode,s=new O(n);return s.moveTo(t,e),u.set(this,s._tree),s}get topNode(){return new b(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(f.get(this)||this.topNode,t,e,!0);return f.set(this,i),i}resolveStack(t,e=0){return function(t,e,i){let n=t.resolveInner(e,i),s=null;for(let r=n instanceof b?n:n.context.parent;r;r=r.parent)if(r.index<0){let t=r.parent;(s||(s=[n])).push(t.resolve(e,i)),r=t}else{let t=h.get(r.tree);if(t&&t.overlay&&t.overlay[0].from<=e&&t.overlay[t.overlay.length-1].to>=e){let o=new b(t.tree,t.overlay[0].from+r.from,-1,r);(s||(s=[n])).push(v(o,e,i,!1))}}return s?M(s):n}(this,t,e)}iterate(t){let{enter:e,leave:i,from:n=0,to:s=this.length}=t,r=t.mode||0,o=(r&d.IncludeAnonymous)>0;for(let h=this.cursor(r|d.IncludeAnonymous);;){let t=!1;if(h.from<=s&&h.to>=n&&(!o&&h.type.isAnonymous||!1!==e(h))){if(h.firstChild())continue;t=!0}for(;t&&i&&(o||!h.type.isAnonymous)&&i(h),!h.nextSibling();){if(!h.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:R(a.none,this.children,this.positions,0,this.children.length,0,this.length,((t,e,i)=>new g(this.type,t,e,i,this.propValues)),t.makeTree||((t,e,i)=>new g(a.none,t,e,i)))}static build(t){return function(t){var e;let{buffer:i,nodeSet:s,maxBufferLength:r=n,reused:h=[],minRepeatType:l=s.types.length}=t,a=Array.isArray(i)?new p(i,i.length):i,c=s.types,u=0,f=0;function d(t,e,i,n,o,g){let{id:p,start:k,end:A,size:M}=a,C=f;for(;M<0;){if(a.next(),-1==M){let e=h[p];return i.push(e),void n.push(k-t)}if(-3==M)return void(u=p);if(-4==M)return void(f=p);throw new RangeError(`Unrecognized record size: ${M}`)}let O,T,D=c[p],E=k-t;if(A-k<=r&&(T=x(a.pos-e,o))){let e=new Uint16Array(T.size-T.skip),i=a.pos-T.size,n=e.length;for(;a.pos>i;)n=S(T.start,e,n);O=new m(e,A-T.start,s),E=T.start-t}else{let t=a.pos-M;a.next();let e=[],i=[],n=p>=l?p:-1,s=0,o=A;for(;a.pos>t;)n>=0&&a.id==n&&a.size>=0?(a.end<=o-r&&(y(e,i,k,s,a.end,o,n,C),s=e.length,o=a.end),a.next()):g>2500?w(k,t,e,i):d(k,t,e,i,n,g+1);if(n>=0&&s>0&&s<e.length&&y(e,i,k,s,k,o,n,C),e.reverse(),i.reverse(),n>-1&&s>0){let t=v(D);O=R(D,e,i,0,e.length,0,A-k,t,t)}else O=b(D,e,i,A-k,C-A)}i.push(O),n.push(E)}function w(t,e,i,n){let o=[],h=0,l=-1;for(;a.pos>e;){let{id:t,start:e,end:i,size:n}=a;if(n>4)a.next();else{if(l>-1&&e<l)break;l<0&&(l=i-r),o.push(t,e,i),h++,a.next()}}if(h){let e=new Uint16Array(4*h),r=o[o.length-2];for(let t=o.length-3,i=0;t>=0;t-=3)e[i++]=o[t],e[i++]=o[t+1]-r,e[i++]=o[t+2]-r,e[i++]=i;i.push(new m(e,o[2]-r,s)),n.push(r-t)}}function v(t){return(e,i,n)=>{let s,r,h=0,l=e.length-1;if(l>=0&&(s=e[l])instanceof g){if(!l&&s.type==t&&s.length==n)return s;(r=s.prop(o.lookAhead))&&(h=i[l]+s.length+r)}return b(t,e,i,n,h)}}function y(t,e,i,n,r,o,h,l){let a=[],c=[];for(;t.length>n;)a.push(t.pop()),c.push(e.pop()+i-r);t.push(b(s.types[h],a,c,o-r,l-o)),e.push(r-i)}function b(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 g(t,e,i,n,r)}function x(t,e){let i=a.fork(),n=0,s=0,o=0,h=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<h)break;let u=i.id>=l?4:0,f=i.start;for(i.next();i.pos>a;){if(i.size<0){if(-3!=i.size)break t;u+=4}else i.id>=l&&(u+=4);i.next()}s=f,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 S(t,e,i){let{id:n,start:s,end:r,size:o}=a;if(a.next(),o>=0&&n<l){let h=i;if(o>4){let n=a.pos-(o-4);for(;a.pos>n;)i=S(t,e,i)}e[--i]=h,e[--i]=r-t,e[--i]=s-t,e[--i]=n}else-3==o?u=n:-4==o&&(f=n);return i}let k=[],A=[];for(;a.pos>0;)d(t.start||0,t.bufferStart||0,k,A,-1,0);let M=null!==(e=t.length)&&void 0!==e?e:k.length?A[0]+k[0].length:0;return new g(c[t.topID],k.reverse(),A.reverse(),M)}(t)}}g.empty=new g(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 m{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)),i==(t+=4))return s;let r=[];for(;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 h=t;h!=e&&!(w(s,n,r[h+1],r[h+2])&&(o=h,i>0));h=r[h+3]);return o}slice(t,e,i){let n=this.buffer,s=new Uint16Array(e-t),r=0;for(let o=t,h=0;o<e;){s[h++]=n[o++],s[h++]=n[o++]-i;let e=s[h++]=n[o++]-i;s[h++]=n[o++]-t,r=Math.max(r,e)}return new m(s,r,this.set)}}function w(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 v(t,e,i,n){for(var s;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 b&&t.index<0?null:t.parent;if(!e)return t;t=e}let r=n?0:d.IgnoreOverlays;if(n)for(let o=t,h=o.parent;h;o=h,h=o.parent)o instanceof b&&o.index<0&&(null===(s=h.enter(e,i,r))||void 0===s?void 0:s.from)!=o.from&&(t=h);for(;;){let n=t.enter(e,i,r);if(!n)return t;t=n}}class y{cursor(t=0){return new O(this,t)}getChild(t,e=null,i=null){let n=x(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return x(this,t,e,i)}resolve(t,e=0){return v(this,t,e,!1)}resolveInner(t,e=0){return v(this,t,e,!0)}matchContext(t){return S(this,t)}enterUnfinishedNodesBefore(t){let e=this.childBefore(t),i=this;for(;e;){let t=e.lastChild;if(!t||t.to!=e.to)break;t.type.isError&&t.from==t.to?(i=e,e=t.prevSibling):e=t}return i}get node(){return this}get next(){return this.parent}}class b extends y{constructor(t,e,i,n){super(),this._tree=t,this.from=e,this.index=i,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,i,n,s=0){for(let r=this;;){for(let{children:o,positions:l}=r._tree,a=e>0?o.length:-1;t!=a;t+=e){let a=o[t],c=l[t]+r.from;if(w(n,i,c,c+a.length))if(a instanceof m){if(s&d.ExcludeBuffers)continue;let o=a.findChild(0,a.buffer.length,e,i-c,n);if(o>-1)return new A(new k(r,a,t,c),null,o)}else if(s&d.IncludeAnonymous||!a.type.isAnonymous||T(a)){let o;if(!(s&d.IgnoreMounts)&&(o=h.get(a))&&!o.overlay)return new b(o.tree,c,t,r);let l=new b(a,c,t,r);return s&d.IncludeAnonymous||!l.type.isAnonymous?l:l.nextChild(e<0?a.children.length-1:0,e,i,n)}}if(s&d.IncludeAnonymous||!r.type.isAnonymous)return null;if(t=r.index>=0?r.index+e:e<0?-1:r._parent._tree.children.length,r=r._parent,!r)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}enter(t,e,i=0){let n;if(!(i&d.IgnoreOverlays)&&(n=h.get(this._tree))&&n.overlay){let i=t-this.from;for(let{from:t,to:s}of n.overlay)if((e>0?t<=i:t<i)&&(e<0?s>=i:s>i))return new b(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;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 tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function x(t,e,i,n){let s=t.cursor(),r=[];if(!s.firstChild())return r;if(null!=i)for(;!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:[]}}function S(t,e,i=e.length-1){for(let n=t.parent;i>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[i]&&e[i]!=n.name)return!1;i--}}return!0}class k{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}}class A extends y{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,i){super(),this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}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 A(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=0){if(i&d.ExcludeBuffers)return null;let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return s<0?null:new A(this.context,this,s)}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 A(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 A(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}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];t.push(i.slice(n,s,r)),e.push(0)}return new g(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function M(t){if(!t.length)return null;let e=0,i=t[0];for(let r=1;r<t.length;r++){let n=t[r];(n.from>i.from||n.to<i.to)&&(i=n,e=r)}let n=i instanceof b&&i.index<0?null:i.parent,s=t.slice();return n?s[e]=n:s.splice(e,1),new C(s,i)}class C{constructor(t,e){this.heads=t,this.node=e}get next(){return M(this.heads)}}class O{get name(){return this.type.name}constructor(t,e=0){if(this.mode=e,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof b)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)}}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 b?(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._tree.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=this.mode){return this.buffer?!(i&d.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&d.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&d.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode));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._tree.children.length;n!=s;n+=t){let t=i._tree.children[n];if(this.mode&d.IncludeAnonymous||t instanceof m||!t.type.isAnonymous||T(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){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,i=0;if(t&&t.context==this.buffer)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 A(this.buffer,e,this.stack[n]);return this.bufferNode=new A(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let i=0;;){let n=!1;if(this.type.isAnonymous||!1!==t(this)){if(this.firstChild()){i++;continue}this.type.isAnonymous||(n=!0)}for(;n&&e&&e(this),n=this.type.isAnonymous,!this.nextSibling();){if(!i)return;this.parent(),i--,n=!0}}}matchContext(t){if(!this.buffer)return S(this.node,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let n=t.length-1,s=this.stack.length-1;n>=0;s--){if(s<0)return S(this.node,t,n);let r=i[e.buffer[this.stack[s]]];if(!r.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}}function T(t){return t.children.some((t=>t instanceof m||!t.type.isAnonymous||T(t)))}const D=new WeakMap;function E(t,e){if(!t.isAnonymous||e instanceof m||e.type!=t)return 1;let i=D.get(e);if(null==i){i=1;for(let n of e.children){if(n.type!=t||!(n instanceof g)){i=1;break}i+=E(t,n)}D.set(e,i)}return i}function R(t,e,i,n,s,r,o,h,l){let a=0;for(let d=n;d<s;d++)a+=E(t,e[d]);let c=Math.ceil(1.5*a/8),u=[],f=[];return function e(i,n,s,o,h){for(let a=s;a<o;){let s=a,d=n[a],g=E(t,i[a]);for(a++;a<o;a++){let e=E(t,i[a]);if(g+e>=c)break;g+=e}if(a==s+1){if(g>c){let t=i[s];e(t.children,t.positions,0,t.children.length,n[s]+h);continue}u.push(i[s])}else{let e=n[a-1]+i[a-1].length-d;u.push(R(t,i,n,s,a,d,e,null,l))}f.push(d+h-r)}}(e,i,n,s,0),(h||l)(u,f,o)}class B{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 B(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,h=0,l=0;;o++){let a=o<e.length?e[o]:null,c=a?a.fromA:1e9;if(c-h>=i)for(;r&&r.from<c;){let e=r;if(h>=e.from||c<=e.to||l){let t=Math.max(e.from,h)-l,i=Math.min(e.to,c)-l;e=t>=i?null:new B(t,i,e.tree,e.offset+l,o>0,!!a)}if(e&&n.push(e),r.to>c)break;r=s<t.length?t[s++]:null}if(!a)break;h=a.toA,l=a.toA-a.toB}return n}}class P{startParse(t,e,i){return"string"==typeof t&&(t=new L(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 L{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)}}new o({perNode:!0})},12482:function(t,e,i){i.d(e,{Gv:()=>B,pJ:()=>Z,bW:()=>I,QR:()=>N});i("52247"),i("63434"),i("71695"),i("92745"),i("61893"),i("19134"),i("96829"),i("39527"),i("92181"),i("99790"),i("67670"),i("88972"),i("47021"),i("61495"),i("84283"),i("82328"),i("55751"),i("26200"),i("25754"),i("22246"),i("77439"),i("19423"),i("32517"),i("5740"),i("11740"),i("44495"),i("16132"),i("36810"),i("14953"),i("58402"),i("31503"),i("16440"),i("2213"),i("57385"),i("71375"),i("15524"),i("20267"),i("46692"),i("22139"),i("13334"),i("36993");const n=1024;let s=0;class r{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=h.match(t)),e=>{let i=t(e);return void 0===i?null:[this,i]}}}r.closedBy=new r({deserialize:t=>t.split(" ")}),r.openedBy=new r({deserialize:t=>t.split(" ")}),r.group=new r({deserialize:t=>t.split(" ")}),r.contextHash=new r({perNode:!0}),r.lookAhead=new r({perNode:!0}),r.mounted=new r({perNode:!0});const o=Object.create(null);class h{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):o,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=new h(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(r.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(r.group),n=-1;n<(i?i.length:0);n++){let s=e[n<0?t.name:i[n]];if(s)return s}}}}h.none=new h("",Object.create(null),0,8);const l=new WeakMap,a=new WeakMap;var c,u;(u=c||(c={}))[u.ExcludeBuffers=1]="ExcludeBuffers",u[u.IncludeAnonymous=2]="IncludeAnonymous",u[u.IgnoreMounts=4]="IgnoreMounts",u[u.IgnoreOverlays=8]="IgnoreOverlays";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(r.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=0){return new k(this.topNode,t)}cursorAt(t,e=0,i=0){let n=l.get(this)||this.topNode,s=new k(n);return s.moveTo(t,e),l.set(this,s._tree),s}get topNode(){return new v(this,0,0,null)}resolve(t,e=0){let i=w(l.get(this)||this.topNode,t,e,!1);return l.set(this,i),i}resolveInner(t,e=0){let i=w(a.get(this)||this.topNode,t,e,!0);return a.set(this,i),i}iterate(t){let{enter:e,leave:i,from:n=0,to:s=this.length}=t,r=t.mode||0,o=(r&c.IncludeAnonymous)>0;for(let h=this.cursor(r|c.IncludeAnonymous);;){let t=!1;if(h.from<=s&&h.to>=n&&(!o&&h.type.isAnonymous||!1!==e(h))){if(h.firstChild())continue;t=!0}for(;t&&i&&(o||!h.type.isAnonymous)&&i(h),!h.nextSibling();){if(!h.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:O(h.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(h.none,t,e,i)))}static build(t){return function(t){var e;let{buffer:i,nodeSet:s,maxBufferLength:o=n,reused:h=[],minRepeatType:l=s.types.length}=t,a=Array.isArray(i)?new d(i,i.length):i,c=s.types,u=0,p=0;function m(t,e,i,n,r){let{id:f,start:d,end:S,size:k}=a,A=p;for(;k<0;){if(a.next(),-1==k){let e=h[f];return i.push(e),void n.push(d-t)}if(-3==k)return void(u=f);if(-4==k)return void(p=f);throw new RangeError(`Unrecognized record size: ${k}`)}let M,C,T=c[f],D=d-t;if(S-d<=o&&(C=b(a.pos-e,r))){let e=new Uint16Array(C.size-C.skip),i=a.pos-C.size,n=e.length;for(;a.pos>i;)n=x(C.start,e,n);M=new g(e,S-C.start,s),D=C.start-t}else{let t=a.pos-k;a.next();let e=[],i=[],n=f>=l?f:-1,s=0,r=S;for(;a.pos>t;)n>=0&&a.id==n&&a.size>=0?(a.end<=r-o&&(v(e,i,d,s,a.end,r,n,A),s=e.length,r=a.end),a.next()):m(d,t,e,i,n);if(n>=0&&s>0&&s<e.length&&v(e,i,d,s,d,r,n,A),e.reverse(),i.reverse(),n>-1&&s>0){let t=w(T);M=O(T,e,i,0,e.length,0,S-d,t,t)}else M=y(T,e,i,S-d,A-S)}i.push(M),n.push(D)}function w(t){return(e,i,n)=>{let s,o,h=0,l=e.length-1;if(l>=0&&(s=e[l])instanceof f){if(!l&&s.type==t&&s.length==n)return s;(o=s.prop(r.lookAhead))&&(h=i[l]+s.length+o)}return y(t,e,i,n,h)}}function v(t,e,i,n,r,o,h,l){let a=[],c=[];for(;t.length>n;)a.push(t.pop()),c.push(e.pop()+i-r);t.push(y(s.types[h],a,c,o-r,l-o)),e.push(r-i)}function y(t,e,i,n,s=0,o){if(u){let t=[r.contextHash,u];o=o?[t].concat(o):[t]}if(s>25){let t=[r.lookAhead,s];o=o?[t].concat(o):[t]}return new f(t,e,i,n,o)}function b(t,e){let i=a.fork(),n=0,s=0,r=0,h=i.end-o,c={size:0,start:0,skip:0};t:for(let o=i.pos-t;i.pos>o;){let t=i.size;if(i.id==e&&t>=0){c.size=n,c.start=s,c.skip=r,r+=4,n+=4,i.next();continue}let a=i.pos-t;if(t<0||a<o||i.start<h)break;let u=i.id>=l?4:0,f=i.start;for(i.next();i.pos>a;){if(i.size<0){if(-3!=i.size)break t;u+=4}else i.id>=l&&(u+=4);i.next()}s=f,n+=t,r+=u}return(e<0||n==t)&&(c.size=n,c.start=s,c.skip=r),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<l){let h=i;if(o>4){let n=a.pos-(o-4);for(;a.pos>n;)i=x(t,e,i)}e[--i]=h,e[--i]=r-t,e[--i]=s-t,e[--i]=n}else-3==o?u=n:-4==o&&(p=n);return i}let S=[],k=[];for(;a.pos>0;)m(t.start||0,t.bufferStart||0,S,k,-1);let A=null!==(e=t.length)&&void 0!==e?e:S.length?k[0]+S[0].length:0;return new f(c[t.topID],S.reverse(),k.reverse(),A)}(t)}}f.empty=new f(h.none,[],[],0);class d{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 d(this.buffer,this.index)}}class g{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return h.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)),i==(t+=4))return s;let r=[];for(;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 h=t;h!=e&&!(p(s,n,r[h+1],r[h+2])&&(o=h,i>0));h=r[h+3]);return o}slice(t,e,i){let n=this.buffer,s=new Uint16Array(e-t),r=0;for(let o=t,h=0;o<e;){s[h++]=n[o++],s[h++]=n[o++]-i;let e=s[h++]=n[o++]-i;s[h++]=n[o++]-t,r=Math.max(r,e)}return new g(s,r,this.set)}}function p(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 m(t,e){let i=t.childBefore(e);for(;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 w(t,e,i,n){for(var s;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 v&&t.index<0?null:t.parent;if(!e)return t;t=e}let r=n?0:c.IgnoreOverlays;if(n)for(let o=t,h=o.parent;h;o=h,h=o.parent)o instanceof v&&o.index<0&&(null===(s=h.enter(e,i,r))||void 0===s?void 0:s.from)!=o.from&&(t=h);for(;;){let n=t.enter(e,i,r);if(!n)return t;t=n}}class v{constructor(t,e,i,n){this._tree=t,this.from=e,this.index=i,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,i,n,s=0){for(let o=this;;){for(let{children:h,positions:l}=o._tree,a=e>0?h.length:-1;t!=a;t+=e){let a=h[t],u=l[t]+o.from;if(p(n,i,u,u+a.length))if(a instanceof g){if(s&c.ExcludeBuffers)continue;let r=a.findChild(0,a.buffer.length,e,i-u,n);if(r>-1)return new S(new x(o,a,t,u),null,r)}else if(s&c.IncludeAnonymous||!a.type.isAnonymous||A(a)){let h;if(!(s&c.IgnoreMounts)&&a.props&&(h=a.prop(r.mounted))&&!h.overlay)return new v(h.tree,u,t,o);let l=new v(a,u,t,o);return s&c.IncludeAnonymous||!l.type.isAnonymous?l:l.nextChild(e<0?a.children.length-1:0,e,i,n)}}if(s&c.IncludeAnonymous||!o.type.isAnonymous)return null;if(t=o.index>=0?o.index+e:e<0?-1:o._parent._tree.children.length,o=o._parent,!o)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}enter(t,e,i=0){let n;if(!(i&c.IgnoreOverlays)&&(n=this._tree.prop(r.mounted))&&n.overlay){let i=t-this.from;for(let{from:t,to:s}of n.overlay)if((e>0?t<=i:t<i)&&(e<0?s>=i:s>i))return new v(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;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}cursor(t=0){return new k(this,t)}get tree(){return this._tree}toTree(){return this._tree}resolve(t,e=0){return w(this,t,e,!1)}resolveInner(t,e=0){return w(this,t,e,!0)}enterUnfinishedNodesBefore(t){return m(this,t)}getChild(t,e=null,i=null){let n=y(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return y(this,t,e,i)}toString(){return this._tree.toString()}get node(){return this}matchContext(t){return b(this,t)}}function y(t,e,i,n){let s=t.cursor(),r=[];if(!s.firstChild())return r;if(null!=i)for(;!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:[]}}function b(t,e,i=e.length-1){for(let n=t.parent;i>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[i]&&e[i]!=n.name)return!1;i--}}return!0}class x{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}}class S{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,i){this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}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 S(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=0){if(i&c.ExcludeBuffers)return null;let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return s<0?null:new S(this.context,this,s)}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 S(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 S(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}cursor(t=0){return new k(this,t)}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];t.push(i.slice(n,s,r)),e.push(0)}return new f(this.type,t,e,this.to-this.from)}resolve(t,e=0){return w(this,t,e,!1)}resolveInner(t,e=0){return w(this,t,e,!0)}enterUnfinishedNodesBefore(t){return m(this,t)}toString(){return this.context.buffer.childString(this.index)}getChild(t,e=null,i=null){let n=y(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return y(this,t,e,i)}get node(){return this}matchContext(t){return b(this,t)}}class k{get name(){return this.type.name}constructor(t,e=0){if(this.mode=e,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof v)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)}}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 v?(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._tree.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=this.mode){return this.buffer?!(i&c.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&c.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&c.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode));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._tree.children.length;n!=s;n+=t){let t=i._tree.children[n];if(this.mode&c.IncludeAnonymous||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){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,i=0;if(t&&t.context==this.buffer)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 S(this.buffer,e,this.stack[n]);return this.bufferNode=new S(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let i=0;;){let n=!1;if(this.type.isAnonymous||!1!==t(this)){if(this.firstChild()){i++;continue}this.type.isAnonymous||(n=!0)}for(;n&&e&&e(this),n=this.type.isAnonymous,!this.nextSibling();){if(!i)return;this.parent(),i--,n=!0}}}matchContext(t){if(!this.buffer)return b(this.node,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let n=t.length-1,s=this.stack.length-1;n>=0;s--){if(s<0)return b(this.node,t,n);let r=i[e.buffer[this.stack[s]]];if(!r.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}}function A(t){return t.children.some((t=>t instanceof g||!t.type.isAnonymous||A(t)))}const M=new WeakMap;function C(t,e){if(!t.isAnonymous||e instanceof g||e.type!=t)return 1;let i=M.get(e);if(null==i){i=1;for(let n of e.children){if(n.type!=t||!(n instanceof f)){i=1;break}i+=C(t,n)}M.set(e,i)}return i}function O(t,e,i,n,s,r,o,h,l){let a=0;for(let d=n;d<s;d++)a+=C(t,e[d]);let c=Math.ceil(1.5*a/8),u=[],f=[];return function e(i,n,s,o,h){for(let a=s;a<o;){let s=a,d=n[a],g=C(t,i[a]);for(a++;a<o;a++){let e=C(t,i[a]);if(g+e>=c)break;g+=e}if(a==s+1){if(g>c){let t=i[s];e(t.children,t.positions,0,t.children.length,n[s]+h);continue}u.push(i[s])}else{let e=n[a-1]+i[a-1].length-d;u.push(O(t,i,n,s,a,d,e,null,l))}f.push(d+h-r)}}(e,i,n,s,0),(h||l)(u,f,o)}new r({perNode:!0});let T=0;class D{constructor(t,e,i){this.set=t,this.base=e,this.modified=i,this.id=T++}static define(t){if(null==t?void 0:t.base)throw new Error("Can not derive from a modified tag");let e=new D([],null,[]);if(e.set.push(e),t)for(let i of t.set)e.set.push(i);return e}static defineModifier(){let t=new R;return e=>e.modified.indexOf(t)>-1?e:R.get(e.base||e,e.modified.concat(t).sort(((t,e)=>t.id-e.id)))}}let E=0;class R{constructor(){this.instances=[],this.id=E++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find((i=>{return i.base==t&&(n=e,s=i.modified,n.length==s.length&&n.every(((t,e)=>t==s[e])));var n,s}));if(i)return i;let n=[],s=new D(n,t,e);for(let o of e)o.instances.push(s);let r=function(t){let e=[[]];for(let i=0;i<t.length;i++)for(let n=0,s=e.length;n<s;n++)e.push(e[n].concat(t[i]));return e.sort(((t,e)=>e.length-t.length))}(e);for(let o of t.set)if(!o.modified.length)for(let t of r)n.push(R.get(o,t));return s}}function B(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]?"":'"'==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,h=i[o];if(!h)throw new RangeError("Invalid path: "+t);let l=new L(n,s,o>0?i.slice(0,o):null);e[h]=l.sort(e[h])}}return P.add(e)}const P=new r;class L{constructor(t,e,i,n){this.tags=t,this.mode=e,this.context=i,this.next=n}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}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}}function N(t,e){let i=Object.create(null);for(let r of t)if(Array.isArray(r.tag))for(let t of r.tag)i[t.id]=r.class;else i[r.tag.id]=r.class;let{scope:n,all:s=null}=e||{};return{style:t=>{let e=s;for(let n of t)for(let t of n.set){let n=i[t.id];if(n){e=e?e+" "+n:n;break}}return e},scope:n}}function I(t,e,i,n=0,s=t.length){let r=new V(n,Array.isArray(e)?e:[e],i);r.highlightRange(t.cursor(),n,s,"",r.highlighters),r.flush(s)}L.empty=new L([],2,null);class V{constructor(t,e,i){this.at=t,this.highlighters=e,this.span=i,this.class=""}startSpan(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,e,i,n,s){let{type:o,from:h,to:l}=t;if(h>=i||l<=e)return;o.isTop&&(s=this.highlighters.filter((t=>!t.scope||t.scope(o))));let a=n,c=function(t){let e=t.type.prop(P);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}(t)||L.empty,u=function(t,e){let i=null;for(let n of t){let t=n.style(e);t&&(i=i?i+" "+t:t)}return i}(s,c.tags);if(u&&(a&&(a+=" "),a+=u,1==c.mode&&(n+=(n?" ":"")+u)),this.startSpan(Math.max(e,h),a),c.opaque)return;let f=t.tree&&t.tree.prop(r.mounted);if(f&&f.overlay){let r=t.node.enter(f.overlay[0].from+h,1),o=this.highlighters.filter((t=>!t.scope||t.scope(f.tree.type))),c=t.firstChild();for(let u=0,d=h;;u++){let g=u<f.overlay.length?f.overlay[u]:null,p=g?g.from+h:l,m=Math.max(e,d),w=Math.min(i,p);if(m<w&&c)for(;t.from<w&&(this.highlightRange(t,m,w,n,s),this.startSpan(Math.min(w,t.to),a),!(t.to>=p)&&t.nextSibling()););if(!g||p>i)break;d=g.to+h,d>e&&(this.highlightRange(r.cursor(),Math.max(e,g.from+h),Math.min(i,d),"",o),this.startSpan(Math.min(i,d),a))}c&&t.parent()}else if(t.firstChild()){f&&(n="");do{if(!(t.to<=e)){if(t.from>=i)break;this.highlightRange(t,e,i,n,s),this.startSpan(Math.min(i,t.to),a)}}while(t.nextSibling());t.parent()}}}const H=D.define,W=H(),F=H(),z=H(F),_=H(F),j=H(),q=H(j),$=H(j),K=H(),J=H(K),G=H(),U=H(),X=H(),Y=H(X),Q=H(),Z={comment:W,lineComment:H(W),blockComment:H(W),docComment:H(W),name:F,variableName:H(F),typeName:z,tagName:H(z),propertyName:_,attributeName:H(_),className:H(F),labelName:H(F),namespace:H(F),macroName:H(F),literal:j,string:q,docString:H(q),character:H(q),attributeValue:H(q),number:$,integer:H($),float:H($),bool:H(j),regexp:H(j),escape:H(j),color:H(j),url:H(j),keyword:G,self:H(G),null:H(G),atom:H(G),unit:H(G),modifier:H(G),operatorKeyword:H(G),controlKeyword:H(G),definitionKeyword:H(G),moduleKeyword:H(G),operator:U,derefOperator:H(U),arithmeticOperator:H(U),logicOperator:H(U),bitwiseOperator:H(U),compareOperator:H(U),updateOperator:H(U),definitionOperator:H(U),typeOperator:H(U),controlOperator:H(U),punctuation:X,separator:H(X),bracket:Y,angleBracket:H(Y),squareBracket:H(Y),paren:H(Y),brace:H(Y),content:K,heading:J,heading1:H(J),heading2:H(J),heading3:H(J),heading4:H(J),heading5:H(J),heading6:H(J),contentSeparator:H(K),list:H(K),quote:H(K),emphasis:H(K),strong:H(K),link:H(K),monospace:H(K),strikethrough:H(K),inserted:H(),deleted:H(),changed:H(),invalid:H(),meta:Q,documentMeta:H(Q),annotation:H(Q),processingInstruction:H(Q),definition:D.defineModifier(),constant:D.defineModifier(),function:D.defineModifier(),standard:D.defineModifier(),local:D.defineModifier(),special:D.defineModifier()};N([{tag:Z.link,class:"tok-link"},{tag:Z.heading,class:"tok-heading"},{tag:Z.emphasis,class:"tok-emphasis"},{tag:Z.strong,class:"tok-strong"},{tag:Z.keyword,class:"tok-keyword"},{tag:Z.atom,class:"tok-atom"},{tag:Z.bool,class:"tok-bool"},{tag:Z.url,class:"tok-url"},{tag:Z.labelName,class:"tok-labelName"},{tag:Z.inserted,class:"tok-inserted"},{tag:Z.deleted,class:"tok-deleted"},{tag:Z.literal,class:"tok-literal"},{tag:Z.string,class:"tok-string"},{tag:Z.number,class:"tok-number"},{tag:[Z.regexp,Z.escape,Z.special(Z.string)],class:"tok-string2"},{tag:Z.variableName,class:"tok-variableName"},{tag:Z.local(Z.variableName),class:"tok-variableName tok-local"},{tag:Z.definition(Z.variableName),class:"tok-variableName tok-definition"},{tag:Z.special(Z.variableName),class:"tok-variableName2"},{tag:Z.definition(Z.propertyName),class:"tok-propertyName tok-definition"},{tag:Z.typeName,class:"tok-typeName"},{tag:Z.namespace,class:"tok-namespace"},{tag:Z.className,class:"tok-className"},{tag:Z.macroName,class:"tok-macroName"},{tag:Z.propertyName,class:"tok-propertyName"},{tag:Z.operator,class:"tok-operator"},{tag:Z.comment,class:"tok-comment"},{tag:Z.meta,class:"tok-meta"},{tag:Z.invalid,class:"tok-invalid"},{tag:Z.punctuation,class:"tok-punctuation"}])},3191:function(t,e,i){i.d(e,{b:function(){return a}});i(69235),i(12385),i(19134),i(11740),i(44495);var n=["and","as","block","endblock","by","cycle","debug","else","elif","extends","filter","endfilter","firstof","do","for","endfor","if","endif","ifchanged","endifchanged","ifequal","endifequal","ifnotequal","set","raw","endraw","endifnotequal","in","include","load","not","now","or","parsed","regroup","reversed","spaceless","call","endcall","macro","endmacro","endspaceless","ssi","templatetag","openblock","closeblock","openvariable","closevariable","without","context","openbrace","closebrace","opencomment","closecomment","widthratio","url","with","endwith","get_current_language","trans","endtrans","noop","blocktrans","endblocktrans","get_available_languages","get_current_language_bidi","pluralize","autoescape","endautoescape"],s=/^[+\-*&%=<>!?|~^]/,r=/^[:\[\(\{]/,o=["true","false"],h=/^(\d[+\-\*\/])?\d+(\.\d+)?/;function l(t,e){var i=t.peek();if(e.incomment)return t.skipTo("#}")?(t.eatWhile(/\#|}/),e.incomment=!1):t.skipToEnd(),"comment";if(e.intag){if(e.operator){if(e.operator=!1,t.match(o))return"atom";if(t.match(h))return"number"}if(e.sign){if(e.sign=!1,t.match(o))return"atom";if(t.match(h))return"number"}if(e.instring)return i==e.instring&&(e.instring=!1),t.next(),"string";if("'"==i||'"'==i)return e.instring=i,t.next(),"string";if(e.inbraces>0&&")"==i)t.next(),e.inbraces--;else if("("==i)t.next(),e.inbraces++;else if(e.inbrackets>0&&"]"==i)t.next(),e.inbrackets--;else if("["==i)t.next(),e.inbrackets++;else{if(!e.lineTag&&(t.match(e.intag+"}")||t.eat("-")&&t.match(e.intag+"}")))return e.intag=!1,"tag";if(t.match(s))return e.operator=!0,"operator";if(t.match(r))e.sign=!0;else{if(1==t.column()&&e.lineTag&&t.match(n))return"keyword";if(t.eat(" ")||t.sol()){if(t.match(n))return"keyword";if(t.match(o))return"atom";if(t.match(h))return"number";t.sol()&&t.next()}else t.next()}}return"variable"}if(t.eat("{")){if(t.eat("#"))return e.incomment=!0,t.skipTo("#}")?(t.eatWhile(/\#|}/),e.incomment=!1):t.skipToEnd(),"comment";if(i=t.eat(/\{|%/))return e.intag=i,e.inbraces=0,e.inbrackets=0,"{"==i&&(e.intag="}"),t.eat("-"),"tag"}else if(t.eat("#")){if("#"==t.peek())return t.skipToEnd(),"comment";if(!t.eol())return e.intag=!0,e.lineTag=!0,e.inbraces=0,e.inbrackets=0,"tag"}t.next()}n=new RegExp("(("+n.join(")|(")+"))\\b"),o=new RegExp("(("+o.join(")|(")+"))\\b");const a={name:"jinja2",startState:function(){return{tokenize:l,inbrackets:0,inbraces:0}},token:function(t,e){var i=e.tokenize(t,e);return t.eol()&&e.lineTag&&!e.instring&&0==e.inbraces&&0==e.inbrackets&&(e.intag=!1,e.lineTag=!1),i},languageData:{commentTokens:{block:{open:"{#",close:"#}",line:"##"}}}}},91847:function(t,e,i){i.d(e,{r:function(){return s}});i(69235),i(12385),i(19134),i(5740),i(11740),i(44495);var n=new RegExp("\\b(("+["true","false","on","off","yes","no"].join(")|(")+"))$","i");const s={name:"yaml",token:function(t,e){var i=t.peek(),s=e.escaped;if(e.escaped=!1,"#"==i&&(0==t.pos||/\s/.test(t.string.charAt(t.pos-1))))return t.skipToEnd(),"comment";if(t.match(/^('([^']|\\.)*'?|"([^"]|\\.)*"?)/))return"string";if(e.literal&&t.indentation()>e.keyCol)return t.skipToEnd(),"string";if(e.literal&&(e.literal=!1),t.sol()){if(e.keyCol=0,e.pair=!1,e.pairStart=!1,t.match("---"))return"def";if(t.match("..."))return"def";if(t.match(/^\s*-\s+/))return"meta"}if(t.match(/^(\{|\}|\[|\])/))return"{"==i?e.inlinePairs++:"}"==i?e.inlinePairs--:"["==i?e.inlineList++:e.inlineList--,"meta";if(e.inlineList>0&&!s&&","==i)return t.next(),"meta";if(e.inlinePairs>0&&!s&&","==i)return e.keyCol=0,e.pair=!1,e.pairStart=!1,t.next(),"meta";if(e.pairStart){if(t.match(/^\s*(\||\>)\s*/))return e.literal=!0,"meta";if(t.match(/^\s*(\&|\*)[a-z0-9\._-]+\b/i))return"variable";if(0==e.inlinePairs&&t.match(/^\s*-?[0-9\.\,]+\s?$/))return"number";if(e.inlinePairs>0&&t.match(/^\s*-?[0-9\.\,]+\s?(?=(,|}))/))return"number";if(t.match(n))return"keyword"}return!e.pair&&t.match(/^\s*(?:[,\[\]{}&*!|>'"%@`][^\s'":]|[^,\[\]{}#&*!|>'"%@`])[^#]*?(?=\s*:($|\s))/)?(e.pair=!0,e.keyCol=t.indentation(),"atom"):e.pair&&t.match(/^:\s*/)?(e.pairStart=!0,"meta"):(e.pairStart=!1,e.escaped="\\"==i,t.next(),null)},startState:function(){return{pair:!1,pairStart:!1,keyCol:0,inlinePairs:0,inlineList:0,literal:!1,escaped:!1}},languageData:{commentTokens:{line:"#"}}}},73755:function(t,e,i){i.a(t,(async function(t,n){try{i.d(e,{Lp:function(){return ut},sW:function(){return C}});i(63721),i(28457),i(71695),i(92745),i(5509),i(69235),i(12385),i(19134),i(5740),i(11740),i(44495),i(64706),i(97003),i(47706),i(46692),i(39527),i(13334),i(36993),i(47021);var s=i(32638),r=i(54373),o=i(65902),h=t([s]);s=(h.then?(await h)():h)[0];const a="function"==typeof String.prototype.normalize?t=>t.normalize("NFKD"):t=>t;class c{constructor(t,e,i=0,n=t.length,s,r){this.test=r,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(a(t)):a,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,r.gm)(this.buffer,this.bufferPos)}next(){for(;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,r.bg)(t),i=this.bufferStart+this.bufferPos;this.bufferPos+=(0,r.nZ)(t);let n=this.normalize(e);if(n.length)for(let s=0,r=i;;s++){let t=n.charCodeAt(s),o=this.match(t,r,this.bufferPos+this.bufferStart);if(s==n.length-1){if(o)return this.value=o,this;break}r==i&&s<e.length&&e.charCodeAt(s)==t&&r++}}}match(t,e,i){let n=null;for(let s=0;s<this.matches.length;s+=2){let e=this.matches[s],r=!1;this.query.charCodeAt(e)==t&&(e==this.query.length-1?n={from:this.matches[s+1],to:i}:(this.matches[s]++,r=!0)),r||(this.matches.splice(s,2),s-=2)}return this.query.charCodeAt(0)==t&&(1==this.query.length?n={from:e,to:i}:this.matches.push(1,e)),n&&this.test&&!this.test(n.from,n.to,this.buffer,this.bufferStart)&&(n=null),n}}"undefined"!=typeof Symbol&&(c.prototype[Symbol.iterator]=function(){return this});const u={from:-1,to:-1,match:/.*/.exec("")},f="gm"+(null==/x/.unicode?"":"u");class d{constructor(t,e,i,n=0,s=t.length){if(this.text=t,this.to=s,this.curLine="",this.done=!1,this.value=u,/\\[sWDnr]|\n|\r|\[\^/.test(e))return new m(t,e,i,n,s);this.re=new RegExp(e,f+((null==i?void 0:i.ignoreCase)?"i":"")),this.test=null==i?void 0:i.test,this.iter=t.iter();let r=t.lineAt(n);this.curLineStart=r.from,this.matchPos=v(t,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=v(this.text,n+(i==n?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<n||i>this.value.to)&&(!this.test||this.test(i,n,e)))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 g=new WeakMap;class p{constructor(t,e){this.from=t,this.text=e}get to(){return this.from+this.text.length}static get(t,e,i){let n=g.get(t);if(!n||n.from>=i||n.to<=e){let n=new p(e,t.sliceString(e,i));return g.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)),g.set(t,new p(r,s)),new p(e,s.slice(e-r,i-r))}}class m{constructor(t,e,i,n,s){this.text=t,this.to=s,this.done=!1,this.value=u,this.matchPos=v(t,n),this.re=new RegExp(e,f+((null==i?void 0:i.ignoreCase)?"i":"")),this.test=null==i?void 0:i.test,this.flat=p.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){let t=this.flat.from+e.index,i=t+e[0].length;if((this.flat.to>=this.to||e.index+e[0].length<=this.flat.text.length-10)&&(!this.test||this.test(t,i,e)))return this.value={from:t,to:i,match:e},this.matchPos=v(this.text,i+(t==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=p.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function w(t){try{return new RegExp(t,f),!0}catch(e){return!1}}function v(t,e){if(e>=t.length)return e;let i,n=t.lineAt(e);for(;e<n.to&&(i=n.text.charCodeAt(e-n.from))>=56320&&i<57344;)e++;return e}function y(t){let e=String(t.state.doc.lineAt(t.state.selection.main.head).number),i=(0,o.Z)("input",{class:"cm-textfield",name:"line",value:e});function n(){let e=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(i.value);if(!e)return;let{state:n}=t,o=n.doc.lineAt(n.selection.main.head),[,h,l,a,c]=e,u=a?+a.slice(1):0,f=l?+l:o.number;if(l&&c){let t=f/100;h&&(t=t*("-"==h?-1:1)+o.number/n.doc.lines),f=Math.round(n.doc.lines*t)}else l&&h&&(f=f*("-"==h?-1:1)+o.number);let d=n.doc.line(Math.max(1,Math.min(n.doc.lines,f))),g=r.jT.cursor(d.from+Math.max(0,Math.min(u,d.length)));t.dispatch({effects:[b.of(!1),s.tk.scrollIntoView(g.from,{y:"center"})],selection:g}),t.focus()}return{dom:(0,o.Z)("form",{class:"cm-gotoLine",onkeydown:e=>{27==e.keyCode?(e.preventDefault(),t.dispatch({effects:b.of(!1)}),t.focus()):13==e.keyCode&&(e.preventDefault(),n())},onsubmit:t=>{t.preventDefault(),n()}},(0,o.Z)("label",t.state.phrase("Go to line"),": ",i)," ",(0,o.Z)("button",{class:"cm-button",type:"submit"},t.state.phrase("go")))}}"undefined"!=typeof Symbol&&(d.prototype[Symbol.iterator]=m.prototype[Symbol.iterator]=function(){return this});const b=r.Py.define(),x=r.QQ.define({create(){return!0},update(t,e){for(let i of e.effects)i.is(b)&&(t=i.value);return t},provide:t=>s.mH.from(t,(t=>t?y:null))}),S=t=>{let e=(0,s.Sd)(t,y);if(!e){let i=[b.of(!0)];null==t.state.field(x,!1)&&i.push(r.Py.appendConfig.of([x,k])),t.dispatch({effects:i}),e=(0,s.Sd)(t,y)}return e&&e.dom.querySelector("input").select(),!0},k=s.tk.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),A={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},M=r.r$.define({combine(t){return(0,r.BO)(t,A,{highlightWordAroundCursor:(t,e)=>t||e,minSelectionLength:Math.min,maxMatches:Math.min})}});function C(t){let e=[B,R];return t&&e.push(M.of(t)),e}const O=s.p.mark({class:"cm-selectionMatch"}),T=s.p.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function D(t,e,i,n){return!(0!=i&&t(e.sliceDoc(i-1,i))==r.D0.Word||n!=e.doc.length&&t(e.sliceDoc(n,n+1))==r.D0.Word)}function E(t,e,i,n){return t(e.sliceDoc(i,i+1))==r.D0.Word&&t(e.sliceDoc(n-1,n))==r.D0.Word}const R=s.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(M),{state:i}=t,n=i.selection;if(n.ranges.length>1)return s.p.none;let r,o=n.main,h=null;if(o.empty){if(!e.highlightWordAroundCursor)return s.p.none;let t=i.wordAt(o.head);if(!t)return s.p.none;h=i.charCategorizer(o.head),r=i.sliceDoc(t.from,t.to)}else{let t=o.to-o.from;if(t<e.minSelectionLength||t>200)return s.p.none;if(e.wholeWords){if(r=i.sliceDoc(o.from,o.to),h=i.charCategorizer(o.head),!D(h,i,o.from,o.to)||!E(h,i,o.from,o.to))return s.p.none}else if(r=i.sliceDoc(o.from,o.to),!r)return s.p.none}let l=[];for(let a of t.visibleRanges){let t=new c(i.doc,r,a.from,a.to);for(;!t.next().done;){let{from:n,to:r}=t.value;if((!h||D(h,i,n,r))&&(o.empty&&n<=o.from&&r>=o.to?l.push(T.range(n,r)):(n>=o.to||r<=o.from)&&l.push(O.range(n,r)),l.length>e.maxMatches))return s.p.none}}return s.p.set(l)}},{decorations:t=>t.decorations}),B=s.tk.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),P=({state:t,dispatch:e})=>{let{selection:i}=t,n=r.jT.create(i.ranges.map((e=>t.wordAt(e.head)||r.jT.cursor(e.head))),i.mainIndex);return!n.eq(i)&&(e(t.update({selection:n})),!0)};function L(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,h=new c(t.doc,e,n[n.length-1].to);;){if(h.next(),!h.done){if(o&&n.some((t=>t.from==h.value.from)))continue;if(r){let e=t.wordAt(h.value.from);if(!e||e.from!=h.value.from||e.to!=h.value.to)continue}return h.value}if(o)return null;h=new c(t.doc,e,0,Math.max(0,n[n.length-1].from-1)),o=!0}}const N=({state:t,dispatch:e})=>{let{ranges:i}=t.selection;if(i.some((t=>t.from===t.to)))return P({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 o=L(t,n);return!!o&&(e(t.update({selection:t.selection.addRange(r.jT.range(o.from,o.to),!1),effects:s.tk.scrollIntoView(o.to)})),!0)},I=r.r$.define({combine(t){return(0,r.BO)(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:t=>new ft(t),scrollToMatch:t=>s.tk.scrollIntoView(t)})}});class V{constructor(t){this.search=t.search,this.caseSensitive=!!t.caseSensitive,this.literal=!!t.literal,this.regexp=!!t.regexp,this.replace=t.replace||"",this.valid=!!this.search&&(!this.regexp||w(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!t.wholeWord}unquote(t){return this.literal?t:t.replace(/\\([nrt\\])/g,((t,e)=>"n"==e?"\n":"r"==e?"\r":"t"==e?"\t":"\\"))}eq(t){return this.search==t.search&&this.replace==t.replace&&this.caseSensitive==t.caseSensitive&&this.regexp==t.regexp&&this.wholeWord==t.wholeWord}create(){return this.regexp?new q(this):new F(this)}getCursor(t,e=0,i){let n=t.doc?t:r.yy.create({doc:t});return null==i&&(i=n.doc.length),this.regexp?z(this,n,e,i):W(this,n,e,i)}}class H{constructor(t){this.spec=t}}function W(t,e,i,n){return new c(e.doc,t.unquoted,i,n,t.caseSensitive?void 0:t=>t.toLowerCase(),t.wholeWord?(s=e.doc,o=e.charCategorizer(e.selection.main.head),(t,e,i,n)=>((n>t||n+i.length<e)&&(n=Math.max(0,t-2),i=s.sliceString(n,Math.min(s.length,e+2))),!(o(_(i,t-n))==r.D0.Word&&o(j(i,t-n))==r.D0.Word||o(j(i,e-n))==r.D0.Word&&o(_(i,e-n))==r.D0.Word))):void 0);var s,o}class F extends H{constructor(t){super(t)}nextMatch(t,e,i){let n=W(this.spec,t,i,t.doc.length).nextOverlapping();if(n.done){let i=Math.min(t.doc.length,e+this.spec.unquoted.length);n=W(this.spec,t,0,i).nextOverlapping()}return n.done||n.value.from==e&&n.value.to==i?null:n.value}prevMatchInRange(t,e,i){for(let n=i;;){let i=Math.max(e,n-1e4-this.spec.unquoted.length),s=W(this.spec,t,i,n),r=null;for(;!s.nextOverlapping().done;)r=s.value;if(r)return r;if(i==e)return null;n-=1e4}}prevMatch(t,e,i){let n=this.prevMatchInRange(t,0,e);return n||(n=this.prevMatchInRange(t,Math.max(0,i-this.spec.unquoted.length),t.doc.length)),!n||n.from==e&&n.to==i?null:n}getReplacement(t){return this.spec.unquote(this.spec.replace)}matchAll(t,e){let i=W(this.spec,t,0,t.doc.length),n=[];for(;!i.next().done;){if(n.length>=e)return null;n.push(i.value)}return n}highlight(t,e,i,n){let s=W(this.spec,t,Math.max(0,e-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,t.doc.length));for(;!s.next().done;)n(s.value.from,s.value.to)}}function z(t,e,i,n){return new d(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:t.wholeWord?(s=e.charCategorizer(e.selection.main.head),(t,e,i)=>!i[0].length||(s(_(i.input,i.index))!=r.D0.Word||s(j(i.input,i.index))!=r.D0.Word)&&(s(j(i.input,i.index+i[0].length))!=r.D0.Word||s(_(i.input,i.index+i[0].length))!=r.D0.Word)):void 0},i,n);var s}function _(t,e){return t.slice((0,r.cp)(t,e,!1),e)}function j(t,e){return t.slice(e,(0,r.cp)(t,e))}class q extends H{nextMatch(t,e,i){let n=z(this.spec,t,i,t.doc.length).next();return n.done&&(n=z(this.spec,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=z(this.spec,t,s,i),o=null;for(;!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.doc.length)}getReplacement(t){return this.spec.unquote(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=z(this.spec,t,0,t.doc.length),n=[];for(;!i.next().done;){if(n.length>=e)return null;n.push(i.value)}return n}highlight(t,e,i,n){let s=z(this.spec,t,Math.max(0,e-250),Math.min(i+250,t.doc.length));for(;!s.next().done;)n(s.value.from,s.value.to)}}const $=r.Py.define(),K=r.Py.define(),J=r.QQ.define({create(t){return new G(ot(t).create(),null)},update(t,e){for(let i of e.effects)i.is($)?t=new G(i.value.create(),t.panel):i.is(K)&&(t=new G(t.query,i.value?rt:null));return t},provide:t=>s.mH.from(t,(t=>t.panel))});class G{constructor(t,e){this.query=t,this.panel=e}}const U=s.p.mark({class:"cm-searchMatch"}),X=s.p.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Y=s.lg.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(J))}update(t){let e=t.state.field(J);(e!=t.startState.field(J)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return s.p.none;let{view:i}=this,n=new r.f_;for(let s=0,r=i.visibleRanges,o=r.length;s<o;s++){let{from:e,to:h}=r[s];for(;s<o-1&&h>r[s+1].from-500;)h=r[++s].to;t.highlight(i.state,e,h,((t,e)=>{let s=i.state.selection.ranges.some((i=>i.from==t&&i.to==e));n.add(t,e,s?X:U)}))}return n.finish()}},{decorations:t=>t.decorations});function Q(t){return e=>{let i=e.state.field(J,!1);return i&&i.query.spec.valid?t(e,i):at(e)}}const Z=Q(((t,{query:e})=>{let{to:i}=t.state.selection.main,n=e.nextMatch(t.state,i,i);if(!n)return!1;let s=r.jT.single(n.from,n.to),o=t.state.facet(I);return t.dispatch({selection:s,effects:[mt(t,n),o.scrollToMatch(s.main,t)],userEvent:"select.search"}),lt(t),!0})),tt=Q(((t,{query:e})=>{let{state:i}=t,{from:n}=i.selection.main,s=e.prevMatch(i,n,n);if(!s)return!1;let o=r.jT.single(s.from,s.to),h=t.state.facet(I);return t.dispatch({selection:o,effects:[mt(t,s),h.scrollToMatch(o.main,t)],userEvent:"select.search"}),lt(t),!0})),et=Q(((t,{query:e})=>{let i=e.matchAll(t.state,1e3);return!(!i||!i.length)&&(t.dispatch({selection:r.jT.create(i.map((t=>r.jT.range(t.from,t.to)))),userEvent:"select.search.matches"}),!0)})),it=({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,o=[],h=0;for(let l=new c(t.doc,t.sliceDoc(n,s));!l.next().done;){if(o.length>1e3)return!1;l.value.from==n&&(h=o.length),o.push(r.jT.range(l.value.from,l.value.to))}return e(t.update({selection:r.jT.create(o,h),userEvent:"select.search.matches"})),!0},nt=Q(((t,{query:e})=>{let{state:i}=t,{from:n,to:o}=i.selection.main;if(i.readOnly)return!1;let h=e.nextMatch(i,n,n);if(!h)return!1;let l,a,c=h,u=[],f=[];if(c.from==n&&c.to==o&&(a=i.toText(e.getReplacement(c)),u.push({from:c.from,to:c.to,insert:a}),c=e.nextMatch(i,c.from,c.to),f.push(s.tk.announce.of(i.phrase("replaced match on line $",i.doc.lineAt(n).number)+"."))),c){let e=0==u.length||u[0].from>=h.to?0:h.to-h.from-a.length;l=r.jT.single(c.from-e,c.to-e),f.push(mt(t,c)),f.push(i.facet(I).scrollToMatch(l.main,t))}return t.dispatch({changes:u,selection:l,effects:f,userEvent:"input.replace"}),!0})),st=Q(((t,{query:e})=>{if(t.state.readOnly)return!1;let i=e.matchAll(t.state,1e9).map((t=>{let{from:i,to:n}=t;return{from:i,to:n,insert:e.getReplacement(t)}}));if(!i.length)return!1;let n=t.state.phrase("replaced $ matches",i.length)+".";return t.dispatch({changes:i,effects:s.tk.announce.of(n),userEvent:"input.replace.all"}),!0}));function rt(t){return t.state.facet(I).createPanel(t)}function ot(t,e){var i,n,s,r,o;let h=t.selection.main,l=h.empty||h.to>h.from+100?"":t.sliceDoc(h.from,h.to);if(e&&!l)return e;let a=t.facet(I);return new V({search:(null!==(i=null==e?void 0:e.literal)&&void 0!==i?i:a.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:null!==(n=null==e?void 0:e.caseSensitive)&&void 0!==n?n:a.caseSensitive,literal:null!==(s=null==e?void 0:e.literal)&&void 0!==s?s:a.literal,regexp:null!==(r=null==e?void 0:e.regexp)&&void 0!==r?r:a.regexp,wholeWord:null!==(o=null==e?void 0:e.wholeWord)&&void 0!==o?o:a.wholeWord})}function ht(t){let e=(0,s.Sd)(t,rt);return e&&e.dom.querySelector("[main-field]")}function lt(t){let e=ht(t);e&&e==t.root.activeElement&&e.select()}const at=t=>{let e=t.state.field(J,!1);if(e&&e.panel){let i=ht(t);if(i&&i!=t.root.activeElement){let n=ot(t.state,e.query.spec);n.valid&&t.dispatch({effects:$.of(n)}),i.focus(),i.select()}}else t.dispatch({effects:[K.of(!0),e?$.of(ot(t.state,e.query.spec)):r.Py.appendConfig.of(vt)]});return!0},ct=t=>{let e=t.state.field(J,!1);if(!e||!e.panel)return!1;let i=(0,s.Sd)(t,rt);return i&&i.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:K.of(!1)}),!0},ut=[{key:"Mod-f",run:at,scope:"editor search-panel"},{key:"F3",run:Z,shift:tt,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Z,shift:tt,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:ct,scope:"editor search-panel"},{key:"Mod-Shift-l",run:it},{key:"Mod-Alt-g",run:S},{key:"Mod-d",run:N,preventDefault:!0}];class ft{constructor(t){this.view=t;let e=this.query=t.state.field(J).query.spec;function i(t,e,i){return(0,o.Z)("button",{class:"cm-button",name:t,onclick:e,type:"button"},i)}this.commit=this.commit.bind(this),this.searchField=(0,o.Z)("input",{value:e.search,placeholder:dt(t,"Find"),"aria-label":dt(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=(0,o.Z)("input",{value:e.replace,placeholder:dt(t,"Replace"),"aria-label":dt(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=(0,o.Z)("input",{type:"checkbox",name:"case",form:"",checked:e.caseSensitive,onchange:this.commit}),this.reField=(0,o.Z)("input",{type:"checkbox",name:"re",form:"",checked:e.regexp,onchange:this.commit}),this.wordField=(0,o.Z)("input",{type:"checkbox",name:"word",form:"",checked:e.wholeWord,onchange:this.commit}),this.dom=(0,o.Z)("div",{onkeydown:t=>this.keydown(t),class:"cm-search"},[this.searchField,i("next",(()=>Z(t)),[dt(t,"next")]),i("prev",(()=>tt(t)),[dt(t,"previous")]),i("select",(()=>et(t)),[dt(t,"all")]),(0,o.Z)("label",null,[this.caseField,dt(t,"match case")]),(0,o.Z)("label",null,[this.reField,dt(t,"regexp")]),(0,o.Z)("label",null,[this.wordField,dt(t,"by word")]),...t.state.readOnly?[]:[(0,o.Z)("br"),this.replaceField,i("replace",(()=>nt(t)),[dt(t,"replace")]),i("replaceAll",(()=>st(t)),[dt(t,"replace all")])],(0,o.Z)("button",{name:"close",onclick:()=>ct(t),"aria-label":dt(t,"close"),type:"button"},["×"])])}commit(){let t=new V({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});t.eq(this.query)||(this.query=t,this.view.dispatch({effects:$.of(t)}))}keydown(t){(0,s.$1)(this.view,t,"search-panel")?t.preventDefault():13==t.keyCode&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?tt:Z)(this.view)):13==t.keyCode&&t.target==this.replaceField&&(t.preventDefault(),nt(this.view))}update(t){for(let e of t.transactions)for(let t of e.effects)t.is($)&&!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,this.wordField.checked=t.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(I).top}}function dt(t,e){return t.state.phrase(e)}const gt=30,pt=/[\s\.,:;?!]/;function mt(t,{from:e,to:i}){let n=t.state.doc.lineAt(e),r=t.state.doc.lineAt(i).to,o=Math.max(n.from,e-gt),h=Math.min(r,i+gt),l=t.state.sliceDoc(o,h);if(o!=n.from)for(let s=0;s<gt;s++)if(!pt.test(l[s+1])&&pt.test(l[s])){l=l.slice(s);break}if(h!=r)for(let s=l.length-1;s>l.length-gt;s--)if(!pt.test(l[s-1])&&pt.test(l[s])){l=l.slice(0,s);break}return s.tk.announce.of(`${t.state.phrase("current match")}. ${l} ${t.state.phrase("on line")} ${n.number}.`)}const wt=s.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"}}),vt=[J,r.Wl.low(Y),wt];n()}catch(l){n(l)}}))},54373:function(t,e,i){i.d(e,{BO:function(){return Ot},D0:function(){return St},Gz:function(){return qt},Py:function(){return gt},QQ:function(){return $},Wl:function(){return Y},Xs:function(){return Bt},YW:function(){return pt},as:function(){return O},bg:function(){return S},cp:function(){return m},f_:function(){return Pt},gc:function(){return M},gm:function(){return x},jT:function(){return N},nZ:function(){return k},q6:function(){return ut},r$:function(){return H},uU:function(){return Tt},xv:function(){return n},yy:function(){return Ct}});i(63721),i(52247),i(71695),i(92745),i(52805),i(61495),i(61893),i(23669),i(69235),i(12385),i(19134),i(32517),i(5740),i(11740),i(92519),i(42179),i(89256),i(24931),i(88463),i(57449),i(19814),i(97003),i(32114),i(39527),i(92181),i(99790),i(67670),i(41360),i(13334),i(34595),i(36993),i(47021);class n{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),r.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),r.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 l(this),s=new l(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 l(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 c(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}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 s(t):r.from(s.split(t,[])):n.empty}}class s extends n{constructor(t,e=function(t){let e=-1;for(let i of t)e+=i.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.text[s],o=n+r.length;if((e?i:o)>=t)return new u(n,o,i,r);n=o+1,i++}}decompose(t,e,i,n){let r=t<=0&&e>=this.length?this:new s(h(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&n){let t=i.pop(),e=o(r.text,t.text.slice(),0,r.length);if(e.length<=32)i.push(new s(e,t.length+r.length));else{let t=e.length>>1;i.push(new s(e.slice(0,t)),new s(e.slice(t)))}}else i.push(r)}replace(t,e,i){if(!(i instanceof s))return super.replace(t,e,i);let n=o(this.text,o(i.text,h(this.text,0,t)),e),l=this.length+i.length-(e-t);return n.length<=32?new s(n,l):r.from(s.split(n,[]),l)}sliceString(t,e=this.length,i="\n"){let n="";for(let s=0,r=0;s<=e&&r<this.text.length;r++){let o=this.text[r],h=s+o.length;s>t&&r&&(n+=i),t<h&&e>s&&(n+=o.slice(Math.max(0,t-s),e-s)),s=h+1}return n}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],n=-1;for(let r of t)i.push(r),n+=r.length+1,32==i.length&&(e.push(new s(i,n)),i=[],n=-1);return n>-1&&e.push(new s(i,n)),e}}class r extends n{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,h=i+r.lines-1;if((e?h:o)>=t)return r.lineInner(t,e,i,n);n=o+1,i=h+1}}decompose(t,e,i,n){for(let s=0,r=0;r<=e&&s<this.children.length;s++){let o=this.children[s],h=r+o.length;if(t<=h&&e>=r){let s=n&((r<=t?1:0)|(h>=e?2:0));r>=t&&h<=e&&!s?i.push(o):o.decompose(t-r,e-r,i,s)}r=h+1}}replace(t,e,i){if(i.lines<this.lines)for(let n=0,s=0;n<this.children.length;n++){let o=this.children[n],h=s+o.length;if(t>=s&&e<=h){let l=o.replace(t-s,e-s,i),a=this.lines-o.lines+l.lines;if(l.lines<a>>4&&l.lines>a>>6){let s=this.children.slice();return s[n]=l,new r(s,this.length-(e-t)+i.length)}return super.replace(s,h,l)}s=h+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i="\n"){let n="";for(let s=0,r=0;s<this.children.length&&r<=e;s++){let o=this.children[s],h=r+o.length;r>t&&s&&(n+=i),t<h&&e>r&&(n+=o.sliceString(t-r,e-r,i)),r=h+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof r))return 0;let i=0,[n,s,o,h]=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==o||s==h)return i;let r=this.children[n],l=t.children[s];if(r!=l)return i+r.scanIdentical(l,e);i+=r.length+1}}static from(t,e=t.reduce(((t,e)=>t+e.length+1),-1)){let i=0;for(let s of t)i+=s.lines;if(i<32){let i=[];for(let e of t)e.flatten(i);return new s(i,e)}let n=Math.max(32,i>>5),o=n<<1,h=n>>1,l=[],a=0,c=-1,u=[];function f(t){let e;if(t.lines>o&&t instanceof r)for(let i of t.children)f(i);else t.lines>h&&(a>h||!a)?(d(),l.push(t)):t instanceof s&&a&&(e=u[u.length-1])instanceof s&&t.lines+e.lines<=32?(a+=t.lines,c+=t.length+1,u[u.length-1]=new s(e.text.concat(t.text),e.length+1+t.length)):(a+t.lines>n&&d(),a+=t.lines,c+=t.length+1,u.push(t))}function d(){0!=a&&(l.push(1==u.length?u[0]:r.from(u,c)),c=-1,a=u.length=0)}for(let s of t)f(s);return d(),1==l.length?l[0]:new r(l,e)}}function o(t,e,i=0,n=1e9){for(let s=0,r=0,o=!0;r<t.length&&s<=n;r++){let h=t[r],l=s+h.length;l>=i&&(l>n&&(h=h.slice(0,n-s)),s<i&&(h=h.slice(i-s)),o?(e[e.length-1]+=h,o=!1):e.push(h)),s=l+1}return e}function h(t,e,i){return o(t,[""],e,i)}n.empty=new s([""],0);class l{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 s?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],r=this.offsets[i],o=r>>1,h=n instanceof s?n.text.length:n.children.length;if(o==(e>0?h: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&r)==(e>0?0:1)){if(this.offsets[i]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(n instanceof s){let s=n.text[o+(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 r=n.children[o+(e<0?-1:0)];t>r.length?(t-=r.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(r),this.offsets.push(e>0?1:(r instanceof s?r.text.length:r.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 l(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 c{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&&(n.prototype[Symbol.iterator]=function(){return this.iter()},l.prototype[Symbol.iterator]=a.prototype[Symbol.iterator]=c.prototype[Symbol.iterator]=function(){return this});class u{constructor(t,e,i,n){this.from=t,this.to=e,this.number=i,this.text=n}get length(){return this.to-this.from}}let f="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 Kt=1;Kt<f.length;Kt++)f[Kt]+=f[Kt-1];function d(t){for(let e=1;e<f.length;e+=2)if(f[e]>t)return f[e-1]<=t;return!1}function g(t){return t>=127462&&t<=127487}const p=8205;function m(t,e,i=!0,n=!0){return(i?w:v)(t,e,n)}function w(t,e,i){if(e==t.length)return e;e&&y(t.charCodeAt(e))&&b(t.charCodeAt(e-1))&&e--;let n=x(t,e);for(e+=k(n);e<t.length;){let s=x(t,e);if(n==p||s==p||i&&d(s))e+=k(s),n=s;else{if(!g(s))break;{let i=0,n=e-2;for(;n>=0&&g(x(t,n));)i++,n-=2;if(i%2==0)break;e+=2}}}return e}function v(t,e,i){for(;e>0;){let n=w(t,e-2,i);if(n<e)return n;e--}return 0}function y(t){return t>=56320&&t<57344}function b(t){return t>=55296&&t<56320}function x(t,e){let i=t.charCodeAt(e);if(!b(i)||e+1==t.length)return i;let n=t.charCodeAt(e+1);return y(n)?n-56320+(i-55296<<10)+65536:i}function S(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10),56320+(1023&t)))}function k(t){return t<65536?1:2}const A=/\r\n?|\n/;var M=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(M||(M={}));class C{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){E(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 C(t)}composeDesc(t){return this.empty?t:t.empty?this:B(this,t)}mapDesc(t,e=!1){return t.empty?this:R(this,t,e)}mapPos(t,e=-1,i=M.Simple){let n=0,s=0;for(let r=0;r<this.sections.length;){let o=this.sections[r++],h=this.sections[r++],l=n+o;if(h<0){if(l>t)return s+(t-n);s+=o}else{if(i!=M.Simple&&l>=t&&(i==M.TrackDel&&n<t&&l>t||i==M.TrackBefore&&n<t||i==M.TrackAfter&&l>t))return null;if(l>t||l==t&&e<0&&!o)return t==n||e<0?s:s+h;s+=h}n=l}if(t>n)throw new RangeError(`Position ${t} is out of range for changeset of length ${n}`);return s}touchesRange(t,e=t){for(let i=0,n=0;i<this.sections.length&&n<=e;){let s=n+this.sections[i++];if(this.sections[i++]>=0&&n<=e&&s>=t)return!(n<t&&s>e)||"cover";n=s}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];t+=(t?" ":"")+i+(n>=0?":"+n:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some((t=>"number"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeDesc");return new C(t)}static create(t){return new C(t)}}class O extends C{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 E(this,((e,i,n,s,r)=>t=t.replace(n,n+(i-e),r)),!1),t}mapDesc(t,e=!1){return R(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let s=0,r=0;s<e.length;s+=2){let o=e[s],h=e[s+1];if(h>=0){e[s]=h,e[s+1]=o;let l=s>>1;for(;i.length<l;)i.push(n.empty);i.push(o?t.slice(r,r+o):n.empty)}r+=o}return new O(e,i)}compose(t){return this.empty?t:t.empty?this:B(this,t,!0)}map(t,e=!1){return t.empty?this:R(this,t,e,!0)}iterChanges(t,e=!1){E(this,t,e)}get desc(){return C.create(this.sections)}filter(t){let e=[],i=[],n=[],s=new P(this);t:for(let r=0,o=0;;){let h=r==t.length?1e9:t[r++];for(;o<h||o==h&&0==s.len;){if(s.done)break t;let t=Math.min(s.len,h-o);T(n,t,-1);let r=-1==s.ins?-1:0==s.off?s.ins:0;T(e,t,r),r>0&&D(i,e,s.text),s.forward(t),o+=t}let l=t[r++];for(;o<l;){if(s.done)break t;let t=Math.min(s.len,l-o);T(e,t,-1),T(n,t,-1==s.ins?-1:0==s.off?s.ins:0),s.forward(t),o+=t}}return{changes:new O(e,i),filtered:C.create(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 s=[],r=[],o=0,h=null;function l(t=!1){if(!t&&!s.length)return;o<e&&T(s,e-o,-1);let i=new O(s,r);h=h?h.compose(i.map(h)):i,s=[],r=[],o=0}return function t(a){if(Array.isArray(a))for(let e of a)t(e);else if(a instanceof O){if(a.length!=e)throw new RangeError(`Mismatched change set length (got ${a.length}, expected ${e})`);l(),h=h?h.compose(a.map(h)):a}else{let{from:t,to:h=t,insert:c}=a;if(t>h||t<0||h>e)throw new RangeError(`Invalid change range ${t} to ${h} (in doc of length ${e})`);let u=c?"string"==typeof c?n.of(c.split(i||A)):c:n.empty,f=u.length;if(t==h&&0==f)return;t<o&&l(),t>o&&T(s,t-o,-1),T(s,h-t,f),D(r,s,u),o=h}}(t),l(!h),h}static empty(t){return new O(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],i=[];for(let s=0;s<t.length;s++){let r=t[s];if("number"==typeof r)e.push(r,-1);else{if(!Array.isArray(r)||"number"!=typeof r[0]||r.some(((t,e)=>e&&"string"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==r.length)e.push(r[0],0);else{for(;i.length<s;)i.push(n.empty);i[s]=n.of(r.slice(1)),e.push(r[0],i[s].length)}}}return new O(e,i)}static createSet(t,e){return new O(t,e)}}function T(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 D(t,e,i){if(0==i.length)return;let s=e.length-2>>1;if(s<t.length)t[t.length-1]=t[t.length-1].append(i);else{for(;t.length<s;)t.push(n.empty);t.push(i)}}function E(t,e,i){let s=t.inserted;for(let r=0,o=0,h=0;h<t.sections.length;){let l=t.sections[h++],a=t.sections[h++];if(a<0)r+=l,o+=l;else{let c=r,u=o,f=n.empty;for(;c+=l,u+=a,a&&s&&(f=f.append(s[h-2>>1])),!(i||h==t.sections.length||t.sections[h+1]<0);)l=t.sections[h++],a=t.sections[h++];e(r,c,o,u,f),r=c,o=u}}}function R(t,e,i,n=!1){let s=[],r=n?[]:null,o=new P(t),h=new P(e);for(let l=-1;;)if(-1==o.ins&&-1==h.ins){let t=Math.min(o.len,h.len);T(s,t,-1),o.forward(t),h.forward(t)}else if(h.ins>=0&&(o.ins<0||l==o.i||0==o.off&&(h.len<o.len||h.len==o.len&&!i))){let t=h.len;for(T(s,h.ins,-1);t;){let e=Math.min(o.len,t);o.ins>=0&&l<o.i&&o.len<=e&&(T(s,0,o.ins),r&&D(r,s,o.text),l=o.i),o.forward(e),t-=e}h.next()}else{if(!(o.ins>=0)){if(o.done&&h.done)return r?O.createSet(s,r):C.create(s);throw new Error("Mismatched change set lengths")}{let t=0,e=o.len;for(;e;)if(-1==h.ins){let i=Math.min(e,h.len);t+=i,e-=i,h.forward(i)}else{if(!(0==h.ins&&h.len<e))break;e-=h.len,h.next()}T(s,t,l<o.i?o.ins:0),r&&l<o.i&&D(r,s,o.text),l=o.i,o.forward(o.len-e)}}}function B(t,e,i=!1){let n=[],s=i?[]:null,r=new P(t),o=new P(e);for(let h=!1;;){if(r.done&&o.done)return s?O.createSet(n,s):C.create(n);if(0==r.ins)T(n,r.len,0,h),r.next();else if(0!=o.len||o.done){if(r.done||o.done)throw new Error("Mismatched change set lengths");{let t=Math.min(r.len2,o.len),e=n.length;if(-1==r.ins){let e=-1==o.ins?-1:o.off?0:o.ins;T(n,t,e,h),s&&e&&D(s,n,o.text)}else-1==o.ins?(T(n,r.off?0:r.len,t,h),s&&D(s,n,r.textBit(t))):(T(n,r.off?0:r.len,o.off?0:o.ins,h),s&&!o.off&&D(s,n,o.text));h=(r.ins>t||o.ins>=0&&o.len>t)&&(h||n.length>e),r.forward2(t),o.forward(t)}}else T(n,0,o.ins,h),s&&D(s,n,o.text),o.next()}}class P{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.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?n.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 L{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,n;return this.empty?i=n=t.mapPos(this.from,e):(i=t.mapPos(this.from,1),n=t.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new L(i,n,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return N.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return N.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 N.range(t.anchor,t.head)}static create(t,e,i){return new L(t,e,i)}}class N{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:N.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 N([this.main],0)}addRange(t,e=!0){return N.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,N.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 N(t.ranges.map((t=>L.fromJSON(t))),t.main)}static single(t,e=t){return new N([N.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 N.normalized(t.slice(),e);i=s.to}return new N(t,e)}static cursor(t,e=0,i,n){return L.create(t,t,(0==e?0:e<0?4:8)|(null==i?3:Math.min(2,i))|(null!=n?n:33554431)<<5)}static range(t,e,i,n){let s=(null!=i?i:33554431)<<5|(null==n?3:Math.min(2,n));return e<t?L.create(e,t,24|s):L.create(t,e,(e>t?4:0)|s)}static normalized(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?N.range(o,r):N.range(r,o))}}return new N(t,e)}}function I(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let V=0;class H{constructor(t,e,i,n,s){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=V++,this.default=t([]),this.extensions="function"==typeof s?s(this):s}static define(t={}){return new H(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:W),!!t.static,t.enables)}of(t){return new F([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new F(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new F(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],(i=>e(i.field(t))))}}function W(t,e){return t==e||t.length==e.length&&t.every(((t,i)=>t===e[i]))}class F{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=this.id,r=t[s]>>1,o=2==this.type,h=!1,l=!1,a=[];for(let c of this.dependencies)"doc"==c?h=!0:"selection"==c?l=!0:1&(null!==(e=t[c.id])&&void 0!==e?e:1)||a.push(t[c.id]);return{create(t){return t.values[r]=i(t),1},update(t,e){if(h&&e.docChanged||l&&(e.docChanged||e.selection)||_(t,a)){let e=i(t);if(o?!z(e,t.values[r],n):!n(e,t.values[r]))return t.values[r]=e,1}return 0},reconfigure:(t,e)=>{let h,l=e.config.address[s];if(null!=l){let s=nt(e,l);if(this.dependencies.every((i=>i instanceof H?e.facet(i)===t.facet(i):!(i instanceof $)||e.field(i,!1)==t.field(i,!1)))||(o?z(h=i(t),s,n):n(h=i(t),s)))return t.values[r]=s,0}else h=i(t);return t.values[r]=h,1}}}}function z(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 _(t,e){let i=!1;for(let n of e)1&it(t,n)&&(i=!0);return i}function j(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;function h(t){let i=[];for(let e=0;e<n.length;e++){let r=nt(t,n[e]);if(2==s[e])for(let t of r)i.push(t);else i.push(r)}return e.combine(i)}return{create(t){for(let e of n)it(t,e);return t.values[o]=h(t),1},update(t,i){if(!_(t,r))return 0;let n=h(t);return e.compare(n,t.values[o])?0:(t.values[o]=n,1)},reconfigure(t,s){let r=_(t,n),l=s.config.facets[e.id],a=s.facet(e);if(l&&!r&&W(i,l))return t.values[o]=a,0;let c=h(t);return e.compare(c,a)?(t.values[o]=a,0):(t.values[o]=c,1)}}}const q=H.define({static:!0});class ${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 $(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(q).find((t=>t.field==this));return((null==e?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:t=>(t.values[e]=this.create(t),1),update:(t,i)=>{let n=t.values[e],s=this.updateF(n,i);return this.compareF(n,s)?0:(t.values[e]=s,1)},reconfigure:(t,i)=>null!=i.config.address[this.id]?(t.values[e]=i.field(this),0):(t.values[e]=this.create(t),1)}}init(t){return[this,q.of({field:this,create:t})]}get extension(){return this}}const K=4,J=3,G=2,U=1;function X(t){return e=>new Q(e,t)}const Y={highest:X(0),high:X(U),default:X(G),low:X(J),lowest:X(K)};class Q{constructor(t,e){this.inner=t,this.prec=e}}class Z{of(t){return new tt(this,t)}reconfigure(t){return Z.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class tt{constructor(t,e){this.compartment=t,this.inner=e}}class et{constructor(t,e,i,n,s,r){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=s,this.facets=r,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return null==e?t.default:this.staticValues[e>>1]}static resolve(t,e,i){let n=[],s=Object.create(null),r=new Map;for(let u of function(t,e,i){let n=[[],[],[],[],[]],s=new Map;function r(t,o){let h=s.get(t);if(null!=h){if(h<=o)return;let e=n[h].indexOf(t);e>-1&&n[h].splice(e,1),t instanceof tt&&i.delete(t.compartment)}if(s.set(t,o),Array.isArray(t))for(let e of t)r(e,o);else if(t instanceof tt){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 Q)r(t.inner,t.prec);else if(t instanceof $)n[o].push(t),t.provides&&r(t.provides,o);else if(t instanceof F)n[o].push(t),t.facet.extensions&&r(t.facet.extensions,G);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,G),n.reduce(((t,e)=>t.concat(e)))}(t,e,r))u instanceof $?n.push(u):(s[u.facet.id]||(s[u.facet.id]=[])).push(u);let o=Object.create(null),h=[],l=[];for(let u of n)o[u.id]=l.length<<1,l.push((t=>u.slot(t)));let a=null==i?void 0:i.config.facets;for(let u in s){let t=s[u],e=t[0].facet,n=a&&a[u]||[];if(t.every((t=>0==t.type)))if(o[e.id]=h.length<<1|1,W(n,t))h.push(i.facet(e));else{let n=e.combine(t.map((t=>t.value)));h.push(i&&e.compare(n,i.facet(e))?i.facet(e):n)}else{for(let e of t)0==e.type?(o[e.id]=h.length<<1|1,h.push(e.value)):(o[e.id]=l.length<<1,l.push((t=>e.dynamicSlot(t))));o[e.id]=l.length<<1,l.push((i=>j(i,e,t)))}}let c=l.map((t=>t(o)));return new et(t,r,c,o,h,s)}}function it(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.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|s}function nt(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const st=H.define(),rt=H.define({combine:t=>t.some((t=>t)),static:!0}),ot=H.define({combine:t=>t.length?t[0]:void 0,static:!0}),ht=H.define(),lt=H.define(),at=H.define(),ct=H.define({combine:t=>!!t.length&&t[0]});class ut{constructor(t,e){this.type=t,this.value=e}static define(){return new ft}}class ft{of(t){return new ut(this,t)}}class dt{constructor(t){this.map=t}of(t){return new gt(this,t)}}class gt{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 gt(this.type,e)}is(t){return this.type==t}static define(t={}){return new dt(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}}gt.reconfigure=gt.define(),gt.appendConfig=gt.define();class pt{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&&I(i,e.newLength),s.some((t=>t.type==pt.time))||(this.annotations=s.concat(pt.time.of(Date.now())))}static create(t,e,i,n,s,r){return new pt(t,e,i,n,s,r)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(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(pt.userEvent);return!(!e||!(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function mt(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 wt(t,e,i){var n;let s,r,o;return i?(s=e.changes,r=O.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:gt.mapEffects(t.effects,s).concat(gt.mapEffects(e.effects,r)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function vt(t,e,i){let n=e.selection,s=xt(e.annotations);return e.userEvent&&(s=s.concat(pt.userEvent.of(e.userEvent))),{changes:e.changes instanceof O?e.changes:O.of(e.changes||[],i,t.facet(ot)),selection:n&&(n instanceof N?n:N.single(n.anchor,n.head)),effects:xt(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function yt(t,e,i){let n=vt(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=wt(n,vt(t,e[r],s?n.changes.newLength:t.doc.length),s)}let s=pt.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return function(t){let e=t.startState,i=e.facet(at),n=t;for(let s=i.length-1;s>=0;s--){let r=i[s](t);r&&Object.keys(r).length&&(n=wt(n,vt(e,r,t.changes.newLength),!0))}return n==t?t:pt.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}(i?function(t){let e=t.startState,i=!0;for(let s of e.facet(ht)){let e=s(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:mt(i,e))}if(!0!==i){let n,s;if(!1===i)s=t.changes.invertedDesc,n=O.empty(e.doc.length);else{let e=t.changes.filter(i);n=e.changes,s=e.filtered.mapDesc(e.changes).invertedDesc}t=pt.create(e,n,t.selection&&t.selection.map(s),gt.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let n=e.facet(lt);for(let s=n.length-1;s>=0;s--){let i=n[s](t);t=i instanceof pt?i:Array.isArray(i)&&1==i.length&&i[0]instanceof pt?i[0]:yt(e,xt(i),!1)}return t}(s):s)}pt.time=ut.define(),pt.userEvent=ut.define(),pt.addToHistory=ut.define(),pt.remote=ut.define();const bt=[];function xt(t){return null==t?bt:Array.isArray(t)?t:[t]}var St=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(St||(St={}));const kt=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let At;try{At=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch($t){}function Mt(t){return e=>{if(!/\S/.test(e))return St.Space;if(function(t){if(At)return At.test(t);for(let e=0;e<t.length;e++){let i=t[e];if(/\w/.test(i)||i>"€"&&(i.toUpperCase()!=i.toLowerCase()||kt.test(i)))return!0}return!1}(e))return St.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return St.Word;return St.Other}}class Ct{constructor(t,e,i,n,s,r){this.config=t,this.doc=e,this.selection=i,this.values=n,this.status=t.statusTemplate.slice(),this.computeSlot=s,r&&(r._state=this);for(let o=0;o<this.config.dynamicSlots.length;o++)it(this,o<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(null!=i)return it(this,i),nt(this,i);if(e)throw new RangeError("Field is not present in this state")}update(...t){return yt(this,t,!0)}applyTransaction(t){let e,i=this.config,{base:n,compartments:s}=i;for(let r of t.effects)r.is(Z.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(gt.reconfigure)?(i=null,n=r.value):r.is(gt.appendConfig)&&(i=null,n=xt(n).concat(r.value));if(i)e=t.startState.values.slice();else{i=et.resolve(n,s,this),e=new Ct(i,this.doc,this.selection,i.dynamicSlots.map((()=>null)),((t,e)=>e.reconfigure(t,this)),null).values}new Ct(i,t.newDoc,t.newSelection,e,((e,i)=>i.update(e,t)),t)}replaceSelection(t){return"string"==typeof t&&(t=this.toText(t)),this.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:t},range:N.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=xt(i.effects);for(let o=1;o<e.ranges.length;o++){let i=t(e.ranges[o]),h=this.changes(i.changes),l=h.map(n);for(let t=0;t<o;t++)s[t]=s[t].map(l);let a=n.mapDesc(h,!0);s.push(i.range.map(a)),n=n.compose(l),r=gt.mapEffects(r,l).concat(gt.mapEffects(xt(i.effects),a))}return{changes:n,selection:N.create(s,e.mainIndex),effects:r}}changes(t=[]){return t instanceof O?t:O.of(t,this.doc.length,this.facet(Ct.lineSeparator))}toText(t){return n.of(t.split(this.facet(Ct.lineSeparator)||A))}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:(it(this,e),nt(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 $&&null!=this.config.address[n.id]&&(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)if(Object.prototype.hasOwnProperty.call(t,s)){let e=i[s],r=t[s];n.push(e.init((t=>e.spec.fromJSON(r,t))))}return Ct.create({doc:t.doc,selection:N.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let e=et.resolve(t.extensions||[],new Map),i=t.doc instanceof n?t.doc:n.of((t.doc||"").split(e.staticFacet(Ct.lineSeparator)||A)),s=t.selection?t.selection instanceof N?t.selection:N.single(t.selection.anchor,t.selection.head):N.single(0);return I(s,i.length),e.staticFacet(rt)||(s=s.asSingle()),new Ct(e,i,s,e.dynamicSlots.map((()=>null)),((t,e)=>e.create(t)),null)}get tabSize(){return this.facet(Ct.tabSize)}get lineBreak(){return this.facet(Ct.lineSeparator)||"\n"}get readOnly(){return this.facet(ct)}phrase(t,...e){for(let i of this.facet(Ct.phrases))if(Object.prototype.hasOwnProperty.call(i,t)){t=i[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,((t,i)=>{if("$"==i)return"$";let n=+(i||1);return!n||n>e.length?t:e[n-1]}))),t}languageDataAt(t,e,i=-1){let n=[];for(let s of this.facet(st))for(let r of s(this,e,i))Object.prototype.hasOwnProperty.call(r,t)&&n.push(r[t]);return n}charCategorizer(t){return Mt(this.languageDataAt("wordChars",t).join(""))}wordAt(t){let{text:e,from:i,length:n}=this.doc.lineAt(t),s=this.charCategorizer(t),r=t-i,o=t-i;for(;r>0;){let t=m(e,r,!1);if(s(e.slice(t,r))!=St.Word)break;r=t}for(;o<n;){let t=m(e,o);if(s(e.slice(o,t))!=St.Word)break;o=t}return r==o?null:N.range(r+i,o+i)}}function Ot(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}Ct.allowMultipleSelections=rt,Ct.tabSize=H.define({combine:t=>t.length?t[0]:4}),Ct.lineSeparator=ot,Ct.readOnly=ct,Ct.phrases=H.define({compare(t,e){let i=Object.keys(t),n=Object.keys(e);return i.length==n.length&&i.every((i=>t[i]==e[i]))}}),Ct.languageData=st,Ct.changeFilter=ht,Ct.transactionFilter=lt,Ct.transactionExtender=at,Z.reconfigure=gt.define();class Tt{eq(t){return this==t}range(t,e=t){return Dt.create(t,e,this)}}Tt.prototype.startSide=Tt.prototype.endSide=0,Tt.prototype.point=!1,Tt.prototype.mapMode=M.TrackDel;class Dt{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new Dt(t,e,i)}}function Et(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Rt{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,h=s[n]-t||(i?this.value[n].endSide:this.value[n].startSide)-e;if(n==r)return h>=0?r:o;h>=0?o=n:r=n+1}}between(t,e,i,n){for(let s=this.findIndex(e,-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 h=0;h<this.value.length;h++){let l,a,c=this.value[h],u=this.from[h]+t,f=this.to[h]+t;if(u==f){let t=e.mapPos(u,c.startSide,c.mapMode);if(null==t)continue;if(l=a=t,c.startSide!=c.endSide&&(a=e.mapPos(u,c.endSide),a<l))continue}else if(l=e.mapPos(u,c.startSide),a=e.mapPos(f,c.endSide),l>a||l==a&&c.startSide>0&&c.endSide<=0)continue;(a-l||c.endSide-c.startSide)<0||(r<0&&(r=l),c.point&&(o=Math.max(o,a-l)),i.push(c),n.push(l-r),s.push(a-r))}return{mapped:i.length?new Rt(n,s,i,o):null,pos:r}}}class Bt{constructor(t,e,i,n){this.chunkPos=t,this.chunk=e,this.nextLayer=i,this.maxPoint=n}static create(t,e,i,n){return new Bt(t,e,i,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,r=t.filter;if(0==e.length&&!r)return this;if(i&&(e=e.slice().sort(Et)),this.isEmpty)return e.length?Bt.of(e):this;let o=new Nt(this,null,-1).goto(0),h=0,l=[],a=new Pt;for(;o.value||h<e.length;)if(h<e.length&&(o.from-e[h].from||o.startSide-e[h].value.startSide)>=0){let t=e[h++];a.addInner(t.from,t.to,t.value)||l.push(t)}else 1==o.rangeIndex&&o.chunkIndex<this.chunk.length&&(h==e.length||this.chunkEnd(o.chunkIndex)<e[h].from)&&(!r||n>this.chunkEnd(o.chunkIndex)||s<this.chunkPos[o.chunkIndex])&&a.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!r||n>o.to||s<o.from||r(o.from,o.to,o.value))&&(a.addInner(o.from,o.to,o.value)||l.push(Dt.create(o.from,o.to,o.value))),o.next());return a.finishInner(this.nextLayer.isEmpty&&!l.length?Bt.empty:this.nextLayer.update({add:l,filter:r,filterFrom:n,filterTo:s}))}map(t){if(t.empty||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],h=t.touchesRange(s,s+o.length);if(!1===h)n=Math.max(n,o.maxPoint),e.push(o),i.push(t.mapPos(s));else if(!0===h){let{mapped:r,pos:h}=o.map(s,t);r&&(n=Math.max(n,r.maxPoint),e.push(r),i.push(h))}}let s=this.nextLayer.map(t);return 0==e.length?s:new Bt(i,e,s||Bt.empty,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 It.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return It.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)),h=Lt(r,o,i),l=new Ht(r,h,s),a=new Ht(o,h,s);i.iterGaps(((t,e,i)=>Wt(l,t,a,e,i,n))),i.empty&&0==i.length&&Wt(l,0,a,0,0,n)}static eq(t,e,i=0,n){null==n&&(n=999999999);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=Lt(s,r),h=new Ht(s,o,0).goto(i),l=new Ht(r,o,0).goto(i);for(;;){if(h.to!=l.to||!Ft(h.active,l.active)||h.point&&(!l.point||!h.point.eq(l.point)))return!1;if(h.to>n)return!0;h.next(),l.next()}}static spans(t,e,i,n,s=-1){let r=new Ht(t,null,s).goto(e),o=e,h=r.openStart;for(;;){let t=Math.min(r.to,i);if(r.point){let i=r.activeForPoint(r.to),s=r.pointFrom<e?i.length+1:Math.min(i.length,h);n.point(o,t,r.point,i,s,r.pointRank),h=Math.min(r.openEnd(t),i.length)}else t>o&&(n.span(o,t,r.active,h),h=r.openEnd(t));if(r.to>i)return h+(r.point&&r.to>i?1:0);o=r.to,r.next()}}static of(t,e=!1){let i=new Pt;for(let n of t instanceof Dt?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let n=t[i];if(Et(e,n)>0)return t.slice().sort(Et);e=n}return t}(t):t)i.add(n.from,n.to,n.value);return i.finish()}}Bt.empty=new Bt([],[],null,-1),Bt.empty.nextLayer=Bt.empty;class Pt{finishChunk(t){this.chunks.push(new Rt(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=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(t,e,i){this.addInner(t,e,i)||(this.nextLayer||(this.nextLayer=new Pt)).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(Bt.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=Bt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function Lt(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.touchesRange(e,e+r.chunk[t].length))||s.add(r.chunk[t])}return s}class Nt{constructor(t,e,i,n=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex<this.layer.chunk.length;){let e=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(e)||this.layer.chunkEnd(this.chunkIndex)<t||e.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}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)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=t}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.rank-t.rank||this.to-t.to||this.endSide-t.endSide}}class It{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 Nt(r,e,i,s));return 1==n.length?n[0]:new It(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--)Vt(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--)Vt(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(),Vt(this.heap,0)}}}function Vt(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 Ht{constructor(t,e,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=It.from(t,e,i)}goto(t,e=-1e9){return this.cursor.goto(t,e),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=t,this.endSide=e,this.openStart=-1,this.next(),this}forward(t,e){for(;this.minActive>-1&&(this.activeTo[this.minActive]-t||this.active[this.minActive].endSide-e)<0;)this.removeActive(this.minActive);this.cursor.forward(t,e)}removeActive(t){zt(this.active,t),zt(this.activeTo,t),zt(this.activeRank,t),this.minActive=jt(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:n,rank:s}=this.cursor;for(;e<this.activeRank.length&&this.activeRank[e]<=s;)e++;_t(this.active,e,i),_t(this.activeTo,e,n),_t(this.activeRank,e,s),t&&_t(t,e,this.cursor.from),this.minActive=jt(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>t){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&zt(i,n)}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 t=this.cursor.value;if(t.point){if(!(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=t,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=t.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(i),this.cursor.next()}}}if(i){this.openStart=0;for(let e=i.length-1;e>=0&&i[e]<t;e--)this.openStart++}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&e.push(this.active[i]);return e.reverse()}openEnd(t){let e=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)e++;return e}}function Wt(t,e,i,n,s,r){t.goto(e),i.goto(n);let o=n+s,h=n,l=n-e;for(;;){let e=t.to+l-i.to||t.endSide-i.endSide,n=e<0?t.to+l:i.to,s=Math.min(n,o);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))&&Ft(t.activeForPoint(t.to),i.activeForPoint(i.to))||r.comparePoint(h,s,t.point,i.point):s>h&&!Ft(t.active,i.active)&&r.compareRange(h,s,t.active,i.active),n>o)break;h=n,e<=0&&t.next(),e>=0&&i.next()}}function Ft(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 zt(t,e){for(let i=e,n=t.length-1;i<n;i++)t[i]=t[i+1];t.pop()}function _t(t,e,i){for(let n=t.length-1;n>=e;n--)t[n+1]=t[n];t[e]=i}function jt(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}function qt(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=m(t,s)}return!0===n?-1:t.length}},32638:function(t,e,i){i.a(t,(async function(t,n){try{i.d(e,{$1:function(){return Nn},Sd:function(){return jn},lg:function(){return $t},mH:function(){return Jn},p:function(){return yt},tk:function(){return kn}});var s=i(31948),r=(i(52247),i(71695),i(92745),i(52805),i(61495),i(61893),i(84283),i(19423),i(23669),i(40251),i(69235),i(12385),i(19134),i(32517),i(5740),i(11740),i(92519),i(42179),i(89256),i(24931),i(88463),i(57449),i(19814),i(97003),i(32114),i(46692),i(39527),i(37210),i(92181),i(99790),i(67670),i(13334),i(34595),i(36993),i(47021),i(54373)),o=i(29933),h=i(96318),l=t([s]);function g(t){let e;return e=11==t.nodeType?t.getSelection?t:t.ownerDocument:t,e.getSelection()}function p(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function m(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function w(t,e){if(!e.anchorNode)return!1;try{return p(t,e.anchorNode)}catch(i){return!1}}function v(t){return 3==t.nodeType?R(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function y(t,e,i,n){return!!i&&(x(t,e,i,n,-1)||x(t,e,i,n,1))}function b(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function x(t,e,i,n,s){for(;;){if(t==i&&e==n)return!0;if(e==(s<0?0:S(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=b(t)+(s<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if(1==(t=t.childNodes[e+(s<0?-1:0)]).nodeType&&"false"==t.contentEditable)return!1;e=s<0?S(t):0}}}function S(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function k(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function A(t){return{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function M(t,e,i,n,s,r,o,h){let l=t.ownerDocument,a=l.defaultView||window;for(let c=t;c;)if(1==c.nodeType){let t,u=c==l.body;if(u)t=A(a);else{if(c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||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 f=0,d=0;if("nearest"==s)e.top<t.top?(d=-(t.top-e.top+o),i>0&&e.bottom>t.bottom+d&&(d=e.bottom-t.bottom+d+o)):e.bottom>t.bottom&&(d=e.bottom-t.bottom+o,i<0&&e.top-d<t.top&&(d=-(t.top+d-e.top+o)));else{let n=e.bottom-e.top,r=t.bottom-t.top;d=("center"==s&&n<=r?e.top+n/2-r/2:"start"==s||"center"==s&&i<0?e.top-o:e.bottom-r+o)-t.top}if("nearest"==n)e.left<t.left?(f=-(t.left-e.left+r),i>0&&e.right>t.right+f&&(f=e.right-t.right+f+r)):e.right>t.right&&(f=e.right-t.right+r,i<0&&e.left<t.left+f&&(f=-(t.left+f-e.left+r)));else{f=("center"==n?e.left+(e.right-e.left)/2-(t.right-t.left)/2:"start"==n==h?e.left-r:e.right-(t.right-t.left)+r)-t.left}if(f||d)if(u)a.scrollBy(f,d);else{let t=0,i=0;if(d){let t=c.scrollTop;c.scrollTop+=d,i=c.scrollTop-t}if(f){let e=c.scrollLeft;c.scrollLeft+=f,t=c.scrollLeft-e}e={left:e.left-t,top:e.top-i,right:e.right-t,bottom:e.bottom-i},t&&Math.abs(t-f)<1&&(n="nearest"),i&&Math.abs(i-d)<1&&(s="nearest")}if(u)break;c=c.assignedSlot||c.parentNode}else{if(11!=c.nodeType)break;c=c.host}}function C(t){let e=t.ownerDocument;for(let i=t.parentNode;i&&i!=e.body;)if(1==i.nodeType){if(i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)return i;i=i.assignedSlot||i.parentNode}else{if(11!=i.nodeType)break;i=i.host}return null}s=(l.then?(await l)():l)[0];class O{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:i}=t;this.set(e,Math.min(t.anchorOffset,e?S(e):0),i,Math.min(t.focusOffset,i?S(i):0))}set(t,e,i,n){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=n}}let T,D=null;function E(t){if(t.setActive)return t.setActive();if(D)return t.focus(D);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==D?{get preventScroll(){return D={preventScroll:!0},!0}}:void 0),!D){D=!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 R(t,e,i=e){let n=T||(T=document.createRange());return n.setEnd(t,i),n.setStart(t,e),n}function B(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 P(t){for(;t;){if(t&&(9==t.nodeType||11==t.nodeType&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function L(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}function N(t,e){let i=e.focusNode,n=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=n)return!1;for(n=Math.min(n,S(i));;)if(n){if(1!=i.nodeType)return!1;let t=i.childNodes[n-1];"false"==t.contentEditable?n--:(i=t,n=S(i))}else{if(i==t)return!0;n=b(i),i=i.parentNode}}class I{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new I(t.parentNode,b(t),e)}static after(t,e){return new I(t.parentNode,b(t)+1,e)}}const V=[];class H{constructor(){this.parent=null,this.dom=null,this.dirty=2}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}sync(t,e){if(2&this.dirty){let i,n=this.dom,s=null;for(let r of this.children){if(r.dirty){if(!r.dom&&(i=s?s.nextSibling:n.firstChild)){let t=H.get(i);(!t||!t.parent&&t.canReuseDOM(r))&&r.reuseDOM(i)}r.sync(t,e),r.dirty=0}if(i=s?s.nextSibling:n.firstChild,e&&!e.written&&e.node==n&&i!=r.dom&&(e.written=!0),r.dom.parentNode==n)for(;i&&i!=r.dom;)i=W(i);else n.insertBefore(r.dom,i);s=r.dom}for(i=s?s.nextSibling:n.firstChild,i&&e&&e.node==n&&(e.written=!0);i;)i=W(i)}else if(1&this.dirty)for(let i of this.children)i.dirty&&(i.sync(t,e),i.dirty=0)}reuseDOM(t){}localPosFromDOM(t,e){let i;if(t==this.dom)i=this.dom.childNodes[e];else{let n=0==S(t)?0:0==e?-1:1;for(;;){let e=t.parentNode;if(e==this.dom)break;0==n&&e.firstChild!=e.lastChild&&(n=t==e.firstChild?-1:1),t=e}i=n<0?t:t.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!H.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 h=0,l=i,a=i;h<this.children.length;h++){let i=this.children[h],c=l+i.length;if(l<t&&c>e)return i.domBoundsAround(t,e,l);if(c>=t&&-1==n&&(n=h,s=l),l>e&&i.dom.parentNode==this.dom){r=h,o=a;break}a=c,l=c+i.breakAfter}return{from:s,to:o<0?i+this.length:o,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:r<this.children.length&&r>=0?this.children[r].dom:null}}markDirty(t=!1){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=V){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 F(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}get isWidget(){return!1}get isHidden(){return!1}merge(t,e,i,n,s,r){return!1}become(t){return!1}canReuseDOM(t){return t.constructor==this.constructor}getSide(){return 0}destroy(){this.parent=null}}function W(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}H.prototype.breakAfter=0;class F{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 z(t,e,i,n,s,r,o,h,l){let{children:a}=t,c=a.length?a[e]:null,u=r.length?r[r.length-1]:null,f=u?u.breakAfter:o;if(!(e==n&&c&&!o&&!f&&r.length<2&&c.merge(i,s,r.length?u:null,0==i,h,l))){if(n<a.length){let t=a[n];t&&s<t.length?(e==n&&(t=t.split(s),s=0),!f&&u&&t.merge(0,s,u,!0,0,l)?r[r.length-1]=t:(s&&t.merge(0,s,null,!1,0,l),r.push(t))):(null==t?void 0:t.breakAfter)&&(u?u.breakAfter=1:o=1),n++}for(c&&(c.breakAfter=o,i>0&&(!o&&r.length&&c.merge(i,c.length,r[0],!1,h,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,h,0),e++));e<n&&r.length;)if(a[n-1].become(r[r.length-1]))n--,r.pop(),l=r.length?0:h;else{if(!a[e].become(r[0]))break;e++,r.shift(),h=r.length?0:l}!r.length&&e&&n<a.length&&!a[e-1].breakAfter&&a[n].merge(0,0,a[e-1],!1,h,l)&&e--,(e<n||r.length)&&t.replaceChildren(e,n,r)}}function _(t,e,i,n,s,r){let o=t.childCursor(),{i:h,off:l}=o.findPos(i,1),{i:a,off:c}=o.findPos(e,-1),u=e-i;for(let f of n)u+=f.length;t.length+=u,z(t,a,c,h,l,n,0,s,r)}let j="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},q="undefined"!=typeof document?document:{documentElement:{style:{}}};const $=/Edge\/(\d+)/.exec(j.userAgent),K=/MSIE \d/.test(j.userAgent),J=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(j.userAgent),G=!!(K||J||$),U=!G&&/gecko\/(\d+)/i.test(j.userAgent),X=!G&&/Chrome\/(\d+)/.exec(j.userAgent),Y="webkitFontSmoothing"in q.documentElement.style,Q=!G&&/Apple Computer/.test(j.vendor),Z=Q&&(/Mobile\/\w+/.test(j.userAgent)||j.maxTouchPoints>2);var a={mac:Z||/Mac/.test(j.platform),windows:/Win/.test(j.platform),linux:/Linux|X11/.test(j.platform),ie:G,ie_version:K?q.documentMode||6:J?+J[1]:$?+$[1]:0,gecko:U,gecko_version:U?+(/Firefox\/(\d+)/.exec(j.userAgent)||[0,0])[1]:0,chrome:!!X,chrome_version:X?+X[1]:0,ios:Z,android:/Android\b/.test(j.userAgent),webkit:Y,safari:Q,webkit_version:Y?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:null!=q.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};const tt=256;class et extends H{constructor(t){super(),this.text=t}get length(){return this.text.length}createDOM(t){this.setDOM(t||document.createTextNode(this.text))}sync(t,e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(t){3==t.nodeType&&this.createDOM(t)}merge(t,e,i){return(!i||i instanceof et&&!(this.length-(e-t)+i.length>tt))&&(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new et(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 I(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 nt(this.dom,t,e)}}class it extends H{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(L(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,e){this.dom?4&this.dirty&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(t,e)}merge(t,e,i,n,s,r){return(!i||!(!(i instanceof it&&i.mark.eq(this.mark))||t&&s<=0||e<this.length&&r<=0))&&(_(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 it(this.mark,e,r)}domAtPos(t){return ut(this,t)}coordsAt(t,e){return dt(this,t,e)}}function nt(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?a.chrome||a.gecko||(e?(s--,o=1):r<n&&(r++,o=-1)):i<0?s--:r<n&&r++;let h=R(t,s,r).getClientRects();if(!h.length)return null;let l=h[(o?o<0:i>=0)?0:h.length-1];return a.safari&&!o&&0==l.width&&(l=Array.prototype.find.call(h,(t=>t.width))||l),o?k(l,o<0):l||null}class st extends H{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||st)(t,e,i)}split(t){let e=st.create(this.widget,this.length-t,this.side);return this.length-=t,e}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.dom.contentEditable="false")}getSide(){return this.side}merge(t,e,i,n,s,r){return!(i&&(!(i instanceof st&&this.widget.compare(i.widget))||t>0&&s<=0||e<this.length&&r<=0))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}become(t){return t instanceof st&&t.side==this.side&&this.widget.constructor==t.widget.constructor&&(this.widget.compare(t.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get overrideDOMText(){if(0==this.length)return r.xv.empty;let t=this;for(;t.parent;)t=t.parent;let{view:e}=t,i=e&&e.state.doc,n=this.posAtStart;return i?i.slice(n,n+this.length):r.xv.empty}domAtPos(t){return(this.length?0==t:this.side>0)?I.before(this.dom):I.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let i=this.widget.coordsAt(this.dom,t,e);if(i)return i;let n=this.dom.getClientRects(),s=null;if(!n.length)return null;let r=this.side?this.side<0:t>0;for(let o=r?n.length-1:0;s=n[o],!(t>0?0==o:o==n.length-1||s.top<s.bottom);o+=r?-1:1);return k(s,!r)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class rt extends st{domAtPos(t){let{topView:e,text:i}=this.widget;return e?ot(t,0,e,i,this.length-e.length,((t,e)=>t.domAtPos(e)),((t,e)=>new I(t,Math.min(e,t.nodeValue.length)))):new I(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?lt(t,e,i,n,this.length-i.length):Math.min(e,this.length)}ignoreMutation(){return!1}get overrideDOMText(){return null}coordsAt(t,e){let{topView:i,text:n}=this.widget;return i?ot(t,e,i,n,this.length-i.length,((t,e,i)=>t.coordsAt(e,i)),((t,e,i)=>nt(t,e,i))):nt(n,t,e)}destroy(){var t;super.destroy(),null===(t=this.widget.topView)||void 0===t||t.destroy()}get isEditable(){return!0}canReuseDOM(){return!0}}function ot(t,e,i,n,s,r,o){if(i instanceof it){for(let h=i.dom.firstChild;h;h=h.nextSibling){let i=H.get(h);if(i){let l=p(h,n),a=i.length+(l?s:0);if(t<a||t==a&&i.getSide()<=0)return l?ot(t,e,i,n,s,r,o):r(i,t,e);t-=a}else{let i=ht(t,e,h,o);if("number"!=typeof i)return i;t=i}}return r(i,i.length,-1)}return i.dom==n?o(n,t,e):r(i,t,e)}function ht(t,e,i,n){if(3==i.nodeType){let s=i.nodeValue.length;if(t<=s)return n(i,t,e);t-=s}else if(1==i.nodeType&&"false"!=i.contentEditable)for(let s=i.firstChild;s;s=s.nextSibling){let i=ht(t,e,s,n);if("number"!=typeof i)return i;t=i}return t}function lt(t,e,i,n,s){if(i instanceof it){let r=0;for(let o=i.dom.firstChild;o;o=o.nextSibling){let i=H.get(o);if(i){let h=p(o,n);if(p(o,t))return r+(h?lt(t,e,i,n,s):i.localPosFromDOM(t,e));r+=i.length+(h?s:0)}else{let i=at(t,e,o);if(null!=i.result)return r+i.result;r+=i.size}}}else if(i.dom==n)return Math.min(e,n.nodeValue.length);return i.localPosFromDOM(t,e)}function at(t,e,i){if(3==i.nodeType)return t==i?{result:e}:{size:i.nodeValue.length};if(1!=i.nodeType||"false"==i.contentEditable)return i.contains(t)?{result:0}:{size:0};{let n=0;for(let s=i.firstChild,r=0;;s=s.nextSibling,r++){if(t==i&&r==e)return{result:n};if(!s)return{size:n};let o=at(t,e,s);if(null!=o.result)return{result:e+o.result};n+=o.size}}}class ct extends H{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof ct&&t.side==this.side}split(){return new ct(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 this.side>0?I.before(this.dom):I.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return r.xv.empty}get isHidden(){return!0}}function ut(t,e){let i=t.dom,{children:n}=t,s=0;for(let r=0;s<n.length;s++){let t=n[s],o=r+t.length;if(!(o==r&&t.getSide()<=0)){if(e>r&&e<o&&t.dom.parentNode==i)return t.domAtPos(e-r);if(e<=r)break;r=o}}for(let r=s;r>0;r--){let t=n[r-1];if(t.dom.parentNode==i)return t.domAtPos(t.length)}for(let r=s;r<n.length;r++){let t=n[r];if(t.dom.parentNode==i)return t.domAtPos(0)}return new I(i,0)}function ft(t,e,i){let n,{children:s}=t;i>0&&e instanceof it&&s.length&&(n=s[s.length-1])instanceof it&&n.mark.eq(e.mark)?ft(n,e.children[0],i-1):(s.push(e),e.setParent(t)),t.length+=e.length}function dt(t,e,i){let n=null,s=-1,r=null,o=-1;!function t(e,h){for(let l=0,a=0;l<e.children.length&&a<=h;l++){let c=e.children[l],u=a+c.length;u>=h&&(c.children.length?t(c,h-a):(!r||r.isHidden&&i>0)&&(u>h||a==u&&c.getSide()>0)?(r=c,o=h-a):(a<h||a==u&&c.getSide()<0&&!c.isHidden)&&(n=c,s=h-a)),a=u}}(t,e);let h=(i<0?n:r)||n||r;return h?h.coordsAt(Math.max(0,h==n?s:o),i):gt(t)}function gt(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=v(e);return i[i.length-1]||null}function pt(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 mt(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 wt(t,e,i){let n=null;if(e)for(let s in e)i&&s in i||t.removeAttribute(n=s);if(i)for(let s in i)e&&e[s]==i[s]||t.setAttribute(n=s,i[s]);return!!n}et.prototype.children=st.prototype.children=ct.prototype.children=V;class vt{eq(t){return!1}updateDOM(t,e){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(t){return!0}coordsAt(t,e,i){return null}get customView(){return null}get isHidden(){return!1}destroy(t){}}var c=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(c||(c={}));class yt extends r.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 bt(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),i=!!t.block;return e+=i&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8,new St(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}=kt(t,n);e=(s?n?-3e8:-1:5e8)-1,i=1+(r?n?2e8:1:-6e8)}return new St(t,e,i,n,t.widget||null,!0)}static line(t){return new xt(t)}static set(t,e=!1){return r.Xs.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}yt.none=r.Xs.empty;class bt extends yt{constructor(t){let{start:e,end:i}=kt(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 bt&&this.tagName==t.tagName&&this.class==t.class&&mt(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)}}bt.prototype.point=!1;class xt extends yt{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof xt&&this.spec.class==t.spec.class&&mt(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)}}xt.prototype.mapMode=r.gc.TrackBefore,xt.prototype.point=!0;class St extends yt{constructor(t,e,i,n,s,o){super(e,i,s,t),this.block=n,this.isReplace=o,this.mapMode=n?e<=0?r.gc.TrackBefore:r.gc.TrackAfter:r.gc.TrackDel}get type(){return this.startSide<this.endSide?c.WidgetRange:this.startSide<=0?c.WidgetBefore:c.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof St&&(e=this.widget,i=t.widget,e==i||!!(e&&i&&e.compare(i)))&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide;var e,i}range(t,e=t){if(this.isReplace&&(t>e||t==e&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}}function kt(t,e=!1){let{inclusiveStart:i,inclusiveEnd:n}=t;return null==i&&(i=t.inclusive),null==n&&(n=t.inclusive),{start:null!=i?i:e,end:null!=n?n:e}}function At(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)}St.prototype.point=!0;class Mt extends H{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 Mt))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),_(this,t,e,i?i.children:[],s,r),!0}split(t){let e=new Mt;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);for(;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&&(this.markDirty(),t.setDOM(this.dom),t.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(t){mt(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){ft(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=pt(e,this.attrs||{})),i&&(this.attrs=pt({class:i},this.attrs||{}))}domAtPos(t){return ut(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.dirty|=6)}sync(t,e){var i;this.dom?4&this.dirty&&(L(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&&(wt(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t,e);let n=this.dom.lastChild;for(;n&&H.get(n)instanceof it;)n=n.lastChild;if(!(n&&this.length&&("BR"==n.nodeName||0!=(null===(i=H.get(n))||void 0===i?void 0:i.isEditable)||a.ios&&this.children.some((t=>t instanceof et))))){let t=document.createElement("BR");t.cmIgnore=!0,this.dom.appendChild(t)}}measureTextSize(){if(0==this.children.length||this.length>20)return null;let t,e=0;for(let i of this.children){if(!(i instanceof et)||/[^ -~]/.test(i.text))return null;let n=v(i.dom);if(1!=n.length)return null;e+=n[0].width,t=n[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(t,e){let i=dt(this,t,e);if(!this.children.length&&i&&this.parent){let{heightOracle:t}=this.parent.view.viewState,e=i.bottom-i.top;if(Math.abs(e-t.lineHeight)<2&&t.textHeight<e){let n=(e-t.textHeight)/2;return{top:i.top+n,bottom:i.bottom-n,left:i.left,right:i.left}}}return i}become(t){return!1}get type(){return c.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 Mt)return s;if(r>e)break}n=r+s.breakAfter}return null}}class Ct extends H{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 Ct&&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?I.before(this.dom):I.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new Ct(this.widget,e,this.type);return i.breakAfter=this.breakAfter,i}get children(){return V}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.dom.contentEditable="false")}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):r.xv.empty}domBoundsAround(){return null}become(t){return t instanceof Ct&&t.widget.constructor==this.widget.constructor&&(t.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,this.type=t.type,this.breakAfter=t.breakAfter,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(t,e){return this.widget.coordsAt(this.dom,t,e)}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class Ot{constructor(t,e,i,n){this.doc=t,this.pos=e,this.end=i,this.disallowBlockEffectsFor=n,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],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 Ct&&t.type==c.WidgetBefore)}getLine(){return this.curLine||(this.content.push(this.curLine=new Mt),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(Tt(new ct(-1),t),t.length),this.pendingBuffer=0)}addBlockWidget(t){this.flushBuffer(),this.curLine=null,this.content.push(t)}finish(t){this.pendingBuffer&&t<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||this.getLine()}buildText(t,e,i){for(;t>0;){if(this.textOff==this.text.length){let{value:e,lineBreak:i,done:n}=this.cursor.next(this.skip);if(this.skip=0,n)throw new Error("Ran out of text content when drawing inline views");if(i){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,t--;continue}this.text=e,this.textOff=0}let n=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(e.length-i)),this.getLine().append(Tt(new et(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,r){if(this.disallowBlockEffectsFor[r]&&i instanceof St){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")}let o=e-t;if(i instanceof St)if(i.block){let{type:t}=i;t!=c.WidgetAfter||this.posCovered()||this.getLine(),this.addBlockWidget(new Ct(i.widget||new Dt("div"),o,t))}else{let r=st.create(i.widget||new Dt("span"),o,o?0:i.startSide),h=this.atCursorPos&&!r.isEditable&&s<=n.length&&(t<e||i.startSide>0),l=!r.isEditable&&(t<e||s>n.length||i.startSide<=0),a=this.getLine();2!=this.pendingBuffer||h||r.isEditable||(this.pendingBuffer=0),this.flushBuffer(n),h&&(a.append(Tt(new ct(1),n),s),s=n.length+Math.max(0,s-n.length)),a.append(Tt(r,n),s),this.atCursorPos=l,this.pendingBuffer=l?t<e||s>n.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=n.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);o&&(this.textOff+o<=this.text.length?this.textOff+=o:(this.skip+=o-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=e),this.openStart<0&&(this.openStart=s)}static build(t,e,i,n,s){let o=new Ot(t,e,i,s);return o.openEnd=r.Xs.spans(n,e,i,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}}function Tt(t,e){for(let i of e)t=new it(i,[t],t.length);return t}class Dt extends vt{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}const Et=r.r$.define(),Rt=r.r$.define(),Bt=r.r$.define(),Pt=r.r$.define(),Lt=r.r$.define(),Nt=r.r$.define(),It=r.r$.define(),Vt=r.r$.define({combine:t=>t.some((t=>t))}),Ht=r.r$.define({combine:t=>t.some((t=>t))});class Wt{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 Wt(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin)}}const Ft=r.Py.define({map:(t,e)=>t.map(e)});function zt(t,e,i){let n=t.facet(Pt);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 _t=r.r$.define({combine:t=>!t.length||t[0]});let jt=0;const qt=r.r$.define();class $t{constructor(t,e,i,n){this.id=t,this.create=e,this.domEventHandlers=i,this.extension=n(this)}static define(t,e){const{eventHandlers:i,provide:n,decorations:s}=e||{};return new $t(jt++,t,i,(t=>{let e=[qt.of(t)];return s&&e.push(Ut.of((e=>{let i=e.plugin(t);return i?s(i):yt.none}))),n&&e.push(n(t)),e}))}static fromClass(t,e){return $t.define((e=>new t(e)),e)}}class Kt{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}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(zt(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){zt(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){zt(t.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Jt=r.r$.define(),Gt=r.r$.define(),Ut=r.r$.define(),Xt=r.r$.define(),Yt=r.r$.define();function Qt(t){let e=0,i=0,n=0,s=0;for(let r of t.state.facet(Yt)){let o=r(t);o&&(null!=o.left&&(e=Math.max(e,o.left)),null!=o.right&&(i=Math.max(i,o.right)),null!=o.top&&(n=Math.max(n,o.top)),null!=o.bottom&&(s=Math.max(s,o.bottom)))}return{left:e,right:i,top:n,bottom:s}}const Zt=r.r$.define();class te{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new te(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let n=t[e-1];if(!(n.fromA>i.toA)){if(n.toA<i.fromA)break;i=i.join(n),t.splice(e-1,1)}}return t.splice(e,0,i),t}static extendWithRanges(t,e){if(0==e.length)return t;let i=[];for(let n=0,s=0,r=0,o=0;;n++){let h=n==t.length?null:t[n],l=r-o,a=h?h.fromB:1e9;for(;s<e.length&&e[s]<a;){let t=e[s],n=e[s+1],r=Math.max(o,t),h=Math.min(a,n);if(r<=h&&new te(r+l,h+l,r,h).addToSet(i),n>a)break;s+=2}if(!h)return i;new te(h.fromA,h.toA,h.fromB,h.toB).addToSet(i),r=h.toA,o=h.toB}}}class ee{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=r.as.empty(this.startState.doc.length);for(let s of i)this.changes=this.changes.compose(s.changes);let n=[];this.changes.iterChangedRanges(((t,e,i,s)=>n.push(new te(t,e,i,s)))),this.changedRanges=n}static create(t,e,i){return new ee(t,e,i)}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 u=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(u||(u={}));const ie=u.LTR,ne=u.RTL;function se(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}const re=se("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),oe=se("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),he=Object.create(null),le=[];for(let Un of["()","[]","{}"]){let Xn=Un.charCodeAt(0),Yn=Un.charCodeAt(1);he[Xn]=Yn,he[Yn]=-Xn}const ae=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class ce{constructor(t,e,i){this.from=t,this.to=e,this.level=i}get dir(){return this.level%2?ne:ie}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 ue=[];function fe(t,e){let i=t.length,n=e==ie?1:2,s=e==ie?2:1;if(!t||1==n&&!ae.test(t))return de(i);for(let h=0,l=n,a=n;h<i;h++){let e=(r=t.charCodeAt(h))<=247?re[r]:1424<=r&&r<=1524?2:1536<=r&&r<=1785?oe[r-1536]:1774<=r&&r<=2220?4:8192<=r&&r<=8203?256:64336<=r&&r<=65023?4:8204==r?256:1;512==e?e=l:8==e&&4==a&&(e=16),ue[h]=4==e?2:e,7&e&&(a=e),l=e}var r;for(let h=0,l=n,a=n;h<i;h++){let t=ue[h];if(128==t)h<i-1&&l==ue[h+1]&&24&l?t=ue[h]=l:ue[h]=256;else if(64==t){let t=h+1;for(;t<i&&64==ue[t];)t++;let e=h&&8==l||t<i&&8==ue[t]?1==a?1:8:256;for(let i=h;i<t;i++)ue[i]=e;h=t-1}else 8==t&&1==a&&(ue[h]=1);l=t,7&t&&(a=t)}for(let h,l,a,c=0,u=0,f=0;c<i;c++)if(l=he[h=t.charCodeAt(c)])if(l<0){for(let t=u-3;t>=0;t-=3)if(le[t+1]==-l){let e=le[t+2],i=2&e?n:4&e?1&e?s:n:0;i&&(ue[c]=ue[le[t]]=i),u=t;break}}else{if(189==le.length)break;le[u++]=c,le[u++]=h,le[u++]=f}else if(2==(a=ue[c])||1==a){let t=a==n;f=t?0:1;for(let e=u-3;e>=0;e-=3){let i=le[e+2];if(2&i)break;if(t)le[e+2]|=2;else{if(4&i)break;le[e+2]|=4}}}for(let h=0;h<i;h++)if(256==ue[h]){let t=h+1;for(;t<i&&256==ue[t];)t++;let e=1==(h?ue[h-1]:n),s=e==(1==(t<i?ue[t]:n))?e?1:2:n;for(let i=h;i<t;i++)ue[i]=s;h=t-1}let o=[];if(1==n)for(let h=0;h<i;){let t=h,e=1!=ue[h++];for(;h<i&&e==(1!=ue[h]);)h++;if(e)for(let i=h;i>t;){let e=i,n=2!=ue[--i];for(;i>t&&n==(2!=ue[i-1]);)i--;o.push(new ce(i,e,n?2:1))}else o.push(new ce(t,h,0))}else for(let h=0;h<i;){let t=h,e=2==ue[h++];for(;h<i&&e==(2==ue[h]);)h++;o.push(new ce(t,h,e?1:2))}return o}function de(t){return[new ce(0,t,0)]}let ge="";function pe(t,e,i,n,s){var o;let h=n.head-t.from,l=-1;if(0==h){if(!s||!t.length)return null;e[0].level!=i&&(h=e[0].side(!1,i),l=0)}else if(h==t.length){if(s)return null;let t=e[e.length-1];t.level!=i&&(h=t.side(!0,i),l=e.length-1)}l<0&&(l=ce.find(e,h,null!==(o=n.bidiLevel)&&void 0!==o?o:-1,n.assoc));let a=e[l];h==a.side(s,i)&&(a=e[l+=s?1:-1],h=a.side(!s,i));let c=s==(a.dir==i),u=(0,r.cp)(t.text,h,c);if(ge=t.text.slice(Math.min(h,u),Math.max(h,u)),u!=a.side(s,i))return r.jT.cursor(u+t.from,c?-1:1,a.level);let f=l==(s?e.length-1:0)?null:e[l+(s?1:-1)];return f||a.level==i?f&&f.level<a.level?r.jT.cursor(f.side(!s,i)+t.from,s?1:-1,f.level):r.jT.cursor(u+t.from,s?-1:1,a.level):r.jT.cursor(s?t.to:t.from,s?-1:1,i)}const me="￿";class we{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(r.yy.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=me}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let n=t;;){this.findPointBefore(i,n);let t=this.text.length;this.readNode(n);let s=n.nextSibling;if(s==e)break;let r=H.get(n),o=H.get(s);(r&&o?r.breakAfter:(r?r.breakAfter:ve(n))||ve(s)&&("BR"!=n.nodeName||n.cmIgnore)&&this.text.length>t)&&this.lineBreak(),n=s}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=H.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 ve(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}class ye{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class be extends H{constructor(t){super(),this.view=t,this.compositionDeco=yt.none,this.decorations=[],this.dynamicDecorationMap=[],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 Mt],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new te(0,0,0,t.state.doc.length)],0)}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=yt.none:(t.transactions.length||this.dirty)&&(this.compositionDeco=ke(this.view,t.changes)),(a.ie||a.chrome)&&!this.compositionDeco.size&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let i=Te(this.decorations,this.updateDeco(),t.changes);return e=te.extendWithRanges(e,i),(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.flexBasis=this.minWidth?this.minWidth+"px":"";let t=a.chrome||a.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,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 Ct&&s.widget instanceof xe&&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:h}=e,{content:l,breakAtStart:a,openStart:c,openEnd:u}=Ot.build(this.view.state.doc,o,h,this.decorations,this.dynamicDecorationMap),{i:f,off:d}=i.findPos(r,1),{i:g,off:p}=i.findPos(s,-1);z(this,g,p,f,d,l,a,c,u)}}updateSelection(t=!1,e=!1){!t&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let i=this.view.root.activeElement,n=i==this.dom,s=!n&&w(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(n||e||s))return;let r=this.forceSelection;this.forceSelection=!1;let o=this.view.state.selection.main,h=this.domAtPos(o.anchor),l=o.empty?h:this.domAtPos(o.head);if(a.gecko&&o.empty&&!this.compositionDeco.size&&(1==(c=h).node.nodeType&&c.node.firstChild&&(0==c.offset||"false"==c.node.childNodes[c.offset-1].contentEditable)&&(c.offset==c.node.childNodes.length||"false"==c.node.childNodes[c.offset].contentEditable))){let t=document.createTextNode("");this.view.observer.ignore((()=>h.node.insertBefore(t,h.node.childNodes[h.offset]||null))),h=l=new I(t,0),r=!0}var c;let u=this.view.observer.selectionRange;!r&&u.focusNode&&y(h.node,h.offset,u.anchorNode,u.anchorOffset)&&y(l.node,l.offset,u.focusNode,u.focusOffset)||(this.view.observer.ignore((()=>{a.android&&a.chrome&&this.dom.contains(u.focusNode)&&De(u.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let t=g(this.view.root);if(t)if(o.empty){if(a.gecko){let t=Ce(h.node,h.offset);if(t&&3!=t){let e=Me(h.node,h.offset,1==t?1:-1);e&&(h=new I(e,1==t?0:e.nodeValue.length))}}t.collapse(h.node,h.offset),null!=o.bidiLevel&&null!=u.cursorBidiLevel&&(u.cursorBidiLevel=o.bidiLevel)}else if(t.extend){t.collapse(h.node,h.offset);try{t.extend(l.node,l.offset)}catch(e){}}else{let e=document.createRange();o.anchor>o.head&&([h,l]=[l,h]),e.setEnd(l.node,l.offset),e.setStart(h.node,h.offset),t.removeAllRanges(),t.addRange(e)}else;s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())})),this.view.observer.setSelectionRange(h,l)),this.impreciseAnchor=h.precise?null:new I(u.anchorNode,u.anchorOffset),this.impreciseHead=l.precise?null:new I(u.focusNode,u.focusOffset)}enforceCursorAssoc(){if(this.compositionDeco.size)return;let{view:t}=this,e=t.state.selection.main,i=g(t.root),{anchorNode:n,anchorOffset:s}=t.observer.selectionRange;if(!(i&&e.empty&&e.assoc&&i.modify))return;let r=Mt.find(this,e.head);if(!r)return;let o=r.posAtStart;if(e.head==o||e.head==o+r.length)return;let h=this.coordsAt(e.head,-1),l=this.coordsAt(e.head,1);if(!h||!l||h.bottom>l.top)return;let a=this.domAtPos(e.head+e.assoc);i.collapse(a.node,a.offset),i.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let c=t.observer.selectionRange;t.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=e.from&&i.collapse(n,s)}nearest(t){for(let e=t;e;){let t=H.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 Mt)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!=c.WidgetBefore&&s.type!=c.WidgetAfter&&(!n||2==e||this.children[n-1].breakAfter||this.children[n-1].type==c.WidgetBefore&&e>-2))return s.coordsAt(t-r,e);i=r}}measureVisibleLineHeights(t){let e=[],{from:i,to:n}=t,s=this.view.contentDOM.clientWidth,r=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,h=this.view.textDirection==u.LTR;for(let l=0,a=0;a<this.children.length;a++){let t=this.children[a],c=l+t.length;if(c>n)break;if(l>=i){let i=t.dom.getBoundingClientRect();if(e.push(i.height),r){let e=t.dom.lastChild,n=e?v(e):[];if(n.length){let t=n[n.length-1],e=h?t.right-i.left:i.right-t.left;e>o&&(o=e,this.minWidth=s,this.minWidthFrom=l,this.minWidthTo=c)}}}l=c+t.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?u.RTL:u.LTR}measureTextSize(){for(let s of this.children)if(s instanceof Mt){let t=s.measureTextSize();if(t)return t}let t,e,i,n=document.createElement("div");return n.className="cm-line",n.style.width="99999px",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore((()=>{this.dom.appendChild(n);let s=v(n.firstChild)[0];t=n.getBoundingClientRect().height,e=s?s.width/27:7,i=s?s.height:t,n.remove()})),{lineHeight:t,charWidth:e,textHeight:i}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new F(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(yt.replace({widget:new xe(n),block:!0,inclusive:!0,isBlockGap:!0}).range(i,r))}if(!s)break;i=s.to+1}return yt.set(t)}updateDeco(){let t=this.view.state.facet(Ut).map(((t,e)=>(this.dynamicDecorationMap[e]="function"==typeof t)?t(this.view):t));for(let e=t.length;e<t.length+3;e++)this.dynamicDecorationMap[e]=!1;return this.decorations=[...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=Qt(this.view),r={left:n.left-s.left,top:n.top-s.top,right:n.right+s.right,bottom:n.bottom+s.bottom};M(this.view.scrollDOM,r,i.head<i.anchor?-1:1,t.x,t.y,t.xMargin,t.yMargin,this.view.textDirection==u.LTR)}}class xe extends vt{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 Se(t){let e=t.observer.selectionRange,i=e.focusNode&&Me(e.focusNode,e.focusOffset,0);if(!i)return null;let n=t.docView.nearest(i);if(!n)return null;if(n instanceof Mt){let t=i;for(;t.parentNode!=n.dom;)t=t.parentNode;let e=t.previousSibling;for(;e&&!H.get(e);)e=e.previousSibling;let s=e?H.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 Mt)break;n=t}let t=n.posAtStart;return{from:t,to:t+n.length,node:n.dom,text:i}}}function ke(t,e){let i=Se(t);if(!i)return yt.none;let{from:n,to:s,node:r,text:o}=i,h=e.mapPos(n,1),l=Math.max(h,e.mapPos(s,-1)),{state:a}=t,c=new we([],a);3==r.nodeType?c.readTextNode(r):c.readRange(r.firstChild,null);let{text:u}=c;if(u.indexOf(me)>-1)return yt.none;if(l-h<u.length)if(a.doc.sliceString(h,Math.min(a.doc.length,h+u.length))==u)l=h+u.length;else{if(a.doc.sliceString(Math.max(0,l-u.length),l)!=u)return yt.none;h=l-u.length}else if(a.doc.sliceString(h,l)!=u)return yt.none;let f=H.get(r);return f instanceof rt?f=f.widget.topView:f&&(f.parent=null),yt.set(yt.replace({widget:new Ae(r,o,f),inclusive:!0}).range(h,l))}class Ae extends vt{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 rt}}function Me(t,e,i){if(i<=0)for(let n=t,s=e;;){if(3==n.nodeType)return n;if(!(1==n.nodeType&&s>0))break;n=n.childNodes[s-1],s=S(n)}if(i>=0)for(let n=t,s=e;;){if(3==n.nodeType)return n;if(!(1==n.nodeType&&s<n.childNodes.length&&i>=0))break;n=n.childNodes[s],s=0}return null}function Ce(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 Oe{constructor(){this.changes=[]}compareRange(t,e){At(t,e,this.changes)}comparePoint(t,e){At(t,e,this.changes)}}function Te(t,e,i){let n=new Oe;return r.Xs.compare(t,e,i,n),n.changes}function De(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 Ee(t,e,i=1){let n=t.charCategorizer(e),s=t.doc.lineAt(e),o=e-s.from;if(0==s.length)return r.jT.cursor(e);0==o?i=1:o==s.length&&(i=-1);let h=o,l=o;i<0?h=(0,r.cp)(s.text,o,!1):l=(0,r.cp)(s.text,o);let a=n(s.text.slice(h,l));for(;h>0;){let t=(0,r.cp)(s.text,h,!1);if(n(s.text.slice(t,h))!=a)break;h=t}for(;l<s.length;){let t=(0,r.cp)(s.text,l);if(n(s.text.slice(l,t))!=a)break;l=t}return r.jT.range(h+s.from,l+s.from)}function Re(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function Be(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function Pe(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function Le(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function Ne(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function Ie(t,e,i){let n,s,r,o,h,l,a,c,u=!1;for(let d=t.firstChild;d;d=d.nextSibling){let t=v(d);for(let f=0;f<t.length;f++){let g=t[f];s&&Pe(s,g)&&(g=Le(Ne(g,s.bottom),s.top));let p=Re(e,g),m=Be(i,g);if(0==p&&0==m)return 3==d.nodeType?Ve(d,e,i):Ie(d,e,i);if(!n||o>m||o==m&&r>p){n=d,s=g,r=p,o=m;let h=m?i<g.top?-1:1:p?e<g.left?-1:1:0;u=!h||(h>0?f<t.length-1:f>0)}0==p?i>g.bottom&&(!a||a.bottom<g.bottom)?(h=d,a=g):i<g.top&&(!c||c.top>g.top)&&(l=d,c=g):a&&Pe(a,g)?a=Ne(a,g.bottom):c&&Pe(c,g)&&(c=Le(c,g.top))}}if(a&&a.bottom>=i?(n=h,s=a):c&&c.top<=i&&(n=l,s=c),!n)return{node:t,offset:0};let f=Math.max(s.left,Math.min(s.right,e));return 3==n.nodeType?Ve(n,f,i):u&&"false"!=n.contentEditable?Ie(n,f,i):{node:t,offset:Array.prototype.indexOf.call(t.childNodes,n)+(e>=(s.left+s.right)/2?1:0)}}function Ve(t,e,i){let n=t.nodeValue.length,s=-1,r=1e9,o=0;for(let h=0;h<n;h++){let n=R(t,h,h+1).getClientRects();for(let l=0;l<n.length;l++){let c=n[l];if(c.top==c.bottom)continue;o||(o=e-c.left);let u=(c.top>i?c.top-i:i-c.bottom)-1;if(c.left-1<=e&&c.right+1>=e&&u<r){let i=e>=(c.left+c.right)/2,n=i;if(a.chrome||a.gecko){R(t,h).getBoundingClientRect().left==c.right&&(n=!i)}if(u<=0)return{node:t,offset:h+(n?1:0)};s=h+(n?1:0),r=u}}}return{node:t,offset:s>-1?s:o>0?t.nodeValue.length:0}}function He(t,e,i,n=-1){var s,r;let o,h=t.contentDOM.getBoundingClientRect(),l=h.top+t.viewState.paddingTop,{docHeight:u}=t.viewState,{x:f,y:d}=e,g=d-l;if(g<0)return 0;if(g>u)return t.state.doc.length;for(let a=t.viewState.heightOracle.textHeight/2,S=!1;o=t.elementAtHeight(g),o.type!=c.Text;)for(;g=n>0?o.bottom+a:o.top-a,!(g>=0&&g<=u);){if(S)return i?null:0;S=!0,n=-n}d=l+g;let p=o.from;if(p<t.viewport.from)return 0==t.viewport.from?0:i?null:We(t,h,o,f,d);if(p>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:We(t,h,o,f,d);let m=t.dom.ownerDocument,w=t.root.elementFromPoint?t.root:m,v=w.elementFromPoint(f,d);v&&!t.contentDOM.contains(v)&&(v=null),v||(f=Math.max(h.left+1,Math.min(h.right-1,f)),v=w.elementFromPoint(f,d),v&&!t.contentDOM.contains(v)&&(v=null));let y,b=-1;if(v&&0!=(null===(s=t.docView.nearest(v))||void 0===s?void 0:s.isEditable))if(m.caretPositionFromPoint){let t=m.caretPositionFromPoint(f,d);t&&({offsetNode:y,offset:b}=t)}else if(m.caretRangeFromPoint){let e=m.caretRangeFromPoint(f,d);e&&(({startContainer:y,startOffset:b}=e),(!t.contentDOM.contains(y)||a.safari&&Fe(y,b,f)||a.chrome&&ze(y,b,f))&&(y=void 0))}if(!y||!t.docView.dom.contains(y)){let e=Mt.find(t.docView,p);if(!e)return g>o.top+o.height/2?o.to:o.from;({node:y,offset:b}=Ie(e.dom,f,d))}let x=t.docView.nearest(y);if(!x)return null;if(x.isWidget&&1==(null===(r=x.dom)||void 0===r?void 0:r.nodeType)){let t=x.dom.getBoundingClientRect();return e.y<t.top||e.y<=t.bottom&&e.x<=(t.left+t.right)/2?x.posAtStart:x.posAtEnd}return x.localPosFromDOM(y,b)+x.posAtStart}function We(t,e,i,n,s){let o=Math.round((n-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>1.5*t.defaultLineHeight){let e=t.viewState.heightOracle.textHeight;o+=Math.floor((s-i.top-.5*(t.defaultLineHeight-e))/e)*t.viewState.heightOracle.lineLength}let h=t.state.sliceDoc(i.from,i.to);return i.from+(0,r.Gz)(h,o,t.state.tabSize)}function Fe(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 R(t,n-1,n).getBoundingClientRect().left>i}function ze(t,e,i){if(0!=e)return!1;for(let n=t;;){let t=n.parentNode;if(!t||1!=t.nodeType||t.firstChild!=n)return!1;if(t.classList.contains("cm-line"))break;n=t}return i-(1==t.nodeType?t.getBoundingClientRect():R(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect()).left>5}function _e(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==c.Text))return n;return i}function je(t,e,i,n){let s=_e(t,e.head),o=n&&s.type==c.Text&&(t.lineWrapping||s.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head):null;if(o){let e=t.dom.getBoundingClientRect(),n=t.textDirectionAt(s.from),h=t.posAtCoords({x:i==(n==u.LTR)?e.right-1:e.left+1,y:(o.top+o.bottom)/2});if(null!=h)return r.jT.cursor(h,i?-1:1)}return r.jT.cursor(i?s.to:s.from,i?-1:1)}function qe(t,e,i,n){let s=t.state.doc.lineAt(e.head),o=t.bidiSpans(s),h=t.textDirectionAt(s.from);for(let l=e,a=null;;){let e=pe(s,o,h,l,i),c=ge;if(!e){if(s.number==(i?t.state.doc.lines:1))return l;c="\n",s=t.state.doc.line(s.number+(i?1:-1)),o=t.bidiSpans(s),e=r.jT.cursor(i?s.from:s.to)}if(a){if(!a(c))return l}else{if(!n)return e;a=n(c)}l=e}}function $e(t,e,i){let n=t.state.charCategorizer(e),s=n(i);return t=>{let e=n(t);return s==r.D0.Space&&(s=e),s==e}}function Ke(t,e,i,n){let s=e.head,o=i?1:-1;if(s==(i?t.state.doc.length:0))return r.jT.cursor(s,e.assoc);let h,l=e.goalColumn,a=t.contentDOM.getBoundingClientRect(),c=t.coordsAtPos(s),u=t.documentTop;if(c)null==l&&(l=c.left-a.left),h=o<0?c.top:c.bottom;else{let e=t.viewState.lineBlockAt(s);null==l&&(l=Math.min(a.right-a.left,t.defaultCharacterWidth*(s-e.from))),h=(o<0?e.top:e.bottom)+u}let f=a.left+l,d=null!=n?n:t.viewState.heightOracle.textHeight>>1;for(let g=0;;g+=10){let i=h+(d+g)*o,n=He(t,{x:f,y:i},!1,o);if(i<a.top||i>a.bottom||(o<0?n<s:n>s))return r.jT.cursor(n,e.assoc,void 0,l)}}function Je(t,e,i){for(;;){let n=0;for(let s of t)s.between(e-1,e+1,((t,s,r)=>{if(e>t&&e<s){let r=n||i||(e-t<s-e?-1:1);e=r<0?t:s,n=r}}));if(!n)return e}}function Ge(t,e,i){let n=Je(t.state.facet(Xt).map((e=>e(t))),i.from,e.head>i.from?-1:1);return n==i.from?i:r.jT.cursor(n,n<i.from?1:-1)}class Ue{constructor(t){this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.chromeScrollHack=-1,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.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null;let e=(e,i)=>{this.ignoreDuringComposition(i)||"keydown"==i.type&&this.keydown(t,i)||(this.mustFlushObserver(i)&&t.observer.forceFlush(),this.runCustomHandlers(i.type,t,i)?i.preventDefault():e(t,i))};for(let i in oi){let n=oi[i];t.contentDOM.addEventListener(i,(i=>{ri(t,i)&&e(n,i)}),hi[i]),this.registeredEvents.push(i)}t.scrollDOM.addEventListener("mousedown",(i=>{if(i.target==t.scrollDOM&&i.clientY>t.contentDOM.getBoundingClientRect().bottom&&(e(oi.mousedown,i),!i.defaultPrevented&&2==i.button)){let e=t.contentDOM.style.minHeight;t.contentDOM.style.minHeight="100%",setTimeout((()=>t.contentDOM.style.minHeight=e),200)}})),t.scrollDOM.addEventListener("drop",(i=>{i.target==t.scrollDOM&&i.clientY>t.contentDOM.getBoundingClientRect().bottom&&e(oi.drop,i)})),a.chrome&&102==a.chrome_version&&t.scrollDOM.addEventListener("wheel",(()=>{this.chromeScrollHack<0?t.contentDOM.style.pointerEvents="none":window.clearTimeout(this.chromeScrollHack),this.chromeScrollHack=setTimeout((()=>{this.chromeScrollHack=-1,t.contentDOM.style.pointerEvents=""}),100)}),{passive:!0}),this.notifiedFocused=t.hasFocus,a.safari&&t.contentDOM.addEventListener("input",(()=>null))}setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}ensureHandlers(t,e){var i;let n;this.customHandlers=[];for(let s of e)if(n=null===(i=s.update(t).spec)||void 0===i?void 0:i.domEventHandlers){this.customHandlers.push({plugin:s.value,handlers:n});for(let e in n)this.registeredEvents.indexOf(e)<0&&"scroll"!=e&&(this.registeredEvents.push(e),t.contentDOM.addEventListener(e,(i=>{ri(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){zt(e.state,n)}}return!1}runScrollHandlers(t,e){this.lastScrollTop=t.scrollDOM.scrollTop,this.lastScrollLeft=t.scrollDOM.scrollLeft;for(let n of this.customHandlers){let s=n.handlers.scroll;if(s)try{s.call(n.plugin,e,t)}catch(i){zt(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(27!=e.keyCode&&Qe.indexOf(e.keyCode)<0&&(t.inputState.lastEscPress=0),a.android&&a.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))return t.observer.delayAndroidKey(e.key,e.keyCode),!0;let i;return!(!a.ios||e.synthetic||e.altKey||e.metaKey||!((i=Xe.find((t=>t.keyCode==e.keyCode)))&&!e.ctrlKey||Ye.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey))&&(this.pendingIOSKey=i||e,setTimeout((()=>this.flushIOSKey(t)),250),!0)}flushIOSKey(t){let e=this.pendingIOSKey;return!!e&&(this.pendingIOSKey=void 0,B(t.contentDOM,e.key,e.keyCode))}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(this.composing>0||!!(a.safari&&!a.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}mustFlushObserver(t){return"keydown"==t.type&&229!=t.keyCode}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 Xe=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Ye="dthko",Qe=[16,17,18,20,91,92,224,225],Ze=6;function ti(t){return.7*Math.max(0,t)+8}class ei{constructor(t,e,i,n){this.view=t,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParent=C(t.contentDOM),this.atoms=t.state.facet(Xt).map((e=>e(t)));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(r.yy.allowMultipleSelections)&&ii(t,e),this.dragging=!(!si(t,e)||1!=bi(e))&&null}start(t){!1===this.dragging&&(t.preventDefault(),this.select(t))}move(t){var e;if(0==t.buttons)return this.destroy();if(!1!==this.dragging)return;this.select(this.lastEvent=t);let i=0,n=0,s=(null===(e=this.scrollParent)||void 0===e?void 0:e.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},r=Qt(this.view);t.clientX-r.left<=s.left+Ze?i=-ti(s.left-t.clientX):t.clientX+r.right>=s.right-Ze&&(i=ti(t.clientX-s.right)),t.clientY-r.top<=s.top+Ze?n=-ti(s.top-t.clientY):t.clientY+r.bottom>=s.bottom-Ze&&(n=ti(t.clientY-s.bottom)),this.setScrollSpeed(i,n)}up(t){null==this.dragging&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval((()=>this.scroll()),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),!1===this.dragging&&this.select(this.lastEvent)}skipAtoms(t){let e=null;for(let i=0;i<t.ranges.length;i++){let n=t.ranges[i],s=null;if(n.empty){let t=Je(this.atoms,n.from,0);t!=n.from&&(s=r.jT.cursor(t,-1))}else{let t=Je(this.atoms,n.from,-1),e=Je(this.atoms,n.to,1);t==n.from&&e==n.to||(s=r.jT.range(n.from==n.anchor?t:e,n.from==n.head?t:e))}s&&(e||(e=t.ranges.slice()),e[i]=s)}return e?r.jT.create(e,t.mainIndex):t}select(t){let{view:e}=this,i=this.skipAtoms(this.style.get(t,this.extend,this.multiple));!this.mustSelect&&i.eq(e.state.selection)&&i.main.assoc==e.state.selection.main.assoc||this.view.dispatch({selection:i,userEvent:"select.pointer"}),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 ii(t,e){let i=t.state.facet(Et);return i.length?i[0](e):a.mac?e.metaKey:e.ctrlKey}function ni(t,e){let i=t.state.facet(Rt);return i.length?i[0](e):a.mac?!e.altKey:!e.ctrlKey}function si(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let n=g(t.root);if(!n||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 ri(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=H.get(n))&&i.ignoreEvent(e))return!1;return!0}const oi=Object.create(null),hi=Object.create(null),li=a.ie&&a.ie_version<15||a.ios&&a.webkit_version<604;function ai(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(),ci(t,i.value)}),50)}function ci(t,e){let i,{state:n}=t,s=1,o=n.toText(e),h=o.lines==n.selection.ranges.length;if(null!=Ci&&n.selection.ranges.every((t=>t.empty))&&Ci==o.toString()){let t=-1;i=n.changeByRange((i=>{let l=n.doc.lineAt(i.from);if(l.from==t)return{range:i};t=l.from;let a=n.toText((h?o.line(s++).text:e)+n.lineBreak);return{changes:{from:l.from,insert:a},range:r.jT.cursor(i.from+a.length)}}))}else i=h?n.changeByRange((t=>{let e=o.line(s++);return{changes:{from:t.from,to:t.to,insert:e.text},range:r.jT.cursor(t.from+e.length)}})):n.replaceSelection(o);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function ui(t,e,i,n){if(1==n)return r.jT.cursor(e,i);if(2==n)return Ee(t.state,e,i);{let i=Mt.find(t.docView,e),n=t.state.doc.lineAt(i?i.posAtEnd:e),s=i?i.posAtStart:n.from,o=i?i.posAtEnd:n.to;return o<t.state.doc.length&&o==n.to&&o++,r.jT.range(s,o)}}oi.keydown=(t,e)=>{t.inputState.setSelectionOrigin("select"),27==e.keyCode&&(t.inputState.lastEscPress=Date.now())},oi.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},oi.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},hi.touchstart=hi.touchmove={passive:!0},oi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return;let i=null;for(let n of t.state.facet(Bt))if(i=n(t,e),i)break;if(i||0!=e.button||(i=xi(t,e)),i){let n=t.root.activeElement!=t.contentDOM;t.inputState.startMouseSelection(new ei(t,e,i,n)),n&&t.observer.ignore((()=>E(t.contentDOM))),t.inputState.mouseSelection&&t.inputState.mouseSelection.start(e)}};let fi=(t,e)=>t>=e.top&&t<=e.bottom,di=(t,e,i)=>fi(e,i)&&t>=i.left&&t<=i.right;function gi(t,e,i,n){let s=Mt.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&&di(i,n,o))return-1;let h=s.coordsAt(r,1);return h&&di(i,n,h)?1:o&&fi(n,o)?-1:1}function pi(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:gi(t,i,e.clientX,e.clientY)}}const mi=a.ie&&a.ie_version<=11;let wi=null,vi=0,yi=0;function bi(t){if(!mi)return t.detail;let e=wi,i=yi;return wi=t,yi=Date.now(),vi=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(vi+1)%3:1}function xi(t,e){let i=pi(t,e),n=bi(e),s=t.state.selection;return{update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),s=s.map(t.changes))},get(e,o,h){let l,a=pi(t,e),c=ui(t,a.pos,a.bias,n);if(i.pos!=a.pos&&!o){let e=ui(t,i.pos,i.bias,n),s=Math.min(e.from,c.from),o=Math.max(e.to,c.to);c=s<c.from?r.jT.range(s,o):r.jT.range(o,s)}return o?s.replaceRange(s.main.extend(c.from,c.to)):h&&1==n&&s.ranges.length>1&&(l=Si(s,a.pos))?l:h?s.addRange(c):r.jT.create([c])}}}function Si(t,e){for(let i=0;i<t.ranges.length;i++){let{from:n,to:s}=t.ranges[i];if(n<=e&&s>=e)return r.jT.create(t.ranges.slice(0,i).concat(t.ranges.slice(i+1)),t.mainIndex==i?0:t.mainIndex-(t.mainIndex>i?1:0))}return null}function ki(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&&ni(t,e)?{from:r.dragging.from,to:r.dragging.to}:null,h={from:s,insert:i},l=t.state.changes(o?[o,h]:h);t.focus(),t.dispatch({changes:l,selection:{anchor:l.mapPos(s,-1),head:l.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"})}function Ai(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 Mi(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}}oi.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")},oi.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&&ki(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 ki(t,e,e.dataTransfer.getData("Text"),!0)},oi.paste=(t,e)=>{if(t.state.readOnly)return e.preventDefault();t.observer.flush();let i=li?null:e.clipboardData;i?(ci(t,i.getData("text/plain")||i.getData("text/uri-text")),e.preventDefault()):ai(t)};let Ci=null;oi.copy=oi.cut=(t,e)=>{let{text:i,ranges:n,linewise:s}=Mi(t.state);if(!i&&!s)return;Ci=s?i:null;let r=li?null:e.clipboardData;r?(e.preventDefault(),r.clearData(),r.setData("text/plain",i)):Ai(t,i),"cut"!=e.type||t.state.readOnly||t.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"})};const Oi=r.q6.define();function Ti(t,e){let i=[];for(let n of t.facet(It)){let s=n(t,e);s&&i.push(s)}return i?t.update({effects:i,annotations:Oi.of(!0)}):null}function Di(t){setTimeout((()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=Ti(t.state,e);i?t.dispatch(i):t.update([])}}),10)}oi.focus=t=>{t.inputState.lastFocusTime=Date.now(),t.scrollDOM.scrollTop||!t.inputState.lastScrollTop&&!t.inputState.lastScrollLeft||(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),Di(t)},oi.blur=t=>{t.observer.clearSelectionRange(),Di(t)},oi.compositionstart=oi.compositionupdate=t=>{null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0)},oi.compositionend=t=>{t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,a.chrome&&a.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then((()=>t.observer.flush())):setTimeout((()=>{t.inputState.composing<0&&t.docView.compositionDeco.size&&t.update([])}),50)},oi.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},oi.beforeinput=(t,e)=>{var i;let n;if(a.chrome&&a.android&&(n=Xe.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 Ei=["pre-wrap","normal","pre-line","break-spaces"];class Ri{constructor(t){this.lineWrapping=t,this.doc=r.xv.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,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.max(0,Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(t){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5))))*this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return Ei.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let n=t[i];n<0?i++:this.heightSamples[Math.floor(10*n)]||(e=!0,this.heightSamples[Math.floor(10*n)]=!0)}return e}refresh(t,e,i,n,s,r){let o=Ei.indexOf(t)>-1,h=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=e,this.charWidth=i,this.textHeight=n,this.lineLength=s,h){this.heightSamples={};for(let t=0;t<r.length;t++){let e=r[t];e<0?t++:this.heightSamples[Math.floor(10*e)]=!0}}return h}}class Bi{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class Pi{constructor(t,e,i,n,s){this.from=t,this.length=e,this.top=i,this.height=n,this._content=s}get type(){return"number"==typeof this._content?c.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof St?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(t){let e=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new Pi(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var f=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}(f||(f={}));const Li=.001;class Ni{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)>Li&&(t.heightChanged=!0),this.height=e)}replace(t,e,i){return Ni.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,n){let s=this,r=i.doc;for(let o=n.length-1;o>=0;o--){let{fromA:h,toA:l,fromB:a,toB:c}=n[o],u=s.lineAt(h,f.ByPosNoHeight,i.setDoc(e),0,0),d=u.to>=l?u:s.lineAt(l,f.ByPosNoHeight,i,0,0);for(c+=d.to-l,l=d.to;o>0&&u.from<=n[o-1].toA;)h=n[o-1].fromA,a=n[o-1].fromB,o--,h<u.from&&(u=s.lineAt(h,f.ByPosNoHeight,i,0,0));a+=u.from-h,h=u.from;let g=_i.build(i.setDoc(r),t,a,c);s=s.replace(h,l,g)}return s.updateHeight(i,0)}static empty(){return new Vi(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 Wi(Ni.of(t.slice(0,e)),r,Ni.of(t.slice(i)))}}Ni.prototype.size=1;class Ii extends Ni{constructor(t,e,i){super(t,e),this.deco=i}blockAt(t,e,i,n){return new Pi(n,this.length,i,this.height,this.deco||0)}lineAt(t,e,i,n,s){return this.blockAt(0,i,n,s)}forEachLine(t,e,i,n,s,r){t<=s+this.length&&e>=s&&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 Vi extends Ii{constructor(t,e){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(t,e,i,n){return new Pi(n,this.length,i,this.height,this.breaks)}replace(t,e,i){let n=i[0];return 1==i.length&&(n instanceof Vi||n instanceof Hi&&4&n.flags)&&Math.abs(this.length-n.length)<10?(n instanceof Hi?n=new Vi(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):Ni.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.breaks*t.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Hi extends Ni{constructor(t){super(t,0)}heightMetrics(t,e){let i,n=t.doc.lineAt(e).number,s=t.doc.lineAt(e+this.length).number,r=s-n+1,o=0;if(t.lineWrapping){let e=Math.min(this.height,t.lineHeight*r);i=e/r,this.length>r+1&&(o=(this.height-e)/(this.length-r-1))}else i=this.height/r;return{firstLine:n,lastLine:s,perLine:i,perChar:o}}blockAt(t,e,i,n){let{firstLine:s,lastLine:r,perLine:o,perChar:h}=this.heightMetrics(e,n);if(e.lineWrapping){let s=n+Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length),r=e.doc.lineAt(s),l=o+r.length*h,a=Math.max(i,t-l/2);return new Pi(r.from,r.length,a,l,0)}{let n=Math.max(0,Math.min(r-s,Math.floor((t-i)/o))),{from:h,length:l}=e.doc.line(s+n);return new Pi(h,l,i+o*n,o,0)}}lineAt(t,e,i,n,s){if(e==f.ByHeight)return this.blockAt(t,i,n,s);if(e==f.ByPosNoHeight){let{from:e,to:n}=i.doc.lineAt(t);return new Pi(e,n-e,0,0,0)}let{firstLine:r,perLine:o,perChar:h}=this.heightMetrics(i,s),l=i.doc.lineAt(t),a=o+l.length*h,c=l.number-r,u=n+o*c+h*(l.from-s-c);return new Pi(l.from,l.length,Math.max(n,Math.min(u,n+this.height-a)),a,0)}forEachLine(t,e,i,n,s,r){t=Math.max(t,s),e=Math.min(e,s+this.length);let{firstLine:o,perLine:h,perChar:l}=this.heightMetrics(i,s);for(let a=t,c=n;a<=e;){let e=i.doc.lineAt(a);if(a==t){let i=e.number-o;c+=h*i+l*(t-s-i)}let n=h+l*e.length;r(new Pi(e.from,e.length,c,n,0)),c+=n,a=e.to+1}}replace(t,e,i){let n=this.length-e;if(n>0){let t=i[i.length-1];t instanceof Hi?i[i.length-1]=new Hi(t.length+n):i.push(null,new Hi(n-1))}if(t>0){let e=i[0];e instanceof Hi?i[0]=new Hi(t+e.length):i.unshift(new Hi(t-1),null)}return Ni.of(i)}decomposeLeft(t,e){e.push(new Hi(t-1),null)}decomposeRight(t,e){e.push(null,new Hi(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;for(n.from>e&&i.push(new Hi(n.from-e-1).updateHeight(t,e));r<=s&&n.more;){let e=t.doc.lineAt(r).length;i.length&&i.push(null);let s=n.heights[n.index++];-1==o?o=s:Math.abs(s-o)>=Li&&(o=-2);let h=new Vi(e,s);h.outdated=!1,i.push(h),r+=e+1}r<=s&&i.push(null,new Hi(s-r).updateHeight(t,r));let h=Ni.of(i);return(o<0||Math.abs(h.height-this.height)>=Li||Math.abs(o-this.heightMetrics(t,e).perLine)>=Li)&&(t.heightChanged=!0),h}return(i||this.outdated)&&(this.setHeight(t,t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class Wi extends Ni{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,h=e==f.ByHeight?t<r:t<o,l=h?this.left.lineAt(t,e,i,n,s):this.right.lineAt(t,e,i,r,o);if(this.break||(h?l.to<o:l.from>o))return l;let a=e==f.ByPosNoHeight?f.ByPosNoHeight:f.ByPos;return h?l.join(this.right.lineAt(o,a,i,r,o)):this.left.lineAt(o,a,i,n,s).join(l)}forEachLine(t,e,i,n,s,r){let o=n+this.left.height,h=s+this.left.length+this.break;if(this.break)t<h&&this.left.forEachLine(t,e,i,n,s,r),e>=h&&this.right.forEachLine(t,e,i,o,h,r);else{let l=this.lineAt(h,f.ByPos,i,n,s);t<l.from&&this.left.forEachLine(t,l.from-1,i,n,s,r),l.to>=t&&l.from<=e&&r(l),e>l.to&&this.right.forEachLine(l.to+1,e,i,o,h,r)}}replace(t,e,i){let n=this.left.length+this.break;if(e<n)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let s=[];t>0&&this.decomposeLeft(t,s);let r=s.length;for(let o of i)s.push(o);if(t>0&&Fi(s,r-1),e<this.length){let t=s.length;this.decomposeRight(e,s),Fi(s,t)}return Ni.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?Ni.of(this.break?[t,null,e]:[t,e]):(this.left=t,this.right=e,this.height=t.height+e.height,this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,i=!1,n){let{left:s,right:r}=this,o=e+s.length+this.break,h=null;return n&&n.from<=e+s.length&&n.more?h=s=s.updateHeight(t,e,i,n):s.updateHeight(t,e,i),n&&n.from<=o+r.length&&n.more?h=r=r.updateHeight(t,o,i,n):r.updateHeight(t,o,i),h?this.balanced(s,r):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Fi(t,e){let i,n;null==t[e]&&(i=t[e-1])instanceof Hi&&(n=t[e+1])instanceof Hi&&t.splice(e-1,3,new Hi(i.length+1+n.length))}const zi=5;class _i{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 Vi?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new Vi(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,s=i.widget?i.widget.lineBreaks:0;n<0&&(n=this.oracle.lineHeight);let r=e-t;i.block?this.addBlock(new Ii(r,n,i)):(r||s||n>=zi)&&this.addLineDeco(n,s,r)}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 Vi(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new Hi(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 Vi)return t;let e=new Vi(0,-1);return this.nodes.push(e),e}addBlock(t){var e;this.enterLine();let i=null===(e=t.deco)||void 0===e?void 0:e.type;i!=c.WidgetAfter||this.isCovered||this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,i!=c.WidgetBefore&&(this.covering=t)}addLineDeco(t,e,i){let n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,t),n.breaks+=e,this.writtenTo=this.pos=this.pos+i}finish(t){let e=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof Vi||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new Vi(0,-1));let i=t;for(let n of this.nodes)n instanceof Vi&&n.updateHeight(this.oracle,i),i+=n?n.length:1;return this.nodes}static build(t,e,i,n){let s=new _i(i,t);return r.Xs.spans(e,i,n,s,0),s.finish(i)}}function ji(t,e,i){let n=new qi;return r.Xs.compare(t,e,i,n,0),n.changes}class qi{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,n){(t<e||i&&i.heightRelevant||n&&n.heightRelevant)&&At(t,e,this.changes,5)}}function $i(t,e){let i=t.getBoundingClientRect(),n=t.ownerDocument,s=n.defaultView||window,r=Math.max(0,i.left),o=Math.min(s.innerWidth,i.right),h=Math.max(0,i.top),l=Math.min(s.innerHeight,i.bottom);for(let a=t.parentNode;a&&a!=n.body;)if(1==a.nodeType){let e=a,i=window.getComputedStyle(e);if((e.scrollHeight>e.clientHeight||e.scrollWidth>e.clientWidth)&&"visible"!=i.overflow){let i=e.getBoundingClientRect();r=Math.max(r,i.left),o=Math.min(o,i.right),h=Math.max(h,i.top),l=a==t.parentNode?i.bottom:Math.min(l,i.bottom)}a="absolute"==i.position||"fixed"==i.position?e.offsetParent:e.parentNode}else{if(11!=a.nodeType)break;a=a.host}return{left:r-i.left,right:Math.max(r,o)-i.left,top:h-(i.top+e),bottom:Math.max(h,l)-(i.top+e)}}function Ki(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class Ji{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 yt.replace({widget:new Gi(this.size,t)}).range(this.from,this.to)}}class Gi extends vt{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 Ui{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.scrollTop=0,this.scrolledToBottom=!0,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=en,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=u.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let e=t.facet(Gt).some((t=>"function"!=typeof t&&"cm-lineWrapping"==t.class));this.heightOracle=new Ri(e),this.stateDeco=t.facet(Ut).filter((t=>"function"!=typeof t)),this.heightMap=Ni.empty().applyChanges(this.stateDeco,r.xv.empty,this.heightOracle.setDoc(t.doc),[new te(0,0,0,t.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=yt.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 Xi(e,i))}}this.viewports=t.sort(((t,e)=>t.from-e.from)),this.scaler=this.heightMap.height<=7e6?en:new nn(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,(t=>{this.viewportLines.push(1==this.scaler.scale?t:sn(t,this.scaler))}))}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(Ut).filter((t=>"function"!=typeof t));let n=t.changedRanges,s=te.extendWithRanges(n,ji(i,this.stateDeco,t?t.changes:r.as.empty(this.state.doc.length))),o=this.heightMap.height,h=this.scrolledToBottom?null:this.lineBlockAtHeight(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),s),this.heightMap.height!=o&&(t.flags|=2),h?(this.scrollAnchorPos=t.changes.mapPos(h.from,-1),this.scrollAnchorHeight=h.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let l=s.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<l.from||e.range.head>l.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,e));let a=!t.changes.empty||2&t.flags||l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,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&&!t.state.facet(Ht)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),n=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?u.RTL:u.LTR;let o=this.heightOracle.mustRefreshForWrapping(s),h=e.getBoundingClientRect(),l=o||this.mustMeasureContent||this.contentDOMHeight!=h.height;this.contentDOMHeight=h.height,this.mustMeasureContent=!1;let a=0,c=0,f=parseInt(i.paddingTop)||0,d=parseInt(i.paddingBottom)||0;this.paddingTop==f&&this.paddingBottom==d||(this.paddingTop=f,this.paddingBottom=d,a|=10),this.editorWidth!=t.scrollDOM.clientWidth&&(n.lineWrapping&&(l=!0),this.editorWidth=t.scrollDOM.clientWidth,a|=8),this.scrollTop!=t.scrollDOM.scrollTop&&(this.scrollAnchorHeight=-1,this.scrollTop=t.scrollDOM.scrollTop),this.scrolledToBottom=this.scrollTop>t.scrollDOM.scrollHeight-t.scrollDOM.clientHeight-4;let g=(this.printing?Ki:$i)(e,this.paddingTop),p=g.top-this.pixelViewport.top,m=g.bottom-this.pixelViewport.bottom;this.pixelViewport=g;let w=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(w!=this.inView&&(this.inView=w,w&&(l=!0)),!this.inView&&!this.scrollTarget)return 0;let v=h.width;if(this.contentDOMWidth==v&&this.editorHeight==t.scrollDOM.clientHeight||(this.contentDOMWidth=h.width,this.editorHeight=t.scrollDOM.clientHeight,a|=8),l){let e=t.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(e)&&(o=!0),o||n.lineWrapping&&Math.abs(v-this.contentDOMWidth)>n.charWidth){let{lineHeight:i,charWidth:r,textHeight:h}=t.docView.measureTextSize();o=i>0&&n.refresh(s,i,r,h,v/r,e),o&&(t.docView.minWidth=0,a|=8)}p>0&&m>0?c=Math.max(p,m):p<0&&m<0&&(c=Math.min(p,m)),n.heightChanged=!1;for(let i of this.viewports){let s=i.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(i);this.heightMap=(o?Ni.empty().applyChanges(this.stateDeco,r.xv.empty,this.heightOracle,[new te(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(n,0,o,new Bi(i.from,s))}n.heightChanged&&(a|=2)}let y=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return y&&(this.viewport=this.getViewport(c,this.scrollTarget)),this.updateForViewport(),(2&a||y)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,t)),a|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),a}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),n=this.heightMap,s=this.heightOracle,{visibleTop:r,visibleBottom:o}=this,h=new Xi(n.lineAt(r-1e3*i,f.ByHeight,s,0,0).from,n.lineAt(o+1e3*(1-i),f.ByHeight,s,0,0).to);if(e){let{head:t}=e.range;if(t<h.from||t>h.to){let i,r=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),o=n.lineAt(t,f.ByPos,s,0,0);i="center"==e.y?(o.top+o.bottom)/2-r/2:"start"==e.y||"nearest"==e.y&&t<h.from?o.top:o.bottom-r,h=new Xi(n.lineAt(i-500,f.ByHeight,s,0,0).from,n.lineAt(i+r+500,f.ByHeight,s,0,0).to)}}return h}mapViewport(t,e){let i=e.mapPos(t.from,-1),n=e.mapPos(t.to,1);return new Xi(this.heightMap.lineAt(i,f.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,f.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(t,f.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(e,f.ByPos,this.heightOracle,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 Ji(e.mapPos(n.from),e.mapPos(n.to),n.size));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,s=n>>1,o=n<<1;if(this.defaultTextDirection!=u.LTR&&!i)return[];let h=[],l=(n,o,a,c)=>{if(o-n<s)return;let u=this.state.selection.main,f=[u.from];u.empty||f.push(u.to);for(let t of f)if(t>n&&t<o)return l(n,t-10,a,c),void l(t+10,o,a,c);let d=tn(t,(t=>t.from>=a.from&&t.to<=a.to&&Math.abs(t.from-n)<s&&Math.abs(t.to-o)<s&&!f.some((e=>t.from<e&&t.to>e))));if(!d){if(o<a.to&&e&&i&&e.visibleRanges.some((t=>t.from<=o&&t.to>=o))){let t=e.moveToLineBoundary(r.jT.cursor(o),!1,!0).head;t>n&&(o=t)}d=new Ji(n,o,this.gapSize(a,n,o,c))}h.push(d)};for(let r of this.viewportLines){if(r.length<o)continue;let t=Yi(r.from,r.to,this.stateDeco);if(t.total<o)continue;let e,s,h=this.scrollTarget?this.scrollTarget.range.head:null;if(i){let i,o,l=n/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=h){let e=Zi(t,h),n=((this.visibleBottom-this.visibleTop)/2+l)/r.height;i=e-n,o=e+n}else i=(this.visibleTop-r.top-l)/r.height,o=(this.visibleBottom-r.top+l)/r.height;e=Qi(t,i),s=Qi(t,o)}else{let i,r,o=t.total*this.heightOracle.charWidth,l=n*this.heightOracle.charWidth;if(null!=h){let e=Zi(t,h),n=((this.pixelViewport.right-this.pixelViewport.left)/2+l)/o;i=e-n,r=e+n}else i=(this.pixelViewport.left-l)/o,r=(this.pixelViewport.right+l)/o;e=Qi(t,i),s=Qi(t,r)}e>r.from&&l(r.from,e,r,t),s<r.to&&l(s,r.to,r,t)}return h}gapSize(t,e,i,n){let s=Zi(n,i)-Zi(n,e);return this.heightOracle.lineWrapping?t.height*s:n.total*this.heightOracle.charWidth*s}updateLineGaps(t){Ji.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=yt.set(t.map((t=>t.draw(this.heightOracle.lineWrapping)))))}computeVisibleRanges(){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let e=[];r.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))||sn(this.heightMap.lineAt(t,f.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return sn(this.heightMap.lineAt(this.scaler.fromDOM(t),f.ByHeight,this.heightOracle,0,0),this.scaler)}elementAtHeight(t){return sn(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Xi{constructor(t,e){this.from=t,this.to=e}}function Yi(t,e,i){let n=[],s=t,o=0;return r.Xs.spans(i,t,e,{span(){},point(t,e){t>s&&(n.push({from:s,to:t}),o+=t-s),s=e}},20),s<e&&(n.push({from:s,to:e}),o+=e-s),{total:o,ranges:n}}function Qi({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 Zi(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 tn(t,e){for(let i of t)if(e(i))return i}const en={toDOM(t){return t},fromDOM(t){return t},scale:1};class nn{constructor(t,e,i){let n=0,s=0,r=0;this.viewports=i.map((({from:i,to:s})=>{let r=e.lineAt(i,f.ByPos,t,0,0).top,o=e.lineAt(s,f.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 sn(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),n=e.toDOM(t.bottom);return new Pi(t.from,t.length,i,n-i,Array.isArray(t._content)?t._content.map((t=>sn(t,e))):t._content)}const rn=r.r$.define({combine:t=>t.join(" ")}),on=r.r$.define({combine:t=>t.indexOf(!0)>-1}),hn=o.V.newName(),ln=o.V.newName(),an=o.V.newName(),cn={"&light":"."+ln,"&dark":"."+an};function un(t,e,i){return new o.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 fn=un("."+hn,{"&":{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,flexShrink:0,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",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",left:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",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"},".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"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},cn);class dn{constructor(t,e,i,n){this.typeOver=n,this.bounds=null,this.text="";let{impreciseHead:s,impreciseAnchor:o}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let e=s||o?[]:mn(t),i=new we(e,t.state);i.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=i.text,this.newSel=wn(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=s&&s.node==e.focusNode&&s.offset==e.focusOffset||!p(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),n=o&&o.node==e.anchorNode&&o.offset==e.anchorOffset||!p(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset);this.newSel=r.jT.single(n,i)}}}function gn(t,e){let i,{newSel:n}=e,s=t.state.selection.main,o=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:n,to:h}=e.bounds,l=s.from,c=null;(8===o||a.android&&e.text.length<h-n)&&(l=s.to,c="end");let u=pn(t.state.doc.sliceString(n,h,me),e.text,l-n,c);u&&(a.chrome&&13==o&&u.toB==u.from+2&&e.text.slice(u.from,u.toB)==me+me&&u.toB--,i={from:n+u.from,to:n+u.toA,insert:r.xv.of(e.text.slice(u.from,u.toB).split(me))})}else n&&(!t.hasFocus&&t.state.facet(_t)||n.main.eq(s))&&(n=null);if(!i&&!n)return!1;if(!i&&e.typeOver&&!s.empty&&n&&n.main.empty?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,s.to)}:i&&i.from>=s.from&&i.to<=s.to&&(i.from!=s.from||i.to!=s.to)&&s.to-s.from-(i.to-i.from)<=4?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,s.to))}:(a.mac||a.android)&&i&&i.from==i.to&&i.from==s.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(n&&2==i.insert.length&&(n=r.jT.single(n.main.anchor-1,n.main.head-1)),i={from:s.from,to:s.to,insert:r.xv.of([" "])}):a.chrome&&i&&i.from==i.to&&i.from==s.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(n&&(n=r.jT.single(n.main.anchor-1,n.main.head-1)),i={from:s.from,to:s.to,insert:r.xv.of([" "])}),i){let e=t.state;if(a.ios&&t.inputState.flushIOSKey(t))return!0;if(a.android&&(i.from==s.from&&i.to==s.to&&1==i.insert.length&&2==i.insert.lines&&B(t.contentDOM,"Enter",13)||(i.from==s.from-1&&i.to==s.to&&0==i.insert.length||8==o&&i.insert.length<i.to-i.from)&&B(t.contentDOM,"Backspace",8)||i.from==s.from&&i.to==s.to+1&&0==i.insert.length&&B(t.contentDOM,"Delete",46)))return!0;let h,l=i.insert.toString();if(t.state.facet(Nt).some((e=>e(t,i.from,i.to,l))))return!0;if(t.inputState.composing>=0&&t.inputState.composing++,i.from>=s.from&&i.to<=s.to&&i.to-i.from>=(s.to-s.from)/3&&(!n||n.main.empty&&n.main.from==i.from+i.insert.length)&&t.inputState.composing<0){let n=s.from<i.from?e.sliceDoc(s.from,i.from):"",r=s.to>i.to?e.sliceDoc(i.to,s.to):"";h=e.replaceSelection(t.state.toText(n+i.insert.sliceString(0,void 0,t.state.lineBreak)+r))}else{let o=e.changes(i),l=n&&n.main.to<=o.newLength?n.main:void 0;if(e.selection.ranges.length>1&&t.inputState.composing>=0&&i.to<=s.to&&i.to>=s.to-10){let n=t.state.sliceDoc(i.from,i.to),a=Se(t)||t.state.doc.lineAt(s.head),c=s.to-i.to,u=s.to-s.from;h=e.changeByRange((h=>{if(h.from==s.from&&h.to==s.to)return{changes:o,range:l||h.map(o)};let f=h.to-c,d=f-n.length;if(h.to-h.from!=u||t.state.sliceDoc(d,f)!=n||a&&h.to>=a.from&&h.from<=a.to)return{range:h};let g=e.changes({from:d,to:f,insert:i.insert}),p=h.to-s.to;return{changes:g,range:l?r.jT.range(Math.max(0,l.anchor+p),Math.max(0,l.head+p)):h.map(g)}}))}else h={changes:o,selection:l&&e.selection.replaceRange(l)}}let c="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,c+=".compose",t.inputState.compositionFirstChange&&(c+=".start",t.inputState.compositionFirstChange=!1)),t.dispatch(h,{scrollIntoView:!0,userEvent:c}),!0}if(n&&!n.main.eq(s)){let e=!1,i="select";return t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(e=!0),i=t.inputState.lastSelectionOrigin),t.dispatch({selection:n,scrollIntoView:e,userEvent:i}),!0}return!1}function pn(t,e,i,n){let s=Math.min(t.length,e.length),r=0;for(;r<s&&t.charCodeAt(r)==e.charCodeAt(r);)r++;if(r==s&&t.length==e.length)return null;let o=t.length,h=e.length;for(;o>0&&h>0&&t.charCodeAt(o-1)==e.charCodeAt(h-1);)o--,h--;if("end"==n){i-=o+Math.max(0,r-Math.min(o,h))-r}if(o<r&&t.length<e.length){r-=i<=r&&i>=o?r-i:0,h=r+(h-o),o=r}else if(h<r){r-=i<=r&&i>=h?r-i:0,o=r+(o-h),h=r}return{from:r,toA:o,toB:h}}function mn(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 ye(i,n)),s==i&&r==n||e.push(new ye(s,r))),e}function wn(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?r.jT.single(i+e,n+e):null}const vn={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},yn=a.ie&&a.ie_version<=11;class bn{constructor(t){this.view=t,this.active=!1,this.selectionRange=new O,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.resizeContent=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);(a.ie&&a.ie_version<=11||a.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()})),yn&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver((()=>{var t;(null===(t=this.view.docView)||void 0===t?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()})),this.resizeScroll.observe(t.scrollDOM),this.resizeContent=new ResizeObserver((()=>this.view.requestMeasure())),this.resizeContent.observe(t.contentDOM)),this.addWindowListeners(this.win=t.win),this.start(),"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")))}),{threshold:[0,.001]}),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()}onScrollChanged(t){this.view.inputState.runScrollHandlers(this.view,t),this.intersecting&&this.view.measure()}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){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(_t)?i.root.activeElement!=this.dom:!w(i.dom,n))return;let s=n.anchorNode&&i.docView.nearest(n.anchorNode);s&&s.ignoreEvent(t)?e||(this.selectionChanged=!1):(a.ie&&a.ie_version<=11||a.android&&a.chrome)&&!i.state.selection.main.empty&&n.focusNode&&y(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=a.safari&&11==t.root.nodeType&&m(this.dom.ownerDocument)==this.dom&&Sn(this.view)||g(t.root);if(!e||this.selectionRange.eq(e))return!1;let i=w(this.dom,e);return i&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&N(this.dom,e)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(e),i&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let i=this.dom;i;)if(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,vn),yn&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),yn&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var i;if(!this.delayedAndroidKey){let t=()=>{let t=this.delayedAndroidKey;if(t){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=t.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&t.force&&B(this.dom,t.key,t.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(t)}this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(null===(i=this.delayedAndroidKey)||void 0===i?void 0:i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame((()=>{this.delayedFlush=-1,this.flush()})))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,n=!1;for(let 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}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),n=this.selectionChanged&&w(this.dom,this.selectionRange);return t<0&&!n?null:(t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1,new dn(this.view,t,e,i))}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return!1;let i=this.view.state,n=gn(this.view,e);return this.view.state==i&&this.view.update([]),n}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=xn(e,t.previousSibling||t.target.previousSibling,-1),n=xn(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}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var t,e,i,n;this.stop(),null===(t=this.intersection)||void 0===t||t.disconnect(),null===(e=this.gapIntersection)||void 0===e||e.disconnect(),null===(i=this.resizeScroll)||void 0===i||i.disconnect(),null===(n=this.resizeContent)||void 0===n||n.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}}function xn(t,e,i){for(;e;){let n=H.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 Sn(t){let e=null;function i(t){t.preventDefault(),t.stopImmediatePropagation(),e=t.getTargetRanges()[0]}if(t.contentDOM.addEventListener("beforeinput",i,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",i,!0),!e)return null;let n=e.startContainer,s=e.startOffset,r=e.endContainer,o=e.endOffset,h=t.docView.domAtPos(t.state.selection.main.anchor);return y(h.node,h.offset,r,o)&&([n,s,r,o]=[r,o,n,s]),{anchorNode:n,anchorOffset:s,focusNode:r,focusOffset:o}}class kn{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: fixed; 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||P(t.parent)||document,this.viewState=new Ui(t.state||r.yy.create(t)),this.plugins=this.state.facet(qt).map((t=>new Kt(t)));for(let e of this.plugins)e.update(this);this.observer=new bn(this),this.inputState=new Ue(this),this.inputState.ensureHandlers(this,this.plugins),this.docView=new be(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}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}dispatch(...t){let e=1==t.length&&t[0]instanceof r.YW?t[0]:this.state.update(...t);this._dispatch(e,this)}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=!1,s=this.state;for(let r of t){if(r.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=r.state}if(this.destroyed)return void(this.viewState.state=s);let o=this.hasFocus,h=0,l=null;t.some((t=>t.annotation(Oi)))?(this.inputState.notifiedFocused=o,h=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=Ti(s,o),l||(h=1));let a=this.observer.delayedAndroidKey,c=null;if(a?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(c=null)):this.observer.clear(),s.facet(r.yy.phrases)!=this.state.facet(r.yy.phrases))return this.setState(s);e=ee.create(this,s,t),e.flags|=h;let u=this.viewState.scrollTarget;try{this.updateState=2;for(let e of t){if(u&&(u=u.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection;u=new Wt(t.empty?t:r.jT.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(Ft)&&(u=t.value)}this.viewState.update(e,u),this.bidiCache=Cn.update(this.bidiCache,e.changes),e.empty||(this.updatePlugins(e),this.inputState.update(e)),i=this.docView.update(e),this.state.facet(Zt)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(i,t.some((t=>t.isUserEvent("select.pointer"))))}finally{this.updateState=0}if(e.startState.facet(rn)!=e.state.facet(rn)&&(this.viewState.mustMeasureContent=!0),(i||n||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!e.empty)for(let r of this.state.facet(Lt))r(e);(l||c)&&Promise.resolve().then((()=>{l&&this.state==l.startState&&this.dispatch(l),c&&!gn(this,c)&&a.force&&B(this.contentDOM,a.key,a.keyCode)}))}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 Ui(t),this.plugins=t.facet(qt).map((t=>new Kt(t))),this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView=new be(this),this.inputState.ensureHandlers(this,this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(qt),i=t.state.facet(qt);if(e!=i){let n=[];for(let s of i){let i=e.indexOf(s);if(i<0)n.push(new Kt(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,this.plugins)}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&&this.win.cancelAnimationFrame(this.measureScheduled),this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,i=this.scrollDOM,{scrollTop:n}=i,{scrollAnchorPos:s,scrollAnchorHeight:r}=this.viewState;if(this.viewState.scrollAnchorHeight=-1,r<0||n!=this.viewState.scrollTop)if(n>i.scrollHeight-i.clientHeight-4)s=-1,r=this.viewState.heightMap.height;else{let t=this.viewState.lineBlockAtHeight(n);s=t.from,r=t.top}try{for(let t=0;;t++){this.updateState=1;let h=this.viewport,l=this.viewState.measure(this);if(!l&&!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 a=[];4&l||([this.measureRequests,a]=[a,this.measureRequests]);let c=a.map((t=>{try{return t.read(this)}catch(e){return zt(this.state,e),Mn}})),u=ee.create(this,this.state,[]),f=!1,d=!1;u.flags|=l,e?e.flags|=l:e=u,this.updateState=2,u.empty||(this.updatePlugins(u),this.inputState.update(u),this.updateAttrs(),f=this.docView.update(u));for(let t=0;t<a.length;t++)if(c[t]!=Mn)try{let e=a[t];e.write&&e.write(c[t],this)}catch(o){zt(this.state,o)}if(this.viewState.editorHeight)if(this.viewState.scrollTarget)this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,d=!0;else if(r>-1){let t=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-r;(t>1||t<-1)&&(i.scrollTop=n+t,d=!0)}if(f&&this.docView.updateSelection(!0),this.viewport.from==h.from&&this.viewport.to==h.to&&!d&&0==this.measureRequests.length)break;r=-1}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let h of this.state.facet(Lt))h(e)}get themeClasses(){return hn+" "+(this.state.facet(on)?an:ln)+" "+this.state.facet(rn)}updateAttrs(){let t=On(this,Jt,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(_t)?"true":"false",class:"cm-content",style:`${a.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),On(this,Gt,e);let i=this.observer.ignore((()=>{let i=wt(this.contentDOM,this.contentAttrs,e),n=wt(this.dom,this.editorAttrs,t);return i||n}));return this.editorAttrs=t,this.contentAttrs=e,i}showAnnouncements(t){let e=!0;for(let i of t)for(let t of i.effects)if(t.is(kn.announce)){e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(Zt),o.V.mount(this.root,this.styleModules.concat(fn).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=this.win.requestAnimationFrame((()=>this.measure()))),t){if(this.measureRequests.indexOf(t)>-1)return;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)}}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}}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return Ge(this,t,qe(this,t,e,i))}moveByGroup(t,e){return Ge(this,t,qe(this,t,e,(e=>$e(this,t.head,e))))}moveToLineBoundary(t,e,i=!0){return je(this,t,e,i)}moveVertically(t,e,i){return Ge(this,t,Ke(this,t,e,i))}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){return this.readMeasured(),He(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);return k(i,s[ce.find(s,t-n.from,-1,e)].dir==u.LTR==e>0)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(Vt)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>An)return de(t.length);let e=this.textDirectionAt(t.from);for(let n of this.bidiCache)if(n.from==t.from&&n.dir==e)return n.order;let i=fe(t.text,e);return this.bidiCache.push(new Cn(t.from,t.to,e,i)),i}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||a.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{E(this.contentDOM),this.docView.updateSelection()}))}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((9==t.nodeType?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return Ft.of(new Wt("number"==typeof t?r.jT.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}static domEventHandlers(t){return $t.define((()=>({})),{eventHandlers:t})}static theme(t,e){let i=o.V.newName(),n=[rn.of(i),Zt.of(un(`.${i}`,t))];return e&&e.dark&&n.push(on.of(!0)),n}static baseTheme(t){return r.Wl.lowest(Zt.of(un("."+hn,t,cn)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),n=i&&H.get(i)||H.get(t);return(null===(e=null==n?void 0:n.rootView)||void 0===e?void 0:e.view)||null}}kn.styleModule=Zt,kn.inputHandler=Nt,kn.focusChangeEffect=It,kn.perLineTextDirection=Vt,kn.exceptionSink=Pt,kn.updateListener=Lt,kn.editable=_t,kn.mouseSelectionStyle=Bt,kn.dragMovesSelection=Rt,kn.clickAddsSelectionRange=Et,kn.decorations=Ut,kn.atomicRanges=Xt,kn.scrollMargins=Yt,kn.darkTheme=on,kn.contentAttributes=Gt,kn.editorAttributes=Jt,kn.lineWrapping=kn.contentAttributes.of({class:"cm-lineWrapping"}),kn.announce=r.Py.define();const An=4096,Mn={};class Cn{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:u.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 Cn(e.mapPos(r.from,1),e.mapPos(r.to,-1),r.dir,r.order))}return i}}function On(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&&pt(r,i)}return i}const Tn=a.mac?"mac":a.windows?"win":a.linux?"linux":"key";function Dn(t,e){const i=t.split(/-(?!$)/);let n,s,r,o,h=i[i.length-1];"Space"==h&&(h=" ");for(let l=0;l<i.length-1;++l){const t=i[l];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&&(h="Alt-"+h),s&&(h="Ctrl-"+h),o&&(h="Meta-"+h),r&&(h="Shift-"+h),h}function En(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 Rn=r.Wl.default(kn.domEventHandlers({keydown(t,e){return Wn(Ln(e.state),t,e,"editor")}})),Bn=r.r$.define({enables:Rn}),Pn=new WeakMap;function Ln(t){let e=t.facet(Bn),i=Pn.get(e);return i||Pn.set(e,i=Hn(e.reduce(((t,e)=>t.concat(e)),[]))),i}function Nn(t,e,i){return Wn(Ln(t.state),e,t,i)}let In=null;const Vn=4e3;function Hn(t,e=Tn){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)=>{var h,l;let a=i[t]||(i[t]=Object.create(null)),c=n.split(/ (?!$)/).map((t=>Dn(t,e)));for(let e=1;e<c.length;e++){let i=c.slice(0,e).join(" ");s(i,!0),a[i]||(a[i]={preventDefault:!0,run:[e=>{let n=In={view:e,prefix:i,scope:t};return setTimeout((()=>{In==n&&(In=null)}),Vn),!0}]})}let u=c.join(" ");s(u,!1);let f=a[u]||(a[u]={preventDefault:!1,run:(null===(l=null===(h=a._any)||void 0===h?void 0:h.run)||void 0===l?void 0:l.slice())||[]});r&&f.run.push(r),o&&(f.preventDefault=!0)};for(let o of t){let t=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let e of t){let t=i[e]||(i[e]=Object.create(null));t._any||(t._any={preventDefault:!1,run:[]});for(let e in t)t[e].run.push(o.any)}let n=o[e]||o.key;if(n)for(let e of t)r(e,n,o.run,o.preventDefault),o.shift&&r(e,"Shift-"+n,o.shift,o.preventDefault)}return i}function Wn(t,e,i,n){let s=(0,h.YG)(e),o=(0,r.gm)(s,0),l=(0,r.nZ)(o)==s.length&&" "!=s,c="",u=!1;In&&In.view==i&&In.scope==n&&(c=In.prefix+" ",(u=Qe.indexOf(e.keyCode)<0)&&(In=null));let f,d,g=new Set,p=t=>{if(t){for(let n of t.run)if(!g.has(n)&&(g.add(n),n(i,e)))return!0;t.preventDefault&&(u=!0)}return!1},m=t[n];if(m){if(p(m[c+En(s,e,!l)]))return!0;if(l&&(e.altKey||e.metaKey||e.ctrlKey)&&!(a.windows&&e.ctrlKey&&e.altKey)&&(f=h.ue[e.keyCode])&&f!=s){if(p(m[c+En(f,e,!0)]))return!0;if(e.shiftKey&&(d=h.uY[e.keyCode])!=s&&d!=f&&p(m[c+En(d,e,!1)]))return!0}else if(l&&e.shiftKey&&p(m[c+En(s,e,!0)]))return!0;if(p(m._any))return!0}return u}const Fn=!a.ios;const zn={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};Fn&&(zn[".cm-line"].caretColor="transparent !important");const _n=r.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 jn(t,e){let i=t.plugin(qn),n=i?i.specs.indexOf(e):-1;return n>-1?i.panels[n]:null}const qn=$t.fromClass(class{constructor(t){this.input=t.state.facet(Jn),this.specs=this.input.filter((t=>t)),this.panels=this.specs.map((e=>e(t)));let e=t.state.facet(_n);this.top=new $n(t,!0,e.topContainer),this.bottom=new $n(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(_n);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new $n(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new $n(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let i=t.state.facet(Jn);if(i!=this.input){let e=i.filter((t=>t)),n=[],s=[],r=[],o=[];for(let i of e){let e,h=this.specs.indexOf(i);h<0?(e=i(t.view),o.push(e)):(e=this.panels[h],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:t=>kn.scrollMargins.of((e=>{let i=e.plugin(t);return i&&{top:i.top.scrollMargin(),bottom:i.bottom.scrollMargin()}}))});class $n{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){for(;t!=e.dom;)t=Kn(t);t=t.nextSibling}else this.dom.insertBefore(e.dom,t);for(;t;)t=Kn(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 Kn(t){let e=t.nextSibling;return t.remove(),e}const Jn=r.r$.define({enables:qn});class Gn extends r.uU{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Gn.prototype.elementClass="",Gn.prototype.toDOM=void 0,Gn.prototype.mapMode=r.gc.TrackBefore,Gn.prototype.startSide=Gn.prototype.endSide=-1,Gn.prototype.point=!0;n()}catch(d){n(d)}}))},96381:function(t,e,i){i.d(e,{BO:function(){return dt},F6:function(){return W},f_:function(){return yt},r$:function(){return D},yy:function(){return ft}});i(63721),i(52247),i(71695),i(92745),i(52805),i(61495),i(61893),i(69235),i(12385),i(19134),i(32517),i(5740),i(11740),i(92519),i(42179),i(89256),i(24931),i(88463),i(57449),i(19814),i(97003),i(32114),i(39527),i(92181),i(99790),i(67670),i(41360),i(13334),i(34595),i(36993),i(47021);var n=i(23618);class s{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){[t,e]=d(this,t,e);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),o.from(n,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){[t,e]=d(this,t,e);let i=[];return this.decompose(t,e,i,0),o.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 a(this),s=new a(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 a(this,t)}iterRange(t,e=this.length){return new c(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 u(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}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 r(t):o.from(r.split(t,[])):s.empty}}class r extends s{constructor(t,e=function(t){let e=-1;for(let i of t)e+=i.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.text[s],o=n+r.length;if((e?i:o)>=t)return new f(n,o,i,r);n=o+1,i++}}decompose(t,e,i,n){let s=t<=0&&e>=this.length?this:new r(l(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&n){let t=i.pop(),e=h(s.text,t.text.slice(),0,s.length);if(e.length<=32)i.push(new r(e,t.length+s.length));else{let t=e.length>>1;i.push(new r(e.slice(0,t)),new r(e.slice(t)))}}else i.push(s)}replace(t,e,i){if(!(i instanceof r))return super.replace(t,e,i);[t,e]=d(this,t,e);let n=h(this.text,h(i.text,l(this.text,0,t)),e),s=this.length+i.length-(e-t);return n.length<=32?new r(n,s):o.from(r.split(n,[]),s)}sliceString(t,e=this.length,i="\n"){[t,e]=d(this,t,e);let n="";for(let s=0,r=0;s<=e&&r<this.text.length;r++){let o=this.text[r],h=s+o.length;s>t&&r&&(n+=i),t<h&&e>s&&(n+=o.slice(Math.max(0,t-s),e-s)),s=h+1}return n}flatten(t){for(let e of this.text)t.push(e)}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 r(i,n)),i=[],n=-1);return n>-1&&e.push(new r(i,n)),e}}class o extends s{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,h=i+r.lines-1;if((e?h:o)>=t)return r.lineInner(t,e,i,n);n=o+1,i=h+1}}decompose(t,e,i,n){for(let s=0,r=0;r<=e&&s<this.children.length;s++){let o=this.children[s],h=r+o.length;if(t<=h&&e>=r){let s=n&((r<=t?1:0)|(h>=e?2:0));r>=t&&h<=e&&!s?i.push(o):o.decompose(t-r,e-r,i,s)}r=h+1}}replace(t,e,i){if([t,e]=d(this,t,e),i.lines<this.lines)for(let n=0,s=0;n<this.children.length;n++){let r=this.children[n],h=s+r.length;if(t>=s&&e<=h){let l=r.replace(t-s,e-s,i),a=this.lines-r.lines+l.lines;if(l.lines<a>>4&&l.lines>a>>6){let s=this.children.slice();return s[n]=l,new o(s,this.length-(e-t)+i.length)}return super.replace(s,h,l)}s=h+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i="\n"){[t,e]=d(this,t,e);let n="";for(let s=0,r=0;s<this.children.length&&r<=e;s++){let o=this.children[s],h=r+o.length;r>t&&s&&(n+=i),t<h&&e>r&&(n+=o.sliceString(t-r,e-r,i)),r=h+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof o))return 0;let i=0,[n,s,r,h]=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==h)return i;let o=this.children[n],l=t.children[s];if(o!=l)return i+o.scanIdentical(l,e);i+=o.length+1}}static from(t,e=t.reduce(((t,e)=>t+e.length+1),-1)){let i=0;for(let r of t)i+=r.lines;if(i<32){let i=[];for(let e of t)e.flatten(i);return new r(i,e)}let n=Math.max(32,i>>5),s=n<<1,h=n>>1,l=[],a=0,c=-1,u=[];function f(t){let e;if(t.lines>s&&t instanceof o)for(let i of t.children)f(i);else t.lines>h&&(a>h||!a)?(d(),l.push(t)):t instanceof r&&a&&(e=u[u.length-1])instanceof r&&t.lines+e.lines<=32?(a+=t.lines,c+=t.length+1,u[u.length-1]=new r(e.text.concat(t.text),e.length+1+t.length)):(a+t.lines>n&&d(),a+=t.lines,c+=t.length+1,u.push(t))}function d(){0!=a&&(l.push(1==u.length?u[0]:o.from(u,c)),c=-1,a=u.length=0)}for(let r of t)f(r);return d(),1==l.length?l[0]:new o(l,e)}}function h(t,e,i=0,n=1e9){for(let s=0,r=0,o=!0;r<t.length&&s<=n;r++){let h=t[r],l=s+h.length;l>=i&&(l>n&&(h=h.slice(0,n-s)),s<i&&(h=h.slice(i-s)),o?(e[e.length-1]+=h,o=!1):e.push(h)),s=l+1}return e}function l(t,e,i){return h(t,[""],e,i)}s.empty=new r([""],0);class a{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 r?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],o=s>>1,h=n instanceof r?n.text.length:n.children.length;if(o==(e>0?h: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 r){let s=n.text[o+(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[o+(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 r?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 c{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new a(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 u{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:n}=this.inner.next(t);return e&&this.afterBreak?(this.value="",this.afterBreak=!1):e?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(s.prototype[Symbol.iterator]=function(){return this.iter()},a.prototype[Symbol.iterator]=c.prototype[Symbol.iterator]=u.prototype[Symbol.iterator]=function(){return this});class f{constructor(t,e,i,n){this.from=t,this.to=e,this.number=i,this.text=n}get length(){return this.to-this.from}}function d(t,e,i){return[e=Math.max(0,Math.min(t.length,e)),Math.max(e,Math.min(t.length,i))]}function g(t,e,i=!0,s=!0){return(0,n.c)(t,e,i,s)}const p=/\r\n?|\n/;var m=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(m||(m={}));class w{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){x(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 w(t)}composeDesc(t){return this.empty?t:t.empty?this:k(this,t)}mapDesc(t,e=!1){return t.empty?this:S(this,t,e)}mapPos(t,e=-1,i=m.Simple){let n=0,s=0;for(let r=0;r<this.sections.length;){let o=this.sections[r++],h=this.sections[r++],l=n+o;if(h<0){if(l>t)return s+(t-n);s+=o}else{if(i!=m.Simple&&l>=t&&(i==m.TrackDel&&n<t&&l>t||i==m.TrackBefore&&n<t||i==m.TrackAfter&&l>t))return null;if(l>t||l==t&&e<0&&!o)return t==n||e<0?s:s+h;s+=h}n=l}if(t>n)throw new RangeError(`Position ${t} is out of range for changeset of length ${n}`);return s}touchesRange(t,e=t){for(let i=0,n=0;i<this.sections.length&&n<=e;){let s=n+this.sections[i++];if(this.sections[i++]>=0&&n<=e&&s>=t)return!(n<t&&s>e)||"cover";n=s}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];t+=(t?" ":"")+i+(n>=0?":"+n:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some((t=>"number"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeDesc");return new w(t)}static create(t){return new w(t)}}class v extends w{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 x(this,((e,i,n,s,r)=>t=t.replace(n,n+(i-e),r)),!1),t}mapDesc(t,e=!1){return S(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let n=0,r=0;n<e.length;n+=2){let o=e[n],h=e[n+1];if(h>=0){e[n]=h,e[n+1]=o;let l=n>>1;for(;i.length<l;)i.push(s.empty);i.push(o?t.slice(r,r+o):s.empty)}r+=o}return new v(e,i)}compose(t){return this.empty?t:t.empty?this:k(this,t,!0)}map(t,e=!1){return t.empty?this:S(this,t,e,!0)}iterChanges(t,e=!1){x(this,t,e)}get desc(){return w.create(this.sections)}filter(t){let e=[],i=[],n=[],s=new A(this);t:for(let r=0,o=0;;){let h=r==t.length?1e9:t[r++];for(;o<h||o==h&&0==s.len;){if(s.done)break t;let t=Math.min(s.len,h-o);y(n,t,-1);let r=-1==s.ins?-1:0==s.off?s.ins:0;y(e,t,r),r>0&&b(i,e,s.text),s.forward(t),o+=t}let l=t[r++];for(;o<l;){if(s.done)break t;let t=Math.min(s.len,l-o);y(e,t,-1),y(n,t,-1==s.ins?-1:0==s.off?s.ins:0),s.forward(t),o+=t}}return{changes:new v(e,i),filtered:w.create(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 n=[],r=[],o=0,h=null;function l(t=!1){if(!t&&!n.length)return;o<e&&y(n,e-o,-1);let i=new v(n,r);h=h?h.compose(i.map(h)):i,n=[],r=[],o=0}return function t(a){if(Array.isArray(a))for(let e of a)t(e);else if(a instanceof v){if(a.length!=e)throw new RangeError(`Mismatched change set length (got ${a.length}, expected ${e})`);l(),h=h?h.compose(a.map(h)):a}else{let{from:t,to:h=t,insert:c}=a;if(t>h||t<0||h>e)throw new RangeError(`Invalid change range ${t} to ${h} (in doc of length ${e})`);let u=c?"string"==typeof c?s.of(c.split(i||p)):c:s.empty,f=u.length;if(t==h&&0==f)return;t<o&&l(),t>o&&y(n,t-o,-1),y(n,h-t,f),b(r,n,u),o=h}}(t),l(!h),h}static empty(t){return new v(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],i=[];for(let n=0;n<t.length;n++){let r=t[n];if("number"==typeof r)e.push(r,-1);else{if(!Array.isArray(r)||"number"!=typeof r[0]||r.some(((t,e)=>e&&"string"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==r.length)e.push(r[0],0);else{for(;i.length<n;)i.push(s.empty);i[n]=s.of(r.slice(1)),e.push(r[0],i[n].length)}}}return new v(e,i)}static createSet(t,e){return new v(t,e)}}function y(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:s>=0&&0==e&&0==t[s]?t[s+1]+=i:n?(t[s]+=e,t[s+1]+=i):t.push(e,i)}function b(t,e,i){if(0==i.length)return;let n=e.length-2>>1;if(n<t.length)t[t.length-1]=t[t.length-1].append(i);else{for(;t.length<n;)t.push(s.empty);t.push(i)}}function x(t,e,i){let n=t.inserted;for(let r=0,o=0,h=0;h<t.sections.length;){let l=t.sections[h++],a=t.sections[h++];if(a<0)r+=l,o+=l;else{let c=r,u=o,f=s.empty;for(;c+=l,u+=a,a&&n&&(f=f.append(n[h-2>>1])),!(i||h==t.sections.length||t.sections[h+1]<0);)l=t.sections[h++],a=t.sections[h++];e(r,c,o,u,f),r=c,o=u}}}function S(t,e,i,n=!1){let s=[],r=n?[]:null,o=new A(t),h=new A(e);for(let l=-1;;){if(o.done&&h.len||h.done&&o.len)throw new Error("Mismatched change set lengths");if(-1==o.ins&&-1==h.ins){let t=Math.min(o.len,h.len);y(s,t,-1),o.forward(t),h.forward(t)}else if(h.ins>=0&&(o.ins<0||l==o.i||0==o.off&&(h.len<o.len||h.len==o.len&&!i))){let t=h.len;for(y(s,h.ins,-1);t;){let e=Math.min(o.len,t);o.ins>=0&&l<o.i&&o.len<=e&&(y(s,0,o.ins),r&&b(r,s,o.text),l=o.i),o.forward(e),t-=e}h.next()}else{if(!(o.ins>=0)){if(o.done&&h.done)return r?v.createSet(s,r):w.create(s);throw new Error("Mismatched change set lengths")}{let t=0,e=o.len;for(;e;)if(-1==h.ins){let i=Math.min(e,h.len);t+=i,e-=i,h.forward(i)}else{if(!(0==h.ins&&h.len<e))break;e-=h.len,h.next()}y(s,t,l<o.i?o.ins:0),r&&l<o.i&&b(r,s,o.text),l=o.i,o.forward(o.len-e)}}}}function k(t,e,i=!1){let n=[],s=i?[]:null,r=new A(t),o=new A(e);for(let h=!1;;){if(r.done&&o.done)return s?v.createSet(n,s):w.create(n);if(0==r.ins)y(n,r.len,0,h),r.next();else if(0!=o.len||o.done){if(r.done||o.done)throw new Error("Mismatched change set lengths");{let t=Math.min(r.len2,o.len),e=n.length;if(-1==r.ins){let e=-1==o.ins?-1:o.off?0:o.ins;y(n,t,e,h),s&&e&&b(s,n,o.text)}else-1==o.ins?(y(n,r.off?0:r.len,t,h),s&&b(s,n,r.textBit(t))):(y(n,r.off?0:r.len,o.off?0:o.ins,h),s&&!o.off&&b(s,n,o.text));h=(r.ins>t||o.ins>=0&&o.len>t)&&(h||n.length>e),r.forward2(t),o.forward(t)}}else y(n,0,o.ins,h),s&&b(s,n,o.text),o.next()}}class A{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?s.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?s.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 M{constructor(t,e,i){this.from=t,this.to=e,this.flags=i}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let t=7&this.flags;return 7==t?null:t}get goalColumn(){let t=this.flags>>6;return 16777215==t?void 0:t}map(t,e=-1){let i,n;return this.empty?i=n=t.mapPos(this.from,e):(i=t.mapPos(this.from,1),n=t.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new M(i,n,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return C.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return C.range(this.anchor,i)}eq(t,e=!1){return!(this.anchor!=t.anchor||this.head!=t.head||e&&this.empty&&this.assoc!=t.assoc)}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 C.range(t.anchor,t.head)}static create(t,e,i){return new M(t,e,i)}}class C{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:C.create(this.ranges.map((i=>i.map(t,e))),this.mainIndex)}eq(t,e=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(t.ranges[i],e))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new C([this.main],0)}addRange(t,e=!0){return C.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,C.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 C(t.ranges.map((t=>M.fromJSON(t))),t.main)}static single(t,e=t){return new C([C.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 C.normalized(t.slice(),e);i=s.to}return new C(t,e)}static cursor(t,e=0,i,n){return M.create(t,t,(0==e?0:e<0?8:16)|(null==i?7:Math.min(6,i))|(null!=n?n:16777215)<<6)}static range(t,e,i,n){let s=(null!=i?i:16777215)<<6|(null==n?7:Math.min(6,n));return e<t?M.create(e,t,48|s):M.create(t,e,(e>t?8:0)|s)}static normalized(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?C.range(o,r):C.range(r,o))}}return new C(t,e)}}function O(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let T=0;class D{constructor(t,e,i,n,s){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=T++,this.default=t([]),this.extensions="function"==typeof s?s(this):s}get reader(){return this}static define(t={}){return new D(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:E),!!t.static,t.enables)}of(t){return new R([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new R(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new R(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],(i=>e(i.field(t))))}}function E(t,e){return t==e||t.length==e.length&&t.every(((t,i)=>t===e[i]))}class R{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=T++}dynamicSlot(t){var e;let i=this.value,n=this.facet.compareInput,s=this.id,r=t[s]>>1,o=2==this.type,h=!1,l=!1,a=[];for(let c of this.dependencies)"doc"==c?h=!0:"selection"==c?l=!0:1&(null!==(e=t[c.id])&&void 0!==e?e:1)||a.push(t[c.id]);return{create(t){return t.values[r]=i(t),1},update(t,e){if(h&&e.docChanged||l&&(e.docChanged||e.selection)||P(t,a)){let e=i(t);if(o?!B(e,t.values[r],n):!n(e,t.values[r]))return t.values[r]=e,1}return 0},reconfigure:(t,e)=>{let h,l=e.config.address[s];if(null!=l){let s=j(e,l);if(this.dependencies.every((i=>i instanceof D?e.facet(i)===t.facet(i):!(i instanceof I)||e.field(i,!1)==t.field(i,!1)))||(o?B(h=i(t),s,n):n(h=i(t),s)))return t.values[r]=s,0}else h=i(t);return t.values[r]=h,1}}}}function B(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 P(t,e){let i=!1;for(let n of e)1&_(t,n)&&(i=!0);return i}function L(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;function h(t){let i=[];for(let e=0;e<n.length;e++){let r=j(t,n[e]);if(2==s[e])for(let t of r)i.push(t);else i.push(r)}return e.combine(i)}return{create(t){for(let e of n)_(t,e);return t.values[o]=h(t),1},update(t,i){if(!P(t,r))return 0;let n=h(t);return e.compare(n,t.values[o])?0:(t.values[o]=n,1)},reconfigure(t,s){let r=P(t,n),l=s.config.facets[e.id],a=s.facet(e);if(l&&!r&&E(i,l))return t.values[o]=a,0;let c=h(t);return e.compare(c,a)?(t.values[o]=a,0):(t.values[o]=c,1)}}}const N=D.define({static:!0});class I{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 I(T++,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(N).find((t=>t.field==this));return((null==e?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:t=>(t.values[e]=this.create(t),1),update:(t,i)=>{let n=t.values[e],s=this.updateF(n,i);return this.compareF(n,s)?0:(t.values[e]=s,1)},reconfigure:(t,i)=>null!=i.config.address[this.id]?(t.values[e]=i.field(this),0):(t.values[e]=this.create(t),1)}}init(t){return[this,N.of({field:this,create:t})]}get extension(){return this}}const V=2;class H{constructor(t,e){this.inner=t,this.prec=e}}class W{of(t){return new F(this,t)}reconfigure(t){return W.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class F{constructor(t,e){this.compartment=t,this.inner=e}}class z{constructor(t,e,i,n,s,r){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=s,this.facets=r,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return null==e?t.default:this.staticValues[e>>1]}static resolve(t,e,i){let n=[],s=Object.create(null),r=new Map;for(let u of function(t,e,i){let n=[[],[],[],[],[]],s=new Map;function r(t,o){let h=s.get(t);if(null!=h){if(h<=o)return;let e=n[h].indexOf(t);e>-1&&n[h].splice(e,1),t instanceof F&&i.delete(t.compartment)}if(s.set(t,o),Array.isArray(t))for(let e of t)r(e,o);else if(t instanceof F){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 H)r(t.inner,t.prec);else if(t instanceof I)n[o].push(t),t.provides&&r(t.provides,o);else if(t instanceof R)n[o].push(t),t.facet.extensions&&r(t.facet.extensions,V);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,V),n.reduce(((t,e)=>t.concat(e)))}(t,e,r))u instanceof I?n.push(u):(s[u.facet.id]||(s[u.facet.id]=[])).push(u);let o=Object.create(null),h=[],l=[];for(let u of n)o[u.id]=l.length<<1,l.push((t=>u.slot(t)));let a=null==i?void 0:i.config.facets;for(let u in s){let t=s[u],e=t[0].facet,n=a&&a[u]||[];if(t.every((t=>0==t.type)))if(o[e.id]=h.length<<1|1,E(n,t))h.push(i.facet(e));else{let n=e.combine(t.map((t=>t.value)));h.push(i&&e.compare(n,i.facet(e))?i.facet(e):n)}else{for(let e of t)0==e.type?(o[e.id]=h.length<<1|1,h.push(e.value)):(o[e.id]=l.length<<1,l.push((t=>e.dynamicSlot(t))));o[e.id]=l.length<<1,l.push((i=>L(i,e,t)))}}let c=l.map((t=>t(o)));return new z(t,r,c,o,h,s)}}function _(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.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|s}function j(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const q=D.define(),$=D.define({combine:t=>t.some((t=>t)),static:!0}),K=D.define({combine:t=>t.length?t[0]:void 0,static:!0}),J=D.define(),G=D.define(),U=D.define(),X=D.define({combine:t=>!!t.length&&t[0]});class Y{constructor(t,e){this.type=t,this.value=e}static define(){return new Q}}class Q{of(t){return new Y(this,t)}}class Z{constructor(t){this.map=t}of(t){return new tt(this,t)}}class tt{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 tt(this.type,e)}is(t){return this.type==t}static define(t={}){return new Z(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}}tt.reconfigure=tt.define(),tt.appendConfig=tt.define();class et{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&&O(i,e.newLength),s.some((t=>t.type==et.time))||(this.annotations=s.concat(et.time.of(Date.now())))}static create(t,e,i,n,s,r){return new et(t,e,i,n,s,r)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(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(et.userEvent);return!(!e||!(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function it(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 nt(t,e,i){var n;let s,r,o;return i?(s=e.changes,r=v.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:tt.mapEffects(t.effects,s).concat(tt.mapEffects(e.effects,r)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function st(t,e,i){let n=e.selection,s=ht(e.annotations);return e.userEvent&&(s=s.concat(et.userEvent.of(e.userEvent))),{changes:e.changes instanceof v?e.changes:v.of(e.changes||[],i,t.facet(K)),selection:n&&(n instanceof C?n:C.single(n.anchor,n.head)),effects:ht(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function rt(t,e,i){let n=st(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=nt(n,st(t,e[r],s?n.changes.newLength:t.doc.length),s)}let s=et.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return function(t){let e=t.startState,i=e.facet(U),n=t;for(let s=i.length-1;s>=0;s--){let r=i[s](t);r&&Object.keys(r).length&&(n=nt(n,st(e,r,t.changes.newLength),!0))}return n==t?t:et.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}(i?function(t){let e=t.startState,i=!0;for(let s of e.facet(J)){let e=s(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:it(i,e))}if(!0!==i){let n,s;if(!1===i)s=t.changes.invertedDesc,n=v.empty(e.doc.length);else{let e=t.changes.filter(i);n=e.changes,s=e.filtered.mapDesc(e.changes).invertedDesc}t=et.create(e,n,t.selection&&t.selection.map(s),tt.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let n=e.facet(G);for(let s=n.length-1;s>=0;s--){let i=n[s](t);t=i instanceof et?i:Array.isArray(i)&&1==i.length&&i[0]instanceof et?i[0]:rt(e,ht(i),!1)}return t}(s):s)}et.time=Y.define(),et.userEvent=Y.define(),et.addToHistory=Y.define(),et.remote=Y.define();const ot=[];function ht(t){return null==t?ot:Array.isArray(t)?t:[t]}var lt=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(lt||(lt={}));const at=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let ct;try{ct=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(Et){}function ut(t){return e=>{if(!/\S/.test(e))return lt.Space;if(function(t){if(ct)return ct.test(t);for(let e=0;e<t.length;e++){let i=t[e];if(/\w/.test(i)||i>"€"&&(i.toUpperCase()!=i.toLowerCase()||at.test(i)))return!0}return!1}(e))return lt.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return lt.Word;return lt.Other}}class ft{constructor(t,e,i,n,s,r){this.config=t,this.doc=e,this.selection=i,this.values=n,this.status=t.statusTemplate.slice(),this.computeSlot=s,r&&(r._state=this);for(let o=0;o<this.config.dynamicSlots.length;o++)_(this,o<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(null!=i)return _(this,i),j(this,i);if(e)throw new RangeError("Field is not present in this state")}update(...t){return rt(this,t,!0)}applyTransaction(t){let e,i=this.config,{base:n,compartments:s}=i;for(let o of t.effects)o.is(W.reconfigure)?(i&&(s=new Map,i.compartments.forEach(((t,e)=>s.set(e,t))),i=null),s.set(o.value.compartment,o.value.extension)):o.is(tt.reconfigure)?(i=null,n=o.value):o.is(tt.appendConfig)&&(i=null,n=ht(n).concat(o.value));if(i)e=t.startState.values.slice();else{i=z.resolve(n,s,this),e=new ft(i,this.doc,this.selection,i.dynamicSlots.map((()=>null)),((t,e)=>e.reconfigure(t,this)),null).values}let r=t.startState.facet($)?t.newSelection:t.newSelection.asSingle();new ft(i,t.newDoc,r,e,((e,i)=>i.update(e,t)),t)}replaceSelection(t){return"string"==typeof t&&(t=this.toText(t)),this.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:t},range:C.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=ht(i.effects);for(let o=1;o<e.ranges.length;o++){let i=t(e.ranges[o]),h=this.changes(i.changes),l=h.map(n);for(let t=0;t<o;t++)s[t]=s[t].map(l);let a=n.mapDesc(h,!0);s.push(i.range.map(a)),n=n.compose(l),r=tt.mapEffects(r,l).concat(tt.mapEffects(ht(i.effects),a))}return{changes:n,selection:C.create(s,e.mainIndex),effects:r}}changes(t=[]){return t instanceof v?t:v.of(t,this.doc.length,this.facet(ft.lineSeparator))}toText(t){return s.of(t.split(this.facet(ft.lineSeparator)||p))}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:(_(this,e),j(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 I&&null!=this.config.address[n.id]&&(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)if(Object.prototype.hasOwnProperty.call(t,s)){let e=i[s],r=t[s];n.push(e.init((t=>e.spec.fromJSON(r,t))))}return ft.create({doc:t.doc,selection:C.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let e=z.resolve(t.extensions||[],new Map),i=t.doc instanceof s?t.doc:s.of((t.doc||"").split(e.staticFacet(ft.lineSeparator)||p)),n=t.selection?t.selection instanceof C?t.selection:C.single(t.selection.anchor,t.selection.head):C.single(0);return O(n,i.length),e.staticFacet($)||(n=n.asSingle()),new ft(e,i,n,e.dynamicSlots.map((()=>null)),((t,e)=>e.create(t)),null)}get tabSize(){return this.facet(ft.tabSize)}get lineBreak(){return this.facet(ft.lineSeparator)||"\n"}get readOnly(){return this.facet(X)}phrase(t,...e){for(let i of this.facet(ft.phrases))if(Object.prototype.hasOwnProperty.call(i,t)){t=i[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,((t,i)=>{if("$"==i)return"$";let n=+(i||1);return!n||n>e.length?t:e[n-1]}))),t}languageDataAt(t,e,i=-1){let n=[];for(let s of this.facet(q))for(let r of s(this,e,i))Object.prototype.hasOwnProperty.call(r,t)&&n.push(r[t]);return n}charCategorizer(t){return ut(this.languageDataAt("wordChars",t).join(""))}wordAt(t){let{text:e,from:i,length:n}=this.doc.lineAt(t),s=this.charCategorizer(t),r=t-i,o=t-i;for(;r>0;){let t=g(e,r,!1);if(s(e.slice(t,r))!=lt.Word)break;r=t}for(;o<n;){let t=g(e,o);if(s(e.slice(o,t))!=lt.Word)break;o=t}return r==o?null:C.range(r+i,o+i)}}function dt(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}ft.allowMultipleSelections=$,ft.tabSize=D.define({combine:t=>t.length?t[0]:4}),ft.lineSeparator=K,ft.readOnly=X,ft.phrases=D.define({compare(t,e){let i=Object.keys(t),n=Object.keys(e);return i.length==n.length&&i.every((i=>t[i]==e[i]))}}),ft.languageData=q,ft.changeFilter=J,ft.transactionFilter=G,ft.transactionExtender=U,W.reconfigure=tt.define();class gt{eq(t){return this==t}range(t,e=t){return pt.create(t,e,this)}}gt.prototype.startSide=gt.prototype.endSide=0,gt.prototype.point=!1,gt.prototype.mapMode=m.TrackDel;class pt{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new pt(t,e,i)}}function mt(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class wt{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,h=s[n]-t||(i?this.value[n].endSide:this.value[n].startSide)-e;if(n==r)return h>=0?r:o;h>=0?o=n:r=n+1}}between(t,e,i,n){for(let s=this.findIndex(e,-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 h=0;h<this.value.length;h++){let l,a,c=this.value[h],u=this.from[h]+t,f=this.to[h]+t;if(u==f){let t=e.mapPos(u,c.startSide,c.mapMode);if(null==t)continue;if(l=a=t,c.startSide!=c.endSide&&(a=e.mapPos(u,c.endSide),a<l))continue}else if(l=e.mapPos(u,c.startSide),a=e.mapPos(f,c.endSide),l>a||l==a&&c.startSide>0&&c.endSide<=0)continue;(a-l||c.endSide-c.startSide)<0||(r<0&&(r=l),c.point&&(o=Math.max(o,a-l)),i.push(c),n.push(l-r),s.push(a-r))}return{mapped:i.length?new wt(n,s,i,o):null,pos:r}}}class vt{constructor(t,e,i,n){this.chunkPos=t,this.chunk=e,this.nextLayer=i,this.maxPoint=n}static create(t,e,i,n){return new vt(t,e,i,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,r=t.filter;if(0==e.length&&!r)return this;if(i&&(e=e.slice().sort(mt)),this.isEmpty)return e.length?vt.of(e):this;let o=new xt(this,null,-1).goto(0),h=0,l=[],a=new yt;for(;o.value||h<e.length;)if(h<e.length&&(o.from-e[h].from||o.startSide-e[h].value.startSide)>=0){let t=e[h++];a.addInner(t.from,t.to,t.value)||l.push(t)}else 1==o.rangeIndex&&o.chunkIndex<this.chunk.length&&(h==e.length||this.chunkEnd(o.chunkIndex)<e[h].from)&&(!r||n>this.chunkEnd(o.chunkIndex)||s<this.chunkPos[o.chunkIndex])&&a.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!r||n>o.to||s<o.from||r(o.from,o.to,o.value))&&(a.addInner(o.from,o.to,o.value)||l.push(pt.create(o.from,o.to,o.value))),o.next());return a.finishInner(this.nextLayer.isEmpty&&!l.length?vt.empty:this.nextLayer.update({add:l,filter:r,filterFrom:n,filterTo:s}))}map(t){if(t.empty||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],h=t.touchesRange(s,s+o.length);if(!1===h)n=Math.max(n,o.maxPoint),e.push(o),i.push(t.mapPos(s));else if(!0===h){let{mapped:r,pos:h}=o.map(s,t);r&&(n=Math.max(n,r.maxPoint),e.push(r),i.push(h))}}let s=this.nextLayer.map(t);return 0==e.length?s:new vt(i,e,s||vt.empty,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 St.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return St.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)),h=bt(r,o,i),l=new At(r,h,s),a=new At(o,h,s);i.iterGaps(((t,e,i)=>Mt(l,t,a,e,i,n))),i.empty&&0==i.length&&Mt(l,0,a,0,0,n)}static eq(t,e,i=0,n){null==n&&(n=999999999);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=bt(s,r),h=new At(s,o,0).goto(i),l=new At(r,o,0).goto(i);for(;;){if(h.to!=l.to||!Ct(h.active,l.active)||h.point&&(!l.point||!h.point.eq(l.point)))return!1;if(h.to>n)return!0;h.next(),l.next()}}static spans(t,e,i,n,s=-1){let r=new At(t,null,s).goto(e),o=e,h=r.openStart;for(;;){let t=Math.min(r.to,i);if(r.point){let i=r.activeForPoint(r.to),s=r.pointFrom<e?i.length+1:r.point.startSide<0?i.length:Math.min(i.length,h);n.point(o,t,r.point,i,s,r.pointRank),h=Math.min(r.openEnd(t),i.length)}else t>o&&(n.span(o,t,r.active,h),h=r.openEnd(t));if(r.to>i)return h+(r.point&&r.to>i?1:0);o=r.to,r.next()}}static of(t,e=!1){let i=new yt;for(let n of t instanceof pt?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let n=t[i];if(mt(e,n)>0)return t.slice().sort(mt);e=n}return t}(t):t)i.add(n.from,n.to,n.value);return i.finish()}static join(t){if(!t.length)return vt.empty;let e=t[t.length-1];for(let i=t.length-2;i>=0;i--)for(let n=t[i];n!=vt.empty;n=n.nextLayer)e=new vt(n.chunkPos,n.chunk,e,Math.max(n.maxPoint,e.maxPoint));return e}}vt.empty=new vt([],[],null,-1),vt.empty.nextLayer=vt.empty;class yt{finishChunk(t){this.chunks.push(new wt(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=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(t,e,i){this.addInner(t,e,i)||(this.nextLayer||(this.nextLayer=new yt)).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(vt.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=vt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function bt(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.touchesRange(e,e+r.chunk[t].length))||s.add(r.chunk[t])}return s}class xt{constructor(t,e,i,n=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex<this.layer.chunk.length;){let e=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(e)||this.layer.chunkEnd(this.chunkIndex)<t||e.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}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)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=t}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.rank-t.rank||this.to-t.to||this.endSide-t.endSide}}class St{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 xt(r,e,i,s));return 1==n.length?n[0]:new St(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--)kt(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--)kt(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(),kt(this.heap,0)}}}function kt(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 At{constructor(t,e,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=St.from(t,e,i)}goto(t,e=-1e9){return this.cursor.goto(t,e),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=t,this.endSide=e,this.openStart=-1,this.next(),this}forward(t,e){for(;this.minActive>-1&&(this.activeTo[this.minActive]-t||this.active[this.minActive].endSide-e)<0;)this.removeActive(this.minActive);this.cursor.forward(t,e)}removeActive(t){Ot(this.active,t),Ot(this.activeTo,t),Ot(this.activeRank,t),this.minActive=Dt(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:n,rank:s}=this.cursor;for(;e<this.activeRank.length&&(s-this.activeRank[e]||n-this.activeTo[e])>0;)e++;Tt(this.active,e,i),Tt(this.activeTo,e,n),Tt(this.activeRank,e,s),t&&Tt(t,e,this.cursor.from),this.minActive=Dt(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>t){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&Ot(i,n)}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 t=this.cursor.value;if(t.point){if(!(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=t,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=t.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(i),this.cursor.next()}}}if(i){this.openStart=0;for(let e=i.length-1;e>=0&&i[e]<t;e--)this.openStart++}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&e.push(this.active[i]);return e.reverse()}openEnd(t){let e=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)e++;return e}}function Mt(t,e,i,n,s,r){t.goto(e),i.goto(n);let o=n+s,h=n,l=n-e;for(;;){let e=t.to+l-i.to,n=e||t.endSide-i.endSide,s=n<0?t.to+l:i.to,a=Math.min(s,o);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))&&Ct(t.activeForPoint(t.to),i.activeForPoint(i.to))||r.comparePoint(h,a,t.point,i.point):a>h&&!Ct(t.active,i.active)&&r.compareRange(h,a,t.active,i.active),s>o)break;(e||t.openEnd!=i.openEnd)&&r.boundChange&&r.boundChange(s),h=s,n<=0&&t.next(),n>=0&&i.next()}}function Ct(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 Ot(t,e){for(let i=e,n=t.length-1;i<n;i++)t[i]=t[i+1];t.pop()}function Tt(t,e,i){for(let n=t.length-1;n>=e;n--)t[n+1]=t[n];t[e]=i}function Dt(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}},10857:function(t,e,i){i.a(t,(async function(t,n){try{i.d(e,{$f:function(){return ss},Eu:function(){return rr},S2:function(){return Ws},Uw:function(){return xs},ZO:function(){return Ts},Zs:function(){return Is},lg:function(){return ye},p:function(){return bt},tk:function(){return Un}});var s=i(31948),r=(i(52247),i(71695),i(92745),i(52805),i(61495),i(61893),i(84283),i(19423),i(23669),i(40251),i(69235),i(12385),i(19134),i(32517),i(5740),i(11740),i(92519),i(42179),i(89256),i(24931),i(88463),i(57449),i(19814),i(97003),i(32114),i(46692),i(39527),i(37210),i(92181),i(99790),i(67670),i(41360),i(13334),i(34595),i(36993),i(47021),i(74347)),o=i(95397),h=i(96318),l=t([s]);function g(t){let e;return e=11==t.nodeType?t.getSelection?t:t.ownerDocument:t,e.getSelection()}function p(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function m(t,e){if(!e.anchorNode)return!1;try{return p(t,e.anchorNode)}catch(i){return!1}}function w(t){return 3==t.nodeType?B(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function v(t,e,i,n){return!!i&&(x(t,e,i,n,-1)||x(t,e,i,n,1))}function y(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function b(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function x(t,e,i,n,s){for(;;){if(t==i&&e==n)return!0;if(e==(s<0?0:S(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=y(t)+(s<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if(1==(t=t.childNodes[e+(s<0?-1:0)]).nodeType&&"false"==t.contentEditable)return!1;e=s<0?S(t):0}}}function S(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function k(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function A(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function M(t,e){let i=e.width/t.offsetWidth,n=e.height/t.offsetHeight;return(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.width-t.offsetWidth)<1)&&(i=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.height-t.offsetHeight)<1)&&(n=1),{scaleX:i,scaleY:n}}function C(t,e,i,n,s,r,o,h){let l=t.ownerDocument,a=l.defaultView||window;for(let c=t,u=!1;c&&!u;)if(1==c.nodeType){let t,f=c==l.body,d=1,g=1;if(f)t=A(a);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(u=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let e=c.getBoundingClientRect();({scaleX:d,scaleY:g}=M(c,e)),t={left:e.left,right:e.left+c.clientWidth*d,top:e.top,bottom:e.top+c.clientHeight*g}}let p=0,m=0;if("nearest"==s)e.top<t.top?(m=-(t.top-e.top+o),i>0&&e.bottom>t.bottom+m&&(m=e.bottom-t.bottom+m+o)):e.bottom>t.bottom&&(m=e.bottom-t.bottom+o,i<0&&e.top-m<t.top&&(m=-(t.top+m-e.top+o)));else{let n=e.bottom-e.top,r=t.bottom-t.top;m=("center"==s&&n<=r?e.top+n/2-r/2:"start"==s||"center"==s&&i<0?e.top-o:e.bottom-r+o)-t.top}if("nearest"==n)e.left<t.left?(p=-(t.left-e.left+r),i>0&&e.right>t.right+p&&(p=e.right-t.right+p+r)):e.right>t.right&&(p=e.right-t.right+r,i<0&&e.left<t.left+p&&(p=-(t.left+p-e.left+r)));else{p=("center"==n?e.left+(e.right-e.left)/2-(t.right-t.left)/2:"start"==n==h?e.left-r:e.right-(t.right-t.left)+r)-t.left}if(p||m)if(f)a.scrollBy(p,m);else{let t=0,i=0;if(m){let t=c.scrollTop;c.scrollTop+=m/g,i=(c.scrollTop-t)*g}if(p){let e=c.scrollLeft;c.scrollLeft+=p/d,t=(c.scrollLeft-e)*d}e={left:e.left-t,top:e.top-i,right:e.right-t,bottom:e.bottom-i},t&&Math.abs(t-p)<1&&(n="nearest"),i&&Math.abs(i-m)<1&&(s="nearest")}if(f)break;c=c.assignedSlot||c.parentNode}else{if(11!=c.nodeType)break;c=c.host}}function O(t){let e,i,n=t.ownerDocument;for(let s=t.parentNode;s&&!(s==n.body||e&&i);)if(1==s.nodeType)!i&&s.scrollHeight>s.clientHeight&&(i=s),!e&&s.scrollWidth>s.clientWidth&&(e=s),s=s.assignedSlot||s.parentNode;else{if(11!=s.nodeType)break;s=s.host}return{x:e,y:i}}s=(l.then?(await l)():l)[0];class T{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:i}=t;this.set(e,Math.min(t.anchorOffset,e?S(e):0),i,Math.min(t.focusOffset,i?S(i):0))}set(t,e,i,n){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=n}}let D,E=null;function R(t){if(t.setActive)return t.setActive();if(E)return t.focus(E);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==E?{get preventScroll(){return E={preventScroll:!0},!0}}:void 0),!E){E=!1;for(let t=0;t<e.length;){let i=e[t++],n=e[t++],s=e[t++];i.scrollTop!=n&&(i.scrollTop=n),i.scrollLeft!=s&&(i.scrollLeft=s)}}}function B(t,e,i=e){let n=D||(D=document.createRange());return n.setEnd(t,i),n.setStart(t,e),n}function P(t,e,i,n){let s={key:e,code:e,keyCode:i,which:i,cancelable:!0};n&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=n);let r=new KeyboardEvent("keydown",s);r.synthetic=!0,t.dispatchEvent(r);let o=new KeyboardEvent("keyup",s);return o.synthetic=!0,t.dispatchEvent(o),r.defaultPrevented||o.defaultPrevented}function L(t){for(;t;){if(t&&(9==t.nodeType||11==t.nodeType&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function N(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}function I(t,e){let i=e.focusNode,n=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=n)return!1;for(n=Math.min(n,S(i));;)if(n){if(1!=i.nodeType)return!1;let t=i.childNodes[n-1];"false"==t.contentEditable?n--:(i=t,n=S(i))}else{if(i==t)return!0;n=y(i),i=i.parentNode}}function V(t){return t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function H(t,e){for(let i=t,n=e;;){if(3==i.nodeType&&n>0)return{node:i,offset:n};if(1==i.nodeType&&n>0){if("false"==i.contentEditable)return null;i=i.childNodes[n-1],n=S(i)}else{if(!i.parentNode||b(i))return null;n=y(i),i=i.parentNode}}}function W(t,e){for(let i=t,n=e;;){if(3==i.nodeType&&n<i.nodeValue.length)return{node:i,offset:n};if(1==i.nodeType&&n<i.childNodes.length){if("false"==i.contentEditable)return null;i=i.childNodes[n],n=0}else{if(!i.parentNode||b(i))return null;n=y(i)+1,i=i.parentNode}}}class F{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new F(t.parentNode,y(t),e)}static after(t,e){return new F(t.parentNode,y(t)+1,e)}}const z=[];class _{constructor(){this.parent=null,this.dom=null,this.flags=2}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}sync(t,e){if(2&this.flags){let i,n=this.dom,s=null;for(let r of this.children){if(7&r.flags){if(!r.dom&&(i=s?s.nextSibling:n.firstChild)){let t=_.get(i);(!t||!t.parent&&t.canReuseDOM(r))&&r.reuseDOM(i)}r.sync(t,e),r.flags&=-8}if(i=s?s.nextSibling:n.firstChild,e&&!e.written&&e.node==n&&i!=r.dom&&(e.written=!0),r.dom.parentNode==n)for(;i&&i!=r.dom;)i=j(i);else n.insertBefore(r.dom,i);s=r.dom}for(i=s?s.nextSibling:n.firstChild,i&&e&&e.node==n&&(e.written=!0);i;)i=j(i)}else if(1&this.flags)for(let i of this.children)7&i.flags&&(i.sync(t,e),i.flags&=-8)}reuseDOM(t){}localPosFromDOM(t,e){let i;if(t==this.dom)i=this.dom.childNodes[e];else{let n=0==S(t)?0:0==e?-1:1;for(;;){let e=t.parentNode;if(e==this.dom)break;0==n&&e.firstChild!=e.lastChild&&(n=t==e.firstChild?-1:1),t=e}i=n<0?t:t.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!_.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 h=0,l=i,a=i;h<this.children.length;h++){let i=this.children[h],c=l+i.length;if(l<t&&c>e)return i.domBoundsAround(t,e,l);if(c>=t&&-1==n&&(n=h,s=l),l>e&&i.dom.parentNode==this.dom){r=h,o=a;break}a=c,l=c+i.breakAfter}return{from:s,to:o<0?i+this.length:o,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:r<this.children.length&&r>=0?this.children[r].dom:null}}markDirty(t=!1){this.flags|=2,this.markParentsDirty(t)}markParentsDirty(t){for(let e=this.parent;e;e=e.parent){if(t&&(e.flags|=2),1&e.flags)return;e.flags|=1,t=!1}}setParent(t){this.parent!=t&&(this.parent=t,7&this.flags&&this.markParentsDirty(!0))}setDOM(t){this.dom!=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=z){this.markDirty();for(let n=t;n<e;n++){let t=this.children[n];t.parent==this&&i.indexOf(t)<0&&t.destroy()}i.length<250?this.children.splice(t,e-t,...i):this.children=[].concat(this.children.slice(0,t),i,this.children.slice(e));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 q(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}get isWidget(){return!1}get isHidden(){return!1}merge(t,e,i,n,s,r){return!1}become(t){return!1}canReuseDOM(t){return t.constructor==this.constructor&&!(8&(this.flags|t.flags))}getSide(){return 0}destroy(){for(let t of this.children)t.parent==this&&t.destroy();this.parent=null}}function j(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}_.prototype.breakAfter=0;class q{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 $(t,e,i,n,s,r,o,h,l){let{children:a}=t,c=a.length?a[e]:null,u=r.length?r[r.length-1]:null,f=u?u.breakAfter:o;if(!(e==n&&c&&!o&&!f&&r.length<2&&c.merge(i,s,r.length?u:null,0==i,h,l))){if(n<a.length){let t=a[n];t&&(s<t.length||t.breakAfter&&(null==u?void 0:u.breakAfter))?(e==n&&(t=t.split(s),s=0),!f&&u&&t.merge(0,s,u,!0,0,l)?r[r.length-1]=t:((s||t.children.length&&!t.children[0].length)&&t.merge(0,s,null,!1,0,l),r.push(t))):(null==t?void 0:t.breakAfter)&&(u?u.breakAfter=1:o=1),n++}for(c&&(c.breakAfter=o,i>0&&(!o&&r.length&&c.merge(i,c.length,r[0],!1,h,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,h,0),e++));e<n&&r.length;)if(a[n-1].become(r[r.length-1]))n--,r.pop(),l=r.length?0:h;else{if(!a[e].become(r[0]))break;e++,r.shift(),h=r.length?0:l}!r.length&&e&&n<a.length&&!a[e-1].breakAfter&&a[n].merge(0,0,a[e-1],!1,h,l)&&e--,(e<n||r.length)&&t.replaceChildren(e,n,r)}}function K(t,e,i,n,s,r){let o=t.childCursor(),{i:h,off:l}=o.findPos(i,1),{i:a,off:c}=o.findPos(e,-1),u=e-i;for(let f of n)u+=f.length;t.length+=u,$(t,a,c,h,l,n,0,s,r)}let J="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},G="undefined"!=typeof document?document:{documentElement:{style:{}}};const U=/Edge\/(\d+)/.exec(J.userAgent),X=/MSIE \d/.test(J.userAgent),Y=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(J.userAgent),Q=!!(X||Y||U),Z=!Q&&/gecko\/(\d+)/i.test(J.userAgent),tt=!Q&&/Chrome\/(\d+)/.exec(J.userAgent),et="webkitFontSmoothing"in G.documentElement.style,it=!Q&&/Apple Computer/.test(J.vendor),nt=it&&(/Mobile\/\w+/.test(J.userAgent)||J.maxTouchPoints>2);var a={mac:nt||/Mac/.test(J.platform),windows:/Win/.test(J.platform),linux:/Linux|X11/.test(J.platform),ie:Q,ie_version:X?G.documentMode||6:Y?+Y[1]:U?+U[1]:0,gecko:Z,gecko_version:Z?+(/Firefox\/(\d+)/.exec(J.userAgent)||[0,0])[1]:0,chrome:!!tt,chrome_version:tt?+tt[1]:0,ios:nt,android:/Android\b/.test(J.userAgent),webkit:et,safari:it,webkit_version:et?+(/\bAppleWebKit\/(\d+)/.exec(J.userAgent)||[0,0])[1]:0,tabSize:null!=G.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};const st=256;class rt extends _{constructor(t){super(),this.text=t}get length(){return this.text.length}createDOM(t){this.setDOM(t||document.createTextNode(this.text))}sync(t,e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(t){3==t.nodeType&&this.createDOM(t)}merge(t,e,i){return!(8&this.flags||i&&(!(i instanceof rt)||this.length-(e-t)+i.length>st||8&i.flags))&&(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new rt(this.text.slice(t));return this.text=this.text.slice(0,t),this.markDirty(),e.flags|=8&this.flags,e}localPosFromDOM(t,e){return t==this.dom?e:e?this.text.length:0}domAtPos(t){return new F(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 ht(this.dom,t,e)}}class ot extends _{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(N(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}canReuseDOM(t){return super.canReuseDOM(t)&&!(8&(this.flags|t.flags))}reuseDOM(t){t.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(t),this.flags|=6)}sync(t,e){this.dom?4&this.flags&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(t,e)}merge(t,e,i,n,s,r){return(!i||!(!(i instanceof ot&&i.mark.eq(this.mark))||t&&s<=0||e<this.length&&r<=0))&&(K(this,t,e,i?i.children.slice():[],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 ot(this.mark,e,r)}domAtPos(t){return ct(this,t)}coordsAt(t,e){return ft(this,t,e)}}function ht(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?a.chrome||a.gecko||(e?(s--,o=1):r<n&&(r++,o=-1)):i<0?s--:r<n&&r++;let h=B(t,s,r).getClientRects();if(!h.length)return null;let l=h[(o?o<0:i>=0)?0:h.length-1];return a.safari&&!o&&0==l.width&&(l=Array.prototype.find.call(h,(t=>t.width))||l),o?k(l,o<0):l||null}class lt extends _{static create(t,e,i){return new lt(t,e,i)}constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i,this.prevWidget=null}split(t){let e=lt.create(this.widget,this.length-t,this.side);return this.length-=t,e}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(t,e,i,n,s,r){return!(i&&(!(i instanceof lt&&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 instanceof lt&&t.side==this.side&&this.widget.constructor==t.widget.constructor&&(this.widget.compare(t.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get overrideDOMText(){if(0==this.length)return r.xv.empty;let t=this;for(;t.parent;)t=t.parent;let{view:e}=t,i=e&&e.state.doc,n=this.posAtStart;return i?i.slice(n,n+this.length):r.xv.empty}domAtPos(t){return(this.length?0==t:this.side>0)?F.before(this.dom):F.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let i=this.widget.coordsAt(this.dom,t,e);if(i)return i;let n=this.dom.getClientRects(),s=null;if(!n.length)return null;let r=this.side?this.side<0:t>0;for(let o=r?n.length-1:0;s=n[o],!(t>0?0==o:o==n.length-1||s.top<s.bottom);o+=r?-1:1);return k(s,!r)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class at extends _{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof at&&t.side==this.side}split(){return new at(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 this.side>0?F.before(this.dom):F.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return r.xv.empty}get isHidden(){return!0}}function ct(t,e){let i=t.dom,{children:n}=t,s=0;for(let r=0;s<n.length;s++){let t=n[s],o=r+t.length;if(!(o==r&&t.getSide()<=0)){if(e>r&&e<o&&t.dom.parentNode==i)return t.domAtPos(e-r);if(e<=r)break;r=o}}for(let r=s;r>0;r--){let t=n[r-1];if(t.dom.parentNode==i)return t.domAtPos(t.length)}for(let r=s;r<n.length;r++){let t=n[r];if(t.dom.parentNode==i)return t.domAtPos(0)}return new F(i,0)}function ut(t,e,i){let n,{children:s}=t;i>0&&e instanceof ot&&s.length&&(n=s[s.length-1])instanceof ot&&n.mark.eq(e.mark)?ut(n,e.children[0],i-1):(s.push(e),e.setParent(t)),t.length+=e.length}function ft(t,e,i){let n=null,s=-1,r=null,o=-1;!function t(e,h){for(let l=0,a=0;l<e.children.length&&a<=h;l++){let c=e.children[l],u=a+c.length;u>=h&&(c.children.length?t(c,h-a):(!r||r.isHidden&&i>0)&&(u>h||a==u&&c.getSide()>0)?(r=c,o=h-a):(a<h||a==u&&c.getSide()<0&&!c.isHidden)&&(n=c,s=h-a)),a=u}}(t,e);let h=(i<0?n:r)||n||r;return h?h.coordsAt(Math.max(0,h==n?s:o),i):dt(t)}function dt(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=w(e);return i[i.length-1]||null}function gt(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}rt.prototype.children=lt.prototype.children=at.prototype.children=z;const pt=Object.create(null);function mt(t,e,i){if(t==e)return!0;t||(t=pt),e||(e=pt);let n=Object.keys(t),s=Object.keys(e);if(n.length-(i&&n.indexOf(i)>-1?1:0)!=s.length-(i&&s.indexOf(i)>-1?1:0))return!1;for(let r of n)if(r!=i&&(-1==s.indexOf(r)||t[r]!==e[r]))return!1;return!0}function wt(t,e,i){let n=!1;if(e)for(let s in e)i&&s in i||(n=!0,"style"==s?t.style.cssText="":t.removeAttribute(s));if(i)for(let s in i)e&&e[s]==i[s]||(n=!0,"style"==s?t.style.cssText=i[s]:t.setAttribute(s,i[s]));return n}function vt(t){let e=Object.create(null);for(let i=0;i<t.attributes.length;i++){let n=t.attributes[i];e[n.name]=n.value}return e}class yt{eq(t){return!1}updateDOM(t,e){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(t){return!0}coordsAt(t,e,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(t){}}var c=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(c||(c={}));class bt extends r.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 xt(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),i=!!t.block;return e+=i&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8,new kt(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}=At(t,n);e=(s?n?-3e8:-1:5e8)-1,i=1+(r?n?2e8:1:-6e8)}return new kt(t,e,i,n,t.widget||null,!0)}static line(t){return new St(t)}static set(t,e=!1){return r.Xs.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}bt.none=r.Xs.empty;class xt extends bt{constructor(t){let{start:e,end:i}=At(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){var e,i;return this==t||t instanceof xt&&this.tagName==t.tagName&&(this.class||(null===(e=this.attrs)||void 0===e?void 0:e.class))==(t.class||(null===(i=t.attrs)||void 0===i?void 0:i.class))&&mt(this.attrs,t.attrs,"class")}range(t,e=t){if(t>=e)throw new RangeError("Mark decorations may not be empty");return super.range(t,e)}}xt.prototype.point=!1;class St extends bt{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof St&&this.spec.class==t.spec.class&&mt(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)}}St.prototype.mapMode=r.gc.TrackBefore,St.prototype.point=!0;class kt extends bt{constructor(t,e,i,n,s,o){super(e,i,s,t),this.block=n,this.isReplace=o,this.mapMode=n?e<=0?r.gc.TrackBefore:r.gc.TrackAfter:r.gc.TrackDel}get type(){return this.startSide!=this.endSide?c.WidgetRange:this.startSide<=0?c.WidgetBefore:c.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof kt&&(e=this.widget,i=t.widget,e==i||!!(e&&i&&e.compare(i)))&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide;var e,i}range(t,e=t){if(this.isReplace&&(t>e||t==e&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}}function At(t,e=!1){let{inclusiveStart:i,inclusiveEnd:n}=t;return null==i&&(i=t.inclusive),null==n&&(n=t.inclusive),{start:null!=i?i:e,end:null!=n?n: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)}kt.prototype.point=!0;class Ct extends _{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 Ct))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),K(this,t,e,i?i.children.slice():[],s,r),!0}split(t){let e=new Ct;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);for(;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&&(this.markDirty(),t.setDOM(this.dom),t.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(t){mt(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){ut(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=gt(e,this.attrs||{})),i&&(this.attrs=gt({class:i},this.attrs||{}))}domAtPos(t){return ct(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.flags|=6)}sync(t,e){var i;this.dom?4&this.flags&&(N(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&&(wt(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t,e);let n=this.dom.lastChild;for(;n&&_.get(n)instanceof ot;)n=n.lastChild;if(!(n&&this.length&&("BR"==n.nodeName||0!=(null===(i=_.get(n))||void 0===i?void 0:i.isEditable)||a.ios&&this.children.some((t=>t instanceof rt))))){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,e=0;for(let i of this.children){if(!(i instanceof rt)||/[^ -~]/.test(i.text))return null;let n=w(i.dom);if(1!=n.length)return null;e+=n[0].width,t=n[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(t,e){let i=ft(this,t,e);if(!this.children.length&&i&&this.parent){let{heightOracle:t}=this.parent.view.viewState,e=i.bottom-i.top;if(Math.abs(e-t.lineHeight)<2&&t.textHeight<e){let n=(e-t.textHeight)/2;return{top:i.top+n,bottom:i.bottom-n,left:i.left,right:i.left}}}return i}become(t){return t instanceof Ct&&0==this.children.length&&0==t.children.length&&mt(this.attrs,t.attrs)&&this.breakAfter==t.breakAfter}covers(){return!0}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 Ct)return s;if(r>e)break}n=r+s.breakAfter}return null}}class Ot extends _{constructor(t,e,i){super(),this.widget=t,this.length=e,this.deco=i,this.breakAfter=0,this.prevWidget=null}merge(t,e,i,n,s,r){return!(i&&(!(i instanceof Ot&&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?F.before(this.dom):F.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new Ot(this.widget,e,this.deco);return i.breakAfter=this.breakAfter,i}get children(){return z}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):r.xv.empty}domBoundsAround(){return null}become(t){return t instanceof Ot&&t.widget.constructor==this.widget.constructor&&(t.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,this.deco=t.deco,this.breakAfter=t.breakAfter,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(t,e){let i=this.widget.coordsAt(this.dom,t,e);return i||(this.widget instanceof Tt?null:k(this.dom.getBoundingClientRect(),this.length?0==t:e<=0))}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(t){let{startSide:e,endSide:i}=this.deco;return e!=i&&(t<0?e<0:i>0)}}class Tt extends yt{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return t.className="cm-gap",this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}class Dt{constructor(t,e,i,n){this.doc=t,this.pos=e,this.end=i,this.disallowBlockEffectsFor=n,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],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 Ot&&t.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new Ct),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(Et(new at(-1),t),t.length),this.pendingBuffer=0)}addBlockWidget(t){this.flushBuffer(),this.curLine=null,this.content.push(t)}finish(t){this.pendingBuffer&&t<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||t&&this.content.length&&this.content[this.content.length-1]instanceof Ot||this.getLine()}buildText(t,e,i){for(;t>0;){if(this.textOff==this.text.length){let{value:e,lineBreak:i,done:n}=this.cursor.next(this.skip);if(this.skip=0,n)throw new Error("Ran out of text content when drawing inline views");if(i){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,t--;continue}this.text=e,this.textOff=0}let n=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(e.length-i)),this.getLine().append(Et(new rt(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,r){if(this.disallowBlockEffectsFor[r]&&i instanceof kt){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")}let o=e-t;if(i instanceof kt)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new Ot(i.widget||Rt.block,o,i));else{let r=lt.create(i.widget||Rt.inline,o,o?0:i.startSide),h=this.atCursorPos&&!r.isEditable&&s<=n.length&&(t<e||i.startSide>0),l=!r.isEditable&&(t<e||s>n.length||i.startSide<=0),a=this.getLine();2!=this.pendingBuffer||h||r.isEditable||(this.pendingBuffer=0),this.flushBuffer(n),h&&(a.append(Et(new at(1),n),s),s=n.length+Math.max(0,s-n.length)),a.append(Et(r,n),s),this.atCursorPos=l,this.pendingBuffer=l?t<e||s>n.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=n.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);o&&(this.textOff+o<=this.text.length?this.textOff+=o:(this.skip+=o-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=e),this.openStart<0&&(this.openStart=s)}static build(t,e,i,n,s){let o=new Dt(t,e,i,s);return o.openEnd=r.Xs.spans(n,e,i,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}}function Et(t,e){for(let i of e)t=new ot(i,[t],t.length);return t}class Rt extends yt{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}Rt.inline=new Rt("span"),Rt.block=new Rt("div");var u=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(u||(u={}));const Bt=u.LTR,Pt=u.RTL;function Lt(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}const Nt=Lt("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),It=Lt("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Vt=Object.create(null),Ht=[];for(let hr of["()","[]","{}"]){let lr=hr.charCodeAt(0),ar=hr.charCodeAt(1);Vt[lr]=ar,Vt[ar]=-lr}function Wt(t){return t<=247?Nt[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?It[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8204?256:64336<=t&&t<=65023?4:1}const Ft=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class zt{get dir(){return this.level%2?Pt:Bt}constructor(t,e,i){this.from=t,this.to=e,this.level=i}side(t,e){return this.dir==e==t?this.to:this.from}forward(t,e){return t==(this.dir==e)}static find(t,e,i,n){let 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}}function _t(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.direction!=s.direction||!_t(n.inner,s.inner))return!1}return!0}const jt=[];function qt(t,e,i,n,s){for(let r=0;r<=n.length;r++){let o=r?n[r-1].to:e,h=r<n.length?n[r].from:i,l=r?256:s;for(let e=o,i=l,n=l;e<h;e++){let s=Wt(t.charCodeAt(e));512==s?s=i:8==s&&4==n&&(s=16),jt[e]=4==s?2:s,7&s&&(n=s),i=s}for(let t=o,e=l,n=l;t<h;t++){let s=jt[t];if(128==s)t<h-1&&e==jt[t+1]&&24&e?s=jt[t]=e:jt[t]=256;else if(64==s){let s=t+1;for(;s<h&&64==jt[s];)s++;let r=t&&8==e||s<i&&8==jt[s]?1==n?1:8:256;for(let e=t;e<s;e++)jt[e]=r;t=s-1}else 8==s&&1==n&&(jt[t]=1);e=s,7&s&&(n=s)}}}function $t(t,e,i,n,s){let r=1==s?2:1;for(let o=0,h=0,l=0;o<=n.length;o++){let a=o?n[o-1].to:e,c=o<n.length?n[o].from:i;for(let e,i,n,o=a;o<c;o++)if(i=Vt[e=t.charCodeAt(o)])if(i<0){for(let t=h-3;t>=0;t-=3)if(Ht[t+1]==-i){let e=Ht[t+2],i=2&e?s:4&e?1&e?r:s:0;i&&(jt[o]=jt[Ht[t]]=i),h=t;break}}else{if(189==Ht.length)break;Ht[h++]=o,Ht[h++]=e,Ht[h++]=l}else if(2==(n=jt[o])||1==n){let t=n==s;l=t?0:1;for(let e=h-3;e>=0;e-=3){let i=Ht[e+2];if(2&i)break;if(t)Ht[e+2]|=2;else{if(4&i)break;Ht[e+2]|=4}}}}}function Kt(t,e,i,n){for(let s=0,r=n;s<=i.length;s++){let o=s?i[s-1].to:t,h=s<i.length?i[s].from:e;for(let l=o;l<h;){let o=jt[l];if(256==o){let o=l+1;for(;;)if(o==h){if(s==i.length)break;o=i[s++].to,h=s<i.length?i[s].from:e}else{if(256!=jt[o])break;o++}let a=1==r,c=a==(1==(o<e?jt[o]:n))?a?1:2:n;for(let e=o,n=s,r=n?i[n-1].to:t;e>l;)e==r&&(e=i[--n].from,r=n?i[n-1].to:t),jt[--e]=c;l=o}else r=o,l++}}}function Jt(t,e,i,n,s,r,o){let h=n%2?2:1;if(n%2==s%2)for(let l=e,a=0;l<i;){let e=!0,c=!1;if(a==r.length||l<r[a].from){let t=jt[l];t!=h&&(e=!1,c=16==t)}let u=e||1!=h?null:[],f=e?n:n+1,d=l;t:for(;;)if(a<r.length&&d==r[a].from){if(c)break t;let g=r[a];if(!e)for(let t=g.to,e=a+1;;){if(t==i)break t;if(!(e<r.length&&r[e].from==t)){if(jt[t]==h)break t;break}t=r[e++].to}if(a++,u)u.push(g);else{g.from>l&&o.push(new zt(l,g.from,f)),Gt(t,g.direction==Bt!=!(f%2)?n+1:n,s,g.inner,g.from,g.to,o),l=g.to}d=g.to}else{if(d==i||(e?jt[d]!=h:jt[d]==h))break;d++}u?Jt(t,l,d,n+1,s,u,o):l<d&&o.push(new zt(l,d,f)),l=d}else for(let l=i,a=r.length;l>e;){let i=!0,c=!1;if(!a||l>r[a-1].to){let t=jt[l-1];t!=h&&(i=!1,c=16==t)}let u=i||1!=h?null:[],f=i?n:n+1,d=l;t:for(;;)if(a&&d==r[a-1].to){if(c)break t;let g=r[--a];if(!i)for(let t=g.from,i=a;;){if(t==e)break t;if(!i||r[i-1].to!=t){if(jt[t-1]==h)break t;break}t=r[--i].from}if(u)u.push(g);else{g.to<l&&o.push(new zt(g.to,l,f)),Gt(t,g.direction==Bt!=!(f%2)?n+1:n,s,g.inner,g.from,g.to,o),l=g.from}d=g.from}else{if(d==e||(i?jt[d-1]!=h:jt[d-1]==h))break;d--}u?Jt(t,d,l,n+1,s,u,o):d<l&&o.push(new zt(d,l,f)),l=d}}function Gt(t,e,i,n,s,r,o){let h=e%2?2:1;qt(t,s,r,n,h),$t(t,s,r,n,h),Kt(s,r,n,h),Jt(t,s,r,e,i,n,o)}function Ut(t,e,i){if(!t)return[new zt(0,0,e==Pt?1:0)];if(e==Bt&&!i.length&&!Ft.test(t))return Xt(t.length);if(i.length)for(;t.length>jt.length;)jt[jt.length]=256;let n=[],s=e==Bt?0:1;return Gt(t,s,s,i,0,t.length,n),n}function Xt(t){return[new zt(0,t,0)]}let Yt="";function Qt(t,e,i,n,s){var o;let h=n.head-t.from,l=zt.find(e,h,null!==(o=n.bidiLevel)&&void 0!==o?o:-1,n.assoc),a=e[l],c=a.side(s,i);if(h==c){let t=l+=s?1:-1;if(t<0||t>=e.length)return null;a=e[l=t],h=a.side(!s,i),c=a.side(s,i)}let u=(0,r.cp)(t.text,h,a.forward(s,i));(u<a.from||u>a.to)&&(u=c),Yt=t.text.slice(Math.min(h,u),Math.max(h,u));let f=l==(s?e.length-1:0)?null:e[l+(s?1:-1)];return f&&u==c&&f.level+(s?0:1)<a.level?r.jT.cursor(f.side(!s,i)+t.from,f.forward(s,i)?1:-1,f.level):r.jT.cursor(u+t.from,a.forward(s,i)?-1:1,a.level)}function Zt(t,e,i){for(let n=e;n<i;n++){let e=Wt(t.charCodeAt(n));if(1==e)return Bt;if(2==e||4==e)return Pt}return Bt}const te=r.r$.define(),ee=r.r$.define(),ie=r.r$.define(),ne=r.r$.define(),se=r.r$.define(),re=r.r$.define(),oe=r.r$.define(),he=r.r$.define(),le=r.r$.define(),ae=r.r$.define({combine:t=>t.some((t=>t))}),ce=r.r$.define({combine:t=>t.some((t=>t))}),ue=r.r$.define();class fe{constructor(t,e="nearest",i="nearest",n=5,s=5,r=!1){this.range=t,this.y=e,this.x=i,this.yMargin=n,this.xMargin=s,this.isSnapshot=r}map(t){return t.empty?this:new fe(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new fe(r.jT.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const de=r.Py.define({map:(t,e)=>t.map(e)}),ge=r.Py.define();function pe(t,e,i){let n=t.facet(ne);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 me=r.r$.define({combine:t=>!t.length||t[0]});let we=0;const ve=r.r$.define();class ye{constructor(t,e,i,n,s){this.id=t,this.create=e,this.domEventHandlers=i,this.domEventObservers=n,this.extension=s(this)}static define(t,e){const{eventHandlers:i,eventObservers:n,provide:s,decorations:r}=e||{};return new ye(we++,t,i,n,(t=>{let e=[ve.of(t)];return r&&e.push(ke.of((e=>{let i=e.plugin(t);return i?r(i):bt.none}))),s&&e.push(s(t)),e}))}static fromClass(t,e){return ye.define((e=>new t(e)),e)}}class be{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}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(pe(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){pe(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){pe(t.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const xe=r.r$.define(),Se=r.r$.define(),ke=r.r$.define(),Ae=r.r$.define(),Me=r.r$.define(),Ce=r.r$.define();function Oe(t,e){let i=t.state.facet(Ce);if(!i.length)return i;let n=i.map((e=>e instanceof Function?e(t):e)),s=[];return r.Xs.spans(n,e.from,e.to,{point(){},span(t,i,n,r){let o=t-e.from,h=i-e.from,l=s;for(let s=n.length-1;s>=0;s--,r--){let t,i=n[s].spec.bidiIsolate;if(null==i&&(i=Zt(e.text,o,h)),r>0&&l.length&&(t=l[l.length-1]).to==o&&t.direction==i)t.to=h,l=t.inner;else{let t={from:o,to:h,direction:i,inner:[]};l.push(t),l=t.inner}}}}),s}const Te=r.r$.define();function De(t){let e=0,i=0,n=0,s=0;for(let r of t.state.facet(Te)){let o=r(t);o&&(null!=o.left&&(e=Math.max(e,o.left)),null!=o.right&&(i=Math.max(i,o.right)),null!=o.top&&(n=Math.max(n,o.top)),null!=o.bottom&&(s=Math.max(s,o.bottom)))}return{left:e,right:i,top:n,bottom:s}}const Ee=r.r$.define();class Re{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new Re(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let n=t[e-1];if(!(n.fromA>i.toA)){if(n.toA<i.fromA)break;i=i.join(n),t.splice(e-1,1)}}return t.splice(e,0,i),t}static extendWithRanges(t,e){if(0==e.length)return t;let i=[];for(let n=0,s=0,r=0,o=0;;n++){let h=n==t.length?null:t[n],l=r-o,a=h?h.fromB:1e9;for(;s<e.length&&e[s]<a;){let t=e[s],n=e[s+1],r=Math.max(o,t),h=Math.min(a,n);if(r<=h&&new Re(r+l,h+l,r,h).addToSet(i),n>a)break;s+=2}if(!h)return i;new Re(h.fromA,h.toA,h.fromB,h.toB).addToSet(i),r=h.toA,o=h.toB}}}class Be{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=r.as.empty(this.startState.doc.length);for(let s of i)this.changes=this.changes.compose(s.changes);let n=[];this.changes.iterChangedRanges(((t,e,i,s)=>n.push(new Re(t,e,i,s)))),this.changedRanges=n}static create(t,e,i){return new Be(t,e,i)}get viewportChanged(){return(4&this.flags)>0}get viewportMoved(){return(8&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(18&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some((t=>t.selection))}get empty(){return 0==this.flags&&0==this.transactions.length}}class Pe extends _{get length(){return this.view.state.doc.length}constructor(t){super(),this.view=t,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=bt.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(t.contentDOM),this.children=[new Ct],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Re(0,0,0,t.state.doc.length)],0,null)}update(t){var e;let i=t.changedRanges;this.minWidth>0&&i.length&&(i.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.updateEditContextFormatting(t);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&((null===(e=this.domChanged)||void 0===e?void 0:e.newSel)?n=this.domChanged.newSel.head:Fe(t.changes,this.hasComposition)||t.selectionSet||(n=t.state.selection.main.head));let s=n>-1?Ne(this.view,t.changes,n):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:e,to:n}=this.hasComposition;i=new Re(e,n,t.changes.mapPos(e,-1),t.changes.mapPos(n,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(a.ie||a.chrome)&&!s&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let r=He(this.decorations,this.updateDeco(),t.changes);return i=Re.extendWithRanges(i,r),!!(7&this.flags||0!=i.length)&&(this.updateInner(i,t.startState.doc.length,s),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e,i){this.view.viewState.mustMeasureContent=!0,this.updateChildren(t,e,i);let{observer:n}=this.view;n.ignore((()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let t=a.chrome||a.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,t),this.flags&=-8,t&&(t.written||n.selectionRange.focusNode!=t.node)&&(this.forceSelection=!0),this.dom.style.height=""})),this.markedForComposition.forEach((t=>t.flags&=-9));let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let r of this.children)r instanceof Ot&&r.widget instanceof Tt&&s.push(r.dom);n.updateGaps(s)}updateChildren(t,e,i){let n=i?i.range.addToSet(t.slice()):t,s=this.childCursor(e);for(let r=n.length-1;;r--){let t=r>=0?n[r]:null;if(!t)break;let e,o,h,l,{fromA:a,toA:c,fromB:u,toB:f}=t;if(i&&i.range.fromB<f&&i.range.toB>u){let t=Dt.build(this.view.state.doc,u,i.range.fromB,this.decorations,this.dynamicDecorationMap),n=Dt.build(this.view.state.doc,i.range.toB,f,this.decorations,this.dynamicDecorationMap);o=t.breakAtStart,h=t.openStart,l=n.openEnd;let s=this.compositionView(i);n.breakAtStart?s.breakAfter=1:n.content.length&&s.merge(s.length,s.length,n.content[0],!1,n.openStart,0)&&(s.breakAfter=n.content[0].breakAfter,n.content.shift()),t.content.length&&s.merge(0,0,t.content[t.content.length-1],!0,0,t.openEnd)&&t.content.pop(),e=t.content.concat(s).concat(n.content)}else({content:e,breakAtStart:o,openStart:h,openEnd:l}=Dt.build(this.view.state.doc,u,f,this.decorations,this.dynamicDecorationMap));let{i:d,off:g}=s.findPos(c,1),{i:p,off:m}=s.findPos(a,-1);$(this,p,m,d,g,e,o,h,l)}i&&this.fixCompositionDOM(i)}updateEditContextFormatting(t){this.editContextFormatting=this.editContextFormatting.map(t.changes);for(let e of t.transactions)for(let t of e.effects)t.is(ge)&&(this.editContextFormatting=t.value)}compositionView(t){let e=new rt(t.text.nodeValue);e.flags|=8;for(let{deco:n}of t.marks)e=new ot(n,[e],e.length);let i=new Ct;return i.append(e,0),i}fixCompositionDOM(t){let e=(t,e)=>{e.flags|=8|(e.children.some((t=>7&t.flags))?1:0),this.markedForComposition.add(e);let i=_.get(t);i&&i!=e&&(i.dom=null),e.setDOM(t)},i=this.childPos(t.range.fromB,1),n=this.children[i.i];e(t.line,n);for(let s=t.marks.length-1;s>=-1;s--)i=n.childPos(i.off,1),n=n.children[i.i],e(s>=0?t.marks[s].node:t.text,n)}updateSelection(t=!1,e=!1){!t&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let i=this.view.root.activeElement,n=i==this.dom,s=!n&&!(this.view.state.facet(me)||this.dom.tabIndex>-1)&&m(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(n||e||s))return;let r=this.forceSelection;this.forceSelection=!1;let o=this.view.state.selection.main,h=this.moveToLine(this.domAtPos(o.anchor)),l=o.empty?h:this.moveToLine(this.domAtPos(o.head));if(a.gecko&&o.empty&&!this.hasComposition&&(1==(c=h).node.nodeType&&c.node.firstChild&&(0==c.offset||"false"==c.node.childNodes[c.offset-1].contentEditable)&&(c.offset==c.node.childNodes.length||"false"==c.node.childNodes[c.offset].contentEditable))){let t=document.createTextNode("");this.view.observer.ignore((()=>h.node.insertBefore(t,h.node.childNodes[h.offset]||null))),h=l=new F(t,0),r=!0}var c;let u=this.view.observer.selectionRange;!r&&u.focusNode&&(v(h.node,h.offset,u.anchorNode,u.anchorOffset)&&v(l.node,l.offset,u.focusNode,u.focusOffset)||this.suppressWidgetCursorChange(u,o))||(this.view.observer.ignore((()=>{a.android&&a.chrome&&this.dom.contains(u.focusNode)&&We(u.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let t=g(this.view.root);if(t)if(o.empty){if(a.gecko){let t=Ie(h.node,h.offset);if(t&&3!=t){let e=(1==t?H:W)(h.node,h.offset);e&&(h=new F(e.node,e.offset))}}t.collapse(h.node,h.offset),null!=o.bidiLevel&&void 0!==t.caretBidiLevel&&(t.caretBidiLevel=o.bidiLevel)}else if(t.extend){t.collapse(h.node,h.offset);try{t.extend(l.node,l.offset)}catch(e){}}else{let e=document.createRange();o.anchor>o.head&&([h,l]=[l,h]),e.setEnd(l.node,l.offset),e.setStart(h.node,h.offset),t.removeAllRanges(),t.addRange(e)}else;s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())})),this.view.observer.setSelectionRange(h,l)),this.impreciseAnchor=h.precise?null:new F(u.anchorNode,u.anchorOffset),this.impreciseHead=l.precise?null:new F(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&v(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)&&this.posFromDOM(t.focusNode,t.focusOffset)==e.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:t}=this,e=t.state.selection.main,i=g(t.root),{anchorNode:n,anchorOffset:s}=t.observer.selectionRange;if(!(i&&e.empty&&e.assoc&&i.modify))return;let r=Ct.find(this,e.head);if(!r)return;let o=r.posAtStart;if(e.head==o||e.head==o+r.length)return;let h=this.coordsAt(e.head,-1),l=this.coordsAt(e.head,1);if(!h||!l||h.bottom>l.top)return;let a=this.domAtPos(e.head+e.assoc);i.collapse(a.node,a.offset),i.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let c=t.observer.selectionRange;t.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=e.from&&i.collapse(n,s)}moveToLine(t){let e,i=this.dom;if(t.node!=i)return t;for(let n=t.offset;!e&&n<i.childNodes.length;n++){let t=_.get(i.childNodes[n]);t instanceof Ct&&(e=t.domAtPos(0))}for(let n=t.offset-1;!e&&n>=0;n--){let t=_.get(i.childNodes[n]);t instanceof Ct&&(e=t.domAtPos(t.length))}return e?new F(e.node,e.offset,!0):t}nearest(t){for(let e=t;e;){let t=_.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 Ct)break;e++,i=0}return this.children[e].domAtPos(i)}coordsAt(t,e){let i=null,n=0;for(let s=this.length,r=this.children.length-1;r>=0;r--){let o=this.children[r],h=s-o.breakAfter,l=h-o.length;if(h<t)break;if(l<=t&&(l<t||o.covers(-1))&&(h>t||o.covers(1))&&(!i||o instanceof Ct&&!(i instanceof Ct&&e>=0)))i=o,n=l;else if(i&&l==t&&h==t&&o instanceof Ot&&Math.abs(e)<2){if(o.deco.startSide<0)break;r&&(i=null)}s=l}return i?i.coordsAt(t-n,e):null}coordsForChar(t){let{i:e,off:i}=this.childPos(t,1),n=this.children[e];if(!(n instanceof Ct))return null;for(;n.children.length;){let{i:t,off:e}=n.childPos(i,1);for(;;t++){if(t==n.children.length)return null;if((n=n.children[t]).length)break}i=e}if(!(n instanceof rt))return null;let s=(0,r.cp)(n.text,i);if(s==i)return null;let o=B(n.dom,i,s).getClientRects();for(let r=0;r<o.length;r++){let t=o[r];if(r==o.length-1||t.top<t.bottom&&t.left<t.right)return t}return null}measureVisibleLineHeights(t){let e=[],{from:i,to:n}=t,s=this.view.contentDOM.clientWidth,r=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,h=this.view.textDirection==u.LTR;for(let l=0,a=0;a<this.children.length;a++){let t=this.children[a],c=l+t.length;if(c>n)break;if(l>=i){let i=t.dom.getBoundingClientRect();if(e.push(i.height),r){let e=t.dom.lastChild,n=e?w(e):[];if(n.length){let t=n[n.length-1],e=h?t.right-i.left:i.right-t.left;e>o&&(o=e,this.minWidth=s,this.minWidthFrom=l,this.minWidthTo=c)}}}l=c+t.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?u.RTL:u.LTR}measureTextSize(){for(let s of this.children)if(s instanceof Ct){let t=s.measureTextSize();if(t)return t}let t,e,i,n=document.createElement("div");return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore((()=>{this.dom.appendChild(n);let s=w(n.firstChild)[0];t=n.getBoundingClientRect().height,e=s?s.width/27:7,i=s?s.height:t,n.remove()})),{lineHeight:t,charWidth:e,textHeight:i}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new q(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)/this.view.scaleY;t.push(bt.replace({widget:new Tt(n),block:!0,inclusive:!0,isBlockGap:!0}).range(i,r))}if(!s)break;i=s.to+1}return bt.set(t)}updateDeco(){let t=1,e=this.view.state.facet(ke).map((e=>(this.dynamicDecorationMap[t++]="function"==typeof e)?e(this.view):e)),i=!1,n=this.view.state.facet(Ae).map(((t,e)=>{let n="function"==typeof t;return n&&(i=!0),n?t(this.view):t}));for(n.length&&(this.dynamicDecorationMap[t++]=i,e.push(r.Xs.join(n))),this.decorations=[this.editContextFormatting,...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];t<this.decorations.length;)this.dynamicDecorationMap[t++]=!1;return this.decorations}scrollIntoView(t){if(t.isSnapshot){let e=this.view.viewState.lineBlockAt(t.range.head);return this.view.scrollDOM.scrollTop=e.top-t.yMargin,void(this.view.scrollDOM.scrollLeft=t.xMargin)}for(let a of this.view.state.facet(ue))try{if(a(this.view,t.range,t))return!0}catch(l){pe(this.view.state,l,"scroll handler")}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=De(this.view),r={left:n.left-s.left,top:n.top-s.top,right:n.right+s.right,bottom:n.bottom+s.bottom},{offsetWidth:o,offsetHeight:h}=this.view.scrollDOM;C(this.view.scrollDOM,r,i.head<i.anchor?-1:1,t.x,t.y,Math.max(Math.min(t.xMargin,o),-o),Math.max(Math.min(t.yMargin,h),-h),this.view.textDirection==u.LTR)}}function Le(t,e){let i=t.observer.selectionRange;if(!i.focusNode)return null;let n=H(i.focusNode,i.focusOffset),s=W(i.focusNode,i.focusOffset),r=n||s;if(s&&n&&s.node!=n.node){let e=_.get(s.node);if(!e||e instanceof rt&&e.text!=s.node.nodeValue)r=s;else if(t.docView.lastCompositionAfterCursor){let t=_.get(n.node);!t||t instanceof rt&&t.text!=n.node.nodeValue||(r=s)}}if(t.docView.lastCompositionAfterCursor=r!=n,!r)return null;let o=e-r.offset;return{from:o,to:o+r.node.nodeValue.length,node:r.node}}function Ne(t,e,i){let n=Le(t,i);if(!n)return null;let{node:s,from:r,to:o}=n,h=s.nodeValue;if(/[\n\r]/.test(h))return null;if(t.state.doc.sliceString(n.from,n.to)!=h)return null;let l=e.invertedDesc,a=new Re(l.mapPos(r),l.mapPos(o),r,o),c=[];for(let u=s.parentNode;;u=u.parentNode){let e=_.get(u);if(e instanceof ot)c.push({node:u,deco:e.mark});else{if(e instanceof Ct||"DIV"==u.nodeName&&u.parentNode==t.contentDOM)return{range:a,text:s,marks:c,line:u};if(u==t.contentDOM)return null;c.push({node:u,deco:new xt({inclusive:!0,attributes:vt(u),tagName:u.tagName.toLowerCase()})})}}}function Ie(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)}let Ve=class{constructor(){this.changes=[]}compareRange(t,e){Mt(t,e,this.changes)}comparePoint(t,e){Mt(t,e,this.changes)}boundChange(t){Mt(t,t,this.changes)}};function He(t,e,i){let n=new Ve;return r.Xs.compare(t,e,i,n),n.changes}function We(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 Fe(t,e){let i=!1;return e&&t.iterChangedRanges(((t,n)=>{t<e.to&&n>e.from&&(i=!0)})),i}function ze(t,e,i=1){let n=t.charCategorizer(e),s=t.doc.lineAt(e),o=e-s.from;if(0==s.length)return r.jT.cursor(e);0==o?i=1:o==s.length&&(i=-1);let h=o,l=o;i<0?h=(0,r.cp)(s.text,o,!1):l=(0,r.cp)(s.text,o);let a=n(s.text.slice(h,l));for(;h>0;){let t=(0,r.cp)(s.text,h,!1);if(n(s.text.slice(t,h))!=a)break;h=t}for(;l<s.length;){let t=(0,r.cp)(s.text,l);if(n(s.text.slice(l,t))!=a)break;l=t}return r.jT.range(h+s.from,l+s.from)}function _e(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function je(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function qe(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function $e(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function Ke(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function Je(t,e,i){let n,s,r,o,h,l,a,c,u=!1;for(let d=t.firstChild;d;d=d.nextSibling){let t=w(d);for(let f=0;f<t.length;f++){let g=t[f];s&&qe(s,g)&&(g=$e(Ke(g,s.bottom),s.top));let p=_e(e,g),m=je(i,g);if(0==p&&0==m)return 3==d.nodeType?Ge(d,e,i):Je(d,e,i);if(!n||o>m||o==m&&r>p){n=d,s=g,r=p,o=m;let h=m?i<g.top?-1:1:p?e<g.left?-1:1:0;u=!h||(h>0?f<t.length-1:f>0)}0==p?i>g.bottom&&(!a||a.bottom<g.bottom)?(h=d,a=g):i<g.top&&(!c||c.top>g.top)&&(l=d,c=g):a&&qe(a,g)?a=Ke(a,g.bottom):c&&qe(c,g)&&(c=$e(c,g.top))}}if(a&&a.bottom>=i?(n=h,s=a):c&&c.top<=i&&(n=l,s=c),!n)return{node:t,offset:0};let f=Math.max(s.left,Math.min(s.right,e));return 3==n.nodeType?Ge(n,f,i):u&&"false"!=n.contentEditable?Je(n,f,i):{node:t,offset:Array.prototype.indexOf.call(t.childNodes,n)+(e>=(s.left+s.right)/2?1:0)}}function Ge(t,e,i){let n=t.nodeValue.length,s=-1,r=1e9,o=0;for(let h=0;h<n;h++){let n=B(t,h,h+1).getClientRects();for(let l=0;l<n.length;l++){let c=n[l];if(c.top==c.bottom)continue;o||(o=e-c.left);let u=(c.top>i?c.top-i:i-c.bottom)-1;if(c.left-1<=e&&c.right+1>=e&&u<r){let i=e>=(c.left+c.right)/2,n=i;if(a.chrome||a.gecko){B(t,h).getBoundingClientRect().left==c.right&&(n=!i)}if(u<=0)return{node:t,offset:h+(n?1:0)};s=h+(n?1:0),r=u}}}return{node:t,offset:s>-1?s:o>0?t.nodeValue.length:0}}function Ue(t,e,i,n=-1){var s,r;let o,h=t.contentDOM.getBoundingClientRect(),l=h.top+t.viewState.paddingTop,{docHeight:u}=t.viewState,{x:f,y:d}=e,g=d-l;if(g<0)return 0;if(g>u)return t.state.doc.length;for(let a=t.viewState.heightOracle.textHeight/2,S=!1;o=t.elementAtHeight(g),o.type!=c.Text;)for(;g=n>0?o.bottom+a:o.top-a,!(g>=0&&g<=u);){if(S)return i?null:0;S=!0,n=-n}d=l+g;let p=o.from;if(p<t.viewport.from)return 0==t.viewport.from?0:i?null:Xe(t,h,o,f,d);if(p>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:Xe(t,h,o,f,d);let m=t.dom.ownerDocument,w=t.root.elementFromPoint?t.root:m,v=w.elementFromPoint(f,d);v&&!t.contentDOM.contains(v)&&(v=null),v||(f=Math.max(h.left+1,Math.min(h.right-1,f)),v=w.elementFromPoint(f,d),v&&!t.contentDOM.contains(v)&&(v=null));let y,b=-1;if(v&&0!=(null===(s=t.docView.nearest(v))||void 0===s?void 0:s.isEditable)){if(m.caretPositionFromPoint){let t=m.caretPositionFromPoint(f,d);t&&({offsetNode:y,offset:b}=t)}else if(m.caretRangeFromPoint){let e=m.caretRangeFromPoint(f,d);e&&(({startContainer:y,startOffset:b}=e),(!t.contentDOM.contains(y)||a.safari&&Ye(y,b,f)||a.chrome&&Qe(y,b,f))&&(y=void 0))}y&&(b=Math.min(S(y),b))}if(!y||!t.docView.dom.contains(y)){let e=Ct.find(t.docView,p);if(!e)return g>o.top+o.height/2?o.to:o.from;({node:y,offset:b}=Je(e.dom,f,d))}let x=t.docView.nearest(y);if(!x)return null;if(x.isWidget&&1==(null===(r=x.dom)||void 0===r?void 0:r.nodeType)){let t=x.dom.getBoundingClientRect();return e.y<t.top||e.y<=t.bottom&&e.x<=(t.left+t.right)/2?x.posAtStart:x.posAtEnd}return x.localPosFromDOM(y,b)+x.posAtStart}function Xe(t,e,i,n,s){let o=Math.round((n-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>1.5*t.defaultLineHeight){let e=t.viewState.heightOracle.textHeight;o+=Math.floor((s-i.top-.5*(t.defaultLineHeight-e))/e)*t.viewState.heightOracle.lineLength}let h=t.state.sliceDoc(i.from,i.to);return i.from+(0,r.Gz)(h,o,t.state.tabSize)}function Ye(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 B(t,n-1,n).getBoundingClientRect().left>i}function Qe(t,e,i){if(0!=e)return!1;for(let n=t;;){let t=n.parentNode;if(!t||1!=t.nodeType||t.firstChild!=n)return!1;if(t.classList.contains("cm-line"))break;n=t}return i-(1==t.nodeType?t.getBoundingClientRect():B(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect()).left>5}function Ze(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==c.Text))return n;return i}function ti(t,e,i,n){let s=Ze(t,e.head),o=n&&s.type==c.Text&&(t.lineWrapping||s.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head):null;if(o){let e=t.dom.getBoundingClientRect(),n=t.textDirectionAt(s.from),h=t.posAtCoords({x:i==(n==u.LTR)?e.right-1:e.left+1,y:(o.top+o.bottom)/2});if(null!=h)return r.jT.cursor(h,i?-1:1)}return r.jT.cursor(i?s.to:s.from,i?-1:1)}function ei(t,e,i,n){let s=t.state.doc.lineAt(e.head),r=t.bidiSpans(s),o=t.textDirectionAt(s.from);for(let h=e,l=null;;){let e=Qt(s,r,o,h,i),a=Yt;if(!e){if(s.number==(i?t.state.doc.lines:1))return h;a="\n",s=t.state.doc.line(s.number+(i?1:-1)),r=t.bidiSpans(s),e=t.visualLineSide(s,!i)}if(l){if(!l(a))return h}else{if(!n)return e;l=n(a)}h=e}}function ii(t,e,i){let n=t.state.charCategorizer(e),s=n(i);return t=>{let e=n(t);return s==r.D0.Space&&(s=e),s==e}}function ni(t,e,i,n){let s=e.head,o=i?1:-1;if(s==(i?t.state.doc.length:0))return r.jT.cursor(s,e.assoc);let h,l=e.goalColumn,a=t.contentDOM.getBoundingClientRect(),c=t.coordsAtPos(s,e.assoc||-1),u=t.documentTop;if(c)null==l&&(l=c.left-a.left),h=o<0?c.top:c.bottom;else{let e=t.viewState.lineBlockAt(s);null==l&&(l=Math.min(a.right-a.left,t.defaultCharacterWidth*(s-e.from))),h=(o<0?e.top:e.bottom)+u}let f=a.left+l,d=null!=n?n:t.viewState.heightOracle.textHeight>>1;for(let g=0;;g+=10){let e=h+(d+g)*o,i=Ue(t,{x:f,y:e},!1,o);if(e<a.top||e>a.bottom||(o<0?i<s:i>s)){let n=t.docView.coordsForChar(i),s=!n||e<n.top?-1:1;return r.jT.cursor(i,s,void 0,l)}}}function si(t,e,i){for(;;){let n=0;for(let s of t)s.between(e-1,e+1,((t,s,r)=>{if(e>t&&e<s){let r=n||i||(e-t<s-e?-1:1);e=r<0?t:s,n=r}}));if(!n)return e}}function ri(t,e,i){let n=si(t.state.facet(Me).map((e=>e(t))),i.from,e.head>i.from?-1:1);return n==i.from?i:r.jT.cursor(n,n<i.from?1:-1)}const oi="￿";class hi{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(r.yy.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=oi}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let n=t;;){this.findPointBefore(i,n);let t=this.text.length;this.readNode(n);let s=n.nextSibling;if(s==e)break;let r=_.get(n),o=_.get(s);(r&&o?r.breakAfter:(r?r.breakAfter:b(n))||b(s)&&("BR"!=n.nodeName||n.cmIgnore)&&this.text.length>t)&&this.lineBreak(),n=s}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=_.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+(li(t,i.node,i.offset)?e:0))}}function li(t,e,i){for(;;){if(!e||i<S(e))return!1;if(e==t)return!0;i=y(e)+1,e=e.parentNode}}class ai{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class ci{constructor(t,e,i,n){this.typeOver=n,this.bounds=null,this.text="",this.domChanged=e>-1;let{impreciseHead:s,impreciseAnchor:o}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let e=s||o?[]:pi(t),i=new hi(e,t.state);i.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=i.text,this.newSel=mi(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=s&&s.node==e.focusNode&&s.offset==e.focusOffset||!p(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),n=o&&o.node==e.anchorNode&&o.offset==e.anchorOffset||!p(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset),h=t.viewport;if((a.ios||a.chrome)&&t.state.selection.main.empty&&i!=n&&(h.from>0||h.to<t.state.doc.length)){let e=Math.min(i,n),s=Math.max(i,n),r=h.from-e,o=h.to-s;0!=r&&1!=r&&0!=e||0!=o&&-1!=o&&s!=t.state.doc.length||(i=0,n=t.state.doc.length)}this.newSel=r.jT.single(n,i)}}}function ui(t,e){let i,{newSel:n}=e,s=t.state.selection.main,o=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:n,to:h}=e.bounds,l=s.from,c=null;(8===o||a.android&&e.text.length<h-n)&&(l=s.to,c="end");let u=gi(t.state.doc.sliceString(n,h,oi),e.text,l-n,c);u&&(a.chrome&&13==o&&u.toB==u.from+2&&e.text.slice(u.from,u.toB)==oi+oi&&u.toB--,i={from:n+u.from,to:n+u.toA,insert:r.xv.of(e.text.slice(u.from,u.toB).split(oi))})}else n&&(!t.hasFocus&&t.state.facet(me)||n.main.eq(s))&&(n=null);if(!i&&!n)return!1;if(!i&&e.typeOver&&!s.empty&&n&&n.main.empty?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,s.to)}:i&&i.from>=s.from&&i.to<=s.to&&(i.from!=s.from||i.to!=s.to)&&s.to-s.from-(i.to-i.from)<=4?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,s.to))}:(a.mac||a.android)&&i&&i.from==i.to&&i.from==s.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(n&&2==i.insert.length&&(n=r.jT.single(n.main.anchor-1,n.main.head-1)),i={from:s.from,to:s.to,insert:r.xv.of([" "])}):a.chrome&&i&&i.from==i.to&&i.from==s.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(n&&(n=r.jT.single(n.main.anchor-1,n.main.head-1)),i={from:s.from,to:s.to,insert:r.xv.of([" "])}),i)return fi(t,i,n,o);if(n&&!n.main.eq(s)){let e=!1,i="select";return t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(e=!0),i=t.inputState.lastSelectionOrigin),t.dispatch({selection:n,scrollIntoView:e,userEvent:i}),!0}return!1}function fi(t,e,i,n=-1){if(a.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(a.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&" "==t.state.sliceDoc(e.from,s.from))&&1==e.insert.length&&2==e.insert.lines&&P(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&0==e.insert.length||8==n&&e.insert.length<e.to-e.from&&e.to>s.head)&&P(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&0==e.insert.length&&P(t.contentDOM,"Delete",46)))return!0;let r,o=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let h=()=>r||(r=di(t,e,i));return t.state.facet(re).some((i=>i(t,e.from,e.to,o,h)))||t.dispatch(h()),!0}function di(t,e,i){let n,s=t.state,o=s.selection.main;if(e.from>=o.from&&e.to<=o.to&&e.to-e.from>=(o.to-o.from)/3&&(!i||i.main.empty&&i.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let i=o.from<e.from?s.sliceDoc(o.from,e.from):"",r=o.to>e.to?s.sliceDoc(e.to,o.to):"";n=s.replaceSelection(t.state.toText(i+e.insert.sliceString(0,void 0,t.state.lineBreak)+r))}else{let h=s.changes(e),l=i&&i.main.to<=h.newLength?i.main:void 0;if(s.selection.ranges.length>1&&t.inputState.composing>=0&&e.to<=o.to&&e.to>=o.to-10){let a,c=t.state.sliceDoc(e.from,e.to),u=i&&Le(t,i.main.head);if(u){let t=e.insert.length-(e.to-e.from);a={from:u.from,to:u.to-t}}else a=t.state.doc.lineAt(o.head);let f=o.to-e.to,d=o.to-o.from;n=s.changeByRange((i=>{if(i.from==o.from&&i.to==o.to)return{changes:h,range:l||i.map(h)};let n=i.to-f,u=n-c.length;if(i.to-i.from!=d||t.state.sliceDoc(u,n)!=c||i.to>=a.from&&i.from<=a.to)return{range:i};let g=s.changes({from:u,to:n,insert:e.insert}),p=i.to-o.to;return{changes:g,range:l?r.jT.range(Math.max(0,l.anchor+p),Math.max(0,l.head+p)):i.map(g)}}))}else n={changes:h,selection:l&&s.selection.replaceRange(l)}}let h="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,h+=".compose",t.inputState.compositionFirstChange&&(h+=".start",t.inputState.compositionFirstChange=!1)),s.update(n,{userEvent:h,scrollIntoView:!0})}function gi(t,e,i,n){let s=Math.min(t.length,e.length),r=0;for(;r<s&&t.charCodeAt(r)==e.charCodeAt(r);)r++;if(r==s&&t.length==e.length)return null;let o=t.length,h=e.length;for(;o>0&&h>0&&t.charCodeAt(o-1)==e.charCodeAt(h-1);)o--,h--;if("end"==n){i-=o+Math.max(0,r-Math.min(o,h))-r}if(o<r&&t.length<e.length){r-=i<=r&&i>=o?r-i:0,h=r+(h-o),o=r}else if(h<r){r-=i<=r&&i>=h?r-i:0,o=r+(o-h),h=r}return{from:r,toA:o,toB:h}}function pi(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 ai(i,n)),s==i&&r==n||e.push(new ai(s,r))),e}function mi(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?r.jT.single(i+e,n+e):null}class wi{setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}constructor(t){this.view=t,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=t.hasFocus,a.safari&&t.contentDOM.addEventListener("input",(()=>null)),a.gecko&&en(t.contentDOM.ownerDocument)}handleEvent(t){Di(this.view,t)&&!this.ignoreDuringComposition(t)&&("keydown"==t.type&&this.keydown(t)||this.runHandlers(t.type,t))}runHandlers(t,e){let i=this.handlers[t];if(i){for(let t of i.observers)t(this.view,e);for(let t of i.handlers){if(e.defaultPrevented)break;if(t(this.view,e)){e.preventDefault();break}}}}ensureHandlers(t){let e=yi(t),i=this.handlers,n=this.view.contentDOM;for(let s in e)if("scroll"!=s){let t=!e[s].handlers.length,r=i[s];r&&t!=!r.handlers.length&&(n.removeEventListener(s,this.handleEvent),r=null),r||n.addEventListener(s,this.handleEvent,{passive:t})}for(let s in i)"scroll"==s||e[s]||n.removeEventListener(s,this.handleEvent);this.handlers=e}keydown(t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),9==t.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&27!=t.keyCode&&Si.indexOf(t.keyCode)<0&&(this.tabFocusMode=-1),a.android&&a.chrome&&!t.synthetic&&(13==t.keyCode||8==t.keyCode))return this.view.observer.delayAndroidKey(t.key,t.keyCode),!0;let e;return!a.ios||t.synthetic||t.altKey||t.metaKey||!((e=bi.find((e=>e.keyCode==t.keyCode)))&&!t.ctrlKey||xi.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)?(229!=t.keyCode&&this.view.observer.forceFlush(),!1):(this.pendingIOSKey=e||t,setTimeout((()=>this.flushIOSKey()),250),!0)}flushIOSKey(t){let e=this.pendingIOSKey;return!!e&&(!("Enter"==e.key&&t&&t.from<t.to&&/^\S+$/.test(t.insert.toString()))&&(this.pendingIOSKey=void 0,P(this.view.contentDOM,e.key,e.keyCode,e instanceof KeyboardEvent?e:void 0)))}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(this.composing>0||!!(a.safari&&!a.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.view.observer.update(t),this.mouseSelection&&this.mouseSelection.update(t),this.draggedContent&&t.docChanged&&(this.draggedContent=this.draggedContent.map(t.changes)),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function vi(t,e){return(i,n)=>{try{return e.call(t,n,i)}catch(s){pe(i.state,s)}}}function yi(t){let e=Object.create(null);function i(t){return e[t]||(e[t]={observers:[],handlers:[]})}for(let n of t){let t=n.spec;if(t&&t.domEventHandlers)for(let e in t.domEventHandlers){let s=t.domEventHandlers[e];s&&i(e).handlers.push(vi(n.value,s))}if(t&&t.domEventObservers)for(let e in t.domEventObservers){let s=t.domEventObservers[e];s&&i(e).observers.push(vi(n.value,s))}}for(let n in Ei)i(n).handlers.push(Ei[n]);for(let n in Ri)i(n).observers.push(Ri[n]);return e}const bi=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],xi="dthko",Si=[16,17,18,20,91,92,224,225],ki=6;function Ai(t){return.7*Math.max(0,t)+8}class Mi{constructor(t,e,i,n){this.view=t,this.startEvent=e,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParents=O(t.contentDOM),this.atoms=t.state.facet(Me).map((e=>e(t)));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(r.yy.allowMultipleSelections)&&Ci(t,e),this.dragging=!(!Ti(t,e)||1!=qi(e))&&null}start(t){!1===this.dragging&&this.select(t)}move(t){if(0==t.buttons)return this.destroy();if(this.dragging||null==this.dragging&&(e=this.startEvent,i=t,Math.max(Math.abs(e.clientX-i.clientX),Math.abs(e.clientY-i.clientY))<10))return;var e,i;this.select(this.lastEvent=t);let n=0,s=0,r=0,o=0,h=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:h}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:o,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=De(this.view);t.clientX-a.left<=r+ki?n=-Ai(r-t.clientX):t.clientX+a.right>=h-ki&&(n=Ai(t.clientX-h)),t.clientY-a.top<=o+ki?s=-Ai(o-t.clientY):t.clientY+a.bottom>=l-ki&&(s=Ai(t.clientY-l)),this.setScrollSpeed(n,s)}up(t){null==this.dragging&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval((()=>this.scroll()),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:t,y:e}=this.scrollSpeed;t&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=t,t=0),e&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=e,e=0),(t||e)&&this.view.win.scrollBy(t,e),!1===this.dragging&&this.select(this.lastEvent)}skipAtoms(t){let e=null;for(let i=0;i<t.ranges.length;i++){let n=t.ranges[i],s=null;if(n.empty){let t=si(this.atoms,n.from,0);t!=n.from&&(s=r.jT.cursor(t,-1))}else{let t=si(this.atoms,n.from,-1),e=si(this.atoms,n.to,1);t==n.from&&e==n.to||(s=r.jT.range(n.from==n.anchor?t:e,n.from==n.head?t:e))}s&&(e||(e=t.ranges.slice()),e[i]=s)}return e?r.jT.create(e,t.mainIndex):t}select(t){let{view:e}=this,i=this.skipAtoms(this.style.get(t,this.extend,this.multiple));!this.mustSelect&&i.eq(e.state.selection,!1===this.dragging)||this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){t.transactions.some((t=>t.isUserEvent("input.type")))?this.destroy():this.style.update(t)&&setTimeout((()=>this.select(this.lastEvent)),20)}}function Ci(t,e){let i=t.state.facet(te);return i.length?i[0](e):a.mac?e.metaKey:e.ctrlKey}function Oi(t,e){let i=t.state.facet(ee);return i.length?i[0](e):a.mac?!e.altKey:!e.ctrlKey}function Ti(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let n=g(t.root);if(!n||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 Di(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=_.get(n))&&i.ignoreEvent(e))return!1;return!0}const Ei=Object.create(null),Ri=Object.create(null),Bi=a.ie&&a.ie_version<15||a.ios&&a.webkit_version<604;function Pi(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(),Ni(t,i.value)}),50)}function Li(t,e,i){for(let n of t.facet(e))i=n(i,t);return i}function Ni(t,e){e=Li(t.state,he,e);let i,{state:n}=t,s=1,o=n.toText(e),h=o.lines==n.selection.ranges.length;if(null!=Xi&&n.selection.ranges.every((t=>t.empty))&&Xi==o.toString()){let t=-1;i=n.changeByRange((i=>{let l=n.doc.lineAt(i.from);if(l.from==t)return{range:i};t=l.from;let a=n.toText((h?o.line(s++).text:e)+n.lineBreak);return{changes:{from:l.from,insert:a},range:r.jT.cursor(i.from+a.length)}}))}else i=h?n.changeByRange((t=>{let e=o.line(s++);return{changes:{from:t.from,to:t.to,insert:e.text},range:r.jT.cursor(t.from+e.length)}})):n.replaceSelection(o);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function Ii(t,e,i,n){if(1==n)return r.jT.cursor(e,i);if(2==n)return ze(t.state,e,i);{let i=Ct.find(t.docView,e),n=t.state.doc.lineAt(i?i.posAtEnd:e),s=i?i.posAtStart:n.from,o=i?i.posAtEnd:n.to;return o<t.state.doc.length&&o==n.to&&o++,r.jT.range(s,o)}}Ri.scroll=t=>{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft},Ei.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),27==e.keyCode&&0!=t.inputState.tabFocusMode&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),Ri.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},Ri.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},Ei.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let i=null;for(let n of t.state.facet(ie))if(i=n(t,e),i)break;if(i||0!=e.button||(i=$i(t,e)),i){let n=!t.hasFocus;t.inputState.startMouseSelection(new Mi(t,e,i,n)),n&&t.observer.ignore((()=>{R(t.contentDOM);let e=t.root.activeElement;e&&!e.contains(t.contentDOM)&&e.blur()}));let s=t.inputState.mouseSelection;if(s)return s.start(e),!1===s.dragging}return!1};let Vi=(t,e,i)=>e>=i.top&&e<=i.bottom&&t>=i.left&&t<=i.right;function Hi(t,e,i,n){let s=Ct.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&&Vi(i,n,o))return-1;let h=s.coordsAt(r,1);return h&&Vi(i,n,h)?1:o&&o.bottom>=n?-1:1}function Wi(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:Hi(t,i,e.clientX,e.clientY)}}const Fi=a.ie&&a.ie_version<=11;let zi=null,_i=0,ji=0;function qi(t){if(!Fi)return t.detail;let e=zi,i=ji;return zi=t,ji=Date.now(),_i=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(_i+1)%3:1}function $i(t,e){let i=Wi(t,e),n=qi(e),s=t.state.selection;return{update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),s=s.map(t.changes))},get(e,o,h){let l,a=Wi(t,e),c=Ii(t,a.pos,a.bias,n);if(i.pos!=a.pos&&!o){let e=Ii(t,i.pos,i.bias,n),s=Math.min(e.from,c.from),o=Math.max(e.to,c.to);c=s<c.from?r.jT.range(s,o):r.jT.range(o,s)}return o?s.replaceRange(s.main.extend(c.from,c.to)):h&&1==n&&s.ranges.length>1&&(l=Ki(s,a.pos))?l:h?s.addRange(c):r.jT.create([c])}}}function Ki(t,e){for(let i=0;i<t.ranges.length;i++){let{from:n,to:s}=t.ranges[i];if(n<=e&&s>=e)return r.jT.create(t.ranges.slice(0,i).concat(t.ranges.slice(i+1)),t.mainIndex==i?0:t.mainIndex-(t.mainIndex>i?1:0))}return null}function Ji(t,e,i,n){if(!(i=Li(t.state,he,i)))return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=t.inputState,o=n&&r&&Oi(t,e)?{from:r.from,to:r.to}:null,h={from:s,insert:i},l=t.state.changes(o?[o,h]:h);t.focus(),t.dispatch({changes:l,selection:{anchor:l.mapPos(s,-1),head:l.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"}),t.inputState.draggedContent=null}function Gi(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 Ui(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:Li(t,le,e.join(t.lineBreak)),ranges:i,linewise:n}}Ei.dragstart=(t,e)=>{let{selection:{main:i}}=t.state;if(e.target.draggable){let n=t.docView.nearest(e.target);if(n&&n.isWidget){let t=n.posAtStart,e=t+n.length;(t>=i.to||e<=i.from)&&(i=r.jT.range(t,e))}}let{inputState:n}=t;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=i,e.dataTransfer&&(e.dataTransfer.setData("Text",Li(t.state,le,t.state.sliceDoc(i.from,i.to))),e.dataTransfer.effectAllowed="copyMove"),!1},Ei.dragend=t=>(t.inputState.draggedContent=null,!1),Ei.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let i=e.dataTransfer.files;if(i&&i.length){let n=Array(i.length),s=0,r=()=>{++s==i.length&&Ji(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])}return!0}{let i=e.dataTransfer.getData("Text");if(i)return Ji(t,e,i,!0),!0}return!1},Ei.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let i=Bi?null:e.clipboardData;return i?(Ni(t,i.getData("text/plain")||i.getData("text/uri-list")),!0):(Pi(t),!1)};let Xi=null;Ei.copy=Ei.cut=(t,e)=>{let{text:i,ranges:n,linewise:s}=Ui(t.state);if(!i&&!s)return!1;Xi=s?i:null,"cut"!=e.type||t.state.readOnly||t.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let r=Bi?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",i),!0):(Gi(t,i),!1)};const Yi=r.q6.define();function Qi(t,e){let i=[];for(let n of t.facet(oe)){let s=n(t,e);s&&i.push(s)}return i?t.update({effects:i,annotations:Yi.of(!0)}):null}function Zi(t){setTimeout((()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=Qi(t.state,e);i?t.dispatch(i):t.update([])}}),10)}Ri.focus=t=>{t.inputState.lastFocusTime=Date.now(),t.scrollDOM.scrollTop||!t.inputState.lastScrollTop&&!t.inputState.lastScrollLeft||(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),Zi(t)},Ri.blur=t=>{t.observer.clearSelectionRange(),Zi(t)},Ri.compositionstart=Ri.compositionupdate=t=>{t.observer.editContext||(null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},Ri.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,a.chrome&&a.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then((()=>t.observer.flush())):setTimeout((()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])}),50))},Ri.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Ei.beforeinput=(t,e)=>{var i,n;if("insertReplacementText"==e.inputType&&t.observer.editContext){let n=null===(i=e.dataTransfer)||void 0===i?void 0:i.getData("text/plain"),s=e.getTargetRanges();if(n&&s.length){let e=s[0],i=t.posAtDOM(e.startContainer,e.startOffset),r=t.posAtDOM(e.endContainer,e.endOffset);return fi(t,{from:i,to:r,insert:t.state.toText(n)},null),!0}}let s;if(a.chrome&&a.android&&(s=bi.find((t=>t.inputType==e.inputType)))&&(t.observer.delayAndroidKey(s.key,s.keyCode),"Backspace"==s.key||"Delete"==s.key)){let e=(null===(n=window.visualViewport)||void 0===n?void 0:n.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)}return a.ios&&"deleteContentForward"==e.inputType&&t.observer.flushSoon(),a.safari&&"insertText"==e.inputType&&t.inputState.composing>=0&&setTimeout((()=>Ri.compositionend(t,e)),20),!1};const tn=new Set;function en(t){tn.has(t)||(tn.add(t),t.addEventListener("copy",(()=>{})),t.addEventListener("cut",(()=>{})))}const nn=["pre-wrap","normal","pre-line","break-spaces"];let sn=!1;function rn(){sn=!1}class on{constructor(t){this.lineWrapping=t,this.doc=r.xv.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(t,e){let i=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(t){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5))))*this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return nn.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let n=t[i];n<0?i++:this.heightSamples[Math.floor(10*n)]||(e=!0,this.heightSamples[Math.floor(10*n)]=!0)}return e}refresh(t,e,i,n,s,r){let o=nn.indexOf(t)>-1,h=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=e,this.charWidth=i,this.textHeight=n,this.lineLength=s,h){this.heightSamples={};for(let t=0;t<r.length;t++){let e=r[t];e<0?t++:this.heightSamples[Math.floor(10*e)]=!0}}return h}}class hn{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class ln{constructor(t,e,i,n,s){this.from=t,this.length=e,this.top=i,this.height=n,this._content=s}get type(){return"number"==typeof this._content?c.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof kt?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(t){let e=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new ln(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var f=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}(f||(f={}));const an=.001;class cn{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){this.height!=t&&(Math.abs(this.height-t)>an&&(sn=!0),this.height=t)}replace(t,e,i){return cn.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,n){let s=this,r=i.doc;for(let o=n.length-1;o>=0;o--){let{fromA:h,toA:l,fromB:a,toB:c}=n[o],u=s.lineAt(h,f.ByPosNoHeight,i.setDoc(e),0,0),d=u.to>=l?u:s.lineAt(l,f.ByPosNoHeight,i,0,0);for(c+=d.to-l,l=d.to;o>0&&u.from<=n[o-1].toA;)h=n[o-1].fromA,a=n[o-1].fromB,o--,h<u.from&&(u=s.lineAt(h,f.ByPosNoHeight,i,0,0));a+=u.from-h,h=u.from;let g=vn.build(i.setDoc(r),t,a,c);s=un(s,s.replace(h,l,g))}return s.updateHeight(i,0)}static empty(){return new dn(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 pn(cn.of(t.slice(0,e)),r,cn.of(t.slice(i)))}}function un(t,e){return t==e?t:(t.constructor!=e.constructor&&(sn=!0),e)}cn.prototype.size=1;class fn extends cn{constructor(t,e,i){super(t,e),this.deco=i}blockAt(t,e,i,n){return new ln(n,this.length,i,this.height,this.deco||0)}lineAt(t,e,i,n,s){return this.blockAt(0,i,n,s)}forEachLine(t,e,i,n,s,r){t<=s+this.length&&e>=s&&r(this.blockAt(0,i,n,s))}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more&&this.setHeight(n.heights[n.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class dn extends fn{constructor(t,e){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(t,e,i,n){return new ln(n,this.length,i,this.height,this.breaks)}replace(t,e,i){let n=i[0];return 1==i.length&&(n instanceof dn||n instanceof gn&&4&n.flags)&&Math.abs(this.length-n.length)<10?(n instanceof gn?n=new dn(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):cn.of(i)}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more?this.setHeight(n.heights[n.index++]):(i||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))+this.breaks*t.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class gn extends cn{constructor(t){super(t,0)}heightMetrics(t,e){let i,n=t.doc.lineAt(e).number,s=t.doc.lineAt(e+this.length).number,r=s-n+1,o=0;if(t.lineWrapping){let e=Math.min(this.height,t.lineHeight*r);i=e/r,this.length>r+1&&(o=(this.height-e)/(this.length-r-1))}else i=this.height/r;return{firstLine:n,lastLine:s,perLine:i,perChar:o}}blockAt(t,e,i,n){let{firstLine:s,lastLine:r,perLine:o,perChar:h}=this.heightMetrics(e,n);if(e.lineWrapping){let s=n+(t<e.lineHeight?0:Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length)),r=e.doc.lineAt(s),l=o+r.length*h,a=Math.max(i,t-l/2);return new ln(r.from,r.length,a,l,0)}{let n=Math.max(0,Math.min(r-s,Math.floor((t-i)/o))),{from:h,length:l}=e.doc.line(s+n);return new ln(h,l,i+o*n,o,0)}}lineAt(t,e,i,n,s){if(e==f.ByHeight)return this.blockAt(t,i,n,s);if(e==f.ByPosNoHeight){let{from:e,to:n}=i.doc.lineAt(t);return new ln(e,n-e,0,0,0)}let{firstLine:r,perLine:o,perChar:h}=this.heightMetrics(i,s),l=i.doc.lineAt(t),a=o+l.length*h,c=l.number-r,u=n+o*c+h*(l.from-s-c);return new ln(l.from,l.length,Math.max(n,Math.min(u,n+this.height-a)),a,0)}forEachLine(t,e,i,n,s,r){t=Math.max(t,s),e=Math.min(e,s+this.length);let{firstLine:o,perLine:h,perChar:l}=this.heightMetrics(i,s);for(let a=t,c=n;a<=e;){let e=i.doc.lineAt(a);if(a==t){let i=e.number-o;c+=h*i+l*(t-s-i)}let n=h+l*e.length;r(new ln(e.from,e.length,c,n,0)),c+=n,a=e.to+1}}replace(t,e,i){let n=this.length-e;if(n>0){let t=i[i.length-1];t instanceof gn?i[i.length-1]=new gn(t.length+n):i.push(null,new gn(n-1))}if(t>0){let e=i[0];e instanceof gn?i[0]=new gn(t+e.length):i.unshift(new gn(t-1),null)}return cn.of(i)}decomposeLeft(t,e){e.push(new gn(t-1),null)}decomposeRight(t,e){e.push(null,new gn(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;for(n.from>e&&i.push(new gn(n.from-e-1).updateHeight(t,e));r<=s&&n.more;){let e=t.doc.lineAt(r).length;i.length&&i.push(null);let s=n.heights[n.index++];-1==o?o=s:Math.abs(s-o)>=an&&(o=-2);let h=new dn(e,s);h.outdated=!1,i.push(h),r+=e+1}r<=s&&i.push(null,new gn(s-r).updateHeight(t,r));let h=cn.of(i);return(o<0||Math.abs(h.height-this.height)>=an||Math.abs(o-this.heightMetrics(t,e).perLine)>=an)&&(sn=!0),un(this,h)}return(i||this.outdated)&&(this.setHeight(t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class pn extends cn{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,h=e==f.ByHeight?t<r:t<o,l=h?this.left.lineAt(t,e,i,n,s):this.right.lineAt(t,e,i,r,o);if(this.break||(h?l.to<o:l.from>o))return l;let a=e==f.ByPosNoHeight?f.ByPosNoHeight:f.ByPos;return h?l.join(this.right.lineAt(o,a,i,r,o)):this.left.lineAt(o,a,i,n,s).join(l)}forEachLine(t,e,i,n,s,r){let o=n+this.left.height,h=s+this.left.length+this.break;if(this.break)t<h&&this.left.forEachLine(t,e,i,n,s,r),e>=h&&this.right.forEachLine(t,e,i,o,h,r);else{let l=this.lineAt(h,f.ByPos,i,n,s);t<l.from&&this.left.forEachLine(t,l.from-1,i,n,s,r),l.to>=t&&l.from<=e&&r(l),e>l.to&&this.right.forEachLine(l.to+1,e,i,o,h,r)}}replace(t,e,i){let n=this.left.length+this.break;if(e<n)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let s=[];t>0&&this.decomposeLeft(t,s);let r=s.length;for(let o of i)s.push(o);if(t>0&&mn(s,r-1),e<this.length){let t=s.length;this.decomposeRight(e,s),mn(s,t)}return cn.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?cn.of(this.break?[t,null,e]:[t,e]):(this.left=un(this.left,t),this.right=un(this.right,e),this.setHeight(t.height+e.height),this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,i=!1,n){let{left:s,right:r}=this,o=e+s.length+this.break,h=null;return n&&n.from<=e+s.length&&n.more?h=s=s.updateHeight(t,e,i,n):s.updateHeight(t,e,i),n&&n.from<=o+r.length&&n.more?h=r=r.updateHeight(t,o,i,n):r.updateHeight(t,o,i),h?this.balanced(s,r):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function mn(t,e){let i,n;null==t[e]&&(i=t[e-1])instanceof gn&&(n=t[e+1])instanceof gn&&t.splice(e-1,3,new gn(i.length+1+n.length))}const wn=5;class vn{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 dn?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new dn(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,s=i.widget?i.widget.lineBreaks:0;n<0&&(n=this.oracle.lineHeight);let r=e-t;i.block?this.addBlock(new fn(r,n,i)):(r||s||n>=wn)&&this.addLineDeco(n,s,r)}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 dn(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new gn(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 dn)return t;let e=new dn(0,-1);return this.nodes.push(e),e}addBlock(t){this.enterLine();let e=t.deco;e&&e.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,e&&e.endSide>0&&(this.covering=t)}addLineDeco(t,e,i){let n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,t),n.breaks+=e,this.writtenTo=this.pos=this.pos+i}finish(t){let e=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof dn||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new dn(0,-1));let i=t;for(let n of this.nodes)n instanceof dn&&n.updateHeight(this.oracle,i),i+=n?n.length:1;return this.nodes}static build(t,e,i,n){let s=new vn(i,t);return r.Xs.spans(e,i,n,s,0),s.finish(i)}}function yn(t,e,i){let n=new bn;return r.Xs.compare(t,e,i,n,0),n.changes}class bn{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,n){(t<e||i&&i.heightRelevant||n&&n.heightRelevant)&&Mt(t,e,this.changes,5)}}function xn(t,e){let i=t.getBoundingClientRect(),n=t.ownerDocument,s=n.defaultView||window,r=Math.max(0,i.left),o=Math.min(s.innerWidth,i.right),h=Math.max(0,i.top),l=Math.min(s.innerHeight,i.bottom);for(let a=t.parentNode;a&&a!=n.body;)if(1==a.nodeType){let e=a,i=window.getComputedStyle(e);if((e.scrollHeight>e.clientHeight||e.scrollWidth>e.clientWidth)&&"visible"!=i.overflow){let i=e.getBoundingClientRect();r=Math.max(r,i.left),o=Math.min(o,i.right),h=Math.max(h,i.top),l=Math.min(a==t.parentNode?s.innerHeight:l,i.bottom)}a="absolute"==i.position||"fixed"==i.position?e.offsetParent:e.parentNode}else{if(11!=a.nodeType)break;a=a.host}return{left:r-i.left,right:Math.max(r,o)-i.left,top:h-(i.top+e),bottom:Math.max(h,l)-(i.top+e)}}function Sn(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class kn{constructor(t,e,i,n){this.from=t,this.to=e,this.size=i,this.displaySize=n}static same(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let n=t[i],s=e[i];if(n.from!=s.from||n.to!=s.to||n.size!=s.size)return!1}return!0}draw(t,e){return bt.replace({widget:new An(this.displaySize*(e?t.scaleY:t.scaleX),e)}).range(this.from,this.to)}}class An extends yt{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 Mn{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.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=Rn,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=u.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let e=t.facet(Se).some((t=>"function"!=typeof t&&"cm-lineWrapping"==t.class));this.heightOracle=new on(e),this.stateDeco=t.facet(ke).filter((t=>"function"!=typeof t)),this.heightMap=cn.empty().applyChanges(this.stateDeco,r.xv.empty,this.heightOracle.setDoc(t.doc),[new Re(0,0,0,t.doc.length)]);for(let i=0;i<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());i++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=bt.set(this.lineGaps.map((t=>t.draw(this,!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 Cn(e,i))}}return this.viewports=t.sort(((t,e)=>t.from-e.from)),this.updateScaler()}updateScaler(){let t=this.scaler;return this.scaler=this.heightMap.height<=7e6?Rn:new Bn(this.heightOracle,this.heightMap,this.viewports),t.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,(t=>{this.viewportLines.push(Pn(t,this.scaler))}))}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(ke).filter((t=>"function"!=typeof t));let n=t.changedRanges,s=Re.extendWithRanges(n,yn(i,this.stateDeco,t?t.changes:r.as.empty(this.state.doc.length))),o=this.heightMap.height,h=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);rn(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||sn)&&(t.flags|=2),h?(this.scrollAnchorPos=t.changes.mapPos(h.from,-1),this.scrollAnchorHeight=h.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let l=s.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<l.from||e.range.head>l.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,e));let a=l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,t.flags|=this.updateForViewport(),(a||!t.changes.empty||2&t.flags)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,t.changes))),t.flags|=this.computeVisibleRanges(t.changes),e&&(this.scrollTarget=e),!this.mustEnforceCursorAssoc&&t.selectionSet&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&!t.state.facet(ce)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),n=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?u.RTL:u.LTR;let o=this.heightOracle.mustRefreshForWrapping(s),h=e.getBoundingClientRect(),l=o||this.mustMeasureContent||this.contentDOMHeight!=h.height;this.contentDOMHeight=h.height,this.mustMeasureContent=!1;let a=0,c=0;if(h.width&&h.height){let{scaleX:t,scaleY:i}=M(e,h);(t>.005&&Math.abs(this.scaleX-t)>.005||i>.005&&Math.abs(this.scaleY-i)>.005)&&(this.scaleX=t,this.scaleY=i,a|=16,o=l=!0)}let f=(parseInt(i.paddingTop)||0)*this.scaleY,d=(parseInt(i.paddingBottom)||0)*this.scaleY;this.paddingTop==f&&this.paddingBottom==d||(this.paddingTop=f,this.paddingBottom=d,a|=18),this.editorWidth!=t.scrollDOM.clientWidth&&(n.lineWrapping&&(l=!0),this.editorWidth=t.scrollDOM.clientWidth,a|=16);let g=t.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=g&&(this.scrollAnchorHeight=-1,this.scrollTop=g),this.scrolledToBottom=V(t.scrollDOM);let p=(this.printing?Sn:xn)(e,this.paddingTop),m=p.top-this.pixelViewport.top,w=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let v=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(v!=this.inView&&(this.inView=v,v&&(l=!0)),!this.inView&&!this.scrollTarget)return 0;let y=h.width;if(this.contentDOMWidth==y&&this.editorHeight==t.scrollDOM.clientHeight||(this.contentDOMWidth=h.width,this.editorHeight=t.scrollDOM.clientHeight,a|=16),l){let e=t.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(e)&&(o=!0),o||n.lineWrapping&&Math.abs(y-this.contentDOMWidth)>n.charWidth){let{lineHeight:i,charWidth:r,textHeight:h}=t.docView.measureTextSize();o=i>0&&n.refresh(s,i,r,h,y/r,e),o&&(t.docView.minWidth=0,a|=16)}m>0&&w>0?c=Math.max(m,w):m<0&&w<0&&(c=Math.min(m,w)),rn();for(let i of this.viewports){let s=i.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(i);this.heightMap=(o?cn.empty().applyChanges(this.stateDeco,r.xv.empty,this.heightOracle,[new Re(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(n,0,o,new hn(i.from,s))}sn&&(a|=2)}let b=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return b&&(2&a&&(a|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),a|=this.updateForViewport()),(2&a||b)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,t)),a|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),a}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),n=this.heightMap,s=this.heightOracle,{visibleTop:r,visibleBottom:o}=this,h=new Cn(n.lineAt(r-1e3*i,f.ByHeight,s,0,0).from,n.lineAt(o+1e3*(1-i),f.ByHeight,s,0,0).to);if(e){let{head:t}=e.range;if(t<h.from||t>h.to){let i,r=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),o=n.lineAt(t,f.ByPos,s,0,0);i="center"==e.y?(o.top+o.bottom)/2-r/2:"start"==e.y||"nearest"==e.y&&t<h.from?o.top:o.bottom-r,h=new Cn(n.lineAt(i-500,f.ByHeight,s,0,0).from,n.lineAt(i+r+500,f.ByHeight,s,0,0).to)}}return h}mapViewport(t,e){let i=e.mapPos(t.from,-1),n=e.mapPos(t.to,1);return new Cn(this.heightMap.lineAt(i,f.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,f.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(t,f.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(e,f.ByPos,this.heightOracle,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 kn(e.mapPos(n.from),e.mapPos(n.to),n.size,n.displaySize));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,s=n>>1,o=n<<1;if(this.defaultTextDirection!=u.LTR&&!i)return[];let h=[],l=(n,o,a,c)=>{if(o-n<s)return;let u=this.state.selection.main,f=[u.from];u.empty||f.push(u.to);for(let t of f)if(t>n&&t<o)return l(n,t-10,a,c),void l(t+10,o,a,c);let d=En(t,(t=>t.from>=a.from&&t.to<=a.to&&Math.abs(t.from-n)<s&&Math.abs(t.to-o)<s&&!f.some((e=>t.from<e&&t.to>e))));if(!d){if(o<a.to&&e&&i&&e.visibleRanges.some((t=>t.from<=o&&t.to>=o))){let t=e.moveToLineBoundary(r.jT.cursor(o),!1,!0).head;t>n&&(o=t)}let t=this.gapSize(a,n,o,c);d=new kn(n,o,t,i||t<2e6?t:2e6)}h.push(d)},a=e=>{if(e.length<o||e.type!=c.Text)return;let s=On(e.from,e.to,this.stateDeco);if(s.total<o)return;let r,h,a=this.scrollTarget?this.scrollTarget.range.head:null;if(i){let t,i,o=n/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=a){let n=Dn(s,a),r=((this.visibleBottom-this.visibleTop)/2+o)/e.height;t=n-r,i=n+r}else t=(this.visibleTop-e.top-o)/e.height,i=(this.visibleBottom-e.top+o)/e.height;r=Tn(s,t),h=Tn(s,i)}else{let i=s.total*this.heightOracle.charWidth,o=n*this.heightOracle.charWidth,l=0;if(i>2e6)for(let n of t)n.from>=e.from&&n.from<e.to&&n.size!=n.displaySize&&n.from*this.heightOracle.charWidth+l<this.pixelViewport.left&&(l=n.size-n.displaySize);let c,u,f=this.pixelViewport.left+l,d=this.pixelViewport.right+l;if(null!=a){let t=Dn(s,a),e=((d-f)/2+o)/i;c=t-e,u=t+e}else c=(f-o)/i,u=(d+o)/i;r=Tn(s,c),h=Tn(s,u)}r>e.from&&l(e.from,r,e,s),h<e.to&&l(h,e.to,e,s)};for(let r of this.viewportLines)Array.isArray(r.type)?r.type.forEach(a):a(r);return h}gapSize(t,e,i,n){let s=Dn(n,i)-Dn(n,e);return this.heightOracle.lineWrapping?t.height*s:n.total*this.heightOracle.charWidth*s}updateLineGaps(t){kn.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=bt.set(t.map((t=>t.draw(this,this.heightOracle.lineWrapping)))))}computeVisibleRanges(t){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let i=[];r.Xs.spans(e,this.viewport.from,this.viewport.to,{span(t,e){i.push({from:t,to:e})},point(){}},20);let n=0;if(i.length!=this.visibleRanges.length)n=12;else for(let s=0;s<i.length&&!(8&n);s++){let e=this.visibleRanges[s],r=i[s];e.from==r.from&&e.to==r.to||(n|=4,t&&t.mapPos(e.from,-1)==r.from&&t.mapPos(e.to,1)==r.to||(n|=8))}return this.visibleRanges=i,n}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find((e=>e.from<=t&&e.to>=t))||Pn(this.heightMap.lineAt(t,f.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return t>=this.viewportLines[0].top&&t<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find((e=>e.top<=t&&e.bottom>=t))||Pn(this.heightMap.lineAt(this.scaler.fromDOM(t),f.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(t){let e=this.lineBlockAtHeight(t+8);return e.from>=this.viewport.from||this.viewportLines[0].top-t>200?e:this.viewportLines[0]}elementAtHeight(t){return Pn(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Cn{constructor(t,e){this.from=t,this.to=e}}function On(t,e,i){let n=[],s=t,o=0;return r.Xs.spans(i,t,e,{span(){},point(t,e){t>s&&(n.push({from:s,to:t}),o+=t-s),s=e}},20),s<e&&(n.push({from:s,to:e}),o+=e-s),{total:o,ranges:n}}function Tn({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 Dn(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 En(t,e){for(let i of t)if(e(i))return i}const Rn={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};class Bn{constructor(t,e,i){let n=0,s=0,r=0;this.viewports=i.map((({from:i,to:s})=>{let r=e.lineAt(i,f.ByPos,t,0,0).top,o=e.lineAt(s,f.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}}eq(t){return t instanceof Bn&&(this.scale==t.scale&&this.viewports.length==t.viewports.length&&this.viewports.every(((e,i)=>e.from==t.viewports[i].from&&e.to==t.viewports[i].to)))}}function Pn(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),n=e.toDOM(t.bottom);return new ln(t.from,t.length,i,n-i,Array.isArray(t._content)?t._content.map((t=>Pn(t,e))):t._content)}const Ln=r.r$.define({combine:t=>t.join(" ")}),Nn=r.r$.define({combine:t=>t.indexOf(!0)>-1}),In=o.V.newName(),Vn=o.V.newName(),Hn=o.V.newName(),Wn={"&light":"."+Vn,"&dark":"."+Hn};function Fn(t,e,i){return new o.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 zn=Fn("."+In,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",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"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&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"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Wn),_n={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},jn=a.ie&&a.ie_version<=11;class qn{constructor(t){this.view=t,this.active=!1,this.editContext=null,this.selectionRange=new T,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver((e=>{for(let t of e)this.queue.push(t);(a.ie&&a.ie_version<=11||a.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()})),!window.EditContext||!1===t.constructor.EDIT_CONTEXT||a.chrome&&a.chrome_version<126||(this.editContext=new Gn(t),t.state.facet(me)&&(t.contentDOM.editContext=this.editContext.editContext)),jn&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver((()=>{var t;(null===(t=this.view.docView)||void 0===t?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()})),this.resizeScroll.observe(t.scrollDOM)),this.addWindowListeners(this.win=t.win),this.start(),"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")))}),{threshold:[0,.001]}),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()}onScrollChanged(t){this.view.inputState.runHandlers("scroll",t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout((()=>{this.resizeTimeout=-1,this.view.requestMeasure()}),50))}onPrint(t){("change"!=t.type&&t.type||t.matches)&&(this.view.viewState.printing=!0,this.view.measure(),setTimeout((()=>{this.view.viewState.printing=!1,this.view.requestMeasure()}),500))}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some(((e,i)=>e!=t[i])))){this.gapIntersection.disconnect();for(let e of t)this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(me)?i.root.activeElement!=this.dom:!m(this.dom,n))return;let s=n.anchorNode&&i.docView.nearest(n.anchorNode);s&&s.ignoreEvent(t)?e||(this.selectionChanged=!1):(a.ie&&a.ie_version<=11||a.android&&a.chrome)&&!i.state.selection.main.empty&&n.focusNode&&v(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=g(t.root);if(!e)return!1;let i=a.safari&&11==t.root.nodeType&&t.root.activeElement==this.dom&&Jn(this.view,e)||e;if(!i||this.selectionRange.eq(i))return!1;let n=m(this.dom,i);return n&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&I(this.dom,i)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(i),n&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let i=this.dom;i;)if(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,_n),jn&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),jn&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var i;if(!this.delayedAndroidKey){let t=()=>{let t=this.delayedAndroidKey;if(t){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=t.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&t.force&&P(this.dom,t.key,t.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(t)}this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(null===(i=this.delayedAndroidKey)||void 0===i?void 0:i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame((()=>{this.delayedFlush=-1,this.flush()})))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,n=!1;for(let 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}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),n=this.selectionChanged&&m(this.dom,this.selectionRange);if(t<0&&!n)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new ci(this.view,t,e,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return this.view.requestMeasure(),!1;let i=this.view.state,n=ui(this.view,e);return this.view.state==i&&(e.domChanged||e.newSel&&!e.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),n}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.flags|=4),"childList"==t.type){let i=$n(e,t.previousSibling||t.target.previousSibling,-1),n=$n(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}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}update(t){this.editContext&&(this.editContext.update(t),t.startState.facet(me)!=t.state.facet(me)&&(t.view.contentDOM.editContext=t.state.facet(me)?this.editContext.editContext: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.resizeScroll)||void 0===i||i.disconnect();for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function $n(t,e,i){for(;e;){let n=_.get(e);if(n&&n.parent==t)return n;let s=e.parentNode;e=s!=t.dom?s:i>0?e.nextSibling:e.previousSibling}return null}function Kn(t,e){let i=e.startContainer,n=e.startOffset,s=e.endContainer,r=e.endOffset,o=t.docView.domAtPos(t.state.selection.main.anchor);return v(o.node,o.offset,s,r)&&([i,n,s,r]=[s,r,i,n]),{anchorNode:i,anchorOffset:n,focusNode:s,focusOffset:r}}function Jn(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return Kn(t,i)}let i=null;function n(t){t.preventDefault(),t.stopImmediatePropagation(),i=t.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",n,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",n,!0),i?Kn(t,i):null}class Gn{constructor(t){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(t.state);let e=this.editContext=new window.EditContext({text:t.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,t.state.selection.main.anchor))),selectionEnd:this.toContextPos(t.state.selection.main.head)});this.handlers.textupdate=e=>{let{anchor:i}=t.state.selection.main,n=this.toEditorPos(e.updateRangeStart),s=this.toEditorPos(e.updateRangeEnd);t.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:e.updateRangeStart,editorBase:n,drifted:!1});let o={from:n,to:s,insert:r.xv.of(e.text.split("\n"))};if(o.from==this.from&&i<this.from?o.from=i:o.to==this.to&&i>this.to&&(o.to=i),o.from!=o.to||o.insert.length){if(this.pendingContextChange=o,!t.state.readOnly){let i=this.to-this.from+(o.to-o.from+o.insert.length);fi(t,o,r.jT.single(this.toEditorPos(e.selectionStart,i),this.toEditorPos(e.selectionEnd,i)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state))}},this.handlers.characterboundsupdate=i=>{let n=[],s=null;for(let e=this.toEditorPos(i.rangeStart),r=this.toEditorPos(i.rangeEnd);e<r;e++){let i=t.coordsForChar(e);s=i&&new DOMRect(i.left,i.top,i.right-i.left,i.bottom-i.top)||s||new DOMRect,n.push(s)}e.updateCharacterBounds(i.rangeStart,n)},this.handlers.textformatupdate=e=>{let i=[];for(let t of e.getTextFormats()){let e=t.underlineStyle,n=t.underlineThickness;if("None"!=e&&"None"!=n){let s=this.toEditorPos(t.rangeStart),r=this.toEditorPos(t.rangeEnd);if(s<r){let t=`text-decoration: underline ${"Dashed"==e?"dashed ":"Squiggle"==e?"wavy ":""}${"Thin"==n?1:2}px`;i.push(bt.mark({attributes:{style:t}}).range(s,r))}}}t.dispatch({effects:ge.of(bt.set(i))})},this.handlers.compositionstart=()=>{t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(t.inputState.composing=-1,t.inputState.compositionFirstChange=null,this.composing){let{drifted:e}=this.composing;this.composing=null,e&&this.reset(t.state)}};for(let i in this.handlers)e.addEventListener(i,this.handlers[i]);this.measureReq={read:t=>{this.editContext.updateControlBounds(t.contentDOM.getBoundingClientRect());let e=g(t.root);e&&e.rangeCount&&this.editContext.updateSelectionBounds(e.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let e=0,i=!1,n=this.pendingContextChange;return t.changes.iterChanges(((s,r,o,h,l)=>{if(i)return;let a=l.length-(r-s);if(n&&r>=n.to){if(n.from==s&&n.to==r&&n.insert.eq(l))return n=this.pendingContextChange=null,e+=a,void(this.to+=a);n=null,this.revertPending(t.state)}if(s+=e,(r+=e)<=this.from)this.from+=a,this.to+=a;else if(s<this.to){if(s<this.from||r>this.to||this.to-this.from+l.length>3e4)return void(i=!0);this.editContext.updateText(this.toContextPos(s),this.toContextPos(r),l.toString()),this.to+=a}e+=a})),n&&!i&&this.revertPending(t.state),!i}update(t){let e=this.pendingContextChange;this.composing&&(this.composing.drifted||t.transactions.some((t=>!t.isUserEvent("input.type")&&t.changes.touchesRange(this.from,this.to))))?(this.composing.drifted=!0,this.composing.editorBase=t.changes.mapPos(this.composing.editorBase)):this.applyEdits(t)&&this.rangeIsValid(t.state)?(t.docChanged||t.selectionSet||e)&&this.setSelection(t.state):(this.pendingContextChange=null,this.reset(t.state)),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:e}=t.selection.main;this.from=Math.max(0,e-1e4),this.to=Math.min(t.doc.length,e+1e4)}reset(t){this.resetRange(t),this.editContext.updateText(0,this.editContext.text.length,t.doc.sliceString(this.from,this.to)),this.setSelection(t)}revertPending(t){let e=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(e.from),this.toContextPos(e.from+e.insert.length),t.doc.sliceString(e.from,e.to))}setSelection(t){let{main:e}=t.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,e.anchor))),n=this.toContextPos(e.head);this.editContext.selectionStart==i&&this.editContext.selectionEnd==n||this.editContext.updateSelection(i,n)}rangeIsValid(t){let{head:e}=t.selection.main;return!(this.from>0&&e-this.from<500||this.to<t.doc.length&&this.to-e<500||this.to-this.from>3e4)}toEditorPos(t,e=this.to-this.from){t=Math.min(t,e);let i=this.composing;return i&&i.drifted?i.editorBase+(t-i.contextBase):t+this.from}toContextPos(t){let e=this.composing;return e&&e.drifted?e.contextBase+(t-e.editorBase):t-this.from}destroy(){for(let t in this.handlers)this.editContext.removeEventListener(t,this.handlers[t])}}class Un{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}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(t={}){var e;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.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:i}=t;this.dispatchTransactions=t.dispatchTransactions||i&&(t=>t.forEach((t=>i(t,this))))||(t=>this.update(t)),this.dispatch=this.dispatch.bind(this),this._root=t.root||L(t.parent)||document,this.viewState=new Mn(t.state||r.yy.create(t)),t.scrollTo&&t.scrollTo.is(de)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(ve).map((t=>new be(t)));for(let n of this.plugins)n.update(this);this.observer=new qn(this),this.inputState=new wi(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Pe(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),(null===(e=document.fonts)||void 0===e?void 0:e.ready)&&document.fonts.ready.then((()=>this.requestMeasure()))}dispatch(...t){let e=1==t.length&&t[0]instanceof r.YW?t:1==t.length&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(e,this)}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=!1,s=this.state;for(let r of t){if(r.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=r.state}if(this.destroyed)return void(this.viewState.state=s);let o=this.hasFocus,h=0,l=null;t.some((t=>t.annotation(Yi)))?(this.inputState.notifiedFocused=o,h=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=Qi(s,o),l||(h=1));let a=this.observer.delayedAndroidKey,c=null;if(a?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(c=null)):this.observer.clear(),s.facet(r.yy.phrases)!=this.state.facet(r.yy.phrases))return this.setState(s);e=Be.create(this,s,t),e.flags|=h;let u=this.viewState.scrollTarget;try{this.updateState=2;for(let e of t){if(u&&(u=u.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection;u=new fe(t.empty?t:r.jT.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(de)&&(u=t.value.clip(this.state))}this.viewState.update(e,u),this.bidiCache=Qn.update(this.bidiCache,e.changes),e.empty||(this.updatePlugins(e),this.inputState.update(e)),i=this.docView.update(e),this.state.facet(Ee)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(i,t.some((t=>t.isUserEvent("select.pointer"))))}finally{this.updateState=0}if(e.startState.facet(Ln)!=e.state.facet(Ln)&&(this.viewState.mustMeasureContent=!0),(i||n||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),i&&this.docViewUpdate(),!e.empty)for(let r of this.state.facet(se))try{r(e)}catch(f){pe(this.state,f,"update listener")}(l||c)&&Promise.resolve().then((()=>{l&&this.state==l.startState&&this.dispatch(l),c&&!ui(this,c)&&a.force&&P(this.contentDOM,a.key,a.keyCode)}))}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 Mn(t),this.plugins=t.facet(ve).map((t=>new be(t))),this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView.destroy(),this.docView=new Pe(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(ve),i=t.state.facet(ve);if(e!=i){let n=[];for(let s of i){let i=e.indexOf(s);if(i<0)n.push(new be(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()}else for(let n of this.plugins)n.mustUpdate=t;for(let n=0;n<this.plugins.length;n++)this.plugins[n].update(this);e!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let i=e.value;if(i&&i.docViewUpdate)try{i.docViewUpdate(this)}catch(t){pe(this.state,t,"doc view update listener")}}}measure(t=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey)return this.measureScheduled=-1,void this.requestMeasure();this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,i=this.scrollDOM,n=i.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:r}=this.viewState;Math.abs(n-this.viewState.scrollTop)>1&&(r=-1),this.viewState.scrollAnchorHeight=-1;try{for(let t=0;;t++){if(r<0)if(V(i))s=-1,r=this.viewState.heightMap.height;else{let t=this.viewState.scrollAnchorAt(n);s=t.from,r=t.top}this.updateState=1;let h=this.viewState.measure(this);if(!h&&!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 l=[];4&h||([this.measureRequests,l]=[l,this.measureRequests]);let a=l.map((t=>{try{return t.read(this)}catch(e){return pe(this.state,e),Yn}})),c=Be.create(this,this.state,[]),u=!1;c.flags|=h,e?e.flags|=h:e=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),u=this.docView.update(c),u&&this.docViewUpdate());for(let t=0;t<l.length;t++)if(a[t]!=Yn)try{let e=l[t];e.write&&e.write(a[t],this)}catch(o){pe(this.state,o)}if(u&&this.docView.updateSelection(!0),!c.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,r=-1;continue}{let t=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-r;if(t>1||t<-1){n+=t,i.scrollTop=n/this.scaleY,r=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let h of this.state.facet(se))h(e)}get themeClasses(){return In+" "+(this.state.facet(Nn)?Hn:Vn)+" "+this.state.facet(Ln)}updateAttrs(){let t=Zn(this,xe,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(me)?"true":"false",class:"cm-content",style:`${a.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),Zn(this,Se,e);let i=this.observer.ignore((()=>{let i=wt(this.contentDOM,this.contentAttrs,e),n=wt(this.dom,this.editorAttrs,t);return i||n}));return this.editorAttrs=t,this.contentAttrs=e,i}showAnnouncements(t){let e=!0;for(let i of t)for(let t of i.effects)if(t.is(Un.announce)){e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(Ee);let t=this.state.facet(Un.cspNonce);o.V.mount(this.root,this.styleModules.concat(zn).reverse(),t?{nonce:t}:void 0)}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=this.win.requestAnimationFrame((()=>this.measure()))),t){if(this.measureRequests.indexOf(t)>-1)return;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)}}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}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return ri(this,t,ei(this,t,e,i))}moveByGroup(t,e){return ri(this,t,ei(this,t,e,(e=>ii(this,t.head,e))))}visualLineSide(t,e){let i=this.bidiSpans(t),n=this.textDirectionAt(t.from),s=i[e?i.length-1:0];return r.jT.cursor(s.side(e,n)+t.from,s.forward(!e,n)?1:-1)}moveToLineBoundary(t,e,i=!0){return ti(this,t,e,i)}moveVertically(t,e,i){return ri(this,t,ni(this,t,e,i))}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){return this.readMeasured(),Ue(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);return k(i,s[zt.find(s,t-n.from,-1,e)].dir==u.LTR==e>0)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(ae)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>Xn)return Xt(t.length);let e,i=this.textDirectionAt(t.from);for(let s of this.bidiCache)if(s.from==t.from&&s.dir==i&&(s.fresh||_t(s.isolates,e=Oe(this,t))))return s.order;e||(e=Oe(this,t));let n=Ut(t.text,i,e);return this.bidiCache.push(new Qn(t.from,t.to,i,e,!0,n)),n}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||a.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{R(this.contentDOM),this.docView.updateSelection()}))}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((9==t.nodeType?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return de.of(new fe("number"==typeof t?r.jT.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}scrollSnapshot(){let{scrollTop:t,scrollLeft:e}=this.scrollDOM,i=this.viewState.scrollAnchorAt(t);return de.of(new fe(r.jT.cursor(i.from),"start","start",i.top-t,e,!0))}setTabFocusMode(t){null==t?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof t?this.inputState.tabFocusMode=t?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return ye.define((()=>({})),{eventHandlers:t})}static domEventObservers(t){return ye.define((()=>({})),{eventObservers:t})}static theme(t,e){let i=o.V.newName(),n=[Ln.of(i),Ee.of(Fn(`.${i}`,t))];return e&&e.dark&&n.push(Nn.of(!0)),n}static baseTheme(t){return r.Wl.lowest(Ee.of(Fn("."+In,t,Wn)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),n=i&&_.get(i)||_.get(t);return(null===(e=null==n?void 0:n.rootView)||void 0===e?void 0:e.view)||null}}Un.styleModule=Ee,Un.inputHandler=re,Un.clipboardInputFilter=he,Un.clipboardOutputFilter=le,Un.scrollHandler=ue,Un.focusChangeEffect=oe,Un.perLineTextDirection=ae,Un.exceptionSink=ne,Un.updateListener=se,Un.editable=me,Un.mouseSelectionStyle=ie,Un.dragMovesSelection=ee,Un.clickAddsSelectionRange=te,Un.decorations=ke,Un.outerDecorations=Ae,Un.atomicRanges=Me,Un.bidiIsolatedRanges=Ce,Un.scrollMargins=Te,Un.darkTheme=Nn,Un.cspNonce=r.r$.define({combine:t=>t.length?t[0]:""}),Un.contentAttributes=Se,Un.editorAttributes=xe,Un.lineWrapping=Un.contentAttributes.of({class:"cm-lineWrapping"}),Un.announce=r.Py.define();const Xn=4096,Yn={};class Qn{constructor(t,e,i,n,s,r){this.from=t,this.to=e,this.dir=i,this.isolates=n,this.fresh=s,this.order=r}static update(t,e){if(e.empty&&!t.some((t=>t.fresh)))return t;let i=[],n=t.length?t[t.length-1].dir:u.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 Qn(e.mapPos(r.from,1),e.mapPos(r.to,-1),r.dir,r.isolates,!1,r.order))}return i}}function Zn(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&&gt(r,i)}return i}const ts=a.mac?"mac":a.windows?"win":a.linux?"linux":"key";function es(t,e){const i=t.split(/-(?!$)/);let n,s,r,o,h=i[i.length-1];"Space"==h&&(h=" ");for(let l=0;l<i.length-1;++l){const t=i[l];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&&(h="Alt-"+h),s&&(h="Ctrl-"+h),o&&(h="Meta-"+h),r&&(h="Shift-"+h),h}function is(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 ns=r.Wl.default(Un.domEventHandlers({keydown(t,e){return us(os(e.state),t,e,"editor")}})),ss=r.r$.define({enables:ns}),rs=new WeakMap;function os(t){let e=t.facet(ss),i=rs.get(e);return i||rs.set(e,i=as(e.reduce(((t,e)=>t.concat(e)),[]))),i}let hs=null;const ls=4e3;function as(t,e=ts){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,h)=>{var l,a;let c=i[t]||(i[t]=Object.create(null)),u=n.split(/ (?!$)/).map((t=>es(t,e)));for(let e=1;e<u.length;e++){let i=u.slice(0,e).join(" ");s(i,!0),c[i]||(c[i]={preventDefault:!0,stopPropagation:!1,run:[e=>{let n=hs={view:e,prefix:i,scope:t};return setTimeout((()=>{hs==n&&(hs=null)}),ls),!0}]})}let f=u.join(" ");s(f,!1);let d=c[f]||(c[f]={preventDefault:!1,stopPropagation:!1,run:(null===(a=null===(l=c._any)||void 0===l?void 0:l.run)||void 0===a?void 0:a.slice())||[]});r&&d.run.push(r),o&&(d.preventDefault=!0),h&&(d.stopPropagation=!0)};for(let o of t){let t=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let e of t){let t=i[e]||(i[e]=Object.create(null));t._any||(t._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:n}=o;for(let e in t)t[e].run.push((t=>n(t,cs)))}let n=o[e]||o.key;if(n)for(let e of t)r(e,n,o.run,o.preventDefault,o.stopPropagation),o.shift&&r(e,"Shift-"+n,o.shift,o.preventDefault,o.stopPropagation)}return i}let cs=null;function us(t,e,i,n){cs=e;let s=(0,h.YG)(e),o=(0,r.gm)(s,0),l=(0,r.nZ)(o)==s.length&&" "!=s,c="",u=!1,f=!1,d=!1;hs&&hs.view==i&&hs.scope==n&&(c=hs.prefix+" ",Si.indexOf(e.keyCode)<0&&(f=!0,hs=null));let g,p,m=new Set,w=t=>{if(t){for(let e of t.run)if(!m.has(e)&&(m.add(e),e(i)))return t.stopPropagation&&(d=!0),!0;t.preventDefault&&(t.stopPropagation&&(d=!0),f=!0)}return!1},v=t[n];return v&&(w(v[c+is(s,e,!l)])?u=!0:l&&(e.altKey||e.metaKey||e.ctrlKey)&&!(a.windows&&e.ctrlKey&&e.altKey)&&(g=h.ue[e.keyCode])&&g!=s?(w(v[c+is(g,e,!0)])||e.shiftKey&&(p=h.uY[e.keyCode])!=s&&p!=g&&w(v[c+is(p,e,!1)]))&&(u=!0):l&&e.shiftKey&&w(v[c+is(s,e,!0)])&&(u=!0),!u&&w(v._any)&&(u=!0)),f&&(u=!0),u&&d&&e.stopPropagation(),cs=null,u}class fs{constructor(t,e,i,n,s){this.className=t,this.left=e,this.top=i,this.width=n,this.height=s}draw(){let t=document.createElement("div");return t.className=this.className,this.adjust(t),t}update(t,e){return e.className==this.className&&(this.adjust(t),!0)}adjust(t){t.style.left=this.left+"px",t.style.top=this.top+"px",null!=this.width&&(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}static forRange(t,e,i){if(i.empty){let n=t.coordsAtPos(i.head,i.assoc||1);if(!n)return[];let s=ds(t);return[new fs(e,n.left-s.left,n.top-s.top,null,n.bottom-n.top)]}return ps(t,e,i)}}function ds(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==u.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function gs(t,e,i,n){let s=t.coordsAtPos(e,2*i);if(!s)return n;let r=t.dom.getBoundingClientRect(),o=(s.top+s.bottom)/2,h=t.posAtCoords({x:r.left+1,y:o}),l=t.posAtCoords({x:r.right-1,y:o});return null==h||null==l?n:{from:Math.max(n.from,Math.min(h,l)),to:Math.min(n.to,Math.max(h,l))}}function ps(t,e,i){if(i.to<=t.viewport.from||i.from>=t.viewport.to)return[];let n=Math.max(i.from,t.viewport.from),s=Math.min(i.to,t.viewport.to),r=t.textDirection==u.LTR,o=t.contentDOM,h=o.getBoundingClientRect(),l=ds(t),a=o.querySelector(".cm-line"),f=a&&window.getComputedStyle(a),d=h.left+(f?parseInt(f.paddingLeft)+Math.min(0,parseInt(f.textIndent)):0),g=h.right-(f?parseInt(f.paddingRight):0),p=Ze(t,n),m=Ze(t,s),w=p.type==c.Text?p:null,v=m.type==c.Text?m:null;if(w&&(t.lineWrapping||p.widgetLineBreaks)&&(w=gs(t,n,1,w)),v&&(t.lineWrapping||m.widgetLineBreaks)&&(v=gs(t,s,-1,v)),w&&v&&w.from==v.from&&w.to==v.to)return b(x(i.from,i.to,w));{let e=w?x(i.from,null,w):S(p,!1),n=v?x(null,i.to,v):S(m,!0),s=[];return(w||p).to<(v||m).from-(w&&v?1:0)||p.widgetLineBreaks>1&&e.bottom+t.defaultLineHeight/2<n.top?s.push(y(d,e.bottom,g,n.top)):e.bottom<n.top&&t.elementAtHeight((e.bottom+n.top)/2).type==c.Text&&(e.bottom=n.top=(e.bottom+n.top)/2),b(e).concat(s).concat(b(n))}function y(t,i,n,s){return new fs(e,t-l.left,i-l.top,n-t,s-i)}function b({top:t,bottom:e,horizontal:i}){let n=[];for(let s=0;s<i.length;s+=2)n.push(y(i[s],t,i[s+1],e));return n}function x(e,i,n){let s=1e9,o=-1e9,h=[];function l(e,i,l,a,c){let f=t.coordsAtPos(e,e==n.to?-2:2),p=t.coordsAtPos(l,l==n.from?2:-2);f&&p&&(s=Math.min(f.top,p.top,s),o=Math.max(f.bottom,p.bottom,o),c==u.LTR?h.push(r&&i?d:f.left,r&&a?g:p.right):h.push(!r&&a?d:p.left,!r&&i?g:f.right))}let a=null!=e?e:n.from,c=null!=i?i:n.to;for(let r of t.visibleRanges)if(r.to>a&&r.from<c)for(let n=Math.max(r.from,a),s=Math.min(r.to,c);;){let r=t.state.doc.lineAt(n);for(let o of t.bidiSpans(r)){let t=o.from+r.from,h=o.to+r.from;if(t>=s)break;h>n&&l(Math.max(t,n),null==e&&t<=a,Math.min(h,s),null==i&&h>=c,o.dir)}if(n=r.to+1,n>=s)break}return 0==h.length&&l(a,null==e,c,null==i,t.textDirection),{top:s,bottom:o,horizontal:h}}function S(t,e){let i=h.top+(e?t.top:t.bottom);return{top:i,bottom:i,horizontal:[]}}}class ms{constructor(t,e){this.view=t,this.layer=e,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=t.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),e.above&&this.dom.classList.add("cm-layer-above"),e.class&&this.dom.classList.add(e.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(t.state),t.requestMeasure(this.measureReq),e.mount&&e.mount(this.dom,t)}update(t){t.startState.facet(ws)!=t.state.facet(ws)&&this.setOrder(t.state),(this.layer.update(t,this.dom)||t.geometryChanged)&&(this.scale(),t.view.requestMeasure(this.measureReq))}docViewUpdate(t){!1!==this.layer.updateOnDocViewUpdate&&t.requestMeasure(this.measureReq)}setOrder(t){let e=0,i=t.facet(ws);for(;e<i.length&&i[e]!=this.layer;)e++;this.dom.style.zIndex=String((this.layer.above?150:-1)-e)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:t,scaleY:e}=this.view;t==this.scaleX&&e==this.scaleY||(this.scaleX=t,this.scaleY=e,this.dom.style.transform=`scale(${1/t}, ${1/e})`)}draw(t){if(t.length!=this.drawn.length||t.some(((t,e)=>{return i=t,n=this.drawn[e],!(i.constructor==n.constructor&&i.eq(n));var i,n}))){let e=this.dom.firstChild,i=0;for(let n of t)n.update&&e&&n.constructor&&this.drawn[i].constructor&&n.update(e,this.drawn[i])?(e=e.nextSibling,i++):this.dom.insertBefore(n.draw(),e);for(;e;){let t=e.nextSibling;e.remove(),e=t}this.drawn=t}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const ws=r.r$.define();function vs(t){return[ye.define((e=>new ms(e,t))),ws.of(t)]}const ys=!(a.ios&&a.webkit&&a.webkit_version<534),bs=r.r$.define({combine(t){return(0,r.BO)(t,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,e)=>Math.min(t,e),drawRangeCursor:(t,e)=>t||e})}});function xs(t={}){return[bs.of(t),ks,Ms,Os,ce.of(!0)]}function Ss(t){return t.startState.facet(bs)!=t.state.facet(bs)}const ks=vs({above:!0,markers(t){let{state:e}=t,i=e.facet(bs),n=[];for(let s of e.selection.ranges){let o=s==e.selection.main;if(s.empty?!o||ys:i.drawRangeCursor){let e=o?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",i=s.empty?s:r.jT.cursor(s.head,s.head>s.anchor?-1:1);for(let s of fs.forRange(t,e,i))n.push(s)}}return n},update(t,e){t.transactions.some((t=>t.selection))&&(e.style.animationName="cm-blink"==e.style.animationName?"cm-blink2":"cm-blink");let i=Ss(t);return i&&As(t.state,e),t.docChanged||t.selectionSet||i},mount(t,e){As(e.state,t)},class:"cm-cursorLayer"});function As(t,e){e.style.animationDuration=t.facet(bs).cursorBlinkRate+"ms"}const Ms=vs({above:!1,markers(t){return t.state.selection.ranges.map((e=>e.empty?[]:fs.forRange(t,"cm-selectionBackground",e))).reduce(((t,e)=>t.concat(e)))},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||Ss(t)},class:"cm-selectionLayer"}),Cs={".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"}},".cm-content":{"& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}};ys&&(Cs[".cm-line"].caretColor=Cs[".cm-content"].caretColor="transparent !important");const Os=r.Wl.highest(Un.theme(Cs));function Ts(){return Es}const Ds=bt.line({class:"cm-activeLine"}),Es=ye.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){let s=t.lineBlockAt(n.head);s.from>e&&(i.push(Ds.range(s.from)),e=s.from)}return bt.set(i)}},{decorations:t=>t.decorations});const Rs=2e3;function Bs(t,e,i){let n=Math.min(e.line,i.line),s=Math.max(e.line,i.line),o=[];if(e.off>Rs||i.off>Rs||e.col<0||i.col<0){let h=Math.min(e.off,i.off),l=Math.max(e.off,i.off);for(let e=n;e<=s;e++){let i=t.doc.line(e);i.length<=l&&o.push(r.jT.range(i.from+h,i.to+l))}}else{let h=Math.min(e.col,i.col),l=Math.max(e.col,i.col);for(let e=n;e<=s;e++){let i=t.doc.line(e),n=(0,r.Gz)(i.text,h,t.tabSize,!0);if(n<0)o.push(r.jT.cursor(i.to));else{let e=(0,r.Gz)(i.text,l,t.tabSize);o.push(r.jT.range(i.from+n,i.from+e))}}}return o}function Ps(t,e){let i=t.coordsAtPos(t.viewport.from);return i?Math.round(Math.abs((i.left-e)/t.defaultCharacterWidth)):-1}function Ls(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1),n=t.state.doc.lineAt(i),s=i-n.from,o=s>Rs?-1:s==n.length?Ps(t,e.clientX):(0,r.IS)(n.text,t.state.tabSize,i-n.from);return{line:n.number,col:o,off:s}}function Ns(t,e){let i=Ls(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,o){let h=Ls(t,e);if(!h)return n;let l=Bs(t.state,i,h);return l.length?o?r.jT.create(l.concat(n.ranges)):r.jT.create(l):n}}:null}function Is(t){let e=(null==t?void 0:t.eventFilter)||(t=>t.altKey&&0==t.button);return Un.mouseSelectionStyle.of(((t,i)=>e(i)?Ns(t,i):null))}const Vs={Alt:[18,t=>!!t.altKey],Control:[17,t=>!!t.ctrlKey],Shift:[16,t=>!!t.shiftKey],Meta:[91,t=>!!t.metaKey]},Hs={style:"cursor: crosshair"};function Ws(t={}){let[e,i]=Vs[t.key||"Alt"],n=ye.fromClass(class{constructor(t){this.view=t,this.isDown=!1}set(t){this.isDown!=t&&(this.isDown=t,this.view.update([]))}},{eventObservers:{keydown(t){this.set(t.keyCode==e||i(t))},keyup(t){t.keyCode!=e&&i(t)||this.set(!1)},mousemove(t){this.set(i(t))}}});return[n,Un.contentAttributes.of((t=>{var e;return(null===(e=t.plugin(n))||void 0===e?void 0:e.isDown)?Hs:null}))]}class Fs extends r.uU{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Fs.prototype.elementClass="",Fs.prototype.toDOM=void 0,Fs.prototype.mapMode=r.gc.TrackBefore,Fs.prototype.startSide=Fs.prototype.endSide=-1,Fs.prototype.point=!0;const zs=r.r$.define(),_s=r.r$.define(),js=r.r$.define();const qs=r.r$.define({combine:t=>t.some((t=>t))});function $s(t){let e=[Ks];return t&&!1===t.fixed&&e.push(qs.of(!0)),e}const Ks=ye.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/this.view.scaleY+"px",this.gutters=t.state.facet(js).map((e=>new Xs(t,e)));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!t.state.facet(qs),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/this.view.scaleY+"px"),this.view.state.facet(qs)!=!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=r.Xs.iter(this.view.state.facet(zs),this.view.viewport.from),n=[],s=this.gutters.map((t=>new Us(t,this.view.viewport,-this.view.documentPadding.top)));for(let r of this.view.viewportLineBlocks)if(n.length&&(n=[]),Array.isArray(r.type)){let t=!0;for(let e of r.type)if(e.type==c.Text&&t){Gs(i,n,e.from);for(let t of s)t.line(this.view,e,n);t=!1}else if(e.widget)for(let t of s)t.widget(this.view,e)}else if(r.type==c.Text){Gs(i,n,r.from);for(let t of s)t.line(this.view,r,n)}else if(r.widget)for(let t of s)t.widget(this.view,r);for(let r of s)r.finish();t&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(t){let e=t.startState.facet(js),i=t.state.facet(js),n=t.docChanged||t.heightChanged||t.viewportChanged||!r.Xs.eq(t.startState.facet(zs),t.state.facet(zs),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 Xs(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:t=>Un.scrollMargins.of((e=>{let i=e.plugin(t);return i&&0!=i.gutters.length&&i.fixed?e.textDirection==u.LTR?{left:i.dom.offsetWidth*e.scaleX}:{right:i.dom.offsetWidth*e.scaleX}:null}))});function Js(t){return Array.isArray(t)?t:[t]}function Gs(t,e,i){for(;t.value&&t.from<=i;)t.from==i&&e.push(t.value),t.next()}class Us{constructor(t,e,i){this.gutter=t,this.height=i,this.i=0,this.cursor=r.Xs.iter(t.markers,e.from)}addElement(t,e,i){let{gutter:n}=this,s=(e.top-this.height)/t.scaleY,r=e.height/t.scaleY;if(this.i==n.elements.length){let e=new Ys(t,r,s,i);n.elements.push(e),n.dom.appendChild(e.dom)}else n.elements[this.i].update(t,r,s,i);this.height=e.bottom,this.i++}line(t,e,i){let n=[];Gs(this.cursor,n,e.from),i.length&&(n=n.concat(i));let s=this.gutter.config.lineMarker(t,e,n);s&&n.unshift(s);let r=this.gutter;(0!=n.length||r.config.renderEmptyElements)&&this.addElement(t,e,n)}widget(t,e){let i=this.gutter.config.widgetMarker(t,e.widget,e),n=i?[i]:null;for(let s of t.state.facet(_s)){let i=s(t,e.widget,e);i&&(n||(n=[])).push(i)}n&&this.addElement(t,e,n)}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let e=t.elements.pop();t.dom.removeChild(e.dom),e.destroy()}}}class Xs{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,r=n.target;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let t=r.getBoundingClientRect();s=(t.top+t.bottom)/2}else s=n.clientY;let o=t.lineBlockAtHeight(s-t.documentTop);e.domEventHandlers[i](t,o,n)&&n.preventDefault()}));this.markers=Js(e.markers(t)),e.initialSpacer&&(this.spacer=new Ys(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=Js(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!r.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 Ys{constructor(t,e,i,n){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,e,i,n)}update(t,e,i,n){this.height!=e&&(this.height=e,this.dom.style.height=e+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),Qs(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,h=s<e.length?e[s++]:null,l=!1;if(h){let t=h.elementClass;t&&(i+=" "+t);for(let e=r;e<this.markers.length;e++)if(this.markers[e].compare(h)){o=e,l=!0;break}}else o=this.markers.length;for(;r<o;){let t=this.markers[r++];if(t.toDOM){t.destroy(n);let e=n.nextSibling;n.remove(),n=e}}if(!h)break;h.toDOM&&(l?n=n.nextSibling:this.dom.insertBefore(h.toDOM(t),n)),l&&r++}this.dom.className=i,this.markers=e}destroy(){this.setMarkers(null,[])}}function Qs(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 Zs=r.r$.define(),tr=r.r$.define(),er=r.r$.define({combine(t){return(0,r.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 ir extends Fs{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function nr(t,e){return t.state.facet(er).formatNumber(e,t.state)}const sr=js.compute([er],(t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(Zs)},lineMarker(t,e,i){return i.some((t=>t.toDOM))?null:new ir(nr(t,t.state.doc.lineAt(e.from).number))},widgetMarker:(t,e,i)=>{for(let n of t.state.facet(tr)){let s=n(t,e,i);if(s)return s}return null},lineMarkerChange:t=>t.startState.facet(er)!=t.state.facet(er),initialSpacer(t){return new ir(nr(t,or(t.state.doc.lines)))},updateSpacer(t,e){let i=nr(e.view,or(e.view.state.doc.lines));return i==t.number?t:new ir(i)},domEventHandlers:t.facet(er).domEventHandlers})));function rr(t={}){return[er.of(t),$s(),sr]}function or(t){let e=9;for(;e<t;)e=10*e+9;return e}n()}catch(d){n(d)}}))},74347:function(t,e,i){i.d(e,{BO:function(){return bt},D0:function(){return pt},Gz:function(){return Ht},IS:function(){return Vt},Py:function(){return ht},Wl:function(){return q},Xs:function(){return Mt},YW:function(){return lt},as:function(){return b},cp:function(){return g},f_:function(){return Ct},gc:function(){return v},gm:function(){return p},jT:function(){return T},nZ:function(){return m},q6:function(){return st},r$:function(){return R},uU:function(){return xt},xv:function(){return s},yy:function(){return yt}});i(63721),i(52247),i(71695),i(92745),i(52805),i(61495),i(61893),i(69235),i(12385),i(19134),i(32517),i(5740),i(11740),i(92519),i(42179),i(89256),i(24931),i(88463),i(57449),i(19814),i(97003),i(32114),i(39527),i(92181),i(99790),i(67670),i(41360),i(13334),i(34595),i(36993),i(47021);var n=i(23618);class s{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){[t,e]=d(this,t,e);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),o.from(n,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){[t,e]=d(this,t,e);let i=[];return this.decompose(t,e,i,0),o.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 a(this),s=new a(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 a(this,t)}iterRange(t,e=this.length){return new c(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 u(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}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 r(t):o.from(r.split(t,[])):s.empty}}class r extends s{constructor(t,e=function(t){let e=-1;for(let i of t)e+=i.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.text[s],o=n+r.length;if((e?i:o)>=t)return new f(n,o,i,r);n=o+1,i++}}decompose(t,e,i,n){let s=t<=0&&e>=this.length?this:new r(l(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&n){let t=i.pop(),e=h(s.text,t.text.slice(),0,s.length);if(e.length<=32)i.push(new r(e,t.length+s.length));else{let t=e.length>>1;i.push(new r(e.slice(0,t)),new r(e.slice(t)))}}else i.push(s)}replace(t,e,i){if(!(i instanceof r))return super.replace(t,e,i);[t,e]=d(this,t,e);let n=h(this.text,h(i.text,l(this.text,0,t)),e),s=this.length+i.length-(e-t);return n.length<=32?new r(n,s):o.from(r.split(n,[]),s)}sliceString(t,e=this.length,i="\n"){[t,e]=d(this,t,e);let n="";for(let s=0,r=0;s<=e&&r<this.text.length;r++){let o=this.text[r],h=s+o.length;s>t&&r&&(n+=i),t<h&&e>s&&(n+=o.slice(Math.max(0,t-s),e-s)),s=h+1}return n}flatten(t){for(let e of this.text)t.push(e)}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 r(i,n)),i=[],n=-1);return n>-1&&e.push(new r(i,n)),e}}class o extends s{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,h=i+r.lines-1;if((e?h:o)>=t)return r.lineInner(t,e,i,n);n=o+1,i=h+1}}decompose(t,e,i,n){for(let s=0,r=0;r<=e&&s<this.children.length;s++){let o=this.children[s],h=r+o.length;if(t<=h&&e>=r){let s=n&((r<=t?1:0)|(h>=e?2:0));r>=t&&h<=e&&!s?i.push(o):o.decompose(t-r,e-r,i,s)}r=h+1}}replace(t,e,i){if([t,e]=d(this,t,e),i.lines<this.lines)for(let n=0,s=0;n<this.children.length;n++){let r=this.children[n],h=s+r.length;if(t>=s&&e<=h){let l=r.replace(t-s,e-s,i),a=this.lines-r.lines+l.lines;if(l.lines<a>>4&&l.lines>a>>6){let s=this.children.slice();return s[n]=l,new o(s,this.length-(e-t)+i.length)}return super.replace(s,h,l)}s=h+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i="\n"){[t,e]=d(this,t,e);let n="";for(let s=0,r=0;s<this.children.length&&r<=e;s++){let o=this.children[s],h=r+o.length;r>t&&s&&(n+=i),t<h&&e>r&&(n+=o.sliceString(t-r,e-r,i)),r=h+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof o))return 0;let i=0,[n,s,r,h]=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==h)return i;let o=this.children[n],l=t.children[s];if(o!=l)return i+o.scanIdentical(l,e);i+=o.length+1}}static from(t,e=t.reduce(((t,e)=>t+e.length+1),-1)){let i=0;for(let r of t)i+=r.lines;if(i<32){let i=[];for(let e of t)e.flatten(i);return new r(i,e)}let n=Math.max(32,i>>5),s=n<<1,h=n>>1,l=[],a=0,c=-1,u=[];function f(t){let e;if(t.lines>s&&t instanceof o)for(let i of t.children)f(i);else t.lines>h&&(a>h||!a)?(d(),l.push(t)):t instanceof r&&a&&(e=u[u.length-1])instanceof r&&t.lines+e.lines<=32?(a+=t.lines,c+=t.length+1,u[u.length-1]=new r(e.text.concat(t.text),e.length+1+t.length)):(a+t.lines>n&&d(),a+=t.lines,c+=t.length+1,u.push(t))}function d(){0!=a&&(l.push(1==u.length?u[0]:o.from(u,c)),c=-1,a=u.length=0)}for(let r of t)f(r);return d(),1==l.length?l[0]:new o(l,e)}}function h(t,e,i=0,n=1e9){for(let s=0,r=0,o=!0;r<t.length&&s<=n;r++){let h=t[r],l=s+h.length;l>=i&&(l>n&&(h=h.slice(0,n-s)),s<i&&(h=h.slice(i-s)),o?(e[e.length-1]+=h,o=!1):e.push(h)),s=l+1}return e}function l(t,e,i){return h(t,[""],e,i)}s.empty=new r([""],0);class a{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 r?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],o=s>>1,h=n instanceof r?n.text.length:n.children.length;if(o==(e>0?h: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 r){let s=n.text[o+(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[o+(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 r?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 c{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new a(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 u{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:n}=this.inner.next(t);return e&&this.afterBreak?(this.value="",this.afterBreak=!1):e?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(s.prototype[Symbol.iterator]=function(){return this.iter()},a.prototype[Symbol.iterator]=c.prototype[Symbol.iterator]=u.prototype[Symbol.iterator]=function(){return this});class f{constructor(t,e,i,n){this.from=t,this.to=e,this.number=i,this.text=n}get length(){return this.to-this.from}}function d(t,e,i){return[e=Math.max(0,Math.min(t.length,e)),Math.max(e,Math.min(t.length,i))]}function g(t,e,i=!0,s=!0){return(0,n.c)(t,e,i,s)}function p(t,e){let i=t.charCodeAt(e);if(!(n=i,n>=55296&&n<56320&&e+1!=t.length))return i;var n;let s=t.charCodeAt(e+1);return function(t){return t>=56320&&t<57344}(s)?s-56320+(i-55296<<10)+65536:i}function m(t){return t<65536?1:2}const w=/\r\n?|\n/;var v=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(v||(v={}));class y{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){k(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 y(t)}composeDesc(t){return this.empty?t:t.empty?this:M(this,t)}mapDesc(t,e=!1){return t.empty?this:A(this,t,e)}mapPos(t,e=-1,i=v.Simple){let n=0,s=0;for(let r=0;r<this.sections.length;){let o=this.sections[r++],h=this.sections[r++],l=n+o;if(h<0){if(l>t)return s+(t-n);s+=o}else{if(i!=v.Simple&&l>=t&&(i==v.TrackDel&&n<t&&l>t||i==v.TrackBefore&&n<t||i==v.TrackAfter&&l>t))return null;if(l>t||l==t&&e<0&&!o)return t==n||e<0?s:s+h;s+=h}n=l}if(t>n)throw new RangeError(`Position ${t} is out of range for changeset of length ${n}`);return s}touchesRange(t,e=t){for(let i=0,n=0;i<this.sections.length&&n<=e;){let s=n+this.sections[i++];if(this.sections[i++]>=0&&n<=e&&s>=t)return!(n<t&&s>e)||"cover";n=s}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];t+=(t?" ":"")+i+(n>=0?":"+n:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some((t=>"number"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeDesc");return new y(t)}static create(t){return new y(t)}}class b extends y{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 k(this,((e,i,n,s,r)=>t=t.replace(n,n+(i-e),r)),!1),t}mapDesc(t,e=!1){return A(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let n=0,r=0;n<e.length;n+=2){let o=e[n],h=e[n+1];if(h>=0){e[n]=h,e[n+1]=o;let l=n>>1;for(;i.length<l;)i.push(s.empty);i.push(o?t.slice(r,r+o):s.empty)}r+=o}return new b(e,i)}compose(t){return this.empty?t:t.empty?this:M(this,t,!0)}map(t,e=!1){return t.empty?this:A(this,t,e,!0)}iterChanges(t,e=!1){k(this,t,e)}get desc(){return y.create(this.sections)}filter(t){let e=[],i=[],n=[],s=new C(this);t:for(let r=0,o=0;;){let h=r==t.length?1e9:t[r++];for(;o<h||o==h&&0==s.len;){if(s.done)break t;let t=Math.min(s.len,h-o);x(n,t,-1);let r=-1==s.ins?-1:0==s.off?s.ins:0;x(e,t,r),r>0&&S(i,e,s.text),s.forward(t),o+=t}let l=t[r++];for(;o<l;){if(s.done)break t;let t=Math.min(s.len,l-o);x(e,t,-1),x(n,t,-1==s.ins?-1:0==s.off?s.ins:0),s.forward(t),o+=t}}return{changes:new b(e,i),filtered:y.create(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 n=[],r=[],o=0,h=null;function l(t=!1){if(!t&&!n.length)return;o<e&&x(n,e-o,-1);let i=new b(n,r);h=h?h.compose(i.map(h)):i,n=[],r=[],o=0}return function t(a){if(Array.isArray(a))for(let e of a)t(e);else if(a instanceof b){if(a.length!=e)throw new RangeError(`Mismatched change set length (got ${a.length}, expected ${e})`);l(),h=h?h.compose(a.map(h)):a}else{let{from:t,to:h=t,insert:c}=a;if(t>h||t<0||h>e)throw new RangeError(`Invalid change range ${t} to ${h} (in doc of length ${e})`);let u=c?"string"==typeof c?s.of(c.split(i||w)):c:s.empty,f=u.length;if(t==h&&0==f)return;t<o&&l(),t>o&&x(n,t-o,-1),x(n,h-t,f),S(r,n,u),o=h}}(t),l(!h),h}static empty(t){return new b(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],i=[];for(let n=0;n<t.length;n++){let r=t[n];if("number"==typeof r)e.push(r,-1);else{if(!Array.isArray(r)||"number"!=typeof r[0]||r.some(((t,e)=>e&&"string"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==r.length)e.push(r[0],0);else{for(;i.length<n;)i.push(s.empty);i[n]=s.of(r.slice(1)),e.push(r[0],i[n].length)}}}return new b(e,i)}static createSet(t,e){return new b(t,e)}}function x(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:s>=0&&0==e&&0==t[s]?t[s+1]+=i:n?(t[s]+=e,t[s+1]+=i):t.push(e,i)}function S(t,e,i){if(0==i.length)return;let n=e.length-2>>1;if(n<t.length)t[t.length-1]=t[t.length-1].append(i);else{for(;t.length<n;)t.push(s.empty);t.push(i)}}function k(t,e,i){let n=t.inserted;for(let r=0,o=0,h=0;h<t.sections.length;){let l=t.sections[h++],a=t.sections[h++];if(a<0)r+=l,o+=l;else{let c=r,u=o,f=s.empty;for(;c+=l,u+=a,a&&n&&(f=f.append(n[h-2>>1])),!(i||h==t.sections.length||t.sections[h+1]<0);)l=t.sections[h++],a=t.sections[h++];e(r,c,o,u,f),r=c,o=u}}}function A(t,e,i,n=!1){let s=[],r=n?[]:null,o=new C(t),h=new C(e);for(let l=-1;;){if(o.done&&h.len||h.done&&o.len)throw new Error("Mismatched change set lengths");if(-1==o.ins&&-1==h.ins){let t=Math.min(o.len,h.len);x(s,t,-1),o.forward(t),h.forward(t)}else if(h.ins>=0&&(o.ins<0||l==o.i||0==o.off&&(h.len<o.len||h.len==o.len&&!i))){let t=h.len;for(x(s,h.ins,-1);t;){let e=Math.min(o.len,t);o.ins>=0&&l<o.i&&o.len<=e&&(x(s,0,o.ins),r&&S(r,s,o.text),l=o.i),o.forward(e),t-=e}h.next()}else{if(!(o.ins>=0)){if(o.done&&h.done)return r?b.createSet(s,r):y.create(s);throw new Error("Mismatched change set lengths")}{let t=0,e=o.len;for(;e;)if(-1==h.ins){let i=Math.min(e,h.len);t+=i,e-=i,h.forward(i)}else{if(!(0==h.ins&&h.len<e))break;e-=h.len,h.next()}x(s,t,l<o.i?o.ins:0),r&&l<o.i&&S(r,s,o.text),l=o.i,o.forward(o.len-e)}}}}function M(t,e,i=!1){let n=[],s=i?[]:null,r=new C(t),o=new C(e);for(let h=!1;;){if(r.done&&o.done)return s?b.createSet(n,s):y.create(n);if(0==r.ins)x(n,r.len,0,h),r.next();else if(0!=o.len||o.done){if(r.done||o.done)throw new Error("Mismatched change set lengths");{let t=Math.min(r.len2,o.len),e=n.length;if(-1==r.ins){let e=-1==o.ins?-1:o.off?0:o.ins;x(n,t,e,h),s&&e&&S(s,n,o.text)}else-1==o.ins?(x(n,r.off?0:r.len,t,h),s&&S(s,n,r.textBit(t))):(x(n,r.off?0:r.len,o.off?0:o.ins,h),s&&!o.off&&S(s,n,o.text));h=(r.ins>t||o.ins>=0&&o.len>t)&&(h||n.length>e),r.forward2(t),o.forward(t)}}else x(n,0,o.ins,h),s&&S(s,n,o.text),o.next()}}class C{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?s.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?s.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 O{constructor(t,e,i){this.from=t,this.to=e,this.flags=i}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let t=7&this.flags;return 7==t?null:t}get goalColumn(){let t=this.flags>>6;return 16777215==t?void 0:t}map(t,e=-1){let i,n;return this.empty?i=n=t.mapPos(this.from,e):(i=t.mapPos(this.from,1),n=t.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new O(i,n,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return T.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return T.range(this.anchor,i)}eq(t,e=!1){return!(this.anchor!=t.anchor||this.head!=t.head||e&&this.empty&&this.assoc!=t.assoc)}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 T.range(t.anchor,t.head)}static create(t,e,i){return new O(t,e,i)}}class T{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:T.create(this.ranges.map((i=>i.map(t,e))),this.mainIndex)}eq(t,e=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(t.ranges[i],e))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new T([this.main],0)}addRange(t,e=!0){return T.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,T.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 T(t.ranges.map((t=>O.fromJSON(t))),t.main)}static single(t,e=t){return new T([T.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 T.normalized(t.slice(),e);i=s.to}return new T(t,e)}static cursor(t,e=0,i,n){return O.create(t,t,(0==e?0:e<0?8:16)|(null==i?7:Math.min(6,i))|(null!=n?n:16777215)<<6)}static range(t,e,i,n){let s=(null!=i?i:16777215)<<6|(null==n?7:Math.min(6,n));return e<t?O.create(e,t,48|s):O.create(t,e,(e>t?8:0)|s)}static normalized(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?T.range(o,r):T.range(r,o))}}return new T(t,e)}}function D(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let E=0;class R{constructor(t,e,i,n,s){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=E++,this.default=t([]),this.extensions="function"==typeof s?s(this):s}get reader(){return this}static define(t={}){return new R(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 P([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new P(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new P(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 P{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=E++}dynamicSlot(t){var e;let i=this.value,n=this.facet.compareInput,s=this.id,r=t[s]>>1,o=2==this.type,h=!1,l=!1,a=[];for(let c of this.dependencies)"doc"==c?h=!0:"selection"==c?l=!0:1&(null!==(e=t[c.id])&&void 0!==e?e:1)||a.push(t[c.id]);return{create(t){return t.values[r]=i(t),1},update(t,e){if(h&&e.docChanged||l&&(e.docChanged||e.selection)||N(t,a)){let e=i(t);if(o?!L(e,t.values[r],n):!n(e,t.values[r]))return t.values[r]=e,1}return 0},reconfigure:(t,e)=>{let h,l=e.config.address[s];if(null!=l){let s=X(e,l);if(this.dependencies.every((i=>i instanceof R?e.facet(i)===t.facet(i):!(i instanceof H)||e.field(i,!1)==t.field(i,!1)))||(o?L(h=i(t),s,n):n(h=i(t),s)))return t.values[r]=s,0}else h=i(t);return t.values[r]=h,1}}}}function L(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 N(t,e){let i=!1;for(let n of e)1&U(t,n)&&(i=!0);return i}function I(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;function h(t){let i=[];for(let e=0;e<n.length;e++){let r=X(t,n[e]);if(2==s[e])for(let t of r)i.push(t);else i.push(r)}return e.combine(i)}return{create(t){for(let e of n)U(t,e);return t.values[o]=h(t),1},update(t,i){if(!N(t,r))return 0;let n=h(t);return e.compare(n,t.values[o])?0:(t.values[o]=n,1)},reconfigure(t,s){let r=N(t,n),l=s.config.facets[e.id],a=s.facet(e);if(l&&!r&&B(i,l))return t.values[o]=a,0;let c=h(t);return e.compare(c,a)?(t.values[o]=a,0):(t.values[o]=c,1)}}}const V=R.define({static:!0});class H{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 H(E++,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(V).find((t=>t.field==this));return((null==e?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:t=>(t.values[e]=this.create(t),1),update:(t,i)=>{let n=t.values[e],s=this.updateF(n,i);return this.compareF(n,s)?0:(t.values[e]=s,1)},reconfigure:(t,i)=>null!=i.config.address[this.id]?(t.values[e]=i.field(this),0):(t.values[e]=this.create(t),1)}}init(t){return[this,V.of({field:this,create:t})]}get extension(){return this}}const W=4,F=3,z=2,_=1;function j(t){return e=>new $(e,t)}const q={highest:j(0),high:j(_),default:j(z),low:j(F),lowest:j(W)};class ${constructor(t,e){this.inner=t,this.prec=e}}class K{of(t){return new J(this,t)}reconfigure(t){return K.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class J{constructor(t,e){this.compartment=t,this.inner=e}}class G{constructor(t,e,i,n,s,r){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=s,this.facets=r,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return null==e?t.default:this.staticValues[e>>1]}static resolve(t,e,i){let n=[],s=Object.create(null),r=new Map;for(let u of function(t,e,i){let n=[[],[],[],[],[]],s=new Map;function r(t,o){let h=s.get(t);if(null!=h){if(h<=o)return;let e=n[h].indexOf(t);e>-1&&n[h].splice(e,1),t instanceof J&&i.delete(t.compartment)}if(s.set(t,o),Array.isArray(t))for(let e of t)r(e,o);else if(t instanceof J){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 $)r(t.inner,t.prec);else if(t instanceof H)n[o].push(t),t.provides&&r(t.provides,o);else if(t instanceof P)n[o].push(t),t.facet.extensions&&r(t.facet.extensions,z);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,z),n.reduce(((t,e)=>t.concat(e)))}(t,e,r))u instanceof H?n.push(u):(s[u.facet.id]||(s[u.facet.id]=[])).push(u);let o=Object.create(null),h=[],l=[];for(let u of n)o[u.id]=l.length<<1,l.push((t=>u.slot(t)));let a=null==i?void 0:i.config.facets;for(let u in s){let t=s[u],e=t[0].facet,n=a&&a[u]||[];if(t.every((t=>0==t.type)))if(o[e.id]=h.length<<1|1,B(n,t))h.push(i.facet(e));else{let n=e.combine(t.map((t=>t.value)));h.push(i&&e.compare(n,i.facet(e))?i.facet(e):n)}else{for(let e of t)0==e.type?(o[e.id]=h.length<<1|1,h.push(e.value)):(o[e.id]=l.length<<1,l.push((t=>e.dynamicSlot(t))));o[e.id]=l.length<<1,l.push((i=>I(i,e,t)))}}let c=l.map((t=>t(o)));return new G(t,r,c,o,h,s)}}function U(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.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|s}function X(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const Y=R.define(),Q=R.define({combine:t=>t.some((t=>t)),static:!0}),Z=R.define({combine:t=>t.length?t[0]:void 0,static:!0}),tt=R.define(),et=R.define(),it=R.define(),nt=R.define({combine:t=>!!t.length&&t[0]});class st{constructor(t,e){this.type=t,this.value=e}static define(){return new rt}}class rt{of(t){return new st(this,t)}}class ot{constructor(t){this.map=t}of(t){return new ht(this,t)}}class ht{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 ht(this.type,e)}is(t){return this.type==t}static define(t={}){return new ot(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}}ht.reconfigure=ht.define(),ht.appendConfig=ht.define();class lt{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&&D(i,e.newLength),s.some((t=>t.type==lt.time))||(this.annotations=s.concat(lt.time.of(Date.now())))}static create(t,e,i,n,s,r){return new lt(t,e,i,n,s,r)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(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(lt.userEvent);return!(!e||!(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function at(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 ct(t,e,i){var n;let s,r,o;return i?(s=e.changes,r=b.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:ht.mapEffects(t.effects,s).concat(ht.mapEffects(e.effects,r)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function ut(t,e,i){let n=e.selection,s=gt(e.annotations);return e.userEvent&&(s=s.concat(lt.userEvent.of(e.userEvent))),{changes:e.changes instanceof b?e.changes:b.of(e.changes||[],i,t.facet(Z)),selection:n&&(n instanceof T?n:T.single(n.anchor,n.head)),effects:gt(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function ft(t,e,i){let n=ut(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=ct(n,ut(t,e[r],s?n.changes.newLength:t.doc.length),s)}let s=lt.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return function(t){let e=t.startState,i=e.facet(it),n=t;for(let s=i.length-1;s>=0;s--){let r=i[s](t);r&&Object.keys(r).length&&(n=ct(n,ut(e,r,t.changes.newLength),!0))}return n==t?t:lt.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}(i?function(t){let e=t.startState,i=!0;for(let s of e.facet(tt)){let e=s(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:at(i,e))}if(!0!==i){let n,s;if(!1===i)s=t.changes.invertedDesc,n=b.empty(e.doc.length);else{let e=t.changes.filter(i);n=e.changes,s=e.filtered.mapDesc(e.changes).invertedDesc}t=lt.create(e,n,t.selection&&t.selection.map(s),ht.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let n=e.facet(et);for(let s=n.length-1;s>=0;s--){let i=n[s](t);t=i instanceof lt?i:Array.isArray(i)&&1==i.length&&i[0]instanceof lt?i[0]:ft(e,gt(i),!1)}return t}(s):s)}lt.time=st.define(),lt.userEvent=st.define(),lt.addToHistory=st.define(),lt.remote=st.define();const dt=[];function gt(t){return null==t?dt:Array.isArray(t)?t:[t]}var pt=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(pt||(pt={}));const mt=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let wt;try{wt=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(Wt){}function vt(t){return e=>{if(!/\S/.test(e))return pt.Space;if(function(t){if(wt)return wt.test(t);for(let e=0;e<t.length;e++){let i=t[e];if(/\w/.test(i)||i>"€"&&(i.toUpperCase()!=i.toLowerCase()||mt.test(i)))return!0}return!1}(e))return pt.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return pt.Word;return pt.Other}}class yt{constructor(t,e,i,n,s,r){this.config=t,this.doc=e,this.selection=i,this.values=n,this.status=t.statusTemplate.slice(),this.computeSlot=s,r&&(r._state=this);for(let o=0;o<this.config.dynamicSlots.length;o++)U(this,o<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(null!=i)return U(this,i),X(this,i);if(e)throw new RangeError("Field is not present in this state")}update(...t){return ft(this,t,!0)}applyTransaction(t){let e,i=this.config,{base:n,compartments:s}=i;for(let o of t.effects)o.is(K.reconfigure)?(i&&(s=new Map,i.compartments.forEach(((t,e)=>s.set(e,t))),i=null),s.set(o.value.compartment,o.value.extension)):o.is(ht.reconfigure)?(i=null,n=o.value):o.is(ht.appendConfig)&&(i=null,n=gt(n).concat(o.value));if(i)e=t.startState.values.slice();else{i=G.resolve(n,s,this),e=new yt(i,this.doc,this.selection,i.dynamicSlots.map((()=>null)),((t,e)=>e.reconfigure(t,this)),null).values}let r=t.startState.facet(Q)?t.newSelection:t.newSelection.asSingle();new yt(i,t.newDoc,r,e,((e,i)=>i.update(e,t)),t)}replaceSelection(t){return"string"==typeof t&&(t=this.toText(t)),this.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:t},range:T.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=gt(i.effects);for(let o=1;o<e.ranges.length;o++){let i=t(e.ranges[o]),h=this.changes(i.changes),l=h.map(n);for(let t=0;t<o;t++)s[t]=s[t].map(l);let a=n.mapDesc(h,!0);s.push(i.range.map(a)),n=n.compose(l),r=ht.mapEffects(r,l).concat(ht.mapEffects(gt(i.effects),a))}return{changes:n,selection:T.create(s,e.mainIndex),effects:r}}changes(t=[]){return t instanceof b?t:b.of(t,this.doc.length,this.facet(yt.lineSeparator))}toText(t){return s.of(t.split(this.facet(yt.lineSeparator)||w))}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:(U(this,e),X(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 H&&null!=this.config.address[n.id]&&(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)if(Object.prototype.hasOwnProperty.call(t,s)){let e=i[s],r=t[s];n.push(e.init((t=>e.spec.fromJSON(r,t))))}return yt.create({doc:t.doc,selection:T.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let e=G.resolve(t.extensions||[],new Map),i=t.doc instanceof s?t.doc:s.of((t.doc||"").split(e.staticFacet(yt.lineSeparator)||w)),n=t.selection?t.selection instanceof T?t.selection:T.single(t.selection.anchor,t.selection.head):T.single(0);return D(n,i.length),e.staticFacet(Q)||(n=n.asSingle()),new yt(e,i,n,e.dynamicSlots.map((()=>null)),((t,e)=>e.create(t)),null)}get tabSize(){return this.facet(yt.tabSize)}get lineBreak(){return this.facet(yt.lineSeparator)||"\n"}get readOnly(){return this.facet(nt)}phrase(t,...e){for(let i of this.facet(yt.phrases))if(Object.prototype.hasOwnProperty.call(i,t)){t=i[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,((t,i)=>{if("$"==i)return"$";let n=+(i||1);return!n||n>e.length?t:e[n-1]}))),t}languageDataAt(t,e,i=-1){let n=[];for(let s of this.facet(Y))for(let r of s(this,e,i))Object.prototype.hasOwnProperty.call(r,t)&&n.push(r[t]);return n}charCategorizer(t){return vt(this.languageDataAt("wordChars",t).join(""))}wordAt(t){let{text:e,from:i,length:n}=this.doc.lineAt(t),s=this.charCategorizer(t),r=t-i,o=t-i;for(;r>0;){let t=g(e,r,!1);if(s(e.slice(t,r))!=pt.Word)break;r=t}for(;o<n;){let t=g(e,o);if(s(e.slice(o,t))!=pt.Word)break;o=t}return r==o?null:T.range(r+i,o+i)}}function bt(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}yt.allowMultipleSelections=Q,yt.tabSize=R.define({combine:t=>t.length?t[0]:4}),yt.lineSeparator=Z,yt.readOnly=nt,yt.phrases=R.define({compare(t,e){let i=Object.keys(t),n=Object.keys(e);return i.length==n.length&&i.every((i=>t[i]==e[i]))}}),yt.languageData=Y,yt.changeFilter=tt,yt.transactionFilter=et,yt.transactionExtender=it,K.reconfigure=ht.define();class xt{eq(t){return this==t}range(t,e=t){return St.create(t,e,this)}}xt.prototype.startSide=xt.prototype.endSide=0,xt.prototype.point=!1,xt.prototype.mapMode=v.TrackDel;class St{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new St(t,e,i)}}function kt(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class At{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,h=s[n]-t||(i?this.value[n].endSide:this.value[n].startSide)-e;if(n==r)return h>=0?r:o;h>=0?o=n:r=n+1}}between(t,e,i,n){for(let s=this.findIndex(e,-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 h=0;h<this.value.length;h++){let l,a,c=this.value[h],u=this.from[h]+t,f=this.to[h]+t;if(u==f){let t=e.mapPos(u,c.startSide,c.mapMode);if(null==t)continue;if(l=a=t,c.startSide!=c.endSide&&(a=e.mapPos(u,c.endSide),a<l))continue}else if(l=e.mapPos(u,c.startSide),a=e.mapPos(f,c.endSide),l>a||l==a&&c.startSide>0&&c.endSide<=0)continue;(a-l||c.endSide-c.startSide)<0||(r<0&&(r=l),c.point&&(o=Math.max(o,a-l)),i.push(c),n.push(l-r),s.push(a-r))}return{mapped:i.length?new At(n,s,i,o):null,pos:r}}}class Mt{constructor(t,e,i,n){this.chunkPos=t,this.chunk=e,this.nextLayer=i,this.maxPoint=n}static create(t,e,i,n){return new Mt(t,e,i,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,r=t.filter;if(0==e.length&&!r)return this;if(i&&(e=e.slice().sort(kt)),this.isEmpty)return e.length?Mt.of(e):this;let o=new Tt(this,null,-1).goto(0),h=0,l=[],a=new Ct;for(;o.value||h<e.length;)if(h<e.length&&(o.from-e[h].from||o.startSide-e[h].value.startSide)>=0){let t=e[h++];a.addInner(t.from,t.to,t.value)||l.push(t)}else 1==o.rangeIndex&&o.chunkIndex<this.chunk.length&&(h==e.length||this.chunkEnd(o.chunkIndex)<e[h].from)&&(!r||n>this.chunkEnd(o.chunkIndex)||s<this.chunkPos[o.chunkIndex])&&a.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!r||n>o.to||s<o.from||r(o.from,o.to,o.value))&&(a.addInner(o.from,o.to,o.value)||l.push(St.create(o.from,o.to,o.value))),o.next());return a.finishInner(this.nextLayer.isEmpty&&!l.length?Mt.empty:this.nextLayer.update({add:l,filter:r,filterFrom:n,filterTo:s}))}map(t){if(t.empty||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],h=t.touchesRange(s,s+o.length);if(!1===h)n=Math.max(n,o.maxPoint),e.push(o),i.push(t.mapPos(s));else if(!0===h){let{mapped:r,pos:h}=o.map(s,t);r&&(n=Math.max(n,r.maxPoint),e.push(r),i.push(h))}}let s=this.nextLayer.map(t);return 0==e.length?s:new Mt(i,e,s||Mt.empty,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 Dt.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return Dt.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)),h=Ot(r,o,i),l=new Rt(r,h,s),a=new Rt(o,h,s);i.iterGaps(((t,e,i)=>Bt(l,t,a,e,i,n))),i.empty&&0==i.length&&Bt(l,0,a,0,0,n)}static eq(t,e,i=0,n){null==n&&(n=999999999);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=Ot(s,r),h=new Rt(s,o,0).goto(i),l=new Rt(r,o,0).goto(i);for(;;){if(h.to!=l.to||!Pt(h.active,l.active)||h.point&&(!l.point||!h.point.eq(l.point)))return!1;if(h.to>n)return!0;h.next(),l.next()}}static spans(t,e,i,n,s=-1){let r=new Rt(t,null,s).goto(e),o=e,h=r.openStart;for(;;){let t=Math.min(r.to,i);if(r.point){let i=r.activeForPoint(r.to),s=r.pointFrom<e?i.length+1:r.point.startSide<0?i.length:Math.min(i.length,h);n.point(o,t,r.point,i,s,r.pointRank),h=Math.min(r.openEnd(t),i.length)}else t>o&&(n.span(o,t,r.active,h),h=r.openEnd(t));if(r.to>i)return h+(r.point&&r.to>i?1:0);o=r.to,r.next()}}static of(t,e=!1){let i=new Ct;for(let n of t instanceof St?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let n=t[i];if(kt(e,n)>0)return t.slice().sort(kt);e=n}return t}(t):t)i.add(n.from,n.to,n.value);return i.finish()}static join(t){if(!t.length)return Mt.empty;let e=t[t.length-1];for(let i=t.length-2;i>=0;i--)for(let n=t[i];n!=Mt.empty;n=n.nextLayer)e=new Mt(n.chunkPos,n.chunk,e,Math.max(n.maxPoint,e.maxPoint));return e}}Mt.empty=new Mt([],[],null,-1),Mt.empty.nextLayer=Mt.empty;class Ct{finishChunk(t){this.chunks.push(new At(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=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(t,e,i){this.addInner(t,e,i)||(this.nextLayer||(this.nextLayer=new Ct)).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(Mt.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=Mt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function Ot(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.touchesRange(e,e+r.chunk[t].length))||s.add(r.chunk[t])}return s}class Tt{constructor(t,e,i,n=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex<this.layer.chunk.length;){let e=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(e)||this.layer.chunkEnd(this.chunkIndex)<t||e.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}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)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=t}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.rank-t.rank||this.to-t.to||this.endSide-t.endSide}}class Dt{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 Tt(r,e,i,s));return 1==n.length?n[0]:new Dt(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--)Et(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--)Et(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(),Et(this.heap,0)}}}function Et(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 Rt{constructor(t,e,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Dt.from(t,e,i)}goto(t,e=-1e9){return this.cursor.goto(t,e),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=t,this.endSide=e,this.openStart=-1,this.next(),this}forward(t,e){for(;this.minActive>-1&&(this.activeTo[this.minActive]-t||this.active[this.minActive].endSide-e)<0;)this.removeActive(this.minActive);this.cursor.forward(t,e)}removeActive(t){Lt(this.active,t),Lt(this.activeTo,t),Lt(this.activeRank,t),this.minActive=It(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:n,rank:s}=this.cursor;for(;e<this.activeRank.length&&(s-this.activeRank[e]||n-this.activeTo[e])>0;)e++;Nt(this.active,e,i),Nt(this.activeTo,e,n),Nt(this.activeRank,e,s),t&&Nt(t,e,this.cursor.from),this.minActive=It(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>t){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&Lt(i,n)}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 t=this.cursor.value;if(t.point){if(!(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=t,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=t.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(i),this.cursor.next()}}}if(i){this.openStart=0;for(let e=i.length-1;e>=0&&i[e]<t;e--)this.openStart++}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&e.push(this.active[i]);return e.reverse()}openEnd(t){let e=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)e++;return e}}function Bt(t,e,i,n,s,r){t.goto(e),i.goto(n);let o=n+s,h=n,l=n-e;for(;;){let e=t.to+l-i.to,n=e||t.endSide-i.endSide,s=n<0?t.to+l:i.to,a=Math.min(s,o);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))&&Pt(t.activeForPoint(t.to),i.activeForPoint(i.to))||r.comparePoint(h,a,t.point,i.point):a>h&&!Pt(t.active,i.active)&&r.compareRange(h,a,t.active,i.active),s>o)break;(e||t.openEnd!=i.openEnd)&&r.boundChange&&r.boundChange(s),h=s,n<=0&&t.next(),n>=0&&i.next()}}function Pt(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 Lt(t,e){for(let i=e,n=t.length-1;i<n;i++)t[i]=t[i+1];t.pop()}function Nt(t,e,i){for(let n=t.length-1;n>=e;n--)t[n+1]=t[n];t[e]=i}function It(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}function Vt(t,e,i=t.length){let n=0;for(let s=0;s<i&&s<t.length;)9==t.charCodeAt(s)?(n+=e-n%e,s++):(n++,s=g(t,s));return n}function Ht(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=g(t,s)}return!0===n?-1:t.length}},95397:function(t,e,i){i.d(e,{V:function(){return o}});i(63721),i(52247),i(71695),i(92745),i(52805),i(43451),i(19134),i(5740),i(11740),i(97003),i(32114),i(39527),i(13334),i(34595),i(47021);const n="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),s="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class o{constructor(t,e){this.rules=[];let{finish:i}=e||{};function n(t){return/^@/.test(t)?[t]:t.split(/,\s*/)}function s(t,e,r,o){let h=[],l=/^@(\w+)\b/.exec(t[0]),a=l&&"keyframes"==l[1];if(l&&null==e)return r.push(t[0]+";");for(let i in e){let o=e[i];if(/&/.test(i))s(i.split(/,\s*/).map((e=>t.map((t=>e.replace(/&/,t))))).reduce(((t,e)=>t.concat(e))),o,r);else if(o&&"object"==typeof o){if(!l)throw new RangeError("The value of a property ("+i+") should be a primitive value.");s(n(i),o,h,a)}else null!=o&&h.push(i.replace(/_.*/,"").replace(/[A-Z]/g,(t=>"-"+t.toLowerCase()))+": "+o+";")}(h.length||a)&&r.push((!i||l||o?t:t.map(i)).join(", ")+" {"+h.join(" ")+"}")}for(let r in t)s(n(r),t[r],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let t=r[n]||1;return r[n]=t+1,"ͼ"+t.toString(36)}static mount(t,e,i){let n=t[s],r=i&&i.nonce;n?r&&n.setNonce(r):n=new l(t,r),n.mount(Array.isArray(e)?e:[e])}}let h=new Map;class l{constructor(t,e){let i=t.ownerDocument||t,n=i.defaultView;if(!t.head&&t.adoptedStyleSheets&&n.CSSStyleSheet){let e=h.get(i);if(e)return t.adoptedStyleSheets=[e.sheet,...t.adoptedStyleSheets],t[s]=e;this.sheet=new n.CSSStyleSheet,t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets],h.set(i,this)}else{this.styleTag=i.createElement("style"),e&&this.styleTag.setAttribute("nonce",e);let n=t.head||t;n.insertBefore(this.styleTag,n.firstChild)}this.modules=[],t[s]=this}mount(t){let e=this.sheet,i=0,n=0;for(let s=0;s<t.length;s++){let r=t[s],o=this.modules.indexOf(r);if(o<n&&o>-1&&(this.modules.splice(o,1),n--,o=-1),-1==o){if(this.modules.splice(n++,0,r),e)for(let t=0;t<r.rules.length;t++)e.insertRule(r.rules[t],i++)}else{for(;n<o;)i+=this.modules[n++].rules.length;i+=r.rules.length,n++}}if(!e){let t="";for(let e=0;e<this.modules.length;e++)t+=this.modules[e].getRules()+"\n";this.styleTag.textContent=t}}setNonce(t){this.styleTag&&this.styleTag.getAttribute("nonce")!=t&&this.styleTag.setAttribute("nonce",t)}}},70585:function(t,e,i){i.d(e,{Jq:function(){return l},Lj:function(){return a},_b:function(){return E},i9:function(){return D},md:function(){return o},mp:function(){return d},vj:function(){return f}});i(52247),i(71695),i(92745),i(61495),i(84283),i(82328),i(55751),i(26200),i(25754),i(22246),i(77439),i(19423),i(19134),i(32517),i(5740),i(11740),i(44495),i(16132),i(36810),i(14953),i(58402),i(31503),i(16440),i(2213),i(57385),i(71375),i(15524),i(20267),i(46692),i(22139),i(39527),i(67670),i(13334),i(36993),i(47021);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=l.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});const h=Object.create(null);class l{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 l(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}}}}l.none=new l("",Object.create(null),0,8);class a{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 l(i.name,n,i.id,i.flags):i)}return new a(e)}}const c=new WeakMap,u=new WeakMap;var f;!function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"}(f||(f={}));class d{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=0){return new A(this.topNode,t)}cursorAt(t,e=0,i=0){let n=c.get(this)||this.topNode,s=new A(n);return s.moveTo(t,e),c.set(this,s._tree),s}get topNode(){return new y(this,0,0,null)}resolve(t,e=0){let i=v(c.get(this)||this.topNode,t,e,!1);return c.set(this,i),i}resolveInner(t,e=0){let i=v(u.get(this)||this.topNode,t,e,!0);return u.set(this,i),i}iterate(t){let{enter:e,leave:i,from:n=0,to:s=this.length}=t,r=t.mode||0,o=(r&f.IncludeAnonymous)>0;for(let h=this.cursor(r|f.IncludeAnonymous);;){let t=!1;if(h.from<=s&&h.to>=n&&(!o&&h.type.isAnonymous||!1!==e(h))){if(h.firstChild())continue;t=!0}for(;t&&i&&(o||!h.type.isAnonymous)&&i(h),!h.nextSibling();){if(!h.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(l.none,this.children,this.positions,0,this.children.length,0,this.length,((t,e,i)=>new d(this.type,t,e,i,this.propValues)),t.makeTree||((t,e,i)=>new d(l.none,t,e,i)))}static build(t){return function(t){var e;let{buffer:i,nodeSet:s,maxBufferLength:r=n,reused:h=[],minRepeatType:l=s.types.length}=t,a=Array.isArray(i)?new g(i,i.length):i,c=s.types,u=0,f=0;function m(t,e,i,n,o){let{id:d,start:g,end:S,size:k}=a,A=f;for(;k<0;){if(a.next(),-1==k){let e=h[d];return i.push(e),void n.push(g-t)}if(-3==k)return void(u=d);if(-4==k)return void(f=d);throw new RangeError(`Unrecognized record size: ${k}`)}let M,C,O=c[d],D=g-t;if(S-g<=r&&(C=b(a.pos-e,o))){let e=new Uint16Array(C.size-C.skip),i=a.pos-C.size,n=e.length;for(;a.pos>i;)n=x(C.start,e,n);M=new p(e,S-C.start,s),D=C.start-t}else{let t=a.pos-k;a.next();let e=[],i=[],n=d>=l?d:-1,s=0,o=S;for(;a.pos>t;)n>=0&&a.id==n&&a.size>=0?(a.end<=o-r&&(v(e,i,g,s,a.end,o,n,A),s=e.length,o=a.end),a.next()):m(g,t,e,i,n);if(n>=0&&s>0&&s<e.length&&v(e,i,g,s,g,o,n,A),e.reverse(),i.reverse(),n>-1&&s>0){let t=w(O);M=T(O,e,i,0,e.length,0,S-g,t,t)}else M=y(O,e,i,S-g,A-S)}i.push(M),n.push(D)}function w(t){return(e,i,n)=>{let s,r,h=0,l=e.length-1;if(l>=0&&(s=e[l])instanceof d){if(!l&&s.type==t&&s.length==n)return s;(r=s.prop(o.lookAhead))&&(h=i[l]+s.length+r)}return y(t,e,i,n,h)}}function v(t,e,i,n,r,o,h,l){let a=[],c=[];for(;t.length>n;)a.push(t.pop()),c.push(e.pop()+i-r);t.push(y(s.types[h],a,c,o-r,l-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 d(t,e,i,n,r)}function b(t,e){let i=a.fork(),n=0,s=0,o=0,h=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<h)break;let u=i.id>=l?4:0,f=i.start;for(i.next();i.pos>a;){if(i.size<0){if(-3!=i.size)break t;u+=4}else i.id>=l&&(u+=4);i.next()}s=f,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<l){let h=i;if(o>4){let n=a.pos-(o-4);for(;a.pos>n;)i=x(t,e,i)}e[--i]=h,e[--i]=r-t,e[--i]=s-t,e[--i]=n}else-3==o?u=n:-4==o&&(f=n);return i}let S=[],k=[];for(;a.pos>0;)m(t.start||0,t.bufferStart||0,S,k,-1);let A=null!==(e=t.length)&&void 0!==e?e:S.length?k[0]+S[0].length:0;return new d(c[t.topID],S.reverse(),k.reverse(),A)}(t)}}d.empty=new d(l.none,[],[],0);class g{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 g(this.buffer,this.index)}}class p{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return l.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)),i==(t+=4))return s;let r=[];for(;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 h=t;h!=e&&!(m(s,n,r[h+1],r[h+2])&&(o=h,i>0));h=r[h+3]);return o}slice(t,e,i){let n=this.buffer,s=new Uint16Array(e-t),r=0;for(let o=t,h=0;o<e;){s[h++]=n[o++],s[h++]=n[o++]-i;let e=s[h++]=n[o++]-i;s[h++]=n[o++]-t,r=Math.max(r,e)}return new p(s,r,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);for(;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){for(var s;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}let r=n?0:f.IgnoreOverlays;if(n)for(let o=t,h=o.parent;h;o=h,h=o.parent)o instanceof y&&o.index<0&&(null===(s=h.enter(e,i,r))||void 0===s?void 0:s.from)!=o.from&&(t=h);for(;;){let n=t.enter(e,i,r);if(!n)return t;t=n}}class y{constructor(t,e,i,n){this._tree=t,this.from=e,this.index=i,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,i,n,s=0){for(let r=this;;){for(let{children:h,positions:l}=r._tree,a=e>0?h.length:-1;t!=a;t+=e){let a=h[t],c=l[t]+r.from;if(m(n,i,c,c+a.length))if(a instanceof p){if(s&f.ExcludeBuffers)continue;let o=a.findChild(0,a.buffer.length,e,i-c,n);if(o>-1)return new k(new S(r,a,t,c),null,o)}else if(s&f.IncludeAnonymous||!a.type.isAnonymous||M(a)){let h;if(!(s&f.IgnoreMounts)&&a.props&&(h=a.prop(o.mounted))&&!h.overlay)return new y(h.tree,c,t,r);let l=new y(a,c,t,r);return s&f.IncludeAnonymous||!l.type.isAnonymous?l:l.nextChild(e<0?a.children.length-1:0,e,i,n)}}if(s&f.IncludeAnonymous||!r.type.isAnonymous)return null;if(t=r.index>=0?r.index+e:e<0?-1:r._parent._tree.children.length,r=r._parent,!r)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}enter(t,e,i=0){let n;if(!(i&f.IgnoreOverlays)&&(n=this._tree.prop(o.mounted))&&n.overlay){let i=t-this.from;for(let{from:t,to:s}of n.overlay)if((e>0?t<=i:t<i)&&(e<0?s>=i:s>i))return new y(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;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}cursor(t=0){return new A(this,t)}get tree(){return this._tree}toTree(){return this._tree}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._tree.toString()}get node(){return this}matchContext(t){return x(this,t)}}function b(t,e,i,n){let s=t.cursor(),r=[];if(!s.firstChild())return r;if(null!=i)for(;!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:[]}}function x(t,e,i=e.length-1){for(let n=t.parent;i>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[i]&&e[i]!=n.name)return!1;i--}}return!0}class S{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}}class k{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,i){this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}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=0){if(i&f.ExcludeBuffers)return null;let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return s<0?null:new k(this.context,this,s)}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))}cursor(t=0){return new A(this,t)}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];t.push(i.slice(n,s,r)),e.push(0)}return new d(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)}get node(){return this}matchContext(t){return x(this,t)}}class A{get name(){return this.type.name}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)}}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._tree.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=this.mode){return this.buffer?!(i&f.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&f.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&f.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode));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._tree.children.length;n!=s;n+=t){let t=i._tree.children[n];if(this.mode&f.IncludeAnonymous||t instanceof p||!t.type.isAnonymous||M(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){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,i=0;if(t&&t.context==this.buffer)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._tree}iterate(t,e){for(let i=0;;){let n=!1;if(this.type.isAnonymous||!1!==t(this)){if(this.firstChild()){i++;continue}this.type.isAnonymous||(n=!0)}for(;n&&e&&e(this),n=this.type.isAnonymous,!this.nextSibling();){if(!i)return;this.parent(),i--,n=!0}}}matchContext(t){if(!this.buffer)return x(this.node,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let n=t.length-1,s=this.stack.length-1;n>=0;s--){if(s<0)return x(this.node,t,n);let r=i[e.buffer[this.stack[s]]];if(!r.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}}function M(t){return t.children.some((t=>t instanceof p||!t.type.isAnonymous||M(t)))}const C=new WeakMap;function O(t,e){if(!t.isAnonymous||e instanceof p||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 d)){i=1;break}i+=O(t,n)}C.set(e,i)}return i}function T(t,e,i,n,s,r,o,h,l){let a=0;for(let d=n;d<s;d++)a+=O(t,e[d]);let c=Math.ceil(1.5*a/8),u=[],f=[];return function e(i,n,s,o,h){for(let a=s;a<o;){let s=a,d=n[a],g=O(t,i[a]);for(a++;a<o;a++){let e=O(t,i[a]);if(g+e>=c)break;g+=e}if(a==s+1){if(g>c){let t=i[s];e(t.children,t.positions,0,t.children.length,n[s]+h);continue}u.push(i[s])}else{let e=n[a-1]+i[a-1].length-d;u.push(T(t,i,n,s,a,d,e,null,l))}f.push(d+h-r)}}(e,i,n,s,0),(h||l)(u,f,o)}class D{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 D(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,h=0,l=0;;o++){let a=o<e.length?e[o]:null,c=a?a.fromA:1e9;if(c-h>=i)for(;r&&r.from<c;){let e=r;if(h>=e.from||c<=e.to||l){let t=Math.max(e.from,h)-l,i=Math.min(e.to,c)-l;e=t>=i?null:new D(t,i,e.tree,e.offset+l,o>0,!!a)}if(e&&n.push(e),r.to>c)break;r=s<t.length?t[s++]:null}if(!a)break;h=a.toA,l=a.toA-a.toB}return n}}class E{startParse(t,e,i){return"string"==typeof t&&(t=new R(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 R{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)}}new o({perNode:!0})},13419:function(t,e,i){i.d(e,{pJ:function(){return A}});i(52247),i(63434),i(71695),i(92745),i(61893),i(19134),i(96829),i(39527),i(92181),i(99790),i(67670),i(88972),i(47021);var n=i(70585);let s=0;class r{constructor(t,e,i,n){this.name=t,this.set=e,this.base=i,this.modified=n,this.id=s++}toString(){let{name:t}=this;for(let e of this.modified)e.name&&(t=`${e.name}(${t})`);return t}static define(t,e){let i="string"==typeof t?t:"?";if(t instanceof r&&(e=t),null==e?void 0:e.base)throw new Error("Can not derive from a modified tag");let n=new r(i,[],null,[]);if(n.set.push(n),e)for(let s of e.set)n.set.push(s);return n}static defineModifier(t){let e=new h(t);return t=>t.modified.indexOf(e)>-1?t:h.get(t.base||t,t.modified.concat(e).sort(((t,e)=>t.id-e.id)))}}let o=0;class h{constructor(t){this.name=t,this.instances=[],this.id=o++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find((i=>{return i.base==t&&(n=e,s=i.modified,n.length==s.length&&n.every(((t,e)=>t==s[e])));var n,s}));if(i)return i;let n=[],s=new r(t.name,n,t,e);for(let r of e)r.instances.push(s);let o=function(t){let e=[[]];for(let i=0;i<t.length;i++)for(let n=0,s=e.length;n<s;n++)e.push(e[n].concat(t[i]));return e.sort(((t,e)=>e.length-t.length))}(e);for(let r of t.set)if(!r.modified.length)for(let t of o)n.push(h.get(r,t));return s}}new n.md;class l{constructor(t,e,i,n){this.tags=t,this.mode=e,this.context=i,this.next=n}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}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}}l.empty=new l([],2,null);const a=r.define,c=a(),u=a(),f=a(u),d=a(u),g=a(),p=a(g),m=a(g),w=a(),v=a(w),y=a(),b=a(),x=a(),S=a(x),k=a(),A={comment:c,lineComment:a(c),blockComment:a(c),docComment:a(c),name:u,variableName:a(u),typeName:f,tagName:a(f),propertyName:d,attributeName:a(d),className:a(u),labelName:a(u),namespace:a(u),macroName:a(u),literal:g,string:p,docString:a(p),character:a(p),attributeValue:a(p),number:m,integer:a(m),float:a(m),bool:a(g),regexp:a(g),escape:a(g),color:a(g),url:a(g),keyword:y,self:a(y),null:a(y),atom:a(y),unit:a(y),modifier:a(y),operatorKeyword:a(y),controlKeyword:a(y),definitionKeyword:a(y),moduleKeyword:a(y),operator:b,derefOperator:a(b),arithmeticOperator:a(b),logicOperator:a(b),bitwiseOperator:a(b),compareOperator:a(b),updateOperator:a(b),definitionOperator:a(b),typeOperator:a(b),controlOperator:a(b),punctuation:x,separator:a(x),bracket:S,angleBracket:a(S),squareBracket:a(S),paren:a(S),brace:a(S),content:w,heading:v,heading1:a(v),heading2:a(v),heading3:a(v),heading4:a(v),heading5:a(v),heading6:a(v),contentSeparator:a(w),list:a(w),quote:a(w),emphasis:a(w),strong:a(w),link:a(w),monospace:a(w),strikethrough:a(w),inserted:a(),deleted:a(),changed:a(),invalid:a(),meta:k,documentMeta:a(k),annotation:a(k),processingInstruction:a(k),definition:r.defineModifier("definition"),constant:r.defineModifier("constant"),function:r.defineModifier("function"),standard:r.defineModifier("standard"),local:r.defineModifier("local"),special:r.defineModifier("special")};for(let M in A){let t=A[M];t instanceof r&&(t.name=M)}!function(t,e){let i=Object.create(null);for(let r of t)if(Array.isArray(r.tag))for(let t of r.tag)i[t.id]=r.class;else i[r.tag.id]=r.class;let{scope:n,all:s=null}=e||{}}([{tag:A.link,class:"tok-link"},{tag:A.heading,class:"tok-heading"},{tag:A.emphasis,class:"tok-emphasis"},{tag:A.strong,class:"tok-strong"},{tag:A.keyword,class:"tok-keyword"},{tag:A.atom,class:"tok-atom"},{tag:A.bool,class:"tok-bool"},{tag:A.url,class:"tok-url"},{tag:A.labelName,class:"tok-labelName"},{tag:A.inserted,class:"tok-inserted"},{tag:A.deleted,class:"tok-deleted"},{tag:A.literal,class:"tok-literal"},{tag:A.string,class:"tok-string"},{tag:A.number,class:"tok-number"},{tag:[A.regexp,A.escape,A.special(A.string)],class:"tok-string2"},{tag:A.variableName,class:"tok-variableName"},{tag:A.local(A.variableName),class:"tok-variableName tok-local"},{tag:A.definition(A.variableName),class:"tok-variableName tok-definition"},{tag:A.special(A.variableName),class:"tok-variableName2"},{tag:A.definition(A.propertyName),class:"tok-propertyName tok-definition"},{tag:A.typeName,class:"tok-typeName"},{tag:A.namespace,class:"tok-namespace"},{tag:A.className,class:"tok-className"},{tag:A.macroName,class:"tok-macroName"},{tag:A.propertyName,class:"tok-propertyName"},{tag:A.operator,class:"tok-operator"},{tag:A.comment,class:"tok-comment"},{tag:A.meta,class:"tok-meta"},{tag:A.invalid,class:"tok-invalid"},{tag:A.punctuation,class:"tok-punctuation"}])},23618:function(t,e,i){i.d(e,{c:function(){return l}});i(92745),i(23669),i(13334);let n=[],s=[];function r(t){if(t<768)return!1;for(let e=0,i=n.length;;){let r=e+i>>1;if(t<n[r])i=r;else{if(!(t>=s[r]))return!0;e=r+1}if(e==i)return!1}}function o(t){return t>=127462&&t<=127487}(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,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 e=0,i=0;e<t.length;e++)(e%2?s:n).push(i+=t[e])})();const h=8205;function l(t,e,i=!0,n=!0){return(i?a:c)(t,e,n)}function a(t,e,i){if(e==t.length)return e;e&&f(t.charCodeAt(e))&&d(t.charCodeAt(e-1))&&e--;let n=u(t,e);for(e+=g(n);e<t.length;){let s=u(t,e);if(n==h||s==h||i&&r(s))e+=g(s),n=s;else{if(!o(s))break;{let i=0,n=e-2;for(;n>=0&&o(u(t,n));)i++,n-=2;if(i%2==0)break;e+=2}}}return e}function c(t,e,i){for(;e>0;){let n=a(t,e-2,i);if(n<e)return n;e--}return 0}function u(t,e){let i=t.charCodeAt(e);if(!d(i)||e+1==t.length)return i;let n=t.charCodeAt(e+1);return f(n)?n-56320+(i-55296<<10)+65536:i}function f(t){return t>=56320&&t<57344}function d(t){return t>=55296&&t<56320}function g(t){return t<65536?1:2}},74092:function(t,e,i){i.a(t,(async function(t,n){try{i.d(e,{C:function(){return v}});i(52247),i(71695),i(92745),i(19423),i(92519),i(42179),i(89256),i(24931),i(88463),i(57449),i(19814),i(81804),i(13334),i(47021);var s=i(51801),r=i(96381),o=i(10857),h=t([s,o]);function a(t,e=t.state){const i=new Set;for(const{from:n,to:s}of t.visibleRanges){let t=n;for(;t<=s;){const n=e.doc.lineAt(t);i.has(n)||i.add(n),t=n.to+1}}return i}function c(t){const e=t.selection.main.head;return t.doc.lineAt(e)}function u(t,e){let i=0;t:for(let n=0;n<t.length;n++)switch(t[n]){case" ":case" ":i+=1;continue t;case"\t":i+=e-i%e;continue t;case"\r":continue t;default:break t}return i}[s,o]=h.then?(await h)():h;const f=r.r$.define({combine(t){return(0,r.BO)(t,{highlightActiveBlock:!0,hideFirstIndent:!1,markerType:"fullScope",thickness:1})}});class d{constructor(t,e,i,n){this.lines=t,this.state=e,this.map=new Map,this.unitWidth=i,this.markerType=n;for(const s of this.lines)this.add(s);this.state.facet(f).highlightActiveBlock&&this.findAndSetActiveLines()}has(t){return this.map.has("number"==typeof t?t:t.number)}get(t){const e=this.map.get("number"==typeof t?t:t.number);if(!e)throw new Error("Line not found in indentation map");return e}set(t,e,i){const n=!t.text.trim().length,s={line:t,col:e,level:i,empty:n};return this.map.set(s.line.number,s),s}add(t){if(this.has(t))return this.get(t);if(!t.length||!t.text.trim().length){if(1===t.number)return this.set(t,0,0);if(t.number===this.state.doc.lines){const e=this.closestNonEmpty(t,-1);return this.set(t,0,e.level)}const e=this.closestNonEmpty(t,-1),i=this.closestNonEmpty(t,1);return e.level>=i.level&&"codeOnly"!==this.markerType?this.set(t,0,e.level):e.empty&&0===e.level&&0!==i.level?this.set(t,0,0):i.level>e.level?this.set(t,0,e.level+1):this.set(t,0,i.level)}const e=u(t.text,this.state.tabSize),i=Math.floor(e/this.unitWidth);return this.set(t,e,i)}closestNonEmpty(t,e){let i=t.number+e;for(;-1===e?i>=1:i<=this.state.doc.lines;){if(this.has(i)){const t=this.get(i);if(!t.empty)return t}const t=this.state.doc.line(i);if(t.text.trim().length){const e=u(t.text,this.state.tabSize),i=Math.floor(e/this.unitWidth);return this.set(t,e,i)}i+=e}const n=this.state.doc.line(-1===e?1:this.state.doc.lines);return this.set(n,0,0)}findAndSetActiveLines(){const t=c(this.state);if(!this.has(t))return;let e,i,n=this.get(t);if(this.has(n.line.number+1)){const t=this.get(n.line.number+1);t.level>n.level&&(n=t)}if(this.has(n.line.number-1)){const t=this.get(n.line.number-1);t.level>n.level&&(n=t)}if(0!==n.level){for(n.active=n.level,e=n.line.number;e>1;e--){if(!this.has(e-1))continue;const t=this.get(e-1);if(t.level<n.level)break;t.active=n.level}for(i=n.line.number;i<this.state.doc.lines;i++){if(!this.has(i+1))continue;const t=this.get(i+1);if(t.level<n.level)break;t.active=n.level}}}}function g(t){const e={light:"#F0F1F2",dark:"#2B3245",activeLight:"#E4E5E6",activeDark:"#3C445C"};let i=e;return t&&(i=Object.assign(Object.assign({},e),t)),o.tk.baseTheme({"&light":{"--indent-marker-bg-color":i.light,"--indent-marker-active-bg-color":i.activeLight},"&dark":{"--indent-marker-bg-color":i.dark,"--indent-marker-active-bg-color":i.activeDark},".cm-line":{position:"relative"},".cm-indent-markers::before":{content:'""',position:"absolute",top:0,left:"2px",right:0,bottom:0,background:"var(--indent-markers)",pointerEvents:"none",zIndex:"-1"}})}function p(t,e,i,n,s){return`${`repeating-linear-gradient(to right, var(${t}) 0 ${e}px, transparent ${e}px ${i}ch)`} ${n*i}.5ch/calc(${i*s}ch - 1px) no-repeat`}function m(t,e,i,n,s){const{level:r,active:o}=t;if(s=null!=s?s:n,i&&0===r)return[];const h=i?1:0,l=[];if(void 0!==o){const t=o-h-1;t>0&&l.push(p("--indent-marker-bg-color",n,e,h,t)),l.push(p("--indent-marker-active-bg-color",s,e,o-1,1)),o!==r&&l.push(p("--indent-marker-bg-color",n,e,o,r-o))}else l.push(p("--indent-marker-bg-color",n,e,h,r-h));return l.join(",")}class w{constructor(t){this.view=t,this.unitWidth=(0,s.y1)(t.state),this.currentLineNumber=c(t.state).number,this.generate(t.state)}update(t){const e=(0,s.y1)(t.state),i=e!==this.unitWidth;i&&(this.unitWidth=e);const n=c(t.state).number,r=n!==this.currentLineNumber;this.currentLineNumber=n;const o=t.state.facet(f).highlightActiveBlock&&r;(t.docChanged||t.viewportChanged||i||o)&&this.generate(t.state)}generate(t){const e=new r.f_,i=a(this.view,t),{hideFirstIndent:n,markerType:s,thickness:h,activeThickness:l}=t.facet(f),c=new d(i,t,this.unitWidth,s);for(const r of i){const t=c.get(r.number);if(!(null==t?void 0:t.level))continue;const i=m(t,this.unitWidth,n,h,l);e.add(r.from,r.from,o.p.line({class:"cm-indent-markers",attributes:{style:`--indent-markers: ${i}`}}))}this.decorations=e.finish()}}function v(t={}){return[f.of(t),g(t.colors),o.lg.fromClass(w,{decorations:t=>t.decorations})]}n()}catch(l){n(l)}}))},65902:function(t,e,i){i.d(e,{Z:function(){return n}});i(52247);function n(){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 r=i[n];"string"==typeof r?t.setAttribute(n,r):null!=r&&(t[n]=r)}e++}for(;e<arguments.length;e++)s(t,arguments[e]);return t}function s(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++)s(t,e[i])}}},29933:function(t,e,i){i.d(e,{V:function(){return o}});i(63721),i(52247),i(71695),i(92745),i(52805),i(43451),i(19134),i(5740),i(11740),i(97003),i(32114),i(39527),i(13334),i(34595),i(47021);const n="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),s="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class o{constructor(t,e){this.rules=[];let{finish:i}=e||{};function n(t){return/^@/.test(t)?[t]:t.split(/,\s*/)}function s(t,e,r,o){let h=[],l=/^@(\w+)\b/.exec(t[0]),a=l&&"keyframes"==l[1];if(l&&null==e)return r.push(t[0]+";");for(let i in e){let o=e[i];if(/&/.test(i))s(i.split(/,\s*/).map((e=>t.map((t=>e.replace(/&/,t))))).reduce(((t,e)=>t.concat(e))),o,r);else if(o&&"object"==typeof o){if(!l)throw new RangeError("The value of a property ("+i+") should be a primitive value.");s(n(i),o,h,a)}else null!=o&&h.push(i.replace(/_.*/,"").replace(/[A-Z]/g,(t=>"-"+t.toLowerCase()))+": "+o+";")}(h.length||a)&&r.push((!i||l||o?t:t.map(i)).join(", ")+" {"+h.join(" ")+"}")}for(let r in t)s(n(r),t[r],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let t=r[n]||1;return r[n]=t+1,"ͼ"+t.toString(36)}static mount(t,e){(t[s]||new l(t)).mount(Array.isArray(e)?e:[e])}}let h=new Map;class l{constructor(t){let e=t.ownerDocument||t,i=e.defaultView;if(!t.head&&t.adoptedStyleSheets&&i.CSSStyleSheet){let n=h.get(e);if(n)return t.adoptedStyleSheets=[n.sheet,...t.adoptedStyleSheets],t[s]=n;this.sheet=new i.CSSStyleSheet,t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets],h.set(e,this)}else{this.styleTag=e.createElement("style");let i=t.head||t;i.insertBefore(this.styleTag,i.firstChild)}this.modules=[],t[s]=this}mount(t){let e=this.sheet,i=0,n=0;for(let s=0;s<t.length;s++){let r=t[s],o=this.modules.indexOf(r);if(o<n&&o>-1&&(this.modules.splice(o,1),n--,o=-1),-1==o){if(this.modules.splice(n++,0,r),e)for(let t=0;t<r.rules.length;t++)e.insertRule(r.rules[t],i++)}else{for(;n<o;)i+=this.modules[n++].rules.length;i+=r.rules.length,n++}}if(!e){let t="";for(let e=0;e<this.modules.length;e++)t+=this.modules[e].getRules()+"\n";this.styleTag.textContent=t}}}},96318:function(t,e,i){i.d(e,{YG:function(){return a},uY:function(){return s},ue:function(){return n}});i(19134),i(5740);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:"'"},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:'"'},r="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),o="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),h=0;h<10;h++)n[48+h]=n[96+h]=String(h);for(h=1;h<=24;h++)n[h+111]="F"+h;for(h=65;h<=90;h++)n[h]=String.fromCharCode(h+32),s[h]=String.fromCharCode(h);for(var l in n)s.hasOwnProperty(l)||(s[l]=n[l]);function a(t){var e=!(r&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||o&&t.shiftKey&&t.key&&1==t.key.length||"Unidentified"==t.key)&&t.key||(t.shiftKey?s:n)[t.keyCode]||t.key||"Unidentified";return"Esc"==e&&(e="Escape"),"Del"==e&&(e="Delete"),"Left"==e&&(e="ArrowLeft"),"Up"==e&&(e="ArrowUp"),"Right"==e&&(e="ArrowRight"),"Down"==e&&(e="ArrowDown"),e}}}]);
//# sourceMappingURL=868.37b5170140099330.js.map