| 82 | ;s[n[0]]=[e,I(n[0],n[1])]}))}}function I(e,t){ |
| 83 | return t?Number(t):(e=>L.includes(e.toLowerCase()))(e)?0:1} |
| 84 | function T(e,{plugins:t}){function n(t,n){ |
| 85 | return RegExp(u(t),"m"+(e.case_insensitive?"i":"")+(n?"g":""))}class s{ |
| 86 | constructor(){ |
| 87 | this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0} |
| 88 | addRule(e,t){ |
| 89 | t.position=this.position++,this.matchIndexes[this.matchAt]=t,this.regexes.push([t,e]), |
| 90 | this.matchAt+=(e=>RegExp(e.toString()+"|").exec("").length-1)(e)+1}compile(){ |
| 91 | 0===this.regexes.length&&(this.exec=()=>null) |
| 92 | ;const e=this.regexes.map((e=>e[1]));this.matcherRe=n(((e,t="|")=>{ |
| 93 | const n=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;let s=0,r="" |
| 94 | ;for(let a=0;a<e.length;a++){s+=1;const i=s;let o=u(e[a]) |
| 95 | ;for(a>0&&(r+=t),r+="(";o.length>0;){const e=n.exec(o);if(null==e){r+=o;break} |
| 96 | r+=o.substring(0,e.index), |
| 97 | o=o.substring(e.index+e[0].length),"\\"===e[0][0]&&e[1]?r+="\\"+(Number(e[1])+i):(r+=e[0], |
| 98 | "("===e[0]&&s++)}r+=")"}return r})(e),!0),this.lastIndex=0}exec(e){ |
| 99 | this.matcherRe.lastIndex=this.lastIndex;const t=this.matcherRe.exec(e) |
| 100 | ;if(!t)return null |
| 101 | ;const n=t.findIndex(((e,t)=>t>0&&void 0!==e)),s=this.matchIndexes[n] |
| 102 | ;return t.splice(0,n),Object.assign(t,s)}}class r{constructor(){ |
| 103 | this.rules=[],this.multiRegexes=[], |
| 104 | this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){ |
| 105 | if(this.multiRegexes[e])return this.multiRegexes[e];const t=new s |
| 106 | ;return this.rules.slice(e).forEach((([e,n])=>t.addRule(e,n))), |
| 107 | t.compile(),this.multiRegexes[e]=t,t}resumingScanAtSamePosition(){ |
| 108 | return 0!==this.regexIndex}considerAll(){this.regexIndex=0}addRule(e,t){ |
| 109 | this.rules.push([e,t]),"begin"===t.type&&this.count++}exec(e){ |
| 110 | const t=this.getMatcher(this.regexIndex);t.lastIndex=this.lastIndex |
| 111 | ;let n=t.exec(e) |
| 112 | ;if(this.resumingScanAtSamePosition())if(n&&n.index===this.lastIndex);else{ |
| 113 | const t=this.getMatcher(0);t.lastIndex=this.lastIndex+1,n=t.exec(e)} |
| 114 | return n&&(this.regexIndex+=n.position+1, |
| 115 | this.regexIndex===this.count&&this.considerAll()),n}} |
| 116 | if(e.compilerExtensions||(e.compilerExtensions=[]), |
| 117 | e.contains&&e.contains.includes("self"))throw Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.") |
| 118 | ;return e.classNameAliases=a(e.classNameAliases||{}),function t(s,i){const o=s |
| 119 | ;if(s.compiled)return o |
| 120 | ;[M].forEach((e=>e(s,i))),e.compilerExtensions.forEach((e=>e(s,i))), |
| 121 | s.__beforeBegin=null,[k,O,A].forEach((e=>e(s,i))),s.compiled=!0;let l=null |
| 122 | ;if("object"==typeof s.keywords&&(l=s.keywords.$pattern, |
| 123 | delete s.keywords.$pattern), |
| 124 | s.keywords&&(s.keywords=B(s.keywords,e.case_insensitive)), |
| 125 | s.lexemes&&l)throw Error("ERR: Prefer `keywords.$pattern` to `mode.lexemes`, BOTH are not allowed. (see mode reference) ") |
| 126 | ;return l=l||s.lexemes||/\w+/, |
| 127 | o.keywordPatternRe=n(l,!0),i&&(s.begin||(s.begin=/\B|\b/), |
| 128 | o.beginRe=n(s.begin),s.endSameAsBegin&&(s.end=s.begin), |
| 129 | s.end||s.endsWithParent||(s.end=/\B|\b/), |
| 130 | s.end&&(o.endRe=n(s.end)),o.terminatorEnd=u(s.end)||"", |
| 131 | s.endsWithParent&&i.terminatorEnd&&(o.terminatorEnd+=(s.end?"|":"")+i.terminatorEnd)), |
| 132 | s.illegal&&(o.illegalRe=n(s.illegal)), |
| 133 | s.contains||(s.contains=[]),s.contains=[].concat(...s.contains.map((e=>(e=>(e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map((t=>a(e,{ |
| 134 | variants:null},t)))),e.cachedVariants?e.cachedVariants:j(e)?a(e,{ |
| 135 | starts:e.starts?a(e.starts):null |
| 136 | }):Object.isFrozen(e)?a(e):e))("self"===e?s:e)))),s.contains.forEach((e=>{t(e,o) |
| 137 | })),s.starts&&t(s.starts,i),o.matcher=(e=>{const t=new r |
| 138 | ;return e.contains.forEach((e=>t.addRule(e.begin,{rule:e,type:"begin" |
| 139 | }))),e.terminatorEnd&&t.addRule(e.terminatorEnd,{type:"end" |
| 140 | }),e.illegal&&t.addRule(e.illegal,{type:"illegal"}),t})(o),o}(e)}function j(e){ |
| 141 | return!!e&&(e.endsWithParent||j(e.starts))}function S(e){const t={ |