i.bottom)&&b==i.bottom-c.bottom>c.top-i.top&&(b=!b);let v=(b?c.top-i.top:i.bottom-c.bottom)-h;if(vy&&e.topw&&(w=b?e.top-p-2-h:e.bottom+h+2);"absolute"==this.position?(l.style.top=w-e.parent.top+"px",l.style.left=y-e.parent.left+"px"):(l.style.top=w+"px",l.style.left=y+"px"),f&&(f.style.left=c.left+(m?g.x:-g.x)-(y+14-7)+"px"),!0!==a.overlap&&r.push({left:y,top:w,right:x,bottom:w+p}),l.classList.toggle("cm-tooltip-above",b),l.classList.toggle("cm-tooltip-below",!b),a.positioned&&a.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=$o}},{eventHandlers:{scroll(){this.maybeMeasure()}}}),qo=Dr.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),zo={x:0,y:0},Lo=q.define({enables:[No,qo]}),Bo=q.define();class Qo{constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Mo(e,Bo,(e=>this.createHostedView(e)))}static create(e){return new Qo(e)}createHostedView(e){let t=e.create(this.view);return t.dom.classList.add("cm-tooltip-section"),this.dom.appendChild(t.dom),this.mounted&&t.mount&&t.mount(this.view),t}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)}}const Io=Lo.compute([Bo],(e=>{let t=e.facet(Bo).filter((e=>e));return 0===t.length?null:{pos:Math.min(...t.map((e=>e.pos))),end:Math.max(...t.filter((e=>null!=e.end)).map((e=>e.end))),create:Qo.create,above:t[0].above,arrow:t.some((e=>e.arrow))}}));class Wo{constructor(e,t,n,i,r){this.view=e,this.source=t,this.field=n,this.setHover=i,this.hoverTime=r,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(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout((()=>this.startHover()),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active)return;let e=Date.now()-this.lastMove.time;en.bottom||e.xn.right+this.view.defaultCharacterWidth)return;let i=this.view.bidiSpans(this.view.state.doc.lineAt(t)).find((e=>e.from<=t&&e.to>=t)),r=i&&i.dir==In.RTL?-1:1,o=this.source(this.view,t,e.x{this.pending==e&&(this.pending=null,t&&this.view.dispatch({effects:this.setHover.of(t)}))}),(e=>Tn(this.view.state,e,"hover tooltip")))}else o&&this.view.dispatch({effects:this.setHover.of(o)})}mousemove(e){var t;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 n=this.active;if(n&&!jo(this.lastMove.target)||this.pending){let{pos:i}=n||this.pending,r=null!==(t=null==n?void 0:n.end)&&void 0!==t?t:i;(i==r?this.view.posAtCoords(this.lastMove)==i:function(e,t,n,i,r,o){let s=document.createRange(),a=e.domAtPos(t),l=e.domAtPos(n);s.setEnd(l.node,l.offset),s.setStart(a.node,a.offset);let c=s.getClientRects();s.detach();for(let e=0;enull,update(e,i){if(e&&(t.hideOnChange&&(i.docChanged||i.selection)||t.hideOn&&t.hideOn(i,e)))return null;if(e&&i.docChanged){let t=i.changes.mapPos(e.pos,-1,S.TrackDel);if(null==t)return null;let n=Object.assign(Object.create(null),e);n.pos=t,null!=e.end&&(n.end=i.changes.mapPos(e.end)),e=n}for(let t of i.effects)t.is(n)&&(e=t.value),t.is(Xo)&&(e=null);return e},provide:e=>Bo.from(e)});return[i,Mn.define((r=>new Wo(r,e,i,n,t.hoverTime||300))),Io]}function Vo(e,t){let n=e.plugin(No);if(!n)return null;let i=n.manager.tooltips.indexOf(t);return i<0?null:n.manager.tooltipViews[i]}const Xo=de.define(),Yo=q.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 Ho(e,t){let n=e.plugin(Go),i=n?n.specs.indexOf(t):-1;return i>-1?n.panels[i]:null}const Go=Mn.fromClass(class{constructor(e){this.input=e.state.facet(Jo),this.specs=this.input.filter((e=>e)),this.panels=this.specs.map((t=>t(e)));let t=e.state.facet(Yo);this.top=new Zo(e,!0,t.topContainer),this.bottom=new Zo(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(Yo);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new Zo(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new Zo(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(Jo);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=>Dr.scrollMargins.of((t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}}))});class Zo{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",this.dom.style[this.top?"top":"bottom"]="0";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=Ko(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=Ko(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 Ko(e){let t=e.nextSibling;return e.remove(),t}const Jo=q.define({enables:Go});class es extends Te{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}es.prototype.elementClass="",es.prototype.toDOM=void 0,es.prototype.mapMode=S.TrackBefore,es.prototype.startSide=es.prototype.endSide=-1,es.prototype.point=!0;const ts=q.define(),ns={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>Me.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},is=q.define();function rs(e){return[ss(),is.of(Object.assign(Object.assign({},ns),e))]}const os=q.define({combine:e=>e.some((e=>e))});function ss(e){let t=[as];return e&&!1===e.fixed&&t.push(os.of(!0)),t}const as=Mn.fromClass(class{constructor(e){this.view=e,this.prevViewport=e.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight+"px",this.gutters=e.state.facet(is).map((t=>new fs(e,t)));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!e.state.facet(os),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}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))}e.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight+"px"),this.view.state.facet(os)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&this.dom.remove();let n=Me.iter(this.view.state.facet(ts),this.view.viewport.from),i=[],r=this.gutters.map((e=>new us(e,this.view.viewport,-this.view.documentPadding.top)));for(let e of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(e.type)){let t=!0;for(let o of e.type)if(o.type==rn.Text&&t){cs(n,i,o.from);for(let e of r)e.line(this.view,o,i);t=!1}else if(o.widget)for(let e of r)e.widget(this.view,o)}else if(e.type==rn.Text){cs(n,i,e.from);for(let t of r)t.line(this.view,e,i)}for(let e of r)e.finish();e&&this.view.scrollDOM.insertBefore(this.dom,t)}updateGutters(e){let t=e.startState.facet(is),n=e.state.facet(is),i=e.docChanged||e.heightChanged||e.viewportChanged||!Me.eq(e.startState.facet(ts),e.state.facet(ts),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let t of this.gutters)t.update(e)&&(i=!0);else{i=!0;let r=[];for(let i of n){let n=t.indexOf(i);n<0?r.push(new fs(this.view,i)):(this.gutters[n].update(e),r.push(this.gutters[n]))}for(let e of this.gutters)e.dom.remove(),r.indexOf(e)<0&&e.destroy();for(let e of r)this.dom.appendChild(e.dom);this.gutters=r}return i}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove()}},{provide:e=>Dr.scrollMargins.of((t=>{let n=t.plugin(e);return n&&0!=n.gutters.length&&n.fixed?t.textDirection==In.LTR?{left:n.dom.offsetWidth}:{right:n.dom.offsetWidth}:null}))});function ls(e){return Array.isArray(e)?e:[e]}function cs(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class us{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=Me.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:i}=this,r=t.top-this.height;if(this.i==i.elements.length){let o=new hs(e,t.height,r,n);i.elements.push(o),i.dom.appendChild(o.dom)}else i.elements[this.i].update(e,t.height,r,n);this.height=t.bottom,this.i++}line(e,t,n){let i=[];cs(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);n&&this.addElement(e,t,[n])}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class fs{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=ls(t.markers(e)),t.initialSpacer&&(this.spacer=new hs(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=ls(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!Me.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 hs{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.dom.style.height=(this.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;nAe(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 gs extends es{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function ms(e,t){return e.state.facet(ps).formatNumber(t,e.state)}const ys=is.compute([ps],(e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:e=>e.state.facet(ds),lineMarker:(e,t,n)=>n.some((e=>e.toDOM))?null:new gs(ms(e,e.state.doc.lineAt(t.from).number)),widgetMarker:()=>null,lineMarkerChange:e=>e.startState.facet(ps)!=e.state.facet(ps),initialSpacer:e=>new gs(ms(e,vs(e.state.doc.lines))),updateSpacer(e,t){let n=ms(t.view,vs(t.view.state.doc.lines));return n==e.number?e:new gs(n)},domEventHandlers:e.facet(ps).domEventHandlers})));function bs(e={}){return[ps.of(e),ss(),ys]}function vs(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(ws.range(r)))}return Me.of(t)}));const _s=1024;let Os=0;class Ss{constructor(e,t){this.from=e,this.to=t}}class ks{constructor(e={}){this.id=Os++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof e&&(e=Ts.match(e)),t=>{let n=e(t);return void 0===n?null:[this,n]}}}ks.closedBy=new ks({deserialize:e=>e.split(" ")}),ks.openedBy=new ks({deserialize:e=>e.split(" ")}),ks.group=new ks({deserialize:e=>e.split(" ")}),ks.contextHash=new ks({perNode:!0}),ks.lookAhead=new ks({perNode:!0}),ks.mounted=new ks({perNode:!0});const As=Object.create(null);class Ts{constructor(e,t,n,i=0){this.name=e,this.props=t,this.id=n,this.flags=i}static define(e){let t=e.props&&e.props.length?Object.create(null):As,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(null==e.name?8:0),i=new Ts(e.name||"",t,e.id,n);if(e.props)for(let n of e.props)if(Array.isArray(n)||(n=n(i)),n){if(n[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[n[0].id]=n[1]}return i}prop(e){return this.props[e.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(e){if("string"==typeof e){if(this.name==e)return!0;let t=this.prop(ks.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let i of n.split(" "))t[i]=e[n];return e=>{for(let n=e.prop(ks.group),i=-1;i<(n?n.length:0);i++){let r=t[i<0?e.name:n[i]];if(r)return r}}}}Ts.none=new Ts("",Object.create(null),0,8);class Es{constructor(e){this.types=e;for(let t=0;t0;for(let e=this.cursor(o|Ms.IncludeAnonymous);;){let o=!1;if(e.from<=r&&e.to>=i&&(!s&&e.type.isAnonymous||!1!==t(e))){if(e.firstChild())continue;o=!0}for(;o&&n&&(s||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;o=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Xs(Ts.none,this.children,this.positions,0,this.children.length,0,this.length,((e,t,n)=>new Ds(this.type,e,t,n,this.propValues)),e.makeTree||((e,t,n)=>new Ds(Ts.none,e,t,n)))}static build(e){return function(e){var t;let{buffer:n,nodeSet:i,maxBufferLength:r=_s,reused:o=[],minRepeatType:s=i.types.length}=e,a=Array.isArray(n)?new Ps(n,n.length):n,l=i.types,c=0,u=0;function f(e,t,n,y,b){let{id:v,start:w,end:x,size:_}=a,O=u;for(;_<0;){if(a.next(),-1==_){let t=o[v];return n.push(t),void y.push(w-e)}if(-3==_)return void(c=v);if(-4==_)return void(u=v);throw new RangeError(`Unrecognized record size: ${_}`)}let S,k,A=l[v],T=w-e;if(x-w<=r&&(k=g(a.pos-t,b))){let t=new Uint16Array(k.size-k.skip),n=a.pos-k.size,r=t.length;for(;a.pos>n;)r=m(k.start,t,r);S=new Rs(t,x-k.start,i),T=k.start-e}else{let e=a.pos-_;a.next();let t=[],n=[],i=v>=s?v:-1,o=0,l=x;for(;a.pos>e;)i>=0&&a.id==i&&a.size>=0?(a.end<=l-r&&(d(t,n,w,o,a.end,l,i,O),o=t.length,l=a.end),a.next()):f(w,e,t,n,i);if(i>=0&&o>0&&o-1&&o>0){let e=h(A);S=Xs(A,t,n,0,t.length,0,x-w,e,e)}else S=p(A,t,n,x-w,O-x)}n.push(S),y.push(T)}function h(e){return(t,n,i)=>{let r,o,s=0,a=t.length-1;if(a>=0&&(r=t[a])instanceof Ds){if(!a&&r.type==e&&r.length==i)return r;(o=r.prop(ks.lookAhead))&&(s=n[a]+r.length+o)}return p(e,t,n,i,s)}}function d(e,t,n,r,o,s,a,l){let c=[],u=[];for(;e.length>r;)c.push(e.pop()),u.push(t.pop()+n-o);e.push(p(i.types[a],c,u,s-o,l-s)),t.push(o-n)}function p(e,t,n,i,r=0,o){if(c){let e=[ks.contextHash,c];o=o?[e].concat(o):[e]}if(r>25){let e=[ks.lookAhead,r];o=o?[e].concat(o):[e]}return new Ds(e,t,n,i,o)}function g(e,t){let n=a.fork(),i=0,o=0,l=0,c=n.end-r,u={size:0,start:0,skip:0};e:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){u.size=i,u.start=o,u.skip=l,l+=4,i+=4,n.next();continue}let a=n.pos-e;if(e<0||a=s?4:0,h=n.start;for(n.next();n.pos>a;){if(n.size<0){if(-3!=n.size)break e;f+=4}else n.id>=s&&(f+=4);n.next()}o=h,i+=e,l+=f}return(t<0||i==e)&&(u.size=i,u.start=o,u.skip=l),u.size>4?u:void 0}function m(e,t,n){let{id:i,start:r,end:o,size:l}=a;if(a.next(),l>=0&&i4){let i=a.pos-(l-4);for(;a.pos>i;)n=m(e,t,n)}t[--n]=s,t[--n]=o-e,t[--n]=r-e,t[--n]=i}else-3==l?c=i:-4==l&&(u=i);return n}let y=[],b=[];for(;a.pos>0;)f(e.start||0,e.bufferStart||0,y,b,-1);let v=null!==(t=e.length)&&void 0!==t?t:y.length?b[0]+y[0].length:0;return new Ds(l[e.topID],y.reverse(),b.reverse(),v)}(e)}}Ds.empty=new Ds(Ts.none,[],[],0);class Ps{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Ps(this.buffer,this.index)}}class Rs{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return Ts.none}toString(){let e=[];for(let t=0;t0));a=o[a+3]);return s}slice(e,t,n){let i=this.buffer,r=new Uint16Array(t-e),o=0;for(let s=e,a=0;s=t&&nt;case 1:return n<=t&&i>t;case 2:return i>t;case 4:return!0}}function Ns(e,t){let n=e.childBefore(t);for(;n;){let t=n.lastChild;if(!t||t.to!=n.to)break;t.type.isError&&t.from==t.to?(e=n,n=t.prevSibling):n=t}return e}function qs(e,t,n,i){for(var r;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to0?s.length:-1;e!=l;e+=t){let l=s[e],c=a[e]+o.from;if(Fs(i,n,c,c+l.length))if(l instanceof Rs){if(r&Ms.ExcludeBuffers)continue;let s=l.findChild(0,l.buffer.length,t,n-c,i);if(s>-1)return new Is(new Qs(o,l,e,c),null,s)}else if(r&Ms.IncludeAnonymous||!l.type.isAnonymous||js(l)){let s;if(!(r&Ms.IgnoreMounts)&&l.props&&(s=l.prop(ks.mounted))&&!s.overlay)return new zs(s.tree,c,e,o);let a=new zs(l,c,e,o);return r&Ms.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(t<0?l.children.length-1:0,t,n,i)}}if(r&Ms.IncludeAnonymous||!o.type.isAnonymous)return null;if(e=o.index>=0?o.index+t:t<0?-1:o._parent._tree.children.length,o=o._parent,!o)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,n=0){let i;if(!(n&Ms.IgnoreOverlays)&&(i=this._tree.prop(ks.mounted))&&i.overlay){let n=e-this.from;for(let{from:e,to:r}of i.overlay)if((t>0?e<=n:e=n:r>n))return new zs(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}cursor(e=0){return new Ws(this,e)}get tree(){return this._tree}toTree(){return this._tree}resolve(e,t=0){return qs(this,e,t,!1)}resolveInner(e,t=0){return qs(this,e,t,!0)}enterUnfinishedNodesBefore(e){return Ns(this,e)}getChild(e,t=null,n=null){let i=Ls(this,e,t,n);return i.length?i[0]:null}getChildren(e,t=null,n=null){return Ls(this,e,t,n)}toString(){return this._tree.toString()}get node(){return this}matchContext(e){return Bs(this,e)}}function Ls(e,t,n,i){let r=e.cursor(),o=[];if(!r.firstChild())return o;if(null!=n)for(;!r.type.is(n);)if(!r.nextSibling())return o;for(;;){if(null!=i&&r.type.is(i))return o;if(r.type.is(t)&&o.push(r.node),!r.nextSibling())return null==i?o:[]}}function Bs(e,t,n=t.length-1){for(let i=e.parent;n>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(t[n]&&t[n]!=i.name)return!1;n--}}return!0}class Qs{constructor(e,t,n,i){this.parent=e,this.buffer=t,this.index=n,this.start=i}}class Is{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:i}=this.context,r=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.context.start,n);return r<0?null:new Is(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,n=0){if(n&Ms.ExcludeBuffers)return null;let{buffer:i}=this.context,r=i.findChild(this.index+4,i.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new Is(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Is(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new Is(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}cursor(e=0){return new Ws(this,e)}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,i=this.index+4,r=n.buffer[this.index+3];if(r>i){let o=n.buffer[this.index+1];e.push(n.slice(i,r,o)),t.push(0)}return new Ds(this.type,e,t,this.to-this.from)}resolve(e,t=0){return qs(this,e,t,!1)}resolveInner(e,t=0){return qs(this,e,t,!0)}enterUnfinishedNodesBefore(e){return Ns(this,e)}toString(){return this.context.buffer.childString(this.index)}getChild(e,t=null,n=null){let i=Ls(this,e,t,n);return i.length?i[0]:null}getChildren(e,t=null,n=null){return Ls(this,e,t,n)}get node(){return this}matchContext(e){return Bs(this,e)}}class Ws{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof zs)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return!!e&&(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0)}yieldBuf(e,t){this.index=e;let{start:n,buffer:i}=this.buffer;return this.type=t||i.set.types[i.buffer[e]],this.from=n+i.buffer[e+1],this.to=n+i.buffer[e+2],!0}yield(e){return!!e&&(e instanceof zs?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:i}=this.buffer,r=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.buffer.start,n);return!(r<0)&&(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?!(n&Ms.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Ms.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Ms.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode));let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:i}=this;if(i){if(e>0){if(this.index-1)for(let i=t+e,r=e<0?-1:n._tree.children.length;i!=r;i+=e){let e=n._tree.children[i];if(this.mode&Ms.IncludeAnonymous||e instanceof Rs||!e.type.isAnonymous||js(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to=0;){for(let o=e;o;o=o._parent)if(o.index==i){if(i==this.index)return o;t=o,n=r+1;break e}i=this.stack[--r]}for(let e=n;e=0;r--){if(r<0)return Bs(this.node,e,i);let o=n[t.buffer[this.stack[r]]];if(!o.isAnonymous){if(e[i]&&e[i]!=o.name)return!1;i--}}return!0}}function js(e){return e.children.some((e=>e instanceof Rs||!e.type.isAnonymous||js(e)))}const Us=new WeakMap;function Vs(e,t){if(!e.isAnonymous||t instanceof Rs||t.type!=e)return 1;let n=Us.get(t);if(null==n){n=1;for(let i of t.children){if(i.type!=e||!(i instanceof Ds)){n=1;break}n+=Vs(e,i)}Us.set(t,n)}return n}function Xs(e,t,n,i,r,o,s,a,l){let c=0;for(let n=i;n=u)break;p+=t}if(c==r+1){if(p>u){let e=n[r];t(e.children,e.positions,0,e.children.length,i[r]+a);continue}f.push(n[r])}else{let t=i[c-1]+n[c-1].length-d;f.push(Xs(e,n,i,r,c,d,t,null,l))}h.push(d+a-o)}}(t,n,i,r,0),(a||l)(f,h,s)}class Ys{constructor(){this.map=new WeakMap}setBuffer(e,t,n){let i=this.map.get(e);i||this.map.set(e,i=new Map),i.set(t,n)}getBuffer(e,t){let n=this.map.get(e);return n&&n.get(t)}set(e,t){e instanceof Is?this.setBuffer(e.context.buffer,e.index,t):e instanceof zs&&this.map.set(e.tree,t)}get(e){return e instanceof Is?this.getBuffer(e.context.buffer,e.index):e instanceof zs?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class Hs{constructor(e,t,n,i,r=!1,o=!1){this.from=e,this.to=t,this.tree=n,this.offset=i,this.open=(r?1:0)|(o?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e,t=[],n=!1){let i=[new Hs(0,e.length,e,0,!1,n)];for(let n of t)n.to>e.length&&i.push(n);return i}static applyChanges(e,t,n=128){if(!t.length)return e;let i=[],r=1,o=e.length?e[0]:null;for(let s=0,a=0,l=0;;s++){let c=s=n)for(;o&&o.from=t.from||u<=t.to||l){let e=Math.max(t.from,a)-l,n=Math.min(t.to,u)-l;t=e>=n?null:new Hs(e,n,t.tree,t.offset+l,s>0,!!c)}if(t&&i.push(t),o.to>u)break;o=rnew Ss(e.from,e.to))):[new Ss(0,0)]:[new Ss(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let i=this.startParse(e,t,n);for(;;){let e=i.advance();if(e)return e}}}class Zs{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new ks({perNode:!0});let Ks=0;class Js{constructor(e,t,n){this.set=e,this.base=t,this.modified=n,this.id=Ks++}static define(e){if(null==e?void 0:e.base)throw new Error("Can not derive from a modified tag");let t=new Js([],null,[]);if(t.set.push(t),e)for(let n of e.set)t.set.push(n);return t}static defineModifier(){let e=new ta;return t=>t.modified.indexOf(e)>-1?t:ta.get(t.base||t,t.modified.concat(e).sort(((e,t)=>e.id-t.id)))}}let ea=0;class ta{constructor(){this.instances=[],this.id=ea++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find((n=>{return n.base==e&&(i=t,r=n.modified,i.length==r.length&&i.every(((e,t)=>e==r[t])));var i,r}));if(n)return n;let i=[],r=new Js(i,e,t);for(let e of t)e.instances.push(r);let o=function(e){let t=[[]];for(let n=0;nt.length-e.length))}(t);for(let t of e.set)if(!t.modified.length)for(let e of o)i.push(ta.get(t,e));return r}}function na(e){let t=Object.create(null);for(let n in e){let i=e[n];Array.isArray(i)||(i=[i]);for(let e of n.split(" "))if(e){let n=[],r=2,o=e;for(let t=0;;){if("..."==o&&t>0&&t+3==e.length){r=1;break}let i=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(o);if(!i)throw new RangeError("Invalid path: "+e);if(n.push("*"==i[0]?"":'"'==i[0][0]?JSON.parse(i[0]):i[0]),t+=i[0].length,t==e.length)break;let s=e[t++];if(t==e.length&&"!"==s){r=0;break}if("/"!=s)throw new RangeError("Invalid path: "+e);o=e.slice(t)}let s=n.length-1,a=n[s];if(!a)throw new RangeError("Invalid path: "+e);let l=new ra(i,r,s>0?n.slice(0,s):null);t[a]=l.sort(t[a])}}return ia.add(t)}const ia=new ks;class ra{constructor(e,t,n,i){this.tags=e,this.mode=t,this.context=n,this.next=i}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(e){return!e||e.depth{let t=r;for(let i of e)for(let e of i.set){let i=n[e.id];if(i){t=t?t+" "+i:i;break}}return t},scope:i}}function sa(e,t,n,i=0,r=e.length){let o=new aa(i,Array.isArray(t)?t:[t],n);o.highlightRange(e.cursor(),i,r,"",o.highlighters),o.flush(r)}ra.empty=new ra([],2,null);class aa{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,i,r){let{type:o,from:s,to:a}=e;if(s>=n||a<=t)return;o.isTop&&(r=this.highlighters.filter((e=>!e.scope||e.scope(o))));let l=i,c=function(e){let t=e.type.prop(ia);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}(e)||ra.empty,u=function(e,t){let n=null;for(let i of e){let e=i.style(t);e&&(n=n?n+" "+e:e)}return n}(r,c.tags);if(u&&(l&&(l+=" "),l+=u,1==c.mode&&(i+=(i?" ":"")+u)),this.startSpan(Math.max(t,s),l),c.opaque)return;let f=e.tree&&e.tree.prop(ks.mounted);if(f&&f.overlay){let o=e.node.enter(f.overlay[0].from+s,1),c=this.highlighters.filter((e=>!e.scope||e.scope(f.tree.type))),u=e.firstChild();for(let h=0,d=s;;h++){let p=h=g)&&e.nextSibling()););if(!p||g>n)break;d=p.to+s,d>t&&(this.highlightRange(o.cursor(),Math.max(t,p.from+s),Math.min(n,d),"",c),this.startSpan(Math.min(n,d),l))}u&&e.parent()}else if(e.firstChild()){f&&(i="");do{if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,i,r),this.startSpan(Math.min(n,e.to),l)}}while(e.nextSibling());e.parent()}}}const la=Js.define,ca=la(),ua=la(),fa=la(ua),ha=la(ua),da=la(),pa=la(da),ga=la(da),ma=la(),ya=la(ma),ba=la(),va=la(),wa=la(),xa=la(wa),_a=la(),Oa={comment:ca,lineComment:la(ca),blockComment:la(ca),docComment:la(ca),name:ua,variableName:la(ua),typeName:fa,tagName:la(fa),propertyName:ha,attributeName:la(ha),className:la(ua),labelName:la(ua),namespace:la(ua),macroName:la(ua),literal:da,string:pa,docString:la(pa),character:la(pa),attributeValue:la(pa),number:ga,integer:la(ga),float:la(ga),bool:la(da),regexp:la(da),escape:la(da),color:la(da),url:la(da),keyword:ba,self:la(ba),null:la(ba),atom:la(ba),unit:la(ba),modifier:la(ba),operatorKeyword:la(ba),controlKeyword:la(ba),definitionKeyword:la(ba),moduleKeyword:la(ba),operator:va,derefOperator:la(va),arithmeticOperator:la(va),logicOperator:la(va),bitwiseOperator:la(va),compareOperator:la(va),updateOperator:la(va),definitionOperator:la(va),typeOperator:la(va),controlOperator:la(va),punctuation:wa,separator:la(wa),bracket:xa,angleBracket:la(xa),squareBracket:la(xa),paren:la(xa),brace:la(xa),content:ma,heading:ya,heading1:la(ya),heading2:la(ya),heading3:la(ya),heading4:la(ya),heading5:la(ya),heading6:la(ya),contentSeparator:la(ma),list:la(ma),quote:la(ma),emphasis:la(ma),strong:la(ma),link:la(ma),monospace:la(ma),strikethrough:la(ma),inserted:la(),deleted:la(),changed:la(),invalid:la(),meta:_a,documentMeta:la(_a),annotation:la(_a),processingInstruction:la(_a),definition:Js.defineModifier(),constant:Js.defineModifier(),function:Js.defineModifier(),standard:Js.defineModifier(),local:Js.defineModifier(),special:Js.defineModifier()};var Sa;oa([{tag:Oa.link,class:"tok-link"},{tag:Oa.heading,class:"tok-heading"},{tag:Oa.emphasis,class:"tok-emphasis"},{tag:Oa.strong,class:"tok-strong"},{tag:Oa.keyword,class:"tok-keyword"},{tag:Oa.atom,class:"tok-atom"},{tag:Oa.bool,class:"tok-bool"},{tag:Oa.url,class:"tok-url"},{tag:Oa.labelName,class:"tok-labelName"},{tag:Oa.inserted,class:"tok-inserted"},{tag:Oa.deleted,class:"tok-deleted"},{tag:Oa.literal,class:"tok-literal"},{tag:Oa.string,class:"tok-string"},{tag:Oa.number,class:"tok-number"},{tag:[Oa.regexp,Oa.escape,Oa.special(Oa.string)],class:"tok-string2"},{tag:Oa.variableName,class:"tok-variableName"},{tag:Oa.local(Oa.variableName),class:"tok-variableName tok-local"},{tag:Oa.definition(Oa.variableName),class:"tok-variableName tok-definition"},{tag:Oa.special(Oa.variableName),class:"tok-variableName2"},{tag:Oa.definition(Oa.propertyName),class:"tok-propertyName tok-definition"},{tag:Oa.typeName,class:"tok-typeName"},{tag:Oa.namespace,class:"tok-namespace"},{tag:Oa.className,class:"tok-className"},{tag:Oa.macroName,class:"tok-macroName"},{tag:Oa.propertyName,class:"tok-propertyName"},{tag:Oa.operator,class:"tok-operator"},{tag:Oa.comment,class:"tok-comment"},{tag:Oa.meta,class:"tok-meta"},{tag:Oa.invalid,class:"tok-invalid"},{tag:Oa.punctuation,class:"tok-punctuation"}]);const ka=new ks;const Aa=new ks;class Ta{constructor(e,t,n=[],i=""){this.data=e,this.name=i,ke.prototype.hasOwnProperty("tree")||Object.defineProperty(ke.prototype,"tree",{get(){return $a(this)}}),this.parser=t,this.extension=[La.of(this),ke.languageData.of(((e,t,n)=>{let i=Ea(e,t,n),r=i.type.prop(ka);if(!r)return[];let o=e.facet(r),s=i.type.prop(Aa);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 Ea(e,t,n).type.prop(ka)==this.data}findRegions(e){let t=e.facet(La);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(ka)==this.data)return void n.push({from:t,to:t+e.length});let r=e.prop(ks.mounted);if(r){if(r.tree.prop(ka)==this.data){if(r.overlay)for(let e of r.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}if(r.overlay){let e=n.length;if(i(r.tree,r.overlay[0].from+t),n.length>e)return}}for(let n=0;ne.concat(n):void 0}));var n;return new Ca(t,e.parser.configure({props:[ka.add((e=>e.isTop?t:void 0))]}),e.name)}configure(e,t){return new Ca(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function $a(e){let t=e.field(Ta.state,!1);return t?t.tree:Ds.empty}class Ma{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 Da=null;class Pa{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 Pa(e,t,[],Ds.empty,0,n,[],null)}startParse(){return this.parser.startParse(new Ma(this.state.doc),this.fragments)}work(e,t){return null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=Ds.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(Hs.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Da;Da=this;try{return e()}finally{Da=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Ra(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:i,treeLen:r,viewport:o,skipped:s}=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=Hs.applyChanges(n,t),i=Ds.empty,r=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){s=[];for(let t of this.skipped){let n=e.mapPos(t.from,1),i=e.mapPos(t.to,-1);ne.from&&(this.fragments=Ra(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 Gs{createParse(t,n,i){let r=i[0].from,o=i[i.length-1].to;return{parsedPos:r,advance(){let t=Da;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=o,new Ds(Ts.none,[],[],o-r)},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 Da}}function Ra(e,t,n){return Hs.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class Fa{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 Fa(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=Pa.create(e.facet(La).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new Fa(n)}}Ta.state=j.define({create:Fa.init,update(e,t){for(let e of t.effects)if(e.is(Ta.setState))return e.value;return t.startState.facet(La)!=t.state.facet(La)?Fa.init(t.state):e.apply(t)}});let Na=e=>{let t=setTimeout((()=>e()),500);return()=>clearTimeout(t)};"undefined"!=typeof requestIdleCallback&&(Na=e=>{let t=-1,n=setTimeout((()=>{t=requestIdleCallback(e,{timeout:400})}),100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const qa=void 0!==d&&(null===(Sa=d.scheduling)||void 0===Sa?void 0:Sa.isInputPending)?()=>d.scheduling.isInputPending():null,za=Mn.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(Ta.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),e.docChanged&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(Ta.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=Na(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndi+1e3,a=r.context.work((()=>qa&&qa()||Date.now()>o),i+(s?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:Ta.setState.of(new Fa(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=>Tn(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()}}}),La=q.define({combine:e=>e.length?e[0]:null,enables:e=>[Ta.state,za,Dr.contentAttributes.compute([e],(t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}}))]});class Ba{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const Qa=q.define(),Ia=q.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 Wa(e){let t=e.facet(Ia);return 9==t.charCodeAt(0)?e.tabSize*t.length:t.length}function ja(e,t){let n="",i=e.tabSize,r=e.facet(Ia)[0];if("\t"==r){for(;t>=i;)n+="\t",t-=i;r=" "}for(let e=0;e=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 We(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 Xa=new ks;function Ya(e){let t=e.type.prop(Xa);if(t)return t;let n,i=e.firstChild;if(i&&(n=i.type.prop(ks.closedBy))){let t=e.lastChild,i=t&&n.indexOf(t.name)>-1;return e=>el(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?Ga:null}function Ha(e,t,n){for(;e;e=e.parent){let i=Ya(e);if(i)return i(Za.create(n,t,e))}return null}function Ga(){return 0}class Za extends Va{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.node=n}static create(e,t,n){return new Za(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(Ka(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){let e=this.node.parent;return e?Ha(e,this.pos,this.base):0}}function Ka(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function Ja({closing:e,align:t=!0,units:n=1}){return i=>el(i,t,n,e)}function el(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)return r.fromn)continue;if(r&&o.from=t&&i.to>n&&(r=i)}}return r}(e,t,n)}function ol(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 sl=de.define({map:ol}),al=de.define({map:ol});function ll(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 cl=j.define({create:()=>on.none,update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(sl)&&!fl(e,n.value.from,n.value.to)?e=e.update({add:[bl.range(n.value.from,n.value.to)]}):n.is(al)&&(e=e.update({filter:(e,t)=>n.value.from!=e||n.value.to!=t,filterFrom:n.value.from,filterTo:n.value.to}));if(t.selection){let n=!1,{head:i}=t.selection.main;e.between(i,i,((e,t)=>{ei&&(n=!0)})),n&&(e=e.update({filterFrom:i,filterTo:i,filter:(e,t)=>t<=i||e>=i}))}return e},provide:e=>Dr.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{(!r||r.from>e)&&(r={from:e,to:t})})),r}function fl(e,t,n){let i=!1;return e.between(t,t,((e,r)=>{e==t&&r==n&&(i=!0)})),i}function hl(e,t){return e.field(cl,!1)?t:t.concat(de.appendConfig.of(yl()))}function dl(e,t,n=!0){let i=e.state.doc.lineAt(t.from).number,r=e.state.doc.lineAt(t.to).number;return Dr.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${i} ${e.state.phrase("to")} ${r}.`)}const pl=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:e=>{for(let t of ll(e)){let n=rl(e.state,t.from,t.to);if(n)return e.dispatch({effects:hl(e.state,[sl.of(n),dl(e,n)])}),!0}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:e=>{if(!e.state.field(cl,!1))return!1;let t=[];for(let n of ll(e)){let i=ul(e.state,n.from,n.to);i&&t.push(al.of(i),dl(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(cl,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,((e,t)=>{n.push(al.of({from:e,to:t}))})),e.dispatch({effects:n}),!0}}],gl={placeholderDOM:null,placeholderText:"…"},ml=q.define({combine:e=>Ae(e,gl)});function yl(e){let t=[cl,_l];return e&&t.push(ml.of(e)),t}const bl=on.replace({widget:new class extends nn{toDOM(e){let{state:t}=e,n=t.facet(ml),i=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),i=ul(e.state,n.from,n.to);i&&e.dispatch({effects:al.of(i)}),t.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(e,i);let r=document.createElement("span");return r.textContent=n.placeholderText,r.setAttribute("aria-label",t.phrase("folded code")),r.title=t.phrase("unfold"),r.className="cm-foldPlaceholder",r.onclick=i,r}}}),vl={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class wl extends es{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 xl(e={}){let t=Object.assign(Object.assign({},vl),e),n=new wl(t,!0),i=new wl(t,!1),r=Mn.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(La)!=e.state.facet(La)||e.startState.field(cl,!1)!=e.state.field(cl,!1)||$a(e.startState)!=$a(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new De;for(let r of e.viewportLineBlocks){let o=ul(e.state,r.from,r.to)?i:rl(e.state,r.from,r.to)?n:null;o&&t.add(r.from,r.from,o)}return t.finish()}}),{domEventHandlers:o}=t;return[r,rs({class:"cm-foldGutter",markers(e){var t;return(null===(t=e.plugin(r))||void 0===t?void 0:t.markers)||Me.empty},initialSpacer:()=>new wl(t,!1),domEventHandlers:Object.assign(Object.assign({},o),{click:(e,t,n)=>{if(o.click&&o.click(e,t,n))return!0;let i=ul(e.state,t.from,t.to);if(i)return e.dispatch({effects:al.of(i)}),!0;let r=rl(e.state,t.from,t.to);return!!r&&(e.dispatch({effects:sl.of(r)}),!0)}})}),yl()]}const _l=Dr.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 Ol{constructor(e,t){let n;function i(e){let t=Ye.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 Ta?e=>e.prop(ka)==o.data:o?e=>e==o:void 0,this.style=oa(e.map((e=>({tag:e.tag,class:e.class||i(Object.assign({},e,{tag:null}))}))),{all:r}).style,this.module=n?new Ye(n):null,this.themeType=t.themeType}static define(e,t){return new Ol(e,t||{})}}const Sl=q.define(),kl=q.define({combine:e=>e.length?[e[0]]:null});function Al(e){let t=e.facet(Sl);return t.length?t:e.facet(kl)}function Tl(e,t){let n,i=[Cl];return e instanceof Ol&&(e.module&&i.push(Dr.styleModule.of(e.module)),n=e.themeType),(null==t?void 0:t.fallback)?i.push(kl.of(e)):n?i.push(Sl.computeN([Dr.darkTheme],(t=>t.facet(Dr.darkTheme)==("dark"==n)?[e]:[]))):i.push(Sl.of(e)),i}class El{constructor(e){this.markCache=Object.create(null),this.tree=$a(e.state),this.decorations=this.buildDeco(e,Al(e.state))}update(e){let t=$a(e.state),n=Al(e.state),i=n!=Al(e.startState);t.length{n.add(e,t,this.markCache[i]||(this.markCache[i]=on.mark({class:i})))}),i,r);return n.finish()}}const Cl=G.high(Mn.fromClass(El,{decorations:e=>e.decorations})),$l=Ol.define([{tag:Oa.meta,color:"#404740"},{tag:Oa.link,textDecoration:"underline"},{tag:Oa.heading,textDecoration:"underline",fontWeight:"bold"},{tag:Oa.emphasis,fontStyle:"italic"},{tag:Oa.strong,fontWeight:"bold"},{tag:Oa.strikethrough,textDecoration:"line-through"},{tag:Oa.keyword,color:"#708"},{tag:[Oa.atom,Oa.bool,Oa.url,Oa.contentSeparator,Oa.labelName],color:"#219"},{tag:[Oa.literal,Oa.inserted],color:"#164"},{tag:[Oa.string,Oa.deleted],color:"#a11"},{tag:[Oa.regexp,Oa.escape,Oa.special(Oa.string)],color:"#e40"},{tag:Oa.definition(Oa.variableName),color:"#00f"},{tag:Oa.local(Oa.variableName),color:"#30a"},{tag:[Oa.typeName,Oa.namespace],color:"#085"},{tag:Oa.className,color:"#167"},{tag:[Oa.special(Oa.variableName),Oa.macroName],color:"#256"},{tag:Oa.definition(Oa.propertyName),color:"#00c"},{tag:Oa.comment,color:"#940"},{tag:Oa.invalid,color:"#f00"}]),Ml=Dr.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Dl="()[]{}",Pl=q.define({combine:e=>Ae(e,{afterCursor:!0,brackets:Dl,maxScanDistance:1e4,renderMatch:Nl})}),Rl=on.mark({class:"cm-matchingBracket"}),Fl=on.mark({class:"cm-nonmatchingBracket"});function Nl(e){let t=[],n=e.matched?Rl:Fl;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}const ql=j.define({create:()=>on.none,update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],i=t.state.facet(Pl);for(let e of t.state.selection.ranges){if(!e.empty)continue;let r=Wl(t.state,e.head,-1,i)||e.head>0&&Wl(t.state,e.head-1,1,i)||i.afterCursor&&(Wl(t.state,e.head,1,i)||e.headDr.decorations.from(e)}),zl=[ql,Ml];function Ll(e={}){return[Pl.of(e),zl]}const Bl=new ks;function Ql(e,t,n){let i=e.prop(t<0?ks.openedBy:ks.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 Il(e){let t=e.type.prop(Bl);return t?t(e.node):e}function Wl(e,t,n,i={}){let r=i.maxScanDistance||1e4,o=i.brackets||Dl,s=$a(e),a=s.resolveInner(t,n);for(let i=a;i;i=i.parent){let r=Ql(i.type,n,o);if(r&&i.from0?t>=s.from&&ts.from&&t<=s.to))return jl(e,t,n,i,s,r,o)}}return function(e,t,n,i,r,o,s){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},u=e.doc.iterRange(t,n>0?e.doc.length:0),f=0;for(let e=0;!u.next().done&&e<=o;){let o=u.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)f++;else{if(1==f)return{start:c,end:{from:a+e,to:a+e+1},matched:t>>1==l>>1};f--}}n>0&&(e+=o.length)}return u.done?{start:c,matched:!1}:null}(e,t,n,s,a.type,r,o)}function jl(e,t,n,i,r,o,s){let a=i.parent,l={from:r.from,to:r.to},c=0,u=null==a?void 0:a.cursor();if(u&&(n<0?u.childBefore(i.from):u.childAfter(i.to)))do{if(n<0?u.to<=i.from:u.from>=i.to){if(0==c&&o.indexOf(u.type.name)>-1&&u.from-1||(Xl.push(e),console.warn(t))}function Gl(e,t){let n=null;for(let i of t.split(".")){let t=e[i]||Oa[i];t?"function"==typeof t?n?n=t(n):Hl(i,`Modifier ${i} used at start of tag`):n?Hl(i,`Tag ${i} used as modifier`):n=t:Hl(i,`Unknown highlighting tag ${i}`)}if(!n)return 0;let i=t.replace(/ /g,"_"),r=Ts.define({id:Vl.length,name:i,props:[na({[i]:n})]});return Vl.push(r),r.id}class Zl{constructor(e,t,n){this.state=e,this.pos=t,this.explicit=n,this.abortListeners=[]}tokenBefore(e){let t=$a(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(ic(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){"abort"==e&&this.abortListeners&&this.abortListeners.push(t)}}function Kl(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,"\\$&")}]`}function Jl(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}}function ec(e,t){return n=>{for(let t=$a(n.state).resolveInner(n.pos,-1);t;t=t.parent){if(e.indexOf(t.name)>-1)return null;if(t.type.isTop)break}return t(n)}}class tc{constructor(e,t,n,i){this.completion=e,this.source=t,this.match=n,this.score=i}}function nc(e){return e.selection.main.from}function ic(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 rc=ue.define();const oc=new WeakMap;function sc(e){if(!Array.isArray(e))return e;let t=oc.get(e);return t||oc.set(e,t=Jl(e)),t}const ac=de.define(),lc=de.define();class cc{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&&l<=57||l>=97&&l<=122?2:l>=65&&l<=90?1:0:(b=x(l))!=b.toLowerCase()?1:b!=b.toUpperCase()?2:0;(!i||1==v&&g||0==y&&0!=v)&&(t[u]==l||n[u]==l&&(f=!0)?o[u++]=i:o.length&&(m=!1)),y=v,i+=_(l)}return u==a&&0==o[0]&&m?this.result((f?-200:0)-100,o,e):h==a&&0==d?this.ret(-200-e.length+(p==e.length?0:-100),[0,p]):s>-1?this.ret(-700-e.length,[s,s+this.pattern.length]):h==a?this.ret(-900-e.length,[d,p]):u==a?this.result((f?-200:0)-100-700+(m?0:-1100),o,e):2!=t.length&&this.result((i[0]?-700:0)-200-1100,i,e)}result(e,t,n){let i=[],r=0;for(let e of t){let t=e+(this.astral?_(w(n,e)):1);r&&i[r-1]==e?i[r-1]=t:(i[r++]=e,i[r++]=t)}return this.ret(e-n.length,i)}}const uc=q.define({combine:e=>Ae(e,{activateOnTyping:!0,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:hc,compareCompletions:(e,t)=>e.label.localeCompare(t.label),interactionDelay:75},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>fc(e(n),t(n)),optionClass:(e,t)=>n=>fc(e(n),t(n)),addToOptions:(e,t)=>e.concat(t)})});function fc(e,t){return e?t?e+" "+t:e:t}function hc(e,t,n,i,r){let o,s,a=e.textDirection==In.RTL,l=a,c=!1,u="top",f=t.left-r.left,h=r.right-t.right,d=i.right-i.left,p=i.bottom-i.top;if(l&&f=p||e>t.top?o=n.bottom-t.top:(u="bottom",o=t.bottom-n.top)}return{style:`${u}: ${o}px; max-width: ${s}px`,class:"cm-completionInfo-"+(c?a?"left-narrow":"right-narrow":l?"left":"right")}}function dc(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.floor((e-t)/n);return{from:e-(i+1)*n,to:e-i*n}}class pc{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(uc);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){let i=document.createElement("span");i.className="cm-completionLabel";let r=e.displayLabel||e.label,o=0;for(let e=0;eo&&i.appendChild(document.createTextNode(r.slice(o,t)));let a=i.appendChild(document.createElement("span"));a.appendChild(document.createTextNode(r.slice(t,s))),a.className="cm-completionMatchedText",o=s}return oe.position-t.position)).map((e=>e.render))}(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=dc(r.length,o,s.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",(t=>{for(let n,i=t.target;i&&i!=this.dom;i=i.parentNode)if("LI"==i.nodeName&&(n=/-(\d+)$/.exec(i.id))&&+n[1]{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(uc).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:lc.of(null)})})),this.list=this.dom.appendChild(this.createListBox(r,i.id,this.range)),this.list.addEventListener("scroll",(()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)}))}mount(){this.updateSel()}update(e){var t,n,i;let r=e.state.field(this.stateField),o=e.startState.field(this.stateField);this.updateTooltipClass(e.state),r!=o&&(this.updateSel(),(null===(t=r.open)||void 0===t?void 0:t.disabled)!=(null===(n=o.open)||void 0===n?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!(null===(i=r.open)||void 0===i?void 0:i.disabled)))}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;if((t.selected>-1&&t.selected=this.range.to)&&(this.range=dc(t.options.length,t.selected,this.view.state.facet(uc).maxRenderedOptions),this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t.options,e.id,this.range)),this.list.addEventListener("scroll",(()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)}))),this.updateSelectedOption(t.selected)){this.destroyInfo();let{completion:n}=t.options[t.selected],{info:i}=n;if(!i)return;let r="string"==typeof i?document.createTextNode(i):i(n);if(!r)return;"then"in r?r.then((t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,n)})).catch((e=>Tn(this.view.state,e,"completion info"))):this.addInfoPane(r,n)}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",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"):i--;return t&&function(e,t){let n=e.getBoundingClientRect(),i=t.getBoundingClientRect();i.topn.bottom&&(e.scrollTop+=i.bottom-n.bottom)}(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.defaultView||window;r={left:0,top:0,right:e.innerWidth,bottom:e.innerHeight}}return i.top>Math.min(r.bottom,t.bottom)-10||i.bottomn.from||0==n.from))if(r=e,"string"!=typeof l&&l.header)i.appendChild(l.header(l));else{i.appendChild(document.createElement("completion-section")).textContent=e}}const c=i.appendChild(document.createElement("li"));c.id=t+"-"+o,c.setAttribute("role","option");let u=this.optionClass(s);u&&(c.className=u);for(let e of this.optionContent){let t=e(s,this.view.state,a);t&&c.appendChild(t)}}return n.from&&i.classList.add("cm-completionListIncompleteTop"),n.tonew pc(n,e,t)}function mc(e){return 100*(e.boost||0)+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}class yc{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 yc(this.options,wc(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,i,r){let o=function(e,t){let n=[],i=null,r=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)}};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)r(new tc(t,i.source,e?e(t):[],1e9-n.length));else{let n=new cc(t.sliceDoc(i.from,i.to));for(let t of i.result.options)if(n.match(t.label)){let o=t.displayLabel?e?e(t,n.matched):[]:n.matched;r(new tc(t,i.source,o,n.score+(t.boost||0)))}}}if(i){let e=Object.create(null),t=0,r=(e,t)=>{var n,i;return(null!==(n=e.rank)&&void 0!==n?n:1e9)-(null!==(i=t.rank)&&void 0!==i?i:1e9)||(e.namet.score-e.score||a(e.completion,t.completion)))){let t=e.completion;!s||s.label!=t.label||s.detail!=t.detail||null!=s.type&&null!=t.type&&s.type!=t.type||s.apply!=t.apply||s.boost!=t.boost?o.push(e):mc(e.completion)>mc(s)&&(o[o.length-1]=e),s=e.completion}return o}(e,t);if(!o.length)return i&&e.some((e=>1==e.state))?new yc(i.options,i.attrs,i.tooltip,i.timestamp,i.selected,!0):null;let s=t.facet(uc).selectOnOpen?0:-1;if(i&&i.selected!=s&&-1!=i.selected){let e=i.options[i.selected].completion;for(let t=0;tt.hasResult()?Math.min(e,t.from):e),1e8),create:gc(Tc,Ec),above:r.aboveCursor},i?i.timestamp:Date.now(),s,!1)}map(e){return new yc(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}}class bc{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new bc(xc,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(e){let{state:t}=e,n=t.facet(uc),i=(n.override||t.languageDataAt("autocomplete",nc(t)).map(sc)).map((t=>(this.active.find((e=>e.source==t))||new Oc(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;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(;n1==e.state))&&(r=null),!r&&i.every((e=>1!=e.state))&&i.some((e=>e.hasResult()))&&(i=i.map((e=>e.hasResult()?new Oc(e.source,0):e)));for(let t of e.effects)t.is(Ac)&&(r=r&&r.setSelected(t.value,this.id));return i==this.active&&r==this.open?this:new bc(i,this.id,r)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:vc}}const vc={"aria-autocomplete":"list"};function wc(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const xc=[];function _c(e){return e.isUserEvent("input.type")?"input":e.isUserEvent("delete.backward")?"delete":null}class Oc{constructor(e,t,n=-1){this.source=e,this.state=t,this.explicitPos=n}hasResult(){return!1}update(e,t){let n=_c(e),i=this;n?i=i.handleUserEvent(e,n,t):e.docChanged?i=i.handleChange(e):e.selection&&0!=i.state&&(i=new Oc(i.source,0));for(let t of e.effects)if(t.is(ac))i=new Oc(i.source,1,t.value?nc(e.state):-1);else if(t.is(lc))i=new Oc(i.source,0);else if(t.is(kc))for(let e of t.value)e.source==i.source&&(i=e);return i}handleUserEvent(e,t,n){return"delete"!=t&&n.activateOnTyping?new Oc(this.source,1):this.map(e.changes)}handleChange(e){return e.changes.touchesRange(nc(e.startState))?new Oc(this.source,0):this.map(e.changes)}map(e){return e.empty||this.explicitPos<0?this:new Oc(this.source,this.state,e.mapPos(this.explicitPos))}}class Sc extends Oc{constructor(e,t,n,i,r){super(e,2,t),this.result=n,this.from=i,this.to=r}hasResult(){return!0}handleUserEvent(e,t,n){var i;let r=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),s=nc(e.state);if((this.explicitPos<0?s<=r:so||"delete"==t&&nc(e.startState)==this.from)return new Oc(this.source,"input"==t&&n.activateOnTyping?1:0);let a,l=this.explicitPos<0?-1:e.changes.mapPos(this.explicitPos);return function(e,t,n,i){if(!e)return!1;let r=t.sliceDoc(n,i);return"function"==typeof e?e(r,n,i,t):ic(e,!0).test(r)}(this.result.validFor,e.state,r,o)?new Sc(this.source,l,this.result,r,o):this.result.update&&(a=this.result.update(this.result,r,o,new Zl(e.state,s,l>=0)))?new Sc(this.source,l,a,a.from,null!==(i=a.to)&&void 0!==i?i:nc(e.state)):new Oc(this.source,1,l)}handleChange(e){return e.changes.touchesRange(this.from,this.to)?new Oc(this.source,0):this.map(e.changes)}map(e){return e.empty?this:new Sc(this.source,this.explicitPos<0?-1:e.mapPos(this.explicitPos),this.result,e.mapPos(this.from),e.mapPos(this.to,1))}}const kc=de.define({map:(e,t)=>e.map((e=>e.map(t)))}),Ac=de.define(),Tc=j.define({create:()=>bc.start(),update:(e,t)=>e.update(t),provide:e=>[Lo.from(e,(e=>e.tooltip)),Dr.contentAttributes.from(e,(e=>e.attrs))]});function Ec(e,t){const n=t.completion.apply||t.completion.label;let i=e.state.field(Tc).active.find((e=>e.source==t.source));return i instanceof Sc&&("string"==typeof n?e.dispatch(Object.assign(Object.assign({},function(e,t,n,i){let{main:r}=e.selection,o=n-r.from,s=i-r.from;return Object.assign(Object.assign({},e.changeByRange((a=>a!=r&&n!=i&&e.sliceDoc(a.from+o,a.from+s)!=e.sliceDoc(n,i)?{range:a}:{changes:{from:a.from+o,to:i==r.from?a.to:a.from+s,insert:t},range:R.cursor(a.from+o+t.length)}))),{userEvent:"input.complete"})}(e.state,n,i.from,i.to)),{annotations:rc.of(t.completion)})):n(e,t.completion,i.from,i.to),!0)}function Cc(e,t="option"){return n=>{let i=n.state.field(Tc,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp-1?i.open.selected+o*(e?1:-1):e?0:s-1;return a<0?a="page"==t?0:s-1:a>=s&&(a="page"==t?s-1:0),n.dispatch({effects:Ac.of(a)}),!0}}class $c{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const Mc=Mn.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.composing=0;for(let t of e.state.field(Tc).active)1==t.state&&this.startQuery(t)}update(e){let t=e.state.field(Tc);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Tc)==t)return;let n=e.transactions.some((e=>(e.selection||e.docChanged)&&!_c(e)));for(let t=0;t50&&Date.now()-i.time>1e3){for(let e of i.context.abortListeners)try{e()}catch(e){Tn(this.view.state,e)}i.context.abortListeners=null,this.running.splice(t--,1)}else i.updates.push(...e.transactions)}if(this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),this.debounceUpdate=t.active.some((e=>1==e.state&&!this.running.some((t=>t.active.source==e.source))))?setTimeout((()=>this.startUpdate()),50):-1,0!=this.composing)for(let t of e.transactions)"input"==_c(t)?this.composing=2:2==this.composing&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1;let{state:e}=this.view,t=e.field(Tc);for(let e of t.active)1!=e.state||this.running.some((t=>t.active.source==e.source))||this.startQuery(e)}startQuery(e){let{state:t}=this.view,n=nc(t),i=new Zl(t,n,e.explicitPos==n),r=new $c(e,i);this.running.push(r),Promise.resolve(e.source(i)).then((e=>{r.context.aborted||(r.done=e||null,this.scheduleAccept())}),(e=>{this.view.dispatch({effects:lc.of(null)}),Tn(this.view.state,e)}))}scheduleAccept(){this.running.every((e=>void 0!==e.done))?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout((()=>this.accept()),50))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(uc);for(let i=0;ie.source==r.active.source));if(o&&1==o.state)if(null==r.done){let e=new Oc(r.active.source,0);for(let t of r.updates)e=e.update(t,n);1!=e.state&&t.push(e)}else this.startQuery(o)}t.length&&this.view.dispatch({effects:kc.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Tc,!1);if(t&&t.tooltip&&this.view.state.facet(uc).closeOnBlur){let n=t.open&&Vo(this.view,t.open.tooltip);n&&n.dom.contains(e.relatedTarget)||this.view.dispatch({effects:lc.of(null)})}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout((()=>this.view.dispatch({effects:ac.of(!1)})),20),this.composing=0}}}),Dc=Dr.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class Pc{constructor(e,t,n,i){this.field=e,this.line=t,this.from=n,this.to=i}}class Rc{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(e){let t=e.mapPos(this.from,-1,S.TrackDel),n=e.mapPos(this.to,1,S.TrackDel);return null==t||null==n?null:new Rc(this.field,t,n)}}class Fc{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let n=[],i=[t],r=e.doc.lineAt(t),o=/^\s*/.exec(r.text)[0];for(let r of this.lines){if(n.length){let n=o,s=/^\t*/.exec(r)[0].length;for(let t=0;tnew Rc(e.field,i[e.line]+e.from,i[e.line]+e.to)));return{text:n,ranges:s}}static parse(e){let t,n=[],i=[],r=[];for(let o of e.split(/\r\n?|\n/)){for(;t=/[#$]\{(?:(\d+)(?::([^}]*))?|([^}]*))\}/.exec(o);){let e=t[1]?+t[1]:null,s=t[2]||t[3]||"",a=-1;for(let t=0;t=a&&e.field++}r.push(new Pc(a,i.length,t.index,t.index+s.length)),o=o.slice(0,t.index)+s+o.slice(t.index+t[0].length)}for(let e;e=/\\([{}])/.exec(o);){o=o.slice(0,e.index)+e[1]+o.slice(e.index+e[0].length);for(let t of r)t.line==i.length&&t.from>e.index&&(t.from--,t.to--)}i.push(o)}return new Fc(i,r)}}let Nc=on.widget({widget:new class extends nn{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),qc=on.mark({class:"cm-snippetField"});class zc{constructor(e,t){this.ranges=e,this.active=t,this.deco=on.set(e.map((e=>(e.from==e.to?Nc:qc).range(e.from,e.to))))}map(e){let t=[];for(let n of this.ranges){let i=n.map(e);if(!i)return null;t.push(i)}return new zc(t,this.active)}selectionInsideField(e){return e.ranges.every((e=>this.ranges.some((t=>t.field==this.active&&t.from<=e.from&&t.to>=e.to))))}}const Lc=de.define({map:(e,t)=>e&&e.map(t)}),Bc=de.define(),Qc=j.define({create:()=>null,update(e,t){for(let n of t.effects){if(n.is(Lc))return n.value;if(n.is(Bc)&&e)return new zc(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>Dr.decorations.from(e,(e=>e?e.deco:on.none))});function Ic(e,t){return R.create(e.filter((e=>e.field==t)).map((e=>R.range(e.from,e.to))))}function Wc(e){let t=Fc.parse(e);return(e,i,r,o)=>{let{text:s,ranges:a}=t.instantiate(e.state,r),l={changes:{from:r,to:o,insert:n.of(s)},scrollIntoView:!0,annotations:i?rc.of(i):void 0};if(a.length&&(l.selection=Ic(a,0)),a.length>1){let t=new zc(a,0),n=l.effects=[Lc.of(t)];void 0===e.state.field(Qc,!1)&&n.push(de.appendConfig.of([Qc,Xc,Hc,Dc]))}e.dispatch(e.state.update(l))}}function jc(e){return({state:t,dispatch:n})=>{let i=t.field(Qc,!1);if(!i||e<0&&0==i.active)return!1;let r=i.active+e,o=e>0&&!i.ranges.some((t=>t.field==r+e));return n(t.update({selection:Ic(i.ranges,r),effects:Lc.of(o?null:new zc(i.ranges,r))})),!0}}const Uc=[{key:"Tab",run:jc(1),shift:jc(-1)},{key:"Escape",run:({state:e,dispatch:t})=>!!e.field(Qc,!1)&&(t(e.update({effects:Lc.of(null)})),!0)}],Vc=q.define({combine:e=>e.length?e[0]:Uc}),Xc=G.highest(Br.compute([Vc],(e=>e.facet(Vc))));function Yc(e,t){return Object.assign(Object.assign({},t),{apply:Wc(e)})}const Hc=Dr.domEventHandlers({mousedown(e,t){let n,i=t.state.field(Qc,!1);if(!i||null==(n=t.posAtCoords({x:e.clientX,y:e.clientY})))return!1;let r=i.ranges.find((e=>e.from<=n&&e.to>=n));return!(!r||r.field==i.active)&&(t.dispatch({selection:Ic(i.ranges,r.field),effects:Lc.of(i.ranges.some((e=>e.field>r.field))?new zc(i.ranges,r.field):null)}),!0)}}),Gc={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Zc=de.define({map(e,t){let n=t.mapPos(e,-1,S.TrackAfter);return null==n?void 0:n}}),Kc=new class extends Te{};Kc.startSide=1,Kc.endSide=-1;const Jc=j.define({create:()=>Me.empty,update(e,t){if(t.selection){let n=t.state.doc.lineAt(t.selection.main.head).from,i=t.startState.doc.lineAt(t.startState.selection.main.head).from;n!=t.changes.mapPos(i,-1)&&(e=Me.empty)}e=e.map(t.changes);for(let n of t.effects)n.is(Zc)&&(e=e.update({add:[Kc.range(n.value,n.value+1)]}));return e}});const eu="()[]{}<>";function tu(e){for(let t=0;t{if((iu?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let r=e.state.selection.main;if(i.length>2||2==i.length&&1==_(w(i,0))||t!=r.from||n!=r.to)return!1;let o=function(e,t){let n=nu(e,e.selection.main.head),i=n.brackets||Gc.brackets;for(let r of i){let o=tu(w(r,0));if(t==r)return o==r?uu(e,r,i.indexOf(r+r+r)>-1,n):lu(e,r,o,n.before||Gc.before);if(t==o&&su(e,e.selection.main.from))return cu(e,r,o)}return null}(e.state,i);return!!o&&(e.dispatch(o),!0)})),ou=[{key:"Backspace",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=nu(e,e.selection.main.head).brackets||Gc.brackets,i=null,r=e.changeByRange((t=>{if(t.empty){let i=function(e,t){let n=e.sliceString(t-2,t);return _(w(n,0))==n.length?n:n.slice(1)}(e.doc,t.head);for(let r of n)if(r==i&&au(e.doc,t.head)==tu(w(r,0)))return{changes:{from:t.head-r.length,to:t.head+r.length},range:R.cursor(t.head-r.length)}}return{range:i=t}}));return i||t(e.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!i}}];function su(e,t){let n=!1;return e.field(Jc).between(0,e.doc.length,(e=>{e==t&&(n=!0)})),n}function au(e,t){let n=e.sliceString(t,t+2);return n.slice(0,_(w(n,0)))}function lu(e,t,n,i){let r=null,o=e.changeByRange((o=>{if(!o.empty)return{changes:[{insert:t,from:o.from},{insert:n,from:o.to}],effects:Zc.of(o.to+t.length),range:R.range(o.anchor+t.length,o.head+t.length)};let s=au(e.doc,o.head);return!s||/\s/.test(s)||i.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:Zc.of(o.head+t.length),range:R.cursor(o.head+t.length)}:{range:r=o}}));return r?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function cu(e,t,n){let i=null,r=e.changeByRange((t=>t.empty&&au(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:R.cursor(t.head+n.length)}:i={range:t}));return i?null:e.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function uu(e,t,n,i){let r=i.stringPrefixes||Gc.stringPrefixes,o=null,s=e.changeByRange((i=>{if(!i.empty)return{changes:[{insert:t,from:i.from},{insert:t,from:i.to}],effects:Zc.of(i.to+t.length),range:R.range(i.anchor+t.length,i.head+t.length)};let s,a=i.head,l=au(e.doc,a);if(l==t){if(fu(e,a))return{changes:{insert:t+t,from:a},effects:Zc.of(a+t.length),range:R.cursor(a+t.length)};if(su(e,a)){let i=n&&e.sliceDoc(a,a+3*t.length)==t+t+t?t+t+t:t;return{changes:{from:a,to:a+i.length,insert:i},range:R.cursor(a+i.length)}}}else{if(n&&e.sliceDoc(a-2*t.length,a)==t+t&&(s=hu(e,a-2*t.length,r))>-1&&fu(e,s))return{changes:{insert:t+t+t+t,from:a},effects:Zc.of(a+t.length),range:R.cursor(a+t.length)};if(e.charCategorizer(a)(l)!=xe.Word&&hu(e,a,r)>-1&&!function(e,t,n,i){let r=$a(e).resolveInner(t,-1),o=i.reduce(((e,t)=>Math.max(e,t.length)),0);for(let s=0;s<5;s++){let s=e.sliceDoc(r.from,Math.min(r.to,r.from+n.length+o)),a=s.indexOf(n);if(!a||a>-1&&i.indexOf(s.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,a,t,r))return{changes:{insert:t+t,from:a},effects:Zc.of(a+t.length),range:R.cursor(a+t.length)}}return{range:o=i}}));return o?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function fu(e,t){let n=$a(e).resolveInner(t+1);return n.parent&&n.from==t}function hu(e,t,n){let i=e.charCategorizer(t);if(i(e.sliceDoc(t-1,t))!=xe.Word)return t;for(let r of n){let n=t-r.length;if(e.sliceDoc(n,t)==r&&i(e.sliceDoc(n-1,n))!=xe.Word)return n}return-1}function du(e={}){return[Tc,uc.of(e),Mc,gu,Dc]}const pu=[{key:"Ctrl-Space",run:e=>!!e.state.field(Tc,!1)&&(e.dispatch({effects:ac.of(!0)}),!0)},{key:"Escape",run:e=>{let t=e.state.field(Tc,!1);return!(!t||!t.active.some((e=>0!=e.state)))&&(e.dispatch({effects:lc.of(null)}),!0)}},{key:"ArrowDown",run:Cc(!0)},{key:"ArrowUp",run:Cc(!1)},{key:"PageDown",run:Cc(!0,"page")},{key:"PageUp",run:Cc(!1,"page")},{key:"Enter",run:e=>{let t=e.state.field(Tc,!1);return!(e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestampe.facet(uc).defaultKeymap?[pu]:[])));function mu(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 yu=mu(_u,0),bu=mu(xu,0),vu=mu(((e,t)=>xu(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),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 wu(e,t){let n=e.languageDataAt("commentTokens",t);return n.length?n[0]:{}}function xu(e,t,n=t.selection.ranges){let i=n.map((e=>wu(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,u=/^\s*/.exec(l)[0].length,f=a.length-c;if(a.slice(f-t.length,f)==t&&l.slice(u,u+n.length)==n)return{open:{pos:i-c,margin:c&&1},close:{pos:r+u,margin:u&&1}};r-i<=100?o=s=e.sliceDoc(i,r):(o=e.sliceDoc(i,i+50),s=e.sliceDoc(r-50,r));let h=/^\s*/.exec(o)[0].length,d=/\s*$/.exec(s)[0].length,p=s.length-d-n.length;return o.slice(h,h+t.length)==t&&s.slice(p,p+n.length)==n?{open:{pos:i+h+t.length,margin:/\s/.test(o.charAt(h+t.length))?1:0},close:{pos:r-d-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,n=l.text.slice(e,e+a.length)==a?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 Ou=ue.define(),Su=ue.define(),ku=q.define(),Au=q.define({combine:e=>Ae(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)})});const Tu=j.define({create:()=>Wu.empty,update(e,t){let n=t.state.facet(Au),i=t.annotation(Ou);if(i){let r=t.docChanged?R.single(function(e){let t=0;return e.iterChangedRanges(((e,n)=>t=n)),t}(t.changes)):void 0,o=Ru.fromTransaction(t,r),s=i.side,a=0==s?e.undone:e.done;return a=o?Fu(a,a.length,n.minDepth,o):zu(a,t.startState.selection),new Wu(0==s?i.rest:a,0==s?a:i.rest)}let r=t.annotation(Su);if("full"!=r&&"before"!=r||(e=e.isolate()),!1===t.annotation(pe.addToHistory))return t.changes.empty?e:e.addMapping(t.changes.desc);let o=Ru.fromTransaction(t),s=t.annotation(pe.time),a=t.annotation(pe.userEvent);return o?e=e.addChanges(o,s,a,n,t):t.selection&&(e=e.addSelection(t.startState.selection,s,a,n.newGroupDelay)),"full"!=r&&"after"!=r||(e=e.isolate()),e},toJSON:e=>({done:e.done.map((e=>e.toJSON())),undone:e.undone.map((e=>e.toJSON()))}),fromJSON:e=>new Wu(e.done.map(Ru.fromJSON),e.undone.map(Ru.fromJSON))});function Eu(e={}){return[Tu,Au.of(e),Dr.domEventHandlers({beforeinput(e,t){let n="historyUndo"==e.inputType?$u:"historyRedo"==e.inputType?Mu:null;return!!n&&(e.preventDefault(),n(t))}})]}function Cu(e,t){return function({state:n,dispatch:i}){if(!t&&n.readOnly)return!1;let r=n.field(Tu,!1);if(!r)return!1;let o=r.pop(e,n,t);return!!o&&(i(o),!0)}}const $u=Cu(0,!1),Mu=Cu(1,!1),Du=Cu(0,!0),Pu=Cu(1,!0);class Ru{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 Ru(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 Ru(e.changes&&A.fromJSON(e.changes),[],e.mapped&&k.fromJSON(e.mapped),e.startSelection&&R.fromJSON(e.startSelection),e.selectionsAfter.map(R.fromJSON))}static fromTransaction(e,t){let n=qu;for(let t of e.startState.facet(ku)){let i=t(e);i.length&&(n=n.concat(i))}return!n.length&&e.changes.empty?null:new Ru(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,qu)}static selection(e){return new Ru(void 0,qu,void 0,void 0,e)}}function Fu(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 Nu(e,t){return e.length?t.length?e.concat(t):e:t}const qu=[];function zu(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),Fu(e,e.length-1,1e9,n.setSelAfter(i)))}return[Ru.selection([t])]}function Lu(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 Bu(e,t){if(!e.length)return e;let n=e.length,i=qu;for(;n;){let r=Qu(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?[Ru.selection(i)]:qu}function Qu(e,t,n){let i=Nu(e.selectionsAfter.length?e.selectionsAfter.map((e=>e.map(t))):qu,n);if(!e.changes)return Ru.selection(i);let r=e.changes.map(t),o=t.mapDesc(e.changes,!0),s=e.mapped?e.mapped.composeDesc(o):o;return new Ru(r,de.mapEffects(e.effects,t),s,e.startSelection.map(o),i)}const Iu=/^(input\.type|delete)($|\.)/;class Wu{constructor(e,t,n=0,i){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=i}isolate(){return this.prevTime?new Wu(this.done,this.undone):this}addChanges(e,t,n,i,r){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&e.changes&&(!n||Iu.test(n))&&(!s.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}(s.changes,e.changes))||"input.type.compose"==n)?Fu(o,o.length-1,i.minDepth,new Ru(e.changes.compose(s.changes),Nu(e.effects,s.effects),s.mapped,s.startSelection,qu)):Fu(o,o.length,i.minDepth,e),new Wu(o,qu,t,n)}addSelection(e,t,n,i){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:qu;return r.length>0&&t-this.prevTimee.empty!=s.ranges[t].empty)).length)?this:new Wu(zu(this.done,e),this.undone,t,n);var o,s}addMapping(e){return new Wu(Bu(this.done,e),Bu(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];if(n&&r.selectionsAfter.length)return t.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:Ou.of({side:e,rest:Lu(i)}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let n=1==i.length?qu:i.slice(0,i.length-1);return r.mapped&&(n=Bu(n,r.mapped)),t.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:Ou.of({side:e,rest:n}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}return null}}Wu.empty=new Wu(qu,qu);const ju=[{key:"Mod-z",run:$u,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Mu,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Mu,preventDefault:!0},{key:"Mod-u",run:Du,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Pu,preventDefault:!0}];function Uu(e,t){return R.create(e.ranges.map(t),e.mainIndex)}function Vu(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function Xu({state:e,dispatch:t},n){let i=Uu(e.selection,n);return!i.eq(e.selection)&&(t(Vu(e,i)),!0)}function Yu(e,t){return R.cursor(t?e.to:e.from)}function Hu(e,t){return Xu(e,(n=>n.empty?e.moveByChar(n,t):Yu(n,t)))}function Gu(e){return e.textDirectionAt(e.state.selection.main.head)==In.LTR}const Zu=e=>Hu(e,!Gu(e)),Ku=e=>Hu(e,Gu(e));function Ju(e,t){return Xu(e,(n=>n.empty?e.moveByGroup(n,t):Yu(n,t)))}function ef(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 tf(e,t,n){let i,r,o=$a(e).resolveInner(t.head),s=n?ks.closedBy:ks.openedBy;for(let i=t.head;;){let t=n?o.childAfter(i):o.childBefore(i);if(!t)break;ef(e,t,s)?o=t:i=n?t.to:t.from}return r=o.type.prop(s)&&(i=n?Wl(e,o.from,1):Wl(e,o.to,-1))&&i.matched?n?i.end.to:i.end.from:n?o.to:o.from,R.cursor(r,n?-1:1)}function nf(e,t){return Xu(e,(n=>{if(!n.empty)return Yu(n,t);let i=e.moveVertically(n,t);return i.head!=n.head?i:e.moveToLineBoundary(n,t)}))}const rf=e=>nf(e,!1),of=e=>nf(e,!0);function sf(e){let t,n=e.scrollDOM.clientHeightn.empty?e.moveVertically(n,t,i.height):Yu(n,t)));if(o.eq(r.selection))return!1;if(i.selfScroll){let t=e.coordsAtPos(r.selection.main.head),s=e.scrollDOM.getBoundingClientRect(),a=s.top+i.marginTop,l=s.bottom-i.marginBottom;t&&t.top>a&&t.bottomaf(e,!1),cf=e=>af(e,!0);function uf(e,t,n){let i=e.lineBlockAt(t.head),r=e.moveToLineBoundary(t,n);if(r.head==t.head&&r.head!=(n?i.to:i.from)&&(r=e.moveToLineBoundary(t,n,!1)),!n&&r.head==i.from&&i.length){let n=/^\s*/.exec(e.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;n&&t.head!=i.from+n&&(r=R.cursor(i.from+n))}return r}function ff(e,t){let n=Uu(e.state.selection,(e=>{let n=t(e);return R.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0)}));return!n.eq(e.state.selection)&&(e.dispatch(Vu(e.state,n)),!0)}function hf(e,t){return ff(e,(n=>e.moveByChar(n,t)))}const df=e=>hf(e,!Gu(e)),pf=e=>hf(e,Gu(e));function gf(e,t){return ff(e,(n=>e.moveByGroup(n,t)))}function mf(e,t){return ff(e,(n=>e.moveVertically(n,t)))}const yf=e=>mf(e,!1),bf=e=>mf(e,!0);function vf(e,t){return ff(e,(n=>e.moveVertically(n,t,sf(e).height)))}const wf=e=>vf(e,!1),xf=e=>vf(e,!0),_f=({state:e,dispatch:t})=>(t(Vu(e,{anchor:0})),!0),Of=({state:e,dispatch:t})=>(t(Vu(e,{anchor:e.doc.length})),!0),Sf=({state:e,dispatch:t})=>(t(Vu(e,{anchor:e.selection.main.anchor,head:0})),!0),kf=({state:e,dispatch:t})=>(t(Vu(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0);function Af(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:i}=e,r=i.changeByRange((i=>{let{from:r,to:o}=i;if(r==o){let i=t(r);ir&&(n="delete.forward",i=Tf(e,i,!0)),r=Math.min(r,i),o=Math.max(o,i)}else r=Tf(e,r,!1),o=Tf(e,o,!0);return r==o?{range:i}:{changes:{from:r,to:o},range:R.cursor(r)}}));return!r.changes.empty&&(e.dispatch(i.update(r,{scrollIntoView:!0,userEvent:n,effects:"delete.selection"==n?Dr.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function Tf(e,t,n){if(e instanceof Dr)for(let i of e.state.facet(Dr.atomicRanges).map((t=>t(e))))i.between(t,t,((e,i)=>{et&&(t=n?i:e)}));return t}const Ef=(e,t)=>Af(e,(n=>{let i,r,{state:o}=e,s=o.doc.lineAt(n);if(!t&&n>s.from&&nEf(e,!1),$f=e=>Ef(e,!0),Mf=(e,t)=>Af(e,(n=>{let i=n,{state:r}=e,o=r.doc.lineAt(i),s=r.charCategorizer(i);for(let e=null;;){if(i==(t?o.to:o.from)){i==n&&o.number!=(t?r.doc.lines:1)&&(i+=t?1:-1);break}let a=g(o.text,i-o.from,t)+o.from,l=o.text.slice(Math.min(i,a)-o.from,Math.max(i,a)-o.from),c=s(l);if(null!=e&&c!=e)break;" "==l&&i==n||(e=c),i=a}return i})),Df=e=>Mf(e,!1),Pf=e=>Af(e,(t=>{let n=e.lineBlockAt(t).to;return t=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 Ff(e,t,n){if(e.readOnly)return!1;let i=[],r=[];for(let t of Rf(e)){if(n?t.to==e.doc.length:0==t.from)continue;let o=e.doc.lineAt(n?t.to+1:t.from-1),s=o.length+1;if(n){i.push({from:t.to,to:o.to},{from:t.from,insert:o.text+e.lineBreak});for(let n of t.ranges)r.push(R.range(Math.min(e.doc.length,n.anchor+s),Math.min(e.doc.length,n.head+s)))}else{i.push({from:o.from,to:t.from},{from:t.to,insert:e.lineBreak+o.text});for(let e of t.ranges)r.push(R.range(e.anchor-s,e.head-s))}}return!!i.length&&(t(e.update({changes:i,scrollIntoView:!0,selection:R.create(r,e.selection.mainIndex),userEvent:"move.line"})),!0)}function Nf(e,t,n){if(e.readOnly)return!1;let i=[];for(let t of Rf(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)});return t(e.update({changes:i,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const qf=zf(!1);function zf(e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let r=t.changeByRange((i=>{let{from:r,to:o}=i,s=t.doc.lineAt(r),a=!e&&r==o&&function(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n,i=$a(e).resolveInner(t),r=i.childBefore(t),o=i.childAfter(t);return r&&o&&r.to<=t&&o.from>=t&&(n=r.type.prop(ks.closedBy))&&n.indexOf(o.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(o.from).from?{from:r.to,to:o.from}:null}(t,r);e&&(r=o=(o<=s.to?s:t.doc.lineAt(o)).to);let l=new Va(t,{simulateBreak:r,simulateDoubleBreak:!!a}),c=Ua(l,r);for(null==c&&(c=/^\s*/.exec(t.doc.lineAt(r).text)[0].length);os.from&&r{let r=[];for(let o=i.from;o<=i.to;){let s=e.doc.lineAt(o);s.number>n&&(i.empty||i.to>s.from)&&(t(s,r,i),n=s.number),o=s.to+1}let o=e.changes(r);return{changes:r,range:R.range(o.mapPos(i.anchor,1),o.mapPos(i.head,1))}}))}const Bf=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(Lf(e,((t,n)=>{n.push({from:t.from,insert:e.facet(Ia)})})),{userEvent:"input.indent"})),!0),Qf=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(Lf(e,((t,n)=>{let i=/^\s*/.exec(t.text)[0];if(!i)return;let r=We(i,e.tabSize),o=0,s=ja(e,Math.max(0,r-Wa(e)));for(;oXu(e,(t=>tf(e.state,t,!Gu(e)))),shift:e=>ff(e,(t=>tf(e.state,t,!Gu(e))))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e=>Xu(e,(t=>tf(e.state,t,Gu(e)))),shift:e=>ff(e,(t=>tf(e.state,t,Gu(e))))},{key:"Alt-ArrowUp",run:({state:e,dispatch:t})=>Ff(e,t,!1)},{key:"Shift-Alt-ArrowUp",run:({state:e,dispatch:t})=>Nf(e,t,!1)},{key:"Alt-ArrowDown",run:({state:e,dispatch:t})=>Ff(e,t,!0)},{key:"Shift-Alt-ArrowDown",run:({state:e,dispatch:t})=>Nf(e,t,!0)},{key:"Escape",run:({state:e,dispatch:t})=>{let n=e.selection,i=null;return n.ranges.length>1?i=R.create([n.main]):n.main.empty||(i=R.create([R.cursor(n.main.head)])),!!i&&(t(Vu(e,i)),!0)}},{key:"Mod-Enter",run:zf(!0)},{key:"Alt-l",mac:"Ctrl-l",run:({state:e,dispatch:t})=>{let n=Rf(e).map((({from:t,to:n})=>R.range(t,Math.min(n+1,e.doc.length))));return t(e.update({selection:R.create(n),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:e,dispatch:t})=>{let n=Uu(e.selection,(t=>{var n;let i=$a(e).resolveInner(t.head,1);for(;!(i.from=t.to||i.to>t.to&&i.from<=t.from)&&(null===(n=i.parent)||void 0===n?void 0:n.parent);)i=i.parent;return R.range(i.to,i.from)}));return t(Vu(e,n)),!0},preventDefault:!0},{key:"Mod-[",run:Qf},{key:"Mod-]",run:Bf},{key:"Mod-Alt-\\",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),i=new Va(e,{overrideIndentation:e=>{let t=n[e];return null==t?-1:t}}),r=Lf(e,((t,r,o)=>{let s=Ua(i,t.from);if(null==s)return;/\S/.test(t.text)||(s=0);let a=/^\s*/.exec(t.text)[0],l=ja(e,s);(a!=l||o.from{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(Rf(t).map((({from:e,to:n})=>(e>0?e--:ne.moveVertically(t,!0))).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 i=!1,r=Uu(e.selection,(t=>{let r=Wl(e,t.head,-1)||Wl(e,t.head,1)||t.head>0&&Wl(e,t.head-1,1)||t.head{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),i=wu(e.state,n.from);return i.line?yu(e):!!i.block&&vu(e)}},{key:"Alt-A",run:bu}].concat([{key:"ArrowLeft",run:Zu,shift:df,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:e=>Ju(e,!Gu(e)),shift:e=>gf(e,!Gu(e)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:e=>Xu(e,(t=>uf(e,t,!Gu(e)))),shift:e=>ff(e,(t=>uf(e,t,!Gu(e)))),preventDefault:!0},{key:"ArrowRight",run:Ku,shift:pf,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:e=>Ju(e,Gu(e)),shift:e=>gf(e,Gu(e)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:e=>Xu(e,(t=>uf(e,t,Gu(e)))),shift:e=>ff(e,(t=>uf(e,t,Gu(e)))),preventDefault:!0},{key:"ArrowUp",run:rf,shift:yf,preventDefault:!0},{mac:"Cmd-ArrowUp",run:_f,shift:Sf},{mac:"Ctrl-ArrowUp",run:lf,shift:wf},{key:"ArrowDown",run:of,shift:bf,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Of,shift:kf},{mac:"Ctrl-ArrowDown",run:cf,shift:xf},{key:"PageUp",run:lf,shift:wf},{key:"PageDown",run:cf,shift:xf},{key:"Home",run:e=>Xu(e,(t=>uf(e,t,!1))),shift:e=>ff(e,(t=>uf(e,t,!1))),preventDefault:!0},{key:"Mod-Home",run:_f,shift:Sf},{key:"End",run:e=>Xu(e,(t=>uf(e,t,!0))),shift:e=>ff(e,(t=>uf(e,t,!0))),preventDefault:!0},{key:"Mod-End",run:Of,shift:kf},{key:"Enter",run:qf},{key:"Mod-a",run:({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:Cf,shift:Cf},{key:"Delete",run:$f},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Df},{key:"Mod-Delete",mac:"Alt-Delete",run:e=>Mf(e,!0)},{mac:"Mod-Backspace",run:e=>Af(e,(t=>{let n=e.lineBlockAt(t).from;return t>n?n:Math.max(0,t-1)}))},{mac:"Mod-Delete",run:Pf}].concat([{key:"Ctrl-b",run:Zu,shift:df,preventDefault:!0},{key:"Ctrl-f",run:Ku,shift:pf},{key:"Ctrl-p",run:rf,shift:yf},{key:"Ctrl-n",run:of,shift:bf},{key:"Ctrl-a",run:e=>Xu(e,(t=>R.cursor(e.lineBlockAt(t.head).from,1))),shift:e=>ff(e,(t=>R.cursor(e.lineBlockAt(t.head).from)))},{key:"Ctrl-e",run:e=>Xu(e,(t=>R.cursor(e.lineBlockAt(t.head).to,-1))),shift:e=>ff(e,(t=>R.cursor(e.lineBlockAt(t.head).to)))},{key:"Ctrl-d",run:$f},{key:"Ctrl-h",run:Cf},{key:"Ctrl-k",run:Pf},{key:"Ctrl-Alt-h",run:Df},{key:"Ctrl-o",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:n.of(["",""])},range:R.cursor(e.from)})));return t(e.update(i,{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,i=e.doc.lineAt(n),r=n==i.from?n-1:g(i.text,n-i.from,!1)+i.from,o=n==i.to?n+1:g(i.text,n-i.from,!0)+i.from;return{changes:{from:r,to:o,insert:e.doc.slice(n,o).append(e.doc.slice(r,n))},range:R.cursor(o)}}));return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:cf}].map((e=>({mac:e.key,run:e.run,shift:e.shift}))))),Wf={key:"Tab",run:Bf,shift:Qf};function jf(){var e=arguments[0];"string"==typeof e&&(e=document.createElement(e));var t=1,n=arguments[1];if(n&&"object"==typeof n&&null==n.nodeType&&!Array.isArray(n)){for(var i in n)if(Object.prototype.hasOwnProperty.call(n,i)){var r=n[i];"string"==typeof r?e.setAttribute(i,r):null!=r&&(e[i]=r)}t++}for(;te.normalize("NFKD"):e=>e;class Xf{constructor(e,t,n=0,i=e.length,r,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,i),this.bufferStart=n,this.normalize=r?e=>r(Vf(e)):Vf,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 w(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=x(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=_(e);let i=this.normalize(t);for(let e=0,r=n;;e++){let o=i.charCodeAt(e),s=this.match(o,r);if(e==i.length-1){if(s)return this.value=s,this;break}r==n&ðis.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=eh(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,match:t},this;e=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length=n||i.to<=t){let i=new Kf(t,e.sliceString(t,n));return Zf.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,match:t},this.matchPos=eh(this.text,n+(e==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Kf.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function eh(e,t){if(t>=e.length)return t;let n,i=e.lineAt(t);for(;t=56320&&n<57344;)t++;return t}function th(e){let t=jf("input",{class:"cm-textfield",name:"line"});function n(){let n=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!n)return;let{state:i}=e,r=i.doc.lineAt(i.selection.main.head),[,o,s,a,l]=n,c=a?+a.slice(1):0,u=s?+s:r.number;if(s&&l){let e=u/100;o&&(e=e*("-"==o?-1:1)+r.number/i.doc.lines),u=Math.round(i.doc.lines*e)}else s&&o&&(u=u*("-"==o?-1:1)+r.number);let f=i.doc.line(Math.max(1,Math.min(i.doc.lines,u))),h=R.cursor(f.from+Math.max(0,Math.min(c,f.length)));e.dispatch({effects:[nh.of(!1),Dr.scrollIntoView(h.from,{y:"center"})],selection:h}),e.focus()}return{dom:jf("form",{class:"cm-gotoLine",onkeydown:t=>{27==t.keyCode?(t.preventDefault(),e.dispatch({effects:nh.of(!1)}),e.focus()):13==t.keyCode&&(t.preventDefault(),n())},onsubmit:e=>{e.preventDefault(),n()}},jf("label",e.state.phrase("Go to line"),": ",t)," ",jf("button",{class:"cm-button",type:"submit"},e.state.phrase("go")))}}"undefined"!=typeof Symbol&&(Gf.prototype[Symbol.iterator]=Jf.prototype[Symbol.iterator]=function(){return this});const nh=de.define(),ih=j.define({create:()=>!0,update(e,t){for(let n of t.effects)n.is(nh)&&(e=n.value);return e},provide:e=>Jo.from(e,(e=>e?th:null))}),rh=Dr.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),oh={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},sh=q.define({combine:e=>Ae(e,oh,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})});function ah(e){let t=[hh,fh];return e&&t.push(sh.of(e)),t}const lh=on.mark({class:"cm-selectionMatch"}),ch=on.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function uh(e,t,n,i){return!(0!=n&&e(t.sliceDoc(n-1,n))==xe.Word||i!=t.doc.length&&e(t.sliceDoc(i,i+1))==xe.Word)}const fh=Mn.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(sh),{state:n}=e,i=n.selection;if(i.ranges.length>1)return on.none;let r,o=i.main,s=null;if(o.empty){if(!t.highlightWordAroundCursor)return on.none;let e=n.wordAt(o.head);if(!e)return on.none;s=n.charCategorizer(o.head),r=n.sliceDoc(e.from,e.to)}else{let e=o.to-o.from;if(e200)return on.none;if(t.wholeWords){if(r=n.sliceDoc(o.from,o.to),s=n.charCategorizer(o.head),!uh(s,n,o.from,o.to)||!function(e,t,n,i){return e(t.sliceDoc(n,n+1))==xe.Word&&e(t.sliceDoc(i-1,i))==xe.Word}(s,n,o.from,o.to))return on.none}else if(r=n.sliceDoc(o.from,o.to).trim(),!r)return on.none}let a=[];for(let i of e.visibleRanges){let e=new Xf(n.doc,r,i.from,i.to);for(;!e.next().done;){let{from:i,to:r}=e.value;if((!s||uh(s,n,i,r))&&(o.empty&&i<=o.from&&r>=o.to?a.push(ch.range(i,r)):(i>=o.to||r<=o.from)&&a.push(lh.range(i,r)),a.length>t.maxMatches))return on.none}}return on.set(a)}},{decorations:e=>e.decorations}),hh=Dr.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}});const dh=q.define({combine:e=>Ae(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Ih(e),scrollToMatch:e=>Dr.scrollIntoView(e)})});class ph{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,Hf),!0}catch(e){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}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}create(){return this.regexp?new xh(this):new yh(this)}getCursor(e,t=0,n){let i=e.doc?e:ke.create({doc:e});return null==n&&(n=i.doc.length),this.regexp?bh(this,i,t,n):mh(this,i,t,n)}}class gh{constructor(e){this.spec=e}}function mh(e,t,n,i){return new Xf(t.doc,e.unquoted,n,i,e.caseSensitive?void 0:e=>e.toLowerCase(),e.wholeWord?function(e,t){return(n,i,r,o)=>((o>n||o+r.length=t)return null;i.push(n.value)}return i}highlight(e,t,n,i){let r=mh(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 bh(e,t,n,i){return new Gf(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:e.wholeWord?(r=t.charCategorizer(t.selection.main.head),(e,t,n)=>!n[0].length||(r(vh(n.input,n.index))!=xe.Word||r(wh(n.input,n.index))!=xe.Word)&&(r(wh(n.input,n.index+n[0].length))!=xe.Word||r(vh(n.input,n.index+n[0].length))!=xe.Word)):void 0},n,i);var r}function vh(e,t){return e.slice(g(e,t,!1),t)}function wh(e,t){return e.slice(t,g(e,t))}class xh extends gh{nextMatch(e,t,n){let i=bh(this.spec,e,n,e.doc.length).next();return i.done&&(i=bh(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=bh(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)=>"$"==n?"$":"&"==n?e.match[0]:"0"!=n&&+n=t)return null;i.push(n.value)}return i}highlight(e,t,n,i){let r=bh(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 _h=de.define(),Oh=de.define(),Sh=j.define({create:e=>new kh(Nh(e).create(),null),update(e,t){for(let n of t.effects)n.is(_h)?e=new kh(n.value.create(),e.panel):n.is(Oh)&&(e=new kh(e.query,n.value?Fh:null));return e},provide:e=>Jo.from(e,(e=>e.panel))});class kh{constructor(e,t){this.query=e,this.panel=t}}const Ah=on.mark({class:"cm-searchMatch"}),Th=on.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Eh=Mn.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(Sh))}update(e){let t=e.state.field(Sh);(t!=e.startState.field(Sh)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return on.none;let{view:n}=this,i=new De;for(let t=0,r=n.visibleRanges,o=r.length;tr[t+1].from-500;)a=r[++t].to;e.highlight(n.state,s,a,((e,t)=>{let r=n.state.selection.ranges.some((n=>n.from==e&&n.to==t));i.add(e,t,r?Th:Ah)}))}return i.finish()}},{decorations:e=>e.decorations});function Ch(e){return t=>{let n=t.state.field(Sh,!1);return n&&n.query.spec.valid?e(t,n):Lh(t)}}const $h=Ch(((e,{query:t})=>{let{to:n}=e.state.selection.main,i=t.nextMatch(e.state,n,n);if(!i)return!1;let r=R.single(i.from,i.to),o=e.state.facet(dh);return e.dispatch({selection:r,effects:[Uh(e,i),o.scrollToMatch(r.main,e)],userEvent:"select.search"}),zh(e),!0})),Mh=Ch(((e,{query:t})=>{let{state:n}=e,{from:i}=n.selection.main,r=t.prevMatch(n,i,i);if(!r)return!1;let o=R.single(r.from,r.to),s=e.state.facet(dh);return e.dispatch({selection:o,effects:[Uh(e,r),s.scrollToMatch(o.main,e)],userEvent:"select.search"}),zh(e),!0})),Dh=Ch(((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!(!n||!n.length)&&(e.dispatch({selection:R.create(n.map((e=>R.range(e.from,e.to)))),userEvent:"select.search.matches"}),!0)})),Ph=Ch(((e,{query:t})=>{let{state:n}=e,{from:i,to:r}=n.selection.main;if(n.readOnly)return!1;let o=t.nextMatch(n,i,i);if(!o)return!1;let s,a,l=[],c=[];if(o.from==i&&o.to==r&&(a=n.toText(t.getReplacement(o)),l.push({from:o.from,to:o.to,insert:a}),o=t.nextMatch(n,o.from,o.to),c.push(Dr.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(i).number)+"."))),o){let t=0==l.length||l[0].from>=o.to?0:o.to-o.from-a.length;s=R.single(o.from-t,o.to-t),c.push(Uh(e,o)),c.push(n.facet(dh).scrollToMatch(s.main,e))}return e.dispatch({changes:l,selection:s,effects:c,userEvent:"input.replace"}),!0})),Rh=Ch(((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map((e=>{let{from:n,to:i}=e;return{from:n,to:i,insert:t.getReplacement(e)}}));if(!n.length)return!1;let i=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:Dr.announce.of(i),userEvent:"input.replace.all"}),!0}));function Fh(e){return e.state.facet(dh).createPanel(e)}function Nh(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(dh);return new ph({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 qh(e){let t=Ho(e,Fh);return t&&t.dom.querySelector("[main-field]")}function zh(e){let t=qh(e);t&&t==e.root.activeElement&&t.select()}const Lh=e=>{let t=e.state.field(Sh,!1);if(t&&t.panel){let n=qh(e);if(n&&n!=e.root.activeElement){let i=Nh(e.state,t.query.spec);i.valid&&e.dispatch({effects:_h.of(i)}),n.focus(),n.select()}}else e.dispatch({effects:[Oh.of(!0),t?_h.of(Nh(e.state,t.query.spec)):de.appendConfig.of(Xh)]});return!0},Bh=e=>{let t=e.state.field(Sh,!1);if(!t||!t.panel)return!1;let n=Ho(e,Fh);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:Oh.of(!1)}),!0},Qh=[{key:"Mod-f",run:Lh,scope:"editor search-panel"},{key:"F3",run:$h,shift:Mh,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:$h,shift:Mh,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Bh,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:r}=n.main,o=[],s=0;for(let t=new Xf(e.doc,e.sliceDoc(i,r));!t.next().done;){if(o.length>1e3)return!1;t.value.from==i&&(s=o.length),o.push(R.range(t.value.from,t.value.to))}return t(e.update({selection:R.create(o,s),userEvent:"select.search.matches"})),!0}},{key:"Alt-g",run:e=>{let t=Ho(e,th);if(!t){let n=[nh.of(!0)];null==e.state.field(ih,!1)&&n.push(de.appendConfig.of([ih,rh])),e.dispatch({effects:n}),t=Ho(e,th)}return t&&t.dom.querySelector("input").focus(),!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.create(n.ranges.map((t=>e.wordAt(t.head)||R.cursor(t.head))),n.mainIndex);return!i.eq(n)&&(t(e.update({selection:i})),!0)})({state:e,dispatch:t});let i=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some((t=>e.sliceDoc(t.from,t.to)!=i)))return!1;let r=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 Xf(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 Xf(e.doc,t,0,Math.max(0,i[i.length-1].from-1)),n=!0}}(e,i);return!!r&&(t(e.update({selection:e.selection.addRange(R.range(r.from,r.to),!1),effects:Dr.scrollIntoView(r.to)})),!0)},preventDefault:!0}];class Ih{constructor(e){this.view=e;let t=this.query=e.state.field(Sh).query.spec;function n(e,t,n){return jf("button",{class:"cm-button",name:e,onclick:t,type:"button"},n)}this.commit=this.commit.bind(this),this.searchField=jf("input",{value:t.search,placeholder:Wh(e,"Find"),"aria-label":Wh(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=jf("input",{value:t.replace,placeholder:Wh(e,"Replace"),"aria-label":Wh(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=jf("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=jf("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=jf("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit}),this.dom=jf("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,n("next",(()=>$h(e)),[Wh(e,"next")]),n("prev",(()=>Mh(e)),[Wh(e,"previous")]),n("select",(()=>Dh(e)),[Wh(e,"all")]),jf("label",null,[this.caseField,Wh(e,"match case")]),jf("label",null,[this.reField,Wh(e,"regexp")]),jf("label",null,[this.wordField,Wh(e,"by word")]),...e.state.readOnly?[]:[jf("br"),this.replaceField,n("replace",(()=>Ph(e)),[Wh(e,"replace")]),n("replaceAll",(()=>Rh(e)),[Wh(e,"replace all")])],jf("button",{name:"close",onclick:()=>Bh(e),"aria-label":Wh(e,"close"),type:"button"},["×"])])}commit(){let e=new ph({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:_h.of(e)}))}keydown(e){var t,n,i;t=this.view,n=e,i="search-panel",jr(Ir(t.state),n,t,i)?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Mh:$h)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),Ph(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(_h)&&!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(dh).top}}function Wh(e,t){return e.state.phrase(t)}const jh=/[\s\.,:;?!]/;function Uh(e,{from:t,to:n}){let i=e.state.doc.lineAt(t),r=e.state.doc.lineAt(n).to,o=Math.max(i.from,t-30),s=Math.min(r,n+30),a=e.state.sliceDoc(o,s);if(o!=i.from)for(let e=0;e<30;e++)if(!jh.test(a[e+1])&&jh.test(a[e])){a=a.slice(e);break}if(s!=r)for(let e=a.length-1;e>a.length-30;e--)if(!jh.test(a[e-1])&&jh.test(a[e])){a=a.slice(0,e);break}return Dr.announce.of(`${e.state.phrase("current match")}. ${a} ${e.state.phrase("on line")} ${i.number}.`)}const Vh=Dr.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"}}),Xh=[Sh,G.lowest(Eh),Vh];class Yh{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}}class Hh{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let i=e,r=n.facet(sd).markerFilter;r&&(i=r(i));let o=on.set(i.map((e=>e.from==e.to||e.from==e.to-1&&n.doc.lineAt(e.from).to==e.from?on.widget({widget:new cd(e),diagnostic:e}).range(e.from):on.mark({attributes:{class:"cm-lintRange cm-lintRange-"+e.severity+(e.markClass?" "+e.markClass:"")},diagnostic:e}).range(e.from,e.to))),!0);return new Hh(o,t,Gh(o))}}function Gh(e,t=null,n=0){let i=null;return e.between(n,1e9,((e,n,{spec:r})=>{if(!t||r.diagnostic==t)return i=new Yh(e,n,r.diagnostic),!1})),i}const Zh=de.define(),Kh=de.define(),Jh=de.define(),ed=j.define({create:()=>new Hh(on.none,null,null),update(e,t){if(t.docChanged){let n=e.diagnostics.map(t.changes),i=null;if(e.selected){let r=t.changes.mapPos(e.selected.from,1);i=Gh(n,e.selected.diagnostic,r)||Gh(n,null,r)}e=new Hh(n,e.panel,i)}for(let n of t.effects)n.is(Zh)?e=Hh.init(n.value,e.panel,t.state):n.is(Kh)?e=new Hh(e.diagnostics,n.value?fd.open:null,e.selected):n.is(Jh)&&(e=new Hh(e.diagnostics,e.panel,n.value));return e},provide:e=>[Jo.from(e,(e=>e.panel)),Dr.decorations.from(e,(e=>e.diagnostics))]}),td=on.mark({class:"cm-lintRange cm-lintRange-active"});function nd(e,t,n){let{diagnostics:i}=e.state.field(ed),r=[],o=2e8,s=0;i.between(t-(n<0?1:0),t+(n>0?1:0),((e,i,{spec:a})=>{t>=e&&t<=i&&(e==i||(t>e||n>0)&&(t({dom:id(e,r)})}:null}function id(e,t){return jf("ul",{class:"cm-tooltip-lint"},t.map((t=>ld(e,t,!1))))}const rd=e=>{let t=e.state.field(ed,!1);return!(!t||!t.panel)&&(e.dispatch({effects:Kh.of(!1)}),!0)},od=[{key:"Mod-Shift-m",run:e=>{let t=e.state.field(ed,!1);var n,i;t&&t.panel||e.dispatch({effects:(n=e.state,i=[Kh.of(!0)],n.field(ed,!1)?i:i.concat(de.appendConfig.of(pd)))});let r=Ho(e,fd.open);return r&&r.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:e=>{let t=e.state.field(ed,!1);if(!t)return!1;let n=e.state.selection.main,i=t.diagnostics.iter(n.to+1);return!(!i.value&&(i=t.diagnostics.iter(0),!i.value||i.from==n.from&&i.to==n.to))&&(e.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)}}],sd=q.define({combine:e=>Object.assign({sources:e.map((e=>e.source))},Ae(e.map((e=>e.config)),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null},{needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t}))});function ad(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 ld(e,t,n){var i;let r=n?ad(t.actions):[];return jf("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},jf("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage():t.message),null===(i=t.actions)||void 0===i?void 0:i.map(((n,i)=>{let o=!1,s=i=>{if(i.preventDefault(),o)return;o=!0;let r=Gh(e.state.field(ed).diagnostics,t);r&&n.apply(e,r.from,r.to)},{name:a}=n,l=r[i]?a.indexOf(r[i]):-1,c=l<0?a:[a.slice(0,l),jf("u",a.slice(l,l+1)),a.slice(l+1)];return jf("button",{type:"button",class:"cm-diagnosticAction",onclick:s,onmousedown:s,"aria-label":` Action: ${a}${l<0?"":` (access key "${r[i]})"`}.`},c)})),t.source&&jf("div",{class:"cm-diagnosticSource"},t.source))}class cd extends nn{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return jf("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}}class ud{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=ld(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class fd{constructor(e){this.view=e,this.items=[];this.list=jf("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t=>{if(27==t.keyCode)rd(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=ad(n.actions);for(let r=0;r{for(let t=0;trd(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(ed).selected;if(!e)return-1;for(let t=0;t{let a,l=-1;for(let e=n;en&&(this.items.splice(n,l-n),i=!0)),t&&a.diagnostic==t.diagnostic?a.dom.hasAttribute("aria-selected")||(a.dom.setAttribute("aria-selected","true"),r=a):a.dom.hasAttribute("aria-selected")&&a.dom.removeAttribute("aria-selected"),n++}));n({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{e.topt.bottom&&(this.list.scrollTop+=e.bottom-t.bottom)}})):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=Gh(this.view.state.field(ed).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:Jh.of(t)})}static open(e){return new fd(e)}}function hd(e){return function(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,')`}(``,'width="6" height="3"')}const dd=Dr.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:hd("#d11")},".cm-lintRange-warning":{backgroundImage:hd("orange")},".cm-lintRange-info":{backgroundImage:hd("#999")},".cm-lintRange-hint":{backgroundImage:hd("#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}}}),pd=[ed,Dr.decorations.compute([ed],(e=>{let{selected:t,panel:n}=e.field(ed);return t&&n&&t.from!=t.to?on.set([td.range(t.from,t.to)]):on.none})),Uo(nd,{hideOn:function(e,t){let n=e.startState.doc.lineAt(t.pos);return!(!e.effects.some((e=>e.is(Zh)))&&!e.changes.touchesRange(n.from,n.to))}}),dd];class gd{constructor(e,t,n,i,r,o,s,a,l,c=0,u){this.p=e,this.stack=t,this.state=n,this.reducePos=i,this.pos=r,this.score=o,this.buffer=s,this.bufferBase=a,this.curContext=l,this.lookAhead=c,this.parent=u}toString(){return`[${this.stack.filter(((e,t)=>t%3==0)).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,n=0){let i=e.parser.context;return new gd(e,[],t,n,n,0,[],0,i?new md(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let n=e>>19,i=65535&e,{parser:r}=this.p,o=r.dynamicPrecedence(i);if(o&&(this.score+=o),0==n)return this.pushState(r.getGoto(this.state,i,!0),this.reducePos),i=2e3&&!(null===(t=this.p.parser.nodeSet.types[i])||void 0===t?void 0:t.isAnonymous)&&(a==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=l):this.p.lastBigReductionSizes;)this.stack.pop();this.reduceContext(i,a)}storeNode(e,t,n,i=4,r=!1){if(0==e&&(!this.stack.length||this.stack[this.stack.length-1]0&&0==e.buffer[i-4]&&e.buffer[i-1]>-1){if(t==n)return;if(e.buffer[i-2]>=t)return void(e.buffer[i-2]=n)}}if(r&&this.pos!=n){let r=this.buffer.length;if(r>0&&0!=this.buffer[r-4])for(;r>0&&this.buffer[r-2]>n;)this.buffer[r]=this.buffer[r-4],this.buffer[r+1]=this.buffer[r-3],this.buffer[r+2]=this.buffer[r-2],this.buffer[r+3]=this.buffer[r-1],r-=4,i>4&&(i-=4);this.buffer[r]=e,this.buffer[r+1]=t,this.buffer[r+2]=n,this.buffer[r+3]=i}else this.buffer.push(e,t,n,i)}shift(e,t,n){let i=this.pos;if(131072&e)this.pushState(65535&e,this.pos);else if(0==(262144&e)){let r=e,{parser:o}=this.p;(n>this.pos||t<=o.maxNode)&&(this.pos=n,o.stateFlag(r,1)||(this.reducePos=n)),this.pushState(r,i),this.shiftContext(t,i),t<=o.maxNode&&this.buffer.push(t,i,n,4)}else this.pos=n,this.shiftContext(t,i),t<=this.p.parser.maxNode&&this.buffer.push(t,i,n,4)}apply(e,t,n){65536&e?this.reduce(e):this.shift(e,t,n)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let i=this.pos;this.reducePos=this.pos=i+e.length,this.pushState(t,i),this.buffer.push(n,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let n=e.buffer.slice(t),i=e.bufferBase+t;for(;e&&i==e.bufferBase;)e=e.parent;return new gd(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,n,i,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new bd(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(0==n)return!1;if(0==(65536&n))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let n=[];for(let i,r=0;r1&t&&e==i))||n.push(t[e],i)}t=n}let n=[];for(let e=0;e>19,i=65535&t,r=this.stack.length-3*n;if(r<0||e.getGoto(this.stack[r],i,!1)<0){let e=this.findForcedReduction();if(null==e)return!1;t=e}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(i,r)=>{if(!t.includes(i))return t.push(i),e.allActions(i,(t=>{if(393216&t);else if(65536&t){let n=(t>>19)-r;if(n>1){let i=65535&t,r=this.stack.length-3*n;if(r>=0&&e.getGoto(this.stack[r],i,!1)>=0)return n<<19|65536|i}}else{let e=n(t,r+1);if(null!=e)return e}}))};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(3!=this.stack.length)return!1;let{parser:e}=this.p;return 65535==e.data[e.stateSlot(this.state,1)]&&!e.stateSlot(this.state,4)}restart(){this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;tthis.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class md{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}var yd;!function(e){e[e.Insert=200]="Insert",e[e.Delete=190]="Delete",e[e.Reduce=100]="Reduce",e[e.MaxNext=4]="MaxNext",e[e.MaxInsertStackDepth=300]="MaxInsertStackDepth",e[e.DampenInsertStackDepth=120]="DampenInsertStackDepth",e[e.MinBigReduction=2e3]="MinBigReduction"}(yd||(yd={}));class bd{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=65535&e,n=e>>19;0==n?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=3*(n-1);let i=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=i}}class vd{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,0==this.index&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new vd(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;null!=e&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,0==this.index&&this.maybeNext()}fork(){return new vd(this.stack,this.pos,this.index)}}function wd(e,t=Uint16Array){if("string"!=typeof e)return e;let n=null;for(let i=0,r=0;i=92&&t--,t>=34&&t--;let r=t-32;if(r>=46&&(r-=46,n=!0),o+=r,n)break;o*=46}n?n[r++]=o:n=new t(o)}return n}class xd{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const _d=new xd;class Od{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=_d,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,i=this.rangeIndex,r=this.pos+e;for(;rn.to:r>=n.to;){if(i==this.ranges.length-1)return null;let e=this.ranges[++i];r+=e.from-n.to,n=e}return r}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,t.from);return this.end}peek(e){let t,n,i=this.chunkOff+e;if(i>=0&&i=this.chunk2Pos&&ti.to&&(this.chunk2=this.chunk2.slice(0,i.to-t)),n=this.chunk2.charCodeAt(0)}}return t>=this.token.lookAhead&&(this.token.lookAhead=t+1),n}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(null==n||n=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=_d,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n="";for(let i of this.ranges){if(i.from>=t)break;i.to>e&&(n+=this.input.read(Math.max(i.from,e),Math.min(i.to,t)))}return n}}class Sd{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;!function(e,t,n,i,r,o){let s=0,a=1<0){let n=e[i];if(l.allows(n)&&(-1==t.token.value||t.token.value==n||Td(n,t.token.value,r,o))){t.acceptToken(n);break}}let i=t.next,c=0,u=e[s+2];if(!(t.next<0&&u>c&&65535==e[n+3*u-3]&&65535==e[n+3*u-3])){for(;c>1,o=n+r+(r<<1),a=e[o],l=e[o+1]||65536;if(i=l)){s=e[o+2],t.advance();continue e}c=r+1}}break}s=e[n+3*u-1]}}(this.data,e,t,this.id,n.data,n.tokenPrecTable)}}Sd.prototype.contextual=Sd.prototype.fallback=Sd.prototype.extend=!1,Sd.prototype.fallback=Sd.prototype.extend=!1;class kd{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}}function Ad(e,t,n){for(let i,r=t;65535!=(i=e[r]);r++)if(i==n)return r-t;return-1}function Td(e,t,n,i){let r=Ad(n,i,t);return r<0||Ad(n,i,e)t)&&!i.type.isError)return n<0?Math.max(0,Math.min(i.to-1,t-25)):Math.min(e.length,Math.max(i.from+1,t+25));if(n<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return n<0?0:e.length}}!function(e){e[e.Margin=25]="Margin"}($d||($d={}));class Pd{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?Dd(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?Dd(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(ee)return this.nextStart=o,null;if(r instanceof Ds){if(o==e){if(o=Math.max(this.safeFrom,e)&&(this.trees.push(r),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+r.length}}}class Rd{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map((e=>new xd))}getActions(e){let t=0,n=null,{parser:i}=e.p,{tokenizers:r}=i,o=i.stateSlot(e.state,3),s=e.curContext?e.curContext.hash:0,a=0;for(let i=0;ic.end+25&&(a=Math.max(c.lookAhead,a)),0!=c.value)){let i=t;if(c.extended>-1&&(t=this.addActions(e,c.extended,c.end,t)),t=this.addActions(e,c.value,c.end,t),!l.extend&&(n=c,t>i))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),n||e.pos!=this.stream.end||(n=new xd,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new xd,{pos:n,p:i}=e;return t.start=n,t.end=Math.min(n+1,i.stream.end),t.value=n==i.stream.end?i.parser.eofTerm:0,t}updateCachedToken(e,t,n){let i=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(i,e),n),e.value>-1){let{parser:t}=n.p;for(let i=0;i=0&&n.p.parser.dialect.allows(r>>1)){0==(1&r)?e.value=r>>1:e.extended=r>>1;break}}}else e.value=0,e.end=this.stream.clipPos(i+1)}putAction(e,t,n,i){for(let t=0;t4*e.bufferLength?new Pd(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e,t,n=this.stacks,i=this.minStackPos,r=this.stacks=[];if(this.bigReductionCount>300&&1==n.length){let[e]=n;for(;e.forceReduce()&&e.stack.length&&e.stack[e.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;oi)r.push(s);else{if(this.advanceStack(s,r,n))continue;{e||(e=[],t=[]),e.push(s);let n=this.tokens.getMainToken(s);t.push(n.value,n.end)}}break}}if(!r.length){let t=e&&function(e){let t=null;for(let n of e){let e=n.p.stoppedAt;(n.pos==n.p.stream.end||null!=e&&n.pos>e)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.scorethis.stoppedAt?e[0]:this.runRecovery(e,t,r);if(n)return this.stackToTree(n.forceAll())}if(this.recovering){let e=1==this.recovering?1:3*this.recovering;if(r.length>e)for(r.sort(((e,t)=>t.score-e.score));r.length>e;)r.pop();r.some((e=>e.reducePos>i))&&this.recovering--}else if(r.length>1){e:for(let e=0;e500&&i.buffer.length>500){if(!((t.score-i.score||t.buffer.length-i.buffer.length)>0)){r.splice(e--,1);continue e}r.splice(n--,1)}}}r.length>12&&r.splice(12,r.length-12)}this.minStackPos=r[0].pos;for(let e=1;e ":"";if(null!=this.stoppedAt&&i>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let t=e.curContext&&e.curContext.tracker.strict,n=t?e.curContext.hash:0;for(let s=this.fragments.nodeAt(i);s;){let i=this.parser.nodeSet.types[s.type.id]==s.type?r.getGoto(e.state,s.type.id):-1;if(i>-1&&s.length&&(!t||(s.prop(ks.contextHash)||0)==n))return e.useNode(s,i),Ed&&console.log(o+this.stackID(e)+` (via reuse of ${r.getName(s.type.id)})`),!0;if(!(s instanceof Ds)||0==s.children.length||s.positions[0]>0)break;let a=s.children[0];if(!(a instanceof Ds&&0==s.positions[0]))break;s=a}}let s=r.stateSlot(e.state,4);if(s>0)return e.reduce(s),Ed&&console.log(o+this.stackID(e)+` (via always-reduce ${r.getName(65535&s)})`),!0;if(e.stack.length>=15e3)for(;e.stack.length>9e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let s=0;si?t.push(h):n.push(h)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return Nd(e,t),!0}}runRecovery(e,t,n){let i=null,r=!1;for(let o=0;o ":"";if(s.deadEnd){if(r)continue;if(r=!0,s.restart(),Ed&&console.log(c+this.stackID(s)+" (restarted)"),this.advanceFully(s,n))continue}let u=s.split(),f=c;for(let e=0;u.forceReduce()&&e<10;e++){if(Ed&&console.log(f+this.stackID(u)+" (via force-reduce)"),this.advanceFully(u,n))break;Ed&&(f=this.stackID(u)+" -> ")}for(let e of s.recoverByInsert(a))Ed&&console.log(c+this.stackID(e)+" (via recover-insert)"),this.advanceFully(e,n);this.stream.end>s.pos?(l==s.pos&&(l++,a=0),s.recoverByDelete(a,l),Ed&&console.log(c+this.stackID(s)+` (via recover-delete ${this.parser.getName(a)})`),Nd(s,n)):(!i||i.scoree;class Ld extends Gs{constructor(e){if(super(),this.wrappers=[],14!=e.version)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let n=0;ne.topRules[t][1])),i=[];for(let e=0;e=0)r(i,e,t[n++]);else{let o=t[n+-i];for(let s=-i;s>0;s--)r(t[n++],e,o);n++}}}this.nodeSet=new Es(t.map(((t,r)=>Ts.define({name:r>=this.minRepeatTerm?void 0:t,id:r,props:i[r],top:n.indexOf(r)>-1,error:0==r,skipped:e.skippedNodes&&e.skippedNodes.indexOf(r)>-1})))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=_s;let o=wd(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let e=0;e"number"==typeof e?new Sd(o,e):e)),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let i=new Fd(this,e,t,n);for(let r of this.wrappers)i=r(i,e,t,n);return i}getGoto(e,t,n=!1){let i=this.goto;if(t>=i[0])return-1;for(let r=i[t+1];;){let t=i[r++],o=1&t,s=i[r++];if(o&&n)return s;for(let n=r+(t>>1);r0}validAction(e,t){return!!this.allActions(e,(e=>e==t||null))}allActions(e,t){let n=this.stateSlot(e,4),i=n?t(n):void 0;for(let n=this.stateSlot(e,1);null==i;n+=3){if(65535==this.data[n]){if(1!=this.data[n+1])break;n=Bd(this.data,n+2)}i=t(Bd(this.data,n+1))}return i}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(65535==this.data[n]){if(1!=this.data[n+1])break;n=Bd(this.data,n+2)}if(0==(1&this.data[n+2])){let e=this.data[n+1];t.some(((t,n)=>1&n&&t==e))||t.push(this.data[n],e)}}return t}configure(e){let t=Object.assign(Object.create(Ld.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let n=this.topRules[e.top];if(!n)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=n}return e.tokenizers&&(t.tokenizers=this.tokenizers.map((t=>{let n=e.tokenizers.find((e=>e.from==t));return n?n.to:t}))),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map(((n,i)=>{let r=e.specializers.find((e=>e.from==n.external));if(!r)return n;let o=Object.assign(Object.assign({},n),{external:r.to});return t.specializers[i]=Qd(o),o}))),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),null!=e.strict&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),null!=e.bufferLength&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return null==t?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map((()=>!1));if(e)for(let i of e.split(" ")){let e=t.indexOf(i);e>=0&&(n[e]=!0)}let i=null;for(let e=0;ee.external(n,i)<<1|t}return e.get}const Id=new Set([27,51,52,265,67,129,58,59,246,64,65,74,62,63,150,151,154]);function Wd(e){return 10==e||13==e}const jd=new kd(((e,t)=>{let n;if(e.next<0)e.acceptToken(201);else if(t.context.depth<0)Wd(e.next)&&e.acceptToken(200,1);else if(((n=e.peek(-1))<0||Wd(n))&&t.canShift(199)){let t=0;for(;32==e.next||9==e.next;)e.advance(),t++;10!=e.next&&13!=e.next&&35!=e.next||e.acceptToken(199,-t)}else Wd(e.next)&&e.acceptToken(198,1)}),{contextual:!0}),Ud=new kd(((e,t)=>{let n=t.context.depth;if(n<0)return;let i=e.peek(-1);if(10==i||13==i){let t=0,i=0;for(;;){if(32==e.next)t++;else{if(9!=e.next)break;t+=8-t%8}e.advance(),i++}t!=n&&10!=e.next&&13!=e.next&&35!=e.next&&(t0),this.strict=!1!==e.strict}}({start:Xd,reduce:(e,t)=>e.depth<0&&Id.has(t)?e.parent:e,shift:(e,t,n,i)=>196==t?new Vd(e,function(e){let t=0;for(let n=0;ne.hash}),Hd=new kd((e=>{for(let t=0;t<5;t++){if(e.next!="print".charCodeAt(t))return;e.advance()}if(!/\w/.test(String.fromCharCode(e.next)))for(let t=0;;t++){let n=e.peek(t);if(32!=n&&9!=n)return void(40!=n&&46!=n&&10!=n&&13!=n&&35!=n&&e.acceptToken(1))}}));function Gd(e,t,n,i,r){return new kd((o=>{let s=o.pos;for(;!(o.next<0);)if(123==o.next){if(123!=o.peek(1)){if(o.pos==s)return void o.acceptToken(i,1);break}o.advance(2)}else if(92==o.next)o.advance(),o.next>=0&&o.advance();else{if(o.next==e&&(1==t||o.peek(1)==e&&o.peek(2)==e)){if(o.pos==s)return void o.acceptToken(r,t);break}o.advance()}o.pos>s&&o.acceptToken(n)}))}const Zd=Gd(39,1,202,2,203),Kd=Gd(34,1,204,3,205),Jd=Gd(39,3,206,4,207),ep=Gd(34,3,208,5,209),tp=na({'async "*" "**" FormatConversion FormatSpec':Oa.modifier,"for while if elif else try except finally return raise break continue with pass assert await yield match case":Oa.controlKeyword,"in not and or is del":Oa.operatorKeyword,"from def class global nonlocal lambda":Oa.definitionKeyword,import:Oa.moduleKeyword,"with as print":Oa.keyword,Boolean:Oa.bool,None:Oa.null,VariableName:Oa.variableName,"CallExpression/VariableName":Oa.function(Oa.variableName),"FunctionDefinition/VariableName":Oa.function(Oa.definition(Oa.variableName)),"ClassDefinition/VariableName":Oa.definition(Oa.className),PropertyName:Oa.propertyName,"CallExpression/MemberExpression/PropertyName":Oa.function(Oa.propertyName),Comment:Oa.lineComment,Number:Oa.number,String:Oa.string,FormatString:Oa.special(Oa.string),UpdateOp:Oa.updateOperator,"ArithOp!":Oa.arithmeticOperator,BitOp:Oa.bitwiseOperator,CompareOp:Oa.compareOperator,AssignOp:Oa.definitionOperator,Ellipsis:Oa.punctuation,At:Oa.meta,"( )":Oa.paren,"[ ]":Oa.squareBracket,"{ }":Oa.brace,".":Oa.derefOperator,", ;":Oa.separator}),np={__proto__:null,await:48,or:58,and:60,in:64,not:66,is:68,if:74,else:76,lambda:80,yield:98,from:100,async:106,for:108,None:168,True:170,False:170,del:184,pass:188,break:192,continue:196,return:200,raise:208,import:212,as:214,global:218,nonlocal:220,assert:224,elif:234,while:238,try:244,except:246,finally:248,with:252,def:256,class:266,match:277,case:283},ip=Ld.deserialize({version:14,states:"#!OO`Q#yOOP$_OSOOO%hQ&nO'#H^OOQS'#Cq'#CqOOQS'#Cr'#CrO'WQ#xO'#CpO(yQ&nO'#H]OOQS'#H^'#H^OOQS'#DW'#DWOOQS'#H]'#H]O)gQ#xO'#DaO)zQ#xO'#DhO*[Q#xO'#DlOOQS'#Dw'#DwO*oO,UO'#DwO*wO7[O'#DwO+POWO'#DxO+[O`O'#DxO+gOpO'#DxO+rO!bO'#DxO-tQ&nO'#G}OOQS'#G}'#G}O'WQ#xO'#G|O/WQ&nO'#G|OOQS'#Ee'#EeO/oQ#xO'#EfOOQS'#G{'#G{O/yQ#xO'#GzOOQV'#Gz'#GzO0UQ#xO'#FXOOQS'#G`'#G`O0ZQ#xO'#FWOOQV'#IS'#ISOOQV'#Gy'#GyOOQV'#Fp'#FpQ`Q#yOOO'WQ#xO'#CsO0iQ#xO'#DPO0pQ#xO'#DTO1OQ#xO'#HbO1`Q&nO'#EYO'WQ#xO'#EZOOQS'#E]'#E]OOQS'#E_'#E_OOQS'#Ea'#EaO1tQ#xO'#EcO2[Q#xO'#EgO0UQ#xO'#EiO2oQ&nO'#EiO0UQ#xO'#ElO/oQ#xO'#EoO/oQ#xO'#EsO/oQ#xO'#EvO2zQ#xO'#ExO3RQ#xO'#E}O3^Q#xO'#EyO/oQ#xO'#E}O0UQ#xO'#FPO0UQ#xO'#FUO3cQ#xO'#FZP3jO#xO'#GxPOOO)CBl)CBlOOQS'#Cg'#CgOOQS'#Ch'#ChOOQS'#Ci'#CiOOQS'#Cj'#CjOOQS'#Ck'#CkOOQS'#Cl'#ClOOQS'#Cn'#CnO'WQ#xO,59QO'WQ#xO,59QO'WQ#xO,59QO'WQ#xO,59QO'WQ#xO,59QO'WQ#xO,59QO3uQ#xO'#DqOOQS,5:[,5:[O4YQ#xO'#HlOOQS,5:_,5:_O4gQMlO,5:_O4lQ&nO,59[O0iQ#xO,59dO0iQ#xO,59dO0iQ#xO,59dO7[Q#xO,59dO7aQ#xO,59dO7hQ#xO,59lO7oQ#xO'#H]O8uQ#xO'#H[OOQS'#H['#H[OOQS'#D^'#D^O9^Q#xO,59cO'WQ#xO,59cO9lQ#xO,59cOOQS,59{,59{O9qQ#xO,5:TO'WQ#xO,5:TOOQS,5:S,5:SO:PQ#xO,5:SO:UQ#xO,5:ZO'WQ#xO,5:ZO'WQ#xO,5:XOOQS,5:W,5:WO:gQ#xO,5:WO:lQ#xO,5:YOOOO'#Fx'#FxO:qO,UO,5:cOOQS,5:c,5:cOOOO'#Fy'#FyO:yO7[O,5:cO;RQ#xO'#DyOOOW'#Fz'#FzO;cOWO,5:dOOQS,5:d,5:dO;RQ#xO'#D}OOO`'#F}'#F}O;nO`O,5:dO;RQ#xO'#EOOOOp'#GO'#GOO;yOpO,5:dO;RQ#xO'#EPOOO!b'#GP'#GPOWOOQS'#Du'#DuOOQS1G/y1G/yOOQS1G/O1G/OO!-ZQ&nO1G/OO!-bQ&nO1G/OO0iQ#xO1G/OO!-}Q#xO1G/WOOQS'#D]'#D]O/oQ#xO,59vOOQS1G.}1G.}O!.UQ#xO1G/gO!.fQ#xO1G/gO!.nQ#xO1G/hO'WQ#xO'#HdO!.sQ#xO'#HdO!.xQ&nO1G.}O!/YQ#xO,59kO!0`Q#xO,5>SO!0pQ#xO,5>SO!0xQ#xO1G/oO!0}Q&nO1G/oOOQS1G/n1G/nO!1_Q#xO,5=}O!2UQ#xO,5=}O/oQ#xO1G/sO!2sQ#xO1G/uO!2xQ&nO1G/uO!3YQ&nO1G/sOOQS1G/r1G/rOOQS1G/t1G/tOOOO-E9v-E9vOOQS1G/}1G/}OOOO-E9w-E9wO!3jQ#xO'#HwO/oQ#xO'#HwO!3xQ#xO,5:eOOOW-E9x-E9xOOQS1G0O1G0OO!4TQ#xO,5:iOOO`-E9{-E9{O!4`Q#xO,5:jOOOp-E9|-E9|O!4kQ#xO,5:kOOO!b-E9}-E9}OOQS-E:O-E:OO!4vQ!LUO1G3SO!5gQ&nO1G3SO'WQ#xO,5jOOQS1G1_1G1_O!6gQ#xO1G1_OOQS'#DX'#DXO/oQ#xO,5=yOOQS,5=y,5=yO!6lQ#xO'#FqO!6wQ#xO,59qO!7PQ#xO1G/ZO!7ZQ&nO,5=}OOQS1G3h1G3hOOQS,5:p,5:pO!7zQ#xO'#G|OOQS,5PO!8{Q#xO,5>PO/oQ#xO1G0mO/oQ#xO1G0mO0UQ#xO1G0oOOQS-E:T-E:TO!9^Q#xO1G0oO!9iQ#xO1G0oO!9nQ#xO,5>mO!9|Q#xO,5>mO!:[Q#xO,5>iO!:rQ#xO,5>iO!;TQ#{O1G0yO!>cQ#{O1G0|O!AnQ#xO,5>oO!AxQ#xO,5>oO!BQQ&nO,5>oO/oQ#xO1G1OO!B[Q#xO1G1OO3^Q#xO1G1TO! RQ#xO1G1VOOQV,5;`,5;`O!BaQ#zO,5;`O!BfQ#{O1G1PO!EwQ#xO'#G]O3^Q#xO1G1PO3^Q#xO1G1PO!FUQ#xO,5>pO!FcQ#xO,5>pO0UQ#xO,5>pOOQV1G1T1G1TO!FkQ#xO'#FRO!F|QMlO1G1VOOQV1G1[1G1[O3^Q#xO1G1[O!GUQ#xO'#F]OOQV1G1a1G1aO! `Q&nO1G1aPOOO1G3O1G3OP!GZOSO1G3OOOQS,5>V,5>VOOQS'#Dr'#DrO/oQ#xO,5>VO!G`Q#xO,5>UO!GsQ#xO,5>UOOQS1G/w1G/wO!G{Q#xO,5>XO!H]Q#xO,5>XO!HeQ#xO,5>XO!HxQ#xO,5>XO!IYQ#xO,5>XOOQS1G3r1G3rOOQS7+$j7+$jO!7PQ#xO7+$rO!J{Q#xO1G/OO!KSQ#xO1G/OOOQS1G/b1G/bOOQS,5<_,5<_O'WQ#xO,5<_OOQS7+%R7+%RO!KZQ#xO7+%ROOQS-E9q-E9qOOQS7+%S7+%SO!KkQ#xO,5>OO'WQ#xO,5>OOOQS7+$i7+$iO!KpQ#xO7+%RO!KxQ#xO7+%SO!K}Q#xO1G3nOOQS7+%Z7+%ZO!L_Q#xO1G3nO!LgQ#xO7+%ZOOQS,5<^,5<^O'WQ#xO,5<^O!LlQ#xO1G3iOOQS-E9p-E9pO!McQ#xO7+%_OOQS7+%a7+%aO!MqQ#xO1G3iO!N`Q#xO7+%aO!NeQ#xO1G3oO!NuQ#xO1G3oO!N}Q#xO7+%_O# SQ#xO,5>cO# jQ#xO,5>cO# jQ#xO,5>cO# xO$ISO'#D{O#!TO#tO'#HxOOOW1G0P1G0PO#!YQ#xO1G0POOO`1G0T1G0TO#!bQ#xO1G0TOOOp1G0U1G0UO#!jQ#xO1G0UOOO!b1G0V1G0VO#!rQ#xO1G0VO#!zQ!LUO7+(nO##kQ&nO1G2XP#$UQ#xO'#GROOQS,5d,5>dOOOW7+%k7+%kOOO`7+%o7+%oOOOp7+%p7+%pOOO!b7+%q7+%qO#7{Q#xO1G3SO#8fQ#xO1G3SP'WQ#xO'#FtO/oQ#xO<lO#9YQ#xO,5>lO0UQ#xO,5>lO#9kQ#xO,5>kOOQS<rO#AdQ#xO,5>rOOQS,5>r,5>rO#AoQ#xO,5>qO#BQQ#xO,5>qOOQS1G1X1G1XOOQS,5;o,5;oO#BYQ#xO1G1cP#B_Q#xO'#FvO#BoQ#xO1G1}O#CSQ#xO1G1}O#CdQ#xO1G1}P#CoQ#xO'#FwO#C|Q#xO7+)_O#D^Q#xO7+)_O#D^Q#xO7+)_O#DfQ#xO7+)_O#DvQ#xO7+)UO7hQ#xO7+)UOOQSAN>XAN>XO#EaQ#xO<eAN>eO/oQ#xO1G1{O#EqQ&nO1G1{P#E{Q#xO'#FuOOQS1G2R1G2RP#FYQ#xO'#F{O#FgQ#xO7+)iO#F}Q#xO,5:hOOOO-E9z-E9zO#GYQ#xO7+(nOOQSAN?_AN?_O#GsQ#xO,5QOOQSANB[ANB[OOOO7+%n7+%nOOQS7+'x7+'xO$'{Q#xO<tO$*qQ#xO,5>tO0UQ#xO,5vO#MRQ#xO,5>vOOQS1G1o1G1oO$.iQ&nO,5wO$.wQ#xO,5>wOOQS1G1r1G1rOOQS7+'R7+'RP#MRQ#xO'#GfO$/PQ#xO1G4bO$/ZQ#xO1G4bO$/cQ#xO1G4bOOQS7+%V7+%VO$/qQ#xO1G1sO$0PQ&nO'#F`O$0WQ#xO,5=POOQS,5=P,5=PO$0fQ#xO1G4cOOQS-E:c-E:cO#MRQ#xO,5=OO$0mQ#xO,5=OO$0rQ#xO7+)|OOQS-E:b-E:bO$0|Q#xO7+)|O#MRQ#xO,5e>hPP'Z'ZPP?QPP'Z'ZPP'Z'Z'Z'Z'Z?U?{'ZP@OP@UD]GyPG}HZH_HcHg'ZPPPHkHq'RP'R'RP'RP'RP'RP'RP'R'R'RP'RPP'RPP'RPHwPIOIUPIOPIOIOPPPIOPKTPK^KdKjKTPIOKpPIOPKwK}PLRLgMUMoLRLRMuNSLRLRLRLRNhNnNqNvNy! T! Z! g! y!!P!!Z!!a!!}!#T!#Z!#a!#k!#q!#w!#}!$T!$Z!$m!$w!$}!%T!%Z!%e!%k!%q!%w!&R!&X!&c!&i!&r!&x!'X!'a!'k!'rPPPPPPPPPPPPPPPPP!'x!'{!(R!([!(f!(qPPPPPPPPPPPP!-e!.y!2s!6TPP!6]!6o!6x!7n!7e!7w!7}!8Q!8T!8W!8`!9PPPPPPPPPP!9S!9cPPPP!:R!:_!:k!:q!:z!:}!;T!;Z!;a!;dP!;l!;u!x|}#@S}!O#AW!O!P#Ci!P!Q#N_!Q!R$!y!R![$&w![!]$1e!]!^$3s!^!_$4w!_!`$7c!`!a$8m!a!b%T!b!c$;U!c!d$W!e!h$W#V#Y$Q<%lO$Xc&m!b&eS&hW%k!TOX%TXY=|Y[%T[]=|]p%Tpq=|qr%Trs&Vsw%Twx/Xx#O%T#O#P?d#P#o%T#o#p8^#p#q%T#q#r8^#r;'S%T;'S;=`=v<%lO%T#s?i[&m!bOY%TYZ=|Z]%T]^=|^#o%T#o#p8^#p#q%T#q#r8^#r;'S%T;'S;=`=P;=`<%l8^<%lO%T!q@hd&m!b&eS&hWOr%Trs&Vsw%Twx/Xx!_%T!_!`Av!`#O%T#O#P7o#P#T%T#T#UBz#U#f%T#f#gBz#g#hBz#h#o%T#o#p8^#p#q%T#q#r8^#r;'S%T;'S;=`=v<%lO%T!qBR]oR&m!b&eS&hWOr%Trs&Vsw%Twx/Xx#O%T#O#P7o#P#o%T#o#p8^#p#q%T#q#r8^#r;'S%T;'S;=`=v<%lO%T!qCV]!nR&m!b&eS&hWOr%Trs&Vsw%Twx/Xx#O%T#O#P7o#P#o%T#o#p8^#p#q%T#q#r8^#r;'S%T;'S;=`=v<%lO%T#cDXa&m!b&eS&csOYE^YZ%TZ]E^]^%T^rE^rs!)|swE^wxGpx#OE^#O#P!!u#P#oE^#o#p!#d#p#qE^#q#r!#d#r;'SE^;'S;=`!)v<%lOE^#cEia&m!b&eS&hW&csOYE^YZ%TZ]E^]^%T^rE^rsFnswE^wxGpx#OE^#O#P!!u#P#oE^#o#p!#d#p#qE^#q#r!#d#r;'SE^;'S;=`!)v<%lOE^#cFw]&m!b&eS&csOr%Trs'Vsw%Twx/Xx#O%T#O#P7o#P#o%T#o#p8^#p#q%T#q#r8^#r;'S%T;'S;=`=v<%lO%T#cGya&m!b&hW&csOYE^YZ%TZ]E^]^%T^rE^rsFnswE^wxIOx#OE^#O#P!!u#P#oE^#o#p!#d#p#qE^#q#r!#d#r;'SE^;'S;=`!)v<%lOE^#cIXa&m!b&hW&csOYE^YZ%TZ]E^]^%T^rE^rsFnswE^wxJ^x#OE^#O#P!!u#P#oE^#o#p!#d#p#qE^#q#r!#d#r;'SE^;'S;=`!)v<%lOE^#_Jg_&m!b&hW&csOYJ^YZ1XZ]J^]^1X^rJ^rsKfs#OJ^#O#PL`#P#oJ^#o#pL}#p#qJ^#q#rL}#r;'SJ^;'S;=`!!o<%lOJ^#_KmZ&m!b&csOr1Xrs2ys#O1X#O#P3q#P#o1X#o#p4`#p#q1X#q#r4`#r;'S1X;'S;=`7i<%lO1X#_LeW&m!bO#oJ^#o#pL}#p#qJ^#q#rL}#r;'SJ^;'S;=`! r;=`<%lL}<%lOJ^{MUZ&hW&csOYL}YZ4`Z]L}]^4`^rL}rsMws#OL}#O#PNc#P;'SL};'S;=`! l<%lOL}{M|V&csOr4`rs5ds#O4`#O#P5y#P;'S4`;'S;=`6t<%lO4`{NfRO;'SL};'S;=`No;=`OL}{Nv[&hW&csOYL}YZ4`Z]L}]^4`^rL}rsMws#OL}#O#PNc#P;'SL};'S;=`! l;=`<%lL}<%lOL}{! oP;=`<%lL}#_! y[&hW&csOYL}YZ4`Z]L}]^4`^rL}rsMws#OL}#O#PNc#P;'SL};'S;=`! l;=`<%lJ^<%lOL}#_!!rP;=`<%lJ^#c!!zW&m!bO#oE^#o#p!#d#p#qE^#q#r!#d#r;'SE^;'S;=`!(q;=`<%l!#d<%lOE^!P!#m]&eS&hW&csOY!#dYZ8^Z]!#d]^8^^r!#drs!$fsw!#dwx!%Yx#O!#d#O#P!'Y#P;'S!#d;'S;=`!(k<%lO!#d!P!$mX&eS&csOr8^rs9rsw8^wx:dx#O8^#O#P;v#P;'S8^;'S;=`^s#O!=U#O#P!@j#P#o!=U#o#p!Ag#p#q!=U#q#r!Ag#r;'S!=U;'S;=`!FQ<%lO!=U#o!>e_U!T&m!bOY!=UYZ1XZ]!=U]^1X^r!=Urs!?ds#O!=U#O#P!@j#P#o!=U#o#p!Ag#p#q!=U#q#r!Ag#r;'S!=U;'S;=`!FQ<%lO!=U#o!?k_U!T&m!bOY!=UYZ1XZ]!=U]^1X^r!=Urs!3`s#O!=U#O#P!@j#P#o!=U#o#p!Ag#p#q!=U#q#r!Ag#r;'S!=U;'S;=`!FQ<%lO!=U#o!@q[U!T&m!bOY!=UYZ1XZ]!=U]^1X^#o!=U#o#p!Ag#p#q!=U#q#r!Ag#r;'S!=U;'S;=`!Ec;=`<%l4`<%lO!=U!]!AnZU!T&hWOY!AgYZ4`Z]!Ag]^4`^r!Agrs!Bas#O!Ag#O#P!DP#P;'S!Ag;'S;=`!E]<%lO!Ag!]!BfZU!TOY!AgYZ4`Z]!Ag]^4`^r!Agrs!CXs#O!Ag#O#P!DP#P;'S!Ag;'S;=`!E]<%lO!Ag!]!C^ZU!TOY!AgYZ4`Z]!Ag]^4`^r!Agrs!4Ys#O!Ag#O#P!DP#P;'S!Ag;'S;=`!E]<%lO!Ag!]!DUWU!TOY!AgYZ4`Z]!Ag]^4`^;'S!Ag;'S;=`!Dn;=`<%l4`<%lO!Ag!]!DsW&hWOr4`rs4zs#O4`#O#P5y#P;'S4`;'S;=`6t;=`<%l!Ag<%lO4`!]!E`P;=`<%l!Ag#o!EhW&hWOr4`rs4zs#O4`#O#P5y#P;'S4`;'S;=`6t;=`<%l!=U<%lO4`#o!FTP;=`<%l!=U#s!F_[U!T&m!bOY!+|YZ%TZ]!+|]^%T^#o!+|#o#p!GT#p#q!+|#q#r!GT#r;'S!+|;'S;=`!Mq;=`<%l8^<%lO!+|!a!G^]U!T&eS&hWOY!GTYZ8^Z]!GT]^8^^r!GTrs!HVsw!GTwx!JVx#O!GT#O#P!LV#P;'S!GT;'S;=`!Mk<%lO!GT!a!H^]U!T&eSOY!GTYZ8^Z]!GT]^8^^r!GTrs!IVsw!GTwx!JVx#O!GT#O#P!LV#P;'S!GT;'S;=`!Mk<%lO!GT!a!I^]U!T&eSOY!GTYZ8^Z]!GT]^8^^r!GTrs!5wsw!GTwx!JVx#O!GT#O#P!LV#P;'S!GT;'S;=`!Mk<%lO!GT!a!J^]U!T&hWOY!GTYZ8^Z]!GT]^8^^r!GTrs!HVsw!GTwx!KVx#O!GT#O#P!LV#P;'S!GT;'S;=`!Mk<%lO!GT!a!K^]U!T&hWOY!GTYZ8^Z]!GT]^8^^r!GTrs!HVsw!GTwx!Agx#O!GT#O#P!LV#P;'S!GT;'S;=`!Mk<%lO!GT!a!L[WU!TOY!GTYZ8^Z]!GT]^8^^;'S!GT;'S;=`!Lt;=`<%l8^<%lO!GT!a!L{Y&eS&hWOr8^rs9Qsw8^wx:dx#O8^#O#P;v#P;'S8^;'S;=`Q<%lO$TP;=`<%l$ei&m!b&eS&hW&b`%}sOr%Trs$@Ssw%Twx$C`x!Q%T!Q![$Q<%lO$Q<%lO$Q<%lO$Q<%lO$Q<%lO$np[e]||-1}],tokenPrec:7205}),rp=new Ys,op=new Set(["Script","Body","FunctionDefinition","ClassDefinition","LambdaExpression","ForStatement","MatchClause"]);function sp(e){return(t,n,i)=>{if(i)return!1;let r=t.node.getChild("VariableName");return r&&n(r,e),!0}}const ap={FunctionDefinition:sp("function"),ClassDefinition:sp("class"),ForStatement(e,t,n){if(n)for(let n=e.node.firstChild;n;n=n.nextSibling)if("VariableName"==n.name)t(n,"variable");else if("in"==n.name)break},ImportStatement(e,t){var n,i;let{node:r}=e,o="from"==(null===(n=r.firstChild)||void 0===n?void 0:n.name);for(let e=r.getChild("import");e;e=e.nextSibling)"VariableName"==e.name&&"as"!=(null===(i=e.nextSibling)||void 0===i?void 0:i.name)&&t(e,o?"variable":"namespace")},AssignStatement(e,t){for(let n=e.node.firstChild;n;n=n.nextSibling)if("VariableName"==n.name)t(n,"variable");else if(":"==n.name||"AssignOp"==n.name)break},ParamList(e,t){for(let n=null,i=e.node.firstChild;i;i=i.nextSibling)"VariableName"!=i.name||n&&/\*|AssignOp/.test(n.name)||t(i,"variable"),n=i},CapturePattern:sp("variable"),AsPattern:sp("variable"),__proto__:null};function lp(e,t){let n=rp.get(t);if(n)return n;let i=[],r=!0;function o(t,n){let r=e.sliceString(t.from,t.to);i.push({label:r,type:n})}return t.cursor(Ms.IncludeAnonymous).iterate((t=>{if(t.name){let e=ap[t.name];if(e&&e(t,o,r)||!r&&op.has(t.name))return!1;r=!1}else if(t.to-t.from>8192){for(let n of lp(e,t.node))i.push(n);return!1}})),rp.set(t,i),i}const cp=/^[\w\xa1-\uffff][\w\d\xa1-\uffff]*$/,up=["String","FormatString","Comment","PropertyName"];function fp(e){let t=$a(e.state).resolveInner(e.pos,-1);if(up.indexOf(t.name)>-1)return null;let n="VariableName"==t.name||t.to-t.from<20&&cp.test(e.state.sliceDoc(t.from,t.to));if(!n&&!e.explicit)return null;let i=[];for(let n=t;n;n=n.parent)op.has(n.name)&&(i=i.concat(lp(e.state.doc,n)));return{options:i,from:n?t.from:e.pos,validFor:cp}}const hp=["__annotations__","__builtins__","__debug__","__doc__","__import__","__name__","__loader__","__package__","__spec__","False","None","True"].map((e=>({label:e,type:"constant"}))).concat(["ArithmeticError","AssertionError","AttributeError","BaseException","BlockingIOError","BrokenPipeError","BufferError","BytesWarning","ChildProcessError","ConnectionAbortedError","ConnectionError","ConnectionRefusedError","ConnectionResetError","DeprecationWarning","EOFError","Ellipsis","EncodingWarning","EnvironmentError","Exception","FileExistsError","FileNotFoundError","FloatingPointError","FutureWarning","GeneratorExit","IOError","ImportError","ImportWarning","IndentationError","IndexError","InterruptedError","IsADirectoryError","KeyError","KeyboardInterrupt","LookupError","MemoryError","ModuleNotFoundError","NameError","NotADirectoryError","NotImplemented","NotImplementedError","OSError","OverflowError","PendingDeprecationWarning","PermissionError","ProcessLookupError","RecursionError","ReferenceError","ResourceWarning","RuntimeError","RuntimeWarning","StopAsyncIteration","StopIteration","SyntaxError","SyntaxWarning","SystemError","SystemExit","TabError","TimeoutError","TypeError","UnboundLocalError","UnicodeDecodeError","UnicodeEncodeError","UnicodeError","UnicodeTranslateError","UnicodeWarning","UserWarning","ValueError","Warning","ZeroDivisionError"].map((e=>({label:e,type:"type"})))).concat(["bool","bytearray","bytes","classmethod","complex","float","frozenset","int","list","map","memoryview","object","range","set","staticmethod","str","super","tuple","type"].map((e=>({label:e,type:"class"})))).concat(["abs","aiter","all","anext","any","ascii","bin","breakpoint","callable","chr","compile","delattr","dict","dir","divmod","enumerate","eval","exec","exit","filter","format","getattr","globals","hasattr","hash","help","hex","id","input","isinstance","issubclass","iter","len","license","locals","max","min","next","oct","open","ord","pow","print","property","quit","repr","reversed","round","setattr","slice","sorted","sum","vars","zip"].map((e=>({label:e,type:"function"})))),dp=[Yc("def ${name}(${params}):\n\t${}",{label:"def",detail:"function",type:"keyword"}),Yc("for ${name} in ${collection}:\n\t${}",{label:"for",detail:"loop",type:"keyword"}),Yc("while ${}:\n\t${}",{label:"while",detail:"loop",type:"keyword"}),Yc("try:\n\t${}\nexcept ${error}:\n\t${}",{label:"try",detail:"/ except block",type:"keyword"}),Yc("if ${}:\n\t\n",{label:"if",detail:"block",type:"keyword"}),Yc("if ${}:\n\t${}\nelse:\n\t${}",{label:"if",detail:"/ else block",type:"keyword"}),Yc("class ${name}:\n\tdef __init__(self, ${params}):\n\t\t\t${}",{label:"class",detail:"definition",type:"keyword"}),Yc("import ${module}",{label:"import",detail:"statement",type:"keyword"}),Yc("from ${module} import ${names}",{label:"from",detail:"import",type:"keyword"})],pp=ec(up,Jl(hp.concat(dp)));function gp(e,t){let n=e.baseIndentFor(t),i=e.lineAt(e.pos,-1),r=i.from+i.text.length;return/^\s*($|#)/.test(i.text)&&e.node.ton?null:n+e.unit}const mp=Ca.define({name:"python",parser:ip.configure({props:[Xa.add({Body:e=>{var t;return null!==(t=gp(e,e.node))&&void 0!==t?t:e.continue()},IfStatement:e=>/^\s*(else:|elif )/.test(e.textAfter)?e.baseIndent:e.continue(),TryStatement:e=>/^\s*(except |finally:|else:)/.test(e.textAfter)?e.baseIndent:e.continue(),"TupleExpression ComprehensionExpression ParamList ArgList ParenthesizedExpression":Ja({closing:")"}),"DictionaryExpression DictionaryComprehensionExpression SetExpression SetComprehensionExpression":Ja({closing:"}"}),"ArrayExpression ArrayComprehensionExpression":Ja({closing:"]"}),"String FormatString":()=>null,Script:e=>{if(e.pos+/\s*/.exec(e.textAfter)[0].length>=e.node.to){let t=null;for(let n=e.node,i=n.to;n=n.lastChild,n&&n.to==i;)"Body"==n.type.name&&(t=n);if(t){let n=gp(e,t);if(null!=n)return n}}return e.continue()}}),nl.add({"ArrayExpression DictionaryExpression SetExpression TupleExpression":function(e){let t=e.firstChild,n=e.lastChild;return t&&t.to({from:e.from+1,to:e.to-(e.to==t.doc.length?0:1)})})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"'''",'"""'],stringPrefixes:["f","fr","rf","r","u","b","br","rb","F","FR","RF","R","U","B","BR","RB"]},commentTokens:{line:"#"},indentOnInput:/^\s*([\}\]\)]|else:|elif |except |finally:)$/}});var yp=new K;return e.codemirror=function(e,n,i,r){var o=Dr.theme({"&":{fontSize:"0.8125rem"},"&.cm-editor.cm-focused":{outline:"0"}});return new Dr({doc:n,parent:e,extensions:[bs(),xs,yo(),Eu(),xl(),Jr(),[ao,lo],ke.allowMultipleSelections.of(!0),ke.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=Ua(s,t.from);if(null==n)continue;let i=/^\s*/.exec(t.text)[0],r=ja(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})),Tl($l,{fallback:!0}),Ll(),[ru,Jc],du(),Ao(),Co(),_o,ah(),Do({parent:document.body}),yp.of([new Ba(mp,[mp.data.of({autocomplete:fp}),mp.data.of({autocomplete:pp})])]),Br.of(t(t(t(t(t(t(t([{key:"Ctrl-Enter",mac:"Cmd-Enter",run:function(e){return i(e.state.doc.toString()),!0}},Wf],ou,!0),If,!0),Qh,!0),ju,!0),pl,!0),pu,!0),od,!0)),Dr.updateListener.of((function(e){return r(e.state.doc.toString())})),o]})},e.startDebugger=function(){},e}({});let re,oe;class se{constructor(){this.buffer=[]}write(e){this.buffer.push(e)}log(e){for(let t=0;t{var e=null;re=async()=>{e=await loadPyodide({indexURL:"https://cdn.jsdelivr.net/pyodide/v0.22.0/full/"}),await e.loadPackage("matplotlib"),e.runPython('import os\nos.environ["MPLBACKEND"] = "AGG"'),e.runPython('import matplotlib\nimport matplotlib.pyplot\nfrom pyodide import create_proxy\n\nclass MplCanvas:\n def __init__(self, pixels, width, height):\n self.pixels = pixels\n self.width = width\n self.height = height\n\ndef show():\n canvas = matplotlib.pyplot.gcf().canvas\n canvas.draw()\n pixels = canvas.buffer_rgba().tobytes()\n width, height = canvas.get_width_height()\n return MplCanvas(pixels, width, height)\n\n# This is probably the better approach, but the object passing stuff doesn\'t support typed arrays yet\ndef showUint8():\n pixels_proxy = None\n pixels_buf = None\n try:\n canvas = matplotlib.pyplot.gcf().canvas\n canvas.draw()\n pixels = canvas.buffer_rgba().tobytes()\n pixels_proxy = create_proxy(pixels)\n pixels_buf = pixels_proxy.getBuffer("u8clamped")\n drawPyodideCanvas(pixels)\n finally:\n if pixels_proxy:\n pixels_proxy.destroy()\n if pixels_buf:\n pixels_buf.release()\n\nmatplotlib.pyplot.show = show\n'),console.log("Patched matplotlib"),await e.loadPackage("pandas"),await e.loadPackage("micropip")};oe=(t,n,i)=>{window[i]=n,console.log("Python string:\n",t);var r,o=new se,s=new se;e.setStdout({batched:e=>o.write(e)}),e.setStderr({batched:e=>s.write(e)});var a,l,c,u={value:{t:{},c:{}},stdout:[],stderr:[]};try{r=e.runPython(t)}catch(e){return u.value.t="Error",u.value.c=e.toString(),u.stdout=o.buffer,u.stderr=s.buffer,console.log("Python execution error:",e.toString()),u}if(u.stdout=o.buffer,u.stderr=s.buffer,void 0!==r){if(r instanceof HTMLElement)return u.value.t="Element",u.value.c=r,u;if("object"==typeof r&&"PythonError"===r.name&&r.__error_address)return console.log("Error"),u.value.t="Error",u.value.c=r.toString(),u;if((c=r)&&void 0!==c.$$&&"PyProxy"===c.$$.type){if("DataFrame"===r.type)return console.log("Dataframe"),u.value.t="Table",u.value.c=r.to_csv(),u;if("MplCanvas"===r.type){var f=r.pixels;return f.toJs&&(f=f.toJs()),(f instanceof Uint8ClampedArray||f instanceof Uint8Array)&&(f=Array.from(f)),u.value.t="Canvas",u.value.c={data:f,width:r.width,height:r.height},u}if(void 0!==r._repr_html_){let e=r._repr_html_();if("string"==typeof e)return u.value.t="Html",u.value.c=e,u;console.log("Other HTML result:",e)}else if(void 0!==r._repr_latex_){let e=r._repr_latex_();var h;console.log("Latex rep",e);var d=0;return e.startsWith("$$")?d=2:e.startsWith("$")&&(d=1),0==d?void console.log("Error rendering latex, not renderable"):(e=e.substr(d,e.length-d-1),h=katex.renderToString(e,{throwOnError:!1,errorColor:"#cc0000",displayMode:!0}),u.value.t="Latex",u.value.c=h,u)}}return u.value.t="Scalar","number"==typeof r?(a=r,isNaN(a)||(0|(l=parseFloat(a)))!==l?(u.value.c.t="Float",u.value.c.c=r):(u.value.c.t="Integer",u.value.c.c=BigInt(r)),u):"bigint"==typeof r?(u.value.c.t="Integer",u.value.c.c=r,u):"string"==typeof r?(u.value.c.t="String",u.value.c.c=r,u):u}return u.value.t="Success",u.value.c="Complete",console.log("Python js completed"),u}})(),function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).vega={})}(this,(function(e){function t(e,t,n){return e.fields=t||[],e.fname=n,e}function n(e){return null==e?null:e.fname}function i(e){return null==e?null:e.fields}function o(e){return 1===e.length?s(e[0]):a(e)}const s=e=>function(t){return t[e]},a=e=>{const t=e.length;return function(n){for(let i=0;ii&&u(),a=i=r+1):"]"===o&&(a||l("Access path missing open bracket: "+e),a>0&&u(),a=0,i=r+1):r>i?u():i=r+1}return a&&l("Access path missing closing bracket: "+e),s&&l("Access path missing closing quote: "+e),r>i&&(r++,u()),t}function u(e,n,i){const r=c(e);return e=1===r.length?r[0]:e,t((i&&i.get||o)(r),[e],n||e)}const f=u("id"),h=t((e=>e),[],"identity"),d=t((()=>0),[],"zero"),p=t((()=>1),[],"one"),g=t((()=>!0),[],"true"),m=t((()=>!1),[],"false");function y(e,t,n){const i=[t].concat([].slice.call(n));console[e].apply(console,i)}function b(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:y,i=e||0;return{level(e){return arguments.length?(i=+e,this):i},error(){return i>=1&&n(t||"error","ERROR",arguments),this},warn(){return i>=2&&n(t||"warn","WARN",arguments),this},info(){return i>=3&&n(t||"log","INFO",arguments),this},debug(){return i>=4&&n(t||"log","DEBUG",arguments),this}}}var v=Array.isArray;function w(e){return e===Object(e)}const x=e=>"__proto__"!==e;function _(){for(var e=arguments.length,t=new Array(e),n=0;n{for(const n in t)if("signals"===n)e.signals=S(e.signals,t.signals);else{const i="legend"===n?{layout:1}:"style"===n||null;O(e,n,t[n],i)}return e}),{})}function O(e,t,n,i){if(!x(t))return;let r,o;if(w(n)&&!v(n))for(r in o=w(e[t])?e[t]:e[t]={},n)i&&(!0===i||i[r])?O(o,r,n[r]):x(r)&&(o[r]=n[r]);else e[t]=n}function S(e,t){if(null==e)return t;const n={},i=[];function r(e){n[e.name]||(n[e.name]=1,i.push(e))}return t.forEach(r),e.forEach(r),i}function k(e){return e[e.length-1]}function A(e){return null==e||""===e?null:+e}const T=e=>t=>e*Math.exp(t),E=e=>t=>Math.log(e*t),C=e=>t=>Math.sign(t)*Math.log1p(Math.abs(t/e)),$=e=>t=>Math.sign(t)*Math.expm1(Math.abs(t))*e,M=e=>t=>t<0?-Math.pow(-t,e):Math.pow(t,e);function D(e,t,n,i){const r=n(e[0]),o=n(k(e)),s=(o-r)*t;return[i(r-s),i(o-s)]}function P(e,t){return D(e,t,A,h)}function R(e,t){var n=Math.sign(e[0]);return D(e,t,E(n),T(n))}function F(e,t,n){return D(e,t,M(n),M(1/n))}function N(e,t,n){return D(e,t,C(n),$(n))}function q(e,t,n,i,r){const o=i(e[0]),s=i(k(e)),a=null!=t?i(t):(o+s)/2;return[r(a+(o-a)*n),r(a+(s-a)*n)]}function z(e,t,n){return q(e,t,n,A,h)}function L(e,t,n){const i=Math.sign(e[0]);return q(e,t,n,E(i),T(i))}function B(e,t,n,i){return q(e,t,n,M(i),M(1/i))}function Q(e,t,n,i){return q(e,t,n,C(i),$(i))}function I(e){return 1+~~(new Date(e).getMonth()/3)}function W(e){return 1+~~(new Date(e).getUTCMonth()/3)}function j(e){return null!=e?v(e)?e:[e]:[]}function U(e,t,n){let i,r=e[0],o=e[1];return o=n-t?[t,n]:[r=Math.min(Math.max(r,t),n-i),r+i]}function V(e){return"function"==typeof e}function X(e,n,r){r=r||{},n=j(n)||[];const o=[],s=[],a={},l=r.comparator||H;return j(e).forEach(((e,t)=>{null!=e&&(o.push("descending"===n[t]?-1:1),s.push(e=V(e)?e:u(e,null,r)),(i(e)||[]).forEach((e=>a[e]=1)))})),0===s.length?null:t(l(s,o),Object.keys(a))}const Y=(e,t)=>(et||null==t)&&null!=e?1:(t=t instanceof Date?+t:t,(e=e instanceof Date?+e:e)!==e&&t==t?-1:t!=t&&e==e?1:0),H=(e,t)=>1===e.length?G(e[0],t[0]):Z(e,t,e.length),G=(e,t)=>function(n,i){return Y(e(n),e(i))*t},Z=(e,t,n)=>(t.push(0),function(i,r){let o,s=0,a=-1;for(;0===s&&++ae}function J(e,t){let n;return i=>{n&&clearTimeout(n),n=setTimeout((()=>(t(i),n=null)),e)}}function ee(e){for(let t,n,i=1,r=arguments.length;io&&(o=i))}else{for(i=t(e[s]);so&&(o=i))}return[r,o]}function ne(e,t){const n=e.length;let i,r,o,s,a,l=-1;if(null==t){for(;++l=r){i=o=r;break}if(l===n)return[-1,-1];for(s=a=l;++lr&&(i=r,s=l),o=r){i=o=r;break}if(l===n)return[-1,-1];for(s=a=l;++lr&&(i=r,s=l),oi(e)?n[e]:void 0,set(e,t){return i(e)||(++r.size,n[e]===re&&--r.empty),n[e]=t,this},delete(e){return i(e)&&(--r.size,++r.empty,n[e]=re),this},clear(){r.size=r.empty=0,r.object=n={}},test(e){return arguments.length?(t=e,r):t},clean(){const e={};let i=0;for(const r in n){const o=n[r];o===re||t&&t(o)||(e[r]=o,++i)}r.size=i,r.empty=0,r.object=n=e}};return e&&Object.keys(e).forEach((t=>{r.set(t,e[t])})),r}function se(e,t,n,i,r,o){if(!n&&0!==n)return o;const s=+n;let a,l=e[0],c=k(e);cs&&(r=o,o=s,s=r),i=void 0===i||i,((n=void 0===n||n)?o<=e:oe.replace(/\\(.)/g,"$1"))):j(e));const r=e&&e.length,s=i&&i.get||o,a=e=>s(n?[e]:c(e));let l;if(r)if(1===r){const t=a(e[0]);l=function(e){return""+t(e)}}else{const t=e.map(a);l=function(e){let n=""+t[0](e),i=0;for(;++i{t={},n={},i=0},o=(r,o)=>(++i>e&&(n=t,t={},i=1),t[r]=o);return r(),{clear:r,has:e=>ie(t,e)||ie(n,e),get:e=>ie(t,e)?t[e]:ie(n,e)?o(e,n[e]):void 0,set:(e,n)=>ie(t,e)?t[e]=n:o(e,n)}}function be(e,t,n,i){const r=t.length,o=n.length;if(!o)return t;if(!r)return n;const s=i||new t.constructor(r+o);let a=0,l=0,c=0;for(;a0?n[l++]:t[a++];for(;a=0;)n+=e;return n}function we(e,t,n,i){const r=n||" ",o=e+"",s=t-o.length;return s<=0?o:"left"===i?ve(r,s)+o:"center"===i?ve(r,~~(s/2))+o+ve(r,Math.ceil(s/2)):o+ve(r,s)}function xe(e){return e&&k(e)-e[0]||0}function _e(e){return v(e)?"["+e.map(_e)+"]":w(e)||pe(e)?JSON.stringify(e).replace("\u2028","\\u2028").replace("\u2029","\\u2029"):e}function Oe(e){return null==e||""===e?null:!(!e||"false"===e||"0"===e)&&!!e}const Se=e=>he(e)||ue(e)?e:Date.parse(e);function ke(e,t){return t=t||Se,null==e||""===e?null:t(e)}function Ae(e){return null==e||""===e?null:e+""}function Te(e){const t={},n=e.length;for(let i=0;i9999?"+"+Re(t,6):Re(t,4))+"-"+Re(e.getUTCMonth()+1,2)+"-"+Re(e.getUTCDate(),2)+(o?"T"+Re(n,2)+":"+Re(i,2)+":"+Re(r,2)+"."+Re(o,3)+"Z":r?"T"+Re(n,2)+":"+Re(i,2)+":"+Re(r,2)+"Z":i||n?"T"+Re(n,2)+":"+Re(i,2)+"Z":"")}function Ne(e){var t=new RegExp('["'+e+"\n\r]"),n=e.charCodeAt(0);function i(e,t){var i,r=[],o=e.length,s=0,a=0,l=o<=0,c=!1;function u(){if(l)return Me;if(c)return c=!1,$e;var t,i,r=s;if(34===e.charCodeAt(r)){for(;s++=o?l=!0:10===(i=e.charCodeAt(s++))?c=!0:13===i&&(c=!0,10===e.charCodeAt(s)&&++s),e.slice(r+1,t-1).replace(/""/g,'"')}for(;s1)i=je(e,t,n);else for(r=0,i=new Array(o=e.arcs.length);rt?1:e>=t?0:NaN}function Ve(e,t){return null==e||null==t?NaN:te?1:t>=e?0:NaN}function Xe(e){let t,n,i;function r(e,i){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.length;if(r>>1;n(e[t],i)<0?r=t+1:o=t}while(rUe(e(t),n),i=(t,n)=>e(t)-n):(t=e===Ue||e===Ve?e:Ye,n=e,i=e),{left:r,center:function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.length;const s=r(e,t,n,o-1);return s>n&&i(e[s-1],t)>-i(e[s],t)?s-1:s},right:function(e,i){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.length;if(r>>1;n(e[t],i)<=0?r=t+1:o=t}while(r0){for(o=e[--r];r>0&&(t=o,n=e[--r],o=t+n,i=n-(o-t),!i););r>0&&(i<0&&e[r-1]<0||i>0&&e[r-1]>0)&&(n=2*i,t=o+n,n==t-o&&(o=t))}return o}}class et extends Map{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ot;if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),null!=e)for(const[t,n]of e)this.set(t,n)}get(e){return super.get(nt(this,e))}has(e){return super.has(nt(this,e))}set(e,t){return super.set(it(this,e),t)}delete(e){return super.delete(rt(this,e))}}class tt extends Set{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ot;if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),null!=e)for(const t of e)this.add(t)}has(e){return super.has(nt(this,e))}add(e){return super.add(it(this,e))}delete(e){return super.delete(rt(this,e))}}function nt(e,t){let{_intern:n,_key:i}=e;const r=i(t);return n.has(r)?n.get(r):t}function it(e,t){let{_intern:n,_key:i}=e;const r=i(t);return n.has(r)?n.get(r):(n.set(r,t),t)}function rt(e,t){let{_intern:n,_key:i}=e;const r=i(t);return n.has(r)&&(t=n.get(r),n.delete(r)),t}function ot(e){return null!==e&&"object"==typeof e?e.valueOf():e}function st(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ue;if(e===Ue)return at;if("function"!=typeof e)throw new TypeError("compare is not a function");return(t,n)=>{const i=e(t,n);return i||0===i?i:(0===e(n,n))-(0===e(t,t))}}function at(e,t){return(null==e||!(e>=e))-(null==t||!(t>=t))||(et?1:0)}const lt=Math.sqrt(50),ct=Math.sqrt(10),ut=Math.sqrt(2);function ft(e,t,n){const i=(t-e)/Math.max(0,n),r=Math.floor(Math.log10(i)),o=i/Math.pow(10,r),s=o>=lt?10:o>=ct?5:o>=ut?2:1;let a,l,c;return r<0?(c=Math.pow(10,-r)/s,a=Math.round(e*c),l=Math.round(t*c),a/ct&&--l,c=-c):(c=Math.pow(10,r)*s,a=Math.round(e/c),l=Math.round(t/c),a*ct&&--l),l0))return[];if((e=+e)===(t=+t))return[e];const i=t=r))return[];const a=o-r+1,l=new Array(a);if(i)if(s<0)for(let e=0;e=t)&&(n=t);else{let i=-1;for(let r of e)null!=(r=t(r,++i,e))&&(n=r)&&(n=r)}return n}function mt(e,t){let n;if(void 0===t)for(const t of e)null!=t&&(n>t||void 0===n&&t>=t)&&(n=t);else{let i=-1;for(let r of e)null!=(r=t(r,++i,e))&&(n>r||void 0===n&&r>=r)&&(n=r)}return n}function yt(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1/0,r=arguments.length>4?arguments[4]:void 0;if(t=Math.floor(t),n=Math.floor(Math.max(0,n)),i=Math.floor(Math.min(e.length-1,i)),!(n<=t&&t<=i))return e;for(r=void 0===r?at:st(r);i>n;){if(i-n>600){const o=i-n+1,s=t-n+1,a=Math.log(o),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/2<0?-1:1);yt(e,t,Math.max(n,Math.floor(t-s*l/o+c)),Math.min(i,Math.floor(t+(o-s)*l/o+c)),r)}const o=e[t];let s=n,a=i;for(bt(e,n,t),r(e[i],o)>0&&bt(e,n,i);s0;)--a}0===r(e[n],o)?bt(e,n,a):(++a,bt(e,a,i)),a<=t&&(n=a+1),t<=a&&(i=a-1)}return e}function bt(e,t,n){const i=e[t];e[t]=e[n],e[n]=i}function vt(e,t,n){if(e=Float64Array.from(function*(e,t){if(void 0===t)for(let t of e)null!=t&&(t=+t)>=t&&(yield t);else{let n=-1;for(let i of e)null!=(i=t(i,++n,e))&&(i=+i)>=i&&(yield i)}}(e,n)),(i=e.length)&&!isNaN(t=+t)){if(t<=0||i<2)return mt(e);if(t>=1)return gt(e);var i,r=(i-1)*t,o=Math.floor(r),s=gt(yt(e,o).subarray(0,o+1));return s+(mt(e.subarray(o+1))-s)*(r-o)}}function wt(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:He;if((i=e.length)&&!isNaN(t=+t)){if(t<=0||i<2)return+n(e[0],0,e);if(t>=1)return+n(e[i-1],i-1,e);var i,r=(i-1)*t,o=Math.floor(r),s=+n(e[o],o,e),a=+n(e[o+1],o+1,e);return s+(a-s)*(r-o)}}function xt(e,t){return vt(e,.5,t)}function _t(e){return Array.from(function*(e){for(const t of e)yield*t}(e))}function Ot(e,t,n){e=+e,t=+t,n=(r=arguments.length)<2?(t=e,e=0,1):r<3?1:+n;for(var i=-1,r=0|Math.max(0,Math.ceil((t-e)/n)),o=new Array(r);++i1?i[0]+i.slice(2):i,+e.slice(n+1)]}function Tt(e){return(e=At(Math.abs(e)))?e[1]:NaN}var Et,Ct=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function $t(e){if(!(t=Ct.exec(e)))throw new Error("invalid format: "+e);var t;return new Mt({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}function Mt(e){this.fill=void 0===e.fill?" ":e.fill+"",this.align=void 0===e.align?">":e.align+"",this.sign=void 0===e.sign?"-":e.sign+"",this.symbol=void 0===e.symbol?"":e.symbol+"",this.zero=!!e.zero,this.width=void 0===e.width?void 0:+e.width,this.comma=!!e.comma,this.precision=void 0===e.precision?void 0:+e.precision,this.trim=!!e.trim,this.type=void 0===e.type?"":e.type+""}function Dt(e,t){var n=At(e,t);if(!n)return e+"";var i=n[0],r=n[1];return r<0?"0."+new Array(-r).join("0")+i:i.length>r+1?i.slice(0,r+1)+"."+i.slice(r+1):i+new Array(r-i.length+2).join("0")}$t.prototype=Mt.prototype,Mt.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var Pt={"%":(e,t)=>(100*e).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:function(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)},e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>Dt(100*e,t),r:Dt,s:function(e,t){var n=At(e,t);if(!n)return e+"";var i=n[0],r=n[1],o=r-(Et=3*Math.max(-8,Math.min(8,Math.floor(r/3))))+1,s=i.length;return o===s?i:o>s?i+new Array(o-s+1).join("0"):o>0?i.slice(0,o)+"."+i.slice(o):"0."+new Array(1-o).join("0")+At(e,Math.max(0,t+o-1))[0]},X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function Rt(e){return e}var Ft,Nt,qt,zt=Array.prototype.map,Lt=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Bt(e){var t,n,i=void 0===e.grouping||void 0===e.thousands?Rt:(t=zt.call(e.grouping,Number),n=e.thousands+"",function(e,i){for(var r=e.length,o=[],s=0,a=t[0],l=0;r>0&&a>0&&(l+a+1>i&&(a=Math.max(1,i-l)),o.push(e.substring(r-=a,r+a)),!((l+=a+1)>i));)a=t[s=(s+1)%t.length];return o.reverse().join(n)}),r=void 0===e.currency?"":e.currency[0]+"",o=void 0===e.currency?"":e.currency[1]+"",s=void 0===e.decimal?".":e.decimal+"",a=void 0===e.numerals?Rt:function(e){return function(t){return t.replace(/[0-9]/g,(function(t){return e[+t]}))}}(zt.call(e.numerals,String)),l=void 0===e.percent?"%":e.percent+"",c=void 0===e.minus?"−":e.minus+"",u=void 0===e.nan?"NaN":e.nan+"";function f(e){var t=(e=$t(e)).fill,n=e.align,f=e.sign,h=e.symbol,d=e.zero,p=e.width,g=e.comma,m=e.precision,y=e.trim,b=e.type;"n"===b?(g=!0,b="g"):Pt[b]||(void 0===m&&(m=12),y=!0,b="g"),(d||"0"===t&&"="===n)&&(d=!0,t="0",n="=");var v="$"===h?r:"#"===h&&/[boxX]/.test(b)?"0"+b.toLowerCase():"",w="$"===h?o:/[%p]/.test(b)?l:"",x=Pt[b],_=/[defgprs%]/.test(b);function O(e){var r,o,l,h=v,O=w;if("c"===b)O=x(e)+O,e="";else{var S=(e=+e)<0||1/e<0;if(e=isNaN(e)?u:x(Math.abs(e),m),y&&(e=function(e){e:for(var t,n=e.length,i=1,r=-1;i0&&(r=0)}return r>0?e.slice(0,r)+e.slice(t+1):e}(e)),S&&0==+e&&"+"!==f&&(S=!1),h=(S?"("===f?f:c:"-"===f||"("===f?"":f)+h,O=("s"===b?Lt[8+Et/3]:"")+O+(S&&"("===f?")":""),_)for(r=-1,o=e.length;++r(l=e.charCodeAt(r))||l>57){O=(46===l?s+e.slice(r+1):e.slice(r))+O,e=e.slice(0,r);break}}g&&!d&&(e=i(e,1/0));var k=h.length+e.length+O.length,A=k>1)+h+e+O+A.slice(k);break;default:e=A+h+e+O}return a(e)}return m=void 0===m?6:/[gprs]/.test(b)?Math.max(1,Math.min(21,m)):Math.max(0,Math.min(20,m)),O.toString=function(){return e+""},O}return{format:f,formatPrefix:function(e,t){var n=f(((e=$t(e)).type="f",e)),i=3*Math.max(-8,Math.min(8,Math.floor(Tt(t)/3))),r=Math.pow(10,-i),o=Lt[8+i/3];return function(e){return n(r*e)+o}}}}function Qt(e){return Math.max(0,-Tt(Math.abs(e)))}function It(e,t){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(Tt(t)/3)))-Tt(Math.abs(e)))}function Wt(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,Tt(t)-Tt(e))+1}!function(e){Ft=Bt(e),Nt=Ft.format,qt=Ft.formatPrefix}({thousands:",",grouping:[3],currency:["$",""]});const jt=new Date,Ut=new Date;function Vt(e,t,n,i){function r(t){return e(t=0===arguments.length?new Date:new Date(+t)),t}return r.floor=t=>(e(t=new Date(+t)),t),r.ceil=n=>(e(n=new Date(n-1)),t(n,1),e(n),n),r.round=e=>{const t=r(e),n=r.ceil(e);return e-t(t(e=new Date(+e),null==n?1:Math.floor(n)),e),r.range=(n,i,o)=>{const s=[];if(n=r.ceil(n),o=null==o?1:Math.floor(o),!(n0))return s;let a;do{s.push(a=new Date(+n)),t(n,o),e(n)}while(aVt((t=>{if(t>=t)for(;e(t),!n(t);)t.setTime(t-1)}),((e,i)=>{if(e>=e)if(i<0)for(;++i<=0;)for(;t(e,-1),!n(e););else for(;--i>=0;)for(;t(e,1),!n(e););})),n&&(r.count=(t,i)=>(jt.setTime(+t),Ut.setTime(+i),e(jt),e(Ut),Math.floor(n(jt,Ut))),r.every=e=>(e=Math.floor(e),isFinite(e)&&e>0?e>1?r.filter(i?t=>i(t)%e==0:t=>r.count(0,t)%e==0):r:null)),r}const Xt=Vt((()=>{}),((e,t)=>{e.setTime(+e+t)}),((e,t)=>t-e));Xt.every=e=>(e=Math.floor(e),isFinite(e)&&e>0?e>1?Vt((t=>{t.setTime(Math.floor(t/e)*e)}),((t,n)=>{t.setTime(+t+n*e)}),((t,n)=>(n-t)/e)):Xt:null),Xt.range;const Yt=1e3,Ht=6e4,Gt=36e5,Zt=864e5,Kt=6048e5,Jt=2592e6,en=31536e6,tn=Vt((e=>{e.setTime(e-e.getMilliseconds())}),((e,t)=>{e.setTime(+e+t*Yt)}),((e,t)=>(t-e)/Yt),(e=>e.getUTCSeconds()));tn.range;const nn=Vt((e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Yt)}),((e,t)=>{e.setTime(+e+t*Ht)}),((e,t)=>(t-e)/Ht),(e=>e.getMinutes()));nn.range;const rn=Vt((e=>{e.setUTCSeconds(0,0)}),((e,t)=>{e.setTime(+e+t*Ht)}),((e,t)=>(t-e)/Ht),(e=>e.getUTCMinutes()));rn.range;const on=Vt((e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Yt-e.getMinutes()*Ht)}),((e,t)=>{e.setTime(+e+t*Gt)}),((e,t)=>(t-e)/Gt),(e=>e.getHours()));on.range;const sn=Vt((e=>{e.setUTCMinutes(0,0,0)}),((e,t)=>{e.setTime(+e+t*Gt)}),((e,t)=>(t-e)/Gt),(e=>e.getUTCHours()));sn.range;const an=Vt((e=>e.setHours(0,0,0,0)),((e,t)=>e.setDate(e.getDate()+t)),((e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*Ht)/Zt),(e=>e.getDate()-1));an.range;const ln=Vt((e=>{e.setUTCHours(0,0,0,0)}),((e,t)=>{e.setUTCDate(e.getUTCDate()+t)}),((e,t)=>(t-e)/Zt),(e=>e.getUTCDate()-1));ln.range;const cn=Vt((e=>{e.setUTCHours(0,0,0,0)}),((e,t)=>{e.setUTCDate(e.getUTCDate()+t)}),((e,t)=>(t-e)/Zt),(e=>Math.floor(e/Zt)));function un(e){return Vt((t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)}),((e,t)=>{e.setDate(e.getDate()+7*t)}),((e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*Ht)/Kt))}cn.range;const fn=un(0),hn=un(1),dn=un(2),pn=un(3),gn=un(4),mn=un(5),yn=un(6);function bn(e){return Vt((t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)}),((e,t)=>{e.setUTCDate(e.getUTCDate()+7*t)}),((e,t)=>(t-e)/Kt))}fn.range,hn.range,dn.range,pn.range,gn.range,mn.range,yn.range;const vn=bn(0),wn=bn(1),xn=bn(2),_n=bn(3),On=bn(4),Sn=bn(5),kn=bn(6);vn.range,wn.range,xn.range,_n.range,On.range,Sn.range,kn.range;const An=Vt((e=>{e.setDate(1),e.setHours(0,0,0,0)}),((e,t)=>{e.setMonth(e.getMonth()+t)}),((e,t)=>t.getMonth()-e.getMonth()+12*(t.getFullYear()-e.getFullYear())),(e=>e.getMonth()));An.range;const Tn=Vt((e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)}),((e,t)=>{e.setUTCMonth(e.getUTCMonth()+t)}),((e,t)=>t.getUTCMonth()-e.getUTCMonth()+12*(t.getUTCFullYear()-e.getUTCFullYear())),(e=>e.getUTCMonth()));Tn.range;const En=Vt((e=>{e.setMonth(0,1),e.setHours(0,0,0,0)}),((e,t)=>{e.setFullYear(e.getFullYear()+t)}),((e,t)=>t.getFullYear()-e.getFullYear()),(e=>e.getFullYear()));En.every=e=>isFinite(e=Math.floor(e))&&e>0?Vt((t=>{t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)}),((t,n)=>{t.setFullYear(t.getFullYear()+n*e)})):null,En.range;const Cn=Vt((e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)}),((e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t)}),((e,t)=>t.getUTCFullYear()-e.getUTCFullYear()),(e=>e.getUTCFullYear()));function $n(e,t,n,i,r,o){const s=[[tn,1,Yt],[tn,5,5e3],[tn,15,15e3],[tn,30,3e4],[o,1,Ht],[o,5,3e5],[o,15,9e5],[o,30,18e5],[r,1,Gt],[r,3,108e5],[r,6,216e5],[r,12,432e5],[i,1,Zt],[i,2,1728e5],[n,1,Kt],[t,1,Jt],[t,3,7776e6],[e,1,en]];function a(t,n,i){const r=Math.abs(n-t)/i,o=Xe((e=>{let[,,t]=e;return t})).right(s,r);if(o===s.length)return e.every(pt(t/en,n/en,i));if(0===o)return Xt.every(Math.max(pt(t,n,i),1));const[a,l]=s[r/s[o-1][2]isFinite(e=Math.floor(e))&&e>0?Vt((t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)}),((t,n)=>{t.setUTCFullYear(t.getUTCFullYear()+n*e)})):null,Cn.range;const[Mn,Dn]=$n(Cn,Tn,vn,cn,sn,rn),[Pn,Rn]=$n(En,An,fn,an,on,nn),Fn="year",Nn="quarter",qn="month",zn="week",Ln="date",Bn="day",Qn="dayofyear",In="hours",Wn="minutes",jn="seconds",Un="milliseconds",Vn=[Fn,Nn,qn,zn,Ln,Bn,Qn,In,Wn,jn,Un],Xn=Vn.reduce(((e,t,n)=>(e[t]=1+n,e)),{});function Yn(e){const t=j(e).slice(),n={};t.length||l("Missing time unit."),t.forEach((e=>{ie(Xn,e)?n[e]=1:l(`Invalid time unit: ${e}.`)}));return(n.week||n.day?1:0)+(n.quarter||n.month||n.date?1:0)+(n.dayofyear?1:0)>1&&l(`Incompatible time units: ${e}`),t.sort(((e,t)=>Xn[e]-Xn[t])),t}const Hn={[Fn]:"%Y ",[Nn]:"Q%q ",[qn]:"%b ",[Ln]:"%d ",[zn]:"W%U ",[Bn]:"%a ",[Qn]:"%j ",[In]:"%H:00",[Wn]:"00:%M",[jn]:":%S",[Un]:".%L","year-month":"%Y-%m ","year-month-date":"%Y-%m-%d ","hours-minutes":"%H:%M"};function Gn(e,t){const n=ee({},Hn,t),i=Yn(e),r=i.length;let o,s,a="",l=0;for(l=0;ll;--o)if(s=i.slice(l,o).join("-"),null!=n[s]){a+=n[s],l=o;break}return a.trim()}const Zn=new Date;function Kn(e){return Zn.setFullYear(e),Zn.setMonth(0),Zn.setDate(1),Zn.setHours(0,0,0,0),Zn}function Jn(e){return ti(new Date(e))}function ei(e){return ni(new Date(e))}function ti(e){return an.count(Kn(e.getFullYear())-1,e)}function ni(e){return fn.count(Kn(e.getFullYear())-1,e)}function ii(e){return Kn(e).getDay()}function ri(e,t,n,i,r,o,s){if(0<=e&&e<100){const a=new Date(-1,t,n,i,r,o,s);return a.setFullYear(e),a}return new Date(e,t,n,i,r,o,s)}function oi(e){return ai(new Date(e))}function si(e){return li(new Date(e))}function ai(e){const t=Date.UTC(e.getUTCFullYear(),0,1);return ln.count(t-1,e)}function li(e){const t=Date.UTC(e.getUTCFullYear(),0,1);return vn.count(t-1,e)}function ci(e){return Zn.setTime(Date.UTC(e,0,1)),Zn.getUTCDay()}function ui(e,t,n,i,r,o,s){if(0<=e&&e<100){const e=new Date(Date.UTC(-1,t,n,i,r,o,s));return e.setUTCFullYear(n.y),e}return new Date(Date.UTC(e,t,n,i,r,o,s))}function fi(e,t,n,i,r){const o=t||1,s=k(e),a=(e,t,r)=>function(e,t,n,i){const r=n<=1?e:i?(t,r)=>i+n*Math.floor((e(t,r)-i)/n):(t,i)=>n*Math.floor(e(t,i)/n);return t?(e,n)=>t(r(e,n),n):r}(n[r=r||e],i[r],e===s&&o,t),l=new Date,c=Te(e),u=c.year?a(Fn):K(2012),f=c.month?a(qn):c.quarter?a(Nn):d,h=c.week&&c.day?a(Bn,1,zn+Bn):c.week?a(zn,1):c.day?a(Bn,1):c.date?a(Ln,1):c.dayofyear?a(Qn,1):p,g=c.hours?a(In):d,m=c.minutes?a(Wn):d,y=c.seconds?a(jn):d,b=c.milliseconds?a(Un):d;return function(e){l.setTime(+e);const t=u(l);return r(t,f(l),h(l,t),g(l),m(l),y(l),b(l))}}function hi(e,t,n){return t+7*e-(n+6)%7}const di={[Fn]:e=>e.getFullYear(),[Nn]:e=>Math.floor(e.getMonth()/3),[qn]:e=>e.getMonth(),[Ln]:e=>e.getDate(),[In]:e=>e.getHours(),[Wn]:e=>e.getMinutes(),[jn]:e=>e.getSeconds(),[Un]:e=>e.getMilliseconds(),[Qn]:e=>ti(e),[zn]:e=>ni(e),[zn+Bn]:(e,t)=>hi(ni(e),e.getDay(),ii(t)),[Bn]:(e,t)=>hi(1,e.getDay(),ii(t))},pi={[Nn]:e=>3*e,[zn]:(e,t)=>hi(e,0,ii(t))};function gi(e,t){return fi(e,t||1,di,pi,ri)}const mi={[Fn]:e=>e.getUTCFullYear(),[Nn]:e=>Math.floor(e.getUTCMonth()/3),[qn]:e=>e.getUTCMonth(),[Ln]:e=>e.getUTCDate(),[In]:e=>e.getUTCHours(),[Wn]:e=>e.getUTCMinutes(),[jn]:e=>e.getUTCSeconds(),[Un]:e=>e.getUTCMilliseconds(),[Qn]:e=>ai(e),[zn]:e=>li(e),[Bn]:(e,t)=>hi(1,e.getUTCDay(),ci(t)),[zn+Bn]:(e,t)=>hi(li(e),e.getUTCDay(),ci(t))},yi={[Nn]:e=>3*e,[zn]:(e,t)=>hi(e,0,ci(t))};function bi(e,t){return fi(e,t||1,mi,yi,ui)}const vi={[Fn]:En,[Nn]:An.every(3),[qn]:An,[zn]:fn,[Ln]:an,[Bn]:an,[Qn]:an,[In]:on,[Wn]:nn,[jn]:tn,[Un]:Xt},wi={[Fn]:Cn,[Nn]:Tn.every(3),[qn]:Tn,[zn]:vn,[Ln]:ln,[Bn]:ln,[Qn]:ln,[In]:sn,[Wn]:rn,[jn]:tn,[Un]:Xt};function xi(e){return vi[e]}function _i(e){return wi[e]}function Oi(e,t,n){return e?e.offset(t,n):void 0}function Si(e,t,n){return Oi(xi(e),t,n)}function ki(e,t,n){return Oi(_i(e),t,n)}function Ai(e,t,n,i){return e?e.range(t,n,i):void 0}function Ti(e,t,n,i){return Ai(xi(e),t,n,i)}function Ei(e,t,n,i){return Ai(_i(e),t,n,i)}const Ci=1e3,$i=6e4,Mi=36e5,Di=864e5,Pi=2592e6,Ri=31536e6,Fi=[Fn,qn,Ln,In,Wn,jn,Un],Ni=Fi.slice(0,-1),qi=Ni.slice(0,-1),zi=qi.slice(0,-1),Li=zi.slice(0,-1),Bi=[Fn,qn],Qi=[Fn],Ii=[[Ni,1,Ci],[Ni,5,5e3],[Ni,15,15e3],[Ni,30,3e4],[qi,1,$i],[qi,5,3e5],[qi,15,9e5],[qi,30,18e5],[zi,1,Mi],[zi,3,108e5],[zi,6,216e5],[zi,12,432e5],[Li,1,Di],[[Fn,zn],1,6048e5],[Bi,1,Pi],[Bi,3,7776e6],[Qi,1,Ri]];function Wi(e){const t=e.extent,n=e.maxbins||40,i=Math.abs(xe(t))/n;let r,o,s=Xe((e=>e[2])).right(Ii,i);return s===Ii.length?(r=Qi,o=pt(t[0]/Ri,t[1]/Ri,n)):s?(s=Ii[i/Ii[s-1][2]=12)]},q:function(e){return 1+~~(e.getMonth()/3)},Q:go,s:mo,S:Fr,u:Nr,U:qr,V:Lr,w:Br,W:Qr,x:null,X:null,y:Ir,Y:jr,Z:Vr,"%":po},w={a:function(e){return s[e.getUTCDay()]},A:function(e){return o[e.getUTCDay()]},b:function(e){return l[e.getUTCMonth()]},B:function(e){return a[e.getUTCMonth()]},c:null,d:Xr,e:Xr,f:Kr,g:co,G:fo,H:Yr,I:Hr,j:Gr,L:Zr,m:Jr,M:eo,p:function(e){return r[+(e.getUTCHours()>=12)]},q:function(e){return 1+~~(e.getUTCMonth()/3)},Q:go,s:mo,S:to,u:no,U:io,V:oo,w:so,W:ao,x:null,X:null,y:lo,Y:uo,Z:ho,"%":po},x={a:function(e,t,n){var i=d.exec(t.slice(n));return i?(e.w=p.get(i[0].toLowerCase()),n+i[0].length):-1},A:function(e,t,n){var i=f.exec(t.slice(n));return i?(e.w=h.get(i[0].toLowerCase()),n+i[0].length):-1},b:function(e,t,n){var i=y.exec(t.slice(n));return i?(e.m=b.get(i[0].toLowerCase()),n+i[0].length):-1},B:function(e,t,n){var i=g.exec(t.slice(n));return i?(e.m=m.get(i[0].toLowerCase()),n+i[0].length):-1},c:function(e,n,i){return S(e,t,n,i)},d:yr,e:yr,f:Or,g:dr,G:hr,H:vr,I:vr,j:br,L:_r,m:mr,M:wr,p:function(e,t,n){var i=c.exec(t.slice(n));return i?(e.p=u.get(i[0].toLowerCase()),n+i[0].length):-1},q:gr,Q:kr,s:Ar,S:xr,u:lr,U:cr,V:ur,w:ar,W:fr,x:function(e,t,i){return S(e,n,t,i)},X:function(e,t,n){return S(e,i,t,n)},y:dr,Y:hr,Z:pr,"%":Sr};function _(e,t){return function(n){var i,r,o,s=[],a=-1,l=0,c=e.length;for(n instanceof Date||(n=new Date(+n));++a53)return null;"w"in o||(o.w=1),"Z"in o?(r=(i=Ui(Vi(o.y,0,1))).getUTCDay(),i=r>4||0===r?wn.ceil(i):wn(i),i=ln.offset(i,7*(o.V-1)),o.y=i.getUTCFullYear(),o.m=i.getUTCMonth(),o.d=i.getUTCDate()+(o.w+6)%7):(r=(i=ji(Vi(o.y,0,1))).getDay(),i=r>4||0===r?hn.ceil(i):hn(i),i=an.offset(i,7*(o.V-1)),o.y=i.getFullYear(),o.m=i.getMonth(),o.d=i.getDate()+(o.w+6)%7)}else("W"in o||"U"in o)&&("w"in o||(o.w="u"in o?o.u%7:"W"in o?1:0),r="Z"in o?Ui(Vi(o.y,0,1)).getUTCDay():ji(Vi(o.y,0,1)).getDay(),o.m=0,o.d="W"in o?(o.w+6)%7+7*o.W-(r+5)%7:o.w+7*o.U-(r+6)%7);return"Z"in o?(o.H+=o.Z/100|0,o.M+=o.Z%100,Ui(o)):ji(o)}}function S(e,t,n,i){for(var r,o,s=0,a=t.length,l=n.length;s=l)return-1;if(37===(r=t.charCodeAt(s++))){if(r=t.charAt(s++),!(o=x[r in Ji?t.charAt(s++):r])||(i=o(e,n,i))<0)return-1}else if(r!=n.charCodeAt(i++))return-1}return i}return v.x=_(n,v),v.X=_(i,v),v.c=_(t,v),w.x=_(n,w),w.X=_(i,w),w.c=_(t,w),{format:function(e){var t=_(e+="",v);return t.toString=function(){return e},t},parse:function(e){var t=O(e+="",!1);return t.toString=function(){return e},t},utcFormat:function(e){var t=_(e+="",w);return t.toString=function(){return e},t},utcParse:function(e){var t=O(e+="",!0);return t.toString=function(){return e},t}}}var Yi,Hi,Gi,Zi,Ki,Ji={"-":"",_:" ",0:"0"},er=/^\s*\d+/,tr=/^%/,nr=/[\\^$*+?|[\]().{}]/g;function ir(e,t,n){var i=e<0?"-":"",r=(i?-e:e)+"",o=r.length;return i+(o[e.toLowerCase(),t])))}function ar(e,t,n){var i=er.exec(t.slice(n,n+1));return i?(e.w=+i[0],n+i[0].length):-1}function lr(e,t,n){var i=er.exec(t.slice(n,n+1));return i?(e.u=+i[0],n+i[0].length):-1}function cr(e,t,n){var i=er.exec(t.slice(n,n+2));return i?(e.U=+i[0],n+i[0].length):-1}function ur(e,t,n){var i=er.exec(t.slice(n,n+2));return i?(e.V=+i[0],n+i[0].length):-1}function fr(e,t,n){var i=er.exec(t.slice(n,n+2));return i?(e.W=+i[0],n+i[0].length):-1}function hr(e,t,n){var i=er.exec(t.slice(n,n+4));return i?(e.y=+i[0],n+i[0].length):-1}function dr(e,t,n){var i=er.exec(t.slice(n,n+2));return i?(e.y=+i[0]+(+i[0]>68?1900:2e3),n+i[0].length):-1}function pr(e,t,n){var i=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n,n+6));return i?(e.Z=i[1]?0:-(i[2]+(i[3]||"00")),n+i[0].length):-1}function gr(e,t,n){var i=er.exec(t.slice(n,n+1));return i?(e.q=3*i[0]-3,n+i[0].length):-1}function mr(e,t,n){var i=er.exec(t.slice(n,n+2));return i?(e.m=i[0]-1,n+i[0].length):-1}function yr(e,t,n){var i=er.exec(t.slice(n,n+2));return i?(e.d=+i[0],n+i[0].length):-1}function br(e,t,n){var i=er.exec(t.slice(n,n+3));return i?(e.m=0,e.d=+i[0],n+i[0].length):-1}function vr(e,t,n){var i=er.exec(t.slice(n,n+2));return i?(e.H=+i[0],n+i[0].length):-1}function wr(e,t,n){var i=er.exec(t.slice(n,n+2));return i?(e.M=+i[0],n+i[0].length):-1}function xr(e,t,n){var i=er.exec(t.slice(n,n+2));return i?(e.S=+i[0],n+i[0].length):-1}function _r(e,t,n){var i=er.exec(t.slice(n,n+3));return i?(e.L=+i[0],n+i[0].length):-1}function Or(e,t,n){var i=er.exec(t.slice(n,n+6));return i?(e.L=Math.floor(i[0]/1e3),n+i[0].length):-1}function Sr(e,t,n){var i=tr.exec(t.slice(n,n+1));return i?n+i[0].length:-1}function kr(e,t,n){var i=er.exec(t.slice(n));return i?(e.Q=+i[0],n+i[0].length):-1}function Ar(e,t,n){var i=er.exec(t.slice(n));return i?(e.s=+i[0],n+i[0].length):-1}function Tr(e,t){return ir(e.getDate(),t,2)}function Er(e,t){return ir(e.getHours(),t,2)}function Cr(e,t){return ir(e.getHours()%12||12,t,2)}function $r(e,t){return ir(1+an.count(En(e),e),t,3)}function Mr(e,t){return ir(e.getMilliseconds(),t,3)}function Dr(e,t){return Mr(e,t)+"000"}function Pr(e,t){return ir(e.getMonth()+1,t,2)}function Rr(e,t){return ir(e.getMinutes(),t,2)}function Fr(e,t){return ir(e.getSeconds(),t,2)}function Nr(e){var t=e.getDay();return 0===t?7:t}function qr(e,t){return ir(fn.count(En(e)-1,e),t,2)}function zr(e){var t=e.getDay();return t>=4||0===t?gn(e):gn.ceil(e)}function Lr(e,t){return e=zr(e),ir(gn.count(En(e),e)+(4===En(e).getDay()),t,2)}function Br(e){return e.getDay()}function Qr(e,t){return ir(hn.count(En(e)-1,e),t,2)}function Ir(e,t){return ir(e.getFullYear()%100,t,2)}function Wr(e,t){return ir((e=zr(e)).getFullYear()%100,t,2)}function jr(e,t){return ir(e.getFullYear()%1e4,t,4)}function Ur(e,t){var n=e.getDay();return ir((e=n>=4||0===n?gn(e):gn.ceil(e)).getFullYear()%1e4,t,4)}function Vr(e){var t=e.getTimezoneOffset();return(t>0?"-":(t*=-1,"+"))+ir(t/60|0,"0",2)+ir(t%60,"0",2)}function Xr(e,t){return ir(e.getUTCDate(),t,2)}function Yr(e,t){return ir(e.getUTCHours(),t,2)}function Hr(e,t){return ir(e.getUTCHours()%12||12,t,2)}function Gr(e,t){return ir(1+ln.count(Cn(e),e),t,3)}function Zr(e,t){return ir(e.getUTCMilliseconds(),t,3)}function Kr(e,t){return Zr(e,t)+"000"}function Jr(e,t){return ir(e.getUTCMonth()+1,t,2)}function eo(e,t){return ir(e.getUTCMinutes(),t,2)}function to(e,t){return ir(e.getUTCSeconds(),t,2)}function no(e){var t=e.getUTCDay();return 0===t?7:t}function io(e,t){return ir(vn.count(Cn(e)-1,e),t,2)}function ro(e){var t=e.getUTCDay();return t>=4||0===t?On(e):On.ceil(e)}function oo(e,t){return e=ro(e),ir(On.count(Cn(e),e)+(4===Cn(e).getUTCDay()),t,2)}function so(e){return e.getUTCDay()}function ao(e,t){return ir(wn.count(Cn(e)-1,e),t,2)}function lo(e,t){return ir(e.getUTCFullYear()%100,t,2)}function co(e,t){return ir((e=ro(e)).getUTCFullYear()%100,t,2)}function uo(e,t){return ir(e.getUTCFullYear()%1e4,t,4)}function fo(e,t){var n=e.getUTCDay();return ir((e=n>=4||0===n?On(e):On.ceil(e)).getUTCFullYear()%1e4,t,4)}function ho(){return"+0000"}function po(){return"%"}function go(e){return+e}function mo(e){return Math.floor(+e/1e3)}function yo(e){const t={};return n=>t[n]||(t[n]=e(n))}function bo(e){const t=yo(e.format),n=e.formatPrefix;return{format:t,formatPrefix:n,formatFloat(e){const n=$t(e||",");if(null==n.precision){switch(n.precision=12,n.type){case"%":n.precision-=2;break;case"e":n.precision-=1}return i=t(n),r=t(".1f")(1)[1],e=>{const t=i(e),n=t.indexOf(r);if(n<0)return t;let o=function(e,t){let n,i=e.lastIndexOf("e");if(i>0)return i;for(i=e.length;--i>t;)if(n=e.charCodeAt(i),n>=48&&n<=57)return i+1}(t,n);const s=on;)if("0"!==t[o]){++o;break}return t.slice(0,o)+s}}return t(n);var i,r},formatSpan(e,i,r,o){o=$t(null==o?",f":o);const s=pt(e,i,r),a=Math.max(Math.abs(e),Math.abs(i));let l;if(null==o.precision)switch(o.type){case"s":return isNaN(l=It(s,a))||(o.precision=l),n(o,a);case"":case"e":case"g":case"p":case"r":isNaN(l=Wt(s,a))||(o.precision=l-("e"===o.type));break;case"f":case"%":isNaN(l=Qt(s))||(o.precision=l-2*("%"===o.type))}return t(o)}}}let vo,wo;function xo(){return vo=bo({format:Nt,formatPrefix:qt})}function _o(e){return bo(Bt(e))}function Oo(e){return arguments.length?vo=_o(e):vo}function So(e,t,n){w(n=n||{})||l(`Invalid time multi-format specifier: ${n}`);const i=t(jn),r=t(Wn),o=t(In),s=t(Ln),a=t(zn),c=t(qn),u=t(Nn),f=t(Fn),h=e(n.milliseconds||".%L"),d=e(n.seconds||":%S"),p=e(n.minutes||"%I:%M"),g=e(n.hours||"%I %p"),m=e(n.date||n.day||"%a %d"),y=e(n.week||"%b %d"),b=e(n.month||"%B"),v=e(n.quarter||"%B"),x=e(n.year||"%Y");return e=>(i(e)pe(e)?t(e):So(t,xi,e),utcFormat:e=>pe(e)?n(e):So(n,_i,e),timeParse:yo(e.parse),utcParse:yo(e.utcParse)}}function Ao(){return wo=ko({format:Hi,parse:Gi,utcFormat:Zi,utcParse:Ki})}function To(e){return ko(Xi(e))}function Eo(e){return arguments.length?wo=To(e):wo}!function(e){Yi=Xi(e),Hi=Yi.format,Gi=Yi.parse,Zi=Yi.utcFormat,Ki=Yi.utcParse}({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]}),xo(),Ao();const Co=(e,t)=>ee({},e,t);function $o(e,t){const n=e?_o(e):Oo(),i=t?To(t):Eo();return Co(n,i)}function Mo(e,t){const n=arguments.length;return n&&2!==n&&l("defaultLocale expects either zero or two arguments."),n?Co(Oo(e),Eo(t)):Co(Oo(),Eo())}const Do=/^(data:|([A-Za-z]+:)?\/\/)/,Po=/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp|file|data):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,Ro=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,Fo="file://";async function No(e,t){const n=await this.sanitize(e,t),i=n.href;return n.localFile?this.file(i):this.http(i,t)}async function qo(e,t){t=ee({},this.options,t);const n=this.fileAccess,i={href:null};let r,o,s;const a=Po.test(e.replace(Ro,""));null!=e&&"string"==typeof e&&a||l("Sanitize failure, invalid URI: "+_e(e));const c=Do.test(e);return(s=t.baseURL)&&!c&&(e.startsWith("/")||s.endsWith("/")||(e="/"+e),e=s+e),o=(r=e.startsWith(Fo))||"file"===t.mode||"http"!==t.mode&&!c&&n,r?e=e.slice(Fo.length):e.startsWith("//")&&("file"===t.defaultProtocol?(e=e.slice(2),o=!0):e=(t.defaultProtocol||"http")+":"+e),Object.defineProperty(i,"localFile",{value:!!o}),i.href=e,t.target&&(i.target=t.target+""),t.rel&&(i.rel=t.rel+""),"image"===t.context&&t.crossOrigin&&(i.crossOrigin=t.crossOrigin+""),i}function zo(e){return e?t=>new Promise(((n,i)=>{e.readFile(t,((e,t)=>{e?i(e):n(t)}))})):Lo}async function Lo(){l("No file system access.")}function Bo(e){return e?async function(t,n){const i=ee({},this.options.http,n),r=n&&n.response,o=await e(t,i);return o.ok?V(o[r])?o[r]():o.text():l(o.status+""+o.statusText)}:Qo}async function Qo(){l("No HTTP fetch method available.")}const Io=e=>!(Number.isNaN(+e)||e instanceof Date),Wo={boolean:Oe,integer:A,number:A,date:ke,string:Ae,unknown:h},jo=[e=>"true"===e||"false"===e||!0===e||!1===e,e=>Io(e)&&Number.isInteger(+e),Io,e=>!Number.isNaN(Date.parse(e))],Uo=["boolean","integer","number","date"];function Vo(e,t){if(!e||!e.length)return"unknown";const n=e.length,i=jo.length,r=jo.map(((e,t)=>t+1));for(let s,a,l=0,c=0;l0===e?t:e),0)-1]}function Xo(e,t){return t.reduce(((t,n)=>(t[n]=Vo(e,n),t)),{})}function Yo(e){const t=function(t,n){const i={delimiter:e};return Ho(t,n?ee(n,i):i)};return t.responseType="text",t}function Ho(e,t){return t.header&&(e=t.header.map(_e).join(t.delimiter)+"\n"+e),Ne(t.delimiter).parse(e+"")}function Go(e,t){const n=t&&t.property?u(t.property):h;return!w(e)||(i=e,"function"==typeof Buffer&&V(Buffer.isBuffer)&&Buffer.isBuffer(i))?n(JSON.parse(e)):function(e,t){!v(e)&&fe(e)&&(e=[...e]);return t&&t.copy?JSON.parse(JSON.stringify(e)):e}(n(e),t);var i}Ho.responseType="text",Go.responseType="json";const Zo={interior:(e,t)=>e!==t,exterior:(e,t)=>e===t};function Ko(e,t){let n,i,r,o;return e=Go(e,t),t&&t.feature?(n=ze,r=t.feature):t&&t.mesh?(n=Ie,r=t.mesh,o=Zo[t.filter]):l("Missing TopoJSON feature or mesh parameter."),i=(i=e.objects[r])?n(e,i,o):l("Invalid TopoJSON object: "+r),i&&i.features||[i]}Ko.responseType="json";const Jo={dsv:Ho,csv:Yo(","),tsv:Yo("\t"),json:Go,topojson:Ko};function es(e,t){return arguments.length>1?(Jo[e]=t,this):ie(Jo,e)?Jo[e]:null}function ts(e){const t=es(e);return t&&t.responseType||"text"}function ns(e,t,n,i){const r=es((t=t||{}).type||"json");return r||l("Unknown data format type: "+t.type),e=r(e,t),t.parse&&function(e,t,n,i){if(!e.length)return;const r=Eo();n=n||r.timeParse,i=i||r.utcParse;let o,s,a,l,c,u,f=e.columns||Object.keys(e[0]);"auto"===t&&(t=Xo(e,f));f=Object.keys(t);const h=f.map((e=>{const r=t[e];let o,s;if(r&&(r.startsWith("date:")||r.startsWith("utc:"))){o=r.split(/:(.+)?/,2),s=o[1],("'"===s[0]&&"'"===s[s.length-1]||'"'===s[0]&&'"'===s[s.length-1])&&(s=s.slice(1,-1));return("utc"===o[0]?i:n)(s)}if(!Wo[r])throw Error("Illegal format pattern: "+e+":"+r);return Wo[r]}));for(a=0,c=e.length,u=f.length;a({options:n||{},sanitize:qo,load:No,fileAccess:!1,file:zo(t),http:Bo(e)})}("undefined"!=typeof fetch&&fetch,null);function rs(e){const t=e||h,n=[],i={};return n.add=e=>{const r=t(e);return i[r]||(i[r]=1,n.push(e)),n},n.remove=e=>{const r=t(e);if(i[r]){i[r]=0;const t=n.indexOf(e);t>=0&&n.splice(t,1)}return n},n}async function os(e,t){try{await t(e)}catch(t){e.error(t)}}const ss=Symbol("vega_id");let as=1;function ls(e){return!(!e||!cs(e))}function cs(e){return e[ss]}function us(e,t){return e[ss]=t,e}function fs(e){const t=e===Object(e)?e:{data:e};return cs(t)?t:us(t,as++)}function hs(e){return ds(e,fs({}))}function ds(e,t){for(const n in e)t[n]=e[n];return t}function ps(e,t){return us(t,cs(e))}function gs(e,t){return e?t?(n,i)=>e(n,i)||cs(t(n))-cs(t(i)):(t,n)=>e(t,n)||cs(t)-cs(n):null}function ms(e){return e&&e.constructor===ys}function ys(){const e=[],t=[],n=[],i=[],r=[];let o=null,s=!1;return{constructor:ys,insert(t){const n=j(t),i=n.length;for(let t=0;t{p(e)&&(c[cs(e)]=-1)}));for(f=0,h=e.length;f0&&(y(g,p,d.value),a.modifies(p));for(f=0,h=r.length;f{p(e)&&c[cs(e)]>0&&y(e,d.field,d.value)})),a.modifies(d.field);if(s)a.mod=t.length||i.length?l.filter((e=>c[cs(e)]>0)):l.slice();else for(m in u)a.mod.push(u[m]);return(o||null==o&&(t.length||i.length))&&a.clean(!0),a}}}const bs="_:mod:_";function vs(){Object.defineProperty(this,bs,{writable:!0,value:{}})}vs.prototype={set(e,t,n,i){const r=this,o=r[e],s=r[bs];return null!=t&&t>=0?(o[t]!==n||i)&&(o[t]=n,s[t+":"+e]=-1,s[e]=-1):(o!==n||i)&&(r[e]=n,s[e]=v(n)?1+n.length:-1),r},modified(e,t){const n=this[bs];if(!arguments.length){for(const e in n)if(n[e])return!0;return!1}if(v(e)){for(let t=0;t