"use strict";(globalThis.webpackChunktemplately||=[]).push([[903],{4216(e,t,n){n.d(t,{wm:()=>J,yU:()=>ue});var i=n(2701),r=n(9747),o=n(6684);class s{constructor(e,t,n,i){this.state=e,this.pos=t,this.explicit=n,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=(0,o.mv)(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),i=t.text.slice(n-t.from,this.pos-t.from),r=i.search(h(e,!1));return r<0?null:{from:n+r,to:this.pos,text:i.slice(r)}}get aborted(){return null==this.abortListeners}addEventListener(e,t,n){"abort"==e&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}}function a(e){let t=Object.keys(e).join(""),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,"")),`[${n?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}class l{constructor(e,t,n,i){this.completion=e,this.source=t,this.match=n,this.score=i}}function c(e){return e.selection.main.from}function h(e,t){var n;let{source:i}=e,r=t&&"^"!=i[0],o="$"!=i[i.length-1];return r||o?new RegExp(`${r?"^":""}(?:${i})${o?"$":""}`,null!==(n=e.flags)&&void 0!==n?n:e.ignoreCase?"i":""):e}const u=i.YH.define();function d(e,t,n,r){let{main:o}=e.selection,s=n-o.from,a=r-o.from;return{...e.changeByRange(l=>{if(l!=o&&n!=r&&e.sliceDoc(l.from+s,l.from+a)!=e.sliceDoc(n,r))return{range:l};let c=e.toText(t);return{changes:{from:l.from+s,to:r==o.from?l.to:l.from+a,insert:c},range:i.OF.cursor(l.from+s+c.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const f=new WeakMap;function p(e){if(!Array.isArray(e))return e;let t=f.get(e);return t||f.set(e,t=function(e){let t=e.map(e=>"string"==typeof e?{label:e}:e),[n,i]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:function(e){let t=Object.create(null),n=Object.create(null);for(let{label:i}of e){t[i[0]]=!0;for(let e=1;e{let r=e.matchBefore(i);return r||e.explicit?{from:r?r.from:e.pos,options:t,validFor:n}:null}}(e)),t}const m=i.Pe.define(),g=i.Pe.define();class b{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t=48&&c<=57||c>=97&&c<=122?2:c>=65&&c<=90?1:0:(v=(0,i.MK)(c))!=v.toLowerCase()?1:v!=v.toUpperCase()?2:0;(!r||1==w&&g||0==y&&0!=w)&&(t[u]==c||n[u]==c&&(d=!0)?s[u++]=r:s.length&&(b=!1)),y=w,r+=(0,i.Fh)(c)}return u==l&&0==s[0]&&b?this.result((d?-200:0)-100,s,e):f==l&&0==p?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):a>-1?this.ret(-700-e.length,[a,a+this.pattern.length]):f==l?this.ret(-900-e.length,[p,m]):u==l?this.result((d?-200:0)-100-700+(b?0:-1100),s,e):2==t.length?null:this.result((r[0]?-700:0)-200-1100,r,e)}result(e,t,n){let r=[],o=0;for(let e of t){let t=e+(this.astral?(0,i.Fh)((0,i.vS)(n,e)):1);o&&r[o-1]==e?r[o-1]=t:(r[o++]=e,r[o++]=t)}return this.ret(e-n.length,r)}}class y{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length(0,i.QR)(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:k,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>w(e(n),t(n)),optionClass:(e,t)=>n=>w(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})});function w(e,t){return e?t?e+" "+t:e:t}function k(e,t,n,i,o,s){let a,l,c=e.textDirection==r.OP.RTL,h=c,u=!1,d="top",f=t.left-o.left,p=o.right-t.right,m=i.right-i.left,g=i.bottom-i.top;if(h&&f=g||e>t.top?a=n.bottom-t.top:(d="bottom",a=t.bottom-n.top)}return{style:`${d}: ${a/((t.bottom-t.top)/s.offsetHeight)}px; max-width: ${l/((t.right-t.left)/s.offsetWidth)}px`,class:"cm-completionInfo-"+(u?c?"left-narrow":"right-narrow":h?"left":"right")}}const x=i.Pe.define();function S(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let i=Math.ceil((e-t)/n);return{from:e-i*n,to:e-(i-1)*n}}class C{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass="";let i=e.state.field(t),{options:r,selected:o}=i.open,s=e.state.facet(v);this.optionContent=function(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement("div");return t.classList.add("cm-completionIcon"),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>"cm-completionIcon-"+e)),t.setAttribute("aria-hidden","true"),t},position:20}),t.push({render(e,t,n,i){let r=document.createElement("span");r.className="cm-completionLabel";let o=e.displayLabel||e.label,s=0;for(let e=0;es&&r.appendChild(document.createTextNode(o.slice(s,t)));let a=r.appendChild(document.createElement("span"));a.appendChild(document.createTextNode(o.slice(t,n))),a.className="cm-completionMatchedText",s=n}return se.position-t.position).map(e=>e.render)}(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=S(r.length,o,s.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",n=>{let{options:i}=e.state.field(t).open;for(let t,r=n.target;r&&r!=this.dom;r=r.parentNode)if("LI"==r.nodeName&&(t=/-(\d+)$/.exec(r.id))&&+t[1]this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;null!=t&&(e.dispatch({effects:x.of(t)}),n.preventDefault())}}),this.dom.addEventListener("focusout",t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(v).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:g.of(null)})}),this.showOptions(r,i.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let n=e.state.field(this.stateField),i=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),n!=i){let{options:r,selected:o,disabled:s}=n.open;i.open&&i.open.options==r||(this.range=S(r.length,o,e.state.facet(v).maxRenderedOptions),this.showOptions(r,n.id)),this.updateSel(),s!=(null===(t=i.open)||void 0===t?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!s)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(" "))e&&this.dom.classList.remove(e);for(let e of t.split(" "))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected=this.range.to)&&(this.range=S(t.options.length,t.selected,this.view.state.facet(v).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:i}=t.options[t.selected],{info:o}=i;if(!o)return;let s="string"==typeof o?document.createTextNode(o):o(i);if(!s)return;"then"in s?s.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,i)}).catch(e=>(0,r.c_)(this.view.state,e,"completion info")):(this.addInfoPane(s,i),n.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",n.id="cm-completionInfo-"+Math.floor(65535*Math.random()).toString(16),null!=e.nodeType)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:i}=e;n.appendChild(t),this.infoDestroy=i||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,i=this.range.from;n;n=n.nextSibling,i++)"LI"==n.nodeName&&n.id?i==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),t=n):n.hasAttribute("aria-selected")&&(n.removeAttribute("aria-selected"),n.removeAttribute("aria-describedby")):i--;return t&&function(e,t){let n=e.getBoundingClientRect(),i=t.getBoundingClientRect(),r=n.height/e.offsetHeight;i.topn.bottom&&(e.scrollTop+=(i.bottom-n.bottom)/r)}(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),i=e.getBoundingClientRect(),r=this.space;if(!r){let e=this.dom.ownerDocument.documentElement;r={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return i.top>Math.min(r.bottom,t.bottom)-10||i.bottom{e.target==i&&e.preventDefault()});let r=null;for(let o=n.from;on.from||0==n.from)&&(r=e,"string"!=typeof l&&l.header?i.appendChild(l.header(l)):i.appendChild(document.createElement("completion-section")).textContent=e)}const c=i.appendChild(document.createElement("li"));c.id=t+"-"+o,c.setAttribute("role","option");let h=this.optionClass(s);h&&(c.className=h);for(let e of this.optionContent){let t=e(s,this.view.state,this.view,a);t&&c.appendChild(t)}}return n.from&&i.classList.add("cm-completionListIncompleteTop"),n.tonew C(n,e,t)}function M(e){return 100*(e.boost||0)+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}class T{constructor(e,t,n,i,r,o){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=i,this.selected=r,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new T(this.options,z(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,i,r,o){if(i&&!o&&e.some(e=>e.isPending))return i.setDisabled();let s=function(e,t){let n=[],i=null,r=null,o=e=>{n.push(e);let{section:t}=e.completion;if(t){i||(i=[]);let e="string"==typeof t?t:t.name;i.some(t=>t.name==e)||i.push("string"==typeof t?{name:e}:t)}},s=t.facet(v);for(let i of e)if(i.hasResult()){let e=i.result.getMatch;if(!1===i.result.filter)for(let t of i.result.options)o(new l(t,i.source,e?e(t):[],1e9-n.length));else{let n,a=t.sliceDoc(i.from,i.to),c=s.filterStrict?new y(a):new b(a);for(let t of i.result.options)if(n=c.match(t.label)){let s=t.displayLabel?e?e(t,n.matched):[]:n.matched,a=n.score+(t.boost||0);if(o(new l(t,i.source,s,a)),"object"==typeof t.section&&"dynamic"===t.section.rank){let{name:e}=t.section;r||(r=Object.create(null)),r[e]=Math.max(a,r[e]||-1e9)}}}}if(i){let e=Object.create(null),t=0,o=(e,t)=>("dynamic"===e.rank&&"dynamic"===t.rank?r[t.name]-r[e.name]:0)||("number"==typeof e.rank?e.rank:1e9)-("number"==typeof t.rank?t.rank:1e9)||(e.namet.score-e.score||h(e.completion,t.completion))){let t=e.completion;!c||c.label!=t.label||c.detail!=t.detail||null!=c.type&&null!=t.type&&c.type!=t.type||c.apply!=t.apply||c.boost!=t.boost?a.push(e):M(e.completion)>M(c)&&(a[a.length-1]=e),c=e.completion}return a}(e,t);if(!s.length)return i&&e.some(e=>e.isPending)?i.setDisabled():null;let a=t.facet(v).selectOnOpen?0:-1;if(i&&i.selected!=a&&-1!=i.selected){let e=i.options[i.selected].completion;for(let t=0;tt.hasResult()?Math.min(e,t.from):e,1e8),create:W,above:r.aboveCursor},i?i.timestamp:Date.now(),a,!1)}map(e){return new T(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new T(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class O{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new O(E,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(e){let{state:t}=e,n=t.facet(v),i=(n.override||t.languageDataAt("autocomplete",c(t)).map(p)).map(t=>(this.active.find(e=>e.source==t)||new R(t,this.active.some(e=>0!=e.state)?1:0)).update(e,n));i.length==this.active.length&&i.every((e,t)=>e==this.active[t])&&(i=this.active);let r=this.open,o=e.effects.some(e=>e.is(I));r&&e.docChanged&&(r=r.map(e.changes)),e.selection||i.some(t=>t.hasResult()&&e.changes.touchesRange(t.from,t.to))||!function(e,t){if(e==t)return!0;for(let n=0,i=0;;){for(;ne.isPending)&&(r=null),!r&&i.every(e=>!e.isPending)&&i.some(e=>e.hasResult())&&(i=i.map(e=>e.hasResult()?new R(e.source,0):e));for(let t of e.effects)t.is(x)&&(r=r&&r.setSelected(t.value,this.id));return i==this.active&&r==this.open?this:new O(i,this.id,r)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?D:L}}const D={"aria-autocomplete":"list"},L={};function z(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const E=[];function B(e,t){if(e.isUserEvent("input.complete")){let n=e.annotation(u);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent("input.type");return n&&t.activateOnTyping?5:n?1:e.isUserEvent("delete.backward")?2:e.selection?8:e.docChanged?16:0}class R{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return 1==this.state}update(e,t){let n=B(e,t),i=this;(8&n||16&n&&this.touches(e))&&(i=new R(i.source,0)),4&n&&0==i.state&&(i=new R(this.source,1)),i=i.updateFor(e,n);for(let t of e.effects)if(t.is(m))i=new R(i.source,1,t.value);else if(t.is(g))i=new R(i.source,0);else if(t.is(I))for(let e of t.value)e.source==i.source&&(i=e);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(c(e.state))}}class P extends R{constructor(e,t,n,i,r,o){super(e,3,t),this.limit=n,this.result=i,this.from=r,this.to=o}hasResult(){return!0}updateFor(e,t){var n;if(!(3&t))return this.map(e.changes);let i=this.result;i.map&&!e.changes.empty&&(i=i.map(i,e.changes));let r=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),a=c(e.state);if(a>o||!i||2&t&&(c(e.startState)==this.from||ae.map(e=>e.map(t))}),N=i.sU.define({create:()=>O.start(),update:(e,t)=>e.update(t),provide:e=>[r.DK.from(e,e=>e.tooltip),r.Lz.contentAttributes.from(e,e=>e.attrs)]});function F(e,t){const n=t.completion.apply||t.completion.label;let i=e.state.field(N).active.find(e=>e.source==t.source);return i instanceof P&&("string"==typeof n?e.dispatch({...d(e.state,n,i.from,i.to),annotations:u.of(t.completion)}):n(e,t.completion,i.from,i.to),!0)}const W=A(N,F);function H(e,t="option"){return n=>{let i=n.state.field(N,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp-1?i.open.selected+s*(e?1:-1):e?0:a-1;return l<0?l="page"==t?0:a-1:l>=a&&(l="page"==t?a-1:0),n.dispatch({effects:x.of(l)}),!0}}const q=e=>!!e.state.field(N,!1)&&(e.dispatch({effects:m.of(!0)}),!0);class V{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const j=r.Z9.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(N).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(N),n=e.state.facet(v);if(!e.selectionSet&&!e.docChanged&&e.startState.field(N)==t)return;let i=e.transactions.some(e=>{let t=B(e,n);return 8&t||(e.selection||e.docChanged)&&!(3&t)});for(let t=0;t50&&Date.now()-n.time>1e3){for(let e of n.context.abortListeners)try{e()}catch(e){(0,r.c_)(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(m)))&&(this.pendingStart=!0);let o=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),o):-1,0!=this.composing)for(let t of e.transactions)t.isUserEvent("input.type")?this.composing=2:2==this.composing&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(N);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(v).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=c(t),i=new s(t,n,e.explicit,this.view),o=new V(e,i);this.running.push(o),Promise.resolve(e.source(i)).then(e=>{o.context.aborted||(o.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:g.of(null)}),(0,r.c_)(this.view.state,e)})}scheduleAccept(){this.running.every(e=>void 0!==e.done)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(v).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(v),i=this.view.state.field(N);for(let r=0;re.source==o.active.source);if(s&&s.isPending)if(null==o.done){let e=new R(o.active.source,0);for(let t of o.updates)e=e.update(t,n);e.isPending||t.push(e)}else this.startQuery(s)}(t.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:I.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(N,!1);if(t&&t.tooltip&&this.view.state.facet(v).closeOnBlur){let n=t.open&&(0,r.Eg)(this.view,t.open.tooltip);n&&n.dom.contains(e.relatedTarget)||setTimeout(()=>this.view.dispatch({effects:g.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout(()=>this.view.dispatch({effects:m.of(!1)}),20),this.composing=0}}}),K="object"==typeof navigator&&/Win/.test(navigator.platform),_=i.Nb.highest(r.Lz.domEventHandlers({keydown(e,t){let n=t.state.field(N,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&(!K||!e.altKey)||e.metaKey)return!1;let i=n.open.options[n.open.selected],r=n.active.find(e=>e.source==i.source),o=i.completion.commitCharacters||r.result.commitCharacters;return o&&o.indexOf(e.key)>-1&&F(t,i),!1}})),U=r.Lz.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",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),$={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Y=i.Pe.define({map:(e,t)=>t.mapPos(e,-1,i.iR.TrackAfter)??void 0}),G=new class extends i.FB{};G.startSide=1,G.endSide=-1;const X=i.sU.define({create:()=>i.om.empty,update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:e=>e>=n.from&&e<=n.to})}for(let n of t.effects)n.is(Y)&&(e=e.update({add:[G.range(n.value,n.value+1)]}));return e}});function J(){return[ne,X]}const Z="()[]{}<>«»»«[]{}";function Q(e){for(let t=0;t<16;t+=2)if(Z.charCodeAt(t)==e)return Z.charAt(t+1);return(0,i.MK)(e<128?e:e+1)}function ee(e,t){return e.languageDataAt("closeBrackets",t)[0]||$}const te="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),ne=r.Lz.inputHandler.of((e,t,n,r)=>{if((te?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let o=e.state.selection.main;if(r.length>2||2==r.length&&1==(0,i.Fh)((0,i.vS)(r,0))||t!=o.from||n!=o.to)return!1;let s=function(e,t){let n=ee(e,e.selection.main.head),r=n.brackets||$.brackets;for(let o of r){let s=Q((0,i.vS)(o,0));if(t==o)return s==o?le(e,o,r.indexOf(o+o+o)>-1,n):se(e,o,s,n.before||$.before);if(t==s&&re(e,e.selection.main.from))return ae(e,0,s)}return null}(e.state,r);return!!s&&(e.dispatch(s),!0)}),ie=[{key:"Backspace",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=ee(e,e.selection.main.head).brackets||$.brackets,r=null,o=e.changeByRange(t=>{if(t.empty){let r=function(e,t){let n=e.sliceString(t-2,t);return(0,i.Fh)((0,i.vS)(n,0))==n.length?n:n.slice(1)}(e.doc,t.head);for(let o of n)if(o==r&&oe(e.doc,t.head)==Q((0,i.vS)(o,0)))return{changes:{from:t.head-o.length,to:t.head+o.length},range:i.OF.cursor(t.head-o.length)}}return{range:r=t}});return r||t(e.update(o,{scrollIntoView:!0,userEvent:"delete.backward"})),!r}}];function re(e,t){let n=!1;return e.field(X).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function oe(e,t){let n=e.sliceString(t,t+2);return n.slice(0,(0,i.Fh)((0,i.vS)(n,0)))}function se(e,t,n,r){let o=null,s=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:n,from:s.to}],effects:Y.of(s.to+t.length),range:i.OF.range(s.anchor+t.length,s.head+t.length)};let a=oe(e.doc,s.head);return!a||/\s/.test(a)||r.indexOf(a)>-1?{changes:{insert:t+n,from:s.head},effects:Y.of(s.head+t.length),range:i.OF.cursor(s.head+t.length)}:{range:o=s}});return o?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function ae(e,t,n){let r=null,o=e.changeByRange(t=>t.empty&&oe(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:i.OF.cursor(t.head+n.length)}:r={range:t});return r?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function le(e,t,n,r){let s=r.stringPrefixes||$.stringPrefixes,a=null,l=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:t,from:r.to}],effects:Y.of(r.to+t.length),range:i.OF.range(r.anchor+t.length,r.head+t.length)};let l,c=r.head,h=oe(e.doc,c);if(h==t){if(ce(e,c))return{changes:{insert:t+t,from:c},effects:Y.of(c+t.length),range:i.OF.cursor(c+t.length)};if(re(e,c)){let r=n&&e.sliceDoc(c,c+3*t.length)==t+t+t?t+t+t:t;return{changes:{from:c,to:c+r.length,insert:r},range:i.OF.cursor(c+r.length)}}}else{if(n&&e.sliceDoc(c-2*t.length,c)==t+t&&(l=he(e,c-2*t.length,s))>-1&&ce(e,l))return{changes:{insert:t+t+t+t,from:c},effects:Y.of(c+t.length),range:i.OF.cursor(c+t.length)};if(e.charCategorizer(c)(h)!=i.Je.Word&&he(e,c,s)>-1&&!function(e,t,n,i){let r=(0,o.mv)(e).resolveInner(t,-1),s=i.reduce((e,t)=>Math.max(e,t.length),0);for(let o=0;o<5;o++){let o=e.sliceDoc(r.from,Math.min(r.to,r.from+n.length+s)),a=o.indexOf(n);if(!a||a>-1&&i.indexOf(o.slice(0,a))>-1){let t=r.firstChild;for(;t&&t.from==r.from&&t.to-t.from>n.length+a;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let l=r.to==t&&r.parent;if(!l)break;r=l}return!1}(e,c,t,s))return{changes:{insert:t+t,from:c},effects:Y.of(c+t.length),range:i.OF.cursor(c+t.length)}}return{range:a=r}});return a?null:e.update(l,{scrollIntoView:!0,userEvent:"input.type"})}function ce(e,t){let n=(0,o.mv)(e).resolveInner(t+1);return n.parent&&n.from==t}function he(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=i.Je.Word)return t;for(let o of n){let n=t-o.length;if(e.sliceDoc(n,t)==o&&r(e.sliceDoc(n-1,n))!=i.Je.Word)return n}return-1}function ue(e={}){return[_,N,v.of(e),j,fe,U]}const de=[{key:"Ctrl-Space",run:q},{mac:"Alt-`",run:q},{mac:"Alt-i",run:q},{key:"Escape",run:e=>{let t=e.state.field(N,!1);return!(!t||!t.active.some(e=>0!=e.state)||(e.dispatch({effects:g.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:e=>{let t=e.state.field(N,!1);return!(e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestampe.facet(v).defaultKeymap?[de]:[]));n.d(t,["Bc",0,ie,"OO",0,de])},4658(e,t,n){n.d(t,{b6:()=>v});var i=n(2701),r=n(9747),o=n(6684),s=n(6411);function a(e,t){return({state:n,dispatch:i})=>{if(n.readOnly)return!1;let r=e(t,n);return!!r&&(i(n.update(r)),!0)}}const l=a(f,0),c=a(d,0),h=a((e,t)=>d(e,t,function(e){let t=[];for(let n of e.selection.ranges){let i=e.doc.lineAt(n.from),r=n.to<=i.to?i:e.doc.lineAt(n.to);r.from>i.from&&r.from==n.to&&(r=n.to==i.to+1?i:e.doc.lineAt(n.to-1));let o=t.length-1;o>=0&&t[o].to>i.from?t[o].to=r.to:t.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:r.to})}return t}(t)),0);function u(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}function d(e,t,n=t.selection.ranges){let i=n.map(e=>u(t,e.from).block);if(!i.every(e=>e))return null;let r=n.map((e,n)=>function(e,{open:t,close:n},i,r){let o,s,a=e.sliceDoc(i-50,i),l=e.sliceDoc(r,r+50),c=/\s*$/.exec(a)[0].length,h=/^\s*/.exec(l)[0].length,u=a.length-c;if(a.slice(u-t.length,u)==t&&l.slice(h,h+n.length)==n)return{open:{pos:i-c,margin:c&&1},close:{pos:r+h,margin:h&&1}};r-i<=100?o=s=e.sliceDoc(i,r):(o=e.sliceDoc(i,i+50),s=e.sliceDoc(r-50,r));let d=/^\s*/.exec(o)[0].length,f=/\s*$/.exec(s)[0].length,p=s.length-f-n.length;return o.slice(d,d+t.length)==t&&s.slice(p,p+n.length)==n?{open:{pos:i+d+t.length,margin:/\s/.test(o.charAt(d+t.length))?1:0},close:{pos:r-f-n.length,margin:/\s/.test(s.charAt(p-1))?1:0}}:null}(t,i[n],e.from,e.to));if(2!=e&&!r.every(e=>e))return{changes:t.changes(n.map((e,t)=>r[t]?[]:[{from:e.from,insert:i[t].open+" "},{from:e.to,insert:" "+i[t].close}]))};if(1!=e&&r.some(e=>e)){let e=[];for(let t,n=0;nr&&(e==o||o>l.from)){r=l.from;let e=/^\s*/.exec(l.text)[0].length,t=e==l.length,o=l.text.slice(e,e+n.length)==n?e:-1;ee.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:r,empty:o,single:s}of i)!s&&o||e.push({from:t.from+r,insert:n+" "});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(1!=e&&i.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:r}of i)if(n>=0){let i=t.from+n,o=i+r.length;" "==t.text[o-t.from]&&o++,e.push({from:i,to:o})}return{changes:e}}return null}const p=i.YH.define(),m=i.YH.define(),g=i.sj.define(),b=i.sj.define({combine:e=>(0,i.QR)(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,i)=>e(n,i)||t(n,i)})}),y=i.sU.define({create:()=>R.empty,update(e,t){let n=t.state.facet(b),r=t.annotation(p);if(r){let i=A.fromTransaction(t,r.selection),o=r.side,s=0==o?e.undone:e.done;return s=i?M(s,s.length,n.minDepth,i):D(s,t.startState.selection),new R(0==o?r.rest:s,0==o?s:r.rest)}let o=t.annotation(m);if("full"!=o&&"before"!=o||(e=e.isolate()),!1===t.annotation(i.ZX.addToHistory))return t.changes.empty?e:e.addMapping(t.changes.desc);let s=A.fromTransaction(t),a=t.annotation(i.ZX.time),l=t.annotation(i.ZX.userEvent);return s?e=e.addChanges(s,a,l,n,t):t.selection&&(e=e.addSelection(t.startState.selection,a,l,n.newGroupDelay)),"full"!=o&&"after"!=o||(e=e.isolate()),e},toJSON:e=>({done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}),fromJSON:e=>new R(e.done.map(A.fromJSON),e.undone.map(A.fromJSON))});function v(e={}){return[y,b.of(e),r.Lz.domEventHandlers({beforeinput(e,t){let n="historyUndo"==e.inputType?k:"historyRedo"==e.inputType?x:null;return!!n&&(e.preventDefault(),n(t))}})]}function w(e,t){return function({state:n,dispatch:i}){if(!t&&n.readOnly)return!1;let r=n.field(y,!1);if(!r)return!1;let o=r.pop(e,n,t);return!!o&&(i(o),!0)}}const k=w(0,!1),x=w(1,!1),S=w(0,!0),C=w(1,!0);class A{constructor(e,t,n,i,r){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=i,this.selectionsAfter=r}setSelAfter(e){return new A(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:null===(e=this.changes)||void 0===e?void 0:e.toJSON(),mapped:null===(t=this.mapped)||void 0===t?void 0:t.toJSON(),startSelection:null===(n=this.startSelection)||void 0===n?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(e){return new A(e.changes&&i.VR.fromJSON(e.changes),[],e.mapped&&i.Gu.fromJSON(e.mapped),e.startSelection&&i.OF.fromJSON(e.startSelection),e.selectionsAfter.map(i.OF.fromJSON))}static fromTransaction(e,t){let n=O;for(let t of e.startState.facet(g)){let i=t(e);i.length&&(n=n.concat(i))}return!n.length&&e.changes.empty?null:new A(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,O)}static selection(e){return new A(void 0,O,void 0,void 0,e)}}function M(e,t,n,i){let r=t+1>n+20?t-n-1:0,o=e.slice(r,t);return o.push(i),o}function T(e,t){return e.length?t.length?e.concat(t):e:t}const O=[];function D(e,t){if(e.length){let n=e[e.length-1],i=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-200));return i.length&&i[i.length-1].eq(t)?e:(i.push(t),M(e,e.length-1,1e9,n.setSelAfter(i)))}return[A.selection([t])]}function L(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function z(e,t){if(!e.length)return e;let n=e.length,i=O;for(;n;){let r=E(e[n-1],t,i);if(r.changes&&!r.changes.empty||r.effects.length){let t=e.slice(0,n);return t[n-1]=r,t}t=r.mapped,n--,i=r.selectionsAfter}return i.length?[A.selection(i)]:O}function E(e,t,n){let r=T(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):O,n);if(!e.changes)return A.selection(r);let o=e.changes.map(t),s=t.mapDesc(e.changes,!0),a=e.mapped?e.mapped.composeDesc(s):s;return new A(o,i.Pe.mapEffects(e.effects,t),a,e.startSelection.map(s),r)}const B=/^(input\.type|delete)($|\.)/;class R{constructor(e,t,n=0,i=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=i}isolate(){return this.prevTime?new R(this.done,this.undone):this}addChanges(e,t,n,r,o){let s=this.done,a=s[s.length-1];return s=a&&a.changes&&!a.changes.empty&&e.changes&&(!n||B.test(n))&&(!a.selectionsAfter.length&&t-this.prevTimen.push(e,t)),t.iterChangedRanges((e,t,r,o)=>{for(let e=0;e=t&&r<=s&&(i=!0)}}),i}(a.changes,e.changes))||"input.type.compose"==n)?M(s,s.length-1,r.minDepth,new A(e.changes.compose(a.changes),T(i.Pe.mapEffects(e.effects,a.changes),a.effects),a.mapped,a.startSelection,O)):M(s,s.length,r.minDepth,e),new R(s,O,t,n)}addSelection(e,t,n,i){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:O;return r.length>0&&t-this.prevTimee.empty!=s.ranges[t].empty).length)?this:new R(D(this.done,e),this.undone,t,n);var o,s}addMapping(e){return new R(z(this.done,e),z(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let i=0==e?this.done:this.undone;if(0==i.length)return null;let r=i[i.length-1],o=r.selectionsAfter[0]||(r.startSelection?r.startSelection.map(r.changes.invertedDesc,1):t.selection);if(n&&r.selectionsAfter.length)return t.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:p.of({side:e,rest:L(i),selection:o}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let n=1==i.length?O:i.slice(0,i.length-1);return r.mapped&&(n=z(n,r.mapped)),t.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:p.of({side:e,rest:n,selection:o}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}return null}}R.empty=new R(O,O);const P=[{key:"Mod-z",run:k,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:x,preventDefault:!0},{linux:"Ctrl-Shift-z",run:x,preventDefault:!0},{key:"Mod-u",run:S,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:C,preventDefault:!0}];function I(e,t){return i.OF.create(e.ranges.map(t),e.mainIndex)}function N(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function F({state:e,dispatch:t},n){let i=I(e.selection,n);return!i.eq(e.selection,!0)&&(t(N(e,i)),!0)}function W(e,t){return i.OF.cursor(t?e.to:e.from)}function H(e,t){return F(e,n=>n.empty?e.moveByChar(n,t):W(n,t))}function q(e){return e.textDirectionAt(e.state.selection.main.head)==r.OP.LTR}const V=e=>H(e,!q(e)),j=e=>H(e,q(e));function K(e,t){return F(e,n=>n.empty?e.moveByGroup(n,t):W(n,t))}function _(e,t,n){if(t.type.prop(n))return!0;let i=t.to-t.from;return i&&(i>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function U(e,t,n){let r,a,l=(0,o.mv)(e).resolveInner(t.head),c=n?s.uY.closedBy:s.uY.openedBy;for(let i=t.head;;){let t=n?l.childAfter(i):l.childBefore(i);if(!t)break;_(e,t,c)?l=t:i=n?t.to:t.from}return a=l.type.prop(c)&&(r=n?(0,o.jU)(e,l.from,1):(0,o.jU)(e,l.to,-1))&&r.matched?n?r.end.to:r.end.from:n?l.to:l.from,i.OF.cursor(a,n?-1:1)}function $(e,t){return F(e,n=>{if(!n.empty)return W(n,t);let i=e.moveVertically(n,t);return i.head!=n.head?i:e.moveToLineBoundary(n,t)})}"undefined"!=typeof Intl&&Intl.Segmenter;const Y=e=>$(e,!1),G=e=>$(e,!0);function X(e){let t,n=e.scrollDOM.clientHeightn.empty?e.moveVertically(n,t,i.height):W(n,t));if(s.eq(o.selection))return!1;if(i.selfScroll){let t=e.coordsAtPos(o.selection.main.head),a=e.scrollDOM.getBoundingClientRect(),l=a.top+i.marginTop,c=a.bottom-i.marginBottom;t&&t.top>l&&t.bottomJ(e,!1),Q=e=>J(e,!0);function ee(e,t,n){let r=e.lineBlockAt(t.head),o=e.moveToLineBoundary(t,n);if(o.head==t.head&&o.head!=(n?r.to:r.from)&&(o=e.moveToLineBoundary(t,n,!1)),!n&&o.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(o=i.OF.cursor(r.from+n))}return o}function te(e,t,n){let r=I(e.state.selection,e=>{e.undirectional&&e.head>=e.anchor!=t&&(e=i.OF.range(e.head,e.anchor));let r=n(e);return i.OF.range(e.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return!r.eq(e.state.selection)&&(e.dispatch(N(e.state,r)),!0)}function ne(e,t){return te(e,t,n=>e.moveByChar(n,t))}const ie=e=>ne(e,!q(e)),re=e=>ne(e,q(e));function oe(e,t){return te(e,t,n=>e.moveByGroup(n,t))}function se(e,t){return te(e,t,n=>e.moveVertically(n,t))}const ae=e=>se(e,!1),le=e=>se(e,!0);function ce(e,t){return te(e,t,n=>e.moveVertically(n,t,X(e).height))}const he=e=>ce(e,!1),ue=e=>ce(e,!0),de=({state:e,dispatch:t})=>(t(N(e,{anchor:0})),!0),fe=({state:e,dispatch:t})=>(t(N(e,{anchor:e.doc.length})),!0),pe=({state:e,dispatch:t})=>(t(N(e,{anchor:e.selection.main.anchor,head:0})),!0),me=({state:e,dispatch:t})=>(t(N(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0);function ge(e,t){let{state:n}=e,r=n.selection,o=n.selection.ranges.slice();for(let i of n.selection.ranges){let r=n.doc.lineAt(i.head);if(t?r.to0)for(let n=i;;){let i=e.moveVertically(n,t);if(i.headr.to){o.some(e=>e.head==i.head)||o.push(i);break}if(i.head==n.head)break;n=i}}return o.length!=r.ranges.length&&(e.dispatch(N(n,i.OF.create(o,o.length-1))),!0)}function be(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:o}=e,s=o.changeByRange(r=>{let{from:o,to:s}=r;if(o==s){let i=t(r);io&&(n="delete.forward",i=ye(e,i,!0)),o=Math.min(o,i),s=Math.max(s,i)}else o=ye(e,o,!1),s=ye(e,s,!0);return o==s?{range:r}:{changes:{from:o,to:s},range:i.OF.cursor(o,ot(e)))i.between(t,t,(e,i)=>{et&&(t=n?i:e)});return t}const ve=(e,t,n)=>be(e,r=>{let s,a,l=r.from,{state:c}=e,h=c.doc.lineAt(l);if(n&&!t&&l>h.from&&lve(e,!1,!0),ke=e=>ve(e,!0,!1),xe=(e,t)=>be(e,n=>{let r=n.head,{state:o}=e,s=o.doc.lineAt(r),a=o.charCategorizer(r);for(let e=null;;){if(r==(t?s.to:s.from)){r==n.head&&s.number!=(t?o.doc.lines:1)&&(r+=t?1:-1);break}let l=(0,i.zK)(s.text,r-s.from,t)+s.from,c=s.text.slice(Math.min(r,l)-s.from,Math.max(r,l)-s.from),h=a(c);if(null!=e&&h!=e)break;" "==c&&r==n.head||(e=h),r=l}return r}),Se=e=>xe(e,!1);function Ce(e){let t=[],n=-1;for(let i of e.selection.ranges){let r=e.doc.lineAt(i.from),o=e.doc.lineAt(i.to);if(i.empty||i.to!=o.from||(o=e.doc.lineAt(i.to-1)),n>=r.number){let e=t[t.length-1];e.to=o.to,e.ranges.push(i)}else t.push({from:r.from,to:o.to,ranges:[i]});n=o.number+1}return t}function Ae(e,t,n){if(e.readOnly)return!1;let r=[],o=[];for(let t of Ce(e)){if(n?t.to==e.doc.length:0==t.from)continue;let s=e.doc.lineAt(n?t.to+1:t.from-1),a=s.length+1;if(n){r.push({from:t.to,to:s.to},{from:t.from,insert:s.text+e.lineBreak});for(let n of t.ranges)o.push(i.OF.range(Math.min(e.doc.length,n.anchor+a),Math.min(e.doc.length,n.head+a)))}else{r.push({from:s.from,to:t.from},{from:t.to,insert:e.lineBreak+s.text});for(let e of t.ranges)o.push(i.OF.range(e.anchor-a,e.head-a))}}return!!r.length&&(t(e.update({changes:r,scrollIntoView:!0,selection:i.OF.create(o,e.selection.mainIndex),userEvent:"move.line"})),!0)}function Me(e,t,n){if(e.readOnly)return!1;let i=[];for(let t of Ce(e))n?i.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):i.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let r=e.changes(i);return t(e.update({changes:r,selection:e.selection.map(r,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Te=Oe(!1);function Oe(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:a}=n,l=t.doc.lineAt(r),c=!e&&r==a&&function(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n,i=(0,o.mv)(e).resolveInner(t),r=i.childBefore(t),a=i.childAfter(t);return r&&a&&r.to<=t&&a.from>=t&&(n=r.type.prop(s.uY.closedBy))&&n.indexOf(a.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(a.from).from&&!/\S/.test(e.sliceDoc(r.to,a.from))?{from:r.to,to:a.from}:null}(t,r);e&&(r=a=(a<=l.to?l:t.doc.lineAt(a)).to);let h=new o.KB(t,{simulateBreak:r,simulateDoubleBreak:!!c}),u=(0,o._v)(h,r);for(null==u&&(u=(0,i.y$)(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize));al.from&&r{let o=[];for(let i=r.from;i<=r.to;){let s=e.doc.lineAt(i);s.number>n&&(r.empty||r.to>s.from)&&(t(s,o,r),n=s.number),i=s.to+1}let s=e.changes(o);return{changes:o,range:i.OF.range(s.mapPos(r.anchor,1),s.mapPos(r.head,1))}})}const Le=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(De(e,(t,n)=>{n.push({from:t.from,insert:e.facet(o.Xt)})}),{userEvent:"input.indent"})),!0),ze=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(De(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let s=(0,i.y$)(r,e.tabSize),a=0,l=(0,o.EI)(e,Math.max(0,s-(0,o.tp)(e)));for(;aF(e,t=>U(e.state,t,!q(e))),shift:e=>{let t=!q(e);return te(e,t,n=>U(e.state,n,t))}},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e=>F(e,t=>U(e.state,t,q(e))),shift:e=>{let t=q(e);return te(e,t,n=>U(e.state,n,t))}},{key:"Alt-ArrowUp",run:({state:e,dispatch:t})=>Ae(e,t,!1)},{key:"Shift-Alt-ArrowUp",run:({state:e,dispatch:t})=>Me(e,t,!1)},{key:"Alt-ArrowDown",run:({state:e,dispatch:t})=>Ae(e,t,!0)},{key:"Shift-Alt-ArrowDown",run:({state:e,dispatch:t})=>Me(e,t,!0)},{key:"Mod-Alt-ArrowUp",run:e=>ge(e,!1)},{key:"Mod-Alt-ArrowDown",run:e=>ge(e,!0)},{key:"Escape",run:({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=i.OF.create([n.main]):n.main.empty||(r=i.OF.create([i.OF.cursor(n.main.head)])),!!r&&(t(N(e,r)),!0)}},{key:"Mod-Enter",run:Oe(!0)},{key:"Alt-l",mac:"Ctrl-l",run:({state:e,dispatch:t})=>{let n=Ce(e).map(({from:t,to:n})=>i.OF.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:i.OF.create(n),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:e,dispatch:t})=>{let n=I(e.selection,t=>{let n=(0,o.mv)(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return i.OF.range(n.to,n.from)}return t});return!n.eq(e.selection)&&(t(N(e,n)),!0)},preventDefault:!0},{key:"Mod-[",run:ze},{key:"Mod-]",run:Le},{key:"Mod-Alt-\\",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),i=new o.KB(e,{overrideIndentation:e=>n[e]??-1}),r=De(e,(t,r,s)=>{let a=(0,o._v)(i,t.from);if(null==a)return;/\S/.test(t.text)||(a=0);let l=/^\s*/.exec(t.text)[0],c=(0,o.EI)(e,a);(l!=c||s.from{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(Ce(t).map(({from:e,to:n})=>(e>0?e--:n{let n;if(e.lineWrapping){let i=e.lineBlockAt(t.head),r=e.coordsAtPos(t.head,t.assoc||1);r&&(n=i.bottom+e.documentTop-r.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:e,dispatch:t})=>function(e,t,n){let r=!1,s=I(e.selection,t=>{let s=(0,o.jU)(e,t.head,-1)||(0,o.jU)(e,t.head,1)||t.head>0&&(0,o.jU)(e,t.head-1,1)||t.head{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),i=u(e.state,n.from);return i.line?l(e):!!i.block&&h(e)}},{key:"Alt-A",run:c},{key:"Ctrl-m",mac:"Shift-Alt-m",run:e=>(e.setTabFocusMode(),!0)}].concat([{key:"ArrowLeft",run:V,shift:ie,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:e=>K(e,!q(e)),shift:e=>oe(e,!q(e)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:e=>F(e,t=>ee(e,t,!q(e))),shift:e=>{let t=!q(e);return te(e,t,n=>ee(e,n,t))},preventDefault:!0},{key:"ArrowRight",run:j,shift:re,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:e=>K(e,q(e)),shift:e=>oe(e,q(e)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:e=>F(e,t=>ee(e,t,q(e))),shift:e=>{let t=q(e);return te(e,t,n=>ee(e,n,t))},preventDefault:!0},{key:"ArrowUp",run:Y,shift:ae,preventDefault:!0},{mac:"Cmd-ArrowUp",run:de,shift:pe},{mac:"Ctrl-ArrowUp",run:Z,shift:he},{key:"ArrowDown",run:G,shift:le,preventDefault:!0},{mac:"Cmd-ArrowDown",run:fe,shift:me},{mac:"Ctrl-ArrowDown",run:Q,shift:ue},{key:"PageUp",run:Z,shift:he},{key:"PageDown",run:Q,shift:ue},{key:"Home",run:e=>F(e,t=>ee(e,t,!1)),shift:e=>te(e,!1,t=>ee(e,t,!1)),preventDefault:!0},{key:"Mod-Home",run:de,shift:pe},{key:"End",run:e=>F(e,t=>ee(e,t,!0)),shift:e=>te(e,!0,t=>ee(e,t,!0)),preventDefault:!0},{key:"Mod-End",run:fe,shift:me},{key:"Enter",run:Te,shift:Te},{key:"Mod-a",run:({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:we,shift:we,preventDefault:!0},{key:"Delete",run:ke,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Se,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:e=>xe(e,!0),preventDefault:!0},{mac:"Mod-Backspace",run:e=>be(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),preventDefault:!0},{mac:"Mod-Delete",run:e=>be(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.headF(e,t=>i.OF.cursor(e.lineBlockAt(t.head).from,1)),shift:e=>te(e,!1,t=>i.OF.cursor(e.lineBlockAt(t.head).from))},{key:"Ctrl-e",run:e=>F(e,t=>i.OF.cursor(e.lineBlockAt(t.head).to,-1)),shift:e=>te(e,!0,t=>i.OF.cursor(e.lineBlockAt(t.head).to))},{key:"Ctrl-d",run:ke},{key:"Ctrl-h",run:we},{key:"Ctrl-k",run:e=>be(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:i.EY.of(["",""])},range:i.OF.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||0==t.from||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),o=n==r.from?n-1:(0,i.zK)(r.text,n-r.from,!1)+r.from,s=n==r.to?n+1:(0,i.zK)(r.text,n-r.from,!0)+r.from;return{changes:{from:o,to:s,insert:e.doc.slice(n,s).append(e.doc.slice(o,n))},range:i.OF.cursor(s)}});return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:Q}].map(e=>({mac:e.key,run:e.run,shift:e.shift})))),Be={key:"Tab",run:Le,shift:ze};n.d(t,["Yc",0,Be,"cL",0,P,"pw",0,Ee])},697(e,t,n){n.r(t),n.d(t,{css:()=>k});var i=n(4274),r=n(6684),o=n(6411);let s=null;function a(){if(!s&&"object"==typeof document&&document.body){let{style:e}=document.body,t=[],n=new Set;for(let i in e)"cssText"!=i&&"cssFloat"!=i&&"string"==typeof e[i]&&(/[A-Z]/.test(i)&&(i=i.replace(/[A-Z]/g,e=>"-"+e.toLowerCase())),n.has(i)||(t.push(i),n.add(i)));s=t.sort().map(e=>({type:"property",label:e,apply:e+": "}))}return s||[]}const l=["active","after","any-link","autofill","backdrop","before","checked","cue","default","defined","disabled","empty","enabled","file-selector-button","first","first-child","first-letter","first-line","first-of-type","focus","focus-visible","focus-within","fullscreen","has","host","host-context","hover","in-range","indeterminate","invalid","is","lang","last-child","last-of-type","left","link","marker","modal","not","nth-child","nth-last-child","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","part","placeholder","placeholder-shown","read-only","read-write","required","right","root","scope","selection","slotted","target","target-text","valid","visited","where"].map(e=>({type:"class",label:e})),c=["above","absolute","activeborder","additive","activecaption","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","antialiased","appworkspace","asterisks","attr","auto","auto-flow","avoid","avoid-column","avoid-page","avoid-region","axis-pan","background","backwards","baseline","below","bidi-override","blink","block","block-axis","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","bullets","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","calc","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","clear","clip","close-quote","col-resize","collapse","color","color-burn","color-dodge","column","column-reverse","compact","condensed","contain","content","contents","content-box","context-menu","continuous","copy","counter","counters","cover","crop","cross","crosshair","currentcolor","cursive","cyclic","darken","dashed","decimal","decimal-leading-zero","default","default-button","dense","destination-atop","destination-in","destination-out","destination-over","difference","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic-abegede-gez","ethiopic-halehame-aa-er","ethiopic-halehame-gez","ew-resize","exclusion","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fill-box","fixed","flat","flex","flex-end","flex-start","footnotes","forwards","from","geometricPrecision","graytext","grid","groove","hand","hard-light","help","hidden","hide","higher","highlight","highlighttext","horizontal","hsl","hsla","hue","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-grid","inline-table","inset","inside","intrinsic","invert","italic","justify","keep-all","landscape","large","larger","left","level","lighter","lighten","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-hexadecimal","lower-latin","lower-norwegian","lowercase","ltr","luminosity","manipulation","match","matrix","matrix3d","medium","menu","menutext","message-box","middle","min-intrinsic","mix","monospace","move","multiple","multiple_mask_images","multiply","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","opacity","open-quote","optimizeLegibility","optimizeSpeed","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","perspective","pinch-zoom","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row","row-resize","row-reverse","rtl","run-in","running","s-resize","sans-serif","saturation","scale","scale3d","scaleX","scaleY","scaleZ","screen","scroll","scrollbar","scroll-position","se-resize","self-start","self-end","semi-condensed","semi-expanded","separate","serif","show","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","soft-light","solid","source-atop","source-in","source-out","source-over","space","space-around","space-between","space-evenly","spell-out","square","start","static","status-bar","stretch","stroke","stroke-box","sub","subpixel-antialiased","svg_masks","super","sw-resize","symbolic","symbols","system-ui","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","text","text-bottom","text-top","textarea","textfield","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","to","top","transform","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","unidirectional-pan","unset","up","upper-latin","uppercase","url","var","vertical","vertical-text","view-box","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","wrap","wrap-reverse","x-large","x-small","xor","xx-large","xx-small"].map(e=>({type:"keyword",label:e})).concat(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"].map(e=>({type:"constant",label:e}))),h=["a","abbr","address","article","aside","b","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","dd","del","details","dfn","dialog","div","dl","dt","em","figcaption","figure","footer","form","header","hgroup","h1","h2","h3","h4","h5","h6","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","main","meter","nav","ol","output","p","pre","ruby","section","select","small","source","span","strong","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","tr","u","ul"].map(e=>({type:"type",label:e})),u=["@charset","@color-profile","@container","@counter-style","@font-face","@font-feature-values","@font-palette-values","@import","@keyframes","@layer","@media","@namespace","@page","@position-try","@property","@scope","@starting-style","@supports","@view-transition"].map(e=>({type:"keyword",label:e})),d=/^(\w[\w-]*|-\w[\w-]*|)$/,f=/^-(-[\w-]*)?$/,p=new o.RY,m=["Declaration"];function g(e){for(let t=e;;){if(t.type.isTop)return t;if(!(t=t.parent))return e}}function b(e,t,n){if(t.to-t.from>4096){let i=p.get(t);if(i)return i;let r=[],s=new Set,a=t.cursor(o.Qj.IncludeAnonymous);if(a.firstChild())do{for(let t of b(e,a.node,n))s.has(t.label)||(s.add(t.label),r.push(t))}while(a.nextSibling());return p.set(t,r),r}{let i=[],r=new Set;return t.cursor().iterate(t=>{var o;if(n(t)&&t.matchContext(m)&&":"==(null===(o=t.node.nextSibling)||void 0===o?void 0:o.name)){let n=e.sliceString(t.from,t.to);r.has(n)||(r.add(n),i.push({label:n,type:"variable"}))}}),i}}const y=e=>t=>{let{state:n,pos:i}=t,o=(0,r.mv)(n).resolveInner(i,-1),s=o.type.isError&&o.from==o.to-1&&"-"==n.doc.sliceString(o.from,o.to);if("PropertyName"==o.name||(s||"TagName"==o.name)&&/^(Block|Styles)$/.test(o.resolve(o.to).name))return{from:o.from,options:a(),validFor:d};if("ValueName"==o.name)return{from:o.from,options:c,validFor:d};if("PseudoClassName"==o.name)return{from:o.from,options:l,validFor:d};if(e(o)||(t.explicit||s)&&function(e,t){var n;if(("("==e.name||e.type.isError)&&(e=e.parent||e),"ArgList"!=e.name)return!1;let i=null===(n=e.parent)||void 0===n?void 0:n.firstChild;return"Callee"==(null==i?void 0:i.name)&&"var"==t.sliceString(i.from,i.to)}(o,n.doc))return{from:e(o)||s?o.from:i,options:b(n.doc,g(o),e),validFor:f};if("TagName"==o.name){for(let{parent:e}=o;e;e=e.parent)if("Block"==e.name)return{from:o.from,options:a(),validFor:d};return{from:o.from,options:h,validFor:d}}if("AtKeyword"==o.name)return{from:o.from,options:u,validFor:d};if(!t.explicit)return null;let p=o.resolve(i),m=p.childBefore(i);return m&&":"==m.name&&"PseudoClassSelector"==p.name?{from:i,options:l,validFor:d}:m&&":"==m.name&&"Declaration"==p.name||"ArgList"==p.name?{from:i,options:c,validFor:d}:"Block"==p.name||"Styles"==p.name?{from:i,options:a(),validFor:d}:null},v=y(e=>"VariableName"==e.name),w=r.bj.define({name:"css",parser:i.K.configure({props:[r.Oh.add({Declaration:(0,r.mz)()}),r.b_.add({"Block KeyframeList":r.yd})]}),languageData:{commentTokens:{block:{open:"/*",close:"*/"}},indentOnInput:/^\s*\}$/,wordChars:"-"}});function k(){return new r.Yy(w,w.data.of({autocomplete:v}))}n.d(t,["cssCompletionSource",0,v,"cssLanguage",0,w,"defineCSSCompletionSource",0,y])},6684(e,t,n){n.d(t,{EI:()=>O,KB:()=>L,Lv:()=>ce,SG:()=>Te,WD:()=>F,Yy:()=>C,_v:()=>D,bj:()=>f,cr:()=>ue,jU:()=>ze,mv:()=>p,mz:()=>N,tp:()=>T,y9:()=>me,yd:()=>q});var i,r=n(6411),o=n(2701),s=n(9747),a=n(1318),l=n(2951);const c=new r.uY;const h=new r.uY;class u{constructor(e,t,n=[],i=""){this.data=e,this.name=i,o.$t.prototype.hasOwnProperty("tree")||Object.defineProperty(o.$t.prototype,"tree",{get(){return p(this)}}),this.parser=t,this.extension=[S.of(this),o.$t.languageData.of((e,t,n)=>{let i=d(e,t,n),r=i.type.prop(c);if(!r)return[];let o=e.facet(r),s=i.type.prop(h);if(s){let r=i.resolve(t-i.from,n);for(let t of s)if(t.test(r,e)){let n=e.facet(t.facet);return"replace"==t.type?n:n.concat(o)}}return o})].concat(n)}isActiveAt(e,t,n=-1){return d(e,t,n).type.prop(c)==this.data}findRegions(e){let t=e.facet(S);if((null==t?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],i=(e,t)=>{if(e.prop(c)==this.data)return void n.push({from:t,to:t+e.length});let o=e.prop(r.uY.mounted);if(o){if(o.tree.prop(c)==this.data){if(o.overlay)for(let e of o.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}if(o.overlay){let e=n.length;if(i(o.tree,o.overlay[0].from+t),n.length>e)return}}for(let n=0;ne.concat(n):void 0}));var n;return new f(t,e.parser.configure({props:[c.add(e=>e.isTop?t:void 0)]}),e.name)}configure(e,t){return new f(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function p(e){let t=e.field(u.state,!1);return t?t.tree:r.PH.empty}class m{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}}let g=null;class b{constructor(e,t,n=[],i,r,o,s,a){this.parser=e,this.state=t,this.fragments=n,this.tree=i,this.treeLen=r,this.viewport=o,this.skipped=s,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new b(e,t,[],r.PH.empty,0,n,[],null)}startParse(){return this.parser.startParse(new m(this.state.doc),this.fragments)}work(e,t){return null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=r.PH.empty&&this.isDone(null!=t?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if("number"==typeof e){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||(this.parse=this.startParse()),null!=t&&(null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&t=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(r.rr.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=g;g=this;try{return e()}finally{g=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=y(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:i,treeLen:o,viewport:s,skipped:a}=this;if(this.takeTree(),!e.empty){let t=[];if(e.iterChangedRanges((e,n,i,r)=>t.push({fromA:e,toA:n,fromB:i,toB:r})),n=r.rr.applyChanges(n,t),i=r.PH.empty,o=0,s={from:e.mapPos(s.from,-1),to:e.mapPos(s.to,1)},this.skipped.length){a=[];for(let t of this.skipped){let n=e.mapPos(t.from,1),i=e.mapPos(t.to,-1);ne.from&&(this.fragments=y(this.fragments,n,i),this.skipped.splice(t--,1))}return!(this.skipped.length>=t||(this.reset(),0))}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends r.iX{createParse(t,n,i){let o=i[0].from,s=i[i.length-1].to;return{parsedPos:o,advance(){let t=g;if(t){for(let e of i)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=s,new r.PH(r.Z6.none,[],[],s-o)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&0==t[0].from&&t[0].to>=e}static get(){return g}}function y(e,t,n){return r.rr.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class v{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new v(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=b.create(e.facet(S).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new v(n)}}u.state=o.sU.define({create:v.init,update(e,t){for(let e of t.effects)if(e.is(u.setState))return e.value;return t.startState.facet(S)!=t.state.facet(S)?v.init(t.state):e.apply(t)}});let w=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};"undefined"!=typeof requestIdleCallback&&(w=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const k="undefined"!=typeof navigator&&(null===(i=navigator.scheduling)||void 0===i?void 0:i.isInputPending)?()=>navigator.scheduling.isInputPending():null,x=s.Z9.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(u.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(u.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=w(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndi+1e3,a=r.context.work(()=>k&&k()||Date.now()>o,i+(s?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:u.setState.of(new v(r.context))})),this.chunkBudget>0&&(!a||s)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>(0,s.c_)(this.view.state,e)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),S=o.sj.define({combine:e=>e.length?e[0]:null,enables:e=>[u.state,x,s.Lz.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});class C{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const A=o.sj.define(),M=o.sj.define({combine:e=>{if(!e.length)return" ";let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return t}});function T(e){let t=e.facet(M);return 9==t.charCodeAt(0)?e.tabSize*t.length:t.length}function O(e,t){let n="",i=e.tabSize,r=e.facet(M)[0];if("\t"==r){for(;t>=i;)n+="\t",t-=i;r=" "}for(let e=0;e=t?function(e,t,n){let i=t.resolveStack(n),r=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(r!=i.node){let e=[];for(let t=r;t&&!(t.fromi.node.to||t.from==i.node.from&&t.type==i.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)i={node:e[t],next:i}}return E(i,e,n)}(e,n,t):null}class L{constructor(e,t={}){this.state=e,this.options=t,this.unit=T(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:i,simulateDoubleBreak:r}=this.options;return null!=i&&i>=n.from&&i<=n.to?r&&i==e?{text:"",from:e}:(t<0?i-1&&(r+=o-this.countColumn(n,n.search(/\S|$/))),r}countColumn(e,t=e.length){return(0,o.y$)(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:i}=this.lineAt(e,t),r=this.options.overrideIndentation;if(r){let e=r(i);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const z=new r.uY;function E(e,t,n){for(let i=e;i;i=i.next){let e=B(i.node);if(e)return e(P.create(t,n,i))}return 0}function B(e){let t=e.type.prop(z);if(t)return t;let n,i=e.firstChild;if(i&&(n=i.type.prop(r.uY.closedBy))){let t=e.lastChild,i=t&&n.indexOf(t.name)>-1;return e=>function(e,t,n,i,r){let o=e.textAfter,s=o.match(/^\s*/)[0].length,a=i&&o.slice(s,s+i.length)==i||r==e.pos+s,l=t?function(e){let t=e.node,n=t.childAfter(t.from),i=t.lastChild;if(!n)return null;let r=e.options.simulateBreak,o=e.state.doc.lineAt(n.from),s=null==r||r<=o.from?o.to:Math.min(o.to,r);for(let e=n.to;;){let r=t.childAfter(e);if(!r||r==i)return null;if(!r.type.isSkipped){if(r.from>=s)return null;let e=/^ */.exec(o.text.slice(n.to-o.from))[0].length;return{from:n.from,to:n.to+e}}e=r.to}}(e):null;return l?a?e.column(l.from):e.column(l.to):e.baseIndent+(a?0:e.unit*n)}(e,!0,1,void 0,i&&!function(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}(e)?t.from:void 0)}return null==e.parent?R:null}function R(){return 0}class P extends L{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(e,t,n){return new P(e,t,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(I(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return E(this.context.next,this.base,this.pos)}}function I(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function N({except:e,units:t=1}={}){return n=>{let i=e&&e.test(n.textAfter);return n.baseIndent+(i?0:t*n.unit)}}function F(){return o.$t.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:i}=e.newSelection.main,r=n.lineAt(i);if(i>r.from+200)return e;let o=n.sliceString(r.from,i);if(!t.some(e=>e.test(o)))return e;let{state:s}=e,a=-1,l=[];for(let{head:e}of s.selection.ranges){let t=s.doc.lineAt(e);if(t.from==a)continue;a=t.from;let n=D(s,t.from);if(null==n)continue;let i=/^\s*/.exec(t.text)[0],r=O(s,n);i!=r&&l.push({from:t.from,to:t.from+i.length,insert:r})}return l.length?[e,{changes:l,sequential:!0}]:e})}const W=o.sj.define(),H=new r.uY;function q(e){let t=e.firstChild,n=e.lastChild;return t&&t.ton)continue;if(r&&s.from=t&&i.to>n&&(r=i)}}return r}(e,t,n)}function K(e,t){let n=t.mapPos(e.from,1),i=t.mapPos(e.to,-1);return n>=i?void 0:{from:n,to:i}}const _=o.Pe.define({map:K}),U=o.Pe.define({map:K});function $(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(e=>e.from<=n&&e.to>=n)||t.push(e.lineBlockAt(n));return t}const Y=o.sU.define({create:()=>s.NZ.none,update(e,t){t.isUserEvent("delete")&&t.changes.iterChangedRanges((t,n)=>e=G(e,t,n)),e=e.map(t.changes);let n=[];for(let i of t.effects)i.is(_)&&!J(e,i.value.from,i.value.to)?n.push(i.value):i.is(U)&&(e=e.update({filter:(e,t)=>i.value.from!=e||i.value.to!=t,filterFrom:i.value.from,filterTo:i.value.to}));if(n.length){let{preparePlaceholder:i}=t.state.facet(ne),r=n.map(e=>(i?s.NZ.replace({widget:new se(i(t.state,e))}):oe).range(e.from,e.to));e=e.update({add:r})}return t.selection&&(e=G(e,t.selection.main.head)),e},provide:e=>s.Lz.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(e,t)=>{n.push(e,t)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw new RangeError("Invalid JSON for fold state");let t=[];for(let n=0;n{et&&(i=!0)}),i?e.update({filterFrom:t,filterTo:n,filter:(e,i)=>e>=n||i<=t}):e}function X(e,t,n){var i;let r=null;return null===(i=e.field(Y,!1))||void 0===i||i.between(t,n,(e,t)=>{(!r||r.from>e)&&(r={from:e,to:t})}),r}function J(e,t,n){let i=!1;return e.between(t,t,(e,r)=>{e==t&&r==n&&(i=!0)}),i}function Z(e,t){return e.field(Y,!1)?t:t.concat(o.Pe.appendConfig.of(ie()))}function Q(e,t,n=!0){let i=e.state.doc.lineAt(t.from).number,r=e.state.doc.lineAt(t.to).number;return s.Lz.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${i} ${e.state.phrase("to")} ${r}.`)}const ee=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:e=>{for(let t of $(e)){let n=j(e.state,t.from,t.to);if(n)return e.dispatch({effects:Z(e.state,[_.of(n),Q(e,n)])}),!0}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:e=>{if(!e.state.field(Y,!1))return!1;let t=[];for(let n of $(e)){let i=X(e.state,n.from,n.to);i&&t.push(U.of(i),Q(e,i,!1))}return t.length&&e.dispatch({effects:t}),t.length>0}},{key:"Ctrl-Alt-[",run:e=>{let{state:t}=e,n=[];for(let i=0;i{let t=e.state.field(Y,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(e,t)=>{n.push(U.of({from:e,to:t}))}),e.dispatch({effects:n}),!0}}],te={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},ne=o.sj.define({combine:e=>(0,o.QR)(e,te)});function ie(e){let t=[Y,he];return e&&t.push(ne.of(e)),t}function re(e,t){let{state:n}=e,i=n.facet(ne),r=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),i=X(e.state,n.from,n.to);i&&e.dispatch({effects:U.of(i)}),t.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(e,r,t);let o=document.createElement("span");return o.textContent=i.placeholderText,o.setAttribute("aria-label",n.phrase("folded code")),o.title=n.phrase("unfold"),o.className="cm-foldPlaceholder",o.onclick=r,o}const oe=s.NZ.replace({widget:new class extends s.xO{toDOM(e){return re(e,null)}}});class se extends s.xO{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return re(e,this.value)}}const ae={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class le extends s.wJ{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function ce(e={}){let t={...ae,...e},n=new le(t,!0),i=new le(t,!1),r=s.Z9.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(S)!=e.state.facet(S)||e.startState.field(Y,!1)!=e.state.field(Y,!1)||p(e.startState)!=p(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new o.vB;for(let r of e.viewportLineBlocks){let o=X(e.state,r.from,r.to)?i:j(e.state,r.from,r.to)?n:null;o&&t.add(r.from,r.from,o)}return t.finish()}}),{domEventHandlers:a}=t;return[r,(0,s.cU)({class:"cm-foldGutter",markers(e){var t;return(null===(t=e.plugin(r))||void 0===t?void 0:t.markers)||o.om.empty},initialSpacer:()=>new le(t,!1),domEventHandlers:{...a,click:(e,t,n)=>{if(a.click&&a.click(e,t,n))return!0;let i=X(e.state,t.from,t.to);if(i)return e.dispatch({effects:U.of(i)}),!0;let r=j(e.state,t.from,t.to);return!!r&&(e.dispatch({effects:_.of(r)}),!0)}}}),ie()]}const he=s.Lz.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class ue{constructor(e,t){let n;function i(e){let t=l.G.newName();return(n||(n=Object.create(null)))["."+t]=e,t}this.specs=e;const r="string"==typeof t.all?t.all:t.all?i(t.all):void 0,o=t.scope;this.scope=o instanceof u?e=>e.prop(c)==o.data:o?e=>e==o:void 0,this.style=(0,a.az)(e.map(e=>({tag:e.tag,class:e.class||i(Object.assign({},e,{tag:null}))})),{all:r}).style,this.module=n?new l.G(n):null,this.themeType=t.themeType}static define(e,t){return new ue(e,t||{})}}const de=o.sj.define(),fe=o.sj.define({combine:e=>e.length?[e[0]]:null});function pe(e){let t=e.facet(de);return t.length?t:e.facet(fe)}function me(e,t){let n,i=[be];return e instanceof ue&&(e.module&&i.push(s.Lz.styleModule.of(e.module)),n=e.themeType),(null==t?void 0:t.fallback)?i.push(fe.of(e)):n?i.push(de.computeN([s.Lz.darkTheme],t=>t.facet(s.Lz.darkTheme)==("dark"==n)?[e]:[])):i.push(de.of(e)),i}class ge{constructor(e){this.markCache=Object.create(null),this.tree=p(e.state),this.decorations=this.buildDeco(e,pe(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=p(e.state),n=pe(e.state),i=n!=pe(e.startState),{viewport:r}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length=r.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||i)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=r.to)}buildDeco(e,t){if(!t||!this.tree.length)return s.NZ.none;let n=new o.vB;for(let{from:i,to:r}of e.visibleRanges)(0,a.DM)(this.tree,t,(e,t,i)=>{n.add(e,t,this.markCache[i]||(this.markCache[i]=s.NZ.mark({class:i})))},i,r);return n.finish()}}const be=o.Nb.high(s.Z9.fromClass(ge,{decorations:e=>e.decorations})),ye=ue.define([{tag:a._A.meta,color:"#404740"},{tag:a._A.link,textDecoration:"underline"},{tag:a._A.heading,textDecoration:"underline",fontWeight:"bold"},{tag:a._A.emphasis,fontStyle:"italic"},{tag:a._A.strong,fontWeight:"bold"},{tag:a._A.strikethrough,textDecoration:"line-through"},{tag:a._A.keyword,color:"#708"},{tag:[a._A.atom,a._A.bool,a._A.url,a._A.contentSeparator,a._A.labelName],color:"#219"},{tag:[a._A.literal,a._A.inserted],color:"#164"},{tag:[a._A.string,a._A.deleted],color:"#a11"},{tag:[a._A.regexp,a._A.escape,a._A.special(a._A.string)],color:"#e40"},{tag:a._A.definition(a._A.variableName),color:"#00f"},{tag:a._A.local(a._A.variableName),color:"#30a"},{tag:[a._A.typeName,a._A.namespace],color:"#085"},{tag:a._A.className,color:"#167"},{tag:[a._A.special(a._A.variableName),a._A.macroName],color:"#256"},{tag:a._A.definition(a._A.propertyName),color:"#00c"},{tag:a._A.comment,color:"#940"},{tag:a._A.invalid,color:"#f00"}]),ve=s.Lz.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),we="()[]{}",ke=o.sj.define({combine:e=>(0,o.QR)(e,{afterCursor:!0,brackets:we,maxScanDistance:1e4,renderMatch:Ce})}),xe=s.NZ.mark({class:"cm-matchingBracket"}),Se=s.NZ.mark({class:"cm-nonmatchingBracket"});function Ce(e){let t=[],n=e.matched?xe:Se;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}function Ae(e){let t=[],n=e.facet(ke);for(let i of e.selection.ranges){if(!i.empty)continue;let r=ze(e,i.head,-1,n)||i.head>0&&ze(e,i.head-1,1,n)||n.afterCursor&&(ze(e,i.head,1,n)||i.heade.decorations}),ve];function Te(e={}){return[ke.of(e),Me]}const Oe=new r.uY;function De(e,t,n){let i=e.prop(t<0?r.uY.openedBy:r.uY.closedBy);if(i)return i;if(1==e.name.length){let i=n.indexOf(e.name);if(i>-1&&i%2==(t<0?1:0))return[n[i+t]]}return null}function Le(e){let t=e.type.prop(Oe);return t?t(e.node):e}function ze(e,t,n,i={}){let r=i.maxScanDistance||1e4,o=i.brackets||we,s=p(e),a=s.resolveInner(t,n);for(let e=a;e;e=e.parent){let i=De(e.type,n,o);if(i&&e.from0?t>=r.from&&tr.from&&t<=r.to))return Ee(0,0,n,e,r,i,o)}}return function(e,t,n,i,r,o,s){if(n<0?!t:t==e.doc.length)return null;let a=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),l=s.indexOf(a);if(l<0||l%2==0!=n>0)return null;let c={from:n<0?t-1:t,to:n>0?t+1:t},h=e.doc.iterRange(t,n>0?e.doc.length:0),u=0;for(let e=0;!h.next().done&&e<=o;){let o=h.value;n<0&&(e+=o.length);let a=t+e*n;for(let e=n>0?0:o.length-1,t=n>0?o.length:-1;e!=t;e+=n){let t=s.indexOf(o[e]);if(!(t<0||i.resolveInner(a+e,1).type!=r))if(t%2==0==n>0)u++;else{if(1==u)return{start:c,end:{from:a+e,to:a+e+1},matched:t>>1==l>>1};u--}}n>0&&(e+=o.length)}return h.done?{start:c,matched:!1}:null}(e,t,n,s,a.type,r,o)}function Ee(e,t,n,i,r,o,s){let a=i.parent,l={from:r.from,to:r.to},c=0,h=null==a?void 0:a.cursor();if(h&&(n<0?h.childBefore(i.from):h.childAfter(i.to)))do{if(n<0?h.to<=i.from:h.from>=i.to){if(0==c&&o.indexOf(h.type.name)>-1&&h.from-1||(Pe.push(e),console.warn(t))}function We(e,t){let n=[];for(let i of t.split(" ")){let t=[];for(let n of i.split(".")){let i=e[n]||a._A[n];i?"function"==typeof i?t.length?t=t.map(i):Fe(n,`Modifier ${n} used at start of tag`):t.length?Fe(n,`Tag ${n} used as modifier`):t=Array.isArray(i)?i:[i]:Fe(n,`Unknown highlighting tag ${n}`)}for(let e of t)n.push(e)}if(!n.length)return 0;let i=t.replace(/ /g,"_"),o=i+" "+n.map(e=>e.id),s=Ie[o];if(s)return s.id;let l=Ie[o]=r.Z6.define({id:Re.length,name:i,props:[(0,a.pn)({[i]:n})]});return Re.push(l),l.id}s.OP.RTL,s.OP.LTR,n.d(t,["Oh",0,z,"Xt",0,M,"Zt",0,ye,"b_",0,H,"f7",0,ee])},6949(e,t,n){n.r(t),n.d(t,{diagnosticCount:()=>g,forEachDiagnostic:()=>X,forceLinting:()=>O,lintGutter:()=>G,linter:()=>T,setDiagnostics:()=>u});var i=n(9747),r=n(2701),o=n(9786);class s{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}}class a{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let o=n.facet(A).markerFilter;o&&(e=o(e,n));let s=e.slice().sort((e,t)=>e.from-t.from||e.to-t.to),c=new r.vB,h=[],u=0,d=n.doc.iter(),f=0,p=n.doc.length;for(let e=0;;){let t,n,r=e==s.length?null:s[e];if(!r&&!h.length)break;if(h.length)t=u,n=h.reduce((e,t)=>Math.min(e,t.to),r&&r.from>t?r.from:1e8);else{if(t=r.from,t>p)break;n=r.to,h.push(r),e++}for(;ei.from||i.to==t)){n=Math.min(i.from,n);break}h.push(i),e++,n=Math.min(i.to,n)}n=Math.min(n,p);let o=!1;if(h.some(e=>e.from==t&&(e.to==n||n==p))&&(o=t==n,!o&&n-t<10)){let e=t-(f+d.value.length);e>0&&(d.next(e),f=t);for(let e=t;;){if(e>=n){o=!0;break}if(!d.lineBreak&&f+d.value.length>e)break;e=f+d.value.length,f+=d.value.length,d.next()}}let a=F(h);if(o)c.add(t,t,i.NZ.widget({widget:new z(a),diagnostics:h.slice()}));else{let e=h.reduce((e,t)=>t.markClass?e+" "+t.markClass:e,"");c.add(t,n,i.NZ.mark({class:"cm-lintRange cm-lintRange-"+a+e,diagnostics:h.slice(),inclusiveEnd:h.some(e=>e.to>n)}))}if(u=n,u==p)break;for(let e=0;e{if(!(t&&r.diagnostics.indexOf(t)<0))if(i){if(r.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new s(i.from,n,i.diagnostic)}else i=new s(e,n,t||r.diagnostics[0])}),i}function c(e,t){let n=t.pos,i=t.end||n,r=e.state.facet(A).hideOn(e,n,i);if(null!=r)return r;let o=e.startState.doc.lineAt(t.pos);return!(!e.effects.some(e=>e.is(d))&&!e.changes.touchesRange(o.from,Math.max(o.to,i)))}function h(e,t){return e.field(m,!1)?t:t.concat(r.Pe.appendConfig.of($))}function u(e,t){return{effects:h(e,[d.of(t)])}}const d=r.Pe.define(),f=r.Pe.define(),p=r.Pe.define(),m=r.sU.define({create:()=>new a(i.NZ.none,null,null),update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),i=null,r=e.panel;if(e.selected){let r=t.changes.mapPos(e.selected.from,1);i=l(n,e.selected.diagnostic,r)||l(n,null,r)}!n.size&&r&&t.state.facet(A).autoPanel&&(r=null),e=new a(n,r,i)}for(let n of t.effects)if(n.is(d)){let i=t.state.facet(A).autoPanel?n.value.length?B.open:null:e.panel;e=a.init(n.value,i,t.state)}else n.is(f)?e=new a(e.diagnostics,n.value?B.open:null,e.selected):n.is(p)&&(e=new a(e.diagnostics,e.panel,n.value));return e},provide:e=>[i.S7.from(e,e=>e.panel),i.Lz.decorations.from(e,e=>e.diagnostics)]});function g(e){let t=e.field(m,!1);return t?t.diagnostics.size:0}const b=i.NZ.mark({class:"cm-lintRange cm-lintRange-active"});function y(e,t,n){let i,{diagnostics:r}=e.state.field(m),o=-1,s=-1;r.between(t-(n<0?1:0),t+(n>0?1:0),(e,r,{spec:a})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t({dom:v(e,i)})}:null}function v(e,t){return(0,o.A)("ul",{class:"cm-tooltip-lint"},t.map(t=>L(e,t,!1)))}const w=e=>{let t=e.state.field(m,!1);t&&t.panel||e.dispatch({effects:h(e.state,[f.of(!0)])});let n=(0,i.ld)(e,B.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},k=e=>{let t=e.state.field(m,!1);return!(!t||!t.panel||(e.dispatch({effects:f.of(!1)}),0))},x=e=>{let t=e.state.field(m,!1);if(!t)return!1;let n=e.state.selection.main,r=l(t.diagnostics,null,n.to+1);return!(!r&&(r=l(t.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)||(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),(0,i.ab)(e,r.from,1,{tooltip:U,until:e=>e.docChanged||e.newSelection.main.headr.to}),0))},S=[{key:"Mod-Shift-m",run:w,preventDefault:!0},{key:"F8",run:x}],C=i.Z9.fromClass(class{constructor(e){this.view=e,this.timeout=-1,this.set=!0;let{delay:t}=e.state.facet(A);this.lintTime=Date.now()+t,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,t)}run(){clearTimeout(this.timeout);let e=Date.now();if(e{i.push(n),clearTimeout(r),i.length==e.length?t(i):r=setTimeout(()=>t(i),200)},n)}(t.map(e=>Promise.resolve(e(this.view))),t=>{this.view.state.doc==e.doc&&this.view.dispatch(u(this.view.state,t.reduce((e,t)=>e.concat(t))))},e=>{(0,i.c_)(this.view.state,e)})}}update(e){let t=e.state.facet(A);(e.docChanged||t!=e.startState.facet(A)||t.needsRefresh&&t.needsRefresh(e))&&(this.lintTime=Date.now()+t.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,t.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}}),A=r.sj.define({combine:e=>({sources:e.map(e=>e.source).filter(e=>null!=e),...(0,r.QR)(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:M,tooltipFilter:M,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,i,r)=>e(n,i,r)||t(n,i,r):e:t,autoPanel:(e,t)=>e||t})})});function M(e,t){return e?t?(n,i)=>t(e(n,i),i):e:t}function T(e,t={}){return[A.of({source:e,config:t}),C,$]}function O(e){let t=e.plugin(C);t&&t.force()}function D(e){let t=[];if(e)e:for(let{name:n}of e){for(let e=0;ee.toLowerCase()==i.toLowerCase())){t.push(i);continue e}}t.push("")}return t}function L(e,t,n){var i;let r=n?D(t.actions):[];return(0,o.A)("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},(0,o.A)("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(e):t.message),null===(i=t.actions)||void 0===i?void 0:i.map((n,i)=>{let s=!1,a=i=>{if(i.preventDefault(),s)return;s=!0;let r=l(e.state.field(m).diagnostics,t);r&&n.apply(e,r.from,r.to)},{name:c}=n,h=r[i]?c.indexOf(r[i]):-1,u=h<0?c:[c.slice(0,h),(0,o.A)("u",c.slice(h,h+1)),c.slice(h+1)],d=n.markClass?" "+n.markClass:"";return(0,o.A)("button",{type:"button",class:"cm-diagnosticAction"+d,onclick:a,onmousedown:a,"aria-label":` Action: ${c}${h<0?"":` (access key "${r[i]})"`}.`},u)}),t.source&&(0,o.A)("div",{class:"cm-diagnosticSource"},t.source))}class z extends i.xO{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return(0,o.A)("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class E{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=L(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class B{constructor(e){this.view=e,this.items=[],this.list=(0,o.A)("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(27==t.keyCode)k(this.view),this.view.focus();else if(38==t.keyCode||33==t.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==t.keyCode||34==t.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==t.keyCode)this.moveSelection(0);else if(35==t.keyCode)this.moveSelection(this.items.length-1);else if(13==t.keyCode)this.view.focus();else{if(!(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0))return;{let{diagnostic:n}=this.items[this.selectedIndex],i=D(n.actions);for(let r=0;r{for(let t=0;tk(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(m).selected;if(!e)return-1;for(let t=0;t{for(let e of a.diagnostics){if(o.has(e))continue;o.add(e);let s,a=-1;for(let t=n;tn&&(this.items.splice(n,a-n),i=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute("aria-selected")||(s.dom.setAttribute("aria-selected","true"),r=s):s.dom.hasAttribute("aria-selected")&&s.dom.removeAttribute("aria-selected"),n++}});n({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.topt.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=l(this.view.state.field(m).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:p.of(t)})}static open(e){return new B(e)}}function R(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(e)}')`}function P(e){return R(``,'width="6" height="3"')}const I=i.Lz.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:P("#f11")},".cm-lintRange-warning":{backgroundImage:P("orange")},".cm-lintRange-info":{backgroundImage:P("#999")},".cm-lintRange-hint":{backgroundImage:P("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function N(e){return"error"==e?4:"warning"==e?3:"info"==e?2:1}function F(e){let t="hint",n=1;for(let i of e){let e=N(i.severity);e>n&&(n=e,t=i.severity)}return t}class W extends i.wJ{constructor(e){super(),this.diagnostics=e,this.severity=F(e)}toDOM(e){let t=document.createElement("div");t.className="cm-lint-marker cm-lint-marker-"+this.severity;let n=this.diagnostics,i=e.state.facet(Y).tooltipFilter;return i&&(n=i(n,e.state)),n.length&&(t.onmouseover=()=>function(e,t,n){function i(){let i=e.elementAtHeight(t.getBoundingClientRect().top+5-e.documentTop);e.coordsAtPos(i.from)&&e.dispatch({effects:j.of({pos:i.from,above:!1,clip:!1,create:()=>({dom:v(e,n),getCoords:()=>t.getBoundingClientRect()})})}),t.onmouseout=t.onmousemove=null,function(e,t){let n=i=>{let r=t.getBoundingClientRect();if(!(i.clientX>r.left-10&&i.clientXr.top-10&&i.clientY{clearTimeout(o),t.onmouseout=t.onmousemove=null},t.onmousemove=()=>{clearTimeout(o),o=setTimeout(i,r)}}(e,t,n)),t}}function H(e,t){let n=Object.create(null);for(let i of t){let t=e.lineAt(i.from);(n[t.from]||(n[t.from]=[])).push(i)}let i=[];for(let e in n)i.push(new W(n[e]).range(+e));return r.om.of(i,!0)}const q=(0,i.cU)({class:"cm-gutter-lint",markers:e=>e.state.field(V),widgetMarker:(e,t,n)=>{let i=[];return e.state.field(V).between(n.from,n.to,(e,t,r)=>{e>n.from&&er.om.empty,update(e,t){e=e.map(t.changes);let n=t.state.facet(Y).markerFilter;for(let i of t.effects)if(i.is(d)){let r=i.value;n&&(r=n(r||[],t.state)),e=H(t.state.doc,r.slice(0))}return e}}),j=r.Pe.define(),K=r.sU.define({create:()=>null,update:(e,t)=>(e&&t.docChanged&&(e=c(t,e)?null:{...e,pos:t.changes.mapPos(e.pos)}),t.effects.reduce((e,t)=>t.is(j)?t.value:e,e)),provide:e=>i.DK.from(e)}),_=i.Lz.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:R('')},".cm-lint-marker-warning":{content:R('')},".cm-lint-marker-error":{content:R('')}}),U=(0,i.Ux)(y,{hideOn:c}),$=[m,i.Lz.decorations.compute([m],e=>{let{selected:t,panel:n}=e.field(m);return t&&n&&t.from!=t.to?i.NZ.set([b.range(t.from,t.to)]):i.NZ.none}),U,I],Y=r.sj.define({combine:e=>(0,r.QR)(e,{hoverTime:300,markerFilter:null,tooltipFilter:null})});function G(e={}){return[Y.of(e),V,q,_,K]}function X(e,t){let n=e.field(m,!1);if(n&&n.diagnostics.size){let e=[],i=[],o=-1;for(let s=r.om.iter([n.diagnostics]);;s.next()){for(let n=0;n{var t;let{state:n}=e,r=n.field(m,!1);if(!r)return!1;let o,s,a,l,c=n.selection.main;if(r.diagnostics.between(0,n.doc.length,(e,t)=>{ta)&&(a=e,l=t)}),null==a||null==o&&a==c.from)return!1;let h=null!=o?o:a,u=null!==(t=null!=s?s:l)&&void 0!==t?t:h;return e.dispatch({selection:{anchor:h,head:u},scrollIntoView:!0}),(0,i.ab)(e,h,1,{tooltip:U,until:e=>e.docChanged||e.newSelection.main.headu}),!0},"setDiagnosticsEffect",0,d])},7969(e,t,n){n.d(t,{gN:()=>b});var i=n(9747),r=n(2701),o=n(9786);const s="function"==typeof String.prototype.normalize?e=>e.normalize("NFKD"):e=>e;class a{constructor(e,t,n=0,i=e.length,r,o){this.test=o,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,i),this.bufferStart=n,this.normalize=r?e=>r(s(e)):s,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return(0,r.vS)(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 t=(0,r.MK)(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=(0,r.Fh)(e);let i=this.normalize(t);if(i.length)for(let e=0,r=n,o=!0;;e++){let n=i.charCodeAt(e),s=this.match(n,r,o,this.bufferPos+this.bufferStart,e==i.length-1);if(s)return this.value=s,this;if(e==i.length-1)break;o&&ethis.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 e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,i=n+t[0].length;if(this.matchPos=p(this.text,i+(n==i?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(nthis.value.to)&&(!this.test||this.test(n,i,t)))return this.value={from:n,to:i,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length=n||i.to<=t){let i=new d(t,e.sliceString(t,n));return u.set(e,i),i}if(i.from==t&&i.to==n)return i;let{text:r,from:o}=i;return o>t&&(r=e.sliceString(t,o)+r,o=t),i.to=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,precise:!0,match:t},this.matchPos=p(this.text,n+(e==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=d.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function p(e,t){if(t>=e.length)return t;let n,i=e.lineAt(t);for(;t=56320&&n<57344;)t++;return t}"undefined"!=typeof Symbol&&(h.prototype[Symbol.iterator]=f.prototype[Symbol.iterator]=function(){return this});const m={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},g=r.sj.define({combine:e=>(0,r.QR)(e,m,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})});function b(e){let t=[x,k];return e&&t.push(g.of(e)),t}const y=i.NZ.mark({class:"cm-selectionMatch"}),v=i.NZ.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function w(e,t,n,i){return!(0!=n&&e(t.sliceDoc(n-1,n))==r.Je.Word||i!=t.doc.length&&e(t.sliceDoc(i,i+1))==r.Je.Word)}const k=i.Z9.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(g),{state:n}=e,o=n.selection;if(o.ranges.length>1)return i.NZ.none;let s,l=o.main,c=null;if(l.empty){if(!t.highlightWordAroundCursor)return i.NZ.none;let e=n.wordAt(l.head);if(!e)return i.NZ.none;c=n.charCategorizer(l.head),s=n.sliceDoc(e.from,e.to)}else{let e=l.to-l.from;if(e200)return i.NZ.none;if(t.wholeWords){if(s=n.sliceDoc(l.from,l.to),c=n.charCategorizer(l.head),!w(c,n,l.from,l.to)||!function(e,t,n,i){return e(t.sliceDoc(n,n+1))==r.Je.Word&&e(t.sliceDoc(i-1,i))==r.Je.Word}(c,n,l.from,l.to))return i.NZ.none}else if(s=n.sliceDoc(l.from,l.to),!s)return i.NZ.none}let h=[];for(let r of e.visibleRanges){let e=new a(n.doc,s,r.from,r.to);for(;!e.next().done;){let{from:r,to:o}=e.value;if((!c||w(c,n,r,o))&&(l.empty&&r<=l.from&&o>=l.to?h.push(v.range(r,o)):(r>=l.to||o<=l.from)&&h.push(y.range(r,o)),h.length>t.maxMatches))return i.NZ.none}}return i.NZ.set(h)}},{decorations:e=>e.decorations}),x=i.Lz.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),S=r.sj.define({combine:e=>(0,r.QR)(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Z(e),scrollToMatch:e=>i.Lz.scrollIntoView(e)})});class C{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||function(e){try{return new RegExp(e,c),!0}catch(e){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>"n"==t?"\n":"r"==t?"\r":"t"==t?"\t":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new z(this):new T(this)}getCursor(e,t=0,n){let i=e.doc?e:r.$t.create({doc:e});return null==n&&(n=i.doc.length),this.regexp?O(this,i,t,n):M(this,i,t,n)}}class A{constructor(e){this.spec=e}}function M(e,t,n,i){let o;var s,l;return e.wholeWord&&(s=t.doc,l=t.charCategorizer(t.selection.main.head),o=(e,t,n,i)=>((i>e||i+n.length{if(n&&!n(i,r,o,s))return!1;let a=i>=s&&r<=s+o.length?o.slice(i-s,r-s):t.doc.sliceString(i,r);return e(a,t,i,r)}}(e.test,t,o)),new a(t.doc,e.unquoted,n,i,e.caseSensitive?void 0:e=>e.toLowerCase(),o)}class T extends A{constructor(e){super(e)}nextMatch(e,t,n){let i=M(this.spec,e,n,e.doc.length).nextOverlapping();if(i.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);i=M(this.spec,e,0,n).nextOverlapping()}return i.done||i.value.from==t&&i.value.to==n?null:i.value}prevMatchInRange(e,t,n){for(let i=n;;){let n=Math.max(t,i-1e4-this.spec.unquoted.length),r=M(this.spec,e,n,i),o=null;for(;!r.nextOverlapping().done;)o=r.value;if(o)return o;if(n==t)return null;i-=1e4}}prevMatch(e,t,n){let i=this.prevMatchInRange(e,0,t);return i||(i=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length)),!i||i.from==t&&i.to==n?null:i}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=M(this.spec,e,0,e.doc.length),i=[];for(;!n.next().done;){if(i.length>=t)return null;i.push(n.value)}return i}highlight(e,t,n,i){let r=M(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)i(r.value.from,r.value.to)}}function O(e,t,n,i){let o;var s;return e.wholeWord&&(s=t.charCategorizer(t.selection.main.head),o=(e,t,n)=>!n[0].length||(s(D(n.input,n.index))!=r.Je.Word||s(L(n.input,n.index))!=r.Je.Word)&&(s(L(n.input,n.index+n[0].length))!=r.Je.Word||s(D(n.input,n.index+n[0].length))!=r.Je.Word)),e.test&&(o=function(e,t,n){return(i,r,o)=>(!n||n(i,r,o))&&e(o[0],t,i,r)}(e.test,t,o)),new h(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:o},n,i)}function D(e,t){return e.slice((0,r.zK)(e,t,!1),t)}function L(e,t){return e.slice(t,(0,r.zK)(e,t))}class z extends A{nextMatch(e,t,n){let i=O(this.spec,e,n,e.doc.length).next();return i.done&&(i=O(this.spec,e,0,t).next()),i.done?null:i.value}prevMatchInRange(e,t,n){for(let i=1;;i++){let r=Math.max(t,n-1e4*i),o=O(this.spec,e,r,n),s=null;for(;!o.next().done;)s=o.value;if(s&&(r==t||s.from>r+10))return s;if(r==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if("&"==n)return e.match[0];if("$"==n)return"$";for(let t=n.length;t>0;t--){let i=+n.slice(0,t);if(i>0&&i=t)return null;i.push(n.value)}return i}highlight(e,t,n,i){let r=O(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!r.next().done;)i(r.value.from,r.value.to)}}const E=r.Pe.define(),B=r.Pe.define(),R=r.sU.define({create:e=>new P(U(e).create(),null),update(e,t){for(let n of t.effects)n.is(E)?e=new P(n.value.create(),e.panel):n.is(B)&&(e=new P(e.query,n.value?_:null));return e},provide:e=>i.S7.from(e,e=>e.panel)});class P{constructor(e,t){this.query=e,this.panel=t}}const I=i.NZ.mark({class:"cm-searchMatch"}),N=i.NZ.mark({class:"cm-searchMatch cm-searchMatch-selected"}),F=i.Z9.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(R))}update(e){let t=e.state.field(R);(t!=e.startState.field(R)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return i.NZ.none;let{view:n}=this,o=new r.vB;for(let t=0,i=n.visibleRanges,r=i.length;ti[t+1].from-500;)a=i[++t].to;e.highlight(n.state,s,a,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);o.add(e,t,i?N:I)})}return o.finish()}},{decorations:e=>e.decorations});function W(e){return t=>{let n=t.state.field(R,!1);return n&&n.query.spec.valid?e(t,n):G(t)}}const H=W((e,{query:t})=>{let{to:n}=e.state.selection.main,i=t.nextMatch(e.state,n,n);if(!i)return!1;let o=r.OF.single(i.from,i.to),s=e.state.facet(S);return e.dispatch({selection:o,effects:[te(e,i),s.scrollToMatch(o.main,e)],userEvent:"select.search"}),Y(e),!0}),q=W((e,{query:t})=>{let{state:n}=e,{from:i}=n.selection.main,o=t.prevMatch(n,i,i);if(!o)return!1;let s=r.OF.single(o.from,o.to),a=e.state.facet(S);return e.dispatch({selection:s,effects:[te(e,o),a.scrollToMatch(s.main,e)],userEvent:"select.search"}),Y(e),!0}),V=W((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!(!n||!n.length||(e.dispatch({selection:r.OF.create(n.map(e=>r.OF.range(e.from,e.to))),userEvent:"select.search.matches"}),0))}),j=W((e,{query:t})=>{let{state:n}=e,{from:o,to:s}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,o,o);if(!a)return!1;let l,c,h=a,u=[],d=[];h.precise?h.from==o&&h.to==s&&(c=n.toText(t.getReplacement(h)),u.push({from:h.from,to:h.to,insert:c}),h=t.nextMatch(n,h.from,h.to),d.push(i.Lz.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(o).number)+"."))):h=t.nextMatch(n,h.from,h.to);let f=e.state.changes(u);return h&&(l=r.OF.single(h.from,h.to).map(f),d.push(te(e,h)),d.push(n.facet(S).scrollToMatch(l.main,e))),e.dispatch({changes:f,selection:l,effects:d,userEvent:"input.replace"}),!0}),K=W((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let i of t.matchAll(e.state,1e9)){let{from:e,to:r,precise:o}=i;o&&n.push({from:e,to:r,insert:t.getReplacement(i)})}if(!n.length)return!1;let r=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:i.Lz.announce.of(r),userEvent:"input.replace.all"}),!0});function _(e){return e.state.facet(S).createPanel(e)}function U(e,t){var n,i,r,o,s;let a=e.selection.main,l=a.empty||a.to>a.from+100?"":e.sliceDoc(a.from,a.to);if(t&&!l)return t;let c=e.facet(S);return new C({search:(null!==(n=null==t?void 0:t.literal)&&void 0!==n?n:c.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:null!==(i=null==t?void 0:t.caseSensitive)&&void 0!==i?i:c.caseSensitive,literal:null!==(r=null==t?void 0:t.literal)&&void 0!==r?r:c.literal,regexp:null!==(o=null==t?void 0:t.regexp)&&void 0!==o?o:c.regexp,wholeWord:null!==(s=null==t?void 0:t.wholeWord)&&void 0!==s?s:c.wholeWord})}function $(e){let t=(0,i.ld)(e,_);return t&&t.dom.querySelector("[main-field]")}function Y(e){let t=$(e);t&&t==e.root.activeElement&&t.select()}const G=e=>{let t=e.state.field(R,!1);if(t&&t.panel){let n=$(e);if(n&&n!=e.root.activeElement){let i=U(e.state,t.query.spec);i.valid&&e.dispatch({effects:E.of(i)}),n.focus(),n.select()}}else e.dispatch({effects:[B.of(!0),t?E.of(U(e.state,t.query.spec)):r.Pe.appendConfig.of(ie)]});return!0},X=e=>{let t=e.state.field(R,!1);if(!t||!t.panel)return!1;let n=(0,i.ld)(e,_);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:B.of(!1)}),!0},J=[{key:"Mod-f",run:G,scope:"editor search-panel"},{key:"F3",run:H,shift:q,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:H,shift:q,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:X,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:i,to:o}=n.main,s=[],l=0;for(let t=new a(e.doc,e.sliceDoc(i,o));!t.next().done;){if(s.length>1e3)return!1;t.value.from==i&&(l=s.length),s.push(r.OF.range(t.value.from,t.value.to))}return t(e.update({selection:r.OF.create(s,l),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:o,result:s}=(0,i.ui)(e,{label:t.phrase("Go to line"),input:{type:"text",name:"line",value:n},focus:!0,submitLabel:t.phrase("go")});return s.then(n=>{let s=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!s)return void e.dispatch({effects:o});let a=t.doc.lineAt(t.selection.main.head),[,l,c,h,u]=s,d=h?+h.slice(1):0,f=c?+c:a.number;if(c&&u){let e=f/100;l&&(e=e*("-"==l?-1:1)+a.number/t.doc.lines),f=Math.round(t.doc.lines*e)}else c&&l&&(f=f*("-"==l?-1:1)+a.number);let p=t.doc.line(Math.max(1,Math.min(t.doc.lines,f))),m=r.OF.cursor(p.from+Math.max(0,Math.min(d,p.length)));e.dispatch({effects:[o,i.Lz.scrollIntoView(m.from,{y:"center"})],selection:m})}),!0}},{key:"Mod-d",run:({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return(({state:e,dispatch:t})=>{let{selection:n}=e,i=r.OF.create(n.ranges.map(t=>e.wordAt(t.head)||r.OF.cursor(t.head)),n.mainIndex);return!i.eq(n)&&(t(e.update({selection:i})),!0)})({state:e,dispatch:t});let o=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=o))return!1;let s=function(e,t){let{main:n,ranges:i}=e.selection,r=e.wordAt(n.head),o=r&&r.from==n.from&&r.to==n.to;for(let n=!1,r=new a(e.doc,t,i[i.length-1].to);;){if(r.next(),!r.done){if(n&&i.some(e=>e.from==r.value.from))continue;if(o){let t=e.wordAt(r.value.from);if(!t||t.from!=r.value.from||t.to!=r.value.to)continue}return r.value}if(n)return null;r=new a(e.doc,t,0,Math.max(0,i[i.length-1].from-1)),n=!0}}(e,o);return!!s&&(t(e.update({selection:e.selection.addRange(r.OF.range(s.from,s.to),!1),effects:i.Lz.scrollIntoView(s.to)})),!0)},preventDefault:!0}];class Z{constructor(e){this.view=e;let t=this.query=e.state.field(R).query.spec;function n(e,t,n){return(0,o.A)("button",{class:"cm-button",name:e,onclick:t,type:"button"},n)}this.commit=this.commit.bind(this),this.searchField=(0,o.A)("input",{value:t.search,placeholder:Q(e,"Find"),"aria-label":Q(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=(0,o.A)("input",{value:t.replace,placeholder:Q(e,"Replace"),"aria-label":Q(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=(0,o.A)("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=(0,o.A)("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=(0,o.A)("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit}),this.dom=(0,o.A)("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,n("next",()=>H(e),[Q(e,"next")]),n("prev",()=>q(e),[Q(e,"previous")]),n("select",()=>V(e),[Q(e,"all")]),(0,o.A)("label",null,[this.caseField,Q(e,"match case")]),(0,o.A)("label",null,[this.reField,Q(e,"regexp")]),(0,o.A)("label",null,[this.wordField,Q(e,"by word")]),...e.state.readOnly?[]:[(0,o.A)("br"),this.replaceField,n("replace",()=>j(e),[Q(e,"replace")]),n("replaceAll",()=>K(e),[Q(e,"replace all")])],(0,o.A)("button",{name:"close",onclick:()=>X(e),"aria-label":Q(e,"close"),type:"button"},["×"])])}commit(){let e=new C({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:E.of(e)}))}keydown(e){(0,i.TS)(this.view,e,"search-panel")?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?q:H)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),j(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(E)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(S).top}}function Q(e,t){return e.state.phrase(t)}const ee=/[\s\.,:;?!]/;function te(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),o=e.state.doc.lineAt(n).to,s=Math.max(r.from,t-30),a=Math.min(o,n+30),l=e.state.sliceDoc(s,a);if(s!=r.from)for(let e=0;e<30;e++)if(!ee.test(l[e+1])&&ee.test(l[e])){l=l.slice(e);break}if(a!=o)for(let e=l.length-1;e>l.length-30;e--)if(!ee.test(l[e-1])&&ee.test(l[e])){l=l.slice(0,e);break}return i.Lz.announce.of(`${e.state.phrase("current match")}. ${l} ${e.state.phrase("on line")} ${r.number}.`)}const ne=i.Lz.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"}}),ie=[R,r.Nb.low(F),ne];n.d(t,["Eo",0,J])},2701(e,t,n){n.d(t,{$t:()=>me,DA:()=>ie,EY:()=>r,FB:()=>be,Fh:()=>b,Gu:()=>w,Je:()=>de,MK:()=>g,N1:()=>d,OF:()=>D,Pe:()=>re,Q6:()=>ve,QR:()=>ge,UJ:()=>ne,VR:()=>k,YH:()=>te,ZX:()=>oe,iR:()=>v,kn:()=>Pe,om:()=>xe,sU:()=>W,sj:()=>E,vB:()=>Se,vS:()=>m,xx:()=>j,y$:()=>Re,yn:()=>O,zK:()=>p});var i=n(5219);class r{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=f(this,e,t);let i=[];return this.decompose(0,e,i,2),n.length&&n.decompose(0,n.length,i,3),this.decompose(t,this.length,i,1),s.from(i,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=f(this,e,t);let n=[];return this.decompose(e,t,n,0),s.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),i=new c(this),r=new c(e);for(let e=t,o=t;;){if(i.next(e),r.next(e),e=0,i.lineBreak!=r.lineBreak||i.done!=r.done||i.value!=r.value)return!1;if(o+=i.value.length,i.done||o>=n)return!0}}iter(e=1){return new c(this,e)}iterRange(e,t=this.length){return new h(this,e,t)}iterLines(e,t){let n;if(null==e)n=this.iter();else{null==t&&(t=this.lines+1);let i=this.line(e).from;n=this.iterRange(i,Math.max(i,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new u(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(0==e.length)throw new RangeError("A document must have at least one line");return 1!=e.length||e[0]?e.length<=32?new o(e):s.from(o.split(e,[])):r.empty}}class o extends r{constructor(e,t=function(e){let t=-1;for(let n of e)t+=n.length+1;return t}(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,i){for(let r=0;;r++){let o=this.text[r],s=i+o.length;if((t?n:s)>=e)return new d(i,s,n,o);i=s+1,n++}}decompose(e,t,n,i){let r=e<=0&&t>=this.length?this:new o(l(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(1&i){let e=n.pop(),t=a(r.text,e.text.slice(),0,r.length);if(t.length<=32)n.push(new o(t,e.length+r.length));else{let e=t.length>>1;n.push(new o(t.slice(0,e)),new o(t.slice(e)))}}else n.push(r)}replace(e,t,n){if(!(n instanceof o))return super.replace(e,t,n);[e,t]=f(this,e,t);let i=a(this.text,a(n.text,l(this.text,0,e)),t),r=this.length+n.length-(t-e);return i.length<=32?new o(i,r):s.from(o.split(i,[]),r)}sliceString(e,t=this.length,n="\n"){[e,t]=f(this,e,t);let i="";for(let r=0,o=0;r<=t&&oe&&o&&(i+=n),er&&(i+=s.slice(Math.max(0,e-r),t-r)),r=a+1}return i}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],i=-1;for(let r of e)n.push(r),i+=r.length+1,32==n.length&&(t.push(new o(n,i)),n=[],i=-1);return i>-1&&t.push(new o(n,i)),t}}class s extends r{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,i){for(let r=0;;r++){let o=this.children[r],s=i+o.length,a=n+o.lines-1;if((t?a:s)>=e)return o.lineInner(e,t,n,i);i=s+1,n=a+1}}decompose(e,t,n,i){for(let r=0,o=0;o<=t&&r=o){let r=i&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!r?n.push(s):s.decompose(e-o,t-o,n,r)}o=a+1}}replace(e,t,n){if([e,t]=f(this,e,t),n.lines=r&&t<=a){let l=o.replace(e-r,t-r,n),c=this.lines-o.lines+l.lines;if(l.lines>4&&l.lines>c>>6){let r=this.children.slice();return r[i]=l,new s(r,this.length-(t-e)+n.length)}return super.replace(r,a,l)}r=a+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n="\n"){[e,t]=f(this,e,t);let i="";for(let r=0,o=0;re&&r&&(i+=n),eo&&(i+=s.sliceString(e-o,t-o,n)),o=a+1}return i}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof s))return 0;let n=0,[i,r,o,a]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=t,r+=t){if(i==o||r==a)return n;let s=this.children[i],l=e.children[r];if(s!=l)return n+s.scanIdentical(l,t);n+=s.length+1}}static from(e,t=e.reduce((e,t)=>e+t.length+1,-1)){let n=0;for(let t of e)n+=t.lines;if(n<32){let n=[];for(let t of e)t.flatten(n);return new o(n,t)}let i=Math.max(32,n>>5),r=i<<1,a=i>>1,l=[],c=0,h=-1,u=[];function d(e){let t;if(e.lines>r&&e instanceof s)for(let t of e.children)d(t);else e.lines>a&&(c>a||!c)?(f(),l.push(e)):e instanceof o&&c&&(t=u[u.length-1])instanceof o&&e.lines+t.lines<=32?(c+=e.lines,h+=e.length+1,u[u.length-1]=new o(t.text.concat(e.text),t.length+1+e.length)):(c+e.lines>i&&f(),c+=e.lines,h+=e.length+1,u.push(e))}function f(){0!=c&&(l.push(1==u.length?u[0]:s.from(u,h)),h=-1,c=u.length=0)}for(let t of e)d(t);return f(),1==l.length?l[0]:new s(l,t)}}function a(e,t,n=0,i=1e9){for(let r=0,o=0,s=!0;o=n&&(l>i&&(a=a.slice(0,i-r)),r0?1:(e instanceof o?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,i=this.nodes[n],r=this.offsets[n],s=r>>1,a=i instanceof o?i.text.length:i.children.length;if(s==(t>0?a:0)){if(0==n)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&r)==(t>0?0:1)){if(this.offsets[n]+=t,0==e)return this.lineBreak=!0,this.value="\n",this;e--}else if(i instanceof o){let r=i.text[s+(t<0?-1:0)];if(this.offsets[n]+=t,r.length>Math.max(0,e))return this.value=0==e?r:t>0?r.slice(e):r.slice(0,r.length-e),this;e-=r.length}else{let r=i.children[s+(t<0?-1:0)];e>r.length?(e-=r.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(r),this.offsets.push(t>0?1:(r instanceof o?r.text.length:r.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class h{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new c(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:i}=this.cursor.next(e);return this.pos+=(i.length+e)*t,this.value=i.length<=n?i:t<0?i.slice(i.length-n):i.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class u{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:i}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(r.prototype[Symbol.iterator]=function(){return this.iter()},c.prototype[Symbol.iterator]=h.prototype[Symbol.iterator]=u.prototype[Symbol.iterator]=function(){return this});class d{constructor(e,t,n,i){this.from=e,this.to=t,this.number=n,this.text=i}get length(){return this.to-this.from}}function f(e,t,n){return[t=Math.max(0,Math.min(e.length,t)),Math.max(t,Math.min(e.length,n))]}function p(e,t,n=!0,r=!0){return(0,i.z)(e,t,n,r)}function m(e,t){let n=e.charCodeAt(t);if(!((i=n)>=55296&&i<56320&&t+1!=e.length))return n;var i;let r=e.charCodeAt(t+1);return function(e){return e>=56320&&e<57344}(r)?r-56320+(n-55296<<10)+65536:n}function g(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10),56320+(1023&e)))}function b(e){return e<65536?1:2}const y=/\r\n?|\n/;var v=function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e}(v||(v={}));class w{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return r+(e-i);r+=s}else{if(n!=v.Simple&&l>=e&&(n==v.TrackDel&&ie||n==v.TrackBefore&&ie))return null;if(l>e||l==e&&t<0&&!s)return e==i||t<0?r:r+a;r+=a}i=l}if(e>i)throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);return r}touchesRange(e,t=e){for(let n=0,i=0;n=0&&i<=t&&r>=e)return!(it)||"cover";i=r}return!1}toString(){let e="";for(let t=0;t=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(e=>"number"!=typeof e))throw new RangeError("Invalid JSON representation of ChangeDesc");return new w(e)}static create(e){return new w(e)}}class k extends w{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return C(this,(t,n,i,r,o)=>e=e.replace(i,i+(n-t),o),!1),e}mapDesc(e,t=!1){return A(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let i=0,o=0;i=0){t[i]=a,t[i+1]=s;let l=i>>1;for(;n.length0&&S(n,t,r.text),r.forward(e),s+=e}let l=e[o++];for(;s>1].toJSON()))}return e}static of(e,t,n){let i=[],o=[],s=0,a=null;function l(e=!1){if(!e&&!i.length)return;sa||e<0||a>t)throw new RangeError(`Invalid change range ${e} to ${a} (in doc of length ${t})`);let u=h?"string"==typeof h?r.of(h.split(n||y)):h:r.empty,d=u.length;if(e==a&&0==d)return;es&&x(i,e-s,-1),x(i,a-e,d),S(o,i,u),s=a}}(e),l(!a),a}static empty(e){return new k(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let i=0;it&&"string"!=typeof e))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==o.length)t.push(o[0],0);else{for(;n.length=0&&n<=0&&n==e[r+1]?e[r]+=t:r>=0&&0==t&&0==e[r]?e[r+1]+=n:i?(e[r]+=t,e[r+1]+=n):e.push(t,n)}function S(e,t,n){if(0==n.length)return;let i=t.length-2>>1;if(i>1])),!(n||a==e.sections.length||e.sections[a+1]<0);)l=e.sections[a++],c=e.sections[a++];t(o,h,s,u,d),o=h,s=u}}}function A(e,t,n,i=!1){let r=[],o=i?[]:null,s=new T(e),a=new T(t);for(let e=-1;;){if(s.done&&a.len||a.done&&s.len)throw new Error("Mismatched change set lengths");if(-1==s.ins&&-1==a.ins){let e=Math.min(s.len,a.len);x(r,e,-1),s.forward(e),a.forward(e)}else if(a.ins>=0&&(s.ins<0||e==s.i||0==s.off&&(a.len=0&&e=0)){if(s.done&&a.done)return o?k.createSet(r,o):w.create(r);throw new Error("Mismatched change set lengths")}{let t=0,n=s.len;for(;n;)if(-1==a.ins){let e=Math.min(n,a.len);t+=e,n-=e,a.forward(e)}else{if(!(0==a.ins&&a.lent||s.ins>=0&&s.len>t)&&(e||i.length>n),o.forward2(t),s.forward(t)}}else x(i,0,s.ins,e),r&&S(r,i,s.text),s.next()}}class T{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?r.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?r.empty:t[n].slice(this.off,null==e?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){-1==this.ins?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class O{constructor(e,t,n,i){this.from=e,this.to=t,this.flags=n,this.goalColumn=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 undirectional(){return(64&this.flags)>0}get bidiLevel(){let e=7&this.flags;return 7==e?null:e}map(e,t=-1){let n,i;return this.empty?n=i=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),i=e.mapPos(this.to,-1)),n==this.from&&i==this.to?this:new O(n,i,this.flags,this.goalColumn)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return D.range(e,t,void 0,void 0,n);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return D.range(this.anchor,i,void 0,void 0,n)}eq(e,t=!1){return!(this.anchor!=e.anchor||this.head!=e.head||this.goalColumn!=e.goalColumn||t&&this.empty&&this.assoc!=e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||"number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid JSON representation for SelectionRange");return D.range(e.anchor,e.head)}static create(e,t,n,i){return new O(e,t,n,i)}}class D{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:D.create(this.ranges.map(n=>n.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;ne.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||"number"!=typeof e.main||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new D(e.ranges.map(e=>O.fromJSON(e)),e.main)}static single(e,t=e){return new D([D.range(e,t)],0)}static create(e,t=0){if(0==e.length)throw new RangeError("A selection needs at least one range");for(let n=0,i=0;ie.from-t.from),t=e.indexOf(n);for(let n=1;ni.head?D.range(s,o):D.range(o,s))}}return new D(e,t)}}function L(e,t){for(let n of e.ranges)if(n.to>t)throw new RangeError("Selection points outside of document")}let z=0;class E{constructor(e,t,n,i,r){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=i,this.id=z++,this.default=e([]),this.extensions="function"==typeof r?r(this):r}get reader(){return this}static define(e={}){return new E(e.combine||(e=>e),e.compareInput||((e,t)=>e===t),e.compare||(e.combine?(e,t)=>e===t:B),!!e.static,e.enables)}of(e){return new R([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new R(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new R(e,this,2,t)}from(e,t){return t||(t=e=>e),this.compute([e],n=>t(n.field(e)))}}function B(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}class R{constructor(e,t,n,i){this.dependencies=e,this.facet=t,this.type=n,this.value=i,this.id=z++}dynamicSlot(e){var t;let n=this.value,i=this.facet.compareInput,r=this.id,o=e[r]>>1,s=2==this.type,a=!1,l=!1,c=[];for(let n of this.dependencies)"doc"==n?a=!0:"selection"==n?l=!0:1&(null!==(t=e[n.id])&&void 0!==t?t:1)||c.push(e[n.id]);return{create:e=>(e.values[o]=n(e),1),update(e,t){if(a&&t.docChanged||l&&(t.docChanged||t.selection)||I(e,c)){let t=n(e);if(s?!P(t,e.values[o],i):!i(t,e.values[o]))return e.values[o]=t,1}return 0},reconfigure:(e,t)=>{let a,l=t.config.address[r];if(null!=l){let r=$(t,l);if(this.dependencies.every(n=>n instanceof E?t.facet(n)===e.facet(n):!(n instanceof W)||t.field(n,!1)==e.field(n,!1))||(s?P(a=n(e),r,i):i(a=n(e),r)))return e.values[o]=r,0}else a=n(e);return e.values[o]=a,1}}}get extension(){return this}}function P(e,t,n){if(e.length!=t.length)return!1;for(let i=0;ie[t.id]),r=n.map(e=>e.type),o=i.filter(e=>!(1&e)),s=e[t.id]>>1;function a(e){let n=[];for(let t=0;te===t),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(F).find(e=>e.field==this);return((null==t?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let i=e.values[t],r=this.updateF(i,n);return this.compareF(i,r)?0:(e.values[t]=r,1)},reconfigure:(e,n)=>{let i,r=e.facet(F),o=n.facet(F);return(i=r.find(e=>e.field==this))&&i!=o.find(e=>e.field==this)?(e.values[t]=i.create(e),1):null!=n.config.address[this.id]?(e.values[t]=n.field(this),0):(e.values[t]=this.create(e),1)}}}init(e){return[this,F.of({field:this,create:e})]}get extension(){return this}}function H(e){return t=>new V(t,e)}const q={highest:H(0),high:H(1),default:H(2),low:H(3),lowest:H(4)};class V{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}}class j{of(e){return new K(this,e)}reconfigure(e){return j.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class K{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}}class _{constructor(e,t,n,i,r,o){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=i,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,t,n){let i=[],r=Object.create(null),o=new Map;for(let n of function(e,t,n){let i=[[],[],[],[],[]],r=new Map;return function e(o,s){let a=r.get(o);if(null!=a){if(a<=s)return;let e=i[a].indexOf(o);e>-1&&i[a].splice(e,1),o instanceof K&&n.delete(o.compartment)}if(r.set(o,s),Array.isArray(o))for(let t of o)e(t,s);else if(o instanceof K){if(n.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let i=t.get(o.compartment)||o.inner;n.set(o.compartment,i),e(i,s)}else if(o instanceof V)e(o.inner,o.prec);else if(o instanceof W)i[s].push(o),o.provides&&e(o.provides,s);else if(o instanceof R)i[s].push(o),o.facet.extensions&&e(o.facet.extensions,2);else{let t=o.extension;if(!t)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(t==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);e(t,s)}}(e,2),i.reduce((e,t)=>e.concat(t))}(e,t,o))n instanceof W?i.push(n):(r[n.facet.id]||(r[n.facet.id]=[])).push(n);let s=Object.create(null),a=[],l=[];for(let e of i)s[e.id]=l.length<<1,l.push(t=>e.slot(t));let c=null==n?void 0:n.config.facets;for(let e in r){let t=r[e],i=t[0].facet,o=c&&c[e]||[];if(t.every(e=>0==e.type))if(s[i.id]=a.length<<1|1,B(o,t))a.push(n.facet(i));else{let e=i.combine(t.map(e=>e.value));a.push(n&&i.compare(e,n.facet(i))?n.facet(i):e)}else{for(let e of t)0==e.type?(s[e.id]=a.length<<1|1,a.push(e.value)):(s[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));s[i.id]=l.length<<1,l.push(e=>N(e,i,t))}}let h=l.map(e=>e(s));return new _(e,o,h,s,a,r)}}function U(e,t){if(1&t)return 2;let n=t>>1,i=e.status[n];if(4==i)throw new Error("Cyclic dependency between fields and/or facets");if(2&i)return i;e.status[n]=4;let r=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|r}function $(e,t){return 1&t?e.config.staticValues[t>>1]:e.values[t>>1]}const Y=E.define(),G=E.define({combine:e=>e.some(e=>e),static:!0}),X=E.define({combine:e=>e.length?e[0]:void 0,static:!0}),J=E.define(),Z=E.define(),Q=E.define(),ee=E.define({combine:e=>!!e.length&&e[0]});class te{constructor(e,t){this.type=e,this.value=t}static define(){return new ne}}class ne{of(e){return new te(this,e)}}class ie{constructor(e){this.map=e}of(e){return new re(this,e)}}class re{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return void 0===t?void 0:t==this.value?this:new re(this.type,t)}is(e){return this.type==e}static define(e={}){return new ie(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let i of e){let e=i.map(t);e&&n.push(e)}return n}}re.reconfigure=re.define(),re.appendConfig=re.define();class oe{constructor(e,t,n,i,r,o){this.startState=e,this.changes=t,this.selection=n,this.effects=i,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,n&&L(n,t.newLength),r.some(e=>e.type==oe.time)||(this.annotations=r.concat(oe.time.of(Date.now())))}static create(e,t,n,i,r,o){return new oe(e,t,n,i,r,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(oe.userEvent);return!(!t||!(t==e||t.length>e.length&&t.slice(0,e.length)==e&&"."==t[e.length]))}}function se(e,t){let n=[];for(let i=0,r=0;;){let o,s;if(i=e[i]))o=e[i++],s=e[i++];else{if(!(r=0;r--){let o=n[r](e);o&&Object.keys(o).length&&(i=ae(i,le(t,o,e.changes.newLength),!0))}return i==e?e:oe.create(t,e.changes,e.selection,i.effects,i.annotations,i.scrollIntoView)}(n?function(e){let t=e.startState,n=!0;for(let i of t.facet(J)){let t=i(e);if(!1===t){n=!1;break}Array.isArray(t)&&(n=!0===n?t:se(n,t))}if(!0!==n){let i,r;if(!1===n)r=e.changes.invertedDesc,i=k.empty(t.doc.length);else{let t=e.changes.filter(n);i=t.changes,r=t.filtered.mapDesc(t.changes).invertedDesc}e=oe.create(t,i,e.selection&&e.selection.map(r),re.mapEffects(e.effects,r),e.annotations,e.scrollIntoView)}let i=t.facet(Z);for(let n=i.length-1;n>=0;n--){let r=i[n](e);e=r instanceof oe?r:Array.isArray(r)&&1==r.length&&r[0]instanceof oe?r[0]:ce(t,ue(r),!1)}return e}(r):r)}oe.time=te.define(),oe.userEvent=te.define(),oe.addToHistory=te.define(),oe.remote=te.define();const he=[];function ue(e){return null==e?he:Array.isArray(e)?e:[e]}var de=function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(de||(de={}));const fe=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let pe;try{pe=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(e){}class me{constructor(e,t,n,i,r,o){this.config=e,this.doc=t,this.selection=n,this.values=i,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let e=0;er.set(t,e)),n=null),r.set(t.value.compartment,t.value.extension)):t.is(re.reconfigure)?(n=null,i=t.value):t.is(re.appendConfig)&&(n=null,i=ue(i).concat(t.value));n?t=e.startState.values.slice():(n=_.resolve(i,r,this),t=new me(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values);let o=e.startState.facet(G)?e.newSelection:e.newSelection.asSingle();new me(n,e.newDoc,o,t,(t,n)=>n.update(t,e),e)}replaceSelection(e){return"string"==typeof e&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:D.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),i=this.changes(n.changes),r=[n.range],o=ue(n.effects);for(let n=1;nr.spec.fromJSON(o,e)))}return me.create({doc:e.doc,selection:D.fromJSON(e.selection),extensions:t.extensions?i.concat([t.extensions]):i})}static create(e={}){let t=_.resolve(e.extensions||[],new Map),n=e.doc instanceof r?e.doc:r.of((e.doc||"").split(t.staticFacet(me.lineSeparator)||y)),i=e.selection?e.selection instanceof D?e.selection:D.single(e.selection.anchor,e.selection.head):D.single(0);return L(i,n.length),t.staticFacet(G)||(i=i.asSingle()),new me(t,n,i,t.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(me.tabSize)}get lineBreak(){return this.facet(me.lineSeparator)||"\n"}get readOnly(){return this.facet(ee)}phrase(e,...t){for(let t of this.facet(me.phrases))if(Object.prototype.hasOwnProperty.call(t,e)){e=t[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(e,n)=>{if("$"==n)return"$";let i=+(n||1);return!i||i>t.length?e:t[i-1]})),e}languageDataAt(e,t,n=-1){let i=[];for(let r of this.facet(Y))for(let o of r(this,t,n))Object.prototype.hasOwnProperty.call(o,e)&&i.push(o[e]);return i}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return n=t.length?t[0]:"",e=>{if(!/\S/.test(e))return de.Space;if(function(e){if(pe)return pe.test(e);for(let t=0;t"€"&&(n.toUpperCase()!=n.toLowerCase()||fe.test(n)))return!0}return!1}(e))return de.Word;for(let t=0;t-1)return de.Word;return de.Other};var n}wordAt(e){let{text:t,from:n,length:i}=this.doc.lineAt(e),r=this.charCategorizer(e),o=e-n,s=e-n;for(;o>0;){let e=p(t,o,!1);if(r(t.slice(e,o))!=de.Word)break;o=e}for(;se.length?e[0]:4}),me.lineSeparator=X,me.readOnly=ee,me.phrases=E.define({compare(e,t){let n=Object.keys(e),i=Object.keys(t);return n.length==i.length&&n.every(n=>e[n]==t[n])}}),me.languageData=Y,me.changeFilter=J,me.transactionFilter=Z,me.transactionExtender=Q,j.reconfigure=re.define();class be{eq(e){return this==e}range(e,t=e){return ve.create(e,t,this)}}function ye(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}be.prototype.startSide=be.prototype.endSide=0,be.prototype.point=!1,be.prototype.mapMode=v.TrackDel;class ve{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new ve(e,t,n)}}function we(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}class ke{constructor(e,t,n,i){this.from=e,this.to=t,this.value=n,this.maxPoint=i}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,i=0){let r=n?this.to:this.from;for(let o=i,s=r.length;;){if(o==s)return o;let i=o+s>>1,a=r[i]-e||(n?this.value[i].endSide:this.value[i].startSide)-t;if(i==o)return a>=0?o:s;a>=0?s=i:o=i+1}}between(e,t,n,i){for(let r=this.findIndex(t,-1e9,!0),o=this.findIndex(n,1e9,!1,r);rc||l==c&&h.startSide>0&&h.endSide<=0)continue;(c-l||h.endSide-h.startSide)<0||(o<0&&(o=l),h.point&&(s=Math.max(s,c-l)),n.push(h),i.push(l-o),r.push(c-o))}return{mapped:n.length?new ke(i,r,n,s):null,pos:o}}}class xe{constructor(e,t,n,i){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=i}static create(e,t,n,i){return new xe(e,t,n,i)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:n=!1,filterFrom:i=0,filterTo:r=this.length}=e,o=e.filter;if(0==t.length&&!o)return this;if(n&&(t=t.slice().sort(we)),this.isEmpty)return t.length?xe.of(t):this;let s=new Ae(this,null,-1).goto(0),a=0,l=[],c=new Se;for(;s.value||a=0){let e=t[a++];c.addInner(e.from,e.to,e.value)||l.push(e)}else 1==s.rangeIndex&&s.chunkIndexthis.chunkEnd(s.chunkIndex)||rs.to||r=r&&e<=r+o.length&&!1===o.between(r,e-r,t-r,n))return}this.nextLayer.between(e,t,n)}}iter(e=0){return Me.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Me.from(e).goto(t)}static compare(e,t,n,i,r=-1){let o=e.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=r),s=t.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=r),a=Ce(o,s,n),l=new Oe(o,a,r),c=new Oe(s,a,r);n.iterGaps((e,t,n)=>De(l,e,c,t,n,i)),n.empty&&0==n.length&&De(l,0,c,0,0,i)}static eq(e,t,n=0,i){null==i&&(i=999999999);let r=e.filter(e=>!e.isEmpty&&t.indexOf(e)<0),o=t.filter(t=>!t.isEmpty&&e.indexOf(t)<0);if(r.length!=o.length)return!1;if(!r.length)return!0;let s=Ce(r,o),a=new Oe(r,s,0).goto(n),l=new Oe(o,s,0).goto(n);for(;;){if(a.to!=l.to||!Le(a.active,l.active)||a.point&&(!l.point||!ye(a.point,l.point)))return!1;if(a.to>i)return!0;a.next(),l.next()}}static spans(e,t,n,i,r=-1){let o=new Oe(e,null,r).goto(t),s=t,a=o.openStart;for(;;){let e=Math.min(o.to,n);if(o.point){let n=o.activeForPoint(o.to),r=o.pointFroms&&(i.span(s,e,o.active,a),a=o.openEnd(e));if(o.to>n)return a+(o.point&&o.to>n?1:0);s=o.to,o.next()}}static of(e,t=!1){let n=new Se;for(let i of e instanceof ve?[e]:t?function(e){if(e.length>1)for(let t=e[0],n=1;n0)return e.slice().sort(we);t=i}return e}(e):e)n.add(i.from,i.to,i.value);return n.finish()}static join(e){if(!e.length)return xe.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let i=e[n];i!=xe.empty;i=i.nextLayer)t=new xe(i.chunkPos,i.chunk,t,Math.max(i.maxPoint,t.maxPoint));return t}}xe.empty=new xe([],[],null,-1),xe.empty.nextLayer=xe.empty;class Se{finishChunk(e){this.chunks.push(new ke(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new Se)).add(e,t,n)}addInner(e,t,n){let i=e-this.lastTo||n.startSide-this.last.endSide;if(i<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(i<0||(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),0))}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(xe.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return e;let t=xe.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function Ce(e,t,n){let i=new Map;for(let t of e)for(let e=0;e=this.minPoint)break}}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=n&&i.push(new Ae(o,t,n,r));return 1==i.length?i[0]:new Me(i)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let e=this.heap.length>>1;e>=0;e--)Te(this.heap,e);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)Te(this.heap,e);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),Te(this.heap,0)}}}function Te(e,t){for(let n=e[t];;){let i=1+(t<<1);if(i>=e.length)break;let r=e[i];if(i+1=0&&(r=e[i+1],i++),n.compare(r)<0)break;e[i]=n,e[t]=r,t=i}}class Oe{constructor(e,t,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Me.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){ze(this.active,e),ze(this.activeTo,e),ze(this.activeRank,e),this.minActive=Be(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:i,rank:r}=this.cursor;for(;t0;)t++;Ee(this.active,t,n),Ee(this.activeTo,t,i),Ee(this.activeRank,t,r),e&&Ee(e,t,this.cursor.from),this.minActive=Be(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let i=this.minActive;if(i>-1&&(this.activeTo[i]-this.cursor.from||this.active[i].endSide-this.cursor.startSide)<0){if(this.activeTo[i]>e){this.to=this.activeTo[i],this.endSide=this.active[i].endSide;break}this.removeActive(i),n&&ze(n,i)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}{let e=this.cursor.value;if(e.point){if(!(t&&this.cursor.to==this.to&&this.cursor.from=0&&n[t]=0&&!(this.activeRank[n]e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}}function De(e,t,n,i,r,o){e.goto(t),n.goto(i);let s=i+r,a=i,l=i-t,c=!!o.boundChange;for(let t=!1;;){let i=e.to+l-n.to,r=i||e.endSide-n.endSide,h=r<0?e.to+l:n.to,u=Math.min(h,s);if(e.point||n.point?(e.point&&n.point&&ye(e.point,n.point)&&Le(e.activeForPoint(e.to),n.activeForPoint(n.to))||o.comparePoint(a,u,e.point,n.point),t=!1):(t&&o.boundChange(a),u>a&&!Le(e.active,n.active)&&o.compareRange(a,u,e.active,n.active),c&&us)break;a=h,r<=0&&e.next(),r>=0&&n.next()}}function Le(e,t){if(e.length!=t.length)return!1;for(let n=0;n=t;n--)e[n+1]=e[n];e[t]=n}function Be(e,t){let n=-1,i=1e9;for(let r=0;r=t)return i;if(i==e.length)break;r+=9==e.charCodeAt(i)?n-r%n:1,i=p(e,i)}return!0===i?-1:e.length}n.d(t,["Nb",0,q])},9747(e,t,n){n.d(t,{$G:()=>Ni,$K:()=>ko,A:()=>$i,BE:()=>sr,C3:()=>jr,D4:()=>pr,Eg:()=>Ir,HJ:()=>br,Hm:()=>ao,Ip:()=>Di,Lz:()=>pi,N$:()=>tr,NZ:()=>M,OP:()=>ne,Pq:()=>qr,TS:()=>Ai,Ux:()=>Rr,VH:()=>Ii,Wu:()=>Ao,X3:()=>tt,Yq:()=>Lo,Z9:()=>qe,_B:()=>A,ab:()=>Pr,cU:()=>oo,c_:()=>Ne,dT:()=>Gi,dz:()=>ar,l_:()=>E,ld:()=>Kr,n6:()=>Nr,qd:()=>Ri,qf:()=>ur,rC:()=>Xr,tF:()=>de,uF:()=>On,ui:()=>Gr,ut:()=>Hr,vX:()=>wr,wJ:()=>eo,wu:()=>Eo,xO:()=>C});var i=n(2701),r=n(2951),o=n(396),s=n(9786);let a="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},l="undefined"!=typeof document?document:{documentElement:{style:{}}};const c=/Edge\/(\d+)/.exec(a.userAgent),h=/MSIE \d/.test(a.userAgent),u=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(a.userAgent),d=!!(h||u||c),f=!d&&/gecko\/(\d+)/i.test(a.userAgent),p=!d&&/Chrome\/(\d+)/.exec(a.userAgent),m="webkitFontSmoothing"in l.documentElement.style,g=!d&&/Apple Computer/.test(a.vendor),b=g&&(/Mobile\/\w+/.test(a.userAgent)||a.maxTouchPoints>2);var y={mac:b||/Mac/.test(a.platform),windows:/Win/.test(a.platform),linux:/Linux|X11/.test(a.platform),ie:d,ie_version:h?l.documentMode||6:u?+u[1]:c?+c[1]:0,gecko:f,gecko_version:f?+(/Firefox\/(\d+)/.exec(a.userAgent)||[0,0])[1]:0,chrome:!!p,chrome_version:p?+p[1]:0,ios:b,android:/Android\b/.test(a.userAgent),webkit:m,webkit_version:m?+(/\bAppleWebKit\/(\d+)/.exec(a.userAgent)||[0,0])[1]:0,safari:g,safari_version:g?+(/\bVersion\/(\d+(\.\d+)?)/.exec(a.userAgent)||[0,0])[1]:0,tabSize:null!=l.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};function v(e,t){for(let n in e)"class"==n&&t.class?t.class+=" "+e.class:"style"==n&&t.style?t.style+=";"+e.style:t[n]=e[n];return t}const w=Object.create(null);function k(e,t,n){if(e==t)return!0;e||(e=w),t||(t=w);let i=Object.keys(e),r=Object.keys(t);if(i.length-(n&&i.indexOf(n)>-1?1:0)!=r.length-(n&&r.indexOf(n)>-1?1:0))return!1;for(let o of i)if(o!=n&&(-1==r.indexOf(o)||e[o]!==t[o]))return!1;return!0}function x(e,t,n){let i=!1;if(t)for(let r in t)n&&r in n||(i=!0,"style"==r?e.style.cssText="":e.removeAttribute(r));if(n)for(let r in n)t&&t[r]==n[r]||(i=!0,"style"==r?e.style.cssText=n[r]:e.setAttribute(r,n[r]));return i}function S(e){let t=Object.create(null);for(let n=0;n0?3e8:-4e8:t>0?1e8:-1e8,new D(e,t,t,n,e.widget||null,!1)}static replace(e){let t,n,i=!!e.block;if(e.isBlockGap)t=-5e8,n=4e8;else{let{start:r,end:o}=L(e,i);t=(r?i?-3e8:-1:5e8)-1,n=1+(o?i?2e8:1:-6e8)}return new D(e,t,n,i,e.widget||null,!0)}static line(e){return new O(e)}static set(e,t=!1){return i.om.of(e,t)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}M.none=i.om.empty;class T extends M{constructor(e){let{start:t,end:n}=L(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?v(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||w}eq(e){return this==e||e instanceof T&&this.tagName==e.tagName&&k(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}T.prototype.point=!1;class O extends M{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof O&&this.spec.class==e.spec.class&&k(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}O.prototype.mapMode=i.iR.TrackBefore,O.prototype.point=!0;class D extends M{constructor(e,t,n,r,o,s){super(t,n,o,e),this.block=r,this.isReplace=s,this.mapMode=r?t<=0?i.iR.TrackBefore:i.iR.TrackAfter:i.iR.TrackDel}get type(){return this.startSide!=this.endSide?A.WidgetRange:this.startSide<=0?A.WidgetBefore:A.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof D&&((t=this.widget)==(n=e.widget)||!!(t&&n&&t.compare(n)))&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide;var t,n}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}function L(e,t=!1){let{inclusiveStart:n,inclusiveEnd:i}=e;return null==n&&(n=e.inclusive),null==i&&(i=e.inclusive),{start:null!=n?n:t,end:null!=i?i:t}}function z(e,t,n,i=0){let r=n.length-1;r>=0&&n[r]+i>=e?n[r]=Math.max(n[r],t):n.push(e,t)}D.prototype.point=!0;class E extends i.FB{constructor(e,t,n){super(),this.tagName=e,this.attributes=t,this.rank=n}eq(e){return e==this||e instanceof E&&this.tagName==e.tagName&&k(this.attributes,e.attributes)}static create(e){return new E(e.tagName,e.attributes||w,null==e.rank?50:Math.max(0,Math.min(e.rank,100)))}static set(e,t=!1){return i.om.of(e,t)}}function B(e){let t;return t=11==e.nodeType?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function R(e,t){return!!t&&(e==t||e.contains(1!=t.nodeType?t.parentNode:t))}function P(e,t){if(!t.anchorNode)return!1;try{return R(e,t.anchorNode)}catch(e){return!1}}function I(e){return 3==e.nodeType?X(e,0,e.nodeValue.length).getClientRects():1==e.nodeType?e.getClientRects():[]}function N(e,t,n,i){return!!n&&(H(e,t,n,i,-1)||H(e,t,n,i,1))}function F(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t}function W(e){return 1==e.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function H(e,t,n,i,r){for(;;){if(e==n&&t==i)return!0;if(t==(r<0?0:q(e))){if("DIV"==e.nodeName)return!1;let n=e.parentNode;if(!n||1!=n.nodeType)return!1;t=F(e)+(r<0?0:1),e=n}else{if(1!=e.nodeType)return!1;if(1==(e=e.childNodes[t+(r<0?-1:0)]).nodeType&&"false"==e.contentEditable)return!1;t=r<0?q(e):0}}}function q(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function V(e,t){let{left:n,right:i}=e;if(n==i)return e;let r=t?n:i;return{left:r,right:r,top:e.top,bottom:e.bottom}}function j(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function K(e,t){let n=t.width/e.offsetWidth,i=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.width-e.offsetWidth)<1)&&(n=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(t.height-e.offsetHeight)<1)&&(i=1),{scaleX:n,scaleY:i}}function _(e,t=!0){let n=e.ownerDocument,i=null,r=null;for(let o=e.parentNode;o&&o!=n.body&&(t&&!i||!r);)if(1==o.nodeType)!r&&o.scrollHeight>o.clientHeight&&(r=o),t&&!i&&o.scrollWidth>o.clientWidth&&(i=o),o=o.assignedSlot||o.parentNode;else{if(11!=o.nodeType)break;o=o.host}return{x:i,y:r}}E.prototype.startSide=E.prototype.endSide=-1;class U{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?q(t):0),n,Math.min(e.focusOffset,n?q(n):0))}set(e,t,n,i){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=i}}let $,Y=null;function G(e){if(e.setActive)return e.setActive();if(Y)return e.focus(Y);let t=[];for(let n=e;n&&(t.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(e.focus(null==Y?{get preventScroll(){return Y={preventScroll:!0},!0}}:void 0),!Y){Y=!1;for(let e=0;eMath.max(0,e.document.documentElement.scrollHeight-e.innerHeight-4):e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function Q(e,t){for(let n=e,i=t;;){if(3==n.nodeType&&i>0)return{node:n,offset:i};if(1==n.nodeType&&i>0){if("false"==n.contentEditable)return null;n=n.childNodes[i-1],i=q(n)}else{if(!n.parentNode||W(n))return null;i=F(n),n=n.parentNode}}}function ee(e,t){for(let n=e,i=t;;){if(3==n.nodeType&&i=26&&(Y=!1);class te{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(e,t){return new te(e.parentNode,F(e),t)}static after(e,t){return new te(e.parentNode,F(e)+1,t)}}var ne=function(e){return e[e.LTR=0]="LTR",e[e.RTL=1]="RTL",e}(ne||(ne={}));const ie=ne.LTR,re=ne.RTL;function oe(e){let t=[];for(let n=0;n=t){if(s.level==n)return o;(r<0||(0!=i?i<0?s.fromt:e[r].level>s.level))&&(r=o)}}if(r<0)throw new RangeError("Index out of range");return r}}function fe(e,t){if(e.length!=t.length)return!1;for(let n=0;nl&&s.push(new de(l,p.from,d)),ge(e,p.direction==ie!=!(d%2)?i+1:i,r,p.inner,p.from,p.to,s),l=p.to),f=p.to}else{if(f==n||(t?pe[f]!=a:pe[f]==a))break;f++}u?me(e,l,f,i+1,r,u,s):lt;){let n=!0,h=!1;if(!c||l>o[c-1].to){let e=pe[l-1];e!=a&&(n=!1,h=16==e)}let u=n||1!=a?null:[],d=n?i:i+1,f=l;e:for(;;)if(c&&f==o[c-1].to){if(h)break e;let p=o[--c];if(!n)for(let e=p.from,n=c;;){if(e==t)break e;if(!n||o[n-1].to!=e){if(pe[e-1]==a)break e;break}e=o[--n].from}u?u.push(p):(p.to=0;e-=3)if(ce[e+1]==-n){let t=ce[e+2],n=2&t?r:4&t?1&t?o:r:0;n&&(pe[s]=pe[ce[e]]=n),a=e;break}}else{if(189==ce.length)break;ce[a++]=s,ce[a++]=t,ce[a++]=l}else if(2==(i=pe[s])||1==i){let e=i==r;l=e?0:1;for(let t=a-3;t>=0;t-=3){let n=ce[t+2];if(2&n)break;if(e)ce[t+2]|=2;else{if(4&n)break;ce[t+2]|=4}}}}}(e,r,o,i,a),function(e,t,n,i){for(let r=0,o=i;r<=n.length;r++){let s=r?n[r-1].to:e,a=rl;)t==o&&(t=n[--i].from,o=i?n[i-1].to:e),pe[--t]=h;l=s}else o=s,l++}}}(r,o,i,a),me(e,r,o,t,n,i,s)}function be(e,t,n){if(!e)return[new de(0,0,t==re?1:0)];if(t==ie&&!n.length&&!ue.test(e))return ye(e.length);if(n.length)for(;e.length>pe.length;)pe[pe.length]=256;let i=[],r=t==ie?0:1;return ge(e,r,r,n,0,e.length,i),i}function ye(e){return[new de(0,e,0)]}let ve="";function we(e,t,n,r,o){var s;let a=r.head-e.from,l=de.find(t,a,null!==(s=r.bidiLevel)&&void 0!==s?s:-1,r.assoc),c=t[l],h=c.side(o,n);if(a==h){let e=l+=o?1:-1;if(e<0||e>=t.length)return null;c=t[l=e],a=c.side(!o,n),h=c.side(o,n)}let u=(0,i.zK)(e.text,a,c.forward(o,n));(uc.to)&&(u=h),ve=e.text.slice(Math.min(a,u),Math.max(a,u));let d=l==(o?t.length-1:0)?null:t[l+(o?1:-1)];return d&&u==h&&d.level+(o?0:1)e.some(e=>e)}),Ee=i.sj.define({combine:e=>e.some(e=>e)}),Be=i.sj.define();class Re{constructor(e,t,n,i,r,o=!1){this.range=e,this.y=t,this.x=n,this.yMargin=i,this.xMargin=r,this.isSnapshot=o}map(e){return e.empty?this:new Re(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new Re(i.OF.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Pe=i.Pe.define({map:(e,t)=>e.map(t)}),Ie=i.Pe.define();function Ne(e,t,n){let i=e.facet(Ae);i.length?i[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)||(n?console.error(n+":",t):console.error(t))}const Fe=i.sj.define({combine:e=>!e.length||e[0]});let We=0;const He=i.sj.define({combine:e=>e.filter((t,n)=>{for(let i=0;i{let t=[];return o&&t.push(_e.of(t=>{let n=t.plugin(e);return n?o(n):M.none})),r&&t.push(r(e)),t})}static fromClass(e,t){return qe.define((t,n)=>new e(t,n),t)}}class Ve{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(Ne(e.state,t,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(e){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){Ne(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(null===(t=this.value)||void 0===t?void 0:t.destroy)try{this.value.destroy()}catch(t){Ne(e.state,t,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const je=i.sj.define(),Ke=i.sj.define(),_e=i.sj.define(),Ue=i.sj.define(),$e=i.sj.define(),Ye=i.sj.define(),Ge=i.sj.define();function Xe(e,t){let n=e.state.facet(Ge);if(!n.length)return n;let r=n.map(t=>t instanceof Function?t(e):t),o=[];return i.om.spans(r,t.from,t.to,{point(){},span(e,n,i,r){let s=e-t.from,a=n-t.from,l=o;for(let e=i.length-1;e>=0;e--,r--){let n,o=i[e].spec.bidiIsolate;if(null==o&&(o=ke(t.text,s,a)),r>0&&l.length&&(n=l[l.length-1]).to==s&&n.direction==o)n.to=a,l=n.inner;else{let e={from:s,to:a,direction:o,inner:[]};l.push(e),l=e.inner}}}}),o}const Je=i.sj.define();function Ze(e){let t=0,n=0,i=0,r=0;for(let o of e.state.facet(Je)){let s=o(e);s&&(null!=s.left&&(t=Math.max(t,s.left)),null!=s.right&&(n=Math.max(n,s.right)),null!=s.top&&(i=Math.max(i,s.top)),null!=s.bottom&&(r=Math.max(r,s.bottom)))}return{left:t,right:n,top:i,bottom:r}}const Qe=i.sj.define();class et{constructor(e,t,n,i){this.fromA=e,this.toA=t,this.fromB=n,this.toB=i}join(e){return new et(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let i=e[t-1];if(!(i.fromA>n.toA)){if(i.toAr.push(new et(e,t,n,i))),this.changedRanges=r}static create(e,t,n){return new tt(e,t,n)}get viewportChanged(){return(4&this.flags)>0}get viewportMoved(){return(8&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(18&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return 0==this.flags&&0==this.transactions.length}}const nt=[];class it{constructor(e,t,n=0){this.dom=e,this.length=t,this.flags=n,this.parent=null,e.cmTile=this}get breakAfter(){return 1&this.flags}get children(){return nt}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,4&this.flags){this.flags&=-5;let e=this.domAttrs;e&&function(e,t){for(let n=e.attributes.length-1;n>=0;n--){let i=e.attributes[n].name;null==t[i]&&e.removeAttribute(i)}for(let n in t){let i=t[n];"style"==n?e.style.cssText=i:e.getAttribute(n)!=i&&e.setAttribute(n,i)}}(this.dom,e)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let n=t;for(let t of this.children){if(t==e)return n;n+=t.length+t.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t,n){return null}domPosFor(e,t){let n=F(this.dom),i=this.length?e>0:t>0;return new te(this.parent.dom,n+(i?1:0),0==e||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&2&this.parent.flags&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof st)return e;return null}static get(e){return e.cmTile}}class rt extends it{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(2&this.flags)return;super.sync(e);let t,n=this.dom,i=null,r=(null==e?void 0:e.node)==n?e:null,o=0;for(let s of this.children){if(s.sync(e),o+=s.length+s.breakAfter,t=i?i.nextSibling:n.firstChild,r&&t!=s.dom&&(r.written=!0),s.dom.parentNode==n)for(;t&&t!=s.dom;)t=ot(t);else n.insertBefore(s.dom,t);i=s.dom}for(t=i?i.nextSibling:n.firstChild,r&&t&&(r.written=!0);t;)t=ot(t);this.length=o}}function ot(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class st extends rt{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=it.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],n=this,i=0,r=0;;)if(i==n.children.length){if(!t.length)return;n=n.parent,n.breakAfter&&r++,i=t.pop()}else{let o=n.children[i++];if(o instanceof at)t.push(i),n=o,i=0;else{let t=r+o.length,n=e(o,r);if(void 0!==n)return n;r=t+o.breakAfter}}}resolveBlock(e,t){let n,i,r=-1,o=-1;if(this.blockTiles((s,a)=>{let l=a+s.length;if(e>=a&&e<=l){if(s.isWidget()&&t>=-1&&t<=1){if(32&s.flags)return!0;16&s.flags&&(n=void 0)}(ae||e==a&&(t>1?s.length:s.covers(-1)))&&(!i||!s.isWidget()&&i.isWidget())&&(i=s,o=e-a)}}),!n&&!i)throw new Error("No tile at position "+e);return n&&t<0||!i?{tile:n,offset:r}:{tile:i,offset:o}}}class at extends rt{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return!!this.children.length&&(e<0?this.children[0].covers(-1):this.lastChild.covers(1))}get domAttrs(){return this.wrapper.attributes}static of(e,t){let n=new at(t||document.createElement(e.tagName),e);return t||(n.flags|=4),n}}class lt extends rt{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,n){let i=new lt(t||document.createElement("div"),e);return t&&n||(i.flags|=4),i}get domAttrs(){return this.attrs}resolveInline(e,t,n){let i=null,r=-1,o=null,s=-1;!function e(a,l){for(let c=0,h=0;c=l&&(u.isComposite()?e(u,l-h):(!o||o.isHidden&&(t>0&&!(32&o.flags)||n&&ct(o,u)))&&(d>l||32&u.flags&&t<=1)?(o=u,s=l-h):(h=-1)&&(i=u,r=l-h)),h=d}}(this,e);let a=(t<0?i:o)||i||o;return a?{tile:a,offset:a==i?r:s}:null}coordsIn(e,t,n){let i=this.resolveInline(e,t,!0);return i?i.tile.coordsIn(Math.max(0,i.offset),t,n):function(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=I(t);return n[n.length-1]||null}(this)}domIn(e,t){let n=this.resolveInline(e,t);if(n){let{tile:e,offset:i}=n;if(this.dom.contains(e.dom))return e.isText()?new te(e.dom,Math.min(e.dom.nodeValue.length,i)):e.domPosFor(i,16&e.flags?1:32&e.flags?-1:t);let r=n.tile.parent,o=!1;for(let e of r.children){if(o)return new te(e.dom,0);e==n.tile&&(o=!0)}}return new te(this.dom,0)}}function ct(e,t){let n=e.coordsIn(0,1),i=t.coordsIn(0,1);return n&&i&&i.topi&&(e=i);let r=e,o=e,s=0;0==e&&t<0||e==i&&t>=0?y.chrome||y.gecko||(e?(r--,s=1):o=0)?0:a.length-1];return y.safari&&!s&&0==l.width&&(l=Array.prototype.find.call(a,e=>e.width)||l),null==n?l:V(l,(s?s>0:t<0)==n)}static of(e,t){let n=new ut(t||document.createTextNode(e),e);return t||(n.flags|=2),n}}class dt extends it{constructor(e,t,n,i){super(e,t,i),this.widget=n}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return!(48&this.flags)&&(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,n){let i=this.widget.coordsAt(this.dom,e,t);if(i)return i;if(n)return V(this.dom.getBoundingClientRect(),this.length?0==e:t<=0);{let t=this.dom.getClientRects(),n=null;if(!t.length)return null;let i=!!(16&this.flags)||!(32&this.flags)&&e>0;for(let r=i?t.length-1:0;n=t[r],!(e>0?0==r:r==t.length-1||n.top0==n)}}class pt{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,n){let{tile:i,index:r,beforeBreak:o,parents:s}=this;for(;e||t>0;)if(i.isComposite())if(o){if(!e)break;n&&n.break(),e--,o=!1}else if(r==i.children.length){if(!e&&!s.length)break;n&&n.leave(i),o=!!i.breakAfter,({tile:i,index:r}=s.pop()),r++}else{let a=i.children[r],l=a.breakAfter;!(t>0?a.length<=e:a.length=0;e--){let n=t.marks[e],r=i.lastChild;if(r instanceof ht&&r.mark.eq(n.mark))r.dom!=n.dom&&r.setDOM(St(n.dom)),i=r;else{if(this.cache.reused.get(n)){let e=it.get(n.dom);e&&e.setDOM(St(n.dom))}let e=ht.of(n.mark,n.dom);i.append(e),i=e}this.cache.reused.set(n,2)}let r=it.get(e.text);r&&this.cache.reused.set(r,2);let o=new ut(e.text,e.text.nodeValue);o.flags|=8,this.pos=e.range.toB,i.append(o)}addInlineWidget(e,t,n){let i=this.afterWidget&&48&e.flags&&(48&this.afterWidget.flags)==(48&e.flags);i||this.flushBuffer();let r=this.ensureMarks(t,n);i||16&e.flags||r.append(this.getBuffer(1)),r.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,n){this.flushBuffer(),this.ensureMarks(t,n).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){(this.afterWidget||this.lastBlock).length+=e,this.pos+=e}addLineStart(e,t){var n;e||(e=xt);let i=lt.start(e,t||(null===(n=this.cache.find(lt))||void 0===n?void 0:n.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=i)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var n;let i=this.curLine;for(let r=e.length-1;r>=0;r--){let o,s=e[r];if(t>0&&(o=i.lastChild)&&o instanceof ht&&o.mark.eq(s))i=o,t--;else{let e=ht.of(s,null===(n=this.cache.find(ht,e=>e.mark.eq(s)))||void 0===n?void 0:n.dom);i.append(e),i=e,t=0}}return i}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;e&&kt(this.curLine,!1)&&("BR"==e.dom.nodeName||!e.isWidget()||y.ios&&kt(this.curLine,!0))||this.curLine.append(this.cache.findWidget(At,0,32)||new dt(At.toDOM(),0,At,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let t=102*e.rank+e.value.rank,n=new mt(e.from,e.to,e.value,t),i=this.wrappers.length;for(;i>0&&(this.wrappers[i-1].rank-n.rank||this.wrappers[i-1].to-n.to)<0;)i--;this.wrappers.splice(i,0,n)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let n of this.wrappers){let i=t.lastChild;if(n.frome.wrapper.eq(n.wrapper)))||void 0===e?void 0:e.dom);t.append(i),t=i}}return t}blockPosCovered(){let e=this.lastBlock;return null!=e&&!e.breakAfter&&(!e.isWidget()||(160&e.flags)>0)}getBuffer(e){let t=2|(e<0?16:32),n=this.cache.find(ft,void 0,1);return n&&(n.flags=t),n||new ft(t)}flushBuffer(){!this.afterWidget||32&this.afterWidget.flags||(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class bt{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:t,lineBreak:n,done:i}=this.cursor.next(this.skipCount);if(this.skipCount=0,i)throw new Error("Ran out of text content when drawing inline views");this.text=t;let r=this.textOff=Math.min(e,t.length);return n?null:t.slice(0,r)}let t=Math.min(this.text.length,this.textOff+e),n=this.text.slice(this.textOff,t);return this.textOff=t,n}}const yt=[dt,lt,ut,ht,ft,at,st];for(let e=0;e[]),this.index=yt.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,n=this.buckets[t];n.length<6?n.push(e):n[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,n=2){let i=e.bucket,r=this.buckets[i],o=this.index[i];for(let e=0;e{if(this.cache.add(e),e.isComposite())return!1},enter:e=>this.cache.add(e),leave:()=>{},break:()=>{}}}run(e,t){let n=t&&this.getCompositionContext(t.text);for(let i=0,r=0,o=0;;){let s=oi){let e=a-i;this.preserve(e,!o,!s),i=a,r+=e}if(!s)break;t&&s.fromA<=t.range.fromA&&s.toA>=t.range.toA?(this.forward(s.fromA,t.range.fromA,t.range.fromA1;n--){let i=n==e.parents.length?e.tile:e.parents[n].tile;i instanceof ht&&t.push(i.mark)}return t}(this.old),r=this.openMarks;this.old.advance(e,n?1:-1,{skip:(e,t,n)=>{if(e.isWidget())if(this.openWidget)this.builder.continueWidget(n-t);else{let o=n>0||t{e.isLine()?this.builder.addLineStart(e.attrs,this.cache.maybeReuse(e)):(this.cache.add(e),e instanceof ht&&i.unshift(e.mark)),this.openWidget=!1},leave:e=>{e.isLine()?i.length&&(i.length=r=0):e instanceof ht&&(i.shift(),r=Math.min(r,i.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let n=null,r=this.builder,o=-1,s=i.om.spans(this.decorations,e,t,{point:(e,t,i,s,a,l)=>{if(i instanceof D){if(this.disallowBlockEffectsFor[l]){if(i.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.view.state.doc.lineAt(e).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(o=s.length,a>s.length)r.continueWidget(t-e);else{let o=i.widget||(i.block?Ct.block:Ct.inline),l=function(e){let t=e.isReplace?(e.startSide<0?64:0)|(e.endSide>0?128:0):e.startSide>0?32:16;return e.block&&(t|=256),t}(i),c=this.cache.findWidget(o,t-e,l)||dt.of(o,this.view,t-e,l);i.block?(i.startSide>0&&r.addLineStartIfNotCovered(n),r.addBlockWidget(c)):(r.ensureLine(n),r.addInlineWidget(c,s,a))}n=null}else n=function(e,t){let n=t.spec.attributes,i=t.spec.class;return n||i?(e||(e={class:"cm-line"}),n&&v(n,e),i&&(e.class+=" "+i),e):e}(n,i);t>e&&this.text.skip(t-e)},span:(e,t,i,s)=>{for(let o=e;o-1&&(this.openWidget=s>o),this.openWidget||r.addLineStartIfNotCovered(n),this.openMarks=s}forward(e,t,n=1){t-e<=10?this.old.advance(t-e,n,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,n,this.reuseWalker))}getCompositionContext(e){let t=[],n=null;for(let i=e.parentNode;;i=i.parentNode){let e=it.get(i);if(i==this.view.contentDOM)break;e instanceof ht?t.push(e):(null==e?void 0:e.isLine())?n=e:e instanceof at||("DIV"!=i.nodeName||n||i==this.view.contentDOM?n||t.push(ht.of(new T({tagName:i.nodeName.toLowerCase(),attributes:S(i)}),i)):n=new lt(i,xt))}return{line:n,marks:t}}}function kt(e,t){let n=e=>{for(let i of e.children)if((t?i.isText():i.length)||n(i))return!0;return!1};return n(e)}const xt={class:"cm-line"};function St(e){let t=it.get(e);return t&&t.setDOM(e.cloneNode()),e}class Ct extends C{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}Ct.inline=new Ct("span"),Ct.block=new Ct("div");const At=new class extends C{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Mt{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=M.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new st(e,e.contentDOM),this.updateInner([new et(0,0,0,e.state.doc.length)],null)}update(e){var t;let n=e.changedRanges;this.minWidth>0&&n.length&&(n.every(({fromA:e,toA:t})=>tthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let r=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&((null===(t=this.domChanged)||void 0===t?void 0:t.newSel)?r=this.domChanged.newSel.head:function(e,t){let n=!1;return t&&e.iterChangedRanges((e,i)=>{et.from&&(n=!0)}),n}(e.changes,this.hasComposition)||e.selectionSet||(r=e.state.selection.main.head));let o=r>-1?function(e,t,n){let i=Ot(e,n);if(!i)return null;let{node:r,from:o,to:s}=i,a=r.nodeValue;if(/[\n\r]/.test(a))return null;if(e.state.doc.sliceString(i.from,i.to)!=a)return null;let l=t.invertedDesc;return{range:new et(l.mapPos(o),l.mapPos(s),o,s),text:r}}(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:t,to:i}=this.hasComposition;n=new et(t,i,e.changes.mapPos(t,-1),e.changes.mapPos(i,1)).addToSet(n.slice())}this.hasComposition=o?{from:o.range.fromB,to:o.range.toB}:null,(y.ie||y.chrome)&&!o&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let s=this.decorations,a=this.blockWrappers;this.updateDeco();let l=function(e,t,n){let r=new Dt;return i.om.compare(e,t,n,r),r.changes}(s,this.decorations,e.changes);l.length&&(n=et.extendWithRanges(n,l));let c=function(e,t,n){let r=new Lt;return i.om.compare(e,t,n,r),r.changes}(a,this.blockWrappers,e.changes);return c.length&&(n=et.extendWithRanges(n,c)),o&&!n.some(e=>e.fromA<=o.range.fromA&&e.toA>=o.range.toA)&&(n=o.range.addToSet(n.slice())),!(2&this.tile.flags&&0==n.length||(this.updateInner(n,o),e.transactions.length&&(this.lastUpdate=Date.now()),0))}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:n}=this.view;n.ignore(()=>{if(t||e.length){let n=this.tile,i=new wt(this.view,n,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&it.get(t.text)&&i.cache.reused.set(it.get(t.text),2),this.tile=i.run(e,t),Tt(n,i.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let i=y.chrome||y.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(i),!i||!i.written&&n.selectionRange.focusNode==i.node&&this.tile.dom.contains(i.node)||(this.forceSelection=!0),this.tile.dom.style.height=""});let i=[];if(this.view.viewport.from||this.view.viewport.to-1)&&P(n,this.view.observer.selectionRange)&&!(i&&n.contains(i));if(!(r||t||o))return;let s=this.forceSelection;this.forceSelection=!1;let a,l,c=this.view.state.selection.main;if(c.empty?l=a=this.inlineDOMNearPos(c.anchor,c.assoc||1):(l=this.inlineDOMNearPos(c.head,c.head==c.from?1:-1),a=this.inlineDOMNearPos(c.anchor,c.anchor==c.from?1:-1)),y.gecko&&c.empty&&!this.hasComposition&&1==(h=a).node.nodeType&&h.node.firstChild&&(0==h.offset||"false"==h.node.childNodes[h.offset-1].contentEditable)&&(h.offset==h.node.childNodes.length||"false"==h.node.childNodes[h.offset].contentEditable)){let e=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(e,a.node.childNodes[a.offset]||null)),a=l=new te(e,0),s=!0}var h;let u=this.view.observer.selectionRange;!s&&u.focusNode&&(N(a.node,a.offset,u.anchorNode,u.anchorOffset)&&N(l.node,l.offset,u.focusNode,u.focusOffset)||this.suppressWidgetCursorChange(u,c))||(this.view.observer.ignore(()=>{y.android&&y.chrome&&n.contains(u.focusNode)&&function(e,t){for(let n=e;n&&n!=t;n=n.assignedSlot||n.parentNode)if(1==n.nodeType&&"false"==n.contentEditable)return!0;return!1}(u.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let e=B(this.view.root);if(e)if(c.empty){if(y.gecko){let e=(t=a.node,r=a.offset,1!=t.nodeType?0:(r&&"false"==t.childNodes[r-1].contentEditable?1:0)|(rc.head&&([a,l]=[l,a]),t.setEnd(l.node,l.offset),t.setStart(a.node,a.offset),e.removeAllRanges(),e.addRange(t)}var t,r;o&&this.view.root.activeElement==n&&(n.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(a,l)),this.impreciseAnchor=a.precise?null:new te(u.anchorNode,u.anchorOffset),this.impreciseHead=l.precise?null:new te(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&N(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=B(e.root),{anchorNode:i,anchorOffset:r}=e.observer.selectionRange;if(!(n&&t.empty&&t.assoc&&n.modify))return;let o=this.lineAt(t.head,t.assoc);if(!o)return;let s=o.posAtStart;if(t.head==s||t.head==s+o.length)return;let a=this.coordsAt(t.head,-1),l=this.coordsAt(t.head,1);if(!a||!l||a.bottom>l.top)return;let c=this.domAtPos(t.head+t.assoc,t.assoc);n.collapse(c.node,c.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let h=e.observer.selectionRange;e.docView.posFromDOM(h.anchorNode,h.anchorOffset)!=t.from&&n.collapse(i,r)}posFromDOM(e,t){let n=this.tile.nearest(e);if(!n)return 2&this.tile.dom.compareDocumentPosition(e)?0:this.view.state.doc.length;let i=n.posAtStart;if(!n.isComposite())return n.isText()?e==n.dom?i+t:i+(t?n.length:0):i;{let r;if(e==n.dom)r=n.dom.childNodes[t];else{let i=0==q(e)?0:0==t?-1:1;for(;;){let t=e.parentNode;if(t==n.dom)break;0==i&&t.firstChild!=t.lastChild&&(i=e==t.firstChild?-1:1),e=t}r=i<0?e:e.nextSibling}if(r==n.dom.firstChild)return i;for(;r&&!it.get(r);)r=r.nextSibling;if(!r)return i+n.length;for(let e=0,t=i;;e++){let i=n.children[e];if(i.dom==r)return t;t+=i.length+i.breakAfter}}}domAtPos(e,t){let{tile:n,offset:i}=this.tile.resolveBlock(e,t);return n.isWidget()?n.domPosFor(i,t):n.domIn(i,t)}inlineDOMNearPos(e,t){let n,i,r=-1,o=!1,s=-1,a=!1;return this.tile.blockTiles((t,l)=>{if(t.isWidget()){if(32&t.flags&&l>=e)return!0;16&t.flags&&(o=!0)}else{let c=l+t.length;if(l<=e&&(n=t,r=e-l,o=c=e&&!i&&(i=t,s=e-l,a=l>e),l>e&&i)return!0}}),n||i?(o&&i?n=null:a&&n&&(i=null),n&&t<0||!i?n.domIn(r,t):i.domIn(s,t)):this.domAtPos(e,t)}coordsAt(e,t,n){let{tile:i,offset:r}=this.tile.resolveBlock(e,t);return i.isWidget()?i.widget instanceof zt?null:i.coordsInWidget(r,t,!0):i.coordsIn(r,t,n)}lineAt(e,t){let{tile:n}=this.tile.resolveBlock(e,t);return n.isLine()?n:null}coordsForChar(e){let{tile:t,offset:n}=this.tile.resolveBlock(e,1);return t.isLine()?function e(t,n){if(t.isComposite())for(let i of t.children){if(i.length>=n){let t=e(i,n);if(t)return t}if((n-=i.length)<0)break}else if(t.isText()&&nMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,s=-1,a=this.view.textDirection==ne.LTR,l=0,c=(e,h,u)=>{for(let d=0;di);d++){let i=e.children[d],f=h+i.length,p=i.dom.getBoundingClientRect(),{height:m}=p;if(u&&!d&&(l+=p.top-u.top),i instanceof at)f>n&&c(i,h,p);else if(h>=n&&(l>0&&t.push(-l),t.push(m+l),l=0,o)){let e=i.dom.lastChild,t=e?I(e):[];if(t.length){let e=t[t.length-1],n=a?e.right-p.left:p.right-e.left;n>s&&(s=n,this.minWidth=r,this.minWidthFrom=h,this.minWidthTo=f)}}u&&d==e.children.length-1&&(l+=u.bottom-p.bottom),h=f+i.breakAfter}};return c(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return"rtl"==getComputedStyle(t.dom).direction?ne.RTL:ne.LTR}measureTextSize(){let e=this.tile.blockTiles(e=>{if(e.isLine()&&e.children.length&&e.length<=20){let t,n=0;for(let i of e.children){if(!i.isText()||/[^ -~]/.test(i.text))return;let e=I(i.dom);if(1!=e.length)return;n+=e[0].width,t=e[0].height}if(n)return{lineHeight:e.dom.getBoundingClientRect().height,charWidth:n/e.length,textHeight:t}}});if(e)return e;let t,n,i,r=document.createElement("div");return r.className="cm-line",r.style.width="99999px",r.style.position="absolute",r.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(r);let e=I(r.firstChild)[0];t=r.getBoundingClientRect().height,n=e&&e.width?e.width/27:7,i=e&&e.height?e.height:t,r.remove()}),{lineHeight:t,charWidth:n,textHeight:i}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,i=0;;i++){let r=i==t.viewports.length?null:t.viewports[i],o=r?r.from-1:this.view.state.doc.length;if(o>n){let i=(t.lineBlockAt(o).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(M.replace({widget:new zt(i),block:!0,inclusive:!0,isBlockGap:!0}).range(n,o))}if(!r)break;n=r.to+1}return M.set(e)}updateDeco(){let e=1,t=this.view.state.facet(_e).map(t=>(this.dynamicDecorationMap[e++]="function"==typeof t)?t(this.view):t),n=!1,r=this.view.state.facet($e).map((e,t)=>{let i="function"==typeof e;return i&&(n=!0),i?e(this.view):e});for(r.length&&(this.dynamicDecorationMap[e++]=n,t.push(i.om.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e"function"==typeof e?e(this.view):e)}scrollIntoView(e){if(e.isSnapshot){let t=this.view.viewState.lineBlockAt(e.range.head);return this.view.scrollDOM.scrollTop=t.top-e.yMargin,void(this.view.scrollDOM.scrollLeft=e.xMargin)}for(let t of this.view.state.facet(Be))try{if(t(this.view,e.range,e))return!0}catch(e){Ne(this.view.state,e,"scroll handler")}let t,{range:n}=e,i=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1));if(!i)return;!n.empty&&(t=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(i={left:Math.min(i.left,t.left),top:Math.min(i.top,t.top),right:Math.max(i.right,t.right),bottom:Math.max(i.bottom,t.bottom)});let r=Ze(this.view),o={left:i.left-r.left,top:i.top-r.top,right:i.right+r.right,bottom:i.bottom+r.bottom},{offsetWidth:s,offsetHeight:a}=this.view.scrollDOM;if(function(e,t,n,i,r,o,s,a){let l=e.ownerDocument,c=l.defaultView||window;for(let h=e,u=!1;h&&!u;)if(1==h.nodeType){let e,d=h==l.body,f=1,p=1;if(d)e=j(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(h).position)&&(u=!0),h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.assignedSlot||h.parentNode;continue}let t=h.getBoundingClientRect();({scaleX:f,scaleY:p}=K(h,t)),e={left:t.left,right:t.left+h.clientWidth*f,top:t.top,bottom:t.top+h.clientHeight*p}}let m=0,g=0;if("nearest"==r)t.top0&&t.bottom>e.bottom+g&&(g=t.bottom-e.bottom+s)):t.bottom>e.bottom-s&&(g=t.bottom-e.bottom+s,n<0&&t.top-g0&&t.right>e.right+m&&(m=t.right-e.right+o)):t.right>e.right-o&&(m=t.right-e.right+o,n<0&&t.lefte.bottom||t.lefte.right)&&(t={left:Math.max(t.left,e.left),right:Math.min(t.right,e.right),top:Math.max(t.top,e.top),bottom:Math.min(t.bottom,e.bottom)}),h=h.assignedSlot||h.parentNode}else{if(11!=h.nodeType)break;h=h.host}}(this.view.scrollDOM,o,n.head1&&(i.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||i.bottome.isWidget()||e.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){Tt(this.tile)}}function Tt(e,t){let n=null==t?void 0:t.get(e);if(1!=n){null==n&&e.destroy();for(let n of e.children)Tt(n,t)}}function Ot(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let i=Q(n.focusNode,n.focusOffset),r=ee(n.focusNode,n.focusOffset),o=i||r;if(r&&i&&r.node!=i.node){let t=it.get(r.node);if(!t||t.isText()&&t.text!=r.node.nodeValue)o=r;else if(e.docView.lastCompositionAfterCursor){let e=it.get(i.node);!e||e.isText()&&e.text!=i.node.nodeValue||(o=r)}}if(e.docView.lastCompositionAfterCursor=o!=i,!o)return null;let s=t-o.offset;return{from:s,to:s+o.node.nodeValue.length,node:o.node}}let Dt=class{constructor(){this.changes=[]}compareRange(e,t){z(e,t,this.changes)}comparePoint(e,t){z(e,t,this.changes)}boundChange(e){z(e,e,this.changes)}};class Lt{constructor(){this.changes=[]}compareRange(e,t){z(e,t,this.changes)}comparePoint(){}boundChange(e){z(e,e,this.changes)}}class zt extends C{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function Et(e,t,n){let i=e.lineBlockAt(t);if(Array.isArray(i.type)){let e;for(let r of i.type){if(r.from>t)break;if(!(r.tot)return r;e&&(r.type!=A.Text||e.type==r.type&&!(n<0?r.fromt))||(e=r)}}return e||i}return i}function Bt(e,t,n,i){let r=e.state.doc.lineAt(t.head),o=e.bidiSpans(r),s=e.textDirectionAt(r.from);for(let a=t,l=null;;){let t=we(r,o,s,a,n),c=ve;if(!t){if(r.number==(n?e.state.doc.lines:1))return a;c="\n",r=e.state.doc.line(r.number+(n?1:-1)),o=e.bidiSpans(r),t=e.visualLineSide(r,!n)}if(l){if(!l(c))return a}else{if(!i)return t;l=i(c)}a=t}}function Rt(e,t,n){for(;;){let i=0;for(let r of e)r.between(t-1,t+1,(e,r,o)=>{if(t>e&&tt(e)),n.from,t.head>n.from?-1:1);return r==n.from?n:i.OF.cursor(r,re.viewState.docHeight)return new Nt(e.state.doc.length,-1);if(o=e.elementAtHeight(h),null==r)break;if(o.type==A.Text){if(r<0?o.toe.viewport.to)break;let t=e.docView.coordsAt(r<0?o.from:o.to,r>0?-1:1);if(t&&(r<0?t.top<=h+a:t.bottom>=h+a))break}let t=e.viewState.heightOracle.textHeight/2;h=r>0?o.bottom+t:o.top-t}if(e.viewport.from>=o.to||e.viewport.to<=o.from){if(n)return null;if(o.type==A.Text){let t=function(e,t,n,r,o){let s=Math.round((r-t.left)*e.defaultCharacterWidth);if(e.lineWrapping&&n.height>1.5*e.defaultLineHeight){let t=e.viewState.heightOracle.textHeight;s+=Math.floor((o-n.top-.5*(e.defaultLineHeight-t))/t)*e.viewState.heightOracle.lineLength}let a=e.state.sliceDoc(n.from,n.to);return n.from+(0,i.kn)(a,s,e.state.tabSize)}(e,s,o,l,c);return new Nt(t,t==o.from?1:-1)}}if(o.type!=A.Text)return h<(o.top+o.bottom)/2?new Nt(o.from,1):new Nt(o.to,-1);let u=e.docView.lineAt(o.from,2);return u&&u.length==o.length||(u=e.docView.lineAt(o.from,-2)),new Wt(e,l,c,e.textDirectionAt(o.from)).scanTile(u,o.from)}class Wt{constructor(e,t,n,i){this.view=e,this.x=t,this.y=n,this.baseDir=i,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||n.length&&(n[0].level!=this.baseDir||n[0].to+i.from>1;t:if(l.has(d)){let e=s+Math.floor(Math.random()*n);for(let t=0;t1)){if(n.bottomthis.y)(!r||r.top>n.top)&&(r=n),l=-1;else{let e=n.left>this.x?this.x-n.left:n.right(n+n+s)/3)return this.y=i.bottom-1,this.scan(e,t,!0);if(r&&r.top<(n+s+s)/3)return this.y=r.top+1,this.scan(e,t,!0)}let d=(c?this.dirAt(e[h],1):this.baseDir)==ne.LTR;return{i:h,after:this.x>(o.left+o.right)/2==d}}scanText(e,t){let n=[];for(let r=0;r{let r=n[i]-t,o=n[i+1]-t;return X(e.dom,r,o).getClientRects()});return r.after?new Nt(n[r.i+1],-1):new Nt(n[r.i],1)}scanTile(e,t){if(!e.length)return new Nt(t,1);if(1==e.children.length){let n=e.children[0];if(n.isText())return this.scanText(n,t);if(n.isComposite())return this.scanTile(n,t)}let n=[t];for(let i=0,r=t;i{let n=e.children[t];return 48&n.flags?null:(1==n.dom.nodeType?n.dom:X(n.dom,0,n.length)).getClientRects()}),r=e.children[i.i],o=n[i.i];return r.isText()?this.scanText(r,o):r.isComposite()?this.scanTile(r,o):i.after?new Nt(n[i.i+1],-1):new Nt(o,1)}}const Ht="￿";class qt{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(i.$t.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Ht}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let i=e;;){this.findPointBefore(n,i);let e=this.text.length;this.readNode(i);let r=it.get(i),o=i.nextSibling;if(o==t){(null==r?void 0:r.breakAfter)&&!o&&n!=this.view.contentDOM&&this.lineBreak();break}let s=it.get(o);(r&&s?r.breakAfter:(r?r.breakAfter:W(i))||W(o)&&("BR"!=i.nodeName||(null==r?void 0:r.isWidget()))&&this.text.length>e)&&!jt(o,t)&&this.lineBreak(),i=o}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,i=this.lineSeparator?null:/\r\n?|\n/g;;){let r,o=-1,s=1;if(this.lineSeparator?(o=t.indexOf(this.lineSeparator,n),s=this.lineSeparator.length):(r=i.exec(t))&&(o=r.index,s=r[0].length),this.append(t.slice(n,o<0?t.length:o)),o<0)break;if(this.lineBreak(),s>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=s-1);n=o+s}}readNode(e){let t=it.get(e),n=t&&t.overrideDOMText;if(null!=n){this.findPointInside(e,n.length);for(let e=n.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else 3==e.nodeType?this.readTextNode(e):"BR"==e.nodeName?e.nextSibling&&this.lineBreak():1==e.nodeType&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(3==e.nodeType?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(Vt(e,n.node,n.offset)?t:0))}}function Vt(e,t,n){for(;;){if(!t||n-1;let{impreciseHead:o,impreciseAnchor:s}=e.docView,a=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=Ut(e.docView.tile,t,n,0))){let t=o||s?[]:function(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:o}=e.observer.selectionRange;return n&&(t.push(new Kt(n,i)),r==n&&o==i||t.push(new Kt(r,o))),t}(e),n=new qt(t,e);n.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=n.text,this.newSel=function(e,t){if(0==e.length)return null;let n=e[0].pos,r=2==e.length?e[1].pos:n;return n>-1&&r>-1?i.OF.single(n+t,r+t):null}(t,this.bounds.from)}else{let t=e.observer.selectionRange,n=o&&o.node==t.focusNode&&o.offset==t.focusOffset||!R(e.contentDOM,t.focusNode)?a.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),r=s&&s.node==t.anchorNode&&s.offset==t.anchorOffset||!R(e.contentDOM,t.anchorNode)?a.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),l=e.viewport;if((y.ios||y.chrome)&&n!=r&&Math.min(n,r)<=a.main.from&&Math.max(n,r)>=a.main.to&&(l.from>0||l.to-1&&a.ranges.length>1)this.newSel=a.replaceRange(i.OF.range(r,n));else if(e.lineWrapping&&r==n&&(!a.main.empty||a.main.head!=n)&&e.inputState.lastTouchTime>Date.now()-100){let t=e.coordsAtPos(n,-1),r=0;t&&(r=e.inputState.lastTouchY<=t.bottom?-1:1),this.newSel=i.OF.create([i.OF.cursor(n,r)])}else this.newSel=i.OF.single(r,n)}}}function Ut(e,t,n,i){if(e.isComposite()){let r=-1,o=-1,s=-1,a=-1;for(let l=0,c=i,h=i;ln)return Ut(i,t,n,c);if(u>=t&&-1==r&&(r=l,o=c),c>n&&i.dom.parentNode==e.dom){s=l,a=h;break}h=u,c=u+i.breakAfter}return{from:o,to:a<0?i+e.length:a,startDOM:(r?e.children[r-1].dom.nextSibling:null)||e.dom.firstChild,endDOM:s=0?e.children[s].dom:null}}return e.isText()?{from:i,to:i+e.length,startDOM:e.dom,endDOM:e.dom.nextSibling}:null}function $t(e,t){let n,{newSel:r}=t,{state:o}=e,s=o.selection.main,a=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:e,to:r}=t.bounds,l=s.from,c=null;(8===a||y.android&&t.text.length=e&&s.to<=r&&(t.typeOver||d!=t.text)&&d.slice(0,s.from-e)==t.text.slice(0,s.from-e)&&d.slice(s.to-e)==t.text.slice(h=t.text.length-(d.length-(s.to-e)))?n={from:s.from,to:s.to,insert:i.EY.of(t.text.slice(s.from-e,h).split(Ht))}:(u=Gt(d,t.text,l-e,c))&&(y.chrome&&13==a&&u.toB==u.from+2&&t.text.slice(u.from,u.toB)==Ht+Ht&&u.toB--,n={from:e+u.from,to:e+u.toA,insert:i.EY.of(t.text.slice(u.from,u.toB).split(Ht))})}else r&&(!e.hasFocus&&o.facet(Fe)||Xt(r,s))&&(r=null);if(!n&&!r)return!1;if((y.mac||y.android)&&n&&n.from==n.to&&n.from==s.head-1&&/^\. ?$/.test(n.insert.toString())&&"off"==e.contentDOM.getAttribute("autocorrect")?(r&&2==n.insert.length&&(r=i.OF.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:i.EY.of([n.insert.toString().replace("."," ")])}):o.doc.lineAt(s.from).toDate.now()-50?n={from:s.from,to:s.to,insert:o.toText(e.inputState.insertingText)}:y.chrome&&n&&n.from==n.to&&n.from==s.head&&"\n "==n.insert.toString()&&e.lineWrapping&&(r&&(r=i.OF.single(r.main.anchor-1,r.main.head-1)),n={from:s.from,to:s.to,insert:i.EY.of([" "])}),n)return Yt(e,n,r,a);if(r&&!Xt(r,s)){let t=!1,n="select";return e.inputState.lastSelectionTime>Date.now()-50&&("select"==e.inputState.lastSelectionOrigin&&(t=!0),n=e.inputState.lastSelectionOrigin,"select.pointer"==n&&(r=Pt(o.facet(Ye).map(t=>t(e)),r))),e.dispatch({selection:r,scrollIntoView:t,userEvent:n}),!0}return!1}function Yt(e,t,n,r=-1){if(y.ios&&e.inputState.flushIOSKey(t))return!0;let o=e.state.selection.main;if(y.android&&(t.to==o.to&&(t.from==o.from||t.from==o.from-1&&" "==e.state.sliceDoc(t.from,o.from))&&1==t.insert.length&&2==t.insert.lines&&J(e.contentDOM,"Enter",13)||(t.from==o.from-1&&t.to==o.to&&0==t.insert.length||8==r&&t.insert.lengtho.head)&&J(e.contentDOM,"Backspace",8)||t.from==o.from&&t.to==o.to+1&&0==t.insert.length&&J(e.contentDOM,"Delete",46)))return!0;let s,a=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let l=()=>s||(s=function(e,t,n){let r,o=e.state,s=o.selection.main,a=-1;if(t.from==t.to&&t.froms.to){let n=t.fromt(e)),i,n);t.from==r&&(a=r)}if(a>-1)r={changes:t,selection:i.OF.cursor(t.from+t.insert.length,-1)};else if(t.from>=s.from&&t.to<=s.to&&t.to-t.from>=(s.to-s.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let n=s.fromt.to?o.sliceDoc(t.to,s.to):"";r=o.replaceSelection(e.state.toText(n+t.insert.sliceString(0,void 0,e.state.lineBreak)+i))}else{let a=o.changes(t),l=n&&n.main.to<=a.newLength?n.main:void 0;if(o.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=s.to+10&&t.to>=s.to-10){let c,h=e.state.sliceDoc(t.from,t.to),u=n&&Ot(e,n.main.head);if(u){let e=t.insert.length-(t.to-t.from);c={from:u.from,to:u.to-e}}else c=e.state.doc.lineAt(s.head);let d=s.to-t.to;r=o.changeByRange(n=>{if(n.from==s.from&&n.to==s.to)return{changes:a,range:l||n.map(a)};let r=n.to-d,u=r-h.length;if(e.state.sliceDoc(u,r)!=h||r>=c.from&&u<=c.to)return{range:n};let f=o.changes({from:u,to:r,insert:t.insert}),p=n.to-s.to;return{changes:f,range:l?i.OF.range(Math.max(0,l.anchor+p),Math.max(0,l.head+p)):n.map(f)}})}else r={changes:a,selection:l&&o.selection.replaceRange(l)}}let l="input.type";return(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,l+=".compose",e.inputState.compositionFirstChange&&(l+=".start",e.inputState.compositionFirstChange=!1)),o.update(r,{userEvent:l,scrollIntoView:!0})}(e,t,n));return e.state.facet(Te).some(n=>n(e,t.from,t.to,a,l))||e.dispatch(l()),!0}function Gt(e,t,n,i){let r=Math.min(e.length,t.length),o=0;for(;o0&&a>0&&e.charCodeAt(s-1)==t.charCodeAt(a-1);)s--,a--;return"end"==i&&(n-=s+Math.max(0,o-Math.min(s,a))-o),s=s?o-n:0,a=o+(a-s),s=o):a=a?o-n:0,s=o+(s-a),a=o),{from:o,toA:s,toB:a}}function Xt(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}class Jt{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,y.safari&&e.contentDOM.addEventListener("input",()=>null),y.gecko&&function(e){xn.has(e)||(xn.add(e),e.addEventListener("copy",()=>{}),e.addEventListener("cut",()=>{}))}(e.contentDOM.ownerDocument)}handleEvent(e){(function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n,i=t.target;i!=e.contentDOM;i=i.parentNode)if(!i||11==i.nodeType||(n=it.get(i))&&n.isWidget()&&!n.isHidden&&n.widget.ignoreEvent(t))return!1;return!0})(this.view,e)&&!this.ignoreDuringComposition(e)&&("keydown"==e.type&&this.keydown(e)||(0!=this.view.updateState?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e)))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let e of n.observers)e(this.view,t);for(let e of n.handlers){if(t.defaultPrevented)break;if(e(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=Qt(e),n=this.handlers,i=this.view.contentDOM;for(let e in t)if("scroll"!=e){let r=!t[e].handlers.length,o=n[e];o&&r!=!o.handlers.length&&(i.removeEventListener(e,this.handleEvent),o=null),o||i.addEventListener(e,this.handleEvent,{passive:r})}for(let e in n)"scroll"==e||t[e]||i.removeEventListener(e,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),9==e.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&27!=e.keyCode&&nn.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),y.android&&y.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(y.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(en.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||tn.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&y.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&(t=this.view.win).visualViewport&&t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),250),!0}var t;return 229!=e.keyCode&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let t=this.pendingIOSKey;return!!t&&!("Enter"==t.key&&e&&e.from0||!!(y.safari&&!y.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function Zt(e,t){return(n,i)=>{try{return t.call(e,i,n)}catch(e){Ne(n.state,e)}}}function Qt(e){let t=Object.create(null);function n(e){return t[e]||(t[e]={observers:[],handlers:[]})}for(let t of e){let e=t.spec,i=e&&e.plugin.domEventHandlers,r=e&&e.plugin.domEventObservers;if(i)for(let e in i){let r=i[e];r&&n(e).handlers.push(Zt(t.value,r))}if(r)for(let e in r){let i=r[e];i&&n(e).observers.push(Zt(t.value,i))}}for(let e in sn)n(e).handlers.push(sn[e]);for(let e in an)n(e).observers.push(an[e]);return t}const en=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],tn="dthko",nn=[16,17,18,20,91,92,224,225];function rn(e){return.7*Math.max(0,e)+8}class on{constructor(e,t,n,r){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=_(e.contentDOM),this.atoms=e.state.facet(Ye).map(t=>t(e));let o=e.contentDOM.ownerDocument;o.addEventListener("mousemove",this.move=this.move.bind(this)),o.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(i.$t.allowMultipleSelections)&&function(e,t){let n=e.state.facet(xe);return n.length?n[0](t):y.mac?t.metaKey:t.ctrlKey}(e,t),this.dragging=!(!function(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let i=B(e.root);if(!i||0==i.rangeCount)return!0;let r=i.getRangeAt(0).getClientRects();for(let e=0;e=t.clientX&&n.top<=t.clientY&&n.bottom>=t.clientY)return!0}return!1}(e,t)||1!=gn(t))&&null}start(e){!1===this.dragging&&this.select(e)}move(e){if(0==e.buttons)return this.destroy();if(this.dragging||null==this.dragging&&(t=this.startEvent,n=e,Math.max(Math.abs(t.clientX-n.clientX),Math.abs(t.clientY-n.clientY))<10))return;var t,n;this.select(this.lastEvent=e);let i=0,r=0,o=0,s=0,a=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:o,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let c=Ze(this.view);e.clientX-c.left<=o+6?i=-rn(o-e.clientX):e.clientX+c.right>=a-6&&(i=rn(e.clientX-a)),e.clientY-c.top<=s+6?r=-rn(s-e.clientY):e.clientY+c.bottom>=l-6&&(r=rn(e.clientY-l)),this.setScrollSpeed(i,r)}up(e){null==this.dragging&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),!1===this.dragging&&this.select(this.lastEvent)}select(e){let{view:t}=this,n=Pt(this.atoms,this.style.get(e,this.extend,this.multiple));!this.mustSelect&&n.eq(t.state.selection,!1===this.dragging)||this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(e=>e.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}const sn=Object.create(null),an=Object.create(null),ln=y.ie&&y.ie_version<15||y.ios&&y.webkit_version<604;function cn(e,t,n){for(let i of e.facet(t))n=i(n,e);return n}function hn(e,t){t=cn(e.state,De,t);let n,{state:r}=e,o=1,s=r.toText(t),a=s.lines==r.selection.ranges.length;if(null!=yn&&r.selection.ranges.every(e=>e.empty)&&yn==s.toString()){let e=-1;n=r.changeByRange(n=>{let l=r.doc.lineAt(n.from);if(l.from==e)return{range:n};e=l.from;let c=r.toText((a?s.line(o++).text:t)+r.lineBreak);return{changes:{from:l.from,insert:c},range:i.OF.cursor(n.from+c.length)}})}else n=a?r.changeByRange(e=>{let t=s.line(o++);return{changes:{from:e.from,to:e.to,insert:t.text},range:i.OF.cursor(e.from+t.length)}}):r.replaceSelection(s);e.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}function un(e,t,n,r){if(1==r)return i.OF.cursor(t,n);if(2==r)return function(e,t,n=1){let r=e.charCategorizer(t),o=e.doc.lineAt(t),s=t-o.from;if(0==o.length)return i.OF.cursor(t);0==s?n=1:s==o.length&&(n=-1);let a=s,l=s;n<0?a=(0,i.zK)(o.text,s,!1):l=(0,i.zK)(o.text,s);let c=r(o.text.slice(a,l));for(;a>0;){let e=(0,i.zK)(o.text,a,!1);if(r(o.text.slice(e,a))!=c)break;a=e}for(;l{let t=e.inputState;t.lastScrollTop=e.scrollDOM.scrollTop,t.lastScrollLeft=e.scrollDOM.scrollLeft,y.ios&&!t.touchActive&&(t.lastIOSMomentumScroll=Date.now())},an.wheel=an.mousewheel=e=>{e.inputState.lastWheelEvent=Date.now()},sn.keydown=(e,t)=>(e.inputState.setSelectionOrigin("select"),27==t.keyCode&&0!=e.inputState.tabFocusMode&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),an.touchstart=(e,t)=>{let n=e.inputState,i=t.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),i&&(n.lastTouchX=i.clientX,n.lastTouchY=i.clientY),n.setSelectionOrigin("select.pointer")},an.touchmove=e=>{e.inputState.setSelectionOrigin("select.pointer")},an.touchend=(e,t)=>{e.inputState.touchActive=!1},sn.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let i of e.state.facet(Ce))if(n=i(e,t),n)break;if(n||0!=t.button||(n=function(e,t){let n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),r=gn(t),o=e.state.selection;return{update(e){e.docChanged&&(n.pos=e.changes.mapPos(n.pos),o=o.map(e.changes))},get(t,s,a){let l,c=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),h=un(e,c.pos,c.assoc,r);if(n.pos!=c.pos&&!s){let t=un(e,n.pos,n.assoc,r),o=Math.min(t.from,h.from),s=Math.max(t.to,h.to);h=o1&&(l=function(e,t){for(let n=0;n=t)return i.OF.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-(e.mainIndex>n?1:0))}return null}(o,c.pos))?l:a?o.addRange(h):i.OF.create([h])}}}(e,t)),n){let i=!e.hasFocus;e.inputState.startMouseSelection(new on(e,t,n,i)),i&&e.observer.ignore(()=>{G(e.contentDOM);let t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()});let r=e.inputState.mouseSelection;if(r)return r.start(t),!1===r.dragging}else e.inputState.setSelectionOrigin("select.pointer");return!1};const dn=y.ie&&y.ie_version<=11;let fn=null,pn=0,mn=0;function gn(e){if(!dn)return e.detail;let t=fn,n=mn;return fn=e,mn=Date.now(),pn=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(pn+1)%3:1}function bn(e,t,n,i){if(!(n=cn(e.state,De,n)))return;let r=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:o}=e.inputState,s=i&&o&&function(e,t){let n=e.state.facet(Se);return n.length?n[0](t):y.mac?!t.altKey:!t.ctrlKey}(e,t)?{from:o.from,to:o.to}:null,a={from:r,insert:n},l=e.state.changes(s?[s,a]:a);e.focus(),e.dispatch({changes:l,selection:{anchor:l.mapPos(r,-1),head:l.mapPos(r,1)},userEvent:s?"move.drop":"input.drop"}),e.inputState.draggedContent=null}sn.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let r=e.docView.tile.nearest(t.target);if(r&&r.isWidget()){let e=r.posAtStart,t=e+r.length;(e>=n.to||t<=n.from)&&(n=i.OF.undirectionalRange(e,t))}}let{inputState:r}=e;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData("Text",cn(e.state,Le,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed="copyMove"),!1},sn.dragend=e=>(e.inputState.draggedContent=null,!1),sn.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let i=Array(n.length),r=0,o=()=>{++r==n.length&&bn(e,t,i.filter(e=>null!=e).join(e.state.lineBreak),!1)};for(let e=0;e{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(i[e]=t.result),o()},t.readAsText(n[e])}return!0}{let n=t.dataTransfer.getData("Text");if(n)return bn(e,t,n,!0),!0}return!1},sn.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=ln?null:t.clipboardData;return n?(hn(e,n.getData("text/plain")||n.getData("text/uri-list")),!0):(function(e){let t=e.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{e.focus(),n.remove(),hn(e,n.value)},50)}(e),!1)};let yn=null;sn.copy=sn.cut=(e,t)=>{if(!P(e.contentDOM,e.observer.selectionRange))return!1;let{text:n,ranges:i,linewise:r}=function(e){let t=[],n=[],i=!1;for(let i of e.selection.ranges)i.empty||(t.push(e.sliceDoc(i.from,i.to)),n.push(i));if(!t.length){let r=-1;for(let{from:i}of e.selection.ranges){let o=e.doc.lineAt(i);o.number>r&&(t.push(o.text),n.push({from:o.from,to:Math.min(e.doc.length,o.to+1)})),r=o.number}i=!0}return{text:cn(e,Le,t.join(e.lineBreak)),ranges:n,linewise:i}}(e.state);if(!n&&!r)return!1;yn=r?n:null,"cut"!=t.type||e.state.readOnly||e.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let o=ln?null:t.clipboardData;return o?(o.clearData(),o.setData("text/plain",n),!0):(function(e,t){let n=e.dom.parentNode;if(!n)return;let i=n.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=t,i.focus(),i.selectionEnd=t.length,i.selectionStart=0,setTimeout(()=>{i.remove(),e.focus()},50)}(e,n),!1)};const vn=i.YH.define();function wn(e,t){let n=[];for(let i of e.facet(Oe)){let r=i(e,t);r&&n.push(r)}return n.length?e.update({effects:n,annotations:vn.of(!0)}):null}function kn(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=wn(e.state,t);n?e.dispatch(n):e.update([])}},10)}an.focus=e=>{e.inputState.lastFocusTime=Date.now(),e.scrollDOM.scrollTop||!e.inputState.lastScrollTop&&!e.inputState.lastScrollLeft||(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),kn(e)},an.blur=e=>{e.observer.clearSelectionRange(),kn(e)},an.compositionstart=an.compositionupdate=e=>{e.observer.editContext||(null==e.inputState.compositionFirstChange&&(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))},an.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,y.chrome&&y.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))},an.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},sn.beforeinput=(e,t)=>{var n,i;if("insertText"!=t.inputType&&"insertCompositionText"!=t.inputType||(e.inputState.insertingText=t.data,e.inputState.insertingTextAt=Date.now()),"insertReplacementText"==t.inputType&&e.observer.editContext){let i=null===(n=t.dataTransfer)||void 0===n?void 0:n.getData("text/plain"),r=t.getTargetRanges();if(i&&r.length){let t=r[0],n=e.posAtDOM(t.startContainer,t.startOffset),o=e.posAtDOM(t.endContainer,t.endOffset);return Yt(e,{from:n,to:o,insert:e.state.toText(i)},null),!0}}let r;if(y.chrome&&y.android&&(r=en.find(e=>e.inputType==t.inputType))&&(e.observer.delayAndroidKey(r.key,r.keyCode),"Backspace"==r.key||"Delete"==r.key)){let t=(null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0;setTimeout(()=>{var n;((null===(n=window.visualViewport)||void 0===n?void 0:n.height)||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return y.ios&&"deleteContentForward"==t.inputType&&e.observer.flushSoon(),y.safari&&"insertText"==t.inputType&&e.inputState.composing>=0&&setTimeout(()=>an.compositionend(e,t),20),!1};const xn=new Set,Sn=["pre-wrap","normal","pre-line","break-spaces"];let Cn=!1;function An(){Cn=!1}class Mn{constructor(e){this.lineWrapping=e,this.doc=i.EY.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Sn.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n-1,a=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=s;if(this.lineWrapping=s,this.lineHeight=t,this.charWidth=n,this.textHeight=i,this.lineLength=r,a){this.heightSamples={};for(let e=0;e0}set outdated(e){this.flags=(e?2:0)|-3&this.flags}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>Ln&&(Cn=!0),this.height=e)}replace(e,t,n){return zn.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,i){let r=this,o=n.doc;for(let s=i.length-1;s>=0;s--){let{fromA:a,toA:l,fromB:c,toB:h}=i[s],u=r.lineAt(a,Dn.ByPosNoHeight,n.setDoc(t),0,0),d=u.to>=l?u:r.lineAt(l,Dn.ByPosNoHeight,n,0,0);for(h+=d.to-l,l=d.to;s>0&&u.from<=i[s-1].toA;)a=i[s-1].fromA,c=i[s-1].fromB,s--,a2*r){let r=e[t-1];r.break?e.splice(--t,1,r.left,null,r.right):e.splice(--t,1,r.left,r.right),n+=1+r.break,i-=r.size}else{if(!(r>2*i))break;{let t=e[n];t.break?e.splice(n,1,t.left,null,t.right):e.splice(n,1,t.left,t.right),n+=2+t.break,r-=t.size}}else if(i=r&&o(this.lineAt(0,Dn.ByPos,n,i,r))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,n=!1,i){return i&&i.from<=t&&i.more&&this.setMeasuredHeight(i),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Pn extends Rn{constructor(e,t,n){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=n}mainBlock(e,t){return new On(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,n){let i=n[0];return 1==n.length&&(i instanceof Pn||i instanceof In&&4&i.flags)&&Math.abs(this.length-i.length)<10?(i instanceof In?i=new Pn(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):zn.of(n)}updateHeight(e,t=0,n=!1,i){return i&&i.from<=t&&i.more?this.setMeasuredHeight(i):(n||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class In extends zn{constructor(e){super(e,0)}heightMetrics(e,t){let n,i=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,o=r-i+1,s=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*o);n=t/o,this.length>o+1&&(s=(this.height-t)/(this.length-o-1))}else n=this.height/o;return{firstLine:i,lastLine:r,perLine:n,perChar:s}}blockAt(e,t,n,i){let{firstLine:r,lastLine:o,perLine:s,perChar:a}=this.heightMetrics(t,i);if(t.lineWrapping){let r=i+(e0){let e=n[n.length-1];e instanceof In?n[n.length-1]=new In(e.length+i):n.push(null,new In(i-1))}if(e>0){let t=n[0];t instanceof In?n[0]=new In(e+t.length):n.unshift(new In(e-1),null)}return zn.of(n)}decomposeLeft(e,t){t.push(new In(e-1),null)}decomposeRight(e,t){t.push(null,new In(this.length-e-1))}updateHeight(e,t=0,n=!1,i){let r=t+this.length;if(i&&i.from<=t+this.length&&i.more){let n=[],o=Math.max(t,i.from),s=-1;for(i.from>t&&n.push(new In(i.from-t-1).updateHeight(e,t));o<=r&&i.more;){let t=e.doc.lineAt(o).length;n.length&&n.push(null);let r=i.heights[i.index++],a=0;r<0&&(a=-r,r=i.heights[i.index++]),-1==s?s=r:Math.abs(r-s)>=Ln&&(s=-2);let l=new Pn(t,r,a);l.outdated=!1,n.push(l),o+=t+1}o<=r&&n.push(null,new In(r-o).updateHeight(e,o));let a=zn.of(n);return(s<0||Math.abs(a.height-this.height)>=Ln||Math.abs(s-this.heightMetrics(e,t).perLine)>=Ln)&&(Cn=!0),En(this,a)}return(n||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class Nn extends zn{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return 1&this.flags}blockAt(e,t,n,i){let r=n+this.left.height;return es))return l;let c=t==Dn.ByPosNoHeight?Dn.ByPosNoHeight:Dn.ByPos;return a?l.join(this.right.lineAt(s,c,n,o,s)):this.left.lineAt(s,c,n,i,r).join(l)}forEachLine(e,t,n,i,r,o){let s=i+this.left.height,a=r+this.left.length+this.break;if(this.break)e=a&&this.right.forEachLine(e,t,n,s,a,o);else{let l=this.lineAt(a,Dn.ByPos,n,i,r);e=e&&l.from<=t&&o(l),t>l.to&&this.right.forEachLine(l.to+1,t,n,s,a,o)}}replace(e,t,n){let i=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-i,t-i,n));let r=[];e>0&&this.decomposeLeft(e,r);let o=r.length;for(let e of n)r.push(e);if(e>0&&Fn(r,o-1),t=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,i=n+this.break;if(e>=i)return this.right.decomposeRight(e-i,t);e2*t.size||t.size>2*e.size?zn.of(this.break?[e,null,t]:[e,t]):(this.left=En(this.left,e),this.right=En(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,i){let{left:r,right:o}=this,s=t+r.length+this.break,a=null;return i&&i.from<=t+r.length&&i.more?a=r=r.updateHeight(e,t,n,i):r.updateHeight(e,t,n),i&&i.from<=s+o.length&&i.more?a=o=o.updateHeight(e,s,n,i):o.updateHeight(e,s,n),a?this.balanced(r,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Fn(e,t){let n,i;null==e[t]&&(n=e[t-1])instanceof In&&(i=e[t+1])instanceof In&&e.splice(t-1,3,new In(n.length+1+i.length))}class Wn{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let e=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof Pn?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new Pn(e-this.pos,-1,0)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e=5)&&this.addLineDeco(i,r,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenToe&&this.nodes.push(new Pn(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let n=new In(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Pn)return e;let t=new Pn(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let i=this.ensureLine();i.length+=n,i.collapsed+=n,i.widgetHeight=Math.max(i.widgetHeight,e),i.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||t instanceof Pn||this.isCovered?(this.writtenTon.clientHeight||n.scrollWidth>n.clientWidth)&&"visible"!=i.overflow){let i=n.getBoundingClientRect();o=Math.max(o,i.left),s=Math.min(s,i.right),a=Math.max(a,i.top),l=Math.min(t==e.parentNode?r.innerHeight:l,i.bottom)}t="absolute"==i.position||"fixed"==i.position?n.offsetParent:n.parentNode}else{if(11!=t.nodeType)break;t=t.host}return{left:o-n.left,right:Math.max(o,s)-n.left,top:a-(n.top+t),bottom:Math.max(a,l)-(n.top+t)}}function Vn(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}class jn{constructor(e,t,n,i){this.from=e,this.to=t,this.size=n,this.displaySize=i}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n"function"!=typeof e&&"cm-lineWrapping"==e.class);this.heightOracle=new Mn(n),this.stateDeco=Jn(t),this.heightMap=zn.empty().applyChanges(this.stateDeco,i.EY.empty,this.heightOracle.setDoc(t.doc),[new et(0,0,0,t.doc.length)]);for(let e=0;e<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());e++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=M.set(this.lineGaps.map(e=>e.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let i=n?t.head:t.anchor;if(!e.some(({from:e,to:t})=>i>=e&&i<=t)){let{from:t,to:n}=this.lineBlockAt(i);e.push(new $n(t,n))}}return this.viewports=e.sort((e,t)=>e.from-t.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Xn:new Zn(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Qn(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=Jn(this.state);let r=e.changedRanges,o=et.extendWithRanges(r,function(e,t,n){let r=new Hn;return i.om.compare(e,t,n,r,0),r.changes}(n,this.stateDeco,e?e.changes:i.VR.empty(this.state.doc.length))),s=this.heightMap.height,a=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);An(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),o),(this.heightMap.height!=s||Cn)&&(e.flags|=2),a?(this.scrollAnchorPos=e.changes.mapPos(a.from,-1),this.scrollAnchorHeight=a.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=s);let l=o.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.headl.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,t));let c=l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,e.flags|=this.updateForViewport(),(c||!e.changes.empty||2&e.flags)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Ee)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,o=n.whiteSpace;this.defaultTextDirection="rtl"==n.direction?ne.RTL:ne.LTR;let s=this.heightOracle.mustRefreshForWrapping(o)||"refresh"===this.mustMeasureContent,a=t.getBoundingClientRect(),l=s||this.mustMeasureContent||this.contentDOMHeight!=a.height;this.contentDOMHeight=a.height,this.mustMeasureContent=!1;let c=0,h=0;if(a.width&&a.height){let{scaleX:e,scaleY:n}=K(t,a);(e>.005&&Math.abs(this.scaleX-e)>.005||n>.005&&Math.abs(this.scaleY-n)>.005)&&(this.scaleX=e,this.scaleY=n,c|=16,s=l=!0)}let u=(parseInt(n.paddingTop)||0)*this.scaleY,d=(parseInt(n.paddingBottom)||0)*this.scaleY;this.paddingTop==u&&this.paddingBottom==d||(this.paddingTop=u,this.paddingBottom=d,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(l=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let f=_(this.view.contentDOM,!1).y;f!=this.scrollParent&&(this.scrollParent=f,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=Z(this.scrollParent||e.win);let m=(this.printing?Vn:qn)(t,this.paddingTop),g=m.top-this.pixelViewport.top,b=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let y=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(y!=this.inView&&(this.inView=y,y&&(l=!0)),!this.inView&&!this.scrollTarget&&!function(e){let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView||window;return t.left0&&t.top0}(e.dom))return 0;let v=a.width;if(this.contentDOMWidth==v&&this.editorHeight==e.scrollDOM.clientHeight||(this.contentDOMWidth=a.width,this.editorHeight=e.scrollDOM.clientHeight,c|=16),l){let t=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(t)&&(s=!0),s||r.lineWrapping&&Math.abs(v-this.contentDOMWidth)>r.charWidth){let{lineHeight:n,charWidth:i,textHeight:a}=e.docView.measureTextSize();s=n>0&&r.refresh(o,n,i,a,Math.max(5,v/i),t),s&&(e.docView.minWidth=0,c|=16)}g>0&&b>0?h=Math.max(g,b):g<0&&b<0&&(h=Math.min(g,b)),An();for(let n of this.viewports){let o=n.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(n);this.heightMap=(s?zn.empty().applyChanges(this.stateDeco,i.EY.empty,this.heightOracle,[new et(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,s,new Tn(n.from,o))}Cn&&(c|=2)}let w=!this.viewportIsAppropriate(this.viewport,h)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return w&&(2&c&&(c|=this.updateScaler()),this.viewport=this.getViewport(h,this.scrollTarget),c|=this.updateForViewport()),(2&c||w)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(s?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),i=this.heightMap,r=this.heightOracle,{visibleTop:o,visibleBottom:s}=this,a=new $n(i.lineAt(o-1e3*n,Dn.ByHeight,r,0,0).from,i.lineAt(s+1e3*(1-n),Dn.ByHeight,r,0,0).to);if(t){let{head:e}=t.range;if(ea.to){let n,o=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),s=i.lineAt(e,Dn.ByPos,r,0,0);n="center"==t.y?(s.top+s.bottom)/2-o/2:"start"==t.y||"nearest"==t.y&&e=s+Math.max(10,Math.min(n,250)))&&i>o-2e3&&r>1,s=r<<1;if(this.defaultTextDirection!=ne.LTR&&!n)return[];let a=[],l=(r,s,c,h)=>{if(s-rr&&ee.from>=c.from&&e.to<=c.to&&Math.abs(e.from-r)e.fromt));if(!f){if(se.from<=s&&e.to>=s)){let e=t.moveToLineBoundary(i.OF.cursor(s),!1,!0).head;e>r&&(s=e)}let e=this.gapSize(c,r,s,h);f=new jn(r,s,e,n||e<2e6?e:2e6)}a.push(f)},c=t=>{if(t.lengtho&&(r.push({from:o,to:e}),s+=e-o),o=t}},20),o2e6)for(let n of e)n.from>=t.from&&n.fromt.from&&l(t.from,a,t,o),ce.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];i.om.spans(t,this.viewport.from,this.viewport.to,{span(e,t){n.push({from:e,to:t})},point(){}},20);let r=0;if(n.length!=this.visibleRanges.length)r=12;else for(let t=0;t=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||Qn(this.heightMap.lineAt(e,Dn.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||Qn(this.heightMap.lineAt(this.scaler.fromDOM(e),Dn.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return Qn(this.heightMap.blockAt(this.scaler.fromDOM(e),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 $n{constructor(e,t){this.from=e,this.to=t}}function Yn({total:e,ranges:t},n){if(n<=0)return t[0].from;if(n>=1)return t[t.length-1].to;let i=Math.floor(e*n);for(let e=0;;e++){let{from:n,to:r}=t[e],o=r-n;if(i<=o)return n+i;i-=o}}function Gn(e,t){let n=0;for(let{from:i,to:r}of e.ranges){if(t<=r){n+=t-i;break}n+=r-i}return n/e.total}const Xn={toDOM:e=>e,fromDOM:e=>e,scale:1,eq(e){return e==this}};function Jn(e){let t=e.facet(_e).filter(e=>"function"!=typeof e),n=e.facet($e).filter(e=>"function"!=typeof e);return n.length&&t.push(i.om.join(n)),t}class Zn{constructor(e,t,n){let i=0,r=0,o=0;this.viewports=n.map(({from:n,to:r})=>{let o=t.lineAt(n,Dn.ByPos,e,0,0).top,s=t.lineAt(r,Dn.ByPos,e,0,0).bottom;return i+=s-o,{from:n,to:r,top:o,bottom:s,domTop:0,domBottom:0}}),this.scale=(7e6-i)/(t.height-i);for(let e of this.viewports)e.domTop=o+(e.top-r)*this.scale,o=e.domBottom=e.domTop+(e.bottom-e.top),r=e.bottom}toDOM(e){for(let t=0,n=0,i=0;;t++){let r=tt.from==e.viewports[n].from&&t.to==e.viewports[n].to)}}function Qn(e,t){if(1==t.scale)return e;let n=t.toDOM(e.top),i=t.toDOM(e.bottom);return new On(e.from,e.length,n,i-n,Array.isArray(e._content)?e._content.map(e=>Qn(e,t)):e._content)}const ei=i.sj.define({combine:e=>e.join(" ")}),ti=i.sj.define({combine:e=>e.indexOf(!0)>-1}),ni=r.G.newName(),ii=r.G.newName(),ri=r.G.newName(),oi={"&light":"."+ii,"&dark":"."+ri};function si(e,t,n){return new r.G(t,{finish:t=>/&/.test(t)?t.replace(/&\w*/,t=>{if("&"==t)return e;if(!n||!n[t])throw new RangeError(`Unsupported selector: ${t}`);return n[t]}):e+" "+t})}const ai=si("."+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,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,\')',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"}},oi),li={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},ci=y.ie&&y.ie_version<=11;class hi{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new U,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let e of t)this.queue.push(e);(y.ie&&y.ie_version<=11||y.ios&&e.composing)&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),!window.EditContext||!y.android||!1===e.constructor.EDIT_CONTEXT||y.chrome&&y.chrome_version<126||(this.editContext=new fi(e),e.state.facet(Fe)&&(e.contentDOM.editContext=this.editContext.editContext)),ci&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver(()=>{var e;(null===(e=this.view.docView)||void 0===e?void 0:e.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){("change"!=e.type&&e.type||e.matches)&&(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,i=this.selectionRange;if(n.state.facet(Fe)?n.root.activeElement!=this.dom:!P(this.dom,i))return;let r=i.anchorNode&&n.docView.tile.nearest(i.anchorNode);r&&r.isWidget()&&r.widget.ignoreEvent(e)?t||(this.selectionChanged=!1):(y.ie&&y.ie_version<=11||y.android&&y.chrome)&&!n.state.selection.main.empty&&i.focusNode&&N(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=B(e.root);if(!t)return!1;let n=y.safari&&11==e.root.nodeType&&e.root.activeElement==this.dom&&function(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return di(e,n)}let n=null;function i(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.contentDOM.addEventListener("beforeinput",i,!0),e.dom.ownerDocument.execCommand("indent"),e.contentDOM.removeEventListener("beforeinput",i,!0),n?di(e,n):null}(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let i=P(this.dom,n);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let e=this.delayedAndroidKey;e&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&J(this.dom,e.key,e.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(e)}this.delayedAndroidKey&&"Enter"!=e||(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,i=!1;for(let r of e){let e=this.readMutation(r);e&&(e.typeOver&&(i=!0),-1==t?({from:t,to:n}=e):(t=Math.min(e.from,t),n=Math.max(e.to,n)))}return{from:t,to:n,typeOver:i}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),i=this.selectionChanged&&P(this.dom,this.selectionRange);if(e<0&&!i)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new _t(this.view,e,t,n);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,i=$t(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!Xt(this.view.state.selection,t.newSel.main))&&this.view.update([]),i}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty("attributes"==e.type),"childList"==e.type){let n=ui(t,e.previousSibling||e.target.previousSibling,-1),i=ui(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:i?t.posBefore(i):t.posAtEnd,typeOver:!1}}return"characterData"==e.type?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Fe)!=e.state.facet(Fe)&&(e.view.contentDOM.editContext=e.state.facet(Fe)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),null===(e=this.intersection)||void 0===e||e.disconnect(),null===(t=this.gapIntersection)||void 0===t||t.disconnect(),null===(n=this.resizeScroll)||void 0===n||n.disconnect();for(let e of this.scrollTargets)e.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function ui(e,t,n){for(;t;){let i=it.get(t);if(i&&i.parent==e)return i;let r=t.parentNode;t=r!=e.dom?r:n>0?t.nextSibling:t.previousSibling}return null}function di(e,t){let n=t.startContainer,i=t.startOffset,r=t.endContainer,o=t.endOffset,s=e.docView.domAtPos(e.state.selection.main.anchor,1);return N(s.node,s.offset,r,o)&&([n,i,r,o]=[r,o,n,i]),{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:o}}class fi{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let r=e.state.selection.main,{anchor:o,head:s}=r,a=this.toEditorPos(n.updateRangeStart),l=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:a,drifted:!1});let c=l-a>n.text.length;a==this.from&&othis.to&&(l=o);let h=Gt(e.state.sliceDoc(a,l),n.text,(c?r.from:r.to)-a,c?"end":null);if(!h){let t=i.OF.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));return void(Xt(t,r)||e.dispatch({selection:t,userEvent:"select"}))}let u={from:h.from+a,to:h.toA+a,insert:i.EY.of(n.text.slice(h.from,h.toB).split("\n"))};if((y.mac||y.android)&&u.from==s-1&&/^\. ?$/.test(n.text)&&"off"==e.contentDOM.getAttribute("autocorrect")&&(u={from:a,to:l,insert:i.EY.of([n.text.replace("."," ")])}),this.pendingContextChange=u,!e.state.readOnly){let t=this.to-this.from+(u.to-u.from+u.insert.length);Yt(e,u,i.OF.single(this.toEditorPos(n.selectionStart,t),this.toEditorPos(n.selectionEnd,t)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),u.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let i=[],r=null;for(let t=this.toEditorPos(n.rangeStart),o=this.toEditorPos(n.rangeEnd);t{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,i=e.underlineThickness;if(!/none/i.test(t)&&!/none/i.test(i)){let r=this.toEditorPos(e.rangeStart),o=this.toEditorPos(e.rangeEnd);if(r{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:t}=this.composing;this.composing=null,t&&this.reset(e.state)}};for(let e in this.handlers)t.addEventListener(e,this.handlers[e]);this.measureReq={read:e=>{let t=B(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,i=this.pendingContextChange;return e.changes.iterChanges((r,o,s,a,l)=>{if(n)return;let c=l.length-(o-r);if(i&&o>=i.to){if(i.from==r&&i.to==o&&i.insert.eq(l))return i=this.pendingContextChange=null,t+=c,void(this.to+=c);i=null,this.revertPending(e.state)}if(r+=t,(o+=t)<=this.from)this.from+=c,this.to+=c;else if(rthis.to||this.to-this.from+l.length>3e4)return void(n=!0);this.editContext.updateText(this.toContextPos(r),this.toContextPos(o),l.toString()),this.to+=c}t+=c}),i&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(e=>!e.isUserEvent("input.type")&&e.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):this.applyEdits(e)&&this.rangeIsValid(e.state)?(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state):(this.pendingContextChange=null,this.reset(e.state)),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),i=this.toContextPos(t.head);this.editContext.selectionStart==n&&this.editContext.selectionEnd==i||this.editContext.updateSelection(n,i)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to3e4)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class pi{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var 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),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;this.dispatchTransactions=e.dispatchTransactions||n&&(e=>e.forEach(e=>n(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||function(e){for(;e;){if(e&&(9==e.nodeType||11==e.nodeType&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}(e.parent)||document,this.viewState=new Un(this,e.state||i.$t.create(e)),e.scrollTo&&e.scrollTo.is(Pe)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(He).map(e=>new Ve(e));for(let e of this.plugins)e.update(this);this.observer=new hi(this),this.inputState=new Jt(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Mt(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),(null===(t=document.fonts)||void 0===t?void 0:t.ready)&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=1==e.length&&e[0]instanceof i.ZX?e:1==e.length&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t,n=!1,r=!1,o=this.state;for(let t of e){if(t.startState!=o)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");o=t.state}if(this.destroyed)return void(this.viewState.state=o);let s=this.hasFocus,a=0,l=null;e.some(e=>e.annotation(vn))?(this.inputState.notifiedFocused=s,a=1):s!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=s,l=wn(o,s),l||(a=1));let c=this.observer.delayedAndroidKey,h=null;if(c?(this.observer.clearDelayedAndroidKey(),h=this.observer.readChange(),(h&&!this.state.doc.eq(o.doc)||!this.state.selection.eq(o.selection))&&(h=null)):this.observer.clear(),o.facet(i.$t.phrases)!=this.state.facet(i.$t.phrases))return this.setState(o);t=tt.create(this,o,e),t.flags|=a;let u=this.viewState.scrollTarget;try{this.updateState=2;for(let t of e){if(u&&(u=u.map(t.changes)),t.scrollIntoView){let{main:e}=t.state.selection,{x:n,y:r}=this.state.facet(pi.cursorScrollMargin);u=new Re(e.empty?e:i.OF.cursor(e.head,e.head>e.anchor?-1:1),"nearest","nearest",r,n)}for(let e of t.effects)e.is(Pe)&&(u=e.value.clip(this.state))}this.viewState.update(t,u),this.bidiCache=bi.update(this.bidiCache,t.changes),t.empty||(this.updatePlugins(t),this.inputState.update(t)),n=this.docView.update(t),this.state.facet(Qe)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(e=>e.isUserEvent("select.pointer")))}finally{this.updateState=0}if(t.startState.facet(ei)!=t.state.facet(ei)&&(this.viewState.mustMeasureContent=!0),(n||r||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!t.empty)for(let e of this.state.facet(Me))try{e(t)}catch(e){Ne(this.state,e,"update listener")}(l||h)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),h&&!$t(this,h)&&c.force&&J(this.contentDOM,c.key,c.keyCode)})}setState(e){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=e);this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);this.viewState=new Un(this,e),this.plugins=e.facet(He).map(e=>new Ve(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new Mt(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(He),n=e.state.facet(He);if(t!=n){let i=[];for(let r of n){let n=t.indexOf(r);if(n<0)i.push(new Ve(r));else{let t=this.plugins[n];t.mustUpdate=e,i.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=i,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey)return this.measureScheduled=-1,void this.requestMeasure();this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.viewState.scrollParent,i=this.viewState.getScrollOffset(),{scrollAnchorPos:r,scrollAnchorHeight:o}=this.viewState;Math.abs(i-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(o<0)if(Z(n||this.win))r=-1,o=this.viewState.heightMap.height;else{let e=this.viewState.scrollAnchorAt(i);r=e.from,o=e.top}this.updateState=1;let s=this.viewState.measure();if(!s&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(e>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let a=[];4&s||([this.measureRequests,a]=[a,this.measureRequests]);let l=a.map(e=>{try{return e.read(this)}catch(e){return Ne(this.state,e),gi}}),c=tt.create(this,this.state,[]),h=!1;c.flags|=s,t?t.flags|=s:t=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),h=this.docView.update(c),h&&this.docViewUpdate());for(let e=0;e1||e<-1)&&!(y.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(n==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){i+=e,n?n.scrollTop+=e:this.win.scrollBy(0,e),o=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(Me))e(t)}get themeClasses(){return ni+" "+(this.state.facet(ti)?ri:ii)+" "+this.state.facet(ei)}updateAttrs(){let e=yi(this,je,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Fe)?"true":"false",class:"cm-content",style:`${y.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),yi(this,Ke,t);let n=this.observer.ignore(()=>{let n=x(this.contentDOM,this.contentAttrs,t),i=x(this.dom,this.editorAttrs,e);return n||i});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let e of n.effects)e.is(pi.announce)&&(t&&(this.announceDOM.textContent=""),t=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=e.value)}mountStyles(){this.styleModules=this.state.facet(Qe);let e=this.state.facet(pi.cspNonce);r.G.mount(this.root,this.styleModules.concat(ai).reverse(),e?{nonce:e}: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(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(null!=e.key)for(let t=0;tt.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return It(this,e,Bt(this,e,t,n))}moveByGroup(e,t){return It(this,e,Bt(this,e,t,t=>function(e,t,n){let r=e.state.charCategorizer(t),o=r(n);return e=>{let t=r(e);return o==i.Je.Space&&(o=t),o==t}}(this,e.head,t)))}visualLineSide(e,t){let n=this.bidiSpans(e),r=this.textDirectionAt(e.from),o=n[t?n.length-1:0];return i.OF.cursor(o.side(t,r)+e.from,o.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,n=!0){return function(e,t,n,r){let o=Et(e,t.head,t.assoc||-1),s=r&&o.type==A.Text&&(e.lineWrapping||o.widgetLineBreaks)?e.coordsAtPos(t.assoc<0&&t.head>o.from?t.head-1:t.head):null;if(s){let t=e.dom.getBoundingClientRect(),r=e.textDirectionAt(o.from),a=e.posAtCoords({x:n==(r==ne.LTR)?t.right-1:t.left+1,y:(s.top+s.bottom)/2});if(null!=a)return i.OF.cursor(a,n?-1:1)}return i.OF.cursor(n?o.to:o.from,n?-1:1)}(this,e,t,n)}moveVertically(e,t,n){return It(this,e,function(e,t,n,r){let o=t.head,s=n?1:-1;if(o==(n?e.state.doc.length:0))return i.OF.cursor(o,t.assoc);let a,l=t.goalColumn,c=e.contentDOM.getBoundingClientRect(),h=e.coordsAtPos(o,t.assoc||((t.empty?n:t.head==t.from)?1:-1)),u=e.documentTop;if(h)null==l&&(l=h.left-c.left),a=s<0?h.top:h.bottom;else{let t=e.viewState.lineBlockAt(o);null==l&&(l=Math.min(c.right-c.left,e.defaultCharacterWidth*(o-t.from))),a=(s<0?t.top:t.bottom)+u}let d=c.left+l,f=e.viewState.heightOracle.textHeight>>1,p=null!=r?r:f;for(let t=0;;t+=f){let r=a+(p+t)*s,o=Ft(e,{x:d,y:r},!1,s);if(n?r>c.bottom:ra:uthis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>mi)return ye(e.length);let t,n=this.textDirectionAt(e.from);for(let i of this.bidiCache)if(i.from==e.from&&i.dir==n&&(i.fresh||fe(i.isolates,t=Xe(this,e))))return i.order;t||(t=Xe(this,e));let i=be(e.text,n,t);return this.bidiCache.push(new bi(e.from,e.to,n,t,!0,i)),i}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||y.safari&&(null===(e=this.inputState)||void 0===e?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{G(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((9==e.nodeType?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){var n,r,o,s;return Pe.of(new Re("number"==typeof e?i.OF.cursor(e):e,null!==(n=t.y)&&void 0!==n?n:"nearest",null!==(r=t.x)&&void 0!==r?r:"nearest",null!==(o=t.yMargin)&&void 0!==o?o:5,null!==(s=t.xMargin)&&void 0!==s?s:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return Pe.of(new Re(i.OF.cursor(n.from),"start","start",n.top-e,t,!0))}setTabFocusMode(e){null==e?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof e?this.inputState.tabFocusMode=e?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return qe.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return qe.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=r.G.newName(),i=[ei.of(n),Qe.of(si(`.${n}`,e))];return t&&t.dark&&i.push(ti.of(!0)),i}static baseTheme(e){return i.Nb.lowest(Qe.of(si("."+ni,e,oi)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),i=n&&it.get(n)||it.get(e);return(null===(t=null==i?void 0:i.root)||void 0===t?void 0:t.view)||null}}pi.styleModule=Qe,pi.inputHandler=Te,pi.clipboardInputFilter=De,pi.clipboardOutputFilter=Le,pi.scrollHandler=Be,pi.focusChangeEffect=Oe,pi.perLineTextDirection=ze,pi.exceptionSink=Ae,pi.updateListener=Me,pi.editable=Fe,pi.mouseSelectionStyle=Ce,pi.dragMovesSelection=Se,pi.clickAddsSelectionRange=xe,pi.decorations=_e,pi.blockWrappers=Ue,pi.outerDecorations=$e,pi.atomicRanges=Ye,pi.bidiIsolatedRanges=Ge,pi.cursorScrollMargin=i.sj.define({combine:e=>{let t=5,n=5;for(let i of e)"number"==typeof i?t=n=i:({x:t,y:n}=i);return{x:t,y:n}}}),pi.scrollMargins=Je,pi.darkTheme=ti,pi.cspNonce=i.sj.define({combine:e=>e.length?e[0]:""}),pi.contentAttributes=Ke,pi.editorAttributes=je,pi.lineWrapping=pi.contentAttributes.of({class:"cm-lineWrapping"}),pi.announce=i.Pe.define();const mi=4096,gi={};class bi{constructor(e,t,n,i,r,o){this.from=e,this.to=t,this.dir=n,this.isolates=i,this.fresh=r,this.order=o}static update(e,t){if(t.empty&&!e.some(e=>e.fresh))return e;let n=[],i=e.length?e[e.length-1].dir:ne.LTR;for(let r=Math.max(0,e.length-10);r=0;r--){let t=i[r],o="function"==typeof t?t(e):t;o&&v(o,n)}return n}const vi=y.mac?"mac":y.windows?"win":y.linux?"linux":"key";function wi(e,t,n){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),!1!==n&&t.shiftKey&&(e="Shift-"+e),e}const ki=i.Nb.default(pi.domEventHandlers({keydown:(e,t)=>Oi(Ci(t.state),e,t,"editor")})),xi=i.sj.define({enables:ki}),Si=new WeakMap;function Ci(e){let t=e.facet(xi),n=Si.get(t);return n||Si.set(t,n=function(e,t=vi){let n=Object.create(null),i=Object.create(null),r=(e,t)=>{let n=i[e];if(null==n)i[e]=t;else if(n!=t)throw new Error("Key binding "+e+" is used both as a regular binding and as a multi-stroke prefix")},o=(e,i,o,s,a)=>{var l,c;let h=n[e]||(n[e]=Object.create(null)),u=i.split(/ (?!$)/).map(e=>function(e,t){const n=e.split(/-(?!$)/);let i,r,o,s,a=n[n.length-1];"Space"==a&&(a=" ");for(let e=0;e{let i=Mi={view:t,prefix:n,scope:e};return setTimeout(()=>{Mi==i&&(Mi=null)},4e3),!0}]})}let d=u.join(" ");r(d,!1);let f=h[d]||(h[d]={preventDefault:!1,stopPropagation:!1,run:(null===(c=null===(l=h._any)||void 0===l?void 0:l.run)||void 0===c?void 0:c.slice())||[]});o&&f.run.push(o),s&&(f.preventDefault=!0),a&&(f.stopPropagation=!0)};for(let i of e){let e=i.scope?i.scope.split(" "):["editor"];if(i.any)for(let t of e){let e=n[t]||(n[t]=Object.create(null));e._any||(e._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:r}=i;for(let t in e)e[t].run.push(e=>r(e,Ti))}let r=i[t]||i.key;if(r)for(let t of e)o(t,r,i.run,i.preventDefault,i.stopPropagation),i.shift&&o(t,"Shift-"+r,i.shift,i.preventDefault,i.stopPropagation)}return n}(t.reduce((e,t)=>e.concat(t),[]))),n}function Ai(e,t,n){return Oi(Ci(e.state),t,e,n)}let Mi=null,Ti=null;function Oi(e,t,n,r){Ti=t;let s=(0,o.xT)(t),a=(0,i.vS)(s,0),l=(0,i.Fh)(a)==s.length&&" "!=s,c="",h=!1,u=!1,d=!1;Mi&&Mi.view==n&&Mi.scope==r&&(c=Mi.prefix+" ",nn.indexOf(t.keyCode)<0&&(u=!0,Mi=null));let f,p,m=new Set,g=e=>{if(e){for(let t of e.run)if(!m.has(t)&&(m.add(t),t(n)))return e.stopPropagation&&(d=!0),!0;e.preventDefault&&(e.stopPropagation&&(d=!0),u=!0)}return!1},b=e[r];return b&&(g(b[c+wi(s,t,!l)])?h=!0:!l||!(t.altKey||t.metaKey||t.ctrlKey)||y.windows&&t.ctrlKey&&t.altKey||y.mac&&t.altKey&&!t.ctrlKey&&!t.metaKey||!(f=o.E3[t.keyCode])||f==s?l&&t.shiftKey&&g(b[c+wi(s,t,!0)])&&(h=!0):(g(b[c+wi(f,t,!0)])||t.shiftKey&&(p=o.BN[t.keyCode])!=s&&p!=f&&g(b[c+wi(p,t,!1)]))&&(h=!0),!h&&g(b._any)&&(h=!0)),u&&(h=!0),h&&d&&t.stopPropagation(),Ti=null,h}class Di{constructor(e,t,n,i,r){this.className=e,this.left=t,this.top=n,this.width=i,this.height=r}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className==this.className&&(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",null!=this.width&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,n){if(n.empty){let i=e.coordsAtPos(n.head,n.assoc||1);if(!i)return[];let r=Li(e);return[new Di(t,i.left-r.left,i.top-r.top,null,i.bottom-i.top)]}return function(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let i=Math.max(n.from,e.viewport.from),r=Math.min(n.to,e.viewport.to),o=e.textDirection==ne.LTR,s=e.contentDOM,a=s.getBoundingClientRect(),l=Li(e),c=s.querySelector(".cm-line"),h=c&&window.getComputedStyle(c),u=a.left+(h?parseInt(h.paddingLeft)+Math.min(0,parseInt(h.textIndent)):0),d=a.right-(h?parseInt(h.paddingRight):0),f=Et(e,i,1),p=Et(e,r,-1),m=f.type==A.Text?f:null,g=p.type==A.Text?p:null;if(m&&(e.lineWrapping||f.widgetLineBreaks)&&(m=zi(e,i,1,m)),g&&(e.lineWrapping||p.widgetLineBreaks)&&(g=zi(e,r,-1,g)),m&&g&&m.from==g.from&&m.to==g.to)return y(v(n.from,n.to,m));{let t=m?v(n.from,null,m):w(f,!1),i=g?v(null,n.to,g):w(p,!0),r=[];return(m||f).to<(g||p).from-(m&&g?1:0)||f.widgetLineBreaks>1&&t.bottom+e.defaultLineHeight/2c&&i.from=o)break;a>r&&l(Math.max(e,r),null==t&&e<=c,Math.min(a,o),null==n&&a>=h,s.dir)}if(r=i.to+1,r>=o)break}return 0==a.length&&l(c,null==t,h,null==n,e.textDirection),{top:r,bottom:s,horizontal:a}}function w(e,t){let n=a.top+(t?e.top:e.bottom);return{top:n,bottom:n,horizontal:[]}}}(e,t,n)}}function Li(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==ne.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function zi(e,t,n,i){let r=e.coordsAtPos(t,2*n);if(!r)return i;let o=e.dom.getBoundingClientRect(),s=(r.top+r.bottom)/2,a=e.posAtCoords({x:o.left+1,y:s}),l=e.posAtCoords({x:o.right-1,y:s});return null==a||null==l?i:{from:Math.max(i.from,Math.min(a,l)),to:Math.min(i.to,Math.max(a,l))}}class Ei{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(Bi)!=e.state.facet(Bi)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){!1!==this.layer.updateOnDocViewUpdate&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(Bi);for(;t{return n=e,i=this.drawn[t],!(n.constructor==i.constructor&&n.eq(i));var n,i})){let t=this.dom.firstChild,n=0;for(let i of e)i.update&&t&&i.constructor&&this.drawn[n].constructor&&i.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(i.draw(),t);for(;t;){let e=t.nextSibling;t.remove(),t=e}this.drawn=e,y.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Bi=i.sj.define();function Ri(e){return[qe.define(t=>new Ei(t,e)),Bi.of(e)]}const Pi=i.sj.define({combine:e=>(0,i.QR)(e,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})});function Ii(e={}){return[Pi.of(e),Wi,qi,ji,Ee.of(!0)]}function Ni(e){return e.facet(Pi)}function Fi(e){return e.startState.facet(Pi)!=e.state.facet(Pi)}const Wi=Ri({above:!0,markers(e){let{state:t}=e,n=t.facet(Pi),r=[];for(let o of t.selection.ranges){let s=o==t.selection.main;if(o.empty||n.drawRangeCursor&&!(s&&y.ios&&n.iosSelectionHandles)){let t=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",n=o.empty?o:i.OF.cursor(o.head,o.assoc);for(let i of Di.forRange(e,t,n))r.push(i)}}return r},update(e,t){e.transactions.some(e=>e.selection)&&(t.style.animationName="cm-blink"==t.style.animationName?"cm-blink2":"cm-blink");let n=Fi(e);return n&&Hi(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){Hi(t.state,e)},class:"cm-cursorLayer"});function Hi(e,t){t.style.animationDuration=e.facet(Pi).cursorBlinkRate+"ms"}const qi=Ri({above:!1,markers(e){let t=[],{main:n,ranges:r}=e.state.selection;for(let n of r)if(!n.empty)for(let i of Di.forRange(e,"cm-selectionBackground",n))t.push(i);if(y.ios&&!n.empty&&e.state.facet(Pi).iosSelectionHandles){for(let r of Di.forRange(e,"cm-selectionHandle cm-selectionHandle-start",i.OF.cursor(n.from,1)))t.push(r);for(let r of Di.forRange(e,"cm-selectionHandle cm-selectionHandle-end",i.OF.cursor(n.to,1)))t.push(r)}return t},update:(e,t)=>e.docChanged||e.selectionSet||e.viewportChanged||Fi(e),class:"cm-selectionLayer"}),Vi=y.gecko&&y.gecko_version>=153?"#ffffff01":"transparent",ji=i.Nb.highest(pi.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${Vi} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),Ki=i.Pe.define({map:(e,t)=>null==e?null:t.mapPos(e)}),_i=i.sU.define({create:()=>null,update:(e,t)=>(null!=e&&(e=t.changes.mapPos(e)),t.effects.reduce((e,t)=>t.is(Ki)?t.value:e,e))}),Ui=qe.fromClass(class{constructor(e){this.view=e,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(e){var t;let n=e.state.field(_i);null==n?null!=this.cursor&&(null===(t=this.cursor)||void 0===t||t.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(e.startState.field(_i)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(_i),n=null!=t&&e.coordsAtPos(t);if(!n)return null;let i=e.scrollDOM.getBoundingClientRect();return{left:n.left-i.left+e.scrollDOM.scrollLeft*e.scaleX,top:n.top-i.top+e.scrollDOM.scrollTop*e.scaleY,height:n.bottom-n.top}}drawCursor(e){if(this.cursor){let{scaleX:t,scaleY:n}=this.view;e?(this.cursor.style.left=e.left/t+"px",this.cursor.style.top=e.top/n+"px",this.cursor.style.height=e.height/n+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(e){this.view.state.field(_i)!=e&&this.view.dispatch({effects:Ki.of(e)})}},{eventObservers:{dragover(e){this.setDropPos(this.view.posAtCoords({x:e.clientX,y:e.clientY}))},dragleave(e){e.target!=this.view.contentDOM&&this.view.contentDOM.contains(e.relatedTarget)||this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function $i(){return[_i,Ui]}function Yi(e,t,n,i,r){t.lastIndex=0;for(let o,s=e.iterRange(n,i),a=n;!s.next().done;a+=s.value.length)if(!s.lineBreak)for(;o=t.exec(s.value);)r(a+o.index,o)}class Gi{constructor(e){const{regexp:t,decoration:n,decorate:i,boundary:r,maxLength:o=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,i)this.addMatch=(e,t,n,r)=>i(r,n,n+e[0].length,e,t);else if("function"==typeof n)this.addMatch=(e,t,i,r)=>{let o=n(e,t,i);o&&r(i,i+e[0].length,o)};else{if(!n)throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.addMatch=(e,t,i,r)=>r(i,i+e[0].length,n)}this.boundary=r,this.maxLength=o}createDeco(e){let t=new i.vB,n=t.add.bind(t);for(let{from:t,to:i}of function(e,t){let n=e.visibleRanges;if(1==n.length&&n[0].from==e.viewport.from&&n[0].to==e.viewport.to)return n;let i=[];for(let{from:r,to:o}of n)r=Math.max(e.state.doc.lineAt(r).from,r-t),o=Math.min(e.state.doc.lineAt(o).to,o+t),i.length&&i[i.length-1].to>=r?i[i.length-1].to=o:i.push({from:r,to:o});return i}(e,this.maxLength))Yi(e.state.doc,this.regexp,t,i,(t,i)=>this.addMatch(i,e,t,n));return t.finish()}updateDeco(e,t){let n=1e9,i=-1;return e.docChanged&&e.changes.iterChanges((t,r,o,s)=>{s>=e.view.viewport.from&&o<=e.view.viewport.to&&(n=Math.min(o,n),i=Math.max(s,i))}),e.viewportMoved||i-n>1e3?this.createDeco(e.view):i>-1?this.updateRange(e.view,t.map(e.changes),n,i):t}updateRange(e,t,n,i){for(let r of e.visibleRanges){let o=Math.max(r.from,n),s=Math.min(r.to,i);if(s>=o){let n=e.state.doc.lineAt(o),i=n.ton.from;o--)if(this.boundary.test(n.text[o-1-n.from])){a=o;break}for(;sh.push(n.range(e,t));if(n==i)for(this.regexp.lastIndex=a-n.from;(c=this.regexp.exec(n.text))&&c.indexthis.addMatch(n,e,t,u));t=t.update({filterFrom:a,filterTo:l,filter:(e,t)=>el,add:h})}}return t}}const Xi=null!=/x/.unicode?"gu":"g",Ji=new RegExp("[\0-\b\n--Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\ufeff-]",Xi),Zi={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let Qi=null;const er=i.sj.define({combine(e){let t=(0,i.QR)(e,{render:null,specialChars:Ji,addSpecialChars:null});return(t.replaceTabs=!function(){var e;if(null==Qi&&"undefined"!=typeof document&&document.body){let t=document.body.style;Qi=null!=(null!==(e=t.tabSize)&&void 0!==e?e:t.MozTabSize)}return Qi||!1}())&&(t.specialChars=new RegExp("\t|"+t.specialChars.source,Xi)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,Xi)),t}});function tr(e={}){return[er.of(e),nr||(nr=qe.fromClass(class{constructor(e){this.view=e,this.decorations=M.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(er)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new Gi({regexp:e.specialChars,decoration:(t,n,r)=>{let{doc:o}=n.state,s=(0,i.vS)(t[0],0);if(9==s){let e=o.lineAt(r),t=n.state.tabSize,s=(0,i.y$)(e.text,t,r-e.from);return M.replace({widget:new rr((t-s%t)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=M.replace({widget:new ir(e,s)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(er);e.startState.facet(er)!=t?(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(e.view)):this.decorations=this.decorator.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}))]}let nr=null;class ir extends C{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=(n=this.code)>=32?"•":10==n?"␤":String.fromCharCode(9216+n);var n;let i=e.state.phrase("Control character")+" "+(Zi[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,i,t);if(r)return r;let o=document.createElement("span");return o.textContent=t,o.title=i,o.setAttribute("aria-label",i),o.className="cm-specialChar",o}ignoreEvent(){return!1}}class rr extends C{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent="\t",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}const or=qe.fromClass(class{constructor(){this.height=1e3,this.attrs={style:"padding-bottom: 1000px"}}update(e){let{view:t}=e,n=t.viewState.editorHeight-t.defaultLineHeight-t.documentPadding.top-.5;n>=0&&n!=this.height&&(this.height=n,this.attrs={style:`padding-bottom: ${n}px`})}});function sr(){return[or,Ke.of(e=>{var t;return(null===(t=e.plugin(or))||void 0===t?void 0:t.attrs)||null})]}function ar(){return cr}const lr=M.line({class:"cm-activeLine"}),cr=qe.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,n=[];for(let i of e.state.selection.ranges){let r=e.lineBlockAt(i.head);r.from>t&&(n.push(lr.range(r.from)),t=r.from)}return M.set(n)}},{decorations:e=>e.decorations});class hr extends C{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild("string"==typeof this.content?document.createTextNode(this.content):"function"==typeof this.content?this.content(e):this.content.cloneNode(!0)),t.setAttribute("aria-hidden","true"),t}coordsAt(e){let t=e.firstChild?I(e.firstChild):[];if(!t.length)return null;let n=window.getComputedStyle(e.parentNode),i=V(t[0],"rtl"!=n.direction),r=parseInt(n.lineHeight);return i.bottom-i.top>1.5*r?{left:i.left,right:i.right,top:i.top,bottom:i.top+r}:i}ignoreEvent(){return!1}}function ur(e){let t=qe.fromClass(class{constructor(t){this.view=t,this.placeholder=e?M.set([M.widget({widget:new hr(e),side:1}).range(0)]):M.none}get decorations(){return this.view.state.doc.length?M.none:this.placeholder}},{decorations:e=>e.decorations});return"string"==typeof e?[t,pi.contentAttributes.of({"aria-placeholder":e})]:t}const dr=2e3;function fr(e,t){let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1),r=e.state.doc.lineAt(n),o=n-r.from,s=o>dr?-1:o==r.length?function(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}(e,t.clientX):(0,i.y$)(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:s,off:o}}function pr(e){let t=(null==e?void 0:e.eventFilter)||(e=>e.altKey&&0==e.button);return pi.mouseSelectionStyle.of((e,n)=>t(n)?function(e,t){let n=fr(e,t),r=e.state.selection;return n?{update(e){if(e.docChanged){let t=e.changes.mapPos(e.startState.doc.line(n.line).from),i=e.state.doc.lineAt(t);n={line:i.number,col:n.col,off:Math.min(n.off,i.length)},r=r.map(e.changes)}},get(t,o,s){let a=fr(e,t);if(!a)return r;let l=function(e,t,n){let r=Math.min(t.line,n.line),o=Math.max(t.line,n.line),s=[];if(t.off>dr||n.off>dr||t.col<0||n.col<0){let a=Math.min(t.off,n.off),l=Math.max(t.off,n.off);for(let t=r;t<=o;t++){let n=e.doc.line(t);n.length<=l&&s.push(i.OF.range(n.from+a,n.to+l))}}else{let a=Math.min(t.col,n.col),l=Math.max(t.col,n.col);for(let t=r;t<=o;t++){let n=e.doc.line(t),r=(0,i.kn)(n.text,a,e.tabSize,!0);if(r<0)s.push(i.OF.cursor(n.to));else{let t=(0,i.kn)(n.text,l,e.tabSize);s.push(i.OF.range(n.from+r,n.from+t))}}}return s}(e.state,n,a);return l.length?s?i.OF.create(l.concat(r.ranges)):i.OF.create(l):r}}:null}(e,n):null)}const mr={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},gr={style:"cursor: crosshair"};function br(e={}){let[t,n]=mr[e.key||"Alt"],i=qe.fromClass(class{constructor(e){this.view=e,this.isDown=!1}set(e){this.isDown!=e&&(this.isDown=e,this.view.update([]))}},{eventObservers:{keydown(e){this.set(e.keyCode==t||n(e))},keyup(e){e.keyCode!=t&&n(e)||this.set(!1)},mousemove(e){this.set(n(e))}}});return[i,pi.contentAttributes.of(e=>{var t;return(null===(t=e.plugin(i))||void 0===t?void 0:t.isDown)?gr:null})]}const yr="-10000px";class vr{constructor(e,t,n,i){this.facet=t,this.createTooltipView=n,this.removeTooltipView=i,this.input=e.state.facet(t),this.tooltips=this.input.filter(e=>e);let r=null;this.tooltipViews=this.tooltips.map(e=>r=n(e,r))}update(e,t){var n;let i=e.state.facet(this.facet),r=i.filter(e=>e);if(i===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let o=[],s=t?[]:null;for(let n=0;nt[n]=e),t.length=s.length),this.input=i,this.tooltips=r,this.tooltipViews=o,!0}}function wr(e={}){return xr.of(e)}function kr(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const xr=i.sj.define({combine:e=>{var t,n,i;return{position:y.ios?"absolute":(null===(t=e.find(e=>e.position))||void 0===t?void 0:t.position)||"fixed",parent:(null===(n=e.find(e=>e.parent))||void 0===n?void 0:n.parent)||null,tooltipSpace:(null===(i=e.find(e=>e.tooltipSpace))||void 0===i?void 0:i.tooltipSpace)||kr}}}),Sr=new WeakMap,Cr=qe.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(xr);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver="function"==typeof ResizeObserver?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new vr(e,Or,(e,t)=>this.createTooltip(e,t),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver="function"==typeof IntersectionObserver?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.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 e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,i=e.state.facet(xr);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let e of this.manager.tooltipViews)e.dom.style.position=this.position;n=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let e of this.manager.tooltipViews)this.container.appendChild(e.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),i=t?t.dom:null;if(n.dom.classList.add("cm-tooltip"),e.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let e=document.createElement("div");e.className="cm-tooltip-arrow",n.dom.appendChild(e)}return n.dom.style.position=this.position,n.dom.style.top=yr,n.dom.style.left="0px",this.container.insertBefore(n.dom,i),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),null===(e=t.destroy)||void 0===e||e.call(t);this.parent&&this.container.remove(),null===(t=this.resizeObserver)||void 0===t||t.disconnect(),null===(n=this.intersectionObserver)||void 0===n||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if("fixed"==this.position&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(y.safari){let t=e.getBoundingClientRect();n=Math.abs(t.top+1e4)>1||Math.abs(t.left)>1}else n=!!e.offsetParent&&e.offsetParent!=this.container.ownerDocument.body}if(n||"absolute"==this.position)if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(e=n.width/this.parent.offsetWidth,t=n.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);let i=this.view.scrollDOM.getBoundingClientRect(),r=Ze(this.view);return{visible:{left:i.left+r.left,top:i.top+r.top,right:i.right-r.right,bottom:i.bottom-r.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((e,t)=>{let n=this.manager.tooltipViews[t];return n.getCoords?n.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(xr).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){var t;if(e.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let e of this.manager.tooltipViews)e.dom.style.position="absolute"}let{visible:n,space:i,scaleX:r,scaleY:o}=e,s=[];for(let a=0;a=Math.min(n.bottom,i.bottom)||u.rightMath.min(n.right,i.right)+.1)){h.style.top=yr;continue}let f=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=f?7:0,m=d.right-d.left,g=null!==(t=Sr.get(c))&&void 0!==t?t:d.bottom-d.top,b=c.offset||Tr,y=this.view.textDirection==ne.LTR,v=d.width>i.right-i.left?y?i.left:i.right-d.width:y?Math.max(i.left,Math.min(u.left-(f?14:0)+b.x,i.right-m)):Math.min(Math.max(i.left,u.left-m+(f?14:0)-b.x),i.right-m),w=this.above[a];!l.strictSide&&(w?u.top-g-p-b.yi.bottom)&&w==i.bottom-u.bottom>u.top-i.top&&(w=this.above[a]=!w);let k=(w?u.top-i.top:i.bottom-u.bottom)-p;if(kv&&e.topx&&(x=w?e.top-g-2-p:e.bottom+p+2);if("absolute"==this.position?(h.style.top=(x-e.parent.top)/o+"px",Ar(h,(v-e.parent.left)/r)):(h.style.top=x/o+"px",Ar(h,v/r)),f){let e=u.left+(y?b.x:-b.x)-(v+14-7);f.style.left=e/r+"px"}!0!==c.overlap&&s.push({left:v,top:x,right:S,bottom:x+g}),h.classList.toggle("cm-tooltip-above",w),h.classList.toggle("cm-tooltip-below",!w),c.positioned&&c.positioned(e.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 e of this.manager.tooltipViews)e.dom.style.top=yr}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Ar(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}const Mr=pi.baseTheme({".cm-tooltip":{zIndex:500,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"}}}),Tr={x:0,y:0},Or=i.sj.define({enables:[Cr,Mr]}),Dr=i.sj.define({combine:e=>e.reduce((e,t)=>e.concat(t),[])});class Lr{static create(e){return new Lr(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new vr(e,Dr,(e,t)=>this.createHostedView(e,t),e=>e.dom.remove())}createHostedView(e,t){let n=e.create(this.view);return n.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(n.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)null===(e=t.destroy)||void 0===e||e.call(t)}passProp(e){let t;for(let n of this.manager.tooltipViews){let i=n[e];if(void 0!==i)if(void 0===t)t=i;else if(t!==i)return}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const zr=Or.compute([Dr],e=>{let t=e.facet(Dr);return 0===t.length?null:{pos:Math.min(...t.map(e=>e.pos)),end:Math.max(...t.map(e=>{var t;return null!==(t=e.end)&&void 0!==t?t:e.pos})),create:Lr.create,above:t[0].above,arrow:t.some(e=>e.arrow)}}),Er=i.sj.define();class Br{constructor(e,t,n,i,r,o){this.view=e,this.source=t,this.field=n,this.locked=i,this.setHover=r,this.hoverTime=o,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(e){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;en.bottom||t.xn.right+e.defaultCharacterWidth)return;let o=e.bidiSpans(e.state.doc.lineAt(i)).find(e=>e.from<=i&&e.to>=i),s=o&&o.dir==ne.RTL?-1:1;r=t.x{if(t&&(!Array.isArray(t)||t.length)){let n=Array.isArray(t)?t:[t];i&&this.locked.set(n,i),e.dispatch({effects:this.setHover.of(n)})}};if(r&&"then"in r){let n=this.pending={pos:t};r.then(e=>{this.pending==n&&(this.pending=null,o(e))},t=>Ne(e.state,t,"hover tooltip"))}else o(r)}get tooltip(){let e=this.view.plugin(Cr),t=e?e.manager.tooltips.findIndex(e=>e.create==Lr.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,n;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:r}=this;if(i.length&&!this.locked.has(i)&&r&&!function(e,t){let n,{left:i,right:r,top:o,bottom:s}=e.getBoundingClientRect();if(n=e.querySelector(".cm-tooltip-arrow")){let e=n.getBoundingClientRect();o=Math.min(e.top,o),s=Math.max(e.bottom,s)}return t.clientX>=i-4&&t.clientX<=r+4&&t.clientY>=o-4&&t.clientY<=s+4}(r.dom,e)||this.pending){let{pos:r}=i[0]||this.pending,o=null!==(n=null===(t=i[0])||void 0===t?void 0:t.end)&&void 0!==n?n:r;(r==o?this.view.posAtCoords(this.lastMove)==r:function(e,t,n,i,r){let o=e.scrollDOM.getBoundingClientRect(),s=e.documentTop+e.documentPadding.top+e.contentHeight;if(o.left>i||o.rightr||Math.min(o.bottom,s)=t&&a<=n}(this.view,r,o,e.clientX,e.clientY))||(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length&&!this.locked.has(t)){let{tooltip:t}=this;t&&t.dom.contains(e.relatedTarget)?this.watchTooltipLeave(t.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=n=>{e.removeEventListener("mouseleave",t);let{active:i}=this;!i.length||this.locked.has(i)||this.view.dom.contains(n.relatedTarget)||this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}function Rr(e,t={}){let n=i.Pe.define(),r=new WeakMap,o=i.sU.define({create:()=>[],update(e,s){let a=r.get(e);if(e.length&&(t.hideOnChange&&(s.docChanged||s.selection)||a&&a(s)?e=[]:t.hideOn&&(e=e.filter(e=>!t.hideOn(s,e)))),s.docChanged&&e.length){let t=[];for(let n of e){let e=s.changes.mapPos(n.pos,-1,i.iR.TrackDel);if(null!=e){let i=Object.assign(Object.create(null),n);i.pos=e,null!=i.end&&(i.end=s.changes.mapPos(i.end)),t.push(i)}}e=t}for(let t of s.effects)t.is(n)&&(e=t.value,a=void 0),(t.is(Fr)&&!t.value||t.value==o)&&(e=[]);return e.length&&a&&r.set(e,a),e},provide:e=>Dr.from(e)});const s=qe.define(i=>new Br(i,e,o,r,n,t.hoverTime||300));return{active:o,extension:[o,s,Er.of(s),zr]}}function Pr(e,t,n,i={}){var r;let o=e.state.facet(Er).map(t=>e.plugin(t)).filter(e=>!!e);if(i.tooltip&&i.tooltip.active){let e=o.find(e=>e.field==i.tooltip.active);e&&(o=[e])}for(let s of o)s.activateHover(e,t,n,null!==(r=i.until)&&void 0!==r?r:()=>!1)}function Ir(e,t){let n=e.plugin(Cr);if(!n)return null;let i=n.manager.tooltips.indexOf(t);return i<0?null:n.manager.tooltipViews[i]}function Nr(e){return e.facet(Dr).some(e=>e)}const Fr=i.Pe.define(),Wr=Fr.of(null);function Hr(e){return Fr.of(e.active)}function qr(e){let t=e.plugin(Cr);t&&t.maybeMeasure()}const Vr=i.sj.define({combine(e){let t,n;for(let i of e)t=t||i.topContainer,n=n||i.bottomContainer;return{topContainer:t,bottomContainer:n}}});function jr(e){return e?[Vr.of(e)]:[]}function Kr(e,t){let n=e.plugin(_r),i=n?n.specs.indexOf(t):-1;return i>-1?n.panels[i]:null}const _r=qe.fromClass(class{constructor(e){this.input=e.state.facet(Yr),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(Vr);this.top=new Ur(e,!0,t.topContainer),this.bottom=new Ur(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top));for(let e of this.panels)e.dom.classList.add("cm-panel"),e.mount&&e.mount()}update(e){let t=e.state.facet(Vr);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new Ur(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new Ur(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(Yr);if(n!=this.input){let t=n.filter(e=>e),i=[],r=[],o=[],s=[];for(let n of t){let t,a=this.specs.indexOf(n);a<0?(t=n(e.view),s.push(t)):(t=this.panels[a],t.update&&t.update(e)),i.push(t),(t.top?r:o).push(t)}this.specs=t,this.panels=i,this.top.sync(r),this.bottom.sync(o);for(let e of s)e.dom.classList.add("cm-panel"),e.mount&&e.mount()}else for(let t of this.panels)t.update&&t.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>pi.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class Ur{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,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";let e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=$r(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=$r(e)}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 e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function $r(e){let t=e.nextSibling;return e.remove(),t}const Yr=i.sj.define({enables:_r});function Gr(e,t){let n,r=new Promise(e=>n=e),o=e=>function(e,t,n){let i=t.content?t.content(e,()=>a(null)):null;if(!i){if(i=(0,s.A)("form"),t.input){let e=(0,s.A)("input",t.input);/^(text|password|number|email|tel|url)$/.test(e.type)&&e.classList.add("cm-textfield"),e.name||(e.name="input"),i.appendChild((0,s.A)("label",(t.label||"")+": ",e))}else i.appendChild(document.createTextNode(t.label||""));i.appendChild(document.createTextNode(" ")),i.appendChild((0,s.A)("button",{class:"cm-button",type:"submit"},t.submitLabel||"OK"))}let r="FORM"==i.nodeName?[i]:i.querySelectorAll("form");for(let e=0;e{27==e.keyCode?(e.preventDefault(),a(null)):13==e.keyCode&&(e.preventDefault(),a(t))}),t.addEventListener("submit",e=>{e.preventDefault(),a(t)})}let o=(0,s.A)("div",i,(0,s.A)("button",{onclick:()=>a(null),"aria-label":e.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));function a(t){o.contains(o.ownerDocument.activeElement)&&e.focus(),n(t)}return t.class&&(o.className=t.class),o.classList.add("cm-dialog"),{dom:o,top:t.top,mount:()=>{if(t.focus){let e;e="string"==typeof t.focus?i.querySelector(t.focus):i.querySelector("input")||i.querySelector("button"),e&&"select"in e?e.select():e&&"focus"in e&&e.focus()}}}}(e,t,n);e.state.field(Jr,!1)?e.dispatch({effects:Zr.of(o)}):e.dispatch({effects:i.Pe.appendConfig.of(Jr.init(()=>[o]))});let a=Qr.of(o);return{close:a,result:r.then(t=>((e.win.queueMicrotask||(t=>e.win.setTimeout(t,10)))(()=>{e.state.field(Jr).indexOf(o)>-1&&e.dispatch({effects:a})}),t))}}function Xr(e,t){let n=e.state.field(Jr,!1)||[];for(let i of n){let n=Kr(e,i);if(n&&n.dom.classList.contains(t))return n}return null}const Jr=i.sU.define({create:()=>[],update(e,t){for(let n of t.effects)n.is(Zr)?e=[n.value].concat(e):n.is(Qr)&&(e=e.filter(e=>e!=n.value));return e},provide:e=>Yr.computeN([e],t=>t.field(e))}),Zr=i.Pe.define(),Qr=i.Pe.define();class eo extends i.FB{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}eo.prototype.elementClass="",eo.prototype.toDOM=void 0,eo.prototype.mapMode=i.iR.TrackBefore,eo.prototype.startSide=eo.prototype.endSide=-1,eo.prototype.point=!0;const to=i.sj.define(),no=i.sj.define(),io={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>i.om.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},ro=i.sj.define();function oo(e){return[ao(),ro.of({...io,...e})]}const so=i.sj.define({combine:e=>e.some(e=>e)});function ao(e){let t=[lo];return e&&!1===e.fixed&&t.push(so.of(!0)),t}const lo=qe.fromClass(class{constructor(e){this.view=e,this.domAfter=null,this.prevViewport=e.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=e.state.facet(ro).map(t=>new fo(e,t)),this.fixed=!e.state.facet(so);for(let e of this.gutters)"after"==e.config.side?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(e){if(this.updateGutters(e)){let t=this.prevViewport,n=e.view.viewport,i=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(i<.8*(n.to-n.from))}if(e.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(so)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=i.om.iter(this.view.state.facet(to),this.view.viewport.from),r=[],o=this.gutters.map(e=>new uo(e,this.view.viewport,-this.view.documentPadding.top));for(let e of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(e.type)){let t=!0;for(let i of e.type)if(i.type==A.Text&&t){ho(n,r,i.from);for(let e of o)e.line(this.view,i,r);t=!1}else if(i.widget)for(let e of o)e.widget(this.view,i)}else if(e.type==A.Text){ho(n,r,e.from);for(let t of o)t.line(this.view,e,r)}else if(e.widget)for(let t of o)t.widget(this.view,e);for(let e of o)e.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(ro),n=e.state.facet(ro),r=e.docChanged||e.heightChanged||e.viewportChanged||!i.om.eq(e.startState.facet(to),e.state.facet(to),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let t of this.gutters)t.update(e)&&(r=!0);else{r=!0;let i=[];for(let r of n){let n=t.indexOf(r);n<0?i.push(new fo(this.view,r)):(this.gutters[n].update(e),i.push(this.gutters[n]))}for(let e of this.gutters)e.dom.remove(),i.indexOf(e)<0&&e.destroy();for(let e of i)"after"==e.config.side?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.gutters=i}return r}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:e=>pi.scrollMargins.of(t=>{let n=t.plugin(e);if(!n||0==n.gutters.length||!n.fixed)return null;let i=n.dom.offsetWidth*t.scaleX,r=n.domAfter?n.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==ne.LTR?{left:i,right:r}:{right:i,left:r}})});function co(e){return Array.isArray(e)?e:[e]}function ho(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class uo{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=i.om.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:i}=this,r=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==i.elements.length){let t=new po(e,o,r,n);i.elements.push(t),i.dom.appendChild(t.dom)}else i.elements[this.i].update(e,o,r,n);this.height=t.bottom,this.i++}line(e,t,n){let i=[];ho(this.cursor,i,t.from),n.length&&(i=i.concat(n));let r=this.gutter.config.lineMarker(e,t,i);r&&i.unshift(r);let o=this.gutter;(0!=i.length||o.config.renderEmptyElements)&&this.addElement(e,t,i)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),i=n?[n]:null;for(let n of e.state.facet(no)){let r=n(e,t.widget,t);r&&(i||(i=[])).push(r)}i&&this.addElement(e,t,i)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class fo{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let n in t.domEventHandlers)this.dom.addEventListener(n,i=>{let r,o=i.target;if(o!=this.dom&&this.dom.contains(o)){for(;o.parentNode!=this.dom;)o=o.parentNode;let e=o.getBoundingClientRect();r=(e.top+e.bottom)/2}else r=i.clientY;let s=e.lineBlockAtHeight(r-e.documentTop);t.domEventHandlers[n](e,s,i)&&i.preventDefault()});this.markers=co(t.markers(e)),t.initialSpacer&&(this.spacer=new po(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=co(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let t=this.config.updateSpacer(this.spacer.markers[0],e);t!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[t])}let n=e.view.viewport;return!i.om.eq(this.markers,t,n.from,n.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(e)}destroy(){for(let e of this.elements)e.destroy()}}class po{constructor(e,t,n,i){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,n,i)}update(e,t,n,i){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),function(e,t){if(e.length!=t.length)return!1;for(let n=0;n(0,i.QR)(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let n=Object.assign({},e);for(let e in t){let i=n[e],r=t[e];n[e]=i?(e,t,n)=>i(e,t,n)||r(e,t,n):r}return n}})});class yo extends eo{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function vo(e,t){return e.state.facet(bo).formatNumber(t,e.state)}const wo=ro.compute([bo],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:e=>e.state.facet(mo),lineMarker:(e,t,n)=>n.some(e=>e.toDOM)?null:new yo(vo(e,e.state.doc.lineAt(t.from).number)),widgetMarker:(e,t,n)=>{for(let i of e.state.facet(go)){let r=i(e,t,n);if(r)return r}return null},lineMarkerChange:e=>e.startState.facet(bo)!=e.state.facet(bo),initialSpacer:e=>new yo(vo(e,xo(e.state.doc.lines))),updateSpacer(e,t){let n=vo(t.view,xo(t.view.state.doc.lines));return n==e.number?e:new yo(n)},domEventHandlers:e.facet(bo).domEventHandlers,side:"before"}));function ko(e={}){return[bo.of(e),ao(),wo]}function xo(e){let t=9;for(;t{let t=[],n=-1;for(let i of e.selection.ranges){let r=e.doc.lineAt(i.head).from;r>n&&(n=r,t.push(So.range(r)))}return i.om.of(t)});function Ao(){return Co}function Mo(e){return qe.define(t=>({decorations:e.createDeco(t),update(t){this.decorations=e.updateDeco(t,this.decorations)}}),{decorations:e=>e.decorations})}const To=M.mark({class:"cm-highlightTab"}),Oo=M.mark({class:"cm-highlightSpace"}),Do=Mo(new Gi({regexp:/\t| /g,decoration:e=>"\t"==e[0]?To:Oo,boundary:/\S/}));function Lo(){return Do}const zo=Mo(new Gi({regexp:/\s+$/g,decoration:M.mark({class:"cm-trailingSpace"})}));function Eo(){return zo}const Bo={HeightMap:zn,HeightOracle:Mn,MeasuredHeights:Tn,QueryType:Dn,ChangedRange:et,computeOrder:be,moveVisually:we,clearHeightChangeFlag:An,getHeightChangeFlag:()=>Cn};n.d(t,["DK",0,Or,"EV",0,to,"QO",0,no,"S7",0,Yr,"pK",0,mo,"qy",0,go,"rU",0,Bo,"vo",0,Wr,"w4",0,xi])},2931(e,t,n){n.r(t),n.d(t,{Annotation:()=>s.YH,AnnotationType:()=>s.UJ,BidiSpan:()=>a.tF,BlockInfo:()=>a.uF,BlockType:()=>a._B,BlockWrapper:()=>a.l_,ChangeDesc:()=>s.Gu,ChangeSet:()=>s.VR,CharCategory:()=>s.Je,Compartment:()=>s.xx,Decoration:()=>a.NZ,Direction:()=>a.OP,EditorSelection:()=>s.OF,EditorState:()=>s.$t,EditorView:()=>a.Lz,ExternalChange:()=>q,Facet:()=>s.sj,GutterMarker:()=>a.wJ,Line:()=>s.N1,MapMode:()=>s.iR,MatchDecorator:()=>a.dT,Prec:()=>s.Nb,Range:()=>s.Q6,RangeSet:()=>s.om,RangeSetBuilder:()=>s.vB,RangeValue:()=>s.FB,RectangleMarker:()=>a.Ip,SelectionRange:()=>s.yn,StateEffect:()=>s.Pe,StateEffectType:()=>s.DA,StateField:()=>s.sU,Text:()=>s.EY,Transaction:()=>s.ZX,ViewPlugin:()=>a.Z9,ViewUpdate:()=>a.X3,WidgetType:()=>a.xO,__test:()=>a.rU,activateHover:()=>a.ab,basicSetup:()=>c.o,closeHoverTooltip:()=>a.ut,closeHoverTooltips:()=>a.vo,codePointAt:()=>s.vS,codePointSize:()=>s.Fh,color:()=>O,combineConfig:()=>s.QR,countColumn:()=>s.y$,crosshairCursor:()=>a.HJ,default:()=>$,defaultLightThemeOption:()=>E,drawSelection:()=>a.VH,dropCursor:()=>a.A,findClusterBreak:()=>s.zK,findColumn:()=>s.kn,fromCodePoint:()=>s.MK,getDefaultExtensions:()=>B,getDialog:()=>a.rC,getDrawSelectionConfig:()=>a.$G,getPanel:()=>a.ld,getStatistics:()=>R,getTooltip:()=>a.Eg,gutter:()=>a.cU,gutterLineClass:()=>a.EV,gutterWidgetClass:()=>a.QO,gutters:()=>a.Hm,hasHoverTooltips:()=>a.n6,highlightActiveLine:()=>a.dz,highlightActiveLineGutter:()=>a.Wu,highlightSpecialChars:()=>a.N$,highlightTrailingWhitespace:()=>a.wu,highlightWhitespace:()=>a.Yq,hoverTooltip:()=>a.Ux,keymap:()=>a.w4,layer:()=>a.qd,lineNumberMarkers:()=>a.pK,lineNumberWidgetMarker:()=>a.qy,lineNumbers:()=>a.$K,logException:()=>a.c_,minimalSetup:()=>c.V,oneDark:()=>z,oneDarkHighlightStyle:()=>L,oneDarkTheme:()=>D,panels:()=>a.C3,placeholder:()=>a.qf,rectangularSelection:()=>a.D4,repositionTooltips:()=>a.Pq,runScopeHandlers:()=>a.TS,scrollPastEnd:()=>a.BE,showDialog:()=>a.ui,showPanel:()=>a.S7,showTooltip:()=>a.DK,tooltips:()=>a.vX,useCodeMirror:()=>j});var i=n(5062),r=n(6905),o=n(1609),s=n(2701),a=n(9747),l=n(4658),c=n(6102),h=n(6684),u=n(1318);const d="#e5c07b",f="#e06c75",p="#56b6c2",m="#ffffff",g="#abb2bf",b="#7d8799",y="#61afef",v="#98c379",w="#d19a66",k="#c678dd",x="#21252b",S="#2c313a",C="#282c34",A="#353a42",M="#3E4451",T="#528bff",O={chalky:d,coral:f,cyan:p,invalid:m,ivory:g,stone:b,malibu:y,sage:v,whiskey:w,violet:k,darkBackground:x,highlightBackground:S,background:C,tooltipBackground:A,selection:M,cursor:T},D=a.Lz.theme({"&":{color:g,backgroundColor:C},".cm-content":{caretColor:T},".cm-cursor, .cm-dropCursor":{borderLeftColor:T},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:M},".cm-panels":{backgroundColor:x,color:g},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:C,color:b,border:"none"},".cm-activeLineGutter":{backgroundColor:S},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:A},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:A,borderBottomColor:A},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:S,color:g}}},{dark:!0}),L=h.cr.define([{tag:u._A.keyword,color:k},{tag:[u._A.name,u._A.deleted,u._A.character,u._A.propertyName,u._A.macroName],color:f},{tag:[u._A.function(u._A.variableName),u._A.labelName],color:y},{tag:[u._A.color,u._A.constant(u._A.name),u._A.standard(u._A.name)],color:w},{tag:[u._A.definition(u._A.name),u._A.separator],color:g},{tag:[u._A.typeName,u._A.className,u._A.number,u._A.changed,u._A.annotation,u._A.modifier,u._A.self,u._A.namespace],color:d},{tag:[u._A.operator,u._A.operatorKeyword,u._A.url,u._A.escape,u._A.regexp,u._A.link,u._A.special(u._A.string)],color:p},{tag:[u._A.meta,u._A.comment],color:b},{tag:u._A.strong,fontWeight:"bold"},{tag:u._A.emphasis,fontStyle:"italic"},{tag:u._A.strikethrough,textDecoration:"line-through"},{tag:u._A.link,color:b,textDecoration:"underline"},{tag:u._A.heading,fontWeight:"bold",color:f},{tag:[u._A.atom,u._A.bool,u._A.special(u._A.variableName)],color:w},{tag:[u._A.processingInstruction,u._A.string,u._A.inserted],color:v},{tag:u._A.invalid,color:m}]),z=[D,(0,h.y9)(L)];var E=a.Lz.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),B=function(e){void 0===e&&(e={});var t=e,n=t.indentWithTab,i=void 0===n||n,r=t.editable,o=void 0===r||r,h=t.readOnly,u=void 0!==h&&h,d=t.theme,f=void 0===d?"light":d,p=t.placeholder,m=void 0===p?"":p,g=t.basicSetup,b=void 0===g||g,y=[];switch(i&&y.unshift(a.w4.of([l.Yc])),b&&("boolean"==typeof b?y.unshift((0,c.o)()):y.unshift((0,c.o)(b))),m&&y.unshift((0,a.qf)(m)),f){case"light":y.push(E);break;case"dark":y.push(z);break;case"none":break;default:y.push(f)}return!1===o&&y.push(a.Lz.editable.of(!1)),u&&y.push(s.$t.readOnly.of(!0)),[...y]},R=e=>({line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map(t=>e.state.sliceDoc(t.from,t.to)),selectedText:e.state.selection.ranges.some(e=>!e.empty)});class P{constructor(e,t){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=t,this.timeoutMS=t,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(e=>{try{e()}catch(e){console.error("TimeoutLatch callback error:",e)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}}class I{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),0===this.latches.size&&this.stop()}start(){null===this.interval&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){null!==this.interval&&(clearInterval(this.interval),this.interval=null)}}var N=null,F=a.Lz.theme({"& .cm-scroller":{height:"100% !important"}}),W=null,H=null,q=s.YH.define(),V=[];function j(e){var t=e.value,n=e.selection,i=e.onChange,r=e.onStatistics,l=e.onCreateEditor,c=e.onUpdate,h=e.extensions,u=void 0===h?V:h,d=e.autoFocus,f=e.theme,p=void 0===f?"light":f,m=e.height,g=void 0===m?null:m,b=e.minHeight,y=void 0===b?null:b,v=e.maxHeight,w=void 0===v?null:v,k=e.width,x=void 0===k?null:k,S=e.minWidth,C=void 0===S?null:S,A=e.maxWidth,M=void 0===A?null:A,T=e.placeholder,O=void 0===T?"":T,D=e.editable,L=void 0===D||D,z=e.readOnly,E=void 0!==z&&z,j=e.indentWithTab,K=void 0===j||j,_=e.basicSetup,U=void 0===_||_,$=e.root,Y=e.initialState,G=(0,o.useState)(),X=G[0],J=G[1],Z=(0,o.useState)(),Q=Z[0],ee=Z[1],te=(0,o.useState)(),ne=te[0],ie=te[1],re=(0,o.useState)(()=>({current:null}))[0],oe=(0,o.useState)(()=>({current:null}))[0],se=function(e,t,n,i,r,o){if(!(e||t||n||i||r||o))return null;var s=JSON.stringify({height:e,minHeight:t,maxHeight:n,width:i,minWidth:r,maxWidth:o});return s===W?H:(W=s,H=a.Lz.theme({"&":{height:e,minHeight:t,maxHeight:n,width:i,minWidth:r,maxWidth:o}}))}(g,y,w,x,C,M),ae=a.Lz.updateListener.of(e=>{if(e.docChanged&&"function"==typeof i&&!e.transactions.some(e=>e.annotation(q))){re.current?re.current.reset():(re.current=new P(()=>{if(oe.current){var e=oe.current;oe.current=null,e()}re.current=null},200),("undefined"==typeof window?new I:(N||(N=new I),N)).add(re.current));var t=e.state.doc.toString();i(t,e)}r&&r(R(e))}),le=B({theme:p,editable:L,readOnly:E,placeholder:O,indentWithTab:K,basicSetup:U}),ce=[ae,...se?[se]:[],F,...le];return c&&"function"==typeof c&&ce.push(a.Lz.updateListener.of(c)),ce=ce.concat(u),(0,o.useLayoutEffect)(()=>{if(X&&!ne){var e={doc:t,selection:n,extensions:ce},i=Y?s.$t.fromJSON(Y.json,e,Y.fields):s.$t.create(e);if(ie(i),!Q){var r=new a.Lz({state:i,parent:X,root:$});ee(r),l&&l(r,i)}}return()=>{Q&&(ie(void 0),ee(void 0))}},[X,ne]),(0,o.useEffect)(()=>{e.container&&J(e.container)},[e.container]),(0,o.useEffect)(()=>()=>{Q&&(Q.destroy(),ee(void 0)),re.current&&(re.current.cancel(),re.current=null)},[Q]),(0,o.useEffect)(()=>{d&&Q&&Q.focus()},[d,Q]),(0,o.useEffect)(()=>{Q&&Q.dispatch({effects:s.Pe.reconfigure.of(ce)})},[p,u,g,y,w,x,C,M,O,L,E,K,U,i,c]),(0,o.useEffect)(()=>{if(void 0!==t){var e=Q?Q.state.doc.toString():"";if(Q&&t!==e){var n=()=>{Q&&t!==Q.state.doc.toString()&&Q.dispatch({changes:{from:0,to:Q.state.doc.toString().length,insert:t||""},annotations:[q.of(!0)]})};re.current&&!re.current.isDone?oe.current=n:n()}}},[t,Q]),{state:ne,setState:ie,view:Q,setView:ee,container:X,setContainer:J}}var K=n(790),_=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],U=(0,o.forwardRef)((e,t)=>{var n=e.className,s=e.value,a=void 0===s?"":s,l=e.selection,c=e.extensions,h=void 0===c?[]:c,u=e.onChange,d=e.onStatistics,f=e.onCreateEditor,p=e.onUpdate,m=e.autoFocus,g=e.theme,b=void 0===g?"light":g,y=e.height,v=e.minHeight,w=e.maxHeight,k=e.width,x=e.minWidth,S=e.maxWidth,C=e.basicSetup,A=e.placeholder,M=e.indentWithTab,T=e.editable,O=e.readOnly,D=e.root,L=e.initialState,z=(0,r.A)(e,_),E=(0,o.useRef)(null),B=j({root:D,value:a,autoFocus:m,theme:b,height:y,minHeight:v,maxHeight:w,width:k,minWidth:x,maxWidth:S,basicSetup:C,placeholder:A,indentWithTab:M,editable:T,readOnly:O,selection:l,onChange:u,onStatistics:d,onCreateEditor:f,onUpdate:p,extensions:h,initialState:L}),R=B.state,P=B.view,I=B.container,N=B.setContainer;(0,o.useImperativeHandle)(t,()=>({editor:E.current,state:R,view:P}),[E,I,R,P]);var F=(0,o.useCallback)(e=>{E.current=e,N(e)},[N]);if("string"!=typeof a)throw new Error("value must be typeof string but got "+typeof a);var W="string"==typeof b?"cm-theme-"+b:"cm-theme";return(0,K.jsx)("div",(0,i.A)({ref:F,className:W+(n?" "+n:"")},z))});U.displayName="CodeMirror";const $=U},8843(e,t,n){n.r(t),n.d(t,{Lexer:()=>Gi,List:()=>lt,OffsetToLocation:()=>pt,TokenStream:()=>kt,clone:()=>rc,createLexer:()=>uc,createSyntax:()=>tr,definitionSyntax:()=>ae,find:()=>fc,findAll:()=>mc,findLast:()=>pc,fork:()=>yc,fromPlainObject:()=>bc,generate:()=>cc,ident:()=>le,isCustomProperty:()=>rn,keyword:()=>en,lexer:()=>hc,parse:()=>lc,property:()=>tn,string:()=>Y,toPlainObject:()=>gc,tokenNames:()=>mt,tokenTypes:()=>i,tokenize:()=>ac,url:()=>ee,vendorPrefix:()=>nn,version:()=>"3.2.1",walk:()=>dc});var i={};n.r(i),n.d(i,{AtKeyword:()=>de,BadString:()=>me,BadUrl:()=>be,CDC:()=>Ce,CDO:()=>Se,Colon:()=>Ae,Comma:()=>Te,Comment:()=>Re,Delim:()=>ye,Dimension:()=>ke,EOF:()=>ce,Function:()=>ue,Hash:()=>fe,Ident:()=>he,LeftCurlyBracket:()=>Ee,LeftParenthesis:()=>Le,LeftSquareBracket:()=>Oe,Number:()=>ve,Percentage:()=>we,RightCurlyBracket:()=>Be,RightParenthesis:()=>ze,RightSquareBracket:()=>De,Semicolon:()=>Me,String:()=>pe,Url:()=>ge,WhiteSpace:()=>xe});var r={};n.r(r),n.d(r,{safe:()=>Pt,spec:()=>Rt});var o={};n.r(o),n.d(o,{angle:()=>qn,decibel:()=>$n,flex:()=>Un,frequency:()=>jn,length:()=>Hn,resolution:()=>Kn,semitones:()=>Yn,time:()=>Vn});var s={};n.r(s),n.d(s,{getTrace:()=>zi,isKeyword:()=>Ri,isProperty:()=>Bi,isType:()=>Ei});var a={};n.r(a),n.d(a,{generate:()=>fr,name:()=>hr,parse:()=>dr,structure:()=>ur});var l={};n.r(l),n.d(l,{generate:()=>wr,name:()=>gr,parse:()=>vr,structure:()=>yr,walkContext:()=>br});var c={};n.r(c),n.d(c,{generate:()=>Ar,name:()=>kr,parse:()=>Cr,structure:()=>Sr,walkContext:()=>xr});var h={};n.r(h),n.d(h,{generate:()=>zr,name:()=>Or,parse:()=>Lr,structure:()=>Dr});var u={};n.r(u),n.d(u,{generate:()=>Hr,name:()=>Ir,parse:()=>Wr,structure:()=>Fr,walkContext:()=>Nr});var d={};n.r(d),n.d(d,{generate:()=>Kr,name:()=>qr,parse:()=>jr,structure:()=>Vr});var f={};n.r(f),n.d(f,{generate:()=>Yr,name:()=>_r,parse:()=>$r,structure:()=>Ur});var p={};n.r(p),n.d(p,{generate:()=>Zr,name:()=>Gr,parse:()=>Jr,structure:()=>Xr});var m={};n.r(m),n.d(m,{generate:()=>no,name:()=>Qr,parse:()=>to,structure:()=>eo});var g={};n.r(g),n.d(g,{generate:()=>so,name:()=>io,parse:()=>oo,structure:()=>ro});var b={};n.r(b),n.d(b,{generate:()=>ho,name:()=>ao,parse:()=>co,structure:()=>lo});var y={};n.r(y),n.d(y,{generate:()=>yo,name:()=>fo,parse:()=>bo,structure:()=>po});var v={};n.r(v),n.d(v,{generate:()=>Mo,name:()=>xo,parse:()=>Ao,structure:()=>Co,walkContext:()=>So});var w={};n.r(w),n.d(w,{generate:()=>Bo,name:()=>Lo,parse:()=>Eo,structure:()=>zo});var k={};n.r(k),n.d(k,{generate:()=>No,name:()=>Ro,parse:()=>Io,structure:()=>Po});var x={};n.r(x),n.d(x,{generate:()=>qo,name:()=>Fo,parse:()=>Ho,structure:()=>Wo});var S={};n.r(S),n.d(S,{generate:()=>Uo,name:()=>Vo,parse:()=>_o,structure:()=>jo});var C={};n.r(C),n.d(C,{generate:()=>Zo,name:()=>$o,parse:()=>Jo,structure:()=>Yo});var A={};n.r(A),n.d(A,{generate:()=>is,name:()=>Qo,parse:()=>ns,structure:()=>ts,walkContext:()=>es});var M={};n.r(M),n.d(M,{generate:()=>as,name:()=>rs,parse:()=>ss,structure:()=>os});var T={};n.r(T),n.d(T,{generate:()=>ds,name:()=>cs,parse:()=>us,structure:()=>hs,xxx:()=>ls});var O={};n.r(O),n.d(O,{generate:()=>gs,name:()=>fs,parse:()=>ms,structure:()=>ps});var D={};n.r(D),n.d(D,{generate:()=>ws,name:()=>bs,parse:()=>vs,structure:()=>ys});var L={};n.r(L),n.d(L,{generate:()=>Cs,name:()=>ks,parse:()=>Ss,structure:()=>xs});var z={};n.r(z),n.d(z,{generate:()=>Os,name:()=>As,parse:()=>Ts,structure:()=>Ms});var E={};n.r(E),n.d(E,{generate:()=>Es,name:()=>Ds,parse:()=>zs,structure:()=>Ls});var B={};n.r(B),n.d(B,{generate:()=>Is,name:()=>Bs,parse:()=>Ps,structure:()=>Rs});var R={};n.r(R),n.d(R,{generate:()=>Hs,name:()=>Ns,parse:()=>Ws,structure:()=>Fs});var P={};n.r(P),n.d(P,{generate:()=>Ks,name:()=>qs,parse:()=>js,structure:()=>Vs});var I={};n.r(I),n.d(I,{generate:()=>Ys,name:()=>_s,parse:()=>$s,structure:()=>Us});var N={};n.r(N),n.d(N,{generate:()=>Zs,name:()=>Gs,parse:()=>Js,structure:()=>Xs});var F={};n.r(F),n.d(F,{generate:()=>na,name:()=>Qs,parse:()=>ta,structure:()=>ea});var W={};n.r(W),n.d(W,{generate:()=>sa,name:()=>ia,parse:()=>oa,structure:()=>ra});var H={};n.r(H),n.d(H,{generate:()=>ua,name:()=>aa,parse:()=>ha,structure:()=>ca,walkContext:()=>la});var q={};n.r(q),n.d(q,{generate:()=>ga,name:()=>da,parse:()=>ma,structure:()=>pa,walkContext:()=>fa});var V={};n.r(V),n.d(V,{generate:()=>ka,name:()=>ya,parse:()=>wa,structure:()=>va});var j={};n.r(j),n.d(j,{generate:()=>Ma,name:()=>Sa,parse:()=>Aa,structure:()=>Ca});var K={};n.r(K),n.d(K,{generate:()=>Ba,name:()=>Da,parse:()=>Ea,structure:()=>za,walkContext:()=>La});var _={};n.r(_),n.d(_,{generate:()=>Na,name:()=>Ra,parse:()=>Ia,structure:()=>Pa});var U={};n.r(U),n.d(U,{generate:()=>qa,name:()=>Fa,parse:()=>Ha,structure:()=>Wa});var $={};n.r($),n.d($,{generate:()=>Ua,name:()=>Va,parse:()=>_a,structure:()=>Ka,walkContext:()=>ja});var Y={};n.r(Y),n.d(Y,{decode:()=>$a,encode:()=>Ya});var G={};n.r(G),n.d(G,{generate:()=>Za,name:()=>Ga,parse:()=>Ja,structure:()=>Xa});var X={};n.r(X),n.d(X,{generate:()=>rl,name:()=>el,parse:()=>il,structure:()=>nl,walkContext:()=>tl});var J={};n.r(J),n.d(J,{generate:()=>ll,name:()=>ol,parse:()=>al,structure:()=>sl});var Z={};n.r(Z),n.d(Z,{generate:()=>fl,name:()=>hl,parse:()=>dl,structure:()=>ul});var Q={};n.r(Q),n.d(Q,{generate:()=>kl,name:()=>yl,parse:()=>wl,structure:()=>vl});var ee={};n.r(ee),n.d(ee,{decode:()=>xl,encode:()=>Sl});var te={};n.r(te),n.d(te,{generate:()=>Tl,name:()=>Cl,parse:()=>Ml,structure:()=>Al});var ne={};n.r(ne),n.d(ne,{generate:()=>zl,name:()=>Ol,parse:()=>Ll,structure:()=>Dl});var ie={};n.r(ie),n.d(ie,{generate:()=>Il,name:()=>Bl,parse:()=>Pl,structure:()=>Rl});var re={};n.r(re),n.d(re,{AnPlusB:()=>a,Atrule:()=>l,AtrulePrelude:()=>c,AttributeSelector:()=>h,Block:()=>u,Brackets:()=>d,CDC:()=>f,CDO:()=>p,ClassSelector:()=>m,Combinator:()=>g,Comment:()=>b,Condition:()=>y,Declaration:()=>v,DeclarationList:()=>w,Dimension:()=>k,Feature:()=>x,FeatureFunction:()=>S,FeatureRange:()=>C,Function:()=>A,GeneralEnclosed:()=>M,Hash:()=>T,IdSelector:()=>D,Identifier:()=>O,Layer:()=>L,LayerList:()=>z,MediaQuery:()=>E,MediaQueryList:()=>B,NestingSelector:()=>R,Nth:()=>P,Number:()=>I,Operator:()=>N,Parentheses:()=>F,Percentage:()=>W,PseudoClassSelector:()=>H,PseudoElementSelector:()=>q,Ratio:()=>V,Raw:()=>j,Rule:()=>K,Scope:()=>_,Selector:()=>U,SelectorList:()=>$,String:()=>G,StyleSheet:()=>X,SupportsDeclaration:()=>J,TypeSelector:()=>Z,UnicodeRange:()=>Q,Url:()=>te,Value:()=>ne,WhiteSpace:()=>ie});var oe={};n.r(oe),n.d(oe,{AtrulePrelude:()=>Wl,Selector:()=>Hl,Value:()=>Kl});var se={};n.r(se),n.d(se,{AnPlusB:()=>dr,Atrule:()=>vr,AtrulePrelude:()=>Cr,AttributeSelector:()=>Lr,Block:()=>Wr,Brackets:()=>jr,CDC:()=>$r,CDO:()=>Jr,ClassSelector:()=>to,Combinator:()=>oo,Comment:()=>co,Condition:()=>bo,Declaration:()=>Ao,DeclarationList:()=>Eo,Dimension:()=>Io,Feature:()=>Ho,FeatureFunction:()=>_o,FeatureRange:()=>Jo,Function:()=>ns,GeneralEnclosed:()=>ss,Hash:()=>us,IdSelector:()=>vs,Identifier:()=>ms,Layer:()=>Ss,LayerList:()=>Ts,MediaQuery:()=>zs,MediaQueryList:()=>Ps,NestingSelector:()=>Ws,Nth:()=>js,Number:()=>$s,Operator:()=>Js,Parentheses:()=>ta,Percentage:()=>oa,PseudoClassSelector:()=>ha,PseudoElementSelector:()=>ma,Ratio:()=>wa,Raw:()=>Aa,Rule:()=>Ea,Scope:()=>Ia,Selector:()=>Ha,SelectorList:()=>_a,String:()=>Ja,StyleSheet:()=>il,SupportsDeclaration:()=>al,TypeSelector:()=>dl,UnicodeRange:()=>wl,Url:()=>Ml,Value:()=>Ll,WhiteSpace:()=>Pl});var ae={};n.r(ae),n.d(ae,{SyntaxError:()=>Gn,generate:()=>Ut,parse:()=>ai,walk:()=>hi});var le={};n.r(le),n.d(le,{decode:()=>oc,encode:()=>sc});const ce=0,he=1,ue=2,de=3,fe=4,pe=5,me=6,ge=7,be=8,ye=9,ve=10,we=11,ke=12,xe=13,Se=14,Ce=15,Ae=16,Me=17,Te=18,Oe=19,De=20,Le=21,ze=22,Ee=23,Be=24,Re=25;function Pe(e){return e>=48&&e<=57}function Ie(e){return Pe(e)||e>=65&&e<=70||e>=97&&e<=102}function Ne(e){return e>=65&&e<=90}function Fe(e){return function(e){return Ne(e)||function(e){return e>=97&&e<=122}(e)}(e)||function(e){return e>=128}(e)||95===e}function We(e){return Fe(e)||Pe(e)||45===e}function He(e){return e>=0&&e<=8||11===e||e>=14&&e<=31||127===e}function qe(e){return 10===e||13===e||12===e}function Ve(e){return qe(e)||32===e||9===e}function je(e,t){return 92===e&&!qe(t)&&0!==t}function Ke(e,t,n){return 45===e?Fe(t)||45===t||je(t,n):!!Fe(e)||92===e&&je(e,t)}function _e(e,t,n){return 43===e||45===e?Pe(t)?2:46===t&&Pe(n)?3:0:46===e?Pe(t)?2:0:Pe(e)?1:0}function Ue(e){return 65279===e||65534===e?1:0}const $e=new Array(128);for(let e=0;e<$e.length;e++)$e[e]=(Ve(e)?130:Pe(e)&&131)||Fe(e)&&132||He(e)&&133||e||128;function Ye(e){return e<128?$e[e]:132}function Ge(e,t){return te.length)return!1;for(let r=t;r=55296&&t<=57343||t>1114111)&&(t=65533),String.fromCodePoint(t)}function st(e,t){function n(t){return t=e.length?void(cString(e+n+1).padStart(h)+" |"+t).join("\n")}const a=("\n".repeat(Math.max(i-1,0))+" ".repeat(Math.max(r-1,0))+e).split(/\r\n?|\n|\f/),l=Math.max(1,t-o)-1,c=Math.min(t+o,a.length+1),h=Math.max(4,String(c).length)+1;let u=0;(n+=3*(a[t-1].substr(0,n-1).match(/\t/g)||[]).length)>100&&(u=n-60+3,n=58);for(let e=l;e<=c;e++)e>=0&&e0&&a[e].length>u?"…":"")+a[e].substr(u,98)+(a[e].length>u+100-1?"…":""));return[s(l,t),new Array(n+h+2).join("-")+"^",s(t,c)].filter(Boolean).join("\n").replace(/^(\s+\d+\s+\|\n)+/,"").replace(/\n(\s+\d+\s+\|)+$/,"")}function ut(e,t,n,i,r,o=1,s=1){return Object.assign(ct("SyntaxError",e),{source:t,offset:n,line:i,column:r,sourceFragment:e=>ht({source:t,line:i,column:r,baseLine:o,baseColumn:s},isNaN(e)?0:e),get formattedMessage(){return`Parse error: ${e}\n`+ht({source:t,line:i,column:r,baseLine:o,baseColumn:s},2)}})}function dt(e=null,t){return null===e||e.length0?Ue(t.charCodeAt(0)):0,r=dt(e.lines,n),o=dt(e.columns,n);let s=e.startLine,a=e.startColumn;for(let e=i;en?n:e}vt[ue]=1,vt[Le]=1,vt[Oe]=1,vt[Ee]=1,vt[ze]=2,vt[De]=2,vt[Be]=2;class kt{constructor(e,t){this.setSource(e,t)}reset(){this.eof=!1,this.tokenIndex=-1,this.tokenType=0,this.tokenStart=this.firstCharOffset,this.tokenEnd=this.firstCharOffset}setSource(e="",t=()=>{}){const n=(e=String(e||"")).length,i=dt(this.offsetAndType,e.length+1),r=dt(this.balance,e.length+1);let o=0,s=-1,a=0,l=e.length;this.offsetAndType=null,this.balance=null,r.fill(0),t(e,(e,t,n)=>{const c=o++;if(i[c]=e<>bt]}else this.isBlockOpenerTokenType(e)&&(l=c,a=yt[e])}),i[o]=ce<o&&(r[e]=o)}this.source=e,this.firstCharOffset=-1===s?0:s,this.tokenCount=o,this.offsetAndType=i,this.balance=r,this.reset(),this.next()}lookupType(e){return(e+=this.tokenIndex)>bt:ce}lookupTypeNonSC(e){for(let t=this.tokenIndex;t>bt;if(n!==xe&&n!==Re&&0===e--)return n}return ce}lookupOffset(e){return(e+=this.tokenIndex)>bt;if(n!==xe&&n!==Re&&0===e--)return t-this.tokenIndex}return ce}lookupValue(e,t){return(e+=this.tokenIndex)0?e>bt}substrToCursor(e){return this.source.substring(e,this.tokenStart)}isBlockOpenerTokenType(e){return 1===vt[e]}isBlockCloserTokenType(e){return 2===vt[e]}getBlockTokenPairIndex(e){const t=this.getTokenType(e);if(1===vt[t]){const n=this.balance[e],i=this.getTokenType(n);return yt[t]===i?n:-1}if(2===vt[t]){const n=this.balance[e],i=this.getTokenType(n);return yt[i]===t?n:-1}return-1}isBalanceEdge(e){return this.balance[this.tokenIndex]>bt,this.tokenEnd=t>):(this.tokenIndex=this.tokenCount,this.next())}next(){let e=this.tokenIndex+1;e>bt,this.tokenEnd=e>):(this.eof=!0,this.tokenIndex=this.tokenCount,this.tokenType=ce,this.tokenStart=this.tokenEnd=this.source.length)}skipSC(){for(;this.tokenType===xe||this.tokenType===Re;)this.next()}skipUntilBalanced(e,t){let n=e,i=0,r=0;e:for(;n0?this.offsetAndType[n-1]>:this.firstCharOffset,t(this.source.charCodeAt(r))){case 1:break e;case 2:n++;break e;default:this.isBlockOpenerTokenType(this.offsetAndType[n]>>bt)&&(n=i)}this.skip(n-this.tokenIndex)}forEachToken(e){for(let t=0,n=this.firstCharOffset;t>bt,i,o,t)}}dump(){const e=new Array(this.tokenCount);return this.forEachToken((t,n,i,r)=>{e[r]={idx:r,type:mt[t],chunk:this.source.substring(n,i),balance:this.balance[r]}}),e}}function xt(e){const t=this.createList();let n=!1;const i={recognizer:e};for(;!this.eof;){switch(this.tokenType){case Re:this.next();continue;case xe:n=!0,this.next();continue}let r=e.getNode.call(this,i);if(void 0===r)break;n&&(e.onWhiteSpace&&e.onWhiteSpace.call(this,r,t,i),n=!1),t.push(r)}return n&&e.onWhiteSpace&&e.onWhiteSpace.call(this,null,t,i),t}const St=()=>{},Ct={createList:()=>[],createSingleNodeList:e=>[e],getFirstListNode:e=>e&&e[0]||null,getLastListNode:e=>e&&e.length>0?e[e.length-1]:null},At={createList:()=>new lt,createSingleNodeList:e=>(new lt).appendData(e),getFirstListNode:e=>e&&e.first,getLastListNode:e=>e&&e.last};function Mt(e){return function(){return this[e]()}}function Tt(e){const t=Object.create(null);for(const n of Object.keys(e)){const i=e[n],r=i.parse||i;r&&(t[n]=r)}return t}var Ot=n(241);const Dt=new Set(["Atrule","Selector","Declaration"]),Lt=(e,t)=>(e===ye&&(e=t),"string"==typeof e&&(e=Math.min(e.charCodeAt(0),128)<<6),e<<1),zt=[[he,he],[he,ue],[he,ge],[he,be],[he,"-"],[he,ve],[he,we],[he,ke],[he,Ce],[he,Le],[de,he],[de,ue],[de,ge],[de,be],[de,"-"],[de,ve],[de,we],[de,ke],[de,Ce],[fe,he],[fe,ue],[fe,ge],[fe,be],[fe,"-"],[fe,ve],[fe,we],[fe,ke],[fe,Ce],[ke,he],[ke,ue],[ke,ge],[ke,be],[ke,"-"],[ke,ve],[ke,we],[ke,ke],[ke,Ce],["#",he],["#",ue],["#",ge],["#",be],["#","-"],["#",ve],["#",we],["#",ke],["#",Ce],["-",he],["-",ue],["-",ge],["-",be],["-","-"],["-",ve],["-",we],["-",ke],["-",Ce],[ve,he],[ve,ue],[ve,ge],[ve,be],[ve,ve],[ve,we],[ve,ke],[ve,"%"],[ve,Ce],["@",he],["@",ue],["@",ge],["@",be],["@","-"],["@",Ce],[".",ve],[".",we],[".",ke],["+",ve],["+",we],["+",ke],["/","*"]],Et=zt.concat([[he,fe],[ke,fe],[fe,fe],[de,Le],[de,pe],[de,Ae],[we,we],[we,ke],[we,ue],[we,"-"],[ze,he],[ze,ue],[ze,we],[ze,ke],[ze,fe],[ze,"-"]]);function Bt(e){const t=new Set(e.map(([e,t])=>Lt(e)<<16|Lt(t)));return function(e,n,i){const r=Lt(n,i),o=i.charCodeAt(0);return r|(45===o&&n!==he&&n!==ue&&n!==Ce||43===o?t.has((65534&e)<<16|o<<7):t.has((65534&e)<<16|r))}}const Rt=Bt(zt),Pt=Bt(Et);function It(e,t){if("function"==typeof t){let n=null;return void e.children.forEach(e=>{null!==n&&t.call(this,n),this.node(e),n=e})}e.children.forEach(this.node,this)}const{hasOwnProperty:Nt}=Object.prototype,Ft=function(){};function Wt(e){return"function"==typeof e?e:Ft}function Ht(e,t){return function(n,i,r){n.type===t&&e.call(this,n,i,r)}}function qt(e,t){const n=t.structure,i=[];for(const e in n){if(!1===Nt.call(n,e))continue;let t=n[e];const r={name:e,type:!1,nullable:!1};Array.isArray(t)||(t=[t]);for(const e of t)null===e?r.nullable=!0:"string"==typeof e?r.type="node":Array.isArray(e)&&(r.type="list");r.type&&i.push(r)}return i.length?{context:t.walkContext,fields:i}:null}function Vt(e,t){const n=e.fields.slice(),i=e.context,r="string"==typeof i;return t&&n.reverse(),function(e,o,s,a){let l;r&&(l=o[i],o[i]=e);for(const i of n){const n=e[i.name];if(!i.nullable||n)if("list"===i.type){if(t?n.reduceRight(a,!1):n.reduce(a,!1))return!0}else if(s(n))return!0}r&&(o[i]=l)}}function jt({StyleSheet:e,Atrule:t,Rule:n,Block:i,DeclarationList:r}){return{Atrule:{StyleSheet:e,Atrule:t,Rule:n,Block:i},Rule:{StyleSheet:e,Atrule:t,Rule:n,Block:i},Declaration:{StyleSheet:e,Atrule:t,Rule:n,Block:i,DeclarationList:r}}}function Kt(e){return e}function _t(e,t,n,i){let r;switch(e.type){case"Group":r=function(e,t,n,i){const r=" "===e.combinator||i?e.combinator:" "+e.combinator+" ",o=e.terms.map(e=>_t(e,t,n,i)).join(r);return e.explicit||n?(i||","===o[0]?"[":"[ ")+o+(i?"]":" ]"):o}(e,t,n,i)+(e.disallowEmpty?"!":"");break;case"Multiplier":return _t(e.term,t,n,i)+t(function(e){const{min:t,max:n,comma:i}=e;return 0===t&&0===n?i?"#?":"*":0===t&&1===n?"?":1===t&&0===n?i?"#":"+":1===t&&1===n?"":(i?"#":"")+(t===n?"{"+t+"}":"{"+t+","+(0!==n?n:"")+"}")}(e),e);case"Boolean":r="";break;case"Type":r="<"+e.name+(e.opts?t(function(e){if("Range"===e.type)return" ["+(null===e.min?"-∞":e.min)+","+(null===e.max?"∞":e.max)+"]";throw new Error("Unknown node type `"+e.type+"`")}(e.opts),e.opts):"")+">";break;case"Property":r="<'"+e.name+"'>";break;case"Keyword":r=e.name;break;case"AtKeyword":r="@"+e.name;break;case"Function":r=e.name+"(";break;case"String":case"Token":r=e.value;break;case"Comma":r=",";break;default:throw new Error("Unknown node type `"+e.type+"`")}return t(r,e)}function Ut(e,t){let n=Kt,i=!1,r=!1;return"function"==typeof t?n=t:t&&(i=Boolean(t.forceBraces),r=Boolean(t.compact),"function"==typeof t.decorate&&(n=t.decorate)),_t(e,n,i,r)}const $t={offset:0,line:1,column:1};function Yt(e,t){const n=e&&e.loc&&e.loc[t];return n?"line"in n?Gt(n):n:null}function Gt({offset:e,line:t,column:n},i){const r={offset:e,line:t,column:n};if(i){const e=i.split(/\n|\r\n?|\f/);r.offset+=i.length,r.line+=e.length-1,r.column=1===e.length?r.column+i.length:e.pop().length+1}return r}const Xt=function(e,t){const n=ct("SyntaxReferenceError",e+(t?" `"+t+"`":""));return n.reference=t,n},Jt=function(e,t,n,i){const r=ct("SyntaxMatchError",e),{css:o,mismatchOffset:s,mismatchLength:a,start:l,end:c}=function(e,t){const n=e.tokens,i=e.longestMatch,r=i1?(s=Yt(o||t,"end")||Gt($t,u),a=Gt(s)):(s=Yt(o,"start")||Gt(Yt(t,"start")||$t,u.slice(0,l)),a=Yt(o,"end")||Gt(s,u.substr(l,c))),{css:u,mismatchOffset:l,mismatchLength:c,start:s,end:a}}(i,n);return r.rawMessage=e,r.syntax=t?Ut(t):"",r.css=o,r.mismatchOffset=s,r.mismatchLength=a,r.message=e+"\n syntax: "+r.syntax+"\n value: "+(o||"")+"\n --------"+new Array(r.mismatchOffset+1).join("-")+"^",Object.assign(r,l),r.loc={source:n&&n.loc&&n.loc.source||"",start:l,end:c},r},Zt=new Map,Qt=new Map,en=function(e){if(Zt.has(e))return Zt.get(e);const t=e.toLowerCase();let n=Zt.get(t);if(void 0===n){const e=rn(t,0),i=e?"":on(t,0);n=Object.freeze({basename:t.substr(i.length),name:t,prefix:i,vendor:i,custom:e})}return Zt.set(e,n),n},tn=function(e){if(Qt.has(e))return Qt.get(e);let t=e,n=e[0];"/"===n?n="/"===e[1]?"//":"/":"_"!==n&&"*"!==n&&"$"!==n&&"#"!==n&&"+"!==n&&"&"!==n&&(n="");const i=rn(t,n.length);if(!i&&(t=t.toLowerCase(),Qt.has(t))){const n=Qt.get(t);return Qt.set(e,n),n}const r=i?"":on(t,n.length),o=t.substr(0,n.length+r.length),s=Object.freeze({basename:t.substr(o.length),name:t.substr(n.length),hack:n,vendor:r,prefix:o,custom:i});return Qt.set(e,s),s},nn=on;function rn(e,t){return t=t||0,e.length-t>=2&&45===e.charCodeAt(t)&&45===e.charCodeAt(t+1)}function on(e,t){if(t=t||0,e.length-t>=3&&45===e.charCodeAt(t)&&45!==e.charCodeAt(t+1)){const n=e.indexOf("-",t+2);if(-1!==n)return e.substring(t,n+1)}return""}const sn=["initial","inherit","unset","revert","revert-layer"],an=45,ln=!0;function cn(e,t){return null!==e&&e.type===ye&&e.value.charCodeAt(0)===t}function hn(e,t,n){for(;null!==e&&(e.type===xe||e.type===Re);)e=n(++t);return t}function un(e,t,n,i){if(!e)return 0;const r=e.value.charCodeAt(t);if(43===r||r===an){if(n)return 0;t++}for(;t6)return 0}return i}function mn(e,t,n){if(!e)return 0;for(;fn(n(t),63);){if(++e>6)return 0;t++}return t}const gn=["calc(","-moz-calc(","-webkit-calc("],bn=["min(","max(","clamp("],yn=["round(","mod(","rem("],vn=["hypot("],wn=["abs("],kn=[...gn,...bn,...yn,"sin(","cos(","tan(","pow(","sqrt(","log(","exp(","sign(",...vn,...wn],xn=[...gn,...bn,...yn,...vn,...wn],Sn=[...gn,...bn,...yn,"asin(","acos(","atan(","atan2(",...vn,...wn],Cn=new Map([[ue,ze],[Le,ze],[Oe,De],[Ee,Be]]);function An(e,t){return te.max&&"string"!=typeof e.max)return!0}return!1}function Ln(e,t){return function(n,i,r){return null===n?0:n.type===ue&&Tn(n.value,t)?function(e,t){let n=0,i=[],r=0;e:do{switch(e.type){case Be:case ze:case De:if(e.type!==n)break e;if(n=i.pop(),0===i.length){r++;break e}break;case ue:case Le:case Oe:case Ee:i.push(n),n=Cn.get(e.type)}r++}while(e=t(r));return r}(n,i):e(n,i,r)}}function zn(e){return function(t){return null===t||t.type!==e?0:1}}function En(e){return null===e||e.type!==he||45!==An(e.value,0)||45!==An(e.value,1)?0:1}function Bn(e){return e&&(e=new Set(e)),function(t,n,i){if(null===t||t.type!==ke)return 0;const r=it(t.value,0);if(null!==e){const n=t.value.indexOf("\\",r),i=-1!==n&&On(t.value,n)?t.value.substring(r,n):t.value.substr(r);if(!1===e.has(i.toLowerCase()))return 0}return Dn(i,t.value,r)?0:1}}function Rn(e){return"function"!=typeof e&&(e=function(){return 0}),function(t,n,i){return null!==t&&t.type===ve&&0===Number(t.value)?1:e(t,n,i)}}const Pn={"ident-token":zn(he),"function-token":zn(ue),"at-keyword-token":zn(de),"hash-token":zn(fe),"string-token":zn(pe),"bad-string-token":zn(me),"url-token":zn(ge),"bad-url-token":zn(be),"delim-token":zn(ye),"number-token":zn(ve),"percentage-token":zn(we),"dimension-token":zn(ke),"whitespace-token":zn(xe),"CDO-token":zn(Se),"CDC-token":zn(Ce),"colon-token":zn(Ae),"semicolon-token":zn(Me),"comma-token":zn(Te),"[-token":zn(Oe),"]-token":zn(De),"(-token":zn(Le),")-token":zn(ze),"{-token":zn(Ee),"}-token":zn(Be)},In={string:zn(pe),ident:zn(he),percentage:Ln(function(e,t,n){return null===e||e.type!==we||Dn(n,e.value,e.value.length-1)?0:1},xn),zero:Rn(),number:Ln(function(e,t,n){if(null===e)return 0;const i=it(e.value,0);return i===e.value.length||On(e.value,i)?Dn(n,e.value,i)?0:1:0},kn),integer:Ln(function(e,t,n){if(null===e||e.type!==ve)return 0;let i=43===An(e.value,0)||45===An(e.value,0)?1:0;for(;i/[a-zA-Z0-9\-]/.test(String.fromCharCode(t))?1:0);class Jn{constructor(e){this.str=e,this.pos=0}charCodeAt(e){return e=128||0===Xn[t])break}return this.pos===e&&this.error("Expect a keyword"),this.substringToPos(e)}scanNumber(){let e=this.pos;for(;e57)break}return this.pos===e&&this.error("Expect a number"),this.substringToPos(e)}scanString(){const e=this.str.indexOf("'",this.pos+1);return-1===e&&(this.pos=this.str.length,this.error("Expect an apostrophe")),this.substringToPos(e+1)}}const Zn=93,Qn=123,ei={" ":1,"&&":2,"||":3,"|":4};function ti(e){let t=null,n=null;return e.eat(Qn),e.skipWs(),t=e.scanNumber(e),e.skipWs(),44===e.charCode()?(e.pos++,e.skipWs(),125!==e.charCode()&&(n=e.scanNumber(e),e.skipWs())):n=t,e.eat(125),{min:Number(t),max:n?Number(n):0}}function ni(e,t){const n=function(e){let t=null,n=!1;switch(e.charCode()){case 42:e.pos++,t={min:0,max:0};break;case 43:e.pos++,t={min:1,max:0};break;case 63:e.pos++,t={min:0,max:1};break;case 35:e.pos++,n=!0,e.charCode()===Qn?t=ti(e):63===e.charCode()?(e.pos++,t={min:0,max:0}):t={min:1,max:0};break;case Qn:t=ti(e);break;default:return null}return{type:"Multiplier",comma:n,min:t.min,max:t.max,term:null}}(e);return null!==n?(n.term=t,35===e.charCode()&&43===e.charCodeAt(e.pos-1)||63===e.charCode()&&125===e.charCodeAt(e.pos-1)?ni(e,n):n):t}function ii(e){const t=e.peek();return""===t?null:ni(e,{type:"Token",value:t})}function ri(e,t){function n(e,t){return{type:"Group",terms:e,combinator:t,disallowEmpty:!1,explicit:!1}}let i;for(t=Object.keys(t).sort((e,t)=>ei[e]-ei[t]);t.length>0;){i=t.shift();let r=0,o=0;for(;r1&&(e.splice(o,r-o,n(e.slice(o,r),i)),r=o+1),o=-1))}-1!==o&&t.length&&e.splice(o,r-o,n(e.slice(o,r),i))}return i}function oi(e,t=-1){const n=Object.create(null),i=[];let r=null,o=e.pos,s=!1;for(;e.charCode()!==t;){let t=s?oi(e,41):si(e);if(!t)break;if("Spaces"!==t.type){if(s){if(0===t.terms.length){s=!1;continue}if(" "===t.combinator){for(;t.terms.length>1;)n[" "]=!0,i.push({type:"Combinator",value:" "},t.terms.shift());t=t.terms[0]}}"Combinator"===t.type?(null!==r&&"Combinator"!==r.type||(e.pos=o,e.error("Unexpected combinator")),n[t.value]=!0):null!==r&&"Combinator"!==r.type&&(n[" "]=!0,i.push({type:"Combinator",value:" "})),i.push(t),r=t,o=e.pos,s="Function"===t.type}}return null!==r&&"Combinator"===r.type&&(e.pos-=o,e.error("Unexpected combinator")),{type:"Group",terms:i,combinator:ri(i,n)||" ",disallowEmpty:!1,explicit:!1}}function si(e){let t=e.charCode();switch(t){case Zn:break;case 91:return ni(e,function(e){let t;return e.eat(91),t=oi(e,Zn),e.eat(Zn),t.explicit=!0,33===e.charCode()&&(e.pos++,t.disallowEmpty=!0),t}(e));case 60:return 39===e.nextCharCode()?function(e){let t;return e.eat(60),e.eat(39),t=e.scanWord(),e.eat(39),e.eat(62),ni(e,{type:"Property",name:t})}(e):function(e){let t,n=null;if(e.eat(60),t=e.scanWord(),"boolean-expr"===t){e.eat(91);const t=oi(e,Zn);return e.eat(Zn),e.eat(62),ni(e,{type:"Boolean",term:1===t.terms.length?t.terms[0]:t})}return 40===e.charCode()&&41===e.nextCharCode()&&(e.pos+=2,t+="()"),91===e.charCodeAt(e.findWsEnd(e.pos))&&(e.skipWs(),n=function(e){let t=null,n=null,i=1;return e.eat(91),45===e.charCode()&&(e.peek(),i=-1),-1==i&&8734===e.charCode()?e.peek():(t=i*Number(e.scanNumber(e)),e.isNameCharCode()&&(t+=e.scanWord())),e.skipWs(),e.eat(44),e.skipWs(),8734===e.charCode()?e.peek():(i=1,45===e.charCode()&&(e.peek(),i=-1),n=i*Number(e.scanNumber(e)),e.isNameCharCode()&&(n+=e.scanWord())),e.eat(Zn),{type:"Range",min:t,max:n}}(e)),e.eat(62),ni(e,{type:"Type",name:t,opts:n})}(e);case 124:return{type:"Combinator",value:e.substringToPos(e.pos+(124===e.nextCharCode()?2:1))};case 38:return e.pos++,e.eat(38),{type:"Combinator",value:"&&"};case 44:return e.pos++,{type:"Comma"};case 39:return ni(e,{type:"String",value:e.scanString()});case 32:case 9:case 10:case 13:case 12:return{type:"Spaces",value:e.scanSpaces()};case 64:return t=e.nextCharCode(),e.isNameCharCode(t)?(e.pos++,{type:"AtKeyword",name:e.scanWord()}):ii(e);case 42:case 43:case 63:case 35:case 33:break;case Qn:if(t=e.nextCharCode(),t<48||t>57)return ii(e);break;default:return e.isNameCharCode(t)?function(e){const t=e.scanWord();return 40===e.charCode()?(e.pos++,{type:"Function",name:t}):ni(e,{type:"Keyword",name:t})}(e):ii(e)}}function ai(e){const t=new Jn(e),n=oi(t);return t.pos!==e.length&&t.error("Unexpected input"),1===n.terms.length&&"Group"===n.terms[0].type?n.terms[0]:n}const li=function(){};function ci(e){return"function"==typeof e?e:li}function hi(e,t,n){let i=li,r=li;if("function"==typeof t?i=t:t&&(i=ci(t.enter),r=ci(t.leave)),i===li&&r===li)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");!function e(t){switch(i.call(n,t),t.type){case"Group":t.terms.forEach(e);break;case"Multiplier":case"Boolean":e(t.term);break;case"Type":case"Property":case"Keyword":case"AtKeyword":case"Function":case"String":case"Token":case"Comma":break;default:throw new Error("Unknown type: "+t.type)}r.call(n,t)}(e)}n.dn(di);const ui={decorator(e){const t=[];let n=null;return{...e,node(t){const i=n;n=t,e.node.call(this,t),n=i},emit(e,i,r){t.push({type:i,value:e,node:r?null:n})},result:()=>t}}};function di(e,t){return"string"==typeof e?function(e){const t=[];return st(e,(n,i,r)=>t.push({type:n,value:e.slice(i,r),node:null})),t}(e):t.generate(e,ui)}const fi={type:"Match"},pi={type:"Mismatch"},mi={type:"DisallowEmpty"};function gi(e,t,n){return t===fi&&n===pi||e===fi&&t===fi&&n===fi?e:("If"===e.type&&e.else===pi&&t===fi&&(t=e.then,e=e.match),{type:"If",match:e,then:t,else:n})}function bi(e){return e.length>2&&40===e.charCodeAt(e.length-2)&&41===e.charCodeAt(e.length-1)}function yi(e){return"Keyword"===e.type||"AtKeyword"===e.type||"Function"===e.type||"Type"===e.type&&bi(e.name)}function vi(e,t=" ",n=!1){return{type:"Group",terms:e,combinator:t,disallowEmpty:!1,explicit:n}}function wi(e,t,n=new Set){if(!n.has(e))switch(n.add(e),e.type){case"If":e.match=wi(e.match,t,n),e.then=wi(e.then,t,n),e.else=wi(e.else,t,n);break;case"Type":return t[e.name]||e}return e}function ki(e,t,n){switch(e){case" ":{let e=fi;for(let n=t.length-1;n>=0;n--)e=gi(t[n],e,pi);return e}case"|":{let e=pi,n=null;for(let i=t.length-1;i>=0;i--){let r=t[i];if(yi(r)&&(null===n&&i>0&&yi(t[i-1])&&(n=Object.create(null),e=gi({type:"Enum",map:n},fi,e)),null!==n)){const e=(bi(r.name)?r.name.slice(0,-1):r.name).toLowerCase();if(e in n==0){n[e]=r;continue}}n=null,e=gi(r,fi,e)}return e}case"&&":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!0};let n=pi;for(let i=t.length-1;i>=0;i--){const r=t[i];let o;o=t.length>1?ki(e,t.filter(function(e){return e!==r}),!1):fi,n=gi(r,o,n)}return n}case"||":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!1};let i=n?fi:pi;for(let n=t.length-1;n>=0;n--){const r=t[n];let o;o=t.length>1?ki(e,t.filter(function(e){return e!==r}),!0):fi,i=gi(r,o,i)}return i}}}function xi(e){if("function"==typeof e)return{type:"Generic",fn:e};switch(e.type){case"Group":{let t=ki(e.combinator,e.terms.map(xi),!1);return e.disallowEmpty&&(t=gi(t,mi,pi)),t}case"Multiplier":return function(e){let t=fi,n=xi(e.term);if(0===e.max)n=gi(n,mi,pi),t=gi(n,null,pi),t.then=gi(fi,fi,t),e.comma&&(t.then.else=gi({type:"Comma",syntax:e},t,pi));else for(let i=e.min||1;i<=e.max;i++)e.comma&&t!==fi&&(t=gi({type:"Comma",syntax:e},t,pi)),t=gi(n,gi(fi,fi,t),pi);if(0===e.min)t=gi(fi,fi,t);else for(let i=0;i=65&&r<=90&&(r|=32),r!==i)return!1}return!0}function Oi(e){return null===e||e.type===Te||e.type===ue||e.type===Le||e.type===Oe||e.type===Ee||function(e){return e.type===ye&&"?"!==e.value}(e)}function Di(e){return null===e||e.type===ze||e.type===De||e.type===Be||e.type===ye&&"/"===e.value}function Li(e,t,n){const i=function(e,t,n){function i(){do{y++,b=yv&&(v=y)}function c(){u={syntax:t.syntax,opts:t.syntax.opts||null!==u&&u.opts||null,prev:u},w={type:2,syntax:t.syntax,token:w.token,prev:w}}function h(){w=2===w.type?w.prev:{type:3,syntax:u.syntax,token:w.token,prev:w},u=u.prev}let u=null,d=null,f=null,p=null,m=0,g=null,b=null,y=-1,v=0,w={type:0,syntax:null,token:null,prev:null};for(i();null===g&&++m<15e3;)switch(t.type){case"Match":if(null===d){if(null!==b&&(y!==e.length-1||"\\0"!==b.value&&"\\9"!==b.value)){t=pi;break}g=Ai;break}if((t=d.nextState)===mi){if(d.matchStack===w){t=pi;break}t=fi}for(;d.syntaxStack!==u;)h();d=d.prev;break;case"Mismatch":if(null!==p&&!1!==p)(null===f||y>f.tokenIndex)&&(f=p,p=!1);else if(null===f){g="Mismatch";break}t=f.nextState,d=f.thenStack,u=f.syntaxStack,w=f.matchStack,y=f.tokenIndex,b=yy){for(;y":"<'"+t.name+"'>"));if(!1!==p&&null!==b&&"Type"===t.type&&("custom-ident"===t.name&&b.type===he||"length"===t.name&&"0"===b.value)){null===p&&(p=o(t,f)),t=pi;break}c(),t=i.matchRef||i.match;break}case"Keyword":{const e=t.name;if(null!==b){let n=b.value;if(-1!==n.indexOf("\\")&&(n=n.replace(/\\[09].*$/,"")),Ti(n,e)){l(),t=fi;break}}t=pi;break}case"AtKeyword":case"Function":if(null!==b&&Ti(b.value,t.name)){l(),t=fi;break}t=pi;break;case"Token":if(null!==b&&b.value===t.value){l(),t=fi;break}t=pi;break;case"Comma":null!==b&&b.type===Te?Oi(w.token)?t=pi:(l(),t=Di(b)?pi:fi):t=Oi(w.token)||Di(b)?fi:pi;break;case"String":let i="",m=y;for(;m"Type"===e.type&&e.name===t)}function Bi(e,t){return Pi(this,e,e=>"Property"===e.type&&e.name===t)}function Ri(e){return Pi(this,e,e=>"Keyword"===e.type)}function Pi(e,t,n){const i=zi.call(e,t);return null!==i&&i.some(n)}function Ii(e){return"node"in e?e.node:Ii(e.match[0])}function Ni(e){return"node"in e?e.node:Ni(e.match[e.match.length-1])}function Fi(e,t,n,i,r){const o=[];return null!==n.matched&&function n(s){if(null!==s.syntax&&s.syntax.type===i&&s.syntax.name===r){const n=Ii(s),i=Ni(s);e.syntax.walk(t,function(e,t,r){if(e===n){const e=new lt;do{if(e.appendData(t.data),t.data===i)break;t=t.next}while(null!==t);o.push({parent:r,nodes:e})}})}Array.isArray(s.match)&&s.match.forEach(n)}(n.matched),o}const{hasOwnProperty:Wi}=Object.prototype;function Hi(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e&&e>=0}function qi(e){return Boolean(e)&&Hi(e.offset)&&Hi(e.line)&&Hi(e.column)}function Vi(e,t){return function(n,i){if(!n||n.constructor!==Object)return i(n,"Type of node should be an Object");for(let r in n){let o=!0;if(!1!==Wi.call(n,r)){if("type"===r)n.type!==e&&i(n,"Wrong node type `"+n.type+"`, expected `"+e+"`");else if("loc"===r){if(null===n.loc)continue;if(n.loc&&n.loc.constructor===Object)if("string"!=typeof n.loc.source)r+=".source";else if(qi(n.loc.start)){if(qi(n.loc.end))continue;r+=".end"}else r+=".start";o=!1}else if(t.hasOwnProperty(r)){o=!1;for(let e=0;!o&&e")}}return n.join(" | ")}function Ki(e,t){const n=t.structure,i={type:String,loc:!0},r={type:'"'+e+'"'};for(const t in n){if(!1===Wi.call(n,t))continue;const o=i[t]=Array.isArray(n[t])?n[t].slice():[n[t]];r[t]=ji(o,e+"."+t)}return{docs:r,check:Vi(e,i)}}function _i(e,t,n){const i={};for(const r in e)e[r].syntax&&(i[r]=n?e[r].syntax:Ut(e[r].syntax,{compact:t}));return i}function Ui(e,t,n){const i={};for(const[r,o]of Object.entries(e))i[r]={prelude:o.prelude&&(n?o.prelude.syntax:Ut(o.prelude.syntax,{compact:t})),descriptors:o.descriptors&&_i(o.descriptors,t,n)};return i}function $i(e,t,n){return{matched:e,iterations:n,error:t,...s}}function Yi(e,t,n,i){const r=di(n,e.syntax);let o;return function(e){for(let t=0;t(Object.defineProperty(o,"syntax",{value:ai(e)}),o.syntax)}):o.syntax=e,Object.defineProperty(o,"match",{get:()=>(Object.defineProperty(o,"match",{value:Si(o.syntax,r)}),o.match)}),"Property"===t&&Object.defineProperty(o,"matchRef",{get(){const e=o.syntax,t=function(e){const t=e.terms[0];return!1===e.explicit&&1===e.terms.length&&"Multiplier"===t.type&&!0===t.comma}(e)?Si({...e,terms:[e.terms[0].term]},r):null;return Object.defineProperty(o,"matchRef",{value:t}),t}})),o}addAtrule_(e,t){t&&(this.atrules[e]={type:"Atrule",name:e,prelude:t.prelude?this.createDescriptor(t.prelude,"AtrulePrelude",e):null,descriptors:t.descriptors?Object.keys(t.descriptors).reduce((n,i)=>(n[i]=this.createDescriptor(t.descriptors[i],"AtruleDescriptor",i,e),n),Object.create(null)):null})}addProperty_(e,t){t&&(this.properties[e]=this.createDescriptor(t,"Property",e))}addType_(e,t){t&&(this.types[e]=this.createDescriptor(t,"Type",e))}checkAtruleName(e){if(!this.getAtrule(e))return new Xt("Unknown at-rule","@"+e)}checkAtrulePrelude(e,t){const n=this.checkAtruleName(e);if(n)return n;const i=this.getAtrule(e);return!i.prelude&&t?new SyntaxError("At-rule `@"+e+"` should not contain a prelude"):!i.prelude||t||Yi(this,i.prelude,"",!1).matched?void 0:new SyntaxError("At-rule `@"+e+"` should contain a prelude")}checkAtruleDescriptorName(e,t){const n=this.checkAtruleName(e);if(n)return n;const i=this.getAtrule(e),r=en(t);return i.descriptors?i.descriptors[r.name]||i.descriptors[r.basename]?void 0:new Xt("Unknown at-rule descriptor",t):new SyntaxError("At-rule `@"+e+"` has no known descriptors")}checkPropertyName(e){if(!this.getProperty(e))return new Xt("Unknown property",e)}matchAtrulePrelude(e,t){const n=this.checkAtrulePrelude(e,t);if(n)return $i(null,n);const i=this.getAtrule(e);return i.prelude?Yi(this,i.prelude,t||"",!1):$i(null,null)}matchAtruleDescriptor(e,t,n){const i=this.checkAtruleDescriptorName(e,t);if(i)return $i(null,i);const r=this.getAtrule(e),o=en(t);return Yi(this,r.descriptors[o.name]||r.descriptors[o.basename],n,!1)}matchDeclaration(e){return"Declaration"!==e.type?$i(null,new Error("Not a Declaration node")):this.matchProperty(e.property,e.value)}matchProperty(e,t){if(tn(e).custom)return $i(null,new Error("Lexer matching doesn't applicable for custom properties"));const n=this.checkPropertyName(e);return n?$i(null,n):Yi(this,this.getProperty(e),t,!0)}matchType(e,t){const n=this.getType(e);return n?Yi(this,n,t,!1):$i(null,new Xt("Unknown type",e))}match(e,t){return"string"==typeof e||e&&e.type?("string"!=typeof e&&e.match||(e=this.createDescriptor(e,"Type","anonymous")),Yi(this,e,t,!1)):$i(null,new Xt("Bad syntax"))}findValueFragments(e,t,n,i){return Fi(this,t,this.matchProperty(e,t),n,i)}findDeclarationValueFragments(e,t,n){return Fi(this,e.value,this.matchDeclaration(e),t,n)}findAllFragments(e,t,n){const i=[];return this.syntax.walk(e,{visit:"Declaration",enter:e=>{i.push.apply(i,this.findDeclarationValueFragments(e,t,n))}}),i}getAtrule(e,t=!0){const n=en(e);return(n.vendor&&t?this.atrules[n.name]||this.atrules[n.basename]:this.atrules[n.name])||null}getAtrulePrelude(e,t=!0){const n=this.getAtrule(e,t);return n&&n.prelude||null}getAtruleDescriptor(e,t){return this.atrules.hasOwnProperty(e)&&this.atrules.declarators&&this.atrules[e].declarators[t]||null}getProperty(e,t=!0){const n=tn(e);return(n.vendor&&t?this.properties[n.name]||this.properties[n.basename]:this.properties[n.name])||null}getType(e){return hasOwnProperty.call(this.types,e)?this.types[e]:null}validate(){function e(e,t){return t?`<${e}>`:`<'${e}'>`}function t(o,s,a,l){if(a.has(s))return a.get(s);a.set(s,!1),null!==l.syntax&&hi(l.syntax,function(l){if("Type"!==l.type&&"Property"!==l.type)return;const c="Type"===l.type?o.types:o.properties,h="Type"===l.type?i:r;hasOwnProperty.call(c,l.name)?t(o,l.name,h,c[l.name])&&(n.push(`${e(s,a===i)} used broken syntax definition ${e(l.name,"Type"===l.type)}`),a.set(s,!0)):(n.push(`${e(s,a===i)} used missed syntax definition ${e(l.name,"Type"===l.type)}`),a.set(s,!0))},this)}const n=[];let i=new Map,r=new Map;for(const e in this.types)t(this,e,i,this.types[e]);for(const e in this.properties)t(this,e,r,this.properties[e]);const o=[...i.keys()].filter(e=>i.get(e)),s=[...r.keys()].filter(e=>r.get(e));return o.length||s.length?{errors:n,types:o,properties:s}:null}dump(e,t){return{generic:this.generic,cssWideKeywords:this.cssWideKeywords,units:this.units,types:_i(this.types,!t,e),properties:_i(this.properties,!t,e),atrules:Ui(this.atrules,!t,e)}}toString(){return JSON.stringify(this.dump())}}function Xi(e,t){return"string"==typeof t&&/^\s*\|/.test(t)?"string"==typeof e?e+t:t.replace(/^\s*\|\s*/,""):t||null}function Ji(e,t){const n=Object.create(null);for(const i of Object.keys(e))t.includes(i)&&(n[i]=e[i]);return n}function Zi(e,t,n){const i={...e};for(const[e,r]of Object.entries(t))i[e]={...i[e],...n?Ji(r,n):r};return i}function Qi(e,t){const n={...e};for(const[i,r]of Object.entries(t))switch(i){case"generic":n[i]=Boolean(r);break;case"cssWideKeywords":n[i]=e[i]?[...e[i],...r]:r||[];break;case"units":n[i]={...e[i]};for(const[e,t]of Object.entries(r))n[i][e]=Array.isArray(t)?t:[];break;case"atrules":n[i]={...e[i]};for(const[e,t]of Object.entries(r)){const r=n[i][e]||{},o=n[i][e]={prelude:r.prelude||null,descriptors:{...r.descriptors}};if(t){o.prelude=t.prelude?Xi(o.prelude,t.prelude):o.prelude||null;for(const[e,n]of Object.entries(t.descriptors||{}))o.descriptors[e]=n?Xi(o.descriptors[e],n):null;Object.keys(o.descriptors).length||(o.descriptors=null)}}break;case"types":case"properties":n[i]={...e[i]};for(const[e,t]of Object.entries(r))n[i][e]=Xi(n[i][e],t);break;case"parseContext":n[i]={...e[i],...r};break;case"scope":case"features":n[i]=Zi(e[i],r);break;case"atrule":case"pseudo":n[i]=Zi(e[i],r,["parse"]);break;case"node":n[i]=Zi(e[i],r,["name","structure","parse","generate","walkContext"])}return n}function er(e){const t=function(e){let t="",n="",i=!1,r=St,o=!1;const s=new pt,a=Object.assign(new kt,function(e){const t={context:Object.create(null),features:Object.assign(Object.create(null),e.features),scope:Object.assign(Object.create(null),e.scope),atrule:Tt(e.atrule),pseudo:Tt(e.pseudo),node:Tt(e.node)};for(const[n,i]of Object.entries(e.parseContext))switch(typeof i){case"function":t.context[n]=i;break;case"string":t.context[n]=Mt(i)}return{config:t,...t,...t.node}}(e||{}),{parseAtrulePrelude:!0,parseRulePrelude:!0,parseValue:!0,parseCustomProperty:!1,readSequence:xt,consumeUntilBalanceEnd:()=>0,consumeUntilLeftCurlyBracket:e=>123===e?1:0,consumeUntilLeftCurlyBracketOrSemicolon:e=>123===e||59===e?1:0,consumeUntilExclamationMarkOrSemicolon:e=>33===e||59===e?1:0,consumeUntilSemicolonIncluded:e=>59===e?2:0,createList:St,createSingleNodeList:St,getFirstListNode:St,getLastListNode:St,parseWithFallback(e,t){const n=this.tokenIndex;try{return e.call(this)}catch(e){if(o)throw e;this.skip(n-this.tokenIndex);const i=t.call(this);return o=!0,r(e,i),o=!1,i}},lookupNonWSType(e){let t;do{if(t=this.lookupType(e++),t!==xe&&t!==Re)return t}while(0!==t);return 0},charCodeAt:e=>e>=0&&et.substring(e,n),substrToCursor(e){return this.source.substring(e,this.tokenStart)},cmpChar:(e,n)=>Je(t,e,n),cmpStr:(e,n,i)=>Ze(t,e,n,i),consume(e){const t=this.tokenStart;return this.eat(e),this.substrToCursor(t)},consumeFunctionName(){const e=t.substring(this.tokenStart,this.tokenEnd-1);return this.eat(ue),e},consumeNumber(e){const n=t.substring(this.tokenStart,it(t,this.tokenStart));return this.eat(e),n},eat(e){if(this.tokenType!==e){const t=mt[e].slice(0,-6).replace(/-/g," ").replace(/^./,e=>e.toUpperCase());let n=`${/[[\](){}]/.test(t)?`"${t}"`:t} is expected`,i=this.tokenStart;switch(e){case he:this.tokenType===ue||this.tokenType===ge?(i=this.tokenEnd-1,n="Identifier is expected but function found"):n="Identifier is expected";break;case fe:this.isDelim(35)&&(this.next(),i++,n="Name is expected");break;case we:this.tokenType===ve&&(i=this.tokenEnd,n="Percent sign is expected")}this.error(n,i)}this.next()},eatIdent(e){this.tokenType===he&&!1!==this.lookupValue(0,e)||this.error(`Identifier "${e}" is expected`),this.next()},eatDelim(e){this.isDelim(e)||this.error(`Delim "${String.fromCharCode(e)}" is expected`),this.next()},getLocation:(e,t)=>i?s.getLocationRange(e,t,n):null,getLocationFromList(e){if(i){const t=this.getFirstListNode(e),i=this.getLastListNode(e);return s.getLocationRange(null!==t?t.loc.start.offset-s.startOffset:this.tokenStart,null!==i?i.loc.end.offset-s.startOffset:this.tokenStart,n)}return null},error(e,n){const i=void 0!==n&&n=0&&Ve(e.charCodeAt(t));t--);return t+1}(t,t.length-1)):s.getLocation(this.tokenStart);throw new ut(e||"Unexpected input",t,i.offset,i.line,i.column,s.startLine,s.startColumn)}});return Object.assign(function(e,l){t=e,l=l||{},a.setSource(t,st),s.setSource(t,l.offset,l.line,l.column),n=l.filename||"",i=Boolean(l.positions),r="function"==typeof l.onParseError?l.onParseError:St,o=!1,a.parseAtrulePrelude=!("parseAtrulePrelude"in l)||Boolean(l.parseAtrulePrelude),a.parseRulePrelude=!("parseRulePrelude"in l)||Boolean(l.parseRulePrelude),a.parseValue=!("parseValue"in l)||Boolean(l.parseValue),a.parseCustomProperty="parseCustomProperty"in l&&Boolean(l.parseCustomProperty);const{context:c="default",list:h=!0,onComment:u,onToken:d}=l;if(c in a.context==0)throw new Error("Unknown context `"+c+"`");Object.assign(a,h?At:Ct),Array.isArray(d)?a.forEachToken((e,t,n)=>{d.push({type:e,start:t,end:n})}):"function"==typeof d&&a.forEachToken(d.bind({filename:n,source:t,tokenCount:a.tokenCount,getTokenType:e=>a.getTokenType(e),getTokenTypeName:e=>mt[a.getTokenType(e)],getTokenStart:e=>a.getTokenStart(e),getTokenEnd:e=>a.getTokenEnd(e),getTokenValue:e=>a.source.substring(a.getTokenStart(e),a.getTokenEnd(e)),substring:(e,t)=>a.source.substring(e,t),balance:a.balance.subarray(0,a.tokenCount+1),isBlockOpenerTokenType:a.isBlockOpenerTokenType,isBlockCloserTokenType:a.isBlockCloserTokenType,getBlockTokenPairIndex:e=>a.getBlockTokenPairIndex(e),getLocation:e=>s.getLocation(e,n),getRangeLocation:(e,t)=>s.getLocationRange(e,t,n)})),"function"==typeof u&&a.forEachToken((e,n,i)=>{if(e===Re){const e=a.getLocation(n,i),r=Ze(t,i-2,i,"*/")?t.slice(n+2,i-2):t.slice(n+2,i);u(r,e)}});const f=a.context[c].call(a,l);return a.eof||a.error(),f},{SyntaxError:ut,config:a.config})}(e),n=function(e){const t=function(e){const t={};for(const n in e.node)if(Nt.call(e.node,n)){const i=e.node[n];if(!i.structure)throw new Error("Missed `structure` field in `"+n+"` node type definition");t[n]=qt(0,i)}return t}(e),n={},i={},r=Symbol("break-walk"),o=Symbol("skip-node");for(const e in t)Nt.call(t,e)&&null!==t[e]&&(n[e]=Vt(t[e],!1),i[e]=Vt(t[e],!0));const s=jt(n),a=jt(i),l=function(e,l){function c(e,t,n){const i=h.call(p,e,t,n);return i===r||i!==o&&(!(!d.hasOwnProperty(e.type)||!d[e.type](e,p,c,f))||u.call(p,e,t,n)===r)}let h=Ft,u=Ft,d=n,f=(e,t,n,i)=>e||c(t,n,i);const p={break:r,skip:o,root:e,stylesheet:null,atrule:null,atrulePrelude:null,rule:null,selector:null,block:null,declaration:null,function:null};if("function"==typeof l)h=l;else if(l&&(h=Wt(l.enter),u=Wt(l.leave),l.reverse&&(d=i),l.visit)){if(s.hasOwnProperty(l.visit))d=l.reverse?a[l.visit]:s[l.visit];else if(!t.hasOwnProperty(l.visit))throw new Error("Bad value `"+l.visit+"` for `visit` option (should be: "+Object.keys(t).sort().join(", ")+")");h=Ht(h,l.visit),u=Ht(u,l.visit)}if(h===Ft&&u===Ft)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");c(e)};return l.break=r,l.skip=o,l.find=function(e,t){let n=null;return l(e,function(e,i,o){if(t.call(this,e,i,o))return n=e,r}),n},l.findLast=function(e,t){let n=null;return l(e,{reverse:!0,enter(e,i,o){if(t.call(this,e,i,o))return n=e,r}}),n},l.findAll=function(e,t){const n=[];return l(e,function(e,i,r){t.call(this,e,i,r)&&n.push(e)}),n},l}(e),i=function(e){const t=new Map;for(let[n,i]of Object.entries(e.node))"function"==typeof(i.generate||i)&&t.set(n,i.generate||i);return function(e,n){let i="",o=0,s={node(e){if(!t.has(e.type))throw new Error("Unknown node type: "+e.type);t.get(e.type).call(a,e)},tokenBefore:Pt,token(e,t,n){o=this.tokenBefore(o,e,t),!n&&1&o&&this.emit(" ",xe,!0),this.emit(t,e,!1),e===ye&&92===t.charCodeAt(0)&&this.emit("\n",xe,!0)},emit(e){i+=e},result:()=>i};n&&("function"==typeof n.decorator&&(s=n.decorator(s)),n.sourceMap&&(s=function(e){const t=new Ot.x,n={line:1,column:0},i={line:0,column:0},r={line:1,column:0},o={generated:r};let s=1,a=0,l=!1;const c=e.node;e.node=function(e){if(e.loc&&e.loc.start&&Dt.has(e.type)){const c=e.loc.start.line,h=e.loc.start.column-1;i.line===c&&i.column===h||(i.line=c,i.column=h,n.line=s,n.column=a,l&&(l=!1,n.line===r.line&&n.column===r.column||t.addMapping(o)),l=!0,t.addMapping({source:e.loc.source,original:i,generated:n}))}c.call(this,e),l&&Dt.has(e.type)&&(r.line=s,r.column=a)};const h=e.emit;e.emit=function(e,t,n){for(let t=0;ts.node(e),children:It,token:(e,t)=>s.token(e,t),tokenize:e=>st(e,(t,n,i)=>{s.token(t,e.slice(n,i),0!==n)})};return s.node(e),s.result()}}(e),{fromPlainObject:o,toPlainObject:s}=function(e){return{fromPlainObject:t=>(e(t,{enter(e){e.children&&e.children instanceof lt==0&&(e.children=(new lt).fromArray(e.children))}}),t),toPlainObject:t=>(e(t,{leave(e){e.children&&e.children instanceof lt&&(e.children=e.children.toArray())}}),t)}}(n),a={lexer:null,createLexer:e=>new Gi(e,a,a.lexer.structure),tokenize:st,parse:t,generate:i,walk:n,find:n.find,findLast:n.findLast,findAll:n.findAll,fromPlainObject:o,toPlainObject:s,fork(t){const n=Qi({},e);return er("function"==typeof t?t(n):Qi(n,t))}};return a.lexer=new Gi({generic:e.generic,cssWideKeywords:e.cssWideKeywords,units:e.units,types:e.types,atrules:e.atrules,properties:e.properties,node:e.node},a),a}const tr=e=>er(Qi({},e));n.dn(tr);const nr=43,ir=45,rr=110,or=!0;function sr(e,t){let n=this.tokenStart+e;const i=this.charCodeAt(n);for(i!==nr&&i!==ir||(t&&this.error("Number sign is not allowed"),n++);n0&&this.skip(e),0===t&&(n=this.charCodeAt(this.tokenStart),n!==nr&&n!==ir&&this.error("Number sign is expected")),ar.call(this,0!==t),t===ir?"-"+this.consume(ve):this.consume(ve)}const hr="AnPlusB",ur={a:[String,null],b:[String,null]};function dr(){const e=this.tokenStart;let t=null,n=null;if(this.tokenType===ve)ar.call(this,!1),n=this.consume(ve);else if(this.tokenType===he&&this.cmpChar(this.tokenStart,ir))switch(t="-1",lr.call(this,1,rr),this.tokenEnd-this.tokenStart){case 2:this.next(),n=cr.call(this);break;case 3:lr.call(this,2,ir),this.next(),this.skipSC(),ar.call(this,or),n="-"+this.consume(ve);break;default:lr.call(this,2,ir),sr.call(this,3,or),this.next(),n=this.substrToCursor(e+2)}else if(this.tokenType===he||this.isDelim(nr)&&this.lookupType(1)===he){let i=0;switch(t="1",this.isDelim(nr)&&(i=1,this.next()),lr.call(this,0,rr),this.tokenEnd-this.tokenStart){case 1:this.next(),n=cr.call(this);break;case 2:lr.call(this,1,ir),this.next(),this.skipSC(),ar.call(this,or),n="-"+this.consume(ve);break;default:lr.call(this,1,ir),sr.call(this,2,or),this.next(),n=this.substrToCursor(e+i+1)}}else if(this.tokenType===ke){const i=this.charCodeAt(this.tokenStart),r=i===nr||i===ir;let o=this.tokenStart+r;for(;o{"Declaration"===e.type&&this.token(Me,";")}),this.token(Be,"}")}const qr="Brackets",Vr={children:[[]]};function jr(e,t){const n=this.tokenStart;let i=null;return this.eat(Oe),i=e.call(this,t),this.eof||this.eat(De),{type:"Brackets",loc:this.getLocation(n,this.tokenStart),children:i}}function Kr(e){this.token(ye,"["),this.children(e),this.token(ye,"]")}const _r="CDC",Ur=[];function $r(){const e=this.tokenStart;return this.eat(Ce),{type:"CDC",loc:this.getLocation(e,this.tokenStart)}}function Yr(){this.token(Ce,"--\x3e")}const Gr="CDO",Xr=[];function Jr(){const e=this.tokenStart;return this.eat(Se),{type:"CDO",loc:this.getLocation(e,this.tokenStart)}}function Zr(){this.token(Se,"\x3c!--")}const Qr="ClassSelector",eo={name:String};function to(){return this.eatDelim(46),{type:"ClassSelector",loc:this.getLocation(this.tokenStart-1,this.tokenEnd),name:this.consume(he)}}function no(e){this.token(ye,"."),this.token(he,e.name)}const io="Combinator",ro={name:String};function oo(){const e=this.tokenStart;let t;switch(this.tokenType){case xe:t=" ";break;case ye:switch(this.charCodeAt(this.tokenStart)){case 62:case 43:case 126:this.next();break;case 47:this.next(),this.eatIdent("deep"),this.eatDelim(47);break;default:this.error("Combinator is expected")}t=this.substrToCursor(e)}return{type:"Combinator",loc:this.getLocation(e,this.tokenStart),name:t}}function so(e){this.tokenize(e.name)}const ao="Comment",lo={value:String};function co(){const e=this.tokenStart;let t=this.tokenEnd;return this.eat(Re),t-e+2>=2&&42===this.charCodeAt(t-2)&&47===this.charCodeAt(t-1)&&(t-=2),{type:"Comment",loc:this.getLocation(e,this.tokenStart),value:this.substring(e+2,t)}}function ho(e){this.token(Re,"/*"+e.value+"*/")}const uo=new Set([Ae,ze,ce]),fo="Condition",po={kind:String,children:[["Identifier","Feature","FeatureFunction","FeatureRange","SupportsDeclaration"]]};function mo(e){return this.lookupTypeNonSC(1)===he&&uo.has(this.lookupTypeNonSC(2))?this.Feature(e):this.FeatureRange(e)}const go={media:mo,container:mo,supports(){return this.SupportsDeclaration()}};function bo(e="media"){const t=this.createList();e:for(;!this.eof;)switch(this.tokenType){case Re:case xe:this.next();continue;case he:t.push(this.Identifier());break;case Le:{let n=this.parseWithFallback(()=>go[e].call(this,e),()=>null);n||(n=this.parseWithFallback(()=>{this.eat(Le);const t=this.Condition(e);return this.eat(ze),t},()=>this.GeneralEnclosed(e))),t.push(n);break}case ue:{let n=this.parseWithFallback(()=>this.FeatureFunction(e),()=>null);n||(n=this.GeneralEnclosed(e)),t.push(n);break}default:break e}return t.isEmpty&&this.error("Condition is expected"),{type:"Condition",loc:this.getLocationFromList(t),kind:e,children:t}}function yo(e){e.children.forEach(e=>{"Condition"===e.type?(this.token(Le,"("),this.node(e),this.token(ze,")")):this.node(e)})}function vo(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!0)}function wo(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!1)}function ko(){const e=this.tokenIndex,t=this.Value();return"Raw"!==t.type&&!1===this.eof&&this.tokenType!==Me&&!1===this.isDelim(33)&&!1===this.isBalanceEdge(e)&&this.error(),t}const xo="Declaration",So="declaration",Co={important:[Boolean,String],property:String,value:["Value","Raw"]};function Ao(){const e=this.tokenStart,t=this.tokenIndex,n=To.call(this),i=rn(n),r=i?this.parseCustomProperty:this.parseValue,o=i?wo:vo;let s,a=!1;this.skipSC(),this.eat(Ae);const l=this.tokenIndex;if(i||this.skipSC(),s=r?this.parseWithFallback(ko,o):o.call(this,this.tokenIndex),i&&"Value"===s.type&&s.children.isEmpty)for(let e=l-this.tokenIndex;e<=0;e++)if(this.lookupType(e)===xe){s.children.appendData({type:"WhiteSpace",loc:null,value:" "});break}return this.isDelim(33)&&(a=Oo.call(this),this.skipSC()),!1===this.eof&&this.tokenType!==Me&&!1===this.isBalanceEdge(t)&&this.error(),{type:"Declaration",loc:this.getLocation(e,this.tokenStart),important:a,property:n,value:s}}function Mo(e){this.token(he,e.property),this.token(Ae,":"),this.node(e.value),e.important&&(this.token(ye,"!"),this.token(he,!0===e.important?"important":e.important))}function To(){const e=this.tokenStart;if(this.tokenType===ye)switch(this.charCodeAt(this.tokenStart)){case 42:case 36:case 43:case 35:case 38:this.next();break;case 47:this.next(),this.isDelim(47)&&this.next()}return this.tokenType===fe?this.eat(fe):this.eat(he),this.substrToCursor(e)}function Oo(){this.eat(ye),this.skipSC();const e=this.consume(he);return"important"===e||e}function Do(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}const Lo="DeclarationList",zo={children:[["Declaration","Atrule","Rule"]]};function Eo(){const e=this.createList();for(;!this.eof;)switch(this.tokenType){case xe:case Re:case Me:this.next();break;case de:e.push(this.parseWithFallback(this.Atrule.bind(this,!0),Do));break;default:this.isDelim(38)?e.push(this.parseWithFallback(this.Rule,Do)):e.push(this.parseWithFallback(this.Declaration,Do))}return{type:"DeclarationList",loc:this.getLocationFromList(e),children:e}}function Bo(e){this.children(e,e=>{"Declaration"===e.type&&this.token(Me,";")})}const Ro="Dimension",Po={value:String,unit:String};function Io(){const e=this.tokenStart,t=this.consumeNumber(ke);return{type:"Dimension",loc:this.getLocation(e,this.tokenStart),value:t,unit:this.substring(e+t.length,this.tokenStart)}}function No(e){this.token(ke,e.value+e.unit)}const Fo="Feature",Wo={kind:String,name:String,value:["Identifier","Number","Dimension","Ratio","Function",null]};function Ho(e){const t=this.tokenStart;let n,i=null;if(this.eat(Le),this.skipSC(),n=this.consume(he),this.skipSC(),this.tokenType!==ze){switch(this.eat(Ae),this.skipSC(),this.tokenType){case ve:i=this.lookupNonWSType(1)===ye?this.Ratio():this.Number();break;case ke:i=this.Dimension();break;case he:i=this.Identifier();break;case ue:i=this.parseWithFallback(()=>{const e=this.Function(this.readSequence,this.scope.Value);return this.skipSC(),this.isDelim(47)&&this.error(),e},()=>this.Ratio());break;default:this.error("Number, dimension, ratio or identifier is expected")}this.skipSC()}return this.eof||this.eat(ze),{type:"Feature",loc:this.getLocation(t,this.tokenStart),kind:e,name:n,value:i}}function qo(e){this.token(Le,"("),this.token(he,e.name),null!==e.value&&(this.token(Ae,":"),this.node(e.value)),this.token(ze,")")}const Vo="FeatureFunction",jo={kind:String,feature:String,value:["Declaration","Selector"]};function Ko(e,t){const n=(this.features[e]||{})[t];return"function"!=typeof n&&this.error(`Unknown feature ${t}()`),n}function _o(e="unknown"){const t=this.tokenStart,n=this.consumeFunctionName(),i=Ko.call(this,e,n.toLowerCase());this.skipSC();const r=this.parseWithFallback(()=>{const e=this.tokenIndex,t=i.call(this);return!1===this.eof&&!1===this.isBalanceEdge(e)&&this.error(),t},()=>this.Raw(null,!1));return this.eof||this.eat(ze),{type:"FeatureFunction",loc:this.getLocation(t,this.tokenStart),kind:e,feature:n,value:r}}function Uo(e){this.token(ue,e.feature+"("),this.node(e.value),this.token(ze,")")}const $o="FeatureRange",Yo={kind:String,left:["Identifier","Number","Dimension","Ratio","Function"],leftComparison:String,middle:["Identifier","Number","Dimension","Ratio","Function"],rightComparison:[String,null],right:["Identifier","Number","Dimension","Ratio","Function",null]};function Go(){switch(this.skipSC(),this.tokenType){case ve:return this.isDelim(47,this.lookupOffsetNonSC(1))?this.Ratio():this.Number();case ke:return this.Dimension();case he:return this.Identifier();case ue:return this.parseWithFallback(()=>{const e=this.Function(this.readSequence,this.scope.Value);return this.skipSC(),this.isDelim(47)&&this.error(),e},()=>this.Ratio());default:this.error("Number, dimension, ratio or identifier is expected")}}function Xo(e){if(this.skipSC(),this.isDelim(60)||this.isDelim(62)){const e=this.source[this.tokenStart];return this.next(),this.isDelim(61)?(this.next(),e+"="):e}if(this.isDelim(61))return"=";this.error(`Expected ${e?'":", ':""}"<", ">", "=" or ")"`)}function Jo(e="unknown"){const t=this.tokenStart;this.skipSC(),this.eat(Le);const n=Go.call(this),i=Xo.call(this,"Identifier"===n.type),r=Go.call(this);let o=null,s=null;return this.lookupNonWSType(0)!==ze&&(o=Xo.call(this),s=Go.call(this)),this.skipSC(),this.eat(ze),{type:"FeatureRange",loc:this.getLocation(t,this.tokenStart),kind:e,left:n,leftComparison:i,middle:r,rightComparison:o,right:s}}function Zo(e){this.token(Le,"("),this.node(e.left),this.tokenize(e.leftComparison),this.node(e.middle),e.right&&(this.tokenize(e.rightComparison),this.node(e.right)),this.token(ze,")")}const Qo="Function",es="function",ts={name:String,children:[[]]};function ns(e,t){const n=this.tokenStart,i=this.consumeFunctionName(),r=i.toLowerCase();let o;return o=t.hasOwnProperty(r)?t[r].call(this,t):e.call(this,t),this.eof||this.eat(ze),{type:"Function",loc:this.getLocation(n,this.tokenStart),name:i,children:o}}function is(e){this.token(ue,e.name+"("),this.children(e),this.token(ze,")")}const rs="GeneralEnclosed",os={kind:String,function:[String,null],children:[[]]};function ss(e){const t=this.tokenStart;let n=null;this.tokenType===ue?n=this.consumeFunctionName():this.eat(Le);const i=this.parseWithFallback(()=>{const e=this.tokenIndex,t=this.readSequence(this.scope.Value);return!1===this.eof&&!1===this.isBalanceEdge(e)&&this.error(),t},()=>this.createSingleNodeList(this.Raw(null,!1)));return this.eof||this.eat(ze),{type:"GeneralEnclosed",loc:this.getLocation(t,this.tokenStart),kind:e,function:n,children:i}}function as(e){e.function?this.token(ue,e.function+"("):this.token(Le,"("),this.children(e),this.token(ze,")")}const ls="XXX",cs="Hash",hs={value:String};function us(){const e=this.tokenStart;return this.eat(fe),{type:"Hash",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e+1)}}function ds(e){this.token(fe,"#"+e.value)}const fs="Identifier",ps={name:String};function ms(){return{type:"Identifier",loc:this.getLocation(this.tokenStart,this.tokenEnd),name:this.consume(he)}}function gs(e){this.token(he,e.name)}const bs="IdSelector",ys={name:String};function vs(){const e=this.tokenStart;return this.eat(fe),{type:"IdSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e+1)}}function ws(e){this.token(ye,"#"+e.name)}const ks="Layer",xs={name:String};function Ss(){let e=this.tokenStart,t=this.consume(he);for(;this.isDelim(46);)this.eat(ye),t+="."+this.consume(he);return{type:"Layer",loc:this.getLocation(e,this.tokenStart),name:t}}function Cs(e){this.tokenize(e.name)}const As="LayerList",Ms={children:[["Layer"]]};function Ts(){const e=this.createList();for(this.skipSC();!this.eof&&(e.push(this.Layer()),this.lookupTypeNonSC(0)===Te);)this.skipSC(),this.next(),this.skipSC();return{type:"LayerList",loc:this.getLocationFromList(e),children:e}}function Os(e){this.children(e,()=>this.token(Te,","))}const Ds="MediaQuery",Ls={modifier:[String,null],mediaType:[String,null],condition:["Condition",null]};function zs(){const e=this.tokenStart;let t=null,n=null,i=null;if(this.skipSC(),this.tokenType===he&&this.lookupTypeNonSC(1)!==Le){const e=this.consume(he),r=e.toLowerCase();switch("not"===r||"only"===r?(this.skipSC(),t=r,n=this.consume(he)):n=e,this.lookupTypeNonSC(0)){case he:this.skipSC(),this.eatIdent("and"),i=this.Condition("media");break;case Ee:case Me:case Te:case ce:break;default:this.error("Identifier or parenthesis is expected")}}else switch(this.tokenType){case he:case Le:case ue:i=this.Condition("media");break;case Ee:case Me:case ce:break;default:this.error("Identifier or parenthesis is expected")}return{type:"MediaQuery",loc:this.getLocation(e,this.tokenStart),modifier:t,mediaType:n,condition:i}}function Es(e){e.mediaType?(e.modifier&&this.token(he,e.modifier),this.token(he,e.mediaType),e.condition&&(this.token(he,"and"),this.node(e.condition))):e.condition&&this.node(e.condition)}const Bs="MediaQueryList",Rs={children:[["MediaQuery"]]};function Ps(){const e=this.createList();for(this.skipSC();!this.eof&&(e.push(this.MediaQuery()),this.tokenType===Te);)this.next();return{type:"MediaQueryList",loc:this.getLocationFromList(e),children:e}}function Is(e){this.children(e,()=>this.token(Te,","))}const Ns="NestingSelector",Fs={};function Ws(){const e=this.tokenStart;return this.eatDelim(38),{type:"NestingSelector",loc:this.getLocation(e,this.tokenStart)}}function Hs(){this.token(ye,"&")}const qs="Nth",Vs={nth:["AnPlusB","Identifier"],selector:["SelectorList",null]};function js(){this.skipSC();const e=this.tokenStart;let t,n=e,i=null;return t=this.lookupValue(0,"odd")||this.lookupValue(0,"even")?this.Identifier():this.AnPlusB(),n=this.tokenStart,this.skipSC(),this.lookupValue(0,"of")&&(this.next(),i=this.SelectorList(),n=this.tokenStart),{type:"Nth",loc:this.getLocation(e,n),nth:t,selector:i}}function Ks(e){this.node(e.nth),null!==e.selector&&(this.token(he,"of"),this.node(e.selector))}const _s="Number",Us={value:String};function $s(){return{type:"Number",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consume(ve)}}function Ys(e){this.token(ve,e.value)}const Gs="Operator",Xs={value:String};function Js(){const e=this.tokenStart;return this.next(),{type:"Operator",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function Zs(e){this.tokenize(e.value)}const Qs="Parentheses",ea={children:[[]]};function ta(e,t){const n=this.tokenStart;let i=null;return this.eat(Le),i=e.call(this,t),this.eof||this.eat(ze),{type:"Parentheses",loc:this.getLocation(n,this.tokenStart),children:i}}function na(e){this.token(Le,"("),this.children(e),this.token(ze,")")}const ia="Percentage",ra={value:String};function oa(){return{type:"Percentage",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consumeNumber(we)}}function sa(e){this.token(we,e.value+"%")}const aa="PseudoClassSelector",la="function",ca={name:String,children:[["Raw"],null]};function ha(){const e=this.tokenStart;let t,n,i=null;return this.eat(Ae),this.tokenType===ue?(t=this.consumeFunctionName(),n=t.toLowerCase(),this.lookupNonWSType(0)==ze?i=this.createList():hasOwnProperty.call(this.pseudo,n)?(this.skipSC(),i=this.pseudo[n].call(this),this.skipSC()):(i=this.createList(),i.push(this.Raw(null,!1))),this.eat(ze)):t=this.consume(he),{type:"PseudoClassSelector",loc:this.getLocation(e,this.tokenStart),name:t,children:i}}function ua(e){this.token(Ae,":"),null===e.children?this.token(he,e.name):(this.token(ue,e.name+"("),this.children(e),this.token(ze,")"))}const da="PseudoElementSelector",fa="function",pa={name:String,children:[["Raw"],null]};function ma(){const e=this.tokenStart;let t,n,i=null;return this.eat(Ae),this.eat(Ae),this.tokenType===ue?(t=this.consumeFunctionName(),n=t.toLowerCase(),this.lookupNonWSType(0)==ze?i=this.createList():hasOwnProperty.call(this.pseudo,n)?(this.skipSC(),i=this.pseudo[n].call(this),this.skipSC()):(i=this.createList(),i.push(this.Raw(null,!1))),this.eat(ze)):t=this.consume(he),{type:"PseudoElementSelector",loc:this.getLocation(e,this.tokenStart),name:t,children:i}}function ga(e){this.token(Ae,":"),this.token(Ae,":"),null===e.children?this.token(he,e.name):(this.token(ue,e.name+"("),this.children(e),this.token(ze,")"))}function ba(){switch(this.skipSC(),this.tokenType){case ve:return this.Number();case ue:return this.Function(this.readSequence,this.scope.Value);default:this.error("Number of function is expected")}}const ya="Ratio",va={left:["Number","Function"],right:["Number","Function",null]};function wa(){const e=this.tokenStart,t=ba.call(this);let n=null;return this.skipSC(),this.isDelim(47)&&(this.eatDelim(47),n=ba.call(this)),{type:"Ratio",loc:this.getLocation(e,this.tokenStart),left:t,right:n}}function ka(e){this.node(e.left),this.token(ye,"/"),e.right?this.node(e.right):this.node(ve,1)}function xa(){return this.tokenIndex>0&&this.lookupType(-1)===xe?this.tokenIndex>1?this.getTokenStart(this.tokenIndex-1):this.firstCharOffset:this.tokenStart}const Sa="Raw",Ca={value:String};function Aa(e,t){const n=this.getTokenStart(this.tokenIndex);let i;return this.skipUntilBalanced(this.tokenIndex,e||this.consumeUntilBalanceEnd),i=t&&this.tokenStart>n?xa.call(this):this.tokenStart,{type:"Raw",loc:this.getLocation(n,i),value:this.substring(n,i)}}function Ma(e){this.tokenize(e.value)}function Ta(){return this.Raw(this.consumeUntilLeftCurlyBracket,!0)}function Oa(){const e=this.SelectorList();return"Raw"!==e.type&&!1===this.eof&&this.tokenType!==Ee&&this.error(),e}const Da="Rule",La="rule",za={prelude:["SelectorList","Raw"],block:["Block"]};function Ea(){const e=this.tokenIndex,t=this.tokenStart;let n,i;return n=this.parseRulePrelude?this.parseWithFallback(Oa,Ta):Ta.call(this,e),i=this.Block(!0),{type:"Rule",loc:this.getLocation(t,this.tokenStart),prelude:n,block:i}}function Ba(e){this.node(e.prelude),this.node(e.block)}const Ra="Scope",Pa={root:["SelectorList","Raw",null],limit:["SelectorList","Raw",null]};function Ia(){let e=null,t=null;this.skipSC();const n=this.tokenStart;return this.tokenType===Le&&(this.next(),this.skipSC(),e=this.parseWithFallback(this.SelectorList,()=>this.Raw(!1,!0)),this.skipSC(),this.eat(ze)),this.lookupNonWSType(0)===he&&(this.skipSC(),this.eatIdent("to"),this.skipSC(),this.eat(Le),this.skipSC(),t=this.parseWithFallback(this.SelectorList,()=>this.Raw(!1,!0)),this.skipSC(),this.eat(ze)),{type:"Scope",loc:this.getLocation(n,this.tokenStart),root:e,limit:t}}function Na(e){e.root&&(this.token(Le,"("),this.node(e.root),this.token(ze,")")),e.limit&&(this.token(he,"to"),this.token(Le,"("),this.node(e.limit),this.token(ze,")"))}const Fa="Selector",Wa={children:[["TypeSelector","IdSelector","ClassSelector","AttributeSelector","PseudoClassSelector","PseudoElementSelector","Combinator"]]};function Ha(){const e=this.readSequence(this.scope.Selector);return null===this.getFirstListNode(e)&&this.error("Selector is expected"),{type:"Selector",loc:this.getLocationFromList(e),children:e}}function qa(e){this.children(e)}const Va="SelectorList",ja="selector",Ka={children:[["Selector","Raw"]]};function _a(){const e=this.createList();for(;!this.eof&&(e.push(this.Selector()),this.tokenType===Te);)this.next();return{type:"SelectorList",loc:this.getLocationFromList(e),children:e}}function Ua(e){this.children(e,()=>this.token(Te,","))}function $a(e){const t=e.length,n=e.charCodeAt(0),i=34===n||39===n?1:0,r=1===i&&t>1&&e.charCodeAt(t-1)===n?t-2:t-1;let o="";for(let n=i;n<=r;n++){let i=e.charCodeAt(n);if(92===i){if(n===r){n!==t-1&&(o=e.substr(n+1));break}if(i=e.charCodeAt(++n),je(92,i)){const t=n-1,i=tt(e,t);n=i-1,o+=ot(e.substring(t+1,i))}else 13===i&&10===e.charCodeAt(n+1)&&n++}else o+=e[n]}return o}function Ya(e,t){const n=t?"'":'"',i=t?39:34;let r="",o=!1;for(let t=0;t6&&this.error("Too many hex digits",i)}return this.next(),n}function ml(e){let t=0;for(;this.isDelim(63);)++t>e&&this.error("Too many question marks"),this.next()}function gl(e){this.charCodeAt(this.tokenStart)!==e&&this.error((43===e?"Plus sign":"Hyphen minus")+" is expected")}function bl(){let e=0;switch(this.tokenType){case ve:if(e=pl.call(this,1,!0),this.isDelim(63)){ml.call(this,6-e);break}if(this.tokenType===ke||this.tokenType===ve){gl.call(this,45),pl.call(this,1,!1);break}break;case ke:e=pl.call(this,1,!0),e>0&&ml.call(this,6-e);break;default:if(this.eatDelim(43),this.tokenType===he){e=pl.call(this,0,!0),e>0&&ml.call(this,6-e);break}if(this.isDelim(63)){this.next(),ml.call(this,5);break}this.error("Hex digit or question mark is expected")}}const yl="UnicodeRange",vl={value:String};function wl(){const e=this.tokenStart;return this.eatIdent("u"),bl.call(this),{type:"UnicodeRange",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function kl(e){this.tokenize(e.value)}function xl(e){const t=e.length;let n=4,i=41===e.charCodeAt(t-1)?t-2:t-1,r="";for(;n )","absolute-size":"xx-small|x-small|small|medium|large|x-large|xx-large|xxx-large","acos()":"acos( )","alpha-value":"|","an+b":"odd|even|||'+'? † n|-n||'+'? † || |'+'? † n |-n | |'+'? † n- |-n- | ['+'|'-'] |'+'? † n ['+'|'-'] |-n ['+'|'-'] ","anchor()":"anchor( ?&& , ? )","anchor-name":"","anchor-side":"inside|outside|top|left|right|bottom|start|end|self-start|self-end||center","anchor-size":"width|height|block|inline|self-block|self-inline","anchor-size()":"anchor-size( [||]? , ? )","angle-percentage":"|","angular-color-hint":"|","angular-color-stop":" ?","angular-color-stop-list":" , [? , ]#?","animateable-feature":"scroll-position|contents|","animation-action":"none|play|play-once|play-forwards|play-backwards|pause|reset|replay","asin()":"asin( )","atan()":"atan( )","atan2()":"atan2( , )",attachment:"scroll|fixed|local","attr()":"attr( ? , ? )","attr-matcher":"['~'|'|'|'^'|'$'|'*']? '='","attr-modifier":"i|s","attr-type":"type( )|raw-string|number|","attribute-selector":"'[' ']'|'[' [|] ? ']'","auto-repeat":"repeat( [auto-fill|auto-fit] , [? ]+ ? )","auto-track-list":"[? [|]]* ? [? [|]]* ?",axis:"block|inline|x|y","baseline-position":"[first|last]? baseline","basic-shape":"||||||","basic-shape-rect":"||","bg-clip":"|border-area|text","bg-image":"|none","bg-layer":"|| [/ ]?||||||||","bg-position":"[[left|center|right|top|bottom|]|[left|center|right|] [top|center|bottom|]|[center|[left|right] ?]&&[center|[top|bottom] ?]]","bg-size":"[|auto]{1,2}|cover|contain","blend-mode":"normal|multiply|screen|overlay|darken|lighten|color-dodge|color-burn|hard-light|soft-light|difference|exclusion|hue|saturation|color|luminosity","blur()":"blur( ? )","brightness()":"brightness( [|]? )","calc()":"calc( )","calc-constant":"e|pi|infinity|-infinity|NaN","calc-product":" ['*' |'/' ]*","calc-size()":"calc-size( , )","calc-size-basis":"||any|","calc-sum":" [['+'|'-'] ]*","calc-value":"||||( )","cf-final-image":"|","cf-mixing-image":"?&&","circle()":"circle( ? [at ]? )","clamp()":"clamp( #{3} )","class-selector":"'.' ","clip-source":"",color:"|currentColor||||<-non-standard-color>","color()":"color( [/ [|none]]? )","color-base":"||||transparent","color-function":"|||||||||","color-interpolation-method":"in [| ?|]","color-mix()":"color-mix( , [&&?]#{2} )","color-stop":"|","color-stop-angle":"[|]{1,2}","color-stop-length":"{1,2}","color-stop-list":" , [? , ]#?","colorspace-params":"[|]",combinator:"'>'|'+'|'~'|['|' '|']","common-lig-values":"[common-ligatures|no-common-ligatures]","compat-auto":"searchfield|textarea|checkbox|radio|menulist|listbox|meter|progress-bar|button","compat-special":"textfield|menulist-button","complex-selector":" [? ]*","complex-selector-list":"#","composite-style":"clear|copy|source-over|source-in|source-out|source-atop|destination-over|destination-in|destination-out|destination-atop|xor","compositing-operator":"add|subtract|intersect|exclude","compound-selector":"[? *]!","compound-selector-list":"#","conic-gradient()":"conic-gradient( [] )","conic-gradient-syntax":"[[[from [|]]? [at ]?]||]? , ","container-condition":"not | [[and ]*|[or ]*]","container-name":"","container-query":"not | [[and ]*|[or ]*]","content-distribution":"space-between|space-around|space-evenly|stretch","content-list":"[|contents||||||]+","content-position":"center|start|end|flex-start|flex-end","content-replacement":"","contextual-alt-values":"[contextual|no-contextual]","contrast()":"contrast( [|]? )","coord-box":"content-box|padding-box|border-box|fill-box|stroke-box|view-box","corner-shape-value":"round|scoop|bevel|notch|square|squircle|","cos()":"cos( )",counter:"|","counter()":"counter( , ? )","counter-name":"","counter-style":"|symbols( )","counter-style-name":"","counters()":"counters( , , ? )","cross-fade()":"cross-fade( , ? )","cubic-bezier()":"cubic-bezier( [ , ]#{2} )","cubic-bezier-easing-function":"ease|ease-in|ease-out|ease-in-out|cubic-bezier( , , , )","cursor-predefined":"auto|default|none|context-menu|help|pointer|progress|wait|cell|crosshair|text|vertical-text|alias|copy|move|no-drop|not-allowed|e-resize|n-resize|ne-resize|nw-resize|s-resize|se-resize|sw-resize|w-resize|ew-resize|ns-resize|nesw-resize|nwse-resize|col-resize|row-resize|all-scroll|zoom-in|zoom-out|grab|grabbing","custom-color-space":"","custom-params":" [||none]+",dasharray:"[[|]+]#","dashndashdigit-ident":"","deprecated-system-color":"ActiveBorder|ActiveCaption|AppWorkspace|Background|ButtonHighlight|ButtonShadow|CaptionText|InactiveBorder|InactiveCaption|InactiveCaptionText|InfoBackground|InfoText|Menu|MenuText|Scrollbar|ThreeDDarkShadow|ThreeDFace|ThreeDHighlight|ThreeDLightShadow|ThreeDShadow|Window|WindowFrame|WindowText","discretionary-lig-values":"[discretionary-ligatures|no-discretionary-ligatures]","display-box":"contents|none","display-inside":"flow|flow-root|table|flex|grid|ruby","display-internal":"table-row-group|table-header-group|table-footer-group|table-row|table-cell|table-column-group|table-column|table-caption|ruby-base|ruby-text|ruby-base-container|ruby-text-container","display-legacy":"inline-block|inline-list-item|inline-table|inline-flex|inline-grid","display-listitem":"?&&[flow|flow-root]?&&list-item","display-outside":"block|inline|run-in","drop-shadow()":"drop-shadow( [?&&{2,3}] )","dynamic-range-limit-mix()":"dynamic-range-limit-mix( [<'dynamic-range-limit'>&&]#{2,} )","easing-function":"||","east-asian-variant-values":"[jis78|jis83|jis90|jis04|simplified|traditional]","east-asian-width-values":"[full-width|proportional-width]","element()":"element( , [first|start|last|first-except]? )|element( )","ellipse()":"ellipse( ? [at ]? )","env()":"env( , ? )","exp()":"exp( )","explicit-track-list":"[? ]+ ?","family-name":"|+","feature-tag-value":" [|on|off]?","feature-type":"@stylistic|@historical-forms|@styleset|@character-variant|@swash|@ornaments|@annotation","feature-value-block":" '{' '}'","feature-value-block-list":"+","feature-value-declaration":" : + ;","feature-value-declaration-list":"","feature-value-name":"","filter-function":"|||||||||","filter-value-list":"[|]+","final-bg-layer":"|| [/ ]?||||||||||<'background-color'>","fit-content()":"fit-content( )","fixed-breadth":"","fixed-repeat":"repeat( [] , [? ]+ ? )","fixed-size":"|minmax( , )|minmax( , )","font-stretch-absolute":"normal|ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded|","font-variant-css2":"normal|small-caps","font-weight-absolute":"normal|bold|","font-width-css3":"normal|ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded","form-control-identifier":"select","frequency-percentage":"|","generic-complete":"serif|sans-serif|system-ui|cursive|fantasy|math|monospace","general-enclosed":"[ ? )]|[( ? )]","generic-family":"|||<-non-standard-generic-family>","generic-incomplete":"ui-serif|ui-sans-serif|ui-monospace|ui-rounded","geometry-box":"|fill-box|stroke-box|view-box",gradient:"||||||<-legacy-gradient>","grayscale()":"grayscale( [|]? )","grid-line":"auto||[&&?]|[span&&[||]]","historical-lig-values":"[historical-ligatures|no-historical-ligatures]","hsl()":"hsl( , , , ? )|hsl( [|none] [||none] [||none] [/ [|none]]? )","hsla()":"hsla( , , , ? )|hsla( [|none] [||none] [||none] [/ [|none]]? )",hue:"|","hue-interpolation-method":"[shorter|longer|increasing|decreasing] hue","hue-rotate()":"hue-rotate( [|]? )","hwb()":"hwb( [|none] [||none] [||none] [/ [|none]]? )","hypot()":"hypot( # )",image:"||||||","image()":"image( ? [? , ?]! )","image-set()":"image-set( # )","image-set-option":"[|] [||type( )]","image-src":"|","image-tags":"ltr|rtl","inflexible-breadth":"|min-content|max-content|auto","inset()":"inset( {1,4} [round <'border-radius'>]? )","invert()":"invert( [|]? )","keyframe-block":"# { }","keyframe-selector":"from|to|| ","keyframes-name":"|","lab()":"lab( [||none] [||none] [||none] [/ [|none]]? )","layer()":"layer( )","layer-name":" ['.' ]*","lch()":"lch( [||none] [||none] [|none] [/ [|none]]? )","leader()":"leader( )","leader-type":"dotted|solid|space|","length-percentage":"|","light-dark()":"light-dark( , )","line-name-list":"[|]+","line-names":"'[' * ']'","line-style":"none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset","line-width":"|thin|medium|thick","linear()":"linear( [&&{0,2}]# )","linear-color-hint":"","linear-color-stop":" ?","linear-easing-function":"linear|","linear-gradient()":"linear-gradient( [] )","linear-gradient-syntax":"[[||to ]||]? , ","log()":"log( , ? )","mask-layer":"|| [/ ]?||||||[|no-clip]||||","mask-position":"[|left|center|right] [|top|center|bottom]?","mask-reference":"none||","mask-source":"","masking-mode":"alpha|luminance|match-source","matrix()":"matrix( #{6} )","matrix3d()":"matrix3d( #{16} )","max()":"max( # )","media-and":" [and ]+","media-condition":"|||","media-condition-without-or":"||","media-feature":"( [||] )","media-in-parens":"( )||","media-not":"not ","media-or":" [or ]+","media-query":"|[not|only]? [and ]?","media-query-list":"#","media-type":"","mf-boolean":"","mf-name":"","mf-plain":" : ","mf-range":" ['<'|'>']? '='? | ['<'|'>']? '='? | '<' '='? '<' '='? | '>' '='? '>' '='? ","mf-value":"|||","min()":"min( # )","minmax()":"minmax( [|min-content|max-content|auto] , [||min-content|max-content|auto] )","mod()":"mod( , )","n-dimension":"","name-repeat":"repeat( [|auto-fill] , + )","named-color":"aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|rebeccapurple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen","namespace-prefix":"","ndash-dimension":"","ndashdigit-dimension":"","ndashdigit-ident":"","ns-prefix":"[|'*']? '|'","number-percentage":"|","numeric-figure-values":"[lining-nums|oldstyle-nums]","numeric-fraction-values":"[diagonal-fractions|stacked-fractions]","numeric-spacing-values":"[proportional-nums|tabular-nums]","offset-path":"||","oklab()":"oklab( [||none] [||none] [||none] [/ [|none]]? )","oklch()":"oklch( [||none] [||none] [|none] [/ [|none]]? )","opacity()":"opacity( [|]? )","opacity-value":"|","outline-line-style":"none|dotted|dashed|solid|double|groove|ridge|inset|outset","outline-radius":"|","overflow-position":"unsafe|safe","page-body":"? [; ]?| ","page-margin-box":" '{' '}'","page-margin-box-type":"@top-left-corner|@top-left|@top-center|@top-right|@top-right-corner|@bottom-left-corner|@bottom-left|@bottom-center|@bottom-right|@bottom-right-corner|@left-top|@left-middle|@left-bottom|@right-top|@right-middle|@right-bottom","page-selector":"+| *","page-selector-list":"[#]?","page-size":"A5|A4|A3|B5|B4|JIS-B5|JIS-B4|letter|legal|ledger",paint:"none|| [none|]?|context-fill|context-stroke","paint()":"paint( , ? )","paint-box":"|fill-box|stroke-box","palette-identifier":"","palette-mix()":"palette-mix( , [[normal|light|dark||]&&?]#{2} )","path()":"path( <'fill-rule'>? , )","perspective()":"perspective( [|none] )","polar-color-space":"hsl|hwb|lch|oklch","polygon()":"polygon( <'fill-rule'>? , [ ]# )",position:"[[left|center|right]||[top|center|bottom]|[left|center|right|] [top|center|bottom|]?|[[left|right] ]&&[[top|bottom] ]]","position-area":"[[left|center|right|span-left|span-right|x-start|x-end|span-x-start|span-x-end|x-self-start|x-self-end|span-x-self-start|span-x-self-end|span-all]||[top|center|bottom|span-top|span-bottom|y-start|y-end|span-y-start|span-y-end|y-self-start|y-self-end|span-y-self-start|span-y-self-end|span-all]|[block-start|center|block-end|span-block-start|span-block-end|span-all]||[inline-start|center|inline-end|span-inline-start|span-inline-end|span-all]|[self-block-start|center|self-block-end|span-self-block-start|span-self-block-end|span-all]||[self-inline-start|center|self-inline-end|span-self-inline-start|span-self-inline-end|span-all]|[start|center|end|span-start|span-end|span-all]{1,2}|[self-start|center|self-end|span-self-start|span-self-end|span-all]{1,2}]","pow()":"pow( , )","predefined-rgb":"srgb|srgb-linear|display-p3|display-p3-linear|a98-rgb|prophoto-rgb|rec2020","predefined-rgb-params":" [||none]{3}","pseudo-class-selector":"':' |':' ')'","pseudo-element-selector":"':' |","pseudo-page":": [left|right|first|blank]","query-in-parens":"( )|( )|style( )|",quote:"open-quote|close-quote|no-open-quote|no-close-quote","radial-extent":"closest-corner|closest-side|farthest-corner|farthest-side","radial-gradient()":"radial-gradient( [] )","radial-gradient-syntax":"[[[||]? [at ]?]||]? , ","radial-shape":"circle|ellipse","radial-size":"||{2}",ratio:" [/ ]?","ray()":"ray( &&?&&contain?&&[at ]? )","ray-size":"closest-side|closest-corner|farthest-side|farthest-corner|sides","rect()":"rect( [|auto]{4} [round <'border-radius'>]? )","rectangular-color-space":"srgb|srgb-linear|display-p3|display-p3-linear|a98-rgb|prophoto-rgb|rec2020|lab|oklab|xyz|xyz-d50|xyz-d65","relative-selector":"? ","relative-selector-list":"#","relative-size":"larger|smaller","rem()":"rem( , )","repeat-style":"repeat-x|repeat-y|[repeat|space|round|no-repeat]{1,2}","repeating-conic-gradient()":"repeating-conic-gradient( [] )","repeating-linear-gradient()":"repeating-linear-gradient( [] )","repeating-radial-gradient()":"repeating-radial-gradient( [] )","reversed-counter-name":"reversed( )","rgb()":"rgb( #{3} , ? )|rgb( #{3} , ? )|rgb( [||none]{3} [/ [|none]]? )","rgba()":"rgba( #{3} , ? )|rgba( #{3} , ? )|rgba( [||none]{3} [/ [|none]]? )","rotate()":"rotate( [|] )","rotate3d()":"rotate3d( , , , [|] )","rotateX()":"rotateX( [|] )","rotateY()":"rotateY( [|] )","rotateZ()":"rotateZ( [|] )","round()":"round( ? , , )","rounding-strategy":"nearest|up|down|to-zero","saturate()":"saturate( [|]? )","scale()":"scale( [|]#{1,2} )","scale3d()":"scale3d( [|]#{3} )","scaleX()":"scaleX( [|] )","scaleY()":"scaleY( [|] )","scaleZ()":"scaleZ( [|] )","scope-end":"","scope-start":"","scroll()":"scroll( [||]? )",scroller:"root|nearest|self","scroll-state-feature":"","scroll-state-in-parens":"( )|( )|","scroll-state-query":"not | [[and ]*|[or ]*]|","selector-list":"","self-position":"center|start|end|self-start|self-end|flex-start|flex-end","sepia()":"sepia( [|]? )",shadow:"inset?&&{2,4}&&?","shadow-t":"[{2,3}&&?]",shape:"rect( , , , )|rect( )","shape-box":"|margin-box","side-or-corner":"[left|right]||[top|bottom]","sign()":"sign( )","signed-integer":"","signless-integer":"","sin()":"sin( )","single-animation":"<'animation-duration'>||||<'animation-delay'>||||||||||[none|]||","single-animation-composition":"replace|add|accumulate","single-animation-direction":"normal|reverse|alternate|alternate-reverse","single-animation-fill-mode":"none|forwards|backwards|both","single-animation-iteration-count":"infinite|","single-animation-play-state":"running|paused","single-animation-timeline":"auto|none|||","single-transition":"[none|]||