@bhsd/codemirror-mediawiki 3.6.5 → 3.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/codemirror.d.ts +1 -0
- package/dist/codemirror.js +3 -2
- package/dist/color.js +1 -1
- package/dist/fold.d.ts +1 -1
- package/dist/main.min.js +2 -2
- package/dist/mediawiki.js +2 -1
- package/dist/mw.min.js +25 -25
- package/dist/mwConfig.js +2 -10
- package/dist/static.js +1 -1
- package/dist/statusBar.js +1 -1
- package/dist/wiki.min.js +22 -22
- package/i18n/en.json +1 -1
- package/i18n/zh-hans.json +1 -1
- package/i18n/zh-hant.json +1 -1
- package/package.json +4 -4
package/dist/main.min.js
CHANGED
|
@@ -24,7 +24,7 @@ var Dy=Object.create;var Fo=Object.defineProperty;var Yy=Object.getOwnPropertyDe
|
|
|
24
24
|
constructor(\${params}) {
|
|
25
25
|
\${}
|
|
26
26
|
}
|
|
27
|
-
}`,{label:"class",detail:"definition",type:"keyword"}),ye('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),ye('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],MP=sm.concat([ye("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),ye("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),ye("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),om=new fp,am=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function Sn(t){return(e,i)=>{let r=e.node.getChild("VariableDefinition");return r&&i(r,t),!0}}var EP=["FunctionDeclaration"],qP={FunctionDeclaration:Sn("function"),ClassDeclaration:Sn("class"),ClassExpression:()=>!0,EnumDeclaration:Sn("constant"),TypeAliasDeclaration:Sn("type"),NamespaceDeclaration:Sn("namespace"),VariableDefinition(t,e){t.matchContext(EP)||e(t,"variable")},TypeDefinition(t,e){e(t,"type")},__proto__:null};function lm(t,e){let i=om.get(e);if(i)return i;let r=[],n=!0;function s(o,a){let l=t.sliceString(o.from,o.to);r.push({label:l,type:a})}return e.cursor(le.IncludeAnonymous).iterate(o=>{if(n)n=!1;else if(o.name){let a=qP[o.name];if(a&&a(o,s)||am.has(o.name))return!1}else if(o.to-o.from>8192){for(let a of lm(t,o.node))r.push(a);return!1}}),om.set(e,r),r}var co=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,bh=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function DP(t){let e=I(t.state).resolveInner(t.pos,-1);if(bh.indexOf(e.name)>-1)return null;let i=e.name=="VariableName"||e.to-e.from<20&&co.test(t.state.sliceDoc(e.from,e.to));if(!i&&!t.explicit)return null;let r=[];for(let n=e;n;n=n.parent)am.has(n.name)&&(r=r.concat(lm(t.state.doc,n)));return{options:r,from:i?e.from:t.pos,validFor:co}}function vh(t,e,i){var r;let n=[];for(;;){let s=e.firstChild,o;if((s==null?void 0:s.name)=="VariableName")return n.push(t(s)),{path:n.reverse(),name:i};if((s==null?void 0:s.name)=="MemberExpression"&&((r=o=s.lastChild)===null||r===void 0?void 0:r.name)=="PropertyName")n.push(t(o)),e=s;else return null}}function YP(t){let e=r=>t.state.doc.sliceString(r.from,r.to),i=I(t.state).resolveInner(t.pos,-1);return i.name=="PropertyName"?vh(e,i.parent,e(i)):(i.name=="."||i.name=="?.")&&i.parent.name=="MemberExpression"?vh(e,i.parent,""):bh.indexOf(i.name)>-1?null:i.name=="VariableName"||i.to-i.from<20&&co.test(e(i))?{path:[],name:e(i)}:i.name=="MemberExpression"?vh(e,i,""):t.explicit?{path:[],name:""}:null}function VP(t,e){let i=[],r=new Set;for(let n=0;;n++){for(let o of(Object.getOwnPropertyNames||Object.keys)(t)){if(!/^[a-zA-Z_$\xaa-\uffdc][\w$\xaa-\uffdc]*$/.test(o)||r.has(o))continue;r.add(o);let a;try{a=t[o]}catch{continue}i.push({label:o,type:typeof a=="function"?/^[A-Z]/.test(o)?"class":e?"function":"method":e?"variable":"property",boost:-n})}let s=Object.getPrototypeOf(t);if(!s)return i;t=s}}function _P(t){let e=new Map;return i=>{let r=YP(i);if(!r)return null;let n=t;for(let o of r.path)if(n=n[o],!n)return null;let s=e.get(n);return s||e.set(n,s=VP(n,!r.path.length)),{from:i.pos-r.name.length,options:s,validFor:co}}}var _e=hn.define({name:"javascript",parser:WP.configure({props:[dr.add({IfStatement:pr({except:/^\s*({|else\b)/}),TryStatement:pr({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:ox,SwitchBody:t=>{let e=t.textAfter,i=/^\s*\}/.test(e),r=/^\s*(case|default)\b/.test(e);return t.baseIndent+(i?0:r?1:2)*t.unit},Block:sx({closing:"}"}),ArrowFunction:t=>t.baseIndent+t.unit,"TemplateString BlockComment":()=>null,"Statement Property":pr({except:/^\s*{/}),JSXElement(t){let e=/^\s*<\//.test(t.textAfter);return t.lineIndent(t.node.from)+(e?0:t.unit)},JSXEscape(t){let e=/\s*\}/.test(t.textAfter);return t.lineIndent(t.node.from)+(e?0:t.unit)},"JSXOpenTag JSXSelfClosingTag"(t){return t.column(t.node.from)+t.unit}}),un.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":Dl,BlockComment(t){return{from:t.from+2,to:t.to-2}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),hm={test:t=>/^JSX/.test(t.name),facet:Rl({commentTokens:{block:{open:"{/*",close:"*/}"}}})},cm=_e.configure({dialect:"ts"},"typescript"),fm=_e.configure({dialect:"jsx",props:[Xl.add(t=>t.isTop?[hm]:void 0)]}),um=_e.configure({dialect:"jsx ts",props:[Xl.add(t=>t.isTop?[hm]:void 0)]},"typescript"),dm=t=>({label:t,type:"keyword"}),pm="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(dm),BP=pm.concat(["declare","implements","private","protected","public"].map(dm));function fo(t={}){let e=t.jsx?t.typescript?um:fm:t.typescript?cm:_e,i=t.typescript?MP.concat(BP):sm.concat(pm);return new Et(e,[_e.data.of({autocomplete:Bx(bh,iO(i))}),_e.data.of({autocomplete:DP}),t.jsx?zP:[]])}function LP(t){for(;;){if(t.name=="JSXOpenTag"||t.name=="JSXSelfClosingTag"||t.name=="JSXFragmentTag")return t;if(t.name=="JSXEscape"||!t.parent)return null;t=t.parent}}function Om(t,e,i=t.length){for(let r=e==null?void 0:e.firstChild;r;r=r.nextSibling)if(r.name=="JSXIdentifier"||r.name=="JSXBuiltin"||r.name=="JSXNamespacedName"||r.name=="JSXMemberExpression")return t.sliceString(r.from,Math.min(r.to,i));return""}var jP=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),zP=x.inputHandler.of((t,e,i,r,n)=>{if((jP?t.composing:t.compositionStarted)||t.state.readOnly||e!=i||r!=">"&&r!="/"||!_e.isActiveAt(t.state,e,-1))return!1;let s=n(),{state:o}=s,a=o.changeByRange(l=>{var h;let{head:c}=l,f=I(o).resolveInner(c-1,-1),u;if(f.name=="JSXStartTag"&&(f=f.parent),!(o.doc.sliceString(c-1,c)!=r||f.name=="JSXAttributeValue"&&f.to>c)){if(r==">"&&f.name=="JSXFragmentTag")return{range:l,changes:{from:c,insert:"</>"}};if(r=="/"&&f.name=="JSXStartCloseTag"){let d=f.parent,p=d.parent;if(p&&d.from==c-2&&((u=Om(o.doc,p.firstChild,c))||((h=p.firstChild)===null||h===void 0?void 0:h.name)=="JSXFragmentTag")){let O=`${u}>`;return{range:k.cursor(c+O.length,-1),changes:{from:c,insert:O}}}}else if(r==">"){let d=LP(f);if(d&&d.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(o.doc.sliceString(c,c+2))&&(u=Om(o.doc,d,c)))return{range:l,changes:{from:c,insert:`</${u}>`}}}}return{range:l}});return a.changes.empty?!1:(t.dispatch([s,o.update(a,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),kn=["_blank","_self","_top","_parent"],yh=["ascii","utf-8","utf-16","latin1","latin1"],Sh=["get","post","put","delete"],kh=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],Ie=["true","false"],E={},NP={a:{attrs:{href:null,ping:null,type:null,media:null,target:kn,hreflang:null}},abbr:E,address:E,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:["default","rect","circle","poly"]}},article:E,aside:E,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["autoplay"],loop:["loop"],controls:["controls"]}},b:E,base:{attrs:{href:null,target:kn}},bdi:E,bdo:E,blockquote:{attrs:{cite:null}},body:E,br:E,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["autofocus"],disabled:["autofocus"],formenctype:kh,formmethod:Sh,formnovalidate:["novalidate"],formtarget:kn,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:E,center:E,cite:E,code:E,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["disabled"],checked:["checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["disabled"],multiple:["multiple"]}},datalist:{attrs:{data:null}},dd:E,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["open"]}},dfn:E,div:E,dl:E,dt:E,em:E,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["disabled"],form:null,name:null}},figcaption:E,figure:E,footer:E,form:{attrs:{action:null,name:null,"accept-charset":yh,autocomplete:["on","off"],enctype:kh,method:Sh,novalidate:["novalidate"],target:kn}},h1:E,h2:E,h3:E,h4:E,h5:E,h6:E,head:{children:["title","base","link","style","meta","script","noscript","command"]},header:E,hgroup:E,hr:E,html:{attrs:{manifest:null}},i:E,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["autofocus"],checked:["checked"],disabled:["disabled"],formenctype:kh,formmethod:Sh,formnovalidate:["novalidate"],formtarget:kn,multiple:["multiple"],readonly:["readonly"],required:["required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:E,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["autofocus"],disabled:["disabled"],keytype:["RSA"]}},label:{attrs:{for:null,form:null}},legend:E,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:null,media:null,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:E,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:yh,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:E,noscript:E,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["typemustmatch"]}},ol:{attrs:{reversed:["reversed"],start:null,type:["1","a","A","i","I"]},children:["li","script","template","ul","ol"]},optgroup:{attrs:{disabled:["disabled"],label:null}},option:{attrs:{disabled:["disabled"],label:null,selected:["selected"],value:null}},output:{attrs:{for:null,form:null,name:null}},p:E,param:{attrs:{name:null,value:null}},pre:E,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:E,rt:E,ruby:E,samp:E,script:{attrs:{type:["text/javascript"],src:null,async:["async"],defer:["defer"],charset:yh}},section:E,select:{attrs:{form:null,name:null,size:null,autofocus:["autofocus"],disabled:["disabled"],multiple:["multiple"]}},slot:{attrs:{name:null}},small:E,source:{attrs:{src:null,type:null,media:null}},span:E,strong:E,style:{attrs:{type:["text/css"],media:null,scoped:null}},sub:E,summary:E,sup:E,table:E,tbody:E,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:E,textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["autofocus"],disabled:["disabled"],readonly:["readonly"],required:["required"],wrap:["soft","hard"]}},tfoot:E,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:E,time:{attrs:{datetime:null}},title:E,tr:E,track:{attrs:{src:null,label:null,default:null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:null}},ul:{children:["li","script","template","ul","ol"]},var:E,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["autoplay"],mediagroup:["movie"],muted:["muted"],controls:["controls"]}},wbr:E},mm={accesskey:null,class:null,contenteditable:Ie,contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["ar","bn","de","en-GB","en-US","es","fr","hi","id","ja","pa","pt","ru","tr","zh"],spellcheck:Ie,autocorrect:Ie,autocapitalize:Ie,style:null,tabindex:null,title:null,translate:["yes","no"],rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"],role:"alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer".split(" "),"aria-activedescendant":null,"aria-atomic":Ie,"aria-autocomplete":["inline","list","both","none"],"aria-busy":Ie,"aria-checked":["true","false","mixed","undefined"],"aria-controls":null,"aria-describedby":null,"aria-disabled":Ie,"aria-dropeffect":null,"aria-expanded":["true","false","undefined"],"aria-flowto":null,"aria-grabbed":["true","false","undefined"],"aria-haspopup":Ie,"aria-hidden":Ie,"aria-invalid":["true","false","grammar","spelling"],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":["off","polite","assertive"],"aria-multiline":Ie,"aria-multiselectable":Ie,"aria-owns":null,"aria-posinset":null,"aria-pressed":["true","false","mixed","undefined"],"aria-readonly":Ie,"aria-relevant":null,"aria-required":Ie,"aria-selected":["true","false","undefined"],"aria-setsize":null,"aria-sort":["ascending","descending","none","other"],"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null},gm="beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload".split(" ").map(t=>"on"+t);for(let t of gm)mm[t]=null;var wn=class{constructor(t,e){this.tags={...NP,...t},this.globalAttrs={...mm,...e},this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}};wn.default=new wn;function mr(t,e,i=t.length){if(!e)return"";let r=e.firstChild,n=r&&r.getChild("TagName");return n?t.sliceString(n.from,Math.min(n.to,i)):""}function gr(t,e=!1){for(;t;t=t.parent)if(t.name=="Element")if(e)e=!1;else return t;return null}function bm(t,e,i){let r=i.tags[mr(t,gr(e))];return(r==null?void 0:r.children)||i.allTags}function wh(t,e){let i=[];for(let r=gr(e);r&&!r.type.isTop;r=gr(r.parent)){let n=mr(t,r);if(n&&r.lastChild.name=="CloseTag")break;n&&i.indexOf(n)<0&&(e.name=="EndTag"||e.from>=r.firstChild.to)&&i.push(n)}return i}var vm=/^[:\-\.\w\u00b7-\uffff]*$/;function ym(t,e,i,r,n){let s=/\s*>/.test(t.sliceDoc(n,n+5))?"":">",o=gr(i,i.name=="StartTag"||i.name=="TagName");return{from:r,to:n,options:bm(t.doc,o,e).map(a=>({label:a,type:"type"})).concat(wh(t.doc,i).map((a,l)=>({label:"/"+a,apply:"/"+a+s,type:"type",boost:99-l}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function Sm(t,e,i,r){let n=/\s*>/.test(t.sliceDoc(r,r+5))?"":">";return{from:i,to:r,options:wh(t.doc,e).map((s,o)=>({label:s,apply:s+n,type:"type",boost:99-o})),validFor:vm}}function IP(t,e,i,r){let n=[],s=0;for(let o of bm(t.doc,i,e))n.push({label:"<"+o,type:"type"});for(let o of wh(t.doc,i))n.push({label:"</"+o+">",type:"type",boost:99-s++});return{from:r,to:r,options:n,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function GP(t,e,i,r,n){let s=gr(i),o=s?e.tags[mr(t.doc,s)]:null,a=o&&o.attrs?Object.keys(o.attrs):[],l=o&&o.globalAttrs===!1?a:a.length?a.concat(e.globalAttrNames):e.globalAttrNames;return{from:r,to:n,options:l.map(h=>({label:h,type:"property"})),validFor:vm}}function UP(t,e,i,r,n){var s;let o=(s=i.parent)===null||s===void 0?void 0:s.getChild("AttributeName"),a=[],l;if(o){let h=t.sliceDoc(o.from,o.to),c=e.globalAttrs[h];if(!c){let f=gr(i),u=f?e.tags[mr(t.doc,f)]:null;c=(u==null?void 0:u.attrs)&&u.attrs[h]}if(c){let f=t.sliceDoc(r,n).toLowerCase(),u='"',d='"';/^['"]/.test(f)?(l=f[0]=='"'?/^[^"]*$/:/^[^']*$/,u="",d=t.sliceDoc(n,n+1)==f[0]?"":f[0],f=f.slice(1),r++):l=/^[^\s<>='"]*$/;for(let p of c)a.push({label:p,apply:u+p+d,type:"constant"})}}return{from:r,to:n,options:a,validFor:l}}function km(t,e){let{state:i,pos:r}=e,n=I(i).resolveInner(r,-1),s=n.resolve(r);for(let o=r,a;s==n&&(a=n.childBefore(o));){let l=a.lastChild;if(!l||!l.type.isError||l.from<l.to)break;s=n=a,o=l.from}return n.name=="TagName"?n.parent&&/CloseTag$/.test(n.parent.name)?Sm(i,n,n.from,r):ym(i,t,n,n.from,r):n.name=="StartTag"||n.name=="IncompleteTag"?ym(i,t,n,r,r):n.name=="StartCloseTag"||n.name=="IncompleteCloseTag"?Sm(i,n,r,r):n.name=="OpenTag"||n.name=="SelfClosingTag"||n.name=="AttributeName"?GP(i,t,n,n.name=="AttributeName"?n.from:r,r):n.name=="Is"||n.name=="AttributeValue"||n.name=="UnquotedAttributeValue"?UP(i,t,n,n.name=="Is"?r:n.from,r):e.explicit&&(s.name=="Element"||s.name=="Text"||s.name=="Document")?IP(i,t,n,r):null}function FP(t){return km(wn.default,t)}function wm(t){let{extraTags:e,extraGlobalAttributes:i}=t,r=i||e?new wn(e,i):wn.default;return n=>km(r,n)}var HP=_e.parser.configure({top:"SingleExpression"}),xm=[{tag:"script",attrs:t=>t.type=="text/typescript"||t.lang=="ts",parser:cm.parser},{tag:"script",attrs:t=>t.type=="text/babel"||t.type=="text/jsx",parser:fm.parser},{tag:"script",attrs:t=>t.type=="text/typescript-jsx",parser:um.parser},{tag:"script",attrs(t){return/^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(t.type)},parser:HP},{tag:"script",attrs(t){return!t.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(t.type)},parser:_e.parser},{tag:"style",attrs(t){return(!t.lang||t.lang=="css")&&(!t.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(t.type))},parser:Gt.parser}],Qm=[{name:"style",parser:Gt.parser.configure({top:"Styles"})}].concat(gm.map(t=>({name:t,parser:_e.parser}))),$m=hn.define({name:"html",parser:M$.configure({props:[dr.add({Element(t){let e=/^(\s*)(<\/)?/.exec(t.textAfter);return t.node.to<=t.pos+e[0].length?t.continue():t.lineIndent(t.node.from)+(e[2]?0:t.unit)},"OpenTag CloseTag SelfClosingTag"(t){return t.column(t.node.from)+t.unit},Document(t){if(t.pos+/\s*/.exec(t.textAfter)[0].length<t.node.to)return t.continue();let e=null,i;for(let r=t.node;;){let n=r.lastChild;if(!n||n.name!="Element"||n.to!=r.to)break;e=r=n}return e&&!((i=e.lastChild)&&(i.name=="CloseTag"||i.name=="SelfClosingTag"))?t.lineIndent(e.from)+t.unit:null}}),un.add({Element(t){let e=t.firstChild,i=t.lastChild;return!e||e.name!="OpenTag"?null:{from:e.to,to:i.name=="CloseTag"?i.from:t.to}}}),Bp.add({"OpenTag CloseTag":t=>t.getChild("TagName")})]}),languageData:{commentTokens:{block:{open:"<!--",close:"-->"}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:"-_"}}),di=$m.configure({wrap:uh(xm,Qm)});function KP(t={}){let e="",i;t.matchClosingTags===!1&&(e="noMatch"),t.selfClosingTags===!0&&(e=(e?e+" ":"")+"selfClosing"),(t.nestedLanguages&&t.nestedLanguages.length||t.nestedAttributes&&t.nestedAttributes.length)&&(i=uh((t.nestedLanguages||[]).concat(xm),(t.nestedAttributes||[]).concat(Qm)));let r=i?$m.configure({wrap:i,dialect:e}):e?di.configure({dialect:e}):di;return new Et(r,[di.data.of({autocomplete:wm(t)}),t.autoCloseTags!==!1?xh:[],fo().support,hP().support])}var Pm=new Set("area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" ")),xh=x.inputHandler.of((t,e,i,r,n)=>{if(t.composing||t.state.readOnly||e!=i||r!=">"&&r!="/"||!di.isActiveAt(t.state,e,-1))return!1;let s=n(),{state:o}=s,a=o.changeByRange(l=>{var h,c,f;let u=o.doc.sliceString(l.from-1,l.to)==r,{head:d}=l,p=I(o).resolveInner(d,-1),O;if(u&&r==">"&&p.name=="EndTag"){let g=p.parent;if(((c=(h=g.parent)===null||h===void 0?void 0:h.lastChild)===null||c===void 0?void 0:c.name)!="CloseTag"&&(O=mr(o.doc,g.parent,d))&&!Pm.has(O)){let b=d+(o.doc.sliceString(d,d+1)===">"?1:0),y=`</${O}>`;return{range:l,changes:{from:d,to:b,insert:y}}}}else if(u&&r=="/"&&p.name=="IncompleteCloseTag"){let g=p.parent;if(p.from==d-2&&((f=g.lastChild)===null||f===void 0?void 0:f.name)!="CloseTag"&&(O=mr(o.doc,g,d))&&!Pm.has(O)){let b=d+(o.doc.sliceString(d,d+1)===">"?1:0),y=`${O}>`;return{range:k.cursor(d+y.length,-1),changes:{from:d,to:b,insert:y}}}}return{range:l}});return a.changes.empty?!1:(t.dispatch([s,o.update(a,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),JP=["zh-hans","zh-hant"],eT="https://testingcf.jsdelivr.net",Tm=typeof document=="object"?document.createElement("textarea"):void 0,tT=t=>(Tm.innerHTML=t,Tm.value),Qh=new Map,br=(t,e,i)=>{if(Qh.has(t))return Qh.get(t);const r=new Promise(n=>{const s=/^https?:\/\//iu.test(t)?t:`${eT}/${t}`;let o=globalThis;for(const a of e.split("."))o=o==null?void 0:o[a];if(o)n();else if(i&&typeof define=="function"&&"amd"in define){const a=globalThis.require;a.config({paths:{[e]:s}}),a([e],l=>{Object.assign(globalThis,{[e]:l}),n()})}else{const a=document.createElement("script");a.src=s,a.onload=()=>{n()},document.head.append(a)}});return Qh.set(t,r),r},iT=t=>JSON.parse(String(localStorage.getItem(t))),Cm=(t,e)=>{localStorage.setItem(t,JSON.stringify(e))},rT=async(t,e,i,r,n,s=(o=>(o=iT(n))!=null?o:{})())=>{const{version:a,lang:l}=s,h=Array.isArray(i)?i:[i];if(a===e&&h.includes(l))return s;for(const c of h){const f=c.toLowerCase();if(r.includes(f))try{const u=await fetch(`${t}/${f}.json`);return Object.assign(s,await u.json(),{version:e,lang:c}),Cm(n,s),s}catch{}}throw new Error(`Failed to fetch the localization for ${h[0]}.`)},Zm=!1,Am=!1,Rm=async(t,e,i)=>{const r="extensions/dist";let n=i||`npm/wikiparser-node/${r}/base.min.js`;if(n.endsWith(".js")||(n=`${n}${n.endsWith("/")?"":"/"}${r}/base.js`),await br(n,"wikiparse"),await br(`${wikiparse.CDN}/${r}/lsp.js`,"wikiparse.LanguageService"),!Zm&&typeof t=="function"){Zm=!0;try{wikiparse.setConfig(await t())}catch{}}if(!Am&&e){Am=!0;const s="wikiparse-i18n",{version:o}=wikiparse;try{wikiparse.setI18N(await rT(`${wikiparse.CDN}/i18n`,o,e,JP,s))}catch{Cm(s,{version:o,lang:"en"})}}},$h=new WeakMap,Ut=(t,e,i,r)=>{if(Rm(i,r),typeof wikiparse!="object"||!wikiparse.LanguageService||$h.has(t))return $h.get(t);const n=new wikiparse.LanguageService(e);return $h.set(t,n),n},Xm=new Map([["aliceblue","#f0f8ff"],["antiquewhite","#faebd7"],["aqua","#00ffff"],["aquamarine","#7fffd4"],["azure","#f0ffff"],["beige","#f5f5dc"],["bisque","#ffe4c4"],["black","#000000"],["blanchedalmond","#ffebcd"],["blue","#0000ff"],["blueviolet","#8a2be2"],["brown","#a52a2a"],["burlywood","#deb887"],["cadetblue","#5f9ea0"],["chartreuse","#7fff00"],["chocolate","#d2691e"],["coral","#ff7f50"],["cornflowerblue","#6495ed"],["cornsilk","#fff8dc"],["crimson","#dc143c"],["cyan","#00ffff"],["darkblue","#00008b"],["darkcyan","#008b8b"],["darkgoldenrod","#b8860b"],["darkgray","#a9a9a9"],["darkgreen","#006400"],["darkgrey","#a9a9a9"],["darkkhaki","#bdb76b"],["darkmagenta","#8b008b"],["darkolivegreen","#556b2f"],["darkorange","#ff8c00"],["darkorchid","#9932cc"],["darkred","#8b0000"],["darksalmon","#e9967a"],["darkseagreen","#8fbc8f"],["darkslateblue","#483d8b"],["darkslategray","#2f4f4f"],["darkslategrey","#2f4f4f"],["darkturquoise","#00ced1"],["darkviolet","#9400d3"],["deeppink","#ff1493"],["deepskyblue","#00bfff"],["dimgray","#696969"],["dimgrey","#696969"],["dodgerblue","#1e90ff"],["firebrick","#b22222"],["floralwhite","#fffaf0"],["forestgreen","#228b22"],["fuchsia","#ff00ff"],["gainsboro","#dcdcdc"],["ghostwhite","#f8f8ff"],["goldenrod","#daa520"],["gold","#ffd700"],["gray","#808080"],["green","#008000"],["greenyellow","#adff2f"],["grey","#808080"],["honeydew","#f0fff0"],["hotpink","#ff69b4"],["indianred","#cd5c5c"],["indigo","#4b0082"],["ivory","#fffff0"],["khaki","#f0e68c"],["lavenderblush","#fff0f5"],["lavender","#e6e6fa"],["lawngreen","#7cfc00"],["lemonchiffon","#fffacd"],["lightblue","#add8e6"],["lightcoral","#f08080"],["lightcyan","#e0ffff"],["lightgoldenrodyellow","#fafad2"],["lightgray","#d3d3d3"],["lightgreen","#90ee90"],["lightgrey","#d3d3d3"],["lightpink","#ffb6c1"],["lightsalmon","#ffa07a"],["lightseagreen","#20b2aa"],["lightskyblue","#87cefa"],["lightslategray","#778899"],["lightslategrey","#778899"],["lightsteelblue","#b0c4de"],["lightyellow","#ffffe0"],["lime","#00ff00"],["limegreen","#32cd32"],["linen","#faf0e6"],["magenta","#ff00ff"],["maroon","#800000"],["mediumaquamarine","#66cdaa"],["mediumblue","#0000cd"],["mediumorchid","#ba55d3"],["mediumpurple","#9370db"],["mediumseagreen","#3cb371"],["mediumslateblue","#7b68ee"],["mediumspringgreen","#00fa9a"],["mediumturquoise","#48d1cc"],["mediumvioletred","#c71585"],["midnightblue","#191970"],["mintcream","#f5fffa"],["mistyrose","#ffe4e1"],["moccasin","#ffe4b5"],["navajowhite","#ffdead"],["navy","#000080"],["oldlace","#fdf5e6"],["olive","#808000"],["olivedrab","#6b8e23"],["orange","#ffa500"],["orangered","#ff4500"],["orchid","#da70d6"],["palegoldenrod","#eee8aa"],["palegreen","#98fb98"],["paleturquoise","#afeeee"],["palevioletred","#db7093"],["papayawhip","#ffefd5"],["peachpuff","#ffdab9"],["peru","#cd853f"],["pink","#ffc0cb"],["plum","#dda0dd"],["powderblue","#b0e0e6"],["purple","#800080"],["rebeccapurple","#663399"],["red","#ff0000"],["rosybrown","#bc8f8f"],["royalblue","#4169e1"],["saddlebrown","#8b4513"],["salmon","#fa8072"],["sandybrown","#f4a460"],["seagreen","#2e8b57"],["seashell","#fff5ee"],["sienna","#a0522d"],["silver","#c0c0c0"],["skyblue","#87ceeb"],["slateblue","#6a5acd"],["slategray","#708090"],["slategrey","#708090"],["snow","#fffafa"],["springgreen","#00ff7f"],["steelblue","#4682b4"],["tan","#d2b48c"],["teal","#008080"],["thistle","#d8bfd8"],["tomato","#ff6347"],["turquoise","#40e0d0"],["violet","#ee82ee"],["wheat","#f5deb3"],["white","#ffffff"],["whitesmoke","#f5f5f5"],["yellow","#ffff00"],["yellowgreen","#9acd32"]]),nT=function(t,e){var i={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(i[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(t);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(i[r[n]]=t[r[n]]);return i},Wm=new WeakMap,wt=(function(t){return t.rgb="RGB",t.hex="HEX",t.named="NAMED",t.hsl="HSL",t})(wt||(wt={})),sT=/rgba?\(\s*(\d{1,3}%?)\s*[,\s]\s*(\d{1,3}%?)\s*[,\s]\s*(\d{1,3}%?)\s*([,/]\s*0?\.?\d+%?)?\s*\)/,oT=/hsla?\(\s*(\d{1,3})(?:deg)?\s*[,\s]\s*(\d{1,3})%?\s*[,\s]\s*(\d{1,3})%?\s*([,/]\s*0?\.?\d+%?)?\s*\)/,aT=/(^|\b)(#[0-9a-f]{3,9})(\b|$)/i;function Mm(t,e,i,r,n,s){var o;switch(r){case"AttributeValue":{const a=t.resolveInner(e,0).tree;if(!a)return null;const l=(o=a.prop(j.mounted))===null||o===void 0?void 0:o.tree;if((l==null?void 0:l.type.name)!=="Styles")return null;const h=[];return l.iterate({from:0,to:l.length,enter:({type:c,from:f,to:u})=>{const d=Mm(t,e+1+f,e+1+u,c.name,n);if(d){if(Array.isArray(d))throw new Error("Unexpected nested overlays");h.push(d)}}}),h}case"CallExpression":{const a=n.sliceString(e,i),l=Em(a);return l?Object.assign(Object.assign({},l),{from:e,to:i}):null}case"ColorLiteral":{const a=qm(n.sliceString(e,i));return a?Object.assign(Object.assign({},a),{from:e,to:i}):null}case"ValueName":{const a=n.sliceString(e,i),l=lT(a);return l?Object.assign(Object.assign({},l),{from:e,to:i}):null}default:return null}}function Em(t){switch(t.slice(0,3)){case"rgb":{const i=sT.exec(t);if(!i)return null;const[r,n,s,o,a]=i,l=cT(n,s,o);return{colorType:wt.rgb,color:l,alpha:(a==null?void 0:a.replace(/^\//,","))||""}}case"hsl":{const i=oT.exec(t);if(!i)return null;const[r,n,s,o,a]=i,l=fT(n,s,o);return{colorType:wt.hsl,color:l,alpha:(a==null?void 0:a.replace(/^\//,","))||""}}default:return null}}function qm(t){if(!aT.exec(t))return null;const[i,r]=hT(t);return{colorType:wt.hex,color:i,alpha:r}}function lT(t){const e=Xm.get(t);return e?{colorType:wt.named,color:e,alpha:""}:null}function Dm(t,e){const i=[],r=I(t.state);for(const n of t.visibleRanges)r.iterate({from:n.from,to:n.to,enter:({type:s,from:o,to:a})=>{var l;const h=e(r,o,a,s.name,t.state.doc,(l=t.state.facet(nt))===null||l===void 0?void 0:l.name);if(h){if(!Array.isArray(h)){i.push(A.widget({widget:new _m(h),side:1}).range(h.from));return}for(const c of h)i.push(A.widget({widget:new _m(c),side:1}).range(c.from))}}});return A.set(i)}function hT(t){return t.length===4?[`#${t[1].repeat(2)}${t[2].repeat(2)}${t[3].repeat(2)}`,""]:t.length===5?[`#${t[1].repeat(2)}${t[2].repeat(2)}${t[3].repeat(2)}`,t[4].repeat(2)]:t.length===9?[`#${t.slice(1,-2)}`,t.slice(-2)]:[t,""]}function Ph(t){let e;if(t.endsWith("%")){const i=Number(t.slice(0,-1));e=Math.round(i/100*255)}else e=Number(t);return uo(e)}function uo(t){const e=t.toString(16);return e.length===1?"0"+e:e}function Ym(t){const e=t.slice(1,3),i=t.slice(3,5),r=t.slice(5,7);return[parseInt(e,16),parseInt(i,16),parseInt(r,16)]}function cT(t,e,i){return`#${Ph(t)}${Ph(e)}${Ph(i)}`}function fT(t,e,i){const r=Number(e)/100,n=Number(i)/100,[s,o,a]=uT(Number(t),r,n);return`#${uo(s)}${uo(o)}${uo(a)}`}function uT(t,e,i){if(e===0){const f=Math.round(i*255);return[f,f,f]}let r;i<.5?r=i*(1+e):r=i+e-i*e;const n=2*i-r;t=t/360;const s=Vm(t+.333),o=t,a=Vm(t-.333),l=Th(r,n,s),h=Th(r,n,o),c=Th(r,n,a);return[Math.round(l*255),Math.round(h*255),Math.round(c*255)]}function Vm(t){return t<0?t+1:t>1?t-1:t}function Th(t,e,i){return 6*i<1?e+(t-e)*6*i:2*i<1?t:3*i<2?e+(t-e)*(.666-i)*6:e}function dT(t,e,i){const r=t/255,n=e/255,s=i/255,o=Math.min(r,n,s),a=Math.max(r,n,s),l=(a+o)/2;if(a===o)return[0,0,l];let h;l<=.5?h=(a-o)/(a+o):h=(a-o)/(2-a-o);let c;for(a===r?c=(n-s)/(a-o):n===a?c=2+(s-r)/(a-o):c=4+(r-n)/(a-o),c=Math.round(c*60);c<0;)c+=360;return[c,h,l]}var vr="cm-css-color-picker-wrapper",_m=class extends gt{constructor(t){var{color:e}=t,i=nT(t,["color"]);super(),this.state=i,this.color=e}eq(t){return t.state.colorType===this.state.colorType&&t.color===this.color&&t.state.from===this.state.from&&t.state.to===this.state.to&&t.state.alpha===this.state.alpha}toDOM(){const t=document.createElement("input");Wm.set(t,this.state),t.type="color",t.value=this.color;const e=document.createElement("span");return e.appendChild(t),e.className=vr,e}ignoreEvent(){return!1}},Bm=x.baseTheme({[`.${vr}`]:{display:"inline-block",outline:"1px solid #eee",marginRight:"0.6ch",height:"1em",width:"1em",transform:"translateY(1px)"},[`.${vr} input[type="color"]`]:{cursor:"pointer",height:"100%",width:"100%",padding:0,border:"none","&::-webkit-color-swatch-wrapper":{padding:0},"&::-webkit-color-swatch":{border:"none"},"&::-moz-color-swatch":{border:"none"}}}),Lm=t=>be.fromClass(class{constructor(i){this.decorations=Dm(i,t.discoverColors)}update(i){(i.docChanged||i.viewportChanged)&&(this.decorations=Dm(i.view,t.discoverColors))}},{decorations:e=>e.decorations,eventHandlers:{change:(e,i)=>{const r=e.target;if(r.nodeName!=="INPUT"||!r.parentElement||!r.parentElement.classList.contains(vr))return!1;const n=Wm.get(r);let s=r.value+n.alpha;if(n.colorType===wt.rgb)s=`rgb(${Ym(r.value).join(", ")}${n.alpha})`;else if(n.colorType===wt.named)for(const[o,a]of Xm.entries())a===r.value&&(s=o);else if(n.colorType===wt.hsl){const[o,a,l]=Ym(r.value),[h,c,f]=dT(o,a,l);s=`hsl(${h}, ${Math.round(c*100)}%, ${Math.round(f*100)}%${n.alpha})`}return i.dispatch({changes:{from:n.from,to:n.to,insert:s}}),!0}}}),Ch=[Lm({discoverColors:Mm}),Bm],Zh=[["b","bdi","del","i","ins","u","font","big","small","sub","sup","h1","h2","h3","h4","h5","h6","cite","code","em","s","strike","strong","tt","var","div","center","blockquote","ol","ul","dl","table","caption","pre","ruby","rb","rp","rt","rtc","p","span","abbr","dfn","kbd","samp","data","time","mark","tr","td","th","q","bdo"],["li","dt","dd"],["br","wbr","hr","meta","link"]],jm=Zh.flat(),zm=Zh[2],Nm=Zh[1],$={apostrophes:"mw-apostrophes",comment:"mw-comment",convertBracket:"mw-convert-bracket",convertDelimiter:"mw-convert-delimiter",convertFlag:"mw-convert-flag",convertLang:"mw-convert-lang",doubleUnderscore:"mw-double-underscore",em:"mw-em",error:"mw-error",extLink:"mw-extlink",extLinkBracket:"mw-extlink-bracket",extLinkProtocol:"mw-extlink-protocol",extLinkText:"mw-extlink-text",extTag:"mw-exttag",extTagAttribute:"mw-exttag-attribute",extTagAttributeValue:"mw-exttag-attribute-value",extTagBracket:"mw-exttag-bracket",extTagName:"mw-exttag-name",fileDelimiter:"mw-file-delimiter",fileText:"mw-file-text",freeExtLink:"mw-free-extlink",freeExtLinkProtocol:"mw-free-extlink-protocol",hr:"mw-hr",htmlEntity:"mw-entity",htmlTagAttribute:"mw-htmltag-attribute",htmlTagAttributeValue:"mw-htmltag-attribute-value",htmlTagBracket:"mw-htmltag-bracket",htmlTagName:"mw-htmltag-name",ignored:"mw-ignored",imageParameter:"mw-image-parameter",linkBracket:"mw-link-bracket",linkDelimiter:"mw-link-delimiter",linkPageName:"mw-link-pagename",linkText:"mw-link-text",linkToSection:"mw-link-tosection",list:"mw-list",magicLink:"mw-magic-link",pageName:"mw-pagename",parserFunction:"mw-parserfunction",parserFunctionBracket:"mw-parserfunction-bracket",parserFunctionDelimiter:"mw-parserfunction-delimiter",parserFunctionName:"mw-parserfunction-name",redirect:"mw-redirect",section:"mw-section",sectionHeader:"mw-section-header",signature:"mw-signature",skipFormatting:"mw-skipformatting",strong:"mw-strong",tableBracket:"mw-table-bracket",tableCaption:"mw-table-caption",tableDefinition:"mw-table-definition",tableDefinitionValue:"mw-table-definition-value",tableDelimiter:"mw-table-delimiter",tableDelimiter2:"mw-table-delimiter2",tableTd:"mw-table-td",tableTh:"mw-table-th",template:"mw-template",templateArgumentName:"mw-template-argument-name",templateBracket:"mw-template-bracket",templateDelimiter:"mw-template-delimiter",templateName:"mw-template-name",templateVariable:"mw-templatevariable",templateVariableBracket:"mw-templatevariable-bracket",templateVariableDelimiter:"mw-templatevariable-delimiter",templateVariableName:"mw-templatevariable-name"},pT=(()=>{const t={variable:m.variableName,"variable-2":m.special(m.variableName),"string-2":m.special(m.string),def:m.definition(m.variableName),tag:m.tagName,attribute:m.attributeName,type:m.typeName,builtin:m.standard(m.variableName),qualifier:m.modifier,error:m.invalid,header:m.heading,property:m.propertyName};for(const e of Object.values($))t[e]=rt.define();return t})(),OT="wiktionary|wiki(?:pedia|books|news|quote|source|versity|voyage)",mT=t=>Math.round(t*255).toString(16).padStart(2,"0"),gT=(()=>{const t=String.raw`#(?:[\da-f]{3,4}|(?:[\da-f]{2}){3,4})(?![\p{L}\p{N}_])`,e=String.raw`(?:\d*\.)?\d+%?`,i=String.raw`(?:\d*\.)?\d+(?:deg|grad|rad|turn)?`,r=String.raw`rgba?\(\s*(?:${String.raw`${new Array(3).fill(e).join(String.raw`\s+`)}(?:\s*\/\s*${e})?`}|${String.raw`${new Array(3).fill(e).join(String.raw`\s*,\s*`)}(?:\s*,\s*${e})?`})\s*\)`,n=String.raw`hsla?\(\s*(?:${String.raw`${i}\s+${e}\s+${e}(?:\s*\/\s*${e})?`}|${String.raw`${i}${String.raw`\s*,\s*(?:\d*\.)?\d+%`.repeat(2)}(?:\s*,\s*${e})?`})\s*\)`;return{full:new RegExp(String.raw`(^|[^\p{L}\p{N}_])(${t}|${r}|${n})`,"giu"),rgb:new RegExp(String.raw`(^|[^\p{L}\p{N}_])(${t}|${r})`,"giu")}})(),bT=(t,e=!0)=>{const i=[],r=gT[e?"full":"rgb"];r.lastIndex=0;let n=r.exec(t),s=0;for(;n;){const o=n.index+n[1].length;o>s&&i.push([t.slice(s,o),s,o,!1]),{lastIndex:s}=r,i.push([n[2],o,s,t[o-1]!=="&"||!/^#\d+$/u.test(n[2])]),n=r.exec(t)}return t.length>s&&i.push([t.slice(s),s,t.length,!1]),i},Im=t=>t.replace(/[{}]/gu,e=>e==="{"?"{":"}");function xt(t){const e=new Map,i=new WeakMap;return r=>{const n=typeof r=="string"?e:i;if(n.has(r)){const o=n.get(r);return o.lastIndex=0,o}const s=t(r);return n.set(r,s),s}}var po=".cm-panel",Gm=".cm-panels",Um=".cm-diagnosticText-clickable",yr=".cm-tooltip-fold",Sr=".cm-tooltip-hover",Fm="cm-matchingTag",Hm="cm-nonmatchingTag",Km=".cm-bidi-isolate",Jm=".cm-bidi-ltr",kr=".cm-status-fix-menu",xn=".cm-status-message",Ah=".cm-diagnosticAction",eg=typeof location=="object"&&new RegExp(String.raw`\.(?:${OT})\.org$`,"u").test(location.hostname),tg=(()=>{const{vendor:t,userAgent:e,maxTouchPoints:i,platform:r}=navigator;return(t==null?void 0:t.includes("Apple Computer"))&&(e.includes("Mobile/")||i>2)||r.includes("Mac")})(),vT=class{get closing(){return ng(this.first,this.type,this.state,!0)}get selfClosing(){return zm.includes(this.name)||(this.type==="ext"||Nm.includes(this.name))&&ng(this.last,this.type,this.state)}get from(){const{first:{from:t,to:e},state:i}=this;return t+i.sliceDoc(t,e).lastIndexOf("<")}get to(){const{last:{from:t,to:e},state:i}=this;return t+i.sliceDoc(t,e).indexOf(">")+1}constructor(t,e,i,r,n){this.type=t,this.name=e,this.first=i,this.last=r,this.state=n}},ig=({name:t})=>/-(?:ext|html)tag-(?!bracket)/u.test(t),rg=t=>{const e=new RegExp(`-htmltag-${t}`,"u"),i=new RegExp(`-exttag-${t}`,"u");return({name:r},n)=>(n==="ext"?i:e).test(r)},Oo=rg("bracket"),Rh=rg("name"),ng=(t,e,i,r)=>Oo(t,e)&&i.sliceDoc(t.from,t.to)[r?"endsWith":"startsWith"]("/"),sg=(t,{from:e,to:i})=>t.sliceDoc(e,i).trim().toLowerCase(),Qn=(t,e)=>{const i=e.name.includes("exttag")?"ext":"html";let{nextSibling:r,prevSibling:n}=e,s=Rh(e,i)?e:null;for(;r&&!Oo(r,i);)({nextSibling:r}=r);if(!r||Oo(r,i)&&t.sliceDoc(r.from,r.from+1)==="<")return null;for(;n&&!Oo(n,i);)s!=null||(s=Rh(n,i)?n:null),{prevSibling:n}=n;const o=sg(t,s);return new vT(i,o,n,r,t)},yT=(t,e)=>{const{type:i,name:r,closing:n}=e,s=n?"prevSibling":"nextSibling",o=n?"first":"last";let a=n?-1:1,l=e[o][s];for(;l;){if(Rh(l,i)&&sg(t,l)===r){const h=Qn(t,l);if(h){if(h.closing?a--:a+=h.selfClosing?0:1,a===0)return h;l=h[o]}}l=l[s]}return null},og=(t,e)=>{const i=fi(t,e);if(!i)return null;let r=i.resolve(e,-1);if(!ig(r)&&(r=i.resolve(e,1),!ig(r)))return null;const n=Qn(t,r);if(n){if(n.selfClosing)return{matched:!0,start:n}}else return null;const s=yT(t,n);return s?{matched:!0,start:n,end:s}:{matched:!1,start:n}},ST=A.mark({class:Fm}),kT=A.mark({class:Hm}),wT=ve.define({create(){return A.none},update(t,{docChanged:e,selection:i,state:r}){if(!e&&!i)return t;const n=[];for(const s of r.selection.ranges)if(s.empty){const o=og(r,s.head);if(o){const a=o.matched?ST:kT,{start:{from:l,to:h,closing:c},end:f}=o;n.push(a.range(l,h)),f&&n[c?"unshift":"push"](a.range(f.from,f.to))}}return A.set(n)},provide(t){return x.decorations.from(t)}}),ag=Km.slice(1),Xh=A.mark({class:`${ag} ${Jm.slice(1)}`,bidiIsolate:se.LTR}),lg=A.mark({class:ag}),hg=({visibleRanges:t,state:e,textDirection:i})=>{const r=new jt;if(i===se.RTL)for(const{from:n,to:s}of t){let o=I(e).resolve(n,1),a=0,l=0,h=0;for(;o&&o.to<=s;){const{name:c,from:f,to:u,nextSibling:d}=o;if(/-(?:ext|html)tag-bracket/u.test(c)&&e.sliceDoc(f,u).includes("<")){const p=Qn(e,d);p&&r.add(p.from,p.to,Xh)}else!a&&!l&&c.includes($.tableDefinition)?/-html-(?:table|tr)/u.test(c)?(l=e.doc.lineAt(f).to,r.add(f,l,Xh)):a=f:l&&f>l?l=0:a&&c.includes($.tableDelimiter2)?(r.add(a,f,Xh),a=0):/-(?:template|parserfunction)-delimiter/u.test(c)?(h&&r.add(h,f,lg),h=u):h&&/-(?:template|parserfunction)-bracket/u.test(c)&&(e.sliceDoc(f,f+1)==="}"&&r.add(h,f,lg),h=0);o=o.nextSibling}}return r.finish()},xT=be.fromClass(class{constructor(t){this.isolates=hg(t),this.tree=I(t.state),this.dir=t.textDirection}update({docChanged:t,viewportChanged:e,state:i,view:r}){const n=I(i),{textDirection:s}=r;(t||e||n!==this.tree||s!==this.dir)&&(this.isolates=hg(r),this.tree=n,this.dir=s)}},{provide(t){const e=i=>{var r,n;return(n=(r=i.plugin(t))==null?void 0:r.isolates)!=null?n:A.none};return Bt.lowest([x.decorations.of(e),x.bidiIsolatedRanges.of(e)])}}),QT=t=>{let{state:e}=t,i=e.doc.lineAt(e.selection.main.from),r=Mh(t.state,i.from);return r.line?$T(t):r.block?TT(t):!1};function Wh(t,e){return({state:i,dispatch:r})=>{if(i.readOnly)return!1;let n=t(e,i);return n?(r(i.update(n)),!0):!1}}var $T=Wh(AT,0),PT=Wh(cg,0),TT=Wh((t,e)=>cg(t,e,ZT(e)),0);function Mh(t,e){let i=t.languageDataAt("commentTokens",e,1);return i.length?i[0]:{}}var $n=50;function CT(t,{open:e,close:i},r,n){let s=t.sliceDoc(r-$n,r),o=t.sliceDoc(n,n+$n),a=/\s*$/.exec(s)[0].length,l=/^\s*/.exec(o)[0].length,h=s.length-a;if(s.slice(h-e.length,h)==e&&o.slice(l,l+i.length)==i)return{open:{pos:r-a,margin:a&&1},close:{pos:n+l,margin:l&&1}};let c,f;n-r<=2*$n?c=f=t.sliceDoc(r,n):(c=t.sliceDoc(r,r+$n),f=t.sliceDoc(n-$n,n));let u=/^\s*/.exec(c)[0].length,d=/\s*$/.exec(f)[0].length,p=f.length-d-i.length;return c.slice(u,u+e.length)==e&&f.slice(p,p+i.length)==i?{open:{pos:r+u+e.length,margin:/\s/.test(c.charAt(u+e.length))?1:0},close:{pos:n-d-i.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function ZT(t){let e=[];for(let i of t.selection.ranges){let r=t.doc.lineAt(i.from),n=i.to<=r.to?r:t.doc.lineAt(i.to);n.from>r.from&&n.from==i.to&&(n=i.to==r.to+1?r:t.doc.lineAt(i.to-1));let s=e.length-1;s>=0&&e[s].to>r.from?e[s].to=n.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:n.to})}return e}function cg(t,e,i=e.selection.ranges){let r=i.map(s=>Mh(e,s.from).block);if(!r.every(s=>s))return null;let n=i.map((s,o)=>CT(e,r[o],s.from,s.to));if(t!=2&&!n.every(s=>s))return{changes:e.changes(i.map((s,o)=>n[o]?[]:[{from:s.from,insert:r[o].open+" "},{from:s.to,insert:" "+r[o].close}]))};if(t!=1&&n.some(s=>s)){let s=[];for(let o=0,a;o<n.length;o++)if(a=n[o]){let l=r[o],{open:h,close:c}=a;s.push({from:h.pos-l.open.length,to:h.pos+h.margin},{from:c.pos-c.margin,to:c.pos+l.close.length})}return{changes:s}}return null}function AT(t,e,i=e.selection.ranges){let r=[],n=-1;for(let{from:s,to:o}of i){let a=r.length,l=1e9,h=Mh(e,s).line;if(h){for(let c=s;c<=o;){let f=e.doc.lineAt(c);if(f.from>n&&(s==o||o>f.from)){n=f.from;let u=/^\s*/.exec(f.text)[0].length,d=u==f.length,p=f.text.slice(u,u+h.length)==h?u:-1;u<f.text.length&&u<l&&(l=u),r.push({line:f,comment:p,token:h,indent:u,empty:d,single:!1})}c=f.to+1}if(l<1e9)for(let c=a;c<r.length;c++)r[c].indent<r[c].line.text.length&&(r[c].indent=l);r.length==a+1&&(r[a].single=!0)}}if(t!=2&&r.some(s=>s.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:a,token:l,indent:h,empty:c,single:f}of r)(f||!c)&&s.push({from:a.from+h,insert:l+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(t!=1&&r.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:a,token:l}of r)if(a>=0){let h=o.from+a,c=h+l.length;o.text[c-o.from]==" "&&c++,s.push({from:h,to:c})}return{changes:s}}return null}var Eh=Lt.define(),RT=Lt.define(),XT=R.define(),fg=R.define({combine(t){return mt(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,i)=>i},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,i)=>(r,n)=>e(r,n)||i(r,n)})}}),ug=ve.define({create(){return Pn.empty},update(t,e){let i=e.state.facet(fg),r=e.annotation(Eh);if(r){let l=Ft.fromTransaction(e,r.selection),h=r.side,c=h==0?t.undone:t.done;return l?c=bo(c,c.length,i.minDepth,l):c=Og(c,e.startState.selection),new Pn(h==0?r.rest:c,h==0?c:r.rest)}let n=e.annotation(RT);if((n=="full"||n=="before")&&(t=t.isolate()),e.annotation(Re.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let s=Ft.fromTransaction(e),o=e.annotation(Re.time),a=e.annotation(Re.userEvent);return s?t=t.addChanges(s,o,a,i,e):e.selection&&(t=t.addSelection(e.startState.selection,o,a,i.newGroupDelay)),(n=="full"||n=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Pn(t.done.map(Ft.fromJSON),t.undone.map(Ft.fromJSON))}});function WT(t={}){return[ug,fg.of(t),x.domEventHandlers({beforeinput(e,i){let r=e.inputType=="historyUndo"?dg:e.inputType=="historyRedo"?go:null;return r?(e.preventDefault(),r(i)):!1}})]}function mo(t,e){return function({state:i,dispatch:r}){if(!e&&i.readOnly)return!1;let n=i.field(ug,!1);if(!n)return!1;let s=n.pop(t,i,e);return s?(r(s),!0):!1}}var dg=mo(0,!1),go=mo(1,!1),MT=mo(0,!0),ET=mo(1,!0),Ft=class zn{constructor(e,i,r,n,s){this.changes=e,this.effects=i,this.mapped=r,this.startSelection=n,this.selectionsAfter=s}setSelAfter(e){return new zn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,i,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(i=this.mapped)===null||i===void 0?void 0:i.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(n=>n.toJSON())}}static fromJSON(e){return new zn(e.changes&&pt.fromJSON(e.changes),[],e.mapped&&Ni.fromJSON(e.mapped),e.startSelection&&k.fromJSON(e.startSelection),e.selectionsAfter.map(k.fromJSON))}static fromTransaction(e,i){let r=st;for(let n of e.startState.facet(XT)){let s=n(e);s.length&&(r=r.concat(s))}return!r.length&&e.changes.empty?null:new zn(e.changes.invert(e.startState.doc),r,void 0,i||e.startState.selection,st)}static selection(e){return new zn(void 0,st,void 0,void 0,e)}};function bo(t,e,i,r){let n=e+1>i+20?e-i-1:0,s=t.slice(n,e);return s.push(r),s}function qT(t,e){let i=[],r=!1;return t.iterChangedRanges((n,s)=>i.push(n,s)),e.iterChangedRanges((n,s,o,a)=>{for(let l=0;l<i.length;){let h=i[l++],c=i[l++];a>=h&&o<=c&&(r=!0)}}),r}function DT(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((i,r)=>i.empty!=e.ranges[r].empty).length===0}function pg(t,e){return t.length?e.length?t.concat(e):t:e}var st=[],YT=200;function Og(t,e){if(t.length){let i=t[t.length-1],r=i.selectionsAfter.slice(Math.max(0,i.selectionsAfter.length-YT));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),bo(t,t.length-1,1e9,i.setSelAfter(r)))}else return[Ft.selection([e])]}function VT(t){let e=t[t.length-1],i=t.slice();return i[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),i}function qh(t,e){if(!t.length)return t;let i=t.length,r=st;for(;i;){let n=_T(t[i-1],e,r);if(n.changes&&!n.changes.empty||n.effects.length){let s=t.slice(0,i);return s[i-1]=n,s}else e=n.mapped,i--,r=n.selectionsAfter}return r.length?[Ft.selection(r)]:st}function _T(t,e,i){let r=pg(t.selectionsAfter.length?t.selectionsAfter.map(a=>a.map(e)):st,i);if(!t.changes)return Ft.selection(r);let n=t.changes.map(e),s=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(s):s;return new Ft(n,B.mapEffects(t.effects,e),o,t.startSelection.map(s),r)}var BT=/^(input\.type|delete)($|\.)/,Pn=class Nn{constructor(e,i,r=0,n=void 0){this.done=e,this.undone=i,this.prevTime=r,this.prevUserEvent=n}isolate(){return this.prevTime?new Nn(this.done,this.undone):this}addChanges(e,i,r,n,s){let o=this.done,a=o[o.length-1];return a&&a.changes&&!a.changes.empty&&e.changes&&(!r||BT.test(r))&&(!a.selectionsAfter.length&&i-this.prevTime<n.newGroupDelay&&n.joinToEvent(s,qT(a.changes,e.changes))||r=="input.type.compose")?o=bo(o,o.length-1,n.minDepth,new Ft(e.changes.compose(a.changes),pg(B.mapEffects(e.effects,a.changes),a.effects),a.mapped,a.startSelection,st)):o=bo(o,o.length,n.minDepth,e),new Nn(o,st,i,r)}addSelection(e,i,r,n){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:st;return s.length>0&&i-this.prevTime<n&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&DT(s[s.length-1],e)?this:new Nn(Og(this.done,e),this.undone,i,r)}addMapping(e){return new Nn(qh(this.done,e),qh(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,i,r){let n=e==0?this.done:this.undone;if(n.length==0)return null;let s=n[n.length-1],o=s.selectionsAfter[0]||i.selection;if(r&&s.selectionsAfter.length)return i.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:Eh.of({side:e,rest:VT(n),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let a=n.length==1?st:n.slice(0,n.length-1);return s.mapped&&(a=qh(a,s.mapped)),i.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:Eh.of({side:e,rest:a,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}};Pn.empty=new Pn(st,st);var LT=[{key:"Mod-z",run:dg,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:go,preventDefault:!0},{linux:"Ctrl-Shift-z",run:go,preventDefault:!0},{key:"Mod-u",run:MT,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:ET,preventDefault:!0}];function wr(t,e){return k.create(t.ranges.map(e),t.mainIndex)}function Qt(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function $t({state:t,dispatch:e},i){let r=wr(t.selection,i);return r.eq(t.selection,!0)?!1:(e(Qt(t,r)),!0)}function vo(t,e){return k.cursor(e?t.to:t.from)}function mg(t,e){return $t(t,i=>i.empty?t.moveByChar(i,e):vo(i,e))}function Ae(t){return t.textDirectionAt(t.state.selection.main.head)==se.LTR}var gg=t=>mg(t,!Ae(t)),bg=t=>mg(t,Ae(t));function vg(t,e){return $t(t,i=>i.empty?t.moveByGroup(i,e):vo(i,e))}var jT=t=>vg(t,!Ae(t)),zT=t=>vg(t,Ae(t)),qA=typeof Intl!="undefined"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function NT(t,e,i){if(e.type.prop(i))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function yo(t,e,i){let r=I(t).resolveInner(e.head),n=i?j.closedBy:j.openedBy;for(let l=e.head;;){let h=i?r.childAfter(l):r.childBefore(l);if(!h)break;NT(t,h,n)?r=h:l=i?h.to:h.from}let s=r.type.prop(n),o,a;return s&&(o=i?qe(t,r.from,1):qe(t,r.to,-1))&&o.matched?a=i?o.end.to:o.end.from:a=i?r.to:r.from,k.cursor(a,i?-1:1)}var IT=t=>$t(t,e=>yo(t.state,e,!Ae(t))),GT=t=>$t(t,e=>yo(t.state,e,Ae(t)));function yg(t,e){return $t(t,i=>{if(!i.empty)return vo(i,e);let r=t.moveVertically(i,e);return r.head!=i.head?r:t.moveToLineBoundary(i,e)})}var Sg=t=>yg(t,!1),kg=t=>yg(t,!0);function wg(t){let e=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,i=0,r=0,n;if(e){for(let s of t.state.facet(x.scrollMargins)){let o=s(t);o!=null&&o.top&&(i=Math.max(o==null?void 0:o.top,i)),o!=null&&o.bottom&&(r=Math.max(o==null?void 0:o.bottom,r))}n=t.scrollDOM.clientHeight-i-r}else n=(t.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:i,marginBottom:r,selfScroll:e,height:Math.max(t.defaultLineHeight,n-5)}}function xg(t,e){let i=wg(t),{state:r}=t,n=wr(r.selection,o=>o.empty?t.moveVertically(o,e,i.height):vo(o,e));if(n.eq(r.selection))return!1;let s;if(i.selfScroll){let o=t.coordsAtPos(r.selection.main.head),a=t.scrollDOM.getBoundingClientRect(),l=a.top+i.marginTop,h=a.bottom-i.marginBottom;o&&o.top>l&&o.bottom<h&&(s=x.scrollIntoView(n.main.head,{y:"start",yMargin:o.top-l}))}return t.dispatch(Qt(r,n),{effects:s}),!0}var Qg=t=>xg(t,!1),Dh=t=>xg(t,!0);function pi(t,e,i){let r=t.lineBlockAt(e.head),n=t.moveToLineBoundary(e,i);if(n.head==e.head&&n.head!=(i?r.to:r.from)&&(n=t.moveToLineBoundary(e,i,!1)),!i&&n.head==r.from&&r.length){let s=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;s&&e.head!=r.from+s&&(n=k.cursor(r.from+s))}return n}var UT=t=>$t(t,e=>pi(t,e,!0)),FT=t=>$t(t,e=>pi(t,e,!1)),HT=t=>$t(t,e=>pi(t,e,!Ae(t))),KT=t=>$t(t,e=>pi(t,e,Ae(t))),JT=t=>$t(t,e=>k.cursor(t.lineBlockAt(e.head).from,1)),eC=t=>$t(t,e=>k.cursor(t.lineBlockAt(e.head).to,-1));function tC(t,e,i){let r=!1,n=wr(t.selection,s=>{let o=qe(t,s.head,-1)||qe(t,s.head,1)||s.head>0&&qe(t,s.head-1,1)||s.head<t.doc.length&&qe(t,s.head+1,-1);if(!o||!o.end)return s;r=!0;let a=o.start.from==s.head?o.end.to:o.end.from;return i?k.range(s.anchor,a):k.cursor(a)});return r?(e(Qt(t,n)),!0):!1}var iC=({state:t,dispatch:e})=>tC(t,e,!1);function ot(t,e){let i=wr(t.state.selection,r=>{let n=e(r);return k.range(r.anchor,n.head,n.goalColumn,n.bidiLevel||void 0)});return i.eq(t.state.selection)?!1:(t.dispatch(Qt(t.state,i)),!0)}function $g(t,e){return ot(t,i=>t.moveByChar(i,e))}var Pg=t=>$g(t,!Ae(t)),Tg=t=>$g(t,Ae(t));function Cg(t,e){return ot(t,i=>t.moveByGroup(i,e))}var rC=t=>Cg(t,!Ae(t)),nC=t=>Cg(t,Ae(t)),sC=t=>ot(t,e=>yo(t.state,e,!Ae(t))),oC=t=>ot(t,e=>yo(t.state,e,Ae(t)));function Zg(t,e){return ot(t,i=>t.moveVertically(i,e))}var Ag=t=>Zg(t,!1),Rg=t=>Zg(t,!0);function Xg(t,e){return ot(t,i=>t.moveVertically(i,e,wg(t).height))}var Wg=t=>Xg(t,!1),Mg=t=>Xg(t,!0),aC=t=>ot(t,e=>pi(t,e,!0)),lC=t=>ot(t,e=>pi(t,e,!1)),hC=t=>ot(t,e=>pi(t,e,!Ae(t))),cC=t=>ot(t,e=>pi(t,e,Ae(t))),fC=t=>ot(t,e=>k.cursor(t.lineBlockAt(e.head).from)),uC=t=>ot(t,e=>k.cursor(t.lineBlockAt(e.head).to)),Eg=({state:t,dispatch:e})=>(e(Qt(t,{anchor:0})),!0),qg=({state:t,dispatch:e})=>(e(Qt(t,{anchor:t.doc.length})),!0),Dg=({state:t,dispatch:e})=>(e(Qt(t,{anchor:t.selection.main.anchor,head:0})),!0),Yg=({state:t,dispatch:e})=>(e(Qt(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),dC=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),pC=({state:t,dispatch:e})=>{let i=ko(t).map(({from:r,to:n})=>k.range(r,Math.min(n+1,t.doc.length)));return e(t.update({selection:k.create(i),userEvent:"select"})),!0},OC=({state:t,dispatch:e})=>{let i=wr(t.selection,r=>{let n=I(t),s=n.resolveStack(r.from,1);if(r.empty){let o=n.resolveStack(r.from,-1);o.node.from>=s.node.from&&o.node.to<=s.node.to&&(s=o)}for(let o=s;o;o=o.next){let{node:a}=o;if((a.from<r.from&&a.to>=r.to||a.to>r.to&&a.from<=r.from)&&o.next)return k.range(a.to,a.from)}return r});return i.eq(t.selection)?!1:(e(Qt(t,i)),!0)};function Vg(t,e){let{state:i}=t,r=i.selection,n=i.selection.ranges.slice();for(let s of i.selection.ranges){let o=i.doc.lineAt(s.head);if(e?o.to<t.state.doc.length:o.from>0)for(let a=s;;){let l=t.moveVertically(a,e);if(l.head<o.from||l.head>o.to){n.some(h=>h.head==l.head)||n.push(l);break}else{if(l.head==a.head)break;a=l}}}return n.length==r.ranges.length?!1:(t.dispatch(Qt(i,k.create(n,n.length-1))),!0)}var mC=t=>Vg(t,!1),gC=t=>Vg(t,!0),bC=({state:t,dispatch:e})=>{let i=t.selection,r=null;return i.ranges.length>1?r=k.create([i.main]):i.main.empty||(r=k.create([k.cursor(i.main.head)])),r?(e(Qt(t,r)),!0):!1};function Tn(t,e){if(t.state.readOnly)return!1;let i="delete.selection",{state:r}=t,n=r.changeByRange(s=>{let{from:o,to:a}=s;if(o==a){let l=e(s);l<o?(i="delete.backward",l=So(t,l,!1)):l>o&&(i="delete.forward",l=So(t,l,!0)),o=Math.min(o,l),a=Math.max(a,l)}else o=So(t,o,!1),a=So(t,a,!0);return o==a?{range:s}:{changes:{from:o,to:a},range:k.cursor(o,o<s.head?-1:1)}});return n.changes.empty?!1:(t.dispatch(r.update(n,{scrollIntoView:!0,userEvent:i,effects:i=="delete.selection"?x.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function So(t,e,i){if(t instanceof x)for(let r of t.state.facet(x.atomicRanges).map(n=>n(t)))r.between(e,e,(n,s)=>{n<e&&s>e&&(e=i?s:n)});return e}var _g=(t,e,i)=>Tn(t,r=>{let n=r.from,{state:s}=t,o=s.doc.lineAt(n),a,l;if(i&&!e&&n>o.from&&n<o.from+200&&!/[^ \t]/.test(a=o.text.slice(0,n-o.from))){if(a[a.length-1]==" ")return n-1;let h=Gi(a,s.tabSize),c=h%Ri(s)||Ri(s);for(let f=0;f<c&&a[a.length-1-f]==" ";f++)n--;l=n}else l=Te(o.text,n-o.from,e,e)+o.from,l==n&&o.number!=(e?s.doc.lines:1)?l+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(l-o.from,n-o.from))&&(l=Te(o.text,l-o.from,!1,!1)+o.from);return l}),Yh=t=>_g(t,!1,!0),Bg=t=>_g(t,!0,!1),Lg=(t,e)=>Tn(t,i=>{let r=i.head,{state:n}=t,s=n.doc.lineAt(r),o=n.charCategorizer(r);for(let a=null;;){if(r==(e?s.to:s.from)){r==i.head&&s.number!=(e?n.doc.lines:1)&&(r+=e?1:-1);break}let l=Te(s.text,r-s.from,e)+s.from,h=s.text.slice(Math.min(r,l)-s.from,Math.max(r,l)-s.from),c=o(h);if(a!=null&&c!=a)break;(h!=" "||r!=i.head)&&(a=c),r=l}return r}),jg=t=>Lg(t,!1),vC=t=>Lg(t,!0),yC=t=>Tn(t,e=>{let i=t.lineBlockAt(e.head).to;return e.head<i?i:Math.min(t.state.doc.length,e.head+1)}),SC=t=>Tn(t,e=>{let i=t.moveToLineBoundary(e,!1).head;return e.head>i?i:Math.max(0,e.head-1)}),kC=t=>Tn(t,e=>{let i=t.moveToLineBoundary(e,!0).head;return e.head<i?i:Math.min(t.state.doc.length,e.head+1)}),wC=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:F.of(["",""])},range:k.cursor(r.from)}));return e(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0},xC=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let n=r.from,s=t.doc.lineAt(n),o=n==s.from?n-1:Te(s.text,n-s.from,!1)+s.from,a=n==s.to?n+1:Te(s.text,n-s.from,!0)+s.from;return{changes:{from:o,to:a,insert:t.doc.slice(n,a).append(t.doc.slice(o,n))},range:k.cursor(a)}});return i.changes.empty?!1:(e(t.update(i,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function ko(t){let e=[],i=-1;for(let r of t.selection.ranges){let n=t.doc.lineAt(r.from),s=t.doc.lineAt(r.to);if(!r.empty&&r.to==s.from&&(s=t.doc.lineAt(r.to-1)),i>=n.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(r)}else e.push({from:n.from,to:s.to,ranges:[r]});i=s.number+1}return e}function zg(t,e,i){if(t.readOnly)return!1;let r=[],n=[];for(let s of ko(t)){if(i?s.to==t.doc.length:s.from==0)continue;let o=t.doc.lineAt(i?s.to+1:s.from-1),a=o.length+1;if(i){r.push({from:s.to,to:o.to},{from:s.from,insert:o.text+t.lineBreak});for(let l of s.ranges)n.push(k.range(Math.min(t.doc.length,l.anchor+a),Math.min(t.doc.length,l.head+a)))}else{r.push({from:o.from,to:s.from},{from:s.to,insert:t.lineBreak+o.text});for(let l of s.ranges)n.push(k.range(l.anchor-a,l.head-a))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:k.create(n,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}var QC=({state:t,dispatch:e})=>zg(t,e,!1),$C=({state:t,dispatch:e})=>zg(t,e,!0);function Ng(t,e,i){if(t.readOnly)return!1;let r=[];for(let n of ko(t))i?r.push({from:n.from,insert:t.doc.slice(n.from,n.to)+t.lineBreak}):r.push({from:n.to,insert:t.lineBreak+t.doc.slice(n.from,n.to)});return e(t.update({changes:r,scrollIntoView:!0,userEvent:"input.copyline"})),!0}var PC=({state:t,dispatch:e})=>Ng(t,e,!1),TC=({state:t,dispatch:e})=>Ng(t,e,!0),CC=t=>{if(t.state.readOnly)return!1;let{state:e}=t,i=e.changes(ko(e).map(({from:n,to:s})=>(n>0?n--:s<e.doc.length&&s++,{from:n,to:s}))),r=wr(e.selection,n=>{let s;if(t.lineWrapping){let o=t.lineBlockAt(n.head),a=t.coordsAtPos(n.head,n.assoc||1);a&&(s=o.bottom+t.documentTop-a.bottom+t.defaultLineHeight/2)}return t.moveVertically(n,!0,s)}).map(i);return t.dispatch({changes:i,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function ZC(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let i=I(t).resolveInner(e),r=i.childBefore(e),n=i.childAfter(e),s;return r&&n&&r.to<=e&&n.from>=e&&(s=r.type.prop(j.closedBy))&&s.indexOf(n.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(n.from).from&&!/\S/.test(t.sliceDoc(r.to,n.from))?{from:r.to,to:n.from}:null}var Ig=Gg(!1),AC=Gg(!0);function Gg(t){return({state:e,dispatch:i})=>{if(e.readOnly)return!1;let r=e.changeByRange(n=>{let{from:s,to:o}=n,a=e.doc.lineAt(s),l=!t&&s==o&&ZC(e,s);t&&(s=o=(o<=a.to?a:e.doc.lineAt(o)).to);let h=new Hs(e,{simulateBreak:s,simulateDoubleBreak:!!l}),c=ql(h,s);for(c==null&&(c=Gi(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));o<a.to&&/\s/.test(a.text[o-a.from]);)o++;l?{from:s,to:o}=l:s>a.from&&s<a.from+100&&!/\S/.test(a.text.slice(0,s))&&(s=a.from);let f=["",fn(e,c)];return l&&f.push(fn(e,h.lineIndent(a.from,-1))),{changes:{from:s,to:o,insert:F.of(f)},range:k.cursor(s+1+f[1].length)}});return i(e.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function Vh(t,e){let i=-1;return t.changeByRange(r=>{let n=[];for(let o=r.from;o<=r.to;){let a=t.doc.lineAt(o);a.number>i&&(r.empty||r.to>a.from)&&(e(a,n,r),i=a.number),o=a.to+1}let s=t.changes(n);return{changes:n,range:k.range(s.mapPos(r.anchor,1),s.mapPos(r.head,1))}})}var RC=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=Object.create(null),r=new Hs(t,{overrideIndentation:s=>{let o=i[s];return o==null?-1:o}}),n=Vh(t,(s,o,a)=>{let l=ql(r,s.from);if(l==null)return;/\S/.test(s.text)||(l=0);let h=/^\s*/.exec(s.text)[0],c=fn(t,l);(h!=c||a.from<s.from+h.length)&&(i[s.from]=l,o.push({from:s.from,to:s.from+h.length,insert:c}))});return n.changes.empty||e(t.update(n,{userEvent:"indent"})),!0},_h=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Vh(t,(i,r)=>{r.push({from:i.from,insert:t.facet(ur)})}),{userEvent:"input.indent"})),!0),Bh=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Vh(t,(i,r)=>{let n=/^\s*/.exec(i.text)[0];if(!n)return;let s=Gi(n,t.tabSize),o=0,a=fn(t,Math.max(0,s-Ri(t)));for(;o<n.length&&o<a.length&&n.charCodeAt(o)==a.charCodeAt(o);)o++;r.push({from:i.from+o,to:i.from+n.length,insert:a.slice(o)})}),{userEvent:"delete.dedent"})),!0),XC=t=>(t.setTabFocusMode(),!0),WC=[{key:"Ctrl-b",run:gg,shift:Pg,preventDefault:!0},{key:"Ctrl-f",run:bg,shift:Tg},{key:"Ctrl-p",run:Sg,shift:Ag},{key:"Ctrl-n",run:kg,shift:Rg},{key:"Ctrl-a",run:JT,shift:fC},{key:"Ctrl-e",run:eC,shift:uC},{key:"Ctrl-d",run:Bg},{key:"Ctrl-h",run:Yh},{key:"Ctrl-k",run:yC},{key:"Ctrl-Alt-h",run:jg},{key:"Ctrl-o",run:wC},{key:"Ctrl-t",run:xC},{key:"Ctrl-v",run:Dh}],MC=[{key:"ArrowLeft",run:gg,shift:Pg,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:jT,shift:rC,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:HT,shift:hC,preventDefault:!0},{key:"ArrowRight",run:bg,shift:Tg,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:zT,shift:nC,preventDefault:!0},{mac:"Cmd-ArrowRight",run:KT,shift:cC,preventDefault:!0},{key:"ArrowUp",run:Sg,shift:Ag,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Eg,shift:Dg},{mac:"Ctrl-ArrowUp",run:Qg,shift:Wg},{key:"ArrowDown",run:kg,shift:Rg,preventDefault:!0},{mac:"Cmd-ArrowDown",run:qg,shift:Yg},{mac:"Ctrl-ArrowDown",run:Dh,shift:Mg},{key:"PageUp",run:Qg,shift:Wg},{key:"PageDown",run:Dh,shift:Mg},{key:"Home",run:FT,shift:lC,preventDefault:!0},{key:"Mod-Home",run:Eg,shift:Dg},{key:"End",run:UT,shift:aC,preventDefault:!0},{key:"Mod-End",run:qg,shift:Yg},{key:"Enter",run:Ig,shift:Ig},{key:"Mod-a",run:dC},{key:"Backspace",run:Yh,shift:Yh,preventDefault:!0},{key:"Delete",run:Bg,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:jg,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:vC,preventDefault:!0},{mac:"Mod-Backspace",run:SC,preventDefault:!0},{mac:"Mod-Delete",run:kC,preventDefault:!0}].concat(WC.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),EC=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:IT,shift:sC},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:GT,shift:oC},{key:"Alt-ArrowUp",run:QC},{key:"Shift-Alt-ArrowUp",run:PC},{key:"Alt-ArrowDown",run:$C},{key:"Shift-Alt-ArrowDown",run:TC},{key:"Mod-Alt-ArrowUp",run:mC},{key:"Mod-Alt-ArrowDown",run:gC},{key:"Escape",run:bC},{key:"Mod-Enter",run:AC},{key:"Alt-l",mac:"Ctrl-l",run:pC},{key:"Mod-i",run:OC,preventDefault:!0},{key:"Mod-[",run:Bh},{key:"Mod-]",run:_h},{key:"Mod-Alt-\\",run:RC},{key:"Shift-Mod-k",run:CC},{key:"Shift-Mod-\\",run:iC},{key:"Mod-/",run:QT},{key:"Alt-A",run:PT},{key:"Ctrl-m",mac:"Shift-Alt-m",run:XC}].concat(MC),qC={key:"Tab",run:_h,shift:Bh},Ug=class{constructor(t,e,i){this.from=t,this.to=e,this.diagnostic=i}},Cn=class Wy{constructor(e,i,r){this.diagnostics=e,this.panel=i,this.selected=r}static init(e,i,r){let n=r.facet(Dt).markerFilter;n&&(e=n(e,r));let s=e.slice().sort((d,p)=>d.from-p.from||d.to-p.to),o=new jt,a=[],l=0,h=r.doc.iter(),c=0,f=r.doc.length;for(let d=0;;){let p=d==s.length?null:s[d];if(!p&&!a.length)break;let O,g;if(a.length)O=l,g=a.reduce((v,S)=>Math.min(v,S.to),p&&p.from>O?p.from:1e8);else{if(O=p.from,O>f)break;g=p.to,a.push(p),d++}for(;d<s.length;){let v=s[d];if(v.from==O&&(v.to>v.from||v.to==O))a.push(v),d++,g=Math.min(v.to,g);else{g=Math.min(v.from,g);break}}g=Math.min(g,f);let b=!1;if(a.some(v=>v.from==O&&(v.to==g||g==f))&&(b=O==g,!b&&g-O<10)){let v=O-(c+h.value.length);v>0&&(h.next(v),c=O);for(let S=O;;){if(S>=g){b=!0;break}if(!h.lineBreak&&c+h.value.length>S)break;S=c+h.value.length,c+=h.value.length,h.next()}}let y=o0(a);if(b)o.add(O,O,A.widget({widget:new NC(y),diagnostics:a.slice()}));else{let v=a.reduce((S,w)=>w.markClass?S+" "+w.markClass:S,"");o.add(O,g,A.mark({class:"cm-lintRange cm-lintRange-"+y+v,diagnostics:a.slice(),inclusiveEnd:a.some(S=>S.to>g)}))}if(l=g,l==f)break;for(let v=0;v<a.length;v++)a[v].to<=l&&a.splice(v--,1)}let u=o.finish();return new Wy(u,i,xr(u))}};function xr(t,e=null,i=0){let r=null;return t.between(i,1e9,(n,s,{spec:o})=>{if(!(e&&o.diagnostics.indexOf(e)<0))if(!r)r=new Ug(n,s,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new Ug(r.from,s,r.diagnostic)}}),r}function Fg(t,e){let i=e.pos,r=e.end||i,n=t.state.facet(Dt).hideOn(t,i,r);if(n!=null)return n;let s=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(o=>o.is(Zn))||t.changes.touchesRange(s.from,Math.max(s.to,r)))}function Hg(t,e){return t.field(Ge,!1)?e:e.concat(B.appendConfig.of(h0))}function DC(t,e){return{effects:Hg(t,[Zn.of(e)])}}var Zn=B.define(),Lh=B.define(),Kg=B.define(),Ge=ve.define({create(){return new Cn(A.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let i=t.diagnostics.map(e.changes),r=null,n=t.panel;if(t.selected){let s=e.changes.mapPos(t.selected.from,1);r=xr(i,t.selected.diagnostic,s)||xr(i,null,s)}!i.size&&n&&e.state.facet(Dt).autoPanel&&(n=null),t=new Cn(i,n,r)}for(let i of e.effects)if(i.is(Zn)){let r=e.state.facet(Dt).autoPanel?i.value.length?jh.open:null:t.panel;t=Cn.init(i.value,r,e.state)}else i.is(Lh)?t=new Cn(t.diagnostics,i.value?jh.open:null,t.selected):i.is(Kg)&&(t=new Cn(t.diagnostics,t.panel,i.value));return t},provide:t=>[rr.from(t,e=>e.panel),x.decorations.from(t,e=>e.diagnostics)]}),YC=A.mark({class:"cm-lintRange cm-lintRange-active"});function VC(t,e,i){let{diagnostics:r}=t.state.field(Ge),n,s=-1,o=-1;r.between(e-(i<0?1:0),e+(i>0?1:0),(l,h,{spec:c})=>{if(e>=l&&e<=h&&(l==h||(e>l||i>0)&&(e<h||i<0)))return n=c.diagnostics,s=l,o=h,!1});let a=t.state.facet(Dt).tooltipFilter;return n&&a&&(n=a(n,t.state)),n?{pos:s,end:o,above:t.state.doc.lineAt(s).to<o,create(){return{dom:Jg(t,n)}}}:null}function Jg(t,e){return Y("ul",{class:"cm-tooltip-lint"},e.map(i=>n0(t,i,!1)))}var _C=t=>{let e=t.state.field(Ge,!1);(!e||!e.panel)&&t.dispatch({effects:Hg(t.state,[Lh.of(!0)])});let i=Jr(t,jh.open);return i&&i.dom.querySelector(".cm-panel-lint ul").focus(),!0},e0=t=>{let e=t.state.field(Ge,!1);return!e||!e.panel?!1:(t.dispatch({effects:Lh.of(!1)}),!0)},t0=t=>{let e=t.state.field(Ge,!1);if(!e)return!1;let i=t.state.selection.main,r=e.diagnostics.iter(i.to+1);return!r.value&&(r=e.diagnostics.iter(0),!r.value||r.from==i.from&&r.to==i.to)?!1:(t.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)},BC=[{key:"Mod-Shift-m",run:_C,preventDefault:!0},{key:"F8",run:t0}],LC=be.fromClass(class{constructor(t){this.view=t,this.timeout=-1,this.set=!0;let{delay:e}=t.state.facet(Dt);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){clearTimeout(this.timeout);let t=Date.now();if(t<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-t);else{this.set=!1;let{state:e}=this.view,{sources:i}=e.facet(Dt);i.length&&jC(i.map(r=>Promise.resolve(r(this.view))),r=>{this.view.state.doc==e.doc&&this.view.dispatch(DC(this.view.state,r.reduce((n,s)=>n.concat(s))))},r=>{Ee(this.view.state,r)})}}update(t){let e=t.state.facet(Dt);(t.docChanged||e!=t.startState.facet(Dt)||e.needsRefresh&&e.needsRefresh(t))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function jC(t,e,i){let r=[],n=-1;for(let s of t)s.then(o=>{r.push(o),clearTimeout(n),r.length==t.length?e(r):n=setTimeout(()=>e(r),200)},i)}var Dt=R.define({combine(t){return{sources:t.map(e=>e.source).filter(e=>e!=null),...mt(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:i0,tooltipFilter:i0,needsRefresh:(e,i)=>e?i?r=>e(r)||i(r):e:i,hideOn:(e,i)=>e?i?(r,n,s)=>e(r,n,s)||i(r,n,s):e:i,autoPanel:(e,i)=>e||i})}}});function i0(t,e){return t?e?(i,r)=>e(t(i,r),r):t:e}function zC(t,e={}){return[Dt.of({source:t,config:e}),LC,h0]}function r0(t){let e=[];if(t)e:for(let{name:i}of t){for(let r=0;r<i.length;r++){let n=i[r];if(/[a-zA-Z]/.test(n)&&!e.some(s=>s.toLowerCase()==n.toLowerCase())){e.push(n);continue e}}e.push("")}return e}function n0(t,e,i){var r;let n=i?r0(e.actions):[];return Y("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},Y("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(r=e.actions)===null||r===void 0?void 0:r.map((s,o)=>{let a=!1,l=d=>{if(d.preventDefault(),a)return;a=!0;let p=xr(t.state.field(Ge).diagnostics,e);p&&s.apply(t,p.from,p.to)},{name:h}=s,c=n[o]?h.indexOf(n[o]):-1,f=c<0?h:[h.slice(0,c),Y("u",h.slice(c,c+1)),h.slice(c+1)],u=s.markClass?" "+s.markClass:"";return Y("button",{type:"button",class:"cm-diagnosticAction"+u,onclick:l,onmousedown:l,"aria-label":` Action: ${h}${c<0?"":` (access key "${n[o]})"`}.`},f)}),e.source&&Y("div",{class:"cm-diagnosticSource"},e.source))}var NC=class extends gt{constructor(t){super(),this.sev=t}eq(t){return t.sev==this.sev}toDOM(){return Y("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}},s0=class{constructor(t,e){this.diagnostic=e,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=n0(t,e,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},jh=class My{constructor(e){this.view=e,this.items=[];let i=n=>{if(n.keyCode==27)e0(this.view),this.view.focus();else if(n.keyCode==38||n.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(n.keyCode==40||n.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(n.keyCode==36)this.moveSelection(0);else if(n.keyCode==35)this.moveSelection(this.items.length-1);else if(n.keyCode==13)this.view.focus();else if(n.keyCode>=65&&n.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],o=r0(s.actions);for(let a=0;a<o.length;a++)if(o[a].toUpperCase().charCodeAt(0)==n.keyCode){let l=xr(this.view.state.field(Ge).diagnostics,s);l&&s.actions[a].apply(e,l.from,l.to)}}else return;n.preventDefault()},r=n=>{for(let s=0;s<this.items.length;s++)this.items[s].dom.contains(n.target)&&this.moveSelection(s)};this.list=Y("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:i,onclick:r}),this.dom=Y("div",{class:"cm-panel-lint"},this.list,Y("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>e0(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(Ge).selected;if(!e)return-1;for(let i=0;i<this.items.length;i++)if(this.items[i].diagnostic==e.diagnostic)return i;return-1}update(){let{diagnostics:e,selected:i}=this.view.state.field(Ge),r=0,n=!1,s=null,o=new Set;for(e.between(0,this.view.state.doc.length,(a,l,{spec:h})=>{for(let c of h.diagnostics){if(o.has(c))continue;o.add(c);let f=-1,u;for(let d=r;d<this.items.length;d++)if(this.items[d].diagnostic==c){f=d;break}f<0?(u=new s0(this.view,c),this.items.splice(r,0,u),n=!0):(u=this.items[f],f>r&&(this.items.splice(r,f-r),n=!0)),i&&u.diagnostic==i.diagnostic?u.dom.hasAttribute("aria-selected")||(u.dom.setAttribute("aria-selected","true"),s=u):u.dom.hasAttribute("aria-selected")&&u.dom.removeAttribute("aria-selected"),r++}});r<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)n=!0,this.items.pop();this.items.length==0&&(this.items.push(new s0(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),n=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:()=>({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:a,panel:l})=>{let h=l.height/this.list.offsetHeight;a.top<l.top?this.list.scrollTop-=(l.top-a.top)/h:a.bottom>l.bottom&&(this.list.scrollTop+=(a.bottom-l.bottom)/h)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),n&&this.sync()}sync(){let e=this.list.firstChild;function i(){let r=e;e=r.nextSibling,r.remove()}for(let r of this.items)if(r.dom.parentNode==this.list){for(;e!=r.dom;)i();e=r.dom.nextSibling}else this.list.insertBefore(r.dom,e);for(;e;)i()}moveSelection(e){if(this.selectedIndex<0)return;let i=this.view.state.field(Ge),r=xr(i.diagnostics,this.items[e].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:Kg.of(r)})}static open(e){return new My(e)}};function wo(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}function xo(t){return wo(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}var IC=x.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:xo("#d11")},".cm-lintRange-warning":{backgroundImage:xo("orange")},".cm-lintRange-info":{backgroundImage:xo("#999")},".cm-lintRange-hint":{backgroundImage:xo("#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}}});function GC(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function o0(t){let e="hint",i=1;for(let r of t){let n=GC(r.severity);n>i&&(i=n,e=r.severity)}return e}var a0=class extends yt{constructor(t){super(),this.diagnostics=t,this.severity=o0(t)}toDOM(t){let e=document.createElement("div");e.className="cm-lint-marker cm-lint-marker-"+this.severity;let i=this.diagnostics,r=t.state.facet(Qo).tooltipFilter;return r&&(i=r(i,t.state)),i.length&&(e.onmouseover=()=>FC(t,e,i)),e}};function UC(t,e){let i=r=>{let n=e.getBoundingClientRect();if(!(r.clientX>n.left-10&&r.clientX<n.right+10&&r.clientY>n.top-10&&r.clientY<n.bottom+10)){for(let s=r.target;s;s=s.parentNode)if(s.nodeType==1&&s.classList.contains("cm-tooltip-lint"))return;window.removeEventListener("mousemove",i),t.state.field(l0)&&t.dispatch({effects:Nh.of(null)})}};window.addEventListener("mousemove",i)}function FC(t,e,i){function r(){let o=t.elementAtHeight(e.getBoundingClientRect().top+5-t.documentTop);t.coordsAtPos(o.from)&&t.dispatch({effects:Nh.of({pos:o.from,above:!1,clip:!1,create(){return{dom:Jg(t,i),getCoords:()=>e.getBoundingClientRect()}}})}),e.onmouseout=e.onmousemove=null,UC(t,e)}let{hoverTime:n}=t.state.facet(Qo),s=setTimeout(r,n);e.onmouseout=()=>{clearTimeout(s),e.onmouseout=e.onmousemove=null},e.onmousemove=()=>{clearTimeout(s),s=setTimeout(r,n)}}function HC(t,e){let i=Object.create(null);for(let n of e){let s=t.lineAt(n.from);(i[s.from]||(i[s.from]=[])).push(n)}let r=[];for(let n in i)r.push(new a0(i[n]).range(+n));return ne.of(r,!0)}var KC=fl({class:"cm-gutter-lint",markers:t=>t.state.field(zh),widgetMarker:(t,e,i)=>{let r=[];return t.state.field(zh).between(i.from,i.to,(n,s,o)=>{n>i.from&&n<i.to&&r.push(...o.diagnostics)}),r.length?new a0(r):null}}),zh=ve.define({create(){return ne.empty},update(t,e){t=t.map(e.changes);let i=e.state.facet(Qo).markerFilter;for(let r of e.effects)if(r.is(Zn)){let n=r.value;i&&(n=i(n||[],e.state)),t=HC(e.state.doc,n.slice(0))}return t}}),Nh=B.define(),l0=ve.define({create(){return null},update(t,e){return t&&e.docChanged&&(t=Fg(e,t)?null:{...t,pos:e.changes.mapPos(t.pos)}),e.effects.reduce((i,r)=>r.is(Nh)?r.value:i,t)},provide:t=>ir.from(t)}),JC=x.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:wo('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:wo('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:wo('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),h0=[Ge,x.decorations.compute([Ge],t=>{let{selected:e,panel:i}=t.field(Ge);return!e||!i||e.from==e.to?A.none:A.set([YC.range(e.from,e.to)])}),cl(VC,{hideOn:Fg}),IC],Qo=R.define({combine(t){return mt(t,{hoverTime:300,markerFilter:null,tooltipFilter:null})}});function eZ(t={}){return[Qo.of(t),zh,KC,JC,l0]}var Ih="#2e3440",c0="#3b4252",f0="#434c5e",Qr="#4c566a",An="#d8dee9",tZ="#e5e9f0",iZ="#eceff4",qi="#8fbcbb",u0="#88c0d0",rZ="#81a1c1",Yt="#5e81ac",nZ="#bf616a",d0="#d08770",Gh="#ebcb8b",$o="#a3be8c",Uh="#b48ead",p0="#d30102",sZ="#252a33",Fh=Qr,oZ=Ih,Hh=c0,aZ=Qr,O0=An,lZ=x.theme({"&":{color:An,backgroundColor:oZ},".cm-content":{caretColor:O0},".cm-cursor, .cm-dropCursor":{borderLeftColor:O0},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:aZ},".cm-panels":{backgroundColor:sZ,color:Qr},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"transparent",outline:`1px solid ${qi}`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:An,color:Ih},".cm-activeLine":{backgroundColor:Fh},".cm-selectionMatch":{backgroundColor:tZ,color:c0},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{outline:`1px solid ${qi}`},"&.cm-focused .cm-matchingBracket":{backgroundColor:iZ,color:f0},".cm-gutters":{backgroundColor:Ih,color:Qr,border:"none"},".cm-activeLineGutter":{backgroundColor:Fh,color:An},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:Hh},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Hh,borderBottomColor:Hh},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Fh,color:Qr}}},{dark:!0}),hZ=eo.define([{tag:m.keyword,color:Yt},{tag:[m.name,m.deleted,m.character,m.propertyName,m.macroName],color:u0},{tag:[m.variableName],color:qi},{tag:[m.function(m.variableName)],color:qi},{tag:[m.labelName],color:rZ},{tag:[m.color,m.constant(m.name),m.standard(m.name)],color:Yt},{tag:[m.definition(m.name),m.separator],color:$o},{tag:[m.brace],color:qi},{tag:[m.annotation],color:p0},{tag:[m.number,m.changed,m.annotation,m.modifier,m.self,m.namespace],color:Uh},{tag:[m.typeName,m.className],color:Gh},{tag:[m.operator,m.operatorKeyword],color:$o},{tag:[m.tagName],color:Uh},{tag:[m.squareBracket],color:nZ},{tag:[m.angleBracket],color:d0},{tag:[m.attributeName],color:Gh},{tag:[m.regexp],color:Yt},{tag:[m.quote],color:Uh},{tag:[m.string],color:$o},{tag:m.link,color:$o,textDecoration:"underline",textUnderlinePosition:"under"},{tag:[m.url,m.escape,m.special(m.string)],color:qi},{tag:[m.meta],color:u0},{tag:[m.monospace],color:An,fontStyle:"italic"},{tag:[m.comment],color:Qr,fontStyle:"italic"},{tag:m.strong,fontWeight:"bold",color:Yt},{tag:m.emphasis,fontStyle:"italic",color:Yt},{tag:m.strikethrough,textDecoration:"line-through"},{tag:m.heading,fontWeight:"bold",color:Yt},{tag:m.special(m.heading1),fontWeight:"bold",color:Yt},{tag:m.heading1,fontWeight:"bold",color:Yt},{tag:[m.heading2,m.heading3,m.heading4],fontWeight:"bold",color:Yt},{tag:[m.heading5,m.heading6],color:Yt},{tag:[m.atom,m.bool,m.special(m.variableName)],color:d0},{tag:[m.processingInstruction,m.inserted],color:qi},{tag:[m.contentSeparator],color:Gh},{tag:m.invalid,color:f0,borderBottom:`1px dotted ${p0}`}]),cZ=[lZ,jl(hZ)],Po="&.cm-focused",m0=`${Po} .${Fm}`,g0=`${Po} .${Hm}`,b0=`${Sr} code`,v0=`${kr}>div:hover`,y0=x.theme({"&":{backgroundColor:"#fff","--cm-arg":"#b0c","--cm-attr":"#179b1c","--cm-comment":"#7b8c8f","--cm-convert":"#b68","--cm-entity":"#00a1a1","--cm-error":"#d73333","--cm-func":"#a11","--cm-hr":"#0076dd","--cm-hr-bg":"rgb(0,0,0,.07)","--cm-link":"#000aaa","--cm-sect":"#006fe6","--cm-sp":"rgb(134,206,255,.3)","--cm-table":"#d08","--cm-table-attr":"#f500d4","--cm-tag":"#14866d","--cm-tpl":"#80c","--cm-var":"#ad9300","--cm-var-name":"#ac6600","--cm-ref":"rgb(223,242,235,.5)"},[m0]:{backgroundColor:"rgb(50,140,130,.32)"},[g0]:{backgroundColor:"rgb(187,85,85,.27)"},[b0]:{backgroundColor:"#e0e6eb"},[kr]:{backgroundColor:"#f5f5f5",boxShadow:"0 2px 2px 0 rgb(0,0,0,.25)"},[v0]:{backgroundColor:"#e2f2ff"},[xn]:{borderColor:"#c8ccd1"}}),fZ=[cZ,x.theme({"&":{"--cm-arg":"#9f78a5","--cm-attr":"#97b757","--cm-comment":"#4c566a","--cm-convert":"#b68","--cm-entity":"#00a1a1","--cm-error":"#bf616a","--cm-func":"#bf616a","--cm-hr":"#5e81ac","--cm-hr-bg":"#3b4252","--cm-link":"#5e81ac","--cm-sect":"#81a1c1","--cm-sp":"#88c0d0","--cm-table":"#b48ead","--cm-table-attr":"#9f78a5","--cm-tag":"#a3be8c","--cm-tpl":"#9f78a5","--cm-var":"#d08770","--cm-var-name":"#d08770","--cm-ref":"rgb(60,90,80,0.5)"},"div.cm-activeLine":{backgroundColor:"rgb(76,86,106,.27)"},[m0]:{backgroundColor:"#eceff4",color:"#434c5e"},[g0]:{backgroundColor:"rgb(235,203,139,.32)"},[`${Po}>.cm-scroller>.cm-selectionLayer div.cm-selectionBackground, ${b0}, ${v0}, ${Ah}, div${yr}`]:{backgroundColor:"#4c566a"},[`div${Gm}`]:{color:"#d8dee9"},[kr]:{backgroundColor:"#252a33"},[xn]:{borderColor:"#000"},[`${Po} .cm-searchMatch.cm-searchMatch-selected`]:{color:"#b48ead"},"div.cm-tooltip-autocomplete ul li[aria-selected]":{color:"inherit"},"div.cm-gutters":{color:"#5e81ac"}})],Kh=()=>x.contentAttributes.of({spellcheck:"true"}),Ht={plain:Kh},Be={},To={},Jh=[],S0=[],ec={light:y0},at={statusBar(){return[]},detectIndent(t,e){return e},foldHandler(){return()=>{}}},uZ=new Set(["closeBrackets","autocompletion","signatureHelp"]),Rn={},tc={},Xn=(Sv=class{constructor(t,e="plain",i,r=!0){xe(this,we);xe(this,ct);xe(this,In,new Ot);xe(this,_i,new Ot);xe(this,Gn,new Ot);xe(this,Un,new Ot);xe(this,Fn,new Ot);xe(this,Hn,new Ot);xe(this,Kn,new Ot);xe(this,Jn,new Ot);xe(this,es,new Ot);xe(this,V);xe(this,Fe);xe(this,Si,!1);xe(this,ki,new Set);xe(this,Rr," ");xe(this,ts);ut(this,ct,t),ut(this,Fe,e),r&&this.initialize(i)}get textarea(){return Q(this,ct)}get view(){return Q(this,V)}get lang(){return Q(this,Fe)}get visible(){return Q(this,Si)&&this.textarea.isConnected}initialize(t){var p;let e;const{textarea:i,lang:r}=this,{value:n,dir:s,accessKey:o,tabIndex:a,lang:l,readOnly:h}=i,c=[Q(this,In).of(Qe(this,we,Fc).call(this,t)),Q(this,_i).of((p=Rn[r])!=null?p:[]),Q(this,Gn).of([]),Q(this,Un).of(x.editorAttributes.of({dir:s})),Q(this,Hn).of([]),Q(this,Kn).of(fe.phrases.of(tc)),Q(this,Jn).of(x.lineWrapping),Q(this,es).of(y0),jl(xx),x.contentAttributes.of({accesskey:o,tabindex:String(a)}),x.editorAttributes.of({lang:l}),j1(),I1(),et.of([...EC,...ww,{key:"Mod-Shift-x",run:()=>{const O=i.dir==="rtl"?"ltr":"rtl";return i.dir=O,Qe(this,we,Jt).call(this,Q(this,Un).reconfigure(x.editorAttributes.of({dir:O}))),!0}}]),x.theme({[Gm]:{direction:document.dir},"& .cm-lineNumbers .cm-gutterElement":{textAlign:"end"},[`.cm-textfield,.cm-button,${po}.cm-search label,${po}.cm-gotoLine label`]:{fontSize:"inherit"},[`${po} [name="close"]`]:{color:"inherit"}}),x.updateListener.of(({state:{doc:O},startState:{doc:g},docChanged:b,focusChanged:y})=>{b&&(clearTimeout(e),e=setTimeout(()=>{i.value=O.toString(),i.dispatchEvent(new Event("input"))},400),g.toString().trim()||this.setIndent(Q(this,Rr))),y&&i.dispatchEvent(new Event(Q(this,V).hasFocus?"focus":"blur"))}),...h?[fe.readOnly.of(!0),fe.transactionFilter.of(O=>O.docChanged?[]:O),x.theme({'input[type="color"]':{pointerEvents:"none"}})]:[WT(),lx(),Q(this,Fn).of(ur.of(at.detectIndent(n,Q(this,Rr),r))),et.of([...LT,qC,{win:"Ctrl-Shift-z",run:go,preventDefault:!0}])]];ut(this,V,new x({extensions:c,doc:n}));const{fontSize:f,lineHeight:u,border:d}=getComputedStyle(i);i.before(Q(this,V).dom),Qe(this,we,Uo).call(this),Q(this,V).dom.style.border=d,Q(this,V).scrollDOM.style.fontSize=f,Q(this,V).scrollDOM.style.lineHeight=u,this.toggle(!0),Q(this,V).dom.addEventListener("click",at.foldHandler(Q(this,V))),this.prefer({})}async setLanguage(t="plain",e){var i;if(ut(this,Fe,t),Q(this,V)){const r=Qe(this,we,Fc).call(this,e);Qe(this,we,Jt).call(this,[Q(this,In).reconfigure(r),Q(this,_i).reconfigure((i=Rn[t])!=null?i:[])]),Qe(this,we,Uo).call(this,!!Rn[t]),this.prefer({})}}lint(t){const e=typeof t=="function"?[t]:t,i=e?[...e.map(r=>zC(async({state:n})=>{const s=(await r(n)).map(o=>({...o,renderMessage(a){const l=Y("span",{class:Um.slice(1)},o.message);return l.addEventListener("click",()=>{a.dispatch({selection:{anchor:o.from,head:o.to}}),a.focus()}),l}}));if(n.readOnly)for(const o of s)delete o.actions;return s})),eZ(),et.of(BC),at.statusBar(this,e[0].fixer)]:[];t?Rn[Q(this,Fe)]=i:delete Rn[Q(this,Fe)],Q(this,V)&&(Qe(this,we,Jt).call(this,Q(this,_i).reconfigure(i)),Qe(this,we,Uo).call(this,!!t))}update(){if(Q(this,V)){const t=Qe(this,we,Ey).call(this);if(t){const e=Q(this,V).plugin(t[1]);e.set=!0,e.force()}}}hasPreference(t){return Q(this,ki).has(t)}prefer(t){if(Array.isArray(t))ut(this,ki,new Set(t.filter(e=>Object.prototype.hasOwnProperty.call(Be,e))));else for(const[e,i]of Object.entries(t))i&&Object.prototype.hasOwnProperty.call(Be,e)?Q(this,ki).add(e):Q(this,ki).delete(e);if(Q(this,V)){const{readOnly:e}=Q(this,V).state;Qe(this,we,Jt).call(this,Q(this,Gn).reconfigure([...Q(this,ki)].filter(i=>!e||!uZ.has(i)).map(i=>{const[r,n={}]=Be[i];return r(n[Q(this,Fe)],this)})))}}setIndent(t){Q(this,V)?Qe(this,we,Jt).call(this,Q(this,Fn).reconfigure(ur.of(at.detectIndent(Q(this,V).state.doc,t,Q(this,Fe))))):ut(this,Rr,t)}setLineWrapping(t){Q(this,V)&&Qe(this,we,Jt).call(this,Q(this,Jn).reconfigure(t?x.lineWrapping:[]))}async getLinter(t){var e;return(e=To[Q(this,Fe)])==null?void 0:e.call(To,t,Q(this,V),Q(this,ts))}setContent(t,e){Q(this,V)&&Q(this,V).dispatch({changes:{from:0,to:Q(this,V).state.doc.length,insert:t},filter:!e})}toggle(t=!Q(this,Si)){if(Q(this,V)){if(t&&!Q(this,Si)){const{value:e,selectionStart:i,selectionEnd:r,scrollTop:n,offsetHeight:s,style:{height:o}}=Q(this,ct),a=document.activeElement===Q(this,ct);this.setContent(e),Q(this,V).dom.style.height=s?`${s}px`:o,Q(this,V).dom.style.removeProperty("display"),Q(this,ct).style.display="none",Q(this,V).requestMeasure(),Q(this,V).dispatch({selection:{anchor:i,head:r}}),a&&Q(this,V).focus(),requestAnimationFrame(()=>{Q(this,V).scrollDOM.scrollTop=n})}else if(!t&&Q(this,Si)){const{state:{selection:{main:{from:e,to:i,head:r}}},hasFocus:n}=Q(this,V),{scrollDOM:{scrollTop:s}}=Q(this,V);Q(this,V).dom.style.setProperty("display","none","important"),Q(this,ct).style.display="",Q(this,ct).setSelectionRange(e,i,r===i?"forward":"backward"),n&&Q(this,ct).focus(),requestAnimationFrame(()=>{Q(this,ct).scrollTop=s})}}else return;ut(this,Si,t)}destroy(){if(this.visible&&this.toggle(!1),Q(this,V)){for(const t of S0)t(Q(this,V));Q(this,V).destroy()}Object.setPrototypeOf(this,null)}extraKeys(t){Q(this,V)&&Qe(this,we,Jt).call(this,Q(this,Hn).reconfigure(et.of(t)))}localize(t){Object.assign(tc,t),Q(this,V)&&Qe(this,we,Jt).call(this,Q(this,Kn).reconfigure(fe.phrases.of(tc)))}getNodeAt(t){var e;return Q(this,V)&&((e=fi(Q(this,V).state,t))==null?void 0:e.resolveInner(t,1))}scrollTo(t){if(Q(this,V)){const e=t!=null?t:Q(this,V).state.selection.main,i=x.scrollIntoView(typeof e=="number"||e instanceof Er?e:k.range(e.anchor,e.head));i.value.isSnapshot=!0,Q(this,V).dispatch({effects:i})}}setTheme(t){var e;t in ec&&((e=Q(this,V))==null||e.dispatch({effects:Q(this,es).reconfigure(ec[t])}))}static replaceSelections(t,e){const{state:i}=t;t.dispatch(i.changeByRange(({from:r,to:n})=>{const s=e(i.sliceDoc(r,n),{from:r,to:n});if(typeof s=="string")return{range:k.range(r,r+s.length),changes:{from:r,to:n,insert:s}};const[o,a,l=a]=s;return{range:k.range(a,l),changes:{from:r,to:n,insert:o}}}))}},ct=new WeakMap,In=new WeakMap,_i=new WeakMap,Gn=new WeakMap,Un=new WeakMap,Fn=new WeakMap,Hn=new WeakMap,Kn=new WeakMap,Jn=new WeakMap,es=new WeakMap,V=new WeakMap,Fe=new WeakMap,Si=new WeakMap,ki=new WeakMap,Rr=new WeakMap,ts=new WeakMap,we=new WeakSet,Fc=function(t){var i;const e=((i=Ht[Q(this,Fe)])!=null?i:Kh)(t);return ut(this,ts,e.nestedMWLanguage),Q(this,Fe)==="mediawiki"&&(this.langConfig=t),e},Jt=function(t){Q(this,V).dispatch({effects:t})},Uo=function(t){Q(this,V).dom.style.minHeight=t?"calc(100px + 2em)":"2em"},Ey=function(){return Q(this,_i).get(Q(this,V).state)[0]},Sv),dZ=(t,e,i,r,n)=>!/mw-(?:(?:ext|html)tag-attribute-value|table-definition)/u.test(r)&&(!/mw-(?:template|parserfunction)(?:$|_)/u.test(r)||!/[|=]/u.test(n.sliceString(e-1,e))||!/[|\n]/u.test(n.sliceString(i,i+1))&&n.sliceString(i,i+2)!=="}}")&&(!/mw-templatevariable(?:$|_)/u.test(r)||n.sliceString(e-1,e)!=="|"||n.sliceString(i,i+1)!=="|"&&n.sliceString(i,i+3)!=="}}}")?null:bT(n.sliceString(e,i)).filter(([,,,s])=>s).map(([s,o,a])=>{const l=s.startsWith("#")?qm(s):Em(s);let h=l==null?void 0:l.alpha;return(l==null?void 0:l.colorType)!==wt.hex&&h&&(h=mT(parseFloat(h.slice(1))/(h.endsWith("%")?100:1))),l&&{...l,colorType:wt.hex,alpha:h!=null?h:"",from:e+o,to:e+a}}).filter(Boolean),pZ=(([t,e]=[])=>t?[t,x.theme({[`.${vr}`]:{outline:"none",...e},[`.${vr} input[type="color"]`]:{outline:"1px solid #eee"}})]:[]),k0={'"':"quot","'":"apos","<":"lt",">":"gt","&":"amp"," ":"nbsp"},w0=(t,e)=>i=>i.state.selection.ranges.some(({empty:r})=>!r)?(Xn.replaceSelections(i,t),!0):e(i),x0=t=>[...t].map(e=>{if(e in k0)return`&${k0[e]};`;const i=e.codePointAt(0);return i<256?`&#${i};`:`&#x${i.toString(16)};`}).join(""),Q0=t=>{if(t.includes("%"))try{return decodeURIComponent(t)}catch{}return encodeURIComponent(t)},$0=t=>{const e=t.view,{state:i}=e,{ranges:r}=i.selection,n=Ut(e,!1,t.getWikiConfig);return n&&"provideRefactoringAction"in n&&r.some(({empty:s})=>!s)?((async()=>{const s=new WeakMap;for(const o of r){const[a]=await n.provideRefactoringAction(i.sliceDoc(o.from,o.to));s.set(o,a==null?void 0:a.edit.changes[""][0].newText)}e.dispatch(i.changeByRange(o=>{const a=s.get(o);return a===void 0?{range:o}:{range:k.range(o.from,o.from+a.length),changes:{from:o.from,to:o.to,insert:a}}}))})(),!0):!1},ic=(t,e)=>{e.stopPropagation(),t.focus()},Co;Jh.push({name:"escape",isActionable({lang:t,view:e}){return t==="mediawiki"&&e.state.selection.ranges.some(({empty:i})=>!i)},getItems(t){if(!Co){const e=t.view,i=Y("div","HTML escape"),r=Y("div","URI encode/decode");i.addEventListener("click",s=>{Xn.replaceSelections(e,x0),ic(e,s)}),r.addEventListener("click",s=>{Xn.replaceSelections(e,Q0),ic(e,s)}),Co=[i,r];const n=Ut(e,!1,t.getWikiConfig);if(n&&"provideRefactoringAction"in n){const s=Y("div","Escape with magic words");s.addEventListener("click",o=>{$0(t),ic(e,o)}),Co.unshift(s)}}return Co}});var OZ=t=>et.of([{key:"Mod-[",run:w0(x0,Bh)},{key:"Mod-]",run:w0(Q0,_h)},{key:"Mod-\\",run(){return $0(t)}}]),mZ={"\n":"<br>","&":"&","<":"<"},Wn=t=>t.replace(/[\n<&]/gu,e=>mZ[e]),Mn=(t,e)=>{const i=t.lineAt(e);return{line:i.number-1,character:e-i.from}},Oi=(t,e)=>{const i=t.line(e.line+1);return Math.min(i.from+e.character,i.to)},P0=(t,e)=>{const i=Y("div"),r=Y("div",{class:Sr.slice(1)},i);return r.style.font=getComputedStyle(t.contentDOM).font,i.innerHTML=e,{dom:r}},rc=(t,e)=>{const i=t.sliceDoc(e.from,e.to);return[i.split("{{").length-1,1-i.split("}}").length]},Se=(t,e)=>(Array.isArray(e)?e:[e]).some(i=>t.has(i in $?$[i]:i)),gZ=xt(t=>new RegExp(`mw-tag-${t}(?![a-z])`,"u")),bZ=(t,{to:e})=>Math.max(t,e),vZ=(t,{from:e,to:i})=>e<=t&&i>t?i:t,Zo=t=>e=>t.some(i=>e==null?void 0:e.name.includes($[i])),nc=Zo(["templateBracket","parserFunctionBracket"]),yZ=Zo(["templateName","parserFunctionName"]),SZ=Zo(["templateDelimiter","parserFunctionDelimiter"]),sc=t=>SZ(t)&&!yZ(t.nextSibling),T0=t=>/-(?:template|ext)[a-z\d-]+ground/u.test(t.name)&&!nc(t),kZ=Zo(["extTagBracket"]),C0=(t,e)=>t.name.includes(`mw-tag-${e?"ref":""}`),wZ=new Set(["ref","references"]),Z0=(t,e,i,r=!1)=>{var f;if(typeof e=="number"&&(i=fi(t,e)),!i)return!1;let n;if(typeof e=="number"){const u=i.resolve(e,-1);if(!r&&T0(u))n=u;else{const d=i.resolve(e,1);n=C0(u,r)&&u.name.split("mw-tag-").length>d.name.split("mw-tag-").length?u:d}}else n=e;if(r||!T0(n)){if(C0(n,r)){const{name:u}=n,[d]=/^[a-z]+/u.exec(u.slice(u.lastIndexOf("mw-tag-")+7)),p=gZ(d);let{nextSibling:O}=n;for(;O&&!(kZ(O)&&!p.test(O.name));)({nextSibling:O}=O);const g=O==null?void 0:O.nextSibling;if(O&&(!r||g&&wZ.has((f=Qn(t,g))==null?void 0:f.name)))return{from:og(t,O.to).end.to,to:O.from}}return!1}let{prevSibling:s,nextSibling:o}=n,a=1,l=sc(n)?n:null,h=0;for(;o;){if(nc(o)){const[u,d]=rc(t,o);if(a+=d,a<=0){h=o.from+t.sliceDoc(o.from,o.to).split("}}").slice(0,a-1).join("}}").length;break}a+=u}else!l&&a===1&&sc(o)&&(l=o);({nextSibling:o}=o)}if(!o)return!1;for(a=-1;s;){if(nc(s)){const[u,d]=rc(t,s);if(a+=u,a>=0)break;a+=d}else a===-1&&sc(s)&&(l=s);({prevSibling:s}=s)}const c=l==null?void 0:l.to;return c&&c<h?{from:c,to:h}:!1},A0=t=>{const{selection:{main:{head:e}}}=t,i=Z0(t,e);if(i){const{from:r,to:n}=i;let s=!1;return Yl(t).between(r,n,(o,a)=>{o===r&&a===n&&(s=!0)}),s?null:{pos:e,above:!0,create(){const o=Y("div",{class:yr.slice(1),title:t.phrase("Fold template or extension tag")},"-");return o.dataset.from=String(r),o.dataset.to=String(n),{dom:o}}}}return null},R0=(t,e,i)=>{var r;return e.length>0?((r=t.dom.querySelector(yr))==null||r.remove(),t.dispatch({effects:e,selection:{anchor:i}}),!0):!1},X0=t=>Math.max(...t.selection.ranges.map(({to:e})=>e)),W0=(t,e,i,r,n,s,o,a)=>{for(;r&&r.from<=n;){const l=Z0(t,r,e,a);if(l){i.push(Xi.of(l)),r=e.resolve(l.to,1),s=o(s,l);continue}r=r.nextSibling}return s},oc=class extends yt{constructor(t){super(),this.open=t}eq(t){return this.open===t.open}toDOM({state:t}){return Y("span",{title:t.phrase(this.open?"Fold line":"Unfold line")},this.open?"⌄":"›")}},xZ=new oc(!0),QZ=new oc(!1),M0=({state:t},e)=>{var r;let i;return(r=t.field(St,!1))==null||r.between(e.from,e.to,(n,s)=>{!i&&s===e.to&&(i={from:n,to:s})}),i},E0=({state:t,viewport:{to:e},viewportLineBlocks:i},{from:r,to:n})=>{const s=I(t),o=h=>{const{name:c}=s.resolve(h,1);return c.includes($.sectionHeader)?Number(/mw-section--(\d)/u.exec(c)[1]):7},a=(h,c)=>{var d;const f=t.sliceDoc(h,c),u=(d=/^\s*(?:(?::+\s*)?\{\||\|\})/u.exec(f))==null?void 0:d[0];if(u){const{name:p}=s.resolve(h+u.length,-1);if(p.includes($.tableBracket))return u.endsWith("|}")?-1:1}return 0},l=o(r);if(l<7){for(const{from:h}of i)if(h>r&&o(h)<=l)return n<h-1&&{from:n,to:h-1};return e===t.doc.length&&e>n&&{from:n,to:e}}else if(a(r,n)===1){for(const{from:h,to:c}of i)if(h>r){const f=a(h,c);if(f===-1)return n<h-1&&{from:n,to:h-1};if(f===1||o(h)<7)break}}return!1},q0=t=>{const e=new jt;for(const i of t.viewportLineBlocks){let r;M0(t,i)?r=QZ:E0(t,i)&&(r=xZ),r&&e.add(i.from,i.from,r)}return e.finish()},D0=be.fromClass(class{constructor(t){this.markers=q0(t)}update({docChanged:t,viewportChanged:e,startState:i,state:r,view:n}){(t||e||i.facet(nt)!==r.facet(nt)||i.field(St,!1)!==r.field(St,!1)||I(i)!==I(r))&&(this.markers=q0(n))}}),$Z=[vx(),et.of(Ox)],Y0=t=>e=>{var o;const{state:i}=e,r=(o=fi(i,i.doc.length,1e3))!=null?o:I(i),n=[],s=W0(i,r,n,r.topNode.firstChild,1/0,X0(i),vZ,t);return R0(e,n,s)},PZ=Y0(!0),TZ=((t=$Z)=>t),CZ=[_l({placeholderDOM(t){const e=Y("span",{"aria-label":"folded code",title:t.state.phrase("unfold"),class:"cm-foldPlaceholder"},"…");return e.addEventListener("click",({target:i})=>{const r=t.posAtDOM(i),{state:n}=t,{selection:s}=n;Yl(n).between(r,r,(o,a)=>{o===r&&t.dispatch({effects:ui.of({from:o,to:a}),selection:s})})}),e}}),ve.define({create:A0,update(t,{state:e,docChanged:i,selection:r}){return i?null:r?A0(e):t},provide(t){return ir.from(t)}}),et.of([{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run(t){const{state:e}=t,i=I(e),r=[];let n=X0(e);for(const{from:s,to:o,empty:a}of e.selection.ranges){let l;a&&(l=i.resolve(s,-1)),(!l||l.name==="Document")&&(l=i.resolve(s,1)),n=W0(e,i,r,l,o,n,bZ)}return R0(t,r,n)}},{key:"Ctrl-Alt-[",run:Y0()},{key:"Mod-Alt-,",run:PZ},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run(t){const{state:e}=t,{selection:i}=e,r=[],n=Yl(e);for(const{from:s,to:o}of i.ranges)n.between(s,o,(a,l)=>{r.push(ui.of({from:a,to:l}))});return r.length>0?(t.dispatch({effects:r,selection:i}),!0):!1}},{key:"Ctrl-Alt-]",run:Mp}]),D0,fl({class:"cm-foldGutter",markers(t){var e,i;return(i=(e=t.plugin(D0))==null?void 0:e.markers)!=null?i:ne.empty},initialSpacer(){return new oc(!1)},domEventHandlers:{click(t,e){const i=M0(t,e);if(i)return t.dispatch({effects:ui.of(i)}),!0;const r=E0(t,e);return r?(t.dispatch({effects:Xi.of(r)}),!0):!1}}}),x.theme({[yr]:{cursor:"pointer",lineHeight:1.2,padding:"0 1px",opacity:.6},[`${yr}:hover`]:{opacity:1}})],ZZ=t=>e=>{const i=e.target.closest(yr);if(i){e.preventDefault();const{dataset:r}=i,n=Number(r.from),s=Number(r.to);t.dispatch({effects:Xi.of({from:n,to:s}),selection:{anchor:s}}),i.remove()}},AZ=t=>[cl(async(e,i,r)=>{var h,c;const{state:n}=e,{doc:s}=n,{paramSuggest:o,tags:a}=t.langConfig;let l=await((h=Ut(e,!1,t.getWikiConfig))==null?void 0:h.provideHover(s.toString(),Mn(s,i)));if(!l&&o&&"templatedata"in a){const f=(c=fi(n,i+Math.max(r,0)))==null?void 0:c.resolve(i,r);if(f!=null&&f.name.includes($.templateName)){const u=await o(n.sliceDoc(f.from,f.to),!1),{description:d,length:p}=u;(d||p>0)&&(l={contents:{kind:"plaintext",value:(d?`<p>${Wn(d)}</p>`:"")+(p===0?"":`<ul>${u.map(([O,g])=>`<li><code>${Wn(O)}</code>${g?` — ${Wn(g)}`:""}</li>`).join("")}</ul>`)},range:{start:Mn(s,f.from),end:Mn(s,f.to)}})}}if(l){await br("npm/marked/lib/marked.umd.js","marked",!0);const{end:f}=l.range;return{pos:i,end:Oi(s,f),above:!0,create(){const{kind:u,value:d}=l.contents;return P0(e,u==="plaintext"?d:marked.parse(d))}}}return null}),x.theme({[Sr]:{padding:"2px 5px",width:"max-content",maxWidth:"60vw",overflowY:"auto"},[`${Sr} *`]:{marginTop:"0!important",marginBottom:"0!important"},[`${Sr}>div`]:{fontSize:"90%",lineHeight:1.4},[`${Sr} code`]:{padding:".1em .4em",borderRadius:".4em"}})],RZ=new Set(["plain","mediawiki"]),V0=t=>{var e,i;return(i=(e=t.children)==null?void 0:e.flatMap(V0))!=null?i:t.text},$r=(t,e,i)=>{if(RZ.has(i))return e;const r=[],n=typeof t=="string"?t.split(`
|
|
27
|
+
}`,{label:"class",detail:"definition",type:"keyword"}),ye('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),ye('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],MP=sm.concat([ye("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),ye("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),ye("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),om=new fp,am=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function Sn(t){return(e,i)=>{let r=e.node.getChild("VariableDefinition");return r&&i(r,t),!0}}var EP=["FunctionDeclaration"],qP={FunctionDeclaration:Sn("function"),ClassDeclaration:Sn("class"),ClassExpression:()=>!0,EnumDeclaration:Sn("constant"),TypeAliasDeclaration:Sn("type"),NamespaceDeclaration:Sn("namespace"),VariableDefinition(t,e){t.matchContext(EP)||e(t,"variable")},TypeDefinition(t,e){e(t,"type")},__proto__:null};function lm(t,e){let i=om.get(e);if(i)return i;let r=[],n=!0;function s(o,a){let l=t.sliceString(o.from,o.to);r.push({label:l,type:a})}return e.cursor(le.IncludeAnonymous).iterate(o=>{if(n)n=!1;else if(o.name){let a=qP[o.name];if(a&&a(o,s)||am.has(o.name))return!1}else if(o.to-o.from>8192){for(let a of lm(t,o.node))r.push(a);return!1}}),om.set(e,r),r}var co=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,bh=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function DP(t){let e=I(t.state).resolveInner(t.pos,-1);if(bh.indexOf(e.name)>-1)return null;let i=e.name=="VariableName"||e.to-e.from<20&&co.test(t.state.sliceDoc(e.from,e.to));if(!i&&!t.explicit)return null;let r=[];for(let n=e;n;n=n.parent)am.has(n.name)&&(r=r.concat(lm(t.state.doc,n)));return{options:r,from:i?e.from:t.pos,validFor:co}}function vh(t,e,i){var r;let n=[];for(;;){let s=e.firstChild,o;if((s==null?void 0:s.name)=="VariableName")return n.push(t(s)),{path:n.reverse(),name:i};if((s==null?void 0:s.name)=="MemberExpression"&&((r=o=s.lastChild)===null||r===void 0?void 0:r.name)=="PropertyName")n.push(t(o)),e=s;else return null}}function YP(t){let e=r=>t.state.doc.sliceString(r.from,r.to),i=I(t.state).resolveInner(t.pos,-1);return i.name=="PropertyName"?vh(e,i.parent,e(i)):(i.name=="."||i.name=="?.")&&i.parent.name=="MemberExpression"?vh(e,i.parent,""):bh.indexOf(i.name)>-1?null:i.name=="VariableName"||i.to-i.from<20&&co.test(e(i))?{path:[],name:e(i)}:i.name=="MemberExpression"?vh(e,i,""):t.explicit?{path:[],name:""}:null}function VP(t,e){let i=[],r=new Set;for(let n=0;;n++){for(let o of(Object.getOwnPropertyNames||Object.keys)(t)){if(!/^[a-zA-Z_$\xaa-\uffdc][\w$\xaa-\uffdc]*$/.test(o)||r.has(o))continue;r.add(o);let a;try{a=t[o]}catch{continue}i.push({label:o,type:typeof a=="function"?/^[A-Z]/.test(o)?"class":e?"function":"method":e?"variable":"property",boost:-n})}let s=Object.getPrototypeOf(t);if(!s)return i;t=s}}function _P(t){let e=new Map;return i=>{let r=YP(i);if(!r)return null;let n=t;for(let o of r.path)if(n=n[o],!n)return null;let s=e.get(n);return s||e.set(n,s=VP(n,!r.path.length)),{from:i.pos-r.name.length,options:s,validFor:co}}}var _e=hn.define({name:"javascript",parser:WP.configure({props:[dr.add({IfStatement:pr({except:/^\s*({|else\b)/}),TryStatement:pr({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:ox,SwitchBody:t=>{let e=t.textAfter,i=/^\s*\}/.test(e),r=/^\s*(case|default)\b/.test(e);return t.baseIndent+(i?0:r?1:2)*t.unit},Block:sx({closing:"}"}),ArrowFunction:t=>t.baseIndent+t.unit,"TemplateString BlockComment":()=>null,"Statement Property":pr({except:/^\s*{/}),JSXElement(t){let e=/^\s*<\//.test(t.textAfter);return t.lineIndent(t.node.from)+(e?0:t.unit)},JSXEscape(t){let e=/\s*\}/.test(t.textAfter);return t.lineIndent(t.node.from)+(e?0:t.unit)},"JSXOpenTag JSXSelfClosingTag"(t){return t.column(t.node.from)+t.unit}}),un.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":Dl,BlockComment(t){return{from:t.from+2,to:t.to-2}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),hm={test:t=>/^JSX/.test(t.name),facet:Rl({commentTokens:{block:{open:"{/*",close:"*/}"}}})},cm=_e.configure({dialect:"ts"},"typescript"),fm=_e.configure({dialect:"jsx",props:[Xl.add(t=>t.isTop?[hm]:void 0)]}),um=_e.configure({dialect:"jsx ts",props:[Xl.add(t=>t.isTop?[hm]:void 0)]},"typescript"),dm=t=>({label:t,type:"keyword"}),pm="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(dm),BP=pm.concat(["declare","implements","private","protected","public"].map(dm));function fo(t={}){let e=t.jsx?t.typescript?um:fm:t.typescript?cm:_e,i=t.typescript?MP.concat(BP):sm.concat(pm);return new Et(e,[_e.data.of({autocomplete:Bx(bh,iO(i))}),_e.data.of({autocomplete:DP}),t.jsx?zP:[]])}function LP(t){for(;;){if(t.name=="JSXOpenTag"||t.name=="JSXSelfClosingTag"||t.name=="JSXFragmentTag")return t;if(t.name=="JSXEscape"||!t.parent)return null;t=t.parent}}function Om(t,e,i=t.length){for(let r=e==null?void 0:e.firstChild;r;r=r.nextSibling)if(r.name=="JSXIdentifier"||r.name=="JSXBuiltin"||r.name=="JSXNamespacedName"||r.name=="JSXMemberExpression")return t.sliceString(r.from,Math.min(r.to,i));return""}var jP=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),zP=x.inputHandler.of((t,e,i,r,n)=>{if((jP?t.composing:t.compositionStarted)||t.state.readOnly||e!=i||r!=">"&&r!="/"||!_e.isActiveAt(t.state,e,-1))return!1;let s=n(),{state:o}=s,a=o.changeByRange(l=>{var h;let{head:c}=l,f=I(o).resolveInner(c-1,-1),u;if(f.name=="JSXStartTag"&&(f=f.parent),!(o.doc.sliceString(c-1,c)!=r||f.name=="JSXAttributeValue"&&f.to>c)){if(r==">"&&f.name=="JSXFragmentTag")return{range:l,changes:{from:c,insert:"</>"}};if(r=="/"&&f.name=="JSXStartCloseTag"){let d=f.parent,p=d.parent;if(p&&d.from==c-2&&((u=Om(o.doc,p.firstChild,c))||((h=p.firstChild)===null||h===void 0?void 0:h.name)=="JSXFragmentTag")){let O=`${u}>`;return{range:k.cursor(c+O.length,-1),changes:{from:c,insert:O}}}}else if(r==">"){let d=LP(f);if(d&&d.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(o.doc.sliceString(c,c+2))&&(u=Om(o.doc,d,c)))return{range:l,changes:{from:c,insert:`</${u}>`}}}}return{range:l}});return a.changes.empty?!1:(t.dispatch([s,o.update(a,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),kn=["_blank","_self","_top","_parent"],yh=["ascii","utf-8","utf-16","latin1","latin1"],Sh=["get","post","put","delete"],kh=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],Ie=["true","false"],E={},NP={a:{attrs:{href:null,ping:null,type:null,media:null,target:kn,hreflang:null}},abbr:E,address:E,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:["default","rect","circle","poly"]}},article:E,aside:E,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["autoplay"],loop:["loop"],controls:["controls"]}},b:E,base:{attrs:{href:null,target:kn}},bdi:E,bdo:E,blockquote:{attrs:{cite:null}},body:E,br:E,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["autofocus"],disabled:["autofocus"],formenctype:kh,formmethod:Sh,formnovalidate:["novalidate"],formtarget:kn,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:E,center:E,cite:E,code:E,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["disabled"],checked:["checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["disabled"],multiple:["multiple"]}},datalist:{attrs:{data:null}},dd:E,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["open"]}},dfn:E,div:E,dl:E,dt:E,em:E,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["disabled"],form:null,name:null}},figcaption:E,figure:E,footer:E,form:{attrs:{action:null,name:null,"accept-charset":yh,autocomplete:["on","off"],enctype:kh,method:Sh,novalidate:["novalidate"],target:kn}},h1:E,h2:E,h3:E,h4:E,h5:E,h6:E,head:{children:["title","base","link","style","meta","script","noscript","command"]},header:E,hgroup:E,hr:E,html:{attrs:{manifest:null}},i:E,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["autofocus"],checked:["checked"],disabled:["disabled"],formenctype:kh,formmethod:Sh,formnovalidate:["novalidate"],formtarget:kn,multiple:["multiple"],readonly:["readonly"],required:["required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:E,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["autofocus"],disabled:["disabled"],keytype:["RSA"]}},label:{attrs:{for:null,form:null}},legend:E,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:null,media:null,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:E,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:yh,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:E,noscript:E,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["typemustmatch"]}},ol:{attrs:{reversed:["reversed"],start:null,type:["1","a","A","i","I"]},children:["li","script","template","ul","ol"]},optgroup:{attrs:{disabled:["disabled"],label:null}},option:{attrs:{disabled:["disabled"],label:null,selected:["selected"],value:null}},output:{attrs:{for:null,form:null,name:null}},p:E,param:{attrs:{name:null,value:null}},pre:E,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:E,rt:E,ruby:E,samp:E,script:{attrs:{type:["text/javascript"],src:null,async:["async"],defer:["defer"],charset:yh}},section:E,select:{attrs:{form:null,name:null,size:null,autofocus:["autofocus"],disabled:["disabled"],multiple:["multiple"]}},slot:{attrs:{name:null}},small:E,source:{attrs:{src:null,type:null,media:null}},span:E,strong:E,style:{attrs:{type:["text/css"],media:null,scoped:null}},sub:E,summary:E,sup:E,table:E,tbody:E,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:E,textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["autofocus"],disabled:["disabled"],readonly:["readonly"],required:["required"],wrap:["soft","hard"]}},tfoot:E,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:E,time:{attrs:{datetime:null}},title:E,tr:E,track:{attrs:{src:null,label:null,default:null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:null}},ul:{children:["li","script","template","ul","ol"]},var:E,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["autoplay"],mediagroup:["movie"],muted:["muted"],controls:["controls"]}},wbr:E},mm={accesskey:null,class:null,contenteditable:Ie,contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["ar","bn","de","en-GB","en-US","es","fr","hi","id","ja","pa","pt","ru","tr","zh"],spellcheck:Ie,autocorrect:Ie,autocapitalize:Ie,style:null,tabindex:null,title:null,translate:["yes","no"],rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"],role:"alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer".split(" "),"aria-activedescendant":null,"aria-atomic":Ie,"aria-autocomplete":["inline","list","both","none"],"aria-busy":Ie,"aria-checked":["true","false","mixed","undefined"],"aria-controls":null,"aria-describedby":null,"aria-disabled":Ie,"aria-dropeffect":null,"aria-expanded":["true","false","undefined"],"aria-flowto":null,"aria-grabbed":["true","false","undefined"],"aria-haspopup":Ie,"aria-hidden":Ie,"aria-invalid":["true","false","grammar","spelling"],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":["off","polite","assertive"],"aria-multiline":Ie,"aria-multiselectable":Ie,"aria-owns":null,"aria-posinset":null,"aria-pressed":["true","false","mixed","undefined"],"aria-readonly":Ie,"aria-relevant":null,"aria-required":Ie,"aria-selected":["true","false","undefined"],"aria-setsize":null,"aria-sort":["ascending","descending","none","other"],"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null},gm="beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload".split(" ").map(t=>"on"+t);for(let t of gm)mm[t]=null;var wn=class{constructor(t,e){this.tags={...NP,...t},this.globalAttrs={...mm,...e},this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}};wn.default=new wn;function mr(t,e,i=t.length){if(!e)return"";let r=e.firstChild,n=r&&r.getChild("TagName");return n?t.sliceString(n.from,Math.min(n.to,i)):""}function gr(t,e=!1){for(;t;t=t.parent)if(t.name=="Element")if(e)e=!1;else return t;return null}function bm(t,e,i){let r=i.tags[mr(t,gr(e))];return(r==null?void 0:r.children)||i.allTags}function wh(t,e){let i=[];for(let r=gr(e);r&&!r.type.isTop;r=gr(r.parent)){let n=mr(t,r);if(n&&r.lastChild.name=="CloseTag")break;n&&i.indexOf(n)<0&&(e.name=="EndTag"||e.from>=r.firstChild.to)&&i.push(n)}return i}var vm=/^[:\-\.\w\u00b7-\uffff]*$/;function ym(t,e,i,r,n){let s=/\s*>/.test(t.sliceDoc(n,n+5))?"":">",o=gr(i,i.name=="StartTag"||i.name=="TagName");return{from:r,to:n,options:bm(t.doc,o,e).map(a=>({label:a,type:"type"})).concat(wh(t.doc,i).map((a,l)=>({label:"/"+a,apply:"/"+a+s,type:"type",boost:99-l}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function Sm(t,e,i,r){let n=/\s*>/.test(t.sliceDoc(r,r+5))?"":">";return{from:i,to:r,options:wh(t.doc,e).map((s,o)=>({label:s,apply:s+n,type:"type",boost:99-o})),validFor:vm}}function IP(t,e,i,r){let n=[],s=0;for(let o of bm(t.doc,i,e))n.push({label:"<"+o,type:"type"});for(let o of wh(t.doc,i))n.push({label:"</"+o+">",type:"type",boost:99-s++});return{from:r,to:r,options:n,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function GP(t,e,i,r,n){let s=gr(i),o=s?e.tags[mr(t.doc,s)]:null,a=o&&o.attrs?Object.keys(o.attrs):[],l=o&&o.globalAttrs===!1?a:a.length?a.concat(e.globalAttrNames):e.globalAttrNames;return{from:r,to:n,options:l.map(h=>({label:h,type:"property"})),validFor:vm}}function UP(t,e,i,r,n){var s;let o=(s=i.parent)===null||s===void 0?void 0:s.getChild("AttributeName"),a=[],l;if(o){let h=t.sliceDoc(o.from,o.to),c=e.globalAttrs[h];if(!c){let f=gr(i),u=f?e.tags[mr(t.doc,f)]:null;c=(u==null?void 0:u.attrs)&&u.attrs[h]}if(c){let f=t.sliceDoc(r,n).toLowerCase(),u='"',d='"';/^['"]/.test(f)?(l=f[0]=='"'?/^[^"]*$/:/^[^']*$/,u="",d=t.sliceDoc(n,n+1)==f[0]?"":f[0],f=f.slice(1),r++):l=/^[^\s<>='"]*$/;for(let p of c)a.push({label:p,apply:u+p+d,type:"constant"})}}return{from:r,to:n,options:a,validFor:l}}function km(t,e){let{state:i,pos:r}=e,n=I(i).resolveInner(r,-1),s=n.resolve(r);for(let o=r,a;s==n&&(a=n.childBefore(o));){let l=a.lastChild;if(!l||!l.type.isError||l.from<l.to)break;s=n=a,o=l.from}return n.name=="TagName"?n.parent&&/CloseTag$/.test(n.parent.name)?Sm(i,n,n.from,r):ym(i,t,n,n.from,r):n.name=="StartTag"||n.name=="IncompleteTag"?ym(i,t,n,r,r):n.name=="StartCloseTag"||n.name=="IncompleteCloseTag"?Sm(i,n,r,r):n.name=="OpenTag"||n.name=="SelfClosingTag"||n.name=="AttributeName"?GP(i,t,n,n.name=="AttributeName"?n.from:r,r):n.name=="Is"||n.name=="AttributeValue"||n.name=="UnquotedAttributeValue"?UP(i,t,n,n.name=="Is"?r:n.from,r):e.explicit&&(s.name=="Element"||s.name=="Text"||s.name=="Document")?IP(i,t,n,r):null}function FP(t){return km(wn.default,t)}function wm(t){let{extraTags:e,extraGlobalAttributes:i}=t,r=i||e?new wn(e,i):wn.default;return n=>km(r,n)}var HP=_e.parser.configure({top:"SingleExpression"}),xm=[{tag:"script",attrs:t=>t.type=="text/typescript"||t.lang=="ts",parser:cm.parser},{tag:"script",attrs:t=>t.type=="text/babel"||t.type=="text/jsx",parser:fm.parser},{tag:"script",attrs:t=>t.type=="text/typescript-jsx",parser:um.parser},{tag:"script",attrs(t){return/^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(t.type)},parser:HP},{tag:"script",attrs(t){return!t.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(t.type)},parser:_e.parser},{tag:"style",attrs(t){return(!t.lang||t.lang=="css")&&(!t.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(t.type))},parser:Gt.parser}],Qm=[{name:"style",parser:Gt.parser.configure({top:"Styles"})}].concat(gm.map(t=>({name:t,parser:_e.parser}))),$m=hn.define({name:"html",parser:M$.configure({props:[dr.add({Element(t){let e=/^(\s*)(<\/)?/.exec(t.textAfter);return t.node.to<=t.pos+e[0].length?t.continue():t.lineIndent(t.node.from)+(e[2]?0:t.unit)},"OpenTag CloseTag SelfClosingTag"(t){return t.column(t.node.from)+t.unit},Document(t){if(t.pos+/\s*/.exec(t.textAfter)[0].length<t.node.to)return t.continue();let e=null,i;for(let r=t.node;;){let n=r.lastChild;if(!n||n.name!="Element"||n.to!=r.to)break;e=r=n}return e&&!((i=e.lastChild)&&(i.name=="CloseTag"||i.name=="SelfClosingTag"))?t.lineIndent(e.from)+t.unit:null}}),un.add({Element(t){let e=t.firstChild,i=t.lastChild;return!e||e.name!="OpenTag"?null:{from:e.to,to:i.name=="CloseTag"?i.from:t.to}}}),Bp.add({"OpenTag CloseTag":t=>t.getChild("TagName")})]}),languageData:{commentTokens:{block:{open:"<!--",close:"-->"}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:"-_"}}),di=$m.configure({wrap:uh(xm,Qm)});function KP(t={}){let e="",i;t.matchClosingTags===!1&&(e="noMatch"),t.selfClosingTags===!0&&(e=(e?e+" ":"")+"selfClosing"),(t.nestedLanguages&&t.nestedLanguages.length||t.nestedAttributes&&t.nestedAttributes.length)&&(i=uh((t.nestedLanguages||[]).concat(xm),(t.nestedAttributes||[]).concat(Qm)));let r=i?$m.configure({wrap:i,dialect:e}):e?di.configure({dialect:e}):di;return new Et(r,[di.data.of({autocomplete:wm(t)}),t.autoCloseTags!==!1?xh:[],fo().support,hP().support])}var Pm=new Set("area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" ")),xh=x.inputHandler.of((t,e,i,r,n)=>{if(t.composing||t.state.readOnly||e!=i||r!=">"&&r!="/"||!di.isActiveAt(t.state,e,-1))return!1;let s=n(),{state:o}=s,a=o.changeByRange(l=>{var h,c,f;let u=o.doc.sliceString(l.from-1,l.to)==r,{head:d}=l,p=I(o).resolveInner(d,-1),O;if(u&&r==">"&&p.name=="EndTag"){let g=p.parent;if(((c=(h=g.parent)===null||h===void 0?void 0:h.lastChild)===null||c===void 0?void 0:c.name)!="CloseTag"&&(O=mr(o.doc,g.parent,d))&&!Pm.has(O)){let b=d+(o.doc.sliceString(d,d+1)===">"?1:0),y=`</${O}>`;return{range:l,changes:{from:d,to:b,insert:y}}}}else if(u&&r=="/"&&p.name=="IncompleteCloseTag"){let g=p.parent;if(p.from==d-2&&((f=g.lastChild)===null||f===void 0?void 0:f.name)!="CloseTag"&&(O=mr(o.doc,g,d))&&!Pm.has(O)){let b=d+(o.doc.sliceString(d,d+1)===">"?1:0),y=`${O}>`;return{range:k.cursor(d+y.length,-1),changes:{from:d,to:b,insert:y}}}}return{range:l}});return a.changes.empty?!1:(t.dispatch([s,o.update(a,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),JP=["zh-hans","zh-hant"],eT="https://testingcf.jsdelivr.net",Tm=typeof document=="object"?document.createElement("textarea"):void 0,tT=t=>(Tm.innerHTML=t,Tm.value),Qh=new Map,br=(t,e,i)=>{if(Qh.has(t))return Qh.get(t);const r=new Promise(n=>{const s=/^https?:\/\//iu.test(t)?t:`${eT}/${t}`;let o=globalThis;for(const a of e.split("."))o=o==null?void 0:o[a];if(o)n();else if(i&&typeof define=="function"&&"amd"in define){const a=globalThis.require;a.config({paths:{[e]:s}}),a([e],l=>{Object.assign(globalThis,{[e]:l}),n()})}else{const a=document.createElement("script");a.src=s,a.onload=()=>{n()},document.head.append(a)}});return Qh.set(t,r),r},iT=t=>JSON.parse(String(localStorage.getItem(t))),Cm=(t,e)=>{localStorage.setItem(t,JSON.stringify(e))},rT=async(t,e,i,r,n,s=(o=>(o=iT(n))!=null?o:{})())=>{const{version:a,lang:l}=s,h=Array.isArray(i)?i:[i];if(a===e&&h.includes(l))return s;for(const c of h){const f=c.toLowerCase();if(r.includes(f))try{const u=await fetch(`${t}/${f}.json`);return Object.assign(s,await u.json(),{version:e,lang:c}),Cm(n,s),s}catch{}}throw new Error(`Failed to fetch the localization for ${h[0]}.`)},Zm=!1,Am=!1,Rm=async(t,e,i)=>{const r="extensions/dist";let n=i||`npm/wikiparser-node/${r}/base.min.js`;if(n.endsWith(".js")||(n=`${n}${n.endsWith("/")?"":"/"}${r}/base.js`),await br(n,"wikiparse"),await br(`${wikiparse.CDN}/${r}/lsp.js`,"wikiparse.LanguageService"),!Zm&&typeof t=="function"){Zm=!0;try{wikiparse.setConfig(await t())}catch{}}if(!Am&&e){Am=!0;const s="wikiparse-i18n",{version:o}=wikiparse;try{wikiparse.setI18N(await rT(`${wikiparse.CDN}/i18n`,o,e,JP,s))}catch{Cm(s,{version:o,lang:"en"})}}},$h=new WeakMap,Ut=(t,e,i,r)=>{if(Rm(i,r),typeof wikiparse!="object"||!wikiparse.LanguageService||$h.has(t))return $h.get(t);const n=new wikiparse.LanguageService(e);return $h.set(t,n),n},Xm=new Map([["aliceblue","#f0f8ff"],["antiquewhite","#faebd7"],["aqua","#00ffff"],["aquamarine","#7fffd4"],["azure","#f0ffff"],["beige","#f5f5dc"],["bisque","#ffe4c4"],["black","#000000"],["blanchedalmond","#ffebcd"],["blue","#0000ff"],["blueviolet","#8a2be2"],["brown","#a52a2a"],["burlywood","#deb887"],["cadetblue","#5f9ea0"],["chartreuse","#7fff00"],["chocolate","#d2691e"],["coral","#ff7f50"],["cornflowerblue","#6495ed"],["cornsilk","#fff8dc"],["crimson","#dc143c"],["cyan","#00ffff"],["darkblue","#00008b"],["darkcyan","#008b8b"],["darkgoldenrod","#b8860b"],["darkgray","#a9a9a9"],["darkgreen","#006400"],["darkgrey","#a9a9a9"],["darkkhaki","#bdb76b"],["darkmagenta","#8b008b"],["darkolivegreen","#556b2f"],["darkorange","#ff8c00"],["darkorchid","#9932cc"],["darkred","#8b0000"],["darksalmon","#e9967a"],["darkseagreen","#8fbc8f"],["darkslateblue","#483d8b"],["darkslategray","#2f4f4f"],["darkslategrey","#2f4f4f"],["darkturquoise","#00ced1"],["darkviolet","#9400d3"],["deeppink","#ff1493"],["deepskyblue","#00bfff"],["dimgray","#696969"],["dimgrey","#696969"],["dodgerblue","#1e90ff"],["firebrick","#b22222"],["floralwhite","#fffaf0"],["forestgreen","#228b22"],["fuchsia","#ff00ff"],["gainsboro","#dcdcdc"],["ghostwhite","#f8f8ff"],["goldenrod","#daa520"],["gold","#ffd700"],["gray","#808080"],["green","#008000"],["greenyellow","#adff2f"],["grey","#808080"],["honeydew","#f0fff0"],["hotpink","#ff69b4"],["indianred","#cd5c5c"],["indigo","#4b0082"],["ivory","#fffff0"],["khaki","#f0e68c"],["lavenderblush","#fff0f5"],["lavender","#e6e6fa"],["lawngreen","#7cfc00"],["lemonchiffon","#fffacd"],["lightblue","#add8e6"],["lightcoral","#f08080"],["lightcyan","#e0ffff"],["lightgoldenrodyellow","#fafad2"],["lightgray","#d3d3d3"],["lightgreen","#90ee90"],["lightgrey","#d3d3d3"],["lightpink","#ffb6c1"],["lightsalmon","#ffa07a"],["lightseagreen","#20b2aa"],["lightskyblue","#87cefa"],["lightslategray","#778899"],["lightslategrey","#778899"],["lightsteelblue","#b0c4de"],["lightyellow","#ffffe0"],["lime","#00ff00"],["limegreen","#32cd32"],["linen","#faf0e6"],["magenta","#ff00ff"],["maroon","#800000"],["mediumaquamarine","#66cdaa"],["mediumblue","#0000cd"],["mediumorchid","#ba55d3"],["mediumpurple","#9370db"],["mediumseagreen","#3cb371"],["mediumslateblue","#7b68ee"],["mediumspringgreen","#00fa9a"],["mediumturquoise","#48d1cc"],["mediumvioletred","#c71585"],["midnightblue","#191970"],["mintcream","#f5fffa"],["mistyrose","#ffe4e1"],["moccasin","#ffe4b5"],["navajowhite","#ffdead"],["navy","#000080"],["oldlace","#fdf5e6"],["olive","#808000"],["olivedrab","#6b8e23"],["orange","#ffa500"],["orangered","#ff4500"],["orchid","#da70d6"],["palegoldenrod","#eee8aa"],["palegreen","#98fb98"],["paleturquoise","#afeeee"],["palevioletred","#db7093"],["papayawhip","#ffefd5"],["peachpuff","#ffdab9"],["peru","#cd853f"],["pink","#ffc0cb"],["plum","#dda0dd"],["powderblue","#b0e0e6"],["purple","#800080"],["rebeccapurple","#663399"],["red","#ff0000"],["rosybrown","#bc8f8f"],["royalblue","#4169e1"],["saddlebrown","#8b4513"],["salmon","#fa8072"],["sandybrown","#f4a460"],["seagreen","#2e8b57"],["seashell","#fff5ee"],["sienna","#a0522d"],["silver","#c0c0c0"],["skyblue","#87ceeb"],["slateblue","#6a5acd"],["slategray","#708090"],["slategrey","#708090"],["snow","#fffafa"],["springgreen","#00ff7f"],["steelblue","#4682b4"],["tan","#d2b48c"],["teal","#008080"],["thistle","#d8bfd8"],["tomato","#ff6347"],["turquoise","#40e0d0"],["violet","#ee82ee"],["wheat","#f5deb3"],["white","#ffffff"],["whitesmoke","#f5f5f5"],["yellow","#ffff00"],["yellowgreen","#9acd32"]]),nT=function(t,e){var i={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(i[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(t);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(i[r[n]]=t[r[n]]);return i},Wm=new WeakMap,wt=(function(t){return t.rgb="RGB",t.hex="HEX",t.named="NAMED",t.hsl="HSL",t})(wt||(wt={})),sT=/rgba?\(\s*(\d{1,3}%?)\s*[,\s]\s*(\d{1,3}%?)\s*[,\s]\s*(\d{1,3}%?)\s*([,/]\s*0?\.?\d+%?)?\s*\)/,oT=/hsla?\(\s*(\d{1,3})(?:deg)?\s*[,\s]\s*(\d{1,3})%?\s*[,\s]\s*(\d{1,3})%?\s*([,/]\s*0?\.?\d+%?)?\s*\)/,aT=/(^|\b)(#[0-9a-f]{3,9})(\b|$)/i;function Mm(t,e,i,r,n,s){var o;switch(r){case"AttributeValue":{const a=t.resolveInner(e,0).tree;if(!a)return null;const l=(o=a.prop(j.mounted))===null||o===void 0?void 0:o.tree;if((l==null?void 0:l.type.name)!=="Styles")return null;const h=[];return l.iterate({from:0,to:l.length,enter:({type:c,from:f,to:u})=>{const d=Mm(t,e+1+f,e+1+u,c.name,n);if(d){if(Array.isArray(d))throw new Error("Unexpected nested overlays");h.push(d)}}}),h}case"CallExpression":{const a=n.sliceString(e,i),l=Em(a);return l?Object.assign(Object.assign({},l),{from:e,to:i}):null}case"ColorLiteral":{const a=qm(n.sliceString(e,i));return a?Object.assign(Object.assign({},a),{from:e,to:i}):null}case"ValueName":{const a=n.sliceString(e,i),l=lT(a);return l?Object.assign(Object.assign({},l),{from:e,to:i}):null}default:return null}}function Em(t){switch(t.slice(0,3)){case"rgb":{const i=sT.exec(t);if(!i)return null;const[r,n,s,o,a]=i,l=cT(n,s,o);return{colorType:wt.rgb,color:l,alpha:(a==null?void 0:a.replace(/^\//,","))||""}}case"hsl":{const i=oT.exec(t);if(!i)return null;const[r,n,s,o,a]=i,l=fT(n,s,o);return{colorType:wt.hsl,color:l,alpha:(a==null?void 0:a.replace(/^\//,","))||""}}default:return null}}function qm(t){if(!aT.exec(t))return null;const[i,r]=hT(t);return{colorType:wt.hex,color:i,alpha:r}}function lT(t){const e=Xm.get(t);return e?{colorType:wt.named,color:e,alpha:""}:null}function Dm(t,e){const i=[],r=I(t.state);for(const n of t.visibleRanges)r.iterate({from:n.from,to:n.to,enter:({type:s,from:o,to:a})=>{var l;const h=e(r,o,a,s.name,t.state.doc,(l=t.state.facet(nt))===null||l===void 0?void 0:l.name);if(h){if(!Array.isArray(h)){i.push(A.widget({widget:new _m(h),side:1}).range(h.from));return}for(const c of h)i.push(A.widget({widget:new _m(c),side:1}).range(c.from))}}});return A.set(i)}function hT(t){return t.length===4?[`#${t[1].repeat(2)}${t[2].repeat(2)}${t[3].repeat(2)}`,""]:t.length===5?[`#${t[1].repeat(2)}${t[2].repeat(2)}${t[3].repeat(2)}`,t[4].repeat(2)]:t.length===9?[`#${t.slice(1,-2)}`,t.slice(-2)]:[t,""]}function Ph(t){let e;if(t.endsWith("%")){const i=Number(t.slice(0,-1));e=Math.round(i/100*255)}else e=Number(t);return uo(e)}function uo(t){const e=t.toString(16);return e.length===1?"0"+e:e}function Ym(t){const e=t.slice(1,3),i=t.slice(3,5),r=t.slice(5,7);return[parseInt(e,16),parseInt(i,16),parseInt(r,16)]}function cT(t,e,i){return`#${Ph(t)}${Ph(e)}${Ph(i)}`}function fT(t,e,i){const r=Number(e)/100,n=Number(i)/100,[s,o,a]=uT(Number(t),r,n);return`#${uo(s)}${uo(o)}${uo(a)}`}function uT(t,e,i){if(e===0){const f=Math.round(i*255);return[f,f,f]}let r;i<.5?r=i*(1+e):r=i+e-i*e;const n=2*i-r;t=t/360;const s=Vm(t+.333),o=t,a=Vm(t-.333),l=Th(r,n,s),h=Th(r,n,o),c=Th(r,n,a);return[Math.round(l*255),Math.round(h*255),Math.round(c*255)]}function Vm(t){return t<0?t+1:t>1?t-1:t}function Th(t,e,i){return 6*i<1?e+(t-e)*6*i:2*i<1?t:3*i<2?e+(t-e)*(.666-i)*6:e}function dT(t,e,i){const r=t/255,n=e/255,s=i/255,o=Math.min(r,n,s),a=Math.max(r,n,s),l=(a+o)/2;if(a===o)return[0,0,l];let h;l<=.5?h=(a-o)/(a+o):h=(a-o)/(2-a-o);let c;for(a===r?c=(n-s)/(a-o):n===a?c=2+(s-r)/(a-o):c=4+(r-n)/(a-o),c=Math.round(c*60);c<0;)c+=360;return[c,h,l]}var vr="cm-css-color-picker-wrapper",_m=class extends gt{constructor(t){var{color:e}=t,i=nT(t,["color"]);super(),this.state=i,this.color=e}eq(t){return t.state.colorType===this.state.colorType&&t.color===this.color&&t.state.from===this.state.from&&t.state.to===this.state.to&&t.state.alpha===this.state.alpha}toDOM(){const t=document.createElement("input");Wm.set(t,this.state),t.type="color",t.value=this.color;const e=document.createElement("span");return e.appendChild(t),e.className=vr,e}ignoreEvent(){return!1}},Bm=x.baseTheme({[`.${vr}`]:{display:"inline-block",outline:"1px solid #eee",marginRight:"0.6ch",height:"1em",width:"1em",transform:"translateY(1px)"},[`.${vr} input[type="color"]`]:{cursor:"pointer",height:"100%",width:"100%",padding:0,border:"none","&::-webkit-color-swatch-wrapper":{padding:0},"&::-webkit-color-swatch":{border:"none"},"&::-moz-color-swatch":{border:"none"}}}),Lm=t=>be.fromClass(class{constructor(i){this.decorations=Dm(i,t.discoverColors)}update(i){(i.docChanged||i.viewportChanged)&&(this.decorations=Dm(i.view,t.discoverColors))}},{decorations:e=>e.decorations,eventHandlers:{change:(e,i)=>{const r=e.target;if(r.nodeName!=="INPUT"||!r.parentElement||!r.parentElement.classList.contains(vr))return!1;const n=Wm.get(r);let s=r.value+n.alpha;if(n.colorType===wt.rgb)s=`rgb(${Ym(r.value).join(", ")}${n.alpha})`;else if(n.colorType===wt.named)for(const[o,a]of Xm.entries())a===r.value&&(s=o);else if(n.colorType===wt.hsl){const[o,a,l]=Ym(r.value),[h,c,f]=dT(o,a,l);s=`hsl(${h}, ${Math.round(c*100)}%, ${Math.round(f*100)}%${n.alpha})`}return i.dispatch({changes:{from:n.from,to:n.to,insert:s}}),!0}}}),Ch=[Lm({discoverColors:Mm}),Bm],Zh=[["b","bdi","del","i","ins","u","font","big","small","sub","sup","h1","h2","h3","h4","h5","h6","cite","code","em","s","strike","strong","tt","var","div","center","blockquote","ol","ul","dl","table","caption","pre","ruby","rb","rp","rt","rtc","p","span","abbr","dfn","kbd","samp","data","time","mark","tr","td","th","q","bdo"],["li","dt","dd"],["br","wbr","hr","meta","link"]],jm=Zh.flat(),zm=Zh[2],Nm=Zh[1],$={apostrophes:"mw-apostrophes",comment:"mw-comment",convertBracket:"mw-convert-bracket",convertDelimiter:"mw-convert-delimiter",convertFlag:"mw-convert-flag",convertLang:"mw-convert-lang",doubleUnderscore:"mw-double-underscore",em:"mw-em",error:"mw-error",extLink:"mw-extlink",extLinkBracket:"mw-extlink-bracket",extLinkProtocol:"mw-extlink-protocol",extLinkText:"mw-extlink-text",extTag:"mw-exttag",extTagAttribute:"mw-exttag-attribute",extTagAttributeValue:"mw-exttag-attribute-value",extTagBracket:"mw-exttag-bracket",extTagName:"mw-exttag-name",fileDelimiter:"mw-file-delimiter",fileText:"mw-file-text",freeExtLink:"mw-free-extlink",freeExtLinkProtocol:"mw-free-extlink-protocol",hr:"mw-hr",htmlEntity:"mw-entity",htmlTagAttribute:"mw-htmltag-attribute",htmlTagAttributeValue:"mw-htmltag-attribute-value",htmlTagBracket:"mw-htmltag-bracket",htmlTagName:"mw-htmltag-name",ignored:"mw-ignored",imageParameter:"mw-image-parameter",linkBracket:"mw-link-bracket",linkDelimiter:"mw-link-delimiter",linkPageName:"mw-link-pagename",linkText:"mw-link-text",linkToSection:"mw-link-tosection",list:"mw-list",magicLink:"mw-magic-link",pageName:"mw-pagename",parserFunction:"mw-parserfunction",parserFunctionBracket:"mw-parserfunction-bracket",parserFunctionDelimiter:"mw-parserfunction-delimiter",parserFunctionName:"mw-parserfunction-name",redirect:"mw-redirect",section:"mw-section",sectionHeader:"mw-section-header",signature:"mw-signature",skipFormatting:"mw-skipformatting",strong:"mw-strong",tableBracket:"mw-table-bracket",tableCaption:"mw-table-caption",tableDefinition:"mw-table-definition",tableDefinitionValue:"mw-table-definition-value",tableDelimiter:"mw-table-delimiter",tableDelimiter2:"mw-table-delimiter2",tableTd:"mw-table-td",tableTh:"mw-table-th",template:"mw-template",templateArgumentName:"mw-template-argument-name",templateBracket:"mw-template-bracket",templateDelimiter:"mw-template-delimiter",templateName:"mw-template-name",templateVariable:"mw-templatevariable",templateVariableBracket:"mw-templatevariable-bracket",templateVariableDelimiter:"mw-templatevariable-delimiter",templateVariableName:"mw-templatevariable-name"},pT=(()=>{const t={variable:m.variableName,"variable-2":m.special(m.variableName),"string-2":m.special(m.string),def:m.definition(m.variableName),tag:m.tagName,attribute:m.attributeName,type:m.typeName,builtin:m.standard(m.variableName),qualifier:m.modifier,error:m.invalid,header:m.heading,property:m.propertyName};for(const e of Object.values($))t[e]=rt.define();return t})(),OT="wiktionary|wiki(?:pedia|books|news|quote|source|versity|voyage)",mT=t=>Math.round(t*255).toString(16).padStart(2,"0"),gT=(()=>{const t=String.raw`#(?:[\da-f]{3,4}|(?:[\da-f]{2}){3,4})(?![\p{L}\p{N}_])`,e=String.raw`(?:\d*\.)?\d+%?`,i=String.raw`(?:\d*\.)?\d+(?:deg|grad|rad|turn)?`,r=String.raw`rgba?\(\s*(?:${String.raw`${new Array(3).fill(e).join(String.raw`\s+`)}(?:\s*\/\s*${e})?`}|${String.raw`${new Array(3).fill(e).join(String.raw`\s*,\s*`)}(?:\s*,\s*${e})?`})\s*\)`,n=String.raw`hsla?\(\s*(?:${String.raw`${i}\s+${e}\s+${e}(?:\s*\/\s*${e})?`}|${String.raw`${i}${String.raw`\s*,\s*(?:\d*\.)?\d+%`.repeat(2)}(?:\s*,\s*${e})?`})\s*\)`;return{full:new RegExp(String.raw`(^|[^\p{L}\p{N}_])(${t}|${r}|${n})`,"giu"),rgb:new RegExp(String.raw`(^|[^\p{L}\p{N}_])(${t}|${r})`,"giu")}})(),bT=(t,e=!0)=>{const i=[],r=gT[e?"full":"rgb"];r.lastIndex=0;let n=r.exec(t),s=0;for(;n;){const o=n.index+n[1].length;o>s&&i.push([t.slice(s,o),s,o,!1]),{lastIndex:s}=r,i.push([n[2],o,s,t[o-1]!=="&"||!/^#\d+$/u.test(n[2])]),n=r.exec(t)}return t.length>s&&i.push([t.slice(s),s,t.length,!1]),i},Im=t=>t.replace(/[{}]/gu,e=>e==="{"?"{":"}");function xt(t){const e=new Map,i=new WeakMap;return r=>{const n=typeof r=="string"?e:i;if(n.has(r)){const o=n.get(r);return o.lastIndex=0,o}const s=t(r);return n.set(r,s),s}}var po=".cm-panel",Gm=".cm-panels",Um=".cm-diagnosticText-clickable",yr=".cm-tooltip-fold",Sr=".cm-tooltip-hover",Fm="cm-matchingTag",Hm="cm-nonmatchingTag",Km=".cm-bidi-isolate",Jm=".cm-bidi-ltr",kr=".cm-status-fix-menu",xn=".cm-status-message",Ah=".cm-diagnosticAction",eg=typeof location=="object"&&new RegExp(String.raw`\.(?:${OT})\.org$`,"u").test(location.hostname),tg=(()=>{const{vendor:t,userAgent:e,maxTouchPoints:i,platform:r}=navigator;return(t==null?void 0:t.includes("Apple Computer"))&&(e.includes("Mobile/")||i>2)||r.includes("Mac")})(),vT=class{get closing(){return ng(this.first,this.type,this.state,!0)}get selfClosing(){return zm.includes(this.name)||(this.type==="ext"||Nm.includes(this.name))&&ng(this.last,this.type,this.state)}get from(){const{first:{from:t,to:e},state:i}=this;return t+i.sliceDoc(t,e).lastIndexOf("<")}get to(){const{last:{from:t,to:e},state:i}=this;return t+i.sliceDoc(t,e).indexOf(">")+1}constructor(t,e,i,r,n){this.type=t,this.name=e,this.first=i,this.last=r,this.state=n}},ig=({name:t})=>/-(?:ext|html)tag-(?!bracket)/u.test(t),rg=t=>{const e=new RegExp(`-htmltag-${t}`,"u"),i=new RegExp(`-exttag-${t}`,"u");return({name:r},n)=>(n==="ext"?i:e).test(r)},Oo=rg("bracket"),Rh=rg("name"),ng=(t,e,i,r)=>Oo(t,e)&&i.sliceDoc(t.from,t.to)[r?"endsWith":"startsWith"]("/"),sg=(t,{from:e,to:i})=>t.sliceDoc(e,i).trim().toLowerCase(),Qn=(t,e)=>{const i=e.name.includes("exttag")?"ext":"html";let{nextSibling:r,prevSibling:n}=e,s=Rh(e,i)?e:null;for(;r&&!Oo(r,i);)({nextSibling:r}=r);if(!r||Oo(r,i)&&t.sliceDoc(r.from,r.from+1)==="<")return null;for(;n&&!Oo(n,i);)s!=null||(s=Rh(n,i)?n:null),{prevSibling:n}=n;const o=sg(t,s);return new vT(i,o,n,r,t)},yT=(t,e)=>{const{type:i,name:r,closing:n}=e,s=n?"prevSibling":"nextSibling",o=n?"first":"last";let a=n?-1:1,l=e[o][s];for(;l;){if(Rh(l,i)&&sg(t,l)===r){const h=Qn(t,l);if(h){if(h.closing?a--:a+=h.selfClosing?0:1,a===0)return h;l=h[o]}}l=l[s]}return null},og=(t,e)=>{const i=fi(t,e);if(!i)return null;let r=i.resolve(e,-1);if(!ig(r)&&(r=i.resolve(e,1),!ig(r)))return null;const n=Qn(t,r);if(n){if(n.selfClosing)return{matched:!0,start:n}}else return null;const s=yT(t,n);return s?{matched:!0,start:n,end:s}:{matched:!1,start:n}},ST=A.mark({class:Fm}),kT=A.mark({class:Hm}),wT=ve.define({create(){return A.none},update(t,{docChanged:e,selection:i,state:r}){if(!e&&!i)return t;const n=[];for(const s of r.selection.ranges)if(s.empty){const o=og(r,s.head);if(o){const a=o.matched?ST:kT,{start:{from:l,to:h,closing:c},end:f}=o;n.push(a.range(l,h)),f&&n[c?"unshift":"push"](a.range(f.from,f.to))}}return A.set(n)},provide(t){return x.decorations.from(t)}}),ag=Km.slice(1),Xh=A.mark({class:`${ag} ${Jm.slice(1)}`,bidiIsolate:se.LTR}),lg=A.mark({class:ag}),hg=({visibleRanges:t,state:e,textDirection:i})=>{const r=new jt;if(i===se.RTL)for(const{from:n,to:s}of t){let o=I(e).resolve(n,1),a=0,l=0,h=0;for(;o&&o.to<=s;){const{name:c,from:f,to:u,nextSibling:d}=o;if(/-(?:ext|html)tag-bracket/u.test(c)&&e.sliceDoc(f,u).includes("<")){const p=Qn(e,d);p&&r.add(p.from,p.to,Xh)}else!a&&!l&&c.includes($.tableDefinition)?/-html-(?:table|tr)/u.test(c)?(l=e.doc.lineAt(f).to,r.add(f,l,Xh)):a=f:l&&f>l?l=0:a&&c.includes($.tableDelimiter2)?(r.add(a,f,Xh),a=0):/-(?:template|parserfunction)-delimiter/u.test(c)?(h&&r.add(h,f,lg),h=u):h&&/-(?:template|parserfunction)-bracket/u.test(c)&&(e.sliceDoc(f,f+1)==="}"&&r.add(h,f,lg),h=0);o=o.nextSibling}}return r.finish()},xT=be.fromClass(class{constructor(t){this.isolates=hg(t),this.tree=I(t.state),this.dir=t.textDirection}update({docChanged:t,viewportChanged:e,state:i,view:r}){const n=I(i),{textDirection:s}=r;(t||e||n!==this.tree||s!==this.dir)&&(this.isolates=hg(r),this.tree=n,this.dir=s)}},{provide(t){const e=i=>{var r,n;return(n=(r=i.plugin(t))==null?void 0:r.isolates)!=null?n:A.none};return Bt.lowest([x.decorations.of(e),x.bidiIsolatedRanges.of(e)])}}),QT=t=>{let{state:e}=t,i=e.doc.lineAt(e.selection.main.from),r=Mh(t.state,i.from);return r.line?$T(t):r.block?TT(t):!1};function Wh(t,e){return({state:i,dispatch:r})=>{if(i.readOnly)return!1;let n=t(e,i);return n?(r(i.update(n)),!0):!1}}var $T=Wh(AT,0),PT=Wh(cg,0),TT=Wh((t,e)=>cg(t,e,ZT(e)),0);function Mh(t,e){let i=t.languageDataAt("commentTokens",e,1);return i.length?i[0]:{}}var $n=50;function CT(t,{open:e,close:i},r,n){let s=t.sliceDoc(r-$n,r),o=t.sliceDoc(n,n+$n),a=/\s*$/.exec(s)[0].length,l=/^\s*/.exec(o)[0].length,h=s.length-a;if(s.slice(h-e.length,h)==e&&o.slice(l,l+i.length)==i)return{open:{pos:r-a,margin:a&&1},close:{pos:n+l,margin:l&&1}};let c,f;n-r<=2*$n?c=f=t.sliceDoc(r,n):(c=t.sliceDoc(r,r+$n),f=t.sliceDoc(n-$n,n));let u=/^\s*/.exec(c)[0].length,d=/\s*$/.exec(f)[0].length,p=f.length-d-i.length;return c.slice(u,u+e.length)==e&&f.slice(p,p+i.length)==i?{open:{pos:r+u+e.length,margin:/\s/.test(c.charAt(u+e.length))?1:0},close:{pos:n-d-i.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function ZT(t){let e=[];for(let i of t.selection.ranges){let r=t.doc.lineAt(i.from),n=i.to<=r.to?r:t.doc.lineAt(i.to);n.from>r.from&&n.from==i.to&&(n=i.to==r.to+1?r:t.doc.lineAt(i.to-1));let s=e.length-1;s>=0&&e[s].to>r.from?e[s].to=n.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:n.to})}return e}function cg(t,e,i=e.selection.ranges){let r=i.map(s=>Mh(e,s.from).block);if(!r.every(s=>s))return null;let n=i.map((s,o)=>CT(e,r[o],s.from,s.to));if(t!=2&&!n.every(s=>s))return{changes:e.changes(i.map((s,o)=>n[o]?[]:[{from:s.from,insert:r[o].open+" "},{from:s.to,insert:" "+r[o].close}]))};if(t!=1&&n.some(s=>s)){let s=[];for(let o=0,a;o<n.length;o++)if(a=n[o]){let l=r[o],{open:h,close:c}=a;s.push({from:h.pos-l.open.length,to:h.pos+h.margin},{from:c.pos-c.margin,to:c.pos+l.close.length})}return{changes:s}}return null}function AT(t,e,i=e.selection.ranges){let r=[],n=-1;for(let{from:s,to:o}of i){let a=r.length,l=1e9,h=Mh(e,s).line;if(h){for(let c=s;c<=o;){let f=e.doc.lineAt(c);if(f.from>n&&(s==o||o>f.from)){n=f.from;let u=/^\s*/.exec(f.text)[0].length,d=u==f.length,p=f.text.slice(u,u+h.length)==h?u:-1;u<f.text.length&&u<l&&(l=u),r.push({line:f,comment:p,token:h,indent:u,empty:d,single:!1})}c=f.to+1}if(l<1e9)for(let c=a;c<r.length;c++)r[c].indent<r[c].line.text.length&&(r[c].indent=l);r.length==a+1&&(r[a].single=!0)}}if(t!=2&&r.some(s=>s.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:a,token:l,indent:h,empty:c,single:f}of r)(f||!c)&&s.push({from:a.from+h,insert:l+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(t!=1&&r.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:a,token:l}of r)if(a>=0){let h=o.from+a,c=h+l.length;o.text[c-o.from]==" "&&c++,s.push({from:h,to:c})}return{changes:s}}return null}var Eh=Lt.define(),RT=Lt.define(),XT=R.define(),fg=R.define({combine(t){return mt(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,i)=>i},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,i)=>(r,n)=>e(r,n)||i(r,n)})}}),ug=ve.define({create(){return Pn.empty},update(t,e){let i=e.state.facet(fg),r=e.annotation(Eh);if(r){let l=Ft.fromTransaction(e,r.selection),h=r.side,c=h==0?t.undone:t.done;return l?c=bo(c,c.length,i.minDepth,l):c=Og(c,e.startState.selection),new Pn(h==0?r.rest:c,h==0?c:r.rest)}let n=e.annotation(RT);if((n=="full"||n=="before")&&(t=t.isolate()),e.annotation(Re.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let s=Ft.fromTransaction(e),o=e.annotation(Re.time),a=e.annotation(Re.userEvent);return s?t=t.addChanges(s,o,a,i,e):e.selection&&(t=t.addSelection(e.startState.selection,o,a,i.newGroupDelay)),(n=="full"||n=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Pn(t.done.map(Ft.fromJSON),t.undone.map(Ft.fromJSON))}});function WT(t={}){return[ug,fg.of(t),x.domEventHandlers({beforeinput(e,i){let r=e.inputType=="historyUndo"?dg:e.inputType=="historyRedo"?go:null;return r?(e.preventDefault(),r(i)):!1}})]}function mo(t,e){return function({state:i,dispatch:r}){if(!e&&i.readOnly)return!1;let n=i.field(ug,!1);if(!n)return!1;let s=n.pop(t,i,e);return s?(r(s),!0):!1}}var dg=mo(0,!1),go=mo(1,!1),MT=mo(0,!0),ET=mo(1,!0),Ft=class zn{constructor(e,i,r,n,s){this.changes=e,this.effects=i,this.mapped=r,this.startSelection=n,this.selectionsAfter=s}setSelAfter(e){return new zn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,i,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(i=this.mapped)===null||i===void 0?void 0:i.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(n=>n.toJSON())}}static fromJSON(e){return new zn(e.changes&&pt.fromJSON(e.changes),[],e.mapped&&Ni.fromJSON(e.mapped),e.startSelection&&k.fromJSON(e.startSelection),e.selectionsAfter.map(k.fromJSON))}static fromTransaction(e,i){let r=st;for(let n of e.startState.facet(XT)){let s=n(e);s.length&&(r=r.concat(s))}return!r.length&&e.changes.empty?null:new zn(e.changes.invert(e.startState.doc),r,void 0,i||e.startState.selection,st)}static selection(e){return new zn(void 0,st,void 0,void 0,e)}};function bo(t,e,i,r){let n=e+1>i+20?e-i-1:0,s=t.slice(n,e);return s.push(r),s}function qT(t,e){let i=[],r=!1;return t.iterChangedRanges((n,s)=>i.push(n,s)),e.iterChangedRanges((n,s,o,a)=>{for(let l=0;l<i.length;){let h=i[l++],c=i[l++];a>=h&&o<=c&&(r=!0)}}),r}function DT(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((i,r)=>i.empty!=e.ranges[r].empty).length===0}function pg(t,e){return t.length?e.length?t.concat(e):t:e}var st=[],YT=200;function Og(t,e){if(t.length){let i=t[t.length-1],r=i.selectionsAfter.slice(Math.max(0,i.selectionsAfter.length-YT));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),bo(t,t.length-1,1e9,i.setSelAfter(r)))}else return[Ft.selection([e])]}function VT(t){let e=t[t.length-1],i=t.slice();return i[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),i}function qh(t,e){if(!t.length)return t;let i=t.length,r=st;for(;i;){let n=_T(t[i-1],e,r);if(n.changes&&!n.changes.empty||n.effects.length){let s=t.slice(0,i);return s[i-1]=n,s}else e=n.mapped,i--,r=n.selectionsAfter}return r.length?[Ft.selection(r)]:st}function _T(t,e,i){let r=pg(t.selectionsAfter.length?t.selectionsAfter.map(a=>a.map(e)):st,i);if(!t.changes)return Ft.selection(r);let n=t.changes.map(e),s=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(s):s;return new Ft(n,B.mapEffects(t.effects,e),o,t.startSelection.map(s),r)}var BT=/^(input\.type|delete)($|\.)/,Pn=class Nn{constructor(e,i,r=0,n=void 0){this.done=e,this.undone=i,this.prevTime=r,this.prevUserEvent=n}isolate(){return this.prevTime?new Nn(this.done,this.undone):this}addChanges(e,i,r,n,s){let o=this.done,a=o[o.length-1];return a&&a.changes&&!a.changes.empty&&e.changes&&(!r||BT.test(r))&&(!a.selectionsAfter.length&&i-this.prevTime<n.newGroupDelay&&n.joinToEvent(s,qT(a.changes,e.changes))||r=="input.type.compose")?o=bo(o,o.length-1,n.minDepth,new Ft(e.changes.compose(a.changes),pg(B.mapEffects(e.effects,a.changes),a.effects),a.mapped,a.startSelection,st)):o=bo(o,o.length,n.minDepth,e),new Nn(o,st,i,r)}addSelection(e,i,r,n){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:st;return s.length>0&&i-this.prevTime<n&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&DT(s[s.length-1],e)?this:new Nn(Og(this.done,e),this.undone,i,r)}addMapping(e){return new Nn(qh(this.done,e),qh(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,i,r){let n=e==0?this.done:this.undone;if(n.length==0)return null;let s=n[n.length-1],o=s.selectionsAfter[0]||i.selection;if(r&&s.selectionsAfter.length)return i.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:Eh.of({side:e,rest:VT(n),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let a=n.length==1?st:n.slice(0,n.length-1);return s.mapped&&(a=qh(a,s.mapped)),i.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:Eh.of({side:e,rest:a,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}};Pn.empty=new Pn(st,st);var LT=[{key:"Mod-z",run:dg,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:go,preventDefault:!0},{linux:"Ctrl-Shift-z",run:go,preventDefault:!0},{key:"Mod-u",run:MT,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:ET,preventDefault:!0}];function wr(t,e){return k.create(t.ranges.map(e),t.mainIndex)}function Qt(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function $t({state:t,dispatch:e},i){let r=wr(t.selection,i);return r.eq(t.selection,!0)?!1:(e(Qt(t,r)),!0)}function vo(t,e){return k.cursor(e?t.to:t.from)}function mg(t,e){return $t(t,i=>i.empty?t.moveByChar(i,e):vo(i,e))}function Ae(t){return t.textDirectionAt(t.state.selection.main.head)==se.LTR}var gg=t=>mg(t,!Ae(t)),bg=t=>mg(t,Ae(t));function vg(t,e){return $t(t,i=>i.empty?t.moveByGroup(i,e):vo(i,e))}var jT=t=>vg(t,!Ae(t)),zT=t=>vg(t,Ae(t)),qA=typeof Intl!="undefined"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function NT(t,e,i){if(e.type.prop(i))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function yo(t,e,i){let r=I(t).resolveInner(e.head),n=i?j.closedBy:j.openedBy;for(let l=e.head;;){let h=i?r.childAfter(l):r.childBefore(l);if(!h)break;NT(t,h,n)?r=h:l=i?h.to:h.from}let s=r.type.prop(n),o,a;return s&&(o=i?qe(t,r.from,1):qe(t,r.to,-1))&&o.matched?a=i?o.end.to:o.end.from:a=i?r.to:r.from,k.cursor(a,i?-1:1)}var IT=t=>$t(t,e=>yo(t.state,e,!Ae(t))),GT=t=>$t(t,e=>yo(t.state,e,Ae(t)));function yg(t,e){return $t(t,i=>{if(!i.empty)return vo(i,e);let r=t.moveVertically(i,e);return r.head!=i.head?r:t.moveToLineBoundary(i,e)})}var Sg=t=>yg(t,!1),kg=t=>yg(t,!0);function wg(t){let e=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,i=0,r=0,n;if(e){for(let s of t.state.facet(x.scrollMargins)){let o=s(t);o!=null&&o.top&&(i=Math.max(o==null?void 0:o.top,i)),o!=null&&o.bottom&&(r=Math.max(o==null?void 0:o.bottom,r))}n=t.scrollDOM.clientHeight-i-r}else n=(t.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:i,marginBottom:r,selfScroll:e,height:Math.max(t.defaultLineHeight,n-5)}}function xg(t,e){let i=wg(t),{state:r}=t,n=wr(r.selection,o=>o.empty?t.moveVertically(o,e,i.height):vo(o,e));if(n.eq(r.selection))return!1;let s;if(i.selfScroll){let o=t.coordsAtPos(r.selection.main.head),a=t.scrollDOM.getBoundingClientRect(),l=a.top+i.marginTop,h=a.bottom-i.marginBottom;o&&o.top>l&&o.bottom<h&&(s=x.scrollIntoView(n.main.head,{y:"start",yMargin:o.top-l}))}return t.dispatch(Qt(r,n),{effects:s}),!0}var Qg=t=>xg(t,!1),Dh=t=>xg(t,!0);function pi(t,e,i){let r=t.lineBlockAt(e.head),n=t.moveToLineBoundary(e,i);if(n.head==e.head&&n.head!=(i?r.to:r.from)&&(n=t.moveToLineBoundary(e,i,!1)),!i&&n.head==r.from&&r.length){let s=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;s&&e.head!=r.from+s&&(n=k.cursor(r.from+s))}return n}var UT=t=>$t(t,e=>pi(t,e,!0)),FT=t=>$t(t,e=>pi(t,e,!1)),HT=t=>$t(t,e=>pi(t,e,!Ae(t))),KT=t=>$t(t,e=>pi(t,e,Ae(t))),JT=t=>$t(t,e=>k.cursor(t.lineBlockAt(e.head).from,1)),eC=t=>$t(t,e=>k.cursor(t.lineBlockAt(e.head).to,-1));function tC(t,e,i){let r=!1,n=wr(t.selection,s=>{let o=qe(t,s.head,-1)||qe(t,s.head,1)||s.head>0&&qe(t,s.head-1,1)||s.head<t.doc.length&&qe(t,s.head+1,-1);if(!o||!o.end)return s;r=!0;let a=o.start.from==s.head?o.end.to:o.end.from;return i?k.range(s.anchor,a):k.cursor(a)});return r?(e(Qt(t,n)),!0):!1}var iC=({state:t,dispatch:e})=>tC(t,e,!1);function ot(t,e){let i=wr(t.state.selection,r=>{let n=e(r);return k.range(r.anchor,n.head,n.goalColumn,n.bidiLevel||void 0)});return i.eq(t.state.selection)?!1:(t.dispatch(Qt(t.state,i)),!0)}function $g(t,e){return ot(t,i=>t.moveByChar(i,e))}var Pg=t=>$g(t,!Ae(t)),Tg=t=>$g(t,Ae(t));function Cg(t,e){return ot(t,i=>t.moveByGroup(i,e))}var rC=t=>Cg(t,!Ae(t)),nC=t=>Cg(t,Ae(t)),sC=t=>ot(t,e=>yo(t.state,e,!Ae(t))),oC=t=>ot(t,e=>yo(t.state,e,Ae(t)));function Zg(t,e){return ot(t,i=>t.moveVertically(i,e))}var Ag=t=>Zg(t,!1),Rg=t=>Zg(t,!0);function Xg(t,e){return ot(t,i=>t.moveVertically(i,e,wg(t).height))}var Wg=t=>Xg(t,!1),Mg=t=>Xg(t,!0),aC=t=>ot(t,e=>pi(t,e,!0)),lC=t=>ot(t,e=>pi(t,e,!1)),hC=t=>ot(t,e=>pi(t,e,!Ae(t))),cC=t=>ot(t,e=>pi(t,e,Ae(t))),fC=t=>ot(t,e=>k.cursor(t.lineBlockAt(e.head).from)),uC=t=>ot(t,e=>k.cursor(t.lineBlockAt(e.head).to)),Eg=({state:t,dispatch:e})=>(e(Qt(t,{anchor:0})),!0),qg=({state:t,dispatch:e})=>(e(Qt(t,{anchor:t.doc.length})),!0),Dg=({state:t,dispatch:e})=>(e(Qt(t,{anchor:t.selection.main.anchor,head:0})),!0),Yg=({state:t,dispatch:e})=>(e(Qt(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),dC=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),pC=({state:t,dispatch:e})=>{let i=ko(t).map(({from:r,to:n})=>k.range(r,Math.min(n+1,t.doc.length)));return e(t.update({selection:k.create(i),userEvent:"select"})),!0},OC=({state:t,dispatch:e})=>{let i=wr(t.selection,r=>{let n=I(t),s=n.resolveStack(r.from,1);if(r.empty){let o=n.resolveStack(r.from,-1);o.node.from>=s.node.from&&o.node.to<=s.node.to&&(s=o)}for(let o=s;o;o=o.next){let{node:a}=o;if((a.from<r.from&&a.to>=r.to||a.to>r.to&&a.from<=r.from)&&o.next)return k.range(a.to,a.from)}return r});return i.eq(t.selection)?!1:(e(Qt(t,i)),!0)};function Vg(t,e){let{state:i}=t,r=i.selection,n=i.selection.ranges.slice();for(let s of i.selection.ranges){let o=i.doc.lineAt(s.head);if(e?o.to<t.state.doc.length:o.from>0)for(let a=s;;){let l=t.moveVertically(a,e);if(l.head<o.from||l.head>o.to){n.some(h=>h.head==l.head)||n.push(l);break}else{if(l.head==a.head)break;a=l}}}return n.length==r.ranges.length?!1:(t.dispatch(Qt(i,k.create(n,n.length-1))),!0)}var mC=t=>Vg(t,!1),gC=t=>Vg(t,!0),bC=({state:t,dispatch:e})=>{let i=t.selection,r=null;return i.ranges.length>1?r=k.create([i.main]):i.main.empty||(r=k.create([k.cursor(i.main.head)])),r?(e(Qt(t,r)),!0):!1};function Tn(t,e){if(t.state.readOnly)return!1;let i="delete.selection",{state:r}=t,n=r.changeByRange(s=>{let{from:o,to:a}=s;if(o==a){let l=e(s);l<o?(i="delete.backward",l=So(t,l,!1)):l>o&&(i="delete.forward",l=So(t,l,!0)),o=Math.min(o,l),a=Math.max(a,l)}else o=So(t,o,!1),a=So(t,a,!0);return o==a?{range:s}:{changes:{from:o,to:a},range:k.cursor(o,o<s.head?-1:1)}});return n.changes.empty?!1:(t.dispatch(r.update(n,{scrollIntoView:!0,userEvent:i,effects:i=="delete.selection"?x.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function So(t,e,i){if(t instanceof x)for(let r of t.state.facet(x.atomicRanges).map(n=>n(t)))r.between(e,e,(n,s)=>{n<e&&s>e&&(e=i?s:n)});return e}var _g=(t,e,i)=>Tn(t,r=>{let n=r.from,{state:s}=t,o=s.doc.lineAt(n),a,l;if(i&&!e&&n>o.from&&n<o.from+200&&!/[^ \t]/.test(a=o.text.slice(0,n-o.from))){if(a[a.length-1]==" ")return n-1;let h=Gi(a,s.tabSize),c=h%Ri(s)||Ri(s);for(let f=0;f<c&&a[a.length-1-f]==" ";f++)n--;l=n}else l=Te(o.text,n-o.from,e,e)+o.from,l==n&&o.number!=(e?s.doc.lines:1)?l+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(l-o.from,n-o.from))&&(l=Te(o.text,l-o.from,!1,!1)+o.from);return l}),Yh=t=>_g(t,!1,!0),Bg=t=>_g(t,!0,!1),Lg=(t,e)=>Tn(t,i=>{let r=i.head,{state:n}=t,s=n.doc.lineAt(r),o=n.charCategorizer(r);for(let a=null;;){if(r==(e?s.to:s.from)){r==i.head&&s.number!=(e?n.doc.lines:1)&&(r+=e?1:-1);break}let l=Te(s.text,r-s.from,e)+s.from,h=s.text.slice(Math.min(r,l)-s.from,Math.max(r,l)-s.from),c=o(h);if(a!=null&&c!=a)break;(h!=" "||r!=i.head)&&(a=c),r=l}return r}),jg=t=>Lg(t,!1),vC=t=>Lg(t,!0),yC=t=>Tn(t,e=>{let i=t.lineBlockAt(e.head).to;return e.head<i?i:Math.min(t.state.doc.length,e.head+1)}),SC=t=>Tn(t,e=>{let i=t.moveToLineBoundary(e,!1).head;return e.head>i?i:Math.max(0,e.head-1)}),kC=t=>Tn(t,e=>{let i=t.moveToLineBoundary(e,!0).head;return e.head<i?i:Math.min(t.state.doc.length,e.head+1)}),wC=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:F.of(["",""])},range:k.cursor(r.from)}));return e(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0},xC=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let n=r.from,s=t.doc.lineAt(n),o=n==s.from?n-1:Te(s.text,n-s.from,!1)+s.from,a=n==s.to?n+1:Te(s.text,n-s.from,!0)+s.from;return{changes:{from:o,to:a,insert:t.doc.slice(n,a).append(t.doc.slice(o,n))},range:k.cursor(a)}});return i.changes.empty?!1:(e(t.update(i,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function ko(t){let e=[],i=-1;for(let r of t.selection.ranges){let n=t.doc.lineAt(r.from),s=t.doc.lineAt(r.to);if(!r.empty&&r.to==s.from&&(s=t.doc.lineAt(r.to-1)),i>=n.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(r)}else e.push({from:n.from,to:s.to,ranges:[r]});i=s.number+1}return e}function zg(t,e,i){if(t.readOnly)return!1;let r=[],n=[];for(let s of ko(t)){if(i?s.to==t.doc.length:s.from==0)continue;let o=t.doc.lineAt(i?s.to+1:s.from-1),a=o.length+1;if(i){r.push({from:s.to,to:o.to},{from:s.from,insert:o.text+t.lineBreak});for(let l of s.ranges)n.push(k.range(Math.min(t.doc.length,l.anchor+a),Math.min(t.doc.length,l.head+a)))}else{r.push({from:o.from,to:s.from},{from:s.to,insert:t.lineBreak+o.text});for(let l of s.ranges)n.push(k.range(l.anchor-a,l.head-a))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:k.create(n,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}var QC=({state:t,dispatch:e})=>zg(t,e,!1),$C=({state:t,dispatch:e})=>zg(t,e,!0);function Ng(t,e,i){if(t.readOnly)return!1;let r=[];for(let n of ko(t))i?r.push({from:n.from,insert:t.doc.slice(n.from,n.to)+t.lineBreak}):r.push({from:n.to,insert:t.lineBreak+t.doc.slice(n.from,n.to)});return e(t.update({changes:r,scrollIntoView:!0,userEvent:"input.copyline"})),!0}var PC=({state:t,dispatch:e})=>Ng(t,e,!1),TC=({state:t,dispatch:e})=>Ng(t,e,!0),CC=t=>{if(t.state.readOnly)return!1;let{state:e}=t,i=e.changes(ko(e).map(({from:n,to:s})=>(n>0?n--:s<e.doc.length&&s++,{from:n,to:s}))),r=wr(e.selection,n=>{let s;if(t.lineWrapping){let o=t.lineBlockAt(n.head),a=t.coordsAtPos(n.head,n.assoc||1);a&&(s=o.bottom+t.documentTop-a.bottom+t.defaultLineHeight/2)}return t.moveVertically(n,!0,s)}).map(i);return t.dispatch({changes:i,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function ZC(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let i=I(t).resolveInner(e),r=i.childBefore(e),n=i.childAfter(e),s;return r&&n&&r.to<=e&&n.from>=e&&(s=r.type.prop(j.closedBy))&&s.indexOf(n.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(n.from).from&&!/\S/.test(t.sliceDoc(r.to,n.from))?{from:r.to,to:n.from}:null}var Ig=Gg(!1),AC=Gg(!0);function Gg(t){return({state:e,dispatch:i})=>{if(e.readOnly)return!1;let r=e.changeByRange(n=>{let{from:s,to:o}=n,a=e.doc.lineAt(s),l=!t&&s==o&&ZC(e,s);t&&(s=o=(o<=a.to?a:e.doc.lineAt(o)).to);let h=new Hs(e,{simulateBreak:s,simulateDoubleBreak:!!l}),c=ql(h,s);for(c==null&&(c=Gi(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));o<a.to&&/\s/.test(a.text[o-a.from]);)o++;l?{from:s,to:o}=l:s>a.from&&s<a.from+100&&!/\S/.test(a.text.slice(0,s))&&(s=a.from);let f=["",fn(e,c)];return l&&f.push(fn(e,h.lineIndent(a.from,-1))),{changes:{from:s,to:o,insert:F.of(f)},range:k.cursor(s+1+f[1].length)}});return i(e.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function Vh(t,e){let i=-1;return t.changeByRange(r=>{let n=[];for(let o=r.from;o<=r.to;){let a=t.doc.lineAt(o);a.number>i&&(r.empty||r.to>a.from)&&(e(a,n,r),i=a.number),o=a.to+1}let s=t.changes(n);return{changes:n,range:k.range(s.mapPos(r.anchor,1),s.mapPos(r.head,1))}})}var RC=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=Object.create(null),r=new Hs(t,{overrideIndentation:s=>{let o=i[s];return o==null?-1:o}}),n=Vh(t,(s,o,a)=>{let l=ql(r,s.from);if(l==null)return;/\S/.test(s.text)||(l=0);let h=/^\s*/.exec(s.text)[0],c=fn(t,l);(h!=c||a.from<s.from+h.length)&&(i[s.from]=l,o.push({from:s.from,to:s.from+h.length,insert:c}))});return n.changes.empty||e(t.update(n,{userEvent:"indent"})),!0},_h=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Vh(t,(i,r)=>{r.push({from:i.from,insert:t.facet(ur)})}),{userEvent:"input.indent"})),!0),Bh=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Vh(t,(i,r)=>{let n=/^\s*/.exec(i.text)[0];if(!n)return;let s=Gi(n,t.tabSize),o=0,a=fn(t,Math.max(0,s-Ri(t)));for(;o<n.length&&o<a.length&&n.charCodeAt(o)==a.charCodeAt(o);)o++;r.push({from:i.from+o,to:i.from+n.length,insert:a.slice(o)})}),{userEvent:"delete.dedent"})),!0),XC=t=>(t.setTabFocusMode(),!0),WC=[{key:"Ctrl-b",run:gg,shift:Pg,preventDefault:!0},{key:"Ctrl-f",run:bg,shift:Tg},{key:"Ctrl-p",run:Sg,shift:Ag},{key:"Ctrl-n",run:kg,shift:Rg},{key:"Ctrl-a",run:JT,shift:fC},{key:"Ctrl-e",run:eC,shift:uC},{key:"Ctrl-d",run:Bg},{key:"Ctrl-h",run:Yh},{key:"Ctrl-k",run:yC},{key:"Ctrl-Alt-h",run:jg},{key:"Ctrl-o",run:wC},{key:"Ctrl-t",run:xC},{key:"Ctrl-v",run:Dh}],MC=[{key:"ArrowLeft",run:gg,shift:Pg,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:jT,shift:rC,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:HT,shift:hC,preventDefault:!0},{key:"ArrowRight",run:bg,shift:Tg,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:zT,shift:nC,preventDefault:!0},{mac:"Cmd-ArrowRight",run:KT,shift:cC,preventDefault:!0},{key:"ArrowUp",run:Sg,shift:Ag,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Eg,shift:Dg},{mac:"Ctrl-ArrowUp",run:Qg,shift:Wg},{key:"ArrowDown",run:kg,shift:Rg,preventDefault:!0},{mac:"Cmd-ArrowDown",run:qg,shift:Yg},{mac:"Ctrl-ArrowDown",run:Dh,shift:Mg},{key:"PageUp",run:Qg,shift:Wg},{key:"PageDown",run:Dh,shift:Mg},{key:"Home",run:FT,shift:lC,preventDefault:!0},{key:"Mod-Home",run:Eg,shift:Dg},{key:"End",run:UT,shift:aC,preventDefault:!0},{key:"Mod-End",run:qg,shift:Yg},{key:"Enter",run:Ig,shift:Ig},{key:"Mod-a",run:dC},{key:"Backspace",run:Yh,shift:Yh,preventDefault:!0},{key:"Delete",run:Bg,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:jg,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:vC,preventDefault:!0},{mac:"Mod-Backspace",run:SC,preventDefault:!0},{mac:"Mod-Delete",run:kC,preventDefault:!0}].concat(WC.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),EC=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:IT,shift:sC},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:GT,shift:oC},{key:"Alt-ArrowUp",run:QC},{key:"Shift-Alt-ArrowUp",run:PC},{key:"Alt-ArrowDown",run:$C},{key:"Shift-Alt-ArrowDown",run:TC},{key:"Mod-Alt-ArrowUp",run:mC},{key:"Mod-Alt-ArrowDown",run:gC},{key:"Escape",run:bC},{key:"Mod-Enter",run:AC},{key:"Alt-l",mac:"Ctrl-l",run:pC},{key:"Mod-i",run:OC,preventDefault:!0},{key:"Mod-[",run:Bh},{key:"Mod-]",run:_h},{key:"Mod-Alt-\\",run:RC},{key:"Shift-Mod-k",run:CC},{key:"Shift-Mod-\\",run:iC},{key:"Mod-/",run:QT},{key:"Alt-A",run:PT},{key:"Ctrl-m",mac:"Shift-Alt-m",run:XC}].concat(MC),qC={key:"Tab",run:_h,shift:Bh},Ug=class{constructor(t,e,i){this.from=t,this.to=e,this.diagnostic=i}},Cn=class Wy{constructor(e,i,r){this.diagnostics=e,this.panel=i,this.selected=r}static init(e,i,r){let n=r.facet(Dt).markerFilter;n&&(e=n(e,r));let s=e.slice().sort((d,p)=>d.from-p.from||d.to-p.to),o=new jt,a=[],l=0,h=r.doc.iter(),c=0,f=r.doc.length;for(let d=0;;){let p=d==s.length?null:s[d];if(!p&&!a.length)break;let O,g;if(a.length)O=l,g=a.reduce((v,S)=>Math.min(v,S.to),p&&p.from>O?p.from:1e8);else{if(O=p.from,O>f)break;g=p.to,a.push(p),d++}for(;d<s.length;){let v=s[d];if(v.from==O&&(v.to>v.from||v.to==O))a.push(v),d++,g=Math.min(v.to,g);else{g=Math.min(v.from,g);break}}g=Math.min(g,f);let b=!1;if(a.some(v=>v.from==O&&(v.to==g||g==f))&&(b=O==g,!b&&g-O<10)){let v=O-(c+h.value.length);v>0&&(h.next(v),c=O);for(let S=O;;){if(S>=g){b=!0;break}if(!h.lineBreak&&c+h.value.length>S)break;S=c+h.value.length,c+=h.value.length,h.next()}}let y=o0(a);if(b)o.add(O,O,A.widget({widget:new NC(y),diagnostics:a.slice()}));else{let v=a.reduce((S,w)=>w.markClass?S+" "+w.markClass:S,"");o.add(O,g,A.mark({class:"cm-lintRange cm-lintRange-"+y+v,diagnostics:a.slice(),inclusiveEnd:a.some(S=>S.to>g)}))}if(l=g,l==f)break;for(let v=0;v<a.length;v++)a[v].to<=l&&a.splice(v--,1)}let u=o.finish();return new Wy(u,i,xr(u))}};function xr(t,e=null,i=0){let r=null;return t.between(i,1e9,(n,s,{spec:o})=>{if(!(e&&o.diagnostics.indexOf(e)<0))if(!r)r=new Ug(n,s,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new Ug(r.from,s,r.diagnostic)}}),r}function Fg(t,e){let i=e.pos,r=e.end||i,n=t.state.facet(Dt).hideOn(t,i,r);if(n!=null)return n;let s=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(o=>o.is(Zn))||t.changes.touchesRange(s.from,Math.max(s.to,r)))}function Hg(t,e){return t.field(Ge,!1)?e:e.concat(B.appendConfig.of(h0))}function DC(t,e){return{effects:Hg(t,[Zn.of(e)])}}var Zn=B.define(),Lh=B.define(),Kg=B.define(),Ge=ve.define({create(){return new Cn(A.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let i=t.diagnostics.map(e.changes),r=null,n=t.panel;if(t.selected){let s=e.changes.mapPos(t.selected.from,1);r=xr(i,t.selected.diagnostic,s)||xr(i,null,s)}!i.size&&n&&e.state.facet(Dt).autoPanel&&(n=null),t=new Cn(i,n,r)}for(let i of e.effects)if(i.is(Zn)){let r=e.state.facet(Dt).autoPanel?i.value.length?jh.open:null:t.panel;t=Cn.init(i.value,r,e.state)}else i.is(Lh)?t=new Cn(t.diagnostics,i.value?jh.open:null,t.selected):i.is(Kg)&&(t=new Cn(t.diagnostics,t.panel,i.value));return t},provide:t=>[rr.from(t,e=>e.panel),x.decorations.from(t,e=>e.diagnostics)]}),YC=A.mark({class:"cm-lintRange cm-lintRange-active"});function VC(t,e,i){let{diagnostics:r}=t.state.field(Ge),n,s=-1,o=-1;r.between(e-(i<0?1:0),e+(i>0?1:0),(l,h,{spec:c})=>{if(e>=l&&e<=h&&(l==h||(e>l||i>0)&&(e<h||i<0)))return n=c.diagnostics,s=l,o=h,!1});let a=t.state.facet(Dt).tooltipFilter;return n&&a&&(n=a(n,t.state)),n?{pos:s,end:o,above:t.state.doc.lineAt(s).to<o,create(){return{dom:Jg(t,n)}}}:null}function Jg(t,e){return Y("ul",{class:"cm-tooltip-lint"},e.map(i=>n0(t,i,!1)))}var _C=t=>{let e=t.state.field(Ge,!1);(!e||!e.panel)&&t.dispatch({effects:Hg(t.state,[Lh.of(!0)])});let i=Jr(t,jh.open);return i&&i.dom.querySelector(".cm-panel-lint ul").focus(),!0},e0=t=>{let e=t.state.field(Ge,!1);return!e||!e.panel?!1:(t.dispatch({effects:Lh.of(!1)}),!0)},t0=t=>{let e=t.state.field(Ge,!1);if(!e)return!1;let i=t.state.selection.main,r=e.diagnostics.iter(i.to+1);return!r.value&&(r=e.diagnostics.iter(0),!r.value||r.from==i.from&&r.to==i.to)?!1:(t.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)},BC=[{key:"Mod-Shift-m",run:_C,preventDefault:!0},{key:"F8",run:t0}],LC=be.fromClass(class{constructor(t){this.view=t,this.timeout=-1,this.set=!0;let{delay:e}=t.state.facet(Dt);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){clearTimeout(this.timeout);let t=Date.now();if(t<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-t);else{this.set=!1;let{state:e}=this.view,{sources:i}=e.facet(Dt);i.length&&jC(i.map(r=>Promise.resolve(r(this.view))),r=>{this.view.state.doc==e.doc&&this.view.dispatch(DC(this.view.state,r.reduce((n,s)=>n.concat(s))))},r=>{Ee(this.view.state,r)})}}update(t){let e=t.state.facet(Dt);(t.docChanged||e!=t.startState.facet(Dt)||e.needsRefresh&&e.needsRefresh(t))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function jC(t,e,i){let r=[],n=-1;for(let s of t)s.then(o=>{r.push(o),clearTimeout(n),r.length==t.length?e(r):n=setTimeout(()=>e(r),200)},i)}var Dt=R.define({combine(t){return{sources:t.map(e=>e.source).filter(e=>e!=null),...mt(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:i0,tooltipFilter:i0,needsRefresh:(e,i)=>e?i?r=>e(r)||i(r):e:i,hideOn:(e,i)=>e?i?(r,n,s)=>e(r,n,s)||i(r,n,s):e:i,autoPanel:(e,i)=>e||i})}}});function i0(t,e){return t?e?(i,r)=>e(t(i,r),r):t:e}function zC(t,e={}){return[Dt.of({source:t,config:e}),LC,h0]}function r0(t){let e=[];if(t)e:for(let{name:i}of t){for(let r=0;r<i.length;r++){let n=i[r];if(/[a-zA-Z]/.test(n)&&!e.some(s=>s.toLowerCase()==n.toLowerCase())){e.push(n);continue e}}e.push("")}return e}function n0(t,e,i){var r;let n=i?r0(e.actions):[];return Y("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},Y("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(r=e.actions)===null||r===void 0?void 0:r.map((s,o)=>{let a=!1,l=d=>{if(d.preventDefault(),a)return;a=!0;let p=xr(t.state.field(Ge).diagnostics,e);p&&s.apply(t,p.from,p.to)},{name:h}=s,c=n[o]?h.indexOf(n[o]):-1,f=c<0?h:[h.slice(0,c),Y("u",h.slice(c,c+1)),h.slice(c+1)],u=s.markClass?" "+s.markClass:"";return Y("button",{type:"button",class:"cm-diagnosticAction"+u,onclick:l,onmousedown:l,"aria-label":` Action: ${h}${c<0?"":` (access key "${n[o]})"`}.`},f)}),e.source&&Y("div",{class:"cm-diagnosticSource"},e.source))}var NC=class extends gt{constructor(t){super(),this.sev=t}eq(t){return t.sev==this.sev}toDOM(){return Y("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}},s0=class{constructor(t,e){this.diagnostic=e,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=n0(t,e,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},jh=class My{constructor(e){this.view=e,this.items=[];let i=n=>{if(n.keyCode==27)e0(this.view),this.view.focus();else if(n.keyCode==38||n.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(n.keyCode==40||n.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(n.keyCode==36)this.moveSelection(0);else if(n.keyCode==35)this.moveSelection(this.items.length-1);else if(n.keyCode==13)this.view.focus();else if(n.keyCode>=65&&n.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],o=r0(s.actions);for(let a=0;a<o.length;a++)if(o[a].toUpperCase().charCodeAt(0)==n.keyCode){let l=xr(this.view.state.field(Ge).diagnostics,s);l&&s.actions[a].apply(e,l.from,l.to)}}else return;n.preventDefault()},r=n=>{for(let s=0;s<this.items.length;s++)this.items[s].dom.contains(n.target)&&this.moveSelection(s)};this.list=Y("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:i,onclick:r}),this.dom=Y("div",{class:"cm-panel-lint"},this.list,Y("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>e0(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(Ge).selected;if(!e)return-1;for(let i=0;i<this.items.length;i++)if(this.items[i].diagnostic==e.diagnostic)return i;return-1}update(){let{diagnostics:e,selected:i}=this.view.state.field(Ge),r=0,n=!1,s=null,o=new Set;for(e.between(0,this.view.state.doc.length,(a,l,{spec:h})=>{for(let c of h.diagnostics){if(o.has(c))continue;o.add(c);let f=-1,u;for(let d=r;d<this.items.length;d++)if(this.items[d].diagnostic==c){f=d;break}f<0?(u=new s0(this.view,c),this.items.splice(r,0,u),n=!0):(u=this.items[f],f>r&&(this.items.splice(r,f-r),n=!0)),i&&u.diagnostic==i.diagnostic?u.dom.hasAttribute("aria-selected")||(u.dom.setAttribute("aria-selected","true"),s=u):u.dom.hasAttribute("aria-selected")&&u.dom.removeAttribute("aria-selected"),r++}});r<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)n=!0,this.items.pop();this.items.length==0&&(this.items.push(new s0(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),n=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:()=>({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:a,panel:l})=>{let h=l.height/this.list.offsetHeight;a.top<l.top?this.list.scrollTop-=(l.top-a.top)/h:a.bottom>l.bottom&&(this.list.scrollTop+=(a.bottom-l.bottom)/h)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),n&&this.sync()}sync(){let e=this.list.firstChild;function i(){let r=e;e=r.nextSibling,r.remove()}for(let r of this.items)if(r.dom.parentNode==this.list){for(;e!=r.dom;)i();e=r.dom.nextSibling}else this.list.insertBefore(r.dom,e);for(;e;)i()}moveSelection(e){if(this.selectedIndex<0)return;let i=this.view.state.field(Ge),r=xr(i.diagnostics,this.items[e].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:Kg.of(r)})}static open(e){return new My(e)}};function wo(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}function xo(t){return wo(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}var IC=x.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:xo("#d11")},".cm-lintRange-warning":{backgroundImage:xo("orange")},".cm-lintRange-info":{backgroundImage:xo("#999")},".cm-lintRange-hint":{backgroundImage:xo("#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}}});function GC(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function o0(t){let e="hint",i=1;for(let r of t){let n=GC(r.severity);n>i&&(i=n,e=r.severity)}return e}var a0=class extends yt{constructor(t){super(),this.diagnostics=t,this.severity=o0(t)}toDOM(t){let e=document.createElement("div");e.className="cm-lint-marker cm-lint-marker-"+this.severity;let i=this.diagnostics,r=t.state.facet(Qo).tooltipFilter;return r&&(i=r(i,t.state)),i.length&&(e.onmouseover=()=>FC(t,e,i)),e}};function UC(t,e){let i=r=>{let n=e.getBoundingClientRect();if(!(r.clientX>n.left-10&&r.clientX<n.right+10&&r.clientY>n.top-10&&r.clientY<n.bottom+10)){for(let s=r.target;s;s=s.parentNode)if(s.nodeType==1&&s.classList.contains("cm-tooltip-lint"))return;window.removeEventListener("mousemove",i),t.state.field(l0)&&t.dispatch({effects:Nh.of(null)})}};window.addEventListener("mousemove",i)}function FC(t,e,i){function r(){let o=t.elementAtHeight(e.getBoundingClientRect().top+5-t.documentTop);t.coordsAtPos(o.from)&&t.dispatch({effects:Nh.of({pos:o.from,above:!1,clip:!1,create(){return{dom:Jg(t,i),getCoords:()=>e.getBoundingClientRect()}}})}),e.onmouseout=e.onmousemove=null,UC(t,e)}let{hoverTime:n}=t.state.facet(Qo),s=setTimeout(r,n);e.onmouseout=()=>{clearTimeout(s),e.onmouseout=e.onmousemove=null},e.onmousemove=()=>{clearTimeout(s),s=setTimeout(r,n)}}function HC(t,e){let i=Object.create(null);for(let n of e){let s=t.lineAt(n.from);(i[s.from]||(i[s.from]=[])).push(n)}let r=[];for(let n in i)r.push(new a0(i[n]).range(+n));return ne.of(r,!0)}var KC=fl({class:"cm-gutter-lint",markers:t=>t.state.field(zh),widgetMarker:(t,e,i)=>{let r=[];return t.state.field(zh).between(i.from,i.to,(n,s,o)=>{n>i.from&&n<i.to&&r.push(...o.diagnostics)}),r.length?new a0(r):null}}),zh=ve.define({create(){return ne.empty},update(t,e){t=t.map(e.changes);let i=e.state.facet(Qo).markerFilter;for(let r of e.effects)if(r.is(Zn)){let n=r.value;i&&(n=i(n||[],e.state)),t=HC(e.state.doc,n.slice(0))}return t}}),Nh=B.define(),l0=ve.define({create(){return null},update(t,e){return t&&e.docChanged&&(t=Fg(e,t)?null:{...t,pos:e.changes.mapPos(t.pos)}),e.effects.reduce((i,r)=>r.is(Nh)?r.value:i,t)},provide:t=>ir.from(t)}),JC=x.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:wo('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:wo('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:wo('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),h0=[Ge,x.decorations.compute([Ge],t=>{let{selected:e,panel:i}=t.field(Ge);return!e||!i||e.from==e.to?A.none:A.set([YC.range(e.from,e.to)])}),cl(VC,{hideOn:Fg}),IC],Qo=R.define({combine(t){return mt(t,{hoverTime:300,markerFilter:null,tooltipFilter:null})}});function eZ(t={}){return[Qo.of(t),zh,KC,JC,l0]}var Ih="#2e3440",c0="#3b4252",f0="#434c5e",Qr="#4c566a",An="#d8dee9",tZ="#e5e9f0",iZ="#eceff4",qi="#8fbcbb",u0="#88c0d0",rZ="#81a1c1",Yt="#5e81ac",nZ="#bf616a",d0="#d08770",Gh="#ebcb8b",$o="#a3be8c",Uh="#b48ead",p0="#d30102",sZ="#252a33",Fh=Qr,oZ=Ih,Hh=c0,aZ=Qr,O0=An,lZ=x.theme({"&":{color:An,backgroundColor:oZ},".cm-content":{caretColor:O0},".cm-cursor, .cm-dropCursor":{borderLeftColor:O0},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:aZ},".cm-panels":{backgroundColor:sZ,color:Qr},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"transparent",outline:`1px solid ${qi}`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:An,color:Ih},".cm-activeLine":{backgroundColor:Fh},".cm-selectionMatch":{backgroundColor:tZ,color:c0},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{outline:`1px solid ${qi}`},"&.cm-focused .cm-matchingBracket":{backgroundColor:iZ,color:f0},".cm-gutters":{backgroundColor:Ih,color:Qr,border:"none"},".cm-activeLineGutter":{backgroundColor:Fh,color:An},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:Hh},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Hh,borderBottomColor:Hh},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Fh,color:Qr}}},{dark:!0}),hZ=eo.define([{tag:m.keyword,color:Yt},{tag:[m.name,m.deleted,m.character,m.propertyName,m.macroName],color:u0},{tag:[m.variableName],color:qi},{tag:[m.function(m.variableName)],color:qi},{tag:[m.labelName],color:rZ},{tag:[m.color,m.constant(m.name),m.standard(m.name)],color:Yt},{tag:[m.definition(m.name),m.separator],color:$o},{tag:[m.brace],color:qi},{tag:[m.annotation],color:p0},{tag:[m.number,m.changed,m.annotation,m.modifier,m.self,m.namespace],color:Uh},{tag:[m.typeName,m.className],color:Gh},{tag:[m.operator,m.operatorKeyword],color:$o},{tag:[m.tagName],color:Uh},{tag:[m.squareBracket],color:nZ},{tag:[m.angleBracket],color:d0},{tag:[m.attributeName],color:Gh},{tag:[m.regexp],color:Yt},{tag:[m.quote],color:Uh},{tag:[m.string],color:$o},{tag:m.link,color:$o,textDecoration:"underline",textUnderlinePosition:"under"},{tag:[m.url,m.escape,m.special(m.string)],color:qi},{tag:[m.meta],color:u0},{tag:[m.monospace],color:An,fontStyle:"italic"},{tag:[m.comment],color:Qr,fontStyle:"italic"},{tag:m.strong,fontWeight:"bold",color:Yt},{tag:m.emphasis,fontStyle:"italic",color:Yt},{tag:m.strikethrough,textDecoration:"line-through"},{tag:m.heading,fontWeight:"bold",color:Yt},{tag:m.special(m.heading1),fontWeight:"bold",color:Yt},{tag:m.heading1,fontWeight:"bold",color:Yt},{tag:[m.heading2,m.heading3,m.heading4],fontWeight:"bold",color:Yt},{tag:[m.heading5,m.heading6],color:Yt},{tag:[m.atom,m.bool,m.special(m.variableName)],color:d0},{tag:[m.processingInstruction,m.inserted],color:qi},{tag:[m.contentSeparator],color:Gh},{tag:m.invalid,color:f0,borderBottom:`1px dotted ${p0}`}]),cZ=[lZ,jl(hZ)],Po="&.cm-focused",m0=`${Po} .${Fm}`,g0=`${Po} .${Hm}`,b0=`${Sr} code`,v0=`${kr}>div:hover`,y0=x.theme({"&":{backgroundColor:"#fff","--cm-arg":"#b0c","--cm-attr":"#179b1c","--cm-comment":"#7b8c8f","--cm-convert":"#b68","--cm-entity":"#00a1a1","--cm-error":"#d73333","--cm-func":"#a11","--cm-hr":"#0076dd","--cm-hr-bg":"rgb(0,0,0,.07)","--cm-link":"#000aaa","--cm-sect":"#006fe6","--cm-sp":"rgb(134,206,255,.3)","--cm-table":"#d08","--cm-table-attr":"#f500d4","--cm-tag":"#14866d","--cm-tpl":"#80c","--cm-var":"#ad9300","--cm-var-name":"#ac6600","--cm-ref":"rgb(223,242,235,.5)"},[m0]:{backgroundColor:"rgb(50,140,130,.32)"},[g0]:{backgroundColor:"rgb(187,85,85,.27)"},[b0]:{backgroundColor:"#e0e6eb"},[kr]:{backgroundColor:"#f5f5f5",boxShadow:"0 2px 2px 0 rgb(0,0,0,.25)"},[v0]:{backgroundColor:"#e2f2ff"},[xn]:{borderColor:"#c8ccd1"}}),fZ=[cZ,x.theme({"&":{"--cm-arg":"#9f78a5","--cm-attr":"#97b757","--cm-comment":"#4c566a","--cm-convert":"#b68","--cm-entity":"#00a1a1","--cm-error":"#bf616a","--cm-func":"#bf616a","--cm-hr":"#5e81ac","--cm-hr-bg":"#3b4252","--cm-link":"#5e81ac","--cm-sect":"#81a1c1","--cm-sp":"#88c0d0","--cm-table":"#b48ead","--cm-table-attr":"#9f78a5","--cm-tag":"#a3be8c","--cm-tpl":"#9f78a5","--cm-var":"#d08770","--cm-var-name":"#d08770","--cm-ref":"rgb(60,90,80,0.5)"},"div.cm-activeLine":{backgroundColor:"rgb(76,86,106,.27)"},[m0]:{backgroundColor:"#eceff4",color:"#434c5e"},[g0]:{backgroundColor:"rgb(235,203,139,.32)"},[`${Po}>.cm-scroller>.cm-selectionLayer div.cm-selectionBackground, ${b0}, ${v0}, ${Ah}, div${yr}`]:{backgroundColor:"#4c566a"},[`div${Gm}`]:{color:"#d8dee9"},[kr]:{backgroundColor:"#252a33"},[xn]:{borderColor:"#000"},[`${Po} .cm-searchMatch.cm-searchMatch-selected`]:{color:"#b48ead"},"div.cm-tooltip-autocomplete ul li[aria-selected]":{color:"inherit"},"div.cm-gutters":{color:"#5e81ac"}})],Kh=()=>x.contentAttributes.of({spellcheck:"true"}),Ht={plain:Kh},Be={},To={},Jh=[],S0=[],ec={light:y0},at={statusBar(){return[]},detectIndent(t,e){return e},foldHandler(){return()=>{}}},uZ=new Set(["closeBrackets","autocompletion","signatureHelp"]),Rn={},tc={},Xn=(Sv=class{constructor(t,e="plain",i,r=!0){xe(this,we);xe(this,ct);xe(this,In,new Ot);xe(this,_i,new Ot);xe(this,Gn,new Ot);xe(this,Un,new Ot);xe(this,Fn,new Ot);xe(this,Hn,new Ot);xe(this,Kn,new Ot);xe(this,Jn,new Ot);xe(this,es,new Ot);xe(this,V);xe(this,Fe);xe(this,Si,!1);xe(this,ki,new Set);xe(this,Rr," ");xe(this,ts);ut(this,ct,t),ut(this,Fe,e),r&&this.initialize(i)}get textarea(){return Q(this,ct)}get view(){return Q(this,V)}get lang(){return Q(this,Fe)}get visible(){return Q(this,Si)&&this.textarea.isConnected}initialize(t){var p;let e;const{textarea:i,lang:r}=this,{value:n,dir:s,accessKey:o,tabIndex:a,lang:l,readOnly:h}=i,c=[Q(this,In).of(Qe(this,we,Fc).call(this,t)),Q(this,_i).of((p=Rn[r])!=null?p:[]),Q(this,Gn).of([]),Q(this,Un).of(x.editorAttributes.of({dir:s})),Q(this,Hn).of([]),Q(this,Kn).of(fe.phrases.of(tc)),Q(this,Jn).of(x.lineWrapping),Q(this,es).of(y0),jl(xx),x.contentAttributes.of({accesskey:o,tabindex:String(a)}),x.editorAttributes.of({lang:l}),j1(),I1(),et.of([...EC,...ww,{key:"Mod-Shift-x",run:()=>{const O=i.dir==="rtl"?"ltr":"rtl";return i.dir=O,Qe(this,we,Jt).call(this,Q(this,Un).reconfigure(x.editorAttributes.of({dir:O}))),!0}}]),x.theme({[Gm]:{direction:document.dir},"& .cm-lineNumbers .cm-gutterElement":{textAlign:"end"},[`.cm-textfield,.cm-button,${po}.cm-search label,${po}.cm-gotoLine label`]:{fontSize:"inherit"},[`${po} [name="close"]`]:{color:"inherit"}}),x.updateListener.of(({state:{doc:O},startState:{doc:g},docChanged:b,focusChanged:y})=>{b&&(clearTimeout(e),e=setTimeout(()=>{i.value=O.toString(),i.dispatchEvent(new InputEvent("input"))},400),g.toString().trim()||this.setIndent(Q(this,Rr))),y&&i.dispatchEvent(new FocusEvent(Q(this,V).hasFocus?"focus":"blur"))}),...h?[fe.readOnly.of(!0),fe.transactionFilter.of(O=>O.docChanged?[]:O),x.theme({'input[type="color"]':{pointerEvents:"none"}})]:[WT(),lx(),Q(this,Fn).of(ur.of(at.detectIndent(n,Q(this,Rr),r))),et.of([...LT,qC,{win:"Ctrl-Shift-z",run:go,preventDefault:!0}])]];ut(this,V,new x({extensions:c,doc:n}));const{fontSize:f,lineHeight:u,border:d}=getComputedStyle(i);i.before(Q(this,V).dom),Qe(this,we,Uo).call(this),Q(this,V).dom.style.border=d,Q(this,V).scrollDOM.style.fontSize=f,Q(this,V).scrollDOM.style.lineHeight=u,this.toggle(!0),Q(this,V).dom.addEventListener("click",at.foldHandler(Q(this,V))),this.prefer({})}async setLanguage(t="plain",e){var i;if(ut(this,Fe,t),Q(this,V)){const r=Qe(this,we,Fc).call(this,e);Qe(this,we,Jt).call(this,[Q(this,In).reconfigure(r),Q(this,_i).reconfigure((i=Rn[t])!=null?i:[])]),Qe(this,we,Uo).call(this,!!Rn[t]),this.prefer({})}}lint(t){const e=typeof t=="function"?[t]:t,i=e?[...e.map(r=>zC(async({state:n})=>{const s=(await r(n)).map(o=>({...o,renderMessage(a){const l=Y("span",{class:Um.slice(1)},o.message);return l.addEventListener("click",()=>{a.dispatch({selection:{anchor:o.from,head:o.to}}),a.focus()}),l}}));if(n.readOnly)for(const o of s)delete o.actions;return s})),eZ(),et.of(BC),at.statusBar(this,e[0].fixer)]:[];t?Rn[Q(this,Fe)]=i:delete Rn[Q(this,Fe)],Q(this,V)&&(Qe(this,we,Jt).call(this,Q(this,_i).reconfigure(i)),Qe(this,we,Uo).call(this,!!t))}update(){if(Q(this,V)){const t=Qe(this,we,Ey).call(this);if(t){const e=Q(this,V).plugin(t[1]);e.set=!0,e.force()}}}hasPreference(t){return Q(this,ki).has(t)}prefer(t){if(Array.isArray(t))ut(this,ki,new Set(t.filter(e=>Object.prototype.hasOwnProperty.call(Be,e))));else for(const[e,i]of Object.entries(t))i&&Object.prototype.hasOwnProperty.call(Be,e)?Q(this,ki).add(e):Q(this,ki).delete(e);if(Q(this,V)){const{readOnly:e}=Q(this,V).state;Qe(this,we,Jt).call(this,Q(this,Gn).reconfigure([...Q(this,ki)].filter(i=>!e||!uZ.has(i)).map(i=>{const[r,n={}]=Be[i];return r(n[Q(this,Fe)],this)})))}}setIndent(t){Q(this,V)?Qe(this,we,Jt).call(this,Q(this,Fn).reconfigure(ur.of(at.detectIndent(Q(this,V).state.doc,t,Q(this,Fe))))):ut(this,Rr,t)}setLineWrapping(t){Q(this,V)&&Qe(this,we,Jt).call(this,Q(this,Jn).reconfigure(t?x.lineWrapping:[]))}async getLinter(t){var e;return(e=To[Q(this,Fe)])==null?void 0:e.call(To,t,Q(this,V),Q(this,ts))}setContent(t,e){Q(this,V)&&Q(this,V).dispatch({changes:{from:0,to:Q(this,V).state.doc.length,insert:t},filter:!e})}toggle(t=!Q(this,Si)){if(Q(this,V)){if(t&&!Q(this,Si)){const{value:e,selectionStart:i,selectionEnd:r,scrollTop:n,offsetHeight:s,style:{height:o}}=Q(this,ct),a=document.activeElement===Q(this,ct);this.setContent(e),Q(this,V).dom.style.height=s?`${s}px`:o,Q(this,V).dom.style.removeProperty("display"),Q(this,ct).style.display="none",Q(this,V).requestMeasure(),Q(this,V).dispatch({selection:{anchor:i,head:r}}),a&&Q(this,V).focus(),requestAnimationFrame(()=>{Q(this,V).scrollDOM.scrollTop=n})}else if(!t&&Q(this,Si)){const{state:{selection:{main:{from:e,to:i,head:r}}},hasFocus:n}=Q(this,V),{scrollDOM:{scrollTop:s}}=Q(this,V);Q(this,V).dom.style.setProperty("display","none","important"),Q(this,ct).style.display="",Q(this,ct).setSelectionRange(e,i,r===i?"forward":"backward"),n&&Q(this,ct).focus(),requestAnimationFrame(()=>{Q(this,ct).scrollTop=s})}}else return;ut(this,Si,t)}destroy(){if(this.visible&&this.toggle(!1),Q(this,V)){for(const t of S0)t(Q(this,V));Q(this,V).destroy()}Object.setPrototypeOf(this,null)}extraKeys(t){Q(this,V)&&Qe(this,we,Jt).call(this,Q(this,Hn).reconfigure(et.of(t)))}localize(t){Object.assign(tc,t),Q(this,V)&&Qe(this,we,Jt).call(this,Q(this,Kn).reconfigure(fe.phrases.of(tc)))}getNodeAt(t){var e;return Q(this,V)&&((e=fi(Q(this,V).state,t))==null?void 0:e.resolveInner(t,1))}scrollTo(t){if(Q(this,V)){const e=t!=null?t:Q(this,V).state.selection.main,i=x.scrollIntoView(typeof e=="number"||e instanceof Er?e:k.range(e.anchor,e.head));i.value.isSnapshot=!0,Q(this,V).dispatch({effects:i})}}setTheme(t){var e;t in ec&&((e=Q(this,V))==null||e.dispatch({effects:Q(this,es).reconfigure(ec[t])}))}static replaceSelections(t,e){const{state:i}=t;t.dispatch(i.changeByRange(({from:r,to:n})=>{const s=e(i.sliceDoc(r,n),{from:r,to:n});if(typeof s=="string")return{range:k.range(r,r+s.length),changes:{from:r,to:n,insert:s}};const[o,a,l=a]=s;return{range:k.range(a,l),changes:{from:r,to:n,insert:o}}}))}},ct=new WeakMap,In=new WeakMap,_i=new WeakMap,Gn=new WeakMap,Un=new WeakMap,Fn=new WeakMap,Hn=new WeakMap,Kn=new WeakMap,Jn=new WeakMap,es=new WeakMap,V=new WeakMap,Fe=new WeakMap,Si=new WeakMap,ki=new WeakMap,Rr=new WeakMap,ts=new WeakMap,we=new WeakSet,Fc=function(t){var i;const e=((i=Ht[Q(this,Fe)])!=null?i:Kh)(t);return ut(this,ts,e.nestedMWLanguage),Q(this,Fe)==="mediawiki"&&(this.langConfig=t),e},Jt=function(t){Q(this,V).dispatch({effects:t})},Uo=function(t){Q(this,V).dom.style.minHeight=t?"calc(100px + 2em)":"2em"},Ey=function(){return Q(this,_i).get(Q(this,V).state)[0]},Sv),dZ=(t,e,i,r,n)=>!/mw-(?:(?:ext|html)tag-attribute-value|table-definition)/u.test(r)&&(!/mw-(?:template|parserfunction)(?:$|_)/u.test(r)||!/[|=]/u.test(n.sliceString(e-1,e))||!/[|\n]/u.test(n.sliceString(i,i+1))&&n.sliceString(i,i+2)!=="}}")&&(!/mw-templatevariable(?:$|_)/u.test(r)||n.sliceString(e-1,e)!=="|"||n.sliceString(i,i+1)!=="|"&&n.sliceString(i,i+3)!=="}}}")?null:bT(n.sliceString(e,i)).filter(([,,,s])=>s).map(([s,o,a])=>{const l=s.startsWith("#")?qm(s):Em(s);let h=l==null?void 0:l.alpha;return(l==null?void 0:l.colorType)!==wt.hex&&h&&(h=mT(parseFloat(h.slice(1))/(h.endsWith("%")?100:1))),l&&{...l,colorType:wt.hex,alpha:h!=null?h:"",from:e+o,to:e+a}}).filter(s=>s!==null),pZ=(([t,e]=[])=>t?[t,x.theme({[`.${vr}`]:{outline:"none",...e},[`.${vr} input[type="color"]`]:{outline:"1px solid #eee"}})]:[]),k0={'"':"quot","'":"apos","<":"lt",">":"gt","&":"amp"," ":"nbsp"},w0=(t,e)=>i=>i.state.selection.ranges.some(({empty:r})=>!r)?(Xn.replaceSelections(i,t),!0):e(i),x0=t=>[...t].map(e=>{if(e in k0)return`&${k0[e]};`;const i=e.codePointAt(0);return i<256?`&#${i};`:`&#x${i.toString(16)};`}).join(""),Q0=t=>{if(t.includes("%"))try{return decodeURIComponent(t)}catch{}return encodeURIComponent(t)},$0=t=>{const e=t.view,{state:i}=e,{ranges:r}=i.selection,n=Ut(e,!1,t.getWikiConfig);return n&&"provideRefactoringAction"in n&&r.some(({empty:s})=>!s)?((async()=>{const s=new WeakMap;for(const o of r){const[a]=await n.provideRefactoringAction(i.sliceDoc(o.from,o.to));s.set(o,a==null?void 0:a.edit.changes[""][0].newText)}e.dispatch(i.changeByRange(o=>{const a=s.get(o);return a===void 0?{range:o}:{range:k.range(o.from,o.from+a.length),changes:{from:o.from,to:o.to,insert:a}}}))})(),!0):!1},ic=(t,e)=>{e.stopPropagation(),t.focus()},Co;Jh.push({name:"escape",isActionable({lang:t,view:e}){return t==="mediawiki"&&e.state.selection.ranges.some(({empty:i})=>!i)},getItems(t){if(!Co){const e=t.view,i=Y("div","HTML escape"),r=Y("div","URI encode/decode");i.addEventListener("click",s=>{Xn.replaceSelections(e,x0),ic(e,s)}),r.addEventListener("click",s=>{Xn.replaceSelections(e,Q0),ic(e,s)}),Co=[i,r];const n=Ut(e,!1,t.getWikiConfig);if(n&&"provideRefactoringAction"in n){const s=Y("div","Escape with magic words");s.addEventListener("click",o=>{$0(t),ic(e,o)}),Co.unshift(s)}}return Co}});var OZ=t=>et.of([{key:"Mod-[",run:w0(x0,Bh)},{key:"Mod-]",run:w0(Q0,_h)},{key:"Mod-\\",run(){return $0(t)}}]),mZ={"\n":"<br>","&":"&","<":"<"},Wn=t=>t.replace(/[\n<&]/gu,e=>mZ[e]),Mn=(t,e)=>{const i=t.lineAt(e);return{line:i.number-1,character:e-i.from}},Oi=(t,e)=>{const i=t.line(e.line+1);return Math.min(i.from+e.character,i.to)},P0=(t,e)=>{const i=Y("div"),r=Y("div",{class:Sr.slice(1)},i);return r.style.font=getComputedStyle(t.contentDOM).font,i.innerHTML=e,{dom:r}},rc=(t,e)=>{const i=t.sliceDoc(e.from,e.to);return[i.split("{{").length-1,1-i.split("}}").length]},Se=(t,e)=>(Array.isArray(e)?e:[e]).some(i=>t.has(i in $?$[i]:i)),gZ=xt(t=>new RegExp(`mw-tag-${t}(?![a-z])`,"u")),bZ=(t,{to:e})=>Math.max(t,e),vZ=(t,{from:e,to:i})=>e<=t&&i>t?i:t,Zo=t=>e=>t.some(i=>e==null?void 0:e.name.includes($[i])),nc=Zo(["templateBracket","parserFunctionBracket"]),yZ=Zo(["templateName","parserFunctionName"]),SZ=Zo(["templateDelimiter","parserFunctionDelimiter"]),sc=t=>SZ(t)&&!yZ(t.nextSibling),T0=t=>/-(?:template|ext)[a-z\d-]+ground/u.test(t.name)&&!nc(t),kZ=Zo(["extTagBracket"]),C0=(t,e)=>t.name.includes(`mw-tag-${e?"ref":""}`),wZ=new Set(["ref","references"]),Z0=(t,e,i,r=!1)=>{var f;if(typeof e=="number"&&(i=fi(t,e)),!i)return!1;let n;if(typeof e=="number"){const u=i.resolve(e,-1);if(!r&&T0(u))n=u;else{const d=i.resolve(e,1);n=C0(u,r)&&u.name.split("mw-tag-").length>d.name.split("mw-tag-").length?u:d}}else n=e;if(r||!T0(n)){if(C0(n,r)){const{name:u}=n,[d]=/^[a-z]+/u.exec(u.slice(u.lastIndexOf("mw-tag-")+7)),p=gZ(d);let{nextSibling:O}=n;for(;O&&!(kZ(O)&&!p.test(O.name));)({nextSibling:O}=O);const g=O==null?void 0:O.nextSibling;if(O&&(!r||g&&wZ.has((f=Qn(t,g))==null?void 0:f.name)))return{from:og(t,O.to).end.to,to:O.from}}return!1}let{prevSibling:s,nextSibling:o}=n,a=1,l=sc(n)?n:null,h=0;for(;o;){if(nc(o)){const[u,d]=rc(t,o);if(a+=d,a<=0){h=o.from+t.sliceDoc(o.from,o.to).split("}}").slice(0,a-1).join("}}").length;break}a+=u}else!l&&a===1&&sc(o)&&(l=o);({nextSibling:o}=o)}if(!o)return!1;for(a=-1;s;){if(nc(s)){const[u,d]=rc(t,s);if(a+=u,a>=0)break;a+=d}else a===-1&&sc(s)&&(l=s);({prevSibling:s}=s)}const c=l==null?void 0:l.to;return c&&c<h?{from:c,to:h}:!1},A0=t=>{const{selection:{main:{head:e}}}=t,i=Z0(t,e);if(i){const{from:r,to:n}=i;let s=!1;return Yl(t).between(r,n,(o,a)=>{o===r&&a===n&&(s=!0)}),s?null:{pos:e,above:!0,create(){const o=Y("div",{class:yr.slice(1),title:t.phrase("Fold template or extension tag")},"-");return o.dataset.from=String(r),o.dataset.to=String(n),{dom:o}}}}return null},R0=(t,e,i)=>{var r;return e.length>0?((r=t.dom.querySelector(yr))==null||r.remove(),t.dispatch({effects:e,selection:{anchor:i}}),!0):!1},X0=t=>Math.max(...t.selection.ranges.map(({to:e})=>e)),W0=(t,e,i,r,n,s,o,a)=>{for(;r&&r.from<=n;){const l=Z0(t,r,e,a);if(l){i.push(Xi.of(l)),r=e.resolve(l.to,1),s=o(s,l);continue}r=r.nextSibling}return s},oc=class extends yt{constructor(t){super(),this.open=t}eq(t){return this.open===t.open}toDOM({state:t}){return Y("span",{title:t.phrase(this.open?"Fold line":"Unfold line")},this.open?"⌄":"›")}},xZ=new oc(!0),QZ=new oc(!1),M0=({state:t},e)=>{var r;let i;return(r=t.field(St,!1))==null||r.between(e.from,e.to,(n,s)=>{!i&&s===e.to&&(i={from:n,to:s})}),i},E0=({state:t,viewport:{to:e},viewportLineBlocks:i},{from:r,to:n})=>{const s=I(t),o=h=>{const{name:c}=s.resolve(h,1);return c.includes($.sectionHeader)?Number(/mw-section--(\d)/u.exec(c)[1]):7},a=(h,c)=>{var d;const f=t.sliceDoc(h,c),u=(d=/^\s*(?:(?::+\s*)?\{\||\|\})/u.exec(f))==null?void 0:d[0];if(u){const{name:p}=s.resolve(h+u.length,-1);if(p.includes($.tableBracket))return u.endsWith("|}")?-1:1}return 0},l=o(r);if(l<7){for(const{from:h}of i)if(h>r&&o(h)<=l)return n<h-1&&{from:n,to:h-1};return e===t.doc.length&&e>n&&{from:n,to:e}}else if(a(r,n)===1){for(const{from:h,to:c}of i)if(h>r){const f=a(h,c);if(f===-1)return n<h-1&&{from:n,to:h-1};if(f===1||o(h)<7)break}}return!1},q0=t=>{const e=new jt;for(const i of t.viewportLineBlocks){let r;M0(t,i)?r=QZ:E0(t,i)&&(r=xZ),r&&e.add(i.from,i.from,r)}return e.finish()},D0=be.fromClass(class{constructor(t){this.markers=q0(t)}update({docChanged:t,viewportChanged:e,startState:i,state:r,view:n}){(t||e||i.facet(nt)!==r.facet(nt)||i.field(St,!1)!==r.field(St,!1)||I(i)!==I(r))&&(this.markers=q0(n))}}),$Z=[vx(),et.of(Ox)],Y0=t=>e=>{var o;const{state:i}=e,r=(o=fi(i,i.doc.length,1e3))!=null?o:I(i),n=[],s=W0(i,r,n,r.topNode.firstChild,1/0,X0(i),vZ,t);return R0(e,n,s)},PZ=Y0(!0),TZ=((t=$Z)=>t),CZ=[_l({placeholderDOM(t){const e=Y("span",{"aria-label":"folded code",title:t.state.phrase("unfold"),class:"cm-foldPlaceholder"},"…");return e.addEventListener("click",({target:i})=>{const r=t.posAtDOM(i),{state:n}=t,{selection:s}=n;Yl(n).between(r,r,(o,a)=>{o===r&&t.dispatch({effects:ui.of({from:o,to:a}),selection:s})})}),e}}),ve.define({create:A0,update(t,{state:e,docChanged:i,selection:r}){return i?null:r?A0(e):t},provide(t){return ir.from(t)}}),et.of([{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run(t){const{state:e}=t,i=I(e),r=[];let n=X0(e);for(const{from:s,to:o,empty:a}of e.selection.ranges){let l;a&&(l=i.resolve(s,-1)),(!l||l.name==="Document")&&(l=i.resolve(s,1)),n=W0(e,i,r,l,o,n,bZ)}return R0(t,r,n)}},{key:"Ctrl-Alt-[",run:Y0()},{key:"Mod-Alt-,",run:PZ},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run(t){const{state:e}=t,{selection:i}=e,r=[],n=Yl(e);for(const{from:s,to:o}of i.ranges)n.between(s,o,(a,l)=>{r.push(ui.of({from:a,to:l}))});return r.length>0?(t.dispatch({effects:r,selection:i}),!0):!1}},{key:"Ctrl-Alt-]",run:Mp}]),D0,fl({class:"cm-foldGutter",markers(t){var e,i;return(i=(e=t.plugin(D0))==null?void 0:e.markers)!=null?i:ne.empty},initialSpacer(){return new oc(!1)},domEventHandlers:{click(t,e){const i=M0(t,e);if(i)return t.dispatch({effects:ui.of(i)}),!0;const r=E0(t,e);return r?(t.dispatch({effects:Xi.of(r)}),!0):!1}}}),x.theme({[yr]:{cursor:"pointer",lineHeight:1.2,padding:"0 1px",opacity:.6},[`${yr}:hover`]:{opacity:1}})],ZZ=t=>e=>{const i=e.target.closest(yr);if(i){e.preventDefault();const{dataset:r}=i,n=Number(r.from),s=Number(r.to);t.dispatch({effects:Xi.of({from:n,to:s}),selection:{anchor:s}}),i.remove()}},AZ=t=>[cl(async(e,i,r)=>{var h,c;const{state:n}=e,{doc:s}=n,{paramSuggest:o,tags:a}=t.langConfig;let l=await((h=Ut(e,!1,t.getWikiConfig))==null?void 0:h.provideHover(s.toString(),Mn(s,i)));if(!l&&o&&"templatedata"in a){const f=(c=fi(n,i+Math.max(r,0)))==null?void 0:c.resolve(i,r);if(f!=null&&f.name.includes($.templateName)){const u=await o(n.sliceDoc(f.from,f.to),!1),{description:d,length:p}=u;(d||p>0)&&(l={contents:{kind:"plaintext",value:(d?`<p>${Wn(d)}</p>`:"")+(p===0?"":`<ul>${u.map(([O,g])=>`<li><code>${Wn(O)}</code>${g?` — ${Wn(g)}`:""}</li>`).join("")}</ul>`)},range:{start:Mn(s,f.from),end:Mn(s,f.to)}})}}if(l){await br("npm/marked/lib/marked.umd.js","marked",!0);const{end:f}=l.range;return{pos:i,end:Oi(s,f),above:!0,create(){const{kind:u,value:d}=l.contents;return P0(e,u==="plaintext"?d:marked.parse(d))}}}return null}),x.theme({[Sr]:{padding:"2px 5px",width:"max-content",maxWidth:"60vw",overflowY:"auto"},[`${Sr} *`]:{marginTop:"0!important",marginBottom:"0!important"},[`${Sr}>div`]:{fontSize:"90%",lineHeight:1.4},[`${Sr} code`]:{padding:".1em .4em",borderRadius:".4em"}})],RZ=new Set(["plain","mediawiki"]),V0=t=>{var e,i;return(i=(e=t.children)==null?void 0:e.flatMap(V0))!=null?i:t.text},$r=(t,e,i)=>{if(RZ.has(i))return e;const r=[],n=typeof t=="string"?t.split(`
|
|
28
28
|
`):V0(t);let s=0;for(const a of n){if(!a.trim())continue;let l=0,h=0;for(const c of a)if(c===" ")l++;else if(c===" ")h++;else break;l&&l*8>=h&&s++,h>1&&h>=l*2&&r.push(h)}const{length:o}=r;if(s>o)return" ";if(s===o)return e;for(let a=Math.min(...r,8);a>2;a--)if(r.every(l=>l%a===0))return" ".repeat(a);return" "},_0="cm-inlay-hint",XZ=class extends gt{constructor(t){super(),this.label=t}toDOM(){return Y("span",{class:_0},this.label)}},B0=B.define(),WZ=ve.define({create(){return A.none},update(t,{state:{doc:e},effects:i}){const r=e.toString();for(const n of i)if(n.is(B0)){const{value:{text:s,inlayHints:o}}=n;if(r===s)return o?A.set(o.reverse().map(({position:a,label:l})=>[Oi(e,a),l]).sort(([a],[l])=>a-l).map(([a,l])=>A.widget({widget:new XZ(l)}).range(a))):A.none}return t},provide(t){return x.decorations.from(t)}}),L0=async({view:t,docChanged:e})=>{var i;if(e){const r=t.state.doc.toString();t.dispatch({effects:B0.of({text:r,inlayHints:await((i=Ut(t))==null?void 0:i.provideInlayHints(r))})})}},MZ=t=>[WZ,be.fromClass(class{constructor(e){const i=setInterval(()=>{Ut(e,!1,t.getWikiConfig)&&(clearInterval(i),L0({view:e,docChanged:!0}))},100)}update(e){L0(e)}}),x.theme({[`.${_0}`]:{color:"#969696",fontStyle:"italic","-webkitUserSelect":"none",userSelect:"none"}})],EZ=[{key:"Ctrl-8",pre:"<blockquote>",post:"</blockquote>",desc:"blockquote"},{key:"Mod-.",pre:"<sup>",post:"</sup>",desc:"sup"},{key:"Mod-,",pre:"<sub>",post:"</sub>",desc:"sub"},{key:"Ctrl-,",pre:"<sub>",post:"</sub>",desc:"sub"},{key:"Mod-Shift-6",pre:"<code>",post:"</code>",desc:"code"},{key:"Ctrl-Shift-5",pre:"<s>",post:"</s>",desc:"s"},{key:"Mod-u",pre:"<u>",post:"</u>",desc:"u"},{key:"Mod-k",pre:"[[",post:"]]",desc:"link"},{key:"Mod-i",pre:"''",post:"''",desc:"italic"},{key:"Mod-b",pre:"'''",post:"'''",desc:"bold"},{key:"Mod-Shift-k",pre:"<ref>",post:"</ref>",desc:"ref"},{key:"Mod-/",pre:"<!-- ",post:" -->",desc:"comment"},{key:"Ctrl-0",splitlines:!0,desc:"heading 0"},...new Array(6).fill(0).map((t,e)=>({key:`Ctrl-${e+1}`,pre:`${"=".repeat(e+1)} `,post:` ${"=".repeat(e+1)}`,splitlines:!0,desc:`heading ${e+1}`})),{key:"Ctrl-7",pre:" ",splitlines:!0,desc:"pre"}],qZ=(t,e,i)=>{const r=t.split(`
|
|
29
29
|
`);return r.map(n=>{var o,a;const s=((a=(o=/^(={1,6})(.+)\1\s*$/u.exec(n))==null?void 0:o[2])!=null?a:n).trim();return e===" "||r.length===1||n.trim()?e+s+i:s}).join(`
|
|
30
30
|
`)},DZ=({key:t,pre:e="",post:i="",splitlines:r})=>({key:t,run(n){const{state:s}=n;return n.dispatch(s.changeByRange(({from:o,to:a})=>{if(r){const c=s.doc.lineAt(o).from,f=s.doc.lineAt(a).to,u=qZ(s.sliceDoc(c,f),e,i);return{range:k.range(c,c+u.length),changes:{from:c,to:f,insert:u}}}const l=e+s.sliceDoc(o,a)+i,h=o+l.length;return{range:o===a?k.range(o+e.length,h-i.length):k.range(h,h),changes:{from:o,to:a,insert:l}}})),!0},preventDefault:!0}),YZ=et.of(EZ.map(DZ)),VZ=Uy(Fy(),1);async function j0(t,e,i,r){const n=i&&("extends"in i||"rules"in i),s=n?i.rules:i,o=n&&"extends"in i&&i.extends!=="stylelint-config-recommended"&&!(Array.isArray(i.extends)&&i.extends.includes("stylelint-config-recommended"))?s!=null?s:{}:{...VZ.rules,...s},a={rules:o,computeEditInfo:!0,fix:r||!1};if(n&&(i.rules=o),r)return(await t.lint({code:e,config:a})).code;const[l]=(await t.lint({code:e,config:a})).results;return l.warnings.filter(({text:h})=>!h.startsWith("Unknown rule "))}var Ao=(t,e,i)=>i===void 0?Math.min(t[1],t[0]+Math.max(0,e)):e===-2?t[0]:e===0?t[1]:t[0]+i,z0=({type:t,tag:e},i)=>`${t==="ext-attr"?"div":e}#${i}{
|
|
@@ -32,7 +32,7 @@ var Dy=Object.create;var Fo=Object.defineProperty;var Yy=Object.getOwnPropertyDe
|
|
|
32
32
|
`);return{line:i.length-1,character:i[i.length-1].length}},I0=t=>!!(t&&("extends"in t||"rules"in t)),G0=async(t,e)=>{await Rm(t==null?void 0:t.getConfig,t==null?void 0:t.i18n);const i=Ut(e,t==null?void 0:t.include),r=await ac(),n=async(s,o)=>{var p,O;const a=(p=o==null?void 0:o.defaultSeverity)!=null?p:2,l=(await i.provideDiagnostics(s)).filter(({code:g,severity:b})=>{var y;return Number((y=o==null?void 0:o[g])!=null?y:a)>+(b===2)}),h="findStyleTokens"in i&&(o==null?void 0:o["invalid-css"])!=="0"?await i.findStyleTokens():[];if(h.length===0)return l;const c=h.map((g,b)=>`${z0(g,b)}${Im(g.childNodes[1].childNodes[0].data).replace(/\n/gu," ")}
|
|
33
33
|
}`),f=o==null?void 0:o.css,u=I0(f),d={};for(const[g,b]of Object.entries((O=u?f.rules:f)!=null?O:{}))b||(d[g]=b);return[...l,...(await r(c.join(`
|
|
34
34
|
`),u?{...f,rules:d}:d)).map(({line:g,column:b,endLine:y,endColumn:v,rule:S,severity:w,text:X,fix:P})=>{const D=Math.ceil(g/3),{range:_}=h[D-1].childNodes[1].childNodes[0],q=Ao(_,g-3*D,b-1),W={from:q,to:y===void 0?q:Ao(_,y-3*D,v-1),severity:w==="error"?1:2,source:"Stylelint",code:S,message:X};if(P){const{length:M}=z0(h[D-1],D),z=c.slice(0,D-1).join(`
|
|
35
|
-
`).length+M+(D-1&&1);W.data=[{range:{start:N0(s,Ao(_,P.range[0]-z)),end:N0(s,Ao(_,P.range[1]-z))},newText:P.text,title:"Fix: Stylelint",fix:!0}]}return W})]};return"resolveCodeAction"in i&&(n.fixer=async(s,o)=>(await i.resolveCodeAction(o)).edit.changes[""][0].newText),n},U0=async(t="npm/@bhsd/eslint-browserify")=>{var s;await br(t,"eslint");const e=new eslint.Linter,i={env:{browser:!0,es2024:!0},parserOptions:{ecmaVersion:15,sourceType:"module"}},r={};for(const[o,{meta:a}]of e.getRules())(s=a==null?void 0:a.docs)!=null&&s.recommended&&(r[o]=2);const n=(o,a)=>{const l={...i,...a};return(!("rules"in l)||l.extends==="eslint:recommended"||Array.isArray(l.extends)&&l.extends.includes("eslint:recommended"))&&(l.rules={...r,...l.rules}),delete l.extends,n.config=l,e.verify(o,l)};return n.fixer=(o,a)=>{var l,h;return e.verifyAndFix(o,a?{...n.config,rules:{[a]:(h=(l=n.config.rules)==null?void 0:l[a])!=null?h:2}}:n.config).output},n},ac=async(t="npm/@bhsd/stylelint-browserify")=>{await br(t,"stylelint");const e=async(i,r)=>{const n=await j0(stylelint,i,r);return e.config=r&&!I0(r)?{rules:r}:r,n};return e.fixer=(i,r)=>{var n,s;if(!e.config)throw new Error("Fixer unavailable!");return j0(stylelint,i,r?{extends:[],rules:{[r]:(s=(n=e.config.rules)==null?void 0:n[r])!=null?s:!0}}:e.config,!0)},e},_Z=async(t="npm/luacheck-browserify")=>{await br(t,"luacheck");const e=await luacheck(void 0);return async i=>(await e.queue(i)).filter(({severity:r})=>r)},BZ=()=>t=>{var e,i,r;try{t.trim()&&JSON.parse(t)}catch(n){if(n instanceof SyntaxError){const{message:s}=n,o=(e=/\bline (\d+)/u.exec(s))==null?void 0:e[1],a=(i=/\bcolumn (\d+)/u.exec(s))==null?void 0:i[1],l=(r=/\bposition (\d+)/u.exec(s))==null?void 0:r[1];return[{message:s,severity:"error",line:o,column:a,position:l}]}}return[]},Di=(t,e)=>typeof t=="function"?t(e):t,En=(t,e,i,r=0)=>{if(r===0)return Oi(t,{line:e-1,character:i-1});const n=t.lineAt(r);return Oi(t,{line:n.number+e-2,character:(e===1?r-n.from:0)+i-1})},lc=(t,e,i,r,n,s=0,o=1/0)=>{const a=En(t,e,i,s);return{from:a,to:r===void 0?Math.min(o,a+1):En(t,r,n,s)}},F0=async(t,e,i,r,n=0,s)=>(await t(e,i)).map(({severity:o,code:a,message:l,range:h,from:c,to:f,data:u=[],source:d})=>({source:d,severity:o===2?"warning":"error",message:d==="Stylelint"?l:`${l} (${a})`,actions:u.map(({title:p,range:O,newText:g})=>({name:p,apply(b){b.dispatch({changes:{from:Oi(r,O.start),to:Oi(r,O.end),insert:g}})}})),...c===void 0?lc(r,h.start.line+1,h.start.character+1,h.end.line+1,h.end.character+1,n,s):{from:c+n,to:(f!=null?f:c)+n}})),LZ=async(t,e)=>{const i=await G0(await Di(t),e),r=async({doc:n})=>F0(i,n.toString(),await Di(t,!0),n);return i.fixer&&(r.fixer=(n,s)=>i.fixer("",s)),r},H0=(t,e,i,r,n=0,s)=>t(e,i).map(({ruleId:o,message:a,severity:l,line:h,column:c,endLine:f,endColumn:u,fix:d,suggestions:p=[]})=>{const O={source:"ESLint",message:a+(o?` (${o})`:""),severity:l===1?"warning":"error",...lc(r,h,c,f,u,n,s)};return(d||p.length>0)&&(O.actions=[...d?[{name:"fix",fix:d}]:[],...p.map(g=>({name:"suggestion",fix:g.fix}))].map(({name:g,fix:{range:[b,y],text:v}})=>({name:g,apply(S){S.dispatch({changes:{from:b+n,to:y+n,insert:v}})}}))),O}),jZ=async t=>{const e=await U0(),i=async({doc:r})=>H0(e,r.toString(),await Di(t),r);return i.fixer=(r,n)=>e.fixer(r.toString(),n),i},hc=async(t,e,i,r,n=0,s)=>{let o=i!=null?i:{};return"extends"in o||"rules"in o||(o={rules:o}),(await t(e,o)).map(({text:a,severity:l,line:h,column:c,endLine:f,endColumn:u,fix:d})=>{const p={source:"Stylelint",message:a,severity:l,...lc(r,h,c,f,u,n,s)};return d&&(p.actions=[{name:"fix",apply(O){O.dispatch({changes:{from:d.range[0]+n,to:d.range[1]+n,insert:d.text}})}}]),p})},zZ=async t=>{const e=await ac(),i=async({doc:r})=>hc(e,r.toString(),await Di(t),r);return i.fixer=async(r,n)=>e.fixer(r.toString(),n),i},K0=async t=>{const e=await ac(),i=await U0();return async r=>{var l;const{doc:n}=r,s=(l=await Di(t,!0))!=null?l:{},o=s.js,a=s.css;return[...(await Promise.all(Gt.findRegions(r).map(async({from:h,to:c})=>{var u;const f=(u=fi(r,h))==null?void 0:u.resolve(h,1);return(f==null?void 0:f.name)==="AttributeValue"?(await hc(e,`a {${Im(r.sliceDoc(h,c))}}`,a,n,h-3,c+1)).filter(({from:d,to:p})=>d<=c&&p>=h).map(d=>(d.from=Math.max(d.from,h),d.to=Math.min(d.to,c),d)):f?hc(e,r.sliceDoc(h,c),a,n,h,c):[]}))).flat(),..._e.findRegions(r).flatMap(({from:h,to:c})=>H0(i,r.sliceDoc(h,c),o,n,h,c))]}},NZ=async(t,e,i)=>{const r=await K0(t),n=await G0({include:!1,...await Di(t)},e);return async s=>{var h;const{doc:o}=s,a=(h=await Di(t,!0))!=null?h:{},l=a.wiki;return[...await r(s),...(await Promise.all(i.findRegions(s).map(({from:c,to:f})=>F0(n,s.sliceDoc(c,f),l,o,c,f)))).flat()]}},IZ=()=>{const t=BZ();return({doc:e})=>{const[i]=t(e.toString());if(i){const{message:r,severity:n,line:s,column:o,position:a}=i;let l=0;return a?l=Number(a):s&&o&&(l=En(e,Number(s),Number(o))),[{message:r,severity:n,from:l,to:l}]}return[]}},GZ=async()=>{const t=await _Z();return async({doc:e})=>(await t(e.toString())).map(({line:i,column:r,end_column:n,msg:s,severity:o})=>({source:"Luacheck",message:s,severity:o===1?"warning":"error",from:En(e,i,r),to:En(e,i,n+1)}))},J0=(t,e,i)=>{let r=t;for(;r;){const{firstChild:n,lastChild:s}=r;if(n&&s){const o=i.indexOf(n.name),a=i.indexOf(s.name);if(o!==-1&&a!==-1&&o%2===0&&a%2===1&&n.from<e&&s.to>e)return{start:n,end:s,matched:!0}}({parent:r}=r)}},UZ=(t,e,i)=>{var l;const{brackets:r,maxScanDistance:n}=i,s=new RegExp(`[${[...r].filter((h,c)=>c%2).map(h=>h==="]"?String.raw`\]`:h).join("")}]`,"gu"),o=t.sliceDoc(e,e+n);let a=s.exec(o);for(;a;){const h=qe(t,e+a.index+1,-1,i),c=(l=h==null?void 0:h.end)==null?void 0:l.to;if(c!==void 0&&c<=e)return h;a=s.exec(o)}return null},FZ=t=>{const e=Ax(t),[{facet:i},[r]]=e;return Object.assign(r,{updateF(n,{state:s,docChanged:o,selection:a}){if(!o&&!a)return n;const l=[],h=s.facet(i),{afterCursor:c,brackets:f,renderMatch:u}=h;for(const{empty:d,head:p}of s.selection.ranges){if(!d)continue;const O=I(s),g=qe(s,p,-1,h)||p>0&&qe(s,p-1,1,h)||c&&(qe(s,p,1,h)||p<s.doc.length&&qe(s,p+1,-1,h))||J0(O.resolveInner(p,-1),p,f)||c&&J0(O.resolveInner(p,1),p,f)||UZ(s,p,h);g&&l.push(...u(g,s))}return A.set(l,!0)}}),e},HZ=new Set(["msg","raw","subst","safesubst"]),cc=t=>!/^_{2}.+_{2}$/u.test(t),lt=new Set(["align"]),eb=new Set(["cite"]),tb=new Set(["cite","datetime"]),ib=new Set(["width"]),KZ=new Set(["axis","align","bgcolor","height","width","valign"]),rb=new Set([...KZ,"abbr","headers","scope","rowspan","colspan"]),nb=new Set(["type"]),JZ=new Set(["summary","align","bgcolor","cellpadding","cellspacing","frame","rules","width"]),e2=new Set(["clear"]),t2=new Set(["bgcolor","align","valign"]),fc=new Set(["id","qid","forcemathmode","type","display"]),sb=new Set(["enclose","inline","lang","line","linelinks","style","class","id","dir","copy","highlight","start"]),ob=new Set(["weight"]),ab=new Set(["width","height","zoom","latitude","longitude","align","mapstyle","lang","alt","text"]),Yi=new Set,i2=new Set(["id","class","style","lang","dir","title","tabindex","aria-describedby","aria-flowto","aria-hidden","aria-label","aria-labelledby","aria-level","aria-owns","role","about","property","resource","datatype","typeof","itemid","itemprop","itemref","itemscope","itemtype"]),r2={div:lt,h1:lt,h2:lt,h3:lt,h4:lt,h5:lt,h6:lt,blockquote:eb,q:eb,p:lt,br:e2,pre:ib,ins:tb,del:tb,ul:nb,ol:new Set(["type","start","reversed"]),li:new Set(["type","value"]),table:new Set([...JZ,"border"]),caption:lt,tr:t2,td:rb,th:rb,font:new Set(["size","color","face"]),hr:ib,data:new Set(["value"]),time:new Set(["datetime"]),meta:new Set(["itemprop","content"]),link:new Set(["itemprop","href","title"]),gallery:nb,poem:lt,categorytree:lt,combooption:lt,img:new Set(["alt","src","width","height","loading","srcset"])},n2={gallery:new Set(["mode","showfilename","caption","perrow","widths","heights","showthumbnails"]),poem:new Set(["compact"]),categorytree:new Set(["hideroot","onlyroot","depth","mode","hideprefix","namespaces","showcount","notranslations"]),combooption:new Set(["name","for","inline"]),nowiki:Yi,indicator:new Set(["name"]),langconvert:new Set(["from","to"]),ref:new Set(["group","name","follow","dir","details"]),references:new Set(["group","responsive"]),charinsert:new Set(["label"]),choose:new Set(["uncached","before","after"]),option:ob,choicetemplate:ob,imagemap:Yi,inputbox:Yi,templatestyles:new Set(["src","wrapper"]),dynamicpagelist:Yi,poll:new Set(["id","show-results-before-voting"]),score:new Set(["line_width_inches","lang","override_midi","raw","note-language","override_audio","override_ogg","sound","vorbis"]),seo:new Set(["title","title_mode","title_separator","keywords","description","robots","google_bot","image","image_width","image_height","image_alt","type","site_name","locale","section","author","published_time","twitter_site"]),tab:new Set(["nested","name","index","class","block","inline","openname","closename","collapsed","dropdown","style","bgcolor","container","id","title"]),tabs:new Set(["plain","class","container","id","title","style"]),combobox:new Set(["placeholder","value","id","class","text","dropdown","style"]),math:new Set([...fc,"chem"]),chem:fc,ce:fc,hiero:Yi,phonos:new Set(["ipa","class","text","lang","wikibase","file"]),section:new Set(["begin","end"]),source:sb,syntaxhighlight:sb,templatedata:Yi,timeline:new Set(["method","font"]),quiz:new Set(["display","shuffleanswers","points","shuffle","case"]),languages:Yi,mapframe:new Set([...ab,"frameless"]),maplink:new Set([...ab,"class"]),rss:new Set(["template","templatename","max","highlight","filter","filterout","reverse","date","item-max-length"]),"page-collection":new Set(["lang","name","description","end-date"])},s2=class{constructor(t,e){this.tags=t.includes("translate")?t.filter(i=>i!=="tvar"):t,this.urlProtocols=new RegExp(String.raw`^(${this.tags.includes("tvar")?"<tvar name=[^>]+>":""})?${e}`,"iu"),this.firstSingleLetterWord=null,this.firstMultiLetterWord=null,this.firstSpace=null,this.readyTokens=[],this.oldToken=null,this.mark=null}},Pr=(t,e,i)=>t.nTemplate===e.nTemplate&&t.nExt===e.nExt&&t.nVar===e.nVar&&t.nLink===e.nLink&&t.nExtLink===e.nExtLink&&t.extName===e.extName&&(i||t.extName!=="mediawiki"||Pr(t.extState,e.extState)),o2=(t,e)=>{t.nTemplate=e.nTemplate,t.nExt=e.nExt,t.nVar=e.nVar,t.nLink=e.nLink,t.nExtLink=e.nExtLink,t.extName=e.extName},Tr=(t,e)=>{const i=e.tokenize(t,e);return Array.isArray(i)?i[0]:i},mi=(t,e,i,r=!1)=>({tokenize:t,stack:[],inHtmlTag:[],extName:!1,extMode:!1,extState:!1,nTemplate:0,nExt:0,nVar:0,nLink:0,nExtLink:0,lbrack:!1,bold:!1,italic:!1,dt:{n:0,html:0},sof:r,redirect:!1,imgLink:!1,data:new s2(e,`(${i.source.slice(4)}`)}),Ro=t=>{const e={...t};for(const[i,r]of Object.entries(t))Array.isArray(r)?e[i]=[...r]:i==="extState"?e[i]=(t.extName&&t.extMode&&t.extMode.copyState||Ro)(r):i!=="data"&&r&&typeof r=="object"&&(e[i]={...r});return e},a2=t=>typeof document!="object"||t.startsWith("#")||[...tT(`&${t}`)].length===1,ee=(t,...e)=>{t.stack.unshift(...e.slice(1),t.tokenize),t.tokenize=e[0]},re=t=>{t.tokenize=t.stack.shift()},Vi=(t,e,i)=>t.sol()&&(e&&t.match(/^\s*(?::+\s*)?\{\|/u,!1)||t.match(/^(?:-{4}|=)/u,!1)||!i&&/[*#;:]/u.test(t.peek()||"")),pe=(t,e)=>{const i={"'":"'(?!')","{":String.raw`\{(?!\{)`,"}":String.raw`\}(?!\})`,"<":e?"<(?!!--)":"<(?!!--|/?[a-z])","~":"~~?(?!~)",_:"_(?!_)","_":"_(?!_)","[":String.raw`\[(?!\[)`,"]":String.raw`\](?!\])`,"/":"/(?!>)","-":String.raw`-(?!\{(?!\{))`};if(typeof e=="object"){const{data:{tags:r}}=e;i["<"]=String.raw`<(?!!--${r.includes("onlyinclude")?"|onlyinclude>":""}|(?:${r.filter(n=>n!=="onlyinclude").join("|")})(?:[\s/>]|$))`}return[...t].map(r=>i[r]).join("|")},uc=t=>{const{dt:e}=t;return!!e.n&&e.html===0&&!t.bold&&!t.italic&&Pr(e,t,!0)},lb=(t="")=>String.raw`[^&${"~{'"}\p{Zs}[\]<>"${t}]|&(?![lg]t;)|${pe("~{'")}`,hb=t=>String.raw`.,;:!?\\${t?"":")"}`,te=(t,e)=>function(...i){const r=t.apply(this,i);return Object.defineProperty(r,"name",{value:e.name}),r.args=i,r},cb=(t,e)=>{var i;return(typeof t=="string"?t:`${t[0]} ${e.bold||(i=e.dt)!=null&&i.n?$.strong:""} ${e.italic?$.em:""}`).trim().replace(/\s{2,}/gu," ")||" "},me=(t,e,i)=>{let r="";switch(e.nTemplate){case 0:break;case 1:r+="-template";break;case 2:r+="-template2";break;default:r+="-template3";break}switch(e.nExt){case 0:break;case 1:r+="-ext";break;case 2:r+="-ext2";break;default:r+="-ext3";break}if((e.nLink||e.nExtLink)&&(r+="-link"),i){e[i]--;const{dt:n}=e;n!=null&&n.n&&e[i]<n[i]&&(n.n=0)}return(r&&`mw${r}-ground `)+t},C=(t,e,i)=>me($[t],e,i),$e=(t,e,i)=>[me(t,e,i)],gi=(t,e,i)=>$e($[t],e,i),l2=(t,e)=>{const i=t.pos,r=t.string.slice(0,i-3),n=r.slice(-1),s=r.slice(-2,-1),{data:o}=e;if(n===" "){if(o.firstMultiLetterWord||o.firstSpace)return;o.firstSpace=i}else if(s===" ")o.firstSingleLetterWord=i;else{if(o.firstMultiLetterWord)return;o.firstMultiLetterWord=i}o.mark=i},dc=t=>String.raw`(?:${t?"":String.raw`\||`}\{(?:\{\s*|\s*\()!\s*\}\})`,pc=t=>{const e=t.peek();return e==="'"||e==='"'?e.repeat(2):""},Xo=t=>t.name==="inTemplateArgument"&&t.args[0]?"=":"",Oc=(t,e)=>{if(e&&t.sol())return!0;const i=t.peek();return!!(i&&!i.trim())},h2=new Set(["syntaxhighlight","source","pre"]),c2=new Set(["raw","msg","filepath","localurl","localurle","fullurl","fullurle","canonicalurl","canonicalurle","int","msgnw"]),fb=new Set(["subst","safesubst"]),f2=new RegExp(`^(?:[^&[<{~'-]|${pe("<{~'-")})+`,"iu"),u2=new RegExp(`^(?:[^|{}<]|${pe("{}<",!0)})+`,"u"),d2=new RegExp(`^(?:[^|[&:}{<~'__-]|${pe("}{<~'__-")})+`,"iu"),p2=new RegExp(`^(?:[^|[&}{<~'__-]|${pe("}{<~'__-")})+`,"iu"),O2=new RegExp(`^(?:[^&'{[<~__:-]|${pe("'{[<~__-")})+`,"iu"),m2=new RegExp(`^(?:[^&={<]|${pe("{<")})+`,"iu"),ub=/^\s*(?:[|!]|\{\{\s*![!)+-]?\s*\}\})/u,db="[{'<-",Wo="{<",pb="'<~__{-",Ob="{/",mb=[!1,!0].map(t=>{const e=hb(t),i=lb(e);return new RegExp(`^(?:${i}|[${e}]+(?=${i}))*`,"u")}),g2=[!1,!0].map(t=>new RegExp(String.raw`^:*\s*(?=\{${dc(t)})`,"u")),b2=[!1,!0].map(t=>new RegExp(String.raw`^${dc(t)}\s*`,"u")),v2=[!1,!0].map(t=>new RegExp(String.raw`^\s*(:+\s*)?(?=\{${dc(t)})`,"u")),y2=[!1,!0].map(t=>{const e=`]'{<${t?"~":"["}-`;return new RegExp(`^(?:[^&${t?"[|":""}\\${e}]|${pe(e)})+`,"iu")}),mc=[new RegExp(String.raw`^(?:[<>{}]|%(?:3[ce]|[57][bd])|${pe("[]")})+`,"iu"),new RegExp(String.raw`^(?:\}|${pe("[]{")})+`,"u"),new RegExp(String.raw`^(?:[>}]|%(?:3[ce]|[57][bd])|${pe("[]{<")})+`,"iu")],S2=["","="].map(t=>new RegExp(String.raw`^(?:[^\s&${Wo}${t}]|${pe(Wo)})+`,"iu")),k2=[!1,!0].map(t=>new RegExp(String.raw`^(?:[^|{}<${t?"[&~'__:-":""}]|\}(?!\}\})|${t?pe("{<~'__-"):pe("{<",!0)})+`,"iu")),w2=["","[&","[&:"].map(t=>xt(e=>new RegExp(`^(?:[^|${t}${e}]|${pe(e)})+`,"iu"))),x2={_:/^[\p{L}\p{N}_]+?__/u,"_":/^[\p{L}\p{N}__]+?_{2}/u},Q2=xt(t=>new RegExp(String.raw`^(?:[^\]&${t}${db}]|${pe(db)})+`,"iu")),$2=xt(t=>new RegExp(`^(?:${lb(t)})+`,"u")),P2=xt(t=>new RegExp(`^(?:[^&${Wo}${t}]|${pe(Wo)})+`,"iu")),T2=xt(t=>new RegExp(`^(?:[^[&${t}${pb}]|${pe(pb)})+`,"iu")),gb=xt(t=>new RegExp(`^(?:[^<>&${Ob}${t}]|${pe(Ob)})+`,"u")),C2=xt(t=>new RegExp(`^(?:[^<>&={/${t}]|${pe("{/")})+`,"u")),Z2=xt(t=>new RegExp(`^(?:[^>/${t}]|${pe("/")})+`,"u")),A2=xt(t=>t==="onlyinclude"?/<\/onlyinclude(?:>|$)/u:new RegExp(String.raw`</${t}\s*(?:>|$)`,"iu")),R2=xt(t=>new RegExp(String.raw`^(?:[^<]|<(?!${t}(?:[\s/>]|$)))+`,"iu")),X2=(Hv=[te],Fv=[te],Uv=[te],Gv=[te],Iv=[te],Nv=[te],zv=[te],jv=[te],Lv=[te],Bv=[te],_v=[te],Vv=[te],Yv=[te],Dv=[te],qv=[te],Ev=[te],Mv=[te],Wv=[te],Xv=[te],Rv=[te],Av=[te],Zv=[te],Cv=[te],Tv=[te],Pv=[te],$v=[te],Qv=[te],xv=[te],wv=[te],kv=[te],U=class{constructor(t){nf(K,5,this);const{urlProtocols:e,permittedHtmlTags:i,implicitlyClosedHtmlTags:r,tags:n,nsid:s,variants:o,functionSynonyms:[a],redirection:l=["#REDIRECT"],img:h={}}=t;this.config=t,this.tokenTable={...pT},this.hiddenTable={},this.permittedHtmlTags=new Set([...jm,...i!=null?i:[]]),this.voidHtmlTags=new Set([...zm,...r!=null?r:[]]),this.urlProtocols=new RegExp(String.raw`^(?:${e})(?=[^\p{Zs}[\]<>"])`,"iu"),this.linkRegex=new RegExp(String.raw`^\[(?!${e})\s*`,"iu"),this.fileRegex=new RegExp(String.raw`^(?:${Object.entries(s).filter(([,c])=>c===6).map(([c])=>c).join("|")})\s*:`,"iu"),this.redirectRegex=new RegExp(String.raw`^\s*(?:${l.join("|")})(\s*:)?\s*(?=\[\[|$)`,"iu"),this.img=Object.keys(h).filter(c=>!/\$1./u.test(c)),this.imgRegex=new RegExp(String.raw`^(?:${this.img.filter(c=>c.endsWith("$1")).map(c=>c.slice(0,-2)).join("|")}|(?:${this.img.filter(c=>!c.endsWith("$1")).join("|")}|(?:\d+x?|\d*x\d+)\s*(?:px)?px)\s*(?=\||\]\]|$))`,"u"),this.tags=[...Object.keys(n),"includeonly","noinclude","onlyinclude"],this.convertRegex=new RegExp(String.raw`^(?:[^}|;&='{[<~__-]|\}(?!-)|=(?!>)|\[(?!\[|${e})|${pe("'{<~__-")})+`,"iu"),this.convertSemicolon=o&&new RegExp(String.raw`^;\s*(?=(?:[^;]*?=>\s*)?(?:${o.join("|")})\s*:|(?:$|\}-))`,"iu"),this.convertLang=o&&new RegExp(String.raw`^(?:=>\s*)?(?:${o.join("|")})\s*:`,"iu"),this.hasVariants=!!(o!=null&&o.length),this.preRegex=[!1,!0].map(c=>new RegExp(String.raw`^(?:[^<&-]|-${this.hasVariants?String.raw`(?!\{)`:""}|<(?!${c?"/":""}nowiki>))+`,"iu")),this.substRegex=new RegExp(String.raw`^\s*(?:(${Object.entries(a).filter(([,c])=>fb.has(c)).map(([c])=>c+(c.endsWith(":")?"":":")).join("|")})\s*)?`,"iu"),this.autocompleteNamespaces={0:"",6:"File:",8:"MediaWiki:",10:"Template:",274:"Widget:",828:"Module:"},this.registerGroundTokens()}addToken(t,e=!1,i){var r,n,s;(s=(r=this[e?"hiddenTable":"tokenTable"])[n=`mw-${t}`])!=null||(r[n]=rt.define(i))}registerGroundTokens(){const t=["ext","ext-link","ext2","ext2-link","ext3","ext3-link","link","template-ext","template-ext-link","template-ext2","template-ext2-link","template-ext3","template-ext3-link","template","template-link","template2-ext","template2-ext-link","template2-ext2","template2-ext2-link","template2-ext3","template2-ext3-link","template2","template2-link","template3-ext","template3-ext-link","template3-ext2","template3-ext2-link","template3-ext3","template3-ext3-link","template3","template3-link"];for(const e of t)this.addToken(`${e}-ground`);for(let e=1;e<7;e++)this.addToken(`section--${e}`);for(const e of this.tags)this.addToken(`tag-${e}`,e!=="nowiki"&&e!=="pre"&&e!=="ref"),this.addToken(`ext-${e}`,!0);for(const e of this.permittedHtmlTags)this.addToken(`html-${e}`,!0);for(const e of Object.keys(this.autocompleteNamespaces))Number.isInteger(Number(e))&&this.addToken(`function-${e}`,!0)}inChars({length:t},e){return(i,r)=>(i.pos+=t,re(r),C(e,r))}inStr(t,e,i="error"){return(r,n)=>r.match(t,!!e)?(re(n),e?C(e,n):""):(r.skipTo(t)||r.skipToEnd(),C(i,n))}eatWikiText(t){t in $&&(t=$[t]);const e=/^(?:(?:RFC|PMID)[\p{Zs}\t]+\d+|ISBN[\p{Zs}\t]+(?:97[89][\p{Zs}\t-]?)?(?:\d[\p{Zs}\t-]?){9}[\dxX])\b/u;return(i,r)=>{var s,o;let n;if(i.eol())return"";if(i.sol()){if(r.sof){if(i.match(/^\s+$/u))return"";r.sof=!1;const l=i.match(this.redirectRegex);if(l)return r.redirect={colon:!l[1]},$.redirect}else if(r.redirect){if(i.match(/^\s+(?=$|\[\[)/u))return"";if(r.redirect.colon&&i.match(/^\s*:\s*(?=$|\[\[)/u))return r.redirect.colon=!1,$.redirect;r.redirect=!1}n=i.next();const a=["inTemplateArgument","inParserFunctionArgument","inVariable"].includes(r.tokenize.name);switch(n){case"#":case";":case"*":return i.backUp(1),this.eatList(i,r);case":":return i.match(g2[a?1:0])?(ee(r,this.eatStartTable),C("list",r)):this.eatList(i,r);case"=":{const l=i.match(/^(={0,5})(.+?(=\1\s*)(?:<!--(?!.*-->\s*\S).*)?)$/u);if(l)return i.backUp(l[2].length),ee(r,this.inSectionHeader(l[3])),me(`${$.sectionHeader} mw-section--${l[1].length+1}`,r);break}case"{":if(i.match(b2[a?1:0]))return ee(r,this.inTableDefinition()),C("tableBracket",r);break;case"-":if(i.match(/^-{3,}/u))return $.hr;break;default:if(!n.trim()){const l=i.match(v2[a?1:0]);if(l)return ee(r,this.eatStartTable),me(l[1]?$.list:"",r);if(n===" "&&!/^ \s*(?=<!--)(?:\s|<!--(?:(?!-->).)*-->)+$/u.test(i.string))return $.skipFormatting}}}else n=i.next();switch(n){case"~":if(i.match(/^~{2,4}/u))return $.signature;break;case"<":{if(i.match("!--"))return ee(r,this.inComment),C("comment",r);const a=!!i.eat("/"),l=i.match(/^([a-z][^\s/>]*)>?/iu,!1);if(l){const h=l[1].toLowerCase();if((l[0]==="onlyinclude>"||h!=="onlyinclude")&&r.data.tags.includes(h))return this.eatExtTag(h,a,r);if(this.permittedHtmlTags.has(h))return this.eatHtmlTag(h,a,r)}break}case"{":{if(i.match(/^\{\{(?!\{|[^{}]*\}\}(?!\}))\s*/u))return r.nVar++,ee(r,this.inVariable()),C("templateVariableBracket",r);if(i.match(/^\{(?!\{(?!\{))/u))return(s=this.eatTransclusion(i,r))!=null?s:$e(t,r);break}case"_":case"_":{const{pos:a}=i;switch(i.eatWhile(n),i.pos-a){case 0:break;case 1:return this.eatDoubleUnderscore(t,n,i,r);default:return i.eol()||i.backUp(2),$e(t,r)}break}case"[":if(i.match(this.linkRegex)){const{redirect:a}=r;if(a||/[^[\]|]/u.test(i.peek()||""))return r.nLink++,r.lbrack=void 0,ee(r,this.inLink(!a&&!!i.match(this.fileRegex,!1))),C("linkBracket",r);if(i.match("]]"))return $e(t,r)}else{const a=i.match(r.data.urlProtocols,!1);if(a)return r.nExtLink++,a[1]?ee(r,this.inChars("<","extTagBracket"),this.eatTagName("tvar"),this.inExternalLink(!0)):ee(r,this.eatExternalLinkProtocol(a[2],!1)),C("extLinkBracket",r)}break;case"'":{const a=this.eatApostrophes(r)(i,r);if(a)return a;break}case":":if(uc(r))return r.dt.n--,C("list",r);break;case"&":return $e(this.eatEntity(i,t),r);case"-":if((o=this.config.variants)!=null&&o.length&&i.match(/^\{(?!\{)\s*/u))return ee(r,this.inConvert(t,!0)),C("convertBracket",r)}if(r.stack.length===0){if(n!=="_"&&n!=="_"){/[\p{L}\p{N}]/u.test(n)?i.backUp(1):i.eatWhile(/[^\p{L}\p{N}__&'{[<~:-]/u);const a=i.match(this.urlProtocols,!1);if(a)return ee(r,this.eatExternalLinkProtocol(a[0])),$e(t,r);const l=i.match(e,!1);if(l)return ee(r,this.inChars(l[0],"magicLink")),$e(t,r)}i.eatWhile(/[\p{L}\p{N}]/u)}return $e(t,r)}}eatApostrophes(t){return(e,i)=>e.match(/^'*(?='{5})/u)||e.match(/^'''(?!')/u,!1)?!1:e.match("''''")?(t.bold=!t.bold,t.italic=!t.italic,C("apostrophes",i)):e.match("''")?(t===i&&i.data.firstSingleLetterWord===null&&l2(e,i),t.bold=!t.bold,C("apostrophes",i)):e.eat("'")?(t.italic=!t.italic,C("apostrophes",i)):!1}eatExternalLinkProtocol({length:t},e=!0){return(i,r)=>(i.pos+=t,r.tokenize=e?this.eatFreeExternalLink:this.inExternalLink(),C(e?"freeExtLinkProtocol":"extLinkProtocol",r))}inExternalLink(t){return(e,i)=>{const r=i.stack[0],n=Xo(r),s=["inTemplateArgument","inParserFunctionArgument","inVariable","inTableCell"].includes(r.name),o=(s?"|":"")+n,a=e.peek();return e.sol()||e.match(/^\p{Zs}*\]/u)||s&&a==="|"||n&&a==="="?(re(i),C("extLinkBracket",i,"nExtLink")):t?e.match(Q2(o))?gi("extLinkText",i):this.eatWikiText("extLinkText")(e,i):e.match($2(o))?C("extLink",i):(i.tokenize=this.inExternalLink(!0),"")}}eatFreeExternalLink(t,e){const i=t.match(mb[0]);return!t.eol()&&i[0].includes("(")&&hb().includes(t.peek())&&t.match(mb[1]),re(e),gi("freeExtLink",e)}inLink(t,e){const i=e?$[t?"error":"linkToSection"]:`${$.linkPageName} ${$.pageName}`,r=e?/^(?:[^|<[\]{}]|<(?!!--|\/?[a-z]))+/iu:/^(?:&#(?:\d+|x[a-f\d]+);|[^#|<>[\]{}%]|%(?!3[ce]|[57][bd]))+/iu;let n;return(s,o)=>{if(s.sol()||n&&s.pos>n||s.match(/^\s*\]\]/u)||s.match(/^\[\[/u,!1))return o.redirect=!1,o.lbrack=!1,re(o),C("linkBracket",o,"nLink");n=void 0;const a=s.eatSpace(),{redirect:l}=o;if(!e&&s.match(/^#\s*/u))return o.tokenize=this.inLink(t,!0),gi(t?"error":"linkToSection",o);if(s.match(/^\|\s*/u)){o.tokenize=this.inLinkText(t);let c=l?"error":"linkDelimiter";return t&&(c="fileDelimiter",this.toEatImageParameter(s,o)),C(c,o)}let h;return l?[h]=mc:e?[,h]=mc:[,,h]=mc,s.match(h)?gi("error",o):l?(s.match(/^(?:[^|<>[\]{}%]|%(?!3[ce]|[57][bd]))+/iu),$e(i,o)):s.match(r)||a?$e(i,o):(s.match(/^<(?!(?:includeonly|noinclude)(?:\/?>|\s|$)|tvar(?:\s|$))[/a-z]/iu,!1)&&!s.match(/^<onlyinclude>/u,!1)&&(n=s.pos+1),this.eatWikiText(e?i:"error")(s,o))}}inLinkText(t,e){const i={bold:!1,italic:!1},r=y2[t?1:0];return(n,s)=>{var f;const o=`${$[t?"fileText":"linkText"]} ${i.bold?$.strong:""} ${i.italic?$.em:""} ${t&&s.imgLink?$.pageName:""}`,{redirect:a,lbrack:l}=s,h=n.match("]]");if(h||!t&&n.match("[[",!1)||!e&&((f=s.stack[0])==null?void 0:f.name)==="inTableCell"&&n.sol()&&n.match(ub,!1))return e?$e(o,s):h&&!a&&l&&n.peek()==="]"?(n.backUp(1),s.lbrack=!1,$e(o,s)):(s.redirect=!1,s.lbrack=!1,re(s),C("linkBracket",s,"nLink"));if(a)return n.skipTo("]]")||n.skipToEnd(),C("error",s);if(t&&n.match(/^\|\s*/u))return this.toEatImageParameter(n,s),C("fileDelimiter",s);if(n.match(/^'(?=')/u))return this.eatApostrophes(i)(n,s)||$e(o,s);if(t&&Vi(n,!0,!0)||n.sol()&&n.match("{|",!1))return this.eatWikiText(o)(n,s);const c=n.match(r);return l===void 0&&(c!=null&&c[0].includes("["))&&(s.lbrack=!0),c?$e(o,s):this.eatWikiText(o)(n,s)}}toEatImageParameter(t,e){var r;e.imgLink=!1;const i=t.match(this.imgRegex,!1);i&&(((r=this.config.img)==null?void 0:r[`${i[0]}$1`])==="img_link"&&(e.imgLink=!0),ee(e,this.inChars(i[0],"imageParameter")))}eatList(t,e){const i=t.match(/^[*#;:]*/u),{dt:r}=e;return i[0].includes(";")&&(r.n=i[0].split(";").length-1,o2(r,e)),C("list",e)}eatDoubleUnderscore(t,e,i,r){const{config:{doubleUnderscore:n}}=this,s=e.repeat(2),o=i.match(x2[e]);if(o){if(Object.prototype.hasOwnProperty.call(n[0],s+o[0].toLowerCase())||Object.prototype.hasOwnProperty.call(n[1],s+o[0]))return $.doubleUnderscore;i.eol()||i.backUp(2)}return $e(t,r)}get eatStartTable(){return(t,e)=>(t.match(/^(?:\{\||\{\{(?:\{\s*|\s*\()!\s*\}\})\s*/u),e.tokenize=this.inTableDefinition(),C("tableBracket",e))}inTableDefinition(t,e){const i=e===void 0?`${$.tableDefinition} mw-html-${t?"tr":"table"}`:$.tableDefinitionValue;return(r,n)=>{if(r.sol())return n.tokenize=this.inTable,"";const s=n.stack[0],o=Xo(s);return o&&r.peek()==="="?(re(n),""):r.match(/^(?:&|\{\{|<(?:!--|\/?[a-z]))/iu,!1)?this.eatWikiText(i)(r,n):e?(r.eat(e[0])?n.tokenize=this.inTableDefinition(t,e[1]):r.match(P2(o+e[0])),me(i,n)):e===""?Oc(r)?(n.tokenize=this.inTableDefinition(t),""):(r.match(S2[o?1:0]),me(i,n)):r.match(/^=\s*/u)?(n.tokenize=this.inTableDefinition(t,pc(r)),me(i,n)):(r.match(m2),me(i,n))}}get inTable(){return(t,e)=>{if(t.sol()){t.eatSpace();const i=t.match(/^(?:\||\{\{\s*!([!)+-])?\s*\}\})/u);if(i)return i[1]==="-"||!i[1]&&t.eat("-")?(t.match(/^-*\s*/u),e.tokenize=this.inTableDefinition(!0),C("tableDelimiter",e)):i[1]==="+"||!i[1]&&t.match(/^\+\s*/u)?(e.tokenize=this.inTableCell($.tableCaption),C("tableDelimiter",e)):i[1]===")"||!i[1]&&t.eat("}")?(re(e),C("tableBracket",e)):(t.eatSpace(),e.tokenize=this.inTableCell($.tableTd,i[1]!=="!"),C("tableDelimiter",e));if(t.match(/^!\s*/u))return e.tokenize=this.inTableCell($.tableTh),C("tableDelimiter",e);if(Vi(t,!0))return this.eatWikiText("error")(t,e)}return t.match(O2)?gi("error",e):this.eatWikiText("error")(t,e)}}inTableCell(t,e=!0,i=!0){return(r,n)=>{if(r.sol()){if(r.match(ub,!1))return n.tokenize=this.inTable,"";if(i)return n.tokenize=this.inTableCell(t,!1,!1),"";if(Vi(r,!0))return this.eatWikiText(t)(r,n)}if(i){if(r.match(/^(?:(?:\||\{\{\s*!\s*\}\}){2}|\{\{\s*!!\s*\}\})\s*/u)||t===$.tableTh&&r.match(/^!!\s*/u))return n.bold=!1,n.italic=!1,e||(n.tokenize=this.inTableCell(t)),C("tableDelimiter",n);if(e&&r.match(/^(?:\||\{\{\s*!\s*\}\})\s*/u))return n.bold=!1,n.italic=!1,n.tokenize=this.inTableCell(t,!1),C("tableDelimiter2",n);e&&r.match("[[",!1)&&(n.tokenize=this.inTableCell(t,!1))}const s=n.stack[0],o=Xo(s);return o&&r.peek()==="="?(re(n),""):r.match(T2((i?"|!":":")+o))?$e(t,n):this.eatWikiText(t)(r,n)}}inSectionHeader(t){return(e,i)=>e.sol()?(re(i),""):e.match(f2)?(e.eol()?(e.backUp(t.length),i.tokenize=this.inStr(t,"sectionHeader")):e.match(/^<!--(?!.*?-->.*?=)/u,!1)&&(e.backUp(t.length),i.tokenize=this.inStr("<!--",!1,"sectionHeader")),C("section",i)):this.eatWikiText("section")(e,i)}get inComment(){return this.inStr("-->","comment","comment")}eatExtTag(t,e,i){return e?(ee(i,this.inStr(">","error")),C("error",i)):(ee(i,this.eatTagName(t)),C("extTagBracket",i))}eatHtmlTag(t,e,i){if(e){const{dt:r,inHtmlTag:n}=i;if(r.n&&r.html&&r.html--,t===n[n.length-1])n.pop();else{ee(i,this.inStr(">","error"));const s=n.lastIndexOf(t);return s!==-1&&n.splice(s,1),C("error",i)}}return ee(i,this.eatTagName(t,e,!0)),C("htmlTagBracket",i)}eatTagName(t,e,i){return(r,n)=>(r.match(t,!0,!0),r.eatSpace(),i?(n.tokenize=e?this.inStr(">","htmlTagBracket"):this.inHtmlTagAttribute(t),C("htmlTagName",n)):(n.tokenize=e?this.inStr(">","extTagBracket"):this.inExtTagAttribute(t),C("extTagName",n)))}inHtmlTagAttribute(t,e){const i=e===void 0?`${$.htmlTagAttribute} mw-html-${t}`:$.htmlTagAttributeValue;return(r,n)=>{var l;if(r.match(new RegExp(`^${pe("<",n)}`,"iu"),!1))return re(n),"";const s=r.match(/^\/?>/u);if(s)return!this.voidHtmlTags.has(t)&&(s[0]===">"||!Nm.includes(t))&&(n.inHtmlTag.push(t),n.dt.html++),re(n),C("htmlTagBracket",n);const o=n.stack[0],a=(["inTemplateArgument","inParserFunctionArgument","inVariable"].includes(o.name)?"|":"")+Xo(o);return a.includes((l=r.peek())!=null?l:"")?(re(n),""):r.match(/^(?:[&<]|\{\{)/u,!1)?this.eatWikiText(i)(r,n):e?(r.eat(e[0])?n.tokenize=this.inHtmlTagAttribute(t,e[1]):r.match(gb(a+e[0])),me(i,n)):e===""?Oc(r,!0)?(n.tokenize=this.inHtmlTagAttribute(t),""):(r.match(gb(String.raw`\s${a}`)),me(i,n)):r.match(/^=\s*/u)?(n.tokenize=this.inHtmlTagAttribute(t,pc(r)),me(i,n)):(r.match(C2(a)),me(i,n))}}inExtTagAttribute(t,e,i,r){const n=`${$.extTagAttribute} mw-ext-${t}`,s=(o,a,l)=>{const h=o.match(l);if(i){let c=h[0].trim().toLowerCase();c==="js"&&(c="javascript"),c in this&&(a.extMode=this[c]())}return me($.extTagAttributeValue+(r?` ${$.pageName}`:""),a)};return(o,a)=>{if(o.match("/>"))return t==="tvar"?(o.backUp(1),C("error",a)):(a.extMode=!1,re(a),C("extTagBracket",a));if(o.eat(">")){const{config:{tagModes:h}}=this;return a.extName=t,a.extMode||(a.extMode=t in h&&h[t]in this&&this[h[t]]([...a.data.tags.filter(c=>c!==t),...t==="translate"?["tvar"]:[]])),a.extMode&&(a.extState=a.extMode.startState(0)),a.tokenize=this.eatExtTagArea(t),C("extTagBracket",a)}else if(e){if(o.eat(e[0])){const[,h]=e;return a.tokenize=this.inExtTagAttribute(t,h,i&&!!h,r&&!!h),C("extTagAttributeValue",a)}return s(o,a,Z2(e[0]))}else{if(e==="")return Oc(o,!0)?(a.tokenize=this.inExtTagAttribute(t),""):s(o,a,/^(?:[^>/\s]|\/(?!>))+/u);if(o.match(/^=\s*/u))return a.tokenize=this.inExtTagAttribute(t,pc(o),i,r),me(n,a)}const l=o.match(/^(?:[^>/=]|\/(?!>))+/u);return o.peek()==="="&&(a.tokenize=this.inExtTagAttribute(t,void 0,h2.has(t)&&/(?:^|\s)lang\s*$/iu.test(l[0]),t==="templatestyles"&&/(?:^|\s)src\s*$/iu.test(l[0]))),me(n,a)}}eatExtTagArea(t){return(e,i)=>{const{pos:r}=e,n=e.string.slice(r).search(A2(t));if(n===0)return e.match("</"),i.tokenize=this.eatTagName(t,!0),i.extName=!1,i.extMode=!1,i.extState=!1,C("extTagBracket",i);let s="";return n!==-1&&(s=e.string,e.string=s.slice(0,r+n)),ee(i,this.inExtTokens(s)),""}}inExtTokens(t){return(e,i)=>{var n;let r;return i.extMode===!1?(r=`mw-tag-${i.extName} ${$.extTag}`,e.skipToEnd()):r=`mw-tag-${i.extName} ${(n=i.extMode.token(e,i.extState))!=null?n:""}`,e.eol()&&(t&&(e.string=t),re(i)),r}}inVariable(t=0){let e="comment";t===0?e="templateVariableName":t===1&&(e="templateVariable");const i=k2[t===1?1:0];return(r,n)=>{const s=r.sol();return r.eatSpace(),r.eol()?me("",n):r.eat("|")?(t<2&&(n.tokenize=this.inVariable(t+1)),C("templateVariableDelimiter",n)):r.match(/^\}{2,3}/u)?(re(n),C("templateVariableBracket",n,"nVar")):r.match("<!--")?(ee(n,this.inComment),C("comment",n)):t===0&&s?(n.nVar--,re(n),r.pos=0,""):t===1&&Vi(r)||!r.match(i)?this.eatWikiText(e)(r,n):(t===1?gi:C)(e,n)}}eatTransclusion(t,e){const[{length:i},r]=t.match(this.substRegex),n=r?[this.inSubst(r)]:[];if(t.peek()==="#")return t.backUp(i),e.nExt++,ee(e,...n,this.inParserFunctionName()),C("parserFunctionBracket",e);const s=t.match(/^([^}<{|::]+)(.?)/u,!1);if(s){const[,o,a]=s,l=a===":";let h=o;l?h+=":":a!==":"&&(h=o.trim());const c=h.toLowerCase(),{config:{functionSynonyms:f,variableIDs:u,functionHooks:d}}=this,p=Object.prototype.hasOwnProperty.call(f[1],h)&&f[1][h]||Object.prototype.hasOwnProperty.call(f[0],c)&&f[0][c];if((!a||l||a===":"||a==="}")&&p&&!fb.has(p)&&(l||a===":"||!u||u.includes(p))&&(!l&&a!==":"||!d||d.includes(p)||HZ.has(p)))return t.backUp(i),e.nExt++,ee(e,...n,this.inParserFunctionName()),C("parserFunctionBracket",e)}if(!t.match("}}"))return t.backUp(i),e.nTemplate++,ee(e,...n,this.inTemplatePageName()),C("templateBracket",e)}inSubst(t){return(e,i)=>t?(e.eatSpace(),e.match(t),e.backUp(1),i.tokenize=this.inSubst(),C("parserFunctionName",i)):(e.next(),re(i),C("parserFunctionDelimiter",i))}inParserFunctionName(t,e,i){return(r,n)=>{var h;const s=r.sol(),o=r.eatSpace();if(r.eol())return me("",n);if(r.eat("}"))return re(n),C(r.eat("}")?"parserFunctionBracket":"error",n,"nExt");if(r.match("<!--"))return ee(n,this.inComment),C("comment",n);if(s)return n.nExt--,re(n),r.pos=0,"";const a=r.eat(/[::|]/u);if(a)return n.tokenize=this.inParserFunctionArgument(t,e,i),C(o||a==="|"?"error":"parserFunctionDelimiter",n);const l=r.match(/^(?:[^::}{|<>[\]\s]|\s(?![::]))+/u);if(l){const c=l[0].trim().toLowerCase()+(r.peek()===":"?":":""),{config:{functionSynonyms:[f]}}=this;if(c.startsWith("#"))switch((h=f[c])!=null?h:f[c.slice(1)]){case"invoke":n.tokenize=this.inParserFunctionName(2);break;case"widget":n.tokenize=this.inParserFunctionName(1);break;case"switch":n.tokenize=this.inParserFunctionName(void 0,1);break;case"tag":n.tokenize=this.inParserFunctionName(void 0,2);break;case"ifexist":case"lst":case"lstx":case"lsth":n.tokenize=this.inParserFunctionName(1/0)}else{const u=f[c];if(c2.has(u)){let d=0;switch(u){case"filepath":d=6;break;case"int":d=8;break;case"raw":case"msg":case"msgnw":d=10}n.tokenize=this.inParserFunctionName(1/0,1/0,d)}}return C("parserFunctionName",n)}return re(n),me("",n,"nExt")}}inTemplatePageName(t,e){const i=e?$.error:`${$.templateName} ${$.pageName}`,r="{}<",n=e?u2:/^(?:&#(?:\d+|x[a-f\d]+);|[^|{}<>[\]#%]|%(?![\da-f]{2}))+/iu;return(s,o)=>{const a=s.sol(),l=s.eatSpace();return s.eol()?me("",o):s.match("}}")?(re(o),C("templateBracket",o,"nTemplate")):s.match("<!--")?(ee(o,this.inComment),C("comment",o)):s.match(/^<\/?onlyinclude>/u)||s.match(/^<(?:(?:includeonly|noinclude)(?:\s[^>]*)?\/?>|\/(?:includeonly|noinclude)\s*>)/iu)||o.data.tags.includes("tvar")&&s.match(/^<(?:tvar\s[^>]*>|\/tvar\s*>)/iu)?C("comment",o):s.eat("|")?(o.tokenize=this.inTemplateArgument(!0),C("templateDelimiter",o)):t&&a?(o.nTemplate--,re(o),s.pos=0,""):!e&&s.eat("#")?(o.tokenize=this.inTemplatePageName(!0,!0),C("error",o)):!e&&s.match(new RegExp(String.raw`^(?:[>[\]]|%[\da-f]{2}|${pe(r,o)})+`,"iu"))?C("error",o):!e&&s.peek()==="<"?(re(o),me("",o,"nTemplate")):l&&!t?me("",o):s.match(n)?(t||(o.tokenize=this.inTemplatePageName(!0,e)),me(i,o)):l?me(i,o):this.eatWikiText(i)(s,o)}}inParserFunctionArgument(t,e=t!=null?t:1/0,i=0){if(e===0)return this.inTemplateArgument(!0,!0);const r=e===2?"}{<":"}{<~'__-";let n=`${$.parserFunction} ${t?$.pageName:""}`;switch(t){case 1:n+=" mw-function-274";break;case 2:n+=" mw-function-828";break;case 1/0:n+=` mw-function-${i}`}return(s,o)=>s.eat("|")?(t?o.tokenize=this.inParserFunctionArgument(void 0,t-1):e!==1/0&&(o.tokenize=this.inParserFunctionArgument(void 0,e-1)),C("parserFunctionDelimiter",o)):s.match("}}")?(re(o),C("parserFunctionBracket",o,"nExt")):!Vi(s)&&s.match(w2[t?0:Number(uc(o))+1](r))?me(n,o):this.eatWikiText("parserFunction")(s,o)}inTemplateArgument(t,e){const i=e?"parserFunction":"template";return(r,n)=>{const s=r.eatSpace();if(r.eol())return C(i,n);if(r.eat("|"))return t||(n.tokenize=this.inTemplateArgument(!0,e)),C(e?"parserFunctionDelimiter":"templateDelimiter",n);if(r.match("}}",!1))return s?C(i,n):(r.pos+=2,re(n),C(e?"parserFunctionBracket":"templateBracket",n,e?"nExt":"nTemplate"));if(r.sol()&&r.peek()==="="){const o=this.eatWikiText(i)(r,n);if(o.includes($.sectionHeader))return o;r.pos=0}return t&&r.match(new RegExp(`^(?:[^=|}{[<]|${pe("}{[<",n)})*=`,"iu"))?(n.tokenize=this.inTemplateArgument(!1,e),C("templateArgumentName",n)):Vi(r)&&r.peek()!=="="?this.eatWikiText(i)(r,n):r.match(uc(n)?d2:p2)||s?C(i,n):this.eatWikiText(i)(r,n)}}inConvert(t,e,i=!0,r){return(n,s)=>{const o=n.eatSpace();return n.match("}-")?(re(s),C("convertBracket",s)):e&&n.match(/^[;\sa-z-]*(?=\|)/iu)?(s.tokenize=this.inConvert(t,!1,!0,r),ee(s,this.inStr("|","convertDelimiter")),C("convertFlag",s)):n.match(this.convertSemicolon)?((e||!i)&&(s.tokenize=this.inConvert(t,!1,!0,r)),C("convertDelimiter",s)):i&&n.match(this.convertLang)?(s.tokenize=this.inConvert(t,!1,!1,r),C("convertLang",s)):r?n.match("-{",!1)?this.eatWikiText(t)(n,s):(n.match(/^(?:(?:[^};=-]|\}(?!-)|=(?!>)|-(?!\{))+|;|=>)/u),$e(t,s)):!Vi(n,!0)&&n.match(this.convertRegex)||o?$e(t,s):this.eatWikiText(t)(n,s)}}eatEntity(t,e){const i=t.match(/^(?:#x[a-f\d]+|#\d+|[a-z\d]+);/iu);return i&&a2(i[0])?$.htmlEntity:e}mediawiki(t){return{startState:()=>mi(this.eatWikiText(""),t!=null?t:this.tags,this.urlProtocols,t===void 0),copyState:Ro,token(e,i){const{data:r}=i,{readyTokens:n}=r;let{oldToken:s}=r;for(;s&&(e.pos>s.pos||e.pos===s.pos&&i.tokenize!==s.state.tokenize);)s=n.shift();if(e.pos===(s==null?void 0:s.pos)&&e.string===s.string&&Pr(i,s.state)){const{pos:a,string:l,state:{bold:h,italic:c,...f},style:u}=n[0];if(Object.assign(i,f),!(i.extName&&i.extMode)&&i.nLink===0&&typeof u=="string"&&u.includes($.apostrophes)){if(r.mark===a){r.mark=null,e.string=l.slice(0,a-2);const p=i.tokenize(e,i);return e.string=l,s.pos++,r.oldToken=s,cb(p,i)}const d=a-e.pos;d!==3&&(i.italic=!i.italic),d!==2&&(i.bold=!i.bold)}else typeof u=="string"&&u.includes($.tableDelimiter)&&(i.bold=!1,i.italic=!1);return r.oldToken=n.shift(),e.pos=a,e.string=l,cb(u,i)}else e.sol()&&(i.bold=!1,i.italic=!1,i.dt.n=0,i.dt.html=0,r.firstSingleLetterWord=null,r.firstMultiLetterWord=null,r.firstSpace=null,i.tokenize.name==="inExtTokens"&&(re(i),re(i),i.extName=!1,i.extMode=!1,i.extState=!1));n.length=0,r.mark=null,r.oldToken={pos:e.pos,string:e.string,state:Ro(i),style:""};const{start:o}=e;do{e.start=e.pos;const a=e.peek(),l=i.tokenize(e,i);if(typeof l=="string"&&l.includes($.templateArgumentName))for(let h=n.length-1;h>=0;h--){const c=n[h];if(Pr(i,c.state,!0)){const f=typeof c.style=="string"&&c.style.split(" "),u=f&&f.indexOf($.template);if(u!==!1&&u!==-1)f[u]=$.templateArgumentName,c.style=f.join(" ");else if(f&&f.includes($.templateDelimiter))break}}else if(typeof l=="string"&&l.includes($.tableDelimiter2))for(let h=n.length-1;h>=0;h--){const c=n[h];if(Pr(i,c.state,!0)){const{style:f}=c,u=typeof f=="string",d=!u&&f[0].split(" ").find(p=>p&&!p.endsWith("-ground"));if(d&&d.startsWith("mw-table-"))c.style=`${f[0].replace("mw-table-","mw-html-")} ${$.tableDefinition}`;else if(u&&f.includes($.tableDelimiter))break}}else if(a==="|"&&typeof l=="string"&&l.includes($.convertDelimiter)){let h=0;for(let c=n.length-1;c>=0;c--){const f=n[c];if(Pr(i,f.state,!0)){const{style:u}=f;if(typeof u=="string"&&u.includes($.convertBracket)){if(h+=f.char==="-"?1:-1,h===1)break}else typeof u=="object"&&(f.style=u[0]+(u[0].includes($.convertFlag)?"":` ${$.convertFlag}`))}}}n.push({pos:e.pos,char:a,string:e.string,state:Ro(i),style:l})}while(!e.eol());return(!i.bold||!i.italic)&&(r.mark=null),e.start=o,e.pos=r.oldToken.pos,e.string=r.oldToken.string,Object.assign(i,r.oldToken.state),""},blankLine(e){e.extName&&e.extMode&&e.extMode.blankLine&&e.extMode.blankLine(e.extState,0)},indent(e,i,r){return e.extName&&e.extMode&&e.extMode.indent?e.extMode.indent(e.extState,i,r):null},...t?void 0:{tokenTable:{...this.tokenTable,...this.hiddenTable,"":rt.define()}}}}"text/mediawiki"(t){return this.mediawiki(t)}"text/nowiki"(){return{startState(){return{}},token:t=>t.eatWhile(/[^&]/u)?"":(t.next(),this.eatEntity(t,""))}}inPre(t){return(e,i)=>e.match(t?/^<\/nowiki>/iu:/^<nowiki>/iu)?(i.tokenize=this.inPre(!t),$.ignored):this.hasVariants&&e.match("-{")?(ee(i,this.inConvert("",!0,!0,!0)),$.convertBracket):e.eat("&")?this.eatEntity(e,""):(e.match(this.preRegex[t?1:0]),"")}"text/pre"(){return{startState:()=>mi(this.inPre(),[],this.urlProtocols),token:Tr}}inNested(t){const e=t==="ref"?/^(?:\{|(?:[^<{]|\{(?!\{)|<(?!!--|ref(?:[\s/>]|$)))+)/iu:R2(t);return(i,r)=>{var n;if(t==="ref"){if(i.match("<!--"))return ee(r,this.inComment),C("comment",r);if(i.match(/^\{{3}(?!\{|[^{}]*\}\}(?!\}))\s*/u))return ee(r,this.inVariable()),$.templateVariableBracket;if(i.match(/^\{\{(?!\{(?!\{))/u))return(n=this.eatTransclusion(i,r))!=null?n:$.ignored}return i.match(e)?$.ignored:(i.eat("<"),ee(r,this.eatTagName(t)),$.extTagBracket)}}"text/references"(t){return{startState:()=>mi(this.inNested("ref"),t,this.urlProtocols),token:Tr}}"text/choose"(t){return{startState:()=>mi(this.inNested("option"),t,this.urlProtocols),token:Tr}}"text/combobox"(t){return{startState:()=>mi(this.inNested("combooption"),t,this.urlProtocols),token:Tr}}get inInputbox(){return(t,e)=>t.match("<!--")?(ee(e,this.inComment),$.comment):(t.match(/^(?:[^<]|<(?!!--))+/u),"")}"text/inputbox"(){return{startState:()=>mi(this.inInputbox,[],this.urlProtocols),token:Tr}}inGallery(t){const e=t?$.error:`${$.linkPageName} ${$.pageName}`,i=t?/^(?:[[}\]]|\{(?!\{))+/u:/^(?:[>[}\]]|\{(?!\{)|<(?!!--))+/u,r=t?/^(?:[^|<[\]{}]|<(?!!--))+/u:/^(?:&#(?:\d+|x[a-f\d]+);|[^#|<>[\]{}])+/u;return(n,s)=>{const o=n.eatSpace();return!t&&n.match(/^#\s*/u)?(s.tokenize=this.inGallery(!0),gi("error",s)):n.match(/^\|\s*/u)?(s.tokenize=this.inLinkText(!0,!0),this.toEatImageParameter(n,s),C("fileDelimiter",s)):n.match(i)?gi("error",s):n.match(r)||o?$e(e,s):this.eatWikiText(t?e:"error")(n,s)}}"text/gallery"(t){return{startState:()=>mi(this.inGallery(),t,this.urlProtocols),token:(e,i)=>(e.sol()&&Object.assign(i,mi(this.inGallery(),i.data.tags,this.urlProtocols)),Tr(e,i))}}},K=tf(null),J(K,1,"inChars",Hv,U),J(K,1,"inStr",Fv,U),J(K,1,"eatWikiText",Uv,U),J(K,1,"eatApostrophes",Gv,U),J(K,1,"eatExternalLinkProtocol",Iv,U),J(K,1,"inExternalLink",Nv,U),J(K,1,"inLink",zv,U),J(K,1,"inLinkText",jv,U),J(K,2,"eatStartTable",Lv,U),J(K,1,"inTableDefinition",Bv,U),J(K,2,"inTable",_v,U),J(K,1,"inTableCell",Vv,U),J(K,1,"inSectionHeader",Yv,U),J(K,2,"inComment",Dv,U),J(K,1,"eatTagName",qv,U),J(K,1,"inHtmlTagAttribute",Ev,U),J(K,1,"inExtTagAttribute",Mv,U),J(K,1,"eatExtTagArea",Wv,U),J(K,1,"inExtTokens",Xv,U),J(K,1,"inVariable",Rv,U),J(K,1,"inSubst",Av,U),J(K,1,"inParserFunctionName",Zv,U),J(K,1,"inTemplatePageName",Cv,U),J(K,1,"inParserFunctionArgument",Tv,U),J(K,1,"inTemplateArgument",Pv,U),J(K,1,"inConvert",$v,U),J(K,1,"inPre",Qv,U),J(K,1,"inNested",xv,U),J(K,2,"inInputbox",wv,U),J(K,1,"inGallery",kv,U),Ho(K,U),U),W2=t=>/mw-[\w-]*link-ground/u.test(t),M2=(t,e,i,r)=>{let{label:n}=e,s;const o=n.charAt(0).toLowerCase(),{state:a}=t,l=a.sliceDoc(r);a.sliceDoc(i,i+1)===o&&(n=o+n.slice(1)),/^\s*\|/u.test(l)||(s={anchor:i+n.length+1,head:i+n.length*2+1},n+=`|${n}${/^\s*\]\]/u.test(l)?"":"]]"}`),t.dispatch({...sO(a,n,i,r),annotations:io.of(e),selection:s})},E2=(Kv=class extends X2{constructor(e){super(e);xe(this,Bi);const{urlProtocols:i,nsid:r,functionSynonyms:n,doubleUnderscore:s}=e;this.nsRegex=new RegExp(String.raw`^(${Object.keys(r).filter(Boolean).join("|").replace(/_/gu," ")})\s*:\s*`,"iu"),this.functionSynonyms=n.flatMap((o,a)=>Object.keys(o).map(l=>({type:a?"constant":"function",label:l}))),this.doubleUnderscore=s.flatMap(Object.keys).filter(cc).map(o=>({type:"constant",label:o})),this.extTags=this.tags.map(o=>({type:"type",label:o})),this.htmlTags=jm.filter(o=>!this.tags.includes(o)).map(o=>({type:"type",label:o})),this.protocols=i.split("|").map(o=>({type:"namespace",label:o.replace(/\\\//gu,"/")})),this.imgKeys=this.img.map(o=>o.endsWith("$1")?{type:"property",label:o.slice(0,-2),detail:"$1"}:{type:"keyword",label:o}),this.htmlAttrs=[...[...i2].map(o=>({type:"property",label:o})),{type:"variable",label:"data-",detail:"*"},{type:"namespace",label:"xmlns:",detail:"*"}],this.elementAttrs=new Map(Object.entries(r2).map(([o,a])=>[o,[...a].map(l=>({type:"property",label:l}))])),this.extAttrs=new Map(Object.entries(n2).map(([o,a])=>[o,[...a].map(l=>({type:"property",label:l}))]))}getTagStyles(){return Object.keys(this.tokenTable).map(e=>({tag:this.tokenTable[e],class:`cm-${e}`}))}mediawiki(e){const i=super.mediawiki(e);return i.languageData={closeBrackets:{brackets:["(","[","{",'"'],before:")]}>"},autocomplete:this.completionSource},i}get completionSource(){return async e=>{var S,w,X,P,D,_;const{state:i,pos:r,explicit:n}=e,s=I(i).resolve(r,-1),{name:o,from:a,to:l}=s,h=new Set(o.split("_")),c=Se(h,"parserFunctionName"),f=i.sliceDoc(a,r).trimStart(),u=r-f.length;let{prevSibling:d}=s;if(n||c&&f.includes("#")||eg){const q=eg?null:{validFor:/^[^|{}<>[\]#]*$/u};if(c||Se(h,"templateName")){const L=f.includes(":")?[]:[...this.functionSynonyms],G=(S=await Qe(this,Bi,Hc).call(this,f,10))!=null?S:{offset:0,options:[]};return L.push(...G.options),L.length===0?null:{from:u+G.offset,options:L,...q}}else if(n&&Se(h,"templateBracket")&&e.matchBefore(/\{\{$/u))return{from:r,options:this.functionSynonyms,...q};const W=Se(h,"pageName")&&Se(h,"parserFunction")||0;if(W&&f.trim()||Se(h,"linkPageName")){const L=W2(o);let G="",ie=0;W?G=this.autocompleteNamespaces[[...h].find(ce=>ce.startsWith("mw-function-")).slice(12)]:Se(h,"mw-tag-gallery")&&!L&&(ie=6);const he=await Qe(this,Bi,Hc).call(this,G+f,ie);if(he)!W&&L?he.options=he.options.map(ce=>({...ce,apply:M2})):G==="Module:"&&(he.options=he.options.filter(({label:ce})=>!ce.endsWith("/doc")));else return null;return{from:u+he.offset-(W&&G.length),options:he.options,...q}}const M=Se(h,"templateArgumentName"),z=d==null?void 0:d.name.includes($.templateDelimiter),N=Se(h,"templateDelimiter")||Se(h,"templateBracket")&&z;if(this.tags.includes("templatedata")&&(N||M&&!f.includes("=")||Se(h,"template")&&z)){let L=-1,G="";for(;d;){const{name:ie,from:he,to:ce}=d;if(ie.includes($.templateBracket)){const[De,ft]=rc(i,d);if(L+=De,L>=0)break;L+=ft}else if(L===-1&&ie.includes($.templateName))G=i.sliceDoc(he,ce)+G;else if(G&&!ie.includes($.comment)){d=null;break}({prevSibling:d}=d)}if(d&&G){const ie=M&&i.sliceDoc(r,l).trim()==="="?"":"=",he=await Qe(this,Bi,qy).call(this,N?"":f,G,ie);if(he&&he.options.length>0)return{from:N?r:u+he.offset,options:he.options,validFor:/^[^|{}=]*$/u}}}}const p=Se(h,["htmlTagName","extTagName"]),O=n&&e.matchBefore(/\s$/u),g=/^[a-z]*$/iu;if(p&&O||Se(h,["htmlTagAttribute","extTagAttribute","tableDefinition"])){const q=p?f.trim():/mw-(?:ext|html)-([a-z]+)/u.exec(o)[1],W=O||e.matchBefore(Se(h,"tableDefinition")?/[\s|-][a-z]+$/iu:/\s[a-z]+$/iu);return W&&(W.from<u||/^\s/u.test(W.text))?{from:W.from+1,options:[...q==="meta"||q==="link"||q in this.config.tags&&!this.elementAttrs.has(q)?[]:this.htmlAttrs,...(w=this.elementAttrs.get(q))!=null?w:[],...(X=this.extAttrs.get(q))!=null?X:[]],validFor:g}:null}else if(n&&Se(h,["tableTd","tableTh","tableCaption"])){const[,q]=/mw-table-([a-z]+)/u.exec(o),W=e.matchBefore(/[\s|!+][a-z]*$/iu);if(W&&(W.from<u||/^\s/u.test(W.text)))return{from:W.from+1,options:[...this.htmlAttrs,...(P=this.elementAttrs.get(q))!=null?P:[]],validFor:g}}else if(Se(h,["comment","templateVariableName","templateName","linkPageName","linkToSection","extLink"]))return null;let b=e.matchBefore(/__(?:(?!__)[\p{L}\p{N}_])*$/u);if(b)return{from:b.from,options:this.doubleUnderscore,validFor:/^[\p{L}\p{N}]*$/u};b=e.matchBefore(/<\/?[a-z\d]*$/iu);const y=[...h].filter(q=>q.startsWith("mw-tag-")).map(q=>q.slice(7));if(b&&(n||b.to-b.from>1)){const q=/^[a-z\d]*$/iu;if(b.text[1]==="/"){const W=e.matchBefore(/<[a-z\d]+(?:\s[^<>]*)?>(?:(?!<\/?[a-z]).)*<\/[a-z\d]*$/iu),M=(_=/^<([a-z\d]+)/iu.exec((D=W==null?void 0:W.text)!=null?D:""))==null?void 0:_[1].toLowerCase(),z=y[y.length-1],N=/^\s*>/u.test(i.sliceDoc(r)),L=[...this.htmlTags.filter(({label:ie})=>!this.voidHtmlTags.has(ie)),...z?[{type:"type",label:z,boost:50}]:[]],G=this.permittedHtmlTags.has(M)&&L.findIndex(({label:ie})=>ie===M);return G!==!1&&G!==-1&&L.splice(G,1,{type:"type",label:M,boost:99}),{from:b.from+2,options:N?L:L.map(ie=>({...ie,apply:`${ie.label}>`})),validFor:q}}return{from:b.from+1,options:[...this.htmlTags,...this.extTags.filter(({label:W})=>!y.includes(W))],validFor:q}}const v=n&&Se(h,"fileDelimiter");if(v||Se(h,"fileText")&&(d!=null&&d.name.includes($.fileDelimiter))&&!f.includes("[")){const q=i.sliceDoc(r,r+1)==="=";return{from:v?r:d.to,options:q?this.imgKeys.map(W=>({...W,apply:W.label.replace(/=$/u,"")})):this.imgKeys,validFor:/^[^|{}<>[\]$]*$/u}}else if(!Se(h,["linkText","extLinkText"])&&(b=e.matchBefore(/(?:^|[^[])\[[a-z:/]*$/iu),b&&(n||!b.text.endsWith("["))))return{from:b.from+(b.text[1]==="["?2:1),options:this.protocols,validFor:/^[a-z:/]*$/iu};return null}}},Bi=new WeakSet,Hc=async function(e,i){const{config:{linkSuggest:r,nsid:n},nsRegex:s}=this;if(typeof r!="function"||/[|{}<>[\]#]/u.test(e))return;let o=!1,a=e,l=0;if(a.startsWith("/"))i=0,o=!0;else{if(a=a.replace(/_/gu," "),[{length:l}]=/^\s*/u.exec(a),a=a.slice(l),a.startsWith(":")){const[{length:u}]=/^:\s*/u.exec(a);l+=u,a=a.slice(u),i=0}if(!a)return;const f=s.exec(a);if(f){const[{length:u},d]=f;i=n[d.replace(/ /gu,"_").toLowerCase()]||1,l+=u,a=`${i===-2?"File":d}:${a.slice(u)}`}}const h=e.slice(l).includes("_");return{offset:l,options:(await r(a,o,i)).map(([c])=>({type:"text",label:h?c.replace(/ /gu,"_"):c}))}},qy=async function(e,i,r){const{config:{paramSuggest:n}}=this,s=await(n==null?void 0:n(i));return s!=null&&s.length?{offset:/^\s*/u.exec(e)[0].length,options:s.map(([o,a])=>({type:"variable",label:o+r,detail:a}))}:void 0},Kv),H=(t,e="")=>typeof e=="string"?t.map(i=>`.cm-mw-${e}${i}`).join():e.map(i=>H(t,i)).join(),gc=(t,e)=>e?`${t}${e===1?"":e}-`:"",ge=(t,e,i,r,n)=>({[t.map(([s,o,a])=>`.cm-mw-${gc("template",s)}${gc("exttag",o)}${gc("link",a)}ground`).join()]:{backgroundColor:`rgb(${e},${i},${r},${n})`}}),q2=x.theme({[H(["","~*"],"section--1")]:{fontSize:"1.8em",lineHeight:"1.2em"},[H(["","~*"],"section--2")]:{fontSize:"1.5em",lineHeight:"1.2em"},[H(["3~*","4~*","5~*","6~*"],"section--")]:{fontWeight:"bold"},[`${H(["section-header","template","parserfunction","file-delimiter","magic-link"])},${H(["pagename","bracket","delimiter"],"link-")},${H(["extlink"],["","free-"])},${H(["bracket","attribute"],["exttag-","htmltag-"])},${H(["delimiter2","definition"],"table-")}`]:{fontWeight:"normal"},[`${H(["redirect","list","free-extlink-protocol","strong"])},${H(["protocol","bracket"],"extlink-")},${H(["tag-name"],["ext","html"])},${H(["bracket","delimiter","th","caption"],"table-")},${H(["bracket","delimiter"],"convert-")}`]:{fontWeight:"bold"},[`${H(["pagename","link-tosection","magic-link"])},${H(["extlink","extlink-protocol"],["","free-"])}`]:{textDecoration:"underline"},".cm-mw-em":{fontStyle:"italic"},[H(["section-header","redirect","list","apostrophes"])]:{color:"var(--cm-hr)"},".cm-mw-error":{color:"var(--cm-error)"},".cm-mw-skipformatting":{backgroundColor:"var(--cm-sp)"},[H(["double-underscore","signature","hr"])]:{color:"var(--cm-hr)",fontWeight:"bold",backgroundColor:"var(--cm-hr-bg)"},[H(["comment","ignored"])]:{color:"var(--cm-comment)",fontWeight:"normal"},[H(["name","delimiter","bracket"],"template-")]:{color:"var(--cm-tpl)",fontWeight:"bold"},".cm-mw-template-argument-name":{color:"var(--cm-arg)",fontWeight:"normal"},".cm-mw-templatevariable":{color:"var(--cm-var)",fontWeight:"normal"},[H(["name","bracket","delimiter"],"templatevariable-")]:{color:"var(--cm-var-name)",fontWeight:"bold"},[H(["name","bracket","delimiter"],"parserfunction-")]:{color:"var(--cm-func)",fontWeight:"bold"},[`${H(["pagename","bracket","delimiter"],"link-")},${H(["file-delimiter","magic-link"])},${H(["","-protocol","-bracket"],"extlink")},${H(["","-protocol"],"free-extlink")}`]:{color:"var(--cm-link)"},[H(["image-parameter","link-tosection"])]:{color:"var(--cm-sect)",fontWeight:"normal"},[H(["name","bracket","attribute"],["exttag-","htmltag-"])]:{color:"var(--cm-tag)"},[H(["tag-attribute-value"],["ext","html"])]:{color:"var(--cm-attr)",fontWeight:"normal"},[H(["bracket","delimiter","delimiter2","definition"],"table-")]:{color:"var(--cm-table)"},".cm-mw-table-definition-value":{color:"var(--cm-table-attr)",fontWeight:"normal"},[H(["bracket","delimiter","flag","lang"],"convert-")]:{color:"var(--cm-convert)"},".cm-mw-entity":{color:"var(--cm-entity)"},".cm-mw-exttag":{backgroundColor:"rgb(119,0,170,.04)"},...ge([[1]],170,17,17,.04),...ge([[2]],170,17,17,.08),...ge([[3]],170,17,17,.12),...ge([[1,1],[,1]],119,0,170,.04),...ge([[1,2],[,2]],119,0,170,.08),...ge([[1,3],[,3]],119,0,170,.12),...ge([[1,,1],[,1,1],[,,1]],34,17,153,.04),...ge([[1,1,1],[,2,1]],77,9,162,.08),...ge([[1,2,1],[,3,1]],91,6,164,.12),...ge([[1,3,1]],98,4,166,.16),...ge([[2,1]],145,9,94,.08),...ge([[2,2]],136,6,119,.12),...ge([[2,3]],132,4,132,.16),...ge([[2,,1]],102,17,85,.08),...ge([[2,1,1]],108,11,113,.12),...ge([[2,2,1]],111,9,128,.16),...ge([[2,3,1]],112,7,136,.2),...ge([[3,1]],153,11,68,.12),...ge([[3,2]],145,9,94,.16),...ge([[3,3]],139,7,109,.2),...ge([[3,,1]],125,17,62,.12),...ge([[3,1,1]],123,13,89,.16),...ge([[3,2,1]],122,10,105,.2),...ge([[3,3,1]],122,9,116,.24),[H(["pre","nowiki"],"tag-")]:{backgroundColor:"rgb(0,0,0,.04)"},".cm-mw-tag-ref":{backgroundColor:"var(--cm-ref)"},[`${Km}, &[dir="rtl"] .cm-mw-template-name`]:{unicodeBidi:"isolate"},[Jm]:{direction:"ltr",display:"inline-block"}}),bb=t=>{const e=new E2(t),i=Np.define(e.mediawiki()),r=jl(eo.define(e.getTagStyles()));return new Et(i,[r,q2])},D2=tg?"metaKey":"ctrlKey",vb=tg?"Meta":"Control",Y2=["extLinkProtocol","extLink","freeExtLinkProtocol","freeExtLink","magicLink","pageName"],V2=["extlink-protocol","extlink","free-extlink-protocol","free-extlink","magic-link"],bc=".cm-mw-pagename",_2=["template-name","link-pagename",`parserfunction${bc}`,`exttag-attribute-value${bc}`,`file-text${bc}`],vc=t=>{for(const e of document.querySelectorAll(".cm-content"))t?e.style.setProperty("--codemirror-cursor","pointer"):e.style.removeProperty("--codemirror-cursor")};(Jv=globalThis.document)==null||Jv.addEventListener("keydown",t=>{t.key===vb&&vc(!0)}),(ey=globalThis.document)==null||ey.addEventListener("keyup",t=>{t.key===vb&&vc()}),(ty=globalThis.document)==null||ty.addEventListener("visibilitychange",()=>{document.hidden&&vc()});var yb=t=>t.startsWith("//")?location.protocol+t:t,B2=(t,e,i)=>{if(!t[D2]||!(t.target instanceof Element&&getComputedStyle(t.target).textDecorationLine==="underline"))return;const r=e.posAtCoords(t);if(!r)return;const{state:n}=e,s=fi(n,r);if(!s)return;let o=s.resolve(r,-1);o.name.includes($.linkToSection)?o=o.prevSibling:Se(new Set(o.name.split("_")),Y2)||(o=s.resolve(r,1));const{name:a,from:l,to:h}=o;if(a.includes($.pageName)&&typeof(i==null?void 0:i.titleParser)=="function")return i.titleParser(n,o);if(a.includes("-extlink-protocol"))return yb(n.sliceDoc(l,o.nextSibling.to));if(/-extlink(?:_|$)/u.test(a))return yb(n.sliceDoc(o.prevSibling.from,h));if(a.includes($.magicLink)){const c=n.sliceDoc(l,h);if(c.startsWith("RFC"))return`https://datatracker.ietf.org/doc/html/rfc${c.slice(3).trim()}`;if(c.startsWith("PMID"))return`https://pubmed.ncbi.nlm.nih.gov/${c.slice(4).trim()}`;if(typeof(i==null?void 0:i.isbnParser)=="function")return i.isbnParser(c)}},L2=({langConfig:t})=>[x.domEventHandlers({mousedown(e,i){if(e.button!==0)return;const r=B2(e,i,t);if(r)return open(r,"_blank","noopener noreferrer"),!0}}),x.theme({[[...V2,...t!=null&&t.titleParser?_2:[]].map(e=>`.cm-mw-${e}`).join()]:{cursor:"var(--codemirror-cursor)"}})],j2=new WeakMap,Sb=".cm-tooltip-ref",kb=".cm-tooltip-no-def",wb=(t,{from:e,to:i})=>t.sliceDoc(e,i).trim(),z2=t=>[cl(async(e,i,r)=>{var o,a;const{state:n}=e,s=(o=fi(n,i))==null?void 0:o.resolve(i,r);if(s&&/-exttag-(?!bracket)/u.test(s.name)){const l=Qn(n,s);if(!l)return null;const{name:h,selfClosing:c,first:f,last:u,to:d}=l;if(h==="ref"&&c){let p=u,O=null;for(;p&&p.from>f.to;){const g=wb(n,p);if(p.name.split("_").includes($.extTagAttribute)&&/(?:^|\s)name(?:$|[\s=])/iu.test(g)){/(?:^|\s)name\s*=/iu.test(g)&&({nextSibling:O}=p);break}({prevSibling:p}=p)}if(O!=null&&O.name.includes($.extTagAttributeValue)){let g=wb(n,O);const b=g.charAt(0);if((b==='"'||b==="'")&&(g=g.slice(1,g.slice(-1)===b?-1:void 0).trim()),g){const{doc:y}=n,v=await((a=Ut(e,!1,t.getWikiConfig))==null?void 0:a.provideDefinition(y.toString(),Mn(y,f.to)));return{pos:i,end:d,above:!0,create(){const S=Y("div",{class:Sb.slice(1)});if(S.style.font=getComputedStyle(e.contentDOM).font,v){const{range:{start:w,end:X}}=v[0],P=Oi(y,w),D=Oi(y,X),_=n.sliceDoc(P,D);let q="";Nw(_,n.facet(nt).parser.parse(_),{style(W){return Sx(n,W)}},(W,M)=>{const z=Wn(W);q+=M?`<span class="${M}">${z}</span>`:z},()=>{q+="<br>"}),S.innerHTML=q,S.addEventListener("click",()=>{e.dispatch({selection:{anchor:P,head:D},scrollIntoView:!0}),e.focus()})}else S.textContent=n.phrase("No definition found"),S.classList.add(kb.slice(1));return{dom:S}}}}}}}return null}),x.updateListener.of(({view:e,docChanged:i})=>{if(i){const r=j2.get(e);r&&(r.docChanged=!0)}}),x.theme({[Sb]:{padding:"2px 5px",width:"max-content",maxWidth:"60vw",cursor:"pointer",whiteSpace:"pre-wrap"},[kb]:{color:"var(--cm-comment)"}})],yc=B.define(),Sc=ve.define({create(){},update(t,{state:{doc:e,selection:{main:{head:i}}},effects:r}){const n=e.toString();for(const s of r)if(s.is(yc)){const{value:o}=s;if(i===o.cursor&&n===o.text)return o}return t}}),N2=t=>[Sc,x.updateListener.of(({view:e,state:i,docChanged:r,selectionSet:n})=>{var s,o;if(r||n&&((o=(s=i.field(Sc))==null?void 0:s.signatureHelp)!=null&&o.signatures.length)){const{doc:a,selection:{main:l}}=i,{head:h}=l,c=a.toString();if(!l.empty){e.dispatch({effects:yc.of({text:c,cursor:h})});return}(async()=>{var f;e.dispatch({effects:yc.of({text:c,cursor:h,signatureHelp:await((f=Ut(e,!1,t.getWikiConfig))==null?void 0:f.provideSignatureHelp(c,Mn(a,h)))})})})()}}),ir.from(Sc,e=>{if(!e)return null;const{cursor:i,signatureHelp:r}=e;if(!r||r.signatures.length===0)return null;const{signatures:n,activeParameter:s}=r;return{pos:i,above:!0,create(o){return P0(o,n.map(({label:a,parameters:l,activeParameter:h=s})=>{const c=Wn(a);if(h<0||h>=l.length)return c;const f=c.indexOf(":"),u=c.slice(f+1,-2).split("|");return u[h]=`<b>${u[h]}</b>`,`${c.slice(0,f)}:${u.join("|")}}}`}).join("<br>"))}}})],I2={onlyinclude:"mediawiki",includeonly:"mediawiki",noinclude:"mediawiki",translate:"mediawiki",tvar:"mediawiki",pre:"text/pre",nowiki:"text/nowiki",indicator:"mediawiki",poem:"mediawiki",ref:"mediawiki",references:"text/references",gallery:"text/gallery",poll:"mediawiki",tabs:"mediawiki",tab:"mediawiki",choose:"text/choose",option:"mediawiki",combobox:"text/combobox",combooption:"mediawiki",inputbox:"text/inputbox"},G2=({variable:t,parserFunction:[e,i,...r],protocol:n,nsid:s,functionHook:o,variants:a,redirection:l,ext:h,doubleUnderscore:[c,f,u,d],img:p},O)=>({tags:Object.fromEntries(h.map(g=>[g,!0])),tagModes:O,doubleUnderscore:[Object.fromEntries((u&&c.length===0?Object.keys(u):c).map(g=>[cc(g)?`__${g}__`:g,!0])),Object.fromEntries((d&&f.length===0?Object.keys(d):f).map(g=>[cc(g)?`__${g}__`:g,!0]))],functionHooks:o,variableIDs:t,functionSynonyms:[{...e,...Object.fromEntries(r.flat().map(g=>[g,g]))},Array.isArray(i)?Object.fromEntries(i.map(g=>[g,g.toLowerCase()])):{...i}],urlProtocols:`${n}|//`,nsid:s,img:Object.fromEntries(Object.entries(p).map(([g,b])=>[g,`img_${b}`])),variants:a,redirection:l}),kc=".cm-panel-status",qn=".cm-status-worker",xb=".cm-status-error",Qb=".cm-status-warning",Mo=".cm-status-fix-enabled",Eo=".cm-status-fix-disabled",qo="cm-status-worker-enabled",$b="cm-status-line";function wc(t,e,i){const r=Y("div",{class:`cm-status-${e}`}),n=Y("div");return e==="fix"?(n.className=Eo.slice(1),r.title="Fix all",r.append(n),i&&r.addEventListener("click",({clientX:s,clientY:o})=>{if(n.className===Mo.slice(1)){const{bottom:a,left:l}=t.dom.getBoundingClientRect();i.style.bottom=`${a-o+5}px`,i.style.left=`${s-20-l}px`,i.style.display="block",i.focus()}})):(n.className=`cm-lint-marker-${e}`,r.append(n,Y("div","0")),r.addEventListener("click",()=>{var s;(s=r.parentElement)!=null&&s.classList.contains(qo)&&(t0(t),t.focus())})),r}var Pb=(t,e,i)=>{i.lastChild.textContent=String(t.filter(({severity:r})=>r===e).length)},Tb=(t,e)=>{t.toggle(Mo.slice(1),e),t.toggle(Eo.slice(1),!e)},Cb=(t,e)=>t.filter(({from:i,to:r})=>i<=e.to&&r>=e.from),Zb=(t,e,i,r)=>{var s;const n=Cb(e,i);if(n.length===0)r.textContent="";else{const o=(s=n.find(({from:l,to:h})=>l<=i.head&&h>=i.head))!=null?s:n[0],a=t.view;r.textContent=o.message,o.actions&&r.append(...o.actions.map(({name:l,apply:h})=>{const c=Y("button",{type:"button",class:Ah.slice(1)},l);return c.addEventListener("click",f=>{f.preventDefault(),h(a,o.from,o.to)}),c}))}},Ab=(t,e,i,r,n,s,o)=>{if(s){const a=Jh.filter(({name:f,isActionable:u})=>t.hasPreference(f)&&u(t)),l=new Set(o&&Cb(e,i).filter(({actions:f})=>f==null?void 0:f.some(({name:u})=>u==="fix"||u!=="Fix: Stylelint"&&u.startsWith("Fix:"))).map(({message:f})=>{var u;return(u=/ \(([^()]+)\)$/u.exec(f))==null?void 0:u[1]}).filter(Boolean));if(a.length===0&&l.size===0){Tb(r,!1);return}Tb(r,!0);const h=a.flatMap(({getItems:f})=>f(t)),c=[...l].map(f=>{const u=Y("div",`Fix all ${f} problems`);return u.dataset.rule=f,u});l.size>0&&c.push(n),s.replaceChildren(...h,...c)}},U2=(t,e)=>[rr.of(i=>{let r=[],n;!i.state.readOnly&&(e||Jh.length>0)&&(n=Y("div",{class:kr.slice(1),tabIndex:-1}),e&&n.addEventListener("click",({target:p})=>{p!==n&&(async()=>{const{doc:O}=i.state,g=await e(O,p.dataset.rule);g!==O.toString()&&i.dispatch({changes:{from:0,to:O.length,insert:g}}),i.focus()})()}),n.addEventListener("focusout",()=>{n.style.display="none"}),i.dom.append(n));const s=wc(i,"error"),o=wc(i,"warning"),a=wc(i,"fix",n),l=Y("div","Fix all auto-fixable problems"),h=Y("div",{class:qn.slice(1)},s,o,a),c=Y("div",{class:xn.slice(1)}),f=Y("div",{class:$b},"0:0"),u=Y("div",{class:`${po.slice(1)} ${kc.slice(1)}`},h,c,f),{classList:d}=a.firstChild;return{dom:u,update({state:{selection:{main:p},doc:O},transactions:g,docChanged:b,selectionSet:y}){for(const v of g)for(const S of v.effects)S.is(Zn)&&(r=S.value,h.classList.toggle(qo,r.length>0),Pb(r,"error",s),Pb(r,"warning",o),Zb(t,r,p,c),Ab(t,r,p,d,l,n,e));if(b||y){Zb(t,r,p,c),Ab(t,r,p,d,l,n,e);const{number:v,from:S}=O.lineAt(p.head);f.textContent=`${v}:${p.head-S}`,p.empty||(f.textContent+=` (${p.to-p.from})`)}}}}),x.theme({[kc]:{lineHeight:1.4},[`${kc}>div`]:{padding:"0 .3em",display:"table-cell"},[qn]:{WebkitUserSelect:"none",userSelect:"none","--fix-icon":`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><path d="M8 19a1 1 0 001 1h2a1 1 0 001-1v-1H8zm9-12a7 7 0 10-12 4.9S7 14 7 15v1a1 1 0 001 1h4a1 1 0 001-1v-1c0-1 2-3.1 2-3.1A7 7 0 0017 7"/></svg>')`},[`${qn}>*`]:{display:"table-cell",whiteSpace:"nowrap"},[`${xb},${Qb}`]:{paddingRight:"8px"},[`.${qo} ${xb},.${qo} ${Qb}`]:{cursor:"pointer"},[`${qn}>*>div`]:{display:"inline-block",verticalAlign:"middle"},[`${qn}>*>div:first-child`]:{marginRight:"4px",width:"1em",height:"1em"},[`${Eo},${Mo}`]:{WebkitMaskImage:"var(--fix-icon)",maskImage:"var(--fix-icon)",WebkitMaskSize:"100%",maskSize:"100%",WebkitMaskRepeat:"no-repeat",maskRepeat:"no-repeat",WebkitMaskPosition:"center",maskPosition:"center"},[Eo]:{backgroundColor:"#dadde3"},[Mo]:{backgroundColor:"#ffce31",cursor:"pointer"},[kr]:{display:"none",position:"absolute",zIndex:301,border:"1px solid #ddd",borderRadius:"2px",outline:"none",whiteSpace:"nowrap"},[`${kr}>div`]:{padding:"1px 5px",cursor:"pointer"},[xn]:{borderStyle:"solid",borderWidth:"0 1px",width:"100%"},[`${xn} ${Ah}`]:{paddingTop:0,paddingBottom:0},[`.${$b}`]:{whiteSpace:"nowrap"},[Um]:{cursor:"pointer"}})],xc=t=>Gt.data.of({autocomplete(e){const{state:i,pos:r}=e,n=I(i).resolveInner(r,-1),s=im(e);if(s)if(n.name==="ValueName"){const o=[{label:"revert",type:"keyword"},...s.options];let{prevSibling:a}=n;for(;a&&a.name!=="PropertyName";)({prevSibling:a}=a);if(a)for(let l=0;l<o.length;l++){const h=o[l];CSS.supports(i.sliceDoc(a.from,n.from)+h.label)&&o.splice(l,1,{...h,boost:50})}s.options=o}else t==="sanitized-css"&&(s.options=s.options.filter(({type:o,label:a})=>o!=="property"||!a.startsWith("-")||a.endsWith("-user-select")));return s}}),F2=t=>new Et(Gt,xc(t)),Qc=_e.data.of({autocomplete:_P(globalThis)}),H2=()=>[fo(),Qc],K2=t=>{const{language:e,support:i}=bb(t),r=new Et(di.configure({wrap:uh([{tag:"script",parser:_e.parser},{tag:"style",parser:Gt.parser},{tag:"noinclude",parser:e.parser}],[{name:"style",parser:Gt.parser.configure({top:"Styles"})}])}),[di.data.of({autocomplete:wm({extraTags:{noinclude:{globalAttrs:!1}}})}),fo().support,Qc,xc(),i]);return Object.assign(r,{nestedMWLanguage:e}),r};function J2(t){return new RegExp("^(?:"+t.join("|")+")","i")}function Do(t){return new RegExp("^(?:"+t.join("|")+")$","i")}var eA=Do(["_G","_VERSION","assert","collectgarbage","dofile","error","getfenv","getmetatable","ipairs","load","loadfile","loadstring","module","next","pairs","pcall","print","rawequal","rawget","rawset","require","select","setfenv","setmetatable","tonumber","tostring","type","unpack","xpcall","coroutine.create","coroutine.resume","coroutine.running","coroutine.status","coroutine.wrap","coroutine.yield","debug.debug","debug.getfenv","debug.gethook","debug.getinfo","debug.getlocal","debug.getmetatable","debug.getregistry","debug.getupvalue","debug.setfenv","debug.sethook","debug.setlocal","debug.setmetatable","debug.setupvalue","debug.traceback","close","flush","lines","read","seek","setvbuf","write","io.close","io.flush","io.input","io.lines","io.open","io.output","io.popen","io.read","io.stderr","io.stdin","io.stdout","io.tmpfile","io.type","io.write","math.abs","math.acos","math.asin","math.atan","math.atan2","math.ceil","math.cos","math.cosh","math.deg","math.exp","math.floor","math.fmod","math.frexp","math.huge","math.ldexp","math.log","math.log10","math.max","math.min","math.modf","math.pi","math.pow","math.rad","math.random","math.randomseed","math.sin","math.sinh","math.sqrt","math.tan","math.tanh","os.clock","os.date","os.difftime","os.execute","os.exit","os.getenv","os.remove","os.rename","os.setlocale","os.time","os.tmpname","package.cpath","package.loaded","package.loaders","package.loadlib","package.path","package.preload","package.seeall","string.byte","string.char","string.dump","string.find","string.format","string.gmatch","string.gsub","string.len","string.lower","string.match","string.rep","string.reverse","string.sub","string.upper","table.concat","table.insert","table.maxn","table.remove","table.sort"]),tA=Do(["and","break","elseif","false","nil","not","or","return","true","function","end","if","then","else","do","while","repeat","until","for","in","local"]),iA=Do(["function","if","repeat","do","\\(","{"]),rA=Do(["end","until","\\)","}"]),nA=J2(["end","until","\\)","}","else","elseif"]);function Rb(t){for(var e=0;t.eat("=");)++e;return t.eat("["),e}function $c(t,e){var i=t.next();return i=="-"&&t.eat("-")?t.eat("[")&&t.eat("[")?(e.cur=Xb(Rb(t),"comment"))(t,e):(t.skipToEnd(),"comment"):i=='"'||i=="'"?(e.cur=sA(i))(t,e):i=="["&&/[\[=]/.test(t.peek())?(e.cur=Xb(Rb(t),"string"))(t,e):/\d/.test(i)?(t.eatWhile(/[\w.%]/),"number"):/[\w_]/.test(i)?(t.eatWhile(/[\w\\\-_.]/),"variable"):null}function Xb(t,e){return function(i,r){for(var n=null,s;(s=i.next())!=null;)if(n==null)s=="]"&&(n=0);else if(s=="=")++n;else if(s=="]"&&n==t){r.cur=$c;break}else n=null;return e}}function sA(t){return function(e,i){for(var r=!1,n;(n=e.next())!=null&&!(n==t&&!r);)r=!r&&n=="\\";return r||(i.cur=$c),"string"}}var Wb={name:"lua",startState:function(){return{basecol:0,indentDepth:0,cur:$c}},token:function(t,e){if(t.eatSpace())return null;var i=e.cur(t,e),r=t.current();return i=="variable"&&(tA.test(r)?i="keyword":eA.test(r)&&(i="builtin")),i!="comment"&&i!="string"&&(iA.test(r)?++e.indentDepth:rA.test(r)&&--e.indentDepth),i},indent:function(t,e,i){var r=nA.test(e);return t.basecol+i.unit*(t.indentDepth-(r?1:0))},languageData:{indentOnInput:/^\s*(?:end|until|else|\)|\})$/,commentTokens:{line:"--",block:{open:"--[[",close:"]]--"}}}},oA={1:"constant",2:"function",3:"interface",4:"namespace"},Mb={debug:{traceback:2},math:{abs:2,acos:2,asin:2,atan:2,atan2:2,ceil:2,cos:2,cosh:2,deg:2,exp:2,floor:2,fmod:2,frexp:2,huge:1,ldexp:2,log:2,log10:2,max:2,min:2,modf:2,pi:1,pow:2,rad:2,random:2,randomseed:2,sin:2,sinh:2,sqrt:2,tan:2,tanh:2},os:{clock:2,date:2,difftime:2,time:2},package:{loaded:3,loaders:3,preload:3,seeall:2},string:{byte:2,char:2,find:2,format:2,gmatch:2,gsub:2,len:2,lower:2,match:2,rep:2,reverse:2,sub:2,ulower:2,upper:2,uupper:2},table:{concat:2,insert:2,maxn:2,remove:2,sort:2},mw:{addWarning:2,allToString:2,clone:2,getCurrentFrame:2,incrementExpensiveFunctionCount:2,isSubsting:2,loadData:2,loadJsonData:2,dumpObject:2,log:2,logObject:2,hash:{hashValue:2,listAlgorithms:2},html:{create:2},language:{fetchLanguageName:2,fetchLanguageNames:2,getContentLanguage:2,getFallbacksFor:2,isKnownLanguageTag:2,isSupportedLanguage:2,isValidBuiltInCode:2,isValidCode:2,new:2,FALLBACK_MESSAGES:1,FALLBACK_STRICT:1},message:{new:2,newFallbackSequence:2,newRawMessage:2,rawParam:2,numParam:2,getDefaultLanguage:2},site:{currentVersion:1,scriptPath:1,server:1,siteName:1,stylePath:1,namespaces:3,contentNamespaces:3,subjectNamespaces:3,talkNamespaces:3,stats:{pages:1,articles:1,files:1,edits:1,users:1,activeUsers:1,admins:1,pagesInCategory:2,pagesInNamespace:2,usersInGroup:2,interwikiMap:2}},svg:{new:2},text:{decode:2,encode:2,jsonDecode:2,jsonEncode:2,killMarkers:2,listToText:2,nowiki:2,split:2,gsplit:2,tag:2,trim:2,truncate:2,unstripNoWiki:2,unstrip:2,JSON_PRESERVE_KEYS:1,JSON_TRY_FIXING:1,JSON_PRETTY:1},title:{equals:2,compare:2,getCurrentTitle:2,new:2,newBatch:2,makeTitle:2},uri:{encode:2,decode:2,anchorEncode:2,buildQueryString:2,parseQueryString:2,canonicalUrl:2,fullUrl:2,localUrl:2,new:2,validate:2},ustring:{maxPatternLength:1,maxStringLength:1,byte:2,byteoffset:2,char:2,codepoint:2,find:2,format:2,gcodepoint:2,gmatch:2,gsub:2,isutf8:2,len:2,lower:2,match:2,rep:2,sub:2,toNFC:2,toNFD:2,toNFKC:2,toNFKD:2,upper:2},ext:4}},Eb=["false","nil","true"],Pc=Eb.map(t=>({label:t,type:"constant"})),Dn=["_G",...Object.keys(Mb)].map(t=>({label:t,type:"namespace"})),Yo=[{label:"_VERSION",type:"constant"},...["assert","error","getfenv","getmetatable","ipairs","next","pairs","pcall","rawequal","rawget","rawset","select","setmetatable","tonumber","tostring","type","unpack","xpcall","require"].map(t=>({label:t,type:"function"}))],qb=["and","or","in"].map(t=>({label:t,type:"keyword"})),Tc=[...["not","function"].map(t=>({label:t,type:"keyword"})),ye("function ${name}(${})\n ${}\nend",{label:"function",detail:"definition",type:"keyword"})],Vo=["break","elseif","return","end","then","else","do","until","goto"].map(t=>({label:t,type:"keyword"})),aA=[...["if","while","repeat","for","local"].map(t=>({label:t,type:"keyword"})),ye("if ${condition} then\n ${}\nend",{label:"if",detail:"block",type:"keyword"}),ye(`if \${condition} then
|
|
35
|
+
`).length+M+(D-1&&1);W.data=[{range:{start:N0(s,Ao(_,P.range[0]-z)),end:N0(s,Ao(_,P.range[1]-z))},newText:P.text,title:"Fix: Stylelint",fix:!0}]}return W})]};return"resolveCodeAction"in i&&(n.fixer=async(s,o)=>(await i.resolveCodeAction(o)).edit.changes[""][0].newText),n},U0=async(t="npm/@bhsd/eslint-browserify")=>{var s;await br(t,"eslint");const e=new eslint.Linter,i={env:{browser:!0,es2024:!0},parserOptions:{ecmaVersion:15,sourceType:"module"}},r={};for(const[o,{meta:a}]of e.getRules())(s=a==null?void 0:a.docs)!=null&&s.recommended&&(r[o]=2);const n=(o,a)=>{const l={...i,...a};return(!("rules"in l)||l.extends==="eslint:recommended"||Array.isArray(l.extends)&&l.extends.includes("eslint:recommended"))&&(l.rules={...r,...l.rules}),delete l.extends,n.config=l,e.verify(o,l)};return n.fixer=(o,a)=>{var l,h;return e.verifyAndFix(o,a?{...n.config,rules:{[a]:(h=(l=n.config.rules)==null?void 0:l[a])!=null?h:2}}:n.config).output},n},ac=async(t="npm/@bhsd/stylelint-browserify")=>{await br(t,"stylelint");const e=async(i,r)=>{const n=await j0(stylelint,i,r);return e.config=r&&!I0(r)?{rules:r}:r,n};return e.fixer=(i,r)=>{var n,s;if(!e.config)throw new Error("Fixer unavailable!");return j0(stylelint,i,r?{extends:[],rules:{[r]:(s=(n=e.config.rules)==null?void 0:n[r])!=null?s:!0}}:e.config,!0)},e},_Z=async(t="npm/luacheck-browserify")=>{await br(t,"luacheck");const e=await luacheck(void 0);return async i=>(await e.queue(i)).filter(({severity:r})=>r)},BZ=()=>t=>{var e,i,r;try{t.trim()&&JSON.parse(t)}catch(n){if(n instanceof SyntaxError){const{message:s}=n,o=(e=/\bline (\d+)/u.exec(s))==null?void 0:e[1],a=(i=/\bcolumn (\d+)/u.exec(s))==null?void 0:i[1],l=(r=/\bposition (\d+)/u.exec(s))==null?void 0:r[1];return[{message:s,severity:"error",line:o,column:a,position:l}]}}return[]},Di=(t,e)=>typeof t=="function"?t(e):t,En=(t,e,i,r=0)=>{if(r===0)return Oi(t,{line:e-1,character:i-1});const n=t.lineAt(r);return Oi(t,{line:n.number+e-2,character:(e===1?r-n.from:0)+i-1})},lc=(t,e,i,r,n,s=0,o=1/0)=>{const a=En(t,e,i,s);return{from:a,to:r===void 0?Math.min(o,a+1):En(t,r,n,s)}},F0=async(t,e,i,r,n=0,s)=>(await t(e,i)).map(({severity:o,code:a,message:l,range:h,from:c,to:f,data:u=[],source:d})=>({source:d,severity:o===2?"warning":"error",message:d==="Stylelint"?l:`${l} (${a})`,actions:u.map(({title:p,range:O,newText:g})=>({name:p,apply(b){b.dispatch({changes:{from:Oi(r,O.start),to:Oi(r,O.end),insert:g}})}})),...c===void 0?lc(r,h.start.line+1,h.start.character+1,h.end.line+1,h.end.character+1,n,s):{from:c+n,to:(f!=null?f:c)+n}})),LZ=async(t,e)=>{const i=await G0(await Di(t),e),r=async({doc:n})=>F0(i,n.toString(),await Di(t,!0),n);return i.fixer&&(r.fixer=(n,s)=>i.fixer("",s)),r},H0=(t,e,i,r,n=0,s)=>t(e,i).map(({ruleId:o,message:a,severity:l,line:h,column:c,endLine:f,endColumn:u,fix:d,suggestions:p=[]})=>{const O={source:"ESLint",message:a+(o?` (${o})`:""),severity:l===1?"warning":"error",...lc(r,h,c,f,u,n,s)};return(d||p.length>0)&&(O.actions=[...d?[{name:"fix",fix:d}]:[],...p.map(g=>({name:"suggestion",fix:g.fix}))].map(({name:g,fix:{range:[b,y],text:v}})=>({name:g,apply(S){S.dispatch({changes:{from:b+n,to:y+n,insert:v}})}}))),O}),jZ=async t=>{const e=await U0(),i=async({doc:r})=>H0(e,r.toString(),await Di(t),r);return i.fixer=(r,n)=>e.fixer(r.toString(),n),i},hc=async(t,e,i,r,n=0,s)=>{let o=i!=null?i:{};return"extends"in o||"rules"in o||(o={rules:o}),(await t(e,o)).map(({text:a,severity:l,line:h,column:c,endLine:f,endColumn:u,fix:d})=>{const p={source:"Stylelint",message:a,severity:l,...lc(r,h,c,f,u,n,s)};return d&&(p.actions=[{name:"fix",apply(O){O.dispatch({changes:{from:d.range[0]+n,to:d.range[1]+n,insert:d.text}})}}]),p})},zZ=async t=>{const e=await ac(),i=async({doc:r})=>hc(e,r.toString(),await Di(t),r);return i.fixer=async(r,n)=>e.fixer(r.toString(),n),i},K0=async t=>{const e=await ac(),i=await U0();return async r=>{var l;const{doc:n}=r,s=(l=await Di(t,!0))!=null?l:{},o=s.js,a=s.css;return[...(await Promise.all(Gt.findRegions(r).map(async({from:h,to:c})=>{var u;const f=(u=fi(r,h))==null?void 0:u.resolve(h,1);return(f==null?void 0:f.name)==="AttributeValue"?(await hc(e,`a {${Im(r.sliceDoc(h,c))}}`,a,n,h-3,c+1)).filter(({from:d,to:p})=>d<=c&&p>=h).map(d=>(d.from=Math.max(d.from,h),d.to=Math.min(d.to,c),d)):f?hc(e,r.sliceDoc(h,c),a,n,h,c):[]}))).flat(),..._e.findRegions(r).flatMap(({from:h,to:c})=>H0(i,r.sliceDoc(h,c),o,n,h,c))]}},NZ=async(t,e,i)=>{const r=await K0(t),n=await G0({include:!1,...await Di(t)},e);return async s=>{var h;const{doc:o}=s,a=(h=await Di(t,!0))!=null?h:{},l=a.wiki;return[...await r(s),...(await Promise.all(i.findRegions(s).map(({from:c,to:f})=>F0(n,s.sliceDoc(c,f),l,o,c,f)))).flat()]}},IZ=()=>{const t=BZ();return({doc:e})=>{const[i]=t(e.toString());if(i){const{message:r,severity:n,line:s,column:o,position:a}=i;let l=0;return a?l=Number(a):s&&o&&(l=En(e,Number(s),Number(o))),[{message:r,severity:n,from:l,to:l}]}return[]}},GZ=async()=>{const t=await _Z();return async({doc:e})=>(await t(e.toString())).map(({line:i,column:r,end_column:n,msg:s,severity:o})=>({source:"Luacheck",message:s,severity:o===1?"warning":"error",from:En(e,i,r),to:En(e,i,n+1)}))},J0=(t,e,i)=>{let r=t;for(;r;){const{firstChild:n,lastChild:s}=r;if(n&&s){const o=i.indexOf(n.name),a=i.indexOf(s.name);if(o!==-1&&a!==-1&&o%2===0&&a%2===1&&n.from<e&&s.to>e)return{start:n,end:s,matched:!0}}({parent:r}=r)}},UZ=(t,e,i)=>{var l;const{brackets:r,maxScanDistance:n}=i,s=new RegExp(`[${[...r].filter((h,c)=>c%2).map(h=>h==="]"?String.raw`\]`:h).join("")}]`,"gu"),o=t.sliceDoc(e,e+n);let a=s.exec(o);for(;a;){const h=qe(t,e+a.index+1,-1,i),c=(l=h==null?void 0:h.end)==null?void 0:l.to;if(c!==void 0&&c<=e)return h;a=s.exec(o)}return null},FZ=t=>{const e=Ax(t),[{facet:i},[r]]=e;return Object.assign(r,{updateF(n,{state:s,docChanged:o,selection:a}){if(!o&&!a)return n;const l=[],h=s.facet(i),{afterCursor:c,brackets:f,renderMatch:u}=h;for(const{empty:d,head:p}of s.selection.ranges){if(!d)continue;const O=I(s),g=qe(s,p,-1,h)||p>0&&qe(s,p-1,1,h)||c&&(qe(s,p,1,h)||p<s.doc.length&&qe(s,p+1,-1,h))||J0(O.resolveInner(p,-1),p,f)||c&&J0(O.resolveInner(p,1),p,f)||UZ(s,p,h);g&&l.push(...u(g,s))}return A.set(l,!0)}}),e},HZ=new Set(["msg","raw","subst","safesubst"]),cc=t=>!/^_{2}.+_{2}$/u.test(t),lt=new Set(["align"]),eb=new Set(["cite"]),tb=new Set(["cite","datetime"]),ib=new Set(["width"]),KZ=new Set(["axis","align","bgcolor","height","width","valign"]),rb=new Set([...KZ,"abbr","headers","scope","rowspan","colspan"]),nb=new Set(["type"]),JZ=new Set(["summary","align","bgcolor","cellpadding","cellspacing","frame","rules","width"]),e2=new Set(["clear"]),t2=new Set(["bgcolor","align","valign"]),fc=new Set(["id","qid","forcemathmode","type","display"]),sb=new Set(["enclose","inline","lang","line","linelinks","style","class","id","dir","copy","highlight","start"]),ob=new Set(["weight"]),ab=new Set(["width","height","zoom","latitude","longitude","align","mapstyle","lang","alt","text"]),Yi=new Set,i2=new Set(["id","class","style","lang","dir","title","tabindex","aria-describedby","aria-flowto","aria-hidden","aria-label","aria-labelledby","aria-level","aria-owns","role","about","property","resource","datatype","typeof","itemid","itemprop","itemref","itemscope","itemtype"]),r2={div:lt,h1:lt,h2:lt,h3:lt,h4:lt,h5:lt,h6:lt,blockquote:eb,q:eb,p:lt,br:e2,pre:ib,ins:tb,del:tb,ul:nb,ol:new Set(["type","start","reversed"]),li:new Set(["type","value"]),table:new Set([...JZ,"border"]),caption:lt,tr:t2,td:rb,th:rb,font:new Set(["size","color","face"]),hr:ib,data:new Set(["value"]),time:new Set(["datetime"]),meta:new Set(["itemprop","content"]),link:new Set(["itemprop","href","title"]),gallery:nb,poem:lt,categorytree:lt,combooption:lt,img:new Set(["alt","src","width","height","loading","srcset"])},n2={gallery:new Set(["mode","showfilename","caption","perrow","widths","heights","showthumbnails"]),poem:new Set(["compact"]),categorytree:new Set(["hideroot","onlyroot","depth","mode","hideprefix","namespaces","showcount","notranslations"]),combooption:new Set(["name","for","inline"]),nowiki:Yi,indicator:new Set(["name"]),langconvert:new Set(["from","to"]),ref:new Set(["group","name","follow","dir","details"]),references:new Set(["group","responsive"]),charinsert:new Set(["label"]),choose:new Set(["uncached","before","after"]),option:ob,choicetemplate:ob,imagemap:Yi,inputbox:Yi,templatestyles:new Set(["src","wrapper"]),dynamicpagelist:Yi,poll:new Set(["id","show-results-before-voting"]),score:new Set(["line_width_inches","lang","override_midi","raw","note-language","override_audio","override_ogg","sound","vorbis"]),seo:new Set(["title","title_mode","title_separator","keywords","description","robots","google_bot","image","image_width","image_height","image_alt","type","site_name","locale","section","author","published_time","twitter_site"]),tab:new Set(["nested","name","index","class","block","inline","openname","closename","collapsed","dropdown","style","bgcolor","container","id","title"]),tabs:new Set(["plain","class","container","id","title","style"]),combobox:new Set(["placeholder","value","id","class","text","dropdown","style"]),math:new Set([...fc,"chem"]),chem:fc,ce:fc,hiero:Yi,phonos:new Set(["ipa","class","text","lang","wikibase","file"]),section:new Set(["begin","end"]),source:sb,syntaxhighlight:sb,templatedata:Yi,timeline:new Set(["method","font"]),quiz:new Set(["display","shuffleanswers","points","shuffle","case"]),languages:Yi,mapframe:new Set([...ab,"frameless"]),maplink:new Set([...ab,"class"]),rss:new Set(["template","templatename","max","highlight","filter","filterout","reverse","date","item-max-length"]),"page-collection":new Set(["lang","name","description","end-date"])},s2=class{constructor(t,e){this.tags=t.includes("translate")?t.filter(i=>i!=="tvar"):t,this.urlProtocols=new RegExp(String.raw`^(${this.tags.includes("tvar")?"<tvar name=[^>]+>":""})?${e}`,"iu"),this.firstSingleLetterWord=null,this.firstMultiLetterWord=null,this.firstSpace=null,this.readyTokens=[],this.oldToken=null,this.mark=null}},Pr=(t,e,i)=>t.nTemplate===e.nTemplate&&t.nExt===e.nExt&&t.nVar===e.nVar&&t.nLink===e.nLink&&t.nExtLink===e.nExtLink&&t.extName===e.extName&&(i||t.extName!=="mediawiki"||Pr(t.extState,e.extState)),o2=(t,e)=>{t.nTemplate=e.nTemplate,t.nExt=e.nExt,t.nVar=e.nVar,t.nLink=e.nLink,t.nExtLink=e.nExtLink,t.extName=e.extName},Tr=(t,e)=>{const i=e.tokenize(t,e);return Array.isArray(i)?i[0]:i},mi=(t,e,i,r=!1)=>({tokenize:t,stack:[],inHtmlTag:[],extName:!1,extMode:!1,extState:!1,nTemplate:0,nExt:0,nVar:0,nLink:0,nExtLink:0,lbrack:!1,bold:!1,italic:!1,dt:{n:0,html:0},sof:r,redirect:!1,imgLink:!1,data:new s2(e,`(${i.source.slice(4)}`)}),Ro=t=>{const e={...t};for(const[i,r]of Object.entries(t))Array.isArray(r)?e[i]=[...r]:i==="extState"?e[i]=(t.extName&&t.extMode&&t.extMode.copyState||Ro)(r):i!=="data"&&r&&typeof r=="object"&&(e[i]={...r});return e},a2=t=>typeof document!="object"||t.startsWith("#")||[...tT(`&${t}`)].length===1,ee=(t,...e)=>{t.stack.unshift(...e.slice(1),t.tokenize),t.tokenize=e[0]},re=t=>{t.tokenize=t.stack.shift()},Vi=(t,e,i)=>t.sol()&&(e&&t.match(/^\s*(?::+\s*)?\{\|/u,!1)||t.match(/^(?:-{4}|=)/u,!1)||!i&&/[*#;:]/u.test(t.peek()||"")),pe=(t,e)=>{const i={"'":"'(?!')","{":String.raw`\{(?!\{)`,"}":String.raw`\}(?!\})`,"<":e?"<(?!!--)":"<(?!!--|/?[a-z])","~":"~~?(?!~)",_:"_(?!_)","_":"_(?!_)","[":String.raw`\[(?!\[)`,"]":String.raw`\](?!\])`,"/":"/(?!>)","-":String.raw`-(?!\{(?!\{))`};if(typeof e=="object"){const{data:{tags:r}}=e;i["<"]=String.raw`<(?!!--${r.includes("onlyinclude")?"|onlyinclude>":""}|(?:${r.filter(n=>n!=="onlyinclude").join("|")})(?:[\s/>]|$))`}return[...t].map(r=>i[r]).join("|")},uc=t=>{const{dt:e}=t;return!!e.n&&e.html===0&&!t.bold&&!t.italic&&Pr(e,t,!0)},lb=(t="")=>String.raw`[^&${"~{'"}\p{Zs}[\]<>"${t}]|&(?![lg]t;)|${pe("~{'")}`,hb=t=>String.raw`.,;:!?\\${t?"":")"}`,te=(t,e)=>function(...i){const r=t.apply(this,i);return Object.defineProperty(r,"name",{value:e.name}),r.args=i,r},cb=(t,e)=>{var i;return(typeof t=="string"?t:`${t[0]} ${e.bold||(i=e.dt)!=null&&i.n?$.strong:""} ${e.italic?$.em:""}`).trim().replace(/\s{2,}/gu," ")||" "},me=(t,e,i)=>{let r="";switch(e.nTemplate){case 0:break;case 1:r+="-template";break;case 2:r+="-template2";break;default:r+="-template3";break}switch(e.nExt){case 0:break;case 1:r+="-ext";break;case 2:r+="-ext2";break;default:r+="-ext3";break}if((e.nLink||e.nExtLink)&&(r+="-link"),i){e[i]--;const{dt:n}=e;n!=null&&n.n&&e[i]<n[i]&&(n.n=0)}return(r&&`mw${r}-ground `)+t},C=(t,e,i)=>me($[t],e,i),$e=(t,e,i)=>[me(t,e,i)],gi=(t,e,i)=>$e($[t],e,i),l2=(t,e)=>{const i=t.pos,r=t.string.slice(0,i-3),n=r.slice(-1),s=r.slice(-2,-1),{data:o}=e;if(n===" "){if(o.firstMultiLetterWord||o.firstSpace)return;o.firstSpace=i}else if(s===" ")o.firstSingleLetterWord=i;else{if(o.firstMultiLetterWord)return;o.firstMultiLetterWord=i}o.mark=i},dc=t=>String.raw`(?:${t?"":String.raw`\||`}\{(?:\{\s*|\s*\()!\s*\}\})`,pc=t=>{const e=t.peek();return e==="'"||e==='"'?e.repeat(2):""},Xo=t=>t.name==="inTemplateArgument"&&t.args[0]?"=":"",Oc=(t,e)=>{if(e&&t.sol())return!0;const i=t.peek();return!!(i&&!i.trim())},h2=new Set(["syntaxhighlight","source","pre"]),c2=new Set(["raw","msg","filepath","localurl","localurle","fullurl","fullurle","canonicalurl","canonicalurle","int","msgnw"]),fb=new Set(["subst","safesubst"]),f2=new RegExp(`^(?:[^&[<{~'-]|${pe("<{~'-")})+`,"iu"),u2=new RegExp(`^(?:[^|{}<]|${pe("{}<",!0)})+`,"u"),d2=new RegExp(`^(?:[^|[&:}{<~'__-]|${pe("}{<~'__-")})+`,"iu"),p2=new RegExp(`^(?:[^|[&}{<~'__-]|${pe("}{<~'__-")})+`,"iu"),O2=new RegExp(`^(?:[^&'{[<~__:-]|${pe("'{[<~__-")})+`,"iu"),m2=new RegExp(`^(?:[^&={<]|${pe("{<")})+`,"iu"),ub=/^\s*(?:[|!]|\{\{\s*![!)+-]?\s*\}\})/u,db="[{'<-",Wo="{<",pb="'<~__{-",Ob="{/",mb=[!1,!0].map(t=>{const e=hb(t),i=lb(e);return new RegExp(`^(?:${i}|[${e}]+(?=${i}))*`,"u")}),g2=[!1,!0].map(t=>new RegExp(String.raw`^:*\s*(?=\{${dc(t)})`,"u")),b2=[!1,!0].map(t=>new RegExp(String.raw`^${dc(t)}\s*`,"u")),v2=[!1,!0].map(t=>new RegExp(String.raw`^\s*(:+\s*)?(?=\{${dc(t)})`,"u")),y2=[!1,!0].map(t=>{const e=`]'{<${t?"~":"["}-`;return new RegExp(`^(?:[^&${t?"[|":""}\\${e}]|${pe(e)})+`,"iu")}),mc=[new RegExp(String.raw`^(?:[<>{}]|%(?:3[ce]|[57][bd])|${pe("[]")})+`,"iu"),new RegExp(String.raw`^(?:\}|${pe("[]{")})+`,"u"),new RegExp(String.raw`^(?:[>}]|%(?:3[ce]|[57][bd])|${pe("[]{<")})+`,"iu")],S2=["","="].map(t=>new RegExp(String.raw`^(?:[^\s&${Wo}${t}]|${pe(Wo)})+`,"iu")),k2=[!1,!0].map(t=>new RegExp(String.raw`^(?:[^|{}<${t?"[&~'__:-":""}]|\}(?!\}\})|${t?pe("{<~'__-"):pe("{<",!0)})+`,"iu")),w2=["","[&","[&:"].map(t=>xt(e=>new RegExp(`^(?:[^|${t}${e}]|${pe(e)})+`,"iu"))),x2={_:/^[\p{L}\p{N}_]+?__/u,"_":/^[\p{L}\p{N}__]+?_{2}/u},Q2=xt(t=>new RegExp(String.raw`^(?:[^\]&${t}${db}]|${pe(db)})+`,"iu")),$2=xt(t=>new RegExp(`^(?:${lb(t)})+`,"u")),P2=xt(t=>new RegExp(`^(?:[^&${Wo}${t}]|${pe(Wo)})+`,"iu")),T2=xt(t=>new RegExp(`^(?:[^[&${t}${pb}]|${pe(pb)})+`,"iu")),gb=xt(t=>new RegExp(`^(?:[^<>&${Ob}${t}]|${pe(Ob)})+`,"u")),C2=xt(t=>new RegExp(`^(?:[^<>&={/${t}]|${pe("{/")})+`,"u")),Z2=xt(t=>new RegExp(`^(?:[^>/${t}]|${pe("/")})+`,"u")),A2=xt(t=>t==="onlyinclude"?/<\/onlyinclude(?:>|$)/u:new RegExp(String.raw`</${t}\s*(?:>|$)`,"iu")),R2=xt(t=>new RegExp(String.raw`^(?:[^<]|<(?!${t}(?:[\s/>]|$)))+`,"iu")),X2=(Hv=[te],Fv=[te],Uv=[te],Gv=[te],Iv=[te],Nv=[te],zv=[te],jv=[te],Lv=[te],Bv=[te],_v=[te],Vv=[te],Yv=[te],Dv=[te],qv=[te],Ev=[te],Mv=[te],Wv=[te],Xv=[te],Rv=[te],Av=[te],Zv=[te],Cv=[te],Tv=[te],Pv=[te],$v=[te],Qv=[te],xv=[te],wv=[te],kv=[te],U=class{constructor(t){nf(K,5,this);const{urlProtocols:e,permittedHtmlTags:i,implicitlyClosedHtmlTags:r,tags:n,nsid:s,variants:o,functionSynonyms:[a],redirection:l=["#REDIRECT"],img:h={}}=t;this.config=t,this.tokenTable={...pT},this.hiddenTable={},this.permittedHtmlTags=new Set([...jm,...i!=null?i:[]]),this.voidHtmlTags=new Set([...zm,...r!=null?r:[]]),this.urlProtocols=new RegExp(String.raw`^(?:${e})(?=[^\p{Zs}[\]<>"])`,"iu"),this.linkRegex=new RegExp(String.raw`^\[(?!${e})\s*`,"iu"),this.fileRegex=new RegExp(String.raw`^(?:${Object.entries(s).filter(([,c])=>c===6).map(([c])=>c).join("|")})\s*:`,"iu"),this.redirectRegex=new RegExp(String.raw`^\s*(?:${l.join("|")})(\s*:)?\s*(?=\[\[|$)`,"iu"),this.img=Object.keys(h).filter(c=>!/\$1./u.test(c)),this.imgRegex=new RegExp(String.raw`^(?:${this.img.filter(c=>c.endsWith("$1")).map(c=>c.slice(0,-2)).join("|")}|(?:${this.img.filter(c=>!c.endsWith("$1")).join("|")}|(?:\d+x?|\d*x\d+)\s*(?:px)?px)\s*(?=\||\]\]|$))`,"u"),this.tags=[...Object.keys(n),"includeonly","noinclude","onlyinclude"],this.convertRegex=new RegExp(String.raw`^(?:[^}|;&='{[<~__-]|\}(?!-)|=(?!>)|\[(?!\[|${e})|${pe("'{<~__-")})+`,"iu"),this.convertSemicolon=o&&new RegExp(String.raw`^;\s*(?=(?:[^;]*?=>\s*)?(?:${o.join("|")})\s*:|(?:$|\}-))`,"iu"),this.convertLang=o&&new RegExp(String.raw`^(?:=>\s*)?(?:${o.join("|")})\s*:`,"iu"),this.hasVariants=!!(o!=null&&o.length),this.preRegex=[!1,!0].map(c=>new RegExp(String.raw`^(?:[^<&-]|-${this.hasVariants?String.raw`(?!\{)`:""}|<(?!${c?"/":""}nowiki>))+`,"iu")),this.substRegex=new RegExp(String.raw`^\s*(?:(${Object.entries(a).filter(([,c])=>fb.has(c)).map(([c])=>c+(c.endsWith(":")?"":":")).join("|")})\s*)?`,"iu"),this.autocompleteNamespaces={0:"",6:"File:",8:"MediaWiki:",10:"Template:",274:"Widget:",828:"Module:"},this.registerGroundTokens()}addToken(t,e=!1,i){var r,n,s;(s=(r=this[e?"hiddenTable":"tokenTable"])[n=`mw-${t}`])!=null||(r[n]=rt.define(i))}registerGroundTokens(){const t=["ext","ext-link","ext2","ext2-link","ext3","ext3-link","link","template-ext","template-ext-link","template-ext2","template-ext2-link","template-ext3","template-ext3-link","template","template-link","template2-ext","template2-ext-link","template2-ext2","template2-ext2-link","template2-ext3","template2-ext3-link","template2","template2-link","template3-ext","template3-ext-link","template3-ext2","template3-ext2-link","template3-ext3","template3-ext3-link","template3","template3-link"];for(const e of t)this.addToken(`${e}-ground`);for(let e=1;e<7;e++)this.addToken(`section--${e}`);for(const e of this.tags)this.addToken(`tag-${e}`,e!=="nowiki"&&e!=="pre"&&e!=="ref"),this.addToken(`ext-${e}`,!0);for(const e of this.permittedHtmlTags)this.addToken(`html-${e}`,!0);for(const e of Object.keys(this.autocompleteNamespaces))Number.isInteger(Number(e))&&this.addToken(`function-${e}`,!0)}inChars({length:t},e){return(i,r)=>(i.pos+=t,re(r),C(e,r))}inStr(t,e,i="error"){return(r,n)=>r.match(t,!!e)?(re(n),e?C(e,n):""):(r.skipTo(t)||r.skipToEnd(),C(i,n))}eatWikiText(t){t in $&&(t=$[t]);const e=/^(?:(?:RFC|PMID)[\p{Zs}\t]+\d+|ISBN[\p{Zs}\t]+(?:97[89][\p{Zs}\t-]?)?(?:\d[\p{Zs}\t-]?){9}[\dxX])\b/u;return(i,r)=>{var s,o;let n;if(i.eol())return"";if(i.sol()){if(r.sof){if(i.match(/^\s+$/u))return"";r.sof=!1;const l=i.match(this.redirectRegex);if(l)return r.redirect={colon:!l[1]},$.redirect}else if(r.redirect){if(i.match(/^\s+(?=$|\[\[)/u))return"";if(r.redirect.colon&&i.match(/^\s*:\s*(?=$|\[\[)/u))return r.redirect.colon=!1,$.redirect;r.redirect=!1}n=i.next();const a=["inTemplateArgument","inParserFunctionArgument","inVariable"].includes(r.tokenize.name);switch(n){case"#":case";":case"*":return i.backUp(1),this.eatList(i,r);case":":return i.match(g2[a?1:0])?(ee(r,this.eatStartTable),C("list",r)):this.eatList(i,r);case"=":{const l=i.match(/^(={0,5})(.+?(=\1\s*)(?:<!--(?!.*-->\s*\S).*)?)$/u);if(l)return i.backUp(l[2].length),ee(r,this.inSectionHeader(l[3])),me(`${$.sectionHeader} mw-section--${l[1].length+1}`,r);break}case"{":if(i.match(b2[a?1:0]))return ee(r,this.inTableDefinition()),C("tableBracket",r);break;case"-":if(i.match(/^-{3,}/u))return $.hr;break;default:if(!n.trim()){const l=i.match(v2[a?1:0]);if(l)return ee(r,this.eatStartTable),me(l[1]?$.list:"",r);if(n===" "&&!/^ \s*(?=<!--)(?:\s|<!--(?:(?!-->).)*-->)+$/u.test(i.string))return $.skipFormatting}}}else n=i.next();switch(n){case"~":if(i.match(/^~{2,4}/u))return $.signature;break;case"<":{if(i.match("!--"))return ee(r,this.inComment),C("comment",r);const a=!!i.eat("/"),l=i.match(/^([a-z][^\s/>]*)>?/iu,!1);if(l){const h=l[1].toLowerCase();if((l[0]==="onlyinclude>"||h!=="onlyinclude")&&r.data.tags.includes(h))return this.eatExtTag(h,a,r);if(this.permittedHtmlTags.has(h))return this.eatHtmlTag(h,a,r)}break}case"{":{if(i.match(/^\{\{(?!\{|[^{}]*\}\}(?!\}))\s*/u))return r.nVar++,ee(r,this.inVariable()),C("templateVariableBracket",r);if(i.match(/^\{(?!\{(?!\{))/u))return(s=this.eatTransclusion(i,r))!=null?s:$e(t,r);break}case"_":case"_":{const{pos:a}=i;switch(i.eatWhile(n),i.pos-a){case 0:break;case 1:return this.eatDoubleUnderscore(t,n,i,r);default:return i.eol()||i.backUp(2),$e(t,r)}break}case"[":if(i.match(this.linkRegex)){const{redirect:a}=r;if(a||/[^[\]|]/u.test(i.peek()||""))return r.nLink++,r.lbrack=void 0,ee(r,this.inLink(!a&&!!i.match(this.fileRegex,!1))),C("linkBracket",r);if(i.match("]]"))return $e(t,r)}else{const a=i.match(r.data.urlProtocols,!1);if(a)return r.nExtLink++,a[1]?ee(r,this.inChars("<","extTagBracket"),this.eatTagName("tvar"),this.inExternalLink(!0)):ee(r,this.eatExternalLinkProtocol(a[2],!1)),C("extLinkBracket",r)}break;case"'":{const a=this.eatApostrophes(r)(i,r);if(a)return a;break}case":":if(uc(r))return r.dt.n--,C("list",r);break;case"&":return $e(this.eatEntity(i,t),r);case"-":if((o=this.config.variants)!=null&&o.length&&i.match(/^\{(?!\{)\s*/u))return ee(r,this.inConvert(t,!0)),C("convertBracket",r)}if(r.stack.length===0){if(n!=="_"&&n!=="_"){/[\p{L}\p{N}]/u.test(n)?i.backUp(1):i.eatWhile(/[^\p{L}\p{N}__&'{[<~:-]/u);const a=i.match(this.urlProtocols,!1);if(a)return ee(r,this.eatExternalLinkProtocol(a[0])),$e(t,r);const l=i.match(e,!1);if(l)return ee(r,this.inChars(l[0],"magicLink")),$e(t,r)}i.eatWhile(/[\p{L}\p{N}]/u)}return $e(t,r)}}eatApostrophes(t){return(e,i)=>e.match(/^'*(?='{5})/u)||e.match(/^'''(?!')/u,!1)?!1:e.match("''''")?(t.bold=!t.bold,t.italic=!t.italic,C("apostrophes",i)):e.match("''")?(t===i&&i.data.firstSingleLetterWord===null&&l2(e,i),t.bold=!t.bold,C("apostrophes",i)):e.eat("'")?(t.italic=!t.italic,C("apostrophes",i)):!1}eatExternalLinkProtocol({length:t},e=!0){return(i,r)=>(i.pos+=t,r.tokenize=e?this.eatFreeExternalLink:this.inExternalLink(),C(e?"freeExtLinkProtocol":"extLinkProtocol",r))}inExternalLink(t){return(e,i)=>{const r=i.stack[0],n=Xo(r),s=["inTemplateArgument","inParserFunctionArgument","inVariable","inTableCell"].includes(r.name),o=(s?"|":"")+n,a=e.peek();return e.sol()||e.match(/^\p{Zs}*\]/u)||s&&a==="|"||n&&a==="="?(re(i),C("extLinkBracket",i,"nExtLink")):t?e.match(Q2(o))?gi("extLinkText",i):this.eatWikiText("extLinkText")(e,i):e.match($2(o))?C("extLink",i):(i.tokenize=this.inExternalLink(!0),"")}}eatFreeExternalLink(t,e){const i=t.match(mb[0]);return!t.eol()&&i[0].includes("(")&&hb().includes(t.peek())&&t.match(mb[1]),re(e),gi("freeExtLink",e)}inLink(t,e){const i=e?$[t?"error":"linkToSection"]:`${$.linkPageName} ${$.pageName}`,r=e?/^(?:[^|<[\]{}]|<(?!!--|\/?[a-z]))+/iu:/^(?:&#(?:\d+|x[a-f\d]+);|[^#|<>[\]{}%]|%(?!3[ce]|[57][bd]))+/iu;let n;return(s,o)=>{if(s.sol()||n&&s.pos>n||s.match(/^\s*\]\]/u)||s.match(/^\[\[/u,!1))return o.redirect=!1,o.lbrack=!1,re(o),C("linkBracket",o,"nLink");n=void 0;const a=s.eatSpace(),{redirect:l}=o;if(!e&&s.match(/^#\s*/u))return o.tokenize=this.inLink(t,!0),gi(t?"error":"linkToSection",o);if(s.match(/^\|\s*/u)){o.tokenize=this.inLinkText(t);let c=l?"error":"linkDelimiter";return t&&(c="fileDelimiter",this.toEatImageParameter(s,o)),C(c,o)}let h;return l?[h]=mc:e?[,h]=mc:[,,h]=mc,s.match(h)?gi("error",o):l?(s.match(/^(?:[^|<>[\]{}%]|%(?!3[ce]|[57][bd]))+/iu),$e(i,o)):s.match(r)||a?$e(i,o):(s.match(/^<(?!(?:includeonly|noinclude)(?:\/?>|\s|$)|tvar(?:\s|$))[/a-z]/iu,!1)&&!s.match(/^<onlyinclude>/u,!1)&&(n=s.pos+1),this.eatWikiText(e?i:"error")(s,o))}}inLinkText(t,e){const i={bold:!1,italic:!1},r=y2[t?1:0];return(n,s)=>{var f;const o=`${$[t?"fileText":"linkText"]} ${i.bold?$.strong:""} ${i.italic?$.em:""} ${t&&s.imgLink?$.pageName:""}`,{redirect:a,lbrack:l}=s,h=n.match("]]");if(h||!t&&n.match("[[",!1)||!e&&((f=s.stack[0])==null?void 0:f.name)==="inTableCell"&&n.sol()&&n.match(ub,!1))return e?$e(o,s):h&&!a&&l&&n.peek()==="]"?(n.backUp(1),s.lbrack=!1,$e(o,s)):(s.redirect=!1,s.lbrack=!1,re(s),C("linkBracket",s,"nLink"));if(a)return n.skipTo("]]")||n.skipToEnd(),C("error",s);if(t&&n.match(/^\|\s*/u))return this.toEatImageParameter(n,s),C("fileDelimiter",s);if(n.match(/^'(?=')/u))return this.eatApostrophes(i)(n,s)||$e(o,s);if(t&&Vi(n,!0,!0)||n.sol()&&n.match("{|",!1))return this.eatWikiText(o)(n,s);const c=n.match(r);return l===void 0&&(c!=null&&c[0].includes("["))&&(s.lbrack=!0),c?$e(o,s):this.eatWikiText(o)(n,s)}}toEatImageParameter(t,e){var r;e.imgLink=!1;const i=t.match(this.imgRegex,!1);i&&(((r=this.config.img)==null?void 0:r[`${i[0]}$1`])==="img_link"&&(e.imgLink=!0),ee(e,this.inChars(i[0],"imageParameter")))}eatList(t,e){const i=t.match(/^[*#;:]*/u),{dt:r}=e;return i[0].includes(";")&&(r.n=i[0].split(";").length-1,o2(r,e)),C("list",e)}eatDoubleUnderscore(t,e,i,r){const{config:{doubleUnderscore:n}}=this,s=e.repeat(2),o=i.match(x2[e]);if(o){if(Object.prototype.hasOwnProperty.call(n[0],s+o[0].toLowerCase())||Object.prototype.hasOwnProperty.call(n[1],s+o[0]))return $.doubleUnderscore;i.eol()||i.backUp(2)}return $e(t,r)}get eatStartTable(){return(t,e)=>(t.match(/^(?:\{\||\{\{(?:\{\s*|\s*\()!\s*\}\})\s*/u),e.tokenize=this.inTableDefinition(),C("tableBracket",e))}inTableDefinition(t,e){const i=e===void 0?`${$.tableDefinition} mw-html-${t?"tr":"table"}`:$.tableDefinitionValue;return(r,n)=>{if(r.sol())return n.tokenize=this.inTable,"";const s=n.stack[0],o=Xo(s);return o&&r.peek()==="="?(re(n),""):r.match(/^(?:&|\{\{|<(?:!--|\/?[a-z]))/iu,!1)?this.eatWikiText(i)(r,n):e?(r.eat(e[0])?n.tokenize=this.inTableDefinition(t,e[1]):r.match(P2(o+e[0])),me(i,n)):e===""?Oc(r)?(n.tokenize=this.inTableDefinition(t),""):(r.match(S2[o?1:0]),me(i,n)):r.match(/^=\s*/u)?(n.tokenize=this.inTableDefinition(t,pc(r)),me(i,n)):(r.match(m2),me(i,n))}}get inTable(){return(t,e)=>{if(t.sol()){t.eatSpace();const i=t.match(/^(?:\||\{\{\s*!([!)+-])?\s*\}\})/u);if(i)return i[1]==="-"||!i[1]&&t.eat("-")?(t.match(/^-*\s*/u),e.tokenize=this.inTableDefinition(!0),C("tableDelimiter",e)):i[1]==="+"||!i[1]&&t.match(/^\+\s*/u)?(e.tokenize=this.inTableCell($.tableCaption),C("tableDelimiter",e)):i[1]===")"||!i[1]&&t.eat("}")?(re(e),C("tableBracket",e)):(t.eatSpace(),e.tokenize=this.inTableCell($.tableTd,i[1]!=="!"),C("tableDelimiter",e));if(t.match(/^!\s*/u))return e.tokenize=this.inTableCell($.tableTh),C("tableDelimiter",e);if(Vi(t,!0))return this.eatWikiText("error")(t,e)}return t.match(O2)?gi("error",e):this.eatWikiText("error")(t,e)}}inTableCell(t,e=!0,i=!0){return(r,n)=>{if(r.sol()){if(r.match(ub,!1))return n.tokenize=this.inTable,"";if(i)return n.tokenize=this.inTableCell(t,!1,!1),"";if(Vi(r,!0))return this.eatWikiText(t)(r,n)}if(i){if(r.match(/^(?:(?:\||\{\{\s*!\s*\}\}){2}|\{\{\s*!!\s*\}\})\s*/u)||t===$.tableTh&&r.match(/^!!\s*/u))return n.bold=!1,n.italic=!1,e||(n.tokenize=this.inTableCell(t)),C("tableDelimiter",n);if(e&&r.match(/^(?:\||\{\{\s*!\s*\}\})\s*/u))return n.bold=!1,n.italic=!1,n.tokenize=this.inTableCell(t,!1),C("tableDelimiter2",n);e&&r.match("[[",!1)&&(n.tokenize=this.inTableCell(t,!1))}const s=n.stack[0],o=Xo(s);return o&&r.peek()==="="?(re(n),""):r.match(T2((i?"|!":":")+o))?$e(t,n):this.eatWikiText(t)(r,n)}}inSectionHeader(t){return(e,i)=>e.sol()?(re(i),""):e.match(f2)?(e.eol()?(e.backUp(t.length),i.tokenize=this.inStr(t,"sectionHeader")):e.match(/^<!--(?!.*?-->.*?=)/u,!1)&&(e.backUp(t.length),i.tokenize=this.inStr("<!--",!1,"sectionHeader")),C("section",i)):this.eatWikiText("section")(e,i)}get inComment(){return this.inStr("-->","comment","comment")}eatExtTag(t,e,i){return e?(ee(i,this.inStr(">","error")),C("error",i)):(ee(i,this.eatTagName(t)),C("extTagBracket",i))}eatHtmlTag(t,e,i){if(e){const{dt:r,inHtmlTag:n}=i;if(r.n&&r.html&&r.html--,t===n[n.length-1])n.pop();else{ee(i,this.inStr(">","error"));const s=n.lastIndexOf(t);return s!==-1&&n.splice(s,1),C("error",i)}}return ee(i,this.eatTagName(t,e,!0)),C("htmlTagBracket",i)}eatTagName(t,e,i){return(r,n)=>(r.match(t,!0,!0),r.eatSpace(),i?(n.tokenize=e?this.inStr(">","htmlTagBracket"):this.inHtmlTagAttribute(t),C("htmlTagName",n)):(n.tokenize=e?this.inStr(">","extTagBracket"):this.inExtTagAttribute(t),C("extTagName",n)))}inHtmlTagAttribute(t,e){const i=e===void 0?`${$.htmlTagAttribute} mw-html-${t}`:$.htmlTagAttributeValue;return(r,n)=>{var l;if(r.match(new RegExp(`^${pe("<",n)}`,"iu"),!1))return re(n),"";const s=r.match(/^\/?>/u);if(s)return!this.voidHtmlTags.has(t)&&(s[0]===">"||!Nm.includes(t))&&(n.inHtmlTag.push(t),n.dt.html++),re(n),C("htmlTagBracket",n);const o=n.stack[0],a=(["inTemplateArgument","inParserFunctionArgument","inVariable"].includes(o.name)?"|":"")+Xo(o);return a.includes((l=r.peek())!=null?l:"")?(re(n),""):r.match(/^(?:[&<]|\{\{)/u,!1)?this.eatWikiText(i)(r,n):e?(r.eat(e[0])?n.tokenize=this.inHtmlTagAttribute(t,e[1]):r.match(gb(a+e[0])),me(i,n)):e===""?Oc(r,!0)?(n.tokenize=this.inHtmlTagAttribute(t),""):(r.match(gb(String.raw`\s${a}`)),me(i,n)):r.match(/^=\s*/u)?(n.tokenize=this.inHtmlTagAttribute(t,pc(r)),me(i,n)):(r.match(C2(a)),me(i,n))}}inExtTagAttribute(t,e,i,r){const n=`${$.extTagAttribute} mw-ext-${t}`,s=(o,a,l)=>{const h=o.match(l);if(i){let c=h[0].trim().toLowerCase();c==="js"&&(c="javascript"),c in this&&(a.extMode=this[c]())}return me($.extTagAttributeValue+(r?` ${$.pageName}`:""),a)};return(o,a)=>{if(o.match("/>"))return t==="tvar"?(o.backUp(1),C("error",a)):(a.extMode=!1,re(a),C("extTagBracket",a));if(o.eat(">")){const{config:{tagModes:h}}=this;return a.extName=t,a.extMode||(a.extMode=t in h&&h[t]in this&&this[h[t]]([...a.data.tags.filter(c=>c!==t),...t==="translate"?["tvar"]:[]])),a.extMode&&(a.extState=a.extMode.startState(0)),a.tokenize=this.eatExtTagArea(t),C("extTagBracket",a)}else if(e){if(o.eat(e[0])){const[,h]=e;return a.tokenize=this.inExtTagAttribute(t,h,i&&!!h,r&&!!h),C("extTagAttributeValue",a)}return s(o,a,Z2(e[0]))}else{if(e==="")return Oc(o,!0)?(a.tokenize=this.inExtTagAttribute(t),""):s(o,a,/^(?:[^>/\s]|\/(?!>))+/u);if(o.match(/^=\s*/u))return a.tokenize=this.inExtTagAttribute(t,pc(o),i,r),me(n,a)}const l=o.match(/^(?:[^>/=]|\/(?!>))+/u);return o.peek()==="="&&(a.tokenize=this.inExtTagAttribute(t,void 0,h2.has(t)&&/(?:^|\s)lang\s*$/iu.test(l[0]),t==="templatestyles"&&/(?:^|\s)src\s*$/iu.test(l[0]))),me(n,a)}}eatExtTagArea(t){return(e,i)=>{const{pos:r}=e,n=e.string.slice(r).search(A2(t));if(n===0)return e.match("</"),i.tokenize=this.eatTagName(t,!0),i.extName=!1,i.extMode=!1,i.extState=!1,C("extTagBracket",i);let s="";return n!==-1&&(s=e.string,e.string=s.slice(0,r+n)),ee(i,this.inExtTokens(s)),""}}inExtTokens(t){return(e,i)=>{var n;let r;return i.extMode===!1?(r=`mw-tag-${i.extName} ${$.extTag}`,e.skipToEnd()):r=`mw-tag-${i.extName} ${(n=i.extMode.token(e,i.extState))!=null?n:""}`,e.eol()&&(t&&(e.string=t),re(i)),r}}inVariable(t=0){let e="comment";t===0?e="templateVariableName":t===1&&(e="templateVariable");const i=k2[t===1?1:0];return(r,n)=>{const s=r.sol();return r.eatSpace(),r.eol()?me("",n):r.eat("|")?(t<2&&(n.tokenize=this.inVariable(t+1)),C("templateVariableDelimiter",n)):r.match(/^\}{2,3}/u)?(re(n),C("templateVariableBracket",n,"nVar")):r.match("<!--")?(ee(n,this.inComment),C("comment",n)):t===0&&s?(n.nVar--,re(n),r.pos=0,""):t===1&&Vi(r)||!r.match(i)?this.eatWikiText(e)(r,n):(t===1?gi:C)(e,n)}}eatTransclusion(t,e){const[{length:i},r]=t.match(this.substRegex),n=r?[this.inSubst(r)]:[];if(t.peek()==="#")return t.backUp(i),e.nExt++,ee(e,...n,this.inParserFunctionName()),C("parserFunctionBracket",e);const s=t.match(/^([^}<{|::]+)(.?)/u,!1);if(s){const[,o,a]=s,l=a===":";let h=o;l?h+=":":a!==":"&&(h=o.trim());const c=h.toLowerCase(),{config:{functionSynonyms:f,variableIDs:u,functionHooks:d}}=this,p=Object.prototype.hasOwnProperty.call(f[1],h)&&f[1][h]||Object.prototype.hasOwnProperty.call(f[0],c)&&f[0][c];if((!a||l||a===":"||a==="}")&&p&&!fb.has(p)&&(l||a===":"||!u||u.includes(p))&&(!l&&a!==":"||!d||d.includes(p)||HZ.has(p)))return t.backUp(i),e.nExt++,ee(e,...n,this.inParserFunctionName()),C("parserFunctionBracket",e)}if(!t.match("}}"))return t.backUp(i),e.nTemplate++,ee(e,...n,this.inTemplatePageName()),C("templateBracket",e)}inSubst(t){return(e,i)=>t?(e.eatSpace(),e.match(t),e.backUp(1),i.tokenize=this.inSubst(),C("parserFunctionName",i)):(e.next(),re(i),C("parserFunctionDelimiter",i))}inParserFunctionName(t,e,i){return(r,n)=>{var h;const s=r.sol(),o=r.eatSpace();if(r.eol())return me("",n);if(r.eat("}"))return re(n),C(r.eat("}")?"parserFunctionBracket":"error",n,"nExt");if(r.match("<!--"))return ee(n,this.inComment),C("comment",n);if(s)return n.nExt--,re(n),r.pos=0,"";const a=r.eat(/[::|]/u);if(a)return n.tokenize=this.inParserFunctionArgument(t,e,i),C(o||a==="|"?"error":"parserFunctionDelimiter",n);const l=r.match(/^(?:[^::}{|<>[\]\s]|\s(?![::]))+/u);if(l){const c=l[0].trim().toLowerCase()+(r.peek()===":"?":":""),{config:{functionSynonyms:[f]}}=this;if(c.startsWith("#"))switch((h=f[c])!=null?h:f[c.slice(1)]){case"invoke":n.tokenize=this.inParserFunctionName(2);break;case"widget":n.tokenize=this.inParserFunctionName(1);break;case"switch":n.tokenize=this.inParserFunctionName(void 0,1);break;case"tag":n.tokenize=this.inParserFunctionName(void 0,2);break;case"ifexist":case"lst":case"lstx":case"lsth":n.tokenize=this.inParserFunctionName(1/0)}else{const u=f[c];if(c2.has(u)){let d=0;switch(u){case"filepath":d=6;break;case"int":d=8;break;case"raw":case"msg":case"msgnw":d=10}n.tokenize=this.inParserFunctionName(1/0,1/0,d)}}return C("parserFunctionName",n)}return re(n),me("",n,"nExt")}}inTemplatePageName(t,e){const i=e?$.error:`${$.templateName} ${$.pageName}`,r="{}<",n=e?u2:/^(?:&#(?:\d+|x[a-f\d]+);|[^|{}<>[\]#%]|%(?![\da-f]{2}))+/iu;return(s,o)=>{const a=s.sol(),l=s.eatSpace();return s.eol()?me("",o):s.match("}}")?(re(o),C("templateBracket",o,"nTemplate")):s.match("<!--")?(ee(o,this.inComment),C("comment",o)):s.match(/^<\/?onlyinclude>/u)||s.match(/^<(?:(?:includeonly|noinclude)(?:\s[^>]*)?\/?>|\/(?:includeonly|noinclude)\s*>)/iu)||o.data.tags.includes("tvar")&&s.match(/^<(?:tvar\s[^>]*>|\/tvar\s*>)/iu)?C("comment",o):s.eat("|")?(o.tokenize=this.inTemplateArgument(!0),C("templateDelimiter",o)):t&&a?(o.nTemplate--,re(o),s.pos=0,""):!e&&s.eat("#")?(o.tokenize=this.inTemplatePageName(!0,!0),C("error",o)):!e&&s.match(new RegExp(String.raw`^(?:[>[\]]|%[\da-f]{2}|${pe(r,o)})+`,"iu"))?C("error",o):!e&&s.peek()==="<"?(re(o),me("",o,"nTemplate")):l&&!t?me("",o):s.match(n)?(t||(o.tokenize=this.inTemplatePageName(!0,e)),me(i,o)):l?me(i,o):this.eatWikiText(i)(s,o)}}inParserFunctionArgument(t,e=t!=null?t:1/0,i=0){if(e===0)return this.inTemplateArgument(!0,!0);const r=e===2?"}{<":"}{<~'__-";let n=`${$.parserFunction} ${t?$.pageName:""}`;switch(t){case 1:n+=" mw-function-274";break;case 2:n+=" mw-function-828";break;case 1/0:n+=` mw-function-${i}`}return(s,o)=>s.eat("|")?(t?o.tokenize=this.inParserFunctionArgument(void 0,t-1):e!==1/0&&(o.tokenize=this.inParserFunctionArgument(void 0,e-1)),C("parserFunctionDelimiter",o)):s.match("}}")?(re(o),C("parserFunctionBracket",o,"nExt")):!Vi(s)&&s.match(w2[t?0:Number(uc(o))+1](r))?me(n,o):this.eatWikiText("parserFunction")(s,o)}inTemplateArgument(t,e){const i=e?"parserFunction":"template";return(r,n)=>{const s=r.eatSpace();if(r.eol())return C(i,n);if(r.eat("|"))return t||(n.tokenize=this.inTemplateArgument(!0,e)),C(e?"parserFunctionDelimiter":"templateDelimiter",n);if(r.match("}}",!1))return s?C(i,n):(r.pos+=2,re(n),C(e?"parserFunctionBracket":"templateBracket",n,e?"nExt":"nTemplate"));if(r.sol()&&r.peek()==="="){const o=this.eatWikiText(i)(r,n);if(o.includes($.sectionHeader))return o;r.pos=0}return t&&r.match(new RegExp(`^(?:[^=|}{[<]|${pe("}{[<",n)})*=`,"iu"))?(n.tokenize=this.inTemplateArgument(!1,e),C("templateArgumentName",n)):Vi(r)&&r.peek()!=="="?this.eatWikiText(i)(r,n):r.match(uc(n)?d2:p2)||s?C(i,n):this.eatWikiText(i)(r,n)}}inConvert(t,e,i=!0,r){return(n,s)=>{const o=n.eatSpace();return n.match("}-")?(re(s),C("convertBracket",s)):e&&n.match(/^[;\sa-z-]*(?=\|)/iu)?(s.tokenize=this.inConvert(t,!1,!0,r),ee(s,this.inStr("|","convertDelimiter")),C("convertFlag",s)):n.match(this.convertSemicolon)?((e||!i)&&(s.tokenize=this.inConvert(t,!1,!0,r)),C("convertDelimiter",s)):i&&n.match(this.convertLang)?(s.tokenize=this.inConvert(t,!1,!1,r),C("convertLang",s)):r?n.match("-{",!1)?this.eatWikiText(t)(n,s):(n.match(/^(?:(?:[^};=-]|\}(?!-)|=(?!>)|-(?!\{))+|;|=>)/u),$e(t,s)):!Vi(n,!0)&&n.match(this.convertRegex)||o?$e(t,s):this.eatWikiText(t)(n,s)}}eatEntity(t,e){const i=t.match(/^(?:#x[a-f\d]+|#\d+|[a-z\d]+);/iu);return i&&a2(i[0])?$.htmlEntity:e}mediawiki(t){return{startState:()=>mi(this.eatWikiText(""),t!=null?t:this.tags,this.urlProtocols,t===void 0),copyState:Ro,token(e,i){const{data:r}=i,{readyTokens:n}=r;let{oldToken:s}=r;for(;s&&(e.pos>s.pos||e.pos===s.pos&&i.tokenize!==s.state.tokenize);)s=n.shift();if(e.pos===(s==null?void 0:s.pos)&&e.string===s.string&&Pr(i,s.state)){const{pos:a,string:l,state:{bold:h,italic:c,...f},style:u}=n[0];if(Object.assign(i,f),!(i.extName&&i.extMode)&&i.nLink===0&&typeof u=="string"&&u.includes($.apostrophes)){if(r.mark===a){r.mark=null,e.string=l.slice(0,a-2);const p=i.tokenize(e,i);return e.string=l,s.pos++,r.oldToken=s,cb(p,i)}const d=a-e.pos;d!==3&&(i.italic=!i.italic),d!==2&&(i.bold=!i.bold)}else typeof u=="string"&&u.includes($.tableDelimiter)&&(i.bold=!1,i.italic=!1);return r.oldToken=n.shift(),e.pos=a,e.string=l,cb(u,i)}else e.sol()&&(i.bold=!1,i.italic=!1,i.dt.n=0,i.dt.html=0,r.firstSingleLetterWord=null,r.firstMultiLetterWord=null,r.firstSpace=null,i.tokenize.name==="inExtTokens"&&(re(i),re(i),i.extName=!1,i.extMode=!1,i.extState=!1));n.length=0,r.mark=null,r.oldToken={pos:e.pos,string:e.string,state:Ro(i),style:""};const{start:o}=e;do{e.start=e.pos;const a=e.peek(),l=i.tokenize(e,i);if(typeof l=="string"&&l.includes($.templateArgumentName))for(let h=n.length-1;h>=0;h--){const c=n[h];if(Pr(i,c.state,!0)){const f=typeof c.style=="string"&&c.style.split(" "),u=f&&f.indexOf($.template);if(u!==!1&&u!==-1)f[u]=$.templateArgumentName,c.style=f.join(" ");else if(f&&f.includes($.templateDelimiter))break}}else if(typeof l=="string"&&l.includes($.tableDelimiter2))for(let h=n.length-1;h>=0;h--){const c=n[h];if(Pr(i,c.state,!0)){const{style:f}=c,u=typeof f=="string",d=!u&&f[0].split(" ").find(p=>p&&!p.endsWith("-ground"));if(d&&d.startsWith("mw-table-"))c.style=`${f[0].replace("mw-table-","mw-html-")} ${$.tableDefinition}`;else if(u&&f.includes($.tableDelimiter))break}}else if(a==="|"&&typeof l=="string"&&l.includes($.convertDelimiter)){let h=0;for(let c=n.length-1;c>=0;c--){const f=n[c];if(Pr(i,f.state,!0)){const{style:u}=f;if(typeof u=="string"&&u.includes($.convertBracket)){if(h+=f.char==="-"?1:-1,h===1)break}else typeof u=="object"&&(f.style=u[0]+(u[0].includes($.convertFlag)?"":` ${$.convertFlag}`))}}}n.push({pos:e.pos,char:a,string:e.string,state:Ro(i),style:l})}while(!e.eol());return(!i.bold||!i.italic)&&(r.mark=null),e.start=o,e.pos=r.oldToken.pos,e.string=r.oldToken.string,Object.assign(i,r.oldToken.state),""},blankLine(e){e.extName&&e.extMode&&e.extMode.blankLine&&e.extMode.blankLine(e.extState,0)},indent(e,i,r){return e.extName&&e.extMode&&e.extMode.indent?e.extMode.indent(e.extState,i,r):null},...t?void 0:{tokenTable:{...this.tokenTable,...this.hiddenTable,"":rt.define()}}}}"text/mediawiki"(t){return this.mediawiki(t)}"text/nowiki"(){return{startState(){return{}},token:t=>t.eatWhile(/[^&]/u)?"":(t.next(),this.eatEntity(t,""))}}inPre(t){return(e,i)=>e.match(t?/^<\/nowiki>/iu:/^<nowiki>/iu)?(i.tokenize=this.inPre(!t),$.ignored):this.hasVariants&&e.match("-{")?(ee(i,this.inConvert("",!0,!0,!0)),$.convertBracket):e.eat("&")?this.eatEntity(e,""):(e.match(this.preRegex[t?1:0]),"")}"text/pre"(){return{startState:()=>mi(this.inPre(),[],this.urlProtocols),token:Tr}}inNested(t){const e=t==="ref"?/^(?:\{|(?:[^<{]|\{(?!\{)|<(?!!--|ref(?:[\s/>]|$)))+)/iu:R2(t);return(i,r)=>{var n;if(t==="ref"){if(i.match("<!--"))return ee(r,this.inComment),C("comment",r);if(i.match(/^\{{3}(?!\{|[^{}]*\}\}(?!\}))\s*/u))return ee(r,this.inVariable()),$.templateVariableBracket;if(i.match(/^\{\{(?!\{(?!\{))/u))return(n=this.eatTransclusion(i,r))!=null?n:$.ignored}return i.match(e)?$.ignored:(i.eat("<"),ee(r,this.eatTagName(t)),$.extTagBracket)}}"text/references"(t){return{startState:()=>mi(this.inNested("ref"),t,this.urlProtocols),token:Tr}}"text/choose"(t){return{startState:()=>mi(this.inNested("option"),t,this.urlProtocols),token:Tr}}"text/combobox"(t){return{startState:()=>mi(this.inNested("combooption"),t,this.urlProtocols),token:Tr}}get inInputbox(){return(t,e)=>t.match("<!--")?(ee(e,this.inComment),$.comment):(t.match(/^(?:[^<]|<(?!!--))+/u),"")}"text/inputbox"(){return{startState:()=>mi(this.inInputbox,[],this.urlProtocols),token:Tr}}inGallery(t){const e=t?$.error:`${$.linkPageName} ${$.pageName}`,i=t?/^(?:[[}\]]|\{(?!\{))+/u:/^(?:[>[}\]]|\{(?!\{)|<(?!!--))+/u,r=t?/^(?:[^|<[\]{}]|<(?!!--))+/u:/^(?:&#(?:\d+|x[a-f\d]+);|[^#|<>[\]{}])+/u;return(n,s)=>{const o=n.eatSpace();return!t&&n.match(/^#\s*/u)?(s.tokenize=this.inGallery(!0),gi("error",s)):n.match(/^\|\s*/u)?(s.tokenize=this.inLinkText(!0,!0),this.toEatImageParameter(n,s),C("fileDelimiter",s)):n.match(i)?gi("error",s):n.match(r)||o?$e(e,s):this.eatWikiText(t?e:"error")(n,s)}}"text/gallery"(t){return{startState:()=>mi(this.inGallery(),t,this.urlProtocols),token:(e,i)=>(e.sol()&&Object.assign(i,mi(this.inGallery(),i.data.tags,this.urlProtocols)),Tr(e,i))}}},K=tf(null),J(K,1,"inChars",Hv,U),J(K,1,"inStr",Fv,U),J(K,1,"eatWikiText",Uv,U),J(K,1,"eatApostrophes",Gv,U),J(K,1,"eatExternalLinkProtocol",Iv,U),J(K,1,"inExternalLink",Nv,U),J(K,1,"inLink",zv,U),J(K,1,"inLinkText",jv,U),J(K,2,"eatStartTable",Lv,U),J(K,1,"inTableDefinition",Bv,U),J(K,2,"inTable",_v,U),J(K,1,"inTableCell",Vv,U),J(K,1,"inSectionHeader",Yv,U),J(K,2,"inComment",Dv,U),J(K,1,"eatTagName",qv,U),J(K,1,"inHtmlTagAttribute",Ev,U),J(K,1,"inExtTagAttribute",Mv,U),J(K,1,"eatExtTagArea",Wv,U),J(K,1,"inExtTokens",Xv,U),J(K,1,"inVariable",Rv,U),J(K,1,"inSubst",Av,U),J(K,1,"inParserFunctionName",Zv,U),J(K,1,"inTemplatePageName",Cv,U),J(K,1,"inParserFunctionArgument",Tv,U),J(K,1,"inTemplateArgument",Pv,U),J(K,1,"inConvert",$v,U),J(K,1,"inPre",Qv,U),J(K,1,"inNested",xv,U),J(K,2,"inInputbox",wv,U),J(K,1,"inGallery",kv,U),Ho(K,U),U),W2=t=>/mw-[\w-]*link-ground/u.test(t),M2=(t,e,i,r)=>{let{label:n}=e,s;const o=n.charAt(0).toLowerCase(),{state:a}=t,l=a.sliceDoc(r);a.sliceDoc(i,i+1)===o&&(n=o+n.slice(1)),/^\s*\|/u.test(l)||(s={anchor:i+n.length+1,head:i+n.length*2+1},n+=`|${n}${/^\s*\]\]/u.test(l)?"":"]]"}`),t.dispatch({...sO(a,n,i,r),annotations:io.of(e),selection:s})},E2=(Kv=class extends X2{constructor(e){super(e);xe(this,Bi);const{urlProtocols:i,nsid:r,functionSynonyms:n,doubleUnderscore:s}=e;this.nsRegex=new RegExp(String.raw`^(${Object.keys(r).filter(o=>o!=="").join("|").replace(/_/gu," ")})\s*:\s*`,"iu"),this.functionSynonyms=n.flatMap((o,a)=>Object.keys(o).map(l=>({type:a?"constant":"function",label:l}))),this.doubleUnderscore=s.flatMap(Object.keys).filter(cc).map(o=>({type:"constant",label:o})),this.extTags=this.tags.map(o=>({type:"type",label:o})),this.htmlTags=jm.filter(o=>!this.tags.includes(o)).map(o=>({type:"type",label:o})),this.protocols=i.split("|").map(o=>({type:"namespace",label:o.replace(/\\\//gu,"/")})),this.imgKeys=this.img.map(o=>o.endsWith("$1")?{type:"property",label:o.slice(0,-2),detail:"$1"}:{type:"keyword",label:o}),this.htmlAttrs=[...[...i2].map(o=>({type:"property",label:o})),{type:"variable",label:"data-",detail:"*"},{type:"namespace",label:"xmlns:",detail:"*"}],this.elementAttrs=new Map(Object.entries(r2).map(([o,a])=>[o,[...a].map(l=>({type:"property",label:l}))])),this.extAttrs=new Map(Object.entries(n2).map(([o,a])=>[o,[...a].map(l=>({type:"property",label:l}))]))}getTagStyles(){return Object.keys(this.tokenTable).map(e=>({tag:this.tokenTable[e],class:`cm-${e}`}))}mediawiki(e){const i=super.mediawiki(e);return i.languageData={closeBrackets:{brackets:["(","[","{",'"'],before:")]}>"},autocomplete:this.completionSource},i}get completionSource(){return async e=>{var S,w,X,P,D,_;const{state:i,pos:r,explicit:n}=e,s=I(i).resolve(r,-1),{name:o,from:a,to:l}=s,h=new Set(o.split("_")),c=Se(h,"parserFunctionName"),f=i.sliceDoc(a,r).trimStart(),u=r-f.length;let{prevSibling:d}=s;if(n||c&&f.includes("#")||eg){const q=eg?null:{validFor:/^[^|{}<>[\]#]*$/u};if(c||Se(h,"templateName")){const L=f.includes(":")?[]:[...this.functionSynonyms],G=(S=await Qe(this,Bi,Hc).call(this,f,10))!=null?S:{offset:0,options:[]};return L.push(...G.options),L.length===0?null:{from:u+G.offset,options:L,...q}}else if(n&&Se(h,"templateBracket")&&e.matchBefore(/\{\{$/u))return{from:r,options:this.functionSynonyms,...q};const W=Se(h,"pageName")&&Se(h,"parserFunction")||0;if(W&&f.trim()||Se(h,"linkPageName")){const L=W2(o);let G="",ie=0;W?G=this.autocompleteNamespaces[[...h].find(ce=>ce.startsWith("mw-function-")).slice(12)]:Se(h,"mw-tag-gallery")&&!L&&(ie=6);const he=await Qe(this,Bi,Hc).call(this,G+f,ie);if(he)!W&&L?he.options=he.options.map(ce=>({...ce,apply:M2})):G==="Module:"&&(he.options=he.options.filter(({label:ce})=>!ce.endsWith("/doc")));else return null;return{from:u+he.offset-(W&&G.length),options:he.options,...q}}const M=Se(h,"templateArgumentName"),z=d==null?void 0:d.name.includes($.templateDelimiter),N=Se(h,"templateDelimiter")||Se(h,"templateBracket")&&z;if(this.tags.includes("templatedata")&&(N||M&&!f.includes("=")||Se(h,"template")&&z)){let L=-1,G="";for(;d;){const{name:ie,from:he,to:ce}=d;if(ie.includes($.templateBracket)){const[De,ft]=rc(i,d);if(L+=De,L>=0)break;L+=ft}else if(L===-1&&ie.includes($.templateName))G=i.sliceDoc(he,ce)+G;else if(G&&!ie.includes($.comment)){d=null;break}({prevSibling:d}=d)}if(d&&G){const ie=M&&i.sliceDoc(r,l).trim()==="="?"":"=",he=await Qe(this,Bi,qy).call(this,N?"":f,G,ie);if(he&&he.options.length>0)return{from:N?r:u+he.offset,options:he.options,validFor:/^[^|{}=]*$/u}}}}const p=Se(h,["htmlTagName","extTagName"]),O=n&&e.matchBefore(/\s$/u),g=/^[a-z]*$/iu;if(p&&O||Se(h,["htmlTagAttribute","extTagAttribute","tableDefinition"])){const q=p?f.trim():/mw-(?:ext|html)-([a-z]+)/u.exec(o)[1],W=O||e.matchBefore(Se(h,"tableDefinition")?/[\s|-][a-z]+$/iu:/\s[a-z]+$/iu);return W&&(W.from<u||/^\s/u.test(W.text))?{from:W.from+1,options:[...q==="meta"||q==="link"||q in this.config.tags&&!this.elementAttrs.has(q)?[]:this.htmlAttrs,...(w=this.elementAttrs.get(q))!=null?w:[],...(X=this.extAttrs.get(q))!=null?X:[]],validFor:g}:null}else if(n&&Se(h,["tableTd","tableTh","tableCaption"])){const[,q]=/mw-table-([a-z]+)/u.exec(o),W=e.matchBefore(/[\s|!+][a-z]*$/iu);if(W&&(W.from<u||/^\s/u.test(W.text)))return{from:W.from+1,options:[...this.htmlAttrs,...(P=this.elementAttrs.get(q))!=null?P:[]],validFor:g}}else if(Se(h,["comment","templateVariableName","templateName","linkPageName","linkToSection","extLink"]))return null;let b=e.matchBefore(/__(?:(?!__)[\p{L}\p{N}_])*$/u);if(b)return{from:b.from,options:this.doubleUnderscore,validFor:/^[\p{L}\p{N}]*$/u};b=e.matchBefore(/<\/?[a-z\d]*$/iu);const y=[...h].filter(q=>q.startsWith("mw-tag-")).map(q=>q.slice(7));if(b&&(n||b.to-b.from>1)){const q=/^[a-z\d]*$/iu;if(b.text[1]==="/"){const W=e.matchBefore(/<[a-z\d]+(?:\s[^<>]*)?>(?:(?!<\/?[a-z]).)*<\/[a-z\d]*$/iu),M=(_=/^<([a-z\d]+)/iu.exec((D=W==null?void 0:W.text)!=null?D:""))==null?void 0:_[1].toLowerCase(),z=y[y.length-1],N=/^\s*>/u.test(i.sliceDoc(r)),L=[...this.htmlTags.filter(({label:ie})=>!this.voidHtmlTags.has(ie)),...z?[{type:"type",label:z,boost:50}]:[]],G=this.permittedHtmlTags.has(M)&&L.findIndex(({label:ie})=>ie===M);return G!==!1&&G!==-1&&L.splice(G,1,{type:"type",label:M,boost:99}),{from:b.from+2,options:N?L:L.map(ie=>({...ie,apply:`${ie.label}>`})),validFor:q}}return{from:b.from+1,options:[...this.htmlTags,...this.extTags.filter(({label:W})=>!y.includes(W))],validFor:q}}const v=n&&Se(h,"fileDelimiter");if(v||Se(h,"fileText")&&(d!=null&&d.name.includes($.fileDelimiter))&&!f.includes("[")){const q=i.sliceDoc(r,r+1)==="=";return{from:v?r:d.to,options:q?this.imgKeys.map(W=>({...W,apply:W.label.replace(/=$/u,"")})):this.imgKeys,validFor:/^[^|{}<>[\]$]*$/u}}else if(!Se(h,["linkText","extLinkText"])&&(b=e.matchBefore(/(?:^|[^[])\[[a-z:/]*$/iu),b&&(n||!b.text.endsWith("["))))return{from:b.from+(b.text[1]==="["?2:1),options:this.protocols,validFor:/^[a-z:/]*$/iu};return null}}},Bi=new WeakSet,Hc=async function(e,i){const{config:{linkSuggest:r,nsid:n},nsRegex:s}=this;if(typeof r!="function"||/[|{}<>[\]#]/u.test(e))return;let o=!1,a=e,l=0;if(a.startsWith("/"))i=0,o=!0;else{if(a=a.replace(/_/gu," "),[{length:l}]=/^\s*/u.exec(a),a=a.slice(l),a.startsWith(":")){const[{length:u}]=/^:\s*/u.exec(a);l+=u,a=a.slice(u),i=0}if(!a)return;const f=s.exec(a);if(f){const[{length:u},d]=f;i=n[d.replace(/ /gu,"_").toLowerCase()]||1,l+=u,a=`${i===-2?"File":d}:${a.slice(u)}`}}const h=e.slice(l).includes("_");return{offset:l,options:(await r(a,o,i)).map(([c])=>({type:"text",label:h?c.replace(/ /gu,"_"):c}))}},qy=async function(e,i,r){const{config:{paramSuggest:n}}=this,s=await(n==null?void 0:n(i));return s!=null&&s.length?{offset:/^\s*/u.exec(e)[0].length,options:s.map(([o,a])=>({type:"variable",label:o+r,detail:a}))}:void 0},Kv),H=(t,e="")=>typeof e=="string"?t.map(i=>`.cm-mw-${e}${i}`).join():e.map(i=>H(t,i)).join(),gc=(t,e)=>e?`${t}${e===1?"":e}-`:"",ge=(t,e,i,r,n)=>({[t.map(([s,o,a])=>`.cm-mw-${gc("template",s)}${gc("exttag",o)}${gc("link",a)}ground`).join()]:{backgroundColor:`rgb(${e},${i},${r},${n})`}}),q2=x.theme({[H(["","~*"],"section--1")]:{fontSize:"1.8em",lineHeight:"1.2em"},[H(["","~*"],"section--2")]:{fontSize:"1.5em",lineHeight:"1.2em"},[H(["3~*","4~*","5~*","6~*"],"section--")]:{fontWeight:"bold"},[`${H(["section-header","template","parserfunction","file-delimiter","magic-link"])},${H(["pagename","bracket","delimiter"],"link-")},${H(["extlink"],["","free-"])},${H(["bracket","attribute"],["exttag-","htmltag-"])},${H(["delimiter2","definition"],"table-")}`]:{fontWeight:"normal"},[`${H(["redirect","list","free-extlink-protocol","strong"])},${H(["protocol","bracket"],"extlink-")},${H(["tag-name"],["ext","html"])},${H(["bracket","delimiter","th","caption"],"table-")},${H(["bracket","delimiter"],"convert-")}`]:{fontWeight:"bold"},[`${H(["pagename","link-tosection","magic-link"])},${H(["extlink","extlink-protocol"],["","free-"])}`]:{textDecoration:"underline"},".cm-mw-em":{fontStyle:"italic"},[H(["section-header","redirect","list","apostrophes"])]:{color:"var(--cm-hr)"},".cm-mw-error":{color:"var(--cm-error)"},".cm-mw-skipformatting":{backgroundColor:"var(--cm-sp)"},[H(["double-underscore","signature","hr"])]:{color:"var(--cm-hr)",fontWeight:"bold",backgroundColor:"var(--cm-hr-bg)"},[H(["comment","ignored"])]:{color:"var(--cm-comment)",fontWeight:"normal"},[H(["name","delimiter","bracket"],"template-")]:{color:"var(--cm-tpl)",fontWeight:"bold"},".cm-mw-template-argument-name":{color:"var(--cm-arg)",fontWeight:"normal"},".cm-mw-templatevariable":{color:"var(--cm-var)",fontWeight:"normal"},[H(["name","bracket","delimiter"],"templatevariable-")]:{color:"var(--cm-var-name)",fontWeight:"bold"},[H(["name","bracket","delimiter"],"parserfunction-")]:{color:"var(--cm-func)",fontWeight:"bold"},[`${H(["pagename","bracket","delimiter"],"link-")},${H(["file-delimiter","magic-link"])},${H(["","-protocol","-bracket"],"extlink")},${H(["","-protocol"],"free-extlink")}`]:{color:"var(--cm-link)"},[H(["image-parameter","link-tosection"])]:{color:"var(--cm-sect)",fontWeight:"normal"},[H(["name","bracket","attribute"],["exttag-","htmltag-"])]:{color:"var(--cm-tag)"},[H(["tag-attribute-value"],["ext","html"])]:{color:"var(--cm-attr)",fontWeight:"normal"},[H(["bracket","delimiter","delimiter2","definition"],"table-")]:{color:"var(--cm-table)"},".cm-mw-table-definition-value":{color:"var(--cm-table-attr)",fontWeight:"normal"},[H(["bracket","delimiter","flag","lang"],"convert-")]:{color:"var(--cm-convert)"},".cm-mw-entity":{color:"var(--cm-entity)"},".cm-mw-exttag":{backgroundColor:"rgb(119,0,170,.04)"},...ge([[1]],170,17,17,.04),...ge([[2]],170,17,17,.08),...ge([[3]],170,17,17,.12),...ge([[1,1],[,1]],119,0,170,.04),...ge([[1,2],[,2]],119,0,170,.08),...ge([[1,3],[,3]],119,0,170,.12),...ge([[1,,1],[,1,1],[,,1]],34,17,153,.04),...ge([[1,1,1],[,2,1]],77,9,162,.08),...ge([[1,2,1],[,3,1]],91,6,164,.12),...ge([[1,3,1]],98,4,166,.16),...ge([[2,1]],145,9,94,.08),...ge([[2,2]],136,6,119,.12),...ge([[2,3]],132,4,132,.16),...ge([[2,,1]],102,17,85,.08),...ge([[2,1,1]],108,11,113,.12),...ge([[2,2,1]],111,9,128,.16),...ge([[2,3,1]],112,7,136,.2),...ge([[3,1]],153,11,68,.12),...ge([[3,2]],145,9,94,.16),...ge([[3,3]],139,7,109,.2),...ge([[3,,1]],125,17,62,.12),...ge([[3,1,1]],123,13,89,.16),...ge([[3,2,1]],122,10,105,.2),...ge([[3,3,1]],122,9,116,.24),[H(["pre","nowiki"],"tag-")]:{backgroundColor:"rgb(0,0,0,.04)"},".cm-mw-tag-ref":{backgroundColor:"var(--cm-ref)"},[`${Km}, &[dir="rtl"] .cm-mw-template-name`]:{unicodeBidi:"isolate"},[Jm]:{direction:"ltr",display:"inline-block"}}),bb=t=>{const e=new E2(t),i=Np.define(e.mediawiki()),r=jl(eo.define(e.getTagStyles()));return new Et(i,[r,q2])},D2=tg?"metaKey":"ctrlKey",vb=tg?"Meta":"Control",Y2=["extLinkProtocol","extLink","freeExtLinkProtocol","freeExtLink","magicLink","pageName"],V2=["extlink-protocol","extlink","free-extlink-protocol","free-extlink","magic-link"],bc=".cm-mw-pagename",_2=["template-name","link-pagename",`parserfunction${bc}`,`exttag-attribute-value${bc}`,`file-text${bc}`],vc=t=>{for(const e of document.querySelectorAll(".cm-content"))t?e.style.setProperty("--codemirror-cursor","pointer"):e.style.removeProperty("--codemirror-cursor")};(Jv=globalThis.document)==null||Jv.addEventListener("keydown",t=>{t.key===vb&&vc(!0)}),(ey=globalThis.document)==null||ey.addEventListener("keyup",t=>{t.key===vb&&vc()}),(ty=globalThis.document)==null||ty.addEventListener("visibilitychange",()=>{document.hidden&&vc()});var yb=t=>t.startsWith("//")?location.protocol+t:t,B2=(t,e,i)=>{if(!t[D2]||!(t.target instanceof Element&&getComputedStyle(t.target).textDecorationLine==="underline"))return;const r=e.posAtCoords(t);if(!r)return;const{state:n}=e,s=fi(n,r);if(!s)return;let o=s.resolve(r,-1);o.name.includes($.linkToSection)?o=o.prevSibling:Se(new Set(o.name.split("_")),Y2)||(o=s.resolve(r,1));const{name:a,from:l,to:h}=o;if(a.includes($.pageName)&&typeof(i==null?void 0:i.titleParser)=="function")return i.titleParser(n,o);if(a.includes("-extlink-protocol"))return yb(n.sliceDoc(l,o.nextSibling.to));if(/-extlink(?:_|$)/u.test(a))return yb(n.sliceDoc(o.prevSibling.from,h));if(a.includes($.magicLink)){const c=n.sliceDoc(l,h);if(c.startsWith("RFC"))return`https://datatracker.ietf.org/doc/html/rfc${c.slice(3).trim()}`;if(c.startsWith("PMID"))return`https://pubmed.ncbi.nlm.nih.gov/${c.slice(4).trim()}`;if(typeof(i==null?void 0:i.isbnParser)=="function")return i.isbnParser(c)}},L2=({langConfig:t})=>[x.domEventHandlers({mousedown(e,i){if(e.button!==0)return;const r=B2(e,i,t);if(r)return open(r,"_blank","noopener noreferrer"),!0}}),x.theme({[[...V2,...t!=null&&t.titleParser?_2:[]].map(e=>`.cm-mw-${e}`).join()]:{cursor:"var(--codemirror-cursor)"}})],j2=new WeakMap,Sb=".cm-tooltip-ref",kb=".cm-tooltip-no-def",wb=(t,{from:e,to:i})=>t.sliceDoc(e,i).trim(),z2=t=>[cl(async(e,i,r)=>{var o,a;const{state:n}=e,s=(o=fi(n,i))==null?void 0:o.resolve(i,r);if(s&&/-exttag-(?!bracket)/u.test(s.name)){const l=Qn(n,s);if(!l)return null;const{name:h,selfClosing:c,first:f,last:u,to:d}=l;if(h==="ref"&&c){let p=u,O=null;for(;p&&p.from>f.to;){const g=wb(n,p);if(p.name.split("_").includes($.extTagAttribute)&&/(?:^|\s)name(?:$|[\s=])/iu.test(g)){/(?:^|\s)name\s*=/iu.test(g)&&({nextSibling:O}=p);break}({prevSibling:p}=p)}if(O!=null&&O.name.includes($.extTagAttributeValue)){let g=wb(n,O);const b=g.charAt(0);if((b==='"'||b==="'")&&(g=g.slice(1,g.slice(-1)===b?-1:void 0).trim()),g){const{doc:y}=n,v=await((a=Ut(e,!1,t.getWikiConfig))==null?void 0:a.provideDefinition(y.toString(),Mn(y,f.to)));return{pos:i,end:d,above:!0,create(){const S=Y("div",{class:Sb.slice(1)});if(S.style.font=getComputedStyle(e.contentDOM).font,v){const{range:{start:w,end:X}}=v[0],P=Oi(y,w),D=Oi(y,X),_=n.sliceDoc(P,D);let q="";Nw(_,n.facet(nt).parser.parse(_),{style(W){return Sx(n,W)}},(W,M)=>{const z=Wn(W);q+=M?`<span class="${M}">${z}</span>`:z},()=>{q+="<br>"}),S.innerHTML=q,S.addEventListener("click",()=>{e.dispatch({selection:{anchor:P,head:D},scrollIntoView:!0}),e.focus()})}else S.textContent=n.phrase("No definition found"),S.classList.add(kb.slice(1));return{dom:S}}}}}}}return null}),x.updateListener.of(({view:e,docChanged:i})=>{if(i){const r=j2.get(e);r&&(r.docChanged=!0)}}),x.theme({[Sb]:{padding:"2px 5px",width:"max-content",maxWidth:"60vw",cursor:"pointer",whiteSpace:"pre-wrap"},[kb]:{color:"var(--cm-comment)"}})],yc=B.define(),Sc=ve.define({create(){},update(t,{state:{doc:e,selection:{main:{head:i}}},effects:r}){const n=e.toString();for(const s of r)if(s.is(yc)){const{value:o}=s;if(i===o.cursor&&n===o.text)return o}return t}}),N2=t=>[Sc,x.updateListener.of(({view:e,state:i,docChanged:r,selectionSet:n})=>{var s,o;if(r||n&&((o=(s=i.field(Sc))==null?void 0:s.signatureHelp)!=null&&o.signatures.length)){const{doc:a,selection:{main:l}}=i,{head:h}=l,c=a.toString();if(!l.empty){e.dispatch({effects:yc.of({text:c,cursor:h})});return}(async()=>{var f;e.dispatch({effects:yc.of({text:c,cursor:h,signatureHelp:await((f=Ut(e,!1,t.getWikiConfig))==null?void 0:f.provideSignatureHelp(c,Mn(a,h)))})})})()}}),ir.from(Sc,e=>{if(!e)return null;const{cursor:i,signatureHelp:r}=e;if(!r||r.signatures.length===0)return null;const{signatures:n,activeParameter:s}=r;return{pos:i,above:!0,create(o){return P0(o,n.map(({label:a,parameters:l,activeParameter:h=s})=>{const c=Wn(a);if(h<0||h>=l.length)return c;const f=c.indexOf(":"),u=c.slice(f+1,-2).split("|");return u[h]=`<b>${u[h]}</b>`,`${c.slice(0,f)}:${u.join("|")}}}`}).join("<br>"))}}})],I2={onlyinclude:"mediawiki",includeonly:"mediawiki",noinclude:"mediawiki",translate:"mediawiki",tvar:"mediawiki",pre:"text/pre",nowiki:"text/nowiki",indicator:"mediawiki",poem:"mediawiki",ref:"mediawiki",references:"text/references",gallery:"text/gallery",poll:"mediawiki",tabs:"mediawiki",tab:"mediawiki",choose:"text/choose",option:"mediawiki",combobox:"text/combobox",combooption:"mediawiki",inputbox:"text/inputbox"},G2=({variable:t,parserFunction:[e,i,...r],protocol:n,nsid:s,functionHook:o,variants:a,redirection:l,ext:h,doubleUnderscore:[c,f,u,d],img:p},O)=>({tags:Object.fromEntries(h.map(g=>[g,!0])),tagModes:O,doubleUnderscore:[Object.fromEntries((u&&c.length===0?Object.keys(u):c).map(g=>[cc(g)?`__${g}__`:g,!0])),Object.fromEntries((d&&f.length===0?Object.keys(d):f).map(g=>[cc(g)?`__${g}__`:g,!0]))],functionHooks:o,variableIDs:t,functionSynonyms:[{...e,...Object.fromEntries(r.flat().map(g=>[g,g]))},{...i}],urlProtocols:`${n}|//`,nsid:s,img:Object.fromEntries(Object.entries(p).map(([g,b])=>[g,`img_${b}`])),variants:a,redirection:l}),kc=".cm-panel-status",qn=".cm-status-worker",xb=".cm-status-error",Qb=".cm-status-warning",Mo=".cm-status-fix-enabled",Eo=".cm-status-fix-disabled",qo="cm-status-worker-enabled",$b="cm-status-line";function wc(t,e,i){const r=Y("div",{class:`cm-status-${e}`}),n=Y("div");return e==="fix"?(n.className=Eo.slice(1),r.title="Fix all",r.append(n),i&&r.addEventListener("click",({clientX:s,clientY:o})=>{if(n.className===Mo.slice(1)){const{bottom:a,left:l}=t.dom.getBoundingClientRect();i.style.bottom=`${a-o+5}px`,i.style.left=`${s-20-l}px`,i.style.display="block",i.focus()}})):(n.className=`cm-lint-marker-${e}`,r.append(n,Y("div","0")),r.addEventListener("click",()=>{var s;(s=r.parentElement)!=null&&s.classList.contains(qo)&&(t0(t),t.focus())})),r}var Pb=(t,e,i)=>{i.lastChild.textContent=String(t.filter(({severity:r})=>r===e).length)},Tb=(t,e)=>{t.toggle(Mo.slice(1),e),t.toggle(Eo.slice(1),!e)},Cb=(t,e)=>t.filter(({from:i,to:r})=>i<=e.to&&r>=e.from),Zb=(t,e,i,r)=>{var s;const n=Cb(e,i);if(n.length===0)r.textContent="";else{const o=(s=n.find(({from:l,to:h})=>l<=i.head&&h>=i.head))!=null?s:n[0],a=t.view;r.textContent=o.message,o.actions&&r.append(...o.actions.map(({name:l,apply:h})=>{const c=Y("button",{type:"button",class:Ah.slice(1)},l);return c.addEventListener("click",f=>{f.preventDefault(),h(a,o.from,o.to)}),c}))}},Ab=(t,e,i,r,n,s,o)=>{if(s){const a=Jh.filter(({name:f,isActionable:u})=>t.hasPreference(f)&&u(t)),l=new Set(o&&Cb(e,i).filter(({actions:f})=>f==null?void 0:f.some(({name:u})=>u==="fix"||u!=="Fix: Stylelint"&&u.startsWith("Fix:"))).map(({message:f})=>{var u;return(u=/ \(([^()]+)\)$/u.exec(f))==null?void 0:u[1]}).filter(f=>f!==void 0));if(a.length===0&&l.size===0){Tb(r,!1);return}Tb(r,!0);const h=a.flatMap(({getItems:f})=>f(t)),c=[...l].map(f=>{const u=Y("div",`Fix all ${f} problems`);return u.dataset.rule=f,u});l.size>0&&c.push(n),s.replaceChildren(...h,...c)}},U2=(t,e)=>[rr.of(i=>{let r=[],n;!i.state.readOnly&&(e||Jh.length>0)&&(n=Y("div",{class:kr.slice(1),tabIndex:-1}),e&&n.addEventListener("click",({target:p})=>{p!==n&&(async()=>{const{doc:O}=i.state,g=await e(O,p.dataset.rule);g!==O.toString()&&i.dispatch({changes:{from:0,to:O.length,insert:g}}),i.focus()})()}),n.addEventListener("focusout",()=>{n.style.display="none"}),i.dom.append(n));const s=wc(i,"error"),o=wc(i,"warning"),a=wc(i,"fix",n),l=Y("div","Fix all auto-fixable problems"),h=Y("div",{class:qn.slice(1)},s,o,a),c=Y("div",{class:xn.slice(1)}),f=Y("div",{class:$b},"0:0"),u=Y("div",{class:`${po.slice(1)} ${kc.slice(1)}`},h,c,f),{classList:d}=a.firstChild;return{dom:u,update({state:{selection:{main:p},doc:O},transactions:g,docChanged:b,selectionSet:y}){for(const v of g)for(const S of v.effects)S.is(Zn)&&(r=S.value,h.classList.toggle(qo,r.length>0),Pb(r,"error",s),Pb(r,"warning",o),Zb(t,r,p,c),Ab(t,r,p,d,l,n,e));if(b||y){Zb(t,r,p,c),Ab(t,r,p,d,l,n,e);const{number:v,from:S}=O.lineAt(p.head);f.textContent=`${v}:${p.head-S}`,p.empty||(f.textContent+=` (${p.to-p.from})`)}}}}),x.theme({[kc]:{lineHeight:1.4},[`${kc}>div`]:{padding:"0 .3em",display:"table-cell"},[qn]:{WebkitUserSelect:"none",userSelect:"none","--fix-icon":`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><path d="M8 19a1 1 0 001 1h2a1 1 0 001-1v-1H8zm9-12a7 7 0 10-12 4.9S7 14 7 15v1a1 1 0 001 1h4a1 1 0 001-1v-1c0-1 2-3.1 2-3.1A7 7 0 0017 7"/></svg>')`},[`${qn}>*`]:{display:"table-cell",whiteSpace:"nowrap"},[`${xb},${Qb}`]:{paddingRight:"8px"},[`.${qo} ${xb},.${qo} ${Qb}`]:{cursor:"pointer"},[`${qn}>*>div`]:{display:"inline-block",verticalAlign:"middle"},[`${qn}>*>div:first-child`]:{marginRight:"4px",width:"1em",height:"1em"},[`${Eo},${Mo}`]:{WebkitMaskImage:"var(--fix-icon)",maskImage:"var(--fix-icon)",WebkitMaskSize:"100%",maskSize:"100%",WebkitMaskRepeat:"no-repeat",maskRepeat:"no-repeat",WebkitMaskPosition:"center",maskPosition:"center"},[Eo]:{backgroundColor:"#dadde3"},[Mo]:{backgroundColor:"#ffce31",cursor:"pointer"},[kr]:{display:"none",position:"absolute",zIndex:301,border:"1px solid #ddd",borderRadius:"2px",outline:"none",whiteSpace:"nowrap"},[`${kr}>div`]:{padding:"1px 5px",cursor:"pointer"},[xn]:{borderStyle:"solid",borderWidth:"0 1px",width:"100%"},[`${xn} ${Ah}`]:{paddingTop:0,paddingBottom:0},[`.${$b}`]:{whiteSpace:"nowrap"},[Um]:{cursor:"pointer"}})],xc=t=>Gt.data.of({autocomplete(e){const{state:i,pos:r}=e,n=I(i).resolveInner(r,-1),s=im(e);if(s)if(n.name==="ValueName"){const o=[{label:"revert",type:"keyword"},...s.options];let{prevSibling:a}=n;for(;a&&a.name!=="PropertyName";)({prevSibling:a}=a);if(a)for(let l=0;l<o.length;l++){const h=o[l];CSS.supports(i.sliceDoc(a.from,n.from)+h.label)&&o.splice(l,1,{...h,boost:50})}s.options=o}else t==="sanitized-css"&&(s.options=s.options.filter(({type:o,label:a})=>o!=="property"||!a.startsWith("-")||a.endsWith("-user-select")));return s}}),F2=t=>new Et(Gt,xc(t)),Qc=_e.data.of({autocomplete:_P(globalThis)}),H2=()=>[fo(),Qc],K2=t=>{const{language:e,support:i}=bb(t),r=new Et(di.configure({wrap:uh([{tag:"script",parser:_e.parser},{tag:"style",parser:Gt.parser},{tag:"noinclude",parser:e.parser}],[{name:"style",parser:Gt.parser.configure({top:"Styles"})}])}),[di.data.of({autocomplete:wm({extraTags:{noinclude:{globalAttrs:!1}}})}),fo().support,Qc,xc(),i]);return Object.assign(r,{nestedMWLanguage:e}),r};function J2(t){return new RegExp("^(?:"+t.join("|")+")","i")}function Do(t){return new RegExp("^(?:"+t.join("|")+")$","i")}var eA=Do(["_G","_VERSION","assert","collectgarbage","dofile","error","getfenv","getmetatable","ipairs","load","loadfile","loadstring","module","next","pairs","pcall","print","rawequal","rawget","rawset","require","select","setfenv","setmetatable","tonumber","tostring","type","unpack","xpcall","coroutine.create","coroutine.resume","coroutine.running","coroutine.status","coroutine.wrap","coroutine.yield","debug.debug","debug.getfenv","debug.gethook","debug.getinfo","debug.getlocal","debug.getmetatable","debug.getregistry","debug.getupvalue","debug.setfenv","debug.sethook","debug.setlocal","debug.setmetatable","debug.setupvalue","debug.traceback","close","flush","lines","read","seek","setvbuf","write","io.close","io.flush","io.input","io.lines","io.open","io.output","io.popen","io.read","io.stderr","io.stdin","io.stdout","io.tmpfile","io.type","io.write","math.abs","math.acos","math.asin","math.atan","math.atan2","math.ceil","math.cos","math.cosh","math.deg","math.exp","math.floor","math.fmod","math.frexp","math.huge","math.ldexp","math.log","math.log10","math.max","math.min","math.modf","math.pi","math.pow","math.rad","math.random","math.randomseed","math.sin","math.sinh","math.sqrt","math.tan","math.tanh","os.clock","os.date","os.difftime","os.execute","os.exit","os.getenv","os.remove","os.rename","os.setlocale","os.time","os.tmpname","package.cpath","package.loaded","package.loaders","package.loadlib","package.path","package.preload","package.seeall","string.byte","string.char","string.dump","string.find","string.format","string.gmatch","string.gsub","string.len","string.lower","string.match","string.rep","string.reverse","string.sub","string.upper","table.concat","table.insert","table.maxn","table.remove","table.sort"]),tA=Do(["and","break","elseif","false","nil","not","or","return","true","function","end","if","then","else","do","while","repeat","until","for","in","local"]),iA=Do(["function","if","repeat","do","\\(","{"]),rA=Do(["end","until","\\)","}"]),nA=J2(["end","until","\\)","}","else","elseif"]);function Rb(t){for(var e=0;t.eat("=");)++e;return t.eat("["),e}function $c(t,e){var i=t.next();return i=="-"&&t.eat("-")?t.eat("[")&&t.eat("[")?(e.cur=Xb(Rb(t),"comment"))(t,e):(t.skipToEnd(),"comment"):i=='"'||i=="'"?(e.cur=sA(i))(t,e):i=="["&&/[\[=]/.test(t.peek())?(e.cur=Xb(Rb(t),"string"))(t,e):/\d/.test(i)?(t.eatWhile(/[\w.%]/),"number"):/[\w_]/.test(i)?(t.eatWhile(/[\w\\\-_.]/),"variable"):null}function Xb(t,e){return function(i,r){for(var n=null,s;(s=i.next())!=null;)if(n==null)s=="]"&&(n=0);else if(s=="=")++n;else if(s=="]"&&n==t){r.cur=$c;break}else n=null;return e}}function sA(t){return function(e,i){for(var r=!1,n;(n=e.next())!=null&&!(n==t&&!r);)r=!r&&n=="\\";return r||(i.cur=$c),"string"}}var Wb={name:"lua",startState:function(){return{basecol:0,indentDepth:0,cur:$c}},token:function(t,e){if(t.eatSpace())return null;var i=e.cur(t,e),r=t.current();return i=="variable"&&(tA.test(r)?i="keyword":eA.test(r)&&(i="builtin")),i!="comment"&&i!="string"&&(iA.test(r)?++e.indentDepth:rA.test(r)&&--e.indentDepth),i},indent:function(t,e,i){var r=nA.test(e);return t.basecol+i.unit*(t.indentDepth-(r?1:0))},languageData:{indentOnInput:/^\s*(?:end|until|else|\)|\})$/,commentTokens:{line:"--",block:{open:"--[[",close:"]]--"}}}},oA={1:"constant",2:"function",3:"interface",4:"namespace"},Mb={debug:{traceback:2},math:{abs:2,acos:2,asin:2,atan:2,atan2:2,ceil:2,cos:2,cosh:2,deg:2,exp:2,floor:2,fmod:2,frexp:2,huge:1,ldexp:2,log:2,log10:2,max:2,min:2,modf:2,pi:1,pow:2,rad:2,random:2,randomseed:2,sin:2,sinh:2,sqrt:2,tan:2,tanh:2},os:{clock:2,date:2,difftime:2,time:2},package:{loaded:3,loaders:3,preload:3,seeall:2},string:{byte:2,char:2,find:2,format:2,gmatch:2,gsub:2,len:2,lower:2,match:2,rep:2,reverse:2,sub:2,ulower:2,upper:2,uupper:2},table:{concat:2,insert:2,maxn:2,remove:2,sort:2},mw:{addWarning:2,allToString:2,clone:2,getCurrentFrame:2,incrementExpensiveFunctionCount:2,isSubsting:2,loadData:2,loadJsonData:2,dumpObject:2,log:2,logObject:2,hash:{hashValue:2,listAlgorithms:2},html:{create:2},language:{fetchLanguageName:2,fetchLanguageNames:2,getContentLanguage:2,getFallbacksFor:2,isKnownLanguageTag:2,isSupportedLanguage:2,isValidBuiltInCode:2,isValidCode:2,new:2,FALLBACK_MESSAGES:1,FALLBACK_STRICT:1},message:{new:2,newFallbackSequence:2,newRawMessage:2,rawParam:2,numParam:2,getDefaultLanguage:2},site:{currentVersion:1,scriptPath:1,server:1,siteName:1,stylePath:1,namespaces:3,contentNamespaces:3,subjectNamespaces:3,talkNamespaces:3,stats:{pages:1,articles:1,files:1,edits:1,users:1,activeUsers:1,admins:1,pagesInCategory:2,pagesInNamespace:2,usersInGroup:2,interwikiMap:2}},svg:{new:2},text:{decode:2,encode:2,jsonDecode:2,jsonEncode:2,killMarkers:2,listToText:2,nowiki:2,split:2,gsplit:2,tag:2,trim:2,truncate:2,unstripNoWiki:2,unstrip:2,JSON_PRESERVE_KEYS:1,JSON_TRY_FIXING:1,JSON_PRETTY:1},title:{equals:2,compare:2,getCurrentTitle:2,new:2,newBatch:2,makeTitle:2},uri:{encode:2,decode:2,anchorEncode:2,buildQueryString:2,parseQueryString:2,canonicalUrl:2,fullUrl:2,localUrl:2,new:2,validate:2},ustring:{maxPatternLength:1,maxStringLength:1,byte:2,byteoffset:2,char:2,codepoint:2,find:2,format:2,gcodepoint:2,gmatch:2,gsub:2,isutf8:2,len:2,lower:2,match:2,rep:2,sub:2,toNFC:2,toNFD:2,toNFKC:2,toNFKD:2,upper:2},ext:4}},Eb=["false","nil","true"],Pc=Eb.map(t=>({label:t,type:"constant"})),Dn=["_G",...Object.keys(Mb)].map(t=>({label:t,type:"namespace"})),Yo=[{label:"_VERSION",type:"constant"},...["assert","error","getfenv","getmetatable","ipairs","next","pairs","pcall","rawequal","rawget","rawset","select","setmetatable","tonumber","tostring","type","unpack","xpcall","require"].map(t=>({label:t,type:"function"}))],qb=["and","or","in"].map(t=>({label:t,type:"keyword"})),Tc=[...["not","function"].map(t=>({label:t,type:"keyword"})),ye("function ${name}(${})\n ${}\nend",{label:"function",detail:"definition",type:"keyword"})],Vo=["break","elseif","return","end","then","else","do","until","goto"].map(t=>({label:t,type:"keyword"})),aA=[...["if","while","repeat","for","local"].map(t=>({label:t,type:"keyword"})),ye("if ${condition} then\n ${}\nend",{label:"if",detail:"block",type:"keyword"}),ye(`if \${condition} then
|
|
36
36
|
\${}
|
|
37
37
|
else
|
|
38
38
|
\${}
|