@sheetxl/sdk 0.7.28-beta.3 → 0.7.28-beta.4

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 (57) hide show
  1. package/browser/cjs/{D6cjnwWR_iUSe1f6.cjs → BF14ZEAnaqxXroSj.cjs} +1 -1
  2. package/browser/cjs/{CWCKcp58KidyndaL.cjs → BXtvdT1Z-MsB_o5F.cjs} +1 -1
  3. package/browser/cjs/Bc4JjVVZfFo3R4He.cjs +33 -0
  4. package/browser/cjs/{BX6A6xGDOr_td9mw.cjs → CD2RXdnfqSYNc6gX.cjs} +1 -1
  5. package/browser/cjs/{B4PKKgaDTG9aSO-f.cjs → DcLpXGexEtOxi-dD.cjs} +1 -1
  6. package/browser/cjs/index.cjs +2 -2
  7. package/browser/esm/{CX1NO_a1QPjXDvTU.mjs → 0Mj5WKM362q6CECb.mjs} +3 -3
  8. package/browser/esm/{Rj8e7SashcMlcdZJ.mjs → CHSahmMFYNB0Ajkf.mjs} +2 -2
  9. package/browser/esm/{B1gpnr-7kLU7jTy-.mjs → CKk58ZLcrllMzfou.mjs} +2 -2
  10. package/browser/esm/{CPgz9_iM7xyAcytg.mjs → CPTtL2f6_4iblmFM.mjs} +2 -2
  11. package/browser/esm/{Dv8FyXyeygJPXoHo.mjs → CoA-sUxjiIUIpTUF.mjs} +2 -2
  12. package/browser/esm/{DZfds6s3ayTZrozO.mjs → DBIu6NUHIcxOOBQp.mjs} +1 -1
  13. package/browser/esm/{C78IaCXqwCcraBPe.mjs → Dy4Sdpju1T2icURu.mjs} +6266 -5497
  14. package/browser/esm/index.mjs +17 -14
  15. package/node/esm/{BkY99r-c3BhlT_Kv.mjs → BtGxbEbBm79YvF_k.mjs} +1 -1
  16. package/node/esm/{DE3eIaqkk5xzmV1c.mjs → DUYP6faJJHCaW1Xf.mjs} +1 -1
  17. package/node/esm/{8VtzCFSmLPKxJjOa.mjs → DqgWsVXROpSgKq6c.mjs} +1 -1
  18. package/node/esm/index.mjs +8589 -7804
  19. package/package.json +6 -6
  20. package/types/scripting-enums.json +2 -0
  21. package/types/scripting.d.ts +265 -8
  22. package/types/src/anchored/IAnchored.d.ts +27 -0
  23. package/types/src/calculation/Calculation.d.ts +21 -12
  24. package/types/src/calculation/ICalculation.d.ts +178 -0
  25. package/types/src/calculation/executor/CalcExecutor.d.ts +204 -13
  26. package/types/src/calculation/executor/CalcExecutorUtils.d.ts +31 -0
  27. package/types/src/calculation/executor/CircularReference.d.ts +81 -0
  28. package/types/src/calculation/grid/CalcGrid.d.ts +3 -1
  29. package/types/src/calculation/grid/CalcGridUtils.d.ts +3 -2
  30. package/types/src/calculation/grid/ICalcGrid.d.ts +12 -1
  31. package/types/src/calculation/spatial/CircularEntry.d.ts +18 -0
  32. package/types/src/calculation/spatial/index.d.ts +1 -0
  33. package/types/src/calculation/state/CalcNode.d.ts +24 -17
  34. package/types/src/calculation/state/CalcState.d.ts +78 -15
  35. package/types/src/calculation/state/CalculationContext.d.ts +39 -0
  36. package/types/src/calculation/state/_ReadObservedGrid.d.ts +90 -0
  37. package/types/src/cell/ICell.d.ts +16 -0
  38. package/types/src/cellRange/ICellRange.d.ts +12 -3
  39. package/types/src/condition/AnchoredConditional.d.ts +26 -6
  40. package/types/src/conditionalFormat/ConditionalFormat.d.ts +8 -1
  41. package/types/src/conditionalFormat/IConditionalFormat.d.ts +4 -1
  42. package/types/src/conditionalFormat/IConditionalFormatCollection.d.ts +6 -2
  43. package/types/src/dataValidation/IDataValidationCollection.d.ts +6 -2
  44. package/types/src/hyperlink/IHyperlink.d.ts +3 -1
  45. package/types/src/hyperlink/_Hyperlink.d.ts +6 -0
  46. package/types/src/lib/utils/utils.browser.d.ts +5 -0
  47. package/types/src/license/LicenseDetails.d.ts +5 -0
  48. package/types/src/primitives/CalcSignal.d.ts +20 -0
  49. package/types/src/protectedRange/IProtectedRangeCollection.d.ts +7 -2
  50. package/types/src/scripting/_ScriptUtils.d.ts +13 -0
  51. package/types/src/sheet/Sheet.d.ts +33 -2
  52. package/types/src/sheet/SheetCell.d.ts +2 -0
  53. package/types/src/sheet/_SheetStateTypes.d.ts +14 -1
  54. package/types/src/style/IStyle.d.ts +5 -0
  55. package/types/src/table/AnchoredTable.d.ts +17 -1
  56. package/types/src/text/TextUtils.d.ts +18 -0
  57. package/browser/cjs/1mH2uhx_Dmceu88H.cjs +0 -33
