solve-engine 2.0.0 → 2.1.0

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.
Files changed (55) hide show
  1. package/dist/{chunk-6KFVG6UY.cjs → chunk-2LFLR3VZ.cjs} +2 -2
  2. package/dist/chunk-2LFLR3VZ.cjs.map +1 -0
  3. package/dist/{chunk-LR4E4A4W.cjs → chunk-32GC2FHC.cjs} +2 -2
  4. package/dist/{chunk-LR4E4A4W.cjs.map → chunk-32GC2FHC.cjs.map} +1 -1
  5. package/dist/{chunk-XR7HEC7B.js → chunk-4E4YVQKK.js} +3 -3
  6. package/dist/{chunk-XR7HEC7B.js.map → chunk-4E4YVQKK.js.map} +1 -1
  7. package/dist/chunk-5FO4PDIG.js +2 -0
  8. package/dist/chunk-5FO4PDIG.js.map +1 -0
  9. package/dist/{chunk-SZGK6RIP.cjs → chunk-7BXPCWKM.cjs} +2 -2
  10. package/dist/{chunk-SZGK6RIP.cjs.map → chunk-7BXPCWKM.cjs.map} +1 -1
  11. package/dist/{chunk-EYRBENHC.js → chunk-E2Q3PQ2G.js} +3 -3
  12. package/dist/{chunk-EYRBENHC.js.map → chunk-E2Q3PQ2G.js.map} +1 -1
  13. package/dist/{chunk-UDQ57ZRX.cjs → chunk-EVI6OHQH.cjs} +2 -2
  14. package/dist/{chunk-UDQ57ZRX.cjs.map → chunk-EVI6OHQH.cjs.map} +1 -1
  15. package/dist/{chunk-UI6IFGBT.js → chunk-G7TBEQRQ.js} +2 -2
  16. package/dist/chunk-G7TBEQRQ.js.map +1 -0
  17. package/dist/{chunk-4J7XZSZJ.cjs → chunk-GK2OHWRF.cjs} +4 -4
  18. package/dist/{chunk-4J7XZSZJ.cjs.map → chunk-GK2OHWRF.cjs.map} +1 -1
  19. package/dist/{chunk-JSPKKNPQ.js → chunk-I52MYCVI.js} +3 -3
  20. package/dist/{chunk-JSPKKNPQ.js.map → chunk-I52MYCVI.js.map} +1 -1
  21. package/dist/{chunk-WN5CMP4T.cjs → chunk-JUIJ6NRD.cjs} +3 -3
  22. package/dist/{chunk-WN5CMP4T.cjs.map → chunk-JUIJ6NRD.cjs.map} +1 -1
  23. package/dist/{chunk-SUXRZWH2.cjs → chunk-OVKDDTXO.cjs} +3 -3
  24. package/dist/{chunk-SUXRZWH2.cjs.map → chunk-OVKDDTXO.cjs.map} +1 -1
  25. package/dist/{chunk-6CY44ZPG.js → chunk-TN5E6JU6.js} +2 -2
  26. package/dist/{chunk-6CY44ZPG.js.map → chunk-TN5E6JU6.js.map} +1 -1
  27. package/dist/{chunk-L3FPQSGN.js → chunk-U4AEVL5Z.js} +2 -2
  28. package/dist/{chunk-L3FPQSGN.js.map → chunk-U4AEVL5Z.js.map} +1 -1
  29. package/dist/chunk-VAGS5JS7.cjs +2 -0
  30. package/dist/chunk-VAGS5JS7.cjs.map +1 -0
  31. package/dist/{chunk-GOIQYUWV.js → chunk-YAHGSBMC.js} +2 -2
  32. package/dist/{chunk-GOIQYUWV.js.map → chunk-YAHGSBMC.js.map} +1 -1
  33. package/dist/constants.cjs +1 -1
  34. package/dist/constants.js +1 -1
  35. package/dist/engine.cjs +1 -1
  36. package/dist/engine.js +1 -1
  37. package/dist/index.cjs +1 -1
  38. package/dist/index.js +1 -1
  39. package/dist/lexer.cjs +1 -1
  40. package/dist/lexer.js +1 -1
  41. package/dist/normalizer.cjs +1 -1
  42. package/dist/normalizer.js +1 -1
  43. package/dist/packages.cjs +1 -1
  44. package/dist/packages.js +1 -1
  45. package/dist/testing.cjs +2 -2
  46. package/dist/testing.js +1 -1
  47. package/dist/worker.cjs +2 -2
  48. package/dist/worker.js +1 -1
  49. package/package.json +1 -1
  50. package/dist/chunk-6KFVG6UY.cjs.map +0 -1
  51. package/dist/chunk-APN442VD.cjs +0 -2
  52. package/dist/chunk-APN442VD.cjs.map +0 -1
  53. package/dist/chunk-QXQE7X4S.js +0 -2
  54. package/dist/chunk-QXQE7X4S.js.map +0 -1
  55. package/dist/chunk-UI6IFGBT.js.map +0 -1
