UNPKG

@uiw/react-codemirror

Version:
1 lines 152 kB
!function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t(require("react"),require("react/jsx-runtime"),require("@codemirror/state"),require("@codemirror/theme-one-dark"),require("@codemirror/view")):"function"===typeof define&&define.amd?define(["react","react/jsx-runtime",,,],t):"object"===typeof exports?exports["@uiw/codemirror"]=t(require("react"),require("react/jsx-runtime"),require("@codemirror/state"),require("@codemirror/theme-one-dark"),require("@codemirror/view")):e["@uiw/codemirror"]=t(e.React,e.ReactJSXRuntime,e.CM["@codemirror/state"],e.CM["@codemirror/theme-one-dark"],e.CM["@codemirror/view"])}(self,((e,t,n,i,r)=>(()=>{"use strict";var o={60:e=>{e.exports=n},89:(e,t,n)=>{n.r(t),n.d(t,{defaultLightThemeOption:()=>a.c,getDefaultExtensions:()=>h});var i=n(720),r=n(687),o=n(730),s=n(708),l=n(60),a=n(806),c={};for(const u in s)["default","getDefaultExtensions"].indexOf(u)<0&&(c[u]=()=>s[u]);n.d(t,c);var h=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.indentWithTab,n=void 0===t||t,c=e.editable,h=void 0===c||c,u=e.readOnly,f=void 0!==u&&u,d=e.theme,p=void 0===d?"light":d,m=e.placeholder,g=void 0===m?"":m,y=e.basicSetup,v=void 0===y||y,b=[];switch(n&&b.unshift(o.keymap.of([i.Yc])),v&&("boolean"===typeof v?b.unshift((0,r.o)()):b.unshift((0,r.o)(v))),g&&b.unshift((0,o.placeholder)(g)),p){case"light":b.push(a.c);break;case"dark":b.push(s.oneDark);break;case"none":break;default:b.push(p)}return!1===h&&b.push(o.EditorView.editable.of(!1)),f&&b.push(l.EditorState.readOnly.of(!0)),[].concat(b)}},194:(e,t,n)=>{n.d(t,{KB:()=>re,SG:()=>et,Zt:()=>He,Lv:()=>Le,f7:()=>De,tp:()=>te,_v:()=>ie,WD:()=>de,EI:()=>ne,Xt:()=>ee,jU:()=>rt,y9:()=>_e,mv:()=>z});var i=n(203),r=n(60),o=n(730);let s=0;class l{constructor(e,t,n,i){this.name=e,this.set=t,this.base=n,this.modified=i,this.id=s++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let n="string"==typeof e?e:"?";if(e instanceof l&&(t=e),null===t||void 0===t?void 0:t.base)throw new Error("Can not derive from a modified tag");let i=new l(n,[],null,[]);if(i.set.push(i),t)for(let r of t.set)i.set.push(r);return i}static defineModifier(e){let t=new c(e);return e=>e.modified.indexOf(t)>-1?e:c.get(e.base||e,e.modified.concat(t).sort(((e,t)=>e.id-t.id)))}}let a=0;class c{constructor(e){this.name=e,this.instances=[],this.id=a++}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 l(e.name,i,e,t);for(let s of t)s.instances.push(r);let o=function(e){let t=[[]];for(let n=0;n<e.length;n++)for(let i=0,r=t.length;i<r;i++)t.push(t[i].concat(e[n]));return t.sort(((e,t)=>t.length-e.length))}(t);for(let s of e.set)if(!s.modified.length)for(let e of o)i.push(c.get(s,e));return r}}function h(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,l=n[s];if(!l)throw new RangeError("Invalid path: "+e);let a=new f(i,r,s>0?n.slice(0,s):null);t[l]=a.sort(t[l])}}return u.add(t)}const u=new i.uY;class f{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<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}function d(e,t){let n=Object.create(null);for(let o of e)if(Array.isArray(o.tag))for(let e of o.tag)n[e.id]=o.class;else n[o.tag.id]=o.class;let{scope:i,all:r=null}=t||{};return{style:e=>{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 p(e,t,n,i=0,r=e.length){let o=new m(i,Array.isArray(t)?t:[t],n);o.highlightRange(e.cursor(),i,r,"",o.highlighters),o.flush(r)}f.empty=new f([],2,null);class m{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,r,o){let{type:s,from:l,to:a}=e;if(l>=n||a<=t)return;s.isTop&&(o=this.highlighters.filter((e=>!e.scope||e.scope(s))));let c=r,h=function(e){let t=e.type.prop(u);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}(e)||f.empty,d=function(e,t){let n=null;for(let i of e){let e=i.style(t);e&&(n=n?n+" "+e:e)}return n}(o,h.tags);if(d&&(c&&(c+=" "),c+=d,1==h.mode&&(r+=(r?" ":"")+d)),this.startSpan(Math.max(t,l),c),h.opaque)return;let p=e.tree&&e.tree.prop(i.uY.mounted);if(p&&p.overlay){let i=e.node.enter(p.overlay[0].from+l,1),s=this.highlighters.filter((e=>!e.scope||e.scope(p.tree.type))),h=e.firstChild();for(let u=0,f=l;;u++){let d=u<p.overlay.length?p.overlay[u]:null,m=d?d.from+l:a,g=Math.max(t,f),y=Math.min(n,m);if(g<y&&h)for(;e.from<y&&(this.highlightRange(e,g,y,r,o),this.startSpan(Math.min(y,e.to),c),!(e.to>=m)&&e.nextSibling()););if(!d||m>n)break;f=d.to+l,f>t&&(this.highlightRange(i.cursor(),Math.max(t,d.from+l),Math.min(n,f),"",s),this.startSpan(Math.min(n,f),c))}h&&e.parent()}else if(e.firstChild()){p&&(r="");do{if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,o),this.startSpan(Math.min(n,e.to),c)}}while(e.nextSibling());e.parent()}}}const g=l.define,y=g(),v=g(),b=g(v),w=g(v),x=g(),k=g(x),S=g(x),C=g(),A=g(C),E=g(),D=g(),M=g(),O=g(M),P=g(),T={comment:y,lineComment:g(y),blockComment:g(y),docComment:g(y),name:v,variableName:g(v),typeName:b,tagName:g(b),propertyName:w,attributeName:g(w),className:g(v),labelName:g(v),namespace:g(v),macroName:g(v),literal:x,string:k,docString:g(k),character:g(k),attributeValue:g(k),number:S,integer:g(S),float:g(S),bool:g(x),regexp:g(x),escape:g(x),color:g(x),url:g(x),keyword:E,self:g(E),null:g(E),atom:g(E),unit:g(E),modifier:g(E),operatorKeyword:g(E),controlKeyword:g(E),definitionKeyword:g(E),moduleKeyword:g(E),operator:D,derefOperator:g(D),arithmeticOperator:g(D),logicOperator:g(D),bitwiseOperator:g(D),compareOperator:g(D),updateOperator:g(D),definitionOperator:g(D),typeOperator:g(D),controlOperator:g(D),punctuation:M,separator:g(M),bracket:O,angleBracket:g(O),squareBracket:g(O),paren:g(O),brace:g(O),content:C,heading:A,heading1:g(A),heading2:g(A),heading3:g(A),heading4:g(A),heading5:g(A),heading6:g(A),contentSeparator:g(C),list:g(C),quote:g(C),emphasis:g(C),strong:g(C),link:g(C),monospace:g(C),strikethrough:g(C),inserted:g(),deleted:g(),changed:g(),invalid:g(),meta:P,documentMeta:g(P),annotation:g(P),processingInstruction:g(P),definition:l.defineModifier("definition"),constant:l.defineModifier("constant"),function:l.defineModifier("function"),standard:l.defineModifier("standard"),local:l.defineModifier("local"),special:l.defineModifier("special")};for(let dt in T){let e=T[dt];e instanceof l&&(e.name=dt)}d([{tag:T.link,class:"tok-link"},{tag:T.heading,class:"tok-heading"},{tag:T.emphasis,class:"tok-emphasis"},{tag:T.strong,class:"tok-strong"},{tag:T.keyword,class:"tok-keyword"},{tag:T.atom,class:"tok-atom"},{tag:T.bool,class:"tok-bool"},{tag:T.url,class:"tok-url"},{tag:T.labelName,class:"tok-labelName"},{tag:T.inserted,class:"tok-inserted"},{tag:T.deleted,class:"tok-deleted"},{tag:T.literal,class:"tok-literal"},{tag:T.string,class:"tok-string"},{tag:T.number,class:"tok-number"},{tag:[T.regexp,T.escape,T.special(T.string)],class:"tok-string2"},{tag:T.variableName,class:"tok-variableName"},{tag:T.local(T.variableName),class:"tok-variableName tok-local"},{tag:T.definition(T.variableName),class:"tok-variableName tok-definition"},{tag:T.special(T.variableName),class:"tok-variableName2"},{tag:T.definition(T.propertyName),class:"tok-propertyName tok-definition"},{tag:T.typeName,class:"tok-typeName"},{tag:T.namespace,class:"tok-namespace"},{tag:T.className,class:"tok-className"},{tag:T.macroName,class:"tok-macroName"},{tag:T.propertyName,class:"tok-propertyName"},{tag:T.operator,class:"tok-operator"},{tag:T.comment,class:"tok-comment"},{tag:T.meta,class:"tok-meta"},{tag:T.invalid,class:"tok-invalid"},{tag:T.punctuation,class:"tok-punctuation"}]);const I="undefined"==typeof Symbol?"__\u037c":Symbol.for("\u037c"),B="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),N="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class R{constructor(e,t){this.rules=[];let{finish:n}=t||{};function i(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function r(e,t,o,s){let l=[],a=/^@(\w+)\b/.exec(e[0]),c=a&&"keyframes"==a[1];if(a&&null==t)return o.push(e[0]+";");for(let n in t){let s=t[n];if(/&/.test(n))r(n.split(/,\s*/).map((t=>e.map((e=>t.replace(/&/,e))))).reduce(((e,t)=>e.concat(t))),s,o);else if(s&&"object"==typeof s){if(!a)throw new RangeError("The value of a property ("+n+") should be a primitive value.");r(i(n),s,l,c)}else null!=s&&l.push(n.replace(/_.*/,"").replace(/[A-Z]/g,(e=>"-"+e.toLowerCase()))+": "+s+";")}(l.length||c)&&o.push((!n||a||s?e:e.map(n)).join(", ")+" {"+l.join(" ")+"}")}for(let o in e)r(i(o),e[o],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let e=N[I]||1;return N[I]=e+1,"\u037c"+e.toString(36)}static mount(e,t,n){let i=e[B],r=n&&n.nonce;i?r&&i.setNonce(r):i=new F(e,r),i.mount(Array.isArray(t)?t:[t],e)}}let L=new Map;class F{constructor(e,t){let n=e.ownerDocument||e,i=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&i.CSSStyleSheet){let t=L.get(n);if(t)return e[B]=t;this.sheet=new i.CSSStyleSheet,L.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[B]=this}mount(e,t){let n=this.sheet,i=0,r=0;for(let o=0;o<e.length;o++){let t=e[o],s=this.modules.indexOf(t);if(s<r&&s>-1&&(this.modules.splice(s,1),r--,s=-1),-1==s){if(this.modules.splice(r++,0,t),n)for(let e=0;e<t.rules.length;e++)n.insertRule(t.rules[e],i++)}else{for(;r<s;)i+=this.modules[r++].rules.length;i+=t.rules.length,r++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let e="";for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+"\n";this.styleTag.textContent=e;let n=t.head||t;this.styleTag.parentNode!=n&&n.insertBefore(this.styleTag,n.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}var j;const W=new i.uY;const V=new i.uY;class q{constructor(e,t,n=[],i=""){this.data=e,this.name=i,r.EditorState.prototype.hasOwnProperty("tree")||Object.defineProperty(r.EditorState.prototype,"tree",{get(){return z(this)}}),this.parser=t,this.extension=[Q.of(this),r.EditorState.languageData.of(((e,t,n)=>{let i=_(e,t,n),r=i.type.prop(W);if(!r)return[];let o=e.facet(r),s=i.type.prop(V);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 _(e,t,n).type.prop(W)==this.data}findRegions(e){let t=e.facet(Q);if((null===t||void 0===t?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(e,t)=>{if(e.prop(W)==this.data)return void n.push({from:t,to:t+e.length});let o=e.prop(i.uY.mounted);if(o){if(o.tree.prop(W)==this.data){if(o.overlay)for(let e of o.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}if(o.overlay){let e=n.length;if(r(o.tree,o.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let o=e.children[n];o instanceof i.PH&&r(o,e.positions[n]+t)}};return r(z(e),0),n}get allowsNesting(){return!0}}function _(e,t,n){let r=e.facet(Q),o=z(e).topNode;if(!r||r.allowsNesting)for(let s=o;s;s=s.enter(t,n,i.Qj.ExcludeBuffers))s.type.isTop&&(o=s);return o}q.setState=r.StateEffect.define();function z(e){let t=e.field(q.state,!1);return t?t.tree:i.PH.empty}class U{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<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}}let H=null;class ${constructor(e,t,n=[],i,r,o,s,l){this.parser=e,this.state=t,this.fragments=n,this.tree=i,this.treeLen=r,this.viewport=o,this.skipped=s,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new $(e,t,[],i.PH.empty,0,n,[],null)}startParse(){return this.parser.startParse(new U(this.state.doc),this.fragments)}work(e,t){return null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=i.PH.empty&&this.isDone(null!==t&&void 0!==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.state.doc.length&&this.parse.stopAt(t);;){let r=this.parse.advance();if(r){if(this.fragments=this.withoutTempSkipped(i.rr.addTree(r,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(n=this.parse.stoppedAt)&&void 0!==n?n:this.state.doc.length,this.tree=r,this.parse=null,!(this.treeLen<(null!==t&&void 0!==t?t:this.state.doc.length)))return!0;this.parse=this.startParse()}if(e())return!1}}))}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=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(i.rr.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=H;H=this;try{return e()}finally{H=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=J(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:r,treeLen:o,viewport:s,skipped:l}=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=i.rr.applyChanges(n,t),r=i.PH.empty,o=0,s={from:e.mapPos(s.from,-1),to:e.mapPos(s.to,1)},this.skipped.length){l=[];for(let t of this.skipped){let n=e.mapPos(t.from,1),i=e.mapPos(t.to,-1);n<i&&l.push({from:n,to:i})}}}return new $(this.parser,t,n,r,o,s,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let n=0;n<this.skipped.length;n++){let{from:t,to:i}=this.skipped[n];t<e.to&&i>e.from&&(this.fragments=J(this.fragments,t,i),this.skipped.splice(n--,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 i.iX{createParse(t,n,r){let o=r[0].from,s=r[r.length-1].to;return{parsedPos:o,advance(){let t=H;if(t){for(let e of r)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=s,new i.PH(i.Z6.none,[],[],s-o)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&0==t[0].from&&t[0].to>=e}static get(){return H}}function J(e,t,n){return i.rr.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class K{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 K(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=$.create(e.facet(Q).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new K(n)}}q.state=r.StateField.define({create:K.init,update(e,t){for(let n of t.effects)if(n.is(q.setState))return n.value;return t.startState.facet(Q)!=t.state.facet(Q)?K.init(t.state):e.apply(t)}});let Y=e=>{let t=setTimeout((()=>e()),500);return()=>clearTimeout(t)};"undefined"!=typeof requestIdleCallback&&(Y=e=>{let t=-1,n=setTimeout((()=>{t=requestIdleCallback(e,{timeout:400})}),100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const G="undefined"!=typeof navigator&&(null===(j=navigator.scheduling)||void 0===j?void 0:j.isInputPending)?()=>navigator.scheduling.isInputPending():null,Z=o.ViewPlugin.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(q.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(q.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=Y(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:i}}=this.view,r=n.field(q.state);if(r.tree==r.context.tree&&r.context.isDone(i+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!G?Math.max(25,e.timeRemaining()-5):1e9),s=r.context.treeLen<i&&n.doc.length>i+1e3,l=r.context.work((()=>G&&G()||Date.now()>o),i+(s?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:q.setState.of(new K(r.context))})),this.chunkBudget>0&&(!l||s)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then((()=>this.scheduleWork())).catch((e=>(0,o.logException)(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()}}}),Q=r.Facet.define({combine:e=>e.length?e[0]:null,enables:e=>[q.state,Z,o.EditorView.contentAttributes.compute([e],(t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}}))]});const X=r.Facet.define(),ee=r.Facet.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 te(e){let t=e.facet(ee);return 9==t.charCodeAt(0)?e.tabSize*t.length:t.length}function ne(e,t){let n="",i=e.tabSize,r=e.facet(ee)[0];if("\t"==r){for(;t>=i;)n+="\t",t-=i;r=" "}for(let o=0;o<t;o++)n+=r;return n}function ie(e,t){e instanceof r.EditorState&&(e=new re(e));for(let i of e.state.facet(X)){let n=i(e,t);if(void 0!==n)return n}let n=z(e.state);return n.length>=t?function(e,t,n){let i=t.resolveStack(n),r=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(r!=i.node){let e=[];for(let t=r;t&&!(t.from<i.node.from||t.to>i.node.to||t.from==i.node.from&&t.type==i.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)i={node:e[t],next:i}}return se(i,e,n)}(e,n,t):null}class re{constructor(e,t={}){this.state=e,this.options=t,this.unit=te(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:i,simulateDoubleBreak:r}=this.options;return null!=i&&i>=n.from&&i<=n.to?r&&i==e?{text:"",from:e}:(t<0?i<e:i<=e)?{text:n.text.slice(i-n.from),from:i}:{text:n.text.slice(0,i-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:i}=this.lineAt(e,t);return n.slice(e-i,Math.min(n.length,e+100-i))}column(e,t=1){let{text:n,from:i}=this.lineAt(e,t),r=this.countColumn(n,e-i),o=this.options.overrideIndentation?this.options.overrideIndentation(i):-1;return o>-1&&(r+=o-this.countColumn(n,n.search(/\S|$/))),r}countColumn(e,t=e.length){return(0,r.countColumn)(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 oe=new i.uY;function se(e,t,n){for(let i=e;i;i=i.next){let e=le(i.node);if(e)return e(ce.create(t,n,i))}return 0}function le(e){let t=e.type.prop(oe);if(t)return t;let n,r=e.firstChild;if(r&&(n=r.type.prop(i.uY.closedBy))){let t=e.lastChild,i=t&&n.indexOf(t.name)>-1;return e=>ue(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?ae:null}function ae(){return 0}class ce extends re{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(e,t,n){return new ce(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(he(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return se(this.context.next,this.base,this.pos)}}function he(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function ue(e,t,n,i,r){let o=e.textAfter,s=o.match(/^\s*/)[0].length,l=i&&o.slice(s,s+i.length)==i||r==e.pos+s,a=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 l=n.to;;){let e=t.childAfter(l);if(!e||e==i)return null;if(!e.type.isSkipped){if(e.from>=s)return null;let t=/^ */.exec(o.text.slice(n.to-o.from))[0].length;return{from:n.from,to:n.to+t}}l=e.to}}(e):null;return a?l?e.column(a.from):e.column(a.to):e.baseIndent+(l?0:e.unit*n)}const fe=200;function de(){return r.EditorState.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+fe)return e;let o=n.sliceString(r.from,i);if(!t.some((e=>e.test(o))))return e;let{state:s}=e,l=-1,a=[];for(let{head:c}of s.selection.ranges){let e=s.doc.lineAt(c);if(e.from==l)continue;l=e.from;let t=ie(s,e.from);if(null==t)continue;let n=/^\s*/.exec(e.text)[0],i=ne(s,t);n!=i&&a.push({from:e.from,to:e.from+n.length,insert:i})}return a.length?[e,{changes:a,sequential:!0}]:e}))}const pe=r.Facet.define(),me=new i.uY;function ge(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function ye(e,t,n){for(let i of e.facet(pe)){let r=i(e,t,n);if(r)return r}return function(e,t,n){let i=z(e);if(i.length<n)return null;let r=null;for(let o=i.resolveStack(n,1);o;o=o.next){let s=o.node;if(s.to<=n||s.from>n)continue;if(r&&s.from<t)break;let l=s.type.prop(me);if(l&&(s.to<i.length-50||i.length==e.doc.length||!ge(s))){let i=l(s,e);i&&i.from<=n&&i.from>=t&&i.to>n&&(r=i)}}return r}(e,t,n)}function ve(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 be=r.StateEffect.define({map:ve}),we=r.StateEffect.define({map:ve});function xe(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 ke=r.StateField.define({create:()=>o.Decoration.none,update(e,t){e=e.map(t.changes);for(let n of t.effects)if(n.is(be)&&!Ce(e,n.value.from,n.value.to)){let{preparePlaceholder:i}=t.state.facet(Oe),r=i?o.Decoration.replace({widget:new Be(i(t.state,n.value))}):Ie;e=e.update({add:[r.range(n.value.from,n.value.to)]})}else n.is(we)&&(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)=>{e<i&&t>i&&(n=!0)})),n&&(e=e.update({filterFrom:i,filterTo:i,filter:(e,t)=>t<=i||e>=i}))}return e},provide:e=>o.EditorView.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<e.length;){let i=e[n++],r=e[n++];if("number"!=typeof i||"number"!=typeof r)throw new RangeError("Invalid JSON for fold state");t.push(Ie.range(i,r))}return o.Decoration.set(t,!0)}});function Se(e,t,n){var i;let r=null;return null===(i=e.field(ke,!1))||void 0===i||i.between(t,n,((e,t)=>{(!r||r.from>e)&&(r={from:e,to:t})})),r}function Ce(e,t,n){let i=!1;return e.between(t,t,((e,r)=>{e==t&&r==n&&(i=!0)})),i}function Ae(e,t){return e.field(ke,!1)?t:t.concat(r.StateEffect.appendConfig.of(Pe()))}function Ee(e,t,n=!0){let i=e.state.doc.lineAt(t.from).number,r=e.state.doc.lineAt(t.to).number;return o.EditorView.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${i} ${e.state.phrase("to")} ${r}.`)}const De=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:e=>{for(let t of xe(e)){let n=ye(e.state,t.from,t.to);if(n)return e.dispatch({effects:Ae(e.state,[be.of(n),Ee(e,n)])}),!0}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:e=>{if(!e.state.field(ke,!1))return!1;let t=[];for(let n of xe(e)){let i=Se(e.state,n.from,n.to);i&&t.push(we.of(i),Ee(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<t.doc.length;){let r=e.lineBlockAt(i),o=ye(t,r.from,r.to);o&&n.push(be.of(o)),i=(o?e.lineBlockAt(o.to):r).to+1}return n.length&&e.dispatch({effects:Ae(e.state,n)}),!!n.length}},{key:"Ctrl-Alt-]",run:e=>{let t=e.state.field(ke,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,((e,t)=>{n.push(we.of({from:e,to:t}))})),e.dispatch({effects:n}),!0}}],Me={placeholderDOM:null,preparePlaceholder:null,placeholderText:"\u2026"},Oe=r.Facet.define({combine:e=>(0,r.combineConfig)(e,Me)});function Pe(e){let t=[ke,Fe];return e&&t.push(Oe.of(e)),t}function Te(e,t){let{state:n}=e,i=n.facet(Oe),r=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),i=Se(e.state,n.from,n.to);i&&e.dispatch({effects:we.of(i)}),t.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(e,r,t);let o=document.createElement("span");return o.textContent=i.placeholderText,o.setAttribute("aria-label",n.phrase("folded code")),o.title=n.phrase("unfold"),o.className="cm-foldPlaceholder",o.onclick=r,o}const Ie=o.Decoration.replace({widget:new class extends o.WidgetType{toDOM(e){return Te(e,null)}}});class Be extends o.WidgetType{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return Te(e,this.value)}}const Ne={openText:"\u2304",closedText:"\u203a",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class Re extends o.GutterMarker{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 Le(e={}){let t={...Ne,...e},n=new Re(t,!0),i=new Re(t,!1),s=o.ViewPlugin.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(Q)!=e.state.facet(Q)||e.startState.field(ke,!1)!=e.state.field(ke,!1)||z(e.startState)!=z(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new r.RangeSetBuilder;for(let r of e.viewportLineBlocks){let o=Se(e.state,r.from,r.to)?i:ye(e.state,r.from,r.to)?n:null;o&&t.add(r.from,r.from,o)}return t.finish()}}),{domEventHandlers:l}=t;return[s,(0,o.gutter)({class:"cm-foldGutter",markers(e){var t;return(null===(t=e.plugin(s))||void 0===t?void 0:t.markers)||r.RangeSet.empty},initialSpacer:()=>new Re(t,!1),domEventHandlers:{...l,click:(e,t,n)=>{if(l.click&&l.click(e,t,n))return!0;let i=Se(e.state,t.from,t.to);if(i)return e.dispatch({effects:we.of(i)}),!0;let r=ye(e.state,t.from,t.to);return!!r&&(e.dispatch({effects:be.of(r)}),!0)}}}),Pe()]}const Fe=o.EditorView.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 je{constructor(e,t){let n;function i(e){let t=R.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 q?e=>e.prop(W)==o.data:o?e=>e==o:void 0,this.style=d(e.map((e=>({tag:e.tag,class:e.class||i(Object.assign({},e,{tag:null}))}))),{all:r}).style,this.module=n?new R(n):null,this.themeType=t.themeType}static define(e,t){return new je(e,t||{})}}const We=r.Facet.define(),Ve=r.Facet.define({combine:e=>e.length?[e[0]]:null});function qe(e){let t=e.facet(We);return t.length?t:e.facet(Ve)}function _e(e,t){let n,i=[Ue];return e instanceof je&&(e.module&&i.push(o.EditorView.styleModule.of(e.module)),n=e.themeType),(null===t||void 0===t?void 0:t.fallback)?i.push(Ve.of(e)):n?i.push(We.computeN([o.EditorView.darkTheme],(t=>t.facet(o.EditorView.darkTheme)==("dark"==n)?[e]:[]))):i.push(We.of(e)),i}class ze{constructor(e){this.markCache=Object.create(null),this.tree=z(e.state),this.decorations=this.buildDeco(e,qe(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=z(e.state),n=qe(e.state),i=n!=qe(e.startState),{viewport:r}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<r.to&&!i&&t.type==this.tree.type&&o>=r.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||i)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=r.to)}buildDeco(e,t){if(!t||!this.tree.length)return o.Decoration.none;let n=new r.RangeSetBuilder;for(let{from:i,to:r}of e.visibleRanges)p(this.tree,t,((e,t,i)=>{n.add(e,t,this.markCache[i]||(this.markCache[i]=o.Decoration.mark({class:i})))}),i,r);return n.finish()}}const Ue=r.Prec.high(o.ViewPlugin.fromClass(ze,{decorations:e=>e.decorations})),He=je.define([{tag:T.meta,color:"#404740"},{tag:T.link,textDecoration:"underline"},{tag:T.heading,textDecoration:"underline",fontWeight:"bold"},{tag:T.emphasis,fontStyle:"italic"},{tag:T.strong,fontWeight:"bold"},{tag:T.strikethrough,textDecoration:"line-through"},{tag:T.keyword,color:"#708"},{tag:[T.atom,T.bool,T.url,T.contentSeparator,T.labelName],color:"#219"},{tag:[T.literal,T.inserted],color:"#164"},{tag:[T.string,T.deleted],color:"#a11"},{tag:[T.regexp,T.escape,T.special(T.string)],color:"#e40"},{tag:T.definition(T.variableName),color:"#00f"},{tag:T.local(T.variableName),color:"#30a"},{tag:[T.typeName,T.namespace],color:"#085"},{tag:T.className,color:"#167"},{tag:[T.special(T.variableName),T.macroName],color:"#256"},{tag:T.definition(T.propertyName),color:"#00c"},{tag:T.comment,color:"#940"},{tag:T.invalid,color:"#f00"}]),$e=o.EditorView.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Je=1e4,Ke="()[]{}",Ye=r.Facet.define({combine:e=>(0,r.combineConfig)(e,{afterCursor:!0,brackets:Ke,maxScanDistance:Je,renderMatch:Qe})}),Ge=o.Decoration.mark({class:"cm-matchingBracket"}),Ze=o.Decoration.mark({class:"cm-nonmatchingBracket"});function Qe(e){let t=[],n=e.matched?Ge:Ze;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 Xe=[r.StateField.define({create:()=>o.Decoration.none,update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],i=t.state.facet(Ye);for(let r of t.state.selection.ranges){if(!r.empty)continue;let e=rt(t.state,r.head,-1,i)||r.head>0&&rt(t.state,r.head-1,1,i)||i.afterCursor&&(rt(t.state,r.head,1,i)||r.head<t.state.doc.length&&rt(t.state,r.head+1,-1,i));e&&(n=n.concat(i.renderMatch(e,t.state)))}return o.Decoration.set(n,!0)},provide:e=>o.EditorView.decorations.from(e)}),$e];function et(e={}){return[Ye.of(e),Xe]}const tt=new i.uY;function nt(e,t,n){let r=e.prop(t<0?i.uY.openedBy:i.uY.closedBy);if(r)return r;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 it(e){let t=e.type.prop(tt);return t?t(e.node):e}function rt(e,t,n,i={}){let r=i.maxScanDistance||Je,o=i.brackets||Ke,s=z(e),l=s.resolveInner(t,n);for(let a=l;a;a=a.parent){let i=nt(a.type,n,o);if(i&&a.from<a.to){let r=it(a);if(r&&(n>0?t>=r.from&&t<r.to:t>r.from&&t<=r.to))return ot(e,t,n,a,r,i,o)}}return function(e,t,n,i,r,o,s){let l=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),a=s.indexOf(l);if(a<0||a%2==0!=n>0)return null;let c={from:n<0?t-1:t,to:n>0?t+1:t},h=e.doc.iterRange(t,n>0?e.doc.length:0),u=0;for(let f=0;!h.next().done&&f<=o;){let e=h.value;n<0&&(f+=e.length);let o=t+f*n;for(let t=n>0?0:e.length-1,l=n>0?e.length:-1;t!=l;t+=n){let l=s.indexOf(e[t]);if(!(l<0||i.resolveInner(o+t,1).type!=r))if(l%2==0==n>0)u++;else{if(1==u)return{start:c,end:{from:o+t,to:o+t+1},matched:l>>1==a>>1};u--}}n>0&&(f+=e.length)}return h.done?{start:c,matched:!1}:null}(e,t,n,s,l.type,r,o)}function ot(e,t,n,i,r,o,s){let l=i.parent,a={from:r.from,to:r.to},c=0,h=null===l||void 0===l?void 0:l.cursor();if(h&&(n<0?h.childBefore(i.from):h.childAfter(i.to)))do{if(n<0?h.to<=i.from:h.from>=i.to){if(0==c&&o.indexOf(h.type.name)>-1&&h.from<h.to){let e=it(h);return{start:a,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}if(nt(h.type,n,s))c++;else if(nt(h.type,-n,s)){if(0==c){let e=it(h);return{start:a,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}c--}}}while(n<0?h.prevSibling():h.nextSibling());return{start:a,matched:!1}}const st=Object.create(null),lt=[i.Z6.none],at=[],ct=Object.create(null),ht=Object.create(null);for(let[dt,pt]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])ht[dt]=ft(st,pt);function ut(e,t){at.indexOf(e)>-1||(at.push(e),console.warn(t))}function ft(e,t){let n=[];for(let i of t.split(" ")){let t=[];for(let n of i.split(".")){let i=e[n]||T[n];i?"function"==typeof i?t.length?t=t.map(i):ut(n,`Modifier ${n} used at start of tag`):t.length?ut(n,`Tag ${n} used as modifier`):t=Array.isArray(i)?i:[i]:ut(n,`Unknown highlighting tag ${n}`)}for(let e of t)n.push(e)}if(!n.length)return 0;let r=t.replace(/ /g,"_"),o=r+" "+n.map((e=>e.id)),s=ct[o];if(s)return s.id;let l=ct[o]=i.Z6.define({id:lt.length,name:r,props:[h({[r]:n})]});return lt.push(l),l.id}o.Direction.RTL,o.Direction.LTR},203:(e,t,n)=>{n.d(t,{PH:()=>p,Qj:()=>d,Z6:()=>c,fI:()=>h,iX:()=>B,rr:()=>I,uY:()=>s});const i=1024;let r=0;class o{constructor(e,t){this.from=e,this.to=t}}class s{constructor(e={}){this.id=r++,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=c.match(e)),t=>{let n=e(t);return void 0===n?null:[this,n]}}}s.closedBy=new s({deserialize:e=>e.split(" ")}),s.openedBy=new s({deserialize:e=>e.split(" ")}),s.group=new s({deserialize:e=>e.split(" ")}),s.isolate=new s({deserialize:e=>{if(e&&"rtl"!=e&&"ltr"!=e&&"auto"!=e)throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}}),s.contextHash=new s({perNode:!0}),s.lookAhead=new s({perNode:!0}),s.mounted=new s({perNode:!0});class l{constructor(e,t,n){this.tree=e,this.overlay=t,this.parser=n}static get(e){return e&&e.props&&e.props[s.mounted.id]}}const a=Object.create(null);class c{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):a,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(null==e.name?8:0),i=new c(e.name||"",t,e.id,n);if(e.props)for(let r of e.props)if(Array.isArray(r)||(r=r(i)),r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[r[0].id]=r[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(s.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(s.group),i=-1;i<(n?n.length:0);i++){let r=t[i<0?e.name:n[i]];if(r)return r}}}}c.none=new c("",Object.create(null),0,8);class h{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let n of this.types){let i=null;for(let t of e){let e=t(n);e&&(i||(i=Object.assign({},n.props)),i[e[0].id]=e[1])}t.push(i?new c(n.name,i,n.id,n.flags):n)}return new h(t)}}const u=new WeakMap,f=new WeakMap;var d;!function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays"}(d||(d={}));class p{constructor(e,t,n,i,r){if(this.type=e,this.children=t,this.positions=n,this.length=i,this.props=null,r&&r.length){this.props=Object.create(null);for(let[e,t]of r)this.props["number"==typeof e?e:e.id]=t}}toString(){let e=l.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let n of this.children){let e=n.toString();e&&(t&&(t+=","),t+=e)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new D(this.topNode,e)}cursorAt(e,t=0,n=0){let i=u.get(this)||this.topNode,r=new D(i);return r.moveTo(e,t),u.set(this,r._tree),r}get topNode(){return new w(this,0,0,null)}resolve(e,t=0){let n=v(u.get(this)||this.topNode,e,t,!1);return u.set(this,n),n}resolveInner(e,t=0){let n=v(f.get(this)||this.topNode,e,t,!0);return f.set(this,n),n}resolveStack(e,t=0){return function(e,t,n){let i=e.resolveInner(t,n),r=null;for(let o=i instanceof w?i:i.context.parent;o;o=o.parent)if(o.index<0){let e=o.parent;(r||(r=[i])).push(e.resolve(t,n)),o=e}else{let e=l.get(o.tree);if(e&&e.overlay&&e.overlay[0].from<=t&&e.overlay[e.overlay.length-1].to>=t){let s=new w(e.tree,e.overlay[0].from+o.from,-1,o);(r||(r=[i])).push(v(s,t,n,!1))}}return r?A(r):i}(this,e,t)}iterate(e){let{enter:t,leave:n,from:i=0,to:r=this.length}=e,o=e.mode||0,s=(o&d.IncludeAnonymous)>0;for(let l=this.cursor(o|d.IncludeAnonymous);;){let e=!1;if(l.from<=r&&l.to>=i&&(!s&&l.type.isAnonymous||!1!==t(l))){if(l.firstChild())continue;e=!0}for(;e&&n&&(s||!l.type.isAnonymous)&&n(l),!l.nextSibling();){if(!l.parent())return;e=!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:T(c.none,this.children,this.positions,0,this.children.length,0,this.length,((e,t,n)=>new p(this.type,e,t,n,this.propValues)),e.makeTree||((e,t,n)=>new p(c.none,e,t,n)))}static build(e){return function(e){var t;let{buffer:n,nodeSet:r,maxBufferLength:o=i,reused:l=[],minRepeatType:a=r.types.length}=e,c=Array.isArray(n)?new m(n,n.length):n,h=r.types,u=0,f=0;function d(e,t,n,i,s,p){let{id:m,start:S,end:C,size:A}=c,E=f,D=u;for(;A<0;){if(c.next(),-1==A){let t=l[m];return n.push(t),void i.push(S-e)}if(-3==A)return void(u=m);if(-4==A)return void(f=m);throw new RangeError(`Unrecognized record size: ${A}`)}let M,O,P=h[m],I=S-e;if(C-S<=o&&(O=x(c.pos-t,s))){let t=new Uint16Array(O.size-O.skip),n=c.pos-O.size,i=t.length;for(;c.pos>n;)i=k(O.start,t,i);M=new g(t,C-O.start,r),I=O.start-e}else{let e=c.pos-A;c.next();let t=[],n=[],i=m>=a?m:-1,r=0,s=C;for(;c.pos>e;)i>=0&&c.id==i&&c.size>=0?(c.end<=s-o&&(b(t,n,S,r,c.end,s,i,E,D),r=t.length,s=c.end),c.next()):p>2500?y(S,e,t,n):d(S,e,t,n,i,p+1);if(i>=0&&r>0&&r<t.length&&b(t,n,S,r,S,s,i,E,D),t.reverse(),n.reverse(),i>-1&&r>0){let e=v(P,D);M=T(P,t,n,0,t.length,0,C-S,e,e)}else M=w(P,t,n,C-S,E-C,D)}n.push(M),i.push(I)}function y(e,t,n,i){let s=[],l=0,a=-1;for(;c.pos>t;){let{id:e,start:t,end:n,size:i}=c;if(i>4)c.next();else{if(a>-1&&t<a)break;a<0&&(a=n-o),s.push(e,t,n),l++,c.next()}}if(l){let t=new Uint16Array(4*l),o=s[s.length-2];for(let e=s.length-3,n=0;e>=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-o,t[n++]=s[e+2]-o,t[n++]=n;n.push(new g(t,s[2]-o,r)),i.push(o-e)}}function v(e,t){return(n,i,r)=>{let o,l,a=0,c=n.length-1;if(c>=0&&(o=n[c])instanceof p){if(!c&&o.type==e&&o.length==r)return o;(l=o.prop(s.lookAhead))&&(a=i[c]+o.length+l)}return w(e,n,i,r,a,t)}}function b(e,t,n,i,o,s,l,a,c){let h=[],u=[];for(;e.length>i;)h.push(e.pop()),u.push(t.pop()+n-o);e.push(w(r.types[l],h,u,s-o,a-s,c)),t.push(o-n)}function w(e,t,n,i,r,o,l){if(o){let e=[s.contextHash,o];l=l?[e].concat(l):[e]}if(r>25){let e=[s.lookAhead,r];l=l?[e].concat(l):[e]}return new p(e,t,n,i,l)}function x(e,t){let n=c.fork(),i=0,r=0,s=0,l=n.end-o,h={size:0,start:0,skip:0};e:for(let o=n.pos-e;n.pos>o;){let e=n.size;if(n.id==t&&e>=0){h.size=i,h.start=r,h.skip=s,s+=4,i+=4,n.next();continue}let c=n.pos-e;if(e<0||c<o||n.start<l)break;let u=n.id>=a?4:0,f=n.start;for(n.next();n.pos>c;){if(n.size<0){if(-3!=n.size)break e;u+=4}else n.id>=a&&(u+=4);n.next()}r=f,i+=e,s+=u}return(t<0||i==e)&&(h.size=i,h.start=r,h.skip=s),h.size>4?h:void 0}function k(e,t,n){let{id:i,start:r,end:o,size:s}=c;if(c.next(),s>=0&&i<a){let l=n;if(s>4){let i=c.pos-(s-4);for(;c.pos>i;)n=k(e,t,n)}t[--n]=l,t[--n]=o-e,t[--n]=r-e,t[--n]=i}else-3==s?u=i:-4==s&&(f=i);return n}let S=[],C=[];for(;c.pos>0;)d(e.start||0,e.bufferStart||0,S,C,-1,0);let A=null!==(t=e.length)&&void 0!==t?t:S.length?C[0]+S[0].length:0;return new p(h[e.topID],S.reverse(),C.reverse(),A)}(e)}}p.empty=new p(c.none,[],[],0);class m{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 m(this.buffer,this.index)}}class g{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return c.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],n=this.buffer[e+3],i=this.set.types[t],r=i.name;if(/\W/.test(r)&&!i.isError&&(r=JSON.stringify(r)),n==(e+=4))return r;let o=[];for(;e<n;)o.push(this.childString(e)),e=this.buffer[e+3];return r+"("+o.join(",")+")"}findChild(e,t,n,i,r){let{buffer:o}=this,s=-1;for(let l=e;l!=t&&!(y(r,i,o[l+1],o[l+2])&&(s=l,n>0));l=o[l+3]);return s}slice(e,t,n){let i=this.buffer,r=new Uint16Array(t-e),o=0;for(let s=e,l=0;s<t;){r[l++]=i[s++],r[l++]=i[s++]-n;let t=r[l++]=i[s++]-n;r[l++]=i[s++]-e,o=Math.max(o,t)}return new g(r,o,this.set)}}function y(e,t,n,i){switch(e){case-2:return n<t;case-1:return i>=t&&n<t;case 0:return n<t&&i>t;case 1:return n<=t&&i>t;case 2:return i>t;case 4:return!0}}function v(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.to<t);){let t=!i&&e instanceof w&&e.index<0?null:e.parent;if(!t)return e;e=t}let o=i?0:d.IgnoreOverlays;if(i)for(let s=e,l=s.parent;l;s=l,l=s.parent)s instanceof w&&s.index<0&&(null===(r=l.enter(t,n,o))||void 0===r?void 0:r.from)!=s.from&&(e=l);for(;;){let i=e.enter(t,n,o);if(!i)return e;e=i}}class b{cursor(e=0){return new D(this,e)}getChild(e,t=null,n=null){let i=x(this,e,t,n);return i.length?i[0]:null}getChildren(e,t=null,n=null){return x(this,e,t,n)}resolve(e,t=0){return v(this,e,t,!1)}resolveInner(e,t=0){return v(this,e,t,!0)}matchContext(e){return k(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}}class w extends b{constructor(e,t,n,i){super(),this._tree=e,this.from=t,this.index=n,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,n,i,r=0){for(let o=this;;){for(let{children:s,positions:a}=o._tree,c=t>0?s.length:-1;e!=c;e+=t){let c=s[e],h=a[e]+o.from;if(y(i,n,h,h+c.length))if(c instanceof g){if(r&d.ExcludeBuffers)continue;let s=c.findChild(0,c.buffer.length,t,n-h,i);if(s>-1)return new C(new S(o,c,e,h),null,s)}else if(r&d.IncludeAnonymous||!c.type.isAnonymous||M(c)){let s;if(!(r&d.IgnoreMounts)&&(s=l.get(c))&&!s.overlay)return new w(s.tree,h,e,o);let a=new w(c,h,e,o);return r&d.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(t<0?c.children.length-1:0,t,n,i)}}if(r&d.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&d.IgnoreOverlays)&&(i=l.get(this._tree))&&i.overlay){let n=e-this.from;for(let{from:e,to:r}of i.overlay)if((t>0?e<=n:e<n)&&(t<0?r>=n:r>n))return new w(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}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function x(e,t,n,i){let r=e.cursor(),o=[];if(!r.firstChild())return o;if(null!=n)for(let s=!1;!s;)if(s=r.type.is(n),!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 k(e,t,n=t.length-1){for(let i=e;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 S{constructor(e,t,n,i){this.parent=e,this.buffer=t,this.index=n,this.start=i}}class C extends b{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){super(),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 C(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&d.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 C(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 C(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 C(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}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 p(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function A(e){if(!e.length)return null;let t=0,n=e[0];for(let o=1;o<e.length;o++){let i=e[o];(i.from>n.from||i.to<n.to)&&(n=i,t=o)}let i=n instanceof w&&n.index<0?null:n.parent,r=e.slice();return i?r[t]=i:r.splice(t,1),new E(r,n)}class E{constructor(e,t){this.heads=e,this.node=t}get next(){return A(this.heads)}}class D{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 w)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 w?(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.b