@@ -1,4 +1,4 @@
1
- const e=require("./1mH2uhx_Dmceu88H.cjs");let t=require("@sheetxl/primitives");function n(e){console&&console.error&&console.error(`Error: ${e}`)}function r(e){console&&console.warn&&console.warn(`Warning: ${e}`)}function i(e){let t=new Date().getTime(),n=e();return{time:new Date().getTime()-t,value:n}}function a(e){function t(){}t.prototype=e;let n=new t;function r(){return typeof n.bar}return r(),r(),e}var o=class{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){this._definition=e}accept(e){e.visit(this),this.definition.forEach(t=>{t.accept(e)})}},s=class extends o{constructor(e){super([]),this.idx=1,Object.assign(this,v(e))}set definition(e){}get definition(){return this.referencedRule===void 0?[]:this.referencedRule.definition}accept(e){e.visit(this)}},c=class extends o{constructor(e){super(e.definition),this.orgText=``,Object.assign(this,v(e))}},l=class extends o{constructor(e){super(e.definition),this.ignoreAmbiguities=!1,Object.assign(this,v(e))}},u=class extends o{constructor(e){super(e.definition),this.idx=1,Object.assign(this,v(e))}},d=class extends o{constructor(e){super(e.definition),this.idx=1,Object.assign(this,v(e))}},f=class extends o{constructor(e){super(e.definition),this.idx=1,Object.assign(this,v(e))}},p=class extends o{constructor(e){super(e.definition),this.idx=1,Object.assign(this,v(e))}},m=class extends o{constructor(e){super(e.definition),this.idx=1,Object.assign(this,v(e))}},h=class extends o{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){super(e.definition),this.idx=1,this.ignoreAmbiguities=!1,this.hasPredicates=!1,Object.assign(this,v(e))}},g=class{constructor(e){this.idx=1,Object.assign(this,v(e))}accept(e){e.visit(this)}};function _(e){function t(e){return e.map(_)}if(e instanceof s){let t={type:`NonTerminal`,name:e.nonTerminalName,idx:e.idx};return typeof e.label==`string`&&(t.label=e.label),t}if(e instanceof l)return{type:`Alternative`,definition:t(e.definition)};if(e instanceof u)return{type:`Option`,idx:e.idx,definition:t(e.definition)};if(e instanceof d)return{type:`RepetitionMandatory`,idx:e.idx,definition:t(e.definition)};if(e instanceof f)return{type:`RepetitionMandatoryWithSeparator`,idx:e.idx,separator:_(new g({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof m)return{type:`RepetitionWithSeparator`,idx:e.idx,separator:_(new g({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof p)return{type:`Repetition`,idx:e.idx,definition:t(e.definition)};if(e instanceof h)return{type:`Alternation`,idx:e.idx,definition:t(e.definition)};if(e instanceof g){let t={type:`Terminal`,name:e.terminalType.name,label:(n=e.terminalType,typeof(r=n).LABEL==`string`&&r.LABEL!==``?n.LABEL:n.name),idx:e.idx};typeof e.label==`string`&&(t.terminalLabel=e.label);let i=e.terminalType.PATTERN;return e.terminalType.PATTERN&&(t.pattern=i instanceof RegExp?i.source:i),t}if(e instanceof c)return{type:`Rule`,name:e.name,orgText:e.orgText,definition:t(e.definition)};throw Error(`non exhaustive match`);var n,r}function v(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}var y=class{visit(e){let t=e;switch(t.constructor){case s:return this.visitNonTerminal(t);case l:return this.visitAlternative(t);case u:return this.visitOption(t);case d:return this.visitRepetitionMandatory(t);case f:return this.visitRepetitionMandatoryWithSeparator(t);case m:return this.visitRepetitionWithSeparator(t);case p:return this.visitRepetition(t);case h:return this.visitAlternation(t);case g:return this.visitTerminal(t);case c:return this.visitRule(t);default:throw Error(`non exhaustive match`)}}visitNonTerminal(e){}visitAlternative(e){}visitOption(e){}visitRepetition(e){}visitRepetitionMandatory(e){}visitRepetitionMandatoryWithSeparator(e){}visitRepetitionWithSeparator(e){}visitAlternation(e){}visitTerminal(e){}visitRule(e){}};function b(e,t=[]){return e instanceof u||e instanceof p||e instanceof m||(e instanceof h?e.definition.some(e=>b(e,t)):!(e instanceof s&&t.includes(e))&&e instanceof o&&(e instanceof s&&t.push(e),e.definition.every(e=>b(e,t))))}function x(e){if(e instanceof s)return`SUBRULE`;if(e instanceof u)return`OPTION`;if(e instanceof h)return`OR`;if(e instanceof d)return`AT_LEAST_ONE`;if(e instanceof f)return`AT_LEAST_ONE_SEP`;if(e instanceof m)return`MANY_SEP`;if(e instanceof p)return`MANY`;if(e instanceof g)return`CONSUME`;throw Error(`non exhaustive match`)}var S=class{walk(e,t=[]){e.definition.forEach((n,r)=>{let i=e.definition.slice(r+1);if(n instanceof s)this.walkProdRef(n,i,t);else if(n instanceof g)this.walkTerminal(n,i,t);else if(n instanceof l)this.walkFlat(n,i,t);else if(n instanceof u)this.walkOption(n,i,t);else if(n instanceof d)this.walkAtLeastOne(n,i,t);else if(n instanceof f)this.walkAtLeastOneSep(n,i,t);else if(n instanceof m)this.walkManySep(n,i,t);else if(n instanceof p)this.walkMany(n,i,t);else{if(!(n instanceof h))throw Error(`non exhaustive match`);this.walkOr(n,i,t)}})}walkTerminal(e,t,n){}walkProdRef(e,t,n){}walkFlat(e,t,n){let r=t.concat(n);this.walk(e,r)}walkOption(e,t,n){let r=t.concat(n);this.walk(e,r)}walkAtLeastOne(e,t,n){let r=[new u({definition:e.definition})].concat(t,n);this.walk(e,r)}walkAtLeastOneSep(e,t,n){let r=C(e,t,n);this.walk(e,r)}walkMany(e,t,n){let r=[new u({definition:e.definition})].concat(t,n);this.walk(e,r)}walkManySep(e,t,n){let r=C(e,t,n);this.walk(e,r)}walkOr(e,t,n){let r=t.concat(n);e.definition.forEach(e=>{let t=new l({definition:[e]});this.walk(t,r)})}};function C(e,t,n){return[new u({definition:[new g({terminalType:e.separator})].concat(e.definition)})].concat(t,n)}function w(e){if(e instanceof s)return w(e.referencedRule);if(e instanceof g)return[e.terminalType];if(function(e){return e instanceof l||e instanceof u||e instanceof p||e instanceof d||e instanceof f||e instanceof m||e instanceof g||e instanceof c}(e))return function(e){let t=[],n=e.definition,r,i=0,a=n.length>i,o=!0;for(;a&&o;)r=n[i],o=b(r),t=t.concat(w(r)),i+=1,a=n.length>i;return[...new Set(t)]}(e);if(function(e){return e instanceof h}(e))return function(e){let t=e.definition.map(e=>w(e));return[...new Set(t.flat())]}(e);throw Error(`non exhaustive match`)}var T=`_~IN~_`,E=class extends S{constructor(e){super(),this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,t,n){}walkProdRef(e,t,n){let r=(i=e.referencedRule,a=e.idx,i.name+a+T+this.topProd.name);var i,a;let o=w(new l({definition:t.concat(n)}));this.follows[r]=o}};function D(e){return e.charCodeAt(0)}function O(e,t){Array.isArray(e)?e.forEach(function(e){t.push(e)}):t.push(e)}function k(e,t){if(!0===e[t])throw`duplicate flag `+t;e[t],e[t]=!0}function A(e){if(e===void 0)throw Error(`Internal Error - Should never get here!`);return!0}function j(){throw Error(`Internal Error - Should never get here!`)}function M(e){return e.type===`Character`}var N=[];for(let e=D(`0`);e<=D(`9`);e++)N.push(e);var P=[D(`_`)].concat(N);for(let e=D(`a`);e<=D(`z`);e++)P.push(e);for(let e=D(`A`);e<=D(`Z`);e++)P.push(e);var ee=[D(` `),D(`\f`),D(`
1
+ const e=require("./Bc4JjVVZfFo3R4He.cjs");let t=require("@sheetxl/primitives");function n(e){console&&console.error&&console.error(`Error: ${e}`)}function r(e){console&&console.warn&&console.warn(`Warning: ${e}`)}function i(e){let t=new Date().getTime(),n=e();return{time:new Date().getTime()-t,value:n}}function a(e){function t(){}t.prototype=e;let n=new t;function r(){return typeof n.bar}return r(),r(),e}var o=class{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){this._definition=e}accept(e){e.visit(this),this.definition.forEach(t=>{t.accept(e)})}},s=class extends o{constructor(e){super([]),this.idx=1,Object.assign(this,v(e))}set definition(e){}get definition(){return this.referencedRule===void 0?[]:this.referencedRule.definition}accept(e){e.visit(this)}},c=class extends o{constructor(e){super(e.definition),this.orgText=``,Object.assign(this,v(e))}},l=class extends o{constructor(e){super(e.definition),this.ignoreAmbiguities=!1,Object.assign(this,v(e))}},u=class extends o{constructor(e){super(e.definition),this.idx=1,Object.assign(this,v(e))}},d=class extends o{constructor(e){super(e.definition),this.idx=1,Object.assign(this,v(e))}},f=class extends o{constructor(e){super(e.definition),this.idx=1,Object.assign(this,v(e))}},p=class extends o{constructor(e){super(e.definition),this.idx=1,Object.assign(this,v(e))}},m=class extends o{constructor(e){super(e.definition),this.idx=1,Object.assign(this,v(e))}},h=class extends o{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){super(e.definition),this.idx=1,this.ignoreAmbiguities=!1,this.hasPredicates=!1,Object.assign(this,v(e))}},g=class{constructor(e){this.idx=1,Object.assign(this,v(e))}accept(e){e.visit(this)}};function _(e){function t(e){return e.map(_)}if(e instanceof s){let t={type:`NonTerminal`,name:e.nonTerminalName,idx:e.idx};return typeof e.label==`string`&&(t.label=e.label),t}if(e instanceof l)return{type:`Alternative`,definition:t(e.definition)};if(e instanceof u)return{type:`Option`,idx:e.idx,definition:t(e.definition)};if(e instanceof d)return{type:`RepetitionMandatory`,idx:e.idx,definition:t(e.definition)};if(e instanceof f)return{type:`RepetitionMandatoryWithSeparator`,idx:e.idx,separator:_(new g({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof m)return{type:`RepetitionWithSeparator`,idx:e.idx,separator:_(new g({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof p)return{type:`Repetition`,idx:e.idx,definition:t(e.definition)};if(e instanceof h)return{type:`Alternation`,idx:e.idx,definition:t(e.definition)};if(e instanceof g){let t={type:`Terminal`,name:e.terminalType.name,label:(n=e.terminalType,typeof(r=n).LABEL==`string`&&r.LABEL!==``?n.LABEL:n.name),idx:e.idx};typeof e.label==`string`&&(t.terminalLabel=e.label);let i=e.terminalType.PATTERN;return e.terminalType.PATTERN&&(t.pattern=i instanceof RegExp?i.source:i),t}if(e instanceof c)return{type:`Rule`,name:e.name,orgText:e.orgText,definition:t(e.definition)};throw Error(`non exhaustive match`);var n,r}function v(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}var y=class{visit(e){let t=e;switch(t.constructor){case s:return this.visitNonTerminal(t);case l:return this.visitAlternative(t);case u:return this.visitOption(t);case d:return this.visitRepetitionMandatory(t);case f:return this.visitRepetitionMandatoryWithSeparator(t);case m:return this.visitRepetitionWithSeparator(t);case p:return this.visitRepetition(t);case h:return this.visitAlternation(t);case g:return this.visitTerminal(t);case c:return this.visitRule(t);default:throw Error(`non exhaustive match`)}}visitNonTerminal(e){}visitAlternative(e){}visitOption(e){}visitRepetition(e){}visitRepetitionMandatory(e){}visitRepetitionMandatoryWithSeparator(e){}visitRepetitionWithSeparator(e){}visitAlternation(e){}visitTerminal(e){}visitRule(e){}};function b(e,t=[]){return e instanceof u||e instanceof p||e instanceof m||(e instanceof h?e.definition.some(e=>b(e,t)):!(e instanceof s&&t.includes(e))&&e instanceof o&&(e instanceof s&&t.push(e),e.definition.every(e=>b(e,t))))}function x(e){if(e instanceof s)return`SUBRULE`;if(e instanceof u)return`OPTION`;if(e instanceof h)return`OR`;if(e instanceof d)return`AT_LEAST_ONE`;if(e instanceof f)return`AT_LEAST_ONE_SEP`;if(e instanceof m)return`MANY_SEP`;if(e instanceof p)return`MANY`;if(e instanceof g)return`CONSUME`;throw Error(`non exhaustive match`)}var S=class{walk(e,t=[]){e.definition.forEach((n,r)=>{let i=e.definition.slice(r+1);if(n instanceof s)this.walkProdRef(n,i,t);else if(n instanceof g)this.walkTerminal(n,i,t);else if(n instanceof l)this.walkFlat(n,i,t);else if(n instanceof u)this.walkOption(n,i,t);else if(n instanceof d)this.walkAtLeastOne(n,i,t);else if(n instanceof f)this.walkAtLeastOneSep(n,i,t);else if(n instanceof m)this.walkManySep(n,i,t);else if(n instanceof p)this.walkMany(n,i,t);else{if(!(n instanceof h))throw Error(`non exhaustive match`);this.walkOr(n,i,t)}})}walkTerminal(e,t,n){}walkProdRef(e,t,n){}walkFlat(e,t,n){let r=t.concat(n);this.walk(e,r)}walkOption(e,t,n){let r=t.concat(n);this.walk(e,r)}walkAtLeastOne(e,t,n){let r=[new u({definition:e.definition})].concat(t,n);this.walk(e,r)}walkAtLeastOneSep(e,t,n){let r=C(e,t,n);this.walk(e,r)}walkMany(e,t,n){let r=[new u({definition:e.definition})].concat(t,n);this.walk(e,r)}walkManySep(e,t,n){let r=C(e,t,n);this.walk(e,r)}walkOr(e,t,n){let r=t.concat(n);e.definition.forEach(e=>{let t=new l({definition:[e]});this.walk(t,r)})}};function C(e,t,n){return[new u({definition:[new g({terminalType:e.separator})].concat(e.definition)})].concat(t,n)}function w(e){if(e instanceof s)return w(e.referencedRule);if(e instanceof g)return[e.terminalType];if(function(e){return e instanceof l||e instanceof u||e instanceof p||e instanceof d||e instanceof f||e instanceof m||e instanceof g||e instanceof c}(e))return function(e){let t=[],n=e.definition,r,i=0,a=n.length>i,o=!0;for(;a&&o;)r=n[i],o=b(r),t=t.concat(w(r)),i+=1,a=n.length>i;return[...new Set(t)]}(e);if(function(e){return e instanceof h}(e))return function(e){let t=e.definition.map(e=>w(e));return[...new Set(t.flat())]}(e);throw Error(`non exhaustive match`)}var T=`_~IN~_`,E=class extends S{constructor(e){super(),this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,t,n){}walkProdRef(e,t,n){let r=(i=e.referencedRule,a=e.idx,i.name+a+T+this.topProd.name);var i,a;let o=w(new l({definition:t.concat(n)}));this.follows[r]=o}};function D(e){return e.charCodeAt(0)}function O(e,t){Array.isArray(e)?e.forEach(function(e){t.push(e)}):t.push(e)}function k(e,t){if(!0===e[t])throw`duplicate flag `+t;e[t],e[t]=!0}function A(e){if(e===void 0)throw Error(`Internal Error - Should never get here!`);return!0}function j(){throw Error(`Internal Error - Should never get here!`)}function M(e){return e.type===`Character`}var N=[];for(let e=D(`0`);e<=D(`9`);e++)N.push(e);var P=[D(`_`)].concat(N);for(let e=D(`a`);e<=D(`z`);e++)P.push(e);for(let e=D(`A`);e<=D(`Z`);e++)P.push(e);var ee=[D(` `),D(`\f`),D(`
2
2
  `),D(`\r`),D(` `),D(`\v`),D(` `),D(`\xA0`),D(` `),D(` `),D(` `),D(` `),D(` `),D(` `),D(` `),D(` `),D(` `),D(` `),D(` `),D(` `),D(`\u2028`),D(`\u2029`),D(` `),D(` `),D(` `),D(``)],te=/[0-9a-fA-F]/,F=/[0-9]/,ne=/[1-9]/,I=class{visitChildren(e){for(let t in e){let n=e[t];e.hasOwnProperty(t)&&(n.type===void 0?Array.isArray(n)&&n.forEach(e=>{this.visit(e)},this):this.visit(n))}}visit(e){switch(e.type){case`Pattern`:this.visitPattern(e);break;case`Flags`:this.visitFlags(e);break;case`Disjunction`:this.visitDisjunction(e);break;case`Alternative`:this.visitAlternative(e);break;case`StartAnchor`:this.visitStartAnchor(e);break;case`EndAnchor`:this.visitEndAnchor(e);break;case`WordBoundary`:this.visitWordBoundary(e);break;case`NonWordBoundary`:this.visitNonWordBoundary(e);break;case`Lookahead`:this.visitLookahead(e);break;case`NegativeLookahead`:this.visitNegativeLookahead(e);break;case`Lookbehind`:this.visitLookbehind(e);break;case`NegativeLookbehind`:this.visitNegativeLookbehind(e);break;case`Character`:this.visitCharacter(e);break;case`Set`:this.visitSet(e);break;case`Group`:this.visitGroup(e);break;case`GroupBackReference`:this.visitGroupBackReference(e);break;case`Quantifier`:this.visitQuantifier(e)}this.visitChildren(e)}visitPattern(e){}visitFlags(e){}visitDisjunction(e){}visitAlternative(e){}visitStartAnchor(e){}visitEndAnchor(e){}visitWordBoundary(e){}visitNonWordBoundary(e){}visitLookahead(e){}visitNegativeLookahead(e){}visitLookbehind(e){}visitNegativeLookbehind(e){}visitCharacter(e){}visitSet(e){}visitGroup(e){}visitGroupBackReference(e){}visitQuantifier(e){}},L={},re=new class{constructor(){this.idx=0,this.input=``,this.groupIdx=0}saveState(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}}restoreState(e){this.idx=e.idx,this.input=e.input,this.groupIdx=e.groupIdx}pattern(e){this.idx=0,this.input=e,this.groupIdx=0,this.consumeChar(`/`);let t=this.disjunction();this.consumeChar(`/`);let n={type:`Flags`,loc:{begin:this.idx,end:e.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};for(;this.isRegExpFlag();)switch(this.popChar()){case`g`:k(n,`global`);break;case`i`:k(n,`ignoreCase`);break;case`m`:k(n,`multiLine`);break;case`u`:k(n,`unicode`);break;case`y`:k(n,`sticky`)}if(this.idx!==this.input.length)throw Error(`Redundant input: `+this.input.substring(this.idx));return{type:`Pattern`,flags:n,value:t,loc:this.loc(0)}}disjunction(){let e=[],t=this.idx;for(e.push(this.alternative());this.peekChar()===`|`;)this.consumeChar(`|`),e.push(this.alternative());return{type:`Disjunction`,value:e,loc:this.loc(t)}}alternative(){let e=[],t=this.idx;for(;this.isTerm();)e.push(this.term());return{type:`Alternative`,value:e,loc:this.loc(t)}}term(){return this.isAssertion()?this.assertion():this.atom()}assertion(){let e=this.idx;switch(this.popChar()){case`^`:return{type:`StartAnchor`,loc:this.loc(e)};case`$`:return{type:`EndAnchor`,loc:this.loc(e)};case`\\`:switch(this.popChar()){case`b`:return{type:`WordBoundary`,loc:this.loc(e)};case`B`:return{type:`NonWordBoundary`,loc:this.loc(e)}}throw Error(`Invalid Assertion Escape`);case`(`:let t;switch(this.consumeChar(`?`),this.popChar()){case`=`:t=`Lookahead`;break;case`!`:t=`NegativeLookahead`;break;case`<`:switch(this.popChar()){case`=`:t=`Lookbehind`;break;case`!`:t=`NegativeLookbehind`}}A(t);let n=this.disjunction();return this.consumeChar(`)`),{type:t,value:n,loc:this.loc(e)}}return j()}quantifier(e=!1){let t,n=this.idx;switch(this.popChar()){case`*`:t={atLeast:0,atMost:1/0};break;case`+`:t={atLeast:1,atMost:1/0};break;case`?`:t={atLeast:0,atMost:1};break;case`{`:let n=this.integerIncludingZero();switch(this.popChar()){case`}`:t={atLeast:n,atMost:n};break;case`,`:let e;this.isDigit()?(e=this.integerIncludingZero(),t={atLeast:n,atMost:e}):t={atLeast:n,atMost:1/0},this.consumeChar(`}`)}if(!0===e&&t===void 0)return;A(t)}if(!0!==e||t!==void 0)return A(t)?(this.peekChar(0)===`?`?(this.consumeChar(`?`),t.greedy=!1):t.greedy=!0,t.type=`Quantifier`,t.loc=this.loc(n),t):void 0}atom(){let e,t=this.idx;switch(this.peekChar()){case`.`:e=this.dotAll();break;case`\\`:e=this.atomEscape();break;case`[`:e=this.characterClass();break;case`(`:e=this.group()}return e===void 0&&this.isPatternCharacter()&&(e=this.patternCharacter()),A(e)?(e.loc=this.loc(t),this.isQuantifier()&&(e.quantifier=this.quantifier()),e):j()}dotAll(){return this.consumeChar(`.`),{type:`Set`,complement:!0,value:[D(`
3
3
  `),D(`\r`),D(`\u2028`),D(`\u2029`)]}}atomEscape(){switch(this.consumeChar(`\\`),this.peekChar()){case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:return this.decimalEscapeAtom();case`d`:case`D`:case`s`:case`S`:case`w`:case`W`:return this.characterClassEscape();case`f`:case`n`:case`r`:case`t`:case`v`:return this.controlEscapeAtom();case`c`:return this.controlLetterEscapeAtom();case`0`:return this.nulCharacterAtom();case`x`:return this.hexEscapeSequenceAtom();case`u`:return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}decimalEscapeAtom(){return{type:`GroupBackReference`,value:this.positiveInteger()}}characterClassEscape(){let e,t=!1;switch(this.popChar()){case`d`:e=N;break;case`D`:e=N,t=!0;break;case`s`:e=ee;break;case`S`:e=ee,t=!0;break;case`w`:e=P;break;case`W`:e=P,t=!0}return A(e)?{type:`Set`,value:e,complement:t}:j()}controlEscapeAtom(){let e;switch(this.popChar()){case`f`:e=D(`\f`);break;case`n`:e=D(`
4
4
  `);break;case`r`:e=D(`\r`);break;case`t`:e=D(` `);break;case`v`:e=D(`\v`)}return A(e)?{type:`Character`,value:e}:j()}controlLetterEscapeAtom(){this.consumeChar(`c`);let e=this.popChar();if(!1===/[a-zA-Z]/.test(e))throw Error(`Invalid `);return{type:`Character`,value:e.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar(`0`),{type:`Character`,value:D(`\0`)}}hexEscapeSequenceAtom(){return this.consumeChar(`x`),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar(`u`),this.parseHexDigits(4)}identityEscapeAtom(){return{type:`Character`,value:D(this.popChar())}}classPatternCharacterAtom(){switch(this.peekChar()){case`
@@ -1 +1 @@
1
- const e=require("./1mH2uhx_Dmceu88H.cjs"),t=require("./BX6A6xGDOr_td9mw.cjs");let n=require("@sheetxl/primitives"),r=require("@sheetxl/utils");var i=[`All`,`Data`,`Headers`,`Totals`,`This Row`],a=class{constructor(n=e.nt){let r=function(e){let t=[...i];if(e)for(let n of Object.values(e)){let e=n?.trim();e&&!t.some(t=>t.toLowerCase()===e.toLowerCase())&&t.push(e)}return t.sort((e,t)=>t.length-e.length),t.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`)}(n.specifiers),a=t.a({name:`WhiteSpace`,pattern:/\s+/,group:t.o.SKIPPED}),o=t.a({name:`TableSpecifier`,pattern:RegExp(`\\[#(?:${r})\\]`,`i`)}),s=[a,o,t.a({name:`BracketedColumn`,pattern:/\[([^[\]]*)\]/,longer_alt:[o]}),t.a({name:`BareSpecifier`,pattern:RegExp(`#(?:${r})`,`i`)}),t.a({name:`ColumnSep`,pattern:/:/}),t.a({name:`ListSep`,pattern:new RegExp(n.separators.separatorFunction.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`))})];this._lexer=new t.o(s,{ensureOptimizations:!0});let c={};s.forEach(e=>{c[e.name]=e}),this._vocabulary=c}getVocabulary(){return this._vocabulary}tokenize(e){return this._lexer.tokenize(e)}},o=class extends t.n{constructor(t=e.nt){let n=new a(t),r=n.getVocabulary();super(r,{nodeLocationTracking:`none`,maxLookahead:2,skipValidations:!0,recoveryEnabled:!1}),this._lexer=n;let{TableSpecifier:i,BracketedColumn:o,BareSpecifier:s,ColumnSep:c,ListSep:l}=r,u=this;u.RULE(`ruleContent`,()=>{let e=[],t=u.SUBRULE(u.ruleItem);return u.ACTION(()=>{t&&e.push(t)}),u.MANY(()=>{u.CONSUME(l),u.OPTION(()=>{let t=u.SUBRULE2(u.ruleItem);u.ACTION(()=>{t&&e.push(t)})})}),e}),u.RULE(`ruleItem`,()=>u.OR([{ALT:()=>u.SUBRULE(u.ruleSpecifier)},{ALT:()=>u.SUBRULE(u.ruleColumnOrRange)}])),u.RULE(`ruleSpecifier`,()=>u.OR([{ALT:()=>{let n=u.CONSUME(i);return u.ACTION(()=>{let r=e.Q(n.image,t);return r.image=n.image,r})}},{ALT:()=>{let n=u.CONSUME(s);return u.ACTION(()=>{let r=e.Q(n.image,t);return r.image=n.image,r})}}])),u.RULE(`ruleColumnOrRange`,()=>{let t=u.CONSUME(o),n,r;return u.OPTION(()=>{n=u.CONSUME(c),r=u.CONSUME2(o)}),u.ACTION(()=>{let i=e.X(t.image);if(i.image=t.image,!r)return i;let a=e.X(r.image);a.image=r.image;let o=e.R(`:`,i,a,!0);return o.image=n?.image??`:`,o})}),u.performSelfAnalysis()}_parseInner(e){let t=this._lexer.tokenize(e);return t.errors.length>0||t.tokens.length===0?[]:(this.input=t.tokens,this.reset(),this.ruleContent()??[])}_parseContent(t){if(!t)return[];let n=t.trim();if(!n)return[];let r=n[0];if(r===`@`){let t=n.slice(1).trim();if(!t){let t=e.G(`@`,null,!0);return t.image=`@`,[t]}let r=e.X(t);r.image=t;let i=e.G(`@`,r,!0);return i.image=`@`,[i]}if(r!==`[`&&r!==`#`){let n=e.X(t);return n.image=t,[n]}return this._parseInner(n)}parse(t,n,r){let i=()=>({root:e.Z(``,[]),errors:[]});if(!r)return i();let a=r.indexOf(`[`);if(a===-1)return i();let o=r.slice(0,a),s=r.slice(a+1,-1),c=this._parseContent(s);return{root:e.Z(o,c),errors:this.errors.length>0?[...this.errors]:[]}}},s=new Set([`:`,`.:.`,`.:`,`:.`]),c=new Set([`.:.`,`.:`,`:.`]),l=t=>{if(!t)return null;if(t.type===e.tt.Cell){let e=t.value;return e.rowIndex===-(2**53-1)?`col`:e.colIndex===-(2**53-1)?`row`:null}return Number.isInteger(t.value)?`row`:null},u=(e,t)=>{let n=parseInt(e.charCodeAt(0)===36?e.substring(1):e,10);return n>=1&&n<=t},d=`A formula must not be empty`;function f(e,t){let n=e?.[0]?.image;if(!n){let e=t?.image;return e?`Expected a value after '${e}'`:`Expected a value`}return`Unexpected '${n}'`}var p={...t.r,buildNoViableAltMessage:e=>f(e.actual,e.previous),buildEarlyExitMessage:e=>f(e.actual,e.previous),buildNotAllInputParsedMessage:e=>{let n=e.firstRedundant?.image;return n?`Unexpected '${n}'`:t.r.buildNotAllInputParsedMessage(e)},buildMismatchTokenMessage:e=>{let n=e.actual?.image;return e.expected===t.i&&n?`Unexpected '${n}'`:t.r.buildMismatchTokenMessage(e)}},m=class extends t.n{constructor(n){let r=n?.lexer??t.t.shared(n?.lexerOptions),i=r.getVocabulary();super(i,{skipValidations:!0,recoveryEnabled:!0,...n,nodeLocationTracking:`full`,errorMessageProvider:p,maxLookahead:1}),this._ruleInfixOp=this.RULE(`ruleInfixOp`,()=>{let{PlusOp:t,MinOp:n,MulOp:r,DivOp:i,ExOp:a,ConcatOp:o,GtOp:s,EqOp:c,LtOp:l,NeqOp:u,GteOp:d,LteOp:f}=this._vocab,p=[];return p.push({node:this.SUBRULE(this._rulePostfixOp)}),this.MANY(()=>{let m=this.OR(this._c1||=[{ALT:()=>this.CONSUME(t).image},{ALT:()=>this.CONSUME(n).image},{ALT:()=>this.CONSUME(r).image},{ALT:()=>this.CONSUME(i).image},{ALT:()=>this.CONSUME(a).image},{ALT:()=>this.CONSUME(o).image},{ALT:()=>this.CONSUME(s).image},{ALT:()=>this.CONSUME(c).image},{ALT:()=>this.CONSUME(l).image},{ALT:()=>this.CONSUME(u).image},{ALT:()=>this.CONSUME(d).image},{ALT:()=>this.CONSUME(f).image}]),h={value:m,index:this.getLexerPosition(),isRange:e.$.includes(m)},g=this.SUBRULE2(this._rulePostfixOp);p.push({op:h,node:g})}),this.ACTION(()=>{let t=p.length-1,n=e.A.length;for(let r=0;t>0&&r<n;r++){let n=e.A[r],i=1;for(;i<p.length;){let r=p[i].op;if(n.includes(r.value)){let n=p[i-1].node,a=p[i].node,o=e.R(r.value,n,a,r.isRange);o=this._tag(o,r.index),p[i-1].node=o,p.splice(i,1),t--}else i++}}}),p[0].node}),this._rulePlusMinusOp=this.RULE(`rulePlusMinusOp`,()=>{let{PlusOp:e,MinOp:t}=this._vocab;return this.OR([{ALT:()=>this.CONSUME(e)},{ALT:()=>this.CONSUME(t)}])}),this._rulePostfixOp=this.RULE(`rulePostfixOp`,()=>{let{PercentOp:t}=this._vocab,n=this.SUBRULE(this._rulePrefixOp),r=[];return this.MANY(()=>{let e=this.CONSUME(t).image;this.ACTION(()=>{r.push([e,this.getLexerPosition()])})}),this.ACTION(()=>{let t=r.length;if(t!==0)for(let i=0;i<t;i++){let t=r[i],a=t[0],o=t[1],s=e.$.includes(a);n=e.W(a,n,s),n=this._tag(n,o)}}),n}),this._rulePrefixOp=this.RULE(`rulePrefixOp`,()=>{let{PlusOp:t,MinOp:n,ImplicitIntersectOp:r}=this._vocab,i=[];this.MANY(()=>{let e=this.OR([{ALT:()=>this.CONSUME(t).image},{ALT:()=>this.CONSUME(n).image},{ALT:()=>this.CONSUME(r).image}]);this.ACTION(()=>{i.push([e,this.getLexerPosition()])})});let a=this.SUBRULE(this._ruleRangeOp);return this.ACTION(()=>{let t=i.length;if(t!==0)for(let n=t-1;n>=0;n--){let t=i[n],r=t[0],o=t[1],s=e.$.includes(r);a=e.G(r,a,s),a=this._tag(a,o)}}),a}),this._ruleRangeOp=this.RULE(`ruleRangeOp`,()=>{let{RangeOp:t,RangeTrimFullOp:n,RangeTrimLeadingOp:r,RangeTrimTrailingOp:i,ArrayAnchorOp:a}=this._vocab,o=[];return o.push({node:this.SUBRULE(this._ruleCallOp)}),this.MANY2(()=>{this.CONSUME(a),o.push({anchor:this.getLexerPosition()})}),this.MANY(()=>{let e={value:this.OR(this._c2||=[{ALT:()=>this.CONSUME(t).image},{ALT:()=>this.CONSUME(n).image},{ALT:()=>this.CONSUME(r).image},{ALT:()=>this.CONSUME(i).image}]),index:this.getLexerPosition()},s=this.SUBRULE2(this._ruleCallOp);o.push({op:e,node:s}),this.MANY3(()=>{this.CONSUME2(a),o.push({anchor:this.getLexerPosition()})})}),this.ACTION(()=>{for(let t=1;t<o.length;t++){let n=o[t];if(n.anchor!==void 0){o[0].node=this._tag(e.W(`#`,o[0].node,!0),n.anchor);continue}let r=n.op,i=e.R(r.value,o[0].node,n.node,!0);i=this._tag(i,r.index),o[0].node=i}}),o[0].node}),this._ruleCallOp=this.RULE(`ruleCallOp`,()=>{let{OpenParen:t,CloseParen:n}=this._vocab,r=this.SUBRULE(this._ruleFormula);return this.MANY({GATE:()=>{let e=this.LA(0),n=this.LA(1);return!(!e||!n||n.tokenType!==t)&&n.startOffset===e.endOffset+1},DEF:()=>{this.CONSUME(t);let i=this.getLexerPosition(),a=this.SUBRULE(this._ruleFunctionArguments),o=r,s=this.ACTION(()=>this._tag(e.N(o,a),i)),c=this.OPTION(()=>this.CONSUME(n));this.ACTION(()=>{c||this._reportError(s,`Missing closing parenthesis ')'`,i),this._tagClose(s,this.getLexerPosition()),r=s})}}),r}),this._ruleIntersectOp=this.RULE(`ruleIntersectOp`,()=>{let t=[this.SUBRULE(this._ruleInfixOp)];return this.MANY(()=>{this.OPTION({GATE:()=>{let e=this.LA(0);return this.LA(1).startOffset>e.endOffset+1},DEF:()=>{t.push(this.SUBRULE3(this._ruleInfixOp))}})}),this.ACTION(()=>{for(;t.length>1;){let n=t.length-1;for(let r=0;r<n;r++){let i=t[r],a=t[r+1],o=e.R(` `,i,a,!0),s=this._tokenMap.get(i);s&&delete s.tokenIndexClose;let c=this._tokenMap.get(a),l=c?.tokenIndex;if(l!==void 0){let e=this.input[l],t=this.input[l-1]?.endOffset??-1,n=this._inputText.slice(t+1,e.startOffset).slice(0,-1);n.length>0&&(o.wsBefore=n)}c&&delete c.tokenIndex,r+1<n&&c&&delete c.tokenIndexClose,t.splice(r,2,o),r--,n--}}}),t[0]}),this._ruleFormula=this.RULE(`ruleFormula`,()=>this.OR9([{ALT:()=>this.SUBRULE(this._ruleLiteral)},{ALT:()=>this.SUBRULE(this._ruleReference)},{ALT:()=>this.SUBRULE(this._ruleFunction)},{ALT:()=>this.SUBRULE(this._ruleParen)},{ALT:()=>this.SUBRULE(this._ruleTableReference)},{ALT:()=>this.SUBRULE(this._ruleBracketedString)},{ALT:()=>this.SUBRULE(this._ruleLiteralArray)}])),this._ruleGroup=this.RULE(`ruleGroup`,()=>{let{ArgSeparator:e}=this._vocab,t=[];return this.MANY(()=>{this.CONSUME(e);let n=this.SUBRULE2(this._ruleIntersectOp);this.ACTION(()=>{t.push(n)})}),t}),this._ruleParen=this.RULE(`ruleParen`,()=>{let{OpenParen:t,CloseParen:n}=this._vocab;return this._processParen(e.tt.Paren,t,n)}),this._ruleLiteralArray=this.RULE(`ruleLiteralArray`,()=>{let{OpenCurlyParen:t,CloseCurlyParen:n,ColSeparator:r,RowSeparator:i}=this._vocab,a=e.V();this.CONSUME(t);let o=this.getLexerPosition(),s=this.ACTION(()=>this._tag(e.z(a),o)),c=this.SUBRULE(this._ruleLiteralForArray);this.ACTION(()=>{a.value.push(c)}),this.MANY(()=>{let t=!1;this.OR([{ALT:()=>{this.CONSUME(r),t=!0}},{ALT:()=>this.CONSUME(i)}]);let n=this.SUBRULE2(this._ruleLiteralForArray);this.ACTION(()=>{t||(a=e.V(),s.value.push(a)),a.value.push(n)})});let l=this.OPTION(()=>this.CONSUME(n));return s=this.ACTION(()=>(l||this._reportError(s,`Missing closing parenthesis '}'`,o),this._tagClose(s,this.getLexerPosition()))),s}),this._ruleLiteralForArray=this.RULE(`ruleLiteralForArray`,()=>{let{StringToken:t,BooleanToken:n,LiteralError:r,RefError:i}=this._vocab;return this.OR([{ALT:()=>{let t=this.OPTION(()=>this.SUBRULE(this._rulePlusMinusOp)),n=this.SUBRULE(this._ruleNumber),r=this.ACTION(()=>this._tag(e.U(n.image,this._locale),this.getLexerPosition()));return this.ACTION(()=>t?e.K(t.image,r):r)}},{ALT:()=>{let n=this.CONSUME(t);return this.ACTION(()=>this._tag(e.Y(n.image),this.getLexerPosition()))}},{ALT:()=>{let t=this.CONSUME(n);return this.ACTION(()=>this._tag(e.M(t.image,this._locale),this.getLexerPosition()))}},{ALT:()=>{let t=this.CONSUME(r);return this.ACTION(()=>this._tag(e.B(t.image,this._locale),this.getLexerPosition()))}},{ALT:()=>{let t=this.CONSUME(i);return this.ACTION(()=>this._tag(e.q(t.image,this._locale),this.getLexerPosition()))}}])}),this._ruleLiteral=this.RULE(`ruleLiteral`,()=>{let{StringToken:t,BooleanToken:n,LiteralError:r,RefError:i}=this._vocab;return this.OR([{ALT:()=>{let t=this.SUBRULE(this._ruleNumber);return this.ACTION(()=>this._tag(e.U(t.image,this._locale),this.getLexerPosition()))}},{ALT:()=>{let n=this.CONSUME(t);return this.ACTION(()=>this._tag(e.Y(n.image),this.getLexerPosition()))}},{ALT:()=>{let t=this.CONSUME(n);return this.ACTION(()=>this._tag(e.M(t.image,this._locale),this.getLexerPosition()))}},{ALT:()=>{let t=this.CONSUME(r);return this.ACTION(()=>this._tag(e.B(t.image,this._locale),this.getLexerPosition()))}},{ALT:()=>{let t=this.CONSUME(i);return this.ACTION(()=>this._tag(e.q(t.image,this._locale),this.getLexerPosition()))}}])}),this._ruleFunction=this.RULE(`ruleFunction`,()=>{let{FunctionToken:t,OpenParen:n,CloseParen:r}=this._vocab,i=this.CONSUME(t).image,a=this.getLexerPosition();this.CONSUME(n);let o=this.SUBRULE(this._ruleFunctionArguments),s=this.ACTION(()=>this._tag(e.L(i,o),a)),c=this.OPTION(()=>this.CONSUME(r));return s=this.ACTION(()=>(c||this._reportError(s,`Missing closing parenthesis ')'`,a),this._tagClose(s,this.getLexerPosition()))),s}),this._ruleFunctionArguments=this.RULE(`ruleFunctionArguments`,()=>{let{ArgSeparator:t,CloseParen:n}=this._vocab,r=[];return this.OPTION({GATE:()=>this.LA(1).tokenType!==n,DEF:()=>{let n;this.OPTION2(()=>{n=this.SUBRULE(this._ruleIntersectOp)}),n=this.ACTION(()=>n??this._tagClose(e.I(),this.getLexerPosition())),r.push(n),this.MANY(()=>{let n;this.CONSUME(t),this.OPTION3(()=>{n=this.SUBRULE2(this._ruleIntersectOp)}),n=this.ACTION(()=>n??this._tagClose(e.I(),this.getLexerPosition())),r.push(n)})}}),r}),this._ruleBracketedString=this.RULE(`ruleBracketedString`,()=>{let{BracketedString:e}=this._vocab,t=this.CONSUME(e),n=this.getLexerPosition();return this.ACTION(()=>{let e=this._srParser.parse(this.rowIndex,this.colIndex,t.image);for(let t of e.errors)this._astErrors.push(t);return this._tag(e.root,n)})}),this._ruleTableReference=this.RULE(`ruleTableReference`,()=>{let{TableReference:e}=this._vocab,t=this.CONSUME(e),n=this.getLexerPosition();return this.ACTION(()=>{let e=this._srParser.parse(this.rowIndex,this.colIndex,t.image);for(let t of e.errors)this._astErrors.push(t);return this._tag(e.root,n)})}),this._ruleReference=this.RULE(`ruleReference`,()=>{let{Sheet:t,SheetQuoted:n,DivOp:r,MulOp:i,PlusOp:a,MinOp:o,ArgSeparator:s,Cell:c,NamedToken:l,SingleQuotedString:u,Column:d,AbsRow:f,DigitToken:p,RefError:m}=this._vocab,h;this.OPTION2({GATE:()=>{for(let e=1;e<6;e++){let c=this.LA(e);if(c.tokenType===t||c.tokenType===n)return!0;if(c.image===``||c.image===`)`||c.tokenType===r||c.tokenType===i||c.tokenType===a||c.tokenType===o||c.tokenType===s)break}return!1},DEF:()=>{h=this.SUBRULE(this._rulePrefixSheetName)}});let g=this.OR([{ALT:()=>{let t=this.CONSUME(c),n=this.getLexerPosition();return this.ACTION(()=>this._tag(e.P(t.image,this.rowIndex,this.colIndex),n))}},{ALT:()=>{let t=this.OR2([{ALT:()=>this.CONSUME(l)},{ALT:()=>this.CONSUME(u)}]);return this.ACTION(()=>this._tag(e.H(t.image),this.getLexerPosition()))}},{ALT:()=>this.SUBRULE(this._ruleBracketedString)},{ALT:()=>this.SUBRULE(this._ruleFunction)},{ALT:()=>{let t=this.CONSUME(d);return this.ACTION(()=>this._tag(e.F(t.image,this.colIndex),this.getLexerPosition()))}},{ALT:()=>{let t=this.CONSUME(f);return this.ACTION(()=>this._tag(e.J(t.image,this.rowIndex),this.getLexerPosition()))}},{ALT:()=>{let t=this.CONSUME(p);return this.ACTION(()=>this._tag(e.J(t.image,this.rowIndex),this.getLexerPosition()))}},{ALT:()=>{let t=this.CONSUME(m);return this.ACTION(()=>this._tag(e.q(t.image,this._locale),this.getLexerPosition()))}}]);return this.ACTION(()=>{if(h&&g){if(h.name===``)return void this._reportError(g,`'${h.image}' is not a valid sheet reference — a '!' needs a sheet name before it`);let t=g;g.type===e.tt.Postfix&&g.inputs?.[0]&&(t=g.inputs[0]),t.type!==e.tt.Cell&&t.type!==e.tt.Named&&t.type!==e.tt.Row&&t.type!==e.tt.TableColumn&&t.type!==e.tt.Error||(t.value.scope=h.name,t.value.scopeImage=h.image)}}),g}),this._rulePrefixSheetName=this.RULE(`rulePrefixSheetName`,()=>{let{SheetQuoted:e,BracketedString:t,NamedToken:n,RangeOp:r,Sheet:i}=this._vocab;return this.OR([{ALT:()=>{let t=this.CONSUME(e).image;return{name:t.slice(1,-2).replace(/''/g,`'`),image:t}}},{ALT:()=>{let e=``;this.OPTION(()=>{e+=this.CONSUME(t).image}),this.OPTION2({GATE:()=>this.LA(2).tokenType===r,DEF:()=>{e+=this.CONSUME(n).image,this.CONSUME(r),e+=`:`}});let a=this.CONSUME(i).image;return{name:e+a.slice(0,-1),image:e+a}}}])}),this._ruleNumber=this.RULE(`ruleNumber`,()=>{let{NumberToken:e,ScientificDigit:t,DigitToken:n}=this._vocab;return this.OR([{ALT:()=>this.CONSUME(e)},{ALT:()=>this.CONSUME(t)},{ALT:()=>this.CONSUME(n)}])}),this._ruleRoot=this.RULE(`ruleRoot`,()=>{let{ArgSeparator:t}=this._vocab,n=this.SUBRULE(this._ruleIntersectOp),r=[];return this.MANY(()=>{this.CONSUME(t),r.push(this.SUBRULE2(this._ruleIntersectOp))}),this.ACTION(()=>r.length===0?n:{type:e.tt.List,value:`,`,inputs:[n,...r],isReference:!0})}),this._lexer=r,this._locale=r.getLocale(),this._vocab=i,this._srParser=n?.srParser??new o(this._locale),this.performSelfAnalysis()}getLexer(){return this._lexer}parse(t,r,i,a){let o=this._lexer.tokenize(i),f;if(!o)return{root:{type:e.tt.Unparsed,value:i},errors:[]};let p=o.tokens;if(p.length===0)throw new n.FormulaError.Parse(d);return this.input=p,this._inputText=i,this._inputTextLength=i.length,this.rowIndex=t,this.colIndex=r,this._astErrors=[],this._tokenMap=new Map,this.reset(),f=this._ruleRoot(),f&&this._bindAllWhitespace(f),f=e.et(f,(n,r)=>{let i=n.type,a=r?.isReference?r.value:void 0,o=typeof a==`string`&&s.has(a),d=typeof a==`string`&&c.has(a),f=o?r.inputs:void 0,p=f?f[0]===n?f[1]:f[0]:void 0,m=this._lexer.getMaxRow();if(o&&i!==e.tt.Cell&&Number.isInteger(n.value)){let r=e.J(n.image,t);return e.j(r,n),l(p)===`row`?u(n.image,m)||this._reportError(r,`'${n.image}' is not a valid row — rows run from 1 to ${m}`):this._reportError(r,`'${n.image}' is not a valid reference — a whole row can only pair with another row (as in ${n.image}:${n.image})`),r}if(d&&i===e.tt.Named)return this._reportError(n,`'${n.image??n.value?.nameId}' is a name — '${a}' needs a cell or range on both sides`),n;if(i===e.tt.Cell){let t=n.value,r=t.colIndex===-(2**53-1),i=t.rowIndex===-(2**53-1);if((r||i)&&l(p)===(r?`row`:`col`))return r&&!u(n.image,m)&&this._reportError(n,`'${n.image}' is not a valid row — rows run from 1 to ${m}`),n;if(r||i||t.colIndex>=16384){let o=e.H(n.image);e.j(o,n);let s=t.scope;return s&&(o.value.scope=s,o.value.scopeImage=t.scopeImage),r?this._reportError(o,`'${n.image}' is not a valid reference — a row needs a column (use ${n.image}:${n.image} for the whole row)`):i&&n.image.includes(`$`)?this._reportError(o,`'${n.image}' is not a valid reference — a whole column can only pair with another column (as in ${n.image}:${n.image})`):d&&this._reportError(o,`'${n.image}' is a name — '${a}' needs a cell or range on both sides`),o}}return n}),a&&f&&(f=e.g(f,a,null)),{root:f,errors:[...this.errors,...this._astErrors]}}_processParen(e,t,n){let r;this.CONSUME(t);let i=this.getLexerPosition();r=this.ACTION(()=>(r={type:e,value:null,inputs:null},this._tag(r,i)));let a=[],o=this.SUBRULE(this._ruleIntersectOp);o&&a.push(o);let s=this.SUBRULE(this._ruleGroup),c=this.OPTION(()=>this.CONSUME(n));return r=this.ACTION(()=>{if(s)for(let e=0;e<s.length;e++)a.push(s[e]);return r&&(c||this._reportError(r,`Missing closing parenthesis`,i),r.inputs=a),this._tagClose(r,this.getLexerPosition())}),r}_reportError(e,t,n=void 0,r=`SyntaxError`){n===void 0&&(n=this.getLexerPosition()),e.error=!0,this._astErrors.push({name:r,message:t,previousToken:this.input[n],ast:e})}_tag(e,t){return e?(e.image??=this.input[t].image,this._tokenMap.set(e,{tokenIndex:t,tokenIndexClose:t}),e):(console.warn(`node is null`),e)}_tagClose(e,t){let n=this._tokenMap.get(e);return n?n.tokenIndexClose=t:this._tokenMap.set(e,{tokenIndexClose:t}),e}_bindNodeWhitespace(e){let t=this._tokenMap.get(e);if(!t)return;let n=this.input,r=this._inputText,i=t.tokenIndex;if(i!==void 0){let t=n[i],a=n[i-1]?.endOffset??-1;a+1<t.startOffset&&(e.wsBefore=r.slice(a+1,t.startOffset))}let a=t.tokenIndexClose;if(a!==void 0){let t=n[a],i=n[a+1]?.startOffset??this._inputTextLength;t.endOffset+1<i&&(e.wsAfter=r.slice(t.endOffset+1,i))}}_bindAllWhitespace(t){if(t){if(this._bindNodeWhitespace(t),t.inputs)for(let e of t.inputs)e&&this._bindAllWhitespace(e);if(t.type===e.tt.Array&&Array.isArray(t.value)){for(let e of t.value)if(e&&Array.isArray(e.value))for(let t of e.value)t&&this._bindAllWhitespace(t)}}}};exports.FormulaCompiler=class{constructor(e){e={...e},this._editing=e.profile===`editing`,this._parser=new m(e)}compile(t,r,i,a,o,s,c,l){if(a.length===0){let e=new n.FormulaError.Parse(d);return this._compileUnparsed(t,o,a,{input:a,cause:e,causes:[e]})}if(a.length>e.rt.MAX_EXPRESSION_LENGTH){let r=new n.FormulaError.Parse((u=a.length,`A formula must not be longer than ${e.rt.MAX_EXPRESSION_LENGTH} characters (this one is ${u})`));return this._compileUnparsed(t,o,a,{input:a,cause:r,causes:[r]})}var u;let f,p,m=[];try{let e=this._parser.parse(r,i,a,l);f=e.root,m=e.errors}catch(e){p=n.FormulaError.isError(e,n.FormulaError.Code.Parse)?e:new n.FormulaError.Parse(e.message,e)}let h=[];for(let t of m)h.push(e.E(t));if(f){e.w(f,s??null)&&h.push(new n.FormulaError.Parse(`The implicit intersection operator ' ' requires a cell or range on both sides`)),e.C(f,s??null)&&h.push(new n.FormulaError.Parse(`The spill anchor operator '#' requires a cell or range`)),e.T(f,s??null)&&h.push(new n.FormulaError.Parse(`Expected a reference; a value cannot be converted to one.`));let t=e.y(f,s??null);t&&h.push(new n.FormulaError.Parse(t));let r=e.b(f,s??null);r&&h.push(new n.FormulaError.Parse(r));let i=e.x(f,s??null);i&&h.push(new n.FormulaError.Parse(i));let a=e.S(f);a&&h.push(new n.FormulaError.Parse(a))}h.length>0&&!p&&(p=h[0]);let g=null;if(p&&(g={input:a,cause:p,causes:h.length>0?h:[p]}),!f){if(this._editing){let e=this._recoverCompiled(t,r,i,a,o,g,c);if(e)return e}return this._compileUnparsed(t,o,a,g)}f=e.O(f,s??null),f=e._(f,s??null),o&&(f=e.D(f,o,c));let _=e.v(t,o,f,this._editing,g,s??null);return this._editing&&g&&e.k(_.getTokens(),o)!==a?this._recoverCompiled(t,r,i,a,o,g,c)||this._compileUnparsed(t,o,a,g):_}autoCorrect(e){let t;try{let n=this._parser.getLexer().tokenize(e,!1);if(n.errors.length>0)return null;t=n.tokens}catch{return null}let n=[];for(let e of t){let t=e.tokenType?.name;if(t===`OpenParen`)n.push(`)`);else if(t===`OpenCurlyParen`)n.push(`}`);else if((t===`CloseParen`||t===`CloseCurlyParen`)&&n.pop()!==(t===`CloseParen`?`)`:`}`))return null}return n.length===0?null:e+n.reverse().join(``)}_compileUnparsed(t,n,i,a){let o={runtime:t,symbols:n,getFunction:null,ast:null,evaluations:r.CommonUtils.EmptyArray,executions:r.CommonUtils.EmptyArray,bindings:r.CommonUtils.EmptyArray,referencesAbsolute:r.CommonUtils.EmptyArray,referencesExecute:r.CommonUtils.EmptyArray,referencesRelative:r.CommonUtils.EmptyArray,referencesRoot:r.CommonUtils.EmptyArray,referenceIndices:r.CommonUtils.EmptyArray,getTokens:()=>[{type:e.tt.Unparsed,value:i,text:i}],namedIds:r.CommonUtils.EmptyArray,symbolIds:r.CommonUtils.EmptyArray,hasTotals:!1,isReferenceOnly:!1,error:a,transform:()=>o};return o}_recoverCompiled(t,n,r,i,a,o,s){let c,l=i.length;try{let e=this._parser.getLexer().tokenize(i,!1);c=e.tokens,e.errors.length>0&&(l=Math.min(l,e.errors[0].offset))}catch{return null}let u=[];for(let e=c.length-1;e>=0&&u.length<24;e--){let t=(c[e].endOffset??-1)+1;t>0&&t<i.length&&t<=l&&u.push(t)}for(let c of u){let l=i.slice(0,c),u,d;try{u=this._parser.parse(n,r,l).root}catch{continue}if(!u||u.type===e.tt.Unparsed)continue;try{let n=e._(u,null),r=a?e.D(n,a,s):n;d=e.v(t,a,r,!0,o)}catch{continue}if(e.k(d.getTokens(),a)!==l)continue;let f=i.slice(c);if(f.length===0)return d;let p,m={...d,getTokens:()=>(p||(p=[...d.getTokens()],this._appendUnparsedTail(p,f)),p),transform:()=>m};return m}return null}_appendUnparsedTail(t,n){let r=[];for(let n of t)n.type===e.tt.Paren&&n.text===`(`?r.push({ctx:n.context,argIndex:0}):n.type===e.tt.Paren&&n.text===`)`?r.pop():n.type===e.tt.Separator&&r.length>0&&r[r.length-1].argIndex++;let i=r.length>0?r[r.length-1]:void 0,a=i?.ctx?{...i.ctx,argIndex:i.ctx.argIndex===-1?i.argIndex:i.ctx.argIndex}:void 0,o=(n,r)=>{let i={type:e.tt.Unparsed,value:n,text:n};a&&(i.context=a),r&&(i.isLookup=!0),t.push(i)},s=/[A-Za-z_][A-Za-z0-9_]*$/.exec(n),c=s?s.index:-1;c>=0&&(c===0||!/[A-Za-z0-9_.]/.test(n[c-1]))?(c>0&&o(n.slice(0,c)),o(n.slice(c),!0)):o(n)}};
1
+ const e=require("./Bc4JjVVZfFo3R4He.cjs"),t=require("./CD2RXdnfqSYNc6gX.cjs");let n=require("@sheetxl/primitives"),r=require("@sheetxl/utils");var i=[`All`,`Data`,`Headers`,`Totals`,`This Row`],a=class{constructor(n=e.nt){let r=function(e){let t=[...i];if(e)for(let n of Object.values(e)){let e=n?.trim();e&&!t.some(t=>t.toLowerCase()===e.toLowerCase())&&t.push(e)}return t.sort((e,t)=>t.length-e.length),t.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`)}(n.specifiers),a=t.a({name:`WhiteSpace`,pattern:/\s+/,group:t.o.SKIPPED}),o=t.a({name:`TableSpecifier`,pattern:RegExp(`\\[#(?:${r})\\]`,`i`)}),s=[a,o,t.a({name:`BracketedColumn`,pattern:/\[([^[\]]*)\]/,longer_alt:[o]}),t.a({name:`BareSpecifier`,pattern:RegExp(`#(?:${r})`,`i`)}),t.a({name:`ColumnSep`,pattern:/:/}),t.a({name:`ListSep`,pattern:new RegExp(n.separators.separatorFunction.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`))})];this._lexer=new t.o(s,{ensureOptimizations:!0});let c={};s.forEach(e=>{c[e.name]=e}),this._vocabulary=c}getVocabulary(){return this._vocabulary}tokenize(e){return this._lexer.tokenize(e)}},o=class extends t.n{constructor(t=e.nt){let n=new a(t),r=n.getVocabulary();super(r,{nodeLocationTracking:`none`,maxLookahead:2,skipValidations:!0,recoveryEnabled:!1}),this._lexer=n;let{TableSpecifier:i,BracketedColumn:o,BareSpecifier:s,ColumnSep:c,ListSep:l}=r,u=this;u.RULE(`ruleContent`,()=>{let e=[],t=u.SUBRULE(u.ruleItem);return u.ACTION(()=>{t&&e.push(t)}),u.MANY(()=>{u.CONSUME(l),u.OPTION(()=>{let t=u.SUBRULE2(u.ruleItem);u.ACTION(()=>{t&&e.push(t)})})}),e}),u.RULE(`ruleItem`,()=>u.OR([{ALT:()=>u.SUBRULE(u.ruleSpecifier)},{ALT:()=>u.SUBRULE(u.ruleColumnOrRange)}])),u.RULE(`ruleSpecifier`,()=>u.OR([{ALT:()=>{let n=u.CONSUME(i);return u.ACTION(()=>{let r=e.Q(n.image,t);return r.image=n.image,r})}},{ALT:()=>{let n=u.CONSUME(s);return u.ACTION(()=>{let r=e.Q(n.image,t);return r.image=n.image,r})}}])),u.RULE(`ruleColumnOrRange`,()=>{let t=u.CONSUME(o),n,r;return u.OPTION(()=>{n=u.CONSUME(c),r=u.CONSUME2(o)}),u.ACTION(()=>{let i=e.X(t.image);if(i.image=t.image,!r)return i;let a=e.X(r.image);a.image=r.image;let o=e.R(`:`,i,a,!0);return o.image=n?.image??`:`,o})}),u.performSelfAnalysis()}_parseInner(e){let t=this._lexer.tokenize(e);return t.errors.length>0||t.tokens.length===0?[]:(this.input=t.tokens,this.reset(),this.ruleContent()??[])}_parseContent(t){if(!t)return[];let n=t.trim();if(!n)return[];let r=n[0];if(r===`@`){let t=n.slice(1).trim();if(!t){let t=e.G(`@`,null,!0);return t.image=`@`,[t]}let r=e.X(t);r.image=t;let i=e.G(`@`,r,!0);return i.image=`@`,[i]}if(r!==`[`&&r!==`#`){let n=e.X(t);return n.image=t,[n]}return this._parseInner(n)}parse(t,n,r){let i=()=>({root:e.Z(``,[]),errors:[]});if(!r)return i();let a=r.indexOf(`[`);if(a===-1)return i();let o=r.slice(0,a),s=r.slice(a+1,-1),c=this._parseContent(s);return{root:e.Z(o,c),errors:this.errors.length>0?[...this.errors]:[]}}},s=new Set([`:`,`.:.`,`.:`,`:.`]),c=new Set([`.:.`,`.:`,`:.`]),l=t=>{if(!t)return null;if(t.type===e.tt.Cell){let e=t.value;return e.rowIndex===-(2**53-1)?`col`:e.colIndex===-(2**53-1)?`row`:null}return Number.isInteger(t.value)?`row`:null},u=(e,t)=>{let n=parseInt(e.charCodeAt(0)===36?e.substring(1):e,10);return n>=1&&n<=t},d=`A formula must not be empty`;function f(e,t){let n=e?.[0]?.image;if(!n){let e=t?.image;return e?`Expected a value after '${e}'`:`Expected a value`}return`Unexpected '${n}'`}var p={...t.r,buildNoViableAltMessage:e=>f(e.actual,e.previous),buildEarlyExitMessage:e=>f(e.actual,e.previous),buildNotAllInputParsedMessage:e=>{let n=e.firstRedundant?.image;return n?`Unexpected '${n}'`:t.r.buildNotAllInputParsedMessage(e)},buildMismatchTokenMessage:e=>{let n=e.actual?.image;return e.expected===t.i&&n?`Unexpected '${n}'`:t.r.buildMismatchTokenMessage(e)}},m=class extends t.n{constructor(n){let r=n?.lexer??t.t.shared(n?.lexerOptions),i=r.getVocabulary();super(i,{skipValidations:!0,recoveryEnabled:!0,...n,nodeLocationTracking:`full`,errorMessageProvider:p,maxLookahead:1}),this._ruleInfixOp=this.RULE(`ruleInfixOp`,()=>{let{PlusOp:t,MinOp:n,MulOp:r,DivOp:i,ExOp:a,ConcatOp:o,GtOp:s,EqOp:c,LtOp:l,NeqOp:u,GteOp:d,LteOp:f}=this._vocab,p=[];return p.push({node:this.SUBRULE(this._rulePostfixOp)}),this.MANY(()=>{let m=this.OR(this._c1||=[{ALT:()=>this.CONSUME(t).image},{ALT:()=>this.CONSUME(n).image},{ALT:()=>this.CONSUME(r).image},{ALT:()=>this.CONSUME(i).image},{ALT:()=>this.CONSUME(a).image},{ALT:()=>this.CONSUME(o).image},{ALT:()=>this.CONSUME(s).image},{ALT:()=>this.CONSUME(c).image},{ALT:()=>this.CONSUME(l).image},{ALT:()=>this.CONSUME(u).image},{ALT:()=>this.CONSUME(d).image},{ALT:()=>this.CONSUME(f).image}]),h={value:m,index:this.getLexerPosition(),isRange:e.$.includes(m)},g=this.SUBRULE2(this._rulePostfixOp);p.push({op:h,node:g})}),this.ACTION(()=>{let t=p.length-1,n=e.A.length;for(let r=0;t>0&&r<n;r++){let n=e.A[r],i=1;for(;i<p.length;){let r=p[i].op;if(n.includes(r.value)){let n=p[i-1].node,a=p[i].node,o=e.R(r.value,n,a,r.isRange);o=this._tag(o,r.index),p[i-1].node=o,p.splice(i,1),t--}else i++}}}),p[0].node}),this._rulePlusMinusOp=this.RULE(`rulePlusMinusOp`,()=>{let{PlusOp:e,MinOp:t}=this._vocab;return this.OR([{ALT:()=>this.CONSUME(e)},{ALT:()=>this.CONSUME(t)}])}),this._rulePostfixOp=this.RULE(`rulePostfixOp`,()=>{let{PercentOp:t}=this._vocab,n=this.SUBRULE(this._rulePrefixOp),r=[];return this.MANY(()=>{let e=this.CONSUME(t).image;this.ACTION(()=>{r.push([e,this.getLexerPosition()])})}),this.ACTION(()=>{let t=r.length;if(t!==0)for(let i=0;i<t;i++){let t=r[i],a=t[0],o=t[1],s=e.$.includes(a);n=e.W(a,n,s),n=this._tag(n,o)}}),n}),this._rulePrefixOp=this.RULE(`rulePrefixOp`,()=>{let{PlusOp:t,MinOp:n,ImplicitIntersectOp:r}=this._vocab,i=[];this.MANY(()=>{let e=this.OR([{ALT:()=>this.CONSUME(t).image},{ALT:()=>this.CONSUME(n).image},{ALT:()=>this.CONSUME(r).image}]);this.ACTION(()=>{i.push([e,this.getLexerPosition()])})});let a=this.SUBRULE(this._ruleRangeOp);return this.ACTION(()=>{let t=i.length;if(t!==0)for(let n=t-1;n>=0;n--){let t=i[n],r=t[0],o=t[1],s=e.$.includes(r);a=e.G(r,a,s),a=this._tag(a,o)}}),a}),this._ruleRangeOp=this.RULE(`ruleRangeOp`,()=>{let{RangeOp:t,RangeTrimFullOp:n,RangeTrimLeadingOp:r,RangeTrimTrailingOp:i,ArrayAnchorOp:a}=this._vocab,o=[];return o.push({node:this.SUBRULE(this._ruleCallOp)}),this.MANY2(()=>{this.CONSUME(a),o.push({anchor:this.getLexerPosition()})}),this.MANY(()=>{let e={value:this.OR(this._c2||=[{ALT:()=>this.CONSUME(t).image},{ALT:()=>this.CONSUME(n).image},{ALT:()=>this.CONSUME(r).image},{ALT:()=>this.CONSUME(i).image}]),index:this.getLexerPosition()},s=this.SUBRULE2(this._ruleCallOp);o.push({op:e,node:s}),this.MANY3(()=>{this.CONSUME2(a),o.push({anchor:this.getLexerPosition()})})}),this.ACTION(()=>{for(let t=1;t<o.length;t++){let n=o[t];if(n.anchor!==void 0){o[0].node=this._tag(e.W(`#`,o[0].node,!0),n.anchor);continue}let r=n.op,i=e.R(r.value,o[0].node,n.node,!0);i=this._tag(i,r.index),o[0].node=i}}),o[0].node}),this._ruleCallOp=this.RULE(`ruleCallOp`,()=>{let{OpenParen:t,CloseParen:n}=this._vocab,r=this.SUBRULE(this._ruleFormula);return this.MANY({GATE:()=>{let e=this.LA(0),n=this.LA(1);return!(!e||!n||n.tokenType!==t)&&n.startOffset===e.endOffset+1},DEF:()=>{this.CONSUME(t);let i=this.getLexerPosition(),a=this.SUBRULE(this._ruleFunctionArguments),o=r,s=this.ACTION(()=>this._tag(e.N(o,a),i)),c=this.OPTION(()=>this.CONSUME(n));this.ACTION(()=>{c||this._reportError(s,`Missing closing parenthesis ')'`,i),this._tagClose(s,this.getLexerPosition()),r=s})}}),r}),this._ruleIntersectOp=this.RULE(`ruleIntersectOp`,()=>{let t=[this.SUBRULE(this._ruleInfixOp)];return this.MANY(()=>{this.OPTION({GATE:()=>{let e=this.LA(0);return this.LA(1).startOffset>e.endOffset+1},DEF:()=>{t.push(this.SUBRULE3(this._ruleInfixOp))}})}),this.ACTION(()=>{for(;t.length>1;){let n=t.length-1;for(let r=0;r<n;r++){let i=t[r],a=t[r+1],o=e.R(` `,i,a,!0),s=this._tokenMap.get(i);s&&delete s.tokenIndexClose;let c=this._tokenMap.get(a),l=c?.tokenIndex;if(l!==void 0){let e=this.input[l],t=this.input[l-1]?.endOffset??-1,n=this._inputText.slice(t+1,e.startOffset).slice(0,-1);n.length>0&&(o.wsBefore=n)}c&&delete c.tokenIndex,r+1<n&&c&&delete c.tokenIndexClose,t.splice(r,2,o),r--,n--}}}),t[0]}),this._ruleFormula=this.RULE(`ruleFormula`,()=>this.OR9([{ALT:()=>this.SUBRULE(this._ruleLiteral)},{ALT:()=>this.SUBRULE(this._ruleReference)},{ALT:()=>this.SUBRULE(this._ruleFunction)},{ALT:()=>this.SUBRULE(this._ruleParen)},{ALT:()=>this.SUBRULE(this._ruleTableReference)},{ALT:()=>this.SUBRULE(this._ruleBracketedString)},{ALT:()=>this.SUBRULE(this._ruleLiteralArray)}])),this._ruleGroup=this.RULE(`ruleGroup`,()=>{let{ArgSeparator:e}=this._vocab,t=[];return this.MANY(()=>{this.CONSUME(e);let n=this.SUBRULE2(this._ruleIntersectOp);this.ACTION(()=>{t.push(n)})}),t}),this._ruleParen=this.RULE(`ruleParen`,()=>{let{OpenParen:t,CloseParen:n}=this._vocab;return this._processParen(e.tt.Paren,t,n)}),this._ruleLiteralArray=this.RULE(`ruleLiteralArray`,()=>{let{OpenCurlyParen:t,CloseCurlyParen:n,ColSeparator:r,RowSeparator:i}=this._vocab,a=e.V();this.CONSUME(t);let o=this.getLexerPosition(),s=this.ACTION(()=>this._tag(e.z(a),o)),c=this.SUBRULE(this._ruleLiteralForArray);this.ACTION(()=>{a.value.push(c)}),this.MANY(()=>{let t=!1;this.OR([{ALT:()=>{this.CONSUME(r),t=!0}},{ALT:()=>this.CONSUME(i)}]);let n=this.SUBRULE2(this._ruleLiteralForArray);this.ACTION(()=>{t||(a=e.V(),s.value.push(a)),a.value.push(n)})});let l=this.OPTION(()=>this.CONSUME(n));return s=this.ACTION(()=>(l||this._reportError(s,`Missing closing parenthesis '}'`,o),this._tagClose(s,this.getLexerPosition()))),s}),this._ruleLiteralForArray=this.RULE(`ruleLiteralForArray`,()=>{let{StringToken:t,BooleanToken:n,LiteralError:r,RefError:i}=this._vocab;return this.OR([{ALT:()=>{let t=this.OPTION(()=>this.SUBRULE(this._rulePlusMinusOp)),n=this.SUBRULE(this._ruleNumber),r=this.ACTION(()=>this._tag(e.U(n.image,this._locale),this.getLexerPosition()));return this.ACTION(()=>t?e.K(t.image,r):r)}},{ALT:()=>{let n=this.CONSUME(t);return this.ACTION(()=>this._tag(e.Y(n.image),this.getLexerPosition()))}},{ALT:()=>{let t=this.CONSUME(n);return this.ACTION(()=>this._tag(e.M(t.image,this._locale),this.getLexerPosition()))}},{ALT:()=>{let t=this.CONSUME(r);return this.ACTION(()=>this._tag(e.B(t.image,this._locale),this.getLexerPosition()))}},{ALT:()=>{let t=this.CONSUME(i);return this.ACTION(()=>this._tag(e.q(t.image,this._locale),this.getLexerPosition()))}}])}),this._ruleLiteral=this.RULE(`ruleLiteral`,()=>{let{StringToken:t,BooleanToken:n,LiteralError:r,RefError:i}=this._vocab;return this.OR([{ALT:()=>{let t=this.SUBRULE(this._ruleNumber);return this.ACTION(()=>this._tag(e.U(t.image,this._locale),this.getLexerPosition()))}},{ALT:()=>{let n=this.CONSUME(t);return this.ACTION(()=>this._tag(e.Y(n.image),this.getLexerPosition()))}},{ALT:()=>{let t=this.CONSUME(n);return this.ACTION(()=>this._tag(e.M(t.image,this._locale),this.getLexerPosition()))}},{ALT:()=>{let t=this.CONSUME(r);return this.ACTION(()=>this._tag(e.B(t.image,this._locale),this.getLexerPosition()))}},{ALT:()=>{let t=this.CONSUME(i);return this.ACTION(()=>this._tag(e.q(t.image,this._locale),this.getLexerPosition()))}}])}),this._ruleFunction=this.RULE(`ruleFunction`,()=>{let{FunctionToken:t,OpenParen:n,CloseParen:r}=this._vocab,i=this.CONSUME(t).image,a=this.getLexerPosition();this.CONSUME(n);let o=this.SUBRULE(this._ruleFunctionArguments),s=this.ACTION(()=>this._tag(e.L(i,o),a)),c=this.OPTION(()=>this.CONSUME(r));return s=this.ACTION(()=>(c||this._reportError(s,`Missing closing parenthesis ')'`,a),this._tagClose(s,this.getLexerPosition()))),s}),this._ruleFunctionArguments=this.RULE(`ruleFunctionArguments`,()=>{let{ArgSeparator:t,CloseParen:n}=this._vocab,r=[];return this.OPTION({GATE:()=>this.LA(1).tokenType!==n,DEF:()=>{let n;this.OPTION2(()=>{n=this.SUBRULE(this._ruleIntersectOp)}),n=this.ACTION(()=>n??this._tagClose(e.I(),this.getLexerPosition())),r.push(n),this.MANY(()=>{let n;this.CONSUME(t),this.OPTION3(()=>{n=this.SUBRULE2(this._ruleIntersectOp)}),n=this.ACTION(()=>n??this._tagClose(e.I(),this.getLexerPosition())),r.push(n)})}}),r}),this._ruleBracketedString=this.RULE(`ruleBracketedString`,()=>{let{BracketedString:e}=this._vocab,t=this.CONSUME(e),n=this.getLexerPosition();return this.ACTION(()=>{let e=this._srParser.parse(this.rowIndex,this.colIndex,t.image);for(let t of e.errors)this._astErrors.push(t);return this._tag(e.root,n)})}),this._ruleTableReference=this.RULE(`ruleTableReference`,()=>{let{TableReference:e}=this._vocab,t=this.CONSUME(e),n=this.getLexerPosition();return this.ACTION(()=>{let e=this._srParser.parse(this.rowIndex,this.colIndex,t.image);for(let t of e.errors)this._astErrors.push(t);return this._tag(e.root,n)})}),this._ruleReference=this.RULE(`ruleReference`,()=>{let{Sheet:t,SheetQuoted:n,DivOp:r,MulOp:i,PlusOp:a,MinOp:o,ArgSeparator:s,Cell:c,NamedToken:l,SingleQuotedString:u,Column:d,AbsRow:f,DigitToken:p,RefError:m}=this._vocab,h;this.OPTION2({GATE:()=>{for(let e=1;e<6;e++){let c=this.LA(e);if(c.tokenType===t||c.tokenType===n)return!0;if(c.image===``||c.image===`)`||c.tokenType===r||c.tokenType===i||c.tokenType===a||c.tokenType===o||c.tokenType===s)break}return!1},DEF:()=>{h=this.SUBRULE(this._rulePrefixSheetName)}});let g=this.OR([{ALT:()=>{let t=this.CONSUME(c),n=this.getLexerPosition();return this.ACTION(()=>this._tag(e.P(t.image,this.rowIndex,this.colIndex),n))}},{ALT:()=>{let t=this.OR2([{ALT:()=>this.CONSUME(l)},{ALT:()=>this.CONSUME(u)}]);return this.ACTION(()=>this._tag(e.H(t.image),this.getLexerPosition()))}},{ALT:()=>this.SUBRULE(this._ruleBracketedString)},{ALT:()=>this.SUBRULE(this._ruleFunction)},{ALT:()=>{let t=this.CONSUME(d);return this.ACTION(()=>this._tag(e.F(t.image,this.colIndex),this.getLexerPosition()))}},{ALT:()=>{let t=this.CONSUME(f);return this.ACTION(()=>this._tag(e.J(t.image,this.rowIndex),this.getLexerPosition()))}},{ALT:()=>{let t=this.CONSUME(p);return this.ACTION(()=>this._tag(e.J(t.image,this.rowIndex),this.getLexerPosition()))}},{ALT:()=>{let t=this.CONSUME(m);return this.ACTION(()=>this._tag(e.q(t.image,this._locale),this.getLexerPosition()))}}]);return this.ACTION(()=>{if(h&&g){if(h.name===``)return void this._reportError(g,`'${h.image}' is not a valid sheet reference — a '!' needs a sheet name before it`);let t=g;g.type===e.tt.Postfix&&g.inputs?.[0]&&(t=g.inputs[0]),t.type!==e.tt.Cell&&t.type!==e.tt.Named&&t.type!==e.tt.Row&&t.type!==e.tt.TableColumn&&t.type!==e.tt.Error||(t.value.scope=h.name,t.value.scopeImage=h.image)}}),g}),this._rulePrefixSheetName=this.RULE(`rulePrefixSheetName`,()=>{let{SheetQuoted:e,BracketedString:t,NamedToken:n,RangeOp:r,Sheet:i}=this._vocab;return this.OR([{ALT:()=>{let t=this.CONSUME(e).image;return{name:t.slice(1,-2).replace(/''/g,`'`),image:t}}},{ALT:()=>{let e=``;this.OPTION(()=>{e+=this.CONSUME(t).image}),this.OPTION2({GATE:()=>this.LA(2).tokenType===r,DEF:()=>{e+=this.CONSUME(n).image,this.CONSUME(r),e+=`:`}});let a=this.CONSUME(i).image;return{name:e+a.slice(0,-1),image:e+a}}}])}),this._ruleNumber=this.RULE(`ruleNumber`,()=>{let{NumberToken:e,ScientificDigit:t,DigitToken:n}=this._vocab;return this.OR([{ALT:()=>this.CONSUME(e)},{ALT:()=>this.CONSUME(t)},{ALT:()=>this.CONSUME(n)}])}),this._ruleRoot=this.RULE(`ruleRoot`,()=>{let{ArgSeparator:t}=this._vocab,n=this.SUBRULE(this._ruleIntersectOp),r=[];return this.MANY(()=>{this.CONSUME(t),r.push(this.SUBRULE2(this._ruleIntersectOp))}),this.ACTION(()=>r.length===0?n:{type:e.tt.List,value:`,`,inputs:[n,...r],isReference:!0})}),this._lexer=r,this._locale=r.getLocale(),this._vocab=i,this._srParser=n?.srParser??new o(this._locale),this.performSelfAnalysis()}getLexer(){return this._lexer}parse(t,r,i,a){let o=this._lexer.tokenize(i),f;if(!o)return{root:{type:e.tt.Unparsed,value:i},errors:[]};let p=o.tokens;if(p.length===0)throw new n.FormulaError.Parse(d);return this.input=p,this._inputText=i,this._inputTextLength=i.length,this.rowIndex=t,this.colIndex=r,this._astErrors=[],this._tokenMap=new Map,this.reset(),f=this._ruleRoot(),f&&this._bindAllWhitespace(f),f=e.et(f,(n,r)=>{let i=n.type,a=r?.isReference?r.value:void 0,o=typeof a==`string`&&s.has(a),d=typeof a==`string`&&c.has(a),f=o?r.inputs:void 0,p=f?f[0]===n?f[1]:f[0]:void 0,m=this._lexer.getMaxRow();if(o&&i!==e.tt.Cell&&Number.isInteger(n.value)){let r=e.J(n.image,t);return e.j(r,n),l(p)===`row`?u(n.image,m)||this._reportError(r,`'${n.image}' is not a valid row — rows run from 1 to ${m}`):this._reportError(r,`'${n.image}' is not a valid reference — a whole row can only pair with another row (as in ${n.image}:${n.image})`),r}if(d&&i===e.tt.Named)return this._reportError(n,`'${n.image??n.value?.nameId}' is a name — '${a}' needs a cell or range on both sides`),n;if(i===e.tt.Cell){let t=n.value,r=t.colIndex===-(2**53-1),i=t.rowIndex===-(2**53-1);if((r||i)&&l(p)===(r?`row`:`col`))return r&&!u(n.image,m)&&this._reportError(n,`'${n.image}' is not a valid row — rows run from 1 to ${m}`),n;if(r||i||t.colIndex>=16384){let o=e.H(n.image);e.j(o,n);let s=t.scope;return s&&(o.value.scope=s,o.value.scopeImage=t.scopeImage),r?this._reportError(o,`'${n.image}' is not a valid reference — a row needs a column (use ${n.image}:${n.image} for the whole row)`):i&&n.image.includes(`$`)?this._reportError(o,`'${n.image}' is not a valid reference — a whole column can only pair with another column (as in ${n.image}:${n.image})`):d&&this._reportError(o,`'${n.image}' is a name — '${a}' needs a cell or range on both sides`),o}}return n}),a&&f&&(f=e.g(f,a,null)),{root:f,errors:[...this.errors,...this._astErrors]}}_processParen(e,t,n){let r;this.CONSUME(t);let i=this.getLexerPosition();r=this.ACTION(()=>(r={type:e,value:null,inputs:null},this._tag(r,i)));let a=[],o=this.SUBRULE(this._ruleIntersectOp);o&&a.push(o);let s=this.SUBRULE(this._ruleGroup),c=this.OPTION(()=>this.CONSUME(n));return r=this.ACTION(()=>{if(s)for(let e=0;e<s.length;e++)a.push(s[e]);return r&&(c||this._reportError(r,`Missing closing parenthesis`,i),r.inputs=a),this._tagClose(r,this.getLexerPosition())}),r}_reportError(e,t,n=void 0,r=`SyntaxError`){n===void 0&&(n=this.getLexerPosition()),e.error=!0,this._astErrors.push({name:r,message:t,previousToken:this.input[n],ast:e})}_tag(e,t){return e?(e.image??=this.input[t].image,this._tokenMap.set(e,{tokenIndex:t,tokenIndexClose:t}),e):(console.warn(`node is null`),e)}_tagClose(e,t){let n=this._tokenMap.get(e);return n?n.tokenIndexClose=t:this._tokenMap.set(e,{tokenIndexClose:t}),e}_bindNodeWhitespace(e){let t=this._tokenMap.get(e);if(!t)return;let n=this.input,r=this._inputText,i=t.tokenIndex;if(i!==void 0){let t=n[i],a=n[i-1]?.endOffset??-1;a+1<t.startOffset&&(e.wsBefore=r.slice(a+1,t.startOffset))}let a=t.tokenIndexClose;if(a!==void 0){let t=n[a],i=n[a+1]?.startOffset??this._inputTextLength;t.endOffset+1<i&&(e.wsAfter=r.slice(t.endOffset+1,i))}}_bindAllWhitespace(t){if(t){if(this._bindNodeWhitespace(t),t.inputs)for(let e of t.inputs)e&&this._bindAllWhitespace(e);if(t.type===e.tt.Array&&Array.isArray(t.value)){for(let e of t.value)if(e&&Array.isArray(e.value))for(let t of e.value)t&&this._bindAllWhitespace(t)}}}};exports.FormulaCompiler=class{constructor(e){e={...e},this._editing=e.profile===`editing`,this._parser=new m(e)}compile(t,r,i,a,o,s,c,l){if(a.length===0){let e=new n.FormulaError.Parse(d);return this._compileUnparsed(t,o,a,{input:a,cause:e,causes:[e]})}if(a.length>e.rt.MAX_EXPRESSION_LENGTH){let r=new n.FormulaError.Parse((u=a.length,`A formula must not be longer than ${e.rt.MAX_EXPRESSION_LENGTH} characters (this one is ${u})`));return this._compileUnparsed(t,o,a,{input:a,cause:r,causes:[r]})}var u;let f,p,m=[];try{let e=this._parser.parse(r,i,a,l);f=e.root,m=e.errors}catch(e){p=n.FormulaError.isError(e,n.FormulaError.Code.Parse)?e:new n.FormulaError.Parse(e.message,e)}let h=[];for(let t of m)h.push(e.E(t));if(f){e.w(f,s??null)&&h.push(new n.FormulaError.Parse(`The implicit intersection operator ' ' requires a cell or range on both sides`)),e.C(f,s??null)&&h.push(new n.FormulaError.Parse(`The spill anchor operator '#' requires a cell or range`)),e.T(f,s??null)&&h.push(new n.FormulaError.Parse(`Expected a reference; a value cannot be converted to one.`));let t=e.y(f,s??null);t&&h.push(new n.FormulaError.Parse(t));let r=e.b(f,s??null);r&&h.push(new n.FormulaError.Parse(r));let i=e.x(f,s??null);i&&h.push(new n.FormulaError.Parse(i));let a=e.S(f);a&&h.push(new n.FormulaError.Parse(a))}h.length>0&&!p&&(p=h[0]);let g=null;if(p&&(g={input:a,cause:p,causes:h.length>0?h:[p]}),!f){if(this._editing){let e=this._recoverCompiled(t,r,i,a,o,g,c);if(e)return e}return this._compileUnparsed(t,o,a,g)}f=e.O(f,s??null),f=e._(f,s??null),o&&(f=e.D(f,o,c));let _=e.v(t,o,f,this._editing,g,s??null);return this._editing&&g&&e.k(_.getTokens(),o)!==a?this._recoverCompiled(t,r,i,a,o,g,c)||this._compileUnparsed(t,o,a,g):_}autoCorrect(e){let t;try{let n=this._parser.getLexer().tokenize(e,!1);if(n.errors.length>0)return null;t=n.tokens}catch{return null}let n=[];for(let e of t){let t=e.tokenType?.name;if(t===`OpenParen`)n.push(`)`);else if(t===`OpenCurlyParen`)n.push(`}`);else if((t===`CloseParen`||t===`CloseCurlyParen`)&&n.pop()!==(t===`CloseParen`?`)`:`}`))return null}return n.length===0?null:e+n.reverse().join(``)}_compileUnparsed(t,n,i,a){let o={runtime:t,symbols:n,getFunction:null,ast:null,evaluations:r.CommonUtils.EmptyArray,executions:r.CommonUtils.EmptyArray,bindings:r.CommonUtils.EmptyArray,referencesAbsolute:r.CommonUtils.EmptyArray,referencesExecute:r.CommonUtils.EmptyArray,referencesRelative:r.CommonUtils.EmptyArray,referencesRoot:r.CommonUtils.EmptyArray,referenceIndices:r.CommonUtils.EmptyArray,getTokens:()=>[{type:e.tt.Unparsed,value:i,text:i}],namedIds:r.CommonUtils.EmptyArray,symbolIds:r.CommonUtils.EmptyArray,hasTotals:!1,isReferenceOnly:!1,error:a,transform:()=>o};return o}_recoverCompiled(t,n,r,i,a,o,s){let c,l=i.length;try{let e=this._parser.getLexer().tokenize(i,!1);c=e.tokens,e.errors.length>0&&(l=Math.min(l,e.errors[0].offset))}catch{return null}let u=[];for(let e=c.length-1;e>=0&&u.length<24;e--){let t=(c[e].endOffset??-1)+1;t>0&&t<i.length&&t<=l&&u.push(t)}for(let c of u){let l=i.slice(0,c),u,d;try{u=this._parser.parse(n,r,l).root}catch{continue}if(!u||u.type===e.tt.Unparsed)continue;try{let n=e._(u,null),r=a?e.D(n,a,s):n;d=e.v(t,a,r,!0,o)}catch{continue}if(e.k(d.getTokens(),a)!==l)continue;let f=i.slice(c);if(f.length===0)return d;let p,m={...d,getTokens:()=>(p||(p=[...d.getTokens()],this._appendUnparsedTail(p,f)),p),transform:()=>m};return m}return null}_appendUnparsedTail(t,n){let r=[];for(let n of t)n.type===e.tt.Paren&&n.text===`(`?r.push({ctx:n.context,argIndex:0}):n.type===e.tt.Paren&&n.text===`)`?r.pop():n.type===e.tt.Separator&&r.length>0&&r[r.length-1].argIndex++;let i=r.length>0?r[r.length-1]:void 0,a=i?.ctx?{...i.ctx,argIndex:i.ctx.argIndex===-1?i.argIndex:i.ctx.argIndex}:void 0,o=(n,r)=>{let i={type:e.tt.Unparsed,value:n,text:n};a&&(i.context=a),r&&(i.isLookup=!0),t.push(i)},s=/[A-Za-z_][A-Za-z0-9_]*$/.exec(n),c=s?s.index:-1;c>=0&&(c===0||!/[A-Za-z0-9_.]/.test(n[c-1]))?(c>0&&o(n.slice(0,c)),o(n.slice(c),!0)):o(n)}};