@@ -1,2 +1,2 @@
1
- 'use strict';var chunk5IJD5L3O_cjs=require('./chunk-5IJD5L3O.cjs'),chunkMSYX32PF_cjs=require('./chunk-MSYX32PF.cjs'),chunkFWW3M36J_cjs=require('./chunk-FWW3M36J.cjs'),chunkSOMGSIO4_cjs=require('./chunk-SOMGSIO4.cjs');chunk5IJD5L3O_cjs.e();function g(){let c=new Uint8Array(128);for(let r=48;r<=57;r++)c[r]=2;for(let r=65;r<=90;r++)c[r]=3;for(let r=97;r<=122;r++)c[r]=3;return c[95]=3,c[46]=4,c[32]=1,c[9]=1,c[10]=1,c[13]=1,c[33]=5,c[37]=5,c[38]=5,c[40]=5,c[41]=5,c[42]=5,c[43]=5,c[44]=5,c[45]=5,c[47]=5,c[58]=5,c[59]=5,c[60]=5,c[61]=5,c[62]=5,c[63]=5,c[91]=5,c[93]=5,c[94]=5,c[123]=5,c[124]=5,c[125]=5,c[126]=5,c[64]=5,c[34]=6,c[35]=7,c[36]=8,c[96]=11,c}function w(c){return c===133||c===160||c===5760||c>=8192&&c<=8202||c===8203||c===8232||c===8233||c===8239||c===8287||c===12288||c===65279}var a=class{constructor(r,t,e,s,o,i,l,n,d){this.type=r;this.typeId=t;this.value=e;this.text=s;this.offset=o;this.lineBreaks=i;this.line=l;this.col=n;this.sourceEnd=d;}},E={61:{61:"EQUALITY",62:"THEREFORE"},33:{61:"NEQ"},62:{61:"GTE"},60:{61:"LTE"},38:{38:"LOGICAL_AND"},124:{124:"LOGICAL_OR"},43:{61:"PLUS_EQUALS"},45:{61:"MINUS_EQUALS"}},y={43:"PLUS",45:"MINUS",42:"STAR",47:"SLASH",94:"CARET",37:"PERCENT",40:"LPAREN",41:"RPAREN",91:"LBRACKET",93:"RBRACKET",123:"LBRACE",125:"RBRACE",44:"COMMA",58:"COLON",59:"SEMICOLON",61:"EQUALS",63:"QUESTION",33:"BANG",38:"BIT_AND",124:"BIT_OR",60:"LT",62:"GT",126:"BIT_NOT",64:"AT"},b=(()=>{let c=new Set;for(let t=48;t<=57;t++)c.add(t);let r=[43,45,42,47,94,37,40,41,91,93,123,125,61,60,62,33,38,124,126,59,63];for(let t of r)c.add(t);return c.add(36),c.add(163),c.add(8364),c.add(165),c.add(8381),c.add(8361),c.add(96),c.add(46),c.add(35),c})(),S=class S{constructor(r="en",t){this.configuredLookup=null;this.input="";this.pos=0;this.len=0;this.line=1;this.lineStartPos=0;this.groupingStack=[];this.pluginKeywordMap=new Map;this.pluginOperators=new Map;this.pluginUnits=new Set;this.hasPluginOps=false;this._inlineSolveSpans=[];this.pluginRawLinePatterns=[];this.pendingRawLineToken=null;this.localeCode=r,this.locale=chunkMSYX32PF_cjs.a(r),this.configuredLookup=t??null,this.keywordMap=new Map;for(let[e,s]of Object.entries(this.locale.keywordMap))this.keywordMap.set(e.toLowerCase(),s);this.mergedKeywords=new Map(this.keywordMap),this.mergedUnits=new Set(chunkFWW3M36J_cjs.a);}matchRawLine(r){for(let t of this.pluginRawLinePatterns){let e=t.pattern.exec(r);if(e&&typeof e[1]=="string"){let s=e[1].trim();if(s.length>0)return new a(t.tokenType,chunk5IJD5L3O_cjs.c(t.tokenType),s,s,0,0,this.line,1)}}return null}rebuildMergedCollections(){this.mergedKeywords=new Map([...this.keywordMap,...this.pluginKeywordMap]),this.mergedUnits=new Set([...chunkFWW3M36J_cjs.a,...this.pluginUnits]);}registerVocabulary(r){if(r.keywords){for(let[t,e]of Object.entries(r.keywords)){let s=t.toLowerCase();if(this.keywordMap.has(s))throw chunkSOMGSIO4_cjs.c.config("PLUGIN_KEYWORD_COLLISION",`Plugin keyword "${t}" conflicts with built-in keyword (type: ${this.keywordMap.get(s)}). Built-in keywords cannot be overridden.`,{keyword:t,builtinType:this.keywordMap.get(s)});this.pluginKeywordMap.set(s,e);}this.rebuildMergedCollections();}if(r.operators){this.hasPluginOps=true;for(let[t,e]of Object.entries(r.operators))if(t.length===2){let s=t.charCodeAt(0),o=t.charCodeAt(1),i=E[s];if(i&&i[o]!==void 0)throw chunkSOMGSIO4_cjs.c.config("PLUGIN_OPERATOR_COLLISION",`Plugin operator "${t}" conflicts with built-in operator (type: ${i[o]}). Built-in operators cannot be overridden.`,{operator:t,builtinType:i[o]});if(s===60&&o===60)throw chunkSOMGSIO4_cjs.c.config("PLUGIN_OPERATOR_COLLISION",`Plugin operator "${t}" conflicts with built-in operator (type: LSHIFT). Built-in operators cannot be overridden.`,{operator:t,builtinType:"LSHIFT"});if(s===62&&o===62)throw chunkSOMGSIO4_cjs.c.config("PLUGIN_OPERATOR_COLLISION",`Plugin operator "${t}" conflicts with built-in operator (type: RSHIFT). Built-in operators cannot be overridden.`,{operator:t,builtinType:"RSHIFT"});if(s===47&&o===47)throw chunkSOMGSIO4_cjs.c.config("PLUGIN_OPERATOR_COLLISION",`Plugin operator "${t}" conflicts with built-in comment sequence. Comment sequences cannot be overridden.`,{operator:t,builtinType:"COMMENT"});let l=this.pluginOperators.get(s);l||(l=new Map,this.pluginOperators.set(s,l)),l.set(o,e);}}if(r.units){for(let t of r.units){if(chunkFWW3M36J_cjs.a.has(t))throw chunkSOMGSIO4_cjs.c.config("PLUGIN_UNIT_COLLISION",`Plugin unit "${t}" conflicts with a built-in unit. Built-in units cannot be overridden.`,{unit:t});this.pluginUnits.add(t);}this.rebuildMergedCollections();}r.rawLinePatterns&&this.pluginRawLinePatterns.push(...r.rawLinePatterns);}unregisterVocabulary(r){if(r.keywords){for(let t of Object.keys(r.keywords))this.pluginKeywordMap.delete(t.toLowerCase());this.rebuildMergedCollections();}if(r.operators){for(let t of Object.keys(r.operators))if(t.length===2){let e=t.charCodeAt(0),s=t.charCodeAt(1),o=this.pluginOperators.get(e);o&&(o.delete(s),o.size===0&&this.pluginOperators.delete(e));}this.hasPluginOps=this.pluginOperators.size>0;}if(r.units){for(let t of r.units)this.pluginUnits.delete(t);this.rebuildMergedCollections();}if(r.rawLinePatterns){let t=new Set(r.rawLinePatterns);this.pluginRawLinePatterns=this.pluginRawLinePatterns.filter(e=>!t.has(e));}}reset(r){this.input=r,this.pos=0,this.len=r.length,this.line=1,this.lineStartPos=0,this.pendingRawLineToken=this.pluginRawLinePatterns.length>0?this.matchRawLine(r):null;}scanDocument(r){this.input=r,this.pos=0,this.len=r.length,this.line=1,this.lineStartPos=0;let t=[],e=this.input,s=this.len;for(;this.pos<s;){let o=this.pos,i=this.pos;for(;i<s;){let p=e.charCodeAt(i);if(p===10||p===13)break;i++;}let l=this.line,n=this.classifyFromPositions(o,i),d=e.slice(o,i),u=[];if(!n.skip){let p=this.pluginRawLinePatterns.length>0?this.matchRawLine(d):null;if(p)u=[p];else {let C=this.len;this.len=i,n.contentOffset!==void 0&&(this.pos=n.contentOffset),u=Array.from(this),this.len=C;}}let f=[];if(n.hasInlineSolve)if(!n.skip&&u.length>0){let p=this.findInlineSolves(d);f=this._inlineSolveSpans.map((C,R)=>({start:p[R]?.start??0,end:p[R]?.end??0,expression:p[R]?.expression??"",columnNumber:p[R]?.columnNumber??C.columnNumber,startTokenIndex:C.startTokenIndex,endTokenIndex:C.endTokenIndex}));}else f=this.findInlineSolves(d);if(t.push({text:d,lineNumber:l,startOffset:o,endOffset:i,classification:n,tokens:u,inlineSolves:f}),this.pos=i,this.pos<s){let p=e.charCodeAt(this.pos);p===13?(this.pos++,this.pos<s&&e.charCodeAt(this.pos)===10&&this.pos++):p===10&&this.pos++;}this.line++,this.lineStartPos=this.pos;}return t}tokenizeAll(){return this.pendingRawLineToken?(this._inlineSolveSpans=[],[this.pendingRawLineToken]):Array.from(this)}*[Symbol.iterator](){let r=this.len;if(r===0){this._inlineSolveSpans=[];return}let t=0,e=null,s=[];if(r===1){let i=this.input.charCodeAt(0);switch(S.CHAR_CLASS[i]??0){case 2:case 4:yield new a("NUMBER",chunk5IJD5L3O_cjs.c("NUMBER"),this.input,this.input,0,0,1,1),t++;break;case 3:{let n=this.input,d=n.toLowerCase();if(this.mergedUnits.has(n))yield new a("UNIT",chunk5IJD5L3O_cjs.c("UNIT"),n,n,0,0,1,1);else {let u=this.mergedKeywords.get(d);u?yield new a(u,chunk5IJD5L3O_cjs.c(u),n,n,0,0,1,1):yield new a("IDENT",chunk5IJD5L3O_cjs.c("IDENT"),n,n,0,0,1,1);}t++;break}case 5:{let n=y[i];n&&(yield new a(n,chunk5IJD5L3O_cjs.c(n),this.input,this.input,0,0,1,1),t++);break}case 6:this.pos=0,yield this.tokenizeString(),t++;break;case 7:this.pos=0,yield this.tokenizeComment(),t++;break;case 8:yield new a("DOLLAR",chunk5IJD5L3O_cjs.c("DOLLAR"),"$","$",0,0,1,1),t++;break;case 11:yield new a("BACKTICK_OPEN",chunk5IJD5L3O_cjs.c("BACKTICK_OPEN"),"`","`",0,0,1,1),t++;break;default:{w(i)||(i===215?(yield new a("STAR",chunk5IJD5L3O_cjs.c("STAR"),"\xD7","\xD7",0,0,1,1),t++):i===247?(yield new a("SLASH",chunk5IJD5L3O_cjs.c("SLASH"),"\xF7","\xF7",0,0,1,1),t++):i===177?(yield new a("PLUS_MINUS",chunk5IJD5L3O_cjs.c("PLUS_MINUS"),"\xB1","\xB1",0,0,1,1),t++):i===8800?(yield new a("NEQ",chunk5IJD5L3O_cjs.c("NEQ"),"\u2260","\u2260",0,0,1,1),t++):i===163?(yield new a("POUND",chunk5IJD5L3O_cjs.c("POUND"),"\xA3","\xA3",0,0,1,1),t++):i===8364?(yield new a("EURO",chunk5IJD5L3O_cjs.c("EURO"),"\u20AC","\u20AC",0,0,1,1),t++):i===165?(yield new a("YEN",chunk5IJD5L3O_cjs.c("YEN"),"\xA5","\xA5",0,0,1,1),t++):i===8381?(yield new a("RUBLE",chunk5IJD5L3O_cjs.c("RUBLE"),"\u20BD","\u20BD",0,0,1,1),t++):i===8361?(yield new a("WON",chunk5IJD5L3O_cjs.c("WON"),"\u20A9","\u20A9",0,0,1,1),t++):i===8377?(yield new a("CURRENCY_SYMBOL",chunk5IJD5L3O_cjs.c("CURRENCY_SYMBOL"),"\u20B9","\u20B9",0,0,1,1),t++):i===8378?(yield new a("CURRENCY_SYMBOL",chunk5IJD5L3O_cjs.c("CURRENCY_SYMBOL"),"\u20BA","\u20BA",0,0,1,1),t++):i===8372?(yield new a("CURRENCY_SYMBOL",chunk5IJD5L3O_cjs.c("CURRENCY_SYMBOL"),"\u20B4","\u20B4",0,0,1,1),t++):i===8362?(yield new a("CURRENCY_SYMBOL",chunk5IJD5L3O_cjs.c("CURRENCY_SYMBOL"),"\u20AA","\u20AA",0,0,1,1),t++):i===8363?(yield new a("CURRENCY_SYMBOL",chunk5IJD5L3O_cjs.c("CURRENCY_SYMBOL"),"\u20AB","\u20AB",0,0,1,1),t++):i===8358?(yield new a("CURRENCY_SYMBOL",chunk5IJD5L3O_cjs.c("CURRENCY_SYMBOL"),"\u20A6","\u20A6",0,0,1,1),t++):i===8369?(yield new a("CURRENCY_SYMBOL",chunk5IJD5L3O_cjs.c("CURRENCY_SYMBOL"),"\u20B1","\u20B1",0,0,1,1),t++):i>=128&&(yield new a("IDENT",chunk5IJD5L3O_cjs.c("IDENT"),this.input,this.input,0,0,1,1),t++));break}}this._inlineSolveSpans=s;return}let o=this.input;for(this.groupingStack.length=0;this.pos<r;){let i=o.charCodeAt(this.pos),l=S.CHAR_CLASS[i]??0;if(e&&i===92&&this.pos+1<r&&o.charCodeAt(this.pos+1)===96){this.pos+=2;continue}switch(l){case 1:this.pos++,i===10?(this.line++,this.lineStartPos=this.pos,this.groupingStack.length=0):i===13&&(this.line++,this.pos<r&&o.charCodeAt(this.pos)===10&&this.pos++,this.lineStartPos=this.pos,this.groupingStack.length=0);break;case 2:yield this.tokenizeNumber(),t++;break;case 3:{let n=this.tokenizeIdentifier();n.type==="INLINE_SOLVE_START"&&(e={startTokenIndex:t,startColumn:n.col}),yield n,t++;break}case 4:if(this.pos+1<r)if((S.CHAR_CLASS[o.charCodeAt(this.pos+1)]??0)===2)yield this.tokenizeNumber();else {let d=this.pos-this.lineStartPos+1;yield new a("DOT",chunk5IJD5L3O_cjs.c("DOT"),".",".",this.pos,0,this.line,d),this.pos++;}else {let n=this.pos-this.lineStartPos+1;yield new a("DOT",chunk5IJD5L3O_cjs.c("DOT"),".",".",this.pos,0,this.line,n),this.pos++;}t++;break;case 5:yield this.tokenizeOperator(),t++;break;case 6:yield this.tokenizeString(),t++;break;case 7:yield this.tokenizeComment(),t++;break;case 8:{let n=this.pos-this.lineStartPos+1;yield new a("DOLLAR",chunk5IJD5L3O_cjs.c("DOLLAR"),"$","$",this.pos,0,this.line,n),this.pos++,t++;break}case 11:{let n=this.pos-this.lineStartPos+1;if(yield new a("BACKTICK_OPEN",chunk5IJD5L3O_cjs.c("BACKTICK_OPEN"),"`","`",this.pos,0,this.line,n),this.pos++,e){let d=e;s.push({start:0,end:0,expression:"",columnNumber:d.startColumn,startTokenIndex:d.startTokenIndex,endTokenIndex:t}),e=null;}t++;break}default:{let n=this.pos-this.lineStartPos+1;w(i)?(this.pos++,(i===8232||i===8233||i===133)&&(this.line++,this.lineStartPos=this.pos)):i===215?(yield new a("STAR",chunk5IJD5L3O_cjs.c("STAR"),"\xD7","\xD7",this.pos,0,this.line,n),this.pos++,t++):i===247?(yield new a("SLASH",chunk5IJD5L3O_cjs.c("SLASH"),"\xF7","\xF7",this.pos,0,this.line,n),this.pos++,t++):i===177?(yield new a("PLUS_MINUS",chunk5IJD5L3O_cjs.c("PLUS_MINUS"),"\xB1","\xB1",this.pos,0,this.line,n),this.pos++,t++):i===8800?(yield new a("NEQ",chunk5IJD5L3O_cjs.c("NEQ"),"\u2260","\u2260",this.pos,0,this.line,n),this.pos++,t++):i===163?(yield new a("POUND",chunk5IJD5L3O_cjs.c("POUND"),"\xA3","\xA3",this.pos,0,this.line,n),this.pos++,t++):i===8364?(yield new a("EURO",chunk5IJD5L3O_cjs.c("EURO"),"\u20AC","\u20AC",this.pos,0,this.line,n),this.pos++,t++):i===165?(yield new a("YEN",chunk5IJD5L3O_cjs.c("YEN"),"\xA5","\xA5",this.pos,0,this.line,n),this.pos++,t++):i===8381?(yield new a("RUBLE",chunk5IJD5L3O_cjs.c("RUBLE"),"\u20BD","\u20BD",this.pos,0,this.line,n),this.pos++,t++):i===8361?(yield new a("WON",chunk5IJD5L3O_cjs.c("WON"),"\u20A9","\u20A9",this.pos,0,this.line,n),this.pos++,t++):i===8377?(yield new a("CURRENCY_SYMBOL",chunk5IJD5L3O_cjs.c("CURRENCY_SYMBOL"),"\u20B9","\u20B9",this.pos,0,this.line,n),this.pos++,t++):i===8378?(yield new a("CURRENCY_SYMBOL",chunk5IJD5L3O_cjs.c("CURRENCY_SYMBOL"),"\u20BA","\u20BA",this.pos,0,this.line,n),this.pos++,t++):i===8372?(yield new a("CURRENCY_SYMBOL",chunk5IJD5L3O_cjs.c("CURRENCY_SYMBOL"),"\u20B4","\u20B4",this.pos,0,this.line,n),this.pos++,t++):i===8362?(yield new a("CURRENCY_SYMBOL",chunk5IJD5L3O_cjs.c("CURRENCY_SYMBOL"),"\u20AA","\u20AA",this.pos,0,this.line,n),this.pos++,t++):i===8363?(yield new a("CURRENCY_SYMBOL",chunk5IJD5L3O_cjs.c("CURRENCY_SYMBOL"),"\u20AB","\u20AB",this.pos,0,this.line,n),this.pos++,t++):i===8358?(yield new a("CURRENCY_SYMBOL",chunk5IJD5L3O_cjs.c("CURRENCY_SYMBOL"),"\u20A6","\u20A6",this.pos,0,this.line,n),this.pos++,t++):i===8369?(yield new a("CURRENCY_SYMBOL",chunk5IJD5L3O_cjs.c("CURRENCY_SYMBOL"),"\u20B1","\u20B1",this.pos,0,this.line,n),this.pos++,t++):i>=128?(yield this.tokenizeIdentifier(),t++):this.pos++;break}}}this._inlineSolveSpans=s;}tokenizeNumber(){let r=this.input,t=this.len,e=this.pos,s=e,o=e-this.lineStartPos+1,i;if(r.charCodeAt(e)===48&&e+1<t){let f=r.charCodeAt(e+1);if(f===120||f===88){for(e+=2;e<t&&(i=r.charCodeAt(e),i>=48&&i<=57||i>=65&&i<=70||i>=97&&i<=102);)e++;let p=r.slice(s,e);return this.pos=e,new a("NUMBER",chunk5IJD5L3O_cjs.c("NUMBER"),p,p,s,0,this.line,o)}if(f===98||f===66){for(e+=2;e<t&&(i=r.charCodeAt(e),i===48||i===49);)e++;let p=r.slice(s,e);return this.pos=e,new a("NUMBER",chunk5IJD5L3O_cjs.c("NUMBER"),p,p,s,0,this.line,o)}if(f===111||f===79){for(e+=2;e<t&&(i=r.charCodeAt(e),i>=48&&i<=55);)e++;let p=r.slice(s,e);return this.pos=e,new a("NUMBER",chunk5IJD5L3O_cjs.c("NUMBER"),p,p,s,0,this.line,o)}}let l=false;for(;e<t&&(i=r.charCodeAt(e),i>=48&&i<=57);)l=true,e++;for(;l&&e<t&&(r.charCodeAt(e)===44||r.charCodeAt(e)===46)&&!(r.charCodeAt(e)===44&&this.groupingStack.length>0&&this.groupingStack[this.groupingStack.length-1]);){if(e+4<=t){let f=r.charCodeAt(e+1),p=r.charCodeAt(e+2),C=r.charCodeAt(e+3),R=e+4<t?r.charCodeAt(e+4):-1,I=!(R>=48&&R<=57);if(f>=48&&f<=57&&p>=48&&p<=57&&C>=48&&C<=57&&I){e+=4,l=true;continue}}break}let n=false;if(e<t&&r.charCodeAt(e)===46&&e+1<t){let f=r.charCodeAt(e+1);if(f>=48&&f<=57)for(n=true,e++;e<t&&(i=r.charCodeAt(e),i>=48&&i<=57);)e++;}let d=false;if(e<t){let f=r.charCodeAt(e);if((f===101||f===69)&&e+1<t){let p=r.charCodeAt(e+1);if(p>=48&&p<=57||p===43||p===45)for(d=true,e++,(p===43||p===45)&&e++;e<t&&(i=r.charCodeAt(e),i>=48&&i<=57);)e++;}}if(e<t&&r.charCodeAt(e)===110&&l&&!n&&!d){e++;let f=r.slice(s,e);return this.pos=e,new a("BIGINT",chunk5IJD5L3O_cjs.c("BIGINT"),f,f,s,0,this.line,o)}let u=r.slice(s,e);return this.pos=e,new a("NUMBER",chunk5IJD5L3O_cjs.c("NUMBER"),u,u,s,0,this.line,o)}tokenizeIdentifier(){let r=this.input,t=this.len,e=this.pos,s=e,o=e-this.lineStartPos+1,i;for(;e<t&&(i=r.charCodeAt(e),i>=48&&i<=57||i>=65&&i<=90||i>=97&&i<=122||i===95||i>=128&&!w(i));)e++;let l=r.slice(s,e),n=l.toLowerCase();if(n==="s"&&e<t&&r.charCodeAt(e)===96){e++,this.pos=e;let f=r.slice(s,e);return new a("INLINE_SOLVE_START",chunk5IJD5L3O_cjs.c("INLINE_SOLVE_START"),f,f,s,0,this.line,o)}if(this.mergedUnits.has(l)&&!this.isFollowedByLParen(e))return this.pos=e,new a("UNIT",chunk5IJD5L3O_cjs.c("UNIT"),l,l,s,0,this.line,o);let u=this.mergedKeywords.get(n);return u?(this.pos=e,new a(u,chunk5IJD5L3O_cjs.c(u),l,l,s,0,this.line,o)):(this.pos=e,new a("IDENT",chunk5IJD5L3O_cjs.c("IDENT"),l,l,s,0,this.line,o))}isFollowedByLParen(r){let t=this.len,e=r;for(;e<t;){let s=this.input.charCodeAt(e);if(s===40)return true;if(s!==32&&s!==9)break;e++;}return false}precededByCallTarget(r){let t=this.input,e=this.lineStartPos,s=r-1;for(;s>=e&&(t.charCodeAt(s)===32||t.charCodeAt(s)===9);)s--;if(s<e)return false;let o=t.charCodeAt(s),i=p=>p>=48&&p<=57||p>=65&&p<=90||p>=97&&p<=122||p===95,l=p=>p>=65&&p<=90||p>=97&&p<=122||p===95;if(!i(o))return false;let n=s+1,d=false;for(;s>=e;){let p=t.charCodeAt(s);if(!i(p))break;l(p)&&(d=true),s--;}if(!d)return false;let u=t.slice(s+1,n).toLowerCase(),f=this.mergedKeywords.get(u);return f===void 0||f==="FUNC"}tokenizeOperator(){let r=this.input,t=this.pos,e=t-this.lineStartPos+1,s=r.charCodeAt(t),o=this.len;if(t+1<o){let n=r.charCodeAt(t+1),d=E[s];if(d){let u=d[n];if(u){let f=r.slice(t,t+2);return this.pos=t+2,new a(u,chunk5IJD5L3O_cjs.c(u),f,f,t,0,this.line,e)}}if(s===47&&n===47){let u=t+2;for(;u<o;){let p=r.charCodeAt(u);if(p===10||p===13)break;u++;}let f=r.slice(t,u);return this.pos=u,new a("COMMENT",chunk5IJD5L3O_cjs.c("COMMENT"),f,f,t,0,this.line,e)}if(s===60&&n===60)return this.pos=t+2,new a("LSHIFT",chunk5IJD5L3O_cjs.c("LSHIFT"),"<<","<<",t,0,this.line,e);if(s===62&&n===62)return r.charCodeAt(t+2)===62?(this.pos=t+3,new a("URSHIFT",chunk5IJD5L3O_cjs.c("URSHIFT"),">>>",">>>",t,0,this.line,e)):(this.pos=t+2,new a("RSHIFT",chunk5IJD5L3O_cjs.c("RSHIFT"),">>",">>",t,0,this.line,e));if(this.hasPluginOps){let u=this.pluginOperators.get(s);if(u){let f=u.get(n);if(f){let p=r.slice(t,t+2);return this.pos=t+2,new a(f,chunk5IJD5L3O_cjs.c(f),p,p,t,0,this.line,e)}}}}this.pos=t+1,s===91?this.groupingStack.push(true):s===40?this.groupingStack.push(this.precededByCallTarget(t)):(s===41||s===93)&&this.groupingStack.length>0&&this.groupingStack.pop();let i=y[s],l=r.charAt(t);return new a(i||"ERROR",chunk5IJD5L3O_cjs.c(i||"ERROR"),l,l,t,0,this.line,e)}tokenizeString(){let r=this.input,t=this.len,e=this.pos,s=e-this.lineStartPos+1,o=e+1,i=0;for(;o<t;){let l=r.charCodeAt(o);if(l===34){o++;let n=r.slice(e,o),d=r.slice(e+1,o-1);return this.pos=o,new a("STRING",chunk5IJD5L3O_cjs.c("STRING"),d,n,e,i,this.line,s)}if(l===92&&o+1<t){o+=2;continue}l===10&&(this.line++,this.lineStartPos=o+1,i++),o++;}throw this.pos=o,chunkSOMGSIO4_cjs.c.parsing("UNTERMINATED_STRING",`Unterminated string literal: ${r.slice(e,o)}`,{literal:r.slice(e,o),offset:e})}static hasExpressionIndicators(r,t,e){let s=b;for(let o=t;o<e;o++){let i=r.charCodeAt(o);if(s.has(i)||i>=128&&(i===215||i===247||i===8800||i===163||i===8364||i===165||i===8381||i===8361))return true}return false}skipMarkerGap(r,t){let e=this.input,s=r;for(;s<t&&(e.charCodeAt(s)===32||e.charCodeAt(s)===9);)s++;if(s+2<t&&e.charCodeAt(s)===91&&e.charCodeAt(s+2)===93){let o=s+3;for(;o<t&&(e.charCodeAt(o)===32||e.charCodeAt(o)===9);)o++;if(o>s+3)return o}return s}matchHexColourEnd(r,t){let e=this.input,s=r+1,o=0;for(;s<t;){let i=e.charCodeAt(s);if(!(i>=48&&i<=57||i>=65&&i<=70||i>=97&&i<=102))break;o++,s++;}if(o!==3&&o!==4&&o!==6&&o!==8)return -1;if(s<t){let i=e.charCodeAt(s);if(i>=48&&i<=57||i>=65&&i<=90||i>=97&&i<=122||i===95)return -1}return s}classifyFromPositions(r,t){let e=t;if(r>=e)return {type:"empty",skip:true,hasInlineSolve:false};let s=this.input,o=r;for(;o<e;){let n=s.charCodeAt(o);if(n!==32&&n!==9)break;o++;}if(o>=e)return {type:"empty",skip:true,hasInlineSolve:false};let i=s.charCodeAt(o),l;if(i===35){if(this.matchHexColourEnd(o,e)!==-1){if(l===void 0){let d=s.indexOf("s`",o);l=d!==-1&&d<e;}return {type:"expression",skip:false,hasInlineSolve:l}}let n=1;for(;o+n<e&&s.charCodeAt(o+n)===35;)n++;return n<=6&&o+n<e&&s.charCodeAt(o+n)===32?{type:"heading",skip:true,hasInlineSolve:false}:{type:"heading",skip:true,hasInlineSolve:false}}if(i===62&&o+1<e&&s.charCodeAt(o+1)===32)return {type:"blockquote",skip:true,hasInlineSolve:false};if(i===96&&o+2<e&&s.charCodeAt(o+1)===96&&s.charCodeAt(o+2)===96)return {type:"code_fence",skip:true,hasInlineSolve:false};if(i===126&&o+2<e&&s.charCodeAt(o+1)===126&&s.charCodeAt(o+2)===126)return {type:"code_fence",skip:true,hasInlineSolve:false};if(i===36&&o+1<e&&s.charCodeAt(o+1)===36)return {type:"math_fence",skip:true,hasInlineSolve:false};if(i===45||i===42||i===95){let n=1;for(;o+n<e&&s.charCodeAt(o+n)===i;)n++;if(n>=3){let d=o+n;for(;d<e&&(s.charCodeAt(d)===32||s.charCodeAt(d)===9);)d++;if(d>=e)return {type:"hr",skip:true,hasInlineSolve:false}}}if((i===45||i===42||i===43)&&o+1<e&&s.charCodeAt(o+1)===32){if(l===void 0){let n=s.indexOf("s`",o);l=n!==-1&&n<e;}return {type:"list",skip:false,hasInlineSolve:l,contentOffset:this.skipMarkerGap(o+1,e)}}if(i>=48&&i<=57){let n=o;for(;n<e&&s.charCodeAt(n)>=48&&s.charCodeAt(n)<=57;)n++;if(n<e&&s.charCodeAt(n)===46&&n+1<e&&s.charCodeAt(n+1)===32){if(l===void 0){let d=s.indexOf("s`",o);l=d!==-1&&d<e;}return {type:"list",skip:false,hasInlineSolve:l,contentOffset:this.skipMarkerGap(n+1,e)}}}if(i===124){let n=o+1;for(;n<e;){let d=s.charCodeAt(n);if(d!==45&&d!==58&&d!==124&&d!==32&&d!==9&&d!==13)break;n++;}if(n>=e)return {type:"table_separator",skip:true,hasInlineSolve:false}}if(i===91&&o+1<e&&s.charCodeAt(o+1)===91){let n=s.indexOf("]]",o+2);if(n!==-1&&n<e){let d=n+2;for(;d<e&&(s.charCodeAt(d)===32||s.charCodeAt(d)===9);)d++;if(d>=e)return {type:"wikilink",skip:true,hasInlineSolve:false}}}if(i===33&&o+2<e&&s.charCodeAt(o+1)===91&&s.charCodeAt(o+2)===91){let n=s.indexOf("]]",o+3);if(n!==-1&&n<e){let d=n+2;for(;d<e&&(s.charCodeAt(d)===32||s.charCodeAt(d)===9);)d++;if(d>=e)return {type:"wikilink",skip:true,hasInlineSolve:false}}}if(i===47&&o+1<e&&s.charCodeAt(o+1)===47)return {type:"comment",skip:true,hasInlineSolve:false};if(i===62){let n=o+1;for(;n<e&&(s.charCodeAt(n)===32||s.charCodeAt(n)===9);)n++;if(n>=e)return {type:"blockquote",skip:true,hasInlineSolve:false}}if(i===45||i===42||i===43){let n=o+1;for(;n<e&&(s.charCodeAt(n)===32||s.charCodeAt(n)===9);)n++;if(n>=e)return {type:"list",skip:false,hasInlineSolve:false}}if(l===void 0){let n=s.indexOf("s`",o);l=n!==-1&&n<e;}if(!l){let n=true;for(let d=o;d<e;d++){let u=s.charCodeAt(d);if(u>=128||S.CHAR_CLASS[u]>1){n=false;break}}if(n)return {type:"empty",skip:true,hasInlineSolve:false}}return {type:"expression",skip:false,hasInlineSolve:l}}classifyLine(r){let t=this.input,e=this.len,s=this.pos;this.input=r,this.len=r.length,this.pos=0;let o=this.classifyFromPositions(0,r.length);return this.input=t,this.len=e,this.pos=s,o}getKeywords(){return Object.fromEntries(this.mergedKeywords)}findInlineSolves(r){let t=[],e=r.length,s=0;for(;s<e;){let o=r.indexOf("s`",s);if(o===-1)break;let i=o+2,l=i;for(;l<e;){let u=r.charCodeAt(l);if(u===92&&l+1<e){l+=2;continue}if(u===96)break;l++;}l>=e&&(l=e);let n=r.slice(i,l),d=l<e?l+1:l;t.push({start:o,end:d,expression:n,columnNumber:o+1}),s=d;}return t}tokenizeComment(){let r=this.input,t=this.len,e=this.pos,s=e-this.lineStartPos+1;if(r.charCodeAt(e)===35){let l=this.matchHexColourEnd(e,t);if(l!==-1){let u=r.slice(e,l);return this.pos=l,new a("HEX_COLOUR",chunk5IJD5L3O_cjs.c("HEX_COLOUR"),u,u,e,0,this.line,s)}let n=r.charCodeAt(e+1);if(n>=65&&n<=90||n>=97&&n<=122){let u=e+2;for(;u<t;){let p=r.charCodeAt(u);if(!(p>=48&&p<=57||p>=65&&p<=90||p>=97&&p<=122||p===95||p===45))break;u++;}let f=r.slice(e+1,u);return this.pos=u,new a("TAG",chunk5IJD5L3O_cjs.c("TAG"),f,f,e,0,this.line,s)}}let o=this.pos;for(o+1<t&&r.charCodeAt(o+1)===47?o+=2:o++;o<t;){let l=r.charCodeAt(o);if(l===10||l===13)break;o++;}let i=r.slice(e,o);return this.pos=o,new a("COMMENT",chunk5IJD5L3O_cjs.c("COMMENT"),i,i,e,0,this.line,s)}};S.CHAR_CLASS=g();var L=S;exports.a=a;exports.b=L;//# sourceMappingURL=chunk-6KFVG6UY.cjs.map
2
- //# sourceMappingURL=chunk-6KFVG6UY.cjs.map
1
+ 'use strict';var chunk5IJD5L3O_cjs=require('./chunk-5IJD5L3O.cjs'),chunkMSYX32PF_cjs=require('./chunk-MSYX32PF.cjs'),chunkFWW3M36J_cjs=require('./chunk-FWW3M36J.cjs'),chunkSOMGSIO4_cjs=require('./chunk-SOMGSIO4.cjs');chunk5IJD5L3O_cjs.e();function g(){let c=new Uint8Array(128);for(let r=48;r<=57;r++)c[r]=2;for(let r=65;r<=90;r++)c[r]=3;for(let r=97;r<=122;r++)c[r]=3;return c[95]=3,c[46]=4,c[32]=1,c[9]=1,c[10]=1,c[13]=1,c[33]=5,c[37]=5,c[38]=5,c[40]=5,c[41]=5,c[42]=5,c[43]=5,c[44]=5,c[45]=5,c[47]=5,c[58]=5,c[59]=5,c[60]=5,c[61]=5,c[62]=5,c[63]=5,c[91]=5,c[93]=5,c[94]=5,c[123]=5,c[124]=5,c[125]=5,c[126]=5,c[64]=5,c[34]=6,c[35]=7,c[36]=8,c[96]=11,c}function w(c){return c===133||c===160||c===5760||c>=8192&&c<=8202||c===8203||c===8232||c===8233||c===8239||c===8287||c===12288||c===65279}var a=class{constructor(r,t,e,s,o,i,l,n,p){this.type=r;this.typeId=t;this.value=e;this.text=s;this.offset=o;this.lineBreaks=i;this.line=l;this.col=n;this.sourceEnd=p;}},y={61:{61:"EQUALITY",62:"THEREFORE"},33:{61:"NEQ"},62:{61:"GTE"},60:{61:"LTE"},38:{38:"LOGICAL_AND"},124:{124:"LOGICAL_OR"},43:{61:"PLUS_EQUALS"},45:{61:"MINUS_EQUALS"}},L={43:"PLUS",45:"MINUS",42:"STAR",47:"SLASH",94:"CARET",37:"PERCENT",40:"LPAREN",41:"RPAREN",91:"LBRACKET",93:"RBRACKET",123:"LBRACE",125:"RBRACE",44:"COMMA",58:"COLON",59:"SEMICOLON",61:"EQUALS",63:"QUESTION",33:"BANG",38:"BIT_AND",124:"BIT_OR",60:"LT",62:"GT",126:"BIT_NOT",64:"AT"},b=(()=>{let c=new Set;for(let t=48;t<=57;t++)c.add(t);let r=[43,45,42,47,94,37,40,41,91,93,123,125,61,60,62,33,38,124,126,59,63];for(let t of r)c.add(t);return c.add(36),c.add(163),c.add(8364),c.add(165),c.add(8381),c.add(8361),c.add(96),c.add(46),c.add(35),c})(),S=class S{constructor(r="en",t){this.configuredLookup=null;this.input="";this.pos=0;this.len=0;this.line=1;this.lineStartPos=0;this.groupingStack=[];this.pluginKeywordMap=new Map;this.pluginOperators=new Map;this.pluginUnits=new Set;this.hasPluginOps=false;this._inlineSolveSpans=[];this.pluginRawLinePatterns=[];this.pendingRawLineToken=null;this.localeCode=r,this.locale=chunkMSYX32PF_cjs.a(r),this.configuredLookup=t??null,this.keywordMap=new Map;for(let[e,s]of Object.entries(this.locale.keywordMap))this.keywordMap.set(e.toLowerCase(),s);this.mergedKeywords=new Map(this.keywordMap),this.mergedUnits=new Set(chunkFWW3M36J_cjs.a);}matchRawLine(r){for(let t of this.pluginRawLinePatterns){let e=t.pattern.exec(r);if(e&&typeof e[1]=="string"){let s=e[1].trim();if(s.length>0)return new a(t.tokenType,chunk5IJD5L3O_cjs.c(t.tokenType),s,s,0,0,this.line,1)}}return null}rebuildMergedCollections(){this.mergedKeywords=new Map([...this.keywordMap,...this.pluginKeywordMap]),this.mergedUnits=new Set([...chunkFWW3M36J_cjs.a,...this.pluginUnits]);}registerVocabulary(r){if(r.keywords){for(let[t,e]of Object.entries(r.keywords)){let s=t.toLowerCase();if(this.keywordMap.has(s))throw chunkSOMGSIO4_cjs.c.config("PLUGIN_KEYWORD_COLLISION",`Plugin keyword "${t}" conflicts with built-in keyword (type: ${this.keywordMap.get(s)}). Built-in keywords cannot be overridden.`,{keyword:t,builtinType:this.keywordMap.get(s)});this.pluginKeywordMap.set(s,e);}this.rebuildMergedCollections();}if(r.operators){this.hasPluginOps=true;for(let[t,e]of Object.entries(r.operators))if(t.length===2){let s=t.charCodeAt(0),o=t.charCodeAt(1),i=y[s];if(i&&i[o]!==void 0)throw chunkSOMGSIO4_cjs.c.config("PLUGIN_OPERATOR_COLLISION",`Plugin operator "${t}" conflicts with built-in operator (type: ${i[o]}). Built-in operators cannot be overridden.`,{operator:t,builtinType:i[o]});if(s===60&&o===60)throw chunkSOMGSIO4_cjs.c.config("PLUGIN_OPERATOR_COLLISION",`Plugin operator "${t}" conflicts with built-in operator (type: LSHIFT). Built-in operators cannot be overridden.`,{operator:t,builtinType:"LSHIFT"});if(s===62&&o===62)throw chunkSOMGSIO4_cjs.c.config("PLUGIN_OPERATOR_COLLISION",`Plugin operator "${t}" conflicts with built-in operator (type: RSHIFT). Built-in operators cannot be overridden.`,{operator:t,builtinType:"RSHIFT"});if(s===47&&o===47)throw chunkSOMGSIO4_cjs.c.config("PLUGIN_OPERATOR_COLLISION",`Plugin operator "${t}" conflicts with built-in comment sequence. Comment sequences cannot be overridden.`,{operator:t,builtinType:"COMMENT"});let l=this.pluginOperators.get(s);l||(l=new Map,this.pluginOperators.set(s,l)),l.set(o,e);}}if(r.units){for(let t of r.units){if(chunkFWW3M36J_cjs.a.has(t))throw chunkSOMGSIO4_cjs.c.config("PLUGIN_UNIT_COLLISION",`Plugin unit "${t}" conflicts with a built-in unit. Built-in units cannot be overridden.`,{unit:t});this.pluginUnits.add(t);}this.rebuildMergedCollections();}r.rawLinePatterns&&this.pluginRawLinePatterns.push(...r.rawLinePatterns);}unregisterVocabulary(r){if(r.keywords){for(let t of Object.keys(r.keywords))this.pluginKeywordMap.delete(t.toLowerCase());this.rebuildMergedCollections();}if(r.operators){for(let t of Object.keys(r.operators))if(t.length===2){let e=t.charCodeAt(0),s=t.charCodeAt(1),o=this.pluginOperators.get(e);o&&(o.delete(s),o.size===0&&this.pluginOperators.delete(e));}this.hasPluginOps=this.pluginOperators.size>0;}if(r.units){for(let t of r.units)this.pluginUnits.delete(t);this.rebuildMergedCollections();}if(r.rawLinePatterns){let t=new Set(r.rawLinePatterns);this.pluginRawLinePatterns=this.pluginRawLinePatterns.filter(e=>!t.has(e));}}reset(r){this.input=r,this.pos=0,this.len=r.length,this.line=1,this.lineStartPos=0,this.pendingRawLineToken=this.pluginRawLinePatterns.length>0?this.matchRawLine(r):null;}scanDocument(r){this.input=r,this.pos=0,this.len=r.length,this.line=1,this.lineStartPos=0;let t=[],e=this.input,s=this.len;for(;this.pos<s;){let o=this.pos,i=this.pos;for(;i<s;){let d=e.charCodeAt(i);if(d===10||d===13)break;i++;}let l=this.line,n=this.classifyFromPositions(o,i),p=e.slice(o,i),u=[];if(!n.skip){let d=this.pluginRawLinePatterns.length>0?this.matchRawLine(p):null;if(d)u=[d];else {let A=this.len;this.len=i,n.contentOffset!==void 0&&(this.pos=n.contentOffset),u=Array.from(this),this.len=A;}}let f=[];if(n.hasInlineSolve)if(!n.skip&&u.length>0){let d=this.findInlineSolves(p);f=this._inlineSolveSpans.map((A,C)=>({start:d[C]?.start??0,end:d[C]?.end??0,expression:d[C]?.expression??"",columnNumber:d[C]?.columnNumber??A.columnNumber,startTokenIndex:A.startTokenIndex,endTokenIndex:A.endTokenIndex}));}else f=this.findInlineSolves(p);if(t.push({text:p,lineNumber:l,startOffset:o,endOffset:i,classification:n,tokens:u,inlineSolves:f}),this.pos=i,this.pos<s){let d=e.charCodeAt(this.pos);d===13?(this.pos++,this.pos<s&&e.charCodeAt(this.pos)===10&&this.pos++):d===10&&this.pos++;}this.line++,this.lineStartPos=this.pos;}return t}tokenizeAll(){return this.pendingRawLineToken?(this._inlineSolveSpans=[],[this.pendingRawLineToken]):Array.from(this)}*[Symbol.iterator](){let r=this.len;if(r===0){this._inlineSolveSpans=[];return}let t=0,e=null,s=[];if(r===1){let i=this.input.charCodeAt(0);switch(S.CHAR_CLASS[i]??0){case 2:case 4:yield new a("NUMBER",chunk5IJD5L3O_cjs.c("NUMBER"),this.input,this.input,0,0,1,1),t++;break;case 3:{let n=this.input,p=n.toLowerCase();if(this.mergedUnits.has(n))yield new a("UNIT",chunk5IJD5L3O_cjs.c("UNIT"),n,n,0,0,1,1);else {let u=this.mergedKeywords.get(p);u?yield new a(u,chunk5IJD5L3O_cjs.c(u),n,n,0,0,1,1):yield new a("IDENT",chunk5IJD5L3O_cjs.c("IDENT"),n,n,0,0,1,1);}t++;break}case 5:{let n=L[i];n&&(yield new a(n,chunk5IJD5L3O_cjs.c(n),this.input,this.input,0,0,1,1),t++);break}case 6:this.pos=0,yield this.tokenizeString(),t++;break;case 7:this.pos=0,yield this.tokenizeComment(),t++;break;case 8:yield new a("DOLLAR",chunk5IJD5L3O_cjs.c("DOLLAR"),"$","$",0,0,1,1),t++;break;case 11:yield new a("BACKTICK_OPEN",chunk5IJD5L3O_cjs.c("BACKTICK_OPEN"),"`","`",0,0,1,1),t++;break;default:{w(i)||(i===215?(yield new a("STAR",chunk5IJD5L3O_cjs.c("STAR"),"\xD7","\xD7",0,0,1,1),t++):i===247?(yield new a("SLASH",chunk5IJD5L3O_cjs.c("SLASH"),"\xF7","\xF7",0,0,1,1),t++):i===177?(yield new a("PLUS_MINUS",chunk5IJD5L3O_cjs.c("PLUS_MINUS"),"\xB1","\xB1",0,0,1,1),t++):i===8800?(yield new a("NEQ",chunk5IJD5L3O_cjs.c("NEQ"),"\u2260","\u2260",0,0,1,1),t++):i===163?(yield new a("POUND",chunk5IJD5L3O_cjs.c("POUND"),"\xA3","\xA3",0,0,1,1),t++):i===8364?(yield new a("EURO",chunk5IJD5L3O_cjs.c("EURO"),"\u20AC","\u20AC",0,0,1,1),t++):i===165?(yield new a("YEN",chunk5IJD5L3O_cjs.c("YEN"),"\xA5","\xA5",0,0,1,1),t++):i===8381?(yield new a("RUBLE",chunk5IJD5L3O_cjs.c("RUBLE"),"\u20BD","\u20BD",0,0,1,1),t++):i===8361?(yield new a("WON",chunk5IJD5L3O_cjs.c("WON"),"\u20A9","\u20A9",0,0,1,1),t++):i===8377?(yield new a("CURRENCY_SYMBOL",chunk5IJD5L3O_cjs.c("CURRENCY_SYMBOL"),"\u20B9","\u20B9",0,0,1,1),t++):i===8378?(yield new a("CURRENCY_SYMBOL",chunk5IJD5L3O_cjs.c("CURRENCY_SYMBOL"),"\u20BA","\u20BA",0,0,1,1),t++):i===8372?(yield new a("CURRENCY_SYMBOL",chunk5IJD5L3O_cjs.c("CURRENCY_SYMBOL"),"\u20B4","\u20B4",0,0,1,1),t++):i===8362?(yield new a("CURRENCY_SYMBOL",chunk5IJD5L3O_cjs.c("CURRENCY_SYMBOL"),"\u20AA","\u20AA",0,0,1,1),t++):i===8363?(yield new a("CURRENCY_SYMBOL",chunk5IJD5L3O_cjs.c("CURRENCY_SYMBOL"),"\u20AB","\u20AB",0,0,1,1),t++):i===8358?(yield new a("CURRENCY_SYMBOL",chunk5IJD5L3O_cjs.c("CURRENCY_SYMBOL"),"\u20A6","\u20A6",0,0,1,1),t++):i===8369?(yield new a("CURRENCY_SYMBOL",chunk5IJD5L3O_cjs.c("CURRENCY_SYMBOL"),"\u20B1","\u20B1",0,0,1,1),t++):i>=128&&(yield new a("IDENT",chunk5IJD5L3O_cjs.c("IDENT"),this.input,this.input,0,0,1,1),t++));break}}this._inlineSolveSpans=s;return}let o=this.input;for(this.groupingStack.length=0;this.pos<r;){let i=o.charCodeAt(this.pos),l=S.CHAR_CLASS[i]??0;if(e&&i===92&&this.pos+1<r&&o.charCodeAt(this.pos+1)===96){this.pos+=2;continue}switch(l){case 1:this.pos++,i===10?(this.line++,this.lineStartPos=this.pos,this.groupingStack.length=0):i===13&&(this.line++,this.pos<r&&o.charCodeAt(this.pos)===10&&this.pos++,this.lineStartPos=this.pos,this.groupingStack.length=0);break;case 2:yield this.tokenizeNumber(),t++;break;case 3:{let n=this.tokenizeIdentifier();n.type==="INLINE_SOLVE_START"&&(e={startTokenIndex:t,startColumn:n.col}),yield n,t++;break}case 4:if(this.pos+1<r)if((S.CHAR_CLASS[o.charCodeAt(this.pos+1)]??0)===2)yield this.tokenizeNumber();else {let p=this.pos-this.lineStartPos+1;yield new a("DOT",chunk5IJD5L3O_cjs.c("DOT"),".",".",this.pos,0,this.line,p),this.pos++;}else {let n=this.pos-this.lineStartPos+1;yield new a("DOT",chunk5IJD5L3O_cjs.c("DOT"),".",".",this.pos,0,this.line,n),this.pos++;}t++;break;case 5:yield this.tokenizeOperator(),t++;break;case 6:yield this.tokenizeString(),t++;break;case 7:yield this.tokenizeComment(),t++;break;case 8:{let n=this.pos-this.lineStartPos+1;yield new a("DOLLAR",chunk5IJD5L3O_cjs.c("DOLLAR"),"$","$",this.pos,0,this.line,n),this.pos++,t++;break}case 11:{let n=this.pos-this.lineStartPos+1;if(yield new a("BACKTICK_OPEN",chunk5IJD5L3O_cjs.c("BACKTICK_OPEN"),"`","`",this.pos,0,this.line,n),this.pos++,e){let p=e;s.push({start:0,end:0,expression:"",columnNumber:p.startColumn,startTokenIndex:p.startTokenIndex,endTokenIndex:t}),e=null;}t++;break}default:{let n=this.pos-this.lineStartPos+1;w(i)?(this.pos++,(i===8232||i===8233||i===133)&&(this.line++,this.lineStartPos=this.pos)):i===215?(yield new a("STAR",chunk5IJD5L3O_cjs.c("STAR"),"\xD7","\xD7",this.pos,0,this.line,n),this.pos++,t++):i===247?(yield new a("SLASH",chunk5IJD5L3O_cjs.c("SLASH"),"\xF7","\xF7",this.pos,0,this.line,n),this.pos++,t++):i===177?(yield new a("PLUS_MINUS",chunk5IJD5L3O_cjs.c("PLUS_MINUS"),"\xB1","\xB1",this.pos,0,this.line,n),this.pos++,t++):i===8800?(yield new a("NEQ",chunk5IJD5L3O_cjs.c("NEQ"),"\u2260","\u2260",this.pos,0,this.line,n),this.pos++,t++):i===163?(yield new a("POUND",chunk5IJD5L3O_cjs.c("POUND"),"\xA3","\xA3",this.pos,0,this.line,n),this.pos++,t++):i===8364?(yield new a("EURO",chunk5IJD5L3O_cjs.c("EURO"),"\u20AC","\u20AC",this.pos,0,this.line,n),this.pos++,t++):i===165?(yield new a("YEN",chunk5IJD5L3O_cjs.c("YEN"),"\xA5","\xA5",this.pos,0,this.line,n),this.pos++,t++):i===8381?(yield new a("RUBLE",chunk5IJD5L3O_cjs.c("RUBLE"),"\u20BD","\u20BD",this.pos,0,this.line,n),this.pos++,t++):i===8361?(yield new a("WON",chunk5IJD5L3O_cjs.c("WON"),"\u20A9","\u20A9",this.pos,0,this.line,n),this.pos++,t++):i===8377?(yield new a("CURRENCY_SYMBOL",chunk5IJD5L3O_cjs.c("CURRENCY_SYMBOL"),"\u20B9","\u20B9",this.pos,0,this.line,n),this.pos++,t++):i===8378?(yield new a("CURRENCY_SYMBOL",chunk5IJD5L3O_cjs.c("CURRENCY_SYMBOL"),"\u20BA","\u20BA",this.pos,0,this.line,n),this.pos++,t++):i===8372?(yield new a("CURRENCY_SYMBOL",chunk5IJD5L3O_cjs.c("CURRENCY_SYMBOL"),"\u20B4","\u20B4",this.pos,0,this.line,n),this.pos++,t++):i===8362?(yield new a("CURRENCY_SYMBOL",chunk5IJD5L3O_cjs.c("CURRENCY_SYMBOL"),"\u20AA","\u20AA",this.pos,0,this.line,n),this.pos++,t++):i===8363?(yield new a("CURRENCY_SYMBOL",chunk5IJD5L3O_cjs.c("CURRENCY_SYMBOL"),"\u20AB","\u20AB",this.pos,0,this.line,n),this.pos++,t++):i===8358?(yield new a("CURRENCY_SYMBOL",chunk5IJD5L3O_cjs.c("CURRENCY_SYMBOL"),"\u20A6","\u20A6",this.pos,0,this.line,n),this.pos++,t++):i===8369?(yield new a("CURRENCY_SYMBOL",chunk5IJD5L3O_cjs.c("CURRENCY_SYMBOL"),"\u20B1","\u20B1",this.pos,0,this.line,n),this.pos++,t++):i>=128?(yield this.tokenizeIdentifier(),t++):this.pos++;break}}}this._inlineSolveSpans=s;}tokenizeNumber(){let r=this.input,t=this.len,e=this.pos,s=e,o=e-this.lineStartPos+1,i;if(r.charCodeAt(e)===48&&e+1<t){let f=r.charCodeAt(e+1);if(f===120||f===88){for(e+=2;e<t&&(i=r.charCodeAt(e),i>=48&&i<=57||i>=65&&i<=70||i>=97&&i<=102);)e++;let d=r.slice(s,e);return this.pos=e,new a("NUMBER",chunk5IJD5L3O_cjs.c("NUMBER"),d,d,s,0,this.line,o)}if(f===98||f===66){for(e+=2;e<t&&(i=r.charCodeAt(e),i===48||i===49);)e++;let d=r.slice(s,e);return this.pos=e,new a("NUMBER",chunk5IJD5L3O_cjs.c("NUMBER"),d,d,s,0,this.line,o)}if(f===111||f===79){for(e+=2;e<t&&(i=r.charCodeAt(e),i>=48&&i<=55);)e++;let d=r.slice(s,e);return this.pos=e,new a("NUMBER",chunk5IJD5L3O_cjs.c("NUMBER"),d,d,s,0,this.line,o)}}let l=false;for(;e<t&&(i=r.charCodeAt(e),i>=48&&i<=57);)l=true,e++;for(;l&&e<t&&(r.charCodeAt(e)===44||r.charCodeAt(e)===46)&&!(r.charCodeAt(e)===44&&this.groupingStack.length>0&&this.groupingStack[this.groupingStack.length-1]);){if(e+4<=t){let f=r.charCodeAt(e+1),d=r.charCodeAt(e+2),A=r.charCodeAt(e+3),C=e+4<t?r.charCodeAt(e+4):-1,T=!(C>=48&&C<=57);if(f>=48&&f<=57&&d>=48&&d<=57&&A>=48&&A<=57&&T){e+=4,l=true;continue}}break}let n=false;if(e<t&&r.charCodeAt(e)===46&&e+1<t){let f=r.charCodeAt(e+1);if(f>=48&&f<=57)for(n=true,e++;e<t&&(i=r.charCodeAt(e),i>=48&&i<=57);)e++;}let p=false;if(e<t){let f=r.charCodeAt(e);if((f===101||f===69)&&e+1<t){let d=r.charCodeAt(e+1);if(d>=48&&d<=57||d===43||d===45)for(p=true,e++,(d===43||d===45)&&e++;e<t&&(i=r.charCodeAt(e),i>=48&&i<=57);)e++;}}if(e<t&&r.charCodeAt(e)===110&&l&&!n&&!p){e++;let f=r.slice(s,e);return this.pos=e,new a("BIGINT",chunk5IJD5L3O_cjs.c("BIGINT"),f,f,s,0,this.line,o)}let u=r.slice(s,e);return this.pos=e,new a("NUMBER",chunk5IJD5L3O_cjs.c("NUMBER"),u,u,s,0,this.line,o)}tokenizeIdentifier(){let r=this.input,t=this.len,e=this.pos,s=e,o=e-this.lineStartPos+1,i;for(;e<t&&(i=r.charCodeAt(e),i>=48&&i<=57||i>=65&&i<=90||i>=97&&i<=122||i===95||i>=128&&!w(i));)e++;let l=r.slice(s,e),n=l.toLowerCase();if(n==="s"&&e<t&&r.charCodeAt(e)===96){e++,this.pos=e;let f=r.slice(s,e);return new a("INLINE_SOLVE_START",chunk5IJD5L3O_cjs.c("INLINE_SOLVE_START"),f,f,s,0,this.line,o)}if(this.mergedUnits.has(l)&&!this.isFollowedByLParen(e))return this.pos=e,new a("UNIT",chunk5IJD5L3O_cjs.c("UNIT"),l,l,s,0,this.line,o);let u=this.mergedKeywords.get(n);return u?(this.pos=e,new a(u,chunk5IJD5L3O_cjs.c(u),l,l,s,0,this.line,o)):(this.pos=e,new a("IDENT",chunk5IJD5L3O_cjs.c("IDENT"),l,l,s,0,this.line,o))}isFollowedByLParen(r){let t=this.len,e=r;for(;e<t;){let s=this.input.charCodeAt(e);if(s===40)return true;if(s!==32&&s!==9)break;e++;}return false}precededByCallTarget(r){let t=this.input,e=this.lineStartPos,s=r-1;for(;s>=e&&(t.charCodeAt(s)===32||t.charCodeAt(s)===9);)s--;if(s<e)return false;let o=t.charCodeAt(s),i=d=>d>=48&&d<=57||d>=65&&d<=90||d>=97&&d<=122||d===95,l=d=>d>=65&&d<=90||d>=97&&d<=122||d===95;if(!i(o))return false;let n=s+1,p=false;for(;s>=e;){let d=t.charCodeAt(s);if(!i(d))break;l(d)&&(p=true),s--;}if(!p)return false;let u=t.slice(s+1,n).toLowerCase(),f=this.mergedKeywords.get(u);return f===void 0||f==="FUNC"}tokenizeOperator(){let r=this.input,t=this.pos,e=t-this.lineStartPos+1,s=r.charCodeAt(t),o=this.len;if(t+1<o){let n=r.charCodeAt(t+1),p=y[s];if(p){let u=p[n];if(u){let f=r.slice(t,t+2);return this.pos=t+2,new a(u,chunk5IJD5L3O_cjs.c(u),f,f,t,0,this.line,e)}}if(s===47&&n===47){let u=t+2;for(;u<o;){let d=r.charCodeAt(u);if(d===10||d===13)break;u++;}let f=r.slice(t,u);return this.pos=u,new a("COMMENT",chunk5IJD5L3O_cjs.c("COMMENT"),f,f,t,0,this.line,e)}if(s===60&&n===60)return this.pos=t+2,new a("LSHIFT",chunk5IJD5L3O_cjs.c("LSHIFT"),"<<","<<",t,0,this.line,e);if(s===62&&n===62)return r.charCodeAt(t+2)===62?(this.pos=t+3,new a("URSHIFT",chunk5IJD5L3O_cjs.c("URSHIFT"),">>>",">>>",t,0,this.line,e)):(this.pos=t+2,new a("RSHIFT",chunk5IJD5L3O_cjs.c("RSHIFT"),">>",">>",t,0,this.line,e));if(this.hasPluginOps){let u=this.pluginOperators.get(s);if(u){let f=u.get(n);if(f){let d=r.slice(t,t+2);return this.pos=t+2,new a(f,chunk5IJD5L3O_cjs.c(f),d,d,t,0,this.line,e)}}}}this.pos=t+1,s===91?this.groupingStack.push(true):s===40?this.groupingStack.push(this.precededByCallTarget(t)):(s===41||s===93)&&this.groupingStack.length>0&&this.groupingStack.pop();let i=L[s],l=r.charAt(t);return new a(i||"ERROR",chunk5IJD5L3O_cjs.c(i||"ERROR"),l,l,t,0,this.line,e)}tokenizeString(){let r=this.input,t=this.len,e=this.pos,s=e-this.lineStartPos+1,o=e+1,i=0;for(;o<t;){let l=r.charCodeAt(o);if(l===34){o++;let n=r.slice(e,o),p=r.slice(e+1,o-1);return this.pos=o,new a("STRING",chunk5IJD5L3O_cjs.c("STRING"),p,n,e,i,this.line,s)}if(l===92&&o+1<t){o+=2;continue}l===10&&(this.line++,this.lineStartPos=o+1,i++),o++;}throw this.pos=o,chunkSOMGSIO4_cjs.c.parsing("UNTERMINATED_STRING",`Unterminated string literal: ${r.slice(e,o)}`,{literal:r.slice(e,o),offset:e})}static hasExpressionIndicators(r,t,e){let s=b;for(let o=t;o<e;o++){let i=r.charCodeAt(o);if(s.has(i)||i>=128&&(i===215||i===247||i===8800||i===163||i===8364||i===165||i===8381||i===8361))return true}return false}skipMarkerGap(r,t){let e=this.input,s=r;for(;s<t&&(e.charCodeAt(s)===32||e.charCodeAt(s)===9);)s++;if(s+2<t&&e.charCodeAt(s)===91&&e.charCodeAt(s+2)===93){let o=s+3;for(;o<t&&(e.charCodeAt(o)===32||e.charCodeAt(o)===9);)o++;if(o>s+3)return o}return s}matchHexColourEnd(r,t){let e=this.input,s=r+1,o=0;for(;s<t;){let i=e.charCodeAt(s);if(!(i>=48&&i<=57||i>=65&&i<=70||i>=97&&i<=102))break;o++,s++;}if(o!==3&&o!==4&&o!==6&&o!==8)return -1;if(s<t){let i=e.charCodeAt(s);if(i>=48&&i<=57||i>=65&&i<=90||i>=97&&i<=122||i===95)return -1}return s}classifyFromPositions(r,t){let e=t;if(r>=e)return {type:"empty",skip:true,hasInlineSolve:false};let s=this.input,o=r;for(;o<e;){let n=s.charCodeAt(o);if(n!==32&&n!==9)break;o++;}if(o>=e)return {type:"empty",skip:true,hasInlineSolve:false};let i=s.charCodeAt(o),l;if(i===35){if(this.matchHexColourEnd(o,e)!==-1){if(l===void 0){let p=s.indexOf("s`",o);l=p!==-1&&p<e;}return {type:"expression",skip:false,hasInlineSolve:l}}let n=1;for(;o+n<e&&s.charCodeAt(o+n)===35;)n++;return n<=6&&o+n<e&&s.charCodeAt(o+n)===32?{type:"heading",skip:true,hasInlineSolve:false}:{type:"heading",skip:true,hasInlineSolve:false}}if(i===62&&o+1<e&&s.charCodeAt(o+1)===32)return {type:"blockquote",skip:true,hasInlineSolve:false};if(i===96&&o+2<e&&s.charCodeAt(o+1)===96&&s.charCodeAt(o+2)===96)return {type:"code_fence",skip:true,hasInlineSolve:false};if(i===126&&o+2<e&&s.charCodeAt(o+1)===126&&s.charCodeAt(o+2)===126)return {type:"code_fence",skip:true,hasInlineSolve:false};if(i===36&&o+1<e&&s.charCodeAt(o+1)===36)return {type:"math_fence",skip:true,hasInlineSolve:false};if(i===45||i===42||i===95){let n=1;for(;o+n<e&&s.charCodeAt(o+n)===i;)n++;if(n>=3){let p=o+n;for(;p<e&&(s.charCodeAt(p)===32||s.charCodeAt(p)===9);)p++;if(p>=e)return {type:"hr",skip:true,hasInlineSolve:false}}}if((i===45||i===42||i===43)&&o+1<e&&s.charCodeAt(o+1)===32){if(l===void 0){let n=s.indexOf("s`",o);l=n!==-1&&n<e;}return {type:"list",skip:false,hasInlineSolve:l,contentOffset:this.skipMarkerGap(o+1,e)}}if(i>=48&&i<=57){let n=o;for(;n<e&&s.charCodeAt(n)>=48&&s.charCodeAt(n)<=57;)n++;if(n<e&&s.charCodeAt(n)===46&&n+1<e&&s.charCodeAt(n+1)===32){if(l===void 0){let p=s.indexOf("s`",o);l=p!==-1&&p<e;}return {type:"list",skip:false,hasInlineSolve:l,contentOffset:this.skipMarkerGap(n+1,e)}}}if(i===124){let n=o+1;for(;n<e;){let p=s.charCodeAt(n);if(p!==45&&p!==58&&p!==124&&p!==32&&p!==9&&p!==13)break;n++;}if(n>=e)return {type:"table_separator",skip:true,hasInlineSolve:false}}if(i===91&&o+1<e&&s.charCodeAt(o+1)===91){let n=s.indexOf("]]",o+2);if(n!==-1&&n<e){let p=n+2;for(;p<e&&(s.charCodeAt(p)===32||s.charCodeAt(p)===9);)p++;if(p>=e)return {type:"wikilink",skip:true,hasInlineSolve:false}}}if(i===33&&o+2<e&&s.charCodeAt(o+1)===91&&s.charCodeAt(o+2)===91){let n=s.indexOf("]]",o+3);if(n!==-1&&n<e){let p=n+2;for(;p<e&&(s.charCodeAt(p)===32||s.charCodeAt(p)===9);)p++;if(p>=e)return {type:"wikilink",skip:true,hasInlineSolve:false}}}if(i===47&&o+1<e&&s.charCodeAt(o+1)===47)return {type:"comment",skip:true,hasInlineSolve:false};if(i===62){let n=o+1;for(;n<e&&(s.charCodeAt(n)===32||s.charCodeAt(n)===9);)n++;if(n>=e)return {type:"blockquote",skip:true,hasInlineSolve:false}}if(i===45||i===42||i===43){let n=o+1;for(;n<e&&(s.charCodeAt(n)===32||s.charCodeAt(n)===9);)n++;if(n>=e)return {type:"list",skip:false,hasInlineSolve:false}}if(l===void 0){let n=s.indexOf("s`",o);l=n!==-1&&n<e;}if(!l){let n=true;for(let p=o;p<e;p++){let u=s.charCodeAt(p);if(u>=128||S.CHAR_CLASS[u]>1){n=false;break}}if(n)return {type:"empty",skip:true,hasInlineSolve:false}}return {type:"expression",skip:false,hasInlineSolve:l}}classifyLine(r){let t=this.input,e=this.len,s=this.pos;this.input=r,this.len=r.length,this.pos=0;let o=this.classifyFromPositions(0,r.length);return this.input=t,this.len=e,this.pos=s,o}getKeywords(){return Object.fromEntries(this.mergedKeywords)}findInlineSolves(r){let t=[],e=r.length,s=0;for(;s<e;){let o=r.indexOf("s`",s);if(o===-1)break;let i=o+2,l=i;for(;l<e;){let u=r.charCodeAt(l);if(u===92&&l+1<e){l+=2;continue}if(u===96)break;l++;}l>=e&&(l=e);let n=r.slice(i,l),p=l<e?l+1:l;t.push({start:o,end:p,expression:n,columnNumber:o+1}),s=p;}return t}tokenizeComment(){let r=this.input,t=this.len,e=this.pos,s=e-this.lineStartPos+1;if(r.charCodeAt(e)===35){let l=this.matchHexColourEnd(e,t);if(l!==-1){let d=r.slice(e,l);return this.pos=l,new a("HEX_COLOUR",chunk5IJD5L3O_cjs.c("HEX_COLOUR"),d,d,e,0,this.line,s)}let n=r.charCodeAt(e+1),p=n>=65&&n<=90||n>=97&&n<=122,u=e>this.lineStartPos?r.charCodeAt(e-1):-1,f=u>=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||u===95;if(p&&!f){let d=e+2;for(;d<t;){let C=r.charCodeAt(d);if(!(C>=48&&C<=57||C>=65&&C<=90||C>=97&&C<=122||C===95||C===45))break;d++;}let A=r.slice(e+1,d);return this.pos=d,new a("TAG",chunk5IJD5L3O_cjs.c("TAG"),A,A,e,0,this.line,s)}}let o=this.pos;for(o+1<t&&r.charCodeAt(o+1)===47?o+=2:o++;o<t;){let l=r.charCodeAt(o);if(l===10||l===13)break;o++;}let i=r.slice(e,o);return this.pos=o,new a("COMMENT",chunk5IJD5L3O_cjs.c("COMMENT"),i,i,e,0,this.line,s)}};S.CHAR_CLASS=g();var I=S;exports.a=a;exports.b=I;//# sourceMappingURL=chunk-2LFLR3VZ.cjs.map
2
+ //# sourceMappingURL=chunk-2LFLR3VZ.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lexer/ExpressionLexer.ts"],"names":["registerAllTokenTypes","buildCharClassTable","table","i","isUnicodeSpace","cc","LexerToken","type","typeId","value","text","offset","lineBreaks","line","col","sourceEnd","TWO_CHAR_OPS","OP_MAP","EXPRESSION_INDICATOR_CODES","set","opCodes","c","_ExpressionLexer","localeCode","lookup","getLocale","k","v","knownUnits","rule","m","tokenTypeId","plugin","keyword","tokenType","lower","ErrorFactory","chars","first","second","builtInSecondMap","inner","unit","toRemove","r","input","results","docLen","lineStart","lineEnd","lineNumber","classification","lineText","tokens","rawToken","savedLen","inlineSolves","charSpans","span","nlChar","len","tokenIndex","openSpan","collectedSpans","c0","identLower","kwType","opType","token","pos","start","startCol","next","hasIntPart","d1","d2","d3","d4","isGroupOfExactlyThree","hasDecimal","nextCc","hasExponent","ec","identText","fullText","localeKwType","lookPos","parenPos","isWord","ch","isAlpha","wordEnd","hasAlpha","word","keywordType","c1","secondMap","twoCharType","commentPos","pluginInner","pluginType","end","indicatorCodes","from","after","hashPos","p","n","hasInline","idx","hashCount","count","trailPos","digitPos","tPos","tc","closePos","trail","onlySkippable","code","savedInput","savedPos","result","sPos","exprStart","exprEnd","expression","hexEnd","isLetter","prevCode","prevIsWordChar","tagEnd","name","ExpressionLexer"],"mappings":"yNAOAA,mBAAAA,EAAsB,CA8GtB,SAASC,CAAAA,EAAkC,CACzC,IAAMC,CAAAA,CAAQ,IAAI,UAAA,CAAW,GAAG,EAGhC,IAAA,IAASC,CAAAA,CAAI,EAAA,CAAIA,CAAAA,EAAK,GAAIA,CAAAA,EAAAA,CAAKD,CAAAA,CAAMC,CAAC,CAAA,CAAI,EAG1C,IAAA,IAASA,CAAAA,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AMyB,CAAAA,CAAQ,CAAA,CAAG6D,CAAM,CAAA,CAC1C,OAAA,IAAA,CAAK,GAAA,CAAMA,CAAAA,CACJ,IAAI7H,CAAAA,CAAW,KAAA,CAAOyB,mBAAAA,CAAY,KAAK,EAAGqG,CAAAA,CAAMA,CAAAA,CAAM9D,CAAAA,CAAO,CAAA,CAAG,KAAK,IAAA,CAAMC,CAAQ,CAC5F,CACF,CAEA,IAAIF,CAAAA,CAAM,IAAA,CAAK,GAAA,CAQf,IANIA,CAAAA,CAAM,CAAA,CAAIT,CAAAA,EAAOf,CAAAA,CAAM,WAAWwB,CAAAA,CAAM,CAAC,CAAA,GAAM,EAAA,CACjDA,GAAO,CAAA,CAEPA,CAAAA,EAAAA,CAGKA,CAAAA,CAAMT,CAAAA,EAAK,CAChB,IAAMI,CAAAA,CAAKnB,CAAAA,CAAM,UAAA,CAAWwB,CAAG,CAAA,CAC/B,GAAIL,CAAAA,GAAO,EAAA,EAAMA,IAAO,EAAA,CAAI,MAC5BK,CAAAA,GACF,CAEA,IAAM3D,CAAAA,CAAOmC,CAAAA,CAAM,KAAA,CAAMyB,CAAAA,CAAOD,CAAG,CAAA,CACnC,OAAA,IAAA,CAAK,GAAA,CAAMA,CAAAA,CACJ,IAAI/D,CAAAA,CAAW,SAAA,CAAWyB,mBAAAA,CAAY,SAAS,EAAGrB,CAAAA,CAAMA,CAAAA,CAAM4D,CAAAA,CAAO,CAAA,CAAG,KAAK,IAAA,CAAMC,CAAQ,CACpG,CACF,EA7rDajD,CAAAA,CACa,UAAA,CAAarB,CAAAA,EAAoB,KAD9CoI,CAAAA,CAAN/G","file":"chunk-2LFLR3VZ.cjs","sourcesContent":["import { Token, tokenTypeId, registerAllTokenTypes } from '@solve-js/lexer/Token';\nimport { knownUnits } from '@solve-js/lexer/units';\nimport { getLocale, type ILocale } from '@solve-js/constants/locales';\nimport { ErrorFactory } from '@solve-js/errors/UnifiedErrorFramework';\nimport type { TokenLookup } from '@solve-js/lexer/TokenClassRegistry';\n\n// Bootstrap all token types at module load\nregisterAllTokenTypes();\n\n// ── Markdown line classification (Phase B) ──────────────────────────────\n\n/** What a line is, structurally, before anything tries to evaluate it. */\nexport type MarkdownLineType =\n | 'expression'\n | 'prose'\n | 'heading'\n | 'blockquote'\n | 'list'\n | 'code_fence'\n | 'math_fence'\n | 'table'\n | 'table_separator'\n | 'hr'\n | 'wikilink'\n | 'comment'\n | 'empty';\n\n/**\n * What a line is and whether it holds anything to evaluate.\n *\n * Produced by a character-level scan that never consults the keyword, unit or\n * operator tables, so any lexer gives the same answer for the same line. See\n * `__tests__/lexer/LineClassificationIsVocabularyIndependent.spec.ts`.\n */\nexport interface LineClassification {\n /** The type of this markdown line */\n type: MarkdownLineType;\n /** Whether this line should be skipped (no expression evaluation) */\n skip: boolean;\n /** Whether the line contains inline solve markers (`s`...``) */\n hasInlineSolve: boolean;\n /**\n * Offset of the first evaluable character, when structural markup precedes\n * it. Absolute, in the same coordinates the classification was asked for,\n * and absent when the whole line is evaluable.\n *\n * A list marker is markup, not arithmetic. `- 100 + 20` is a bullet holding\n * `100 + 20`, but `-` is also a prefix operator, so without this the line\n * evaluated as negative one hundred and answered -80: a wrong answer that\n * looks like a right one. `*` and `+` in the same position could not even do\n * that, one erroring and the other correct by luck, so the three markers\n * disagreed with each other about the same document.\n *\n * Consumers must slice both the text and the token stream from here, or the\n * two describe different lines.\n */\n contentOffset?: number;\n}\n\n/** Inline solve position with precise coordinates */\nexport interface InlineSolveSpan {\n /** Character offset of the `s`` marker */\n start: number;\n /** Character offset past the closing `` ` `` */\n end: number;\n /** The expression text between the backticks */\n expression: string;\n /** 1-based column of the `s`` marker */\n columnNumber: number;\n /** Token index of INLINE_SOLVE_START in the line's token array (set during tokenization). */\n startTokenIndex?: number;\n /** Token index of closing BACKTICK_OPEN in the line's token array (set during tokenization). */\n endTokenIndex?: number;\n}\n\n/**\n * Result from a single line processed by scanDocument().\n * Combines line classification, tokenized tokens, and inline solve spans\n * into a single structure, eliminating the need for separate classifyLine()\n * findInlineSolves(), and per-line Lexer.reset() calls.\n */\nexport interface ScanLineResult {\n /** The raw line text (without trailing newline). */\n text: string;\n /** 1-based line number within the document. */\n lineNumber: number;\n /** Character offset of the line start within the document. */\n startOffset: number;\n /** Character offset of the line end (before newline). */\n endOffset: number;\n /** The line classification. */\n classification: LineClassification;\n /** Tokenized tokens (empty array if line is skipped). */\n tokens: Token[];\n /** Inline solve spans found in this line (empty if none). */\n inlineSolves: InlineSolveSpan[];\n}\n\n// ── Character class constants ─────────────────────────────────────────────\n// Used as the result of the CHAR_CLASS lookup table. V8 compiles the\n// outer switch on these small integer constants into a jump table.\nconst enum CharClass {\n SKIP = 0, // Invalid / control / unicode fallback\n WHITESPACE = 1, // space, tab, \\n, \\r\n DIGIT = 2, // 0-9\n ALPHA = 3, // a-z, A-Z, _\n DOT = 4, // . (could be decimal point or DOT token)\n OPERATOR = 5, // + - * / ^ % ( ) [ ] { } , : ; = ? & | ~ ! < >\n QUOTE = 6, // \"\n HASH = 7, // # (comment)\n DOLLAR = 8, // $\n POUND = 9, // £ (U+00A3)\n EURO = 10, // € (U+20AC)\n BACKTICK = 11, // `\n}\n\n// ── Static character class table (built once at module load) ──────────────\nfunction buildCharClassTable(): Uint8Array {\n const table = new Uint8Array(128);\n\n // Digits 0-9\n for (let i = 48; i <= 57; i++) table[i] = CharClass.DIGIT;\n\n // Uppercase A-Z\n for (let i = 65; i <= 90; i++) table[i] = CharClass.ALPHA;\n\n // Lowercase a-z\n for (let i = 97; i <= 122; i++) table[i] = CharClass.ALPHA;\n\n // Underscore\n table[95] = CharClass.ALPHA;\n\n // Dot\n table[46] = CharClass.DOT;\n\n // Whitespace\n table[32] = CharClass.WHITESPACE; // space\n table[9] = CharClass.WHITESPACE; // tab\n table[10] = CharClass.WHITESPACE; // \\n\n table[13] = CharClass.WHITESPACE; // \\r\n\n // Operators / punctuation\n table[33] = CharClass.OPERATOR; // !\n table[37] = CharClass.OPERATOR; // %\n table[38] = CharClass.OPERATOR; // &\n table[40] = CharClass.OPERATOR; // (\n table[41] = CharClass.OPERATOR; // )\n table[42] = CharClass.OPERATOR; // *\n table[43] = CharClass.OPERATOR; // +\n table[44] = CharClass.OPERATOR; // ,\n table[45] = CharClass.OPERATOR; // -\n table[47] = CharClass.OPERATOR; // /\n table[58] = CharClass.OPERATOR; // :\n table[59] = CharClass.OPERATOR; // ;\n table[60] = CharClass.OPERATOR; // <\n table[61] = CharClass.OPERATOR; // =\n table[62] = CharClass.OPERATOR; // >\n table[63] = CharClass.OPERATOR; // ?\n table[91] = CharClass.OPERATOR; // [\n table[93] = CharClass.OPERATOR; // ]\n table[94] = CharClass.OPERATOR; // ^\n table[123] = CharClass.OPERATOR; // {\n table[124] = CharClass.OPERATOR; // |\n table[125] = CharClass.OPERATOR; // }\n table[126] = CharClass.OPERATOR; // ~\n // \"@\" was previously unclassified (defaulted to CharClass.SKIP, silently\n // dropped before ever reaching OP_MAP). See OP_MAP's own \"@\" entry doc\n // comment for why this is being activated now.\n table[64] = CharClass.OPERATOR; // @\n\n // Other\n table[34] = CharClass.QUOTE; // \"\n table[35] = CharClass.HASH; // #\n table[36] = CharClass.DOLLAR; // $\n table[96] = CharClass.BACKTICK; // `\n\n return table;\n}\n\n/**\n * Whether a non-ASCII code point separates tokens rather than joining them.\n *\n * The CHAR_CLASS table above is 128 entries wide, so every code point past\n * ASCII falls through to one branch that reads it as part of an identifier.\n * That is right for `café`, `日本語` and emoji, and wrong for the dozen or so\n * code points that are whitespace without being ASCII whitespace. Without this,\n * a no-break space between two operands JOINED them: `1<NBSP>+<NBSP>1` lexed as\n * one identifier and reported \"Undefined variable: 1 + 1\", and a byte-order\n * mark at the head of a file did the same to its first line. Both arrive\n * constantly in pasted text, from a web page, a word processor, a spreadsheet\n * export, or a Windows editor that writes a BOM.\n *\n * The zero-width JOINERS are deliberately absent. U+200D is what holds a family\n * emoji together as one grapheme, and U+200C is its non-joining partner; both\n * bind their neighbours rather than separating them, so they stay identifier\n * characters. U+200B, the zero-width SPACE, is a separator despite being\n * invisible, which is exactly why it is worth handling: it is unreadable on\n * screen and would otherwise silently break the line it lands in.\n *\n * @param cc - A UTF-16 code unit, only meaningful for values >= 128.\n * @returns True when the character should be skipped like a space.\n */\nfunction isUnicodeSpace(cc: number): boolean {\n return (\n cc === 0x0085 || // NEL, next line\n cc === 0x00A0 || // no-break space\n cc === 0x1680 || // ogham space mark\n (cc >= 0x2000 && cc <= 0x200A) || // en quad through hair space, incl. figure/thin space\n cc === 0x200B || // zero-width space\n cc === 0x2028 || // line separator\n cc === 0x2029 || // paragraph separator\n cc === 0x202F || // narrow no-break space\n cc === 0x205F || // medium mathematical space\n cc === 0x3000 || // ideographic space\n cc === 0xFEFF // byte-order mark / zero-width no-break space\n );\n}\n\n// ── Monomorphic Token class ───────────────────────────────────────────────\n// V8 assigns a single stable HiddenClass because all properties are\n// initialized in the constructor and never added/removed afterwards.\n// This enables fast property access (inline cache hits) and allows\n// allocation in V8's nursery (cheap GC).\n// All 9 fields are always set, no optional fields, no different shapes.\n/**\n * A token, as the lexer produces it.\n *\n * A class rather than an object literal because tokens are created on every\n * keystroke and a shared hidden class keeps that path predictable for the\n * engine running it.\n */\nexport class LexerToken implements Token {\n constructor(\n public type: string,\n public typeId: number,\n public value: string,\n public text: string,\n public offset: number,\n public lineBreaks: number,\n public line: number,\n public col: number,\n /** See {@link Token.sourceEnd}. Set only on normalizer-fused tokens. */\n public sourceEnd?: number,\n ) {}\n}\n\n// ── Two-character operator lookup ─────────────────────────────────────────\n// Maps first-char → (second-char → token type). Used for operators like\n// ==, !=, >=, <=, **, <<, >>.\ninterface TwoCharOpMap {\n [firstChar: number]: { [secondChar: number]: string };\n}\nconst TWO_CHAR_OPS: TwoCharOpMap = {\n 61: { 61: 'EQUALITY', 62: 'THEREFORE' }, // ==, => (opposite char order from >='s GTE below — no collision)\n 33: { 61: 'NEQ' }, // !=\n 62: { 61: 'GTE' }, // >=\n 60: { 61: 'LTE' }, // <=\n 38: { 38: 'LOGICAL_AND' }, // &&\n 124: { 124: 'LOGICAL_OR' }, // ||\n 43: { 61: 'PLUS_EQUALS' }, // += (compound assignment, running totals)\n 45: { 61: 'MINUS_EQUALS' }, // -= (neither + nor - had a two-char op before)\n // Note: ** is NOT a single token, the existing moo lexer emits two\n // separate STAR tokens, and the parser consumes them that way.\n // 42: { 42: 'EXPONENT' }, // **, disabled for moo compatibility\n};\n// Note: LSHIFT (<<) and RSHIFT (>>) are handled separately because\n// 60 is also used for LTE, so we check LTE first then LSHIFT.\n\n// ── Single-character operator lookup ──────────────────────────────────────\nconst OP_MAP: Record<number, string> = {\n 43: 'PLUS', // +\n 45: 'MINUS', // -\n 42: 'STAR', // *\n 47: 'SLASH', // /\n 94: 'CARET', // ^\n 37: 'PERCENT', // %\n 40: 'LPAREN', // (\n 41: 'RPAREN', // )\n 91: 'LBRACKET', // [\n 93: 'RBRACKET', // ]\n 123: 'LBRACE', // {\n 125: 'RBRACE', // }\n 44: 'COMMA', // ,\n 58: 'COLON', // :\n 59: 'SEMICOLON',// ;\n 61: 'EQUALS', // =\n 63: 'QUESTION', // ?\n 33: 'BANG', // !\n 38: 'BIT_AND', // &\n 124: 'BIT_OR', // |\n 60: 'LT', // <\n 62: 'GT', // >\n 126: 'BIT_NOT', // ~\n // \"@\", activates the token type name already dormant-reserved for this\n // exact purpose (see Token.ts's OVER/RATE_AT doc comment and\n // normalizer/TokenNormalizer.ts's NON_WORD_NAMES, both of which already\n // anticipated \"AT\" as a future \"@\" symbol token before this addition).\n // Backs the time package's video-timecode literal's alternate fps\n // separator (`01:02:03:04 @ 30fps`, equivalent to `... at 30fps`). See\n // packages/time/parselets/VideoTimecodeParselet.ts.\n 64: 'AT', // @\n};\n\n/**\n * Plugin interface for extending the ExpressionLexer with custom tokens.\n *\n * Plugins can register:\n * - `keywords`: Map identifier strings to custom token types (checked after locale keywords).\n * - `operators`: Map multi-character operator sequences to custom token types.\n * - `units`: Register additional unit identifiers (checked alongside built-in units).\n *\n * Multi-word phrase matching has been moved to the TokenNormalizer post-lexer\n * stage. To register phrase patterns, use `IEnginePackage.normalizerRules` instead.\n *\n * All registrations are additive, built-in patterns still work.\n */\nexport interface LexerVocabulary {\n /**\n * Keyword → tokenType mappings. Each key is a lowercase identifier that,\n * when encountered, will emit the specified token type instead of IDENT.\n * These are checked AFTER the locale's built-in keywordMap, so locale\n * keywords take priority.\n */\n keywords?: Record<string, string>;\n\n /**\n * Multi-character operator → tokenType mappings. Each key is the exact\n * character sequence (e.g., \"::\", \"->\", \"=>\") and the value is the token\n * type to emit. Two-character operators take priority during matching.\n * Built-in operators (==, !=, >=, <=, <<, >>) always take priority.\n */\n operators?: Record<string, string>;\n\n /**\n * Additional unit identifiers to recognize (e.g., \"gp\", \"osrs\", \"tile\").\n * These are checked alongside the built-in `knownUnits` set.\n */\n units?: string[];\n\n /**\n * Whole-line patterns matched against the RAW line text, BEFORE any\n * per-character tokenization begins.\n *\n * Every other extension point in this file (`keywords`/`operators`/\n * `units`, plus `IEnginePackage.phrases`/`normalizerRules`) transforms\n * a token STREAM -- they all assume the line is, at some granularity,\n * valid Solve syntax. This hook exists for the one shape that isn't:\n * a package whose grammar captures arbitrary free-form text terminated\n * by a fixed marker (e.g. a natural-language query ending in `= ?`),\n * where the text itself (\"distance to the moon\") would never tokenize\n * or parse as a normal expression and must be captured verbatim\n * instead -- see `packages/knowledge/` for the reference use.\n *\n * Each entry's `pattern` is tested (via `RegExp.exec`) against the\n * full, untrimmed line text. If it matches AND capture group 1 is\n * non-empty after trimming, the ENTIRE line becomes a single\n * synthetic token of `tokenType` whose `value`/`text` is the trimmed\n * capture group -- the character-by-character scanner never runs for\n * that line. Patterns are tried in registration order; the first\n * match wins. A package registering a rule here still needs a\n * `prefixParselets` entry for `tokenType` to actually consume the\n * resulting token.\n *\n * Because this bypasses tokenization entirely, a matching line can\n * contain characters that would otherwise be lexer errors (unmatched\n * quotes, stray symbols, ...) -- by design, since the whole point is\n * to hand the package raw text the normal pipeline was never meant to\n * parse.\n */\n rawLinePatterns?: Array<{ pattern: RegExp; tokenType: string }>;\n}\n\n// ── Expression gating (L1) ──────────────────────────────────────────────\n// Pre-computed Set of character codes that indicate an expression might\n// be present. Used by hasExpressionIndicators() to gate prose lines\n// before full tokenization.\n//\n// NOTE: Currently unused, L1 prose gating was removed from classifyFromPositions()\n// because it incorrectly skipped keyword-only lines (\"pi\"), single identifiers\n// (\"hello\"), and short alpha lines. Retained for future re-implementation with\n// keyword-awareness and proper test coverage.\nconst EXPRESSION_INDICATOR_CODES = (() => {\n const set = new Set<number>();\n // Digits 0-9\n for (let i = 48; i <= 57; i++) set.add(i);\n // Operators / punctuation\n // Note: colon (58) is intentionally excluded, it's common in prose\n // (e.g., \"Subject: Hello world\") and would cause false-positive\n // expression classification. Variable assignment lines like\n // \":myVar = 5\" are still caught by '=' and digit indicators.\n const opCodes = [43, 45, 42, 47, 94, 37, 40, 41, 91, 93, 123, 125, 61, 60, 62, 33, 38, 124, 126, 59, 63];\n for (const c of opCodes) set.add(c);\n // Currency\n set.add(36); // $\n set.add(0x00A3); // £\n set.add(0x20AC); // €\n set.add(0x00A5); // ¥\n set.add(0x20BD); // ₽\n set.add(0x20A9); // ₩\n // Backtick (inline solve)\n set.add(96); // `\n // Dot (could be decimal)\n set.add(46); // .\n // Hash (comment, still an expression indicator)\n set.add(35); // #\n return set;\n})();\n\n// ── ExpressionLexer ───────────────────────────────────────────────────────\n/**\n * Character-by-character tokenizer for expression text.\n *\n * Scans a raw line/expression string into a stream of typed tokens\n * (numbers, identifiers, operators, units, keywords, ...), handling\n * markdown-line classification (`classifyLine`), inline `` s`...` `` solve\n * spans, and package-contributed vocabulary (registered via\n * {@link registerVocabulary}/{@link unregisterVocabulary}, keywords\n * operators, and units a package wants recognized as their own token\n * types rather than falling through to generic identifiers).\n *\n * Most consumers should use the higher-level {@link Lexer} wrapper, which\n * adds streaming `next()`/`peek()` access over this class's scan results.\n */\nexport class ExpressionLexer {\n private static readonly CHAR_CLASS = buildCharClassTable();\n /**\n * Configured TokenLookup from TokenClassRegistry. When set, replaces\n * the internal keyword map and unit set with registry-built equivalents.\n * Enables data-driven keyword/unit registration across locale keywords,\n * provider keywords, and plugins.\n *\n * Set at construction time via the constructor parameter. Plugin-registered\n * keywords/units (via registerVocabulary()) are checked alongside\n * the configuredLookup, neither source is bypassed.\n */\tprivate configuredLookup: TokenLookup | null = null;\n\n\t// Instance state\n private input: string = '';\n private pos: number = 0;\n private len: number = 0;\n\n // Line / column tracking (1-indexed)\n private line: number = 1;\n private lineStartPos: number = 0;\n\n // Open-bracket context stack for the current line, one entry per unclosed\n // `(`/`[`, `true` when a comma inside it is a separator rather than a\n // thousands group. A `[` (vector/matrix) and a CALL `(` (`rgb(255,255,255)`,\n // preceded by an identifier) are separator contexts; a bare GROUPING `(`\n // (`(1,000)`, preceded by an operator or the line start) is not, so a\n // parenthesised thousands number still reads as one scalar. The number scanner\n // consults the innermost entry. Tracked here because the flat token stream\n // carries no nesting otherwise; reset per line, so an unbalanced bracket\n // cannot bleed the decision into the next.\n private groupingStack: boolean[] = [];\n\n // Keyword map: lowercase identifier → token type (locale keywords only)\n private keywordMap: Map<string, string>;\n\n // ── Merged lookup collections (keywordMap + pluginKeywordMap, knownUnits + pluginUnits)\n private mergedKeywords: Map<string, string>;\n private mergedUnits: Set<string>;\n\n // Plugin-extensible keyword map (merged with locale keywordMap)\n private pluginKeywordMap: Map<string, string> = new Map();\n\n // Plugin-extensible two-char operators: firstChar → (secondChar → tokenType)\n private pluginOperators: Map<number, Map<number, string>> = new Map();\n\n // Plugin-extensible units (merged with knownUnits)\n private pluginUnits: Set<string> = new Set();\t// Fast-path guards: skip plugin lookups entirely when no plugins registered\n\tprivate hasPluginOps = false;\n\n // Locale for function-identifier lookups\n private localeCode: string;\n private locale: ILocale;\n\n /**\n * Inline solve spans collected during the most recent tokenization pass.\n * Populated by [Symbol.iterator]() and consumed by scanDocument().\n */\n _inlineSolveSpans: InlineSolveSpan[] = [];\n\n // Plugin-extensible raw-line patterns. See LexerVocabulary.rawLinePatterns.\n private pluginRawLinePatterns: Array<{ pattern: RegExp; tokenType: string }> = [];\n\n /**\n * If a `rawLinePatterns` rule matches the FULL text most recently passed\n * to {@link reset}, this holds the single synthetic token that\n * {@link tokenizeAll} should return instead of running the\n * character-by-character scanner. Cleared (re-evaluated) on every\n * {@link reset} call. `null` when no plugin registered any raw-line\n * patterns, or none matched, the overwhelmingly common case, checked\n * with a `length === 0` guard before ever touching this field so a\n * plugin-free lexer pays zero cost for the feature.\n */\n private pendingRawLineToken: Token | null = null;\n\n /**\n * Test `text` against every registered `rawLinePatterns` rule, in\n * registration order. Returns a synthetic token for the first rule\n * whose `pattern` matches AND whose capture group 1 is non-empty after\n * trimming; returns `null` if no rule matches (the normal\n * character-by-character scanner should run instead).\n */\n private matchRawLine(text: string): Token | null {\n for (const rule of this.pluginRawLinePatterns) {\n const m = rule.pattern.exec(text);\n if (m && typeof m[1] === 'string') {\n const value = m[1].trim();\n if (value.length > 0) {\n return new LexerToken(rule.tokenType, tokenTypeId(rule.tokenType), value, value, 0, 0, this.line, 1);\n }\n }\n }\n return null;\n }\n\n /** Rebuild merged keyword and unit collections after plugin registration. */\n private rebuildMergedCollections(): void {\n this.mergedKeywords = new Map([...this.keywordMap, ...this.pluginKeywordMap]);\n this.mergedUnits = new Set([...knownUnits, ...this.pluginUnits]);\n }\n\n constructor(localeCode = 'en', lookup?: TokenLookup) {\n this.localeCode = localeCode;\n this.locale = getLocale(localeCode);\n this.configuredLookup = lookup ?? null;\n this.keywordMap = new Map<string, string>();\n for (const [k, v] of Object.entries(this.locale.keywordMap)) {\n this.keywordMap.set(k.toLowerCase(), v);\n }\n this.mergedKeywords = new Map(this.keywordMap);\n this.mergedUnits = new Set(knownUnits);\n }\n\n /**\n * Register a plugin to extend the lexer with custom tokens.\n *\n * All registrations are additive, built-in patterns still work.\n * Keywords, operators, and units from the plugin are merged\n * with existing ones. Calling multiple times adds more entries.\n *\n * Note: multi-word phrases are now handled by the TokenNormalizer\n * (see `IEnginePackage.normalizerRules`), not the lexer.\n *\n * Built-in tokens CANNOT be overridden. Throws a EngineError if the\n * plugin attempts to register a keyword, operator, or unit\n * that conflicts with a built-in one.\n */\n registerVocabulary(plugin: LexerVocabulary): void {\n if (plugin.keywords) {\n for (const [keyword, tokenType] of Object.entries(plugin.keywords)) {\n const lower = keyword.toLowerCase();\n // Guard: prevent overriding built-in locale keywords\n if (this.keywordMap.has(lower)) {\n throw ErrorFactory.config(\n 'PLUGIN_KEYWORD_COLLISION',\n `Plugin keyword \"${keyword}\" conflicts with built-in keyword ` +\n `(type: ${this.keywordMap.get(lower)}). Built-in keywords cannot be overridden.`,\n { keyword, builtinType: this.keywordMap.get(lower) }\n );\n }\n this.pluginKeywordMap.set(lower, tokenType);\n }\n this.rebuildMergedCollections();\n }\n\n if (plugin.operators) {\n this.hasPluginOps = true;\n for (const [chars, tokenType] of Object.entries(plugin.operators)) {\n // Only support 2-char operators for the fast path\n if (chars.length === 2) {\n const first = chars.charCodeAt(0);\n const second = chars.charCodeAt(1);\n\n // Guard: prevent overriding built-in two-char operators (==, !=, >=, <=)\n const builtInSecondMap = TWO_CHAR_OPS[first];\n if (builtInSecondMap && builtInSecondMap[second] !== undefined) {\n throw ErrorFactory.config(\n 'PLUGIN_OPERATOR_COLLISION',\n `Plugin operator \"${chars}\" conflicts with built-in operator ` +\n `(type: ${builtInSecondMap[second]}). Built-in operators cannot be overridden.`,\n { operator: chars, builtinType: builtInSecondMap[second] }\n );\n }\n // Guard: prevent overriding LSHIFT (<<) and RSHIFT (>>)\n if (first === 60 && second === 60) {\n throw ErrorFactory.config(\n 'PLUGIN_OPERATOR_COLLISION',\n `Plugin operator \"${chars}\" conflicts with built-in operator ` +\n `(type: LSHIFT). Built-in operators cannot be overridden.`,\n { operator: chars, builtinType: 'LSHIFT' }\n );\n }\n if (first === 62 && second === 62) {\n throw ErrorFactory.config(\n 'PLUGIN_OPERATOR_COLLISION',\n `Plugin operator \"${chars}\" conflicts with built-in operator ` +\n `(type: RSHIFT). Built-in operators cannot be overridden.`,\n { operator: chars, builtinType: 'RSHIFT' }\n );\n }\n // Guard: prevent overriding comment sequences (//)\n if (first === 47 && second === 47) {\n throw ErrorFactory.config(\n 'PLUGIN_OPERATOR_COLLISION',\n `Plugin operator \"${chars}\" conflicts with built-in comment sequence. ` +\n `Comment sequences cannot be overridden.`,\n { operator: chars, builtinType: 'COMMENT' }\n );\n }\n\n let inner = this.pluginOperators.get(first);\n if (!inner) {\n inner = new Map();\n this.pluginOperators.set(first, inner);\n }\n inner.set(second, tokenType);\n }\n }\n }\n\n if (plugin.units) {\n for (const unit of plugin.units) {\n // Guard: prevent overriding built-in units\n if (knownUnits.has(unit)) {\n throw ErrorFactory.config(\n 'PLUGIN_UNIT_COLLISION',\n `Plugin unit \"${unit}\" conflicts with a built-in unit. ` +\n `Built-in units cannot be overridden.`,\n { unit }\n );\n }\n this.pluginUnits.add(unit);\n }\n this.rebuildMergedCollections();\n }\n\n if (plugin.rawLinePatterns) {\n this.pluginRawLinePatterns.push(...plugin.rawLinePatterns);\n }\n }\n\n /**\n * Unregister a plugin, removing its custom tokens from the lexer.\n *\n * This is the inverse of registerVocabulary(). All keywords, operators,\n * and units registered by the plugin are removed. After\n * unregistration, those tokens will revert to their default behavior\n * (e.g., keywords become IDENT, operators become ERROR).\n *\n * Calling unregisterVocabulary with a plugin that was never registered\n * is safe, it simply has no effect.\n */\n unregisterVocabulary(plugin: LexerVocabulary): void {\n if (plugin.keywords) {\n for (const keyword of Object.keys(plugin.keywords)) {\n this.pluginKeywordMap.delete(keyword.toLowerCase());\n }\n \n this.rebuildMergedCollections();\n }\n\n if (plugin.operators) {\n for (const chars of Object.keys(plugin.operators)) {\n if (chars.length === 2) {\n const first = chars.charCodeAt(0);\n const second = chars.charCodeAt(1);\n const inner = this.pluginOperators.get(first);\n if (inner) {\n inner.delete(second);\n if (inner.size === 0) {\n this.pluginOperators.delete(first);\n }\n }\n }\n }\n this.hasPluginOps = this.pluginOperators.size > 0;\n }\n\n if (plugin.units) {\n for (const unit of plugin.units) {\n this.pluginUnits.delete(unit);\n }\n \n this.rebuildMergedCollections();\n }\n\n if (plugin.rawLinePatterns) {\n const toRemove = new Set(plugin.rawLinePatterns);\n this.pluginRawLinePatterns = this.pluginRawLinePatterns.filter((r) => !toRemove.has(r));\n }\n }\n\n reset(input: string): void {\n this.input = input;\n this.pos = 0;\n this.len = input.length;\n this.line = 1;\n this.lineStartPos = 0;\n this.pendingRawLineToken = this.pluginRawLinePatterns.length > 0 ? this.matchRawLine(input) : null;\n }\n\n /**\n * Scan a full document text in a single pass, classifying each line and\n * tokenizing non-skipped lines.\n *\n * Replaces the separate classifyLine() + findInlineSolves() + per-line\n * reset() + tokenizeAll() pattern with a single character-by-character\n * walk through the entire document. Key benefits:\n *\n * - **Single reset()**: `this.pos`, `this.len`, `this.line`, and\n * `this.lineStartPos` are set once for the whole document, not per-line.\n * - **Single classification**: classifyLine() runs once per line inline;\n * skipped lines are jumped over without tokenization.\n * - **Shared tokenization**: Non-skipped lines are tokenized using the\n * existing state machine, yielding Token[] without per-line reset().\n * - **Inline solve detection**: findInlineSolves() is called only for\n * lines that classifyLine() marks as having inline solves.\n *\n * Tokenization is scoped to each line by temporarily restricting\n * `this.len` to the line end position, so the [Symbol.iterator]\n * generator naturally stops at the line boundary. After tokenization,\n * `this.len` is restored and `this.pos` advances past the newline.\n *\n * @param text The full document text (with newlines).\n * @returns Array of ScanLineResult, one per line, in document order.\n */\n scanDocument(text: string): ScanLineResult[] {\n this.input = text;\n this.pos = 0;\n this.len = text.length;\n this.line = 1;\n this.lineStartPos = 0;\n\n const results: ScanLineResult[] = [];\n const input = this.input;\n const docLen = this.len;\n\n while (this.pos < docLen) {\n const lineStart = this.pos;\n\n // ── Find end of current line (newline boundary) ───────────────\n let lineEnd = this.pos;\n while (lineEnd < docLen) {\n const cc = input.charCodeAt(lineEnd);\n if (cc === 10 || cc === 13) break; // \\n or \\r\n lineEnd++;\n }\n\n const lineNumber = this.line;\n\n // ── Classify the line ─────────────────────────────────────────\n // Uses classifyFromPositions() to read from this.input directly\n // avoids allocating a substring and keeps classification reads\n // within the same memory region as tokenization.\n const classification = this.classifyFromPositions(lineStart, lineEnd);\n\n // ── Slice line text for ScanLineResult.text ────────────────\n // Hoisted above tokenization (rather than after, as originally) so the\n // raw-line-pattern check below can test the exact substring a plugin\n // registered via `LexerVocabulary.rawLinePatterns`. See reset()/\n // tokenizeAll() for the single-expression-string equivalent of this\n // same check.\n const lineText = input.slice(lineStart, lineEnd);\n\n // ── Tokenize non-skipped lines ────────────────────────────────\n let tokens: Token[] = [];\n if (!classification.skip) {\n const rawToken = this.pluginRawLinePatterns.length > 0 ? this.matchRawLine(lineText) : null;\n if (rawToken) {\n tokens = [rawToken];\n } else {\n // Scope tokenization to just this line by temporarily restricting len.\n // The [Symbol.iterator]() generator captures `this.len` at call time,\n // so creating the iterator AFTER setting this.len = lineEnd ensures\n // tokenization stops at the line boundary. After tokenization,\n // this.pos will be at lineEnd (the newline position).\n const savedLen = this.len;\n this.len = lineEnd;\n // Start past any structural marker, so the marker never becomes a\n // token. Token source offsets stay absolute, so everything\n // downstream (spans, highlighting, inline solves) still lines up\n // with the raw document.\n if (classification.contentOffset !== undefined) this.pos = classification.contentOffset;\n tokens = Array.from(this);\n this.len = savedLen;\n // this.pos is now at lineEnd, advance past newline below\n }\n }\n\n // ── Detect inline solves ──────────────────────────────────────\n // Two data sources are merged:\n // 1. _inlineSolveSpans, token indices collected inline during\n // [Symbol.iterator](). Provides correct startTokenIndex /\n // endTokenIndex. Also handles \\` escape (skips the pair\n // instead of closing the span early).\n // 2. findInlineSolves(), character-level string scan for\n // expression text. Still needed because token-based\n // reconstruction loses whitespace (the lexer skips spaces),\n // which breaks multi-word expressions like\n // \"2 weeks in days\" → \"2weeksindays\" (wrong tokenization).\n let inlineSolves: InlineSolveSpan[] = [];\n if (classification.hasInlineSolve) {\n if (!classification.skip && tokens.length > 0) {\n const charSpans = this.findInlineSolves(lineText);\n inlineSolves = this._inlineSolveSpans.map((span, i) => ({\n start: charSpans[i]?.start ?? 0,\n end: charSpans[i]?.end ?? 0,\n expression: charSpans[i]?.expression ?? '',\n columnNumber: charSpans[i]?.columnNumber ?? span.columnNumber,\n startTokenIndex: span.startTokenIndex,\n endTokenIndex: span.endTokenIndex,\n }));\n } else {\n // Skipped lines weren't tokenized, fall back to string scan\n inlineSolves = this.findInlineSolves(lineText);\n }\n }\n\n results.push({\n text: lineText,\n lineNumber,\n startOffset: lineStart,\n endOffset: lineEnd,\n classification,\n tokens,\n inlineSolves,\n });\n\n // ── Advance past newline ─────────────────────────────────────\n this.pos = lineEnd;\n if (this.pos < docLen) {\n const nlChar = input.charCodeAt(this.pos);\n if (nlChar === 13) { // \\r\n this.pos++;\n if (this.pos < docLen && input.charCodeAt(this.pos) === 10) {\n this.pos++; // skip \\n in \\r\\n\n }\n } else if (nlChar === 10) { // \\n\n this.pos++;\n }\n }\n this.line++;\n this.lineStartPos = this.pos;\n }\n\n return results;\n }\n\n /**\n * Tokenize an expression string into an array of Tokens.\n *\n * Delegates to the lazy [Symbol.iterator]() generator and collects all\n * yielded tokens via Array.from(). For memory-sensitive use cases, prefer\n * iterating the lexer directly with for...of to avoid array allocation.\n *\n * Optimizations:\n * - CHAR_CLASS jump table (Uint8Array) → switch on small integers\n * - Direct character-code dispatch (c0 cached pattern)\n * - Mathematical digit parsing (integer math, not slice+parseFloat)\n * - Inline operator tokenizer with two-char peek-ahead\n * - Whitespace eliminated in-lexer (never emitted)\n * - 0-char and 1-char fast paths\n */\n tokenizeAll(): Token[] {\n if (this.pendingRawLineToken) {\n this._inlineSolveSpans = [];\n return [this.pendingRawLineToken];\n }\n return Array.from(this);\n }\n\n // ── Lazy iterator ─────────────────────────────────────────────────────\n /**\n * Lazy token-by-token generator. Yields each token without allocating an\n * intermediate Token[] array. Supports for...of and spread usage.\n *\n * Usage:\n * for (const t of lexer) { ... } // lazy, no array allocation\n * const tokens = [...lexer]; // materializes via spread\n * const tokens = lexer.tokenizeAll(); // materializes via Array.from()\n *\n * IMPORTANT: This generator captures `this.len` ONCE at creation time\n * (const len = this.len). `scanDocument()` relies on this behavior to\n * scope tokenization to a single line by temporarily restricting\n * `this.len` to the line end position before creating the iterator.\n * Do NOT refactor to re-read `this.len` mid-loop without also updating\n * `scanDocument()`.\n */\n *[Symbol.iterator](): Generator<Token, void, undefined> {\n const len = this.len;\n\n // ── 0-char fast path ────────────────────────────────────────────────\n if (len === 0) { this._inlineSolveSpans = []; return; }\n\n // Inline solve tracking state, collected inline during tokenization\n let tokenIndex = 0;\n let openSpan: { startTokenIndex: number; startColumn: number } | null = null;\n const collectedSpans: InlineSolveSpan[] = [];\n\n // ── 1-char fast path ────────────────────────────────────────────────\n if (len === 1) {\n const c0 = this.input.charCodeAt(0);\n const cc = ExpressionLexer.CHAR_CLASS[c0] ?? CharClass.SKIP;\n\n switch (cc) {\n case CharClass.DIGIT:\n case CharClass.DOT:\n yield new LexerToken('NUMBER', tokenTypeId('NUMBER'), this.input, this.input, 0, 0, 1, 1);\n tokenIndex++;\n break;\n\n case CharClass.ALPHA: {\n const input = this.input;\n const identLower = input.toLowerCase();\n // Use pre-merged collections (built-in + plugin), single lookup each\n if (this.mergedUnits.has(input)) {\n yield new LexerToken('UNIT', tokenTypeId('UNIT'), input, input, 0, 0, 1, 1);\n } else {\n const kwType = this.mergedKeywords.get(identLower);\n if (kwType) {\n yield new LexerToken(kwType, tokenTypeId(kwType), input, input, 0, 0, 1, 1);\n } else {\n yield new LexerToken('IDENT', tokenTypeId('IDENT'), input, input, 0, 0, 1, 1);\n }\n }\n tokenIndex++;\n break;\n }\n\n case CharClass.OPERATOR: {\n const opType = OP_MAP[c0];\n if (opType) {\n yield new LexerToken(opType, tokenTypeId(opType), this.input, this.input, 0, 0, 1, 1);\n tokenIndex++;\n }\n break;\n }\n\n case CharClass.QUOTE:\n // Delegate to tokenizeString for correctness (handles unterminated)\n this.pos = 0;\n yield this.tokenizeString();\n tokenIndex++;\n break;\n\n case CharClass.HASH:\n // Delegate to tokenizeComment for correctness\n this.pos = 0;\n yield this.tokenizeComment();\n tokenIndex++;\n break;\n\n case CharClass.DOLLAR:\n yield new LexerToken('DOLLAR', tokenTypeId('DOLLAR'), '$', '$', 0, 0, 1, 1);\n tokenIndex++;\n break;\n\n case CharClass.BACKTICK:\n // s` is 2 chars, openSpan can never be set in the 1-char fast path\n yield new LexerToken('BACKTICK_OPEN', tokenTypeId('BACKTICK_OPEN'), '`', '`', 0, 0, 1, 1);\n tokenIndex++;\n break;\n\n default: {\n // CharClass.SKIP, includes non-ASCII characters (code >= 128)\n if (isUnicodeSpace(c0)) {\n // A line holding nothing but a no-break space or a byte-order mark\n // holds no expression, exactly as a line holding one space does.\n // Yielding an IDENT for it made it an undefined variable instead.\n } else if (c0 === 0x00D7) { // × → STAR\n yield new LexerToken('STAR', tokenTypeId('STAR'), '\\u00D7', '\\u00D7', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x00F7) { // ÷ → SLASH\n yield new LexerToken('SLASH', tokenTypeId('SLASH'), '\\u00F7', '\\u00F7', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x00B1) { // U+00B1 plus-minus sign, the uncertainty operator\n yield new LexerToken('PLUS_MINUS', tokenTypeId('PLUS_MINUS'), '\\u00B1', '\\u00B1', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x2260) { // ≠ → NEQ\n yield new LexerToken('NEQ', tokenTypeId('NEQ'), '\\u2260', '\\u2260', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x00A3) { // £\n yield new LexerToken('POUND', tokenTypeId('POUND'), '\\u00A3', '\\u00A3', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x20AC) { // €\n yield new LexerToken('EURO', tokenTypeId('EURO'), '\\u20AC', '\\u20AC', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x00A5) { // ¥\n yield new LexerToken('YEN', tokenTypeId('YEN'), '¥', '¥', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x20BD) { // ₽\n yield new LexerToken('RUBLE', tokenTypeId('RUBLE'), '₽', '₽', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x20A9) { // ₩\n yield new LexerToken('WON', tokenTypeId('WON'), '₩', '₩', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x20B9) { // ₹ (Indian rupee) — see uom/CurrencyAliases.ts\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₹', '₹', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x20BA) { // ₺ (Turkish lira)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₺', '₺', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x20B4) { // ₴ (Ukrainian hryvnia)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₴', '₴', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x20AA) { // ₪ (Israeli new shekel)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₪', '₪', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x20AB) { // ₫ (Vietnamese dong)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₫', '₫', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x20A6) { // ₦ (Nigerian naira)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₦', '₦', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x20B1) { // ₱ (Philippine peso)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₱', '₱', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 >= 128) {\n // Unknown unicode, treat as IDENT for forward compatibility\n yield new LexerToken('IDENT', tokenTypeId('IDENT'), this.input, this.input, 0, 0, 1, 1);\n tokenIndex++;\n }\n break;\n }\n }\n this._inlineSolveSpans = collectedSpans;\n return;\n }\n\n const input = this.input;\n // Fresh nesting stack for this pass (see the field's doc).\n this.groupingStack.length = 0;\n\n // ── Main tokenization loop ──────────────────────────────────────────\n while (this.pos < len) {\n const c0 = input.charCodeAt(this.pos);\n const cc = ExpressionLexer.CHAR_CLASS[c0] ?? CharClass.SKIP;\n\n // ── Escaped backtick inside inline solve ────────────────────────\n // \\` is treated as an escaped backtick, skip both characters\n // without closing the inline solve span. Without this, the\n // backtick would close the span early, producing wrong expression\n // text for expressions like s`hello \\` world`.\n if (openSpan && c0 === 92 && this.pos + 1 < len && input.charCodeAt(this.pos + 1) === 96) {\n this.pos += 2; // skip \\ and `\n continue;\n }\n\n switch (cc) {\n // ── Whitespace, skip entirely, track newlines ────────────────\n case CharClass.WHITESPACE:\n this.pos++;\n if (c0 === 10) { // \\n\n this.line++;\n this.lineStartPos = this.pos;\n this.groupingStack.length = 0; // each line groups thousands on its own\n } else if (c0 === 13) { // \\r\n this.line++;\n if (this.pos < len && input.charCodeAt(this.pos) === 10) {\n this.pos++; // skip \\n in \\r\\n\n }\n this.lineStartPos = this.pos;\n this.groupingStack.length = 0;\n }\n break;\n\n // ── Digit, inline number tokenizer ───────────────────────────\n case CharClass.DIGIT:\n yield this.tokenizeNumber();\n tokenIndex++;\n break;\n\n // ── Alpha / underscore, identifier or keyword ────────────────\n case CharClass.ALPHA: {\n const token = this.tokenizeIdentifier();\n if (token.type === 'INLINE_SOLVE_START') {\n openSpan = { startTokenIndex: tokenIndex, startColumn: token.col };\n }\n yield token;\n tokenIndex++;\n break;\n }\n\n // ── Dot, could be decimal (.5) or DOT token ─────────────────\n case CharClass.DOT:\n if (this.pos + 1 < len) {\n const nextCc = ExpressionLexer.CHAR_CLASS[input.charCodeAt(this.pos + 1)] ?? CharClass.SKIP;\n if (nextCc === CharClass.DIGIT) {\n yield this.tokenizeNumber();\n } else {\n const col = this.pos - this.lineStartPos + 1;\n yield new LexerToken('DOT', tokenTypeId('DOT'), '.', '.', this.pos, 0, this.line, col);\n this.pos++;\n }\n } else {\n const col = this.pos - this.lineStartPos + 1;\n yield new LexerToken('DOT', tokenTypeId('DOT'), '.', '.', this.pos, 0, this.line, col);\n this.pos++;\n }\n tokenIndex++;\n break;\n\n // ── Operator / punctuation ────────────────────────────────────\n case CharClass.OPERATOR:\n yield this.tokenizeOperator();\n tokenIndex++;\n break;\n\n // ── String literal ────────────────────────────────────────────\n case CharClass.QUOTE:\n yield this.tokenizeString();\n tokenIndex++;\n break;\n\n // ── Comment (# or //) ─────────────────────────────────────────\n case CharClass.HASH:\n yield this.tokenizeComment();\n tokenIndex++;\n break;\n\n // ── Dollar sign $ ─────────────────────────────────────────────\n case CharClass.DOLLAR: {\n const col = this.pos - this.lineStartPos + 1;\n yield new LexerToken('DOLLAR', tokenTypeId('DOLLAR'), '$', '$', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n break;\n }\n\n // ── Backtick ` ───────────────────────────────────────────────\n case CharClass.BACKTICK: {\n const col = this.pos - this.lineStartPos + 1;\n yield new LexerToken('BACKTICK_OPEN', tokenTypeId('BACKTICK_OPEN'), '`', '`', this.pos, 0, this.line, col);\n this.pos++;\n if (openSpan) {\n const span = openSpan; // narrow for TS\n collectedSpans.push({\n start: 0, end: 0, expression: '',\n columnNumber: span.startColumn,\n startTokenIndex: span.startTokenIndex,\n endTokenIndex: tokenIndex,\n });\n openSpan = null;\n }\n tokenIndex++;\n break;\n }\n\n // ── Non-ASCII characters ─────────────────────────────────────\n default: {\n const col = this.pos - this.lineStartPos + 1;\n if (isUnicodeSpace(c0)) {\n // Separates its neighbours instead of joining them. See\n // isUnicodeSpace()'s doc comment: this branch is why a sum pasted\n // out of a web page or a spreadsheet evaluates at all.\n this.pos++;\n if (c0 === 0x2028 || c0 === 0x2029 || c0 === 0x0085) {\n // The three that are line breaks rather than spaces, tracked the\n // same way \"\\n\" is above so a later token reports its own line.\n this.line++;\n this.lineStartPos = this.pos;\n }\n } else if (c0 === 0x00D7) { // × → STAR\n yield new LexerToken('STAR', tokenTypeId('STAR'), '\\u00D7', '\\u00D7', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x00F7) { // ÷ → SLASH\n yield new LexerToken('SLASH', tokenTypeId('SLASH'), '\\u00F7', '\\u00F7', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x00B1) { // U+00B1 plus-minus sign, the uncertainty operator\n yield new LexerToken('PLUS_MINUS', tokenTypeId('PLUS_MINUS'), '\\u00B1', '\\u00B1', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x2260) { // ≠ → NEQ\n yield new LexerToken('NEQ', tokenTypeId('NEQ'), '\\u2260', '\\u2260', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x00A3) { // £\n yield new LexerToken('POUND', tokenTypeId('POUND'), '\\u00A3', '\\u00A3', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x20AC) { // €\n yield new LexerToken('EURO', tokenTypeId('EURO'), '\\u20AC', '\\u20AC', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x00A5) { // ¥\n yield new LexerToken('YEN', tokenTypeId('YEN'), '¥', '¥', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x20BD) { // ₽\n yield new LexerToken('RUBLE', tokenTypeId('RUBLE'), '₽', '₽', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x20A9) { // ₩\n yield new LexerToken('WON', tokenTypeId('WON'), '₩', '₩', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x20B9) { // ₹ (Indian rupee) — see uom/CurrencyAliases.ts\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₹', '₹', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x20BA) { // ₺ (Turkish lira)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₺', '₺', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x20B4) { // ₴ (Ukrainian hryvnia)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₴', '₴', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x20AA) { // ₪ (Israeli new shekel)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₪', '₪', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x20AB) { // ₫ (Vietnamese dong)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₫', '₫', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x20A6) { // ₦ (Nigerian naira)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₦', '₦', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x20B1) { // ₱ (Philippine peso)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₱', '₱', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 >= 128) {\n // Unknown unicode, treat as IDENT for forward compatibility.\n // tokenizeIdentifier() now includes cc >= 128 in its reading loop,\n // so this properly advances past all consecutive Unicode chars.\n yield this.tokenizeIdentifier();\n tokenIndex++;\n } else {\n // Unknown ASCII, silently skip\n this.pos++;\n }\n break;\n }\n }\n }\n this._inlineSolveSpans = collectedSpans;\n }\n\n // ── Inline number tokenizer ────────────────────────────────────────────\n /**\n * Character-by-character number parsing.\n *\n * Supports: integers, floats, scientific notation (1.5e10, 1.5e-10),\n * hex (0xFF), binary (0b1010), octal (0o17), BigInt suffix (123n),\n * thousands separators (1,234 or 1.234.567).\n *\n * Returns a LexerToken and advances `this.pos` past the number.\n */\n private tokenizeNumber(): Token {\n const input = this.input;\n const len = this.len;\n let pos = this.pos;\n const start = pos;\n const startCol = pos - this.lineStartPos + 1;\n let cc: number;\n\n // ── Hex literal: 0x / 0X ───────────────────────────────────────────\n if (input.charCodeAt(pos) === 48 && pos + 1 < len) {\n const next = input.charCodeAt(pos + 1);\n if (next === 0x78 || next === 0x58) { // 'x' or 'X'\n pos += 2;\n while (\n pos < len &&\n ((cc = input.charCodeAt(pos)),\n (cc >= 48 && cc <= 57) || (cc >= 65 && cc <= 70) || (cc >= 97 && cc <= 102))\n ) {\n pos++;\n }\n const text = input.slice(start, pos);\n this.pos = pos;\n return new LexerToken('NUMBER', tokenTypeId('NUMBER'), text, text, start, 0, this.line, startCol);\n }\n // ── Binary literal: 0b / 0B ─────────────────────────────────────\n if (next === 0x62 || next === 0x42) { // 'b' or 'B'\n pos += 2;\n while (pos < len && ((cc = input.charCodeAt(pos)), cc === 48 || cc === 49)) {\n pos++;\n }\n const text = input.slice(start, pos);\n this.pos = pos;\n return new LexerToken('NUMBER', tokenTypeId('NUMBER'), text, text, start, 0, this.line, startCol);\n }\n // ── Octal literal: 0o / 0O ───────────────────────────────────────\n if (next === 0x6F || next === 0x4F) { // 'o' or 'O'\n pos += 2;\n while (pos < len && ((cc = input.charCodeAt(pos)), cc >= 48 && cc <= 55)) {\n pos++;\n }\n const text = input.slice(start, pos);\n this.pos = pos;\n return new LexerToken('NUMBER', tokenTypeId('NUMBER'), text, text, start, 0, this.line, startCol);\n }\n }\n\n let hasIntPart = false;\n\n // ── Integer part ───────────────────────────────────────────────────\n while (pos < len && ((cc = input.charCodeAt(pos)), cc >= 48 && cc <= 57)) {\n hasIntPart = true;\n pos++;\n }\n\n // ── Thousands separators, coalesce with digits ────────────────────\n while (hasIntPart && pos < len && (input.charCodeAt(pos) === 44 || input.charCodeAt(pos) === 46)) {\n // A comma inside a call or bracket is an argument/element separator, not a\n // thousands group: `rgb(255,255,255)` is three numbers and `[100,200,300]`\n // a three-element vector, not `255255255`/`100200300`. A comma in a bare\n // grouping paren (`(1,000)`) still groups thousands, and so does a\n // top-level comma (`1,000,000`). The innermost bracket's context decides;\n // the `.` grouping form is context-free and unaffected. See\n // {@link groupingStack}.\n if (\n input.charCodeAt(pos) === 44 &&\n this.groupingStack.length > 0 &&\n this.groupingStack[this.groupingStack.length - 1]\n ) {\n break;\n }\n if (pos + 4 <= len) {\n const d1 = input.charCodeAt(pos + 1);\n const d2 = input.charCodeAt(pos + 2);\n const d3 = input.charCodeAt(pos + 3);\n // A genuine thousands group is always exactly 3 digits, followed\n // by either another separator, or a non-digit (end of number,\n // operator, unit, EOF), never a 4th consecutive digit. Without\n // this check, a plain decimal fraction with 4+ digits after the\n // point, e.g. \"0.0001\", had its first 3 fractional digits\n // misread as a \".\" thousands-group, silently truncating the\n // number to \"0.000\" and leaving the remaining digit(s) as a\n // separate, unrelated NUMBER token right after it (so\n // \"0.0001 BTC to USD\" tokenized as \"0.000\", \"1\", \"BTC\", \"to\",\n // \"USD\", two number literals instead of one, and evaluated to\n // a bare 0 instead of a real BTC quantity).\n const d4 = pos + 4 < len ? input.charCodeAt(pos + 4) : -1;\n const isGroupOfExactlyThree = !(d4 >= 48 && d4 <= 57);\n if (\n d1 >= 48 && d1 <= 57 &&\n d2 >= 48 && d2 <= 57 &&\n d3 >= 48 && d3 <= 57 &&\n isGroupOfExactlyThree\n ) {\n pos += 4;\n hasIntPart = true;\n continue;\n }\n }\n break;\n }\n\n // ── Decimal part (.xxx) ───────────────────────────────────────────\n let hasDecimal = false;\n if (pos < len && input.charCodeAt(pos) === 46) {\n if (pos + 1 < len) {\n const nextCc = input.charCodeAt(pos + 1);\n if (nextCc >= 48 && nextCc <= 57) {\n hasDecimal = true;\n pos++;\n while (pos < len && ((cc = input.charCodeAt(pos)), cc >= 48 && cc <= 57)) {\n pos++;\n }\n }\n }\n }\n\n // ── Exponent (e / E [+-]? \\n+) ────────────────────────────────────\n let hasExponent = false;\n if (pos < len) {\n const ec = input.charCodeAt(pos);\n if (ec === 0x65 || ec === 0x45) { // 'e' or 'E'\n if (pos + 1 < len) {\n const next = input.charCodeAt(pos + 1);\n if (\n (next >= 48 && next <= 57) ||\n next === 43 || next === 45 // + or -\n ) {\n hasExponent = true;\n pos++;\n if (next === 43 || next === 45) pos++;\n while (pos < len && ((cc = input.charCodeAt(pos)), cc >= 48 && cc <= 57)) {\n pos++;\n }\n }\n }\n }\n }\n\n // ── BigInt suffix check ────────────────────────────────────────────\n if (pos < len && input.charCodeAt(pos) === 110) { // 'n'\n if (hasIntPart && !hasDecimal && !hasExponent) {\n pos++;\n const text = input.slice(start, pos);\n this.pos = pos;\n return new LexerToken('BIGINT', tokenTypeId('BIGINT'), text, text, start, 0, this.line, startCol);\n }\n }\n\n // ── Emit NUMBER token ──────────────────────────────────────────────\n const text = input.slice(start, pos);\n this.pos = pos;\n return new LexerToken('NUMBER', tokenTypeId('NUMBER'), text, text, start, 0, this.line, startCol);\n }\n\n // ── Inline identifier / keyword tokenizer ──────────────────────────────\n /**\n * Reads [a-zA-Z_][a-zA-Z0-9_]* and resolves to:\n * - A unit type (via knownUnits, case-sensitive)\n * - A keyword type (via locale keywordMap, case-insensitive)\n * - IDENT if none of the above\n *\n * Multi-word phrases (e.g., \"to the power of\") are handled by the\n * TokenNormalizer post-lexer pass, not the lexer.\n */\n private tokenizeIdentifier(): Token {\n const input = this.input;\n const len = this.len;\n let pos = this.pos;\n const start = pos;\n const startCol = pos - this.lineStartPos + 1;\n let cc: number;\n\n // Read [a-zA-Z0-9_]* plus any Unicode (>= 128) including emoji surrogate pairs.\n // Without this, non-ASCII characters cause an infinite loop: the default case\n // calls tokenizeIdentifier(), the while loop doesn't match the Unicode char,\n // pos never advances, and the outer loop re-reads the same char forever.\n while (\n pos < len &&\n ((cc = input.charCodeAt(pos)),\n (cc >= 48 && cc <= 57) || // 0-9\n (cc >= 65 && cc <= 90) || // A-Z\n (cc >= 97 && cc <= 122) || // a-z\n cc === 95 || // _\n (cc >= 128 && !isUnicodeSpace(cc))) // Unicode (accented chars, emoji, etc.), but not Unicode whitespace\n ) {\n pos++;\n }\n\n const identText = input.slice(start, pos);\n const identLower = identText.toLowerCase();\n\n // ── Inline solve marker: s` (lowercase 's' followed by backtick) ──\n if (identLower === 's' && pos < len && input.charCodeAt(pos) === 96) {\n pos++;\n this.pos = pos;\n const fullText = input.slice(start, pos);\n return new LexerToken('INLINE_SOLVE_START', tokenTypeId('INLINE_SOLVE_START'), fullText, fullText, start, 0, this.line, startCol);\n }\n\n // ── Unit lookup (case-sensitive)\n const isKnownUnit = this.mergedUnits.has(identText);\n if (isKnownUnit) {\n if (!this.isFollowedByLParen(pos)) {\n this.pos = pos;\n return new LexerToken('UNIT', tokenTypeId('UNIT'), identText, identText, start, 0, this.line, startCol);\n }\n }\n\n // ── Keyword lookup (case-insensitive)\n const localeKwType = this.mergedKeywords.get(identLower);\n if (localeKwType) {\n this.pos = pos;\n return new LexerToken(localeKwType, tokenTypeId(localeKwType), identText, identText, start, 0, this.line, startCol);\n }\n\n // ── Fall through: emit IDENT\n // Multi-word phrases are now handled by the TokenNormalizer post-lexer pass,\n // which keeps the lexer slim and focused on single-token production.\n this.pos = pos;\n return new LexerToken('IDENT', tokenTypeId('IDENT'), identText, identText, start, 0, this.line, startCol);\n }\n\n /**\n * Peek past in-expression whitespace (space, tab) from `pos` to check\n * if the next significant character is '('.\n */\n private isFollowedByLParen(pos: number): boolean {\n const len = this.len;\n let lookPos = pos;\n while (lookPos < len) {\n const cc = this.input.charCodeAt(lookPos);\n if (cc === 40) return true;\n if (cc !== 32 && cc !== 9) break;\n lookPos++;\n }\n return false;\n }\n\n // ── Inline operator tokenizer ─────────────────────────────────────────\n /**\n * Whether the `(` at `parenPos` opens a function call rather than a bare\n * grouping, deciding whether a comma inside it is a separator or a thousands\n * group (see {@link groupingStack}).\n *\n * It is a call when the nearest non-whitespace character before it belongs to\n * the value the call applies to: a closing `)`/`]` (a call on a result), or an\n * IDENTIFIER (`rgb(`, `vec2(`). A run of digits alone is a number, not an\n * identifier, so `2(1,000)` is implicit multiplication over the grouping\n * `(1,000)`, not a call, while `vec2(` and `atan2(` (identifiers that end in a\n * digit) are calls. A `(` after an operator, a comma, or the line start is a\n * grouping.\n */\n private precededByCallTarget(parenPos: number): boolean {\n const input = this.input;\n const start = this.lineStartPos;\n let i = parenPos - 1;\n while (i >= start && (input.charCodeAt(i) === 32 || input.charCodeAt(i) === 9)) i--; // skip spaces/tabs\n if (i < start) return false; // line start (or only whitespace before): a grouping\n const c = input.charCodeAt(i);\n const isWord = (ch: number): boolean =>\n (ch >= 48 && ch <= 57) || (ch >= 65 && ch <= 90) || (ch >= 97 && ch <= 122) || ch === 95;\n const isAlpha = (ch: number): boolean =>\n (ch >= 65 && ch <= 90) || (ch >= 97 && ch <= 122) || ch === 95;\n // A non-word char before \"(\" (an operator, a comma, a `)`/`]`, or the line\n // start) is a grouping. There is no curried/first-class call or index-\n // application in this grammar, so `)(` and `](` are implicit multiplication\n // over a grouping (`(2)(1,000)` is `2 * 1000`), not a call. The only call\n // targets are an identifier or a FUNC keyword, handled below.\n if (!isWord(c)) return false;\n // Walk back over the whole word run. A bare number run (`2(1,000)`) is\n // implicit multiplication over a grouping, not a call.\n const wordEnd = i + 1;\n let hasAlpha = false;\n while (i >= start) {\n const ch = input.charCodeAt(i);\n if (!isWord(ch)) break;\n if (isAlpha(ch)) hasAlpha = true;\n i--;\n }\n if (!hasAlpha) return false;\n // The word is an identifier. A KEYWORD that is not a function name is a\n // word-operator or connective (`mod`, `xor`, `and`, `to`, `in`) or a\n // constant (`pi`, `e`), and the `(...)` after it is a grouped operand, so\n // its comma still groups thousands (`100 mod (1,000)` is `100 mod 1000`).\n // A plain identifier (a function like `rgb`, or a variable) or a function\n // keyword (`sqrt`, `max`) is a real call target, where the comma separates.\n const word = input.slice(i + 1, wordEnd).toLowerCase();\n const keywordType = this.mergedKeywords.get(word);\n return keywordType === undefined || keywordType === \"FUNC\";\n }\n\n /**\n * Reads an operator/punctuation token.\n * Handles two-char operators (==, !=, >=, <=, **) and the special\n * cases << (LSHIFT) and >> (RSHIFT).\n */\n private tokenizeOperator(): Token {\n const input = this.input;\n const pos = this.pos;\n const col = pos - this.lineStartPos + 1;\n const c0 = input.charCodeAt(pos);\n const len = this.len;\n\n // ── Two-character operators ────────────────────────────────────────\n if (pos + 1 < len) {\n const c1 = input.charCodeAt(pos + 1);\n\n // ==, !=, >=, <=\n const secondMap = TWO_CHAR_OPS[c0];\n if (secondMap) {\n const twoCharType = secondMap[c1];\n if (twoCharType) {\n const text = input.slice(pos, pos + 2);\n this.pos = pos + 2;\n return new LexerToken(twoCharType, tokenTypeId(twoCharType), text, text, pos, 0, this.line, col);\n }\n }\n\n // // comment\n if (c0 === 47 && c1 === 47) {\n let commentPos = pos + 2;\n while (commentPos < len) {\n const cc = input.charCodeAt(commentPos);\n if (cc === 10 || cc === 13) break;\n commentPos++;\n }\n const text = input.slice(pos, commentPos);\n this.pos = commentPos;\n return new LexerToken('COMMENT', tokenTypeId('COMMENT'), text, text, pos, 0, this.line, col);\n }\n\n // << (LSHIFT), >> (RSHIFT) and >>> (URSHIFT).\n //\n // >>> is tested before >>, or the two-char match would consume the first\n // two angle brackets and leave a stray > for the parser to choke on.\n if (c0 === 60 && c1 === 60) {\n this.pos = pos + 2;\n return new LexerToken('LSHIFT', tokenTypeId('LSHIFT'), '<<', '<<', pos, 0, this.line, col);\n }\n if (c0 === 62 && c1 === 62) {\n if (input.charCodeAt(pos + 2) === 62) {\n this.pos = pos + 3;\n return new LexerToken('URSHIFT', tokenTypeId('URSHIFT'), '>>>', '>>>', pos, 0, this.line, col);\n }\n this.pos = pos + 2;\n return new LexerToken('RSHIFT', tokenTypeId('RSHIFT'), '>>', '>>', pos, 0, this.line, col);\n }\n\n // ── Plugin-registered two-char operators ──────────────────────\n if (this.hasPluginOps) {\n const pluginInner = this.pluginOperators.get(c0);\n if (pluginInner) {\n const pluginType = pluginInner.get(c1);\n if (pluginType) {\n const text = input.slice(pos, pos + 2);\n this.pos = pos + 2;\n return new LexerToken(pluginType, tokenTypeId(pluginType), text, text, pos, 0, this.line, col);\n }\n }\n }\n }\n\n // ── Single-character operator ──────────────────────────────────────\n this.pos = pos + 1;\n // Track `(`/`[` nesting so the number scanner can tell a thousands group\n // from an argument/element separator (see {@link groupingStack}). `[` always\n // opens a separator context (a vector/matrix). `(` opens a separator context\n // only when it is a CALL, i.e. it directly follows a value the call applies\n // to, an identifier/unit, or a closing `)`/`]`; a bare GROUPING `(`, after an\n // operator or the line start, keeps thousands so `(1,000)` stays one number.\n // `)`/`]` pop; a stray closer with an empty stack is ignored.\n if (c0 === 91) { // [\n this.groupingStack.push(true);\n } else if (c0 === 40) { // (\n this.groupingStack.push(this.precededByCallTarget(pos));\n } else if (c0 === 41 || c0 === 93) { // ) or ]\n if (this.groupingStack.length > 0) this.groupingStack.pop();\n }\n const opType = OP_MAP[c0];\n const text = input.charAt(pos);\n return new LexerToken(opType || 'ERROR', tokenTypeId(opType || 'ERROR'), text, text, pos, 0, this.line, col);\n }\n\n // ── String literal tokenizer ──────────────────────────────────────────\n /**\n * Reads a double-quoted string literal. Supports backslash escapes.\n *\n * `text` is the raw source slice, quotes included, because that is what\n * `offset` + `text.length` has to span for a host to underline the literal.\n * `value` is the PAYLOAD, quotes excluded, because that is what\n * `PUSH_STRING` puts into the Value.\n *\n * The two used to be the same string. `\"abc\"` carried the five characters\n * `\"abc\"` as its value, which was invisible on screen (the formatter prints\n * the payload raw and the retained quotes landed where a display would have\n * put them back) and not invisible anywhere else: `parseFloat('\"5\"')` is NaN\n * whatever the digits say, so `\"5\" + 5` answered 5.\n *\n * An unterminated literal is an error rather than a string that happens to\n * reach the end of the line. It used to return what it had, so `\"abc` and\n * `\"abc\"` were indistinguishable by payload once the quotes were stripped,\n * which is the other half of why they are stripped here rather than later.\n */\n private tokenizeString(): Token {\n const input = this.input;\n const len = this.len;\n const start = this.pos;\n const startCol = start - this.lineStartPos + 1;\n let pos = start + 1;\n let lineBreaks = 0;\n\n while (pos < len) {\n const c0 = input.charCodeAt(pos);\n if (c0 === 34) {\n pos++;\n const text = input.slice(start, pos);\n const value = input.slice(start + 1, pos - 1);\n this.pos = pos;\n return new LexerToken('STRING', tokenTypeId('STRING'), value, text, start, lineBreaks, this.line, startCol);\n }\n if (c0 === 92 && pos + 1 < len) {\n pos += 2;\n continue;\n }\n if (c0 === 10) {\n this.line++;\n this.lineStartPos = pos + 1;\n lineBreaks++;\n }\n pos++;\n }\n\n this.pos = pos;\n throw ErrorFactory.parsing(\n \"UNTERMINATED_STRING\",\n `Unterminated string literal: ${input.slice(start, pos)}`,\n { literal: input.slice(start, pos), offset: start },\n );\n }\n\n // ── Markdown line scanner (Phase B) ───────────────────────────────────\n\n /**\n * L1 expression gating: quickly determine if a line contains any\n * characters that indicate an expression (digits, operators, currency,\n * backticks, parentheses, etc.).\n *\n * Pure prose lines (e.g., \"The quick brown fox jumps over the lazy dog\")\n * return false and can be skipped without full tokenization (L2).\n *\n * This is a fast character-by-character scan that stops at the first\n * expression indicator. Called once per line in classifyFromPositions().\n */\n static hasExpressionIndicators(input: string, start: number, end: number): boolean {\n const indicatorCodes = EXPRESSION_INDICATOR_CODES;\n for (let i = start; i < end; i++) {\n const cc = input.charCodeAt(i);\n // Check digits and operators via pre-computed Set (O(1) lookup)\n if (indicatorCodes.has(cc)) return true;\n // Unicode math/currency symbols (≥ 128, not in the 128-byte table)\n if (cc >= 128) {\n // ×, ÷, ≠, £, €, ¥, ₽, ₩, common expression symbols\n if (cc === 0x00D7 || cc === 0x00F7 || cc === 0x2260 ||\n cc === 0x00A3 || cc === 0x20AC ||\n cc === 0x00A5 || cc === 0x20BD || cc === 0x20A9) {\n return true;\n }\n }\n }\n return false;\n }\n\n /**\n * Classify a line by its character positions within this.input.\n * Reads directly from this.input using start/end boundaries.\n * DOES NOT modify this.pos, purely a read-only classifier.\n */\n /**\n * Advance past the whitespace after a list marker, and past a task-item\n * checkbox if one follows.\n *\n * The checkbox is included because it is markup by the same argument the\n * marker is, and because leaving it stopped the line dead: `- [ ] 100 + 20`\n * lexed `[ ]` as a matrix literal and reported that a matrix cannot be\n * empty, which tells a user writing a to-do list nothing they can act on.\n *\n * @param from - Offset just past the marker character.\n * @param end - Line end, never read past.\n * @returns Offset of the first evaluable character.\n */\n private skipMarkerGap(from: number, end: number): number {\n const input = this.input;\n let pos = from;\n while (pos < end && (input.charCodeAt(pos) === 32 || input.charCodeAt(pos) === 9)) pos++;\n\n // `[ ]`, `[x]`, `[X]`, or any single-character state Obsidian allows.\n if (pos + 2 < end && input.charCodeAt(pos) === 91 && input.charCodeAt(pos + 2) === 93) {\n let after = pos + 3;\n while (after < end && (input.charCodeAt(after) === 32 || input.charCodeAt(after) === 9)) after++;\n // Only when whitespace followed, so `[1,2]` opening a real matrix is\n // never mistaken for a checkbox.\n if (after > pos + 3) return after;\n }\n return pos;\n }\n\n /**\n * The end offset (exclusive) of a `#hex` colour literal starting at `hashPos`,\n * or -1 if the run there is not one. A colour is `#` followed by EXACTLY 3, 4,\n * 6 or 8 hex digits (the CSS forms `#rgb`/`#rgba`/`#rrggbb`/`#rrggbbaa`) and\n * then a boundary, not a longer word or number. This is the one predicate that\n * carves colours out of the two things `#` otherwise means, a markdown heading\n * at line start and a comment mid-line, and it is pure character logic so line\n * classification stays vocabulary-independent. Examples: `#f00`, `#ff0000`,\n * `#deadbeef` match; `# Heading` (space), `#tag`/`#todo` (non-hex letter),\n * `#12345` (length 5), `#ff0000zz` (trailing word) do not.\n */\n private matchHexColourEnd(hashPos: number, end: number): number {\n const input = this.input;\n let p = hashPos + 1;\n let n = 0;\n while (p < end) {\n const c = input.charCodeAt(p);\n const isHex = (c >= 48 && c <= 57) || (c >= 65 && c <= 70) || (c >= 97 && c <= 102);\n if (!isHex) break;\n n++;\n p++;\n }\n if (n !== 3 && n !== 4 && n !== 6 && n !== 8) return -1;\n if (p < end) {\n const c = input.charCodeAt(p);\n const isWord = (c >= 48 && c <= 57) || (c >= 65 && c <= 90) || (c >= 97 && c <= 122) || c === 95;\n if (isWord) return -1;\n }\n return p;\n }\n\n private classifyFromPositions(start: number, end: number): LineClassification {\n const len = end;\n\n if (start >= len) {\n return { type: 'empty', skip: true, hasInlineSolve: false };\n }\n\n const input = this.input;\n let pos = start;\n\n while (pos < len) {\n const cc = input.charCodeAt(pos);\n if (cc !== 32 && cc !== 9) break;\n pos++;\n }\n\n if (pos >= len) {\n return { type: 'empty', skip: true, hasInlineSolve: false };\n }\n\n const c0 = input.charCodeAt(pos);\n let hasInline: boolean | undefined;\n\n // ── Heading: #{1,6} ' ' ──────────────────────────────────────────\n if (c0 === 35) {\n // A bare #hex colour is a value, not a heading. A real heading has a space\n // after its #(s), so the colour shape (# + 3/4/6/8 hex digits) never\n // collides with one. This line is tokenized like any expression.\n if (this.matchHexColourEnd(pos, len) !== -1) {\n if (hasInline === undefined) {\n const idx = input.indexOf('s`', pos);\n hasInline = idx !== -1 && idx < len;\n }\n return { type: 'expression', skip: false, hasInlineSolve: hasInline };\n }\n let hashCount = 1;\n while (pos + hashCount < len && input.charCodeAt(pos + hashCount) === 35) {\n hashCount++;\n }\n if (hashCount <= 6 && pos + hashCount < len && input.charCodeAt(pos + hashCount) === 32) {\n return { type: 'heading', skip: true, hasInlineSolve: false };\n }\n return { type: 'heading', skip: true, hasInlineSolve: false };\n }\n\n // ── Blockquote: > ' ' ────────────────────────────────────────────\n if (c0 === 62) {\n if (pos + 1 < len && input.charCodeAt(pos + 1) === 32) {\n return { type: 'blockquote', skip: true, hasInlineSolve: false };\n }\n }\n\n // ── Code fence: ``` or ~~~ ────────────────────────────────────────\n if (c0 === 96 && pos + 2 < len && input.charCodeAt(pos + 1) === 96 && input.charCodeAt(pos + 2) === 96) {\n return { type: 'code_fence', skip: true, hasInlineSolve: false };\n }\n if (c0 === 126 && pos + 2 < len && input.charCodeAt(pos + 1) === 126 && input.charCodeAt(pos + 2) === 126) {\n return { type: 'code_fence', skip: true, hasInlineSolve: false };\n }\n\n // ── Math fence: $$ ────────────────────────────────────────────────\n if (c0 === 36 && pos + 1 < len && input.charCodeAt(pos + 1) === 36) {\n return { type: 'math_fence', skip: true, hasInlineSolve: false };\n }\n\n // ── Horizontal rule: ---, ***, ___ (3+ same char, then only whitespace)\n if (c0 === 45 || c0 === 42 || c0 === 95) {\n let count = 1;\n while (pos + count < len && input.charCodeAt(pos + count) === c0) {\n count++;\n }\n if (count >= 3) {\n let trailPos = pos + count;\n while (trailPos < len && (input.charCodeAt(trailPos) === 32 || input.charCodeAt(trailPos) === 9)) {\n trailPos++;\n }\n if (trailPos >= len) {\n return { type: 'hr', skip: true, hasInlineSolve: false };\n }\n }\n }\n\n // ── Unordered list: - ' ', * ' ', + ' ' ──────────────────────────\n if ((c0 === 45 || c0 === 42 || c0 === 43) && pos + 1 < len && input.charCodeAt(pos + 1) === 32) {\n if (hasInline === undefined) {\n const idx = input.indexOf('s`', pos);\n hasInline = idx !== -1 && idx < len;\n }\n // The space is what makes this a marker rather than an operator, and it\n // is required by CommonMark for exactly that reason. `-100 + 20` has no\n // space and stays arithmetic; `- 100 + 20` is a bullet.\n return { type: 'list', skip: false, hasInlineSolve: hasInline, contentOffset: this.skipMarkerGap(pos + 1, len) };\n }\n\n // ── Ordered list: \\n+ '. ' ────────────────────────────────────────\n if (c0 >= 48 && c0 <= 57) {\n let digitPos = pos;\n while (digitPos < len && input.charCodeAt(digitPos) >= 48 && input.charCodeAt(digitPos) <= 57) {\n digitPos++;\n }\n if (digitPos < len && input.charCodeAt(digitPos) === 46) {\n if (digitPos + 1 < len && input.charCodeAt(digitPos + 1) === 32) {\n if (hasInline === undefined) {\n const idx = input.indexOf('s`', pos);\n hasInline = idx !== -1 && idx < len;\n }\n return { type: 'list', skip: false, hasInlineSolve: hasInline, contentOffset: this.skipMarkerGap(digitPos + 1, len) };\n }\n }\n }\n\n // ── Table / table separator: | ────────────────────────────────────\n if (c0 === 124) {\n let tPos = pos + 1;\n while (tPos < len) {\n const tc = input.charCodeAt(tPos);\n if (tc !== 45 && tc !== 58 && tc !== 124 && tc !== 32 && tc !== 9 && tc !== 13) break;\n tPos++;\n }\n if (tPos >= len) {\n return { type: 'table_separator', skip: true, hasInlineSolve: false };\n }\n }\n\n // ── Wikilink / embed: [[ or ![[ ───────────────────────────────────\n if (c0 === 91 && pos + 1 < len && input.charCodeAt(pos + 1) === 91) {\n const closePos = input.indexOf(']]', pos + 2);\n if (closePos !== -1 && closePos < len) {\n let trailPos = closePos + 2;\n while (trailPos < len && (input.charCodeAt(trailPos) === 32 || input.charCodeAt(trailPos) === 9)) {\n trailPos++;\n }\n if (trailPos >= len) {\n return { type: 'wikilink', skip: true, hasInlineSolve: false };\n }\n }\n }\n if (c0 === 33 && pos + 2 < len && input.charCodeAt(pos + 1) === 91 && input.charCodeAt(pos + 2) === 91) {\n const closePos = input.indexOf(']]', pos + 3);\n if (closePos !== -1 && closePos < len) {\n let trailPos = closePos + 2;\n while (trailPos < len && (input.charCodeAt(trailPos) === 32 || input.charCodeAt(trailPos) === 9)) {\n trailPos++;\n }\n if (trailPos >= len) {\n return { type: 'wikilink', skip: true, hasInlineSolve: false };\n }\n }\n }\n\n // ── Comment: // ──────────────────────────────────────────────────\n if (c0 === 47 && pos + 1 < len && input.charCodeAt(pos + 1) === 47) {\n return { type: 'comment', skip: true, hasInlineSolve: false };\n }\n\n // ── Default: expression or prose line ─────────────────────────────\n if (c0 === 62) {\n let trail = pos + 1;\n while (trail < len && (input.charCodeAt(trail) === 32 || input.charCodeAt(trail) === 9)) trail++;\n if (trail >= len) return { type: 'blockquote', skip: true, hasInlineSolve: false };\n }\n if (c0 === 45 || c0 === 42 || c0 === 43) {\n let trail = pos + 1;\n while (trail < len && (input.charCodeAt(trail) === 32 || input.charCodeAt(trail) === 9)) trail++;\n if (trail >= len) return { type: 'list', skip: false, hasInlineSolve: false };\n }\n if (hasInline === undefined) {\n const idx = input.indexOf('s`', pos);\n hasInline = idx !== -1 && idx < len;\n }\n\n // A line built only from characters the tokenizer discards produces no\n // tokens, so it has nothing to evaluate. Whitespace-only lines already\n // classify as empty above; the gap was an unknown ASCII character like a\n // backslash, which the lexer skips (it falls through to CharClass.SKIP)\n // rather than tokenising. A run of them (\"\\\\\", \"\\\\\\\\\") reached the\n // expression path, lexed to an empty token stream, and the engine reported\n // that stream as the number 0: a result on screen for a line that holds no\n // expression at all. Classify it as empty, the same as a blank line, so\n // every surface (the batch parse, the incremental evaluator, and the\n // playground's shouldEvaluateLine) skips it rather than answering 0. A\n // non-ASCII code point is real content (it lexes as an IDENT for forward\n // compatibility), so only ASCII whitespace and skip characters count here.\n if (!hasInline) {\n let onlySkippable = true;\n for (let i = pos; i < len; i++) {\n const code = input.charCodeAt(i);\n if (code >= 128 || ExpressionLexer.CHAR_CLASS[code] > CharClass.WHITESPACE) {\n onlySkippable = false;\n break;\n }\n }\n if (onlySkippable) {\n return { type: 'empty', skip: true, hasInlineSolve: false };\n }\n }\n\n // Return expression, all non-markdown-structure lines are tokenized.\n // (L1 prose gating removed: it incorrectly skipped keyword-only lines\n // like \"pi\", single identifiers like \"hello\", and any line without\n // digits/operators/currency. Can be re-added with keyword-awareness\n // and proper test coverage.)\n return { type: 'expression', skip: false, hasInlineSolve: hasInline };\n }\n\n /**\n * Classify a single line of markdown text.\n */\n classifyLine(lineText: string): LineClassification {\n const savedInput = this.input;\n const savedLen = this.len;\n const savedPos = this.pos;\n this.input = lineText;\n this.len = lineText.length;\n this.pos = 0;\n const result = this.classifyFromPositions(0, lineText.length);\n this.input = savedInput;\n this.len = savedLen;\n this.pos = savedPos;\n return result;\n }\n\n /**\n * Every keyword this lexer currently recognizes, locale keywords\n * (`pi`, `sqrt`, `convert`, ...) merged with any plugin-contributed ones\n * from `registerVocabulary()` (e.g. a package's custom keywords), mapped to\n * the token type they lex to. A snapshot copy, not a live reference\n * mutating the return value has no effect on the lexer.\n */\n getKeywords(): Record<string, string> {\n return Object.fromEntries(this.mergedKeywords);\n }\n\n /**\n * Find all inline solve markers in a line with precise coordinate mapping.\n */\n findInlineSolves(lineText: string): InlineSolveSpan[] {\n const results: InlineSolveSpan[] = [];\n const len = lineText.length;\n let pos = 0;\n\n while (pos < len) {\n const sPos = lineText.indexOf('s`', pos);\n if (sPos === -1) break;\n\n const exprStart = sPos + 2;\n\n let exprEnd = exprStart;\n while (exprEnd < len) {\n const cc = lineText.charCodeAt(exprEnd);\n if (cc === 92 && exprEnd + 1 < len) {\n exprEnd += 2;\n continue;\n }\n if (cc === 96) break;\n exprEnd++;\n }\n\n if (exprEnd >= len) {\n exprEnd = len;\n }\n\n const expression = lineText.slice(exprStart, exprEnd);\n const end = exprEnd < len ? exprEnd + 1 : exprEnd;\n\n results.push({\n start: sPos,\n end,\n expression,\n columnNumber: sPos + 1,\n });\n\n pos = end;\n }\n\n return results;\n }\n\n // ── Comment tokenizer ─────────────────────────────────────────────────\n /**\n * Reads a comment: # to end of line, or // to end of line.\n */\n private tokenizeComment(): Token {\n const input = this.input;\n const len = this.len;\n const start = this.pos;\n const startCol = start - this.lineStartPos + 1;\n\n // A `#hex` colour literal is not a comment. Recognised here (the single\n // choke-point both `#` call sites reach) so `#ff0000` becomes a HEX_COLOUR\n // token while `# comment`, `#tag`, `#face` (length 4 all-hex still counts as a\n // colour) and `// c` stay comments. Only fires when the char is `#`, never `/`.\n if (input.charCodeAt(start) === 35) {\n const hexEnd = this.matchHexColourEnd(start, len);\n if (hexEnd !== -1) {\n const text = input.slice(start, hexEnd);\n this.pos = hexEnd;\n return new LexerToken('HEX_COLOUR', tokenTypeId('HEX_COLOUR'), text, text, start, 0, this.line, startCol);\n }\n\n // A bounded `#tag` annotation: `#` then a letter then a run of\n // `[A-Za-z0-9_-]`, consuming only the tag, not the rest of the line. So\n // `1200 #housing // note` keeps the `// note` comment, and a mid-line tag\n // no longer swallows the line. `# ` (space) and `#123` (leading digit)\n // still fall through to a comment; a line-start `#` is a heading\n // (classified elsewhere); a `#hex` colour is caught above.\n const first = input.charCodeAt(start + 1);\n const isLetter = (first >= 65 && first <= 90) || (first >= 97 && first <= 122);\n // #198: a `#` glued to the end of a word or number is not a tag. The\n // category-tag scanner (packages/tags/TagScanner.ts) only counts a tag at\n // a non-word boundary (`(?:^|[^0-9A-Za-z_])#...`), so `100#food`, `$100#food`\n // and `a#b` are excluded there; the lexer must agree, or a line renders\n // tagged but is silently left out of the totals. A line-first `#` never\n // reaches here (the classifier makes it a heading), so a mid-line tag only\n // needs its preceding character to be a non-word char.\n const prevCode = start > this.lineStartPos ? input.charCodeAt(start - 1) : -1;\n const prevIsWordChar =\n (prevCode >= 48 && prevCode <= 57) ||\n (prevCode >= 65 && prevCode <= 90) ||\n (prevCode >= 97 && prevCode <= 122) ||\n prevCode === 95;\n if (isLetter && !prevIsWordChar) {\n let tagEnd = start + 2;\n while (tagEnd < len) {\n const c = input.charCodeAt(tagEnd);\n const isTagChar = (c >= 48 && c <= 57) || (c >= 65 && c <= 90) || (c >= 97 && c <= 122) || c === 95 || c === 45;\n if (!isTagChar) break;\n tagEnd++;\n }\n // Store the name without the `#`, matching how LINE_REF keeps the bare\n // number.\n const name = input.slice(start + 1, tagEnd);\n this.pos = tagEnd;\n return new LexerToken('TAG', tokenTypeId('TAG'), name, name, start, 0, this.line, startCol);\n }\n }\n\n let pos = this.pos;\n\n if (pos + 1 < len && input.charCodeAt(pos + 1) === 47) {\n pos += 2;\n } else {\n pos++;\n }\n\n while (pos < len) {\n const c0 = input.charCodeAt(pos);\n if (c0 === 10 || c0 === 13) break;\n pos++;\n }\n\n const text = input.slice(start, pos);\n this.pos = pos;\n return new LexerToken('COMMENT', tokenTypeId('COMMENT'), text, text, start, 0, this.line, startCol);\n }\n}"]}
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkY7O4D3BJ_cjs=require('./chunk-Y7O4D3BJ.cjs'),chunk6KFVG6UY_cjs=require('./chunk-6KFVG6UY.cjs'),chunkMSYX32PF_cjs=require('./chunk-MSYX32PF.cjs'),chunkFWW3M36J_cjs=require('./chunk-FWW3M36J.cjs');var u=(s=>(s.Main="main",s.Inline="inline",s.String="string",s))(u||{});var l=class{constructor(e="en",t){this.currentState="main";this.hasPeeked=false;this.tokens=[];this.tokenIdx=0;this.expressionLexer=new chunk6KFVG6UY_cjs.b(e,t);}reset(e,t){let s=t??"main";if(this.currentState=s,this.hasPeeked=false,this.peekedToken=void 0,s==="main"){if(this.expressionLexer.classifyLine(e).skip){this.tokens=[],this.tokenIdx=0;return}this.expressionLexer.reset(e),this.tokens=this.expressionLexer.tokenizeAll(),this.tokenIdx=0;}else this.expressionLexer.reset(e),this.tokens=this.expressionLexer.tokenizeAll(),this.tokenIdx=0;}classifyLine(e){return this.expressionLexer.classifyLine(e)}findInlineSolves(e){return this.expressionLexer.findInlineSolves(e)}getKeywords(){return this.expressionLexer.getKeywords()}next(){if(this.hasPeeked)return this.hasPeeked=false,this.peekedToken;if(this.tokenIdx<this.tokens.length)return this.tokens[this.tokenIdx++]}peek(){return this.hasPeeked?this.peekedToken:(this.peekedToken=this.next(),this.hasPeeked=true,this.peekedToken)}[Symbol.iterator](){return this.tokens[Symbol.iterator]()}registerVocabulary(e){this.expressionLexer.registerVocabulary(e);}unregisterVocabulary(e){this.expressionLexer.unregisterVocabulary(e);}resetExpression(e){this.currentState="main",this.hasPeeked=false,this.peekedToken=void 0,this.expressionLexer.reset(e),this.tokens=this.expressionLexer.tokenizeAll(),this.tokenIdx=0;}scanDocument(e){return this.expressionLexer.scanDocument(e)}getState(){return this.currentState}setState(e){this.currentState=e;}getHighlightTokens(e){let t=this.expressionLexer.classifyLine(e);return t.skip&&e.startsWith("> ")?this.collectHighlightTokens(e.slice(2)):t.skip?[]:this.collectHighlightTokens(e)}getHighlightTokenObjects(e){let t=this.expressionLexer.classifyLine(e);return t.skip&&e.startsWith("> ")?this.collectTokenObjects(e.slice(2)):t.skip?[]:this.collectTokenObjects(e)}collectTokenObjects(e){this.resetExpression(e);let t=[];for(let s of this)s.type==="WS"||s.type==="NEWLINE"||s.type.startsWith("MD_")||s.type==="INLINE_SOLVE_START"||s.type==="BACKTICK_CLOSE"||t.push(s);return t}collectHighlightTokens(e){return this.collectTokenObjects(e).map(t=>({type:t.type,value:t.value,offset:t.offset,col:t.col,length:t.text.length,category:chunkY7O4D3BJ_cjs.d(t.type)}))}},T=new l("en",void 0);var n=class{constructor(){this.classes=[];this.localeKeywordMap=null;this.localePhraseMap=null;this.unitNames=null;}register(e){this.classes.push(e);}unregister(e){this.classes=this.classes.filter(t=>t.tokenType!==e);}setLocale(e,t){this.localeKeywordMap=e,this.localePhraseMap=t??null;}setUnits(e){this.unitNames=e;}build(){let e=new Map;if(this.localeKeywordMap)for(let[r,i]of Object.entries(this.localeKeywordMap))e.set(r.toLowerCase(),i);let t=[...this.classes].sort((r,i)=>(r.priority??0)-(i.priority??0));for(let r of t)for(let i of Object.keys(r.keywords))e.set(i.toLowerCase(),r.tokenType);let s=this.buildPhraseTrie(),o=this.buildPhraseStartWords();return {keywordToType:e,phraseTrie:s,phraseStartWords:o,unitNames:this.unitNames??new Set}}buildPhraseTrie(){let e={children:new Map};if(this.localePhraseMap)for(let[t,s]of Object.entries(this.localePhraseMap))this.insertPhrase(e,t.toLowerCase(),s);for(let t of this.classes)if(t.phrases)for(let s of Object.keys(t.phrases))this.insertPhrase(e,s.toLowerCase(),t.tokenType);return e.children.size>0?e:null}insertPhrase(e,t,s){let o=t.split(" "),r=e;for(let i of o)r.children.has(i)||r.children.set(i,{children:new Map}),r=r.children.get(i);r.type||(r.type=s);}buildPhraseStartWords(){let e=new Set;if(this.localePhraseMap)for(let t of Object.keys(this.localePhraseMap)){let s=t.split(" ")[0].toLowerCase();e.add(s);}for(let t of this.classes)if(t.phrases)for(let s of Object.keys(t.phrases)){let o=s.split(" ")[0].toLowerCase();e.add(o);}return e}};var k={"to the power of":"CARET","power of":"CARET","increase by":"INCREASE_BY","decrease by":"DECREASE_BY","times by":"TIMES_BY","multiply by":"MULTIPLY_BY","multiplied by":"MULTIPLY_BY","divide by":"DIVIDE_BY"};function P(a="en"){let e=chunkMSYX32PF_cjs.a(a),t=new n;return t.setLocale(e.keywordMap,k),t.setUnits(chunkFWW3M36J_cjs.a),t.build()}exports.a=u;exports.b=l;exports.c=T;exports.d=P;//# sourceMappingURL=chunk-LR4E4A4W.cjs.map
2
- //# sourceMappingURL=chunk-LR4E4A4W.cjs.map
1
+ 'use strict';var chunkY7O4D3BJ_cjs=require('./chunk-Y7O4D3BJ.cjs'),chunk2LFLR3VZ_cjs=require('./chunk-2LFLR3VZ.cjs'),chunkMSYX32PF_cjs=require('./chunk-MSYX32PF.cjs'),chunkFWW3M36J_cjs=require('./chunk-FWW3M36J.cjs');var u=(s=>(s.Main="main",s.Inline="inline",s.String="string",s))(u||{});var l=class{constructor(e="en",t){this.currentState="main";this.hasPeeked=false;this.tokens=[];this.tokenIdx=0;this.expressionLexer=new chunk2LFLR3VZ_cjs.b(e,t);}reset(e,t){let s=t??"main";if(this.currentState=s,this.hasPeeked=false,this.peekedToken=void 0,s==="main"){if(this.expressionLexer.classifyLine(e).skip){this.tokens=[],this.tokenIdx=0;return}this.expressionLexer.reset(e),this.tokens=this.expressionLexer.tokenizeAll(),this.tokenIdx=0;}else this.expressionLexer.reset(e),this.tokens=this.expressionLexer.tokenizeAll(),this.tokenIdx=0;}classifyLine(e){return this.expressionLexer.classifyLine(e)}findInlineSolves(e){return this.expressionLexer.findInlineSolves(e)}getKeywords(){return this.expressionLexer.getKeywords()}next(){if(this.hasPeeked)return this.hasPeeked=false,this.peekedToken;if(this.tokenIdx<this.tokens.length)return this.tokens[this.tokenIdx++]}peek(){return this.hasPeeked?this.peekedToken:(this.peekedToken=this.next(),this.hasPeeked=true,this.peekedToken)}[Symbol.iterator](){return this.tokens[Symbol.iterator]()}registerVocabulary(e){this.expressionLexer.registerVocabulary(e);}unregisterVocabulary(e){this.expressionLexer.unregisterVocabulary(e);}resetExpression(e){this.currentState="main",this.hasPeeked=false,this.peekedToken=void 0,this.expressionLexer.reset(e),this.tokens=this.expressionLexer.tokenizeAll(),this.tokenIdx=0;}scanDocument(e){return this.expressionLexer.scanDocument(e)}getState(){return this.currentState}setState(e){this.currentState=e;}getHighlightTokens(e){let t=this.expressionLexer.classifyLine(e);return t.skip&&e.startsWith("> ")?this.collectHighlightTokens(e.slice(2)):t.skip?[]:this.collectHighlightTokens(e)}getHighlightTokenObjects(e){let t=this.expressionLexer.classifyLine(e);return t.skip&&e.startsWith("> ")?this.collectTokenObjects(e.slice(2)):t.skip?[]:this.collectTokenObjects(e)}collectTokenObjects(e){this.resetExpression(e);let t=[];for(let s of this)s.type==="WS"||s.type==="NEWLINE"||s.type.startsWith("MD_")||s.type==="INLINE_SOLVE_START"||s.type==="BACKTICK_CLOSE"||t.push(s);return t}collectHighlightTokens(e){return this.collectTokenObjects(e).map(t=>({type:t.type,value:t.value,offset:t.offset,col:t.col,length:t.text.length,category:chunkY7O4D3BJ_cjs.d(t.type)}))}},T=new l("en",void 0);var n=class{constructor(){this.classes=[];this.localeKeywordMap=null;this.localePhraseMap=null;this.unitNames=null;}register(e){this.classes.push(e);}unregister(e){this.classes=this.classes.filter(t=>t.tokenType!==e);}setLocale(e,t){this.localeKeywordMap=e,this.localePhraseMap=t??null;}setUnits(e){this.unitNames=e;}build(){let e=new Map;if(this.localeKeywordMap)for(let[r,i]of Object.entries(this.localeKeywordMap))e.set(r.toLowerCase(),i);let t=[...this.classes].sort((r,i)=>(r.priority??0)-(i.priority??0));for(let r of t)for(let i of Object.keys(r.keywords))e.set(i.toLowerCase(),r.tokenType);let s=this.buildPhraseTrie(),o=this.buildPhraseStartWords();return {keywordToType:e,phraseTrie:s,phraseStartWords:o,unitNames:this.unitNames??new Set}}buildPhraseTrie(){let e={children:new Map};if(this.localePhraseMap)for(let[t,s]of Object.entries(this.localePhraseMap))this.insertPhrase(e,t.toLowerCase(),s);for(let t of this.classes)if(t.phrases)for(let s of Object.keys(t.phrases))this.insertPhrase(e,s.toLowerCase(),t.tokenType);return e.children.size>0?e:null}insertPhrase(e,t,s){let o=t.split(" "),r=e;for(let i of o)r.children.has(i)||r.children.set(i,{children:new Map}),r=r.children.get(i);r.type||(r.type=s);}buildPhraseStartWords(){let e=new Set;if(this.localePhraseMap)for(let t of Object.keys(this.localePhraseMap)){let s=t.split(" ")[0].toLowerCase();e.add(s);}for(let t of this.classes)if(t.phrases)for(let s of Object.keys(t.phrases)){let o=s.split(" ")[0].toLowerCase();e.add(o);}return e}};var k={"to the power of":"CARET","power of":"CARET","increase by":"INCREASE_BY","decrease by":"DECREASE_BY","times by":"TIMES_BY","multiply by":"MULTIPLY_BY","multiplied by":"MULTIPLY_BY","divide by":"DIVIDE_BY"};function P(a="en"){let e=chunkMSYX32PF_cjs.a(a),t=new n;return t.setLocale(e.keywordMap,k),t.setUnits(chunkFWW3M36J_cjs.a),t.build()}exports.a=u;exports.b=l;exports.c=T;exports.d=P;//# sourceMappingURL=chunk-32GC2FHC.cjs.map
2
+ //# sourceMappingURL=chunk-32GC2FHC.cjs.map