homeassistant/custom_components/hacs/hacs_frontend_experimental/frontend_latest/2562.5ziDUy8KqmY.js
2025-01-10 21:08:35 -08:00

2 lines
No EOL
858 KiB
JavaScript
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.

export const id=2562;export const ids=[2562];export const modules={90561:(t,e,i)=>{i.d(e,{ys:()=>q});var n=i(74075),s=i(58626),r=i(67289);class o{constructor(t,e,i){this.state=t,this.pos=e,this.explicit=i,this.abortListeners=[]}tokenBefore(t){let e=(0,r.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(u(t,!1));return s<0?null:{from:i+s,to:this.pos,text:n.slice(s)}}get aborted(){return null==this.abortListeners}addEventListener(t,e){"abort"==t&&this.abortListeners&&this.abortListeners.push(e)}}function h(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 l(t){let e=t.map((t=>"string"==typeof t?{label:t}:t)),[i,n]=e.every((t=>/^\w+$/.test(t.label)))?[/\w*$/,/\w+$/]:function(t){let e=Object.create(null),i=Object.create(null);for(let{label:n}of t){e[n[0]]=!0;for(let t=1;t<n.length;t++)i[n[t]]=!0}let n=h(e)+h(i)+"*$";return[new RegExp("^"+n),new RegExp(n)]}(e);return t=>{let s=t.matchBefore(n);return s||t.explicit?{from:s?s.from:t.pos,options:e,validFor:i}:null}}class a{constructor(t,e,i,n){this.completion=t,this.source=e,this.match=i,this.score=n}}function c(t){return t.selection.main.from}function u(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 f=n.q6.define();const d=new WeakMap;function p(t){if(!Array.isArray(t))return t;let e=d.get(t);return e||d.set(t,e=l(t)),e}const g=n.Py.define(),m=n.Py.define();class w{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,n.gm)(t,e),s=(0,n.nZ)(i);this.chars.push(i);let r=t.slice(e,e+s),o=r.toUpperCase();this.folded.push((0,n.gm)(o==r?r.toLowerCase():o,0)),e+=s}this.astral=t.length!=this.chars.length}ret(t,e){return this.score=t,this.matched=e,!0}match(t){if(0==this.pattern.length)return this.ret(-100,[]);if(t.length<this.pattern.length)return!1;let{chars:e,folded:i,any:s,precise:r,byWord:o}=this;if(1==e.length){let s=(0,n.gm)(t,0),r=(0,n.nZ)(s),o=r==t.length?0:-100;if(s==e[0]);else{if(s!=i[0])return!1;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,n.gm)(t,r);o!=e[a]&&o!=i[a]||(s[a++]=r),r+=(0,n.nZ)(o)}if(a<l)return!1}let c=0,u=0,f=!1,d=0,p=-1,g=-1,m=/[a-z]/.test(t),w=!0;for(let s=0,a=Math.min(t.length,200),v=0;s<a&&u<l;){let a=(0,n.gm)(t,s);h<0&&(c<l&&a==e[c]&&(r[c++]=s),d<l&&(a==e[d]||a==i[d]?(0==d&&(p=s),g=s+1,d++):d=0));let y,b=a<255?a>=48&&a<=57||a>=97&&a<=122?2:a>=65&&a<=90?1:0:(y=(0,n.bg)(a))!=y.toLowerCase()?1:y!=y.toUpperCase()?2:0;(!s||1==b&&m||0==v&&0!=b)&&(e[u]==a||i[u]==a&&(f=!0)?o[u++]=s:o.length&&(w=!1)),v=b,s+=(0,n.nZ)(a)}return u==l&&0==o[0]&&w?this.result((f?-200:0)-100,o,t):d==l&&0==p?this.ret(-200-t.length+(g==t.length?0:-100),[0,g]):h>-1?this.ret(-700-t.length,[h,h+this.pattern.length]):d==l?this.ret(-900-t.length,[p,g]):u==l?this.result((f?-200:0)-100-700+(w?0:-1100),o,t):2!=e.length&&this.result((s[0]?-700:0)-200-1100,s,t)}result(t,e,i){let s=[],r=0;for(let t of e){let e=t+(this.astral?(0,n.nZ)((0,n.gm)(i,t)):1);r&&s[r-1]==t?s[r-1]=e:(s[r++]=t,s[r++]=e)}return this.ret(t-i.length,s)}}const v=n.r$.define({combine:t=>(0,n.BO)(t,{activateOnTyping:!0,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:b,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=>y(t(i),e(i)),optionClass:(t,e)=>i=>y(t(i),e(i)),addToOptions:(t,e)=>t.concat(e)})});function y(t,e){return t?e?t+" "+e:t:e}function b(t,e,i,n,r,o){let h,l,a=t.textDirection==s.Nm.RTL,c=a,u=!1,f="top",d=e.left-r.left,p=r.right-e.right,g=n.right-n.left,m=n.bottom-n.top;if(c&&d<Math.min(g,p)?c=!1:!c&&p<Math.min(g,d)&&(c=!0),g<=(c?d:p))h=Math.max(r.top,Math.min(i.top,r.bottom-m))-e.top,l=Math.min(400,c?d:p);else{u=!0,l=Math.min(400,(a?e.right:r.right-e.left)-30);let t=r.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 x(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 k{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(v);this.optionContent=function(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 t=0;t<n.length;){let e=n[t++],i=n[t++];e>o&&s.appendChild(document.createTextNode(r.slice(o,e)));let h=s.appendChild(document.createElement("span"));h.appendChild(document.createTextNode(r.slice(e,i))),h.className="cm-completionMatchedText",o=i}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))}(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=x(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(v).closeOnBlur&&e.relatedTarget!=t.contentDOM&&t.dispatch({effects:m.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=x(s.length,r,t.state.facet(v).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=x(e.options.length,e.selected,this.view.state.facet(v).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 r="string"==typeof n?document.createTextNode(n):n(i);if(!r)return;"then"in r?r.then((e=>{e&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(e,i)})).catch((t=>(0,s.OO)(this.view.state,t,"completion info"))):this.addInfoPane(r,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&&function(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)}(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(v).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 S(t,e){return i=>new k(i,t,e)}function A(t){return 100*(t.boost||0)+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}class M{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 M(this.options,T(e,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,e,i,n,s){let r=function(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)}};for(let n of t)if(n.hasResult()){let t=n.result.getMatch;if(!1===n.result.filter)for(let e of n.result.options)s(new a(e,n.source,t?t(e):[],1e9-i.length));else{let i=new w(e.sliceDoc(n.from,n.to));for(let e of n.result.options)if(i.match(e.label)){let r=e.displayLabel?t?t(e,i.matched):[]:i.matched;s(new a(e,n.source,r,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 e of i){let{section:i}=e.completion;i&&(e.score+=t["string"==typeof i?i:i.name])}}let r=[],o=null,h=e.facet(v).compareCompletions;for(let t of i.sort(((t,e)=>e.score-t.score||h(t.completion,e.completion)))){let e=t.completion;!o||o.label!=e.label||o.detail!=e.detail||null!=o.type&&null!=e.type&&o.type!=e.type||o.apply!=e.apply||o.boost!=e.boost?r.push(t):A(t.completion)>A(o)&&(r[r.length-1]=t),o=t.completion}return r}(t,e);if(!r.length)return n&&t.some((t=>1==t.state))?new M(n.options,n.attrs,n.tooltip,n.timestamp,n.selected,!0):null;let o=e.facet(v).selectOnOpen?0:-1;if(n&&n.selected!=o&&-1!=n.selected){let t=n.options[n.selected].completion;for(let e=0;e<r.length;e++)if(r[e].completion==t){o=e;break}}return new M(r,T(i,o),{pos:t.reduce(((t,e)=>e.hasResult()?Math.min(t,e.from):t),1e8),create:V,above:s.aboveCursor},n?n.timestamp:Date.now(),o,!1)}map(t){return new M(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:t.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}}class C{constructor(t,e,i){this.active=t,this.id=e,this.open=i}static start(){return new C(D,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(t){let{state:e}=t,i=e.facet(v),n=(i.override||e.languageDataAt("autocomplete",c(e)).map(p)).map((e=>(this.active.find((t=>t.source==e))||new B(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;s&&t.docChanged&&(s=s.map(t.changes)),t.selection||n.some((e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to)))||!function(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}}(n,this.active)?s=M.build(n,e,this.id,s,i):s&&s.disabled&&!n.some((t=>1==t.state))&&(s=null),!s&&n.every((t=>1!=t.state))&&n.some((t=>t.hasResult()))&&(n=n.map((t=>t.hasResult()?new B(t.source,0):t)));for(let e of t.effects)e.is(I)&&(s=s&&s.setSelected(e.value,this.id));return n==this.active&&s==this.open?this:new C(n,this.id,s)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:O}}const O={"aria-autocomplete":"list"};function T(t,e){let i={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(i["aria-activedescendant"]=t+"-"+e),i}const D=[];function E(t){return t.isUserEvent("input.type")?"input":t.isUserEvent("delete.backward")?"delete":null}class B{constructor(t,e,i=-1){this.source=t,this.state=e,this.explicitPos=i}hasResult(){return!1}update(t,e){let i=E(t),n=this;i?n=n.handleUserEvent(t,i,e):t.docChanged?n=n.handleChange(t):t.selection&&0!=n.state&&(n=new B(n.source,0));for(let e of t.effects)if(e.is(g))n=new B(n.source,1,e.value?c(t.state):-1);else if(e.is(m))n=new B(n.source,0);else if(e.is(P))for(let t of e.value)t.source==n.source&&(n=t);return n}handleUserEvent(t,e,i){return"delete"!=e&&i.activateOnTyping?new B(this.source,1):this.map(t.changes)}handleChange(t){return t.changes.touchesRange(c(t.startState))?new B(this.source,0):this.map(t.changes)}map(t){return t.empty||this.explicitPos<0?this:new B(this.source,this.state,t.mapPos(this.explicitPos))}}class R extends B{constructor(t,e,i,n,s){super(t,2,e),this.result=i,this.from=n,this.to=s}hasResult(){return!0}handleUserEvent(t,e,i){var n;let s=t.changes.mapPos(this.from),r=t.changes.mapPos(this.to,1),h=c(t.state);if((this.explicitPos<0?h<=s:h<this.from)||h>r||"delete"==e&&c(t.startState)==this.from)return new B(this.source,"input"==e&&i.activateOnTyping?1:0);let l,a=this.explicitPos<0?-1:t.changes.mapPos(this.explicitPos);return function(t,e,i,n){if(!t)return!1;let s=e.sliceDoc(i,n);return"function"==typeof t?t(s,i,n,e):u(t,!0).test(s)}(this.result.validFor,t.state,s,r)?new R(this.source,a,this.result,s,r):this.result.update&&(l=this.result.update(this.result,s,r,new o(t.state,h,a>=0)))?new R(this.source,a,l,l.from,null!==(n=l.to)&&void 0!==n?n:c(t.state)):new B(this.source,1,a)}handleChange(t){return t.changes.touchesRange(this.from,this.to)?new B(this.source,0):this.map(t.changes)}map(t){return t.empty?this:new R(this.source,this.explicitPos<0?-1:t.mapPos(this.explicitPos),this.result,t.mapPos(this.from),t.mapPos(this.to,1))}}const P=n.Py.define({map:(t,e)=>t.map((t=>t.map(e)))}),I=n.Py.define(),N=n.QQ.define({create:()=>C.start(),update:(t,e)=>t.update(e),provide:t=>[s.hJ.from(t,(t=>t.tooltip)),s.tk.contentAttributes.from(t,(t=>t.attrs))]});function L(t,e){const i=e.completion.apply||e.completion.label;let s=t.state.field(N).active.find((t=>t.source==e.source));return s instanceof R&&("string"==typeof i?t.dispatch(Object.assign(Object.assign({},function(t,e,i,s){let{main:r}=t.selection,o=i-r.from,h=s-r.from;return Object.assign(Object.assign({},t.changeByRange((l=>l!=r&&i!=s&&t.sliceDoc(l.from+o,l.from+h)!=t.sliceDoc(i,s)?{range:l}:{changes:{from:l.from+o,to:s==r.from?l.to:l.from+h,insert:e},range:n.jT.cursor(l.from+o+e.length)}))),{scrollIntoView:!0,userEvent:"input.complete"})}(t.state,i,s.from,s.to)),{annotations:f.of(e.completion)})):i(t,e.completion,s.from,s.to),!0)}const V=S(N,L);function H(t,e="option"){return i=>{let n=i.state.field(N,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp<i.state.facet(v).interactionDelay)return!1;let r,o=1;"page"==e&&(r=(0,s.gB)(i,n.open.tooltip))&&(o=Math.max(2,Math.floor(r.dom.offsetHeight/r.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:I.of(l)}),!0}}class W{constructor(t,e){this.active=t,this.context=e,this.time=Date.now(),this.updates=[],this.done=void 0}}const _=s.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(N).active)1==e.state&&this.startQuery(e)}update(t){let e=t.state.field(N);if(!t.selectionSet&&!t.docChanged&&t.startState.field(N)==e)return;let i=t.transactions.some((t=>(t.selection||t.docChanged)&&!E(t)));for(let e=0;e<this.running.length;e++){let n=this.running[e];if(i||n.updates.length+t.transactions.length>50&&Date.now()-n.time>1e3){for(let t of n.context.abortListeners)try{t()}catch(t){(0,s.OO)(this.view.state,t)}n.context.abortListeners=null,this.running.splice(e--,1)}else n.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some((t=>t.effects.some((t=>t.is(g)))))&&(this.pendingStart=!0);let n=this.pendingStart?50:t.state.facet(v).activateOnTypingDelay;if(this.debounceUpdate=e.active.some((t=>1==t.state&&!this.running.some((e=>e.active.source==t.source))))?setTimeout((()=>this.startUpdate()),n):-1,0!=this.composing)for(let e of t.transactions)"input"==E(e)?this.composing=2:2==this.composing&&e.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(N);for(let t of e.active)1!=t.state||this.running.some((e=>e.active.source==t.source))||this.startQuery(t)}startQuery(t){let{state:e}=this.view,i=c(e),n=new o(e,i,t.explicitPos==i),r=new W(t,n);this.running.push(r),Promise.resolve(t.source(n)).then((t=>{r.context.aborted||(r.done=t||null,this.scheduleAccept())}),(t=>{this.view.dispatch({effects:m.of(null)}),(0,s.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(v).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],i=this.view.state.facet(v);for(let n=0;n<this.running.length;n++){let s=this.running[n];if(void 0===s.done)continue;if(this.running.splice(n--,1),s.done){let n=new R(s.active.source,s.active.explicitPos,s.done,s.done.from,null!==(t=s.done.to)&&void 0!==t?t:c(s.updates.length?s.updates[0].startState:this.view.state));for(let t of s.updates)n=n.update(t,i);if(n.hasResult()){e.push(n);continue}}let r=this.view.state.field(N).active.find((t=>t.source==s.active.source));if(r&&1==r.state)if(null==s.done){let t=new B(s.active.source,0);for(let e of s.updates)t=t.update(e,i);1!=t.state&&e.push(t)}else this.startQuery(r)}e.length&&this.view.dispatch({effects:P.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(N,!1);if(e&&e.tooltip&&this.view.state.facet(v).closeOnBlur){let i=e.open&&(0,s.gB)(this.view,e.open.tooltip);i&&i.dom.contains(t.relatedTarget)||setTimeout((()=>this.view.dispatch({effects:m.of(null)})),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout((()=>this.view.dispatch({effects:g.of(!1)})),20),this.composing=0}}}),z=s.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"},".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 F=new class extends n.uU{};F.startSide=1,F.endSide=-1;"object"==typeof navigator&&navigator.userAgent;function q(t={}){return[N,v.of(t),_,K,z]}const j=[{key:"Ctrl-Space",run:t=>!!t.state.field(N,!1)&&(t.dispatch({effects:g.of(!0)}),!0)},{key:"Escape",run:t=>{let e=t.state.field(N,!1);return!(!e||!e.active.some((t=>0!=t.state)))&&(t.dispatch({effects:m.of(null)}),!0)}},{key:"ArrowDown",run:H(!0)},{key:"ArrowUp",run:H(!1)},{key:"PageDown",run:H(!0,"page")},{key:"PageUp",run:H(!1,"page")},{key:"Enter",run:t=>{let e=t.state.field(N,!1);return!(t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(v).interactionDelay)&&L(t,e.open.options[e.open.selected])}}],K=n.Wl.highest(s.$f.computeN([v],(t=>t.facet(v).defaultKeymap?[j]:[])))},65300:(t,e,i)=>{i.d(e,{wQ:()=>Sc,m8:()=>aa,f$:()=>Ca,xi:()=>kc,at:()=>xc});var n=i(74075);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){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){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 t=e,r=e;;){if(n.next(t),s.next(t),t=0,n.lineBreak!=s.lineBreak||n.done!=s.done||n.value!=s.value)return!1;if(r+=n.value.length,n.done||r>=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);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"){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 e of t)this.lines+=e.lines}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.children[s],o=n+r.length,h=i+r.lines-1;if((e?h:o)>=t)return r.lineInner(t,e,i,n);n=o+1,i=h+1}}decompose(t,e,i,n){for(let s=0,r=0;r<=e&&s<this.children.length;s++){let o=this.children[s],h=r+o.length;if(t<=h&&e>=r){let s=n&((r<=t?1:0)|(h>=e?2:0));r>=t&&h<=e&&!s?i.push(o):o.decompose(t-r,e-r,i,s)}r=h+1}}replace(t,e,i){if(i.lines<this.lines)for(let n=0,s=0;n<this.children.length;n++){let r=this.children[n],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"){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 e of t)i+=e.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 e of t.children)f(e);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 e of t)f(e);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.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}}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 p(t){for(let e=1;e<d.length;e+=2)if(d[e]>t)return d[e-1]<=t;return!1}function g(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=k(t,e);for(e+=S(n);e<t.length;){let s=k(t,e);if(n==m||s==m||i&&p(s))e+=S(s),n=s;else{if(!g(s))break;{let i=0,n=e-2;for(;n>=0&&g(k(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 k(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 S(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:R(this,t)}mapDesc(t,e=!1){return t.empty?this:B(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 B(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 O(e,i)}compose(t){return this.empty?t:t.empty?this:R(this,t,!0)}map(t,e=!1){return t.empty?this:B(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 n=[],r=[],o=0,h=null;function l(t=!1){if(!t&&!n.length)return;o<e&&T(n,e-o,-1);let i=new O(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 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?s.of(c.split(i||A)):c:s.empty,f=u.length;if(t==h&&0==f)return;t<o&&l(),t>o&&T(n,t-o,-1),T(n,h-t,f),D(r,n,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 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 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 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 E(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 B(t,e,i,n=!1){let s=[],r=n?[]:null,o=new P(t),h=new P(e);for(let t=-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||t==o.i||0==o.off&&(h.len<o.len||h.len==o.len&&!i))){let e=h.len;for(T(s,h.ins,-1);e;){let i=Math.min(o.len,e);o.ins>=0&&t<o.i&&o.len<=i&&(T(s,0,o.ins),r&&D(r,s,o.text),t=o.i),o.forward(i),e-=i}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 e=0,i=o.len;for(;i;)if(-1==h.ins){let t=Math.min(i,h.len);e+=t,i-=t,h.forward(t)}else{if(!(0==h.ins&&h.len<i))break;i-=h.len,h.next()}T(s,e,t<o.i?o.ins:0),r&&t<o.i&&D(r,s,o.text),t=o.i,o.forward(o.len-i)}}}function R(t,e,i=!1){let n=[],s=i?[]:null,r=new P(t),o=new P(e);for(let t=!1;;){if(r.done&&o.done)return s?O.createSet(n,s):C.create(n);if(0==r.ins)T(n,r.len,0,t),r.next();else if(0!=o.len||o.done){if(r.done||o.done)throw new Error("Mismatched change set lengths");{let e=Math.min(r.len2,o.len),i=n.length;if(-1==r.ins){let i=-1==o.ins?-1:o.off?0:o.ins;T(n,e,i,t),s&&i&&D(s,n,o.text)}else-1==o.ins?(T(n,r.off?0:r.len,e,t),s&&D(s,n,r.textBit(e))):(T(n,r.off?0:r.len,o.off?0:o.ins,t),s&&!o.off&&D(s,n,o.text));t=(r.ins>e||o.ins>=0&&o.len>e)&&(t||n.length>i),r.forward2(e),o.forward(e)}}else T(n,0,o.ins,t),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?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 I{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 I(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 I(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=>I.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 I.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?I.create(e,t,24|s):I.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 i=1;i<t.length;i++){let n=t[i],s=t[i-1];if(n.empty?n.from<=s.to:n.from<s.to){let r=s.from,o=Math.max(n.to,s.to);i<=e&&e--,t.splice(--i,2,n.anchor>n.head?N.range(o,r):N.range(r,o))}}return new N(t,e)}}function L(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 _([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new _(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new _(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 _{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 i of this.dependencies)"doc"==i?h=!0:"selection"==i?l=!0:0==(1&(null!==(e=t[i.id])&&void 0!==e?e:1))&&a.push(t[i.id]);return{create:t=>(t.values[r]=i(t),1),update(t,e){if(h&&e.docChanged||l&&(e.docChanged||e.selection)||F(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 K)||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 F(t,e){let i=!1;for(let n of e)1&it(t,n)&&(i=!0);return i}function q(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(!F(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=F(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 j=H.define({static:!0});class K{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 K(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(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,J=3,U=2,G=1;function X(t){return e=>new Q(e,t)}const Y={highest:X(0),high:X(G),default:X(U),low:X(J),lowest:X($)};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 i of function(t,e,i){let n=[[],[],[],[],[]],s=new Map;function r(t,o){let h=s.get(t);if(null!=h){if(h<=o)return;let e=n[h].indexOf(t);e>-1&&n[h].splice(e,1),t instanceof 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 K)n[o].push(t),t.provides&&r(t.provides,o);else if(t instanceof _)n[o].push(t),t.facet.extensions&&r(t.facet.extensions,U);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,U),n.reduce(((t,e)=>t.concat(e)))}(t,e,r))i instanceof K?n.push(i):(s[i.facet.id]||(s[i.facet.id]=[])).push(i);let o=Object.create(null),h=[],l=[];for(let t of n)o[t.id]=l.length<<1,l.push((e=>t.slot(e)));let a=null==i?void 0:i.config.facets;for(let t in s){let e=s[t],n=e[0].facet,r=a&&a[t]||[];if(e.every((t=>0==t.type)))if(o[n.id]=h.length<<1|1,W(r,e))h.push(i.facet(n));else{let t=n.combine(e.map((t=>t.value)));h.push(i&&n.compare(t,i.facet(n))?i.facet(n):t)}else{for(let t of e)0==t.type?(o[t.id]=h.length<<1|1,h.push(t.value)):(o[t.id]=l.length<<1,l.push((e=>t.dynamicSlot(e))));o[n.id]=l.length<<1,l.push((t=>q(t,n,e)))}}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 pt(this,t)}}class pt{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 pt(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}}pt.reconfigure=pt.define(),pt.appendConfig=pt.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&&L(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 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:pt.mapEffects(t.effects,s).concat(pt.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(gt.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 s=1;s<e.length;s++){!1===e[s].filter&&(i=!1);let r=!!e[s].sequential;n=wt(n,vt(t,e[s],r?n.changes.newLength:t.doc.length),r)}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(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:gt.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}(i?function(t){let e=t.startState,i=!0;for(let n of e.facet(ht)){let e=n(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=gt.create(e,n,t.selection&&t.selection.map(s),pt.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let n=e.facet(lt);for(let i=n.length-1;i>=0;i--){let s=n[i](t);t=s instanceof gt?s:Array.isArray(s)&&1==s.length&&s[0]instanceof gt?s[0]:yt(e,xt(s),!1)}return t}(s):s)}gt.time=ut.define(),gt.userEvent=ut.define(),gt.addToHistory=ut.define(),gt.remote=ut.define();const bt=[];function xt(t){return null==t?bt:Array.isArray(t)?t:[t]}var kt=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(kt||(kt={}));const St=/[\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 kt.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()||St.test(i)))return!0}return!1}(e))return kt.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return kt.Word;return kt.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 t=0;t<this.config.dynamicSlots.length;t++)it(this,t<<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 e of t.effects)e.is(Z.reconfigure)?(i&&(s=new Map,i.compartments.forEach(((t,e)=>s.set(e,t))),i=null),s.set(e.value.compartment,e.value.extension)):e.is(pt.reconfigure)?(i=null,n=e.value):e.is(pt.appendConfig)&&(i=null,n=xt(n).concat(e.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 i=1;i<e.ranges.length;i++){let o=t(e.ranges[i]),h=this.changes(o.changes),l=h.map(n);for(let t=0;t<i;t++)s[t]=s[t].map(l);let a=n.mapDesc(h,!0);s.push(o.range.map(a)),n=n.compose(l),r=pt.mapEffects(r,l).concat(pt.mapEffects(xt(o.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 s.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 K&&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 e in i)if(Object.prototype.hasOwnProperty.call(t,e)){let s=i[e],r=t[e];n.push(s.init((t=>s.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 s?t.doc:s.of((t.doc||"").split(e.staticFacet(Ct.lineSeparator)||A)),n=t.selection?t.selection instanceof N?t.selection:N.single(t.selection.anchor,t.selection.head):N.single(0);return L(n,i.length),e.staticFacet(rt)||(n=n.asSingle()),new Ct(e,i,n,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 e of this.facet(Ct.phrases))if(Object.prototype.hasOwnProperty.call(e,t)){t=e[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))!=kt.Word)break;r=t}for(;o<n;){let t=w(e,o);if(s(e.slice(o,t))!=kt.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=pt.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 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(Dt)),this.isEmpty)return e.length?Bt.of(e):this;let o=new It(this,null,-1).goto(0),h=0,l=[],a=new Rt;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?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 s=0;s<this.chunk.length;s++){let r=this.chunkPos[s],o=this.chunk[s],h=t.touchesRange(r,r+o.length);if(!1===h)n=Math.max(n,o.maxPoint),e.push(o),i.push(t.mapPos(r));else if(!0===h){let{mapped:s,pos:h}=o.map(r,t);s&&(n=Math.max(n,s.maxPoint),e.push(s),i.push(h))}}let s=this.nextLayer.map(t);return 0==e.length?s:new 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 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 Rt;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()}}Bt.empty=new Bt([],[],null,-1),Bt.empty.nextLayer=Bt.empty;class Rt{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 Rt)).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 Pt(t,e,i){let n=new Map;for(let e of t)for(let t=0;t<e.chunk.length;t++)e.chunk[t].maxPoint<=0&&n.set(e.chunk[t],e.chunkPos[t]);let s=new Set;for(let t of e)for(let e=0;e<t.chunk.length;e++){let r=n.get(t.chunk[e]);null==r||(i?i.mapPos(r):r)!=t.chunkPos[e]||(null==i?void 0:i.touchesRange(r,r+t.chunk[e].length))||s.add(t.chunk[e])}return s}class It{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 It(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 t=this.heap.length>>1;t>=0;t--)Lt(this.heap,t);return this.next(),this}forward(t,e){for(let i of this.heap)i.forward(t,e);for(let t=this.heap.length>>1;t>=0;t--)Lt(this.heap,t);(this.to-t||this.value.endSide-e)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),Lt(this.heap,0)}}}function Lt(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){_t(this.active,t),_t(this.activeTo,t),_t(this.activeRank,t),this.minActive=Ft(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=Ft(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&&_t(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 _t(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 i=t.length-1;i>=e;i--)t[i+1]=t[i];t[e]=i}function Ft(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}var qt=i(28450);i(29350);function jt(t){let e;return e=11==t.nodeType?t.getSelection?t:t.ownerDocument:t,e.getSelection()}function Kt(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function $t(t,e){if(!e.anchorNode)return!1;try{return Kt(t,e.anchorNode)}catch(t){return!1}}function Jt(t){return 3==t.nodeType?se(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function Ut(t,e,i,n){return!!i&&(Xt(t,e,i,n,-1)||Xt(t,e,i,n,1))}function Gt(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function Xt(t,e,i,n,s){for(;;){if(t==i&&e==n)return!0;if(e==(s<0?0:Yt(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=Gt(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?Yt(t):0}}}function Yt(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function Qt(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function Zt(t){return{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}class te{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?Yt(e):0),i,Math.min(t.focusOffset,i?Yt(i):0))}set(t,e,i,n){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=n}}let ee,ie=null;function ne(t){if(t.setActive)return t.setActive();if(ie)return t.focus(ie);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==ie?{get preventScroll(){return ie={preventScroll:!0},!0}}:void 0),!ie){ie=!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 se(t,e,i=e){let n=ee||(ee=document.createRange());return n.setEnd(t,i),n.setStart(t,e),n}function re(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 oe(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}class he{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new he(t.parentNode,Gt(t),e)}static after(t,e){return new he(t.parentNode,Gt(t)+1,e)}}const le=[];class ae{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=ae.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=ce(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=ce(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==Yt(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&&!ae.get(i);)i=i.nextSibling;if(!i)return this.length;for(let t=0,e=0;;t++){let n=this.children[t];if(n.dom==i)return e;e+=n.length+n.breakAfter}}domBoundsAround(t,e,i=0){let n=-1,s=-1,r=-1,o=-1;for(let h=0,l=i,a=i;h<this.children.length;h++){let i=this.children[h],c=l+i.length;if(l<t&&c>e)return i.domBoundsAround(t,e,l);if(c>=t&&-1==n&&(n=h,s=l),l>e&&i.dom.parentNode==this.dom){r=h,o=a;break}a=c,l=c+i.breakAfter}return{from:s,to:o<0?i+this.length:o,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:r<this.children.length&&r>=0?this.children[r].dom:null}}markDirty(t=!1){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=le){this.markDirty();for(let i=t;i<e;i++){let t=this.children[i];t.parent==this&&t.destroy()}this.children.splice(t,e-t,...i);for(let t=0;t<i.length;t++)i[t].setParent(this)}ignoreMutation(t){return!1}ignoreEvent(t){return!1}childCursor(t=this.length){return new ue(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 ce(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}ae.prototype.breakAfter=0;class ue{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 fe(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 de(t,e,i,n,s,r){let o=t.childCursor(),{i:h,off:l}=o.findPos(i,1),{i:a,off:c}=o.findPos(e,-1),u=e-i;for(let t of n)u+=t.length;t.length+=u,fe(t,a,c,h,l,n,0,s,r)}let pe="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},ge="undefined"!=typeof document?document:{documentElement:{style:{}}};const me=/Edge\/(\d+)/.exec(pe.userAgent),we=/MSIE \d/.test(pe.userAgent),ve=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(pe.userAgent),ye=!!(we||ve||me),be=!ye&&/gecko\/(\d+)/i.test(pe.userAgent),xe=!ye&&/Chrome\/(\d+)/.exec(pe.userAgent),ke="webkitFontSmoothing"in ge.documentElement.style,Se=!ye&&/Apple Computer/.test(pe.vendor),Ae=Se&&(/Mobile\/\w+/.test(pe.userAgent)||pe.maxTouchPoints>2);var Me={mac:Ae||/Mac/.test(pe.platform),windows:/Win/.test(pe.platform),linux:/Linux|X11/.test(pe.platform),ie:ye,ie_version:we?ge.documentMode||6:ve?+ve[1]:me?+me[1]:0,gecko:be,gecko_version:be?+(/Firefox\/(\d+)/.exec(pe.userAgent)||[0,0])[1]:0,chrome:!!xe,chrome_version:xe?+xe[1]:0,ios:Ae,android:/Android\b/.test(pe.userAgent),webkit:ke,safari:Se,webkit_version:ke?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:null!=ge.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class Ce extends ae{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 Ce&&!(this.length-(e-t)+i.length>256))&&(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new Ce(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 he(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 Te(this.dom,t,e)}}class Oe extends ae{constructor(t,e=[],i=0){super(),this.mark=t,this.children=e,this.length=i;for(let t of e)t.setParent(this)}setAttrs(t){if(oe(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 Oe&&i.mark.eq(this.mark))||t&&s<=0||e<this.length&&r<=0))&&(de(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 r of this.children){let o=i+r.length;o>t&&e.push(i<t?r.split(t-i):r),n<0&&i>=t&&(n=s),i=o,s++}let r=this.length-t;return this.length=t,n>-1&&(this.children.length=n,this.markDirty()),new Oe(this.mark,e,r)}domAtPos(t){return Le(this,t)}coordsAt(t,e){return He(this,t,e)}}function Te(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?Me.chrome||Me.gecko||(e?(s--,o=1):r<n&&(r++,o=-1)):i<0?s--:r<n&&r++;let h=se(t,s,r).getClientRects();if(!h.length)return null;let l=h[(o?o<0:i>=0)?0:h.length-1];return Me.safari&&!o&&0==l.width&&(l=Array.prototype.find.call(h,(t=>t.width))||l),o?Qt(l,o<0):l||null}class De extends ae{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||De)(t,e,i)}split(t){let e=De.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 De&&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 De&&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 s.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):s.empty}domAtPos(t){return(this.length?0==t:this.side>0)?he.before(this.dom):he.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 e=r?n.length-1:0;s=n[e],!(t>0?0==e:e==n.length-1||s.top<s.bottom);e+=r?-1:1);return Qt(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 Ee extends De{domAtPos(t){let{topView:e,text:i}=this.widget;return e?Be(t,0,e,i,this.length-e.length,((t,e)=>t.domAtPos(e)),((t,e)=>new he(t,Math.min(e,t.nodeValue.length)))):new he(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?Pe(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?Be(t,e,i,n,this.length-i.length,((t,e,i)=>t.coordsAt(e,i)),((t,e,i)=>Te(t,e,i))):Te(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 Be(t,e,i,n,s,r,o){if(i instanceof Oe){for(let h=i.dom.firstChild;h;h=h.nextSibling){let i=ae.get(h);if(i){let l=Kt(h,n),a=i.length+(l?s:0);if(t<a||t==a&&i.getSide()<=0)return l?Be(t,e,i,n,s,r,o):r(i,t,e);t-=a}else{let i=Re(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 Re(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=Re(t,e,s,n);if("number"!=typeof i)return i;t=i}return t}function Pe(t,e,i,n,s){if(i instanceof Oe){let r=0;for(let o=i.dom.firstChild;o;o=o.nextSibling){let i=ae.get(o);if(i){let h=Kt(o,n);if(Kt(o,t))return r+(h?Pe(t,e,i,n,s):i.localPosFromDOM(t,e));r+=i.length+(h?s:0)}else{let i=Ie(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 Ie(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=Ie(t,e,s);if(null!=o.result)return{result:e+o.result};n+=o.size}}}class Ne extends ae{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof Ne&&t.side==this.side}split(){return new Ne(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?he.before(this.dom):he.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return s.empty}get isHidden(){return!0}}function Le(t,e){let i=t.dom,{children:n}=t,s=0;for(let t=0;s<n.length;s++){let r=n[s],o=t+r.length;if(!(o==t&&r.getSide()<=0)){if(e>t&&e<o&&r.dom.parentNode==i)return r.domAtPos(e-t);if(e<=t)break;t=o}}for(let t=s;t>0;t--){let e=n[t-1];if(e.dom.parentNode==i)return e.domAtPos(e.length)}for(let t=s;t<n.length;t++){let e=n[t];if(e.dom.parentNode==i)return e.domAtPos(0)}return new he(i,0)}function Ve(t,e,i){let n,{children:s}=t;i>0&&e instanceof Oe&&s.length&&(n=s[s.length-1])instanceof Oe&&n.mark.eq(e.mark)?Ve(n,e.children[0],i-1):(s.push(e),e.setParent(t)),t.length+=e.length}function He(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):function(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=Jt(e);return i[i.length-1]||null}(t)}function We(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 _e(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 ze(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}Ce.prototype.children=De.prototype.children=Ne.prototype.children=le;class Fe{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 qe=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(qe||(qe={}));class je extends Ot{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 Ke(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 Je(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}=Ue(t,n);e=(s?n?-3e8:-1:5e8)-1,i=1+(r?n?2e8:1:-6e8)}return new Je(t,e,i,n,t.widget||null,!0)}static line(t){return new $e(t)}static set(t,e=!1){return Bt.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}je.none=Bt.empty;class Ke extends je{constructor(t){let{start:e,end:i}=Ue(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 Ke&&this.tagName==t.tagName&&this.class==t.class&&_e(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)}}Ke.prototype.point=!1;class $e extends je{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof $e&&this.spec.class==t.spec.class&&_e(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)}}$e.prototype.mapMode=M.TrackBefore,$e.prototype.point=!0;class Je extends je{constructor(t,e,i,n,s,r){super(e,i,s,t),this.block=n,this.isReplace=r,this.mapMode=n?e<=0?M.TrackBefore:M.TrackAfter:M.TrackDel}get type(){return this.startSide<this.endSide?qe.WidgetRange:this.startSide<=0?qe.WidgetBefore:qe.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof Je&&(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 Ue(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 Ge(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)}Je.prototype.point=!0;class Xe extends ae{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 Xe))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),de(this,t,e,i?i.children:[],s,r),!0}split(t){let e=new Xe;if(e.breakAfter=this.breakAfter,0==this.length)return e;let{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 t=i;t<this.children.length;t++)e.append(this.children[t],0);for(;i>0&&0==this.children[i-1].length;)this.children[--i].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){_e(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){Ve(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=We(e,this.attrs||{})),i&&(this.attrs=We({class:i},this.attrs||{}))}domAtPos(t){return Le(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.dirty|=6)}sync(t,e){var i;this.dom?4&this.dirty&&(oe(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&&(ze(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&&ae.get(n)instanceof Oe;)n=n.lastChild;if(!(n&&this.length&&("BR"==n.nodeName||0!=(null===(i=ae.get(n))||void 0===i?void 0:i.isEditable)||Me.ios&&this.children.some((t=>t instanceof Ce))))){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 Ce)||/[^ -~]/.test(i.text))return null;let n=Jt(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=He(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 qe.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 Xe)return s;if(r>e)break}n=r+s.breakAfter}return null}}class Ye extends ae{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 Ye&&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?he.before(this.dom):he.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new Ye(this.widget,e,this.type);return i.breakAfter=this.breakAfter,i}get children(){return le}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):s.empty}domBoundsAround(){return null}become(t){return t instanceof Ye&&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 Qe{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 Ye&&t.type==qe.WidgetBefore)}getLine(){return this.curLine||(this.content.push(this.curLine=new Xe),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(Ze(new Ne(-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(Ze(new Ce(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 Je){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 Je)if(i.block){let{type:t}=i;t!=qe.WidgetAfter||this.posCovered()||this.getLine(),this.addBlockWidget(new Ye(i.widget||new ti("div"),o,t))}else{let r=De.create(i.widget||new ti("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(Ze(new Ne(1),n),s),s=n.length+Math.max(0,s-n.length)),a.append(Ze(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 r=new Qe(t,e,i,s);return r.openEnd=Bt.spans(n,e,i,r),r.openStart<0&&(r.openStart=r.openEnd),r.finish(r.openEnd),r}}function Ze(t,e){for(let i of e)t=new Oe(i,[t],t.length);return t}class ti extends Fe{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 ei=H.define(),ii=H.define(),ni=H.define(),si=H.define(),ri=H.define(),oi=H.define(),hi=H.define(),li=H.define({combine:t=>t.some((t=>t))}),ai=H.define({combine:t=>t.some((t=>t))});class ci{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 ci(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin)}}const ui=pt.define({map:(t,e)=>t.map(e)});function fi(t,e,i){let n=t.facet(si);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 di=H.define({combine:t=>!t.length||t[0]});let pi=0;const gi=H.define();class mi{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 mi(pi++,t,i,(t=>{let e=[gi.of(t)];return s&&e.push(bi.of((e=>{let i=e.plugin(t);return i?s(i):je.none}))),n&&e.push(n(t)),e}))}static fromClass(t,e){return mi.define((e=>new t(e)),e)}}class wi{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(fi(t.state,e,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(t){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(t)}catch(e){fi(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(e){fi(t.state,e,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const vi=H.define(),yi=H.define(),bi=H.define(),xi=H.define(),ki=H.define();function Si(t){let e=0,i=0,n=0,s=0;for(let r of t.state.facet(ki)){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 Ai=H.define();class Mi{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new Mi(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 Mi(r+l,h+l,r,h).addToSet(i),n>a)break;s+=2}if(!h)return i;new Mi(h.fromA,h.toA,h.fromB,h.toB).addToSet(i),r=h.toA,o=h.toB}}}class Ci{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=O.empty(this.startState.doc.length);for(let t of i)this.changes=this.changes.compose(t.changes);let n=[];this.changes.iterChangedRanges(((t,e,i,s)=>n.push(new Mi(t,e,i,s)))),this.changedRanges=n}static create(t,e,i){return new Ci(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 Oi=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(Oi||(Oi={}));const Ti=Oi.LTR,Di=Oi.RTL;function Ei(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}const Bi=Ei("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Ri=Ei("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Pi=Object.create(null),Ii=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),i=t.charCodeAt(1);Pi[e]=i,Pi[i]=-e}const Ni=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Li{constructor(t,e,i){this.from=t,this.to=e,this.level=i}get dir(){return this.level%2?Di:Ti}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 Vi=[];function Hi(t,e){let i=t.length,n=e==Ti?1:2,s=e==Ti?2:1;if(!t||1==n&&!Ni.test(t))return Wi(i);for(let e=0,s=n,o=n;e<i;e++){let i=(r=t.charCodeAt(e))<=247?Bi[r]:1424<=r&&r<=1524?2:1536<=r&&r<=1785?Ri[r-1536]:1774<=r&&r<=2220?4:8192<=r&&r<=8203?256:64336<=r&&r<=65023?4:8204==r?256:1;512==i?i=s:8==i&&4==o&&(i=16),Vi[e]=4==i?2:i,7&i&&(o=i),s=i}var r;for(let t=0,e=n,s=n;t<i;t++){let n=Vi[t];if(128==n)t<i-1&&e==Vi[t+1]&&24&e?n=Vi[t]=e:Vi[t]=256;else if(64==n){let n=t+1;for(;n<i&&64==Vi[n];)n++;let r=t&&8==e||n<i&&8==Vi[n]?1==s?1:8:256;for(let e=t;e<n;e++)Vi[e]=r;t=n-1}else 8==n&&1==s&&(Vi[t]=1);e=n,7&n&&(s=n)}for(let e,r,o,h=0,l=0,a=0;h<i;h++)if(r=Pi[e=t.charCodeAt(h)])if(r<0){for(let t=l-3;t>=0;t-=3)if(Ii[t+1]==-r){let e=Ii[t+2],i=2&e?n:4&e?1&e?s:n:0;i&&(Vi[h]=Vi[Ii[t]]=i),l=t;break}}else{if(189==Ii.length)break;Ii[l++]=h,Ii[l++]=e,Ii[l++]=a}else if(2==(o=Vi[h])||1==o){let t=o==n;a=t?0:1;for(let e=l-3;e>=0;e-=3){let i=Ii[e+2];if(2&i)break;if(t)Ii[e+2]|=2;else{if(4&i)break;Ii[e+2]|=4}}}for(let t=0;t<i;t++)if(256==Vi[t]){let e=t+1;for(;e<i&&256==Vi[e];)e++;let s=1==(t?Vi[t-1]:n),r=s==(1==(e<i?Vi[e]:n))?s?1:2:n;for(let i=t;i<e;i++)Vi[i]=r;t=e-1}let o=[];if(1==n)for(let t=0;t<i;){let e=t,n=1!=Vi[t++];for(;t<i&&n==(1!=Vi[t]);)t++;if(n)for(let i=t;i>e;){let t=i,n=2!=Vi[--i];for(;i>e&&n==(2!=Vi[i-1]);)i--;o.push(new Li(i,t,n?2:1))}else o.push(new Li(e,t,0))}else for(let t=0;t<i;){let e=t,n=2==Vi[t++];for(;t<i&&n==(2==Vi[t]);)t++;o.push(new Li(e,t,n?1:2))}return o}function Wi(t){return[new Li(0,t,0)]}let _i="";function zi(t,e,i,n,s){var r;let o=n.head-t.from,h=-1;if(0==o){if(!s||!t.length)return null;e[0].level!=i&&(o=e[0].side(!1,i),h=0)}else if(o==t.length){if(s)return null;let t=e[e.length-1];t.level!=i&&(o=t.side(!0,i),h=e.length-1)}h<0&&(h=Li.find(e,o,null!==(r=n.bidiLevel)&&void 0!==r?r:-1,n.assoc));let l=e[h];o==l.side(s,i)&&(l=e[h+=s?1:-1],o=l.side(!s,i));let a=s==(l.dir==i),c=w(t.text,o,a);if(_i=t.text.slice(Math.min(o,c),Math.max(o,c)),c!=l.side(s,i))return N.cursor(c+t.from,a?-1:1,l.level);let u=h==(s?e.length-1:0)?null:e[h+(s?1:-1)];return u||l.level==i?u&&u.level<l.level?N.cursor(u.side(!s,i)+t.from,s?1:-1,u.level):N.cursor(c+t.from,s?-1:1,l.level):N.cursor(s?t.to:t.from,s?-1:1,i)}const Fi="￿";class qi{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(Ct.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=Fi}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=ae.get(n),o=ae.get(s);(r&&o?r.breakAfter:(r?r.breakAfter:ji(n))||ji(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=ae.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 ji(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}class Ki{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class $i extends ae{constructor(t){super(),this.view=t,this.compositionDeco=je.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 Xe],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Mi(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=je.none:(t.transactions.length||this.dirty)&&(this.compositionDeco=function(t,e){let i=Ui(t);if(!i)return je.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 qi([],a);3==r.nodeType?c.readTextNode(r):c.readRange(r.firstChild,null);let{text:u}=c;if(u.indexOf(Fi)>-1)return je.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 je.none;h=l-u.length}else if(a.doc.sliceString(h,l)!=u)return je.none;let f=ae.get(r);f instanceof Ee?f=f.widget.topView:f&&(f.parent=null);return je.set(je.replace({widget:new Gi(r,o,f),inclusive:!0}).range(h,l))}(this.view,t.changes)),(Me.ie||Me.chrome)&&!this.compositionDeco.size&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let i=function(t,e,i){let n=new Yi;return Bt.compare(t,e,i,n),n.changes}(this.decorations,this.updateDeco(),t.changes);return e=Mi.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=Me.chrome||Me.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 t of this.children)t instanceof Ye&&t.widget instanceof Ji&&n.push(t.dom);i.updateGaps(n)}updateChildren(t,e){let i=this.childCursor(e);for(let e=t.length-1;;e--){let n=e>=0?t[e]:null;if(!n)break;let{fromA:s,toA:r,fromB:o,toB:h}=n,{content:l,breakAtStart:a,openStart:c,openEnd:u}=Qe.build(this.view.state.doc,o,h,this.decorations,this.dynamicDecorationMap),{i:f,off:d}=i.findPos(r,1),{i:p,off:g}=i.findPos(s,-1);fe(this,p,g,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&&$t(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(Me.gecko&&o.empty&&!this.compositionDeco.size&&(1==(a=h).node.nodeType&&a.node.firstChild&&(0==a.offset||"false"==a.node.childNodes[a.offset-1].contentEditable)&&(a.offset==a.node.childNodes.length||"false"==a.node.childNodes[a.offset].contentEditable))){let t=document.createTextNode("");this.view.observer.ignore((()=>h.node.insertBefore(t,h.node.childNodes[h.offset]||null))),h=l=new he(t,0),r=!0}var a;let c=this.view.observer.selectionRange;!r&&c.focusNode&&Ut(h.node,h.offset,c.anchorNode,c.anchorOffset)&&Ut(l.node,l.offset,c.focusNode,c.focusOffset)||(this.view.observer.ignore((()=>{Me.android&&Me.chrome&&this.dom.contains(c.focusNode)&&function(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}(c.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let t=jt(this.view.root);if(t)if(o.empty){if(Me.gecko){let t=(e=h.node,n=h.offset,1!=e.nodeType?0:(n&&"false"==e.childNodes[n-1].contentEditable?1:0)|(n<e.childNodes.length&&"false"==e.childNodes[n].contentEditable?2:0));if(t&&3!=t){let e=Xi(h.node,h.offset,1==t?1:-1);e&&(h=new he(e,1==t?0:e.nodeValue.length))}}t.collapse(h.node,h.offset),null!=o.bidiLevel&&null!=c.cursorBidiLevel&&(c.cursorBidiLevel=o.bidiLevel)}else if(t.extend){t.collapse(h.node,h.offset);try{t.extend(l.node,l.offset)}catch(t){}}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;var e,n;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 he(c.anchorNode,c.anchorOffset),this.impreciseHead=l.precise?null:new he(c.focusNode,c.focusOffset)}enforceCursorAssoc(){if(this.compositionDeco.size)return;let{view:t}=this,e=t.state.selection.main,i=jt(t.root),{anchorNode:n,anchorOffset:s}=t.observer.selectionRange;if(!(i&&e.empty&&e.assoc&&i.modify))return;let r=Xe.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=ae.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 Xe)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!=qe.WidgetBefore&&s.type!=qe.WidgetAfter&&(!n||2==e||this.children[n-1].breakAfter||this.children[n-1].type==qe.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==Oi.LTR;for(let t=0,l=0;l<this.children.length;l++){let a=this.children[l],c=t+a.length;if(c>n)break;if(t>=i){let i=a.dom.getBoundingClientRect();if(e.push(i.height),r){let e=a.dom.lastChild,n=e?Jt(e):[];if(n.length){let e=n[n.length-1],r=h?e.right-i.left:i.right-e.left;r>o&&(o=r,this.minWidth=s,this.minWidthFrom=t,this.minWidthTo=c)}}}t=c+a.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?Oi.RTL:Oi.LTR}measureTextSize(){for(let t of this.children)if(t instanceof Xe){let e=t.measureTextSize();if(e)return e}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=Jt(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 ue(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(je.replace({widget:new Ji(n),block:!0,inclusive:!0,isBlockGap:!0}).range(i,r))}if(!s)break;i=s.to+1}return je.set(t)}updateDeco(){let t=this.view.state.facet(bi).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=Si(this.view),r={left:n.left-s.left,top:n.top-s.top,right:n.right+s.right,bottom:n.bottom+s.bottom};!function(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=Zt(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))):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,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}}(this.view.scrollDOM,r,i.head<i.anchor?-1:1,t.x,t.y,t.xMargin,t.yMargin,this.view.textDirection==Oi.LTR)}}class Ji extends Fe{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 Ui(t){let e=t.observer.selectionRange,i=e.focusNode&&Xi(e.focusNode,e.focusOffset,0);if(!i)return null;let n=t.docView.nearest(i);if(!n)return null;if(n instanceof Xe){let t=i;for(;t.parentNode!=n.dom;)t=t.parentNode;let e=t.previousSibling;for(;e&&!ae.get(e);)e=e.previousSibling;let s=e?ae.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 Xe)break;n=t}let t=n.posAtStart;return{from:t,to:t+n.length,node:n.dom,text:i}}}class Gi extends Fe{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 Ee}}function Xi(t,e,i){if(i<=0)for(let i=t,n=e;;){if(3==i.nodeType)return i;if(!(1==i.nodeType&&n>0))break;i=i.childNodes[n-1],n=Yt(i)}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}class Yi{constructor(){this.changes=[]}compareRange(t,e){Ge(t,e,this.changes)}comparePoint(t,e){Ge(t,e,this.changes)}}function Qi(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function Zi(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function tn(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function en(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function nn(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function sn(t,e,i){let n,s,r,o,h,l,a,c,u=!1;for(let f=t.firstChild;f;f=f.nextSibling){let t=Jt(f);for(let d=0;d<t.length;d++){let p=t[d];s&&tn(s,p)&&(p=en(nn(p,s.bottom),s.top));let g=Qi(e,p),m=Zi(i,p);if(0==g&&0==m)return 3==f.nodeType?rn(f,e,i):sn(f,e,i);if(!n||o>m||o==m&&r>g){n=f,s=p,r=g,o=m;let h=m?i<p.top?-1:1:g?e<p.left?-1:1:0;u=!h||(h>0?d<t.length-1:d>0)}0==g?i>p.bottom&&(!a||a.bottom<p.bottom)?(h=f,a=p):i<p.top&&(!c||c.top>p.top)&&(l=f,c=p):a&&tn(a,p)?a=nn(a,p.bottom):c&&tn(c,p)&&(c=en(c,p.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?rn(n,f,i):u&&"false"!=n.contentEditable?sn(n,f,i):{node:t,offset:Array.prototype.indexOf.call(t.childNodes,n)+(e>=(s.left+s.right)/2?1:0)}}function rn(t,e,i){let n=t.nodeValue.length,s=-1,r=1e9,o=0;for(let h=0;h<n;h++){let n=se(t,h,h+1).getClientRects();for(let l=0;l<n.length;l++){let a=n[l];if(a.top==a.bottom)continue;o||(o=e-a.left);let c=(a.top>i?a.top-i:i-a.bottom)-1;if(a.left-1<=e&&a.right+1>=e&&c<r){let i=e>=(a.left+a.right)/2,n=i;if(Me.chrome||Me.gecko){se(t,h).getBoundingClientRect().left==a.right&&(n=!i)}if(c<=0)return{node:t,offset:h+(n?1:0)};s=h+(n?1:0),r=c}}}return{node:t,offset:s>-1?s:o>0?t.nodeValue.length:0}}function on(t,e,i,n=-1){var s,r;let o,h=t.contentDOM.getBoundingClientRect(),l=h.top+t.viewState.paddingTop,{docHeight:a}=t.viewState,{x:c,y:u}=e,f=u-l;if(f<0)return 0;if(f>a)return t.state.doc.length;for(let e=t.viewState.heightOracle.textHeight/2,s=!1;o=t.elementAtHeight(f),o.type!=qe.Text;)for(;f=n>0?o.bottom+e:o.top-e,!(f>=0&&f<=a);){if(s)return i?null:0;s=!0,n=-n}u=l+f;let d=o.from;if(d<t.viewport.from)return 0==t.viewport.from?0:i?null:hn(t,h,o,c,u);if(d>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:hn(t,h,o,c,u);let p=t.dom.ownerDocument,g=t.root.elementFromPoint?t.root:p,m=g.elementFromPoint(c,u);m&&!t.contentDOM.contains(m)&&(m=null),m||(c=Math.max(h.left+1,Math.min(h.right-1,c)),m=g.elementFromPoint(c,u),m&&!t.contentDOM.contains(m)&&(m=null));let w,v=-1;if(m&&0!=(null===(s=t.docView.nearest(m))||void 0===s?void 0:s.isEditable))if(p.caretPositionFromPoint){let t=p.caretPositionFromPoint(c,u);t&&({offsetNode:w,offset:v}=t)}else if(p.caretRangeFromPoint){let e=p.caretRangeFromPoint(c,u);e&&(({startContainer:w,startOffset:v}=e),(!t.contentDOM.contains(w)||Me.safari&&function(t,e,i){let n;if(3!=t.nodeType||e!=(n=t.nodeValue.length))return!1;for(let e=t.nextSibling;e;e=e.nextSibling)if(1!=e.nodeType||"BR"!=e.nodeName)return!1;return se(t,n-1,n).getBoundingClientRect().left>i}(w,v,c)||Me.chrome&&function(t,e,i){if(0!=e)return!1;for(let e=t;;){let t=e.parentNode;if(!t||1!=t.nodeType||t.firstChild!=e)return!1;if(t.classList.contains("cm-line"))break;e=t}let n=1==t.nodeType?t.getBoundingClientRect():se(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect();return i-n.left>5}(w,v,c))&&(w=void 0))}if(!w||!t.docView.dom.contains(w)){let e=Xe.find(t.docView,d);if(!e)return f>o.top+o.height/2?o.to:o.from;({node:w,offset:v}=sn(e.dom,c,u))}let y=t.docView.nearest(w);if(!y)return null;if(y.isWidget&&1==(null===(r=y.dom)||void 0===r?void 0:r.nodeType)){let t=y.dom.getBoundingClientRect();return e.y<t.top||e.y<=t.bottom&&e.x<=(t.left+t.right)/2?y.posAtStart:y.posAtEnd}return y.localPosFromDOM(w,v)+y.posAtStart}function hn(t,e,i,n,s){let r=Math.round((n-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>1.5*t.defaultLineHeight){let e=t.viewState.heightOracle.textHeight;r+=Math.floor((s-i.top-.5*(t.defaultLineHeight-e))/e)*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(i.from,i.to);return i.from+function(t,e,i,n){for(let n=0,s=0;;){if(s>=e)return n;if(n==t.length)break;s+=9==t.charCodeAt(n)?i-s%i:1,n=w(t,n)}return!0===n?-1:t.length}(o,r,t.state.tabSize)}function ln(t,e){let i=t.lineBlockAt(e);if(Array.isArray(i.type))for(let t of i.type)if(t.to>e||t.to==e&&(t.to==i.to||t.type==qe.Text))return t;return i}function an(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=zi(s,r,o,h,i),a=_i;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=N.cursor(i?s.from:s.to)}if(l){if(!l(a))return h}else{if(!n)return e;l=n(a)}h=e}}function cn(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 un(t,e,i){let n=cn(t.state.facet(xi).map((e=>e(t))),i.from,e.head>i.from?-1:1);return n==i.from?i:N.cursor(n,n<i.from?1:-1)}class fn{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 yn){let n=yn[i];t.contentDOM.addEventListener(i,(i=>{vn(t,i)&&e(n,i)}),bn[i]),this.registeredEvents.push(i)}t.scrollDOM.addEventListener("mousedown",(i=>{if(i.target==t.scrollDOM&&i.clientY>t.contentDOM.getBoundingClientRect().bottom&&(e(yn.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(yn.drop,i)})),Me.chrome&&102==Me.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,Me.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=>{vn(t,i)&&this.runCustomHandlers(e,t,i)&&i.preventDefault()})))}}runCustomHandlers(t,e,i){for(let n of this.customHandlers){let s=n.handlers[t];if(s)try{if(s.call(n.plugin,i,e)||i.defaultPrevented)return!0}catch(t){fi(e.state,t)}}return!1}runScrollHandlers(t,e){this.lastScrollTop=t.scrollDOM.scrollTop,this.lastScrollLeft=t.scrollDOM.scrollLeft;for(let i of this.customHandlers){let n=i.handlers.scroll;if(n)try{n.call(i.plugin,e,t)}catch(e){fi(t.state,e)}}}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&&gn.indexOf(e.keyCode)<0&&(t.inputState.lastEscPress=0),Me.android&&Me.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))return t.observer.delayAndroidKey(e.key,e.keyCode),!0;let i;return!(!Me.ios||e.synthetic||e.altKey||e.metaKey||!((i=dn.find((t=>t.keyCode==e.keyCode)))&&!e.ctrlKey||pn.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,re(t.contentDOM,e.key,e.keyCode))}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(this.composing>0||!!(Me.safari&&!Me.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 dn=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],pn="dthko",gn=[16,17,18,20,91,92,224,225];function mn(t){return.7*Math.max(0,t)+8}class wn{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=function(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}(t.contentDOM),this.atoms=t.state.facet(xi).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(Ct.allowMultipleSelections)&&function(t,e){let i=t.state.facet(ei);return i.length?i[0](e):Me.mac?e.metaKey:e.ctrlKey}(t,e),this.dragging=!(!function(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let n=jt(t.root);if(!n||0==n.rangeCount)return!0;let s=n.getRangeAt(0).getClientRects();for(let t=0;t<s.length;t++){let i=s[t];if(i.left<=e.clientX&&i.right>=e.clientX&&i.top<=e.clientY&&i.bottom>=e.clientY)return!0}return!1}(t,e)||1!=Rn(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=Si(this.view);t.clientX-r.left<=s.left+6?i=-mn(s.left-t.clientX):t.clientX+r.right>=s.right-6&&(i=mn(t.clientX-s.right)),t.clientY-r.top<=s.top+6?n=-mn(s.top-t.clientY):t.clientY+r.bottom>=s.bottom-6&&(n=mn(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=cn(this.atoms,n.from,0);t!=n.from&&(s=N.cursor(t,-1))}else{let t=cn(this.atoms,n.from,-1),e=cn(this.atoms,n.to,1);t==n.from&&e==n.to||(s=N.range(n.from==n.anchor?t:e,n.from==n.head?t:e))}s&&(e||(e=t.ranges.slice()),e[i]=s)}return e?N.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 vn(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=ae.get(n))&&i.ignoreEvent(e))return!1;return!0}const yn=Object.create(null),bn=Object.create(null),xn=Me.ie&&Me.ie_version<15||Me.ios&&Me.webkit_version<604;function kn(t,e){let i,{state:n}=t,s=1,r=n.toText(e),o=r.lines==n.selection.ranges.length;if(null!=In&&n.selection.ranges.every((t=>t.empty))&&In==r.toString()){let t=-1;i=n.changeByRange((i=>{let h=n.doc.lineAt(i.from);if(h.from==t)return{range:i};t=h.from;let l=n.toText((o?r.line(s++).text:e)+n.lineBreak);return{changes:{from:h.from,insert:l},range:N.cursor(i.from+l.length)}}))}else i=o?n.changeByRange((t=>{let e=r.line(s++);return{changes:{from:t.from,to:t.to,insert:e.text},range:N.cursor(t.from+e.length)}})):n.replaceSelection(r);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function Sn(t,e,i,n){if(1==n)return N.cursor(e,i);if(2==n)return function(t,e,i=1){let n=t.charCategorizer(e),s=t.doc.lineAt(e),r=e-s.from;if(0==s.length)return N.cursor(e);0==r?i=1:r==s.length&&(i=-1);let o=r,h=r;i<0?o=w(s.text,r,!1):h=w(s.text,r);let l=n(s.text.slice(o,h));for(;o>0;){let t=w(s.text,o,!1);if(n(s.text.slice(t,o))!=l)break;o=t}for(;h<s.length;){let t=w(s.text,h);if(n(s.text.slice(h,t))!=l)break;h=t}return N.range(o+s.from,h+s.from)}(t.state,e,i);{let i=Xe.find(t.docView,e),n=t.state.doc.lineAt(i?i.posAtEnd:e),s=i?i.posAtStart:n.from,r=i?i.posAtEnd:n.to;return r<t.state.doc.length&&r==n.to&&r++,N.range(s,r)}}yn.keydown=(t,e)=>{t.inputState.setSelectionOrigin("select"),27==e.keyCode&&(t.inputState.lastEscPress=Date.now())},yn.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},yn.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},bn.touchstart=bn.touchmove={passive:!0},yn.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return;let i=null;for(let n of t.state.facet(ni))if(i=n(t,e),i)break;if(i||0!=e.button||(i=function(t,e){let i=On(t,e),n=Rn(e),s=t.state.selection;return{update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),s=s.map(t.changes))},get(e,r,o){let h,l=On(t,e),a=Sn(t,l.pos,l.bias,n);if(i.pos!=l.pos&&!r){let e=Sn(t,i.pos,i.bias,n),s=Math.min(e.from,a.from),r=Math.max(e.to,a.to);a=s<a.from?N.range(s,r):N.range(r,s)}return r?s.replaceRange(s.main.extend(a.from,a.to)):o&&1==n&&s.ranges.length>1&&(h=function(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 N.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}(s,l.pos))?h:o?s.addRange(a):N.create([a])}}}(t,e)),i){let n=t.root.activeElement!=t.contentDOM;t.inputState.startMouseSelection(new wn(t,e,i,n)),n&&t.observer.ignore((()=>ne(t.contentDOM))),t.inputState.mouseSelection&&t.inputState.mouseSelection.start(e)}};let An=(t,e)=>t>=e.top&&t<=e.bottom,Mn=(t,e,i)=>An(e,i)&&t>=i.left&&t<=i.right;function Cn(t,e,i,n){let s=Xe.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&&Mn(i,n,o))return-1;let h=s.coordsAt(r,1);return h&&Mn(i,n,h)?1:o&&An(n,o)?-1:1}function On(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:Cn(t,i,e.clientX,e.clientY)}}const Tn=Me.ie&&Me.ie_version<=11;let Dn=null,En=0,Bn=0;function Rn(t){if(!Tn)return t.detail;let e=Dn,i=Bn;return Dn=t,Bn=Date.now(),En=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(En+1)%3:1}function Pn(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&&function(t,e){let i=t.state.facet(ii);return i.length?i[0](e):Me.mac?!e.altKey:!e.ctrlKey}(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"})}yn.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")},yn.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&&Pn(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 Pn(t,e,e.dataTransfer.getData("Text"),!0)},yn.paste=(t,e)=>{if(t.state.readOnly)return e.preventDefault();t.observer.flush();let i=xn?null:e.clipboardData;i?(kn(t,i.getData("text/plain")||i.getData("text/uri-text")),e.preventDefault()):function(t){let e=t.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout((()=>{t.focus(),i.remove(),kn(t,i.value)}),50)}(t)};let In=null;yn.copy=yn.cut=(t,e)=>{let{text:i,ranges:n,linewise:s}=function(t){let e=[],i=[],n=!1;for(let n of t.selection.ranges)n.empty||(e.push(t.sliceDoc(n.from,n.to)),i.push(n));if(!e.length){let s=-1;for(let{from:n}of t.selection.ranges){let r=t.doc.lineAt(n);r.number>s&&(e.push(r.text),i.push({from:r.from,to:Math.min(t.doc.length,r.to+1)})),s=r.number}n=!0}return{text:e.join(t.lineBreak),ranges:i,linewise:n}}(t.state);if(!i&&!s)return;In=s?i:null;let r=xn?null:e.clipboardData;r?(e.preventDefault(),r.clearData(),r.setData("text/plain",i)):function(t,e){let i=t.dom.parentNode;if(!i)return;let n=i.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout((()=>{n.remove(),t.focus()}),50)}(t,i),"cut"!=e.type||t.state.readOnly||t.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"})};const Nn=ut.define();function Ln(t,e){let i=[];for(let n of t.facet(hi)){let s=n(t,e);s&&i.push(s)}return i?t.update({effects:i,annotations:Nn.of(!0)}):null}function Vn(t){setTimeout((()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=Ln(t.state,e);i?t.dispatch(i):t.update([])}}),10)}yn.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),Vn(t)},yn.blur=t=>{t.observer.clearSelectionRange(),Vn(t)},yn.compositionstart=yn.compositionupdate=t=>{null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0)},yn.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,Me.chrome&&Me.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)},yn.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},yn.beforeinput=(t,e)=>{var i;let n;if(Me.chrome&&Me.android&&(n=dn.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 Hn=["pre-wrap","normal","pre-line","break-spaces"];class Wn{constructor(t){this.lineWrapping=t,this.doc=s.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 Hn.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=Hn.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 _n{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class zn{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?qe.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 Je?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 zn(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var Fn=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}(Fn||(Fn={}));const qn=.001;class jn{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)>qn&&(t.heightChanged=!0),this.height=e)}replace(t,e,i){return jn.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,Fn.ByPosNoHeight,i.setDoc(e),0,0),f=u.to>=l?u:s.lineAt(l,Fn.ByPosNoHeight,i,0,0);for(c+=f.to-l,l=f.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,Fn.ByPosNoHeight,i,0,0));a+=u.from-h,h=u.from;let d=Xn.build(i.setDoc(r),t,a,c);s=s.replace(h,l,d)}return s.updateHeight(i,0)}static empty(){return new $n(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 Un(jn.of(t.slice(0,e)),r,jn.of(t.slice(i)))}}jn.prototype.size=1;class Kn extends jn{constructor(t,e,i){super(t,e),this.deco=i}blockAt(t,e,i,n){return new zn(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 $n extends Kn{constructor(t,e){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(t,e,i,n){return new zn(n,this.length,i,this.height,this.breaks)}replace(t,e,i){let n=i[0];return 1==i.length&&(n instanceof $n||n instanceof Jn&&4&n.flags)&&Math.abs(this.length-n.length)<10?(n instanceof Jn?n=new $n(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):jn.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 Jn extends jn{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 zn(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 zn(h,l,i+o*n,o,0)}}lineAt(t,e,i,n,s){if(e==Fn.ByHeight)return this.blockAt(t,i,n,s);if(e==Fn.ByPosNoHeight){let{from:e,to:n}=i.doc.lineAt(t);return new zn(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 zn(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 zn(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 Jn?i[i.length-1]=new Jn(t.length+n):i.push(null,new Jn(n-1))}if(t>0){let e=i[0];e instanceof Jn?i[0]=new Jn(t+e.length):i.unshift(new Jn(t-1),null)}return jn.of(i)}decomposeLeft(t,e){e.push(new Jn(t-1),null)}decomposeRight(t,e){e.push(null,new Jn(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 Jn(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)>=qn&&(o=-2);let h=new $n(e,s);h.outdated=!1,i.push(h),r+=e+1}r<=s&&i.push(null,new Jn(s-r).updateHeight(t,r));let h=jn.of(i);return(o<0||Math.abs(h.height-this.height)>=qn||Math.abs(o-this.heightMetrics(t,e).perLine)>=qn)&&(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 Un extends jn{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==Fn.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==Fn.ByPosNoHeight?Fn.ByPosNoHeight:Fn.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,Fn.ByPos,i,n,s);t<l.from&&this.left.forEachLine(t,l.from-1,i,n,s,r),l.to>=t&&l.from<=e&&r(l),e>l.to&&this.right.forEachLine(l.to+1,e,i,o,h,r)}}replace(t,e,i){let n=this.left.length+this.break;if(e<n)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let s=[];t>0&&this.decomposeLeft(t,s);let r=s.length;for(let t of i)s.push(t);if(t>0&&Gn(s,r-1),e<this.length){let t=s.length;this.decomposeRight(e,s),Gn(s,t)}return jn.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?jn.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 Gn(t,e){let i,n;null==t[e]&&(i=t[e-1])instanceof Jn&&(n=t[e+1])instanceof Jn&&t.splice(e-1,3,new Jn(i.length+1+n.length))}class Xn{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 $n?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new $n(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 Kn(r,n,i)):(r||s||n>=5)&&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 $n(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new Jn(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 $n)return t;let e=new $n(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!=qe.WidgetAfter||this.isCovered||this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,i!=qe.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 $n||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new $n(0,-1));let i=t;for(let t of this.nodes)t instanceof $n&&t.updateHeight(this.oracle,i),i+=t?t.length:1;return this.nodes}static build(t,e,i,n){let s=new Xn(i,t);return Bt.spans(e,i,n,s,0),s.finish(i)}}class Yn{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,n){(t<e||i&&i.heightRelevant||n&&n.heightRelevant)&&Ge(t,e,this.changes,5)}}function Qn(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 e=t.parentNode;e&&e!=n.body;)if(1==e.nodeType){let i=e,n=window.getComputedStyle(i);if((i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)&&"visible"!=n.overflow){let n=i.getBoundingClientRect();r=Math.max(r,n.left),o=Math.min(o,n.right),h=Math.max(h,n.top),l=e==t.parentNode?n.bottom:Math.min(l,n.bottom)}e="absolute"==n.position||"fixed"==n.position?i.offsetParent:i.parentNode}else{if(11!=e.nodeType)break;e=e.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 Zn(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class ts{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 je.replace({widget:new es(this.size,t)}).range(this.from,this.to)}}class es extends Fe{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 is{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=hs,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Oi.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let e=t.facet(yi).some((t=>"function"!=typeof t&&"cm-lineWrapping"==t.class));this.heightOracle=new Wn(e),this.stateDeco=t.facet(bi).filter((t=>"function"!=typeof t)),this.heightMap=jn.empty().applyChanges(this.stateDeco,s.empty,this.heightOracle.setDoc(t.doc),[new Mi(0,0,0,t.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=je.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 ns(e,i))}}this.viewports=t.sort(((t,e)=>t.from-e.from)),this.scaler=this.heightMap.height<=7e6?hs:new ls(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:as(t,this.scaler))}))}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(bi).filter((t=>"function"!=typeof t));let n=t.changedRanges,s=Mi.extendWithRanges(n,function(t,e,i){let n=new Yn;return Bt.compare(t,e,i,n,0),n.changes}(i,this.stateDeco,t?t.changes:O.empty(this.state.doc.length))),r=this.heightMap.height,o=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!=r&&(t.flags|=2),o?(this.scrollAnchorPos=t.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let h=s.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<h.from||e.range.head>h.to)||!this.viewportIsAppropriate(h))&&(h=this.getViewport(0,e));let l=!t.changes.empty||2&t.flags||h.from!=this.viewport.from||h.to!=this.viewport.to;this.viewport=h,this.updateForViewport(),l&&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(ai)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),n=this.heightOracle,r=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?Oi.RTL:Oi.LTR;let o=this.heightOracle.mustRefreshForWrapping(r),h=e.getBoundingClientRect(),l=o||this.mustMeasureContent||this.contentDOMHeight!=h.height;this.contentDOMHeight=h.height,this.mustMeasureContent=!1;let a=0,c=0,u=parseInt(i.paddingTop)||0,f=parseInt(i.paddingBottom)||0;this.paddingTop==u&&this.paddingBottom==f||(this.paddingTop=u,this.paddingBottom=f,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 d=(this.printing?Zn:Qn)(e,this.paddingTop),p=d.top-this.pixelViewport.top,g=d.bottom-this.pixelViewport.bottom;this.pixelViewport=d;let m=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(m!=this.inView&&(this.inView=m,m&&(l=!0)),!this.inView&&!this.scrollTarget)return 0;let w=h.width;if(this.contentDOMWidth==w&&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(w-this.contentDOMWidth)>n.charWidth){let{lineHeight:i,charWidth:s,textHeight:h}=t.docView.measureTextSize();o=i>0&&n.refresh(r,i,s,h,w/s,e),o&&(t.docView.minWidth=0,a|=8)}p>0&&g>0?c=Math.max(p,g):p<0&&g<0&&(c=Math.min(p,g)),n.heightChanged=!1;for(let i of this.viewports){let r=i.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(i);this.heightMap=(o?jn.empty().applyChanges(this.stateDeco,s.empty,this.heightOracle,[new Mi(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(n,0,o,new _n(i.from,r))}n.heightChanged&&(a|=2)}let v=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return v&&(this.viewport=this.getViewport(c,this.scrollTarget)),this.updateForViewport(),(2&a||v)&&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 ns(n.lineAt(r-1e3*i,Fn.ByHeight,s,0,0).from,n.lineAt(o+1e3*(1-i),Fn.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,Fn.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 ns(n.lineAt(i-500,Fn.ByHeight,s,0,0).from,n.lineAt(i+r+500,Fn.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 ns(this.heightMap.lineAt(i,Fn.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,Fn.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,Fn.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(e,Fn.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 ts(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,r=n<<1;if(this.defaultTextDirection!=Oi.LTR&&!i)return[];let o=[],h=(n,r,l,a)=>{if(r-n<s)return;let c=this.state.selection.main,u=[c.from];c.empty||u.push(c.to);for(let t of u)if(t>n&&t<r)return h(n,t-10,l,a),void h(t+10,r,l,a);let f=function(t,e){for(let i of t)if(e(i))return i;return}(t,(t=>t.from>=l.from&&t.to<=l.to&&Math.abs(t.from-n)<s&&Math.abs(t.to-r)<s&&!u.some((e=>t.from<e&&t.to>e))));if(!f){if(r<l.to&&e&&i&&e.visibleRanges.some((t=>t.from<=r&&t.to>=r))){let t=e.moveToLineBoundary(N.cursor(r),!1,!0).head;t>n&&(r=t)}f=new ts(n,r,this.gapSize(l,n,r,a))}o.push(f)};for(let t of this.viewportLines){if(t.length<r)continue;let e=ss(t.from,t.to,this.stateDeco);if(e.total<r)continue;let s,o,l=this.scrollTarget?this.scrollTarget.range.head:null;if(i){let i,r,h=n/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=l){let n=os(e,l),s=((this.visibleBottom-this.visibleTop)/2+h)/t.height;i=n-s,r=n+s}else i=(this.visibleTop-t.top-h)/t.height,r=(this.visibleBottom-t.top+h)/t.height;s=rs(e,i),o=rs(e,r)}else{let t,i,r=e.total*this.heightOracle.charWidth,h=n*this.heightOracle.charWidth;if(null!=l){let n=os(e,l),s=((this.pixelViewport.right-this.pixelViewport.left)/2+h)/r;t=n-s,i=n+s}else t=(this.pixelViewport.left-h)/r,i=(this.pixelViewport.right+h)/r;s=rs(e,t),o=rs(e,i)}s>t.from&&h(t.from,s,t,e),o<t.to&&h(o,t.to,t,e)}return o}gapSize(t,e,i,n){let s=os(n,i)-os(n,e);return this.heightOracle.lineWrapping?t.height*s:n.total*this.heightOracle.charWidth*s}updateLineGaps(t){ts.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=je.set(t.map((t=>t.draw(this.heightOracle.lineWrapping)))))}computeVisibleRanges(){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let e=[];Bt.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))||as(this.heightMap.lineAt(t,Fn.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return as(this.heightMap.lineAt(this.scaler.fromDOM(t),Fn.ByHeight,this.heightOracle,0,0),this.scaler)}elementAtHeight(t){return as(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 ns{constructor(t,e){this.from=t,this.to=e}}function ss(t,e,i){let n=[],s=t,r=0;return Bt.spans(i,t,e,{span(){},point(t,e){t>s&&(n.push({from:s,to:t}),r+=t-s),s=e}},20),s<e&&(n.push({from:s,to:e}),r+=e-s),{total:r,ranges:n}}function rs({total:t,ranges:e},i){if(i<=0)return e[0].from;if(i>=1)return e[e.length-1].to;let n=Math.floor(t*i);for(let t=0;;t++){let{from:i,to:s}=e[t],r=s-i;if(n<=r)return i+n;n-=r}}function os(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}const hs={toDOM:t=>t,fromDOM:t=>t,scale:1};class ls{constructor(t,e,i){let n=0,s=0,r=0;this.viewports=i.map((({from:i,to:s})=>{let r=e.lineAt(i,Fn.ByPos,t,0,0).top,o=e.lineAt(s,Fn.ByPos,t,0,0).bottom;return n+=o-r,{from:i,to:s,top:r,bottom:o,domTop:0,domBottom:0}})),this.scale=(7e6-n)/(e.height-n);for(let t of this.viewports)t.domTop=r+(t.top-s)*this.scale,r=t.domBottom=t.domTop+(t.bottom-t.top),s=t.bottom}toDOM(t){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 as(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),n=e.toDOM(t.bottom);return new zn(t.from,t.length,i,n-i,Array.isArray(t._content)?t._content.map((t=>as(t,e))):t._content)}const cs=H.define({combine:t=>t.join(" ")}),us=H.define({combine:t=>t.indexOf(!0)>-1}),fs=qt.V.newName(),ds=qt.V.newName(),ps=qt.V.newName(),gs={"&light":"."+ds,"&dark":"."+ps};function ms(t,e,i){return new qt.V(e,{finish:e=>/&/.test(e)?e.replace(/&\w*/,(e=>{if("&"==e)return t;if(!i||!i[e])throw new RangeError(`Unsupported selector: ${e}`);return i[e]})):t+" "+e})}const ws=ms("."+fs,{"&":{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"}},gs);class vs{constructor(t,e,i,n){this.typeOver=n,this.bounds=null,this.text="";let{impreciseHead:s,impreciseAnchor:r}=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||r?[]:function(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:n,focusNode:s,focusOffset:r}=t.observer.selectionRange;i&&(e.push(new Ki(i,n)),s==i&&r==n||e.push(new Ki(s,r)));return e}(t),i=new qi(e,t.state);i.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=i.text,this.newSel=function(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?N.single(i+e,n+e):null}(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=s&&s.node==e.focusNode&&s.offset==e.focusOffset||!Kt(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),n=r&&r.node==e.anchorNode&&r.offset==e.anchorOffset||!Kt(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset);this.newSel=N.single(n,i)}}}function ys(t,e){let i,{newSel:n}=e,r=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=r.from,a=null;(8===o||Me.android&&e.text.length<h-n)&&(l=r.to,a="end");let c=function(t,e,i,n){let s=Math.min(t.length,e.length),r=0;for(;r<s&&t.charCodeAt(r)==e.charCodeAt(r);)r++;if(r==s&&t.length==e.length)return null;let o=t.length,h=e.length;for(;o>0&&h>0&&t.charCodeAt(o-1)==e.charCodeAt(h-1);)o--,h--;if("end"==n){i-=o+Math.max(0,r-Math.min(o,h))-r}if(o<r&&t.length<e.length){r-=i<=r&&i>=o?r-i:0,h=r+(h-o),o=r}else if(h<r){r-=i<=r&&i>=h?r-i:0,o=r+(o-h),h=r}return{from:r,toA:o,toB:h}}(t.state.doc.sliceString(n,h,Fi),e.text,l-n,a);c&&(Me.chrome&&13==o&&c.toB==c.from+2&&e.text.slice(c.from,c.toB)==Fi+Fi&&c.toB--,i={from:n+c.from,to:n+c.toA,insert:s.of(e.text.slice(c.from,c.toB).split(Fi))})}else n&&(!t.hasFocus&&t.state.facet(di)||n.main.eq(r))&&(n=null);if(!i&&!n)return!1;if(!i&&e.typeOver&&!r.empty&&n&&n.main.empty?i={from:r.from,to:r.to,insert:t.state.doc.slice(r.from,r.to)}:i&&i.from>=r.from&&i.to<=r.to&&(i.from!=r.from||i.to!=r.to)&&r.to-r.from-(i.to-i.from)<=4?i={from:r.from,to:r.to,insert:t.state.doc.slice(r.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,r.to))}:(Me.mac||Me.android)&&i&&i.from==i.to&&i.from==r.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(n&&2==i.insert.length&&(n=N.single(n.main.anchor-1,n.main.head-1)),i={from:r.from,to:r.to,insert:s.of([" "])}):Me.chrome&&i&&i.from==i.to&&i.from==r.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(n&&(n=N.single(n.main.anchor-1,n.main.head-1)),i={from:r.from,to:r.to,insert:s.of([" "])}),i){let e=t.state;if(Me.ios&&t.inputState.flushIOSKey(t))return!0;if(Me.android&&(i.from==r.from&&i.to==r.to&&1==i.insert.length&&2==i.insert.lines&&re(t.contentDOM,"Enter",13)||(i.from==r.from-1&&i.to==r.to&&0==i.insert.length||8==o&&i.insert.length<i.to-i.from)&&re(t.contentDOM,"Backspace",8)||i.from==r.from&&i.to==r.to+1&&0==i.insert.length&&re(t.contentDOM,"Delete",46)))return!0;let s,h=i.insert.toString();if(t.state.facet(oi).some((e=>e(t,i.from,i.to,h))))return!0;if(t.inputState.composing>=0&&t.inputState.composing++,i.from>=r.from&&i.to<=r.to&&i.to-i.from>=(r.to-r.from)/3&&(!n||n.main.empty&&n.main.from==i.from+i.insert.length)&&t.inputState.composing<0){let n=r.from<i.from?e.sliceDoc(r.from,i.from):"",o=r.to>i.to?e.sliceDoc(i.to,r.to):"";s=e.replaceSelection(t.state.toText(n+i.insert.sliceString(0,void 0,t.state.lineBreak)+o))}else{let o=e.changes(i),h=n&&n.main.to<=o.newLength?n.main:void 0;if(e.selection.ranges.length>1&&t.inputState.composing>=0&&i.to<=r.to&&i.to>=r.to-10){let n=t.state.sliceDoc(i.from,i.to),l=Ui(t)||t.state.doc.lineAt(r.head),a=r.to-i.to,c=r.to-r.from;s=e.changeByRange((s=>{if(s.from==r.from&&s.to==r.to)return{changes:o,range:h||s.map(o)};let u=s.to-a,f=u-n.length;if(s.to-s.from!=c||t.state.sliceDoc(f,u)!=n||l&&s.to>=l.from&&s.from<=l.to)return{range:s};let d=e.changes({from:f,to:u,insert:i.insert}),p=s.to-r.to;return{changes:d,range:h?N.range(Math.max(0,h.anchor+p),Math.max(0,h.head+p)):s.map(d)}}))}else s={changes:o,selection:h&&e.selection.replaceRange(h)}}let l="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,l+=".compose",t.inputState.compositionFirstChange&&(l+=".start",t.inputState.compositionFirstChange=!1)),t.dispatch(s,{scrollIntoView:!0,userEvent:l}),!0}if(n&&!n.main.eq(r)){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}const bs={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},xs=Me.ie&&Me.ie_version<=11;class ks{constructor(t){this.view=t,this.active=!1,this.selectionRange=new te,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);(Me.ie&&Me.ie_version<=11||Me.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()})),xs&&(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(di)?i.root.activeElement!=this.dom:!$t(i.dom,n))return;let s=n.anchorNode&&i.docView.nearest(n.anchorNode);s&&s.ignoreEvent(t)?e||(this.selectionChanged=!1):(Me.ie&&Me.ie_version<=11||Me.android&&Me.chrome)&&!i.state.selection.main.empty&&n.focusNode&&Ut(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=Me.safari&&11==t.root.nodeType&&function(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}(this.dom.ownerDocument)==this.dom&&function(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);Ut(h.node,h.offset,r,o)&&([n,s,r,o]=[r,o,n,s]);return{anchorNode:n,anchorOffset:s,focusNode:r,focusOffset:o}}(this.view)||jt(t.root);if(!e||this.selectionRange.eq(e))return!1;let i=$t(this.dom,e);return i&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&function(t,e){let i=e.focusNode,n=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=n)return!1;for(n=Math.min(n,Yt(i));;)if(n){if(1!=i.nodeType)return!1;let t=i.childNodes[n-1];"false"==t.contentEditable?n--:(i=t,n=Yt(i))}else{if(i==t)return!0;n=Gt(i),i=i.parentNode}}(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,bs),xs&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),xs&&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&&re(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&&$t(this.dom,this.selectionRange);return t<0&&!n?null:(t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1,new vs(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=ys(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=Ss(e,t.previousSibling||t.target.previousSibling,-1),n=Ss(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 t of this.scrollTargets)t.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 Ss(t,e,i){for(;e;){let n=ae.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}class As{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||function(t){for(;t;){if(t&&(9==t.nodeType||11==t.nodeType&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}(t.parent)||document,this.viewState=new is(t.state||Ct.create(t)),this.plugins=this.state.facet(gi).map((t=>new wi(t)));for(let t of this.plugins)t.update(this);this.observer=new ks(this),this.inputState=new fn(this),this.inputState.ensureHandlers(this,this.plugins),this.docView=new $i(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 gt?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 e of t){if(e.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=e.state}if(this.destroyed)return void(this.viewState.state=s);let r=this.hasFocus,o=0,h=null;t.some((t=>t.annotation(Nn)))?(this.inputState.notifiedFocused=r,o=1):r!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=r,h=Ln(s,r),h||(o=1));let l=this.observer.delayedAndroidKey,a=null;if(l?(this.observer.clearDelayedAndroidKey(),a=this.observer.readChange(),(a&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(a=null)):this.observer.clear(),s.facet(Ct.phrases)!=this.state.facet(Ct.phrases))return this.setState(s);e=Ci.create(this,s,t),e.flags|=o;let c=this.viewState.scrollTarget;try{this.updateState=2;for(let e of t){if(c&&(c=c.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection;c=new ci(t.empty?t:N.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(ui)&&(c=t.value)}this.viewState.update(e,c),this.bidiCache=Os.update(this.bidiCache,e.changes),e.empty||(this.updatePlugins(e),this.inputState.update(e)),i=this.docView.update(e),this.state.facet(Ai)!=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(cs)!=e.state.facet(cs)&&(this.viewState.mustMeasureContent=!0),(i||n||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!e.empty)for(let t of this.state.facet(ri))t(e);(h||a)&&Promise.resolve().then((()=>{h&&this.state==h.startState&&this.dispatch(h),a&&!ys(this,a)&&l.force&&re(this.contentDOM,l.key,l.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 is(t),this.plugins=t.facet(gi).map((t=>new wi(t))),this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView=new $i(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(gi),i=t.state.facet(gi);if(e!=i){let n=[];for(let s of i){let i=e.indexOf(s);if(i<0)n.push(new wi(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 e of this.plugins)e.mustUpdate=t;for(let t=0;t<this.plugins.length;t++)this.plugins[t].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 o=this.viewport,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(t){return fi(this.state,t),Cs}})),c=Ci.create(this,this.state,[]),u=!1,f=!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]!=Cs)try{let e=l[t];e.write&&e.write(a[t],this)}catch(t){fi(this.state,t)}if(this.viewState.editorHeight)if(this.viewState.scrollTarget)this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,f=!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,f=!0)}if(u&&this.docView.updateSelection(!0),this.viewport.from==o.from&&this.viewport.to==o.to&&!f&&0==this.measureRequests.length)break;r=-1}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let t of this.state.facet(ri))t(e)}get themeClasses(){return fs+" "+(this.state.facet(us)?ps:ds)+" "+this.state.facet(cs)}updateAttrs(){let t=Ts(this,vi,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(di)?"true":"false",class:"cm-content",style:`${Me.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),Ts(this,yi,e);let i=this.observer.ignore((()=>{let i=ze(this.contentDOM,this.contentAttrs,e),n=ze(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(As.announce)){e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(Ai),qt.V.mount(this.root,this.styleModules.concat(ws).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 un(this,t,an(this,t,e,i))}moveByGroup(t,e){return un(this,t,an(this,t,e,(e=>function(t,e,i){let n=t.state.charCategorizer(e),s=n(i);return t=>{let e=n(t);return s==kt.Space&&(s=e),s==e}}(this,t.head,e))))}moveToLineBoundary(t,e,i=!0){return function(t,e,i,n){let s=ln(t,e.head),r=n&&s.type==qe.Text&&(t.lineWrapping||s.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head):null;if(r){let e=t.dom.getBoundingClientRect(),n=t.textDirectionAt(s.from),o=t.posAtCoords({x:i==(n==Oi.LTR)?e.right-1:e.left+1,y:(r.top+r.bottom)/2});if(null!=o)return N.cursor(o,i?-1:1)}return N.cursor(i?s.to:s.from,i?-1:1)}(this,t,e,i)}moveVertically(t,e,i){return un(this,t,function(t,e,i,n){let s=e.head,r=i?1:-1;if(s==(i?t.state.doc.length:0))return N.cursor(s,e.assoc);let o,h=e.goalColumn,l=t.contentDOM.getBoundingClientRect(),a=t.coordsAtPos(s),c=t.documentTop;if(a)null==h&&(h=a.left-l.left),o=r<0?a.top:a.bottom;else{let e=t.viewState.lineBlockAt(s);null==h&&(h=Math.min(l.right-l.left,t.defaultCharacterWidth*(s-e.from))),o=(r<0?e.top:e.bottom)+c}let u=l.left+h,f=null!=n?n:t.viewState.heightOracle.textHeight>>1;for(let i=0;;i+=10){let n=o+(f+i)*r,a=on(t,{x:u,y:n},!1,r);if(n<l.top||n>l.bottom||(r<0?a<s:a>s))return N.cursor(a,e.assoc,void 0,h)}}(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(),on(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 Qt(i,s[Li.find(s,t-n.from,-1,e)].dir==Oi.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(li)||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>Ms)return Wi(t.length);let e=this.textDirectionAt(t.from);for(let i of this.bidiCache)if(i.from==t.from&&i.dir==e)return i.order;let i=Hi(t.text,e);return this.bidiCache.push(new Os(t.from,t.to,e,i)),i}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||Me.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{ne(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 ui.of(new ci("number"==typeof t?N.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}static domEventHandlers(t){return mi.define((()=>({})),{eventHandlers:t})}static theme(t,e){let i=qt.V.newName(),n=[cs.of(i),Ai.of(ms(`.${i}`,t))];return e&&e.dark&&n.push(us.of(!0)),n}static baseTheme(t){return Y.lowest(Ai.of(ms("."+fs,t,gs)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),n=i&&ae.get(i)||ae.get(t);return(null===(e=null==n?void 0:n.rootView)||void 0===e?void 0:e.view)||null}}As.styleModule=Ai,As.inputHandler=oi,As.focusChangeEffect=hi,As.perLineTextDirection=li,As.exceptionSink=si,As.updateListener=ri,As.editable=di,As.mouseSelectionStyle=ni,As.dragMovesSelection=ii,As.clickAddsSelectionRange=ei,As.decorations=bi,As.atomicRanges=xi,As.scrollMargins=ki,As.darkTheme=us,As.contentAttributes=yi,As.editorAttributes=vi,As.lineWrapping=As.contentAttributes.of({class:"cm-lineWrapping"}),As.announce=pt.define();const Ms=4096,Cs={};class Os{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:Oi.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 Os(e.mapPos(r.from,1),e.mapPos(r.to,-1),r.dir,r.order))}return i}}function Ts(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&&We(r,i)}return i}Me.mac||Me.windows||Me.linux;const Ds=!Me.ios;const Es={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};Ds&&(Es[".cm-line"].caretColor="transparent !important");class Bs extends Ot{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Bs.prototype.elementClass="",Bs.prototype.toDOM=void 0,Bs.prototype.mapMode=M.TrackBefore,Bs.prototype.startSide=Bs.prototype.endSide=-1,Bs.prototype.point=!0;const Rs=1024;let Ps=0;class Is{constructor(t,e){this.from=t,this.to=e}}class Ns{constructor(t={}){this.id=Ps++,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=Vs.match(t)),e=>{let i=t(e);return void 0===i?null:[this,i]}}}Ns.closedBy=new Ns({deserialize:t=>t.split(" ")}),Ns.openedBy=new Ns({deserialize:t=>t.split(" ")}),Ns.group=new Ns({deserialize:t=>t.split(" ")}),Ns.contextHash=new Ns({perNode:!0}),Ns.lookAhead=new Ns({perNode:!0}),Ns.mounted=new Ns({perNode:!0});const Ls=Object.create(null);class Vs{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):Ls,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=new Vs(t.name||"",e,t.id,i);if(t.props)for(let i of t.props)if(Array.isArray(i)||(i=i(n)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[i[0].id]=i[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(Ns.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(Ns.group),n=-1;n<(i?i.length:0);n++){let s=e[n<0?t.name:i[n]];if(s)return s}}}}Vs.none=new Vs("",Object.create(null),0,8);const Hs=new WeakMap,Ws=new WeakMap;var _s;!function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"}(_s||(_s={}));class zs{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(Ns.mounted);if(t&&!t.overlay)return t.tree.toString();let e="";for(let t of this.children){let i=t.toString();i&&(e&&(e+=","),e+=i)}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 Qs(this.topNode,t)}cursorAt(t,e=0,i=0){let n=Hs.get(this)||this.topNode,s=new Qs(n);return s.moveTo(t,e),Hs.set(this,s._tree),s}get topNode(){return new Js(this,0,0,null)}resolve(t,e=0){let i=$s(Hs.get(this)||this.topNode,t,e,!1);return Hs.set(this,i),i}resolveInner(t,e=0){let i=$s(Ws.get(this)||this.topNode,t,e,!0);return Ws.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&_s.IncludeAnonymous)>0;for(let t=this.cursor(r|_s.IncludeAnonymous);;){let r=!1;if(t.from<=s&&t.to>=n&&(!o&&t.type.isAnonymous||!1!==e(t))){if(t.firstChild())continue;r=!0}for(;r&&i&&(o||!t.type.isAnonymous)&&i(t),!t.nextSibling();){if(!t.parent())return;r=!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:ir(Vs.none,this.children,this.positions,0,this.children.length,0,this.length,((t,e,i)=>new zs(this.type,t,e,i,this.propValues)),t.makeTree||((t,e,i)=>new zs(Vs.none,t,e,i)))}static build(t){return function(t){var e;let{buffer:i,nodeSet:n,maxBufferLength:s=Rs,reused:r=[],minRepeatType:o=n.types.length}=t,h=Array.isArray(i)?new Fs(i,i.length):i,l=n.types,a=0,c=0;function u(t,e,i,w,v){let{id:y,start:b,end:x,size:k}=h,S=c;for(;k<0;){if(h.next(),-1==k){let e=r[y];return i.push(e),void w.push(b-t)}if(-3==k)return void(a=y);if(-4==k)return void(c=y);throw new RangeError(`Unrecognized record size: ${k}`)}let A,M,C=l[y],O=b-t;if(x-b<=s&&(M=g(h.pos-e,v))){let e=new Uint16Array(M.size-M.skip),i=h.pos-M.size,s=e.length;for(;h.pos>i;)s=m(M.start,e,s);A=new qs(e,x-M.start,n),O=M.start-t}else{let t=h.pos-k;h.next();let e=[],i=[],n=y>=o?y:-1,r=0,l=x;for(;h.pos>t;)n>=0&&h.id==n&&h.size>=0?(h.end<=l-s&&(d(e,i,b,r,h.end,l,n,S),r=e.length,l=h.end),h.next()):u(b,t,e,i,n);if(n>=0&&r>0&&r<e.length&&d(e,i,b,r,b,l,n,S),e.reverse(),i.reverse(),n>-1&&r>0){let t=f(C);A=ir(C,e,i,0,e.length,0,x-b,t,t)}else A=p(C,e,i,x-b,S-x)}i.push(A),w.push(O)}function f(t){return(e,i,n)=>{let s,r,o=0,h=e.length-1;if(h>=0&&(s=e[h])instanceof zs){if(!h&&s.type==t&&s.length==n)return s;(r=s.prop(Ns.lookAhead))&&(o=i[h]+s.length+r)}return p(t,e,i,n,o)}}function d(t,e,i,s,r,o,h,l){let a=[],c=[];for(;t.length>s;)a.push(t.pop()),c.push(e.pop()+i-r);t.push(p(n.types[h],a,c,o-r,l-o)),e.push(r-i)}function p(t,e,i,n,s=0,r){if(a){let t=[Ns.contextHash,a];r=r?[t].concat(r):[t]}if(s>25){let t=[Ns.lookAhead,s];r=r?[t].concat(r):[t]}return new zs(t,e,i,n,r)}function g(t,e){let i=h.fork(),n=0,r=0,l=0,a=i.end-s,c={size:0,start:0,skip:0};t:for(let s=i.pos-t;i.pos>s;){let t=i.size;if(i.id==e&&t>=0){c.size=n,c.start=r,c.skip=l,l+=4,n+=4,i.next();continue}let h=i.pos-t;if(t<0||h<s||i.start<a)break;let u=i.id>=o?4:0,f=i.start;for(i.next();i.pos>h;){if(i.size<0){if(-3!=i.size)break t;u+=4}else i.id>=o&&(u+=4);i.next()}r=f,n+=t,l+=u}return(e<0||n==t)&&(c.size=n,c.start=r,c.skip=l),c.size>4?c:void 0}function m(t,e,i){let{id:n,start:s,end:r,size:l}=h;if(h.next(),l>=0&&n<o){let o=i;if(l>4){let n=h.pos-(l-4);for(;h.pos>n;)i=m(t,e,i)}e[--i]=o,e[--i]=r-t,e[--i]=s-t,e[--i]=n}else-3==l?a=n:-4==l&&(c=n);return i}let w=[],v=[];for(;h.pos>0;)u(t.start||0,t.bufferStart||0,w,v,-1);let y=null!==(e=t.length)&&void 0!==e?e:w.length?v[0]+w[0].length:0;return new zs(l[t.topID],w.reverse(),v.reverse(),y)}(t)}}zs.empty=new zs(Vs.none,[],[],0);class Fs{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 Fs(this.buffer,this.index)}}class qs{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return Vs.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&&!(js(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 qs(s,r,this.set)}}function js(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 Ks(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 $s(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 Js&&t.index<0?null:t.parent;if(!e)return t;t=e}let r=n?0:_s.IgnoreOverlays;if(n)for(let n=t,o=n.parent;o;n=o,o=n.parent)n instanceof Js&&n.index<0&&(null===(s=o.enter(e,i,r))||void 0===s?void 0:s.from)!=n.from&&(t=o);for(;;){let n=t.enter(e,i,r);if(!n)return t;t=n}}class Js{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:o,positions:h}=r._tree,l=e>0?o.length:-1;t!=l;t+=e){let l=o[t],a=h[t]+r.from;if(js(n,i,a,a+l.length))if(l instanceof qs){if(s&_s.ExcludeBuffers)continue;let o=l.findChild(0,l.buffer.length,e,i-a,n);if(o>-1)return new Ys(new Xs(r,l,t,a),null,o)}else if(s&_s.IncludeAnonymous||!l.type.isAnonymous||Zs(l)){let o;if(!(s&_s.IgnoreMounts)&&l.props&&(o=l.prop(Ns.mounted))&&!o.overlay)return new Js(o.tree,a,t,r);let h=new Js(l,a,t,r);return s&_s.IncludeAnonymous||!h.type.isAnonymous?h:h.nextChild(e<0?l.children.length-1:0,e,i,n)}}if(s&_s.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&_s.IgnoreOverlays)&&(n=this._tree.prop(Ns.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 Js(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 Qs(this,t)}get tree(){return this._tree}toTree(){return this._tree}resolve(t,e=0){return $s(this,t,e,!1)}resolveInner(t,e=0){return $s(this,t,e,!0)}enterUnfinishedNodesBefore(t){return Ks(this,t)}getChild(t,e=null,i=null){let n=Us(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return Us(this,t,e,i)}toString(){return this._tree.toString()}get node(){return this}matchContext(t){return Gs(this,t)}}function Us(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 Gs(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 Xs{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}}class Ys{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 Ys(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&_s.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 Ys(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 Ys(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 Ys(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}cursor(t=0){return new Qs(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 zs(this.type,t,e,this.to-this.from)}resolve(t,e=0){return $s(this,t,e,!1)}resolveInner(t,e=0){return $s(this,t,e,!0)}enterUnfinishedNodesBefore(t){return Ks(this,t)}toString(){return this.context.buffer.childString(this.index)}getChild(t,e=null,i=null){let n=Us(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return Us(this,t,e,i)}get node(){return this}matchContext(t){return Gs(this,t)}}class Qs{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 Js)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 Js?(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&_s.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&_s.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&_s.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&_s.IncludeAnonymous||t instanceof qs||!t.type.isAnonymous||Zs(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 t=i;t<this.stack.length;t++)e=new Ys(this.buffer,e,this.stack[t]);return this.bufferNode=new Ys(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 Gs(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 Gs(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 Zs(t){return t.children.some((t=>t instanceof qs||!t.type.isAnonymous||Zs(t)))}const tr=new WeakMap;function er(t,e){if(!t.isAnonymous||e instanceof qs||e.type!=t)return 1;let i=tr.get(e);if(null==i){i=1;for(let n of e.children){if(n.type!=t||!(n instanceof zs)){i=1;break}i+=er(t,n)}tr.set(e,i)}return i}function ir(t,e,i,n,s,r,o,h,l){let a=0;for(let i=n;i<s;i++)a+=er(t,e[i]);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],p=er(t,i[a]);for(a++;a<o;a++){let e=er(t,i[a]);if(p+e>=c)break;p+=e}if(a==s+1){if(p>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(ir(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 nr{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 nr(0,t.length,t,0,!1,i)];for(let i of e)i.to>t.length&&n.push(i);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 nr(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 sr{startParse(t,e,i){return"string"==typeof t&&(t=new rr(t)),i=i?i.length?i.map((t=>new Is(t.from,t.to))):[new Is(0,0)]:[new Is(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 rr{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 Ns({perNode:!0});class or{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),lr.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),lr.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 ur(this),s=new ur(t);for(let t=e,r=e;;){if(n.next(t),s.next(t),t=0,n.lineBreak!=s.lineBreak||n.done!=s.done||n.value!=s.value)return!1;if(r+=n.value.length,n.done||r>=i)return!0}}iter(t=1){return new ur(this,t)}iterRange(t,e=this.length){return new fr(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 dr(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 hr(t):lr.from(hr.split(t,[])):or.empty}}class hr extends or{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 pr(n,o,i,r);n=o+1,i++}}decompose(t,e,i,n){let s=t<=0&&e>=this.length?this:new hr(cr(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&n){let t=i.pop(),e=ar(s.text,t.text.slice(),0,s.length);if(e.length<=32)i.push(new hr(e,t.length+s.length));else{let t=e.length>>1;i.push(new hr(e.slice(0,t)),new hr(e.slice(t)))}}else i.push(s)}replace(t,e,i){if(!(i instanceof hr))return super.replace(t,e,i);let n=ar(this.text,ar(i.text,cr(this.text,0,t)),e),s=this.length+i.length-(e-t);return n.length<=32?new hr(n,s):lr.from(hr.split(n,[]),s)}sliceString(t,e=this.length,i="\n"){let n="";for(let s=0,r=0;s<=e&&r<this.text.length;r++){let o=this.text[r],h=s+o.length;s>t&&r&&(n+=i),t<h&&e>s&&(n+=o.slice(Math.max(0,t-s),e-s)),s=h+1}return n}flatten(t){for(let e of this.text)t.push(e)}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 hr(i,n)),i=[],n=-1);return n>-1&&e.push(new hr(i,n)),e}}class lr extends or{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let e of t)this.lines+=e.lines}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.children[s],o=n+r.length,h=i+r.lines-1;if((e?h:o)>=t)return r.lineInner(t,e,i,n);n=o+1,i=h+1}}decompose(t,e,i,n){for(let s=0,r=0;r<=e&&s<this.children.length;s++){let o=this.children[s],h=r+o.length;if(t<=h&&e>=r){let s=n&((r<=t?1:0)|(h>=e?2:0));r>=t&&h<=e&&!s?i.push(o):o.decompose(t-r,e-r,i,s)}r=h+1}}replace(t,e,i){if(i.lines<this.lines)for(let n=0,s=0;n<this.children.length;n++){let r=this.children[n],o=s+r.length;if(t>=s&&e<=o){let h=r.replace(t-s,e-s,i),l=this.lines-r.lines+h.lines;if(h.lines<l>>4&&h.lines>l>>6){let s=this.children.slice();return s[n]=h,new lr(s,this.length-(e-t)+i.length)}return super.replace(s,o,h)}s=o+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i="\n"){let n="";for(let s=0,r=0;s<this.children.length&&r<=e;s++){let o=this.children[s],h=r+o.length;r>t&&s&&(n+=i),t<h&&e>r&&(n+=o.sliceString(t-r,e-r,i)),r=h+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof lr))return 0;let i=0,[n,s,r,o]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;n+=e,s+=e){if(n==r||s==o)return i;let h=this.children[n],l=t.children[s];if(h!=l)return i+h.scanIdentical(l,e);i+=h.length+1}}static from(t,e=t.reduce(((t,e)=>t+e.length+1),-1)){let i=0;for(let e of t)i+=e.lines;if(i<32){let i=[];for(let e of t)e.flatten(i);return new hr(i,e)}let n=Math.max(32,i>>5),s=n<<1,r=n>>1,o=[],h=0,l=-1,a=[];function c(t){let e;if(t.lines>s&&t instanceof lr)for(let e of t.children)c(e);else t.lines>r&&(h>r||!h)?(u(),o.push(t)):t instanceof hr&&h&&(e=a[a.length-1])instanceof hr&&t.lines+e.lines<=32?(h+=t.lines,l+=t.length+1,a[a.length-1]=new hr(e.text.concat(t.text),e.length+1+t.length)):(h+t.lines>n&&u(),h+=t.lines,l+=t.length+1,a.push(t))}function u(){0!=h&&(o.push(1==a.length?a[0]:lr.from(a,l)),l=-1,h=a.length=0)}for(let e of t)c(e);return u(),1==o.length?o[0]:new lr(o,e)}}function ar(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 cr(t,e,i){return ar(t,[""],e,i)}or.empty=new hr([""],0);class ur{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 hr?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],s=this.offsets[i],r=s>>1,o=n instanceof hr?n.text.length:n.children.length;if(r==(e>0?o:0)){if(0==i)return this.done=!0,this.value="",this;e>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&s)==(e>0?0:1)){if(this.offsets[i]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(n instanceof hr){let s=n.text[r+(e<0?-1:0)];if(this.offsets[i]+=e,s.length>Math.max(0,t))return this.value=0==t?s:e>0?s.slice(t):s.slice(0,s.length-t),this;t-=s.length}else{let s=n.children[r+(e<0?-1:0)];t>s.length?(t-=s.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(s),this.offsets.push(e>0?1:(s instanceof hr?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 fr{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new ur(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 dr{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&&(or.prototype[Symbol.iterator]=function(){return this.iter()},ur.prototype[Symbol.iterator]=fr.prototype[Symbol.iterator]=dr.prototype[Symbol.iterator]=function(){return this});class pr{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 gr="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<gr.length;t++)gr[t]+=gr[t-1];function mr(t){for(let e=1;e<gr.length;e+=2)if(gr[e]>t)return gr[e-1]<=t;return!1}function wr(t){return t>=127462&&t<=127487}const vr=8205;function yr(t,e,i=!0,n=!0){return(i?br:xr)(t,e,n)}function br(t,e,i){if(e==t.length)return e;e&&kr(t.charCodeAt(e))&&Sr(t.charCodeAt(e-1))&&e--;let n=Ar(t,e);for(e+=Mr(n);e<t.length;){let s=Ar(t,e);if(n==vr||s==vr||i&&mr(s))e+=Mr(s),n=s;else{if(!wr(s))break;{let i=0,n=e-2;for(;n>=0&&wr(Ar(t,n));)i++,n-=2;if(i%2==0)break;e+=2}}}return e}function xr(t,e,i){for(;e>0;){let n=br(t,e-2,i);if(n<e)return n;e--}return 0}function kr(t){return t>=56320&&t<57344}function Sr(t){return t>=55296&&t<56320}function Ar(t,e){let i=t.charCodeAt(e);if(!Sr(i)||e+1==t.length)return i;let n=t.charCodeAt(e+1);return kr(n)?n-56320+(i-55296<<10)+65536:i}function Mr(t){return t<65536?1:2}const Cr=/\r\n?|\n/;var Or=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(Or||(Or={}));class Tr{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){Rr(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 Tr(t)}composeDesc(t){return this.empty?t:t.empty?this:Ir(this,t)}mapDesc(t,e=!1){return t.empty?this:Pr(this,t,e)}mapPos(t,e=-1,i=Or.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!=Or.Simple&&l>=t&&(i==Or.TrackDel&&n<t&&l>t||i==Or.TrackBefore&&n<t||i==Or.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 Tr(t)}static create(t){return new Tr(t)}}class Dr extends Tr{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 Rr(this,((e,i,n,s,r)=>t=t.replace(n,n+(i-e),r)),!1),t}mapDesc(t,e=!1){return Pr(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let n=0,s=0;n<e.length;n+=2){let r=e[n],o=e[n+1];if(o>=0){e[n]=o,e[n+1]=r;let h=n>>1;for(;i.length<h;)i.push(or.empty);i.push(r?t.slice(s,s+r):or.empty)}s+=r}return new Dr(e,i)}compose(t){return this.empty?t:t.empty?this:Ir(this,t,!0)}map(t,e=!1){return t.empty?this:Pr(this,t,e,!0)}iterChanges(t,e=!1){Rr(this,t,e)}get desc(){return Tr.create(this.sections)}filter(t){let e=[],i=[],n=[],s=new Nr(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);Er(n,t,-1);let r=-1==s.ins?-1:0==s.off?s.ins:0;Er(e,t,r),r>0&&Br(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);Er(e,t,-1),Er(n,t,-1==s.ins?-1:0==s.off?s.ins:0),s.forward(t),o+=t}}return{changes:new Dr(e,i),filtered:Tr.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=[],s=[],r=0,o=null;function h(t=!1){if(!t&&!n.length)return;r<e&&Er(n,e-r,-1);let i=new Dr(n,s);o=o?o.compose(i.map(o)):i,n=[],s=[],r=0}return function t(l){if(Array.isArray(l))for(let e of l)t(e);else if(l instanceof Dr){if(l.length!=e)throw new RangeError(`Mismatched change set length (got ${l.length}, expected ${e})`);h(),o=o?o.compose(l.map(o)):l}else{let{from:t,to:o=t,insert:a}=l;if(t>o||t<0||o>e)throw new RangeError(`Invalid change range ${t} to ${o} (in doc of length ${e})`);let c=a?"string"==typeof a?or.of(a.split(i||Cr)):a:or.empty,u=c.length;if(t==o&&0==u)return;t<r&&h(),t>r&&Er(n,t-r,-1),Er(n,o-t,u),Br(s,n,c),r=o}}(t),h(!o),o}static empty(t){return new Dr(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 s=t[n];if("number"==typeof s)e.push(s,-1);else{if(!Array.isArray(s)||"number"!=typeof s[0]||s.some(((t,e)=>e&&"string"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==s.length)e.push(s[0],0);else{for(;i.length<n;)i.push(or.empty);i[n]=or.of(s.slice(1)),e.push(s[0],i[n].length)}}}return new Dr(e,i)}static createSet(t,e){return new Dr(t,e)}}function Er(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 Br(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(or.empty);t.push(i)}}function Rr(t,e,i){let n=t.inserted;for(let s=0,r=0,o=0;o<t.sections.length;){let h=t.sections[o++],l=t.sections[o++];if(l<0)s+=h,r+=h;else{let a=s,c=r,u=or.empty;for(;a+=h,c+=l,l&&n&&(u=u.append(n[o-2>>1])),!(i||o==t.sections.length||t.sections[o+1]<0);)h=t.sections[o++],l=t.sections[o++];e(s,a,r,c,u),s=a,r=c}}}function Pr(t,e,i,n=!1){let s=[],r=n?[]:null,o=new Nr(t),h=new Nr(e);for(let t=-1;;)if(-1==o.ins&&-1==h.ins){let t=Math.min(o.len,h.len);Er(s,t,-1),o.forward(t),h.forward(t)}else if(h.ins>=0&&(o.ins<0||t==o.i||0==o.off&&(h.len<o.len||h.len==o.len&&!i))){let e=h.len;for(Er(s,h.ins,-1);e;){let i=Math.min(o.len,e);o.ins>=0&&t<o.i&&o.len<=i&&(Er(s,0,o.ins),r&&Br(r,s,o.text),t=o.i),o.forward(i),e-=i}h.next()}else{if(!(o.ins>=0)){if(o.done&&h.done)return r?Dr.createSet(s,r):Tr.create(s);throw new Error("Mismatched change set lengths")}{let e=0,i=o.len;for(;i;)if(-1==h.ins){let t=Math.min(i,h.len);e+=t,i-=t,h.forward(t)}else{if(!(0==h.ins&&h.len<i))break;i-=h.len,h.next()}Er(s,e,t<o.i?o.ins:0),r&&t<o.i&&Br(r,s,o.text),t=o.i,o.forward(o.len-i)}}}function Ir(t,e,i=!1){let n=[],s=i?[]:null,r=new Nr(t),o=new Nr(e);for(let t=!1;;){if(r.done&&o.done)return s?Dr.createSet(n,s):Tr.create(n);if(0==r.ins)Er(n,r.len,0,t),r.next();else if(0!=o.len||o.done){if(r.done||o.done)throw new Error("Mismatched change set lengths");{let e=Math.min(r.len2,o.len),i=n.length;if(-1==r.ins){let i=-1==o.ins?-1:o.off?0:o.ins;Er(n,e,i,t),s&&i&&Br(s,n,o.text)}else-1==o.ins?(Er(n,r.off?0:r.len,e,t),s&&Br(s,n,r.textBit(e))):(Er(n,r.off?0:r.len,o.off?0:o.ins,t),s&&!o.off&&Br(s,n,o.text));t=(r.ins>e||o.ins>=0&&o.len>e)&&(t||n.length>i),r.forward2(e),o.forward(e)}}else Er(n,0,o.ins,t),s&&Br(s,n,o.text),o.next()}}class Nr{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?or.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?or.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 Lr{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 Lr(i,n,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return Vr.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return Vr.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 Vr.range(t.anchor,t.head)}static create(t,e,i){return new Lr(t,e,i)}}class Vr{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:Vr.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 Vr([this.main],0)}addRange(t,e=!0){return Vr.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,Vr.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 Vr(t.ranges.map((t=>Lr.fromJSON(t))),t.main)}static single(t,e=t){return new Vr([Vr.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 Vr.normalized(t.slice(),e);i=s.to}return new Vr(t,e)}static cursor(t,e=0,i,n){return Lr.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?Lr.create(e,t,24|s):Lr.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 i=1;i<t.length;i++){let n=t[i],s=t[i-1];if(n.empty?n.from<=s.to:n.from<s.to){let r=s.from,o=Math.max(n.to,s.to);i<=e&&e--,t.splice(--i,2,n.anchor>n.head?Vr.range(o,r):Vr.range(r,o))}}return new Vr(t,e)}}function Hr(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let Wr=0;class _r{constructor(t,e,i,n,s){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=Wr++,this.default=t([]),this.extensions="function"==typeof s?s(this):s}static define(t={}){return new _r(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:zr),!!t.static,t.enables)}of(t){return new Fr([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new Fr(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new Fr(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],(i=>e(i.field(t))))}}function zr(t,e){return t==e||t.length==e.length&&t.every(((t,i)=>t===e[i]))}class Fr{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=Wr++}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 i of this.dependencies)"doc"==i?h=!0:"selection"==i?l=!0:0==(1&(null!==(e=t[i.id])&&void 0!==e?e:1))&&a.push(t[i.id]);return{create:t=>(t.values[r]=i(t),1),update(t,e){if(h&&e.docChanged||l&&(e.docChanged||e.selection)||jr(t,a)){let e=i(t);if(o?!qr(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=to(e,l);if(this.dependencies.every((i=>i instanceof _r?e.facet(i)===t.facet(i):!(i instanceof Jr)||e.field(i,!1)==t.field(i,!1)))||(o?qr(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 qr(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 jr(t,e){let i=!1;for(let n of e)1&Zr(t,n)&&(i=!0);return i}function Kr(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=to(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)Zr(t,e);return t.values[o]=h(t),1},update(t,i){if(!jr(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=jr(t,n),l=s.config.facets[e.id],a=s.facet(e);if(l&&!r&&zr(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 $r=_r.define({static:!0});class Jr{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 Jr(Wr++,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($r).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,$r.of({field:this,create:t})]}get extension(){return this}}const Ur=2;class Gr{constructor(t,e){this.inner=t,this.prec=e}}class Xr{of(t){return new Yr(this,t)}reconfigure(t){return Xr.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class Yr{constructor(t,e){this.compartment=t,this.inner=e}}class Qr{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 i of function(t,e,i){let n=[[],[],[],[],[]],s=new Map;function r(t,o){let h=s.get(t);if(null!=h){if(h<=o)return;let e=n[h].indexOf(t);e>-1&&n[h].splice(e,1),t instanceof Yr&&i.delete(t.compartment)}if(s.set(t,o),Array.isArray(t))for(let e of t)r(e,o);else if(t instanceof Yr){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 Gr)r(t.inner,t.prec);else if(t instanceof Jr)n[o].push(t),t.provides&&r(t.provides,o);else if(t instanceof Fr)n[o].push(t),t.facet.extensions&&r(t.facet.extensions,Ur);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,Ur),n.reduce(((t,e)=>t.concat(e)))}(t,e,r))i instanceof Jr?n.push(i):(s[i.facet.id]||(s[i.facet.id]=[])).push(i);let o=Object.create(null),h=[],l=[];for(let t of n)o[t.id]=l.length<<1,l.push((e=>t.slot(e)));let a=null==i?void 0:i.config.facets;for(let t in s){let e=s[t],n=e[0].facet,r=a&&a[t]||[];if(e.every((t=>0==t.type)))if(o[n.id]=h.length<<1|1,zr(r,e))h.push(i.facet(n));else{let t=n.combine(e.map((t=>t.value)));h.push(i&&n.compare(t,i.facet(n))?i.facet(n):t)}else{for(let t of e)0==t.type?(o[t.id]=h.length<<1|1,h.push(t.value)):(o[t.id]=l.length<<1,l.push((e=>t.dynamicSlot(e))));o[n.id]=l.length<<1,l.push((t=>Kr(t,n,e)))}}let c=l.map((t=>t(o)));return new Qr(t,r,c,o,h,s)}}function Zr(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 to(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const eo=_r.define(),io=_r.define({combine:t=>t.some((t=>t)),static:!0}),no=_r.define({combine:t=>t.length?t[0]:void 0,static:!0}),so=_r.define(),ro=_r.define(),oo=_r.define(),ho=_r.define({combine:t=>!!t.length&&t[0]});class lo{constructor(t,e){this.type=t,this.value=e}static define(){return new ao}}class ao{of(t){return new lo(this,t)}}class co{constructor(t){this.map=t}of(t){return new uo(this,t)}}class uo{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 uo(this.type,e)}is(t){return this.type==t}static define(t={}){return new co(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}}uo.reconfigure=uo.define(),uo.appendConfig=uo.define();class fo{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&&Hr(i,e.newLength),s.some((t=>t.type==fo.time))||(this.annotations=s.concat(fo.time.of(Date.now())))}static create(t,e,i,n,s,r){return new fo(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(fo.userEvent);return!(!e||!(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function po(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 go(t,e,i){var n;let s,r,o;return i?(s=e.changes,r=Dr.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:uo.mapEffects(t.effects,s).concat(uo.mapEffects(e.effects,r)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function mo(t,e,i){let n=e.selection,s=yo(e.annotations);return e.userEvent&&(s=s.concat(fo.userEvent.of(e.userEvent))),{changes:e.changes instanceof Dr?e.changes:Dr.of(e.changes||[],i,t.facet(no)),selection:n&&(n instanceof Vr?n:Vr.single(n.anchor,n.head)),effects:yo(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function wo(t,e,i){let n=mo(t,e.length?e[0]:{},t.doc.length);e.length&&!1===e[0].filter&&(i=!1);for(let s=1;s<e.length;s++){!1===e[s].filter&&(i=!1);let r=!!e[s].sequential;n=go(n,mo(t,e[s],r?n.changes.newLength:t.doc.length),r)}let s=fo.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return function(t){let e=t.startState,i=e.facet(oo),n=t;for(let s=i.length-1;s>=0;s--){let r=i[s](t);r&&Object.keys(r).length&&(n=go(n,mo(e,r,t.changes.newLength),!0))}return n==t?t:fo.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}(i?function(t){let e=t.startState,i=!0;for(let n of e.facet(so)){let e=n(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:po(i,e))}if(!0!==i){let n,s;if(!1===i)s=t.changes.invertedDesc,n=Dr.empty(e.doc.length);else{let e=t.changes.filter(i);n=e.changes,s=e.filtered.mapDesc(e.changes).invertedDesc}t=fo.create(e,n,t.selection&&t.selection.map(s),uo.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let n=e.facet(ro);for(let i=n.length-1;i>=0;i--){let s=n[i](t);t=s instanceof fo?s:Array.isArray(s)&&1==s.length&&s[0]instanceof fo?s[0]:wo(e,yo(s),!1)}return t}(s):s)}fo.time=lo.define(),fo.userEvent=lo.define(),fo.addToHistory=lo.define(),fo.remote=lo.define();const vo=[];function yo(t){return null==t?vo:Array.isArray(t)?t:[t]}var bo=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(bo||(bo={}));const xo=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let ko;try{ko=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(t){}function So(t){return e=>{if(!/\S/.test(e))return bo.Space;if(function(t){if(ko)return ko.test(t);for(let e=0;e<t.length;e++){let i=t[e];if(/\w/.test(i)||i>"€"&&(i.toUpperCase()!=i.toLowerCase()||xo.test(i)))return!0}return!1}(e))return bo.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return bo.Word;return bo.Other}}class Ao{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 t=0;t<this.config.dynamicSlots.length;t++)Zr(this,t<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(null!=i)return Zr(this,i),to(this,i);if(e)throw new RangeError("Field is not present in this state")}update(...t){return wo(this,t,!0)}applyTransaction(t){let e,i=this.config,{base:n,compartments:s}=i;for(let e of t.effects)e.is(Xr.reconfigure)?(i&&(s=new Map,i.compartments.forEach(((t,e)=>s.set(e,t))),i=null),s.set(e.value.compartment,e.value.extension)):e.is(uo.reconfigure)?(i=null,n=e.value):e.is(uo.appendConfig)&&(i=null,n=yo(n).concat(e.value));if(i)e=t.startState.values.slice();else{i=Qr.resolve(n,s,this),e=new Ao(i,this.doc,this.selection,i.dynamicSlots.map((()=>null)),((t,e)=>e.reconfigure(t,this)),null).values}new Ao(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:Vr.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=yo(i.effects);for(let i=1;i<e.ranges.length;i++){let o=t(e.ranges[i]),h=this.changes(o.changes),l=h.map(n);for(let t=0;t<i;t++)s[t]=s[t].map(l);let a=n.mapDesc(h,!0);s.push(o.range.map(a)),n=n.compose(l),r=uo.mapEffects(r,l).concat(uo.mapEffects(yo(o.effects),a))}return{changes:n,selection:Vr.create(s,e.mainIndex),effects:r}}changes(t=[]){return t instanceof Dr?t:Dr.of(t,this.doc.length,this.facet(Ao.lineSeparator))}toText(t){return or.of(t.split(this.facet(Ao.lineSeparator)||Cr))}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:(Zr(this,e),to(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 Jr&&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 e in i)if(Object.prototype.hasOwnProperty.call(t,e)){let s=i[e],r=t[e];n.push(s.init((t=>s.spec.fromJSON(r,t))))}return Ao.create({doc:t.doc,selection:Vr.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let e=Qr.resolve(t.extensions||[],new Map),i=t.doc instanceof or?t.doc:or.of((t.doc||"").split(e.staticFacet(Ao.lineSeparator)||Cr)),n=t.selection?t.selection instanceof Vr?t.selection:Vr.single(t.selection.anchor,t.selection.head):Vr.single(0);return Hr(n,i.length),e.staticFacet(io)||(n=n.asSingle()),new Ao(e,i,n,e.dynamicSlots.map((()=>null)),((t,e)=>e.create(t)),null)}get tabSize(){return this.facet(Ao.tabSize)}get lineBreak(){return this.facet(Ao.lineSeparator)||"\n"}get readOnly(){return this.facet(ho)}phrase(t,...e){for(let e of this.facet(Ao.phrases))if(Object.prototype.hasOwnProperty.call(e,t)){t=e[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(eo))for(let r of s(this,e,i))Object.prototype.hasOwnProperty.call(r,t)&&n.push(r[t]);return n}charCategorizer(t){return So(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=yr(e,r,!1);if(s(e.slice(t,r))!=bo.Word)break;r=t}for(;o<n;){let t=yr(e,o);if(s(e.slice(o,t))!=bo.Word)break;o=t}return r==o?null:Vr.range(r+i,o+i)}}Ao.allowMultipleSelections=io,Ao.tabSize=_r.define({combine:t=>t.length?t[0]:4}),Ao.lineSeparator=no,Ao.readOnly=ho,Ao.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]))}}),Ao.languageData=eo,Ao.changeFilter=so,Ao.transactionFilter=ro,Ao.transactionExtender=oo,Xr.reconfigure=uo.define();class Mo{eq(t){return this==t}range(t,e=t){return Co.create(t,e,this)}}Mo.prototype.startSide=Mo.prototype.endSide=0,Mo.prototype.point=!1,Mo.prototype.mapMode=Or.TrackDel;class Co{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new Co(t,e,i)}}function Oo(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class To{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 To(n,s,i,o):null,pos:r}}}class Do{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 Do(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(Oo)),this.isEmpty)return e.length?Do.of(e):this;let o=new Ro(this,null,-1).goto(0),h=0,l=[],a=new Eo;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(Co.create(o.from,o.to,o.value))),o.next());return a.finishInner(this.nextLayer.isEmpty&&!l.length?Do.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 s=0;s<this.chunk.length;s++){let r=this.chunkPos[s],o=this.chunk[s],h=t.touchesRange(r,r+o.length);if(!1===h)n=Math.max(n,o.maxPoint),e.push(o),i.push(t.mapPos(r));else if(!0===h){let{mapped:s,pos:h}=o.map(r,t);s&&(n=Math.max(n,s.maxPoint),e.push(s),i.push(h))}}let s=this.nextLayer.map(t);return 0==e.length?s:new Do(i,e,s||Do.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 Po.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return Po.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=Bo(r,o,i),l=new No(r,h,s),a=new No(o,h,s);i.iterGaps(((t,e,i)=>Lo(l,t,a,e,i,n))),i.empty&&0==i.length&&Lo(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=Bo(s,r),h=new No(s,o,0).goto(i),l=new No(r,o,0).goto(i);for(;;){if(h.to!=l.to||!Vo(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 No(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 Eo;for(let n of t instanceof Co?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let n=t[i];if(Oo(e,n)>0)return t.slice().sort(Oo);e=n}return t}(t):t)i.add(n.from,n.to,n.value);return i.finish()}}Do.empty=new Do([],[],null,-1),Do.empty.nextLayer=Do.empty;class Eo{finishChunk(t){this.chunks.push(new To(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 Eo)).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(Do.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=Do.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function Bo(t,e,i){let n=new Map;for(let e of t)for(let t=0;t<e.chunk.length;t++)e.chunk[t].maxPoint<=0&&n.set(e.chunk[t],e.chunkPos[t]);let s=new Set;for(let t of e)for(let e=0;e<t.chunk.length;e++){let r=n.get(t.chunk[e]);null==r||(i?i.mapPos(r):r)!=t.chunkPos[e]||(null==i?void 0:i.touchesRange(r,r+t.chunk[e].length))||s.add(t.chunk[e])}return s}class Ro{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 Po{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 Ro(r,e,i,s));return 1==n.length?n[0]:new Po(n)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(let i of this.heap)i.goto(t,e);for(let t=this.heap.length>>1;t>=0;t--)Io(this.heap,t);return this.next(),this}forward(t,e){for(let i of this.heap)i.forward(t,e);for(let t=this.heap.length>>1;t>=0;t--)Io(this.heap,t);(this.to-t||this.value.endSide-e)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),Io(this.heap,0)}}}function Io(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 No{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=Po.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){Ho(this.active,t),Ho(this.activeTo,t),Ho(this.activeRank,t),this.minActive=_o(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++;Wo(this.active,e,i),Wo(this.activeTo,e,n),Wo(this.activeRank,e,s),t&&Wo(t,e,this.cursor.from),this.minActive=_o(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&&Ho(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 Lo(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))&&Vo(t.activeForPoint(t.to),i.activeForPoint(i.to))||r.comparePoint(h,s,t.point,i.point):s>h&&!Vo(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 Vo(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 Ho(t,e){for(let i=e,n=t.length-1;i<n;i++)t[i]=t[i+1];t.pop()}function Wo(t,e,i){for(let i=t.length-1;i>=e;i--)t[i+1]=t[i];t[e]=i}function _o(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}const zo=1024;let Fo=0;class qo{constructor(t={}){this.id=Fo++,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=Ko.match(t)),e=>{let i=t(e);return void 0===i?null:[this,i]}}}qo.closedBy=new qo({deserialize:t=>t.split(" ")}),qo.openedBy=new qo({deserialize:t=>t.split(" ")}),qo.group=new qo({deserialize:t=>t.split(" ")}),qo.contextHash=new qo({perNode:!0}),qo.lookAhead=new qo({perNode:!0}),qo.mounted=new qo({perNode:!0});const jo=Object.create(null);class Ko{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):jo,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=new Ko(t.name||"",e,t.id,i);if(t.props)for(let i of t.props)if(Array.isArray(i)||(i=i(n)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[i[0].id]=i[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(qo.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(qo.group),n=-1;n<(i?i.length:0);n++){let s=e[n<0?t.name:i[n]];if(s)return s}}}}Ko.none=new Ko("",Object.create(null),0,8);const $o=new WeakMap,Jo=new WeakMap;var Uo;!function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"}(Uo||(Uo={}));class Go{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(qo.mounted);if(t&&!t.overlay)return t.tree.toString();let e="";for(let t of this.children){let i=t.toString();i&&(e&&(e+=","),e+=i)}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 oh(this.topNode,t)}cursorAt(t,e=0,i=0){let n=$o.get(this)||this.topNode,s=new oh(n);return s.moveTo(t,e),$o.set(this,s._tree),s}get topNode(){return new eh(this,0,0,null)}resolve(t,e=0){let i=th($o.get(this)||this.topNode,t,e,!1);return $o.set(this,i),i}resolveInner(t,e=0){let i=th(Jo.get(this)||this.topNode,t,e,!0);return Jo.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&Uo.IncludeAnonymous)>0;for(let t=this.cursor(r|Uo.IncludeAnonymous);;){let r=!1;if(t.from<=s&&t.to>=n&&(!o&&t.type.isAnonymous||!1!==e(t))){if(t.firstChild())continue;r=!0}for(;r&&i&&(o||!t.type.isAnonymous)&&i(t),!t.nextSibling();){if(!t.parent())return;r=!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:ch(Ko.none,this.children,this.positions,0,this.children.length,0,this.length,((t,e,i)=>new Go(this.type,t,e,i,this.propValues)),t.makeTree||((t,e,i)=>new Go(Ko.none,t,e,i)))}static build(t){return function(t){var e;let{buffer:i,nodeSet:n,maxBufferLength:s=zo,reused:r=[],minRepeatType:o=n.types.length}=t,h=Array.isArray(i)?new Xo(i,i.length):i,l=n.types,a=0,c=0;function u(t,e,i,w,v){let{id:y,start:b,end:x,size:k}=h,S=c;for(;k<0;){if(h.next(),-1==k){let e=r[y];return i.push(e),void w.push(b-t)}if(-3==k)return void(a=y);if(-4==k)return void(c=y);throw new RangeError(`Unrecognized record size: ${k}`)}let A,M,C=l[y],O=b-t;if(x-b<=s&&(M=g(h.pos-e,v))){let e=new Uint16Array(M.size-M.skip),i=h.pos-M.size,s=e.length;for(;h.pos>i;)s=m(M.start,e,s);A=new Yo(e,x-M.start,n),O=M.start-t}else{let t=h.pos-k;h.next();let e=[],i=[],n=y>=o?y:-1,r=0,l=x;for(;h.pos>t;)n>=0&&h.id==n&&h.size>=0?(h.end<=l-s&&(d(e,i,b,r,h.end,l,n,S),r=e.length,l=h.end),h.next()):u(b,t,e,i,n);if(n>=0&&r>0&&r<e.length&&d(e,i,b,r,b,l,n,S),e.reverse(),i.reverse(),n>-1&&r>0){let t=f(C);A=ch(C,e,i,0,e.length,0,x-b,t,t)}else A=p(C,e,i,x-b,S-x)}i.push(A),w.push(O)}function f(t){return(e,i,n)=>{let s,r,o=0,h=e.length-1;if(h>=0&&(s=e[h])instanceof Go){if(!h&&s.type==t&&s.length==n)return s;(r=s.prop(qo.lookAhead))&&(o=i[h]+s.length+r)}return p(t,e,i,n,o)}}function d(t,e,i,s,r,o,h,l){let a=[],c=[];for(;t.length>s;)a.push(t.pop()),c.push(e.pop()+i-r);t.push(p(n.types[h],a,c,o-r,l-o)),e.push(r-i)}function p(t,e,i,n,s=0,r){if(a){let t=[qo.contextHash,a];r=r?[t].concat(r):[t]}if(s>25){let t=[qo.lookAhead,s];r=r?[t].concat(r):[t]}return new Go(t,e,i,n,r)}function g(t,e){let i=h.fork(),n=0,r=0,l=0,a=i.end-s,c={size:0,start:0,skip:0};t:for(let s=i.pos-t;i.pos>s;){let t=i.size;if(i.id==e&&t>=0){c.size=n,c.start=r,c.skip=l,l+=4,n+=4,i.next();continue}let h=i.pos-t;if(t<0||h<s||i.start<a)break;let u=i.id>=o?4:0,f=i.start;for(i.next();i.pos>h;){if(i.size<0){if(-3!=i.size)break t;u+=4}else i.id>=o&&(u+=4);i.next()}r=f,n+=t,l+=u}return(e<0||n==t)&&(c.size=n,c.start=r,c.skip=l),c.size>4?c:void 0}function m(t,e,i){let{id:n,start:s,end:r,size:l}=h;if(h.next(),l>=0&&n<o){let o=i;if(l>4){let n=h.pos-(l-4);for(;h.pos>n;)i=m(t,e,i)}e[--i]=o,e[--i]=r-t,e[--i]=s-t,e[--i]=n}else-3==l?a=n:-4==l&&(c=n);return i}let w=[],v=[];for(;h.pos>0;)u(t.start||0,t.bufferStart||0,w,v,-1);let y=null!==(e=t.length)&&void 0!==e?e:w.length?v[0]+w[0].length:0;return new Go(l[t.topID],w.reverse(),v.reverse(),y)}(t)}}Go.empty=new Go(Ko.none,[],[],0);class Xo{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 Xo(this.buffer,this.index)}}class Yo{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return Ko.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&&!(Qo(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 Yo(s,r,this.set)}}function Qo(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 Zo(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 th(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 eh&&t.index<0?null:t.parent;if(!e)return t;t=e}let r=n?0:Uo.IgnoreOverlays;if(n)for(let n=t,o=n.parent;o;n=o,o=n.parent)n instanceof eh&&n.index<0&&(null===(s=o.enter(e,i,r))||void 0===s?void 0:s.from)!=n.from&&(t=o);for(;;){let n=t.enter(e,i,r);if(!n)return t;t=n}}class eh{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:o,positions:h}=r._tree,l=e>0?o.length:-1;t!=l;t+=e){let l=o[t],a=h[t]+r.from;if(Qo(n,i,a,a+l.length))if(l instanceof Yo){if(s&Uo.ExcludeBuffers)continue;let o=l.findChild(0,l.buffer.length,e,i-a,n);if(o>-1)return new rh(new sh(r,l,t,a),null,o)}else if(s&Uo.IncludeAnonymous||!l.type.isAnonymous||hh(l)){let o;if(!(s&Uo.IgnoreMounts)&&l.props&&(o=l.prop(qo.mounted))&&!o.overlay)return new eh(o.tree,a,t,r);let h=new eh(l,a,t,r);return s&Uo.IncludeAnonymous||!h.type.isAnonymous?h:h.nextChild(e<0?l.children.length-1:0,e,i,n)}}if(s&Uo.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&Uo.IgnoreOverlays)&&(n=this._tree.prop(qo.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 eh(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 oh(this,t)}get tree(){return this._tree}toTree(){return this._tree}resolve(t,e=0){return th(this,t,e,!1)}resolveInner(t,e=0){return th(this,t,e,!0)}enterUnfinishedNodesBefore(t){return Zo(this,t)}getChild(t,e=null,i=null){let n=ih(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return ih(this,t,e,i)}toString(){return this._tree.toString()}get node(){return this}matchContext(t){return nh(this,t)}}function ih(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 nh(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 sh{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}}class rh{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 rh(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&Uo.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 rh(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 rh(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 rh(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}cursor(t=0){return new oh(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 Go(this.type,t,e,this.to-this.from)}resolve(t,e=0){return th(this,t,e,!1)}resolveInner(t,e=0){return th(this,t,e,!0)}enterUnfinishedNodesBefore(t){return Zo(this,t)}toString(){return this.context.buffer.childString(this.index)}getChild(t,e=null,i=null){let n=ih(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return ih(this,t,e,i)}get node(){return this}matchContext(t){return nh(this,t)}}class oh{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 eh)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 eh?(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&Uo.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Uo.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&Uo.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&Uo.IncludeAnonymous||t instanceof Yo||!t.type.isAnonymous||hh(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 t=i;t<this.stack.length;t++)e=new rh(this.buffer,e,this.stack[t]);return this.bufferNode=new rh(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 nh(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 nh(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 hh(t){return t.children.some((t=>t instanceof Yo||!t.type.isAnonymous||hh(t)))}const lh=new WeakMap;function ah(t,e){if(!t.isAnonymous||e instanceof Yo||e.type!=t)return 1;let i=lh.get(e);if(null==i){i=1;for(let n of e.children){if(n.type!=t||!(n instanceof Go)){i=1;break}i+=ah(t,n)}lh.set(e,i)}return i}function ch(t,e,i,n,s,r,o,h,l){let a=0;for(let i=n;i<s;i++)a+=ah(t,e[i]);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],p=ah(t,i[a]);for(a++;a<o;a++){let e=ah(t,i[a]);if(p+e>=c)break;p+=e}if(a==s+1){if(p>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(ch(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 qo({perNode:!0});let uh=0;class fh{constructor(t,e,i){this.set=t,this.base=e,this.modified=i,this.id=uh++}static define(t){if(null==t?void 0:t.base)throw new Error("Can not derive from a modified tag");let e=new fh([],null,[]);if(e.set.push(e),t)for(let i of t.set)e.set.push(i);return e}static defineModifier(){let t=new ph;return e=>e.modified.indexOf(t)>-1?e:ph.get(e.base||e,e.modified.concat(t).sort(((t,e)=>t.id-e.id)))}}let dh=0;class ph{constructor(){this.instances=[],this.id=dh++}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 fh(n,t,e);for(let t of e)t.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 e of t.set)if(!e.modified.length)for(let t of r)n.push(ph.get(e,t));return s}}function gh(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 wh(n,s,o>0?i.slice(0,o):null);e[h]=l.sort(e[h])}}return mh.add(e)}const mh=new qo;class wh{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 vh(t,e){let i=Object.create(null);for(let e of t)if(Array.isArray(e.tag))for(let t of e.tag)i[t.id]=e.class;else i[e.tag.id]=e.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}}wh.empty=new wh([],2,null);const yh=fh.define,bh=yh(),xh=yh(),kh=yh(xh),Sh=yh(xh),Ah=yh(),Mh=yh(Ah),Ch=yh(Ah),Oh=yh(),Th=yh(Oh),Dh=yh(),Eh=yh(),Bh=yh(),Rh=yh(Bh),Ph=yh(),Ih={comment:bh,lineComment:yh(bh),blockComment:yh(bh),docComment:yh(bh),name:xh,variableName:yh(xh),typeName:kh,tagName:yh(kh),propertyName:Sh,attributeName:yh(Sh),className:yh(xh),labelName:yh(xh),namespace:yh(xh),macroName:yh(xh),literal:Ah,string:Mh,docString:yh(Mh),character:yh(Mh),attributeValue:yh(Mh),number:Ch,integer:yh(Ch),float:yh(Ch),bool:yh(Ah),regexp:yh(Ah),escape:yh(Ah),color:yh(Ah),url:yh(Ah),keyword:Dh,self:yh(Dh),null:yh(Dh),atom:yh(Dh),unit:yh(Dh),modifier:yh(Dh),operatorKeyword:yh(Dh),controlKeyword:yh(Dh),definitionKeyword:yh(Dh),moduleKeyword:yh(Dh),operator:Eh,derefOperator:yh(Eh),arithmeticOperator:yh(Eh),logicOperator:yh(Eh),bitwiseOperator:yh(Eh),compareOperator:yh(Eh),updateOperator:yh(Eh),definitionOperator:yh(Eh),typeOperator:yh(Eh),controlOperator:yh(Eh),punctuation:Bh,separator:yh(Bh),bracket:Rh,angleBracket:yh(Rh),squareBracket:yh(Rh),paren:yh(Rh),brace:yh(Rh),content:Oh,heading:Th,heading1:yh(Th),heading2:yh(Th),heading3:yh(Th),heading4:yh(Th),heading5:yh(Th),heading6:yh(Th),contentSeparator:yh(Oh),list:yh(Oh),quote:yh(Oh),emphasis:yh(Oh),strong:yh(Oh),link:yh(Oh),monospace:yh(Oh),strikethrough:yh(Oh),inserted:yh(),deleted:yh(),changed:yh(),invalid:yh(),meta:Ph,documentMeta:yh(Ph),annotation:yh(Ph),processingInstruction:yh(Ph),definition:fh.defineModifier(),constant:fh.defineModifier(),function:fh.defineModifier(),standard:fh.defineModifier(),local:fh.defineModifier(),special:fh.defineModifier()};vh([{tag:Ih.link,class:"tok-link"},{tag:Ih.heading,class:"tok-heading"},{tag:Ih.emphasis,class:"tok-emphasis"},{tag:Ih.strong,class:"tok-strong"},{tag:Ih.keyword,class:"tok-keyword"},{tag:Ih.atom,class:"tok-atom"},{tag:Ih.bool,class:"tok-bool"},{tag:Ih.url,class:"tok-url"},{tag:Ih.labelName,class:"tok-labelName"},{tag:Ih.inserted,class:"tok-inserted"},{tag:Ih.deleted,class:"tok-deleted"},{tag:Ih.literal,class:"tok-literal"},{tag:Ih.string,class:"tok-string"},{tag:Ih.number,class:"tok-number"},{tag:[Ih.regexp,Ih.escape,Ih.special(Ih.string)],class:"tok-string2"},{tag:Ih.variableName,class:"tok-variableName"},{tag:Ih.local(Ih.variableName),class:"tok-variableName tok-local"},{tag:Ih.definition(Ih.variableName),class:"tok-variableName tok-definition"},{tag:Ih.special(Ih.variableName),class:"tok-variableName2"},{tag:Ih.definition(Ih.propertyName),class:"tok-propertyName tok-definition"},{tag:Ih.typeName,class:"tok-typeName"},{tag:Ih.namespace,class:"tok-namespace"},{tag:Ih.className,class:"tok-className"},{tag:Ih.macroName,class:"tok-macroName"},{tag:Ih.propertyName,class:"tok-propertyName"},{tag:Ih.operator,class:"tok-operator"},{tag:Ih.comment,class:"tok-comment"},{tag:Ih.meta,class:"tok-meta"},{tag:Ih.invalid,class:"tok-invalid"},{tag:Ih.punctuation,class:"tok-punctuation"}]);var Nh;const Lh=new Ns;const Vh=new Ns;class Hh{constructor(t,e,i=[],n=""){this.data=t,this.name=n,Ao.prototype.hasOwnProperty("tree")||Object.defineProperty(Ao.prototype,"tree",{get(){return _h(this)}}),this.parser=e,this.extension=[Gh.of(this),Ao.languageData.of(((t,e,i)=>{let n=Wh(t,e,i),s=n.type.prop(Lh);if(!s)return[];let r=t.facet(s),o=n.type.prop(Vh);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 Wh(t,e,i).type.prop(Lh)==this.data}findRegions(t){let e=t.facet(Gh);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(Lh)==this.data)return void i.push({from:e,to:e+t.length});let s=t.prop(Ns.mounted);if(s){if(s.tree.prop(Lh)==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 zs&&n(s,t.positions[i]+e)}};return n(_h(t),0),i}get allowsNesting(){return!0}}function Wh(t,e,i){let n=t.facet(Gh),s=_h(t).topNode;if(!n||n.allowsNesting)for(let t=s;t;t=t.enter(e,i,_s.ExcludeBuffers))t.type.isTop&&(s=t);return s}Hh.setState=uo.define();function _h(t){let e=t.field(Hh.state,!1);return e?e.tree:zs.empty}class zh{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 Fh=null;class qh{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 qh(t,e,[],zs.empty,0,i,[],null)}startParse(){return this.parser.startParse(new zh(this.state.doc),this.fragments)}work(t,e){return null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=zs.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(nr.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(nr.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=Fh;Fh=this;try{return t()}finally{Fh=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=jh(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:n,treeLen:s,viewport:r,skipped:o}=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=nr.applyChanges(i,e),n=zs.empty,s=0,r={from:t.mapPos(r.from,-1),to:t.mapPos(r.to,1)},this.skipped.length){o=[];for(let e of this.skipped){let i=t.mapPos(e.from,1),n=t.mapPos(e.to,-1);i<n&&o.push({from:i,to:n})}}}return new qh(this.parser,e,i,n,s,r,o,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 e=0;e<this.skipped.length;e++){let{from:i,to:n}=this.skipped[e];i<t.to&&n>t.from&&(this.fragments=jh(this.fragments,i,n),this.skipped.splice(e--,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 sr{createParse(e,i,n){let s=n[0].from,r=n[n.length-1].to;return{parsedPos:s,advance(){let e=Fh;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=r,new zs(Vs.none,[],[],r-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 Fh}}function jh(t,e,i){return nr.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}class Kh{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 Kh(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=qh.create(t.facet(Gh).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new Kh(i)}}Hh.state=Jr.define({create:Kh.init,update(t,e){for(let t of e.effects)if(t.is(Hh.setState))return t.value;return e.startState.facet(Gh)!=e.state.facet(Gh)?Kh.init(e.state):t.apply(e)}});let $h=t=>{let e=setTimeout((()=>t()),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&($h=t=>{let e=-1,i=setTimeout((()=>{e=requestIdleCallback(t,{timeout:400})}),100);return()=>e<0?clearTimeout(i):cancelIdleCallback(e)});const Jh="undefined"!=typeof navigator&&(null===(Nh=navigator.scheduling)||void 0===Nh?void 0:Nh.isInputPending)?()=>navigator.scheduling.isInputPending():null,Uh=mi.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(Hh.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(Hh.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=$h(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(Hh.state);if(s.tree==s.context.tree&&s.context.isDone(n+1e5))return;let r=Date.now()+Math.min(this.chunkBudget,100,t&&!Jh?Math.max(25,t.timeRemaining()-5):1e9),o=s.context.treeLen<n&&i.doc.length>n+1e3,h=s.context.work((()=>Jh&&Jh()||Date.now()>r),n+(o?0:1e5));this.chunkBudget-=Date.now()-e,(h||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Hh.setState.of(new Kh(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=>fi(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()}}}),Gh=_r.define({combine:t=>t.length?t[0]:null,enables:t=>[Hh.state,Uh,As.contentAttributes.compute([t],(e=>{let i=e.facet(t);return i&&i.name?{"data-language":i.name}:{}}))]});const Xh=_r.define(),Yh=_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 Qh(t){let e=t.facet(Yh);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function Zh(t,e){let i="",n=t.tabSize,s=t.facet(Yh)[0];if("\t"==s){for(;e>=n;)i+="\t",e-=n;s=" "}for(let t=0;t<e;t++)i+=s;return i}function tl(t,e){t instanceof Ao&&(t=new el(t));for(let i of t.state.facet(Xh)){let n=i(t,e);if(void 0!==n)return n}let i=_h(t.state);return i?function(t,e,i){return sl(e.resolveInner(i).enterUnfinishedNodesBefore(i),i,t)}(t,i,e):null}class el{constructor(t,e={}){this.state=t,this.options=e,this.unit=Qh(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 function(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=yr(t,s));return n}(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 il=new Ns;function nl(t){let e=t.type.prop(il);if(e)return e;let i,n=t.firstChild;if(n&&(i=n.type.prop(Ns.closedBy))){let e=t.lastChild,n=e&&i.indexOf(e.name)>-1;return t=>ll(t,!0,1,void 0,n&&!function(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}(t)?e.from:void 0)}return null==t.parent?rl:null}function sl(t,e,i){for(;t;t=t.parent){let n=nl(t);if(n)return n(ol.create(i,e,t))}return null}function rl(){return 0}class ol extends el{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 ol(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(hl(i,t))break;e=this.state.doc.lineAt(i.from)}return this.lineIndent(e.from)}continue(){let t=this.node.parent;return t?sl(t,this.pos,this.base):0}}function hl(t,e){for(let i=e;i;i=i.parent)if(t==i)return!0;return!1}function ll(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?function(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 t=i.to;;){let s=e.childAfter(t);if(!s||s==n)return null;if(!s.type.isSkipped)return s.from<o?i:null;t=s.to}}(t):null;return l?h?t.column(l.from):t.column(l.to):t.baseIndent+(h?0:t.unit*i)}class al{constructor(t,e){let i;function n(t){let e=qt.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 Hh?t=>t.prop(Lh)==r.data:r?t=>t==r:void 0,this.style=vh(t.map((t=>({tag:t.tag,class:t.class||n(Object.assign({},t,{tag:null}))}))),{all:s}).style,this.module=i?new qt.V(i):null,this.themeType=e.themeType}static define(t,e){return new al(t,e||{})}}Ih.meta,Ih.link,Ih.heading,Ih.emphasis,Ih.strong,Ih.strikethrough,Ih.keyword,Ih.atom,Ih.bool,Ih.url,Ih.contentSeparator,Ih.labelName,Ih.literal,Ih.inserted,Ih.string,Ih.deleted,Ih.regexp,Ih.escape,Ih.string,Ih.variableName,Ih.variableName,Ih.typeName,Ih.namespace,Ih.className,Ih.variableName,Ih.macroName,Ih.propertyName,Ih.comment,Ih.invalid;const cl=1e4,ul="()[]{}";const fl=new Ns;function dl(t,e,i){let n=t.prop(e<0?Ns.openedBy:Ns.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 pl(t){let e=t.type.prop(fl);return e?e(t.node):t}function gl(t,e,i,n={}){let s=n.maxScanDistance||cl,r=n.brackets||ul,o=_h(t),h=o.resolveInner(e,i);for(let n=h;n;n=n.parent){let s=dl(n.type,i,r);if(s&&n.from<n.to){let o=pl(n);if(o&&(i>0?e>=o.from&&e<o.to:e>o.from&&e<=o.to))return ml(t,e,i,n,o,s,r)}}return function(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 t=0;!c.next().done&&t<=r;){let r=c.value;i<0&&(t+=r.length);let h=e+t*i;for(let t=i>0?0:r.length-1,e=i>0?r.length:-1;t!=e;t+=i){let e=o.indexOf(r[t]);if(!(e<0||n.resolveInner(h+t,1).type!=s))if(e%2==0==i>0)u++;else{if(1==u)return{start:a,end:{from:h+t,to:h+t+1},matched:e>>1==l>>1};u--}}i>0&&(t+=r.length)}return c.done?{start:a,matched:!1}:null}(t,e,i,o,h.type,s,r)}function ml(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=pl(c);return{start:l,end:t?{from:t.from,to:t.to}:void 0,matched:!0}}if(dl(c.type,i,o))a++;else if(dl(c.type,-i,o)){if(0==a){let t=pl(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}}const wl=Object.create(null),vl=[Vs.none],yl=[],bl=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])bl[t]=kl(wl,e);function xl(t,e){yl.indexOf(t)>-1||(yl.push(t),console.warn(e))}function kl(t,e){let i=null;for(let n of e.split(".")){let e=t[n]||Ih[n];e?"function"==typeof e?i?i=e(i):xl(n,`Modifier ${n} used at start of tag`):i?xl(n,`Tag ${n} used as modifier`):i=e:xl(n,`Unknown highlighting tag ${n}`)}if(!i)return 0;let n=e.replace(/ /g,"_"),s=Vs.define({id:vl.length,name:n,props:[gh({[n]:i})]});return vl.push(s),s.id}const Sl=1024;let Al=0;class Ml{constructor(t={}){this.id=Al++,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=Tl.match(t)),e=>{let i=t(e);return void 0===i?null:[this,i]}}}Ml.closedBy=new Ml({deserialize:t=>t.split(" ")}),Ml.openedBy=new Ml({deserialize:t=>t.split(" ")}),Ml.group=new Ml({deserialize:t=>t.split(" ")}),Ml.isolate=new Ml({deserialize:t=>{if(t&&"rtl"!=t&&"ltr"!=t&&"auto"!=t)throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),Ml.contextHash=new Ml({perNode:!0}),Ml.lookAhead=new Ml({perNode:!0}),Ml.mounted=new Ml({perNode:!0});class Cl{constructor(t,e,i){this.tree=t,this.overlay=e,this.parser=i}static get(t){return t&&t.props&&t.props[Ml.mounted.id]}}const Ol=Object.create(null);class Tl{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):Ol,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=new Tl(t.name||"",e,t.id,i);if(t.props)for(let i of t.props)if(Array.isArray(i)||(i=i(n)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[i[0].id]=i[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(Ml.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(Ml.group),n=-1;n<(i?i.length:0);n++){let s=e[n<0?t.name:i[n]];if(s)return s}}}}Tl.none=new Tl("",Object.create(null),0,8);const Dl=new WeakMap,El=new WeakMap;var Bl;!function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"}(Bl||(Bl={}));class Rl{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=Cl.get(this);if(t&&!t.overlay)return t.tree.toString();let e="";for(let t of this.children){let i=t.toString();i&&(e&&(e+=","),e+=i)}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 Kl(this.topNode,t)}cursorAt(t,e=0,i=0){let n=Dl.get(this)||this.topNode,s=new Kl(n);return s.moveTo(t,e),Dl.set(this,s._tree),s}get topNode(){return new Hl(this,0,0,null)}resolve(t,e=0){let i=Ll(Dl.get(this)||this.topNode,t,e,!1);return Dl.set(this,i),i}resolveInner(t,e=0){let i=Ll(El.get(this)||this.topNode,t,e,!0);return El.set(this,i),i}resolveStack(t,e=0){return function(t,e,i){let n=t.resolveInner(e,i),s=null;for(let t=n instanceof Hl?n:n.context.parent;t;t=t.parent)if(t.index<0){let r=t.parent;(s||(s=[n])).push(r.resolve(e,i)),t=r}else{let r=Cl.get(t.tree);if(r&&r.overlay&&r.overlay[0].from<=e&&r.overlay[r.overlay.length-1].to>=e){let o=new Hl(r.tree,r.overlay[0].from+t.from,-1,t);(s||(s=[n])).push(Ll(o,e,i,!1))}}return s?ql(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&Bl.IncludeAnonymous)>0;for(let t=this.cursor(r|Bl.IncludeAnonymous);;){let r=!1;if(t.from<=s&&t.to>=n&&(!o&&t.type.isAnonymous||!1!==e(t))){if(t.firstChild())continue;r=!0}for(;r&&i&&(o||!t.type.isAnonymous)&&i(t),!t.nextSibling();){if(!t.parent())return;r=!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:Gl(Tl.none,this.children,this.positions,0,this.children.length,0,this.length,((t,e,i)=>new Rl(this.type,t,e,i,this.propValues)),t.makeTree||((t,e,i)=>new Rl(Tl.none,t,e,i)))}static build(t){return function(t){var e;let{buffer:i,nodeSet:n,maxBufferLength:s=Sl,reused:r=[],minRepeatType:o=n.types.length}=t,h=Array.isArray(i)?new Pl(i,i.length):i,l=n.types,a=0,c=0;function u(t,e,i,v,y,b){let{id:x,start:k,end:S,size:A}=h,M=c;for(;A<0;){if(h.next(),-1==A){let e=r[x];return i.push(e),void v.push(k-t)}if(-3==A)return void(a=x);if(-4==A)return void(c=x);throw new RangeError(`Unrecognized record size: ${A}`)}let C,O,T=l[x],D=k-t;if(S-k<=s&&(O=m(h.pos-e,y))){let e=new Uint16Array(O.size-O.skip),i=h.pos-O.size,s=e.length;for(;h.pos>i;)s=w(O.start,e,s);C=new Il(e,S-O.start,n),D=O.start-t}else{let t=h.pos-A;h.next();let e=[],i=[],n=x>=o?x:-1,r=0,l=S;for(;h.pos>t;)n>=0&&h.id==n&&h.size>=0?(h.end<=l-s&&(p(e,i,k,r,h.end,l,n,M),r=e.length,l=h.end),h.next()):b>2500?f(k,t,e,i):u(k,t,e,i,n,b+1);if(n>=0&&r>0&&r<e.length&&p(e,i,k,r,k,l,n,M),e.reverse(),i.reverse(),n>-1&&r>0){let t=d(T);C=Gl(T,e,i,0,e.length,0,S-k,t,t)}else C=g(T,e,i,S-k,M-S)}i.push(C),v.push(D)}function f(t,e,i,r){let o=[],l=0,a=-1;for(;h.pos>e;){let{id:t,start:e,end:i,size:n}=h;if(n>4)h.next();else{if(a>-1&&e<a)break;a<0&&(a=i-s),o.push(t,e,i),l++,h.next()}}if(l){let e=new Uint16Array(4*l),s=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]-s,e[i++]=o[t+2]-s,e[i++]=i;i.push(new Il(e,o[2]-s,n)),r.push(s-t)}}function d(t){return(e,i,n)=>{let s,r,o=0,h=e.length-1;if(h>=0&&(s=e[h])instanceof Rl){if(!h&&s.type==t&&s.length==n)return s;(r=s.prop(Ml.lookAhead))&&(o=i[h]+s.length+r)}return g(t,e,i,n,o)}}function p(t,e,i,s,r,o,h,l){let a=[],c=[];for(;t.length>s;)a.push(t.pop()),c.push(e.pop()+i-r);t.push(g(n.types[h],a,c,o-r,l-o)),e.push(r-i)}function g(t,e,i,n,s=0,r){if(a){let t=[Ml.contextHash,a];r=r?[t].concat(r):[t]}if(s>25){let t=[Ml.lookAhead,s];r=r?[t].concat(r):[t]}return new Rl(t,e,i,n,r)}function m(t,e){let i=h.fork(),n=0,r=0,l=0,a=i.end-s,c={size:0,start:0,skip:0};t:for(let s=i.pos-t;i.pos>s;){let t=i.size;if(i.id==e&&t>=0){c.size=n,c.start=r,c.skip=l,l+=4,n+=4,i.next();continue}let h=i.pos-t;if(t<0||h<s||i.start<a)break;let u=i.id>=o?4:0,f=i.start;for(i.next();i.pos>h;){if(i.size<0){if(-3!=i.size)break t;u+=4}else i.id>=o&&(u+=4);i.next()}r=f,n+=t,l+=u}return(e<0||n==t)&&(c.size=n,c.start=r,c.skip=l),c.size>4?c:void 0}function w(t,e,i){let{id:n,start:s,end:r,size:l}=h;if(h.next(),l>=0&&n<o){let o=i;if(l>4){let n=h.pos-(l-4);for(;h.pos>n;)i=w(t,e,i)}e[--i]=o,e[--i]=r-t,e[--i]=s-t,e[--i]=n}else-3==l?a=n:-4==l&&(c=n);return i}let v=[],y=[];for(;h.pos>0;)u(t.start||0,t.bufferStart||0,v,y,-1,0);let b=null!==(e=t.length)&&void 0!==e?e:v.length?y[0]+v[0].length:0;return new Rl(l[t.topID],v.reverse(),y.reverse(),b)}(t)}}Rl.empty=new Rl(Tl.none,[],[],0);class Pl{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 Pl(this.buffer,this.index)}}class Il{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return Tl.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&&!(Nl(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 Il(s,r,this.set)}}function Nl(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 Ll(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 Hl&&t.index<0?null:t.parent;if(!e)return t;t=e}let r=n?0:Bl.IgnoreOverlays;if(n)for(let n=t,o=n.parent;o;n=o,o=n.parent)n instanceof Hl&&n.index<0&&(null===(s=o.enter(e,i,r))||void 0===s?void 0:s.from)!=n.from&&(t=o);for(;;){let n=t.enter(e,i,r);if(!n)return t;t=n}}class Vl{cursor(t=0){return new Kl(this,t)}getChild(t,e=null,i=null){let n=Wl(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return Wl(this,t,e,i)}resolve(t,e=0){return Ll(this,t,e,!1)}resolveInner(t,e=0){return Ll(this,t,e,!0)}matchContext(t){return _l(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 Hl extends Vl{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:h}=r._tree,l=e>0?o.length:-1;t!=l;t+=e){let l=o[t],a=h[t]+r.from;if(Nl(n,i,a,a+l.length))if(l instanceof Il){if(s&Bl.ExcludeBuffers)continue;let o=l.findChild(0,l.buffer.length,e,i-a,n);if(o>-1)return new Fl(new zl(r,l,t,a),null,o)}else if(s&Bl.IncludeAnonymous||!l.type.isAnonymous||$l(l)){let o;if(!(s&Bl.IgnoreMounts)&&(o=Cl.get(l))&&!o.overlay)return new Hl(o.tree,a,t,r);let h=new Hl(l,a,t,r);return s&Bl.IncludeAnonymous||!h.type.isAnonymous?h:h.nextChild(e<0?l.children.length-1:0,e,i,n)}}if(s&Bl.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&Bl.IgnoreOverlays)&&(n=Cl.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 Hl(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 Wl(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 _l(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 zl{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}}class Fl extends Vl{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 Fl(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&Bl.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 Fl(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 Fl(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 Fl(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 Rl(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function ql(t){if(!t.length)return null;let e=0,i=t[0];for(let n=1;n<t.length;n++){let s=t[n];(s.from>i.from||s.to<i.to)&&(i=s,e=n)}let n=i instanceof Hl&&i.index<0?null:i.parent,s=t.slice();return n?s[e]=n:s.splice(e,1),new jl(s,i)}class jl{constructor(t,e){this.heads=t,this.node=e}get next(){return ql(this.heads)}}class Kl{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 Hl)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 Hl?(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&Bl.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Bl.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&Bl.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&Bl.IncludeAnonymous||t instanceof Il||!t.type.isAnonymous||$l(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 t=i;t<this.stack.length;t++)e=new Fl(this.buffer,e,this.stack[t]);return this.bufferNode=new Fl(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 _l(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 _l(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 $l(t){return t.children.some((t=>t instanceof Il||!t.type.isAnonymous||$l(t)))}const Jl=new WeakMap;function Ul(t,e){if(!t.isAnonymous||e instanceof Il||e.type!=t)return 1;let i=Jl.get(e);if(null==i){i=1;for(let n of e.children){if(n.type!=t||!(n instanceof Rl)){i=1;break}i+=Ul(t,n)}Jl.set(e,i)}return i}function Gl(t,e,i,n,s,r,o,h,l){let a=0;for(let i=n;i<s;i++)a+=Ul(t,e[i]);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],p=Ul(t,i[a]);for(a++;a<o;a++){let e=Ul(t,i[a]);if(p+e>=c)break;p+=e}if(a==s+1){if(p>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(Gl(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 Ml({perNode:!0});function Xl(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 Yl=Xl(na,0),Ql=Xl(ia,0),Zl=Xl(((t,e)=>ia(t,e,function(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),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}(e))),0);function ta(t,e){let i=t.languageDataAt("commentTokens",e);return i.length?i[0]:{}}const ea=50;function ia(t,e,i=e.selection.ranges){let n=i.map((t=>ta(e,t.from).block));if(!n.every((t=>t)))return null;let s=i.map(((t,i)=>function(t,{open:e,close:i},n,s){let r,o,h=t.sliceDoc(n-ea,n),l=t.sliceDoc(s,s+ea),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*ea?r=o=t.sliceDoc(n,s):(r=t.sliceDoc(n,n+ea),o=t.sliceDoc(s-ea,s));let f=/^\s*/.exec(r)[0].length,d=/\s*$/.exec(o)[0].length,p=o.length-d-i.length;return r.slice(f,f+e.length)==e&&o.slice(p,p+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(p-1))?1:0}}:null}(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 na(t,e,i=e.selection.ranges){let n=[],s=-1;for(let{from:t,to:r}of i){let i=n.length,o=1e9,h=ta(e,t).line;if(h){for(let i=t;i<=r;){let l=e.doc.lineAt(i);if(l.from>s&&(t==r||r>l.from)){s=l.from;let t=/^\s*/.exec(l.text)[0].length,e=t==l.length,i=l.text.slice(t,t+h.length)==h?t:-1;t<l.text.length&&t<o&&(o=t),n.push({line:l,comment:i,token:h,indent:t,empty:e,single:!1})}i=l.to+1}if(o<1e9)for(let t=i;t<n.length;t++)n[t].indent<n[t].line.text.length&&(n[t].indent=o);n.length==i+1&&(n[i].single=!0)}}if(2!=t&&n.some((t=>t.comment<0&&(!t.empty||t.single)))){let t=[];for(let{line:e,token:i,indent:s,empty:r,single:o}of n)!o&&r||t.push({from:e.from+s,insert:i+" "});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 sa=n.q6.define(),ra=n.q6.define(),oa=n.r$.define(),ha=n.r$.define({combine:t=>(0,n.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)})}),la=n.QQ.define({create:()=>Ma.empty,update(t,e){let i=e.state.facet(ha),s=e.annotation(sa);if(s){let n=ga.fromTransaction(e,s.selection),r=s.side,o=0==r?t.undone:t.done;return o=n?ma(o,o.length,i.minDepth,n):ba(o,e.startState.selection),new Ma(0==r?s.rest:o,0==r?o:s.rest)}let r=e.annotation(ra);if("full"!=r&&"before"!=r||(t=t.isolate()),!1===e.annotation(n.YW.addToHistory))return e.changes.empty?t:t.addMapping(e.changes.desc);let o=ga.fromTransaction(e),h=e.annotation(n.YW.time),l=e.annotation(n.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=>({done:t.done.map((t=>t.toJSON())),undone:t.undone.map((t=>t.toJSON()))}),fromJSON:t=>new Ma(t.done.map(ga.fromJSON),t.undone.map(ga.fromJSON))});function aa(t={}){return[la,ha.of(t),As.domEventHandlers({beforeinput(t,e){let i="historyUndo"==t.inputType?ua:"historyRedo"==t.inputType?fa:null;return!!i&&(t.preventDefault(),i(e))}})]}function ca(t,e){return function({state:i,dispatch:n}){if(!e&&i.readOnly)return!1;let s=i.field(la,!1);if(!s)return!1;let r=s.pop(t,i,e);return!!r&&(n(r),!0)}}const ua=ca(0,!1),fa=ca(1,!1),da=ca(0,!0),pa=ca(1,!0);class ga{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 ga(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 ga(t.changes&&n.as.fromJSON(t.changes),[],t.mapped&&n.n0.fromJSON(t.mapped),t.startSelection&&n.jT.fromJSON(t.startSelection),t.selectionsAfter.map(n.jT.fromJSON))}static fromTransaction(t,e){let i=va;for(let e of t.startState.facet(oa)){let n=e(t);n.length&&(i=i.concat(n))}return!i.length&&t.changes.empty?null:new ga(t.changes.invert(t.startState.doc),i,void 0,e||t.startState.selection,va)}static selection(t){return new ga(void 0,va,void 0,void 0,t)}}function ma(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 wa(t,e){return t.length?e.length?t.concat(e):t:e}const va=[],ya=200;function ba(t,e){if(t.length){let i=t[t.length-1],n=i.selectionsAfter.slice(Math.max(0,i.selectionsAfter.length-ya));return n.length&&n[n.length-1].eq(e)?t:(n.push(e),ma(t,t.length-1,1e9,i.setSelAfter(n)))}return[ga.selection([e])]}function xa(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 ka(t,e){if(!t.length)return t;let i=t.length,n=va;for(;i;){let s=Sa(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?[ga.selection(n)]:va}function Sa(t,e,i){let s=wa(t.selectionsAfter.length?t.selectionsAfter.map((t=>t.map(e))):va,i);if(!t.changes)return ga.selection(s);let r=t.changes.map(e),o=e.mapDesc(t.changes,!0),h=t.mapped?t.mapped.composeDesc(o):o;return new ga(r,n.Py.mapEffects(t.effects,e),h,t.startSelection.map(o),s)}const Aa=/^(input\.type|delete)($|\.)/;class Ma{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 Ma(this.done,this.undone):this}addChanges(t,e,i,n,s){let r=this.done,o=r[r.length-1];return r=o&&o.changes&&!o.changes.empty&&t.changes&&(!i||Aa.test(i))&&(!o.selectionsAfter.length&&e-this.prevTime<n.newGroupDelay&&n.joinToEvent(s,function(t,e){let i=[],n=!1;return t.iterChangedRanges(((t,e)=>i.push(t,e))),e.iterChangedRanges(((t,e,s,r)=>{for(let t=0;t<i.length;){let e=i[t++],o=i[t++];r>=e&&s<=o&&(n=!0)}})),n}(o.changes,t.changes))||"input.type.compose"==i)?ma(r,r.length-1,n.minDepth,new ga(t.changes.compose(o.changes),wa(t.effects,o.effects),o.mapped,o.startSelection,va)):ma(r,r.length,n.minDepth,t),new Ma(r,va,e,i)}addSelection(t,e,i,n){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:va;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 Ma(ba(this.done,t),this.undone,e,i);var r,o}addMapping(t){return new Ma(ka(this.done,t),ka(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:sa.of({side:t,rest:xa(n),selection:r}),userEvent:0==t?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let i=1==n.length?va:n.slice(0,n.length-1);return s.mapped&&(i=ka(i,s.mapped)),e.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:sa.of({side:t,rest:i,selection:r}),filter:!1,userEvent:0==t?"undo":"redo",scrollIntoView:!0})}return null}}Ma.empty=new Ma(va,va);const Ca=[{key:"Mod-z",run:ua,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:fa,preventDefault:!0},{linux:"Ctrl-Shift-z",run:fa,preventDefault:!0},{key:"Mod-u",run:da,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:pa,preventDefault:!0}];function Oa(t,e){return n.jT.create(t.ranges.map(e),t.mainIndex)}function Ta(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Da({state:t,dispatch:e},i){let n=Oa(t.selection,i);return!n.eq(t.selection,!0)&&(e(Ta(t,n)),!0)}function Ea(t,e){return n.jT.cursor(e?t.to:t.from)}function Ba(t,e){return Da(t,(i=>i.empty?t.moveByChar(i,e):Ea(i,e)))}function Ra(t){return t.textDirectionAt(t.state.selection.main.head)==Oi.LTR}const Pa=t=>Ba(t,!Ra(t)),Ia=t=>Ba(t,Ra(t));function Na(t,e){return Da(t,(i=>i.empty?t.moveByGroup(i,e):Ea(i,e)))}"undefined"!=typeof Intl&&Intl.Segmenter;function La(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 Va(t,e,i){let s,r,o=_h(t).resolveInner(e.head),h=i?Ml.closedBy:Ml.openedBy;for(let n=e.head;;){let e=i?o.childAfter(n):o.childBefore(n);if(!e)break;La(t,e,h)?o=e:n=i?e.to:e.from}return r=o.type.prop(h)&&(s=i?gl(t,o.from,1):gl(t,o.to,-1))&&s.matched?i?s.end.to:s.end.from:i?o.to:o.from,n.jT.cursor(r,i?-1:1)}function Ha(t,e){return Da(t,(i=>{if(!i.empty)return Ea(i,e);let n=t.moveVertically(i,e);return n.head!=i.head?n:t.moveToLineBoundary(i,e)}))}const Wa=t=>Ha(t,!1),_a=t=>Ha(t,!0);function za(t){let e,i=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,n=0,s=0;if(i){for(let e of t.state.facet(As.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 Fa(t,e){let i,n=za(t),{state:s}=t,r=Oa(s.selection,(i=>i.empty?t.moveVertically(i,e,n.height):Ea(i,e)));if(r.eq(s.selection))return!1;if(n.selfScroll){let e=t.coordsAtPos(s.selection.main.head),o=t.scrollDOM.getBoundingClientRect(),h=o.top+n.marginTop,l=o.bottom-n.marginBottom;e&&e.top>h&&e.bottom<l&&(i=As.scrollIntoView(r.main.head,{y:"start",yMargin:e.top-h}))}return t.dispatch(Ta(s,r),{effects:i}),!0}const qa=t=>Fa(t,!1),ja=t=>Fa(t,!0);function Ka(t,e,i){let s=t.lineBlockAt(e.head),r=t.moveToLineBoundary(e,i);if(r.head==e.head&&r.head!=(i?s.to:s.from)&&(r=t.moveToLineBoundary(e,i,!1)),!i&&r.head==s.from&&s.length){let i=/^\s*/.exec(t.state.sliceDoc(s.from,Math.min(s.from+100,s.to)))[0].length;i&&e.head!=s.from+i&&(r=n.jT.cursor(s.from+i))}return r}function $a(t,e,i){let s=!1,r=Oa(t.selection,(e=>{let r=gl(t,e.head,-1)||gl(t,e.head,1)||e.head>0&&gl(t,e.head-1,1)||e.head<t.doc.length&&gl(t,e.head+1,-1);if(!r||!r.end)return e;s=!0;let o=r.start.from==e.head?r.end.to:r.end.from;return i?n.jT.range(e.anchor,o):n.jT.cursor(o)}));return!!s&&(e(Ta(t,r)),!0)}function Ja(t,e){let i=Oa(t.state.selection,(t=>{let i=e(t);return n.jT.range(t.anchor,i.head,i.goalColumn,i.bidiLevel||void 0)}));return!i.eq(t.state.selection)&&(t.dispatch(Ta(t.state,i)),!0)}function Ua(t,e){return Ja(t,(i=>t.moveByChar(i,e)))}const Ga=t=>Ua(t,!Ra(t)),Xa=t=>Ua(t,Ra(t));function Ya(t,e){return Ja(t,(i=>t.moveByGroup(i,e)))}function Qa(t,e){return Ja(t,(i=>t.moveVertically(i,e)))}const Za=t=>Qa(t,!1),tc=t=>Qa(t,!0);function ec(t,e){return Ja(t,(i=>t.moveVertically(i,e,za(t).height)))}const ic=t=>ec(t,!1),nc=t=>ec(t,!0),sc=({state:t,dispatch:e})=>(e(Ta(t,{anchor:0})),!0),rc=({state:t,dispatch:e})=>(e(Ta(t,{anchor:t.doc.length})),!0),oc=({state:t,dispatch:e})=>(e(Ta(t,{anchor:t.selection.main.anchor,head:0})),!0),hc=({state:t,dispatch:e})=>(e(Ta(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0);function lc(t,e){if(t.state.readOnly)return!1;let i="delete.selection",{state:s}=t,r=s.changeByRange((s=>{let{from:r,to:o}=s;if(r==o){let n=e(s);n<r?(i="delete.backward",n=ac(t,n,!1)):n>r&&(i="delete.forward",n=ac(t,n,!0)),r=Math.min(r,n),o=Math.max(o,n)}else r=ac(t,r,!1),o=ac(t,o,!0);return r==o?{range:s}:{changes:{from:r,to:o},range:n.jT.cursor(r,r<s.head?-1:1)}}));return!r.changes.empty&&(t.dispatch(s.update(r,{scrollIntoView:!0,userEvent:i,effects:"delete.selection"==i?As.announce.of(s.phrase("Selection deleted")):void 0})),!0)}function ac(t,e,i){if(t instanceof As)for(let n of t.state.facet(As.atomicRanges).map((e=>e(t))))n.between(e,e,((t,n)=>{t<e&&n>e&&(e=i?n:t)}));return e}const cc=(t,e)=>lc(t,(i=>{let s,r,o=i.from,{state:h}=t,l=h.doc.lineAt(o);if(!e&&o>l.from&&o<l.from+200&&!/[^ \t]/.test(s=l.text.slice(0,o-l.from))){if("\t"==s[s.length-1])return o-1;let t=(0,n.IS)(s,h.tabSize)%Qh(h)||Qh(h);for(let e=0;e<t&&" "==s[s.length-1-e];e++)o--;r=o}else r=(0,n.cp)(l.text,o-l.from,e,e)+l.from,r==o&&l.number!=(e?h.doc.lines:1)?r+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(l.text.slice(r-l.from,o-l.from))&&(r=(0,n.cp)(l.text,r-l.from,!1,!1)+l.from);return r})),uc=t=>cc(t,!1),fc=t=>cc(t,!0),dc=(t,e)=>lc(t,(i=>{let s=i.head,{state:r}=t,o=r.doc.lineAt(s),h=r.charCategorizer(s);for(let t=null;;){if(s==(e?o.to:o.from)){s==i.head&&o.number!=(e?r.doc.lines:1)&&(s+=e?1:-1);break}let l=(0,n.cp)(o.text,s-o.from,e)+o.from,a=o.text.slice(Math.min(s,l)-o.from,Math.max(s,l)-o.from),c=h(a);if(null!=t&&c!=t)break;" "==a&&s==i.head||(t=c),s=l}return s})),pc=t=>dc(t,!1);function gc(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 mc(t,e,i){if(t.readOnly)return!1;let s=[],r=[];for(let e of gc(t)){if(i?e.to==t.doc.length:0==e.from)continue;let o=t.doc.lineAt(i?e.to+1:e.from-1),h=o.length+1;if(i){s.push({from:e.to,to:o.to},{from:e.from,insert:o.text+t.lineBreak});for(let i of e.ranges)r.push(n.jT.range(Math.min(t.doc.length,i.anchor+h),Math.min(t.doc.length,i.head+h)))}else{s.push({from:o.from,to:e.from},{from:e.to,insert:t.lineBreak+o.text});for(let t of e.ranges)r.push(n.jT.range(t.anchor-h,t.head-h))}}return!!s.length&&(e(t.update({changes:s,scrollIntoView:!0,selection:n.jT.create(r,t.selection.mainIndex),userEvent:"move.line"})),!0)}function wc(t,e,i){if(t.readOnly)return!1;let n=[];for(let e of gc(t))i?n.push({from:e.from,insert:t.doc.slice(e.from,e.to)+t.lineBreak}):n.push({from:e.to,insert:t.lineBreak+t.doc.slice(e.from,e.to)});return e(t.update({changes:n,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const vc=yc(!1);function yc(t){return({state:e,dispatch:i})=>{if(e.readOnly)return!1;let s=e.changeByRange((i=>{let{from:s,to:r}=i,o=e.doc.lineAt(s),h=!t&&s==r&&function(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let i,n=_h(t).resolveInner(e),s=n.childBefore(e),r=n.childAfter(e);return s&&r&&s.to<=e&&r.from>=e&&(i=s.type.prop(Ml.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}(e,s);t&&(s=r=(r<=o.to?o:e.doc.lineAt(r)).to);let l=new el(e,{simulateBreak:s,simulateDoubleBreak:!!h}),a=tl(l,s);for(null==a&&(a=(0,n.IS)(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));r<o.to&&/\s/.test(o.text[r-o.from]);)r++;h?({from:s,to:r}=h):s>o.from&&s<o.from+100&&!/\S/.test(o.text.slice(0,s))&&(s=o.from);let c=["",Zh(e,a)];return h&&c.push(Zh(e,l.lineIndent(o.from,-1))),{changes:{from:s,to:r,insert:n.xv.of(c)},range:n.jT.cursor(s+1+c[1].length)}}));return i(e.update(s,{scrollIntoView:!0,userEvent:"input"})),!0}}function bc(t,e){let i=-1;return t.changeByRange((s=>{let r=[];for(let n=s.from;n<=s.to;){let o=t.doc.lineAt(n);o.number>i&&(s.empty||s.to>o.from)&&(e(o,r,s),i=o.number),n=o.to+1}let o=t.changes(r);return{changes:r,range:n.jT.range(o.mapPos(s.anchor,1),o.mapPos(s.head,1))}}))}const xc=({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(bc(t,((e,i)=>{i.push({from:e.from,insert:t.facet(Yh)})})),{userEvent:"input.indent"})),!0),kc=({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(bc(t,((e,i)=>{let s=/^\s*/.exec(e.text)[0];if(!s)return;let r=(0,n.IS)(s,t.tabSize),o=0,h=Zh(t,Math.max(0,r-Qh(t)));for(;o<s.length&&o<h.length&&s.charCodeAt(o)==h.charCodeAt(o);)o++;i.push({from:e.from+o,to:e.from+s.length,insert:h.slice(o)})})),{userEvent:"delete.dedent"})),!0),Sc=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:t=>Da(t,(e=>Va(t.state,e,!Ra(t)))),shift:t=>Ja(t,(e=>Va(t.state,e,!Ra(t))))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:t=>Da(t,(e=>Va(t.state,e,Ra(t)))),shift:t=>Ja(t,(e=>Va(t.state,e,Ra(t))))},{key:"Alt-ArrowUp",run:({state:t,dispatch:e})=>mc(t,e,!1)},{key:"Shift-Alt-ArrowUp",run:({state:t,dispatch:e})=>wc(t,e,!1)},{key:"Alt-ArrowDown",run:({state:t,dispatch:e})=>mc(t,e,!0)},{key:"Shift-Alt-ArrowDown",run:({state:t,dispatch:e})=>wc(t,e,!0)},{key:"Escape",run:({state:t,dispatch:e})=>{let i=t.selection,s=null;return i.ranges.length>1?s=n.jT.create([i.main]):i.main.empty||(s=n.jT.create([n.jT.cursor(i.main.head)])),!!s&&(e(Ta(t,s)),!0)}},{key:"Mod-Enter",run:yc(!0)},{key:"Alt-l",mac:"Ctrl-l",run:({state:t,dispatch:e})=>{let i=gc(t).map((({from:e,to:i})=>n.jT.range(e,Math.min(i+1,t.doc.length))));return e(t.update({selection:n.jT.create(i),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:t,dispatch:e})=>{let i=Oa(t.selection,(e=>{var i;for(let s=_h(t).resolveStack(e.from,1);s;s=s.next){let{node:t}=s;if((t.from<e.from&&t.to>=e.to||t.to>e.to&&t.from<=e.from)&&(null===(i=t.parent)||void 0===i?void 0:i.parent))return n.jT.range(t.to,t.from)}return e}));return e(Ta(t,i)),!0},preventDefault:!0},{key:"Mod-[",run:kc},{key:"Mod-]",run:xc},{key:"Mod-Alt-\\",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=Object.create(null),n=new el(t,{overrideIndentation:t=>{let e=i[t];return null==e?-1:e}}),s=bc(t,((e,s,r)=>{let o=tl(n,e.from);if(null==o)return;/\S/.test(e.text)||(o=0);let h=/^\s*/.exec(e.text)[0],l=Zh(t,o);(h!=l||r.from<e.from+h.length)&&(i[e.from]=o,s.push({from:e.from,to:e.from+h.length,insert:l}))}));return s.changes.empty||e(t.update(s,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:t=>{if(t.state.readOnly)return!1;let{state:e}=t,i=e.changes(gc(e).map((({from:t,to:i})=>(t>0?t--:i<e.doc.length&&i++,{from:t,to:i})))),n=Oa(e.selection,(e=>t.moveVertically(e,!0))).map(i);return t.dispatch({changes:i,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:t,dispatch:e})=>$a(t,e,!1)},{key:"Mod-/",run:t=>{let{state:e}=t,i=e.doc.lineAt(e.selection.main.from),n=ta(t.state,i.from);return n.line?Yl(t):!!n.block&&Zl(t)}},{key:"Alt-A",run:Ql}].concat([{key:"ArrowLeft",run:Pa,shift:Ga,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:t=>Na(t,!Ra(t)),shift:t=>Ya(t,!Ra(t)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:t=>Da(t,(e=>Ka(t,e,!Ra(t)))),shift:t=>Ja(t,(e=>Ka(t,e,!Ra(t)))),preventDefault:!0},{key:"ArrowRight",run:Ia,shift:Xa,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:t=>Na(t,Ra(t)),shift:t=>Ya(t,Ra(t)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:t=>Da(t,(e=>Ka(t,e,Ra(t)))),shift:t=>Ja(t,(e=>Ka(t,e,Ra(t)))),preventDefault:!0},{key:"ArrowUp",run:Wa,shift:Za,preventDefault:!0},{mac:"Cmd-ArrowUp",run:sc,shift:oc},{mac:"Ctrl-ArrowUp",run:qa,shift:ic},{key:"ArrowDown",run:_a,shift:tc,preventDefault:!0},{mac:"Cmd-ArrowDown",run:rc,shift:hc},{mac:"Ctrl-ArrowDown",run:ja,shift:nc},{key:"PageUp",run:qa,shift:ic},{key:"PageDown",run:ja,shift:nc},{key:"Home",run:t=>Da(t,(e=>Ka(t,e,!1))),shift:t=>Ja(t,(e=>Ka(t,e,!1))),preventDefault:!0},{key:"Mod-Home",run:sc,shift:oc},{key:"End",run:t=>Da(t,(e=>Ka(t,e,!0))),shift:t=>Ja(t,(e=>Ka(t,e,!0))),preventDefault:!0},{key:"Mod-End",run:rc,shift:hc},{key:"Enter",run:vc},{key:"Mod-a",run:({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:uc,shift:uc},{key:"Delete",run:fc},{key:"Mod-Backspace",mac:"Alt-Backspace",run:pc},{key:"Mod-Delete",mac:"Alt-Delete",run:t=>dc(t,!0)},{mac:"Mod-Backspace",run:t=>lc(t,(e=>{let i=t.moveToLineBoundary(e,!1).head;return e.head>i?i:Math.max(0,e.head-1)}))},{mac:"Mod-Delete",run:t=>lc(t,(e=>{let i=t.moveToLineBoundary(e,!0).head;return e.head<i?i:Math.min(t.state.doc.length,e.head+1)}))}].concat([{key:"Ctrl-b",run:Pa,shift:Ga,preventDefault:!0},{key:"Ctrl-f",run:Ia,shift:Xa},{key:"Ctrl-p",run:Wa,shift:Za},{key:"Ctrl-n",run:_a,shift:tc},{key:"Ctrl-a",run:t=>Da(t,(e=>n.jT.cursor(t.lineBlockAt(e.head).from,1))),shift:t=>Ja(t,(e=>n.jT.cursor(t.lineBlockAt(e.head).from)))},{key:"Ctrl-e",run:t=>Da(t,(e=>n.jT.cursor(t.lineBlockAt(e.head).to,-1))),shift:t=>Ja(t,(e=>n.jT.cursor(t.lineBlockAt(e.head).to)))},{key:"Ctrl-d",run:fc},{key:"Ctrl-h",run:uc},{key:"Ctrl-k",run:t=>lc(t,(e=>{let i=t.lineBlockAt(e.head).to;return e.head<i?i:Math.min(t.state.doc.length,e.head+1)}))},{key:"Ctrl-Alt-h",run:pc},{key:"Ctrl-o",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange((t=>({changes:{from:t.from,to:t.to,insert:n.xv.of(["",""])},range:n.jT.cursor(t.from)})));return e(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({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,s=t.doc.lineAt(i),r=i==s.from?i-1:(0,n.cp)(s.text,i-s.from,!1)+s.from,o=i==s.to?i+1:(0,n.cp)(s.text,i-s.from,!0)+s.from;return{changes:{from:r,to:o,insert:t.doc.slice(i,o).append(t.doc.slice(r,i))},range:n.jT.cursor(o)}}));return!i.changes.empty&&(e(t.update(i,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:ja}].map((t=>({mac:t.key,run:t.run,shift:t.shift})))))},67289:(t,e,i)=>{i.d(e,{Qf:()=>Vi,il:()=>Gi,QN:()=>Fi,nF:()=>zi,qz:()=>Ai});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 i of t.props)if(Array.isArray(i)||(i=i(n)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[i[0].id]=i[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 p{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 t of this.children){let i=t.toString();i&&(e&&(e+=","),e+=i)}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 t=n instanceof b?n:n.context.parent;t;t=t.parent)if(t.index<0){let r=t.parent;(s||(s=[n])).push(r.resolve(e,i)),t=r}else{let r=h.get(t.tree);if(r&&r.overlay&&r.overlay[0].from<=e&&r.overlay[r.overlay.length-1].to>=e){let o=new b(r.tree,r.overlay[0].from+t.from,-1,t);(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 t=this.cursor(r|d.IncludeAnonymous);;){let r=!1;if(t.from<=s&&t.to>=n&&(!o&&t.type.isAnonymous||!1!==e(t))){if(t.firstChild())continue;r=!0}for(;r&&i&&(o||!t.type.isAnonymous)&&i(t),!t.nextSibling();){if(!t.parent())return;r=!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:B(a.none,this.children,this.positions,0,this.children.length,0,this.length,((t,e,i)=>new p(this.type,t,e,i,this.propValues)),t.makeTree||((t,e,i)=>new p(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 g(i,i.length):i,c=s.types,u=0,f=0;function d(t,e,i,n,o,p){let{id:g,start:S,end:A,size:M}=a,C=f;for(;M<0;){if(a.next(),-1==M){let e=h[g];return i.push(e),void n.push(S-t)}if(-3==M)return void(u=g);if(-4==M)return void(f=g);throw new RangeError(`Unrecognized record size: ${M}`)}let O,T,D=c[g],E=S-t;if(A-S<=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=k(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=g>=l?g:-1,s=0,o=A;for(;a.pos>t;)n>=0&&a.id==n&&a.size>=0?(a.end<=o-r&&(y(e,i,S,s,a.end,o,n,C),s=e.length,o=a.end),a.next()):p>2500?w(S,t,e,i):d(S,t,e,i,n,p+1);if(n>=0&&s>0&&s<e.length&&y(e,i,S,s,S,o,n,C),e.reverse(),i.reverse(),n>-1&&s>0){let t=v(D);O=B(D,e,i,0,e.length,0,A-S,t,t)}else O=b(D,e,i,A-S,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 p){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 p(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 k(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=k(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=[],A=[];for(;a.pos>0;)d(t.start||0,t.bufferStart||0,S,A,-1,0);let M=null!==(e=t.length)&&void 0!==e?e:S.length?A[0]+S[0].length:0;return new p(c[t.topID],S.reverse(),A.reverse(),M)}(t)}}p.empty=new p(a.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 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 n=t,o=n.parent;o;n=o,o=n.parent)n instanceof b&&n.index<0&&(null===(s=o.enter(e,i,r))||void 0===s?void 0:s.from)!=n.from&&(t=o);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 k(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 S(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 k(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 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 p(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 n=1;n<t.length;n++){let s=t[n];(s.from>i.from||s.to<i.to)&&(i=s,e=n)}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 t=i;t<this.stack.length;t++)e=new A(this.buffer,e,this.stack[t]);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 k(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 k(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 p)){i=1;break}i+=E(t,n)}D.set(e,i)}return i}function B(t,e,i,n,s,r,o,h,l){let a=0;for(let i=n;i<s;i++)a+=E(t,e[i]);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],p=E(t,i[a]);for(a++;a<o;a++){let e=E(t,i[a]);if(p+e>=c)break;p+=e}if(a==s+1){if(p>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(B(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 R{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 R(0,t.length,t,0,!1,i)];for(let i of e)i.to>t.length&&n.push(i);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 R(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 I(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 I{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});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),V.from(n,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){let i=[];return this.decompose(t,e,i,0),V.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),i=this.length-this.scanIdentical(t,-1),n=new _(this),s=new _(t);for(let t=e,r=e;;){if(n.next(t),s.next(t),t=0,n.lineBreak!=s.lineBreak||n.done!=s.done||n.value!=s.value)return!1;if(r+=n.value.length,n.done||r>=i)return!0}}iter(t=1){return new _(this,t)}iterRange(t,e=this.length){return new z(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 F(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 L(t):V.from(L.split(t,[])):N.empty}}class L 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 q(n,o,i,r);n=o+1,i++}}decompose(t,e,i,n){let s=t<=0&&e>=this.length?this:new L(W(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 L(e,t.length+s.length));else{let t=e.length>>1;i.push(new L(e.slice(0,t)),new L(e.slice(t)))}}else i.push(s)}replace(t,e,i){if(!(i instanceof L))return super.replace(t,e,i);let n=H(this.text,H(i.text,W(this.text,0,t)),e),s=this.length+i.length-(e-t);return n.length<=32?new L(n,s):V.from(L.split(n,[]),s)}sliceString(t,e=this.length,i="\n"){let n="";for(let s=0,r=0;s<=e&&r<this.text.length;r++){let o=this.text[r],h=s+o.length;s>t&&r&&(n+=i),t<h&&e>s&&(n+=o.slice(Math.max(0,t-s),e-s)),s=h+1}return n}flatten(t){for(let e of this.text)t.push(e)}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 L(i,n)),i=[],n=-1);return n>-1&&e.push(new L(i,n)),e}}class V extends N{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let e of t)this.lines+=e.lines}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.children[s],o=n+r.length,h=i+r.lines-1;if((e?h:o)>=t)return r.lineInner(t,e,i,n);n=o+1,i=h+1}}decompose(t,e,i,n){for(let s=0,r=0;r<=e&&s<this.children.length;s++){let o=this.children[s],h=r+o.length;if(t<=h&&e>=r){let s=n&((r<=t?1:0)|(h>=e?2:0));r>=t&&h<=e&&!s?i.push(o):o.decompose(t-r,e-r,i,s)}r=h+1}}replace(t,e,i){if(i.lines<this.lines)for(let n=0,s=0;n<this.children.length;n++){let r=this.children[n],o=s+r.length;if(t>=s&&e<=o){let h=r.replace(t-s,e-s,i),l=this.lines-r.lines+h.lines;if(h.lines<l>>4&&h.lines>l>>6){let s=this.children.slice();return s[n]=h,new V(s,this.length-(e-t)+i.length)}return super.replace(s,o,h)}s=o+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i="\n"){let n="";for(let s=0,r=0;s<this.children.length&&r<=e;s++){let o=this.children[s],h=r+o.length;r>t&&s&&(n+=i),t<h&&e>r&&(n+=o.sliceString(t-r,e-r,i)),r=h+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof V))return 0;let i=0,[n,s,r,o]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;n+=e,s+=e){if(n==r||s==o)return i;let h=this.children[n],l=t.children[s];if(h!=l)return i+h.scanIdentical(l,e);i+=h.length+1}}static from(t,e=t.reduce(((t,e)=>t+e.length+1),-1)){let i=0;for(let e of t)i+=e.lines;if(i<32){let i=[];for(let e of t)e.flatten(i);return new L(i,e)}let n=Math.max(32,i>>5),s=n<<1,r=n>>1,o=[],h=0,l=-1,a=[];function c(t){let e;if(t.lines>s&&t instanceof V)for(let e of t.children)c(e);else t.lines>r&&(h>r||!h)?(u(),o.push(t)):t instanceof L&&h&&(e=a[a.length-1])instanceof L&&t.lines+e.lines<=32?(h+=t.lines,l+=t.length+1,a[a.length-1]=new L(e.text.concat(t.text),e.length+1+t.length)):(h+t.lines>n&&u(),h+=t.lines,l+=t.length+1,a.push(t))}function u(){0!=h&&(o.push(1==a.length?a[0]:V.from(a,l)),l=-1,h=a.length=0)}for(let e of t)c(e);return u(),1==o.length?o[0]:new V(o,e)}}function 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 W(t,e,i){return H(t,[""],e,i)}N.empty=new L([""],0);class _{constructor(t,e=1){this.dir=e,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[e>0?1:(t instanceof L?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],s=this.offsets[i],r=s>>1,o=n instanceof L?n.text.length:n.children.length;if(r==(e>0?o:0)){if(0==i)return this.done=!0,this.value="",this;e>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&s)==(e>0?0:1)){if(this.offsets[i]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(n instanceof L){let s=n.text[r+(e<0?-1:0)];if(this.offsets[i]+=e,s.length>Math.max(0,t))return this.value=0==t?s:e>0?s.slice(t):s.slice(0,s.length-t),this;t-=s.length}else{let s=n.children[r+(e<0?-1:0)];t>s.length?(t-=s.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(s),this.offsets.push(e>0?1:(s instanceof L?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 z{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new _(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 F{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()},_.prototype[Symbol.iterator]=z.prototype[Symbol.iterator]=F.prototype[Symbol.iterator]=function(){return this});class q{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 j="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<j.length;t++)j[t]+=j[t-1];function K(t){for(let e=1;e<j.length;e+=2)if(j[e]>t)return j[e-1]<=t;return!1}function $(t){return t>=127462&&t<=127487}const J=8205;function U(t,e,i=!0,n=!0){return(i?G:X)(t,e,n)}function G(t,e,i){if(e==t.length)return e;e&&Y(t.charCodeAt(e))&&Q(t.charCodeAt(e-1))&&e--;let n=Z(t,e);for(e+=tt(n);e<t.length;){let s=Z(t,e);if(n==J||s==J||i&&K(s))e+=tt(s),n=s;else{if(!$(s))break;{let i=0,n=e-2;for(;n>=0&&$(Z(t,n));)i++,n-=2;if(i%2==0)break;e+=2}}}return e}function X(t,e,i){for(;e>0;){let n=G(t,e-2,i);if(n<e)return n;e--}return 0}function Y(t){return t>=56320&&t<57344}function Q(t){return t>=55296&&t<56320}function Z(t,e){let i=t.charCodeAt(e);if(!Q(i)||e+1==t.length)return i;let n=t.charCodeAt(e+1);return Y(n)?n-56320+(i-55296<<10)+65536:i}function tt(t){return t<65536?1:2}const et=/\r\n?|\n/;var it=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(it||(it={}));class nt{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){ht(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 nt(t)}composeDesc(t){return this.empty?t:t.empty?this:at(this,t)}mapDesc(t,e=!1){return t.empty?this:lt(this,t,e)}mapPos(t,e=-1,i=it.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!=it.Simple&&l>=t&&(i==it.TrackDel&&n<t&&l>t||i==it.TrackBefore&&n<t||i==it.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 nt(t)}static create(t){return new nt(t)}}class st extends nt{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 ht(this,((e,i,n,s,r)=>t=t.replace(n,n+(i-e),r)),!1),t}mapDesc(t,e=!1){return lt(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let n=0,s=0;n<e.length;n+=2){let r=e[n],o=e[n+1];if(o>=0){e[n]=o,e[n+1]=r;let h=n>>1;for(;i.length<h;)i.push(N.empty);i.push(r?t.slice(s,s+r):N.empty)}s+=r}return new st(e,i)}compose(t){return this.empty?t:t.empty?this:at(this,t,!0)}map(t,e=!1){return t.empty?this:lt(this,t,e,!0)}iterChanges(t,e=!1){ht(this,t,e)}get desc(){return nt.create(this.sections)}filter(t){let e=[],i=[],n=[],s=new ct(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);rt(n,t,-1);let r=-1==s.ins?-1:0==s.off?s.ins:0;rt(e,t,r),r>0&&ot(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);rt(e,t,-1),rt(n,t,-1==s.ins?-1:0==s.off?s.ins:0),s.forward(t),o+=t}}return{changes:new st(e,i),filtered:nt.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=[],s=[],r=0,o=null;function h(t=!1){if(!t&&!n.length)return;r<e&&rt(n,e-r,-1);let i=new st(n,s);o=o?o.compose(i.map(o)):i,n=[],s=[],r=0}return function t(l){if(Array.isArray(l))for(let e of l)t(e);else if(l instanceof st){if(l.length!=e)throw new RangeError(`Mismatched change set length (got ${l.length}, expected ${e})`);h(),o=o?o.compose(l.map(o)):l}else{let{from:t,to:o=t,insert:a}=l;if(t>o||t<0||o>e)throw new RangeError(`Invalid change range ${t} to ${o} (in doc of length ${e})`);let c=a?"string"==typeof a?N.of(a.split(i||et)):a:N.empty,u=c.length;if(t==o&&0==u)return;t<r&&h(),t>r&&rt(n,t-r,-1),rt(n,o-t,u),ot(s,n,c),r=o}}(t),h(!o),o}static empty(t){return new st(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 s=t[n];if("number"==typeof s)e.push(s,-1);else{if(!Array.isArray(s)||"number"!=typeof s[0]||s.some(((t,e)=>e&&"string"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==s.length)e.push(s[0],0);else{for(;i.length<n;)i.push(N.empty);i[n]=N.of(s.slice(1)),e.push(s[0],i[n].length)}}}return new st(e,i)}static createSet(t,e){return new st(t,e)}}function rt(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 ot(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(N.empty);t.push(i)}}function ht(t,e,i){let n=t.inserted;for(let s=0,r=0,o=0;o<t.sections.length;){let h=t.sections[o++],l=t.sections[o++];if(l<0)s+=h,r+=h;else{let a=s,c=r,u=N.empty;for(;a+=h,c+=l,l&&n&&(u=u.append(n[o-2>>1])),!(i||o==t.sections.length||t.sections[o+1]<0);)h=t.sections[o++],l=t.sections[o++];e(s,a,r,c,u),s=a,r=c}}}function lt(t,e,i,n=!1){let s=[],r=n?[]:null,o=new ct(t),h=new ct(e);for(let t=-1;;)if(-1==o.ins&&-1==h.ins){let t=Math.min(o.len,h.len);rt(s,t,-1),o.forward(t),h.forward(t)}else if(h.ins>=0&&(o.ins<0||t==o.i||0==o.off&&(h.len<o.len||h.len==o.len&&!i))){let e=h.len;for(rt(s,h.ins,-1);e;){let i=Math.min(o.len,e);o.ins>=0&&t<o.i&&o.len<=i&&(rt(s,0,o.ins),r&&ot(r,s,o.text),t=o.i),o.forward(i),e-=i}h.next()}else{if(!(o.ins>=0)){if(o.done&&h.done)return r?st.createSet(s,r):nt.create(s);throw new Error("Mismatched change set lengths")}{let e=0,i=o.len;for(;i;)if(-1==h.ins){let t=Math.min(i,h.len);e+=t,i-=t,h.forward(t)}else{if(!(0==h.ins&&h.len<i))break;i-=h.len,h.next()}rt(s,e,t<o.i?o.ins:0),r&&t<o.i&&ot(r,s,o.text),t=o.i,o.forward(o.len-i)}}}function at(t,e,i=!1){let n=[],s=i?[]:null,r=new ct(t),o=new ct(e);for(let t=!1;;){if(r.done&&o.done)return s?st.createSet(n,s):nt.create(n);if(0==r.ins)rt(n,r.len,0,t),r.next();else if(0!=o.len||o.done){if(r.done||o.done)throw new Error("Mismatched change set lengths");{let e=Math.min(r.len2,o.len),i=n.length;if(-1==r.ins){let i=-1==o.ins?-1:o.off?0:o.ins;rt(n,e,i,t),s&&i&&ot(s,n,o.text)}else-1==o.ins?(rt(n,r.off?0:r.len,e,t),s&&ot(s,n,r.textBit(e))):(rt(n,r.off?0:r.len,o.off?0:o.ins,t),s&&!o.off&&ot(s,n,o.text));t=(r.ins>e||o.ins>=0&&o.len>e)&&(t||n.length>i),r.forward2(e),o.forward(e)}}else rt(n,0,o.ins,t),s&&ot(s,n,o.text),o.next()}}class ct{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 ut{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 ut(i,n,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return ft.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return ft.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 ft.range(t.anchor,t.head)}static create(t,e,i){return new ut(t,e,i)}}class ft{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:ft.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 ft([this.main],0)}addRange(t,e=!0){return ft.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,ft.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 ft(t.ranges.map((t=>ut.fromJSON(t))),t.main)}static single(t,e=t){return new ft([ft.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 ft.normalized(t.slice(),e);i=s.to}return new ft(t,e)}static cursor(t,e=0,i,n){return ut.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?ut.create(e,t,24|s):ut.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 i=1;i<t.length;i++){let n=t[i],s=t[i-1];if(n.empty?n.from<=s.to:n.from<s.to){let r=s.from,o=Math.max(n.to,s.to);i<=e&&e--,t.splice(--i,2,n.anchor>n.head?ft.range(o,r):ft.range(r,o))}}return new ft(t,e)}}function dt(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let pt=0;class gt{constructor(t,e,i,n,s){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=pt++,this.default=t([]),this.extensions="function"==typeof s?s(this):s}static define(t={}){return new gt(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:mt),!!t.static,t.enables)}of(t){return new wt([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new wt(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new wt(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],(i=>e(i.field(t))))}}function mt(t,e){return t==e||t.length==e.length&&t.every(((t,i)=>t===e[i]))}class wt{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=pt++}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 i of this.dependencies)"doc"==i?h=!0:"selection"==i?l=!0:0==(1&(null!==(e=t[i.id])&&void 0!==e?e:1))&&a.push(t[i.id]);return{create:t=>(t.values[r]=i(t),1),update(t,e){if(h&&e.docChanged||l&&(e.docChanged||e.selection)||yt(t,a)){let e=i(t);if(o?!vt(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 gt?e.facet(i)===t.facet(i):!(i instanceof kt)||e.field(i,!1)==t.field(i,!1)))||(o?vt(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 vt(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 yt(t,e){let i=!1;for(let n of e)1&Pt(t,n)&&(i=!0);return i}function bt(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)Pt(t,e);return t.values[o]=h(t),1},update(t,i){if(!yt(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=yt(t,n),l=s.config.facets[e.id],a=s.facet(e);if(l&&!r&&mt(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 xt=gt.define({static:!0});class kt{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 kt(pt++,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(xt).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,xt.of({field:this,create:t})]}get extension(){return this}}const St=4,At=3,Mt=2,Ct=1;function Ot(t){return e=>new Dt(e,t)}const Tt={highest:Ot(0),high:Ot(Ct),default:Ot(Mt),low:Ot(At),lowest:Ot(St)};class Dt{constructor(t,e){this.inner=t,this.prec=e}}class Et{of(t){return new Bt(this,t)}reconfigure(t){return Et.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class Bt{constructor(t,e){this.compartment=t,this.inner=e}}class Rt{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 i of function(t,e,i){let n=[[],[],[],[],[]],s=new Map;function r(t,o){let h=s.get(t);if(null!=h){if(h<=o)return;let e=n[h].indexOf(t);e>-1&&n[h].splice(e,1),t instanceof Bt&&i.delete(t.compartment)}if(s.set(t,o),Array.isArray(t))for(let e of t)r(e,o);else if(t instanceof Bt){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 Dt)r(t.inner,t.prec);else if(t instanceof kt)n[o].push(t),t.provides&&r(t.provides,o);else if(t instanceof wt)n[o].push(t),t.facet.extensions&&r(t.facet.extensions,Mt);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,Mt),n.reduce(((t,e)=>t.concat(e)))}(t,e,r))i instanceof kt?n.push(i):(s[i.facet.id]||(s[i.facet.id]=[])).push(i);let o=Object.create(null),h=[],l=[];for(let t of n)o[t.id]=l.length<<1,l.push((e=>t.slot(e)));let a=null==i?void 0:i.config.facets;for(let t in s){let e=s[t],n=e[0].facet,r=a&&a[t]||[];if(e.every((t=>0==t.type)))if(o[n.id]=h.length<<1|1,mt(r,e))h.push(i.facet(n));else{let t=n.combine(e.map((t=>t.value)));h.push(i&&n.compare(t,i.facet(n))?i.facet(n):t)}else{for(let t of e)0==t.type?(o[t.id]=h.length<<1|1,h.push(t.value)):(o[t.id]=l.length<<1,l.push((e=>t.dynamicSlot(e))));o[n.id]=l.length<<1,l.push((t=>bt(t,n,e)))}}let c=l.map((t=>t(o)));return new Rt(t,r,c,o,h,s)}}function Pt(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=gt.define(),Lt=gt.define({combine:t=>t.some((t=>t)),static:!0}),Vt=gt.define({combine:t=>t.length?t[0]:void 0,static:!0}),Ht=gt.define(),Wt=gt.define(),_t=gt.define(),zt=gt.define({combine:t=>!!t.length&&t[0]});class Ft{constructor(t,e){this.type=t,this.value=e}static define(){return new qt}}class qt{of(t){return new Ft(this,t)}}class jt{constructor(t){this.map=t}of(t){return new Kt(this,t)}}class Kt{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 Kt(this.type,e)}is(t){return this.type==t}static define(t={}){return new jt(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}}Kt.reconfigure=Kt.define(),Kt.appendConfig=Kt.define();class $t{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&&dt(i,e.newLength),s.some((t=>t.type==$t.time))||(this.annotations=s.concat($t.time.of(Date.now())))}static create(t,e,i,n,s,r){return new $t(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($t.userEvent);return!(!e||!(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function Jt(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 Ut(t,e,i){var n;let s,r,o;return i?(s=e.changes,r=st.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:Kt.mapEffects(t.effects,s).concat(Kt.mapEffects(e.effects,r)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function Gt(t,e,i){let n=e.selection,s=Qt(e.annotations);return e.userEvent&&(s=s.concat($t.userEvent.of(e.userEvent))),{changes:e.changes instanceof st?e.changes:st.of(e.changes||[],i,t.facet(Vt)),selection:n&&(n instanceof ft?n:ft.single(n.anchor,n.head)),effects:Qt(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function Xt(t,e,i){let n=Gt(t,e.length?e[0]:{},t.doc.length);e.length&&!1===e[0].filter&&(i=!1);for(let s=1;s<e.length;s++){!1===e[s].filter&&(i=!1);let r=!!e[s].sequential;n=Ut(n,Gt(t,e[s],r?n.changes.newLength:t.doc.length),r)}let s=$t.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return function(t){let e=t.startState,i=e.facet(_t),n=t;for(let s=i.length-1;s>=0;s--){let r=i[s](t);r&&Object.keys(r).length&&(n=Ut(n,Gt(e,r,t.changes.newLength),!0))}return n==t?t:$t.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}(i?function(t){let e=t.startState,i=!0;for(let n of e.facet(Ht)){let e=n(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:Jt(i,e))}if(!0!==i){let n,s;if(!1===i)s=t.changes.invertedDesc,n=st.empty(e.doc.length);else{let e=t.changes.filter(i);n=e.changes,s=e.filtered.mapDesc(e.changes).invertedDesc}t=$t.create(e,n,t.selection&&t.selection.map(s),Kt.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let n=e.facet(Wt);for(let i=n.length-1;i>=0;i--){let s=n[i](t);t=s instanceof $t?s:Array.isArray(s)&&1==s.length&&s[0]instanceof $t?s[0]:Xt(e,Qt(s),!1)}return t}(s):s)}$t.time=Ft.define(),$t.userEvent=Ft.define(),$t.addToHistory=Ft.define(),$t.remote=Ft.define();const Yt=[];function Qt(t){return null==t?Yt:Array.isArray(t)?t:[t]}var Zt=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(Zt||(Zt={}));const te=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let ee;try{ee=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(t){}function ie(t){return e=>{if(!/\S/.test(e))return Zt.Space;if(function(t){if(ee)return ee.test(t);for(let e=0;e<t.length;e++){let i=t[e];if(/\w/.test(i)||i>"€"&&(i.toUpperCase()!=i.toLowerCase()||te.test(i)))return!0}return!1}(e))return Zt.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return Zt.Word;return Zt.Other}}class ne{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 t=0;t<this.config.dynamicSlots.length;t++)Pt(this,t<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(null!=i)return Pt(this,i),It(this,i);if(e)throw new RangeError("Field is not present in this state")}update(...t){return Xt(this,t,!0)}applyTransaction(t){let e,i=this.config,{base:n,compartments:s}=i;for(let e of t.effects)e.is(Et.reconfigure)?(i&&(s=new Map,i.compartments.forEach(((t,e)=>s.set(e,t))),i=null),s.set(e.value.compartment,e.value.extension)):e.is(Kt.reconfigure)?(i=null,n=e.value):e.is(Kt.appendConfig)&&(i=null,n=Qt(n).concat(e.value));if(i)e=t.startState.values.slice();else{i=Rt.resolve(n,s,this),e=new ne(i,this.doc,this.selection,i.dynamicSlots.map((()=>null)),((t,e)=>e.reconfigure(t,this)),null).values}new ne(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:ft.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=Qt(i.effects);for(let i=1;i<e.ranges.length;i++){let o=t(e.ranges[i]),h=this.changes(o.changes),l=h.map(n);for(let t=0;t<i;t++)s[t]=s[t].map(l);let a=n.mapDesc(h,!0);s.push(o.range.map(a)),n=n.compose(l),r=Kt.mapEffects(r,l).concat(Kt.mapEffects(Qt(o.effects),a))}return{changes:n,selection:ft.create(s,e.mainIndex),effects:r}}changes(t=[]){return t instanceof st?t:st.of(t,this.doc.length,this.facet(ne.lineSeparator))}toText(t){return N.of(t.split(this.facet(ne.lineSeparator)||et))}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:(Pt(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 kt&&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 e in i)if(Object.prototype.hasOwnProperty.call(t,e)){let s=i[e],r=t[e];n.push(s.init((t=>s.spec.fromJSON(r,t))))}return ne.create({doc:t.doc,selection:ft.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let e=Rt.resolve(t.extensions||[],new Map),i=t.doc instanceof N?t.doc:N.of((t.doc||"").split(e.staticFacet(ne.lineSeparator)||et)),n=t.selection?t.selection instanceof ft?t.selection:ft.single(t.selection.anchor,t.selection.head):ft.single(0);return dt(n,i.length),e.staticFacet(Lt)||(n=n.asSingle()),new ne(e,i,n,e.dynamicSlots.map((()=>null)),((t,e)=>e.create(t)),null)}get tabSize(){return this.facet(ne.tabSize)}get lineBreak(){return this.facet(ne.lineSeparator)||"\n"}get readOnly(){return this.facet(zt)}phrase(t,...e){for(let e of this.facet(ne.phrases))if(Object.prototype.hasOwnProperty.call(e,t)){t=e[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 ie(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=U(e,r,!1);if(s(e.slice(t,r))!=Zt.Word)break;r=t}for(;o<n;){let t=U(e,o);if(s(e.slice(o,t))!=Zt.Word)break;o=t}return r==o?null:ft.range(r+i,o+i)}}ne.allowMultipleSelections=Lt,ne.tabSize=gt.define({combine:t=>t.length?t[0]:4}),ne.lineSeparator=Vt,ne.readOnly=zt,ne.phrases=gt.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]))}}),ne.languageData=Nt,ne.changeFilter=Ht,ne.transactionFilter=Wt,ne.transactionExtender=_t,Et.reconfigure=Kt.define();class se{eq(t){return this==t}range(t,e=t){return re.create(t,e,this)}}se.prototype.startSide=se.prototype.endSide=0,se.prototype.point=!1,se.prototype.mapMode=it.TrackDel;class re{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new re(t,e,i)}}function oe(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class he{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 he(n,s,i,o):null,pos:r}}}class le{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 le(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(oe)),this.isEmpty)return e.length?le.of(e):this;let o=new ue(this,null,-1).goto(0),h=0,l=[],a=new ae;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(re.create(o.from,o.to,o.value))),o.next());return a.finishInner(this.nextLayer.isEmpty&&!l.length?le.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 s=0;s<this.chunk.length;s++){let r=this.chunkPos[s],o=this.chunk[s],h=t.touchesRange(r,r+o.length);if(!1===h)n=Math.max(n,o.maxPoint),e.push(o),i.push(t.mapPos(r));else if(!0===h){let{mapped:s,pos:h}=o.map(r,t);s&&(n=Math.max(n,s.maxPoint),e.push(s),i.push(h))}}let s=this.nextLayer.map(t);return 0==e.length?s:new le(i,e,s||le.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 fe.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return fe.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=ce(r,o,i),l=new pe(r,h,s),a=new pe(o,h,s);i.iterGaps(((t,e,i)=>ge(l,t,a,e,i,n))),i.empty&&0==i.length&&ge(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=ce(s,r),h=new pe(s,o,0).goto(i),l=new pe(r,o,0).goto(i);for(;;){if(h.to!=l.to||!me(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 pe(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 ae;for(let n of t instanceof re?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let n=t[i];if(oe(e,n)>0)return t.slice().sort(oe);e=n}return t}(t):t)i.add(n.from,n.to,n.value);return i.finish()}}le.empty=new le([],[],null,-1),le.empty.nextLayer=le.empty;class ae{finishChunk(t){this.chunks.push(new he(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 ae)).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(le.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=le.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function ce(t,e,i){let n=new Map;for(let e of t)for(let t=0;t<e.chunk.length;t++)e.chunk[t].maxPoint<=0&&n.set(e.chunk[t],e.chunkPos[t]);let s=new Set;for(let t of e)for(let e=0;e<t.chunk.length;e++){let r=n.get(t.chunk[e]);null==r||(i?i.mapPos(r):r)!=t.chunkPos[e]||(null==i?void 0:i.touchesRange(r,r+t.chunk[e].length))||s.add(t.chunk[e])}return s}class ue{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 fe{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 ue(r,e,i,s));return 1==n.length?n[0]:new fe(n)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(let i of this.heap)i.goto(t,e);for(let t=this.heap.length>>1;t>=0;t--)de(this.heap,t);return this.next(),this}forward(t,e){for(let i of this.heap)i.forward(t,e);for(let t=this.heap.length>>1;t>=0;t--)de(this.heap,t);(this.to-t||this.value.endSide-e)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),de(this.heap,0)}}}function de(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 pe{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=fe.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){we(this.active,t),we(this.activeTo,t),we(this.activeRank,t),this.minActive=ye(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++;ve(this.active,e,i),ve(this.activeTo,e,n),ve(this.activeRank,e,s),t&&ve(t,e,this.cursor.from),this.minActive=ye(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&&we(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 ge(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))&&me(t.activeForPoint(t.to),i.activeForPoint(i.to))||r.comparePoint(h,s,t.point,i.point):s>h&&!me(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 me(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 we(t,e){for(let i=e,n=t.length-1;i<n;i++)t[i]=t[i+1];t.pop()}function ve(t,e,i){for(let i=t.length-1;i>=e;i--)t[i+1]=t[i];t[e]=i}function ye(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}var be=i(58626);const xe=1024;let ke=0;class Se{constructor(t={}){this.id=ke++,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=Me.match(t)),e=>{let i=t(e);return void 0===i?null:[this,i]}}}Se.closedBy=new Se({deserialize:t=>t.split(" ")}),Se.openedBy=new Se({deserialize:t=>t.split(" ")}),Se.group=new Se({deserialize:t=>t.split(" ")}),Se.contextHash=new Se({perNode:!0}),Se.lookAhead=new Se({perNode:!0}),Se.mounted=new Se({perNode:!0});const Ae=Object.create(null);class Me{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):Ae,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=new Me(t.name||"",e,t.id,i);if(t.props)for(let i of t.props)if(Array.isArray(i)||(i=i(n)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[i[0].id]=i[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(Se.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(Se.group),n=-1;n<(i?i.length:0);n++){let s=e[n<0?t.name:i[n]];if(s)return s}}}}Me.none=new Me("",Object.create(null),0,8);const Ce=new WeakMap,Oe=new WeakMap;var Te;!function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"}(Te||(Te={}));class De{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(Se.mounted);if(t&&!t.overlay)return t.tree.toString();let e="";for(let t of this.children){let i=t.toString();i&&(e&&(e+=","),e+=i)}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 _e(this.topNode,t)}cursorAt(t,e=0,i=0){let n=Ce.get(this)||this.topNode,s=new _e(n);return s.moveTo(t,e),Ce.set(this,s._tree),s}get topNode(){return new Ne(this,0,0,null)}resolve(t,e=0){let i=Ie(Ce.get(this)||this.topNode,t,e,!1);return Ce.set(this,i),i}resolveInner(t,e=0){let i=Ie(Oe.get(this)||this.topNode,t,e,!0);return Oe.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&Te.IncludeAnonymous)>0;for(let t=this.cursor(r|Te.IncludeAnonymous);;){let r=!1;if(t.from<=s&&t.to>=n&&(!o&&t.type.isAnonymous||!1!==e(t))){if(t.firstChild())continue;r=!0}for(;r&&i&&(o||!t.type.isAnonymous)&&i(t),!t.nextSibling();){if(!t.parent())return;r=!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:je(Me.none,this.children,this.positions,0,this.children.length,0,this.length,((t,e,i)=>new De(this.type,t,e,i,this.propValues)),t.makeTree||((t,e,i)=>new De(Me.none,t,e,i)))}static build(t){return function(t){var e;let{buffer:i,nodeSet:n,maxBufferLength:s=xe,reused:r=[],minRepeatType:o=n.types.length}=t,h=Array.isArray(i)?new Ee(i,i.length):i,l=n.types,a=0,c=0;function u(t,e,i,w,v){let{id:y,start:b,end:x,size:k}=h,S=c;for(;k<0;){if(h.next(),-1==k){let e=r[y];return i.push(e),void w.push(b-t)}if(-3==k)return void(a=y);if(-4==k)return void(c=y);throw new RangeError(`Unrecognized record size: ${k}`)}let A,M,C=l[y],O=b-t;if(x-b<=s&&(M=g(h.pos-e,v))){let e=new Uint16Array(M.size-M.skip),i=h.pos-M.size,s=e.length;for(;h.pos>i;)s=m(M.start,e,s);A=new Be(e,x-M.start,n),O=M.start-t}else{let t=h.pos-k;h.next();let e=[],i=[],n=y>=o?y:-1,r=0,l=x;for(;h.pos>t;)n>=0&&h.id==n&&h.size>=0?(h.end<=l-s&&(d(e,i,b,r,h.end,l,n,S),r=e.length,l=h.end),h.next()):u(b,t,e,i,n);if(n>=0&&r>0&&r<e.length&&d(e,i,b,r,b,l,n,S),e.reverse(),i.reverse(),n>-1&&r>0){let t=f(C);A=je(C,e,i,0,e.length,0,x-b,t,t)}else A=p(C,e,i,x-b,S-x)}i.push(A),w.push(O)}function f(t){return(e,i,n)=>{let s,r,o=0,h=e.length-1;if(h>=0&&(s=e[h])instanceof De){if(!h&&s.type==t&&s.length==n)return s;(r=s.prop(Se.lookAhead))&&(o=i[h]+s.length+r)}return p(t,e,i,n,o)}}function d(t,e,i,s,r,o,h,l){let a=[],c=[];for(;t.length>s;)a.push(t.pop()),c.push(e.pop()+i-r);t.push(p(n.types[h],a,c,o-r,l-o)),e.push(r-i)}function p(t,e,i,n,s=0,r){if(a){let t=[Se.contextHash,a];r=r?[t].concat(r):[t]}if(s>25){let t=[Se.lookAhead,s];r=r?[t].concat(r):[t]}return new De(t,e,i,n,r)}function g(t,e){let i=h.fork(),n=0,r=0,l=0,a=i.end-s,c={size:0,start:0,skip:0};t:for(let s=i.pos-t;i.pos>s;){let t=i.size;if(i.id==e&&t>=0){c.size=n,c.start=r,c.skip=l,l+=4,n+=4,i.next();continue}let h=i.pos-t;if(t<0||h<s||i.start<a)break;let u=i.id>=o?4:0,f=i.start;for(i.next();i.pos>h;){if(i.size<0){if(-3!=i.size)break t;u+=4}else i.id>=o&&(u+=4);i.next()}r=f,n+=t,l+=u}return(e<0||n==t)&&(c.size=n,c.start=r,c.skip=l),c.size>4?c:void 0}function m(t,e,i){let{id:n,start:s,end:r,size:l}=h;if(h.next(),l>=0&&n<o){let o=i;if(l>4){let n=h.pos-(l-4);for(;h.pos>n;)i=m(t,e,i)}e[--i]=o,e[--i]=r-t,e[--i]=s-t,e[--i]=n}else-3==l?a=n:-4==l&&(c=n);return i}let w=[],v=[];for(;h.pos>0;)u(t.start||0,t.bufferStart||0,w,v,-1);let y=null!==(e=t.length)&&void 0!==e?e:w.length?v[0]+w[0].length:0;return new De(l[t.topID],w.reverse(),v.reverse(),y)}(t)}}De.empty=new De(Me.none,[],[],0);class Ee{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 Ee(this.buffer,this.index)}}class Be{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return Me.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&&!(Re(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 Be(s,r,this.set)}}function Re(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 Pe(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 Ie(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 Ne&&t.index<0?null:t.parent;if(!e)return t;t=e}let r=n?0:Te.IgnoreOverlays;if(n)for(let n=t,o=n.parent;o;n=o,o=n.parent)n instanceof Ne&&n.index<0&&(null===(s=o.enter(e,i,r))||void 0===s?void 0:s.from)!=n.from&&(t=o);for(;;){let n=t.enter(e,i,r);if(!n)return t;t=n}}class Ne{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:o,positions:h}=r._tree,l=e>0?o.length:-1;t!=l;t+=e){let l=o[t],a=h[t]+r.from;if(Re(n,i,a,a+l.length))if(l instanceof Be){if(s&Te.ExcludeBuffers)continue;let o=l.findChild(0,l.buffer.length,e,i-a,n);if(o>-1)return new We(new He(r,l,t,a),null,o)}else if(s&Te.IncludeAnonymous||!l.type.isAnonymous||ze(l)){let o;if(!(s&Te.IgnoreMounts)&&l.props&&(o=l.prop(Se.mounted))&&!o.overlay)return new Ne(o.tree,a,t,r);let h=new Ne(l,a,t,r);return s&Te.IncludeAnonymous||!h.type.isAnonymous?h:h.nextChild(e<0?l.children.length-1:0,e,i,n)}}if(s&Te.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&Te.IgnoreOverlays)&&(n=this._tree.prop(Se.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 Ne(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 _e(this,t)}get tree(){return this._tree}toTree(){return this._tree}resolve(t,e=0){return Ie(this,t,e,!1)}resolveInner(t,e=0){return Ie(this,t,e,!0)}enterUnfinishedNodesBefore(t){return Pe(this,t)}getChild(t,e=null,i=null){let n=Le(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return Le(this,t,e,i)}toString(){return this._tree.toString()}get node(){return this}matchContext(t){return Ve(this,t)}}function Le(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 Ve(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 He{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}}class We{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 We(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&Te.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 We(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 We(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 We(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}cursor(t=0){return new _e(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 De(this.type,t,e,this.to-this.from)}resolve(t,e=0){return Ie(this,t,e,!1)}resolveInner(t,e=0){return Ie(this,t,e,!0)}enterUnfinishedNodesBefore(t){return Pe(this,t)}toString(){return this.context.buffer.childString(this.index)}getChild(t,e=null,i=null){let n=Le(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return Le(this,t,e,i)}get node(){return this}matchContext(t){return Ve(this,t)}}class _e{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 Ne)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 Ne?(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&Te.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Te.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&Te.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&Te.IncludeAnonymous||t instanceof Be||!t.type.isAnonymous||ze(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 t=i;t<this.stack.length;t++)e=new We(this.buffer,e,this.stack[t]);return this.bufferNode=new We(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 Ve(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 Ve(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 ze(t){return t.children.some((t=>t instanceof Be||!t.type.isAnonymous||ze(t)))}const Fe=new WeakMap;function qe(t,e){if(!t.isAnonymous||e instanceof Be||e.type!=t)return 1;let i=Fe.get(e);if(null==i){i=1;for(let n of e.children){if(n.type!=t||!(n instanceof De)){i=1;break}i+=qe(t,n)}Fe.set(e,i)}return i}function je(t,e,i,n,s,r,o,h,l){let a=0;for(let i=n;i<s;i++)a+=qe(t,e[i]);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],p=qe(t,i[a]);for(a++;a<o;a++){let e=qe(t,i[a]);if(p+e>=c)break;p+=e}if(a==s+1){if(p>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(je(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 Se({perNode:!0});let Ke=0;class $e{constructor(t,e,i){this.set=t,this.base=e,this.modified=i,this.id=Ke++}static define(t){if(null==t?void 0:t.base)throw new Error("Can not derive from a modified tag");let e=new $e([],null,[]);if(e.set.push(e),t)for(let i of t.set)e.set.push(i);return e}static defineModifier(){let t=new Ue;return e=>e.modified.indexOf(t)>-1?e:Ue.get(e.base||e,e.modified.concat(t).sort(((t,e)=>t.id-e.id)))}}let Je=0;class Ue{constructor(){this.instances=[],this.id=Je++}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 $e(n,t,e);for(let t of e)t.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 e of t.set)if(!e.modified.length)for(let t of r)n.push(Ue.get(e,t));return s}}function Ge(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 Ye(n,s,o>0?i.slice(0,o):null);e[h]=l.sort(e[h])}}return Xe.add(e)}const Xe=new Se;class Ye{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 Qe(t,e){let i=Object.create(null);for(let e of t)if(Array.isArray(e.tag))for(let t of e.tag)i[t.id]=e.class;else i[e.tag.id]=e.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 Ze(t,e,i,n=0,s=t.length){let r=new ti(n,Array.isArray(e)?e:[e],i);r.highlightRange(t.cursor(),n,s,"",r.highlighters),r.flush(s)}Ye.empty=new Ye([],2,null);class ti{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:r,from:o,to:h}=t;if(o>=i||h<=e)return;r.isTop&&(s=this.highlighters.filter((t=>!t.scope||t.scope(r))));let l=n,a=function(t){let e=t.type.prop(Xe);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}(t)||Ye.empty,c=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,a.tags);if(c&&(l&&(l+=" "),l+=c,1==a.mode&&(n+=(n?" ":"")+c)),this.startSpan(Math.max(e,o),l),a.opaque)return;let u=t.tree&&t.tree.prop(Se.mounted);if(u&&u.overlay){let r=t.node.enter(u.overlay[0].from+o,1),a=this.highlighters.filter((t=>!t.scope||t.scope(u.tree.type))),c=t.firstChild();for(let f=0,d=o;;f++){let p=f<u.overlay.length?u.overlay[f]:null,g=p?p.from+o:h,m=Math.max(e,d),w=Math.min(i,g);if(m<w&&c)for(;t.from<w&&(this.highlightRange(t,m,w,n,s),this.startSpan(Math.min(w,t.to),l),!(t.to>=g)&&t.nextSibling()););if(!p||g>i)break;d=p.to+o,d>e&&(this.highlightRange(r.cursor(),Math.max(e,p.from+o),Math.min(i,d),"",a),this.startSpan(Math.min(i,d),l))}c&&t.parent()}else if(t.firstChild()){u&&(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),l)}}while(t.nextSibling());t.parent()}}}const ei=$e.define,ii=ei(),ni=ei(),si=ei(ni),ri=ei(ni),oi=ei(),hi=ei(oi),li=ei(oi),ai=ei(),ci=ei(ai),ui=ei(),fi=ei(),di=ei(),pi=ei(di),gi=ei(),mi={comment:ii,lineComment:ei(ii),blockComment:ei(ii),docComment:ei(ii),name:ni,variableName:ei(ni),typeName:si,tagName:ei(si),propertyName:ri,attributeName:ei(ri),className:ei(ni),labelName:ei(ni),namespace:ei(ni),macroName:ei(ni),literal:oi,string:hi,docString:ei(hi),character:ei(hi),attributeValue:ei(hi),number:li,integer:ei(li),float:ei(li),bool:ei(oi),regexp:ei(oi),escape:ei(oi),color:ei(oi),url:ei(oi),keyword:ui,self:ei(ui),null:ei(ui),atom:ei(ui),unit:ei(ui),modifier:ei(ui),operatorKeyword:ei(ui),controlKeyword:ei(ui),definitionKeyword:ei(ui),moduleKeyword:ei(ui),operator:fi,derefOperator:ei(fi),arithmeticOperator:ei(fi),logicOperator:ei(fi),bitwiseOperator:ei(fi),compareOperator:ei(fi),updateOperator:ei(fi),definitionOperator:ei(fi),typeOperator:ei(fi),controlOperator:ei(fi),punctuation:di,separator:ei(di),bracket:pi,angleBracket:ei(pi),squareBracket:ei(pi),paren:ei(pi),brace:ei(pi),content:ai,heading:ci,heading1:ei(ci),heading2:ei(ci),heading3:ei(ci),heading4:ei(ci),heading5:ei(ci),heading6:ei(ci),contentSeparator:ei(ai),list:ei(ai),quote:ei(ai),emphasis:ei(ai),strong:ei(ai),link:ei(ai),monospace:ei(ai),strikethrough:ei(ai),inserted:ei(),deleted:ei(),changed:ei(),invalid:ei(),meta:gi,documentMeta:ei(gi),annotation:ei(gi),processingInstruction:ei(gi),definition:$e.defineModifier(),constant:$e.defineModifier(),function:$e.defineModifier(),standard:$e.defineModifier(),local:$e.defineModifier(),special:$e.defineModifier()};Qe([{tag:mi.link,class:"tok-link"},{tag:mi.heading,class:"tok-heading"},{tag:mi.emphasis,class:"tok-emphasis"},{tag:mi.strong,class:"tok-strong"},{tag:mi.keyword,class:"tok-keyword"},{tag:mi.atom,class:"tok-atom"},{tag:mi.bool,class:"tok-bool"},{tag:mi.url,class:"tok-url"},{tag:mi.labelName,class:"tok-labelName"},{tag:mi.inserted,class:"tok-inserted"},{tag:mi.deleted,class:"tok-deleted"},{tag:mi.literal,class:"tok-literal"},{tag:mi.string,class:"tok-string"},{tag:mi.number,class:"tok-number"},{tag:[mi.regexp,mi.escape,mi.special(mi.string)],class:"tok-string2"},{tag:mi.variableName,class:"tok-variableName"},{tag:mi.local(mi.variableName),class:"tok-variableName tok-local"},{tag:mi.definition(mi.variableName),class:"tok-variableName tok-definition"},{tag:mi.special(mi.variableName),class:"tok-variableName2"},{tag:mi.definition(mi.propertyName),class:"tok-propertyName tok-definition"},{tag:mi.typeName,class:"tok-typeName"},{tag:mi.namespace,class:"tok-namespace"},{tag:mi.className,class:"tok-className"},{tag:mi.macroName,class:"tok-macroName"},{tag:mi.propertyName,class:"tok-propertyName"},{tag:mi.operator,class:"tok-operator"},{tag:mi.comment,class:"tok-comment"},{tag:mi.meta,class:"tok-meta"},{tag:mi.invalid,class:"tok-invalid"},{tag:mi.punctuation,class:"tok-punctuation"}]);var wi,vi=i(28450);const yi=new o;function bi(t){return gt.define({combine:t?e=>e.concat(t):void 0})}const xi=new o;class ki{constructor(t,e,i=[],n=""){this.data=t,this.name=n,ne.prototype.hasOwnProperty("tree")||Object.defineProperty(ne.prototype,"tree",{get(){return Ai(this)}}),this.parser=e,this.extension=[Pi.of(this),ne.languageData.of(((t,e,i)=>{let n=Si(t,e,i),s=n.type.prop(yi);if(!s)return[];let r=t.facet(s),o=n.type.prop(xi);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 Si(t,e,i).type.prop(yi)==this.data}findRegions(t){let e=t.facet(Pi);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(yi)==this.data)return void i.push({from:e,to:e+t.length});let s=t.prop(o.mounted);if(s){if(s.tree.prop(yi)==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 p&&n(s,t.positions[i]+e)}};return n(Ai(t),0),i}get allowsNesting(){return!0}}function Si(t,e,i){let n=t.facet(Pi),s=Ai(t).topNode;if(!n||n.allowsNesting)for(let t=s;t;t=t.enter(e,i,d.ExcludeBuffers))t.type.isTop&&(s=t);return s}ki.setState=Kt.define();function Ai(t){let e=t.field(ki.state,!1);return e?e.tree:p.empty}class Mi{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 Ci=null;class Oi{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 Oi(t,e,[],p.empty,0,i,[],null)}startParse(){return this.parser.startParse(new Mi(this.state.doc),this.fragments)}work(t,e){return null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=p.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.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.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=Ci;Ci=this;try{return t()}finally{Ci=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=Ti(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:n,treeLen:s,viewport:r,skipped:o}=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.applyChanges(i,e),n=p.empty,s=0,r={from:t.mapPos(r.from,-1),to:t.mapPos(r.to,1)},this.skipped.length){o=[];for(let e of this.skipped){let i=t.mapPos(e.from,1),n=t.mapPos(e.to,-1);i<n&&o.push({from:i,to:n})}}}return new Oi(this.parser,e,i,n,s,r,o,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 e=0;e<this.skipped.length;e++){let{from:i,to:n}=this.skipped[e];i<t.to&&n>t.from&&(this.fragments=Ti(this.fragments,i,n),this.skipped.splice(e--,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 P{createParse(e,i,n){let s=n[0].from,r=n[n.length-1].to;return{parsedPos:s,advance(){let e=Ci;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=r,new p(a.none,[],[],r-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 Ci}}function Ti(t,e,i){return R.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}class Di{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 Di(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=Oi.create(t.facet(Pi).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new Di(i)}}ki.state=kt.define({create:Di.init,update(t,e){for(let t of e.effects)if(t.is(ki.setState))return t.value;return e.startState.facet(Pi)!=e.state.facet(Pi)?Di.init(e.state):t.apply(e)}});let Ei=t=>{let e=setTimeout((()=>t()),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&(Ei=t=>{let e=-1,i=setTimeout((()=>{e=requestIdleCallback(t,{timeout:400})}),100);return()=>e<0?clearTimeout(i):cancelIdleCallback(e)});const Bi="undefined"!=typeof navigator&&(null===(wi=navigator.scheduling)||void 0===wi?void 0:wi.isInputPending)?()=>navigator.scheduling.isInputPending():null,Ri=be.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(ki.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(ki.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=Ei(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(ki.state);if(s.tree==s.context.tree&&s.context.isDone(n+1e5))return;let r=Date.now()+Math.min(this.chunkBudget,100,t&&!Bi?Math.max(25,t.timeRemaining()-5):1e9),o=s.context.treeLen<n&&i.doc.length>n+1e3,h=s.context.work((()=>Bi&&Bi()||Date.now()>r),n+(o?0:1e5));this.chunkBudget-=Date.now()-e,(h||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:ki.setState.of(new Di(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,be.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()}}}),Pi=gt.define({combine:t=>t.length?t[0]:null,enables:t=>[ki.state,Ri,be.tk.contentAttributes.compute([t],(e=>{let i=e.facet(t);return i&&i.name?{"data-language":i.name}:{}}))]});const Ii=gt.define(),Ni=gt.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 Li(t){let e=t.facet(Ni);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}be.l9;class Vi{constructor(t,e){let i;function n(t){let e=vi.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 ki?t=>t.prop(yi)==r.data:r?t=>t==r:void 0,this.style=Qe(t.map((t=>({tag:t.tag,class:t.class||n(Object.assign({},t,{tag:null}))}))),{all:s}).style,this.module=i?new vi.V(i):null,this.themeType=e.themeType}static define(t,e){return new Vi(t,e||{})}}const Hi=gt.define(),Wi=gt.define({combine:t=>t.length?[t[0]]:null});function _i(t){let e=t.facet(Hi);return e.length?e:t.facet(Wi)}function zi(t,e){let i,n=[ji];return t instanceof Vi&&(t.module&&n.push(be.tk.styleModule.of(t.module)),i=t.themeType),(null==e?void 0:e.fallback)?n.push(Wi.of(t)):i?n.push(Hi.computeN([be.tk.darkTheme],(e=>e.facet(be.tk.darkTheme)==("dark"==i)?[t]:[]))):n.push(Hi.of(t)),n}function Fi(t,e,i){let n=_i(t),s=null;if(n)for(let t of n)if(!t.scope||i&&t.scope(i)){let i=t.style(e);i&&(s=s?s+" "+i:i)}return s}class qi{constructor(t){this.markCache=Object.create(null),this.tree=Ai(t.state),this.decorations=this.buildDeco(t,_i(t.state))}update(t){let e=Ai(t.state),i=_i(t.state),n=i!=_i(t.startState);e.length<t.view.viewport.to&&!n&&e.type==this.tree.type?this.decorations=this.decorations.map(t.changes):(e!=this.tree||t.viewportChanged||n)&&(this.tree=e,this.decorations=this.buildDeco(t.view,i))}buildDeco(t,e){if(!e||!this.tree.length)return be.p.none;let i=new ae;for(let{from:n,to:s}of t.visibleRanges)Ze(this.tree,e,((t,e,n)=>{i.add(t,e,this.markCache[n]||(this.markCache[n]=be.p.mark({class:n})))}),n,s);return i.finish()}}const ji=Tt.high(be.lg.fromClass(qi,{decorations:t=>t.decorations}));mi.meta,mi.link,mi.heading,mi.emphasis,mi.strong,mi.strikethrough,mi.keyword,mi.atom,mi.bool,mi.url,mi.contentSeparator,mi.labelName,mi.literal,mi.inserted,mi.string,mi.deleted,mi.regexp,mi.escape,mi.string,mi.variableName,mi.variableName,mi.typeName,mi.namespace,mi.className,mi.variableName,mi.macroName,mi.propertyName,mi.comment,mi.invalid;function Ki(t,e,i,n=0,s=0){null==e&&-1==(e=t.search(/[^\s\u00a0]/))&&(e=t.length);let r=s;for(let s=n;s<e;s++)9==t.charCodeAt(s)?r+=i-r%i:r++;return r}class $i{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=Ki(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:Ki(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 Ji(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 Ui=new WeakMap;class Gi extends ki{constructor(t){let e,i=bi(t.languageData),n={name:(s=t).name||"",token:s.token,blankLine:s.blankLine||(()=>{}),startState:s.startState||(()=>!0),copyState:s.copyState||Ji,indent:s.indent||(()=>null),languageData:s.languageData||{},tokenTable:s.tokenTable||tn};var s;super(i,new class extends P{createParse(t,i,n){return new Qi(e,t,i,n)}},[Ii.of(((t,e)=>this.getIndent(t,e)))],t.name),this.topNode=function(t){let e=a.define({id:en.length,name:"Document",props:[yi.add((()=>t))],top:!0});return en.push(e),e}(i),e=this,this.streamParser=n,this.stateAfter=new o({perNode:!0}),this.tokenTable=t.tokenTable?new hn(n.tokenTable):ln}static define(t){return new Gi(t)}getIndent(t,e){let i,n=Ai(t.state),s=n.resolve(e);for(;s&&s.type!=this.topNode;)s=s.parent;if(!s)return null;let{overrideIndentation:r}=t.options;r&&(i=Ui.get(t.state),null!=i&&i<e-1e4&&(i=void 0));let o,h,l=Xi(this,n,0,s.from,null!=i?i:e);if(l?(h=l.state,o=l.pos+1):(h=this.streamParser.startState(t.unit),o=0),e-o>1e4)return null;for(;o<e;){let i=t.state.doc.lineAt(o),n=Math.min(e,i.to);if(i.length){let e=r?r(i.from):-1,s=new $i(i.text,t.state.tabSize,t.unit,e<0?void 0:e);for(;s.pos<n-i.from;)Zi(this.streamParser.token,s,h)}else this.streamParser.blankLine(h,t.unit);if(n==e)break;o=i.to+1}let a=t.lineAt(e);return r&&null==i&&Ui.set(t.state,a.from),this.streamParser.indent(h,/^\s*(.*)/.exec(a.text)[1],t)}get allowsNesting(){return!1}}function Xi(t,e,i,n,s){let r=i>=n&&i+e.length<=s&&e.prop(t.stateAfter);if(r)return{state:t.streamParser.copyState(r),pos:i+e.length};for(let r=e.children.length-1;r>=0;r--){let o=e.children[r],h=i+e.positions[r],l=o instanceof p&&h<s&&Xi(t,o,h,n,s);if(l)return l}return null}function Yi(t,e,i,n,s){if(s&&i<=0&&n>=e.length)return e;s||e.type!=t.topNode||(s=!0);for(let r=e.children.length-1;r>=0;r--){let o,h=e.positions[r],l=e.children[r];if(h<n&&l instanceof p){if(!(o=Yi(t,l,i-h,n-h,s)))break;return s?new p(e.type,e.children.slice(0,r).concat(o),e.positions.slice(0,r+1),h+o.length):o}}return null}class Qi{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=Oi.get(),r=n[0].from,{state:o,tree:h}=function(t,e,i,n){for(let n of e){let e,s=n.from+(n.openStart?25:0),r=n.to-(n.openEnd?25:0),o=s<=i&&r>i&&Xi(t,n.tree,0-n.offset,i,r);if(o&&(e=Yi(t,n.tree,i+n.offset,o.pos+n.offset,!1)))return{state:o.state,tree:e}}return{state:t.streamParser.startState(n?Li(n):4),tree:p.empty}}(t,i,r,null==s?void 0:s.state);this.state=o,this.parsedPos=this.chunkStart=r+h.length;for(let t=0;t<h.children.length;t++)this.chunks.push(h.children[t]),this.chunkPos.push(h.positions[t]);s&&this.parsedPos<s.viewport.from-1e5&&(this.state=this.lang.streamParser.startState(Li(s.state)),s.skipUntilInView(this.parsedPos,s.viewport.from),this.parsedPos=s.viewport.from),this.moveRangeIndex()}advance(){let t=Oi.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 t=this.rangeIndex;;){let n=this.ranges[t].to;if(n>=i)break;if(e=e.slice(0,n-(i-e.length)),t++,t==this.ranges.length)break;let s=this.ranges[t].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,s){if(this.ranges.length>1){e+=s=this.skipGapsTo(e,s,1);let t=this.chunk.length;i+=s=this.skipGapsTo(i,s,-1),n+=this.chunk.length-t}return this.chunk.push(t,e,i,n),s}parseLine(t){let{line:e,end:i}=this.nextLine(),n=0,{streamParser:s}=this.lang,r=new $i(e,t?t.state.tabSize:4,t?Li(t.state):2);if(r.eol())s.blankLine(this.state,r.indentUnit);else for(;!r.eol();){let t=Zi(s.token,r,this.state);if(t&&(n=this.emitToken(this.lang.tokenTable.resolve(t),this.parsedPos+r.start,this.parsedPos+r.pos,4,n)),r.start>1e4)break}this.parsedPos=i,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let t=p.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:nn,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new p(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 p(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}}function Zi(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 tn=Object.create(null),en=[a.none],nn=new c(en),sn=[],rn=Object.create(null),on=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])on[t]=cn(tn,e);class hn{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),on)}resolve(t){return t?this.table[t]||(this.table[t]=cn(this.extra,t)):0}}const ln=new hn(tn);function an(t,e){sn.indexOf(t)>-1||(sn.push(t),console.warn(e))}function cn(t,e){let i=[];for(let n of e.split(" ")){let e=[];for(let i of n.split(".")){let n=t[i]||mi[i];n?"function"==typeof n?e.length?e=e.map(n):an(i,`Modifier ${i} used at start of tag`):e.length?an(i,`Tag ${i} used as modifier`):e=Array.isArray(n)?n:[n]:an(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)),r=rn[s];if(r)return r.id;let o=rn[s]=a.define({id:en.length,name:n,props:[Ge({[n]:i})]});return en.push(o),o.id}be.Nm.RTL,be.Nm.LTR},17429:(t,e,i)=>{i.d(e,{b:()=>a});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:"##"}}}}},76697:(t,e,i)=>{i.d(e,{r:()=>s});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:"#"}}}},52456:(t,e,i)=>{i.d(e,{sW:()=>cr,Lp:()=>jr});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 t=e,r=e;;){if(n.next(t),s.next(t),t=0,n.lineBreak!=s.lineBreak||n.done!=s.done||n.value!=s.value)return!1;if(r+=n.value.length,n.done||r>=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 e of t)this.lines+=e.lines}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.children[s],o=n+r.length,h=i+r.lines-1;if((e?h:o)>=t)return r.lineInner(t,e,i,n);n=o+1,i=h+1}}decompose(t,e,i,n){for(let s=0,r=0;r<=e&&s<this.children.length;s++){let o=this.children[s],h=r+o.length;if(t<=h&&e>=r){let s=n&((r<=t?1:0)|(h>=e?2:0));r>=t&&h<=e&&!s?i.push(o):o.decompose(t-r,e-r,i,s)}r=h+1}}replace(t,e,i){if(i.lines<this.lines)for(let n=0,s=0;n<this.children.length;n++){let 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 e of t)i+=e.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 e of t.children)f(e);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 e of t)f(e);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 p(t){return t>=127462&&t<=127487}const g=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==g||s==g||i&&d(s))e+=k(s),n=s;else{if(!p(s))break;{let i=0,n=e-2;for(;n>=0&&p(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 k(t){return t<65536?1:2}const S=/\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:B(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:B(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 R(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||S)):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 R(t),h=new R(e);for(let t=-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||t==o.i||0==o.off&&(h.len<o.len||h.len==o.len&&!i))){let e=h.len;for(O(s,h.ins,-1);e;){let i=Math.min(o.len,e);o.ins>=0&&t<o.i&&o.len<=i&&(O(s,0,o.ins),r&&T(r,s,o.text),t=o.i),o.forward(i),e-=i}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 e=0,i=o.len;for(;i;)if(-1==h.ins){let t=Math.min(i,h.len);e+=t,i-=t,h.forward(t)}else{if(!(0==h.ins&&h.len<i))break;i-=h.len,h.next()}O(s,e,t<o.i?o.ins:0),r&&t<o.i&&T(r,s,o.text),t=o.i,o.forward(o.len-i)}}}function B(t,e,i=!1){let n=[],s=i?[]:null,r=new R(t),o=new R(e);for(let t=!1;;){if(r.done&&o.done)return s?C.createSet(n,s):M.create(n);if(0==r.ins)O(n,r.len,0,t),r.next();else if(0!=o.len||o.done){if(r.done||o.done)throw new Error("Mismatched change set lengths");{let e=Math.min(r.len2,o.len),i=n.length;if(-1==r.ins){let i=-1==o.ins?-1:o.off?0:o.ins;O(n,e,i,t),s&&i&&T(s,n,o.text)}else-1==o.ins?(O(n,r.off?0:r.len,e,t),s&&T(s,n,r.textBit(e))):(O(n,r.off?0:r.len,o.off?0:o.ins,t),s&&!o.off&&T(s,n,o.text));t=(r.ins>e||o.ins>=0&&o.len>e)&&(t||n.length>i),r.forward2(e),o.forward(e)}}else O(n,0,o.ins,t),s&&T(s,n,o.text),o.next()}}class R{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 I.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return I.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 I.range(t.anchor,t.head)}static create(t,e,i){return new P(t,e,i)}}class I{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:I.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 I([this.main],0)}addRange(t,e=!0){return I.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,I.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 I(t.ranges.map((t=>P.fromJSON(t))),t.main)}static single(t,e=t){return new I([I.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 I.normalized(t.slice(),e);i=s.to}return new I(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 i=1;i<t.length;i++){let n=t[i],s=t[i-1];if(n.empty?n.from<=s.to:n.from<s.to){let r=s.from,o=Math.max(n.to,s.to);i<=e&&e--,t.splice(--i,2,n.anchor>n.head?I.range(o,r):I.range(r,o))}}return new I(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 L=0;class V{constructor(t,e,i,n,s){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=L++,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=L++}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 i of this.dependencies)"doc"==i?h=!0:"selection"==i?l=!0:0==(1&(null!==(e=t[i.id])&&void 0!==e?e:1))&&a.push(t[i.id]);return{create:t=>(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?!_(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 j)||e.field(i,!1)==t.field(i,!1)))||(o?_(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 _(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 F(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 q=V.define({static:!0});class j{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 j(L++,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,$=3,J=2,U=1;function G(t){return e=>new Y(e,t)}const X={highest:G(0),high:G(U),default:G(J),low:G($),lowest:G(K)};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 i of function(t,e,i){let n=[[],[],[],[],[]],s=new Map;function r(t,o){let h=s.get(t);if(null!=h){if(h<=o)return;let e=n[h].indexOf(t);e>-1&&n[h].splice(e,1),t instanceof 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 j)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))i instanceof j?n.push(i):(s[i.facet.id]||(s[i.facet.id]=[])).push(i);let o=Object.create(null),h=[],l=[];for(let t of n)o[t.id]=l.length<<1,l.push((e=>t.slot(e)));let a=null==i?void 0:i.config.facets;for(let t in s){let e=s[t],n=e[0].facet,r=a&&a[t]||[];if(e.every((t=>0==t.type)))if(o[n.id]=h.length<<1|1,H(r,e))h.push(i.facet(n));else{let t=n.combine(e.map((t=>t.value)));h.push(i&&n.compare(t,i.facet(n))?i.facet(n):t)}else{for(let t of e)0==t.type?(o[t.id]=h.length<<1|1,h.push(t.value)):(o[t.id]=l.length<<1,l.push((e=>t.dynamicSlot(e))));o[n.id]=l.length<<1,l.push((t=>F(t,n,e)))}}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 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&&N(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 gt(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(pt.userEvent.of(e.userEvent))),{changes:e.changes instanceof C?e.changes:C.of(e.changes||[],i,t.facet(rt)),selection:n&&(n instanceof I?n:I.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 s=1;s<e.length;s++){!1===e[s].filter&&(i=!1);let r=!!e[s].sequential;n=mt(n,wt(t,e[s],r?n.changes.newLength:t.doc.length),r)}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(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:pt.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}(i?function(t){let e=t.startState,i=!0;for(let n of e.facet(ot)){let e=n(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:gt(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=pt.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 i=n.length-1;i>=0;i--){let s=n[i](t);t=s instanceof pt?s:Array.isArray(s)&&1==s.length&&s[0]instanceof pt?s[0]:vt(e,bt(s),!1)}return t}(s):s)}pt.time=ct.define(),pt.userEvent=ct.define(),pt.addToHistory=ct.define(),pt.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 kt=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let St;try{St=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(St)return St.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 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 t=0;t<this.config.dynamicSlots.length;t++)et(this,t<<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 e of t.effects)e.is(Q.reconfigure)?(i&&(s=new Map,i.compartments.forEach(((t,e)=>s.set(e,t))),i=null),s.set(e.value.compartment,e.value.extension)):e.is(dt.reconfigure)?(i=null,n=e.value):e.is(dt.appendConfig)&&(i=null,n=bt(n).concat(e.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:I.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 i=1;i<e.ranges.length;i++){let o=t(e.ranges[i]),h=this.changes(o.changes),l=h.map(n);for(let t=0;t<i;t++)s[t]=s[t].map(l);let a=n.mapDesc(h,!0);s.push(o.range.map(a)),n=n.compose(l),r=dt.mapEffects(r,l).concat(dt.mapEffects(bt(o.effects),a))}return{changes:n,selection:I.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)||S))}sliceDoc(t=0,e=this.doc.length){return this.doc.sliceString(t,e,this.lineBreak)}facet(t){let e=this.config.address[t.id];return null==e?t.default:(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 j&&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 e in i)if(Object.prototype.hasOwnProperty.call(t,e)){let s=i[e],r=t[e];n.push(s.init((t=>s.spec.fromJSON(r,t))))}return Mt.create({doc:t.doc,selection:I.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)||S)),s=t.selection?t.selection instanceof I?t.selection:I.single(t.selection.anchor,t.selection.head):I.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 e of this.facet(Mt.phrases))if(Object.prototype.hasOwnProperty.call(e,t)){t=e[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:I.range(r+i,o+i)}}function Ct(t,e,i={}){let n={};for(let e of t)for(let t of Object.keys(e)){let s=e[t],r=n[t];if(void 0===r)n[t]=s;else if(r===s||void 0===s);else{if(!Object.hasOwnProperty.call(i,t))throw new Error("Config merge conflict for field "+t);n[t]=i[t](r,s)}}for(let t in e)void 0===n[t]&&(n[t]=e[t]);return n}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 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(Dt)),this.isEmpty)return e.length?Bt.of(e):this;let o=new It(this,null,-1).goto(0),h=0,l=[],a=new Rt;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?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 s=0;s<this.chunk.length;s++){let r=this.chunkPos[s],o=this.chunk[s],h=t.touchesRange(r,r+o.length);if(!1===h)n=Math.max(n,o.maxPoint),e.push(o),i.push(t.mapPos(r));else if(!0===h){let{mapped:s,pos:h}=o.map(r,t);s&&(n=Math.max(n,s.maxPoint),e.push(s),i.push(h))}}let s=this.nextLayer.map(t);return 0==e.length?s:new 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 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 Rt;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()}}Bt.empty=new Bt([],[],null,-1),Bt.empty.nextLayer=Bt.empty;class Rt{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 Rt)).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 Pt(t,e,i){let n=new Map;for(let e of t)for(let t=0;t<e.chunk.length;t++)e.chunk[t].maxPoint<=0&&n.set(e.chunk[t],e.chunkPos[t]);let s=new Set;for(let t of e)for(let e=0;e<t.chunk.length;e++){let r=n.get(t.chunk[e]);null==r||(i?i.mapPos(r):r)!=t.chunkPos[e]||(null==i?void 0:i.touchesRange(r,r+t.chunk[e].length))||s.add(t.chunk[e])}return s}class It{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 It(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 t=this.heap.length>>1;t>=0;t--)Lt(this.heap,t);return this.next(),this}forward(t,e){for(let i of this.heap)i.forward(t,e);for(let t=this.heap.length>>1;t>=0;t--)Lt(this.heap,t);(this.to-t||this.value.endSide-e)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),Lt(this.heap,0)}}}function Lt(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){_t(this.active,t),_t(this.activeTo,t),_t(this.activeRank,t),this.minActive=Ft(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=Ft(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&&_t(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 _t(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 i=t.length-1;i>=e;i--)t[i+1]=t[i];t[e]=i}function Ft(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}var qt=i(28450),jt=i(29350);function Kt(t){let e;return e=11==t.nodeType?t.getSelection?t:t.ownerDocument:t,e.getSelection()}function $t(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function Jt(t,e){if(!e.anchorNode)return!1;try{return $t(t,e.anchorNode)}catch(t){return!1}}function Ut(t){return 3==t.nodeType?re(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function Gt(t,e,i,n){return!!i&&(Yt(t,e,i,n,-1)||Yt(t,e,i,n,1))}function Xt(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function Yt(t,e,i,n,s){for(;;){if(t==i&&e==n)return!0;if(e==(s<0?0:Qt(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=Xt(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?Qt(t):0}}}function Qt(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function Zt(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function te(t){return{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}class ee{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?Qt(e):0),i,Math.min(t.focusOffset,i?Qt(i):0))}set(t,e,i,n){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=n}}let ie,ne=null;function se(t){if(t.setActive)return t.setActive();if(ne)return t.focus(ne);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==ne?{get preventScroll(){return ne={preventScroll:!0},!0}}:void 0),!ne){ne=!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 re(t,e,i=e){let n=ie||(ie=document.createRange());return n.setEnd(t,i),n.setStart(t,e),n}function oe(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 he(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}class le{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new le(t.parentNode,Xt(t),e)}static after(t,e){return new le(t.parentNode,Xt(t)+1,e)}}const ae=[];class ce{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=ce.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=ue(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=ue(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==Qt(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&&!ce.get(i);)i=i.nextSibling;if(!i)return this.length;for(let t=0,e=0;;t++){let n=this.children[t];if(n.dom==i)return e;e+=n.length+n.breakAfter}}domBoundsAround(t,e,i=0){let n=-1,s=-1,r=-1,o=-1;for(let h=0,l=i,a=i;h<this.children.length;h++){let i=this.children[h],c=l+i.length;if(l<t&&c>e)return i.domBoundsAround(t,e,l);if(c>=t&&-1==n&&(n=h,s=l),l>e&&i.dom.parentNode==this.dom){r=h,o=a;break}a=c,l=c+i.breakAfter}return{from:s,to:o<0?i+this.length:o,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:r<this.children.length&&r>=0?this.children[r].dom:null}}markDirty(t=!1){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=ae){this.markDirty();for(let i=t;i<e;i++){let t=this.children[i];t.parent==this&&t.destroy()}this.children.splice(t,e-t,...i);for(let t=0;t<i.length;t++)i[t].setParent(this)}ignoreMutation(t){return!1}ignoreEvent(t){return!1}childCursor(t=this.length){return new fe(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 ue(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}ce.prototype.breakAfter=0;class fe{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 de(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 pe(t,e,i,n,s,r){let o=t.childCursor(),{i:h,off:l}=o.findPos(i,1),{i:a,off:c}=o.findPos(e,-1),u=e-i;for(let t of n)u+=t.length;t.length+=u,de(t,a,c,h,l,n,0,s,r)}let ge="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},me="undefined"!=typeof document?document:{documentElement:{style:{}}};const we=/Edge\/(\d+)/.exec(ge.userAgent),ve=/MSIE \d/.test(ge.userAgent),ye=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ge.userAgent),be=!!(ve||ye||we),xe=!be&&/gecko\/(\d+)/i.test(ge.userAgent),ke=!be&&/Chrome\/(\d+)/.exec(ge.userAgent),Se="webkitFontSmoothing"in me.documentElement.style,Ae=!be&&/Apple Computer/.test(ge.vendor),Me=Ae&&(/Mobile\/\w+/.test(ge.userAgent)||ge.maxTouchPoints>2);var Ce={mac:Me||/Mac/.test(ge.platform),windows:/Win/.test(ge.platform),linux:/Linux|X11/.test(ge.platform),ie:be,ie_version:ve?me.documentMode||6:ye?+ye[1]:we?+we[1]:0,gecko:xe,gecko_version:xe?+(/Firefox\/(\d+)/.exec(ge.userAgent)||[0,0])[1]:0,chrome:!!ke,chrome_version:ke?+ke[1]:0,ios:Me,android:/Android\b/.test(ge.userAgent),webkit:Se,safari:Ae,webkit_version:Se?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:null!=me.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class Oe extends ce{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 Oe&&!(this.length-(e-t)+i.length>256))&&(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new Oe(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 le(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 De(this.dom,t,e)}}class Te extends ce{constructor(t,e=[],i=0){super(),this.mark=t,this.children=e,this.length=i;for(let t of e)t.setParent(this)}setAttrs(t){if(he(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 Te&&i.mark.eq(this.mark))||t&&s<=0||e<this.length&&r<=0))&&(pe(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 r of this.children){let o=i+r.length;o>t&&e.push(i<t?r.split(t-i):r),n<0&&i>=t&&(n=s),i=o,s++}let r=this.length-t;return this.length=t,n>-1&&(this.children.length=n,this.markDirty()),new Te(this.mark,e,r)}domAtPos(t){return Ve(this,t)}coordsAt(t,e){return We(this,t,e)}}function De(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?Ce.chrome||Ce.gecko||(e?(s--,o=1):r<n&&(r++,o=-1)):i<0?s--:r<n&&r++;let h=re(t,s,r).getClientRects();if(!h.length)return null;let l=h[(o?o<0:i>=0)?0:h.length-1];return Ce.safari&&!o&&0==l.width&&(l=Array.prototype.find.call(h,(t=>t.width))||l),o?Zt(l,o<0):l||null}class Ee extends ce{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||Ee)(t,e,i)}split(t){let e=Ee.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 Ee&&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 Ee&&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 n.empty;let t=this;for(;t.parent;)t=t.parent;let{view:e}=t,i=e&&e.state.doc,s=this.posAtStart;return i?i.slice(s,s+this.length):n.empty}domAtPos(t){return(this.length?0==t:this.side>0)?le.before(this.dom):le.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 e=r?n.length-1:0;s=n[e],!(t>0?0==e:e==n.length-1||s.top<s.bottom);e+=r?-1:1);return Zt(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 Be extends Ee{domAtPos(t){let{topView:e,text:i}=this.widget;return e?Re(t,0,e,i,this.length-e.length,((t,e)=>t.domAtPos(e)),((t,e)=>new le(t,Math.min(e,t.nodeValue.length)))):new le(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?Ie(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?Re(t,e,i,n,this.length-i.length,((t,e,i)=>t.coordsAt(e,i)),((t,e,i)=>De(t,e,i))):De(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 Re(t,e,i,n,s,r,o){if(i instanceof Te){for(let h=i.dom.firstChild;h;h=h.nextSibling){let i=ce.get(h);if(i){let l=$t(h,n),a=i.length+(l?s:0);if(t<a||t==a&&i.getSide()<=0)return l?Re(t,e,i,n,s,r,o):r(i,t,e);t-=a}else{let i=Pe(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 Pe(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=Pe(t,e,s,n);if("number"!=typeof i)return i;t=i}return t}function Ie(t,e,i,n,s){if(i instanceof Te){let r=0;for(let o=i.dom.firstChild;o;o=o.nextSibling){let i=ce.get(o);if(i){let h=$t(o,n);if($t(o,t))return r+(h?Ie(t,e,i,n,s):i.localPosFromDOM(t,e));r+=i.length+(h?s:0)}else{let i=Ne(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 Ne(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=Ne(t,e,s);if(null!=o.result)return{result:e+o.result};n+=o.size}}}class Le extends ce{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof Le&&t.side==this.side}split(){return new Le(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?le.before(this.dom):le.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return n.empty}get isHidden(){return!0}}function Ve(t,e){let i=t.dom,{children:n}=t,s=0;for(let t=0;s<n.length;s++){let r=n[s],o=t+r.length;if(!(o==t&&r.getSide()<=0)){if(e>t&&e<o&&r.dom.parentNode==i)return r.domAtPos(e-t);if(e<=t)break;t=o}}for(let t=s;t>0;t--){let e=n[t-1];if(e.dom.parentNode==i)return e.domAtPos(e.length)}for(let t=s;t<n.length;t++){let e=n[t];if(e.dom.parentNode==i)return e.domAtPos(0)}return new le(i,0)}function He(t,e,i){let n,{children:s}=t;i>0&&e instanceof Te&&s.length&&(n=s[s.length-1])instanceof Te&&n.mark.eq(e.mark)?He(n,e.children[0],i-1):(s.push(e),e.setParent(t)),t.length+=e.length}function We(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):function(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=Ut(e);return i[i.length-1]||null}(t)}function _e(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 ze(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 Fe(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}Oe.prototype.children=Ee.prototype.children=Le.prototype.children=ae;class qe{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 je=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(je||(je={}));class Ke extends Ot{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 $e(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 Ue(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}=Ge(t,n);e=(s?n?-3e8:-1:5e8)-1,i=1+(r?n?2e8:1:-6e8)}return new Ue(t,e,i,n,t.widget||null,!0)}static line(t){return new Je(t)}static set(t,e=!1){return Bt.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}Ke.none=Bt.empty;class $e extends Ke{constructor(t){let{start:e,end:i}=Ge(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 $e&&this.tagName==t.tagName&&this.class==t.class&&ze(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)}}$e.prototype.point=!1;class Je extends Ke{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof Je&&this.spec.class==t.spec.class&&ze(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)}}Je.prototype.mapMode=A.TrackBefore,Je.prototype.point=!0;class Ue extends Ke{constructor(t,e,i,n,s,r){super(e,i,s,t),this.block=n,this.isReplace=r,this.mapMode=n?e<=0?A.TrackBefore:A.TrackAfter:A.TrackDel}get type(){return this.startSide<this.endSide?je.WidgetRange:this.startSide<=0?je.WidgetBefore:je.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof Ue&&(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 Ge(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 Xe(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)}Ue.prototype.point=!0;class Ye extends ce{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 Ye))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),pe(this,t,e,i?i.children:[],s,r),!0}split(t){let e=new Ye;if(e.breakAfter=this.breakAfter,0==this.length)return e;let{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 t=i;t<this.children.length;t++)e.append(this.children[t],0);for(;i>0&&0==this.children[i-1].length;)this.children[--i].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){ze(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){He(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=_e(e,this.attrs||{})),i&&(this.attrs=_e({class:i},this.attrs||{}))}domAtPos(t){return Ve(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.dirty|=6)}sync(t,e){var i;this.dom?4&this.dirty&&(he(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&&(Fe(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&&ce.get(n)instanceof Te;)n=n.lastChild;if(!(n&&this.length&&("BR"==n.nodeName||0!=(null===(i=ce.get(n))||void 0===i?void 0:i.isEditable)||Ce.ios&&this.children.some((t=>t instanceof Oe))))){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 Oe)||/[^ -~]/.test(i.text))return null;let n=Ut(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=We(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 je.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 Ye)return s;if(r>e)break}n=r+s.breakAfter}return null}}class Qe extends ce{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 Qe&&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?le.before(this.dom):le.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new Qe(this.widget,e,this.type);return i.breakAfter=this.breakAfter,i}get children(){return ae}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):n.empty}domBoundsAround(){return null}become(t){return t instanceof Qe&&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 Ze{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 Qe&&t.type==je.WidgetBefore)}getLine(){return this.curLine||(this.content.push(this.curLine=new Ye),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(ti(new Le(-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(ti(new Oe(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 Ue){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 Ue)if(i.block){let{type:t}=i;t!=je.WidgetAfter||this.posCovered()||this.getLine(),this.addBlockWidget(new Qe(i.widget||new ei("div"),o,t))}else{let r=Ee.create(i.widget||new ei("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(ti(new Le(1),n),s),s=n.length+Math.max(0,s-n.length)),a.append(ti(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 r=new Ze(t,e,i,s);return r.openEnd=Bt.spans(n,e,i,r),r.openStart<0&&(r.openStart=r.openEnd),r.finish(r.openEnd),r}}function ti(t,e){for(let i of e)t=new Te(i,[t],t.length);return t}class ei extends qe{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 ii=V.define(),ni=V.define(),si=V.define(),ri=V.define(),oi=V.define(),hi=V.define(),li=V.define(),ai=V.define({combine:t=>t.some((t=>t))}),ci=V.define({combine:t=>t.some((t=>t))});class ui{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 ui(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin)}}const fi=dt.define({map:(t,e)=>t.map(e)});function di(t,e,i){let n=t.facet(ri);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 pi=V.define({combine:t=>!t.length||t[0]});let gi=0;const mi=V.define();class wi{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 wi(gi++,t,i,(t=>{let e=[mi.of(t)];return s&&e.push(xi.of((e=>{let i=e.plugin(t);return i?s(i):Ke.none}))),n&&e.push(n(t)),e}))}static fromClass(t,e){return wi.define((e=>new t(e)),e)}}class vi{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(di(t.state,e,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(t){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(t)}catch(e){di(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(e){di(t.state,e,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const yi=V.define(),bi=V.define(),xi=V.define(),ki=V.define(),Si=V.define();function Ai(t){let e=0,i=0,n=0,s=0;for(let r of t.state.facet(Si)){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 Mi=V.define();class Ci{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new Ci(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 Ci(r+l,h+l,r,h).addToSet(i),n>a)break;s+=2}if(!h)return i;new Ci(h.fromA,h.toA,h.fromB,h.toB).addToSet(i),r=h.toA,o=h.toB}}}class Oi{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=C.empty(this.startState.doc.length);for(let t of i)this.changes=this.changes.compose(t.changes);let n=[];this.changes.iterChangedRanges(((t,e,i,s)=>n.push(new Ci(t,e,i,s)))),this.changedRanges=n}static create(t,e,i){return new Oi(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 Ti=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(Ti||(Ti={}));const Di=Ti.LTR,Ei=Ti.RTL;function Bi(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}const Ri=Bi("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Pi=Bi("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Ii=Object.create(null),Ni=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),i=t.charCodeAt(1);Ii[e]=i,Ii[i]=-e}const Li=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Vi{constructor(t,e,i){this.from=t,this.to=e,this.level=i}get dir(){return this.level%2?Ei:Di}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 Hi=[];function Wi(t,e){let i=t.length,n=e==Di?1:2,s=e==Di?2:1;if(!t||1==n&&!Li.test(t))return _i(i);for(let e=0,s=n,o=n;e<i;e++){let i=(r=t.charCodeAt(e))<=247?Ri[r]:1424<=r&&r<=1524?2:1536<=r&&r<=1785?Pi[r-1536]:1774<=r&&r<=2220?4:8192<=r&&r<=8203?256:64336<=r&&r<=65023?4:8204==r?256:1;512==i?i=s:8==i&&4==o&&(i=16),Hi[e]=4==i?2:i,7&i&&(o=i),s=i}var r;for(let t=0,e=n,s=n;t<i;t++){let n=Hi[t];if(128==n)t<i-1&&e==Hi[t+1]&&24&e?n=Hi[t]=e:Hi[t]=256;else if(64==n){let n=t+1;for(;n<i&&64==Hi[n];)n++;let r=t&&8==e||n<i&&8==Hi[n]?1==s?1:8:256;for(let e=t;e<n;e++)Hi[e]=r;t=n-1}else 8==n&&1==s&&(Hi[t]=1);e=n,7&n&&(s=n)}for(let e,r,o,h=0,l=0,a=0;h<i;h++)if(r=Ii[e=t.charCodeAt(h)])if(r<0){for(let t=l-3;t>=0;t-=3)if(Ni[t+1]==-r){let e=Ni[t+2],i=2&e?n:4&e?1&e?s:n:0;i&&(Hi[h]=Hi[Ni[t]]=i),l=t;break}}else{if(189==Ni.length)break;Ni[l++]=h,Ni[l++]=e,Ni[l++]=a}else if(2==(o=Hi[h])||1==o){let t=o==n;a=t?0:1;for(let e=l-3;e>=0;e-=3){let i=Ni[e+2];if(2&i)break;if(t)Ni[e+2]|=2;else{if(4&i)break;Ni[e+2]|=4}}}for(let t=0;t<i;t++)if(256==Hi[t]){let e=t+1;for(;e<i&&256==Hi[e];)e++;let s=1==(t?Hi[t-1]:n),r=s==(1==(e<i?Hi[e]:n))?s?1:2:n;for(let i=t;i<e;i++)Hi[i]=r;t=e-1}let o=[];if(1==n)for(let t=0;t<i;){let e=t,n=1!=Hi[t++];for(;t<i&&n==(1!=Hi[t]);)t++;if(n)for(let i=t;i>e;){let t=i,n=2!=Hi[--i];for(;i>e&&n==(2!=Hi[i-1]);)i--;o.push(new Vi(i,t,n?2:1))}else o.push(new Vi(e,t,0))}else for(let t=0;t<i;){let e=t,n=2==Hi[t++];for(;t<i&&n==(2==Hi[t]);)t++;o.push(new Vi(e,t,n?1:2))}return o}function _i(t){return[new Vi(0,t,0)]}let zi="";function Fi(t,e,i,n,s){var r;let o=n.head-t.from,h=-1;if(0==o){if(!s||!t.length)return null;e[0].level!=i&&(o=e[0].side(!1,i),h=0)}else if(o==t.length){if(s)return null;let t=e[e.length-1];t.level!=i&&(o=t.side(!0,i),h=e.length-1)}h<0&&(h=Vi.find(e,o,null!==(r=n.bidiLevel)&&void 0!==r?r:-1,n.assoc));let l=e[h];o==l.side(s,i)&&(l=e[h+=s?1:-1],o=l.side(!s,i));let a=s==(l.dir==i),c=m(t.text,o,a);if(zi=t.text.slice(Math.min(o,c),Math.max(o,c)),c!=l.side(s,i))return I.cursor(c+t.from,a?-1:1,l.level);let u=h==(s?e.length-1:0)?null:e[h+(s?1:-1)];return u||l.level==i?u&&u.level<l.level?I.cursor(u.side(!s,i)+t.from,s?1:-1,u.level):I.cursor(c+t.from,s?-1:1,l.level):I.cursor(s?t.to:t.from,s?-1:1,i)}const qi="￿";class ji{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(Mt.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=qi}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=ce.get(n),o=ce.get(s);(r&&o?r.breakAfter:(r?r.breakAfter:Ki(n))||Ki(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=ce.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 Ki(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}class $i{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class Ji extends ce{constructor(t){super(),this.view=t,this.compositionDeco=Ke.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 Ye],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Ci(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=Ke.none:(t.transactions.length||this.dirty)&&(this.compositionDeco=function(t,e){let i=Gi(t);if(!i)return Ke.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 ji([],a);3==r.nodeType?c.readTextNode(r):c.readRange(r.firstChild,null);let{text:u}=c;if(u.indexOf(qi)>-1)return Ke.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 Ke.none;h=l-u.length}else if(a.doc.sliceString(h,l)!=u)return Ke.none;let f=ce.get(r);f instanceof Be?f=f.widget.topView:f&&(f.parent=null);return Ke.set(Ke.replace({widget:new Xi(r,o,f),inclusive:!0}).range(h,l))}(this.view,t.changes)),(Ce.ie||Ce.chrome)&&!this.compositionDeco.size&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let i=function(t,e,i){let n=new Qi;return Bt.compare(t,e,i,n),n.changes}(this.decorations,this.updateDeco(),t.changes);return e=Ci.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=Ce.chrome||Ce.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 t of this.children)t instanceof Qe&&t.widget instanceof Ui&&n.push(t.dom);i.updateGaps(n)}updateChildren(t,e){let i=this.childCursor(e);for(let e=t.length-1;;e--){let n=e>=0?t[e]:null;if(!n)break;let{fromA:s,toA:r,fromB:o,toB:h}=n,{content:l,breakAtStart:a,openStart:c,openEnd:u}=Ze.build(this.view.state.doc,o,h,this.decorations,this.dynamicDecorationMap),{i:f,off:d}=i.findPos(r,1),{i:p,off:g}=i.findPos(s,-1);de(this,p,g,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&&Jt(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(Ce.gecko&&o.empty&&!this.compositionDeco.size&&(1==(a=h).node.nodeType&&a.node.firstChild&&(0==a.offset||"false"==a.node.childNodes[a.offset-1].contentEditable)&&(a.offset==a.node.childNodes.length||"false"==a.node.childNodes[a.offset].contentEditable))){let t=document.createTextNode("");this.view.observer.ignore((()=>h.node.insertBefore(t,h.node.childNodes[h.offset]||null))),h=l=new le(t,0),r=!0}var a;let c=this.view.observer.selectionRange;!r&&c.focusNode&&Gt(h.node,h.offset,c.anchorNode,c.anchorOffset)&&Gt(l.node,l.offset,c.focusNode,c.focusOffset)||(this.view.observer.ignore((()=>{Ce.android&&Ce.chrome&&this.dom.contains(c.focusNode)&&function(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}(c.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let t=Kt(this.view.root);if(t)if(o.empty){if(Ce.gecko){let t=(e=h.node,n=h.offset,1!=e.nodeType?0:(n&&"false"==e.childNodes[n-1].contentEditable?1:0)|(n<e.childNodes.length&&"false"==e.childNodes[n].contentEditable?2:0));if(t&&3!=t){let e=Yi(h.node,h.offset,1==t?1:-1);e&&(h=new le(e,1==t?0:e.nodeValue.length))}}t.collapse(h.node,h.offset),null!=o.bidiLevel&&null!=c.cursorBidiLevel&&(c.cursorBidiLevel=o.bidiLevel)}else if(t.extend){t.collapse(h.node,h.offset);try{t.extend(l.node,l.offset)}catch(t){}}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;var e,n;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 le(c.anchorNode,c.anchorOffset),this.impreciseHead=l.precise?null:new le(c.focusNode,c.focusOffset)}enforceCursorAssoc(){if(this.compositionDeco.size)return;let{view:t}=this,e=t.state.selection.main,i=Kt(t.root),{anchorNode:n,anchorOffset:s}=t.observer.selectionRange;if(!(i&&e.empty&&e.assoc&&i.modify))return;let r=Ye.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=ce.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 Ye)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!=je.WidgetBefore&&s.type!=je.WidgetAfter&&(!n||2==e||this.children[n-1].breakAfter||this.children[n-1].type==je.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==Ti.LTR;for(let t=0,l=0;l<this.children.length;l++){let a=this.children[l],c=t+a.length;if(c>n)break;if(t>=i){let i=a.dom.getBoundingClientRect();if(e.push(i.height),r){let e=a.dom.lastChild,n=e?Ut(e):[];if(n.length){let e=n[n.length-1],r=h?e.right-i.left:i.right-e.left;r>o&&(o=r,this.minWidth=s,this.minWidthFrom=t,this.minWidthTo=c)}}}t=c+a.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?Ti.RTL:Ti.LTR}measureTextSize(){for(let t of this.children)if(t instanceof Ye){let e=t.measureTextSize();if(e)return e}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=Ut(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 fe(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(Ke.replace({widget:new Ui(n),block:!0,inclusive:!0,isBlockGap:!0}).range(i,r))}if(!s)break;i=s.to+1}return Ke.set(t)}updateDeco(){let t=this.view.state.facet(xi).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=Ai(this.view),r={left:n.left-s.left,top:n.top-s.top,right:n.right+s.right,bottom:n.bottom+s.bottom};!function(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=te(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))):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,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}}(this.view.scrollDOM,r,i.head<i.anchor?-1:1,t.x,t.y,t.xMargin,t.yMargin,this.view.textDirection==Ti.LTR)}}class Ui extends qe{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 Gi(t){let e=t.observer.selectionRange,i=e.focusNode&&Yi(e.focusNode,e.focusOffset,0);if(!i)return null;let n=t.docView.nearest(i);if(!n)return null;if(n instanceof Ye){let t=i;for(;t.parentNode!=n.dom;)t=t.parentNode;let e=t.previousSibling;for(;e&&!ce.get(e);)e=e.previousSibling;let s=e?ce.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 Ye)break;n=t}let t=n.posAtStart;return{from:t,to:t+n.length,node:n.dom,text:i}}}class Xi extends qe{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 Be}}function Yi(t,e,i){if(i<=0)for(let i=t,n=e;;){if(3==i.nodeType)return i;if(!(1==i.nodeType&&n>0))break;i=i.childNodes[n-1],n=Qt(i)}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}class Qi{constructor(){this.changes=[]}compareRange(t,e){Xe(t,e,this.changes)}comparePoint(t,e){Xe(t,e,this.changes)}}function Zi(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function tn(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function en(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function nn(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function sn(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function rn(t,e,i){let n,s,r,o,h,l,a,c,u=!1;for(let f=t.firstChild;f;f=f.nextSibling){let t=Ut(f);for(let d=0;d<t.length;d++){let p=t[d];s&&en(s,p)&&(p=nn(sn(p,s.bottom),s.top));let g=Zi(e,p),m=tn(i,p);if(0==g&&0==m)return 3==f.nodeType?on(f,e,i):rn(f,e,i);if(!n||o>m||o==m&&r>g){n=f,s=p,r=g,o=m;let h=m?i<p.top?-1:1:g?e<p.left?-1:1:0;u=!h||(h>0?d<t.length-1:d>0)}0==g?i>p.bottom&&(!a||a.bottom<p.bottom)?(h=f,a=p):i<p.top&&(!c||c.top>p.top)&&(l=f,c=p):a&&en(a,p)?a=sn(a,p.bottom):c&&en(c,p)&&(c=nn(c,p.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?on(n,f,i):u&&"false"!=n.contentEditable?rn(n,f,i):{node:t,offset:Array.prototype.indexOf.call(t.childNodes,n)+(e>=(s.left+s.right)/2?1:0)}}function on(t,e,i){let n=t.nodeValue.length,s=-1,r=1e9,o=0;for(let h=0;h<n;h++){let n=re(t,h,h+1).getClientRects();for(let l=0;l<n.length;l++){let a=n[l];if(a.top==a.bottom)continue;o||(o=e-a.left);let c=(a.top>i?a.top-i:i-a.bottom)-1;if(a.left-1<=e&&a.right+1>=e&&c<r){let i=e>=(a.left+a.right)/2,n=i;if(Ce.chrome||Ce.gecko){re(t,h).getBoundingClientRect().left==a.right&&(n=!i)}if(c<=0)return{node:t,offset:h+(n?1:0)};s=h+(n?1:0),r=c}}}return{node:t,offset:s>-1?s:o>0?t.nodeValue.length:0}}function hn(t,e,i,n=-1){var s,r;let o,h=t.contentDOM.getBoundingClientRect(),l=h.top+t.viewState.paddingTop,{docHeight:a}=t.viewState,{x:c,y:u}=e,f=u-l;if(f<0)return 0;if(f>a)return t.state.doc.length;for(let e=t.viewState.heightOracle.textHeight/2,s=!1;o=t.elementAtHeight(f),o.type!=je.Text;)for(;f=n>0?o.bottom+e:o.top-e,!(f>=0&&f<=a);){if(s)return i?null:0;s=!0,n=-n}u=l+f;let d=o.from;if(d<t.viewport.from)return 0==t.viewport.from?0:i?null:ln(t,h,o,c,u);if(d>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:ln(t,h,o,c,u);let p=t.dom.ownerDocument,g=t.root.elementFromPoint?t.root:p,m=g.elementFromPoint(c,u);m&&!t.contentDOM.contains(m)&&(m=null),m||(c=Math.max(h.left+1,Math.min(h.right-1,c)),m=g.elementFromPoint(c,u),m&&!t.contentDOM.contains(m)&&(m=null));let w,v=-1;if(m&&0!=(null===(s=t.docView.nearest(m))||void 0===s?void 0:s.isEditable))if(p.caretPositionFromPoint){let t=p.caretPositionFromPoint(c,u);t&&({offsetNode:w,offset:v}=t)}else if(p.caretRangeFromPoint){let e=p.caretRangeFromPoint(c,u);e&&(({startContainer:w,startOffset:v}=e),(!t.contentDOM.contains(w)||Ce.safari&&function(t,e,i){let n;if(3!=t.nodeType||e!=(n=t.nodeValue.length))return!1;for(let e=t.nextSibling;e;e=e.nextSibling)if(1!=e.nodeType||"BR"!=e.nodeName)return!1;return re(t,n-1,n).getBoundingClientRect().left>i}(w,v,c)||Ce.chrome&&function(t,e,i){if(0!=e)return!1;for(let e=t;;){let t=e.parentNode;if(!t||1!=t.nodeType||t.firstChild!=e)return!1;if(t.classList.contains("cm-line"))break;e=t}let n=1==t.nodeType?t.getBoundingClientRect():re(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect();return i-n.left>5}(w,v,c))&&(w=void 0))}if(!w||!t.docView.dom.contains(w)){let e=Ye.find(t.docView,d);if(!e)return f>o.top+o.height/2?o.to:o.from;({node:w,offset:v}=rn(e.dom,c,u))}let y=t.docView.nearest(w);if(!y)return null;if(y.isWidget&&1==(null===(r=y.dom)||void 0===r?void 0:r.nodeType)){let t=y.dom.getBoundingClientRect();return e.y<t.top||e.y<=t.bottom&&e.x<=(t.left+t.right)/2?y.posAtStart:y.posAtEnd}return y.localPosFromDOM(w,v)+y.posAtStart}function ln(t,e,i,n,s){let r=Math.round((n-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>1.5*t.defaultLineHeight){let e=t.viewState.heightOracle.textHeight;r+=Math.floor((s-i.top-.5*(t.defaultLineHeight-e))/e)*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(i.from,i.to);return i.from+function(t,e,i,n){for(let n=0,s=0;;){if(s>=e)return n;if(n==t.length)break;s+=9==t.charCodeAt(n)?i-s%i:1,n=m(t,n)}return!0===n?-1:t.length}(o,r,t.state.tabSize)}function an(t,e){let i=t.lineBlockAt(e);if(Array.isArray(i.type))for(let t of i.type)if(t.to>e||t.to==e&&(t.to==i.to||t.type==je.Text))return t;return i}function cn(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=Fi(s,r,o,h,i),a=zi;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=I.cursor(i?s.from:s.to)}if(l){if(!l(a))return h}else{if(!n)return e;l=n(a)}h=e}}function un(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 fn(t,e,i){let n=un(t.state.facet(ki).map((e=>e(t))),i.from,e.head>i.from?-1:1);return n==i.from?i:I.cursor(n,n<i.from?1:-1)}class dn{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 bn){let n=bn[i];t.contentDOM.addEventListener(i,(i=>{yn(t,i)&&e(n,i)}),xn[i]),this.registeredEvents.push(i)}t.scrollDOM.addEventListener("mousedown",(i=>{if(i.target==t.scrollDOM&&i.clientY>t.contentDOM.getBoundingClientRect().bottom&&(e(bn.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(bn.drop,i)})),Ce.chrome&&102==Ce.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,Ce.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=>{yn(t,i)&&this.runCustomHandlers(e,t,i)&&i.preventDefault()})))}}runCustomHandlers(t,e,i){for(let n of this.customHandlers){let s=n.handlers[t];if(s)try{if(s.call(n.plugin,i,e)||i.defaultPrevented)return!0}catch(t){di(e.state,t)}}return!1}runScrollHandlers(t,e){this.lastScrollTop=t.scrollDOM.scrollTop,this.lastScrollLeft=t.scrollDOM.scrollLeft;for(let i of this.customHandlers){let n=i.handlers.scroll;if(n)try{n.call(i.plugin,e,t)}catch(e){di(t.state,e)}}}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&&mn.indexOf(e.keyCode)<0&&(t.inputState.lastEscPress=0),Ce.android&&Ce.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))return t.observer.delayAndroidKey(e.key,e.keyCode),!0;let i;return!(!Ce.ios||e.synthetic||e.altKey||e.metaKey||!((i=pn.find((t=>t.keyCode==e.keyCode)))&&!e.ctrlKey||gn.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,oe(t.contentDOM,e.key,e.keyCode))}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(this.composing>0||!!(Ce.safari&&!Ce.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 pn=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],gn="dthko",mn=[16,17,18,20,91,92,224,225];function wn(t){return.7*Math.max(0,t)+8}class vn{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=function(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}(t.contentDOM),this.atoms=t.state.facet(ki).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(Mt.allowMultipleSelections)&&function(t,e){let i=t.state.facet(ii);return i.length?i[0](e):Ce.mac?e.metaKey:e.ctrlKey}(t,e),this.dragging=!(!function(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let n=Kt(t.root);if(!n||0==n.rangeCount)return!0;let s=n.getRangeAt(0).getClientRects();for(let t=0;t<s.length;t++){let i=s[t];if(i.left<=e.clientX&&i.right>=e.clientX&&i.top<=e.clientY&&i.bottom>=e.clientY)return!0}return!1}(t,e)||1!=Pn(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=Ai(this.view);t.clientX-r.left<=s.left+6?i=-wn(s.left-t.clientX):t.clientX+r.right>=s.right-6&&(i=wn(t.clientX-s.right)),t.clientY-r.top<=s.top+6?n=-wn(s.top-t.clientY):t.clientY+r.bottom>=s.bottom-6&&(n=wn(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=un(this.atoms,n.from,0);t!=n.from&&(s=I.cursor(t,-1))}else{let t=un(this.atoms,n.from,-1),e=un(this.atoms,n.to,1);t==n.from&&e==n.to||(s=I.range(n.from==n.anchor?t:e,n.from==n.head?t:e))}s&&(e||(e=t.ranges.slice()),e[i]=s)}return e?I.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 yn(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=ce.get(n))&&i.ignoreEvent(e))return!1;return!0}const bn=Object.create(null),xn=Object.create(null),kn=Ce.ie&&Ce.ie_version<15||Ce.ios&&Ce.webkit_version<604;function Sn(t,e){let i,{state:n}=t,s=1,r=n.toText(e),o=r.lines==n.selection.ranges.length;if(null!=Nn&&n.selection.ranges.every((t=>t.empty))&&Nn==r.toString()){let t=-1;i=n.changeByRange((i=>{let h=n.doc.lineAt(i.from);if(h.from==t)return{range:i};t=h.from;let l=n.toText((o?r.line(s++).text:e)+n.lineBreak);return{changes:{from:h.from,insert:l},range:I.cursor(i.from+l.length)}}))}else i=o?n.changeByRange((t=>{let e=r.line(s++);return{changes:{from:t.from,to:t.to,insert:e.text},range:I.cursor(t.from+e.length)}})):n.replaceSelection(r);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function An(t,e,i,n){if(1==n)return I.cursor(e,i);if(2==n)return function(t,e,i=1){let n=t.charCategorizer(e),s=t.doc.lineAt(e),r=e-s.from;if(0==s.length)return I.cursor(e);0==r?i=1:r==s.length&&(i=-1);let o=r,h=r;i<0?o=m(s.text,r,!1):h=m(s.text,r);let l=n(s.text.slice(o,h));for(;o>0;){let t=m(s.text,o,!1);if(n(s.text.slice(t,o))!=l)break;o=t}for(;h<s.length;){let t=m(s.text,h);if(n(s.text.slice(h,t))!=l)break;h=t}return I.range(o+s.from,h+s.from)}(t.state,e,i);{let i=Ye.find(t.docView,e),n=t.state.doc.lineAt(i?i.posAtEnd:e),s=i?i.posAtStart:n.from,r=i?i.posAtEnd:n.to;return r<t.state.doc.length&&r==n.to&&r++,I.range(s,r)}}bn.keydown=(t,e)=>{t.inputState.setSelectionOrigin("select"),27==e.keyCode&&(t.inputState.lastEscPress=Date.now())},bn.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},bn.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},xn.touchstart=xn.touchmove={passive:!0},bn.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return;let i=null;for(let n of t.state.facet(si))if(i=n(t,e),i)break;if(i||0!=e.button||(i=function(t,e){let i=Tn(t,e),n=Pn(e),s=t.state.selection;return{update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),s=s.map(t.changes))},get(e,r,o){let h,l=Tn(t,e),a=An(t,l.pos,l.bias,n);if(i.pos!=l.pos&&!r){let e=An(t,i.pos,i.bias,n),s=Math.min(e.from,a.from),r=Math.max(e.to,a.to);a=s<a.from?I.range(s,r):I.range(r,s)}return r?s.replaceRange(s.main.extend(a.from,a.to)):o&&1==n&&s.ranges.length>1&&(h=function(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 I.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}(s,l.pos))?h:o?s.addRange(a):I.create([a])}}}(t,e)),i){let n=t.root.activeElement!=t.contentDOM;t.inputState.startMouseSelection(new vn(t,e,i,n)),n&&t.observer.ignore((()=>se(t.contentDOM))),t.inputState.mouseSelection&&t.inputState.mouseSelection.start(e)}};let Mn=(t,e)=>t>=e.top&&t<=e.bottom,Cn=(t,e,i)=>Mn(e,i)&&t>=i.left&&t<=i.right;function On(t,e,i,n){let s=Ye.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&&Cn(i,n,o))return-1;let h=s.coordsAt(r,1);return h&&Cn(i,n,h)?1:o&&Mn(n,o)?-1:1}function Tn(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:On(t,i,e.clientX,e.clientY)}}const Dn=Ce.ie&&Ce.ie_version<=11;let En=null,Bn=0,Rn=0;function Pn(t){if(!Dn)return t.detail;let e=En,i=Rn;return En=t,Rn=Date.now(),Bn=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Bn+1)%3:1}function In(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&&function(t,e){let i=t.state.facet(ni);return i.length?i[0](e):Ce.mac?!e.altKey:!e.ctrlKey}(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"})}bn.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")},bn.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&&In(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 In(t,e,e.dataTransfer.getData("Text"),!0)},bn.paste=(t,e)=>{if(t.state.readOnly)return e.preventDefault();t.observer.flush();let i=kn?null:e.clipboardData;i?(Sn(t,i.getData("text/plain")||i.getData("text/uri-text")),e.preventDefault()):function(t){let e=t.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout((()=>{t.focus(),i.remove(),Sn(t,i.value)}),50)}(t)};let Nn=null;bn.copy=bn.cut=(t,e)=>{let{text:i,ranges:n,linewise:s}=function(t){let e=[],i=[],n=!1;for(let n of t.selection.ranges)n.empty||(e.push(t.sliceDoc(n.from,n.to)),i.push(n));if(!e.length){let s=-1;for(let{from:n}of t.selection.ranges){let r=t.doc.lineAt(n);r.number>s&&(e.push(r.text),i.push({from:r.from,to:Math.min(t.doc.length,r.to+1)})),s=r.number}n=!0}return{text:e.join(t.lineBreak),ranges:i,linewise:n}}(t.state);if(!i&&!s)return;Nn=s?i:null;let r=kn?null:e.clipboardData;r?(e.preventDefault(),r.clearData(),r.setData("text/plain",i)):function(t,e){let i=t.dom.parentNode;if(!i)return;let n=i.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout((()=>{n.remove(),t.focus()}),50)}(t,i),"cut"!=e.type||t.state.readOnly||t.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"})};const Ln=ct.define();function Vn(t,e){let i=[];for(let n of t.facet(li)){let s=n(t,e);s&&i.push(s)}return i?t.update({effects:i,annotations:Ln.of(!0)}):null}function Hn(t){setTimeout((()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=Vn(t.state,e);i?t.dispatch(i):t.update([])}}),10)}bn.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),Hn(t)},bn.blur=t=>{t.observer.clearSelectionRange(),Hn(t)},bn.compositionstart=bn.compositionupdate=t=>{null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0)},bn.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,Ce.chrome&&Ce.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)},bn.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},bn.beforeinput=(t,e)=>{var i;let n;if(Ce.chrome&&Ce.android&&(n=pn.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 Wn=["pre-wrap","normal","pre-line","break-spaces"];class _n{constructor(t){this.lineWrapping=t,this.doc=n.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 Wn.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=Wn.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 zn{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class Fn{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?je.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 Ue?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 Fn(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var qn=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}(qn||(qn={}));const jn=.001;class Kn{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)>jn&&(t.heightChanged=!0),this.height=e)}replace(t,e,i){return Kn.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,qn.ByPosNoHeight,i.setDoc(e),0,0),f=u.to>=l?u:s.lineAt(l,qn.ByPosNoHeight,i,0,0);for(c+=f.to-l,l=f.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,qn.ByPosNoHeight,i,0,0));a+=u.from-h,h=u.from;let d=Yn.build(i.setDoc(r),t,a,c);s=s.replace(h,l,d)}return s.updateHeight(i,0)}static empty(){return new Jn(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 Gn(Kn.of(t.slice(0,e)),r,Kn.of(t.slice(i)))}}Kn.prototype.size=1;class $n extends Kn{constructor(t,e,i){super(t,e),this.deco=i}blockAt(t,e,i,n){return new Fn(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 Jn extends $n{constructor(t,e){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(t,e,i,n){return new Fn(n,this.length,i,this.height,this.breaks)}replace(t,e,i){let n=i[0];return 1==i.length&&(n instanceof Jn||n instanceof Un&&4&n.flags)&&Math.abs(this.length-n.length)<10?(n instanceof Un?n=new Jn(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):Kn.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 Un extends Kn{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 Fn(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 Fn(h,l,i+o*n,o,0)}}lineAt(t,e,i,n,s){if(e==qn.ByHeight)return this.blockAt(t,i,n,s);if(e==qn.ByPosNoHeight){let{from:e,to:n}=i.doc.lineAt(t);return new Fn(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 Fn(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 Fn(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 Un?i[i.length-1]=new Un(t.length+n):i.push(null,new Un(n-1))}if(t>0){let e=i[0];e instanceof Un?i[0]=new Un(t+e.length):i.unshift(new Un(t-1),null)}return Kn.of(i)}decomposeLeft(t,e){e.push(new Un(t-1),null)}decomposeRight(t,e){e.push(null,new Un(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 Un(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)>=jn&&(o=-2);let h=new Jn(e,s);h.outdated=!1,i.push(h),r+=e+1}r<=s&&i.push(null,new Un(s-r).updateHeight(t,r));let h=Kn.of(i);return(o<0||Math.abs(h.height-this.height)>=jn||Math.abs(o-this.heightMetrics(t,e).perLine)>=jn)&&(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 Gn extends Kn{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==qn.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==qn.ByPosNoHeight?qn.ByPosNoHeight:qn.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,qn.ByPos,i,n,s);t<l.from&&this.left.forEachLine(t,l.from-1,i,n,s,r),l.to>=t&&l.from<=e&&r(l),e>l.to&&this.right.forEachLine(l.to+1,e,i,o,h,r)}}replace(t,e,i){let n=this.left.length+this.break;if(e<n)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let s=[];t>0&&this.decomposeLeft(t,s);let r=s.length;for(let t of i)s.push(t);if(t>0&&Xn(s,r-1),e<this.length){let t=s.length;this.decomposeRight(e,s),Xn(s,t)}return Kn.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?Kn.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 Xn(t,e){let i,n;null==t[e]&&(i=t[e-1])instanceof Un&&(n=t[e+1])instanceof Un&&t.splice(e-1,3,new Un(i.length+1+n.length))}class Yn{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 Jn?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new Jn(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 $n(r,n,i)):(r||s||n>=5)&&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 Jn(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new Un(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 Jn)return t;let e=new Jn(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!=je.WidgetAfter||this.isCovered||this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,i!=je.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 Jn||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new Jn(0,-1));let i=t;for(let t of this.nodes)t instanceof Jn&&t.updateHeight(this.oracle,i),i+=t?t.length:1;return this.nodes}static build(t,e,i,n){let s=new Yn(i,t);return Bt.spans(e,i,n,s,0),s.finish(i)}}class Qn{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,n){(t<e||i&&i.heightRelevant||n&&n.heightRelevant)&&Xe(t,e,this.changes,5)}}function Zn(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 e=t.parentNode;e&&e!=n.body;)if(1==e.nodeType){let i=e,n=window.getComputedStyle(i);if((i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)&&"visible"!=n.overflow){let n=i.getBoundingClientRect();r=Math.max(r,n.left),o=Math.min(o,n.right),h=Math.max(h,n.top),l=e==t.parentNode?n.bottom:Math.min(l,n.bottom)}e="absolute"==n.position||"fixed"==n.position?i.offsetParent:i.parentNode}else{if(11!=e.nodeType)break;e=e.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 ts(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class es{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 Ke.replace({widget:new is(this.size,t)}).range(this.from,this.to)}}class is extends qe{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 ns{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=ls,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Ti.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let e=t.facet(bi).some((t=>"function"!=typeof t&&"cm-lineWrapping"==t.class));this.heightOracle=new _n(e),this.stateDeco=t.facet(xi).filter((t=>"function"!=typeof t)),this.heightMap=Kn.empty().applyChanges(this.stateDeco,n.empty,this.heightOracle.setDoc(t.doc),[new Ci(0,0,0,t.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Ke.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 ss(e,i))}}this.viewports=t.sort(((t,e)=>t.from-e.from)),this.scaler=this.heightMap.height<=7e6?ls:new as(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:cs(t,this.scaler))}))}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(xi).filter((t=>"function"!=typeof t));let n=t.changedRanges,s=Ci.extendWithRanges(n,function(t,e,i){let n=new Qn;return Bt.compare(t,e,i,n,0),n.changes}(i,this.stateDeco,t?t.changes:C.empty(this.state.doc.length))),r=this.heightMap.height,o=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!=r&&(t.flags|=2),o?(this.scrollAnchorPos=t.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let h=s.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<h.from||e.range.head>h.to)||!this.viewportIsAppropriate(h))&&(h=this.getViewport(0,e));let l=!t.changes.empty||2&t.flags||h.from!=this.viewport.from||h.to!=this.viewport.to;this.viewport=h,this.updateForViewport(),l&&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(ci)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),s=this.heightOracle,r=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?Ti.RTL:Ti.LTR;let o=this.heightOracle.mustRefreshForWrapping(r),h=e.getBoundingClientRect(),l=o||this.mustMeasureContent||this.contentDOMHeight!=h.height;this.contentDOMHeight=h.height,this.mustMeasureContent=!1;let a=0,c=0,u=parseInt(i.paddingTop)||0,f=parseInt(i.paddingBottom)||0;this.paddingTop==u&&this.paddingBottom==f||(this.paddingTop=u,this.paddingBottom=f,a|=10),this.editorWidth!=t.scrollDOM.clientWidth&&(s.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 d=(this.printing?ts:Zn)(e,this.paddingTop),p=d.top-this.pixelViewport.top,g=d.bottom-this.pixelViewport.bottom;this.pixelViewport=d;let m=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(m!=this.inView&&(this.inView=m,m&&(l=!0)),!this.inView&&!this.scrollTarget)return 0;let w=h.width;if(this.contentDOMWidth==w&&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(s.mustRefreshForHeights(e)&&(o=!0),o||s.lineWrapping&&Math.abs(w-this.contentDOMWidth)>s.charWidth){let{lineHeight:i,charWidth:n,textHeight:h}=t.docView.measureTextSize();o=i>0&&s.refresh(r,i,n,h,w/n,e),o&&(t.docView.minWidth=0,a|=8)}p>0&&g>0?c=Math.max(p,g):p<0&&g<0&&(c=Math.min(p,g)),s.heightChanged=!1;for(let i of this.viewports){let r=i.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(i);this.heightMap=(o?Kn.empty().applyChanges(this.stateDeco,n.empty,this.heightOracle,[new Ci(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(s,0,o,new zn(i.from,r))}s.heightChanged&&(a|=2)}let v=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return v&&(this.viewport=this.getViewport(c,this.scrollTarget)),this.updateForViewport(),(2&a||v)&&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 ss(n.lineAt(r-1e3*i,qn.ByHeight,s,0,0).from,n.lineAt(o+1e3*(1-i),qn.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,qn.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 ss(n.lineAt(i-500,qn.ByHeight,s,0,0).from,n.lineAt(i+r+500,qn.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 ss(this.heightMap.lineAt(i,qn.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,qn.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,qn.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(e,qn.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 es(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,r=n<<1;if(this.defaultTextDirection!=Ti.LTR&&!i)return[];let o=[],h=(n,r,l,a)=>{if(r-n<s)return;let c=this.state.selection.main,u=[c.from];c.empty||u.push(c.to);for(let t of u)if(t>n&&t<r)return h(n,t-10,l,a),void h(t+10,r,l,a);let f=function(t,e){for(let i of t)if(e(i))return i;return}(t,(t=>t.from>=l.from&&t.to<=l.to&&Math.abs(t.from-n)<s&&Math.abs(t.to-r)<s&&!u.some((e=>t.from<e&&t.to>e))));if(!f){if(r<l.to&&e&&i&&e.visibleRanges.some((t=>t.from<=r&&t.to>=r))){let t=e.moveToLineBoundary(I.cursor(r),!1,!0).head;t>n&&(r=t)}f=new es(n,r,this.gapSize(l,n,r,a))}o.push(f)};for(let t of this.viewportLines){if(t.length<r)continue;let e=rs(t.from,t.to,this.stateDeco);if(e.total<r)continue;let s,o,l=this.scrollTarget?this.scrollTarget.range.head:null;if(i){let i,r,h=n/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=l){let n=hs(e,l),s=((this.visibleBottom-this.visibleTop)/2+h)/t.height;i=n-s,r=n+s}else i=(this.visibleTop-t.top-h)/t.height,r=(this.visibleBottom-t.top+h)/t.height;s=os(e,i),o=os(e,r)}else{let t,i,r=e.total*this.heightOracle.charWidth,h=n*this.heightOracle.charWidth;if(null!=l){let n=hs(e,l),s=((this.pixelViewport.right-this.pixelViewport.left)/2+h)/r;t=n-s,i=n+s}else t=(this.pixelViewport.left-h)/r,i=(this.pixelViewport.right+h)/r;s=os(e,t),o=os(e,i)}s>t.from&&h(t.from,s,t,e),o<t.to&&h(o,t.to,t,e)}return o}gapSize(t,e,i,n){let s=hs(n,i)-hs(n,e);return this.heightOracle.lineWrapping?t.height*s:n.total*this.heightOracle.charWidth*s}updateLineGaps(t){es.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=Ke.set(t.map((t=>t.draw(this.heightOracle.lineWrapping)))))}computeVisibleRanges(){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let e=[];Bt.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))||cs(this.heightMap.lineAt(t,qn.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return cs(this.heightMap.lineAt(this.scaler.fromDOM(t),qn.ByHeight,this.heightOracle,0,0),this.scaler)}elementAtHeight(t){return cs(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 ss{constructor(t,e){this.from=t,this.to=e}}function rs(t,e,i){let n=[],s=t,r=0;return Bt.spans(i,t,e,{span(){},point(t,e){t>s&&(n.push({from:s,to:t}),r+=t-s),s=e}},20),s<e&&(n.push({from:s,to:e}),r+=e-s),{total:r,ranges:n}}function os({total:t,ranges:e},i){if(i<=0)return e[0].from;if(i>=1)return e[e.length-1].to;let n=Math.floor(t*i);for(let t=0;;t++){let{from:i,to:s}=e[t],r=s-i;if(n<=r)return i+n;n-=r}}function hs(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}const ls={toDOM:t=>t,fromDOM:t=>t,scale:1};class as{constructor(t,e,i){let n=0,s=0,r=0;this.viewports=i.map((({from:i,to:s})=>{let r=e.lineAt(i,qn.ByPos,t,0,0).top,o=e.lineAt(s,qn.ByPos,t,0,0).bottom;return n+=o-r,{from:i,to:s,top:r,bottom:o,domTop:0,domBottom:0}})),this.scale=(7e6-n)/(e.height-n);for(let t of this.viewports)t.domTop=r+(t.top-s)*this.scale,r=t.domBottom=t.domTop+(t.bottom-t.top),s=t.bottom}toDOM(t){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 cs(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),n=e.toDOM(t.bottom);return new Fn(t.from,t.length,i,n-i,Array.isArray(t._content)?t._content.map((t=>cs(t,e))):t._content)}const us=V.define({combine:t=>t.join(" ")}),fs=V.define({combine:t=>t.indexOf(!0)>-1}),ds=qt.V.newName(),ps=qt.V.newName(),gs=qt.V.newName(),ms={"&light":"."+ps,"&dark":"."+gs};function ws(t,e,i){return new qt.V(e,{finish:e=>/&/.test(e)?e.replace(/&\w*/,(e=>{if("&"==e)return t;if(!i||!i[e])throw new RangeError(`Unsupported selector: ${e}`);return i[e]})):t+" "+e})}const vs=ws("."+ds,{"&":{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"}},ms);class ys{constructor(t,e,i,n){this.typeOver=n,this.bounds=null,this.text="";let{impreciseHead:s,impreciseAnchor:r}=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||r?[]:function(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:n,focusNode:s,focusOffset:r}=t.observer.selectionRange;i&&(e.push(new $i(i,n)),s==i&&r==n||e.push(new $i(s,r)));return e}(t),i=new ji(e,t.state);i.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=i.text,this.newSel=function(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?I.single(i+e,n+e):null}(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=s&&s.node==e.focusNode&&s.offset==e.focusOffset||!$t(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),n=r&&r.node==e.anchorNode&&r.offset==e.anchorOffset||!$t(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset);this.newSel=I.single(n,i)}}}function bs(t,e){let i,{newSel:s}=e,r=t.state.selection.main,o=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:s,to:h}=e.bounds,l=r.from,a=null;(8===o||Ce.android&&e.text.length<h-s)&&(l=r.to,a="end");let c=function(t,e,i,n){let s=Math.min(t.length,e.length),r=0;for(;r<s&&t.charCodeAt(r)==e.charCodeAt(r);)r++;if(r==s&&t.length==e.length)return null;let o=t.length,h=e.length;for(;o>0&&h>0&&t.charCodeAt(o-1)==e.charCodeAt(h-1);)o--,h--;if("end"==n){i-=o+Math.max(0,r-Math.min(o,h))-r}if(o<r&&t.length<e.length){r-=i<=r&&i>=o?r-i:0,h=r+(h-o),o=r}else if(h<r){r-=i<=r&&i>=h?r-i:0,o=r+(o-h),h=r}return{from:r,toA:o,toB:h}}(t.state.doc.sliceString(s,h,qi),e.text,l-s,a);c&&(Ce.chrome&&13==o&&c.toB==c.from+2&&e.text.slice(c.from,c.toB)==qi+qi&&c.toB--,i={from:s+c.from,to:s+c.toA,insert:n.of(e.text.slice(c.from,c.toB).split(qi))})}else s&&(!t.hasFocus&&t.state.facet(pi)||s.main.eq(r))&&(s=null);if(!i&&!s)return!1;if(!i&&e.typeOver&&!r.empty&&s&&s.main.empty?i={from:r.from,to:r.to,insert:t.state.doc.slice(r.from,r.to)}:i&&i.from>=r.from&&i.to<=r.to&&(i.from!=r.from||i.to!=r.to)&&r.to-r.from-(i.to-i.from)<=4?i={from:r.from,to:r.to,insert:t.state.doc.slice(r.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,r.to))}:(Ce.mac||Ce.android)&&i&&i.from==i.to&&i.from==r.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(s&&2==i.insert.length&&(s=I.single(s.main.anchor-1,s.main.head-1)),i={from:r.from,to:r.to,insert:n.of([" "])}):Ce.chrome&&i&&i.from==i.to&&i.from==r.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(s&&(s=I.single(s.main.anchor-1,s.main.head-1)),i={from:r.from,to:r.to,insert:n.of([" "])}),i){let e=t.state;if(Ce.ios&&t.inputState.flushIOSKey(t))return!0;if(Ce.android&&(i.from==r.from&&i.to==r.to&&1==i.insert.length&&2==i.insert.lines&&oe(t.contentDOM,"Enter",13)||(i.from==r.from-1&&i.to==r.to&&0==i.insert.length||8==o&&i.insert.length<i.to-i.from)&&oe(t.contentDOM,"Backspace",8)||i.from==r.from&&i.to==r.to+1&&0==i.insert.length&&oe(t.contentDOM,"Delete",46)))return!0;let n,h=i.insert.toString();if(t.state.facet(hi).some((e=>e(t,i.from,i.to,h))))return!0;if(t.inputState.composing>=0&&t.inputState.composing++,i.from>=r.from&&i.to<=r.to&&i.to-i.from>=(r.to-r.from)/3&&(!s||s.main.empty&&s.main.from==i.from+i.insert.length)&&t.inputState.composing<0){let s=r.from<i.from?e.sliceDoc(r.from,i.from):"",o=r.to>i.to?e.sliceDoc(i.to,r.to):"";n=e.replaceSelection(t.state.toText(s+i.insert.sliceString(0,void 0,t.state.lineBreak)+o))}else{let o=e.changes(i),h=s&&s.main.to<=o.newLength?s.main:void 0;if(e.selection.ranges.length>1&&t.inputState.composing>=0&&i.to<=r.to&&i.to>=r.to-10){let s=t.state.sliceDoc(i.from,i.to),l=Gi(t)||t.state.doc.lineAt(r.head),a=r.to-i.to,c=r.to-r.from;n=e.changeByRange((n=>{if(n.from==r.from&&n.to==r.to)return{changes:o,range:h||n.map(o)};let u=n.to-a,f=u-s.length;if(n.to-n.from!=c||t.state.sliceDoc(f,u)!=s||l&&n.to>=l.from&&n.from<=l.to)return{range:n};let d=e.changes({from:f,to:u,insert:i.insert}),p=n.to-r.to;return{changes:d,range:h?I.range(Math.max(0,h.anchor+p),Math.max(0,h.head+p)):n.map(d)}}))}else n={changes:o,selection:h&&e.selection.replaceRange(h)}}let l="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,l+=".compose",t.inputState.compositionFirstChange&&(l+=".start",t.inputState.compositionFirstChange=!1)),t.dispatch(n,{scrollIntoView:!0,userEvent:l}),!0}if(s&&!s.main.eq(r)){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:s,scrollIntoView:e,userEvent:i}),!0}return!1}const xs={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},ks=Ce.ie&&Ce.ie_version<=11;class Ss{constructor(t){this.view=t,this.active=!1,this.selectionRange=new ee,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);(Ce.ie&&Ce.ie_version<=11||Ce.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()})),ks&&(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(pi)?i.root.activeElement!=this.dom:!Jt(i.dom,n))return;let s=n.anchorNode&&i.docView.nearest(n.anchorNode);s&&s.ignoreEvent(t)?e||(this.selectionChanged=!1):(Ce.ie&&Ce.ie_version<=11||Ce.android&&Ce.chrome)&&!i.state.selection.main.empty&&n.focusNode&&Gt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=Ce.safari&&11==t.root.nodeType&&function(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}(this.dom.ownerDocument)==this.dom&&function(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);Gt(h.node,h.offset,r,o)&&([n,s,r,o]=[r,o,n,s]);return{anchorNode:n,anchorOffset:s,focusNode:r,focusOffset:o}}(this.view)||Kt(t.root);if(!e||this.selectionRange.eq(e))return!1;let i=Jt(this.dom,e);return i&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&function(t,e){let i=e.focusNode,n=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=n)return!1;for(n=Math.min(n,Qt(i));;)if(n){if(1!=i.nodeType)return!1;let t=i.childNodes[n-1];"false"==t.contentEditable?n--:(i=t,n=Qt(i))}else{if(i==t)return!0;n=Xt(i),i=i.parentNode}}(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,xs),ks&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),ks&&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&&oe(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&&Jt(this.dom,this.selectionRange);return t<0&&!n?null:(t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1,new ys(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=bs(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=As(e,t.previousSibling||t.target.previousSibling,-1),n=As(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 t of this.scrollTargets)t.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 As(t,e,i){for(;e;){let n=ce.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}class Ms{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||function(t){for(;t;){if(t&&(9==t.nodeType||11==t.nodeType&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}(t.parent)||document,this.viewState=new ns(t.state||Mt.create(t)),this.plugins=this.state.facet(mi).map((t=>new vi(t)));for(let t of this.plugins)t.update(this);this.observer=new Ss(this),this.inputState=new dn(this),this.inputState.ensureHandlers(this,this.plugins),this.docView=new Ji(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 pt?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 e of t){if(e.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=e.state}if(this.destroyed)return void(this.viewState.state=s);let r=this.hasFocus,o=0,h=null;t.some((t=>t.annotation(Ln)))?(this.inputState.notifiedFocused=r,o=1):r!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=r,h=Vn(s,r),h||(o=1));let l=this.observer.delayedAndroidKey,a=null;if(l?(this.observer.clearDelayedAndroidKey(),a=this.observer.readChange(),(a&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(a=null)):this.observer.clear(),s.facet(Mt.phrases)!=this.state.facet(Mt.phrases))return this.setState(s);e=Oi.create(this,s,t),e.flags|=o;let c=this.viewState.scrollTarget;try{this.updateState=2;for(let e of t){if(c&&(c=c.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection;c=new ui(t.empty?t:I.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(fi)&&(c=t.value)}this.viewState.update(e,c),this.bidiCache=Ts.update(this.bidiCache,e.changes),e.empty||(this.updatePlugins(e),this.inputState.update(e)),i=this.docView.update(e),this.state.facet(Mi)!=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(us)!=e.state.facet(us)&&(this.viewState.mustMeasureContent=!0),(i||n||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!e.empty)for(let t of this.state.facet(oi))t(e);(h||a)&&Promise.resolve().then((()=>{h&&this.state==h.startState&&this.dispatch(h),a&&!bs(this,a)&&l.force&&oe(this.contentDOM,l.key,l.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 ns(t),this.plugins=t.facet(mi).map((t=>new vi(t))),this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView=new Ji(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(mi),i=t.state.facet(mi);if(e!=i){let n=[];for(let s of i){let i=e.indexOf(s);if(i<0)n.push(new vi(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 e of this.plugins)e.mustUpdate=t;for(let t=0;t<this.plugins.length;t++)this.plugins[t].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 o=this.viewport,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(t){return di(this.state,t),Os}})),c=Oi.create(this,this.state,[]),u=!1,f=!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]!=Os)try{let e=l[t];e.write&&e.write(a[t],this)}catch(t){di(this.state,t)}if(this.viewState.editorHeight)if(this.viewState.scrollTarget)this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,f=!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,f=!0)}if(u&&this.docView.updateSelection(!0),this.viewport.from==o.from&&this.viewport.to==o.to&&!f&&0==this.measureRequests.length)break;r=-1}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let t of this.state.facet(oi))t(e)}get themeClasses(){return ds+" "+(this.state.facet(fs)?gs:ps)+" "+this.state.facet(us)}updateAttrs(){let t=Ds(this,yi,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(pi)?"true":"false",class:"cm-content",style:`${Ce.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),Ds(this,bi,e);let i=this.observer.ignore((()=>{let i=Fe(this.contentDOM,this.contentAttrs,e),n=Fe(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(Ms.announce)){e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(Mi),qt.V.mount(this.root,this.styleModules.concat(vs).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 fn(this,t,cn(this,t,e,i))}moveByGroup(t,e){return fn(this,t,cn(this,t,e,(e=>function(t,e,i){let n=t.state.charCategorizer(e),s=n(i);return t=>{let e=n(t);return s==xt.Space&&(s=e),s==e}}(this,t.head,e))))}moveToLineBoundary(t,e,i=!0){return function(t,e,i,n){let s=an(t,e.head),r=n&&s.type==je.Text&&(t.lineWrapping||s.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head):null;if(r){let e=t.dom.getBoundingClientRect(),n=t.textDirectionAt(s.from),o=t.posAtCoords({x:i==(n==Ti.LTR)?e.right-1:e.left+1,y:(r.top+r.bottom)/2});if(null!=o)return I.cursor(o,i?-1:1)}return I.cursor(i?s.to:s.from,i?-1:1)}(this,t,e,i)}moveVertically(t,e,i){return fn(this,t,function(t,e,i,n){let s=e.head,r=i?1:-1;if(s==(i?t.state.doc.length:0))return I.cursor(s,e.assoc);let o,h=e.goalColumn,l=t.contentDOM.getBoundingClientRect(),a=t.coordsAtPos(s),c=t.documentTop;if(a)null==h&&(h=a.left-l.left),o=r<0?a.top:a.bottom;else{let e=t.viewState.lineBlockAt(s);null==h&&(h=Math.min(l.right-l.left,t.defaultCharacterWidth*(s-e.from))),o=(r<0?e.top:e.bottom)+c}let u=l.left+h,f=null!=n?n:t.viewState.heightOracle.textHeight>>1;for(let i=0;;i+=10){let n=o+(f+i)*r,a=hn(t,{x:u,y:n},!1,r);if(n<l.top||n>l.bottom||(r<0?a<s:a>s))return I.cursor(a,e.assoc,void 0,h)}}(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(),hn(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 Zt(i,s[Vi.find(s,t-n.from,-1,e)].dir==Ti.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(ai)||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>Cs)return _i(t.length);let e=this.textDirectionAt(t.from);for(let i of this.bidiCache)if(i.from==t.from&&i.dir==e)return i.order;let i=Wi(t.text,e);return this.bidiCache.push(new Ts(t.from,t.to,e,i)),i}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||Ce.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{se(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 fi.of(new ui("number"==typeof t?I.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}static domEventHandlers(t){return wi.define((()=>({})),{eventHandlers:t})}static theme(t,e){let i=qt.V.newName(),n=[us.of(i),Mi.of(ws(`.${i}`,t))];return e&&e.dark&&n.push(fs.of(!0)),n}static baseTheme(t){return X.lowest(Mi.of(ws("."+ds,t,ms)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),n=i&&ce.get(i)||ce.get(t);return(null===(e=null==n?void 0:n.rootView)||void 0===e?void 0:e.view)||null}}Ms.styleModule=Mi,Ms.inputHandler=hi,Ms.focusChangeEffect=li,Ms.perLineTextDirection=ai,Ms.exceptionSink=ri,Ms.updateListener=oi,Ms.editable=pi,Ms.mouseSelectionStyle=si,Ms.dragMovesSelection=ni,Ms.clickAddsSelectionRange=ii,Ms.decorations=xi,Ms.atomicRanges=ki,Ms.scrollMargins=Si,Ms.darkTheme=fs,Ms.contentAttributes=bi,Ms.editorAttributes=yi,Ms.lineWrapping=Ms.contentAttributes.of({class:"cm-lineWrapping"}),Ms.announce=dt.define();const Cs=4096,Os={};class Ts{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:Ti.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 Ts(e.mapPos(r.from,1),e.mapPos(r.to,-1),r.dir,r.order))}return i}}function Ds(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&&_e(r,i)}return i}const Es=Ce.mac?"mac":Ce.windows?"win":Ce.linux?"linux":"key";function Bs(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 Rs=V.define({enables:X.default(Ms.domEventHandlers({keydown:(t,e)=>Vs(Is(e.state),t,e,"editor")}))}),Ps=new WeakMap;function Is(t){let e=t.facet(Rs),i=Ps.get(e);return i||Ps.set(e,i=function(t,e=Es){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=>function(t,e){const i=t.split(/-(?!$)/);let n,s,r,o,h=i[i.length-1];"Space"==h&&(h=" ");for(let t=0;t<i.length-1;++t){const h=i[t];if(/^(cmd|meta|m)$/i.test(h))o=!0;else if(/^a(lt)?$/i.test(h))n=!0;else if(/^(c|ctrl|control)$/i.test(h))s=!0;else if(/^s(hift)?$/i.test(h))r=!0;else{if(!/^mod$/i.test(h))throw new Error("Unrecognized modifier name: "+h);"mac"==e?o=!0:s=!0}}return n&&(h="Alt-"+h),s&&(h="Ctrl-"+h),o&&(h="Meta-"+h),r&&(h="Shift-"+h),h}(t,e)));for(let e=1;e<c.length;e++){let i=c.slice(0,e).join(" ");s(i,!0),a[i]||(a[i]={preventDefault:!0,run:[e=>{let n=Ns={view:e,prefix:i,scope:t};return setTimeout((()=>{Ns==n&&(Ns=null)}),Ls),!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 n of t){let t=n.scope?n.scope.split(" "):["editor"];if(n.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(n.any)}let s=n[e]||n.key;if(s)for(let e of t)r(e,s,n.run,n.preventDefault),n.shift&&r(e,"Shift-"+s,n.shift,n.preventDefault)}return i}(e.reduce(((t,e)=>t.concat(e)),[]))),i}let Ns=null;const Ls=4e3;function Vs(t,e,i,n){let s=(0,jt.YG)(e),r=k(x(s,0))==s.length&&" "!=s,o="",h=!1;Ns&&Ns.view==i&&Ns.scope==n&&(o=Ns.prefix+" ",(h=mn.indexOf(e.keyCode)<0)&&(Ns=null));let l,a,c=new Set,u=t=>{if(t){for(let n of t.run)if(!c.has(n)&&(c.add(n),n(i,e)))return!0;t.preventDefault&&(h=!0)}return!1},f=t[n];if(f){if(u(f[o+Bs(s,e,!r)]))return!0;if(r&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Ce.windows&&e.ctrlKey&&e.altKey)&&(l=jt.ue[e.keyCode])&&l!=s){if(u(f[o+Bs(l,e,!0)]))return!0;if(e.shiftKey&&(a=jt.uY[e.keyCode])!=s&&a!=l&&u(f[o+Bs(a,e,!1)]))return!0}else if(r&&e.shiftKey&&u(f[o+Bs(s,e,!0)]))return!0;if(u(f._any))return!0}return h}const Hs=!Ce.ios;const Ws={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};Hs&&(Ws[".cm-line"].caretColor="transparent !important");const _s=V.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 zs(t,e){let i=t.plugin(Fs),n=i?i.specs.indexOf(e):-1;return n>-1?i.panels[n]:null}const Fs=wi.fromClass(class{constructor(t){this.input=t.state.facet(Ks),this.specs=this.input.filter((t=>t)),this.panels=this.specs.map((e=>e(t)));let e=t.state.facet(_s);this.top=new qs(t,!0,e.topContainer),this.bottom=new qs(t,!1,e.bottomContainer),this.top.sync(this.panels.filter((t=>t.top))),this.bottom.sync(this.panels.filter((t=>!t.top)));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(t){let e=t.state.facet(_s);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new qs(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new qs(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let i=t.state.facet(Ks);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 e of this.panels)e.update&&e.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>Ms.scrollMargins.of((e=>{let i=e.plugin(t);return i&&{top:i.top.scrollMargin(),bottom:i.bottom.scrollMargin()}}))});class qs{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=js(t);t=t.nextSibling}else this.dom.insertBefore(e.dom,t);for(;t;)t=js(t)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(this.container&&this.classes!=this.view.themeClasses){for(let t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}}function js(t){let e=t.nextSibling;return t.remove(),e}const Ks=V.define({enables:Fs});class $s extends Ot{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}$s.prototype.elementClass="",$s.prototype.toDOM=void 0,$s.prototype.mapMode=A.TrackBefore,$s.prototype.startSide=$s.prototype.endSide=-1,$s.prototype.point=!0;function Js(){var t=arguments[0];"string"==typeof t&&(t=document.createElement(t));var e=1,i=arguments[1];if(i&&"object"==typeof i&&null==i.nodeType&&!Array.isArray(i)){for(var n in i)if(Object.prototype.hasOwnProperty.call(i,n)){var s=i[n];"string"==typeof s?t.setAttribute(n,s):null!=s&&(t[n]=s)}e++}for(;e<arguments.length;e++)Us(t,arguments[e]);return t}function Us(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++)Us(t,e[i])}}const Gs="function"==typeof String.prototype.normalize?t=>t.normalize("NFKD"):t=>t;class Xs{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(Gs(t)):Gs,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 x(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let i=(t=e)<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10),56320+(1023&t))),n=this.bufferStart+this.bufferPos;this.bufferPos+=k(e);let s=this.normalize(i);for(let t=0,e=n;;t++){let r=s.charCodeAt(t),o=this.match(r,e);if(t==s.length-1){if(o)return this.value=o,this;break}e==n&&t<i.length&&i.charCodeAt(t)==r&&e++}}var t}match(t,e){let i=null;for(let n=0;n<this.matches.length;n+=2){let s=this.matches[n],r=!1;this.query.charCodeAt(s)==t&&(s==this.query.length-1?i={from:this.matches[n+1],to:e+1}:(this.matches[n]++,r=!0)),r||(this.matches.splice(n,2),n-=2)}return this.query.charCodeAt(0)==t&&(1==this.query.length?i={from:e,to:e+1}:this.matches.push(1,e)),i&&this.test&&!this.test(i.from,i.to,this.buffer,this.bufferStart)&&(i=null),i}}"undefined"!=typeof Symbol&&(Xs.prototype[Symbol.iterator]=function(){return this});const Ys={from:-1,to:-1,match:/.*/.exec("")},Qs="gm"+(null==/x/.unicode?"":"u");class Zs{constructor(t,e,i,n=0,s=t.length){if(this.text=t,this.to=s,this.curLine="",this.done=!1,this.value=Ys,/\\[sWDnr]|\n|\r|\[\^/.test(e))return new ir(t,e,i,n,s);this.re=new RegExp(e,Qs+((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=nr(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=nr(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 tr=new WeakMap;class er{constructor(t,e){this.from=t,this.text=e}get to(){return this.from+this.text.length}static get(t,e,i){let n=tr.get(t);if(!n||n.from>=i||n.to<=e){let n=new er(e,t.sliceString(e,i));return tr.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)),tr.set(t,new er(r,s)),new er(e,s.slice(e-r,i-r))}}class ir{constructor(t,e,i,n,s){this.text=t,this.to=s,this.done=!1,this.value=Ys,this.matchPos=nr(t,n),this.re=new RegExp(e,Qs+((null==i?void 0:i.ignoreCase)?"i":"")),this.test=null==i?void 0:i.test,this.flat=er.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=nr(this.text,i+(t==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=er.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function nr(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 sr(t){let e=Js("input",{class:"cm-textfield",name:"line",value:String(t.state.doc.lineAt(t.state.selection.main.head).number)});function i(){let i=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(e.value);if(!i)return;let{state:n}=t,s=n.doc.lineAt(n.selection.main.head),[,r,o,h,l]=i,a=h?+h.slice(1):0,c=o?+o:s.number;if(o&&l){let t=c/100;r&&(t=t*("-"==r?-1:1)+s.number/n.doc.lines),c=Math.round(n.doc.lines*t)}else o&&r&&(c=c*("-"==r?-1:1)+s.number);let u=n.doc.line(Math.max(1,Math.min(n.doc.lines,c))),f=I.cursor(u.from+Math.max(0,Math.min(a,u.length)));t.dispatch({effects:[rr.of(!1),Ms.scrollIntoView(f.from,{y:"center"})],selection:f}),t.focus()}return{dom:Js("form",{class:"cm-gotoLine",onkeydown:e=>{27==e.keyCode?(e.preventDefault(),t.dispatch({effects:rr.of(!1)}),t.focus()):13==e.keyCode&&(e.preventDefault(),i())},onsubmit:t=>{t.preventDefault(),i()}},Js("label",t.state.phrase("Go to line"),": ",e)," ",Js("button",{class:"cm-button",type:"submit"},t.state.phrase("go")))}}"undefined"!=typeof Symbol&&(Zs.prototype[Symbol.iterator]=ir.prototype[Symbol.iterator]=function(){return this});const rr=dt.define(),or=j.define({create:()=>!0,update(t,e){for(let i of e.effects)i.is(rr)&&(t=i.value);return t},provide:t=>Ks.from(t,(t=>t?sr:null))}),hr=Ms.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),lr={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},ar=V.define({combine:t=>Ct(t,lr,{highlightWordAroundCursor:(t,e)=>t||e,minSelectionLength:Math.min,maxMatches:Math.min})});function cr(t){let e=[gr,pr];return t&&e.push(ar.of(t)),e}const ur=Ke.mark({class:"cm-selectionMatch"}),fr=Ke.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function dr(t,e,i,n){return!(0!=i&&t(e.sliceDoc(i-1,i))==xt.Word||n!=e.doc.length&&t(e.sliceDoc(n,n+1))==xt.Word)}const pr=wi.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(ar),{state:i}=t,n=i.selection;if(n.ranges.length>1)return Ke.none;let s,r=n.main,o=null;if(r.empty){if(!e.highlightWordAroundCursor)return Ke.none;let t=i.wordAt(r.head);if(!t)return Ke.none;o=i.charCategorizer(r.head),s=i.sliceDoc(t.from,t.to)}else{let t=r.to-r.from;if(t<e.minSelectionLength||t>200)return Ke.none;if(e.wholeWords){if(s=i.sliceDoc(r.from,r.to),o=i.charCategorizer(r.head),!dr(o,i,r.from,r.to)||!function(t,e,i,n){return t(e.sliceDoc(i,i+1))==xt.Word&&t(e.sliceDoc(n-1,n))==xt.Word}(o,i,r.from,r.to))return Ke.none}else if(s=i.sliceDoc(r.from,r.to).trim(),!s)return Ke.none}let h=[];for(let n of t.visibleRanges){let t=new Xs(i.doc,s,n.from,n.to);for(;!t.next().done;){let{from:n,to:s}=t.value;if((!o||dr(o,i,n,s))&&(r.empty&&n<=r.from&&s>=r.to?h.push(fr.range(n,s)):(n>=r.to||s<=r.from)&&h.push(ur.range(n,s)),h.length>e.maxMatches))return Ke.none}}return Ke.set(h)}},{decorations:t=>t.decorations}),gr=Ms.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}});const mr=V.define({combine:t=>Ct(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:t=>new Kr(t),scrollToMatch:t=>Ms.scrollIntoView(t)})});class wr{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||function(t){try{return new RegExp(t,Qs),!0}catch(t){return!1}}(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 Ar(this):new br(this)}getCursor(t,e=0,i){let n=t.doc?t:Mt.create({doc:t});return null==i&&(i=n.doc.length),this.regexp?xr(this,n,e,i):yr(this,n,e,i)}}class vr{constructor(t){this.spec=t}}function yr(t,e,i,n){return new Xs(e.doc,t.unquoted,i,n,t.caseSensitive?void 0:t=>t.toLowerCase(),t.wholeWord?function(t,e){return(i,n,s,r)=>((r>i||r+s.length<n)&&(r=Math.max(0,i-2),s=t.sliceString(r,Math.min(t.length,n+2))),!(e(kr(s,i-r))==xt.Word&&e(Sr(s,i-r))==xt.Word||e(Sr(s,n-r))==xt.Word&&e(kr(s,n-r))==xt.Word))}(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}class br extends vr{constructor(t){super(t)}nextMatch(t,e,i){let n=yr(this.spec,t,i,t.doc.length).nextOverlapping();return n.done&&(n=yr(this.spec,t,0,e).nextOverlapping()),n.done?null:n.value}prevMatchInRange(t,e,i){for(let n=i;;){let i=Math.max(e,n-1e4-this.spec.unquoted.length),s=yr(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){return this.prevMatchInRange(t,0,e)||this.prevMatchInRange(t,i,t.doc.length)}getReplacement(t){return this.spec.unquote(this.spec.replace)}matchAll(t,e){let i=yr(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=yr(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 xr(t,e,i,n){return new Zs(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:t.wholeWord?(s=e.charCategorizer(e.selection.main.head),(t,e,i)=>!i[0].length||(s(kr(i.input,i.index))!=xt.Word||s(Sr(i.input,i.index))!=xt.Word)&&(s(Sr(i.input,i.index+i[0].length))!=xt.Word||s(kr(i.input,i.index+i[0].length))!=xt.Word)):void 0},i,n);var s}function kr(t,e){return t.slice(m(t,e,!1),e)}function Sr(t,e){return t.slice(e,m(t,e))}class Ar extends vr{nextMatch(t,e,i){let n=xr(this.spec,t,i,t.doc.length).next();return n.done&&(n=xr(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=xr(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=xr(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=xr(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 Mr=dt.define(),Cr=dt.define(),Or=j.define({create:t=>new Tr(Wr(t).create(),null),update(t,e){for(let i of e.effects)i.is(Mr)?t=new Tr(i.value.create(),t.panel):i.is(Cr)&&(t=new Tr(t.query,i.value?Hr:null));return t},provide:t=>Ks.from(t,(t=>t.panel))});class Tr{constructor(t,e){this.query=t,this.panel=e}}const Dr=Ke.mark({class:"cm-searchMatch"}),Er=Ke.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Br=wi.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(Or))}update(t){let e=t.state.field(Or);(e!=t.startState.field(Or)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return Ke.none;let{view:i}=this,n=new Rt;for(let e=0,s=i.visibleRanges,r=s.length;e<r;e++){let{from:o,to:h}=s[e];for(;e<r-1&&h>s[e+1].from-500;)h=s[++e].to;t.highlight(i.state,o,h,((t,e)=>{let s=i.state.selection.ranges.some((i=>i.from==t&&i.to==e));n.add(t,e,s?Er:Dr)}))}return n.finish()}},{decorations:t=>t.decorations});function Rr(t){return e=>{let i=e.state.field(Or,!1);return i&&i.query.spec.valid?t(e,i):Fr(e)}}const Pr=Rr(((t,{query:e})=>{let{to:i}=t.state.selection.main,n=e.nextMatch(t.state,i,i);if(!n)return!1;let s=I.single(n.from,n.to),r=t.state.facet(mr);return t.dispatch({selection:s,effects:[Gr(t,n),r.scrollToMatch(s.main,t)],userEvent:"select.search"}),zr(t),!0})),Ir=Rr(((t,{query:e})=>{let{state:i}=t,{from:n}=i.selection.main,s=e.prevMatch(i,n,n);if(!s)return!1;let r=I.single(s.from,s.to),o=t.state.facet(mr);return t.dispatch({selection:r,effects:[Gr(t,s),o.scrollToMatch(r.main,t)],userEvent:"select.search"}),zr(t),!0})),Nr=Rr(((t,{query:e})=>{let i=e.matchAll(t.state,1e3);return!(!i||!i.length)&&(t.dispatch({selection:I.create(i.map((t=>I.range(t.from,t.to)))),userEvent:"select.search.matches"}),!0)})),Lr=Rr(((t,{query:e})=>{let{state:i}=t,{from:n,to:s}=i.selection.main;if(i.readOnly)return!1;let r=e.nextMatch(i,n,n);if(!r)return!1;let o,h,l=[],a=[];if(r.from==n&&r.to==s&&(h=i.toText(e.getReplacement(r)),l.push({from:r.from,to:r.to,insert:h}),r=e.nextMatch(i,r.from,r.to),a.push(Ms.announce.of(i.phrase("replaced match on line $",i.doc.lineAt(n).number)+"."))),r){let e=0==l.length||l[0].from>=r.to?0:r.to-r.from-h.length;o=I.single(r.from-e,r.to-e),a.push(Gr(t,r)),a.push(i.facet(mr).scrollToMatch(o.main,t))}return t.dispatch({changes:l,selection:o,effects:a,userEvent:"input.replace"}),!0})),Vr=Rr(((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:Ms.announce.of(n),userEvent:"input.replace.all"}),!0}));function Hr(t){return t.state.facet(mr).createPanel(t)}function Wr(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(mr);return new wr({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 _r(t){let e=zs(t,Hr);return e&&e.dom.querySelector("[main-field]")}function zr(t){let e=_r(t);e&&e==t.root.activeElement&&e.select()}const Fr=t=>{let e=t.state.field(Or,!1);if(e&&e.panel){let i=_r(t);if(i&&i!=t.root.activeElement){let n=Wr(t.state,e.query.spec);n.valid&&t.dispatch({effects:Mr.of(n)}),i.focus(),i.select()}}else t.dispatch({effects:[Cr.of(!0),e?Mr.of(Wr(t.state,e.query.spec)):dt.appendConfig.of(Yr)]});return!0},qr=t=>{let e=t.state.field(Or,!1);if(!e||!e.panel)return!1;let i=zs(t,Hr);return i&&i.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:Cr.of(!1)}),!0},jr=[{key:"Mod-f",run:Fr,scope:"editor search-panel"},{key:"F3",run:Pr,shift:Ir,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Pr,shift:Ir,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:qr,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:t,dispatch:e})=>{let i=t.selection;if(i.ranges.length>1||i.main.empty)return!1;let{from:n,to:s}=i.main,r=[],o=0;for(let e=new Xs(t.doc,t.sliceDoc(n,s));!e.next().done;){if(r.length>1e3)return!1;e.value.from==n&&(o=r.length),r.push(I.range(e.value.from,e.value.to))}return e(t.update({selection:I.create(r,o),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:t=>{let e=zs(t,sr);if(!e){let i=[rr.of(!0)];null==t.state.field(or,!1)&&i.push(dt.appendConfig.of([or,hr])),t.dispatch({effects:i}),e=zs(t,sr)}return e&&e.dom.querySelector("input").select(),!0}},{key:"Mod-d",run:({state:t,dispatch:e})=>{let{ranges:i}=t.selection;if(i.some((t=>t.from===t.to)))return(({state:t,dispatch:e})=>{let{selection:i}=t,n=I.create(i.ranges.map((e=>t.wordAt(e.head)||I.cursor(e.head))),i.mainIndex);return!n.eq(i)&&(e(t.update({selection:n})),!0)})({state:t,dispatch:e});let n=t.sliceDoc(i[0].from,i[0].to);if(t.selection.ranges.some((e=>t.sliceDoc(e.from,e.to)!=n)))return!1;let s=function(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 i=!1,s=new Xs(t.doc,e,n[n.length-1].to);;){if(s.next(),!s.done){if(i&&n.some((t=>t.from==s.value.from)))continue;if(r){let e=t.wordAt(s.value.from);if(!e||e.from!=s.value.from||e.to!=s.value.to)continue}return s.value}if(i)return null;s=new Xs(t.doc,e,0,Math.max(0,n[n.length-1].from-1)),i=!0}}(t,n);return!!s&&(e(t.update({selection:t.selection.addRange(I.range(s.from,s.to),!1),effects:Ms.scrollIntoView(s.to)})),!0)},preventDefault:!0}];class Kr{constructor(t){this.view=t;let e=this.query=t.state.field(Or).query.spec;function i(t,e,i){return Js("button",{class:"cm-button",name:t,onclick:e,type:"button"},i)}this.commit=this.commit.bind(this),this.searchField=Js("input",{value:e.search,placeholder:$r(t,"Find"),"aria-label":$r(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Js("input",{value:e.replace,placeholder:$r(t,"Replace"),"aria-label":$r(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Js("input",{type:"checkbox",name:"case",form:"",checked:e.caseSensitive,onchange:this.commit}),this.reField=Js("input",{type:"checkbox",name:"re",form:"",checked:e.regexp,onchange:this.commit}),this.wordField=Js("input",{type:"checkbox",name:"word",form:"",checked:e.wholeWord,onchange:this.commit}),this.dom=Js("div",{onkeydown:t=>this.keydown(t),class:"cm-search"},[this.searchField,i("next",(()=>Pr(t)),[$r(t,"next")]),i("prev",(()=>Ir(t)),[$r(t,"previous")]),i("select",(()=>Nr(t)),[$r(t,"all")]),Js("label",null,[this.caseField,$r(t,"match case")]),Js("label",null,[this.reField,$r(t,"regexp")]),Js("label",null,[this.wordField,$r(t,"by word")]),...t.state.readOnly?[]:[Js("br"),this.replaceField,i("replace",(()=>Lr(t)),[$r(t,"replace")]),i("replaceAll",(()=>Vr(t)),[$r(t,"replace all")])],Js("button",{name:"close",onclick:()=>qr(t),"aria-label":$r(t,"close"),type:"button"},["×"])])}commit(){let t=new wr({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:Mr.of(t)}))}keydown(t){var e,i,n;e=this.view,i=t,n="search-panel",Vs(Is(e.state),i,e,n)?t.preventDefault():13==t.keyCode&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?Ir:Pr)(this.view)):13==t.keyCode&&t.target==this.replaceField&&(t.preventDefault(),Lr(this.view))}update(t){for(let e of t.transactions)for(let t of e.effects)t.is(Mr)&&!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(mr).top}}function $r(t,e){return t.state.phrase(e)}const Jr=30,Ur=/[\s\.,:;?!]/;function Gr(t,{from:e,to:i}){let n=t.state.doc.lineAt(e),s=t.state.doc.lineAt(i).to,r=Math.max(n.from,e-Jr),o=Math.min(s,i+Jr),h=t.state.sliceDoc(r,o);if(r!=n.from)for(let t=0;t<Jr;t++)if(!Ur.test(h[t+1])&&Ur.test(h[t])){h=h.slice(t);break}if(o!=s)for(let t=h.length-1;t>h.length-Jr;t--)if(!Ur.test(h[t-1])&&Ur.test(h[t])){h=h.slice(0,t);break}return Ms.announce.of(`${t.state.phrase("current match")}. ${h} ${t.state.phrase("on line")} ${n.number}.`)}const Xr=Ms.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"}}),Yr=[Or,X.low(Br),Xr]},74075:(t,e,i)=>{i.d(e,{BO:()=>Tt,D0:()=>St,F6:()=>tt,Gz:()=>$t,IS:()=>Kt,Py:()=>gt,QQ:()=>$,Wl:()=>Q,Xs:()=>Pt,YW:()=>mt,as:()=>T,bg:()=>S,cp:()=>w,f_:()=>It,gc:()=>C,gm:()=>k,jT:()=>L,n0:()=>O,nZ:()=>A,q6:()=>ft,r$:()=>W,uU:()=>Dt,xv:()=>n,yy:()=>Ot});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 t=e,r=e;;){if(n.next(t),s.next(t),t=0,n.lineBreak!=s.lineBreak||n.done!=s.done||n.value!=s.value)return!1;if(r+=n.value.length,n.done||r>=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 e of t)this.lines+=e.lines}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.children[s],o=n+r.length,h=i+r.lines-1;if((e?h:o)>=t)return r.lineInner(t,e,i,n);n=o+1,i=h+1}}decompose(t,e,i,n){for(let s=0,r=0;r<=e&&s<this.children.length;s++){let o=this.children[s],h=r+o.length;if(t<=h&&e>=r){let s=n&((r<=t?1:0)|(h>=e?2:0));r>=t&&h<=e&&!s?i.push(o):o.decompose(t-r,e-r,i,s)}r=h+1}}replace(t,e,i){if([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 e of t)i+=e.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 e of t.children)f(e);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 e of t)f(e);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 p(t){for(let e=1;e<d.length;e+=2)if(d[e]>t)return d[e-1]<=t;return!1}function g(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=k(t,e);for(e+=A(n);e<t.length;){let s=k(t,e);if(n==m||s==m||i&&p(s))e+=A(s),n=s;else{if(!g(s))break;{let i=0,n=e-2;for(;n>=0&&g(k(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 k(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 S(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10),56320+(1023&t)))}function A(t){return t<65536?1:2}const M=/\r\n?|\n/;var C=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(C||(C={}));class O{constructor(t){this.sections=t}get length(){let t=0;for(let e=0;e<this.sections.length;e+=2)t+=this.sections[e];return t}get newLength(){let t=0;for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e+1];t+=i<0?this.sections[e]:i}return t}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(t){for(let e=0,i=0,n=0;e<this.sections.length;){let s=this.sections[e++],r=this.sections[e++];r<0?(t(i,n,s),n+=s):n+=r,i+=s}}iterChangedRanges(t,e=!1){B(this,t,e)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];n<0?t.push(i,n):t.push(n,i)}return new O(t)}composeDesc(t){return this.empty?t:t.empty?this:P(this,t)}mapDesc(t,e=!1){return t.empty?this:R(this,t,e)}mapPos(t,e=-1,i=C.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!=C.Simple&&l>=t&&(i==C.TrackDel&&n<t&&l>t||i==C.TrackBefore&&n<t||i==C.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 O(t)}static create(t){return new O(t)}}class T extends O{constructor(t,e){super(t),this.inserted=e}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return B(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 T(e,i)}compose(t){return this.empty?t:t.empty?this:P(this,t,!0)}map(t,e=!1){return t.empty?this:R(this,t,e,!0)}iterChanges(t,e=!1){B(this,t,e)}get desc(){return O.create(this.sections)}filter(t){let e=[],i=[],n=[],s=new I(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);D(n,t,-1);let r=-1==s.ins?-1:0==s.off?s.ins:0;D(e,t,r),r>0&&E(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);D(e,t,-1),D(n,t,-1==s.ins?-1:0==s.off?s.ins:0),s.forward(t),o+=t}}return{changes:new T(e,i),filtered:O.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&&D(s,e-o,-1);let i=new T(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 T){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||M)):c:n.empty,f=u.length;if(t==h&&0==f)return;t<o&&l(),t>o&&D(s,t-o,-1),D(s,h-t,f),E(r,s,u),o=h}}(t),l(!h),h}static empty(t){return new T(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 T(e,i)}static createSet(t,e){return new T(t,e)}}function D(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 E(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 B(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 I(t),h=new I(e);for(let t=-1;;)if(-1==o.ins&&-1==h.ins){let t=Math.min(o.len,h.len);D(s,t,-1),o.forward(t),h.forward(t)}else if(h.ins>=0&&(o.ins<0||t==o.i||0==o.off&&(h.len<o.len||h.len==o.len&&!i))){let e=h.len;for(D(s,h.ins,-1);e;){let i=Math.min(o.len,e);o.ins>=0&&t<o.i&&o.len<=i&&(D(s,0,o.ins),r&&E(r,s,o.text),t=o.i),o.forward(i),e-=i}h.next()}else{if(!(o.ins>=0)){if(o.done&&h.done)return r?T.createSet(s,r):O.create(s);throw new Error("Mismatched change set lengths")}{let e=0,i=o.len;for(;i;)if(-1==h.ins){let t=Math.min(i,h.len);e+=t,i-=t,h.forward(t)}else{if(!(0==h.ins&&h.len<i))break;i-=h.len,h.next()}D(s,e,t<o.i?o.ins:0),r&&t<o.i&&E(r,s,o.text),t=o.i,o.forward(o.len-i)}}}function P(t,e,i=!1){let n=[],s=i?[]:null,r=new I(t),o=new I(e);for(let t=!1;;){if(r.done&&o.done)return s?T.createSet(n,s):O.create(n);if(0==r.ins)D(n,r.len,0,t),r.next();else if(0!=o.len||o.done){if(r.done||o.done)throw new Error("Mismatched change set lengths");{let e=Math.min(r.len2,o.len),i=n.length;if(-1==r.ins){let i=-1==o.ins?-1:o.off?0:o.ins;D(n,e,i,t),s&&i&&E(s,n,o.text)}else-1==o.ins?(D(n,r.off?0:r.len,e,t),s&&E(s,n,r.textBit(e))):(D(n,r.off?0:r.len,o.off?0:o.ins,t),s&&!o.off&&E(s,n,o.text));t=(r.ins>e||o.ins>=0&&o.len>e)&&(t||n.length>i),r.forward2(e),o.forward(e)}}else D(n,0,o.ins,t),s&&E(s,n,o.text),o.next()}}class I{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 N{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 N(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,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 L.range(t.anchor,t.head)}static create(t,e,i){return new N(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,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 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=>N.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 N.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?N.create(e,t,48|s):N.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 i=1;i<t.length;i++){let n=t[i],s=t[i-1];if(n.empty?n.from<=s.to:n.from<s.to){let r=s.from,o=Math.max(n.to,s.to);i<=e&&e--,t.splice(--i,2,n.anchor>n.head?L.range(o,r):L.range(r,o))}}return new L(t,e)}}function V(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let H=0;class W{constructor(t,e,i,n,s){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=H++,this.default=t([]),this.extensions="function"==typeof s?s(this):s}get reader(){return this}static define(t={}){return new W(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:_),!!t.static,t.enables)}of(t){return new z([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new z(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new z(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],(i=>e(i.field(t))))}}function _(t,e){return t==e||t.length==e.length&&t.every(((t,i)=>t===e[i]))}class z{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=H++}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 i of this.dependencies)"doc"==i?h=!0:"selection"==i?l=!0:0==(1&(null!==(e=t[i.id])&&void 0!==e?e:1))&&a.push(t[i.id]);return{create:t=>(t.values[r]=i(t),1),update(t,e){if(h&&e.docChanged||l&&(e.docChanged||e.selection)||q(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=st(e,l);if(this.dependencies.every((i=>i instanceof W?e.facet(i)===t.facet(i):!(i instanceof $)||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 q(t,e){let i=!1;for(let n of e)1&nt(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=st(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)nt(t,e);return t.values[o]=h(t),1},update(t,i){if(!q(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=q(t,n),l=s.config.facets[e.id],a=s.facet(e);if(l&&!r&&_(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 K=W.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 $(H++,t.create,t.update,t.compare||((t,e)=>t===e),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet(K).find((t=>t.field==this));return((null==e?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{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,K.of({field:this,create:t})]}get extension(){return this}}const J=4,U=3,G=2,X=1;function Y(t){return e=>new Z(e,t)}const Q={highest:Y(0),high:Y(X),default:Y(G),low:Y(U),lowest:Y(J)};class Z{constructor(t,e){this.inner=t,this.prec=e}}class tt{of(t){return new et(this,t)}reconfigure(t){return tt.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class et{constructor(t,e){this.compartment=t,this.inner=e}}class it{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 i of function(t,e,i){let n=[[],[],[],[],[]],s=new Map;function r(t,o){let h=s.get(t);if(null!=h){if(h<=o)return;let e=n[h].indexOf(t);e>-1&&n[h].splice(e,1),t instanceof et&&i.delete(t.compartment)}if(s.set(t,o),Array.isArray(t))for(let e of t)r(e,o);else if(t instanceof et){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 Z)r(t.inner,t.prec);else if(t instanceof $)n[o].push(t),t.provides&&r(t.provides,o);else if(t instanceof z)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))i instanceof $?n.push(i):(s[i.facet.id]||(s[i.facet.id]=[])).push(i);let o=Object.create(null),h=[],l=[];for(let t of n)o[t.id]=l.length<<1,l.push((e=>t.slot(e)));let a=null==i?void 0:i.config.facets;for(let t in s){let e=s[t],n=e[0].facet,r=a&&a[t]||[];if(e.every((t=>0==t.type)))if(o[n.id]=h.length<<1|1,_(r,e))h.push(i.facet(n));else{let t=n.combine(e.map((t=>t.value)));h.push(i&&n.compare(t,i.facet(n))?i.facet(n):t)}else{for(let t of e)0==t.type?(o[t.id]=h.length<<1|1,h.push(t.value)):(o[t.id]=l.length<<1,l.push((e=>t.dynamicSlot(e))));o[n.id]=l.length<<1,l.push((t=>j(t,n,e)))}}let c=l.map((t=>t(o)));return new it(t,r,c,o,h,s)}}function nt(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 st(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const rt=W.define(),ot=W.define({combine:t=>t.some((t=>t)),static:!0}),ht=W.define({combine:t=>t.length?t[0]:void 0,static:!0}),lt=W.define(),at=W.define(),ct=W.define(),ut=W.define({combine:t=>!!t.length&&t[0]});class ft{constructor(t,e){this.type=t,this.value=e}static define(){return new dt}}class dt{of(t){return new ft(this,t)}}class pt{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 pt(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 mt{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&&V(i,e.newLength),s.some((t=>t.type==mt.time))||(this.annotations=s.concat(mt.time.of(Date.now())))}static create(t,e,i,n,s,r){return new mt(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(mt.userEvent);return!(!e||!(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function wt(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 vt(t,e,i){var n;let s,r,o;return i?(s=e.changes,r=T.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 yt(t,e,i){let n=e.selection,s=kt(e.annotations);return e.userEvent&&(s=s.concat(mt.userEvent.of(e.userEvent))),{changes:e.changes instanceof T?e.changes:T.of(e.changes||[],i,t.facet(ht)),selection:n&&(n instanceof L?n:L.single(n.anchor,n.head)),effects:kt(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function bt(t,e,i){let n=yt(t,e.length?e[0]:{},t.doc.length);e.length&&!1===e[0].filter&&(i=!1);for(let s=1;s<e.length;s++){!1===e[s].filter&&(i=!1);let r=!!e[s].sequential;n=vt(n,yt(t,e[s],r?n.changes.newLength:t.doc.length),r)}let s=mt.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return function(t){let e=t.startState,i=e.facet(ct),n=t;for(let s=i.length-1;s>=0;s--){let r=i[s](t);r&&Object.keys(r).length&&(n=vt(n,yt(e,r,t.changes.newLength),!0))}return n==t?t:mt.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}(i?function(t){let e=t.startState,i=!0;for(let n of e.facet(lt)){let e=n(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:wt(i,e))}if(!0!==i){let n,s;if(!1===i)s=t.changes.invertedDesc,n=T.empty(e.doc.length);else{let e=t.changes.filter(i);n=e.changes,s=e.filtered.mapDesc(e.changes).invertedDesc}t=mt.create(e,n,t.selection&&t.selection.map(s),gt.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let n=e.facet(at);for(let i=n.length-1;i>=0;i--){let s=n[i](t);t=s instanceof mt?s:Array.isArray(s)&&1==s.length&&s[0]instanceof mt?s[0]:bt(e,kt(s),!1)}return t}(s):s)}mt.time=ft.define(),mt.userEvent=ft.define(),mt.addToHistory=ft.define(),mt.remote=ft.define();const xt=[];function kt(t){return null==t?xt: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 At=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Mt;try{Mt=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(t){}function Ct(t){return e=>{if(!/\S/.test(e))return St.Space;if(function(t){if(Mt)return Mt.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 St.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return St.Word;return St.Other}}class Ot{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 t=0;t<this.config.dynamicSlots.length;t++)nt(this,t<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(null!=i)return nt(this,i),st(this,i);if(e)throw new RangeError("Field is not present in this state")}update(...t){return bt(this,t,!0)}applyTransaction(t){let e,i=this.config,{base:n,compartments:s}=i;for(let e of t.effects)e.is(tt.reconfigure)?(i&&(s=new Map,i.compartments.forEach(((t,e)=>s.set(e,t))),i=null),s.set(e.value.compartment,e.value.extension)):e.is(gt.reconfigure)?(i=null,n=e.value):e.is(gt.appendConfig)&&(i=null,n=kt(n).concat(e.value));if(i)e=t.startState.values.slice();else{i=it.resolve(n,s,this),e=new Ot(i,this.doc,this.selection,i.dynamicSlots.map((()=>null)),((t,e)=>e.reconfigure(t,this)),null).values}let r=t.startState.facet(ot)?t.newSelection:t.newSelection.asSingle();new Ot(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: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=kt(i.effects);for(let i=1;i<e.ranges.length;i++){let o=t(e.ranges[i]),h=this.changes(o.changes),l=h.map(n);for(let t=0;t<i;t++)s[t]=s[t].map(l);let a=n.mapDesc(h,!0);s.push(o.range.map(a)),n=n.compose(l),r=gt.mapEffects(r,l).concat(gt.mapEffects(kt(o.effects),a))}return{changes:n,selection:L.create(s,e.mainIndex),effects:r}}changes(t=[]){return t instanceof T?t:T.of(t,this.doc.length,this.facet(Ot.lineSeparator))}toText(t){return n.of(t.split(this.facet(Ot.lineSeparator)||M))}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:(nt(this,e),st(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 e in i)if(Object.prototype.hasOwnProperty.call(t,e)){let s=i[e],r=t[e];n.push(s.init((t=>s.spec.fromJSON(r,t))))}return Ot.create({doc:t.doc,selection:L.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let e=it.resolve(t.extensions||[],new Map),i=t.doc instanceof n?t.doc:n.of((t.doc||"").split(e.staticFacet(Ot.lineSeparator)||M)),s=t.selection?t.selection instanceof L?t.selection:L.single(t.selection.anchor,t.selection.head):L.single(0);return V(s,i.length),e.staticFacet(ot)||(s=s.asSingle()),new Ot(e,i,s,e.dynamicSlots.map((()=>null)),((t,e)=>e.create(t)),null)}get tabSize(){return this.facet(Ot.tabSize)}get lineBreak(){return this.facet(Ot.lineSeparator)||"\n"}get readOnly(){return this.facet(ut)}phrase(t,...e){for(let e of this.facet(Ot.phrases))if(Object.prototype.hasOwnProperty.call(e,t)){t=e[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(rt))for(let r of s(this,e,i))Object.prototype.hasOwnProperty.call(r,t)&&n.push(r[t]);return n}charCategorizer(t){return Ct(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:L.range(r+i,o+i)}}function Tt(t,e,i={}){let n={};for(let e of t)for(let t of Object.keys(e)){let s=e[t],r=n[t];if(void 0===r)n[t]=s;else if(r===s||void 0===s);else{if(!Object.hasOwnProperty.call(i,t))throw new Error("Config merge conflict for field "+t);n[t]=i[t](r,s)}}for(let t in e)void 0===n[t]&&(n[t]=e[t]);return n}Ot.allowMultipleSelections=ot,Ot.tabSize=W.define({combine:t=>t.length?t[0]:4}),Ot.lineSeparator=ht,Ot.readOnly=ut,Ot.phrases=W.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]))}}),Ot.languageData=rt,Ot.changeFilter=lt,Ot.transactionFilter=at,Ot.transactionExtender=ct,tt.reconfigure=gt.define();class Dt{eq(t){return this==t}range(t,e=t){return Et.create(t,e,this)}}Dt.prototype.startSide=Dt.prototype.endSide=0,Dt.prototype.point=!1,Dt.prototype.mapMode=C.TrackDel;class Et{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new Et(t,e,i)}}function Bt(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 Pt{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 Pt(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(Bt)),this.isEmpty)return e.length?Pt.of(e):this;let o=new Lt(this,null,-1).goto(0),h=0,l=[],a=new It;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(Et.create(o.from,o.to,o.value))),o.next());return a.finishInner(this.nextLayer.isEmpty&&!l.length?Pt.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 s=0;s<this.chunk.length;s++){let r=this.chunkPos[s],o=this.chunk[s],h=t.touchesRange(r,r+o.length);if(!1===h)n=Math.max(n,o.maxPoint),e.push(o),i.push(t.mapPos(r));else if(!0===h){let{mapped:s,pos:h}=o.map(r,t);s&&(n=Math.max(n,s.maxPoint),e.push(s),i.push(h))}}let s=this.nextLayer.map(t);return 0==e.length?s:new Pt(i,e,s||Pt.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 Vt.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return Vt.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=Nt(r,o,i),l=new Wt(r,h,s),a=new Wt(o,h,s);i.iterGaps(((t,e,i)=>_t(l,t,a,e,i,n))),i.empty&&0==i.length&&_t(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=Nt(s,r),h=new Wt(s,o,0).goto(i),l=new Wt(r,o,0).goto(i);for(;;){if(h.to!=l.to||!zt(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 Wt(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 It;for(let n of t instanceof Et?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let n=t[i];if(Bt(e,n)>0)return t.slice().sort(Bt);e=n}return t}(t):t)i.add(n.from,n.to,n.value);return i.finish()}static join(t){if(!t.length)return Pt.empty;let e=t[t.length-1];for(let i=t.length-2;i>=0;i--)for(let n=t[i];n!=Pt.empty;n=n.nextLayer)e=new Pt(n.chunkPos,n.chunk,e,Math.max(n.maxPoint,e.maxPoint));return e}}Pt.empty=new Pt([],[],null,-1),Pt.empty.nextLayer=Pt.empty;class It{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 It)).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(Pt.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=Pt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function Nt(t,e,i){let n=new Map;for(let e of t)for(let t=0;t<e.chunk.length;t++)e.chunk[t].maxPoint<=0&&n.set(e.chunk[t],e.chunkPos[t]);let s=new Set;for(let t of e)for(let e=0;e<t.chunk.length;e++){let r=n.get(t.chunk[e]);null==r||(i?i.mapPos(r):r)!=t.chunkPos[e]||(null==i?void 0:i.touchesRange(r,r+t.chunk[e].length))||s.add(t.chunk[e])}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 Vt{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 Vt(n)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(let i of this.heap)i.goto(t,e);for(let t=this.heap.length>>1;t>=0;t--)Ht(this.heap,t);return this.next(),this}forward(t,e){for(let i of this.heap)i.forward(t,e);for(let t=this.heap.length>>1;t>=0;t--)Ht(this.heap,t);(this.to-t||this.value.endSide-e)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),Ht(this.heap,0)}}}function Ht(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 Wt{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=Vt.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=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++;qt(this.active,e,i),qt(this.activeTo,e,n),qt(this.activeRank,e,s),t&&qt(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&&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 _t(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))&&zt(t.activeForPoint(t.to),i.activeForPoint(i.to))||r.comparePoint(h,s,t.point,i.point):s>h&&!zt(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 zt(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 qt(t,e,i){for(let i=t.length-1;i>=e;i--)t[i+1]=t[i];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 Kt(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 n=0,s=0;;){if(s>=e)return n;if(n==t.length)break;s+=9==t.charCodeAt(n)?i-s%i:1,n=w(t,n)}return!0===n?-1:t.length}},58626:(t,e,i)=>{i.d(e,{p:()=>ut,Nm:()=>bt,tk:()=>Qi,lg:()=>ee,l9:()=>at,S2:()=>Vn,Uw:()=>xn,gB:()=>Jn,ZO:()=>Tn,$f:()=>hn,Eu:()=>cs,OO:()=>Yt,Zs:()=>In,hJ:()=>$n});var n=i(74075);const s="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),r="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class h{constructor(t,e){this.rules=[];let{finish:i}=e||{};function n(t){return/^@/.test(t)?[t]:t.split(/,\s*/)}function s(t,e,r,o){let h=[],l=/^@(\w+)\b/.exec(t[0]),a=l&&"keyframes"==l[1];if(l&&null==e)return r.push(t[0]+";");for(let i in e){let o=e[i];if(/&/.test(i))s(i.split(/,\s*/).map((e=>t.map((t=>e.replace(/&/,t))))).reduce(((t,e)=>t.concat(e))),o,r);else if(o&&"object"==typeof o){if(!l)throw new RangeError("The value of a property ("+i+") should be a primitive value.");s(n(i),o,h,a)}else null!=o&&h.push(i.replace(/_.*/,"").replace(/[A-Z]/g,(t=>"-"+t.toLowerCase()))+": "+o+";")}(h.length||a)&&r.push((!i||l||o?t:t.map(i)).join(", ")+" {"+h.join(" ")+"}")}for(let e in t)s(n(e),t[e],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let t=o[s]||1;return o[s]=t+1,"ͼ"+t.toString(36)}static mount(t,e,i){let n=t[r],s=i&&i.nonce;n?s&&n.setNonce(s):n=new a(t,s),n.mount(Array.isArray(e)?e:[e])}}let l=new Map;class a{constructor(t,e){let i=t.ownerDocument||t,n=i.defaultView;if(!t.head&&t.adoptedStyleSheets&&n.CSSStyleSheet){let e=l.get(i);if(e)return t.adoptedStyleSheets=[e.sheet,...t.adoptedStyleSheets],t[r]=e;this.sheet=new n.CSSStyleSheet,t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets],l.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[r]=this}mount(t){let e=this.sheet,i=0,n=0;for(let s=0;s<t.length;s++){let r=t[s],o=this.modules.indexOf(r);if(o<n&&o>-1&&(this.modules.splice(o,1),n--,o=-1),-1==o){if(this.modules.splice(n++,0,r),e)for(let t=0;t<r.rules.length;t++)e.insertRule(r.rules[t],i++)}else{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)}}var c=i(29350);function u(t){let e;return e=11==t.nodeType?t.getSelection?t:t.ownerDocument:t,e.getSelection()}function f(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function d(t,e){if(!e.anchorNode)return!1;try{return f(t,e.anchorNode)}catch(t){return!1}}function p(t){return 3==t.nodeType?C(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function g(t,e,i,n){return!!i&&(w(t,e,i,n,-1)||w(t,e,i,n,1))}function m(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function w(t,e,i,n,s){for(;;){if(t==i&&e==n)return!0;if(e==(s<0?0:v(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=m(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?v(t):0}}}function v(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function y(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function b(t){return{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function x(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}}class k{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?v(e):0),i,Math.min(t.focusOffset,i?v(i):0))}set(t,e,i,n){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=n}}let S,A=null;function M(t){if(t.setActive)return t.setActive();if(A)return t.focus(A);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==A?{get preventScroll(){return A={preventScroll:!0},!0}}:void 0),!A){A=!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 C(t,e,i=e){let n=S||(S=document.createRange());return n.setEnd(t,i),n.setStart(t,e),n}function O(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 T(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}function D(t){return t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}class E{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new E(t.parentNode,m(t),e)}static after(t,e){return new E(t.parentNode,m(t)+1,e)}}const B=[];class R{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=R.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=P(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=P(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==v(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&&!R.get(i);)i=i.nextSibling;if(!i)return this.length;for(let t=0,e=0;;t++){let n=this.children[t];if(n.dom==i)return e;e+=n.length+n.breakAfter}}domBoundsAround(t,e,i=0){let n=-1,s=-1,r=-1,o=-1;for(let h=0,l=i,a=i;h<this.children.length;h++){let i=this.children[h],c=l+i.length;if(l<t&&c>e)return i.domBoundsAround(t,e,l);if(c>=t&&-1==n&&(n=h,s=l),l>e&&i.dom.parentNode==this.dom){r=h,o=a;break}a=c,l=c+i.breakAfter}return{from:s,to:o<0?i+this.length:o,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:r<this.children.length&&r>=0?this.children[r].dom:null}}markDirty(t=!1){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=B){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 t=0;t<i.length;t++)i[t].setParent(this)}ignoreMutation(t){return!1}ignoreEvent(t){return!1}childCursor(t=this.length){return new I(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 P(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}R.prototype.breakAfter=0;class I{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 N(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 L(t,e,i,n,s,r){let o=t.childCursor(),{i:h,off:l}=o.findPos(i,1),{i:a,off:c}=o.findPos(e,-1),u=e-i;for(let t of n)u+=t.length;t.length+=u,N(t,a,c,h,l,n,0,s,r)}let V="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},H="undefined"!=typeof document?document:{documentElement:{style:{}}};const W=/Edge\/(\d+)/.exec(V.userAgent),_=/MSIE \d/.test(V.userAgent),z=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(V.userAgent),F=!!(_||z||W),q=!F&&/gecko\/(\d+)/i.test(V.userAgent),j=!F&&/Chrome\/(\d+)/.exec(V.userAgent),K="webkitFontSmoothing"in H.documentElement.style,$=!F&&/Apple Computer/.test(V.vendor),J=$&&(/Mobile\/\w+/.test(V.userAgent)||V.maxTouchPoints>2);var U={mac:J||/Mac/.test(V.platform),windows:/Win/.test(V.platform),linux:/Linux|X11/.test(V.platform),ie:F,ie_version:_?H.documentMode||6:z?+z[1]:W?+W[1]:0,gecko:q,gecko_version:q?+(/Firefox\/(\d+)/.exec(V.userAgent)||[0,0])[1]:0,chrome:!!j,chrome_version:j?+j[1]:0,ios:J,android:/Android\b/.test(V.userAgent),webkit:K,safari:$,webkit_version:K?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:null!=H.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class G extends R{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 G)||this.length-(e-t)+i.length>256||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 G(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 E(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 function(t,e,i){let n=t.nodeValue.length;e>n&&(e=n);let s=e,r=e,o=0;0==e&&i<0||e==n&&i>=0?U.chrome||U.gecko||(e?(s--,o=1):r<n&&(r++,o=-1)):i<0?s--:r<n&&r++;let h=C(t,s,r).getClientRects();if(!h.length)return null;let l=h[(o?o<0:i>=0)?0:h.length-1];U.safari&&!o&&0==l.width&&(l=Array.prototype.find.call(h,(t=>t.width))||l);return o?y(l,o<0):l||null}(this.dom,t,e)}}class X extends R{constructor(t,e=[],i=0){super(),this.mark=t,this.children=e,this.length=i;for(let t of e)t.setParent(this)}setAttrs(t){if(T(t),this.mark.class&&(t.className=this.mark.class),this.mark.attrs)for(let e in this.mark.attrs)t.setAttribute(e,this.mark.attrs[e]);return t}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 X&&i.mark.eq(this.mark))||t&&s<=0||e<this.length&&r<=0))&&(L(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 r of this.children){let o=i+r.length;o>t&&e.push(i<t?r.split(t-i):r),n<0&&i>=t&&(n=s),i=o,s++}let r=this.length-t;return this.length=t,n>-1&&(this.children.length=n,this.markDirty()),new X(this.mark,e,r)}domAtPos(t){return Z(this,t)}coordsAt(t,e){return et(this,t,e)}}class Y extends R{static create(t,e,i){return new Y(t,e,i)}constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i,this.prevWidget=null}split(t){let e=Y.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 Y&&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 Y&&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 n.xv.empty;let t=this;for(;t.parent;)t=t.parent;let{view:e}=t,i=e&&e.state.doc,s=this.posAtStart;return i?i.slice(s,s+this.length):n.xv.empty}domAtPos(t){return(this.length?0==t:this.side>0)?E.before(this.dom):E.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 e=r?n.length-1:0;s=n[e],!(t>0?0==e:e==n.length-1||s.top<s.bottom);e+=r?-1:1);return y(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 Q extends R{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof Q&&t.side==this.side}split(){return new Q(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?E.before(this.dom):E.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return n.xv.empty}get isHidden(){return!0}}function Z(t,e){let i=t.dom,{children:n}=t,s=0;for(let t=0;s<n.length;s++){let r=n[s],o=t+r.length;if(!(o==t&&r.getSide()<=0)){if(e>t&&e<o&&r.dom.parentNode==i)return r.domAtPos(e-t);if(e<=t)break;t=o}}for(let t=s;t>0;t--){let e=n[t-1];if(e.dom.parentNode==i)return e.domAtPos(e.length)}for(let t=s;t<n.length;t++){let e=n[t];if(e.dom.parentNode==i)return e.domAtPos(0)}return new E(i,0)}function tt(t,e,i){let n,{children:s}=t;i>0&&e instanceof X&&s.length&&(n=s[s.length-1])instanceof X&&n.mark.eq(e.mark)?tt(n,e.children[0],i-1):(s.push(e),e.setParent(t)),t.length+=e.length}function et(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):function(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=p(e);return i[i.length-1]||null}(t)}function it(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}G.prototype.children=Y.prototype.children=Q.prototype.children=B;const nt=Object.create(null);function st(t,e,i){if(t==e)return!0;t||(t=nt),e||(e=nt);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 rt(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 ot(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 ht extends R{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 ht))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),L(this,t,e,i?i.children.slice():[],s,r),!0}split(t){let e=new ht;if(e.breakAfter=this.breakAfter,0==this.length)return e;let{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 t=i;t<this.children.length;t++)e.append(this.children[t],0);for(;i>0&&0==this.children[i-1].length;)this.children[--i].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){st(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){tt(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=it(e,this.attrs||{})),i&&(this.attrs=it({class:i},this.attrs||{}))}domAtPos(t){return Z(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.flags|=6)}sync(t,e){var i;this.dom?4&this.flags&&(T(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),void 0!==this.prevAttrs&&(rt(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&&R.get(n)instanceof X;)n=n.lastChild;if(!(n&&this.length&&("BR"==n.nodeName||0!=(null===(i=R.get(n))||void 0===i?void 0:i.isEditable)||U.ios&&this.children.some((t=>t instanceof G))))){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 G)||/[^ -~]/.test(i.text))return null;let n=p(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=et(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 ht)return s;if(r>e)break}n=r+s.breakAfter}return null}}class lt extends R{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 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)}domAtPos(t){return 0==t?E.before(this.dom):E.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new lt(this.widget,e,this.deco);return i.breakAfter=this.breakAfter,i}get children(){return B}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):n.xv.empty}domBoundsAround(){return null}become(t){return t instanceof lt&&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 at{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 ct=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(ct||(ct={}));class ut extends n.uU{constructor(t,e,i,n){super(),this.startSide=t,this.endSide=e,this.widget=i,this.spec=n}get heightRelevant(){return!1}static mark(t){return new ft(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 pt(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}=gt(t,n);e=(s?n?-3e8:-1:5e8)-1,i=1+(r?n?2e8:1:-6e8)}return new pt(t,e,i,n,t.widget||null,!0)}static line(t){return new dt(t)}static set(t,e=!1){return n.Xs.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}ut.none=n.Xs.empty;class ft extends ut{constructor(t){let{start:e,end:i}=gt(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 ft&&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))&&st(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)}}ft.prototype.point=!1;class dt extends ut{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof dt&&this.spec.class==t.spec.class&&st(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw new RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}}dt.prototype.mapMode=n.gc.TrackBefore,dt.prototype.point=!0;class pt extends ut{constructor(t,e,i,s,r,o){super(e,i,r,t),this.block=s,this.isReplace=o,this.mapMode=s?e<=0?n.gc.TrackBefore:n.gc.TrackAfter:n.gc.TrackDel}get type(){return this.startSide!=this.endSide?ct.WidgetRange:this.startSide<=0?ct.WidgetBefore:ct.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof pt&&(e=this.widget,i=t.widget,e==i||!!(e&&i&&e.compare(i)))&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide;var e,i}range(t,e=t){if(this.isReplace&&(t>e||t==e&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}}function gt(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)}pt.prototype.point=!0;class wt{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 lt&&t.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new ht),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(vt(new Q(-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 lt||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(vt(new G(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 pt){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 pt)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new lt(i.widget||new yt("div"),o,i));else{let r=Y.create(i.widget||new yt("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(vt(new Q(1),n),s),s=n.length+Math.max(0,s-n.length)),a.append(vt(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,s,r){let o=new wt(t,e,i,r);return o.openEnd=n.Xs.spans(s,e,i,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}}function vt(t,e){for(let i of e)t=new X(i,[t],t.length);return t}class yt extends at{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 bt=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(bt||(bt={}));const xt=bt.LTR,kt=bt.RTL;function St(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}const At=St("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Mt=St("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Ct=Object.create(null),Ot=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),i=t.charCodeAt(1);Ct[e]=i,Ct[i]=-e}function Tt(t){return t<=247?At[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?Mt[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8204?256:64336<=t&&t<=65023?4:1}const Dt=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Et{get dir(){return this.level%2?kt:xt}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 Bt(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||!Bt(n.inner,s.inner))return!1}return!0}const Rt=[];function Pt(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=Rt[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 p=r[a];if(!e)for(let t=p.to,e=a+1;;){if(t==i)break t;if(!(e<r.length&&r[e].from==t)){if(Rt[t]==h)break t;break}t=r[e++].to}if(a++,u)u.push(p);else{p.from>l&&o.push(new Et(l,p.from,f)),It(t,p.direction==xt!=!(f%2)?n+1:n,s,p.inner,p.from,p.to,o),l=p.to}d=p.to}else{if(d==i||(e?Rt[d]!=h:Rt[d]==h))break;d++}u?Pt(t,l,d,n+1,s,u,o):l<d&&o.push(new Et(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=Rt[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 p=r[--a];if(!i)for(let t=p.from,i=a;;){if(t==e)break t;if(!i||r[i-1].to!=t){if(Rt[t-1]==h)break t;break}t=r[--i].from}if(u)u.push(p);else{p.to<l&&o.push(new Et(p.to,l,f)),It(t,p.direction==xt!=!(f%2)?n+1:n,s,p.inner,p.from,p.to,o),l=p.from}d=p.from}else{if(d==e||(i?Rt[d-1]!=h:Rt[d-1]==h))break;d--}u?Pt(t,d,l,n+1,s,u,o):d<l&&o.push(new Et(d,l,f)),l=d}}function It(t,e,i,n,s,r,o){let h=e%2?2:1;!function(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=Tt(t.charCodeAt(e));512==s?s=i:8==s&&4==n&&(s=16),Rt[e]=4==s?2:s,7&s&&(n=s),i=s}for(let t=o,e=l,n=l;t<h;t++){let s=Rt[t];if(128==s)t<h-1&&e==Rt[t+1]&&24&e?s=Rt[t]=e:Rt[t]=256;else if(64==s){let s=t+1;for(;s<h&&64==Rt[s];)s++;let r=t&&8==e||s<i&&8==Rt[s]?1==n?1:8:256;for(let e=t;e<s;e++)Rt[e]=r;t=s-1}else 8==s&&1==n&&(Rt[t]=1);e=s,7&s&&(n=s)}}}(t,s,r,n,h),function(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=Ct[e=t.charCodeAt(o)])if(i<0){for(let t=h-3;t>=0;t-=3)if(Ot[t+1]==-i){let e=Ot[t+2],i=2&e?s:4&e?1&e?r:s:0;i&&(Rt[o]=Rt[Ot[t]]=i),h=t;break}}else{if(189==Ot.length)break;Ot[h++]=o,Ot[h++]=e,Ot[h++]=l}else if(2==(n=Rt[o])||1==n){let t=n==s;l=t?0:1;for(let e=h-3;e>=0;e-=3){let i=Ot[e+2];if(2&i)break;if(t)Ot[e+2]|=2;else{if(4&i)break;Ot[e+2]|=4}}}}}(t,s,r,n,h),function(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=Rt[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!=Rt[o])break;o++}let a=1==r,c=a==(1==(o<e?Rt[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),Rt[--e]=c;l=o}else r=o,l++}}}(s,r,n,h),Pt(t,s,r,e,i,n,o)}function Nt(t,e,i){if(!t)return[new Et(0,0,e==kt?1:0)];if(e==xt&&!i.length&&!Dt.test(t))return Lt(t.length);if(i.length)for(;t.length>Rt.length;)Rt[Rt.length]=256;let n=[],s=e==xt?0:1;return It(t,s,s,i,0,t.length,n),n}function Lt(t){return[new Et(0,t,0)]}let Vt="";function Ht(t,e,i,s,r){var o;let h=s.head-t.from,l=Et.find(e,h,null!==(o=s.bidiLevel)&&void 0!==o?o:-1,s.assoc),a=e[l],c=a.side(r,i);if(h==c){let t=l+=r?1:-1;if(t<0||t>=e.length)return null;a=e[l=t],h=a.side(!r,i),c=a.side(r,i)}let u=(0,n.cp)(t.text,h,a.forward(r,i));(u<a.from||u>a.to)&&(u=c),Vt=t.text.slice(Math.min(h,u),Math.max(h,u));let f=l==(r?e.length-1:0)?null:e[l+(r?1:-1)];return f&&u==c&&f.level+(r?0:1)<a.level?n.jT.cursor(f.side(!r,i)+t.from,f.forward(r,i)?1:-1,f.level):n.jT.cursor(u+t.from,a.forward(r,i)?-1:1,a.level)}function Wt(t,e,i){for(let n=e;n<i;n++){let e=Tt(t.charCodeAt(n));if(1==e)return xt;if(2==e||4==e)return kt}return xt}const _t=n.r$.define(),zt=n.r$.define(),Ft=n.r$.define(),qt=n.r$.define(),jt=n.r$.define(),Kt=n.r$.define(),$t=n.r$.define(),Jt=n.r$.define({combine:t=>t.some((t=>t))}),Ut=n.r$.define({combine:t=>t.some((t=>t))});class Gt{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 Gt(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 Gt(n.jT.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Xt=n.Py.define({map:(t,e)=>t.map(e)});function Yt(t,e,i){let n=t.facet(qt);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 Qt=n.r$.define({combine:t=>!t.length||t[0]});let Zt=0;const te=n.r$.define();class ee{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 ee(Zt++,t,i,n,(t=>{let e=[te.of(t)];return r&&e.push(re.of((e=>{let i=e.plugin(t);return i?r(i):ut.none}))),s&&e.push(s(t)),e}))}static fromClass(t,e){return ee.define((e=>new t(e)),e)}}class ie{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(Yt(t.state,e,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(t){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(t)}catch(e){Yt(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(e){Yt(t.state,e,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const ne=n.r$.define(),se=n.r$.define(),re=n.r$.define(),oe=n.r$.define(),he=n.r$.define(),le=n.r$.define();function ae(t,e){let i=t.state.facet(le);if(!i.length)return i;let s=i.map((e=>e instanceof Function?e(t):e)),r=[];return n.Xs.spans(s,e.from,e.to,{point(){},span(t,i,n,s){let o=t-e.from,h=i-e.from,l=r;for(let t=n.length-1;t>=0;t--,s--){let i,r=n[t].spec.bidiIsolate;if(null==r&&(r=Wt(e.text,o,h)),s>0&&l.length&&(i=l[l.length-1]).to==o&&i.direction==r)i.to=h,l=i.inner;else{let t={from:o,to:h,direction:r,inner:[]};l.push(t),l=t.inner}}}}),r}const ce=n.r$.define();function ue(t){let e=0,i=0,n=0,s=0;for(let r of t.state.facet(ce)){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 fe=n.r$.define();class de{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new de(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 de(r+l,h+l,r,h).addToSet(i),n>a)break;s+=2}if(!h)return i;new de(h.fromA,h.toA,h.fromB,h.toB).addToSet(i),r=h.toA,o=h.toB}}}class pe{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=n.as.empty(this.startState.doc.length);for(let t of i)this.changes=this.changes.compose(t.changes);let s=[];this.changes.iterChangedRanges(((t,e,i,n)=>s.push(new de(t,e,i,n)))),this.changedRanges=s}static create(t,e,i){return new pe(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 ge extends R{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 ht],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new de(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 s=-1;this.view.inputState.composing>=0&&((null===(e=this.domChanged)||void 0===e?void 0:e.newSel)?s=this.domChanged.newSel.head:function(t,e){let i=!1;e&&t.iterChangedRanges(((t,n)=>{t<e.to&&n>e.from&&(i=!0)}));return i}(t.changes,this.hasComposition)||t.selectionSet||(s=t.state.selection.main.head));let r=s>-1?function(t,e,i){let n=we(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 de(l.mapPos(r),l.mapPos(o),r,o),c=[];for(let e=s.parentNode;;e=e.parentNode){let i=R.get(e);if(i instanceof X)c.push({node:e,deco:i.mark});else{if(i instanceof ht||"DIV"==e.nodeName&&e.parentNode==t.contentDOM)return{range:a,text:s,marks:c,line:e};if(e==t.contentDOM)return null;c.push({node:e,deco:new ft({inclusive:!0,attributes:ot(e),tagName:e.tagName.toLowerCase()})})}}}(this.view,t.changes,s):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:e,to:n}=this.hasComposition;i=new de(e,n,t.changes.mapPos(e,-1),t.changes.mapPos(n,1)).addToSet(i.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(U.ie||U.chrome)&&!r&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let o=function(t,e,i){let s=new ye;return n.Xs.compare(t,e,i,s),s.changes}(this.decorations,this.updateDeco(),t.changes);return i=de.extendWithRanges(i,o),!!(7&this.flags||0!=i.length)&&(this.updateInner(i,t.startState.doc.length,r),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=U.chrome||U.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 t of this.children)t instanceof lt&&t.widget instanceof me&&s.push(t.dom);n.updateGaps(s)}updateChildren(t,e,i){let n=i?i.range.addToSet(t.slice()):t,s=this.childCursor(e);for(let t=n.length-1;;t--){let e=t>=0?n[t]:null;if(!e)break;let r,o,h,l,{fromA:a,toA:c,fromB:u,toB:f}=e;if(i&&i.range.fromB<f&&i.range.toB>u){let t=wt.build(this.view.state.doc,u,i.range.fromB,this.decorations,this.dynamicDecorationMap),e=wt.build(this.view.state.doc,i.range.toB,f,this.decorations,this.dynamicDecorationMap);o=t.breakAtStart,h=t.openStart,l=e.openEnd;let n=this.compositionView(i);e.breakAtStart?n.breakAfter=1:e.content.length&&n.merge(n.length,n.length,e.content[0],!1,e.openStart,0)&&(n.breakAfter=e.content[0].breakAfter,e.content.shift()),t.content.length&&n.merge(0,0,t.content[t.content.length-1],!0,0,t.openEnd)&&t.content.pop(),r=t.content.concat(n).concat(e.content)}else({content:r,breakAtStart:o,openStart:h,openEnd:l}=wt.build(this.view.state.doc,u,f,this.decorations,this.dynamicDecorationMap));let{i:d,off:p}=s.findPos(c,1),{i:g,off:m}=s.findPos(a,-1);N(this,g,m,d,p,r,o,h,l)}i&&this.fixCompositionDOM(i)}compositionView(t){let e=new G(t.text.nodeValue);e.flags|=8;for(let{deco:i}of t.marks)e=new X(i,[e],e.length);let i=new ht;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=R.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&&d(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(U.gecko&&o.empty&&!this.hasComposition&&(1==(a=h).node.nodeType&&a.node.firstChild&&(0==a.offset||"false"==a.node.childNodes[a.offset-1].contentEditable)&&(a.offset==a.node.childNodes.length||"false"==a.node.childNodes[a.offset].contentEditable))){let t=document.createTextNode("");this.view.observer.ignore((()=>h.node.insertBefore(t,h.node.childNodes[h.offset]||null))),h=l=new E(t,0),r=!0}var a;let c=this.view.observer.selectionRange;!r&&c.focusNode&&(g(h.node,h.offset,c.anchorNode,c.anchorOffset)&&g(l.node,l.offset,c.focusNode,c.focusOffset)||this.suppressWidgetCursorChange(c,o))||(this.view.observer.ignore((()=>{U.android&&U.chrome&&this.dom.contains(c.focusNode)&&function(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}(c.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let t=u(this.view.root);if(t)if(o.empty){if(U.gecko){let t=(e=h.node,n=h.offset,1!=e.nodeType?0:(n&&"false"==e.childNodes[n-1].contentEditable?1:0)|(n<e.childNodes.length&&"false"==e.childNodes[n].contentEditable?2:0));if(t&&3!=t){let e=ve(h.node,h.offset,1==t?1:-1);e&&(h=new E(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(t){}}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;var e,n;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 E(c.anchorNode,c.anchorOffset),this.impreciseHead=l.precise?null:new E(c.focusNode,c.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&g(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=u(t.root),{anchorNode:n,anchorOffset:s}=t.observer.selectionRange;if(!(i&&e.empty&&e.assoc&&i.modify))return;let r=ht.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=R.get(i.childNodes[n]);t instanceof ht&&(e=t.domAtPos(0))}for(let n=t.offset-1;!e&&n>=0;n--){let t=R.get(i.childNodes[n]);t instanceof ht&&(e=t.domAtPos(t.length))}return e?new E(e.node,e.offset,!0):t}nearest(t){for(let e=t;e;){let t=R.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 ht)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 ht&&!(i instanceof ht&&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),s=this.children[e];if(!(s instanceof ht))return null;for(;s.children.length;){let{i:t,off:e}=s.childPos(i,1);for(;;t++){if(t==s.children.length)return null;if((s=s.children[t]).length)break}i=e}if(!(s instanceof G))return null;let r=(0,n.cp)(s.text,i);if(r==i)return null;let o=C(s.dom,i,r).getClientRects();for(let t=0;t<o.length;t++){let e=o[t];if(t==o.length-1||e.top<e.bottom&&e.left<e.right)return e}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==bt.LTR;for(let t=0,l=0;l<this.children.length;l++){let a=this.children[l],c=t+a.length;if(c>n)break;if(t>=i){let i=a.dom.getBoundingClientRect();if(e.push(i.height),r){let e=a.dom.lastChild,n=e?p(e):[];if(n.length){let e=n[n.length-1],r=h?e.right-i.left:i.right-e.left;r>o&&(o=r,this.minWidth=s,this.minWidthFrom=t,this.minWidthTo=c)}}}t=c+a.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?bt.RTL:bt.LTR}measureTextSize(){for(let t of this.children)if(t instanceof ht){let e=t.measureTextSize();if(e)return e}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=p(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 I(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(ut.replace({widget:new me(n),block:!0,inclusive:!0,isBlockGap:!0}).range(i,r))}if(!s)break;i=s.to+1}return ut.set(t)}updateDeco(){let t=this.view.state.facet(re).map(((t,e)=>(this.dynamicDecorationMap[e]="function"==typeof t)?t(this.view):t)),e=!1,i=this.view.state.facet(oe).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(n.Xs.join(i)));for(let e=t.length;e<t.length+3;e++)this.dynamicDecorationMap[e]=!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=ue(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;!function(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,p=1;if(f)t=b(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:p}=x(c,e)),t={left:e.left,right:e.left+c.clientWidth*d,top:e.top,bottom:e.top+c.clientHeight*p}}let g=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?(g=-(t.left-e.left+r),i>0&&e.right>t.right+g&&(g=e.right-t.right+g+r)):e.right>t.right&&(g=e.right-t.right+r,i<0&&e.left<t.left+g&&(g=-(t.left+g-e.left+r))):g=("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,g||m)if(f)a.scrollBy(g,m);else{let t=0,i=0;if(m){let t=c.scrollTop;c.scrollTop+=m/p,i=(c.scrollTop-t)*p}if(g){let e=c.scrollLeft;c.scrollLeft+=g/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-g)<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}}(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==bt.LTR)}}class me extends at{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 we(t,e){let i=t.observer.selectionRange,n=i.focusNode&&ve(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 ve(t,e,i){if(i<=0)for(let i=t,n=e;;){if(3==i.nodeType)return{node:i,offset:n};if(!(1==i.nodeType&&n>0))break;i=i.childNodes[n-1],n=v(i)}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}let ye=class{constructor(){this.changes=[]}compareRange(t,e){mt(t,e,this.changes)}comparePoint(t,e){mt(t,e,this.changes)}};function be(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function xe(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function ke(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function Se(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function Ae(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function Me(t,e,i){let n,s,r,o,h,l,a,c,u=!1;for(let f=t.firstChild;f;f=f.nextSibling){let t=p(f);for(let d=0;d<t.length;d++){let p=t[d];s&&ke(s,p)&&(p=Se(Ae(p,s.bottom),s.top));let g=be(e,p),m=xe(i,p);if(0==g&&0==m)return 3==f.nodeType?Ce(f,e,i):Me(f,e,i);if(!n||o>m||o==m&&r>g){n=f,s=p,r=g,o=m;let h=m?i<p.top?-1:1:g?e<p.left?-1:1:0;u=!h||(h>0?d<t.length-1:d>0)}0==g?i>p.bottom&&(!a||a.bottom<p.bottom)?(h=f,a=p):i<p.top&&(!c||c.top>p.top)&&(l=f,c=p):a&&ke(a,p)?a=Ae(a,p.bottom):c&&ke(c,p)&&(c=Se(c,p.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?Ce(n,f,i):u&&"false"!=n.contentEditable?Me(n,f,i):{node:t,offset:Array.prototype.indexOf.call(t.childNodes,n)+(e>=(s.left+s.right)/2?1:0)}}function Ce(t,e,i){let n=t.nodeValue.length,s=-1,r=1e9,o=0;for(let h=0;h<n;h++){let n=C(t,h,h+1).getClientRects();for(let l=0;l<n.length;l++){let a=n[l];if(a.top==a.bottom)continue;o||(o=e-a.left);let c=(a.top>i?a.top-i:i-a.bottom)-1;if(a.left-1<=e&&a.right+1>=e&&c<r){let i=e>=(a.left+a.right)/2,n=i;if(U.chrome||U.gecko){C(t,h).getBoundingClientRect().left==a.right&&(n=!i)}if(c<=0)return{node:t,offset:h+(n?1:0)};s=h+(n?1:0),r=c}}}return{node:t,offset:s>-1?s:o>0?t.nodeValue.length:0}}function Oe(t,e,i,n=-1){var s,r;let o,h=t.contentDOM.getBoundingClientRect(),l=h.top+t.viewState.paddingTop,{docHeight:a}=t.viewState,{x:c,y:u}=e,f=u-l;if(f<0)return 0;if(f>a)return t.state.doc.length;for(let e=t.viewState.heightOracle.textHeight/2,s=!1;o=t.elementAtHeight(f),o.type!=ct.Text;)for(;f=n>0?o.bottom+e:o.top-e,!(f>=0&&f<=a);){if(s)return i?null:0;s=!0,n=-n}u=l+f;let d=o.from;if(d<t.viewport.from)return 0==t.viewport.from?0:i?null:Te(t,h,o,c,u);if(d>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:Te(t,h,o,c,u);let p=t.dom.ownerDocument,g=t.root.elementFromPoint?t.root:p,m=g.elementFromPoint(c,u);m&&!t.contentDOM.contains(m)&&(m=null),m||(c=Math.max(h.left+1,Math.min(h.right-1,c)),m=g.elementFromPoint(c,u),m&&!t.contentDOM.contains(m)&&(m=null));let w,v=-1;if(m&&0!=(null===(s=t.docView.nearest(m))||void 0===s?void 0:s.isEditable))if(p.caretPositionFromPoint){let t=p.caretPositionFromPoint(c,u);t&&({offsetNode:w,offset:v}=t)}else if(p.caretRangeFromPoint){let e=p.caretRangeFromPoint(c,u);e&&(({startContainer:w,startOffset:v}=e),(!t.contentDOM.contains(w)||U.safari&&function(t,e,i){let n;if(3!=t.nodeType||e!=(n=t.nodeValue.length))return!1;for(let e=t.nextSibling;e;e=e.nextSibling)if(1!=e.nodeType||"BR"!=e.nodeName)return!1;return C(t,n-1,n).getBoundingClientRect().left>i}(w,v,c)||U.chrome&&function(t,e,i){if(0!=e)return!1;for(let e=t;;){let t=e.parentNode;if(!t||1!=t.nodeType||t.firstChild!=e)return!1;if(t.classList.contains("cm-line"))break;e=t}let n=1==t.nodeType?t.getBoundingClientRect():C(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect();return i-n.left>5}(w,v,c))&&(w=void 0))}if(!w||!t.docView.dom.contains(w)){let e=ht.find(t.docView,d);if(!e)return f>o.top+o.height/2?o.to:o.from;({node:w,offset:v}=Me(e.dom,c,u))}let y=t.docView.nearest(w);if(!y)return null;if(y.isWidget&&1==(null===(r=y.dom)||void 0===r?void 0:r.nodeType)){let t=y.dom.getBoundingClientRect();return e.y<t.top||e.y<=t.bottom&&e.x<=(t.left+t.right)/2?y.posAtStart:y.posAtEnd}return y.localPosFromDOM(w,v)+y.posAtStart}function Te(t,e,i,s,r){let o=Math.round((s-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>1.5*t.defaultLineHeight){let e=t.viewState.heightOracle.textHeight;o+=Math.floor((r-i.top-.5*(t.defaultLineHeight-e))/e)*t.viewState.heightOracle.lineLength}let h=t.state.sliceDoc(i.from,i.to);return i.from+(0,n.Gz)(h,o,t.state.tabSize)}function De(t,e){let i=t.lineBlockAt(e);if(Array.isArray(i.type))for(let t of i.type)if(t.to>e||t.to==e&&(t.to==i.to||t.type==ct.Text))return t;return i}function Ee(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=Ht(s,r,o,h,i),a=Vt;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 Be(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 Re(t,e,i){let s=Be(t.state.facet(he).map((e=>e(t))),i.from,e.head>i.from?-1:1);return s==i.from?i:n.jT.cursor(s,s<i.from?1:-1)}class Pe{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,U.safari&&t.contentDOM.addEventListener("input",(()=>null)),U.gecko&&function(t){oi.has(t)||(oi.add(t),t.addEventListener("copy",(()=>{})),t.addEventListener("cut",(()=>{})))}(t.contentDOM.ownerDocument)}handleEvent(t){(function(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=R.get(n))&&i.ignoreEvent(e))return!1;return!0})(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=Ne(t),i=this.handlers,n=this.view.contentDOM;for(let t in e)if("scroll"!=t){let s=!e[t].handlers.length,r=i[t];r&&s!=!r.handlers.length&&(n.removeEventListener(t,this.handleEvent),r=null),r||n.addEventListener(t,this.handleEvent,{passive:s})}for(let t in i)"scroll"==t||e[t]||n.removeEventListener(t,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&&He.indexOf(t.keyCode)<0&&(this.view.inputState.lastEscPress=0),U.android&&U.chrome&&!t.synthetic&&(13==t.keyCode||8==t.keyCode))return this.view.observer.delayAndroidKey(t.key,t.keyCode),!0;let e;return!U.ios||t.synthetic||t.altKey||t.metaKey||!((e=Le.find((e=>e.keyCode==t.keyCode)))&&!t.ctrlKey||Ve.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,O(this.view.contentDOM,t.key,t.keyCode))}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(this.composing>0||!!(U.safari&&!U.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 Ie(t,e){return(i,n)=>{try{return e.call(t,n,i)}catch(t){Yt(i.state,t)}}}function Ne(t){let e=Object.create(null);function i(t){return e[t]||(e[t]={observers:[],handlers:[]})}for(let e of t){let t=e.spec;if(t&&t.domEventHandlers)for(let n in t.domEventHandlers){let s=t.domEventHandlers[n];s&&i(n).handlers.push(Ie(e.value,s))}if(t&&t.domEventObservers)for(let n in t.domEventObservers){let s=t.domEventObservers[n];s&&i(n).observers.push(Ie(e.value,s))}}for(let t in ze)i(t).handlers.push(ze[t]);for(let t in Fe)i(t).observers.push(Fe[t]);return e}const Le=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Ve="dthko",He=[16,17,18,20,91,92,224,225];function We(t){return.7*Math.max(0,t)+8}class _e{constructor(t,e,i,s){this.view=t,this.startEvent=e,this.style=i,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParent=function(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}(t.contentDOM),this.atoms=t.state.facet(he).map((e=>e(t)));let r=t.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(n.yy.allowMultipleSelections)&&function(t,e){let i=t.state.facet(_t);return i.length?i[0](e):U.mac?e.metaKey:e.ctrlKey}(t,e),this.dragging=!(!function(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let n=u(t.root);if(!n||0==n.rangeCount)return!0;let s=n.getRangeAt(0).getClientRects();for(let t=0;t<s.length;t++){let i=s[t];if(i.left<=e.clientX&&i.right>=e.clientX&&i.top<=e.clientY&&i.bottom>=e.clientY)return!0}return!1}(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=ue(this.view);t.clientX-h.left<=o.left+6?s=-We(o.left-t.clientX):t.clientX+h.right>=o.right-6&&(s=We(t.clientX-o.right)),t.clientY-h.top<=o.top+6?r=-We(o.top-t.clientY):t.clientY+h.bottom>=o.bottom-6&&(r=We(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 s=t.ranges[i],r=null;if(s.empty){let t=Be(this.atoms,s.from,0);t!=s.from&&(r=n.jT.cursor(t,-1))}else{let t=Be(this.atoms,s.from,-1),e=Be(this.atoms,s.to,1);t==s.from&&e==s.to||(r=n.jT.range(s.from==s.anchor?t:e,s.from==s.head?t:e))}r&&(e||(e=t.ranges.slice()),e[i]=r)}return e?n.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)}}const ze=Object.create(null),Fe=Object.create(null),qe=U.ie&&U.ie_version<15||U.ios&&U.webkit_version<604;function je(t,e){let i,{state:s}=t,r=1,o=s.toText(e),h=o.lines==s.selection.ranges.length;if(null!=ii&&s.selection.ranges.every((t=>t.empty))&&ii==o.toString()){let t=-1;i=s.changeByRange((i=>{let l=s.doc.lineAt(i.from);if(l.from==t)return{range:i};t=l.from;let a=s.toText((h?o.line(r++).text:e)+s.lineBreak);return{changes:{from:l.from,insert:a},range:n.jT.cursor(i.from+a.length)}}))}else i=h?s.changeByRange((t=>{let e=o.line(r++);return{changes:{from:t.from,to:t.to,insert:e.text},range:n.jT.cursor(t.from+e.length)}})):s.replaceSelection(o);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function Ke(t,e,i,s){if(1==s)return n.jT.cursor(e,i);if(2==s)return function(t,e,i=1){let s=t.charCategorizer(e),r=t.doc.lineAt(e),o=e-r.from;if(0==r.length)return n.jT.cursor(e);0==o?i=1:o==r.length&&(i=-1);let h=o,l=o;i<0?h=(0,n.cp)(r.text,o,!1):l=(0,n.cp)(r.text,o);let a=s(r.text.slice(h,l));for(;h>0;){let t=(0,n.cp)(r.text,h,!1);if(s(r.text.slice(t,h))!=a)break;h=t}for(;l<r.length;){let t=(0,n.cp)(r.text,l);if(s(r.text.slice(l,t))!=a)break;l=t}return n.jT.range(h+r.from,l+r.from)}(t.state,e,i);{let i=ht.find(t.docView,e),s=t.state.doc.lineAt(i?i.posAtEnd:e),r=i?i.posAtStart:s.from,o=i?i.posAtEnd:s.to;return o<t.state.doc.length&&o==s.to&&o++,n.jT.range(r,o)}}Fe.scroll=t=>{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft},ze.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),27==e.keyCode&&(t.inputState.lastEscPress=Date.now()),!1),Fe.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},Fe.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},ze.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(Ft))if(i=n(t,e),i)break;if(i||0!=e.button||(i=function(t,e){let i=Ge(t,e),s=ti(e),r=t.state.selection;return{update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),r=r.map(t.changes))},get(e,o,h){let l,a=Ge(t,e),c=Ke(t,a.pos,a.bias,s);if(i.pos!=a.pos&&!o){let e=Ke(t,i.pos,i.bias,s),r=Math.min(e.from,c.from),o=Math.max(e.to,c.to);c=r<c.from?n.jT.range(r,o):n.jT.range(o,r)}return o?r.replaceRange(r.main.extend(c.from,c.to)):h&&1==s&&r.ranges.length>1&&(l=function(t,e){for(let i=0;i<t.ranges.length;i++){let{from:s,to:r}=t.ranges[i];if(s<=e&&r>=e)return n.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}(r,a.pos))?l:h?r.addRange(c):n.jT.create([c])}}}(t,e)),i){let n=!t.hasFocus;t.inputState.startMouseSelection(new _e(t,e,i,n)),n&&t.observer.ignore((()=>M(t.contentDOM)));let s=t.inputState.mouseSelection;if(s)return s.start(e),!1===s.dragging}return!1};let $e=(t,e)=>t>=e.top&&t<=e.bottom,Je=(t,e,i)=>$e(e,i)&&t>=i.left&&t<=i.right;function Ue(t,e,i,n){let s=ht.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&&Je(i,n,o))return-1;let h=s.coordsAt(r,1);return h&&Je(i,n,h)?1:o&&$e(n,o)?-1:1}function Ge(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:Ue(t,i,e.clientX,e.clientY)}}const Xe=U.ie&&U.ie_version<=11;let Ye=null,Qe=0,Ze=0;function ti(t){if(!Xe)return t.detail;let e=Ye,i=Ze;return Ye=t,Ze=Date.now(),Qe=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Qe+1)%3:1}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&&function(t,e){let i=t.state.facet(zt);return i.length?i[0](e):U.mac?!e.altKey:!e.ctrlKey}(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}ze.dragstart=(t,e)=>{let{selection:{main:i}}=t.state;if(e.target.draggable){let s=t.docView.nearest(e.target);if(s&&s.isWidget){let t=s.posAtStart,e=t+s.length;(t>=i.to||e<=i.from)&&(i=n.jT.range(t,e))}}let{inputState:s}=t;return s.mouseSelection&&(s.mouseSelection.dragging=!0),s.draggedContent=i,e.dataTransfer&&(e.dataTransfer.setData("Text",t.state.sliceDoc(i.from,i.to)),e.dataTransfer.effectAllowed="copyMove"),!1},ze.dragend=t=>(t.inputState.draggedContent=null,!1),ze.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},ze.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let i=qe?null:e.clipboardData;return i?(je(t,i.getData("text/plain")||i.getData("text/uri-text")),!0):(function(t){let e=t.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout((()=>{t.focus(),i.remove(),je(t,i.value)}),50)}(t),!1)};let ii=null;ze.copy=ze.cut=(t,e)=>{let{text:i,ranges:n,linewise:s}=function(t){let e=[],i=[],n=!1;for(let n of t.selection.ranges)n.empty||(e.push(t.sliceDoc(n.from,n.to)),i.push(n));if(!e.length){let s=-1;for(let{from:n}of t.selection.ranges){let r=t.doc.lineAt(n);r.number>s&&(e.push(r.text),i.push({from:r.from,to:Math.min(t.doc.length,r.to+1)})),s=r.number}n=!0}return{text:e.join(t.lineBreak),ranges:i,linewise:n}}(t.state);if(!i&&!s)return!1;ii=s?i:null,"cut"!=e.type||t.state.readOnly||t.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let r=qe?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",i),!0):(function(t,e){let i=t.dom.parentNode;if(!i)return;let n=i.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout((()=>{n.remove(),t.focus()}),50)}(t,i),!1)};const ni=n.q6.define();function si(t,e){let i=[];for(let n of t.facet($t)){let s=n(t,e);s&&i.push(s)}return i?t.update({effects:i,annotations:ni.of(!0)}):null}function ri(t){setTimeout((()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=si(t.state,e);i?t.dispatch(i):t.update([])}}),10)}Fe.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),ri(t)},Fe.blur=t=>{t.observer.clearSelectionRange(),ri(t)},Fe.compositionstart=Fe.compositionupdate=t=>{null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0)},Fe.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,U.chrome&&U.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then((()=>t.observer.flush())):setTimeout((()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])}),50)},Fe.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},ze.beforeinput=(t,e)=>{var i;let n;if(U.chrome&&U.android&&(n=Le.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 oi=new Set;const hi=["pre-wrap","normal","pre-line","break-spaces"];class li{constructor(t){this.lineWrapping=t,this.doc=n.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 hi.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=hi.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 ai{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class ci{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?ct.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 pt?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 ci(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var ui=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}(ui||(ui={}));const fi=.001;class di{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)>fi&&(t.heightChanged=!0),this.height=e)}replace(t,e,i){return di.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,ui.ByPosNoHeight,i.setDoc(e),0,0),f=u.to>=l?u:s.lineAt(l,ui.ByPosNoHeight,i,0,0);for(c+=f.to-l,l=f.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,ui.ByPosNoHeight,i,0,0));a+=u.from-h,h=u.from;let d=yi.build(i.setDoc(r),t,a,c);s=s.replace(h,l,d)}return s.updateHeight(i,0)}static empty(){return new gi(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(di.of(t.slice(0,e)),r,di.of(t.slice(i)))}}di.prototype.size=1;class pi extends di{constructor(t,e,i){super(t,e),this.deco=i}blockAt(t,e,i,n){return new ci(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 gi extends pi{constructor(t,e){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(t,e,i,n){return new ci(n,this.length,i,this.height,this.breaks)}replace(t,e,i){let n=i[0];return 1==i.length&&(n instanceof gi||n instanceof mi&&4&n.flags)&&Math.abs(this.length-n.length)<10?(n instanceof mi?n=new gi(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):di.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 mi extends di{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 ci(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 ci(h,l,i+o*n,o,0)}}lineAt(t,e,i,n,s){if(e==ui.ByHeight)return this.blockAt(t,i,n,s);if(e==ui.ByPosNoHeight){let{from:e,to:n}=i.doc.lineAt(t);return new ci(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 ci(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 ci(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 mi?i[i.length-1]=new mi(t.length+n):i.push(null,new mi(n-1))}if(t>0){let e=i[0];e instanceof mi?i[0]=new mi(t+e.length):i.unshift(new mi(t-1),null)}return di.of(i)}decomposeLeft(t,e){e.push(new mi(t-1),null)}decomposeRight(t,e){e.push(null,new mi(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 mi(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)>=fi&&(o=-2);let h=new gi(e,s);h.outdated=!1,i.push(h),r+=e+1}r<=s&&i.push(null,new mi(s-r).updateHeight(t,r));let h=di.of(i);return(o<0||Math.abs(h.height-this.height)>=fi||Math.abs(o-this.heightMetrics(t,e).perLine)>=fi)&&(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 di{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==ui.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==ui.ByPosNoHeight?ui.ByPosNoHeight:ui.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,ui.ByPos,i,n,s);t<l.from&&this.left.forEachLine(t,l.from-1,i,n,s,r),l.to>=t&&l.from<=e&&r(l),e>l.to&&this.right.forEachLine(l.to+1,e,i,o,h,r)}}replace(t,e,i){let n=this.left.length+this.break;if(e<n)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let s=[];t>0&&this.decomposeLeft(t,s);let r=s.length;for(let t of i)s.push(t);if(t>0&&vi(s,r-1),e<this.length){let t=s.length;this.decomposeRight(e,s),vi(s,t)}return di.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?di.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 vi(t,e){let i,n;null==t[e]&&(i=t[e-1])instanceof mi&&(n=t[e+1])instanceof mi&&t.splice(e-1,3,new mi(i.length+1+n.length))}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 gi?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new gi(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 pi(r,n,i)):(r||s||n>=5)&&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 gi(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new mi(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 gi)return t;let e=new gi(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 gi||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new gi(0,-1));let i=t;for(let t of this.nodes)t instanceof gi&&t.updateHeight(this.oracle,i),i+=t?t.length:1;return this.nodes}static build(t,e,i,s){let r=new yi(i,t);return n.Xs.spans(e,i,s,r,0),r.finish(i)}}class bi{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,n){(t<e||i&&i.heightRelevant||n&&n.heightRelevant)&&mt(t,e,this.changes,5)}}function xi(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 e=t.parentNode;e&&e!=n.body;)if(1==e.nodeType){let i=e,n=window.getComputedStyle(i);if((i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)&&"visible"!=n.overflow){let n=i.getBoundingClientRect();r=Math.max(r,n.left),o=Math.min(o,n.right),h=Math.max(h,n.top),l=e==t.parentNode?n.bottom:Math.min(l,n.bottom)}e="absolute"==n.position||"fixed"==n.position?i.offsetParent:i.parentNode}else{if(11!=e.nodeType)break;e=e.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 Si{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 ut.replace({widget:new Ai(this.size*(e?t.scaleY:t.scaleX),e)}).range(this.from,this.to)}}class Ai extends at{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 Mi{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=Ei,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=bt.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let e=t.facet(se).some((t=>"function"!=typeof t&&"cm-lineWrapping"==t.class));this.heightOracle=new li(e),this.stateDeco=t.facet(re).filter((t=>"function"!=typeof t)),this.heightMap=di.empty().applyChanges(this.stateDeco,n.xv.empty,this.heightOracle.setDoc(t.doc),[new de(0,0,0,t.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ut.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 Ci(e,i))}}this.viewports=t.sort(((t,e)=>t.from-e.from)),this.scaler=this.heightMap.height<=7e6?Ei:new Bi(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:Ri(t,this.scaler))}))}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(re).filter((t=>"function"!=typeof t));let s=t.changedRanges,r=de.extendWithRanges(s,function(t,e,i){let s=new bi;return n.Xs.compare(t,e,i,s,0),s.changes}(i,this.stateDeco,t?t.changes:n.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),r),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=r.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<l.from||e.range.head>l.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,e));let a=!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(Ut)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),s=this.heightOracle,r=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?bt.RTL:bt.LTR;let o=this.heightOracle.mustRefreshForWrapping(r),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}=x(e,h);this.scaleX==t&&this.scaleY==i||(this.scaleX=t,this.scaleY=i,a|=8,o=l=!0)}let u=(parseInt(i.paddingTop)||0)*this.scaleY,f=(parseInt(i.paddingBottom)||0)*this.scaleY;this.paddingTop==u&&this.paddingBottom==f||(this.paddingTop=u,this.paddingBottom=f,a|=10),this.editorWidth!=t.scrollDOM.clientWidth&&(s.lineWrapping&&(l=!0),this.editorWidth=t.scrollDOM.clientWidth,a|=8);let d=t.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=d&&(this.scrollAnchorHeight=-1,this.scrollTop=d),this.scrolledToBottom=D(t.scrollDOM);let p=(this.printing?ki:xi)(e,this.paddingTop),g=p.top-this.pixelViewport.top,m=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;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(s.mustRefreshForHeights(e)&&(o=!0),o||s.lineWrapping&&Math.abs(v-this.contentDOMWidth)>s.charWidth){let{lineHeight:i,charWidth:n,textHeight:h}=t.docView.measureTextSize();o=i>0&&s.refresh(r,i,n,h,v/n,e),o&&(t.docView.minWidth=0,a|=8)}g>0&&m>0?c=Math.max(g,m):g<0&&m<0&&(c=Math.min(g,m)),s.heightChanged=!1;for(let i of this.viewports){let r=i.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(i);this.heightMap=(o?di.empty().applyChanges(this.stateDeco,n.xv.empty,this.heightOracle,[new de(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(s,0,o,new ai(i.from,r))}s.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 Ci(n.lineAt(r-1e3*i,ui.ByHeight,s,0,0).from,n.lineAt(o+1e3*(1-i),ui.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,ui.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 Ci(n.lineAt(i-500,ui.ByHeight,s,0,0).from,n.lineAt(i+r+500,ui.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 Ci(this.heightMap.lineAt(i,ui.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,ui.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,ui.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(e,ui.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 Si(e.mapPos(n.from),e.mapPos(n.to),n.size));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,s=i?1e4:2e3,r=s>>1,o=s<<1;if(this.defaultTextDirection!=bt.LTR&&!i)return[];let h=[],l=(s,o,a,c)=>{if(o-s<r)return;let u=this.state.selection.main,f=[u.from];u.empty||f.push(u.to);for(let t of f)if(t>s&&t<o)return l(s,t-10,a,c),void l(t+10,o,a,c);let d=function(t,e){for(let i of t)if(e(i))return i;return}(t,(t=>t.from>=a.from&&t.to<=a.to&&Math.abs(t.from-s)<r&&Math.abs(t.to-o)<r&&!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(n.jT.cursor(o),!1,!0).head;t>s&&(o=t)}d=new Si(s,o,this.gapSize(a,s,o,c))}h.push(d)};for(let t of this.viewportLines){if(t.length<o)continue;let e=Oi(t.from,t.to,this.stateDeco);if(e.total<o)continue;let n,r,h=this.scrollTarget?this.scrollTarget.range.head:null;if(i){let i,o,l=s/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=h){let n=Di(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;n=Ti(e,i),r=Ti(e,o)}else{let t,i,o=e.total*this.heightOracle.charWidth,l=s*this.heightOracle.charWidth;if(null!=h){let n=Di(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;n=Ti(e,t),r=Ti(e,i)}n>t.from&&l(t.from,n,t,e),r<t.to&&l(r,t.to,t,e)}return h}gapSize(t,e,i,n){let s=Di(n,i)-Di(n,e);return this.heightOracle.lineWrapping?t.height*s:n.total*this.heightOracle.charWidth*s}updateLineGaps(t){Si.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=ut.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=[];n.Xs.spans(t,this.viewport.from,this.viewport.to,{span(t,i){e.push({from:t,to:i})},point(){}},20);let i=e.length!=this.visibleRanges.length||this.visibleRanges.some(((t,i)=>t.from!=e[i].from||t.to!=e[i].to));return this.visibleRanges=e,i?4:0}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find((e=>e.from<=t&&e.to>=t))||Ri(this.heightMap.lineAt(t,ui.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return Ri(this.heightMap.lineAt(this.scaler.fromDOM(t),ui.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 Ri(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 Ci{constructor(t,e){this.from=t,this.to=e}}function Oi(t,e,i){let s=[],r=t,o=0;return n.Xs.spans(i,t,e,{span(){},point(t,e){t>r&&(s.push({from:r,to:t}),o+=t-r),r=e}},20),r<e&&(s.push({from:r,to:e}),o+=e-r),{total:o,ranges:s}}function Ti({total:t,ranges:e},i){if(i<=0)return e[0].from;if(i>=1)return e[e.length-1].to;let n=Math.floor(t*i);for(let t=0;;t++){let{from:i,to:s}=e[t],r=s-i;if(n<=r)return i+n;n-=r}}function Di(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}const Ei={toDOM:t=>t,fromDOM:t=>t,scale:1};class Bi{constructor(t,e,i){let n=0,s=0,r=0;this.viewports=i.map((({from:i,to:s})=>{let r=e.lineAt(i,ui.ByPos,t,0,0).top,o=e.lineAt(s,ui.ByPos,t,0,0).bottom;return n+=o-r,{from:i,to:s,top:r,bottom:o,domTop:0,domBottom:0}})),this.scale=(7e6-n)/(e.height-n);for(let t of this.viewports)t.domTop=r+(t.top-s)*this.scale,r=t.domBottom=t.domTop+(t.bottom-t.top),s=t.bottom}toDOM(t){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 Ri(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),n=e.toDOM(t.bottom);return new ci(t.from,t.length,i,n-i,Array.isArray(t._content)?t._content.map((t=>Ri(t,e))):t._content)}const Pi=n.r$.define({combine:t=>t.join(" ")}),Ii=n.r$.define({combine:t=>t.indexOf(!0)>-1}),Ni=h.newName(),Li=h.newName(),Vi=h.newName(),Hi={"&light":"."+Li,"&dark":"."+Vi};function Wi(t,e,i){return new h(e,{finish:e=>/&/.test(e)?e.replace(/&\w*/,(e=>{if("&"==e)return t;if(!i||!i[e])throw new RangeError(`Unsupported selector: ${e}`);return i[e]})):t+" "+e})}const _i=Wi("."+Ni,{"&":{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"}},Hi),zi="￿";class Fi{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(n.yy.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=zi}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=R.get(n),o=R.get(s);(r&&o?r.breakAfter:(r?r.breakAfter:ji(n))||ji(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=R.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+(qi(t,i.node,i.offset)?e:0))}}function qi(t,e,i){for(;;){if(!e||i<v(e))return!1;if(e==t)return!0;i=m(e)+1,e=e.parentNode}}function ji(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}class Ki{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class $i{constructor(t,e,i,s){this.typeOver=s,this.bounds=null,this.text="";let{impreciseHead:r,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=r||o?[]:function(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:n,focusNode:s,focusOffset:r}=t.observer.selectionRange;i&&(e.push(new Ki(i,n)),s==i&&r==n||e.push(new Ki(s,r)));return e}(t),i=new Fi(e,t.state);i.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=i.text,this.newSel=function(t,e){if(0==t.length)return null;let i=t[0].pos,s=2==t.length?t[1].pos:i;return i>-1&&s>-1?n.jT.single(i+e,s+e):null}(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=r&&r.node==e.focusNode&&r.offset==e.focusOffset||!f(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),s=o&&o.node==e.anchorNode&&o.offset==e.anchorOffset||!f(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset),h=t.viewport;if(U.ios&&t.state.selection.main.empty&&i!=s&&(h.from>0||h.to<t.state.doc.length)){let e=h.from-Math.min(i,s),n=h.to-Math.max(i,s);0!=e&&1!=e||0!=n&&-1!=n||(i=0,s=t.state.doc.length)}this.newSel=n.jT.single(s,i)}}}function Ji(t,e){let i,{newSel:s}=e,r=t.state.selection.main,o=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:s,to:h}=e.bounds,l=r.from,a=null;(8===o||U.android&&e.text.length<h-s)&&(l=r.to,a="end");let c=function(t,e,i,n){let s=Math.min(t.length,e.length),r=0;for(;r<s&&t.charCodeAt(r)==e.charCodeAt(r);)r++;if(r==s&&t.length==e.length)return null;let o=t.length,h=e.length;for(;o>0&&h>0&&t.charCodeAt(o-1)==e.charCodeAt(h-1);)o--,h--;if("end"==n){i-=o+Math.max(0,r-Math.min(o,h))-r}if(o<r&&t.length<e.length){r-=i<=r&&i>=o?r-i:0,h=r+(h-o),o=r}else if(h<r){r-=i<=r&&i>=h?r-i:0,o=r+(o-h),h=r}return{from:r,toA:o,toB:h}}(t.state.doc.sliceString(s,h,zi),e.text,l-s,a);c&&(U.chrome&&13==o&&c.toB==c.from+2&&e.text.slice(c.from,c.toB)==zi+zi&&c.toB--,i={from:s+c.from,to:s+c.toA,insert:n.xv.of(e.text.slice(c.from,c.toB).split(zi))})}else s&&(!t.hasFocus&&t.state.facet(Qt)||s.main.eq(r))&&(s=null);if(!i&&!s)return!1;if(!i&&e.typeOver&&!r.empty&&s&&s.main.empty?i={from:r.from,to:r.to,insert:t.state.doc.slice(r.from,r.to)}:i&&i.from>=r.from&&i.to<=r.to&&(i.from!=r.from||i.to!=r.to)&&r.to-r.from-(i.to-i.from)<=4?i={from:r.from,to:r.to,insert:t.state.doc.slice(r.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,r.to))}:(U.mac||U.android)&&i&&i.from==i.to&&i.from==r.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(s&&2==i.insert.length&&(s=n.jT.single(s.main.anchor-1,s.main.head-1)),i={from:r.from,to:r.to,insert:n.xv.of([" "])}):U.chrome&&i&&i.from==i.to&&i.from==r.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(s&&(s=n.jT.single(s.main.anchor-1,s.main.head-1)),i={from:r.from,to:r.to,insert:n.xv.of([" "])}),i){if(U.ios&&t.inputState.flushIOSKey())return!0;if(U.android&&(i.from==r.from&&i.to==r.to&&1==i.insert.length&&2==i.insert.lines&&O(t.contentDOM,"Enter",13)||(i.from==r.from-1&&i.to==r.to&&0==i.insert.length||8==o&&i.insert.length<i.to-i.from&&i.to>r.head)&&O(t.contentDOM,"Backspace",8)||i.from==r.from&&i.to==r.to+1&&0==i.insert.length&&O(t.contentDOM,"Delete",46)))return!0;let e,h=i.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let l=()=>e||(e=function(t,e,i){let s,r=t.state,o=r.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?r.sliceDoc(o.from,e.from):"",n=o.to>e.to?r.sliceDoc(e.to,o.to):"";s=r.replaceSelection(t.state.toText(i+e.insert.sliceString(0,void 0,t.state.lineBreak)+n))}else{let h=r.changes(e),l=i&&i.main.to<=h.newLength?i.main:void 0;if(r.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&&we(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;s=r.changeByRange((i=>{if(i.from==o.from&&i.to==o.to)return{changes:h,range:l||i.map(h)};let s=i.to-f,u=s-c.length;if(i.to-i.from!=d||t.state.sliceDoc(u,s)!=c||i.to>=a.from&&i.from<=a.to)return{range:i};let p=r.changes({from:u,to:s,insert:e.insert}),g=i.to-o.to;return{changes:p,range:l?n.jT.range(Math.max(0,l.anchor+g),Math.max(0,l.head+g)):i.map(p)}}))}else s={changes:h,selection:l&&r.selection.replaceRange(l)}}let h="input.type";(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));return r.update(s,{userEvent:h,scrollIntoView:!0})}(t,i,s));return t.state.facet(Kt).some((e=>e(t,i.from,i.to,h,l)))||t.dispatch(l()),!0}if(s&&!s.main.eq(r)){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:s,scrollIntoView:e,userEvent:i}),!0}return!1}const Ui={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Gi=U.ie&&U.ie_version<=11;class Xi{constructor(t){this.view=t,this.active=!1,this.selectionRange=new k,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);(U.ie&&U.ie_version<=11||U.ios&&t.composing)&&e.some((t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length))?this.flushSoon():this.flush()})),Gi&&(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(Qt)?i.root.activeElement!=this.dom:!d(i.dom,n))return;let s=n.anchorNode&&i.docView.nearest(n.anchorNode);s&&s.ignoreEvent(t)?e||(this.selectionChanged=!1):(U.ie&&U.ie_version<=11||U.android&&U.chrome)&&!i.state.selection.main.empty&&n.focusNode&&g(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=U.safari&&11==t.root.nodeType&&function(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}(this.dom.ownerDocument)==this.dom&&function(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);g(h.node,h.offset,r,o)&&([n,s,r,o]=[r,o,n,s]);return{anchorNode:n,anchorOffset:s,focusNode:r,focusOffset:o}}(this.view)||u(t.root);if(!e||this.selectionRange.eq(e))return!1;let i=d(this.dom,e);return i&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&function(t,e){let i=e.focusNode,n=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=n)return!1;for(n=Math.min(n,v(i));;)if(n){if(1!=i.nodeType)return!1;let t=i.childNodes[n-1];"false"==t.contentEditable?n--:(i=t,n=v(i))}else{if(i==t)return!0;n=m(i),i=i.parentNode}}(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,Ui),Gi&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Gi&&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&&O(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&&d(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 $i(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=Ji(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=Yi(e,t.previousSibling||t.target.previousSibling,-1),n=Yi(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 t of this.scrollTargets)t.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 Yi(t,e,i){for(;e;){let n=R.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}class Qi{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||function(t){for(;t;){if(t&&(9==t.nodeType||11==t.nodeType&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}(t.parent)||document,this.viewState=new Mi(t.state||n.yy.create(t)),t.scrollTo&&t.scrollTo.is(Xt)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(te).map((t=>new ie(t)));for(let t of this.plugins)t.update(this);this.observer=new Xi(this),this.inputState=new Pe(this),this.inputState.ensureHandlers(this.plugins),this.docView=new ge(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure()}dispatch(...t){let e=1==t.length&&t[0]instanceof n.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,s=!1,r=this.state;for(let e of t){if(e.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=e.state}if(this.destroyed)return void(this.viewState.state=r);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=si(r,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(r.doc)||!this.state.selection.eq(r.selection))&&(c=null)):this.observer.clear(),r.facet(n.yy.phrases)!=this.state.facet(n.yy.phrases))return this.setState(r);e=pe.create(this,r,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 Gt(t.empty?t:n.jT.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(Xt)&&(u=t.value.clip(this.state))}this.viewState.update(e,u),this.bidiCache=en.update(this.bidiCache,e.changes),e.empty||(this.updatePlugins(e),this.inputState.update(e)),i=this.docView.update(e),this.state.facet(fe)!=this.styleModules&&this.mountStyles(),s=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(i,t.some((t=>t.isUserEvent("select.pointer"))))}finally{this.updateState=0}if(e.startState.facet(Pi)!=e.state.facet(Pi)&&(this.viewState.mustMeasureContent=!0),(i||s||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!e.empty)for(let t of this.state.facet(jt))try{t(e)}catch(t){Yt(this.state,t,"update listener")}(l||c)&&Promise.resolve().then((()=>{l&&this.state==l.startState&&this.dispatch(l),c&&!Ji(this,c)&&a.force&&O(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 Mi(t),this.plugins=t.facet(te).map((t=>new ie(t))),this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView.destroy(),this.docView=new ge(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(te),i=t.state.facet(te);if(e!=i){let n=[];for(let s of i){let i=e.indexOf(s);if(i<0)n.push(new ie(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 e of this.plugins)e.mustUpdate=t;for(let t=0;t<this.plugins.length;t++)this.plugins[t].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(D(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 o=this.viewState.measure(this);if(!o&&!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 h=[];4&o||([this.measureRequests,h]=[h,this.measureRequests]);let l=h.map((t=>{try{return t.read(this)}catch(t){return Yt(this.state,t),tn}})),a=pe.create(this,this.state,[]),c=!1;a.flags|=o,e?e.flags|=o:e=a,this.updateState=2,a.empty||(this.updatePlugins(a),this.inputState.update(a),this.updateAttrs(),c=this.docView.update(a));for(let t=0;t<h.length;t++)if(l[t]!=tn)try{let e=h[t];e.write&&e.write(l[t],this)}catch(t){Yt(this.state,t)}if(c&&this.docView.updateSelection(!0),!a.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 t of this.state.facet(jt))t(e)}get themeClasses(){return Ni+" "+(this.state.facet(Ii)?Vi:Li)+" "+this.state.facet(Pi)}updateAttrs(){let t=nn(this,ne,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(Qt)?"true":"false",class:"cm-content",style:`${U.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),nn(this,se,e);let i=this.observer.ignore((()=>{let i=rt(this.contentDOM,this.contentAttrs,e),n=rt(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(Qi.announce)){e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(fe);let t=this.state.facet(Qi.cspNonce);h.mount(this.root,this.styleModules.concat(_i).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 Re(this,t,Ee(this,t,e,i))}moveByGroup(t,e){return Re(this,t,Ee(this,t,e,(e=>function(t,e,i){let s=t.state.charCategorizer(e),r=s(i);return t=>{let e=s(t);return r==n.D0.Space&&(r=e),r==e}}(this,t.head,e))))}visualLineSide(t,e){let i=this.bidiSpans(t),s=this.textDirectionAt(t.from),r=i[e?i.length-1:0];return n.jT.cursor(r.side(e,s)+t.from,r.forward(!e,s)?1:-1)}moveToLineBoundary(t,e,i=!0){return function(t,e,i,s){let r=De(t,e.head),o=s&&r.type==ct.Text&&(t.lineWrapping||r.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head):null;if(o){let e=t.dom.getBoundingClientRect(),s=t.textDirectionAt(r.from),h=t.posAtCoords({x:i==(s==bt.LTR)?e.right-1:e.left+1,y:(o.top+o.bottom)/2});if(null!=h)return n.jT.cursor(h,i?-1:1)}return n.jT.cursor(i?r.to:r.from,i?-1:1)}(this,t,e,i)}moveVertically(t,e,i){return Re(this,t,function(t,e,i,s){let r=e.head,o=i?1:-1;if(r==(i?t.state.doc.length:0))return n.jT.cursor(r,e.assoc);let h,l=e.goalColumn,a=t.contentDOM.getBoundingClientRect(),c=t.coordsAtPos(r,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(r);null==l&&(l=Math.min(a.right-a.left,t.defaultCharacterWidth*(r-e.from))),h=(o<0?e.top:e.bottom)+u}let f=a.left+l,d=null!=s?s:t.viewState.heightOracle.textHeight>>1;for(let e=0;;e+=10){let i=h+(d+e)*o,s=Oe(t,{x:f,y:i},!1,o);if(i<a.top||i>a.bottom||(o<0?s<r:s>r)){let e=t.docView.coordsForChar(s),r=!e||i<e.top?-1:1;return n.jT.cursor(s,r,void 0,l)}}}(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(),Oe(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 y(i,s[Et.find(s,t-n.from,-1,e)].dir==bt.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(Jt)||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>Zi)return Lt(t.length);let e,i=this.textDirectionAt(t.from);for(let n of this.bidiCache)if(n.from==t.from&&n.dir==i&&(n.fresh||Bt(n.isolates,e=ae(this,t))))return n.order;e||(e=ae(this,t));let n=Nt(t.text,i,e);return this.bidiCache.push(new en(t.from,t.to,i,e,!0,n)),n}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||U.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{M(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 Xt.of(new Gt("number"==typeof t?n.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 Xt.of(new Gt(n.jT.cursor(i.from),"start","start",i.top-t,e,!0))}static domEventHandlers(t){return ee.define((()=>({})),{eventHandlers:t})}static domEventObservers(t){return ee.define((()=>({})),{eventObservers:t})}static theme(t,e){let i=h.newName(),n=[Pi.of(i),fe.of(Wi(`.${i}`,t))];return e&&e.dark&&n.push(Ii.of(!0)),n}static baseTheme(t){return n.Wl.lowest(fe.of(Wi("."+Ni,t,Hi)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),n=i&&R.get(i)||R.get(t);return(null===(e=null==n?void 0:n.rootView)||void 0===e?void 0:e.view)||null}}Qi.styleModule=fe,Qi.inputHandler=Kt,Qi.focusChangeEffect=$t,Qi.perLineTextDirection=Jt,Qi.exceptionSink=qt,Qi.updateListener=jt,Qi.editable=Qt,Qi.mouseSelectionStyle=Ft,Qi.dragMovesSelection=zt,Qi.clickAddsSelectionRange=_t,Qi.decorations=re,Qi.outerDecorations=oe,Qi.atomicRanges=he,Qi.bidiIsolatedRanges=le,Qi.scrollMargins=ce,Qi.darkTheme=Ii,Qi.cspNonce=n.r$.define({combine:t=>t.length?t[0]:""}),Qi.contentAttributes=se,Qi.editorAttributes=ne,Qi.lineWrapping=Qi.contentAttributes.of({class:"cm-lineWrapping"}),Qi.announce=n.Py.define();const Zi=4096,tn={};class en{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:bt.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 en(e.mapPos(r.from,1),e.mapPos(r.to,-1),r.dir,r.isolates,!1,r.order))}return i}}function nn(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&&it(r,i)}return i}const sn=U.mac?"mac":U.windows?"win":U.linux?"linux":"key";function rn(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 on=n.Wl.default(Qi.domEventHandlers({keydown:(t,e)=>fn(an(e.state),t,e,"editor")})),hn=n.r$.define({enables:on}),ln=new WeakMap;function an(t){let e=t.facet(hn),i=ln.get(e);return i||ln.set(e,i=function(t,e=sn){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=>function(t,e){const i=t.split(/-(?!$)/);let n,s,r,o,h=i[i.length-1];"Space"==h&&(h=" ");for(let t=0;t<i.length-1;++t){const h=i[t];if(/^(cmd|meta|m)$/i.test(h))o=!0;else if(/^a(lt)?$/i.test(h))n=!0;else if(/^(c|ctrl|control)$/i.test(h))s=!0;else if(/^s(hift)?$/i.test(h))r=!0;else{if(!/^mod$/i.test(h))throw new Error("Unrecognized modifier name: "+h);"mac"==e?o=!0:s=!0}}return n&&(h="Alt-"+h),s&&(h="Ctrl-"+h),o&&(h="Meta-"+h),r&&(h="Shift-"+h),h}(t,e)));for(let e=1;e<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=cn={view:e,prefix:i,scope:t};return setTimeout((()=>{cn==n&&(cn=null)}),un),!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 n of t){let t=n.scope?n.scope.split(" "):["editor"];if(n.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(n.any)}let s=n[e]||n.key;if(s)for(let e of t)r(e,s,n.run,n.preventDefault,n.stopPropagation),n.shift&&r(e,"Shift-"+s,n.shift,n.preventDefault,n.stopPropagation)}return i}(e.reduce(((t,e)=>t.concat(e)),[]))),i}let cn=null;const un=4e3;function fn(t,e,i,s){let r=(0,c.YG)(e),o=(0,n.gm)(r,0),h=(0,n.nZ)(o)==r.length&&" "!=r,l="",a=!1,u=!1,f=!1;cn&&cn.view==i&&cn.scope==s&&(l=cn.prefix+" ",He.indexOf(e.keyCode)<0&&(u=!0,cn=null));let d,p,g=new Set,m=t=>{if(t){for(let n of t.run)if(!g.has(n)&&(g.add(n),n(i,e)))return t.stopPropagation&&(f=!0),!0;t.preventDefault&&(t.stopPropagation&&(f=!0),u=!0)}return!1},w=t[s];return w&&(m(w[l+rn(r,e,!h)])?a=!0:h&&(e.altKey||e.metaKey||e.ctrlKey)&&!(U.windows&&e.ctrlKey&&e.altKey)&&(d=c.ue[e.keyCode])&&d!=r?(m(w[l+rn(d,e,!0)])||e.shiftKey&&(p=c.uY[e.keyCode])!=r&&p!=d&&m(w[l+rn(p,e,!1)]))&&(a=!0):h&&e.shiftKey&&m(w[l+rn(r,e,!0)])&&(a=!0),!a&&m(w._any)&&(a=!0)),u&&(a=!0),a&&f&&e.stopPropagation(),a}class dn{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=pn(t);return[new dn(e,n.left-s.left,n.top-s.top,null,n.bottom-n.top)]}return function(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==bt.LTR,o=t.contentDOM,h=o.getBoundingClientRect(),l=pn(t),a=o.querySelector(".cm-line"),c=a&&window.getComputedStyle(a),u=h.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),f=h.right-(c?parseInt(c.paddingRight):0),d=De(t,n),p=De(t,s),g=d.type==ct.Text?d:null,m=p.type==ct.Text?p:null;g&&(t.lineWrapping||d.widgetLineBreaks)&&(g=gn(t,n,g));m&&(t.lineWrapping||p.widgetLineBreaks)&&(m=gn(t,s,m));if(g&&m&&g.from==m.from)return v(y(i.from,i.to,g));{let e=g?y(i.from,null,g):b(d,!1),n=m?y(null,i.to,m):b(p,!0),s=[];return(g||d).to<(m||p).from-(g&&m?1:0)||d.widgetLineBreaks>1&&e.bottom+t.defaultLineHeight/2<n.top?s.push(w(u,e.bottom,f,n.top)):e.bottom<n.top&&t.elementAtHeight((e.bottom+n.top)/2).type==ct.Text&&(e.bottom=n.top=(e.bottom+n.top)/2),v(e).concat(s).concat(v(n))}function w(t,i,n,s){return new dn(e,t-l.left,i-l.top-.01,n-t,s-i+.01)}function v({top:t,bottom:e,horizontal:i}){let n=[];for(let s=0;s<i.length;s+=2)n.push(w(i[s],t,i[s+1],e));return n}function y(e,i,n){let s=1e9,o=-1e9,h=[];function l(e,i,l,a,c){let d=t.coordsAtPos(e,e==n.to?-2:2),p=t.coordsAtPos(l,l==n.from?2:-2);d&&p&&(s=Math.min(d.top,p.top,s),o=Math.max(d.bottom,p.bottom,o),c==bt.LTR?h.push(r&&i?u:d.left,r&&a?f:p.right):h.push(!r&&a?u:p.left,!r&&i?f:d.right))}let a=null!=e?e:n.from,c=null!=i?i:n.to;for(let n of t.visibleRanges)if(n.to>a&&n.from<c)for(let s=Math.max(n.from,a),r=Math.min(n.to,c);;){let n=t.state.doc.lineAt(s);for(let o of t.bidiSpans(n)){let t=o.from+n.from,h=o.to+n.from;if(t>=r)break;h>s&&l(Math.max(t,s),null==e&&t<=a,Math.min(h,r),null==i&&h>=c,o.dir)}if(s=n.to+1,s>=r)break}return 0==h.length&&l(a,null==e,c,null==i,t.textDirection),{top:s,bottom:o,horizontal:h}}function b(t,e){let i=h.top+(e?t.top:t.bottom);return{top:i,bottom:i,horizontal:[]}}}(t,e,i)}}function pn(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==bt.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function gn(t,e,i){let s=n.jT.cursor(e);return{from:Math.max(i.from,t.moveToLineBoundary(s,!1,!0).from),to:Math.min(i.to,t.moveToLineBoundary(s,!0,!0).from),type:ct.Text}}class mn{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(wn)!=t.state.facet(wn)&&this.setOrder(t.state),(this.layer.update(t,this.dom)||t.geometryChanged)&&(this.scale(),t.view.requestMeasure(this.measureReq))}setOrder(t){let e=0,i=t.facet(wn);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 wn=n.r$.define();function vn(t){return[ee.define((e=>new mn(e,t))),wn.of(t)]}const yn=!U.ios,bn=n.r$.define({combine:t=>(0,n.BO)(t,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,e)=>Math.min(t,e),drawRangeCursor:(t,e)=>t||e})});function xn(t={}){return[bn.of(t),Sn,Mn,On,Ut.of(!0)]}function kn(t){return t.startState.facet(bn)!=t.state.facet(bn)}const Sn=vn({above:!0,markers(t){let{state:e}=t,i=e.facet(bn),s=[];for(let r of e.selection.ranges){let o=r==e.selection.main;if(r.empty?!o||yn:i.drawRangeCursor){let e=o?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",i=r.empty?r:n.jT.cursor(r.head,r.head>r.anchor?-1:1);for(let n of dn.forRange(t,e,i))s.push(n)}}return s},update(t,e){t.transactions.some((t=>t.selection))&&(e.style.animationName="cm-blink"==e.style.animationName?"cm-blink2":"cm-blink");let i=kn(t);return i&&An(t.state,e),t.docChanged||t.selectionSet||i},mount(t,e){An(e.state,t)},class:"cm-cursorLayer"});function An(t,e){e.style.animationDuration=t.facet(bn).cursorBlinkRate+"ms"}const Mn=vn({above:!1,markers:t=>t.state.selection.ranges.map((e=>e.empty?[]:dn.forRange(t,"cm-selectionBackground",e))).reduce(((t,e)=>t.concat(e))),update:(t,e)=>t.docChanged||t.selectionSet||t.viewportChanged||kn(t),class:"cm-selectionLayer"}),Cn={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};yn&&(Cn[".cm-line"].caretColor="transparent !important",Cn[".cm-content"]={caretColor:"transparent !important"});const On=n.Wl.highest(Qi.theme(Cn));function Tn(){return En}const Dn=ut.line({class:"cm-activeLine"}),En=ee.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(Dn.range(s.from)),e=s.from)}return ut.set(i)}},{decorations:t=>t.decorations});const Bn=2e3;function Rn(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1),s=t.state.doc.lineAt(i),r=i-s.from,o=r>Bn?-1:r==s.length?function(t,e){let i=t.coordsAtPos(t.viewport.from);return i?Math.round(Math.abs((i.left-e)/t.defaultCharacterWidth)):-1}(t,e.clientX):(0,n.IS)(s.text,t.state.tabSize,i-s.from);return{line:s.number,col:o,off:r}}function Pn(t,e){let i=Rn(t,e),s=t.state.selection;return i?{update(t){if(t.docChanged){let e=t.changes.mapPos(t.startState.doc.line(i.line).from),n=t.state.doc.lineAt(e);i={line:n.number,col:i.col,off:Math.min(i.off,n.length)},s=s.map(t.changes)}},get(e,r,o){let h=Rn(t,e);if(!h)return s;let l=function(t,e,i){let s=Math.min(e.line,i.line),r=Math.max(e.line,i.line),o=[];if(e.off>Bn||i.off>Bn||e.col<0||i.col<0){let h=Math.min(e.off,i.off),l=Math.max(e.off,i.off);for(let e=s;e<=r;e++){let i=t.doc.line(e);i.length<=l&&o.push(n.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=s;e<=r;e++){let i=t.doc.line(e),s=(0,n.Gz)(i.text,h,t.tabSize,!0);if(s<0)o.push(n.jT.cursor(i.to));else{let e=(0,n.Gz)(i.text,l,t.tabSize);o.push(n.jT.range(i.from+s,i.from+e))}}}return o}(t.state,i,h);return l.length?o?n.jT.create(l.concat(s.ranges)):n.jT.create(l):s}}:null}function In(t){let e=(null==t?void 0:t.eventFilter)||(t=>t.altKey&&0==t.button);return Qi.mouseSelectionStyle.of(((t,i)=>e(i)?Pn(t,i):null))}const Nn={Alt:[18,t=>!!t.altKey],Control:[17,t=>!!t.ctrlKey],Shift:[16,t=>!!t.shiftKey],Meta:[91,t=>!!t.metaKey]},Ln={style:"cursor: crosshair"};function Vn(t={}){let[e,i]=Nn[t.key||"Alt"],n=ee.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,Qi.contentAttributes.of((t=>{var e;return(null===(e=t.plugin(n))||void 0===e?void 0:e.isDown)?Ln:null}))]}const Hn="-10000px";class Wn{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 i=0;i<s.length;i++){let n=s[i],h=-1;if(n){for(let t=0;t<this.tooltips.length;t++){let e=this.tooltips[t];e&&e.create==n.create&&(h=t)}if(h<0)r[i]=this.createTooltipView(n),o&&(o[i]=!!n.above);else{let n=r[i]=this.tooltipViews[h];o&&(o[i]=e[h]),n.update&&n.update(t)}}}for(let t of this.tooltipViews)r.indexOf(t)<0&&(t.dom.remove(),null===(i=t.destroy)||void 0===i||i.call(t));return e&&(o.forEach(((t,i)=>e[i]=t)),e.length=o.length),this.input=n,this.tooltips=s,this.tooltipViews=r,!0}}function _n(t){let{win:e}=t;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}const zn=n.r$.define({combine:t=>{var e,i,n;return{position:U.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)||_n}}}),Fn=new WeakMap,qn=ee.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(zn);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 Wn(t,$n,(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(zn);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=Hn,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 e of this.manager.tooltipViews)e.dom.remove(),null===(t=e.destroy)||void 0===t||t.call(e);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(U.gecko)n=t.offsetParent!=this.container.ownerDocument.body;else if(t.style.top==Hn&&"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(zn).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,u=t.pos[h],f=t.size[h];if(!u||u.bottom<=Math.max(i.top,n.top)||u.top>=Math.min(i.bottom,n.bottom)||u.right<Math.max(i.left,n.left)-.1||u.left>Math.min(i.right,n.right)+.1){c.style.top=Hn;continue}let d=l.arrow?a.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,g=f.right-f.left,m=null!==(e=Fn.get(a))&&void 0!==e?e:f.bottom-f.top,w=a.offset||Kn,v=this.view.textDirection==bt.LTR,y=f.width>n.right-n.left?v?n.left:n.right-f.width:v?Math.min(u.left-(d?14:0)+w.x,n.right-g):Math.max(n.left,u.left-g+(d?14:0)-w.x),b=this.above[h];!l.strictSide&&(b?u.top-(f.bottom-f.top)-w.y<n.top:u.bottom+(f.bottom-f.top)+w.y>n.bottom)&&b==n.bottom-u.bottom>u.top-n.top&&(b=this.above[h]=!b);let x=(b?u.top-n.top:n.bottom-u.bottom)-p;if(x<m&&!1!==a.resize){if(x<this.view.defaultLineHeight){c.style.top=Hn;continue}Fn.set(a,m),c.style.height=(m=x)/r+"px"}else c.style.height&&(c.style.height="");let k=b?u.top-m-p-w.y:u.bottom+p+w.y,S=y+g;if(!0!==a.overlap)for(let t of o)t.left<S&&t.right>y&&t.top<k+m&&t.bottom>k&&(k=b?t.top-m-2-p:t.bottom+p+2);if("absolute"==this.position?(c.style.top=(k-t.parent.top)/r+"px",c.style.left=(y-t.parent.left)/s+"px"):(c.style.top=k/r+"px",c.style.left=y/s+"px"),d){let t=u.left+(v?w.x:-w.x)-(y+14-7);d.style.left=t/s+"px"}!0!==a.overlap&&o.push({left:y,top:k,right:S,bottom:k+m}),c.classList.toggle("cm-tooltip-above",b),c.classList.toggle("cm-tooltip-below",!b),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=Hn}},{eventObservers:{scroll(){this.maybeMeasure()}}}),jn=Qi.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"}}}),Kn={x:0,y:0},$n=n.r$.define({enables:[qn,jn]});function Jn(t,e){let i=t.plugin(qn);if(!i)return null;let n=i.manager.tooltips.indexOf(e);return n<0?null:i.manager.tooltipViews[n]}class Un extends n.uU{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Un.prototype.elementClass="",Un.prototype.toDOM=void 0,Un.prototype.mapMode=n.gc.TrackBefore,Un.prototype.startSide=Un.prototype.endSide=-1,Un.prototype.point=!0;const Gn=n.r$.define(),Xn=n.r$.define();const Yn=n.r$.define({combine:t=>t.some((t=>t))});function Qn(t){let e=[Zn];return t&&!1===t.fixed&&e.push(Yn.of(!0)),e}const Zn=ee.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(Xn).map((e=>new ns(t,e)));for(let t of this.gutters)this.dom.appendChild(t.dom);this.fixed=!t.state.facet(Yn),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(Yn)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&this.dom.remove();let i=n.Xs.iter(this.view.state.facet(Gn),this.view.viewport.from),s=[],r=this.gutters.map((t=>new is(t,this.view.viewport,-this.view.documentPadding.top)));for(let t of this.view.viewportLineBlocks)if(s.length&&(s=[]),Array.isArray(t.type)){let e=!0;for(let n of t.type)if(n.type==ct.Text&&e){es(i,s,n.from);for(let t of r)t.line(this.view,n,s);e=!1}else if(n.widget)for(let t of r)t.widget(this.view,n)}else if(t.type==ct.Text){es(i,s,t.from);for(let e of r)e.line(this.view,t,s)}else if(t.widget)for(let e of r)e.widget(this.view,t);for(let t of r)t.finish();t&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(t){let e=t.startState.facet(Xn),i=t.state.facet(Xn),s=t.docChanged||t.heightChanged||t.viewportChanged||!n.Xs.eq(t.startState.facet(Gn),t.state.facet(Gn),t.view.viewport.from,t.view.viewport.to);if(e==i)for(let e of this.gutters)e.update(t)&&(s=!0);else{s=!0;let n=[];for(let s of i){let i=e.indexOf(s);i<0?n.push(new ns(this.view,s)):(this.gutters[i].update(t),n.push(this.gutters[i]))}for(let t of this.gutters)t.dom.remove(),n.indexOf(t)<0&&t.destroy();for(let t of n)this.dom.appendChild(t.dom);this.gutters=n}return s}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove()}},{provide:t=>Qi.scrollMargins.of((e=>{let i=e.plugin(t);return i&&0!=i.gutters.length&&i.fixed?e.textDirection==bt.LTR?{left:i.dom.offsetWidth*e.scaleX}:{right:i.dom.offsetWidth*e.scaleX}:null}))});function ts(t){return Array.isArray(t)?t:[t]}function es(t,e,i){for(;t.value&&t.from<=i;)t.from==i&&e.push(t.value),t.next()}class is{constructor(t,e,i){this.gutter=t,this.height=i,this.i=0,this.cursor=n.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 ss(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=[];es(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 ns{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=ts(e.markers(t)),e.initialSpacer&&(this.spacer=new ss(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=ts(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let e=this.config.updateSpacer(this.spacer.markers[0],t);e!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[e])}let i=t.view.viewport;return!n.Xs.eq(this.markers,e,i.from,i.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(t)}destroy(){for(let t of this.elements)t.destroy()}}class ss{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":""),function(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}(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 t=r;t<this.markers.length;t++)if(this.markers[t].compare(h)){o=t,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,[])}}const rs=n.r$.define(),os=n.r$.define({combine:t=>(0,n.BO)(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,e){let i=Object.assign({},t);for(let t in e){let n=i[t],s=e[t];i[t]=n?(t,e,i)=>n(t,e,i)||s(t,e,i):s}return i}})});class hs extends Un{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function ls(t,e){return t.state.facet(os).formatNumber(e,t.state)}const as=Xn.compute([os],(t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:t=>t.state.facet(rs),lineMarker:(t,e,i)=>i.some((t=>t.toDOM))?null:new hs(ls(t,t.state.doc.lineAt(e.from).number)),widgetMarker:()=>null,lineMarkerChange:t=>t.startState.facet(os)!=t.state.facet(os),initialSpacer:t=>new hs(ls(t,us(t.state.doc.lines))),updateSpacer(t,e){let i=ls(e.view,us(e.view.state.doc.lines));return i==t.number?t:new hs(i)},domEventHandlers:t.facet(os).domEventHandlers})));function cs(t={}){return[os.of(t),Qn(),as]}function us(t){let e=9;for(;e<t;)e=10*e+9;return e}},35905:(t,e,i)=>{i.d(e,{pJ:()=>J});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 i of t.props)if(Array.isArray(i)||(i=i(n)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[i[0].id]=i[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;!function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"}(c||(c={}));class u{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 t of this.children){let i=t.toString();i&&(e&&(e+=","),e+=i)}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 w(this,0,0,null)}resolve(t,e=0){let i=m(l.get(this)||this.topNode,t,e,!1);return l.set(this,i),i}resolveInner(t,e=0){let i=m(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 t=this.cursor(r|c.IncludeAnonymous);;){let r=!1;if(t.from<=s&&t.to>=n&&(!o&&t.type.isAnonymous||!1!==e(t))){if(t.firstChild())continue;r=!0}for(;r&&i&&(o||!t.type.isAnonymous)&&i(t),!t.nextSibling();){if(!t.parent())return;r=!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:C(h.none,this.children,this.positions,0,this.children.length,0,this.length,((t,e,i)=>new u(this.type,t,e,i,this.propValues)),t.makeTree||((t,e,i)=>new u(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 f(i,i.length):i,c=s.types,p=0,g=0;function m(t,e,i,n,r){let{id:u,start:f,end:k,size:S}=a,A=g;for(;S<0;){if(a.next(),-1==S){let e=h[u];return i.push(e),void n.push(f-t)}if(-3==S)return void(p=u);if(-4==S)return void(g=u);throw new RangeError(`Unrecognized record size: ${S}`)}let M,O,T=c[u],D=f-t;if(k-f<=o&&(O=b(a.pos-e,r))){let e=new Uint16Array(O.size-O.skip),i=a.pos-O.size,n=e.length;for(;a.pos>i;)n=x(O.start,e,n);M=new d(e,k-O.start,s),D=O.start-t}else{let t=a.pos-S;a.next();let e=[],i=[],n=u>=l?u:-1,s=0,r=k;for(;a.pos>t;)n>=0&&a.id==n&&a.size>=0?(a.end<=r-o&&(v(e,i,f,s,a.end,r,n,A),s=e.length,r=a.end),a.next()):m(f,t,e,i,n);if(n>=0&&s>0&&s<e.length&&v(e,i,f,s,f,r,n,A),e.reverse(),i.reverse(),n>-1&&s>0){let t=w(T);M=C(T,e,i,0,e.length,0,k-f,t,t)}else M=y(T,e,i,k-f,A-k)}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 u){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(p){let t=[r.contextHash,p];o=o?[t].concat(o):[t]}if(s>25){let t=[r.lookAhead,s];o=o?[t].concat(o):[t]}return new u(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?p=n:-4==o&&(g=n);return i}let k=[],S=[];for(;a.pos>0;)m(t.start||0,t.bufferStart||0,k,S,-1);let A=null!==(e=t.length)&&void 0!==e?e:k.length?S[0]+k[0].length:0;return new u(c[t.topID],k.reverse(),S.reverse(),A)}(t)}}u.empty=new u(h.none,[],[],0);class f{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 f(this.buffer,this.index)}}class d{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 d(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 g(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 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 w&&t.index<0?null:t.parent;if(!e)return t;t=e}let r=n?0:c.IgnoreOverlays;if(n)for(let n=t,o=n.parent;o;n=o,o=n.parent)n instanceof w&&n.index<0&&(null===(s=o.enter(e,i,r))||void 0===s?void 0:s.from)!=n.from&&(t=o);for(;;){let n=t.enter(e,i,r);if(!n)return t;t=n}}class w{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 d){if(s&c.ExcludeBuffers)continue;let r=a.findChild(0,a.buffer.length,e,i-u,n);if(r>-1)return new x(new b(o,a,t,u),null,r)}else if(s&c.IncludeAnonymous||!a.type.isAnonymous||S(a)){let h;if(!(s&c.IgnoreMounts)&&a.props&&(h=a.prop(r.mounted))&&!h.overlay)return new w(h.tree,u,t,o);let l=new w(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 w(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 m(this,t,e,!1)}resolveInner(t,e=0){return m(this,t,e,!0)}enterUnfinishedNodesBefore(t){return g(this,t)}getChild(t,e=null,i=null){let n=v(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return v(this,t,e,i)}toString(){return this._tree.toString()}get node(){return this}matchContext(t){return y(this,t)}}function v(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 y(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 b{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}}class x{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 x(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 x(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 x(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 x(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 u(this.type,t,e,this.to-this.from)}resolve(t,e=0){return m(this,t,e,!1)}resolveInner(t,e=0){return m(this,t,e,!0)}enterUnfinishedNodesBefore(t){return g(this,t)}toString(){return this.context.buffer.childString(this.index)}getChild(t,e=null,i=null){let n=v(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return v(this,t,e,i)}get node(){return this}matchContext(t){return y(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 w)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 w?(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 d||!t.type.isAnonymous||S(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 t=i;t<this.stack.length;t++)e=new x(this.buffer,e,this.stack[t]);return this.bufferNode=new x(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 y(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 y(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 S(t){return t.children.some((t=>t instanceof d||!t.type.isAnonymous||S(t)))}const A=new WeakMap;function M(t,e){if(!t.isAnonymous||e instanceof d||e.type!=t)return 1;let i=A.get(e);if(null==i){i=1;for(let n of e.children){if(n.type!=t||!(n instanceof u)){i=1;break}i+=M(t,n)}A.set(e,i)}return i}function C(t,e,i,n,s,r,o,h,l){let a=0;for(let i=n;i<s;i++)a+=M(t,e[i]);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],p=M(t,i[a]);for(a++;a<o;a++){let e=M(t,i[a]);if(p+e>=c)break;p+=e}if(a==s+1){if(p>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(C(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 O=0;class T{constructor(t,e,i){this.set=t,this.base=e,this.modified=i,this.id=O++}static define(t){if(null==t?void 0:t.base)throw new Error("Can not derive from a modified tag");let e=new T([],null,[]);if(e.set.push(e),t)for(let i of t.set)e.set.push(i);return e}static defineModifier(){let t=new E;return e=>e.modified.indexOf(t)>-1?e:E.get(e.base||e,e.modified.concat(t).sort(((t,e)=>t.id-e.id)))}}let D=0;class E{constructor(){this.instances=[],this.id=D++}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 T(n,t,e);for(let t of e)t.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 e of t.set)if(!e.modified.length)for(let t of r)n.push(E.get(e,t));return s}}new r;class B{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}}B.empty=new B([],2,null);const R=T.define,P=R(),I=R(),N=R(I),L=R(I),V=R(),H=R(V),W=R(V),_=R(),z=R(_),F=R(),q=R(),j=R(),K=R(j),$=R(),J={comment:P,lineComment:R(P),blockComment:R(P),docComment:R(P),name:I,variableName:R(I),typeName:N,tagName:R(N),propertyName:L,attributeName:R(L),className:R(I),labelName:R(I),namespace:R(I),macroName:R(I),literal:V,string:H,docString:R(H),character:R(H),attributeValue:R(H),number:W,integer:R(W),float:R(W),bool:R(V),regexp:R(V),escape:R(V),color:R(V),url:R(V),keyword:F,self:R(F),null:R(F),atom:R(F),unit:R(F),modifier:R(F),operatorKeyword:R(F),controlKeyword:R(F),definitionKeyword:R(F),moduleKeyword:R(F),operator:q,derefOperator:R(q),arithmeticOperator:R(q),logicOperator:R(q),bitwiseOperator:R(q),compareOperator:R(q),updateOperator:R(q),definitionOperator:R(q),typeOperator:R(q),controlOperator:R(q),punctuation:j,separator:R(j),bracket:K,angleBracket:R(K),squareBracket:R(K),paren:R(K),brace:R(K),content:_,heading:z,heading1:R(z),heading2:R(z),heading3:R(z),heading4:R(z),heading5:R(z),heading6:R(z),contentSeparator:R(_),list:R(_),quote:R(_),emphasis:R(_),strong:R(_),link:R(_),monospace:R(_),strikethrough:R(_),inserted:R(),deleted:R(),changed:R(),invalid:R(),meta:$,documentMeta:R($),annotation:R($),processingInstruction:R($),definition:T.defineModifier(),constant:T.defineModifier(),function:T.defineModifier(),standard:T.defineModifier(),local:T.defineModifier(),special:T.defineModifier()};!function(t,e){let i=Object.create(null);for(let e of t)if(Array.isArray(e.tag))for(let t of e.tag)i[t.id]=e.class;else i[e.tag.id]=e.class;let{scope:n,all:s=null}=e||{}}([{tag:J.link,class:"tok-link"},{tag:J.heading,class:"tok-heading"},{tag:J.emphasis,class:"tok-emphasis"},{tag:J.strong,class:"tok-strong"},{tag:J.keyword,class:"tok-keyword"},{tag:J.atom,class:"tok-atom"},{tag:J.bool,class:"tok-bool"},{tag:J.url,class:"tok-url"},{tag:J.labelName,class:"tok-labelName"},{tag:J.inserted,class:"tok-inserted"},{tag:J.deleted,class:"tok-deleted"},{tag:J.literal,class:"tok-literal"},{tag:J.string,class:"tok-string"},{tag:J.number,class:"tok-number"},{tag:[J.regexp,J.escape,J.special(J.string)],class:"tok-string2"},{tag:J.variableName,class:"tok-variableName"},{tag:J.local(J.variableName),class:"tok-variableName tok-local"},{tag:J.definition(J.variableName),class:"tok-variableName tok-definition"},{tag:J.special(J.variableName),class:"tok-variableName2"},{tag:J.definition(J.propertyName),class:"tok-propertyName tok-definition"},{tag:J.typeName,class:"tok-typeName"},{tag:J.namespace,class:"tok-namespace"},{tag:J.className,class:"tok-className"},{tag:J.macroName,class:"tok-macroName"},{tag:J.propertyName,class:"tok-propertyName"},{tag:J.operator,class:"tok-operator"},{tag:J.comment,class:"tok-comment"},{tag:J.meta,class:"tok-meta"},{tag:J.invalid,class:"tok-invalid"},{tag:J.punctuation,class:"tok-punctuation"}])},28450:(t,e,i)=>{i.d(e,{V:()=>o});const n="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),s="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class o{constructor(t,e){this.rules=[];let{finish:i}=e||{};function n(t){return/^@/.test(t)?[t]:t.split(/,\s*/)}function s(t,e,r,o){let h=[],l=/^@(\w+)\b/.exec(t[0]),a=l&&"keyframes"==l[1];if(l&&null==e)return r.push(t[0]+";");for(let i in e){let o=e[i];if(/&/.test(i))s(i.split(/,\s*/).map((e=>t.map((t=>e.replace(/&/,t))))).reduce(((t,e)=>t.concat(e))),o,r);else if(o&&"object"==typeof o){if(!l)throw new RangeError("The value of a property ("+i+") should be a primitive value.");s(n(i),o,h,a)}else null!=o&&h.push(i.replace(/_.*/,"").replace(/[A-Z]/g,(t=>"-"+t.toLowerCase()))+": "+o+";")}(h.length||a)&&r.push((!i||l||o?t:t.map(i)).join(", ")+" {"+h.join(" ")+"}")}for(let e in t)s(n(e),t[e],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let t=r[n]||1;return r[n]=t+1,"ͼ"+t.toString(36)}static mount(t,e){(t[s]||new l(t)).mount(Array.isArray(e)?e:[e])}}let h=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}}}},29350:(t,e,i)=>{i.d(e,{YG:()=>a,uY:()=>s,ue:()=>n});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=2562.5ziDUy8KqmY.js.map