@univerjs-pro/engine-formula 0.22.1 → 0.23.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.
- package/lib/cjs/facade.js +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/es/facade.js +1 -1
- package/lib/es/index.js +1 -1
- package/lib/facade.js +1 -1
- package/lib/index.js +1 -1
- package/lib/types/engine/dependency-engine/cell-codec.d.ts +39 -0
- package/lib/types/engine/dependency-engine/dependency-engine.d.ts +341 -0
- package/lib/types/engine/dependency-engine/formula-cell-index.d.ts +23 -0
- package/lib/types/engine/dependency-engine/helpers.d.ts +32 -0
- package/lib/types/engine/dependency-engine/node-helpers.d.ts +7 -0
- package/lib/types/engine/dependency-engine/point-subscription-index.d.ts +24 -0
- package/lib/types/engine/dependency-engine/range-index.d.ts +66 -0
- package/lib/types/engine/dependency-engine/types.d.ts +220 -0
- package/lib/types/engine/dependency-engine.d.ts +8 -0
- package/lib/types/engine/formula-dependency.d.ts +85 -23
- package/lib/types/engine/shared-formula-group-analyzer.d.ts +45 -0
- package/lib/types/index.d.ts +0 -1
- package/lib/types/plugin.d.ts +0 -2
- package/lib/types/services/calculate-formula.service.d.ts +18 -1
- package/lib/types/services/dependency-manager.service.d.ts +39 -14
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +5 -5
- package/lib/types/engine/lexer-tree-builder.d.ts +0 -25
package/lib/cjs/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const _0x68ee84=_0x16ee;(function(_0x3bcd1d,_0x47334c){const _0x754c21=_0x16ee,_0xd15067=_0x3bcd1d();while(!![]){try{const _0x1f8a55=parseInt(_0x754c21(0x18e))/0x1*(-parseInt(_0x754c21(0x188))/0x2)+parseInt(_0x754c21(0x187))/0x3+parseInt(_0x754c21(0x18b))/0x4+parseInt(_0x754c21(0x183))/0x5*(parseInt(_0x754c21(0x18a))/0x6)+parseInt(_0x754c21(0x185))/0x7+parseInt(_0x754c21(0x18d))/0x8*(parseInt(_0x754c21(0x182))/0x9)+-parseInt(_0x754c21(0x186))/0xa*(parseInt(_0x754c21(0x184))/0xb);if(_0x1f8a55===_0x47334c)break;else _0xd15067['push'](_0xd15067['shift']());}catch(_0x2c8f79){_0xd15067['push'](_0xd15067['shift']());}}}(_0x4819,0xe6073),Object[_0x68ee84(0x189)](exports,Symbol[_0x68ee84(0x18f)],{'value':_0x68ee84(0x181)}));function _0x16ee(_0x3e6bf3,_0x3a2b81){_0x3e6bf3=_0x3e6bf3-0x181;const _0x4819be=_0x4819();let _0x16eebc=_0x4819be[_0x3e6bf3];return _0x16eebc;}let e=require(`@univerjs/engine-formula/facade`);function _0x4819(){const _0x122ba0=['toStringTag','Module','6718077fGwYzl','6498810cXFbVi','3091SeTgas','8285333gowKjE','109030ibAdMu','452700tloiye','230988dCJEtk','defineProperty','6qoUrjs','900932uEzZqc','FFormula','16afOLTM','3nXhxBo'];_0x4819=function(){return _0x122ba0;};return _0x4819();}Object[_0x68ee84(0x189)](exports,_0x68ee84(0x18c),{'enumerable':!0x0,'get':function(){const _0x322c6e=_0x68ee84;return e[_0x322c6e(0x18c)];}});
|
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const _0x49edc8=_0x2e96;(function(_0x1ae20d,_0x5096f9){const _0x4af1e5=_0x2e96,_0x4bdd4d=_0x1ae20d();while(!![]){try{const _0x17fc16=parseInt(_0x4af1e5(0x231))/0x1*(-parseInt(_0x4af1e5(0x150))/0x2)+parseInt(_0x4af1e5(0x1ba))/0x3+parseInt(_0x4af1e5(0x1f9))/0x4*(parseInt(_0x4af1e5(0x23c))/0x5)+-parseInt(_0x4af1e5(0x227))/0x6+-parseInt(_0x4af1e5(0x221))/0x7+-parseInt(_0x4af1e5(0x22e))/0x8*(-parseInt(_0x4af1e5(0x207))/0x9)+parseInt(_0x4af1e5(0x184))/0xa*(parseInt(_0x4af1e5(0x1cd))/0xb);if(_0x17fc16===_0x5096f9)break;else _0x4bdd4d['push'](_0x4bdd4d['shift']());}catch(_0x20c2a3){_0x4bdd4d['push'](_0x4bdd4d['shift']());}}}(_0x5522,0x72b4b),Object[_0x49edc8(0x192)](exports,Symbol[_0x49edc8(0x21f)],{'value':_0x49edc8(0x19c)}));let _univerjs_engine_formula=require('@univerjs/engine-formula'),_univerjs_pro_license=require('@univerjs-pro/license'),_univerjs_core=require('@univerjs/core');function _typeof(_0x28cbc4){'@babel/helpers - typeof';const _0x22d9bf=_0x49edc8;return _typeof='function'==typeof Symbol&&_0x22d9bf(0x1ae)==typeof Symbol[_0x22d9bf(0x1e1)]?function(_0x20b070){return typeof _0x20b070;}:function(_0x1944c3){const _0x3097be=_0x22d9bf;return _0x1944c3&&_0x3097be(0x236)==typeof Symbol&&_0x1944c3[_0x3097be(0x224)]===Symbol&&_0x1944c3!==Symbol[_0x3097be(0x210)]?_0x3097be(0x1ae):typeof _0x1944c3;},_typeof(_0x28cbc4);}function toPrimitive(_0x25ae21,_0x5edaa9){const _0x50a3dc=_0x49edc8;if('object'!=_typeof(_0x25ae21)||!_0x25ae21)return _0x25ae21;var _0x3bcb9b=_0x25ae21[Symbol[_0x50a3dc(0x1ca)]];if(void 0x0!==_0x3bcb9b){var _0x5d10a7=_0x3bcb9b[_0x50a3dc(0x1dc)](_0x25ae21,_0x5edaa9||'default');if(_0x50a3dc(0x155)!=_typeof(_0x5d10a7))return _0x5d10a7;throw new TypeError(_0x50a3dc(0x158));}return(_0x50a3dc(0x202)===_0x5edaa9?String:Number)(_0x25ae21);}function toPropertyKey(_0x4d95b6){const _0x18b75f=_0x49edc8;var _0x32e332=toPrimitive(_0x4d95b6,_0x18b75f(0x202));return _0x18b75f(0x1ae)==_typeof(_0x32e332)?_0x32e332:_0x32e332+'';}function _defineProperty(_0x450137,_0x26270a,_0x1245a6){const _0x48fae9=_0x49edc8;return(_0x26270a=toPropertyKey(_0x26270a))in _0x450137?Object[_0x48fae9(0x192)](_0x450137,_0x26270a,{'value':_0x1245a6,'enumerable':!0x0,'configurable':!0x0,'writable':!0x0}):_0x450137[_0x26270a]=_0x1245a6,_0x450137;}var LexerTreeProBuilder=class extends _univerjs_engine_formula[_0x49edc8(0x1c9)]{constructor(..._0x33a387){const _0x32aeb8=_0x49edc8;super(..._0x33a387),_defineProperty(this,_0x32aeb8(0x140),![]),_defineProperty(this,_0x32aeb8(0x163),new Set()),_defineProperty(this,_0x32aeb8(0x20e),_0x32aeb8(0x1af)),_defineProperty(this,_0x32aeb8(0x182),'_xlfn.'),_defineProperty(this,_0x32aeb8(0x19e),'');}[_0x49edc8(0x23d)](){const _0x272174=_0x49edc8;this['_xlpmPrefix']='_xlpm.',this[_0x272174(0x182)]='_xlfn.';}[_0x49edc8(0x1c3)](){const _0xe7b9f9=_0x49edc8;this['_xlpmPrefix']='',this[_0xe7b9f9(0x182)]='';}[_0x49edc8(0x228)](_0x4f28b8,_0x2561e2){const _0x281112=_0x49edc8,_0x9409e4=this[_0x281112(0x13b)](_0x4f28b8,![]);if(!_0x9409e4||_0x9409e4===_univerjs_engine_formula['ErrorType'][_0x281112(0x13f)]||Array['isArray'](_0x9409e4))return null;const _0x217b3a=[];this[_0x281112(0x140)]=![],this[_0x281112(0x203)](_0x9409e4,_0x217b3a,_0x2561e2);if(this['_hasNewExcelFunction'])return'='+_0x217b3a[_0x281112(0x1dd)]('');return null;}['_generateNewFunctionString'](_0x542d94,_0xb751f1,_0x4a084c){const _0x31ac4c=_0x49edc8,_0x452fb0=_0x542d94[_0x31ac4c(0x1eb)](),_0x57ae85=_0x452fb0[_0x31ac4c(0x173)](),_0x162849=_0x57ae85[_0x31ac4c(0x1ea)](),_0x295546=this[_0x31ac4c(0x1d3)](_0x162849),_0x20f36b=_0x4a084c(_0x295546);let _0x13609b=0x0;if(_0x452fb0===_univerjs_engine_formula[_0x31ac4c(0x235)])_0x13609b=0x3;else{if(_0x452fb0===_univerjs_engine_formula[_0x31ac4c(0x13c)])_0x13609b=0x4;else{if(_0x452fb0===_univerjs_engine_formula[_0x31ac4c(0x191)])_0x13609b=0x5;else{if(_univerjs_engine_formula['NEW_EXCEL_FUNCTIONS']['has'](_0x295546))_0xb751f1[_0x31ac4c(0x193)](''+this[_0x31ac4c(0x182)]+_0x57ae85),this[_0x31ac4c(0x140)]=!![];else{if(_0x162849===_univerjs_engine_formula[_0x31ac4c(0x16a)])_0xb751f1['push'](''+this['_xlfnPrefix']+_0x57ae85),this[_0x31ac4c(0x140)]=!![],_0x13609b=0x2;else{if(_0x162849===_univerjs_engine_formula[_0x31ac4c(0x200)])_0xb751f1[_0x31ac4c(0x193)](''+this[_0x31ac4c(0x182)]+_0x57ae85),this[_0x31ac4c(0x140)]=!![],_0x13609b=0x1;else{if(_0x162849===_univerjs_engine_formula[_0x31ac4c(0x16e)]['COLON'])_0x13609b=0x8;else{if(_univerjs_engine_formula[_0x31ac4c(0x1d9)][_0x31ac4c(0x23e)](_0x162849))_0x13609b=0x7;else{if(_0x162849===_univerjs_engine_formula[_0x31ac4c(0x1fb)][_0x31ac4c(0x1e9)]){if(this[_0x31ac4c(0x1f0)](_0x542d94))_0x13609b=0x9;_0xb751f1[_0x31ac4c(0x193)](_0x452fb0);}else _0xb751f1[_0x31ac4c(0x193)](_0x452fb0),_0x13609b=0xa;}}}}}}}}if(_0x20f36b){if(_0x13609b!==0x2&&_0x13609b!==0x1)_0x13609b=0x6;_0xb751f1[_0x31ac4c(0x193)]('(');}else{if(_0x13609b===0x9)_0xb751f1[_0x31ac4c(0x193)]('(');}const _0x39922d=_0x542d94['getChildren'](),_0x376916=_0x39922d[_0x31ac4c(0x172)];if(_0x13609b===0x2){const _0x5a52fe=_0x39922d[0x0];let _0x624fa8=0x0;if(_0x5a52fe instanceof _univerjs_engine_formula[_0x31ac4c(0x177)]){if(_0x5a52fe['getToken']()===_univerjs_engine_formula[_0x31ac4c(0x191)])_0x624fa8=0x1;}for(let _0x3873e2=_0x624fa8;_0x3873e2<_0x376916-0x1;_0x3873e2++){const _0x364a16=_0x39922d[_0x3873e2];if(_0x364a16 instanceof _univerjs_engine_formula[_0x31ac4c(0x177)]){const _0x3df55c=_0x364a16[_0x31ac4c(0x214)]()[0x0];if(typeof _0x3df55c===_0x31ac4c(0x202)){if(this[_0x31ac4c(0x163)][_0x31ac4c(0x23e)](_0x3df55c))console[_0x31ac4c(0x18d)]('Lambda\x20parameter\x20name\x20\x22'+_0x3df55c+_0x31ac4c(0x1c1));this[_0x31ac4c(0x163)][_0x31ac4c(0x1f2)](_0x3df55c),_0xb751f1[_0x31ac4c(0x193)](''+this[_0x31ac4c(0x20e)]+_0x3df55c),this[_0x31ac4c(0x140)]=!![];}}_0xb751f1[_0x31ac4c(0x193)](',');}this[_0x31ac4c(0x1f6)](_0x39922d[_0x376916-0x1],_0xb751f1,_0x4a084c);if(_0x624fa8===0x1)_0xb751f1['push'](')'),_0xb751f1[_0x31ac4c(0x193)]('('),this['_generateNewFunctionString'](_0x5a52fe,_0xb751f1,_0x4a084c),_0xb751f1[_0x31ac4c(0x193)](')');else _0xb751f1[_0x31ac4c(0x193)](')');return;}else{if(_0x13609b===0x1){for(let _0x24140f=0x0;_0x24140f<_0x376916-0x1;_0x24140f++){const _0x2ca573=_0x39922d[_0x24140f];if(_0x2ca573 instanceof _univerjs_engine_formula[_0x31ac4c(0x177)]&&_0x24140f%0x2===0x0){const _0x5d371c=_0x2ca573[_0x31ac4c(0x214)]()[0x0];if(typeof _0x5d371c===_0x31ac4c(0x202)){if(this['_lambdaFunctionParameterSet'][_0x31ac4c(0x23e)](_0x5d371c))console['error'](_0x31ac4c(0x14a)+_0x5d371c+_0x31ac4c(0x1c1));this[_0x31ac4c(0x163)][_0x31ac4c(0x1f2)](_0x5d371c),_0xb751f1[_0x31ac4c(0x193)](''+this[_0x31ac4c(0x20e)]+_0x5d371c),this['_hasNewExcelFunction']=!![],_0xb751f1[_0x31ac4c(0x193)](',');continue;}}this[_0x31ac4c(0x1f6)](_0x2ca573,_0xb751f1,_0x4a084c);if(_0x2ca573 instanceof _univerjs_engine_formula['LexerNode']){const _0x2577b2=_0x39922d[_0x24140f+0x1];if(_0x2577b2&&_0x2577b2 instanceof _univerjs_engine_formula[_0x31ac4c(0x177)])_0xb751f1[_0x31ac4c(0x193)](',');}}this[_0x31ac4c(0x1f6)](_0x39922d[_0x376916-0x1],_0xb751f1,_0x4a084c),_0xb751f1[_0x31ac4c(0x193)](')');return;}else{if(_0x13609b===0x8){const _0x3a5c3e=_0x39922d[0x0],_0x372bc3=_0x39922d[0x1];this[_0x31ac4c(0x1f6)](_0x3a5c3e,_0xb751f1,_0x4a084c),_0xb751f1[_0x31ac4c(0x193)](_0x452fb0),this[_0x31ac4c(0x1f6)](_0x372bc3,_0xb751f1,_0x4a084c);return;}}}for(let _0x154962=0x0;_0x154962<_0x376916;_0x154962++){const _0x18d394=_0x39922d[_0x154962];this[_0x31ac4c(0x1f6)](_0x18d394,_0xb751f1,_0x4a084c);if(_0x18d394 instanceof _univerjs_engine_formula[_0x31ac4c(0x177)]){const _0x6ba97f=_0x39922d[_0x154962+0x1];if(_0x6ba97f&&_0x6ba97f instanceof _univerjs_engine_formula[_0x31ac4c(0x177)])_0xb751f1[_0x31ac4c(0x193)](',');}}if(_0x13609b===0x7)_0xb751f1[_0x31ac4c(0x193)](_0x452fb0);if(_0x20f36b)_0xb751f1[_0x31ac4c(0x193)](')');else{if(_0x13609b===0x9)_0xb751f1[_0x31ac4c(0x193)](')');}}[_0x49edc8(0x1f6)](_0x456870,_0x3c5874,_0x19a3a1){const _0x57770c=_0x49edc8;if(_0x456870 instanceof _univerjs_engine_formula['LexerNode'])this[_0x57770c(0x203)](_0x456870,_0x3c5874,_0x19a3a1);else{if(this[_0x57770c(0x163)]['has'](_0x456870))_0x3c5874[_0x57770c(0x193)](''+this['_xlpmPrefix']+_0x456870),this['_hasNewExcelFunction']=!![];else _0x3c5874[_0x57770c(0x193)](_0x456870);}}[_0x49edc8(0x1d3)](_0x487895){const _0x527283=_0x49edc8;let _0x585748=_0x487895[_0x527283(0x173)]();if(!_0x585748)return _0x585748;const _0x15b1a3=_0x585748[0x0];if(_0x15b1a3===_univerjs_engine_formula[_0x527283(0x1fb)]['AT']||_0x15b1a3===_univerjs_engine_formula['prefixToken'][_0x527283(0x1e9)]||_0x15b1a3===_univerjs_engine_formula[_0x527283(0x1fb)][_0x527283(0x16b)])_0x585748=_0x585748[_0x527283(0x170)](0x1);if(!_0x585748)return _0x585748;const _0xd9fbd0=_0x585748[_0x585748[_0x527283(0x172)]-0x1];if(_univerjs_engine_formula[_0x527283(0x1d9)][_0x527283(0x23e)](_0xd9fbd0))_0x585748=_0x585748[_0x527283(0x170)](0x0,-0x1);return _0x585748;}[_0x49edc8(0x1f0)](_0x3bbf08){const _0x43eaef=_0x49edc8,_0x33c872=_0x3bbf08['getChildren']()[0x0];if(!_0x33c872||!(_0x33c872 instanceof _univerjs_engine_formula[_0x43eaef(0x177)])||_0x3bbf08[_0x43eaef(0x214)]()[_0x43eaef(0x172)]>0x1)return![];const _0x785a46=_0x33c872[_0x43eaef(0x214)](),_0x5e8a20=_0x785a46[_0x43eaef(0x172)];if(_0x5e8a20===0x1)return![];for(let _0x295219=0x0;_0x295219<_0x5e8a20;_0x295219++){const _0x4ddb1f=_0x785a46[_0x295219];if(!(_0x4ddb1f instanceof _univerjs_engine_formula['LexerNode'])&&_univerjs_engine_formula[_0x43eaef(0x223)][_0x43eaef(0x23e)](_0x4ddb1f))return!![];}return![];}[_0x49edc8(0x179)](_0x57f9dc,_0x785c8e,_0x123c33,_0x2addf1,_0x3c8d7a){const _0xeb8e7e=_0x49edc8,_0x2455fa=this[_0xeb8e7e(0x13b)](_0x57f9dc,![]);if(!_0x2455fa||_0x2455fa===_univerjs_engine_formula[_0xeb8e7e(0x208)][_0xeb8e7e(0x13f)]||Array['isArray'](_0x2455fa))return null;this[_0xeb8e7e(0x1c3)](),this[_0xeb8e7e(0x19e)]=_0x785c8e;const _0x4c8698=this[_0xeb8e7e(0x151)](_0x2455fa,_0x123c33,_0x2addf1,_0x3c8d7a);return this[_0xeb8e7e(0x19e)]='',this[_0xeb8e7e(0x23d)](),_0x4c8698;}[_0x49edc8(0x151)](_0x17adce,_0xd3e803,_0xc47a9c,_0xbb6464){const _0x254d66=_0x49edc8,_0x26e3fd={'value':'','children':[],'startIndex':0x0};let _0x5d0ff3=_0x17adce;if(_0x5d0ff3 instanceof _univerjs_engine_formula[_0x254d66(0x177)]&&(_0x5d0ff3['getToken']()===_univerjs_engine_formula[_0x254d66(0x235)]||_0x5d0ff3[_0x254d66(0x1eb)]()===_univerjs_engine_formula['DEFAULT_TOKEN_TYPE_PARAMETER'])&&_0x5d0ff3[_0x254d66(0x214)]()['length']===0x1)_0x5d0ff3=_0x5d0ff3[_0x254d66(0x214)]()[0x0];if(!(_0x5d0ff3 instanceof _univerjs_engine_formula[_0x254d66(0x177)]))return this[_0x254d66(0x15d)](_0x5d0ff3,_0xc47a9c,_0xbb6464);const _0x1b2de8=_0x5d0ff3[_0x254d66(0x214)](),_0xd717bd=_0x1b2de8[_0x254d66(0x172)],_0x5c8007=[];this['_generateNewFunctionString'](_0x5d0ff3,_0x5c8007,_0xd3e803),_0x26e3fd[_0x254d66(0x17a)]=_0x5c8007['join'](''),_0x26e3fd[_0x254d66(0x17b)]=_0x5d0ff3[_0x254d66(0x142)]();const _0x21711b=this[_0x254d66(0x135)](_0x5d0ff3);if(_0x21711b===0x2){const _0x37b8c2=_0x1b2de8[0x0];if(_0x37b8c2 instanceof _univerjs_engine_formula[_0x254d66(0x177)]){if(_0x37b8c2[_0x254d66(0x1eb)]()[_0x254d66(0x173)]()!==_univerjs_engine_formula[_0x254d66(0x191)])return _0x26e3fd;this[_0x254d66(0x1a2)](_0x37b8c2,_0x26e3fd,_0xd3e803,_0xc47a9c,_0xbb6464);}return _0x26e3fd;}else{if(_0x21711b===0x1){for(let _0x565124=0x0;_0x565124<_0xd717bd-0x1;_0x565124++){const _0x32bfe3=_0x1b2de8[_0x565124];if(_0x32bfe3 instanceof _univerjs_engine_formula['LexerNode']&&_0x565124%0x2===0x1){const _0xa0a77f=_0x32bfe3[_0x254d66(0x214)]();if(_0xa0a77f[_0x254d66(0x172)]===0x1&&!(_0xa0a77f[0x0]instanceof _univerjs_engine_formula[_0x254d66(0x177)]))continue;const _0x135b84=this[_0x254d66(0x151)](_0x32bfe3,_0xd3e803,_0xc47a9c,_0xbb6464);_0x135b84&&_0x26e3fd['children'][_0x254d66(0x193)](_0x135b84);}}return _0x26e3fd;}else{if(_0x21711b===0x8){const _0x35bcbd=_0x1b2de8[0x0];if(_0x35bcbd instanceof _univerjs_engine_formula['LexerNode']){const _0x86861b=_0x35bcbd[_0x254d66(0x214)]()[0x0];if(_0x86861b instanceof _univerjs_engine_formula[_0x254d66(0x177)])_0x26e3fd[_0x254d66(0x17b)]=_0x86861b[_0x254d66(0x142)]();}if(this[_0x254d66(0x156)](_0x5d0ff3))return _0x26e3fd;}else{if(_0x21711b===0x7){const _0x5f40ea=_0x1b2de8[0x0];if(_0x5f40ea instanceof _univerjs_engine_formula['LexerNode']){const _0x4da342=_0x5f40ea['getChildren']()[0x0];if(_0x4da342 instanceof _univerjs_engine_formula[_0x254d66(0x177)])_0x26e3fd[_0x254d66(0x17b)]=_0x4da342['getStartIndex']();}}}}}return this[_0x254d66(0x1d7)](_0x1b2de8,_0x21711b,_0x26e3fd,_0xd3e803,_0xc47a9c,_0xbb6464),_0x26e3fd;}[_0x49edc8(0x1d7)](_0x29f8ae,_0x4a7fdc,_0x52cc24,_0x376b02,_0x5b4710,_0x529048){const _0x239ad7=_0x49edc8;for(let _0x4f026e=0x0;_0x4f026e<_0x29f8ae[_0x239ad7(0x172)];_0x4f026e++){let _0x431565=_0x29f8ae[_0x4f026e];if(!(_0x431565 instanceof _univerjs_engine_formula[_0x239ad7(0x177)])){const _0x496e21=this['_handleTextNodeForExprTree'](_0x431565,_0x5b4710,_0x529048);_0x496e21&&_0x52cc24[_0x239ad7(0x1a8)][_0x239ad7(0x193)](_0x496e21);continue;}const _0x4c524e=_0x431565[_0x239ad7(0x214)]();if(_0x4c524e[_0x239ad7(0x172)]===0x1&&!(_0x4c524e[0x0]instanceof _univerjs_engine_formula[_0x239ad7(0x177)])){const _0x563f51=_0x4c524e[0x0];if(!_0x5b4710(this['_currentUnitId'],_0x563f51)&&!this[_0x239ad7(0x1de)](_0x563f51,_0x529048)&&!(0x0,_univerjs_engine_formula[_0x239ad7(0x1b9)])(_0x563f51))continue;}if(_0x4a7fdc===0x8){const _0x59977e=_0x4c524e[0x0];if(_0x59977e instanceof _univerjs_engine_formula['LexerNode']){if((0x0,_univerjs_engine_formula['isReferenceString'])(_0x59977e[_0x239ad7(0x1eb)]()[_0x239ad7(0x173)]()))continue;_0x431565=_0x59977e;}}const _0x5cb441=this[_0x239ad7(0x151)](_0x431565,_0x376b02,_0x5b4710,_0x529048);_0x5cb441&&_0x52cc24[_0x239ad7(0x1a8)][_0x239ad7(0x193)](_0x5cb441);}}[_0x49edc8(0x156)](_0x38fd8e){const _0xffd7af=_0x49edc8,_0x5714aa=_0x38fd8e[_0xffd7af(0x214)]();if(_0x5714aa[_0xffd7af(0x172)]<0x2)return![];const _0x1ff8b3=_0x5714aa[0x0],_0x25ee42=_0x5714aa[0x1];if(!(_0x1ff8b3 instanceof _univerjs_engine_formula[_0xffd7af(0x177)])||!(_0x25ee42 instanceof _univerjs_engine_formula[_0xffd7af(0x177)]))return![];const _0x53d1a4=_0x1ff8b3[_0xffd7af(0x214)]()[0x0],_0x5e00b0=_0x25ee42[_0xffd7af(0x214)]()[0x0];if(!(_0x53d1a4 instanceof _univerjs_engine_formula[_0xffd7af(0x177)])||!(_0x5e00b0 instanceof _univerjs_engine_formula['LexerNode']))return![];const _0x581376=_0x53d1a4[_0xffd7af(0x1eb)]()[_0xffd7af(0x173)](),_0x38647e=_0x5e00b0[_0xffd7af(0x1eb)]()[_0xffd7af(0x173)]();if((0x0,_univerjs_engine_formula[_0xffd7af(0x1b9)])(''+_0x581376+_univerjs_engine_formula[_0xffd7af(0x16e)][_0xffd7af(0x1d4)]+_0x38647e))return!![];return![];}[_0x49edc8(0x15d)](_0x49128a,_0x236c97,_0x51343d){const _0x8ffe69=_0x49edc8,_0x17189f=_0x49128a[_0x8ffe69(0x173)]();if(_0x17189f[_0x8ffe69(0x234)]('{')&&_0x17189f['endsWith']('}')||_0x236c97(this['_currentUnitId'],_0x17189f)||this[_0x8ffe69(0x1de)](_0x17189f,_0x51343d)||(0x0,_univerjs_engine_formula[_0x8ffe69(0x1b9)])(_0x17189f))return{'value':_0x17189f,'children':[],'startIndex':-0x1};return null;}[_0x49edc8(0x1de)](_0x30184f,_0x4148f3){const _0x2b510d=_0x49edc8,{tableName:_0x9cd4e7}=(0x0,_univerjs_engine_formula[_0x2b510d(0x1ad)])(_0x30184f);if(_0x4148f3(this[_0x2b510d(0x19e)],_0x9cd4e7))return _0x9cd4e7;return null;}[_0x49edc8(0x1a2)](_0x34679b,_0x1900f8,_0x28767e,_0x465122,_0x16dbac){const _0x2b78cd=_0x49edc8,_0x29d6e3=_0x34679b['getChildren']();for(let _0xcd5e15=0x0;_0xcd5e15<_0x29d6e3[_0x2b78cd(0x172)];_0xcd5e15++){const _0x36a8b1=_0x29d6e3[_0xcd5e15];if(!(_0x36a8b1 instanceof _univerjs_engine_formula[_0x2b78cd(0x177)]))continue;const _0x4e2924=_0x36a8b1['getChildren']();if(_0x4e2924[_0x2b78cd(0x172)]===0x1&&!(_0x4e2924[0x0]instanceof _univerjs_engine_formula[_0x2b78cd(0x177)]))continue;const _0x381973=this[_0x2b78cd(0x151)](_0x36a8b1,_0x28767e,_0x465122,_0x16dbac);_0x381973&&_0x1900f8[_0x2b78cd(0x1a8)][_0x2b78cd(0x193)](_0x381973);}}[_0x49edc8(0x135)](_0x2cb0c6){const _0x37749e=_0x49edc8,_0x1bb6d6=_0x2cb0c6['getToken'](),_0x56d25b=_0x1bb6d6['trim']()['toUpperCase']();let _0x3d9366=0x0;if(_0x1bb6d6===_univerjs_engine_formula['DEFAULT_TOKEN_TYPE_ROOT'])_0x3d9366=0x3;else{if(_0x1bb6d6===_univerjs_engine_formula['DEFAULT_TOKEN_TYPE_PARAMETER'])_0x3d9366=0x4;else{if(_0x1bb6d6===_univerjs_engine_formula['DEFAULT_TOKEN_TYPE_LAMBDA_PARAMETER'])_0x3d9366=0x5;else{if(_0x56d25b===_univerjs_engine_formula[_0x37749e(0x16a)])_0x3d9366=0x2;else{if(_0x56d25b===_univerjs_engine_formula[_0x37749e(0x200)])_0x3d9366=0x1;else{if(_0x56d25b===_univerjs_engine_formula['matchToken'][_0x37749e(0x1d4)])_0x3d9366=0x8;else{if(_univerjs_engine_formula[_0x37749e(0x1d9)][_0x37749e(0x23e)](_0x56d25b))_0x3d9366=0x7;else{if(_0x56d25b===_univerjs_engine_formula[_0x37749e(0x1fb)]['MINUS']){if(this[_0x37749e(0x1f0)](_0x2cb0c6))_0x3d9366=0x9;}else _0x3d9366=0xa;}}}}}}}return _0x3d9366;}},name=_0x49edc8(0x1d2),version=_0x49edc8(0x17e),FormulaDependencyProGenerator=class extends _univerjs_engine_formula[_0x49edc8(0x186)]{constructor(..._0xdddecf){const _0x6aa44c=_0x49edc8;super(..._0xdddecf),_defineProperty(this,_0x6aa44c(0x148),new Map());}[_0x49edc8(0x211)](){const _0x37bc31=_0x49edc8;super[_0x37bc31(0x211)](),this[_0x37bc31(0x148)][_0x37bc31(0x1da)]();}async[_0x49edc8(0x138)](_0x5ef732=![]){const _0x2f0ceb=_0x49edc8;this[_0x2f0ceb(0x141)]();const _0x3e30bd=this[_0x2f0ceb(0x152)][_0x2f0ceb(0x1c2)](),_0x3ad9f7=this[_0x2f0ceb(0x1bd)]['getOtherFormulaData'](),_0x469ddb=this[_0x2f0ceb(0x152)][_0x2f0ceb(0x180)]();if(_0x469ddb!=null)Object[_0x2f0ceb(0x21a)](_0x469ddb)[_0x2f0ceb(0x1fe)](_0x4a54ad=>{const _0x3a989f=_0x2f0ceb;if(_0x4a54ad==null)return;Object[_0x3a989f(0x21a)](_0x469ddb[_0x4a54ad])['forEach'](_0x238311=>{const _0x317140=_0x3a989f;if(_0x238311==null)return;this['_dependencyManagerService'][_0x317140(0x1d6)](_0x4a54ad,_0x238311),this[_0x317140(0x1e3)][_0x317140(0x23f)](_0x4a54ad,_0x238311),this[_0x317140(0x1e3)][_0x317140(0x22f)](_0x4a54ad,_0x238311);});});const _0xefe5c4=this['_currentConfigService']['getUnitData']();await this[_0x2f0ceb(0x1c4)](_0x3e30bd,_0x3ad9f7,_0xefe5c4),this[_0x2f0ceb(0x1e3)]['openKdTree']();const _0x1bcd60=this[_0x2f0ceb(0x1b2)](),_0x2ed465=this[_0x2f0ceb(0x1a7)](_0x1bcd60);if(this['_checkIsCycleDependency'](_0x2ed465))this[_0x2f0ceb(0x1e0)][_0x2f0ceb(0x1e4)]();if(_0x5ef732)this[_0x2f0ceb(0x1e0)][_0x2f0ceb(0x22a)](this[_0x2f0ceb(0x197)](Array[_0x2f0ceb(0x1b5)](this[_0x2f0ceb(0x148)][_0x2f0ceb(0x17f)]())));return this[_0x2f0ceb(0x148)]['clear'](),this[_0x2f0ceb(0x13d)][_0x2f0ceb(0x1da)](),this[_0x2f0ceb(0x1e3)][_0x2f0ceb(0x1f3)](),this['_runtimeService'][_0x2f0ceb(0x15a)](),Promise['resolve'](_0x2ed465);}[_0x49edc8(0x1a9)](_0x29f1f4,_0x10ea98){const _0x539768=_0x49edc8,_0x4fcc76=0x0,_0x590023=0x1,_0x161356=0x2,_0x3ef82a=[_0x29f1f4];while(_0x3ef82a[_0x539768(0x172)]>0x0){const _0x37ce7c=_0x3ef82a[_0x3ef82a[_0x539768(0x172)]-0x1];if((_0x10ea98[_0x539768(0x222)](_0x37ce7c)||_0x4fcc76)===_0x4fcc76){_0x10ea98[_0x539768(0x18a)](_0x37ce7c,_0x590023);const _0x417bf0=this[_0x539768(0x148)]['get'](_0x37ce7c);if(_0x417bf0==null){_0x10ea98[_0x539768(0x18a)](_0x37ce7c,_0x161356),_0x3ef82a[_0x539768(0x213)]();continue;}const _0x349ad3=this['_dependencyManagerService'][_0x539768(0x1cb)](_0x417bf0[_0x539768(0x237)]());for(const _0x97b8dc of _0x349ad3){const _0xe13b8=_0x10ea98[_0x539768(0x222)](_0x97b8dc)||_0x4fcc76;if(_0xe13b8===_0x590023)return!![];else{if(_0xe13b8===_0x4fcc76)_0x3ef82a[_0x539768(0x193)](_0x97b8dc);}}}else _0x10ea98['set'](_0x37ce7c,_0x161356),_0x3ef82a[_0x539768(0x213)]();}return![];}[_0x49edc8(0x196)](_0x19132d){const _0x24e7a7=_0x49edc8,_0x2063ce=new Map();for(const _0x461cfe of _0x19132d)if(!_0x2063ce['has'](_0x461cfe[_0x24e7a7(0x1be)])){if(this[_0x24e7a7(0x1a9)](_0x461cfe[_0x24e7a7(0x1be)],_0x2063ce))return!![];}return _0x2063ce['clear'](),![];}[_0x49edc8(0x1b1)](_0x2ea39e,_0x3cd949,_0x368887){const _0x90b593=_0x49edc8,{unitId:_0x3bbf16,subUnitId:_0x7dc162,dependencyRanges:_0x46a1e9,getDirtyData:_0x2f5378}=_0x368887,_0x5993e9=new _univerjs_engine_formula[(_0x90b593(0x15e))](_0x3cd949||(0x0,_univerjs_engine_formula[_0x90b593(0x14f)])(this[_0x90b593(0x1e3)]));_0x5993e9['unitId']=_0x3bbf16,_0x5993e9['subUnitId']=_0x7dc162,_0x5993e9[_0x90b593(0x201)]=_0x46a1e9,_0x5993e9['getDirtyData']=_0x2f5378;const _0x3112e3=_0x2f5378(this['_currentConfigService']['getDirtyData'](),this[_0x90b593(0x1e0)][_0x90b593(0x1fa)]());_0x5993e9[_0x90b593(0x1a0)]=this[_0x90b593(0x1ee)](_0x3112e3['dirtyRanges']),_0x5993e9[_0x90b593(0x136)]=_0x2ea39e,_0x5993e9[_0x90b593(0x1ef)]=_univerjs_engine_formula[_0x90b593(0x188)][_0x90b593(0x1f8)],this[_0x90b593(0x1e3)][_0x90b593(0x146)](_0x3bbf16,_0x7dc162,_0x2ea39e,_0x5993e9),this[_0x90b593(0x148)][_0x90b593(0x18a)](_0x5993e9[_0x90b593(0x1be)],_0x5993e9);if(this[_0x90b593(0x1e3)][_0x90b593(0x230)](_0x368887['unitId'],_0x368887[_0x90b593(0x1e5)],_0x2ea39e))_0x5993e9['isCache']=!![];return _0x5993e9;}[_0x49edc8(0x16c)](_0x10ed9f,_0x48aa37,_0x1e226e){const _0x4371ec=_0x49edc8;for(const _0x5044c6 of _0x48aa37){const _0xa4a0b1=_0x10ed9f[_0x5044c6];if(_0xa4a0b1==null)continue;const _0x5e7de8=Object[_0x4371ec(0x21a)](_0xa4a0b1);for(const _0x12745b of _0x5e7de8){const _0x379368=_0xa4a0b1[_0x12745b];if(_0x379368==null)continue;const {rowCount:rowCount=Infinity,columnCount:columnCount=Infinity}=this['_currentConfigService']['getSheetRowColumnCount'](_0x5044c6,_0x12745b)||{},_0x37695f=Object[_0x4371ec(0x21a)](_0x379368);for(const _0x295b7d of _0x37695f){var _0x347c0e;const _0x5c4812=this[_0x4371ec(0x1e3)]['hasOtherFormulaDataMainData'](_0x295b7d),{f:_0x4cf722,ranges:_0x4378cc}=_0x379368[_0x295b7d];let _0x55dbea=![];if(_0x5c4812)_0x55dbea=!![];const {firstRow:_0x2539a5,firstColumn:_0x4714f9}=this[_0x4371ec(0x16d)](_0x4378cc),_0x1a261=this[_0x4371ec(0x1e3)][_0x4371ec(0x21d)](_0x5044c6,_0x12745b,_0x295b7d),_0x1b158a=new _univerjs_engine_formula[(_0x4371ec(0x15e))]((_0x347c0e=_0x1a261===null||_0x1a261===void 0x0?void 0x0:_0x1a261[_0x4371ec(0x209)](0x0,0x0))!==null&&_0x347c0e!==void 0x0?_0x347c0e:(0x0,_univerjs_engine_formula[_0x4371ec(0x14f)])(this['_dependencyManagerService']));for(let _0x223d0c=0x0;_0x223d0c<_0x4378cc[_0x4371ec(0x172)];_0x223d0c++){const _0x32f48c=_0x4378cc[_0x223d0c],{startRow:_0x4bad45,startColumn:_0x3d3e77}=_0x32f48c;let {endRow:_0x12f7fd,endColumn:_0x199dad}=_0x32f48c;_0x12f7fd=Math['min'](_0x12f7fd,rowCount-0x1),_0x199dad=Math[_0x4371ec(0x20c)](_0x199dad,columnCount-0x1);for(let _0x2ea7e5=_0x4bad45;_0x2ea7e5<=_0x12f7fd;_0x2ea7e5++)for(let _0x5a3288=_0x3d3e77;_0x5a3288<=_0x199dad;_0x5a3288++){const _0x328ef6=_0x5a3288-_0x4714f9,_0x2b4111=_0x2ea7e5-_0x2539a5;if(_0x328ef6===0x0&&_0x2b4111===0x0){_0x1b158a['formula']=_0x4cf722,_0x1b158a['unitId']=_0x5044c6,_0x1b158a['subUnitId']=_0x12745b,_0x1b158a[_0x4371ec(0x20a)]=_0x295b7d,_0x1b158a['type']=_univerjs_engine_formula[_0x4371ec(0x188)][_0x4371ec(0x1f1)],_0x1b158a[_0x4371ec(0x1c7)]=_0x55dbea,_0x1e226e[_0x4371ec(0x193)](_0x1b158a),this[_0x4371ec(0x148)][_0x4371ec(0x18a)](_0x1b158a[_0x4371ec(0x1be)],_0x1b158a),this[_0x4371ec(0x1e3)][_0x4371ec(0x164)](_0x5044c6,_0x12745b,_0x295b7d,_0x1b158a),this[_0x4371ec(0x1e3)][_0x4371ec(0x16f)](_0x1b158a);continue;}const _0x4a12c7=new _univerjs_engine_formula['FormulaDependencyTreeVirtual']();_0x4a12c7[_0x4371ec(0x1be)]=(_0x1a261===null||_0x1a261===void 0x0?void 0x0:_0x1a261[_0x4371ec(0x209)](_0x328ef6,_0x2b4111))||(0x0,_univerjs_engine_formula[_0x4371ec(0x14f)])(this['_dependencyManagerService']),_0x4a12c7[_0x4371ec(0x143)]=_0x1b158a,_0x4a12c7[_0x4371ec(0x18e)]=_0x328ef6,_0x4a12c7['refOffsetY']=_0x2b4111,_0x4a12c7[_0x4371ec(0x1c7)]=_0x55dbea,_0x4a12c7[_0x4371ec(0x1ef)]=_univerjs_engine_formula['FormulaDependencyTreeType']['OTHER_FORMULA'],this['_dependencyManagerService']['addOtherFormulaDependency'](_0x5044c6,_0x12745b,_0x295b7d,_0x4a12c7),this[_0x4371ec(0x1e3)][_0x4371ec(0x16f)](_0x4a12c7),_0x1e226e[_0x4371ec(0x193)](_0x4a12c7),this[_0x4371ec(0x148)][_0x4371ec(0x18a)](_0x4a12c7[_0x4371ec(0x1be)],_0x4a12c7);}}this[_0x4371ec(0x1e3)][_0x4371ec(0x1ce)](_0x295b7d);}}}}['_registerFormulas'](_0x188f2d,_0x4cc12b,_0x8d3145,_0x4f9bc9){const _0x417db0=_0x49edc8;for(const _0x2c1892 of _0x188f2d){const _0x598cc8=_0x4cc12b[_0x2c1892];if(_0x598cc8==null)continue;const _0xe59173=Object['keys'](_0x598cc8);for(const _0x4e258a of _0xe59173){const _0x3888d0=new _univerjs_core[(_0x417db0(0x238))](_0x598cc8[_0x4e258a]||{}),_0x27b363=new Map();_0x3888d0[_0x417db0(0x14d)]((_0x35e274,_0x50b564,_0x1ceec3)=>{const _0x490422=_0x417db0;if(_0x1ceec3==null)return!![];const {x:x=0x0,y:y=0x0,si:_0x3dd86c}=_0x1ceec3;if(!(x===0x0&&y===0x0&&_0x3dd86c!=null))return!![];const _0x2c4089=this[_0x490422(0x1c5)](_0x2c1892,_0x4e258a,_0x35e274,_0x50b564,_0x8d3145,_0x1ceec3),_0xc2a78a=this['_dependencyManagerService'][_0x490422(0x215)](_0x2c1892,_0x4e258a,_0x35e274,_0x50b564);if(_0xc2a78a!=null)_0x2c4089['treeId']=_0xc2a78a;else this['_dependencyManagerService'][_0x490422(0x15b)](_0x2c1892,_0x4e258a,_0x35e274,_0x50b564,_0x2c4089),this[_0x490422(0x1e3)][_0x490422(0x16f)](_0x2c4089);_0x27b363[_0x490422(0x18a)](_0x3dd86c,_0x2c4089),_0x4f9bc9[_0x490422(0x193)](_0x2c4089),this['_dependencyTreeCache'][_0x490422(0x18a)](_0x2c4089[_0x490422(0x1be)],_0x2c4089);}),_0x3888d0[_0x417db0(0x14d)]((_0x61204,_0x469671,_0x4f5196)=>{const _0x3f5025=_0x417db0;if(_0x4f5196==null)return!![];const {x:x=0x0,y:y=0x0,si:_0x59820d}=_0x4f5196;if(x===0x0&&y===0x0&&_0x59820d!=null)return!![];let _0xc7728c;if(_0x59820d&&_0x27b363[_0x3f5025(0x23e)](_0x59820d)){const _0x27ec96=_0x27b363[_0x3f5025(0x222)](_0x59820d);_0xc7728c=this[_0x3f5025(0x18f)](_0x27ec96,_0x4f5196);}else _0xc7728c=this[_0x3f5025(0x1c5)](_0x2c1892,_0x4e258a,_0x61204,_0x469671,_0x8d3145,_0x4f5196);const _0x2fb7a3=this['_dependencyManagerService'][_0x3f5025(0x215)](_0x2c1892,_0x4e258a,_0x61204,_0x469671);if(_0x2fb7a3!=null)_0xc7728c[_0x3f5025(0x1be)]=_0x2fb7a3;else this[_0x3f5025(0x1e3)][_0x3f5025(0x15b)](_0x2c1892,_0x4e258a,_0x61204,_0x469671,_0xc7728c),this[_0x3f5025(0x1e3)]['addFormulaDependencyByDefinedName'](_0xc7728c);_0x4f9bc9['push'](_0xc7728c),this[_0x3f5025(0x148)][_0x3f5025(0x18a)](_0xc7728c[_0x3f5025(0x1be)],_0xc7728c);}),_0x27b363[_0x417db0(0x1da)]();}}}[_0x49edc8(0x1c5)](_0x2b8061,_0x43321a,_0x3669a2,_0x28a85d,_0x10438a,_0x1713a1){const _0x688c0=_0x49edc8,{f:_0x58eaa2,x:x=0x0,y:y=0x0}=_0x1713a1,_0x4b72be=new _univerjs_engine_formula[(_0x688c0(0x15e))]((0x0,_univerjs_engine_formula[_0x688c0(0x14f)])(this[_0x688c0(0x1e3)])),_0x431479=_0x10438a[_0x2b8061][_0x43321a];return _0x4b72be[_0x688c0(0x181)]=_0x58eaa2,_0x4b72be[_0x688c0(0x149)]=_0x2b8061,_0x4b72be['subUnitId']=_0x43321a,_0x4b72be[_0x688c0(0x147)]=_0x3669a2,_0x4b72be['column']=_0x28a85d,_0x4b72be['rowCount']=_0x431479[_0x688c0(0x206)],_0x4b72be[_0x688c0(0x17c)]=_0x431479['columnCount'],_0x4b72be;}[_0x49edc8(0x1b2)](){const _0x467c2a=_0x49edc8,_0x206b19=[],_0x31e2b6=new Set(),_0x543d4b=this[_0x467c2a(0x152)][_0x467c2a(0x1a1)](),_0x397da5=this['_currentConfigService']['getDirtyRanges'](),_0x39da67=this[_0x467c2a(0x1e3)][_0x467c2a(0x1cb)](_0x397da5),_0x57b2e2=this[_0x467c2a(0x13d)][_0x467c2a(0x1e2)](_0x397da5);for(const _0x21a0af of _0x57b2e2)_0x39da67[_0x467c2a(0x1f2)](_0x21a0af);for(const [_0x2310c5,_0x2b48c9]of this[_0x467c2a(0x148)])(_0x543d4b||_0x2b48c9['isDirty']||_0x2b48c9[_0x467c2a(0x220)](this[_0x467c2a(0x152)][_0x467c2a(0x21c)]())||_0x39da67[_0x467c2a(0x23e)](_0x2310c5)&&!_0x2b48c9[_0x467c2a(0x22c)](this['_currentConfigService'][_0x467c2a(0x169)]()))&&!_0x31e2b6[_0x467c2a(0x23e)](_0x2310c5)&&(_0x206b19[_0x467c2a(0x193)](_0x2b48c9),_0x31e2b6['add'](_0x2310c5));for(const [_0x2cb425,_0x1d3ee3]of this['_dependencyTreeCache']){if(_0x1d3ee3[_0x467c2a(0x1f7)])continue;_0x1d3ee3[_0x467c2a(0x201)][_0x467c2a(0x172)]=0x0;}return _0x206b19;}[_0x49edc8(0x1c0)](_0x2c2828){const _0x50f2e8=_0x49edc8;return this[_0x50f2e8(0x148)][_0x50f2e8(0x222)](_0x2c2828);}[_0x49edc8(0x225)](_0x56c8ad){const _0xb6d54b=_0x49edc8;return(0x0,_univerjs_engine_formula['generateAstNode'])(_0x56c8ad[_0xb6d54b(0x149)],_0x56c8ad[_0xb6d54b(0x181)],this[_0xb6d54b(0x19d)],this['_astTreeBuilder'],this[_0xb6d54b(0x152)]);}*[_0x49edc8(0x1e7)](_0x19c5b0,_0x2240d5){const _0x5098ab=_0x49edc8,_0x2ee826=_0x19c5b0,_0x39251d=new Set();while(_0x2ee826[_0x5098ab(0x172)]>0x0){const _0x164c11=_0x2ee826[_0x5098ab(0x213)]();_0x39251d[_0x5098ab(0x1da)]();if(_0x164c11===void 0x0||_0x164c11['isSkip']())continue;if(_0x164c11['isAdded']()){yield _0x164c11,_0x164c11['setSkip'](),_0x2240d5[_0x5098ab(0x1f2)](_0x164c11['treeId']);continue;}const _0x5b249d=this['_dependencyManagerService']['searchDependency'](_0x164c11['toRTreeItem'](),_0x2240d5),_0x2a804b=this[_0x5098ab(0x13d)]['bulkSearch'](_0x164c11[_0x5098ab(0x237)](),_0x2240d5);for(const _0x10992d of _0x2a804b)_0x5b249d[_0x5098ab(0x1f2)](_0x10992d);for(const _0x27c951 of _0x5b249d){const _0x10981f=this[_0x5098ab(0x148)]['get'](_0x27c951);if(!_0x10981f){console[_0x5098ab(0x18d)](_0x5098ab(0x241),_0x27c951);continue;}if(_0x10981f['isAdded']()||_0x164c11[_0x5098ab(0x160)]())continue;_0x39251d[_0x5098ab(0x1f2)](_0x10981f);}_0x5b249d[_0x5098ab(0x1da)]();if(_0x39251d[_0x5098ab(0x19f)]===0x0)yield _0x164c11,_0x164c11[_0x5098ab(0x13a)](),_0x2240d5[_0x5098ab(0x1f2)](_0x164c11[_0x5098ab(0x1be)]);else{_0x164c11[_0x5098ab(0x1cf)](),_0x2ee826[_0x5098ab(0x193)](_0x164c11);for(const _0x2b8298 of _0x39251d)_0x2ee826[_0x5098ab(0x193)](_0x2b8298);}}_0x2ee826[_0x5098ab(0x172)]=0x0,_0x39251d['clear']();}[_0x49edc8(0x1a7)](_0x430be3){const _0x5bff3a=_0x49edc8,_0x176794=[],_0x34c7de=new Set();for(const _0x531110 of this['_traverse'](_0x430be3,_0x34c7de))_0x176794[_0x5bff3a(0x193)](_0x531110);return _0x176794;}async[_0x49edc8(0x162)](){const _0x5618c8=_0x49edc8;return await this['_initializeGenerateTreeList'](),Array[_0x5618c8(0x1b5)](this['_dependencyTreeCache'][_0x5618c8(0x17f)]());}[_0x49edc8(0x145)](_0x204dc7){const _0x421392=_0x49edc8;return this[_0x421392(0x1e3)][_0x421392(0x1cb)](_0x204dc7[_0x421392(0x237)]());}[_0x49edc8(0x1e8)](_0x44168b){const _0x40b41f=_0x49edc8,_0x433153=new Set(),_0x62aa02=_0x44168b['rangeList'];for(const [_0x7689ae,_0xfb7b2d]of this[_0x40b41f(0x148)])for(const _0x508487 of _0x62aa02){const _0xf596ec=_0x508487['unitId'],_0x571733=_0x508487[_0x40b41f(0x226)];if(_0xfb7b2d[_0x40b41f(0x149)]!==_0xf596ec||_0xfb7b2d[_0x40b41f(0x1e5)]!==_0x571733)continue;const _0x117367=_0x508487[_0x40b41f(0x20f)];if(_0xfb7b2d[_0x40b41f(0x153)](_0x117367)){_0x433153[_0x40b41f(0x1f2)](_0x7689ae);break;}}return _0x433153;}[_0x49edc8(0x139)](){const _0x4eb81d=_0x49edc8;this['_dependencyManagerService'][_0x4eb81d(0x1b0)]();}[_0x49edc8(0x1ec)](){const _0x1d1d74=_0x49edc8;this['_formulaDependencyTreeModel'][_0x1d1d74(0x1da)](),this[_0x1d1d74(0x148)][_0x1d1d74(0x1da)](),this[_0x1d1d74(0x1e3)]['closeKdTree']();}},CalculateFormulaProService=class extends _univerjs_engine_formula[_0x49edc8(0x166)]{async[_0x49edc8(0x1f4)](_0x95db07=![]){const _0x30dab4=_0x49edc8;if(_0x95db07)this[_0x30dab4(0x1e0)]['setFormulaExecuteStage'](_univerjs_engine_formula[_0x30dab4(0x1bb)][_0x30dab4(0x1d5)]);else this[_0x30dab4(0x1e0)]['setFormulaExecuteStage'](_univerjs_engine_formula[_0x30dab4(0x1bb)][_0x30dab4(0x23a)]);this[_0x30dab4(0x1a6)]['next'](this[_0x30dab4(0x1e0)][_0x30dab4(0x19b)]());const _0x3e6215=await this[_0x30dab4(0x1c6)][_0x30dab4(0x138)](this[_0x30dab4(0x18b)]),_0x4ca65c=this[_0x30dab4(0x19a)];_0x95db07?(this[_0x30dab4(0x1e0)][_0x30dab4(0x1bc)](_univerjs_engine_formula[_0x30dab4(0x1bb)][_0x30dab4(0x1ed)]),this[_0x30dab4(0x1e0)][_0x30dab4(0x185)](_0x3e6215[_0x30dab4(0x172)])):(this[_0x30dab4(0x1e0)][_0x30dab4(0x1bc)](_univerjs_engine_formula[_0x30dab4(0x1bb)]['START_CALCULATION']),this[_0x30dab4(0x1e0)][_0x30dab4(0x15f)](_0x3e6215[_0x30dab4(0x172)]));this['_executionInProgressListener$'][_0x30dab4(0x1a4)](this['_runtimeService'][_0x30dab4(0x19b)]());let _0x1f54ce=[];const _0x3d00e3=this[_0x30dab4(0x189)][_0x30dab4(0x1d8)](_univerjs_engine_formula['ENGINE_FORMULA_PLUGIN_CONFIG_KEY']),_0x4e589f=(_0x3d00e3===null||_0x3d00e3===void 0x0?void 0x0:_0x3d00e3[_0x30dab4(0x13e)])||_univerjs_engine_formula['DEFAULT_INTERVAL_COUNT'];let _0x313dd3=0x0;const _0x598333=_0x3e6215['length'];while(_0x3e6215['length']>0x0){const _0x482e05=_0x3e6215[_0x30dab4(0x213)](),_0x46497b=(0x0,_univerjs_engine_formula[_0x30dab4(0x1fc)])(_0x482e05[_0x30dab4(0x149)],_0x482e05[_0x30dab4(0x181)],this[_0x30dab4(0x19d)],this['_astTreeBuilder'],this['_currentConfigService']),_0x1e56a1={'node':_0x46497b,'refOffsetX':_0x482e05['refOffsetX'],'refOffsetY':_0x482e05['refOffsetY']},_0x1c7500=_0x482e05[_0x30dab4(0x171)];if(_0x313dd3%_0x4e589f===0x0){await new Promise(_0x35eaf5=>{const _0x20cc9e=_0x30dab4,_0x18e8ff=(0x0,_univerjs_core[_0x20cc9e(0x216)])(_0x35eaf5);_0x1f54ce[_0x20cc9e(0x193)](_0x18e8ff);});_0x95db07?(this[_0x30dab4(0x1e0)][_0x30dab4(0x1bc)](_univerjs_engine_formula[_0x30dab4(0x1bb)][_0x30dab4(0x159)]),this[_0x30dab4(0x1e0)][_0x30dab4(0x17d)](_0x313dd3+0x1)):(this[_0x30dab4(0x1e0)][_0x30dab4(0x1bc)](_univerjs_engine_formula[_0x30dab4(0x1bb)][_0x30dab4(0x20d)]),this['_runtimeService'][_0x30dab4(0x20b)](_0x313dd3+0x1));this[_0x30dab4(0x1a6)][_0x30dab4(0x1a4)](this[_0x30dab4(0x1e0)]['getRuntimeState']());if(this[_0x30dab4(0x1e0)][_0x30dab4(0x187)]()||_0x1e56a1==null&&_0x1c7500==null){this[_0x30dab4(0x1e0)][_0x30dab4(0x1bc)](_univerjs_engine_formula[_0x30dab4(0x1bb)][_0x30dab4(0x1aa)]),this[_0x30dab4(0x1e0)]['markedAsStopFunctionsExecuted'](),this[_0x30dab4(0x14e)][_0x30dab4(0x1a4)](this[_0x30dab4(0x1e0)][_0x30dab4(0x1fa)]());return;}}this[_0x30dab4(0x1e0)][_0x30dab4(0x1b3)](_0x482e05[_0x30dab4(0x147)],_0x482e05[_0x30dab4(0x194)],_0x482e05[_0x30dab4(0x206)],_0x482e05[_0x30dab4(0x17c)],_0x482e05[_0x30dab4(0x1e5)],_0x482e05[_0x30dab4(0x149)]);let _0x294c6b;if(_0x1c7500!=null&&_0x482e05[_0x30dab4(0x136)]!=null){const {runtimeCellData:_0x1992b1,dirtyRanges:_0x4c8600}=_0x1c7500(this[_0x30dab4(0x152)][_0x30dab4(0x171)](),this[_0x30dab4(0x1e0)][_0x30dab4(0x1fa)]());this['_runtimeService']['setRuntimeFeatureCellData'](_0x482e05[_0x30dab4(0x136)],_0x1992b1),this[_0x30dab4(0x1e0)][_0x30dab4(0x217)](_0x482e05['featureId'],_0x4c8600);}else{if(_0x1e56a1!=null){if(_0x4ca65c[_0x30dab4(0x205)](_0x1e56a1[_0x30dab4(0x176)]))_0x294c6b=await _0x4ca65c[_0x30dab4(0x195)](_0x1e56a1);else _0x294c6b=_0x4ca65c[_0x30dab4(0x168)](_0x1e56a1);if(_0x482e05[_0x30dab4(0x20a)]!=null)this['_runtimeService']['setRuntimeOtherData'](_0x482e05['formulaId'],_0x482e05[_0x30dab4(0x18e)],_0x482e05[_0x30dab4(0x1df)],_0x294c6b);else this[_0x30dab4(0x1e0)][_0x30dab4(0x18c)](_0x294c6b);}}_0x46497b[_0x30dab4(0x21e)](),_0x313dd3++;}_0x1f54ce[_0x30dab4(0x1fe)](_0x3f737c=>_0x3f737c()),_0x1f54ce=[];if(_0x598333>0x0)this[_0x30dab4(0x1e0)][_0x30dab4(0x183)]();else{if(!_0x95db07)this['_runtimeService'][_0x30dab4(0x1cc)]();}return this[_0x30dab4(0x1e0)][_0x30dab4(0x1fa)]();}},DependencyManagerProService=class extends _univerjs_engine_formula['DependencyManagerBaseService']{constructor(..._0x323f81){const _0x263359=_0x49edc8;super(..._0x323f81),_defineProperty(this,_0x263359(0x167),new Map()),_defineProperty(this,'_dependencyRTreeCache',new _univerjs_core[(_0x263359(0x204))](!![]));}[_0x49edc8(0x14c)](){const _0x482296=_0x49edc8;this[_0x482296(0x1a5)][_0x482296(0x1da)](),this['_featureFormulaData'][_0x482296(0x1da)](),this[_0x482296(0x1d1)]['clear'](),this['_dependencyRTreeCache'][_0x482296(0x1da)](),this[_0x482296(0x167)][_0x482296(0x1da)](),this[_0x482296(0x239)](),this[_0x482296(0x161)]['clear']();}['addOtherFormulaDependency'](_0xf91045,_0x329890,_0xd82793,_0x723a52){const _0x5e23ea=_0x49edc8;if(!this[_0x5e23ea(0x1a5)][_0x5e23ea(0x23e)](_0xf91045))this[_0x5e23ea(0x1a5)]['set'](_0xf91045,new Map());const _0x324fb0=this[_0x5e23ea(0x1a5)][_0x5e23ea(0x222)](_0xf91045);if(!_0x324fb0[_0x5e23ea(0x23e)](_0x329890))_0x324fb0[_0x5e23ea(0x18a)](_0x329890,new Map());const _0x448223=_0x324fb0[_0x5e23ea(0x222)](_0x329890);if(!_0x448223[_0x5e23ea(0x23e)](_0xd82793))_0x448223[_0x5e23ea(0x18a)](_0xd82793,new _univerjs_core[(_0x5e23ea(0x238))]());_0x448223['get'](_0xd82793)['setValue'](_0x723a52['refOffsetX'],_0x723a52[_0x5e23ea(0x1df)],_0x723a52['treeId']);}[_0x49edc8(0x154)](_0x3d32ea,_0x2155b2,_0xeb2247){const _0x315cd3=_0x49edc8,_0x319c4a=this[_0x315cd3(0x1a5)]['get'](_0x3d32ea);if(_0x319c4a&&_0x319c4a['has'](_0x2155b2)){const _0x3dbdc9=_0x319c4a[_0x315cd3(0x222)](_0x2155b2);_0xeb2247['forEach'](_0x5d3339=>{const _0xc52c6a=_0x315cd3,_0x45d3d7=_0x3dbdc9[_0xc52c6a(0x222)](_0x5d3339);if(_0x45d3d7==null)return;_0x45d3d7[_0xc52c6a(0x14d)]((_0x4d117f,_0xee5116,_0x196bb9)=>{const _0x8df4e0=_0xc52c6a;this[_0x8df4e0(0x190)](_0x196bb9),this[_0x8df4e0(0x1a3)](_0x196bb9);}),_0x3dbdc9[_0xc52c6a(0x22d)](_0x5d3339),this[_0xc52c6a(0x161)][_0xc52c6a(0x22d)](_0x5d3339);});if(_0x3dbdc9[_0x315cd3(0x19f)]===0x0)_0x319c4a[_0x315cd3(0x22d)](_0x2155b2);if(_0x319c4a[_0x315cd3(0x19f)]===0x0)this[_0x315cd3(0x1a5)][_0x315cd3(0x22d)](_0x3d32ea);}}[_0x49edc8(0x1d6)](_0x54c9a9,_0x486839){const _0x44c929=_0x49edc8,_0x33453f=this[_0x44c929(0x1a5)][_0x44c929(0x222)](_0x54c9a9);if(_0x486839&&_0x33453f&&_0x33453f[_0x44c929(0x23e)](_0x486839)){const _0x13c809=_0x33453f[_0x44c929(0x222)](_0x486839);this[_0x44c929(0x240)](_0x54c9a9,_0x486839);for(const _0x5e6e19 of _0x13c809['keys']()){const _0x12435d=_0x13c809[_0x44c929(0x222)](_0x5e6e19);if(_0x12435d==null)continue;_0x12435d[_0x44c929(0x14d)]((_0x21dd27,_0x88a6f0,_0x530994)=>{const _0x1ed37b=_0x44c929;if(this[_0x1ed37b(0x167)]['get'](_0x530994))this[_0x1ed37b(0x1a3)](_0x530994);}),this[_0x44c929(0x161)]['delete'](_0x5e6e19);}_0x13c809[_0x44c929(0x1da)]();}else{if(_0x33453f){for(const _0x5e8841 of _0x33453f[_0x44c929(0x21a)]()){const _0x1d50ed=_0x33453f['get'](_0x5e8841);this[_0x44c929(0x240)](_0x54c9a9,_0x5e8841);for(const _0xc05eee of _0x1d50ed['keys']()){const _0x501db7=_0x1d50ed[_0x44c929(0x222)](_0xc05eee);if(_0x501db7==null)continue;_0x501db7[_0x44c929(0x14d)]((_0x20d0d1,_0x95fe83,_0x5a0f2e)=>{const _0xd6e8c7=_0x44c929;if(this[_0xd6e8c7(0x167)]['get'](_0x5a0f2e))this['_removeAllTreeMap'](_0x5a0f2e);}),this[_0x44c929(0x161)][_0x44c929(0x22d)](_0xc05eee);}}this['_otherFormulaData'][_0x44c929(0x22d)](_0x54c9a9);}}}[_0x49edc8(0x146)](_0x2e5362,_0xfa738c,_0x372a39,_0x3b35eb){const _0x172d80=_0x49edc8;if(!this[_0x172d80(0x21b)]['has'](_0x2e5362))this['_featureFormulaData'][_0x172d80(0x18a)](_0x2e5362,new Map());const _0x4a8095=this['_featureFormulaData'][_0x172d80(0x222)](_0x2e5362);if(!_0x4a8095[_0x172d80(0x23e)](_0xfa738c))_0x4a8095[_0x172d80(0x18a)](_0xfa738c,new Map());_0x4a8095[_0x172d80(0x222)](_0xfa738c)[_0x172d80(0x18a)](_0x372a39,_0x3b35eb[_0x172d80(0x1be)]);}['removeFeatureFormulaDependency'](_0xba33c5,_0x237264,_0x325290){const _0x11b5c5=_0x49edc8,_0x2c6371=this[_0x11b5c5(0x21b)]['get'](_0xba33c5);if(_0x2c6371&&_0x2c6371[_0x11b5c5(0x23e)](_0x237264)){const _0x18eee5=_0x2c6371[_0x11b5c5(0x222)](_0x237264);_0x325290['forEach'](_0x17e884=>{const _0x5f2f8f=_0x11b5c5,_0x346e29=_0x18eee5[_0x5f2f8f(0x222)](_0x17e884);if(_0x346e29==null)return;this[_0x5f2f8f(0x190)](_0x346e29),_0x18eee5[_0x5f2f8f(0x22d)](_0x17e884),this[_0x5f2f8f(0x1a3)](_0x346e29);});}}[_0x49edc8(0x23f)](_0x152ce1,_0x56aece){const _0x4cc3a0=_0x49edc8,_0x4811bd=this[_0x4cc3a0(0x21b)]['get'](_0x152ce1);if(_0x56aece&&_0x4811bd&&_0x4811bd[_0x4cc3a0(0x23e)](_0x56aece)){const _0x592d39=_0x4811bd['get'](_0x56aece);this['_removeDependencyRTreeCacheById'](_0x152ce1,_0x56aece),_0x592d39[_0x4cc3a0(0x1fe)](_0xacdb1d=>{const _0x10e763=_0x4cc3a0;if(_0xacdb1d==null)return;this[_0x10e763(0x1a3)](_0xacdb1d);}),_0x592d39[_0x4cc3a0(0x1da)]();}else _0x4811bd&&(_0x4811bd[_0x4cc3a0(0x1fe)]((_0x3315dc,_0x86bd04)=>{const _0x48b3ec=_0x4cc3a0;this[_0x48b3ec(0x240)](_0x152ce1,_0x86bd04),_0x3315dc[_0x48b3ec(0x1fe)](_0x3abe7c=>{const _0x10d93b=_0x48b3ec;if(_0x3abe7c==null)return;this[_0x10d93b(0x1a3)](_0x3abe7c);});}),this[_0x4cc3a0(0x21b)][_0x4cc3a0(0x22d)](_0x152ce1));}['addFormulaDependency'](_0x2ee59f,_0x2038a2,_0x5359f1,_0x1a7f0e,_0x84d0cd){const _0x394407=_0x49edc8;if(!this['_formulaData'][_0x394407(0x23e)](_0x2ee59f))this[_0x394407(0x1d1)][_0x394407(0x18a)](_0x2ee59f,new Map());const _0x4a15cc=this[_0x394407(0x1d1)][_0x394407(0x222)](_0x2ee59f);if(!_0x4a15cc[_0x394407(0x23e)](_0x2038a2))_0x4a15cc['set'](_0x2038a2,new _univerjs_core[(_0x394407(0x238))]());_0x4a15cc['get'](_0x2038a2)[_0x394407(0x212)](_0x5359f1,_0x1a7f0e,_0x84d0cd[_0x394407(0x1be)]);}[_0x49edc8(0x1e6)](_0x1cb095,_0x215574,_0x5f4e92,_0x271f8d){const _0x36f1b4=_0x49edc8,_0x4161a7=this[_0x36f1b4(0x1d1)][_0x36f1b4(0x222)](_0x1cb095);if(_0x4161a7&&_0x4161a7[_0x36f1b4(0x23e)](_0x215574)){const _0x30dc34=_0x4161a7[_0x36f1b4(0x222)](_0x215574),_0x5d261c=_0x30dc34[_0x36f1b4(0x209)](_0x5f4e92,_0x271f8d);if(_0x5d261c==null)return;this[_0x36f1b4(0x190)](_0x5d261c),_0x30dc34['realDeleteValue'](_0x5f4e92,_0x271f8d),this[_0x36f1b4(0x1a3)](_0x5d261c);}}[_0x49edc8(0x22f)](_0xba5666,_0x3bb60e){const _0xb0cc61=_0x49edc8,_0x4931d8=this['_formulaData'][_0xb0cc61(0x222)](_0xba5666);if(_0x3bb60e&&_0x4931d8&&_0x4931d8['has'](_0x3bb60e)){const _0x4d8723=_0x4931d8['get'](_0x3bb60e);this[_0xb0cc61(0x240)](_0xba5666,_0x3bb60e),_0x4d8723[_0xb0cc61(0x14d)]((_0x14c154,_0x257c49,_0x52b723)=>{const _0x33a884=_0xb0cc61;if(_0x52b723==null)return!![];this[_0x33a884(0x1a3)](_0x52b723);}),_0x4d8723[_0xb0cc61(0x14c)]();}else _0x4931d8&&(_0x4931d8[_0xb0cc61(0x1fe)]((_0x49bbd0,_0x388e2d)=>{const _0x4fcd2f=_0xb0cc61;this[_0x4fcd2f(0x240)](_0xba5666,_0x388e2d),_0x49bbd0[_0x4fcd2f(0x14d)]((_0x14201c,_0x2d5234,_0x148b60)=>{const _0x1138e6=_0x4fcd2f;if(_0x148b60==null)return!![];this[_0x1138e6(0x1a3)](_0x148b60);});}),this[_0xb0cc61(0x1d1)][_0xb0cc61(0x22d)](_0xba5666));}['_removeDependencyRTreeCache'](_0x1e7c96){const _0x39917e=_0x49edc8;if(_0x1e7c96==null)return;const _0x1ecace=this[_0x39917e(0x167)]['get'](_0x1e7c96);if(_0x1ecace){const _0x53e074=[];for(const [_0x517349,_0x1146e8]of _0x1ecace)for(const [_0x22554e,_0x329b14]of _0x1146e8)_0x53e074[_0x39917e(0x193)]({'unitId':_0x517349,'sheetId':_0x22554e,'range':_0x329b14,'id':_0x1e7c96});this[_0x39917e(0x1b8)][_0x39917e(0x1fd)](_0x53e074);}}[_0x49edc8(0x1ff)](_0x3ad566,_0x50110a){const _0x36ad4b=_0x49edc8,_0x1b27d6=this[_0x36ad4b(0x23b)][_0x36ad4b(0x222)](_0x3ad566);if(_0x1b27d6){const _0x37e5ba=_0x1b27d6['get'](_0x50110a);if(_0x37e5ba){for(const _0x3dc3c0 of _0x37e5ba){this['_removeDependencyRTreeCache'](_0x3dc3c0),this[_0x36ad4b(0x1a3)](_0x3dc3c0);}_0x37e5ba['clear']();}}}[_0x49edc8(0x1b0)](){const _0x227812=_0x49edc8;this[_0x227812(0x1b8)][_0x227812(0x1b0)]();}['closeKdTree'](){const _0x55d0b0=_0x49edc8;this[_0x55d0b0(0x1b8)]['closeKdTree']();}[_0x49edc8(0x1a3)](_0x30c65c){const _0x563ede=_0x49edc8;if(_0x30c65c==null)return;this[_0x563ede(0x167)]['delete'](_0x30c65c);}[_0x49edc8(0x1ab)](_0xb66aa2){const _0x21c1e9=_0x49edc8,_0x2ca8fe=_0xb66aa2[_0x21c1e9(0x201)];let _0x2db9a6=this[_0x21c1e9(0x167)][_0x21c1e9(0x222)](_0xb66aa2['treeId']);for(let _0x16392f=0x0;_0x16392f<_0x2ca8fe['length'];_0x16392f++){var _0x1ffd89,_0x147d2b;let {unitId:_0x184b70,sheetId:_0xf41479,range:_0xb626b9}=_0x2ca8fe[_0x16392f];!_0x2db9a6&&(_0x2db9a6=new Map(),this[_0x21c1e9(0x167)]['set'](_0xb66aa2[_0x21c1e9(0x1be)],_0x2db9a6));if(!_0x2db9a6[_0x21c1e9(0x23e)](_0x184b70))_0x2db9a6[_0x21c1e9(0x18a)](_0x184b70,new Map());const _0x4fb249=_0x2db9a6===null||_0x2db9a6===void 0x0||(_0x1ffd89=_0x2db9a6[_0x21c1e9(0x222)](_0x184b70))===null||_0x1ffd89===void 0x0?void 0x0:_0x1ffd89['get'](_0xf41479);if(_0x4fb249)_0xb626b9={'startRow':Math[_0x21c1e9(0x20c)](_0xb626b9[_0x21c1e9(0x198)],_0x4fb249[_0x21c1e9(0x198)]),'startColumn':Math[_0x21c1e9(0x20c)](_0xb626b9[_0x21c1e9(0x219)],_0x4fb249['startColumn']),'endRow':Math[_0x21c1e9(0x144)](_0xb626b9[_0x21c1e9(0x229)],_0x4fb249[_0x21c1e9(0x229)]),'endColumn':Math[_0x21c1e9(0x144)](_0xb626b9[_0x21c1e9(0x157)],_0x4fb249[_0x21c1e9(0x157)])};(_0x147d2b=_0x2db9a6[_0x21c1e9(0x222)](_0x184b70))===null||_0x147d2b===void 0x0||_0x147d2b[_0x21c1e9(0x18a)](_0xf41479,_0xb626b9);}}};function _0x2e96(_0x11ac6c,_0x4f8057){_0x11ac6c=_0x11ac6c-0x135;const _0x552243=_0x5522();let _0x2e96bb=_0x552243[_0x11ac6c];return _0x2e96bb;}function __decorate(_0x38855d,_0x1aee06,_0xa5a2d3,_0x21d37f){const _0x23e314=_0x49edc8;var _0x32a8ea=arguments[_0x23e314(0x172)],_0x571962=_0x32a8ea<0x3?_0x1aee06:_0x21d37f===null?_0x21d37f=Object[_0x23e314(0x1d0)](_0x1aee06,_0xa5a2d3):_0x21d37f,_0x33678f;if(typeof Reflect==='object'&&typeof Reflect['decorate']==='function')_0x571962=Reflect[_0x23e314(0x165)](_0x38855d,_0x1aee06,_0xa5a2d3,_0x21d37f);else{for(var _0x36d889=_0x38855d['length']-0x1;_0x36d889>=0x0;_0x36d889--)if(_0x33678f=_0x38855d[_0x36d889])_0x571962=(_0x32a8ea<0x3?_0x33678f(_0x571962):_0x32a8ea>0x3?_0x33678f(_0x1aee06,_0xa5a2d3,_0x571962):_0x33678f(_0x1aee06,_0xa5a2d3))||_0x571962;}return _0x32a8ea>0x3&&_0x571962&&Object[_0x23e314(0x192)](_0x1aee06,_0xa5a2d3,_0x571962),_0x571962;}const BUILD_TIMESTAMP=Number[_0x49edc8(0x137)](0x6a042e58);let UniverProFormulaEnginePlugin=class UniverProFormulaEnginePlugin extends _univerjs_engine_formula['UniverFormulaEnginePlugin']{[_0x49edc8(0x178)](){const _0x51c088=_0x49edc8;if(this[_0x51c088(0x1c8)]()){var _0xc54a77;this['_injector'][_0x51c088(0x1f2)]([_univerjs_engine_formula['LexerTreeBuilder'],{'useClass':LexerTreeProBuilder}]);if(!((_0xc54a77=this['_config'])===null||_0xc54a77===void 0x0?void 0x0:_0xc54a77[_0x51c088(0x1b6)]))[[_univerjs_engine_formula[_0x51c088(0x174)],{'useClass':CalculateFormulaProService}],[_univerjs_engine_formula[_0x51c088(0x1db)],{'useClass':DependencyManagerProService}],[_univerjs_engine_formula[_0x51c088(0x232)],{'useClass':FormulaDependencyProGenerator}]]['forEach'](_0x411294=>this[_0x51c088(0x1b4)][_0x51c088(0x1f2)](_0x411294));}else{var _0xc55a13;this[_0x51c088(0x1b4)][_0x51c088(0x1f2)]([_univerjs_engine_formula[_0x51c088(0x1c9)],{'useClass':_univerjs_engine_formula[_0x51c088(0x1c9)]}]);if(!((_0xc55a13=this['_config'])===null||_0xc55a13===void 0x0?void 0x0:_0xc55a13['notExecuteFormula']))[[_univerjs_engine_formula['ICalculateFormulaService'],{'useClass':_univerjs_engine_formula[_0x51c088(0x166)]}],[_univerjs_engine_formula[_0x51c088(0x1db)],{'useClass':_univerjs_engine_formula[_0x51c088(0x1bf)]}],[_univerjs_engine_formula['IFormulaDependencyGenerator'],{'useClass':_univerjs_engine_formula[_0x51c088(0x186)]}]][_0x51c088(0x1fe)](_0x43561e=>this[_0x51c088(0x1b4)][_0x51c088(0x1f2)](_0x43561e));}}[_0x49edc8(0x1c8)](){const _0x466cde=_0x49edc8;var _0x3a52c0;const {ls:_0x15add9,pbk:_0x2eb00b}=(_0x3a52c0=this[_0x466cde(0x189)]['getConfig'](_univerjs_pro_license['LS_CONFIG_KEY']))!==null&&_0x3a52c0!==void 0x0?_0x3a52c0:{};if(!_0x15add9||!_0x2eb00b)return![];const _0x2c97d3=(0x0,_univerjs_pro_license[_0x466cde(0x218)])(_0x15add9,_0x2eb00b),_0x199d25=_0x2c97d3['message'];if(_0x2c97d3['valid']){if((0x0,_univerjs_pro_license[_0x466cde(0x1ac)])(_0x199d25,'sf',BUILD_TIMESTAMP))return(0x0,_univerjs_pro_license[_0x466cde(0x15c)])(_0x199d25,!![],'a',!![],![],![]);}return![];}};_defineProperty(UniverProFormulaEnginePlugin,_0x49edc8(0x14b),name),_defineProperty(UniverProFormulaEnginePlugin,_0x49edc8(0x1f5),version),UniverProFormulaEnginePlugin=__decorate([(0x0,_univerjs_core['DependentOn'])(_univerjs_pro_license[_0x49edc8(0x233)])],UniverProFormulaEnginePlugin),exports[_0x49edc8(0x1b7)]=LexerTreeProBuilder,Object[_0x49edc8(0x192)](exports,_0x49edc8(0x199),{'enumerable':!![],'get':function(){return UniverProFormulaEnginePlugin;}}),Object[_0x49edc8(0x21a)](_univerjs_engine_formula)['forEach'](function(_0x41c68f){const _0xd50662=_0x49edc8;if(_0x41c68f!==_0xd50662(0x175)&&!Object[_0xd50662(0x210)][_0xd50662(0x22b)][_0xd50662(0x1dc)](exports,_0x41c68f))Object['defineProperty'](exports,_0x41c68f,{'enumerable':!![],'get':function(){return _univerjs_engine_formula[_0x41c68f];}});});function _0x5522(){const _0x272a9f=['treeId','DependencyManagerService','_getTreeById','\x22\x20is\x20duplicated.','getFormulaData','_clearPrefix','_generateTreeList','_createFDtree','_formulaDependencyGenerator','isCache','_initLicenseValid','LexerTreeBuilder','toPrimitive','searchDependency','markedAsNoFunctionsExecuted','5312285eAGvLe','addOtherFormulaDependencyMainData','setAdded','getOwnPropertyDescriptor','_formulaData','@univerjs-pro/engine-formula','_clearFunctionString','COLON','START_DEPENDENCY_ARRAY_FORMULA','clearOtherFormulaDependency','_handleChildrenForExprTree','getConfig','SUFFIX_TOKEN_SET','clear','IDependencyManagerService','call','join','_getTableNameFromStructuredRef','refOffsetY','_runtimeService','iterator','bulkSearch','_dependencyManagerService','enableCycleDependency','subUnitId','removeFormulaDependency','_traverse','_getDependencyTreeChildrenIds','MINUS','toUpperCase','getToken','_endFormulaDependencyTreeModel','START_CALCULATION_ARRAY_FORMULA','_convertDirtyRangesToUnitRange','type','_checkAddBracketForMinus','OTHER_FORMULA','add','closeKdTree','_apply','version','_handleNewFunctionChild','isVirtual','FEATURE_FORMULA','9388ILjZjN','getAllRuntimeData','prefixToken','generateAstNode','bulkRemove','forEach','removeFormulaDependencyByDefinedName','DEFAULT_TOKEN_LET_FUNCTION_NAME','rangeList','string','_generateNewFunctionString','RTree','checkAsyncNode','rowCount','189207NAHDbk','ErrorType','getValue','formulaId','setCompletedFormulasCount','min','CURRENTLY_CALCULATING','_xlpmPrefix','range','prototype','dispose','setValue','pop','getChildren','getFormulaDependency','requestImmediateMacroTask','setRuntimeFeatureRange','getLicenseInfo','startColumn','keys','_featureFormulaData','getDirtyNameMap','getOtherFormulaDependency','resetCalculationState','toStringTag','dependencySheetName','2216200xYTvLC','get','OPERATOR_TOKEN_SET','constructor','_getTreeNode','sheetId','2402220uUlgXB','getNewFormulaWithPrefix','endRow','setDependencyTreeModelData','hasOwnProperty','isExcludeRange','delete','160hDYDrF','clearFormulaDependency','getFeatureFormulaDependency','18kOeZXT','IFormulaDependencyGenerator','UniverLicensePlugin','startsWith','DEFAULT_TOKEN_TYPE_ROOT','function','toRTreeItem','ObjectMatrix','_restDependencyTreeId','START_DEPENDENCY','_definedNameMap','70QAkzWH','_resetPrefix','has','clearFeatureFormulaDependency','_removeDependencyRTreeCacheById','Dependency\x20tree\x20not\x20found\x20for\x20treeId:','_getCurNodeTypeForExprTree','featureId','parseInt','generate','_startFormulaDependencyTreeModel','setSkip','treeBuilder','DEFAULT_TOKEN_TYPE_PARAMETER','_dependencyRTreeCacheForAddressFunction','intervalCount','VALUE','_hasNewExcelFunction','_updateRangeFlatten','getStartIndex','refTree','max','_getDependencyTreeParenIds','addFeatureFormulaDependency','row','_dependencyTreeCache','unitId','Let\x20variable\x20name\x20\x22','packageName','reset','forValue','_executionCompleteListener$','generateRandomDependencyTreeId','10970BGXnOI','_generateExprTree','_currentConfigService','inRangeData','removeOtherFormulaDependency','object','_checkColonNodeForExprTree','endColumn','@@toPrimitive\x20must\x20return\x20a\x20primitive\x20value.','CURRENTLY_CALCULATING_ARRAY_FORMULA','clearArrayObjectCache','addFormulaDependency','getSheetFeatureLimit','_handleTextNodeForExprTree','FormulaDependencyTree','setTotalFormulasToCalculate','isSkip','_otherFormulaDataMainData','_getAllTreeList','_lambdaFunctionParameterSet','addOtherFormulaDependency','decorate','CalculateFormulaService','_allTreeMap','execute','getExcludedRange','DEFAULT_TOKEN_LAMBDA_FUNCTION_NAME','PLUS','_registerOtherFormulas','_getFirstCellOfRange','matchToken','addFormulaDependencyByDefinedName','slice','getDirtyData','length','trim','ICalculateFormulaService','default','node','LexerNode','_initializeWithOverride','getFormulaExprTree','value','startIndex','columnCount','setCompletedArrayFormulasCount','0.22.1','values','getClearDependencyTreeCache','formula','_xlfnPrefix','markedAsSuccessfullyExecuted','10lypMzE','setTotalArrayFormulasToCalculate','FormulaDependencyGenerator','isStopExecution','FormulaDependencyTreeType','_configService','set','_isCalculateTreeModel','setRuntimeData','error','refOffsetX','_createVirtualFDtree','_removeDependencyRTreeCache','DEFAULT_TOKEN_TYPE_LAMBDA_PARAMETER','defineProperty','push','column','executeAsync','_checkIsCycleDependency','_getAllDependencyJson','startRow','UniverProFormulaEnginePlugin','_interpreter','getRuntimeState','Module','_lexer','_currentUnitId','size','featureDirtyRanges','isForceCalculate','_handleLambdaForExprTree','_removeAllTreeMap','next','_otherFormulaData','_executionInProgressListener$','_calculateRunList','children','_isCyclicUtilMap','IDLE','_addAllTreeMap','isFeatureAuthorizedWithinTime','splitTableStructuredRef','symbol','_xlpm.','openKdTree','_getFeatureFormulaTree','_getUpdateTreeListAndMakeDependency','setCurrent','_injector','from','notExecuteFormula','LexerTreeProBuilder','_dependencyRTreeCache','isReferenceString','1047846YcbTZj','FormulaExecuteStageType','setFormulaExecuteStage','_otherFormulaManagerService'];_0x5522=function(){return _0x272a9f;};return _0x5522();}
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@univerjs-pro/license`),t=require(`@univerjs/core`),n=require(`@univerjs/engine-formula`);var r=`@univerjs-pro/engine-formula`,i=`0.23.0`;function a(){return{totalFormulaNodes:0,totalSharedFormulaGroups:0,compressedSharedFormulaGroups:0,compressibleSharedFormulaGroups:0,expandedSharedFormulaGroups:0,totalVirtualFormulaNodesInCompressedGroups:0,totalVirtualFormulaNodesInCompressibleGroups:0,skippedExpandedDependencyRegistrationCount:0,sharedPatternCount:0,sharedSourceCoverageEntryCount:0,fallbackReasonCounts:{}}}function o(e,t={}){var n;let r=(n=t.minSharedGroupSize)==null?32:n,i=a(),o=s(e,i),l=[];return o.forEach(e=>{let t=c(e,r);if(l.push(t),i.totalSharedFormulaGroups++,t.mode===`candidate`){i.compressibleSharedFormulaGroups++,i.totalVirtualFormulaNodesInCompressibleGroups+=t.virtualFormulaCount;return}if(i.expandedSharedFormulaGroups++,t.fallbackReason){var n;i.fallbackReasonCounts[t.fallbackReason]=((n=i.fallbackReasonCounts[t.fallbackReason])==null?0:n)+1}}),{groups:l,metrics:i}}function s(e,t){let n=new Map;return Object.keys(e).forEach(r=>{let i=e[r];i!=null&&Object.keys(i).forEach(e=>{let a=i[e];a!=null&&Object.keys(a).forEach(i=>{let o=a[Number(i)];o!=null&&Object.keys(o).forEach(a=>{let s=o[Number(a)];if(s==null||(t.totalFormulaNodes++,s.si==null))return;let c=String(s.si),l=d(r,e,c),u=n.get(l);u==null&&(u={groupId:l,unitId:r,sheetId:e,si:c,members:[]},n.set(l,u)),u.members.push({row:Number(i),col:Number(a),item:s})})})})}),n}function c(e,t){let n=l(e.members),r=n.maxCol-n.minCol+1,i=n.maxRow-n.minRow+1,a={unitId:e.unitId,sheetId:e.sheetId,range:{startRow:n.minRow,endRow:n.maxRow,startColumn:n.minCol,endColumn:n.maxCol}},o=e.members.filter(e=>f(e.item)),s=o.length===1?{unitId:e.unitId,sheetId:e.sheetId,row:o[0].row,col:o[0].col}:void 0,c=u(e,a,o.length,t);return{groupId:e.groupId,unitId:e.unitId,sheetId:e.sheetId,si:e.si,anchor:s,fillRange:a,width:r,height:i,size:e.members.length,virtualFormulaCount:Math.max(0,e.members.length-1),mode:c==null?`candidate`:`expanded`,fallbackReason:c}}function l(e){let t=1/0,n=-1/0,r=1/0,i=-1/0;for(let a=0;a<e.length;a++){let o=e[a];t=Math.min(t,o.row),n=Math.max(n,o.row),r=Math.min(r,o.col),i=Math.max(i,o.col)}return{minRow:t,maxRow:n,minCol:r,maxCol:i}}function u(e,t,n,r){var i;if(n===0)return`missing-anchor-formula`;if(n>1)return`ambiguous-anchor-formula`;if(!p(e.members,t))return`non-rectangular-fill-range`;if(e.members.length<r)return`small-group`;let a=e.members.find(e=>f(e.item)),o=(i=a==null?void 0:a.item.f)==null?``:i;if(g(o))return`external-reference`;if(m(o))return`unsupported-dynamic-reference`;if(h(o))return`volatile-function`;if(_(o))return`array-formula`;if(v(o))return`spill-formula`}function d(e,t,n){return[e,t,n].join(`\0`)}function f(e){var t,n;return((t=e.x)==null?0:t)===0&&((n=e.y)==null?0:n)===0}function p(e,t){let n=t.range.endColumn-t.range.startColumn+1;if(n*(t.range.endRow-t.range.startRow+1)!==e.length)return!1;let r=new Set;for(let i=0;i<e.length;i++){let a=e[i],o=(a.row-t.range.startRow)*n+(a.col-t.range.startColumn);if(r.has(o))return!1;r.add(o)}return!0}function m(e){return y(e,[`INDIRECT`,`OFFSET`])}function h(e){return y(e,[`RAND`,`RANDBETWEEN`,`NOW`,`TODAY`])}function g(e){return/\[[^\]]+\]/.test(e)}function _(e){return/^\s*\{=.*\}\s*$/.test(e)}function v(e){return/#/.test(e)}function y(e,t){for(let n=0;n<t.length;n++)if(RegExp(`(^|[^A-Z0-9_.])${t[n]}\\s*\\(`,`i`).test(e))return!0;return!1}function b(e){"@babel/helpers - typeof";return b=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},b(e)}function x(e,t){if(b(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(b(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function S(e){var t=x(e,`string`);return b(t)==`symbol`?t:t+``}function C(e,t,n){return(t=S(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var w=class extends n.FormulaDependencyGenerator{constructor(...e){super(...e),C(this,`_featureFormulaDirtyDependencies`,[]),C(this,`_calculationTreeCache`,new Map),C(this,`_calculationNodeDataCache`,new Map),C(this,`_forcedRecalculationNodeIndices`,new Set),C(this,`_sharedFormulaCompressionMetrics`,a()),C(this,`_cacheDependencyTreeModelRangeList`,!1)}dispose(){super.dispose(),this._dependencyTreeCache.clear(),this._calculationTreeCache.clear(),this._calculationNodeDataCache=new Map,this._featureFormulaDirtyDependencies.length=0,this._forcedRecalculationNodeIndices.clear(),this._sharedFormulaCompressionMetrics=a()}clearCalculatedDirty(e){this._dependencyManagerService.clearCalculatedDirty(e)}clearCachedCalculationNodeData(){this._calculationNodeDataCache=new Map}clearCachedCalculationTree(){this._calculationTreeCache.clear()}getCachedCalculationNodeData(e){return this._calculationNodeDataCache.get(e)}getCalculationOrder(){return this._dependencyManagerService.getCalculationOrder({detectCycles:!0})}getSharedFormulaCompressionMetrics(){return this._sharedFormulaCompressionMetrics}hasDynamicDepsByIndex(e){return this._dependencyManagerService.hasDynamicDepsByIndex(e)}refreshDynamicDepsByIndex(e,t){return this._dependencyManagerService.refreshDynamicDepsByIndex(e,t)}hasUncalculatedDirtyPrecedentByIndex(e,t){return this._dependencyManagerService.hasUncalculatedDirtyPrecedentByIndex(e,t)}async getAllDependencyJson(){this._featureFormulaDirtyDependencies.length=0,this._updateRangeFlatten();let e=this._currentConfigService.getFormulaData(),t=o(e);this._sharedFormulaCompressionMetrics=t.metrics;let n=this._otherFormulaManagerService.getOtherFormulaData(),r=this._currentConfigService.getUnitData();this._cacheDependencyTreeModelRangeList=!0;try{return await this._generateTreeListPro(e,n,r,t),this._getAllDependencyJsonPro(this._calculationTreeCache)}finally{this._cacheDependencyTreeModelRangeList=!1,this._featureFormulaDirtyDependencies.length=0}}async generatePro(e=!1){this._featureFormulaDirtyDependencies.length=0,this._updateRangeFlatten();let t=this._currentConfigService.getFormulaData(),n=o(t);this._sharedFormulaCompressionMetrics=n.metrics;let r=this._otherFormulaManagerService.getOtherFormulaData(),i=this._currentConfigService.getClearDependencyTreeCache(),a=this._dependencyManagerService;i!=null&&Object.keys(i).forEach(e=>{e!=null&&Object.keys(i[e]).forEach(t=>{t!=null&&(a.clearOtherFormulaDependency(e,t),a.clearFeatureFormulaDependency(e,t),a.clearFormulaDependency(e,t),this._clearCalculationTreeCache(e,t))})});let s=this._currentConfigService.getUnitData();this._cacheDependencyTreeModelRangeList=e;try{await this._generateTreeListPro(t,r,s,n)}finally{this._cacheDependencyTreeModelRangeList=!1}await this._markDirtyDependenciesPro(),this._featureFormulaDirtyDependencies.length=0,this._runtimeService.clearArrayObjectCache();let c=a.getCalculationOrder({detectCycles:!0}),l=this._calculationTreeCache;return e&&this._runtimeService.setDependencyTreeModelData(this._getAllDependencyJsonPro(l)),{calculationOrderResult:c,dependencyTree:l}}async _generateTreeListPro(e,t,n,r){let i=Object.keys(e),a=Object.keys(t);this._registerFeatureFormulasPro(),await this._registerFormulasPro(i,e,n,r),await this._registerOtherFormulasPro(t,a)}_registerFeatureFormulasPro(){this._featureCalculationManagerService.getReferenceExecutorMap().forEach((e,t)=>{e.forEach((e,t)=>{e.forEach((e,t)=>{let n=this._dependencyManagerService.getFeatureFormulaDependency(e.unitId,e.subUnitId,t);this._getFeatureFormulaTreePro(t,n,e)})})})}_getFeatureFormulaTreePro(e,t,r){let{unitId:i,subUnitId:a,dependencyRanges:o,getDirtyData:s}=r,c=new n.FormulaDependencyTree(t||(0,n.generateRandomDependencyTreeId)(this._dependencyManagerService));c.unitId=i,c.subUnitId=a,c.rangeList=o,c.getDirtyData=s;let l=s(this._currentConfigService.getDirtyData(),this._runtimeService.getAllRuntimeData()),u=this._convertDirtyRangesToUnitRange(l.dirtyRanges);c.featureDirtyRanges=u,c.featureId=e,c.type=n.FormulaDependencyTreeType.FEATURE_FORMULA;let d=this._dependencyManagerService.getFeatureFormulaDependencyPro(r.unitId,r.subUnitId,e),f;return d===void 0&&(d=this._dependencyManagerService.addFeatureFormulaDependencyPro(i,a,e,c),f=d),u.length>0&&this._featureFormulaDirtyDependencies.push({node:this._dependencyManagerService.getFeatureFormulaDependencyNodePro(i,a,e),dirtyRanges:u}),this._cacheCalculationTree(d,c),this._releaseDependencyTree(c),f}async _registerOtherFormulasPro(e,t){for(let r of t){let t=e[r];if(t==null)continue;let i=Object.keys(t);for(let e of i){let i=t[e];if(i==null)continue;let{rowCount:a=1/0,columnCount:o=1/0}=this._currentConfigService.getSheetRowColumnCount(r,e)||{},s=Object.keys(i);for(let t of s){let s=this._dependencyManagerService.hasOtherFormulaDataMainData(t),{f:c,ranges:l}=i[t],u=!1;s&&(u=!0);let{firstRow:d,firstColumn:f}=this._getFirstCellOfRange(l),p=new n.FormulaDependencyTree((0,n.generateRandomDependencyTreeId)(this._dependencyManagerService));for(let i=0;i<l.length;i++){let s=l[i],{startRow:m,startColumn:h}=s,{endRow:g,endColumn:_}=s;g=Math.min(g,a-1),_=Math.min(_,o-1);for(let i=m;i<=g;i++)for(let a=h;a<=_;a++){let o=a-f,s=i-d,l=this._dependencyManagerService.getOtherFormulaDependencyPro(r,e,t,o,s);if(o===0&&s===0){p.formula=c,p.unitId=r,p.subUnitId=e,p.formulaId=t,p.type=n.FormulaDependencyTreeType.OTHER_FORMULA,p.isCache=u,p.node||await this._initialAstNodeAndRanges(p);let i=this._getFeatureFormulaDependencyNodes(p.rangeList);l===void 0?l=this._dependencyManagerService.addOtherFormulaDependencyPro(r,e,t,p,i):i.length>0&&(l=this._dependencyManagerService.addOtherFormulaDependencyPro(r,e,t,p,i,`merge`)),this._ensureTreeNodeForCalculation(p),this._cacheCalculationTree(l,p),this._syncForcedRecalculationNodeIndex(l,p);continue}let m=new n.FormulaDependencyTreeVirtual;m.treeId=(0,n.generateRandomDependencyTreeId)(this._dependencyManagerService),m.refTree=p,m.refOffsetX=o,m.refOffsetY=s,m.isCache=u,m.type=n.FormulaDependencyTreeType.OTHER_FORMULA;let h=this._getFeatureFormulaDependencyNodes(m.rangeList);l===void 0?l=this._dependencyManagerService.addOtherFormulaDependencyPro(r,e,t,m,h):h.length>0&&(l=this._dependencyManagerService.addOtherFormulaDependencyPro(r,e,t,m,h,`merge`)),this._cacheCalculationTree(l,m),this._syncForcedRecalculationNodeIndex(l,m),this._releaseDependencyTree(m)}}this._releaseDependencyTree(p)}}}}async _registerFormulasPro(e,t,r,i=o(t)){let a=this._createSharedFormulaGroupMap(i.groups),s=new Map,c=this._dependencyManagerService;for(let i of e){let e=t[i];if(e==null)continue;let o=Object.keys(e);for(let t of o){let o=new Map,l=[],u=e[t];if(u==null)continue;let d=Object.keys(u);for(let e of d){let n=Number.parseInt(e,10),d=u[n];if(d==null)continue;let f=Object.keys(d);for(let e of f){let u=Number.parseInt(e,10),f=d[u];if(f==null)continue;let{x:p=0,y:m=0,si:h}=f;if(!(p===0&&m===0&&h!=null))continue;let g=this._createFDtree(i,t,n,u,r,f),_=this._createSharedFormulaGroupId(i,t,h),v=a.get(_),y=(v==null?void 0:v.mode)===`candidate`?await this._analyzeSharedFormulaCompression(g,v):void 0,b=c.getFormulaDependencyPro(i,t,n,u);if((y==null?void 0:y.mode)===`compressed`)b=c.addFormulaDependencyNodeOnlyPro(i,t,n,u),s.set(_,y),l.push(y);else if((y==null?void 0:y.mode)===`expanded`&&(s.set(_,y),this._recordExpandedSharedFormulaGroupMetrics(y)),b===void 0){g.node||await this._initialAstNodeAndRanges(g);let e=this._getFeatureFormulaDependencyNodes(g.rangeList);b=c.addFormulaDependencyPro(i,t,n,u,g,e)}else{await this._ensureTreeInitializedForFeatureDependencies(g);let e=this._getFeatureFormulaDependencyNodes(g.rangeList);e.length>0&&(b=c.addFormulaDependencyPro(i,t,n,u,g,e,`merge`))}this._ensureTreeNodeForCalculation(g),o.set(h,g),this._cacheCalculationTree(b,g),this._syncForcedRecalculationNodeIndex(b,g)}}for(let e of d){let a=Number.parseInt(e,10),l=u[a];if(l==null)continue;let d=Object.keys(l);for(let e of d){let u=Number.parseInt(e,10),d=l[u];if(d==null)continue;let{x:f=0,y:p=0,si:m}=d;if(f===0&&p===0&&m!=null)continue;let h=c.getFormulaDependencyPro(i,t,a,u),g=m==null?void 0:this._createSharedFormulaGroupId(i,t,m),_=g==null?void 0:s.get(g);if((_==null?void 0:_.mode)===`compressed`&&m!=null&&o.has(m)){h=c.addFormulaDependencyNodeOnlyPro(i,t,a,u);let e=o.get(m),{x:n=0,y:r=0}=d;this._cacheCompressedVirtualCalculationTree(h,e,n,r),this._syncCompressedVirtualForcedRecalculationNodeIndex(h,e);continue}let v;if(m!=null&&o.has(m)){let e=o.get(m);v=this._createVirtualFDtree(e,d)}else v=this._createFDtree(i,t,a,u,r,d);if(h===void 0){!v.isVirtual&&!v.node&&await this._initialAstNodeAndRanges(v);let e=this._getFeatureFormulaDependencyNodes(v.rangeList);h=c.addFormulaDependencyPro(i,t,a,u,v,e)}else{await this._ensureTreeInitializedForFeatureDependencies(v);let e=this._getFeatureFormulaDependencyNodes(v.rangeList);e.length>0&&(h=c.addFormulaDependencyPro(i,t,a,u,v,e,`merge`))}this._cacheCalculationTree(h,v),this._syncForcedRecalculationNodeIndex(h,v),v instanceof n.FormulaDependencyTreeVirtual?this._releaseDependencyTree(v):m!=null&&o.has(m)||this._releaseDependencyTree(v)}}for(let e=0;e<l.length;e++){let t=l[e];t.patterns&&t.group.fillRange&&(c.registerCompressedSharedFormulaGroup({groupId:t.group.groupId,fillRange:t.group.fillRange,patterns:t.patterns}),this._recordCompressedSharedFormulaGroupMetrics(t))}o.forEach(e=>this._releaseDependencyTree(e)),o.clear()}}}_createSharedFormulaGroupMap(e){let t=new Map;for(let n=0;n<e.length;n++)t.set(e[n].groupId,e[n]);return t}_createSharedFormulaGroupId(e,t,n){return[e,t,String(n)].join(`\0`)}async _analyzeSharedFormulaCompression(e,t){if(t.fillRange==null)return{group:t,mode:`expanded`,fallbackReason:`non-rectangular-fill-range`};e.node||await this._initialAstNodeAndRanges(e);let n=this._getFeatureFormulaDependencyNodes(e.rangeList),r=this._getSharedFormulaUnsupportedReason(e,n.length);if(r)return{group:t,mode:`expanded`,fallbackReason:r};let i=this._convertSharedFormulaPatterns(e);return i==null||i.length===0?{group:t,mode:`expanded`,fallbackReason:`unsupported-range-pattern`}:this._hasSharedFormulaSelfOverlap(t.fillRange,i)?{group:t,mode:`expanded`,fallbackReason:`self-overlap`}:{group:t,mode:`compressed`,patterns:i}}_getSharedFormulaUnsupportedReason(e,t){if(e.addressFunctionNodes&&e.addressFunctionNodes.length>0)return`unsupported-dynamic-reference`;if(t>0||/\$/.test(e.formula))return`unsupported-range-pattern`}_convertSharedFormulaPatterns(e){let t=[],n=new Set,r=e.row,i=e.column;for(let a=0;a<e.rangeList.length;a++){let o=e.rangeList[a],s=this._normalizeSharedFormulaRange(o.range),c;c=s.startRow===s.endRow&&s.startColumn===s.endColumn?{kind:`cell`,unitId:o.unitId,sheetId:o.sheetId,rowDelta:s.startRow-r,colDelta:s.startColumn-i}:{kind:`range`,unitId:o.unitId,sheetId:o.sheetId,startRowDelta:s.startRow-r,startColDelta:s.startColumn-i,endRowDelta:s.endRow-r,endColDelta:s.endColumn-i};let l=JSON.stringify(c);n.has(l)||(n.add(l),t.push(c))}return t}_hasSharedFormulaSelfOverlap(e,n){for(let r=0;r<n.length;r++){let i=this._computeSharedFormulaSourceCoverage(e,n[r]);if(!(i.unitId!==e.unitId||i.sheetId!==e.sheetId)&&t.Rectangle.intersects(i.range,e.range))return!0}return!1}_computeSharedFormulaSourceCoverage(e,t){if(t.kind===`cell`)return{unitId:t.unitId,sheetId:t.sheetId,range:this._normalizeSharedFormulaRange({startRow:e.range.startRow+t.rowDelta,endRow:e.range.endRow+t.rowDelta,startColumn:e.range.startColumn+t.colDelta,endColumn:e.range.endColumn+t.colDelta})};let n=Math.min(t.startRowDelta,t.endRowDelta),r=Math.max(t.startRowDelta,t.endRowDelta),i=Math.min(t.startColDelta,t.endColDelta),a=Math.max(t.startColDelta,t.endColDelta);return{unitId:t.unitId,sheetId:t.sheetId,range:this._normalizeSharedFormulaRange({startRow:e.range.startRow+n,endRow:e.range.endRow+r,startColumn:e.range.startColumn+i,endColumn:e.range.endColumn+a})}}_normalizeSharedFormulaRange(e){return{startRow:Math.min(e.startRow,e.endRow),endRow:Math.max(e.startRow,e.endRow),startColumn:Math.min(e.startColumn,e.endColumn),endColumn:Math.max(e.startColumn,e.endColumn)}}_recordCompressedSharedFormulaGroupMetrics(e){e.mode!==`compressed`||e.patterns==null||(this._sharedFormulaCompressionMetrics.compressedSharedFormulaGroups++,this._sharedFormulaCompressionMetrics.totalVirtualFormulaNodesInCompressedGroups+=e.group.virtualFormulaCount,this._sharedFormulaCompressionMetrics.skippedExpandedDependencyRegistrationCount+=e.group.size*e.patterns.length,this._sharedFormulaCompressionMetrics.sharedPatternCount+=e.patterns.length,this._sharedFormulaCompressionMetrics.sharedSourceCoverageEntryCount+=e.patterns.length)}_recordExpandedSharedFormulaGroupMetrics(e){var t;e.mode!==`expanded`||e.fallbackReason==null||(this._sharedFormulaCompressionMetrics.expandedSharedFormulaGroups++,this._sharedFormulaCompressionMetrics.fallbackReasonCounts[e.fallbackReason]=((t=this._sharedFormulaCompressionMetrics.fallbackReasonCounts[e.fallbackReason])==null?0:t)+1)}async _markDirtyDependenciesPro(){let e=this._dependencyManagerService;if(this._currentConfigService.isForceCalculate()){e.markAllDirty();return}let t=this._currentConfigService.getDirtyRanges();t.length>0&&e.markRangesChanged(t,{includeFormulaCells:!0}),e.markDirtyFeatureCalculations(this._currentConfigService.getDirtyUnitFeatureMap()),e.markDirtyOtherFormulas(this._currentConfigService.getDirtyUnitOtherFormulaMap()),e.markDirtySheetNames(this._currentConfigService.getDirtyNameMap()),this._markForcedRecalculationNodesPro(e),await this._markDirtyDefinedNameDependenciesPro(e)}_markForcedRecalculationNodesPro(e){if(this._forcedRecalculationNodeIndices.size===0)return;let t=[];this._forcedRecalculationNodeIndices.forEach(e=>{t.push(e)}),e.markIndicesChanged(t)}async _markDirtyDefinedNameDependenciesPro(e){let t=this._currentConfigService.getDirtyDefinedNameMap();if(!this._hasDirtyDefinedNames(t))return;let n=[];for(let[e,t]of this._calculationTreeCache)t.formula&&t.formula.length>0&&this._includeDirtyDefinedNamePro(t.formula)&&n.push(e);n.length>0&&e.markIndicesChanged(n)}_cacheCalculationTree(e,t){let n={unitId:t.unitId,subUnitId:t.subUnitId,formula:t.formula,row:t.row,column:t.column,rowCount:t.rowCount,columnCount:t.columnCount,refOffsetX:t.refOffsetX,refOffsetY:t.refOffsetY,formulaId:t.formulaId,featureId:t.featureId,getDirtyData:t.getDirtyData,hasDynamicDeps:t.addressFunctionNodes.length>0,type:t.type};(t.addressFunctionNodes.length>0||this._cacheDependencyTreeModelRangeList)&&(n.rangeList=t.rangeList);let r=t.nodeData;(r==null?void 0:r.node)!=null&&this._calculationNodeDataCache.set(e,{node:r.node,refOffsetX:r.refOffsetX,refOffsetY:r.refOffsetY}),this._calculationTreeCache.set(e,n)}_cacheCompressedVirtualCalculationTree(e,t,n,r){this._calculationTreeCache.set(e,{unitId:t.unitId,subUnitId:t.subUnitId,formula:t.formula,row:t.row+r,column:t.column+n,rowCount:t.rowCount,columnCount:t.columnCount,refOffsetX:n,refOffsetY:r,formulaId:t.formulaId,featureId:t.featureId,getDirtyData:null,hasDynamicDeps:!1,type:t.type}),this._cacheDependencyTreeModelRangeList&&(this._calculationTreeCache.get(e).rangeList=this._getOffsetRangeList(t.rangeList,n,r)),t.node!=null&&this._calculationNodeDataCache.set(e,{node:t.node,refOffsetX:n,refOffsetY:r})}_getOffsetRangeList(e,t,n){return t===0&&n===0?e:e.map(e=>({unitId:e.unitId,sheetId:e.sheetId,range:{startRow:e.range.startRow+n,endRow:e.range.endRow+n,startColumn:e.range.startColumn+t,endColumn:e.range.endColumn+t}}))}_getAllDependencyJsonPro(e){let t=this._dependencyManagerService,n=[];for(let[a,o]of e){var r,i;let s=[],c=[];t.forEachPrecedentNodeByIndex(a,t=>{e.has(t)&&s.push(t)}),t.forEachDependentNodeByIndex(a,t=>{e.has(t)&&c.push(t)}),n.push({children:s,parents:c,treeId:a,formula:o.formula,row:o.row,column:o.column,unitId:o.unitId,subUnitId:o.subUnitId,refOffsetX:o.refOffsetX,refOffsetY:o.refOffsetY,rangeList:(r=o.rangeList)==null?[]:r,refTreeId:void 0,formulaId:o.formulaId,featureId:o.featureId,type:(i=o.type)==null?this._inferDependencyTreeTypePro(o):i})}return n}_inferDependencyTreeTypePro(e){return e.featureId==null?e.formulaId==null?n.FormulaDependencyTreeType.NORMAL_FORMULA:n.FormulaDependencyTreeType.OTHER_FORMULA:n.FormulaDependencyTreeType.FEATURE_FORMULA}_clearCalculationTreeCache(e,t){for(let[n,r]of this._calculationTreeCache)r.unitId===e&&r.subUnitId===t&&(this._calculationTreeCache.delete(n),this._calculationNodeDataCache.delete(n),this._forcedRecalculationNodeIndices.delete(n))}_releaseDependencyTree(e){if(e instanceof n.FormulaDependencyTreeVirtual){e.dispose();return}let t=e;t.dispose(),t.node=null}_hasDirtyDefinedNames(e){let t=Object.keys(e);for(let n=0;n<t.length;n++){let r=e[t[n]];if(r!=null&&Object.keys(r).length>0)return!0}return!1}_syncForcedRecalculationNodeIndex(e,t){if(!t.formula){this._forcedRecalculationNodeIndices.delete(e);return}let n=t.nodeData.node;n&&this._detectForcedRecalculationNodePro(n)?this._forcedRecalculationNodeIndices.add(e):this._forcedRecalculationNodeIndices.delete(e)}_syncCompressedVirtualForcedRecalculationNodeIndex(e,t){t.node&&this._detectForcedRecalculationNodePro(t.node)?this._forcedRecalculationNodeIndices.add(e):this._forcedRecalculationNodeIndices.delete(e)}_detectForcedRecalculationNodePro(e){if(e.isForcedCalculateFunction())return!0;let t=e.getChildren();for(let e=0;e<t.length;e++)if(this._detectForcedRecalculationNodePro(t[e]))return!0;return!1}_includeDirtyDefinedNamePro(e){let t=this._currentConfigService.getExecuteUnitId();if(t==null)return!1;let n=this._currentConfigService.getDirtyDefinedNameMap()[t];if(n==null)return!1;let r=Object.keys(n);for(let t=0;t<r.length;t++)if(e.indexOf(r[t])>-1)return!0;return!1}async _ensureTreeInitializedForFeatureDependencies(e){if(this._featureFormulaDirtyDependencies.length===0||e.isVirtual)return;let t=e;t.node||await this._initialAstNodeAndRanges(t)}_ensureTreeNodeForCalculation(e){if(e.node||this._lexer==null||this._astTreeBuilder==null)return;let{unitId:t,formula:r}=e;e.node=(0,n.generateAstNode)(t,r,this._lexer,this._astTreeBuilder,this._currentConfigService),e.addressFunctionNodes=this._getAddressFunctionNodeList(e.node)}_getFeatureFormulaDependencyNodes(e){if(this._featureFormulaDirtyDependencies.length===0||e.length===0)return[];let t=[];for(let n=0;n<this._featureFormulaDirtyDependencies.length;n++){let r=this._featureFormulaDirtyDependencies[n];this._rangesIntersectAny(e,r.dirtyRanges)&&t.push(r.node)}return t}_rangesIntersectAny(e,n){for(let r=0;r<e.length;r++){let i=e[r];for(let e=0;e<n.length;e++){let r=n[e];if(i.unitId===r.unitId&&i.sheetId===r.sheetId&&t.Rectangle.intersects(i.range,r.range))return!0}}return!1}async _initialAstNodeAndRanges(e){let{unitId:t,formula:r}=e,i=(0,n.generateAstNode)(t,r,this._lexer,this._astTreeBuilder,this._currentConfigService);e.node=i,e.addressFunctionNodes=this._getAddressFunctionNodeList(i),this._runtimeService.setCurrent(e.row,e.column,e.rowCount,e.columnCount,e.subUnitId,e.unitId);let a=await this._getRangeListByNode({node:i,refOffsetX:e.refOffsetX,refOffsetY:e.refOffsetY});e.pushRangeList(a)}_createFDtree(e,t,r,i,a,o){let{f:s}=o,c=new n.FormulaDependencyTree((0,n.generateRandomDependencyTreeId)(this._dependencyManagerService)),l=a[e][t];return c.formula=s,c.unitId=e,c.subUnitId=t,c.row=r,c.column=i,c.rowCount=l.rowCount,c.columnCount=l.columnCount,c}},T=class extends n.CalculateFormulaService{constructor(...e){super(...e),C(this,`_dynamicRuntimeRanges`,void 0)}async execute(e){this._runtimeService.setFormulaExecuteStage(n.FormulaExecuteStageType.START),this._executionInProgressListener$.next(this._runtimeService.getRuntimeState()),this._currentConfigService.load(e),this._runtimeService.reset();let t=e.maxIteration||n.DEFAULT_CYCLE_REFERENCE_COUNT;this._isCalculateTreeModel=e.isCalculateTreeModel||!1,this._executeLock.acquire(`FORMULA_EXECUTION_LOCK`,async()=>{await this._executeStep(t),this._runtimeService.setFormulaExecuteStage(n.FormulaExecuteStageType.CALCULATION_COMPLETED),this._executionInProgressListener$.next(this._runtimeService.getRuntimeState()),this._executionCompleteListener$.next(this._runtimeService.getAllRuntimeData()),n.CELL_INVERTED_INDEX_CACHE.clear(),this._runtimeService.reset()})}async _executeStep(e=n.DEFAULT_CYCLE_REFERENCE_COUNT){let t=await this._apply(!1,e);if(t==null)return;let{arrayFormulaRange:r}=t,{dirtyRanges:i,excludedCell:a}=this._getArrayFormulaDirtyRangeAndExcludedRange(r,{});return i==null||i.length===0?!0:(n.FORMULA_REF_TO_ARRAY_CACHE.clear(),this._currentConfigService.loadDirtyRangesAndExcludedCell(i,a),await this._apply(!0,e),!0)}async _apply(e=!1,t=n.DEFAULT_CYCLE_REFERENCE_COUNT){e?this._runtimeService.setFormulaExecuteStage(n.FormulaExecuteStageType.START_DEPENDENCY_ARRAY_FORMULA):this._runtimeService.setFormulaExecuteStage(n.FormulaExecuteStageType.START_DEPENDENCY),this._executionInProgressListener$.next(this._runtimeService.getRuntimeState());let r=this._configService.getConfig(n.ENGINE_FORMULA_PLUGIN_CONFIG_KEY),i=(r==null?void 0:r.intervalCount)||n.DEFAULT_INTERVAL_COUNT,a=this._formulaDependencyGenerator;try{let{calculationOrderResult:r,dependencyTree:o}=await a.generatePro(this._isCalculateTreeModel),s=this._getCalculationPlanTreeCount(r,o,t);r.hasCycle&&this._runtimeService.enableCycleDependency(),e?(this._runtimeService.setFormulaExecuteStage(n.FormulaExecuteStageType.START_CALCULATION_ARRAY_FORMULA),this._runtimeService.setTotalArrayFormulasToCalculate(s)):(this._runtimeService.setFormulaExecuteStage(n.FormulaExecuteStageType.START_CALCULATION),this._runtimeService.setTotalFormulasToCalculate(s)),this._executionInProgressListener$.next(this._runtimeService.getRuntimeState());let c=[],l=[],u=new Set,d=!1,f=0,p=0;for(this._runtimeService.setFormulaCycleIndex(0);;){let n=!1;if(await this._forEachCalculationPlanTree(r,o,t,async(t,r,o)=>{if(this._runtimeService.setFormulaCycleIndex(o==null?0:o),await this._waitForExecutionSlot(f,i,e,t,c))return d=!0,!1;await this._calculateDependencyTree(t,r,a)&&this._shouldRescheduleAfterDynamicChange(a,r,u)&&(n=!0),u.has(r)||(u.add(r),l.push(r)),f++}),r.calculationForest.length=0,d||!n)break;if(p++,p>8)throw Error(`Dynamic dependency did not stabilize`);r=a.getCalculationOrder(),r.hasCycle&&this._runtimeService.enableCycleDependency(),s=this._getCalculationPlanTreeCount(r,o,t),e?this._runtimeService.setTotalArrayFormulasToCalculate(s):this._runtimeService.setTotalFormulasToCalculate(s)}for(let e=0;e<c.length;e++)c[e]();return l.length>0&&a.clearCalculatedDirty(l),d?void 0:(s>0||l.length>0?this._runtimeService.markedAsSuccessfullyExecuted():e||this._runtimeService.markedAsNoFunctionsExecuted(),this._runtimeService.getAllRuntimeData())}finally{a.clearCachedCalculationNodeData(),a.clearCachedCalculationTree(),this._dynamicRuntimeRanges=void 0}}_shouldRescheduleAfterDynamicChange(e,t,n){let r=e;return typeof r.hasUncalculatedDirtyPrecedentByIndex==`function`?r.hasUncalculatedDirtyPrecedentByIndex(t,n):!0}async _forEachCalculationPlanTree(e,t,r,i){let a=Math.max(r,1);for(let r=0;r<e.calculationForest.length;r++){let o=e.calculationForest[r];for(let e=0;e<o.plan.length;e++){let r=o.plan[e];if(r.type===`node`){let e=t.get(r.nodeIndex);if(e!=null&&await i(e,r.nodeIndex)===!1)return;continue}if(r.type===`nodes`){for(let e=0;e<r.nodeIndices.length;e++){let n=r.nodeIndices[e],a=t.get(n);if(a!=null&&await i(a,n)===!1)return}r.nodeIndices.length=0;continue}for(let e=0;e<a;e++){e>0&&n.FORMULA_REF_TO_ARRAY_CACHE.clear();for(let n=0;n<r.nodeIndices.length;n++){let a=r.nodeIndices[n],o=t.get(a);if(o!=null&&await i(o,a,e)===!1)return}}}}}_getCalculationPlanTreeCount(e,t,n){let r=Math.max(n,1),i=0;for(let n=0;n<e.calculationForest.length;n++){let a=e.calculationForest[n];for(let e=0;e<a.plan.length;e++){let n=a.plan[e];if(n.type===`node`){t.has(n.nodeIndex)&&i++;continue}if(n.type===`nodes`){for(let e=0;e<n.nodeIndices.length;e++)t.has(n.nodeIndices[e])&&i++;continue}let o=0;for(let e=0;e<n.nodeIndices.length;e++)t.has(n.nodeIndices[e])&&o++;i+=o*r}}return i}_getDynamicResolver(){let e=this._dynamicRuntimeRanges;if(e==null)return;let t=e.map(e=>this._getRangeSignature(e)).sort().join(`|`);return()=>({signature:t,ranges:e,status:e.length>0?`resolved`:`unknown`})}_refreshDynamicDepsAfterCalculate(e,t,n,r){if(n.hasDynamicDeps===!1||!e.hasDynamicDepsByIndex(t))return!1;let i=this._collectAddressFunctionRuntimeRanges(r);if(i.length===0)return!1;this._dynamicRuntimeRanges=i;try{let n=this._getDynamicResolver();return n==null?!1:e.refreshDynamicDepsByIndex(t,n)}finally{this._dynamicRuntimeRanges=void 0}}_collectAddressFunctionRuntimeRanges(e){let t=[];return this._collectAddressFunctionRuntimeRangesInternal(e,t),t}_collectAddressFunctionRuntimeRangesInternal(e,t){if(e.isAddress()){let n=e.getValue();n!=null&&n.isReferenceObject()&&t.push(n.toUnitRange())}let n=e.getChildren();for(let e=0;e<n.length;e++)this._collectAddressFunctionRuntimeRangesInternal(n[e],t)}_getRangeSignature(e){return[e.unitId,e.sheetId,e.range.startRow,e.range.endRow,e.range.startColumn,e.range.endColumn].join(`:`)}async _waitForExecutionSlot(e,r,i,a,o){return e%r===0?(await new Promise(e=>{let n=(0,t.requestImmediateMacroTask)(e);o.push(n)}),i?(this._runtimeService.setFormulaExecuteStage(n.FormulaExecuteStageType.CURRENTLY_CALCULATING_ARRAY_FORMULA),this._runtimeService.setCompletedArrayFormulasCount(e+1)):(this._runtimeService.setFormulaExecuteStage(n.FormulaExecuteStageType.CURRENTLY_CALCULATING),this._runtimeService.setCompletedFormulasCount(e+1)),this._executionInProgressListener$.next(this._runtimeService.getRuntimeState()),this._runtimeService.isStopExecution()||a.formula==null&&a.getDirtyData==null?(this._runtimeService.setFormulaExecuteStage(n.FormulaExecuteStageType.IDLE),this._runtimeService.markedAsStopFunctionsExecuted(),this._executionCompleteListener$.next(this._runtimeService.getAllRuntimeData()),!0):!1):!1}async _calculateDependencyTree(e,t,n){let r=e.getDirtyData;if(this._runtimeService.setCurrent(e.row,e.column,e.rowCount,e.columnCount,e.subUnitId,e.unitId),r!=null&&e.featureId!=null){let t=e.featureId,{runtimeCellData:n,dirtyRanges:i}=r(this._currentConfigService.getDirtyData(),this._runtimeService.getAllRuntimeData());return this._runtimeService.setRuntimeFeatureCellData(t,n),this._runtimeService.setRuntimeFeatureRange(t,i),!1}let i=this._getCalculationNodeData(e,t,n),a=i.node,o;try{return o=this._interpreter.checkAsyncNode(i.node)?await this._interpreter.executeAsync(i):this._interpreter.execute(i),e.formulaId==null?this._runtimeService.setRuntimeData(o):this._runtimeService.setRuntimeOtherData(e.formulaId,e.refOffsetX,e.refOffsetY,o),this._refreshDynamicDepsAfterCalculate(n,t,e,a)}finally{a.resetCalculationState()}}_getCalculationNodeData(e,t,r){let i=r.getCachedCalculationNodeData(t);return(i==null?void 0:i.node)==null?{node:(0,n.generateAstNode)(e.unitId,e.formula,this._lexer,this._astTreeBuilder,this._currentConfigService),refOffsetX:e.refOffsetX,refOffsetY:e.refOffsetY}:i}},E=class{constructor(e,t){C(this,`maxRows`,void 0),C(this,`maxCols`,void 0),C(this,`sheetSize`,void 0),C(this,`_sheetKeyById`,new Map),C(this,`_sheetIdByKey`,[]),this.maxRows=e,this.maxCols=t,this.sheetSize=e*t}reset(){this._sheetKeyById.clear(),this._sheetIdByKey.length=0}encodeCell(e,t,n,r){return this.encodeSheet(e,t)*this.sheetSize+n*this.maxCols+r}decodeCell(e){let t=Math.floor(e/this.sheetSize),n=e-t*this.sheetSize,r=Math.floor(n/this.maxCols),i=n-r*this.maxCols,{unitId:a,sheetId:o}=this.decodeSheetKey(t);return{unitId:a,sheetId:o,row:r,col:i}}encodeSheet(e,t){let n=`${e}\0${t}`,r=this._sheetKeyById.get(n);if(r!==void 0)return r;let i=this._sheetIdByKey.length;return this._sheetKeyById.set(n,i),this._sheetIdByKey.push({unitId:e,sheetId:t}),i}decodeSheetKey(e){let t=this._sheetIdByKey[e];if(!t)throw Error(`Unknown sheet key: ${e}`);return t}encodeRow(e,t,n){return this.encodeSheet(e,t)*this.maxRows+n}encodeRowBySheetKey(e,t){return e*this.maxRows+t}decodeRowKey(e){let t=Math.floor(e/this.maxRows),n=e-t*this.maxRows;return{sheetKey:t,...this.decodeSheetKey(t),row:n}}encodeCol(e,t,n){return this.encodeSheet(e,t)*this.maxCols+n}encodeColBySheetKey(e,t){return e*this.maxCols+t}decodeColKey(e){let t=Math.floor(e/this.maxCols),n=e-t*this.maxCols;return{sheetKey:t,...this.decodeSheetKey(t),col:n}}};function D(e){if(typeof e!=`number`)throw TypeError(`CellFormula node id must be a numeric CellId`)}function O(e){let{startRow:t,endRow:n,startColumn:r,endColumn:i}=e.range;if(t<=n&&r<=i)return e;let a=t<n?t:n,o=t<n?n:t,s=r<i?r:i,c=r<i?i:r;return{...e,range:{...e.range,startRow:a,endRow:o,startColumn:s,endColumn:c}}}function k(e){return e.range.endRow-e.range.startRow+1}function A(e){return e.range.endColumn-e.range.startColumn+1}function j(e,t){return e.unitId===t.unitId&&e.sheetId===t.sheetId&&e.range.startRow<=t.row&&t.row<=e.range.endRow&&e.range.startColumn<=t.col&&t.col<=e.range.endColumn}function M(e){if(!e||e.length===0)return[];if(e.length===1)return[e[0]];let t=e.slice().sort((e,t)=>e-t),n=1;for(let e=1;e<t.length;e++)t[e]!==t[n-1]&&(t[n++]=t[e]);return t.length=n,t}function N(e,t,n){let r=e.get(t);r||(r=[],e.set(t,r)),r.push(n)}function P(e,t){let n=e.indexOf(t);if(n<0)return!1;let r=e.pop();return n<e.length&&(e[n]=r),!0}function F(e,t,n){let r=e.get(t);r&&(P(r,n),r.length===0&&e.delete(t))}function I(e,t){if(e===void 0)return t;if(typeof e==`number`)return e===t?e:[e,t];for(let n=0;n<e.length;n++)if(e[n]===t)return e;return e.push(t),e}function L(e,t){if(e===void 0)return;if(typeof e==`number`)return e===t?void 0:e;let n=e.indexOf(t);if(n<0)return e;if(e.length===1)return;if(e.length===2)return e[1-n];let r=e.pop();return n<e.length&&(e[n]=r),e}function R(e,t){if(e!==void 0){if(typeof e==`number`){t(e);return}for(let n=0;n<e.length;n++)t(e[n])}}function z(e,t,n){let r=I(e.get(t),n);e.set(t,r)}function B(e,t,n){let r=e.get(t);if(r===void 0)return;let i=L(r,n);i===void 0?e.delete(t):e.set(t,i)}function V(e,t){if(e.length>=t)return e;let n=Math.max(16,e.length);for(;n<t;)n*=2;let r=new Uint8Array(n);return r.set(e),r}function H(e,t){if(e.length>=t)return e;let n=Math.max(16,e.length);for(;n<t;)n*=2;let r=new Uint32Array(n);return r.set(e),r}function U(e){if(!e||e.length===0)return[];let t=new Set,n=[];for(let r=0;r<e.length;r++){let i=e[r],a=`${i.type}:${String(i.id)}`;t.has(a)||(t.add(a),n.push(i))}return n}function W(e){if(e.length<=1){let t=Array(e.length);for(let n=0;n<e.length;n++)t[n]=O(e[n]);return t}let t=Array(e.length);for(let n=0;n<e.length;n++)t[n]=O(e[n]);return K(G(t))}function G(e){let t=e.slice().sort((e,t)=>{let n=e.unitId.localeCompare(t.unitId);if(n!==0)return n;let r=e.sheetId.localeCompare(t.sheetId);return r===0?e.range.startRow===t.range.startRow?e.range.endRow===t.range.endRow?e.range.startColumn===t.range.startColumn?e.range.endColumn-t.range.endColumn:e.range.startColumn-t.range.startColumn:e.range.endRow-t.range.endRow:e.range.startRow-t.range.startRow:r}),n=[];for(let e of t){let t=n[n.length-1];t&&t.unitId===e.unitId&&t.sheetId===e.sheetId&&t.range.startRow===e.range.startRow&&t.range.endRow===e.range.endRow&&e.range.startColumn<=t.range.endColumn+1?e.range.endColumn>t.range.endColumn&&(t.range.endColumn=e.range.endColumn):n.push({...e,range:{...e.range}})}return n}function K(e){let t=e.slice().sort((e,t)=>{let n=e.unitId.localeCompare(t.unitId);if(n!==0)return n;let r=e.sheetId.localeCompare(t.sheetId);return r===0?e.range.startColumn===t.range.startColumn?e.range.endColumn===t.range.endColumn?e.range.startRow===t.range.startRow?e.range.endRow-t.range.endRow:e.range.startRow-t.range.startRow:e.range.endColumn-t.range.endColumn:e.range.startColumn-t.range.startColumn:r}),n=[];for(let e of t){let t=n[n.length-1];t&&t.unitId===e.unitId&&t.sheetId===e.sheetId&&t.range.startColumn===e.range.startColumn&&t.range.endColumn===e.range.endColumn&&e.range.startRow<=t.range.endRow+1?e.range.endRow>t.range.endRow&&(t.range.endRow=e.range.endRow):n.push({...e,range:{...e.range}})}return n}var q=class{constructor(e,t){this._codec=e,this._indexToNodeId=t,C(this,`_rowBuckets`,new Map),C(this,`_colBuckets`,new Map)}addFormulaCell(e,t){let n=this._codec.decodeCell(e);N(this._rowBuckets,this._codec.encodeRow(n.unitId,n.sheetId,n.row),t),N(this._colBuckets,this._codec.encodeCol(n.unitId,n.sheetId,n.col),t)}removeFormulaCell(e,t){let n=this._codec.decodeCell(e);F(this._rowBuckets,this._codec.encodeRow(n.unitId,n.sheetId,n.row),t),F(this._colBuckets,this._codec.encodeCol(n.unitId,n.sheetId,n.col),t)}forEachFormulaInRange(e,t){let n=O(e);return k(n)<=A(n)?this._scanRows(n,t):this._scanCols(n,t)}_scanRows(e,t){if(k(e)<=this._rowBuckets.size){for(let n=e.range.startRow;n<=e.range.endRow;n++)if(this._scanRowBucket(this._codec.encodeRow(e.unitId,e.sheetId,n),e,t)===!1)return!1;return!0}for(let[n]of this._rowBuckets){let r=this._codec.decodeRowKey(n);if(r.unitId===e.unitId&&r.sheetId===e.sheetId&&e.range.startRow<=r.row&&r.row<=e.range.endRow&&this._scanRowBucket(n,e,t)===!1)return!1}return!0}_scanCols(e,t){if(A(e)<=this._colBuckets.size){for(let n=e.range.startColumn;n<=e.range.endColumn;n++)if(this._scanColBucket(this._codec.encodeCol(e.unitId,e.sheetId,n),e,t)===!1)return!1;return!0}for(let[n]of this._colBuckets){let r=this._codec.decodeColKey(n);if(r.unitId===e.unitId&&r.sheetId===e.sheetId&&e.range.startColumn<=r.col&&r.col<=e.range.endColumn&&this._scanColBucket(n,e,t)===!1)return!1}return!0}_scanRowBucket(e,t,n){let r=this._rowBuckets.get(e);if(!r)return!0;for(let e=0;e<r.length;e++){let i=r[e],a=this._indexToNodeId[i],o=this._codec.decodeCell(a);if(o.unitId===t.unitId&&o.sheetId===t.sheetId&&t.range.startColumn<=o.col&&o.col<=t.range.endColumn&&n(i)===!1)return!1}return!0}_scanColBucket(e,t,n){let r=this._colBuckets.get(e);if(!r)return!0;for(let e=0;e<r.length;e++){let i=r[e],a=this._indexToNodeId[i],o=this._codec.decodeCell(a);if(o.unitId===t.unitId&&o.sheetId===t.sheetId&&t.range.startRow<=o.row&&o.row<=t.range.endRow&&n(i)===!1)return!1}return!0}},J=class{constructor(e,t){this._codec=e,this._pointScanCellLimit=t,C(this,`_rowCells`,new Map),C(this,`_colCells`,new Map)}add(e){let t=this._codec.decodeCell(e);N(this._rowCells,this._codec.encodeRow(t.unitId,t.sheetId,t.row),e),N(this._colCells,this._codec.encodeCol(t.unitId,t.sheetId,t.col),e)}remove(e){let t=this._codec.decodeCell(e);F(this._rowCells,this._codec.encodeRow(t.unitId,t.sheetId,t.row),e),F(this._colCells,this._codec.encodeCol(t.unitId,t.sheetId,t.col),e)}forEachCellInRange(e,t){let n=O(e),r=k(n),i=A(n);if(this._isSmallArea(r,i)){for(let e=n.range.startRow;e<=n.range.endRow;e++)for(let r=n.range.startColumn;r<=n.range.endColumn;r++)t(this._codec.encodeCell(n.unitId,n.sheetId,e,r));return}Math.min(r,this._rowCells.size)<=Math.min(i,this._colCells.size)?this._scanRows(n,t):this._scanCols(n,t)}_isSmallArea(e,t){return e<=0||t<=0?!0:e>this._pointScanCellLimit?!1:e*t<=this._pointScanCellLimit}_scanRows(e,t){if(k(e)<=this._rowCells.size){for(let n=e.range.startRow;n<=e.range.endRow;n++)this._scanRowBucket(this._codec.encodeRow(e.unitId,e.sheetId,n),e,t);return}for(let[n]of this._rowCells){let r=this._codec.decodeRowKey(n);r.unitId===e.unitId&&r.sheetId===e.sheetId&&e.range.startRow<=r.row&&r.row<=e.range.endRow&&this._scanRowBucket(n,e,t)}}_scanCols(e,t){if(A(e)<=this._colCells.size){for(let n=e.range.startColumn;n<=e.range.endColumn;n++)this._scanColBucket(this._codec.encodeCol(e.unitId,e.sheetId,n),e,t);return}for(let[n]of this._colCells){let r=this._codec.decodeColKey(n);r.unitId===e.unitId&&r.sheetId===e.sheetId&&e.range.startColumn<=r.col&&r.col<=e.range.endColumn&&this._scanColBucket(n,e,t)}}_scanRowBucket(e,t,n){let r=this._rowCells.get(e);if(r)for(let e=0;e<r.length;e++){let i=r[e],a=this._codec.decodeCell(i);a.unitId===t.unitId&&a.sheetId===t.sheetId&&t.range.startColumn<=a.col&&a.col<=t.range.endColumn&&n(i)}}_scanColBucket(e,t,n){let r=this._colCells.get(e);if(r)for(let e=0;e<r.length;e++){let i=r[e],a=this._codec.decodeCell(i);a.unitId===t.unitId&&a.sheetId===t.sheetId&&t.range.startRow<=a.row&&a.row<=t.range.endRow&&n(i)}}},Y=class{constructor(e,t,n){this._codec=e,this._maxIndexedSpan=n,C(this,`_wholeSheet`,new Map),C(this,`_wholeCol`,new Map),C(this,`_wholeRow`,new Map),C(this,`_rowBuckets`,new Map),C(this,`_colBuckets`,new Map),C(this,`_largeRangeIds`,[]),C(this,`_sheetArr`,void 0),C(this,`_startRowArr`,void 0),C(this,`_endRowArr`,void 0),C(this,`_startColArr`,void 0),C(this,`_endColArr`,void 0),C(this,`_nodeArr`,void 0),C(this,`_kindArr`,void 0),C(this,`_activeArr`,void 0),C(this,`_rangeSeenEpochArr`,void 0),C(this,`_rangeEpoch`,1),C(this,`_nextRangeId`,0),C(this,`_freeRangeIds`,[]),C(this,`_nodeToRangeIds`,new Map),C(this,`_nodeToWholeSheetKeys`,new Map),C(this,`_nodeToWholeColKeys`,new Map),C(this,`_nodeToWholeRowKeys`,new Map);let r=Math.max(16,t);this._sheetArr=new Uint32Array(r),this._startRowArr=new Uint32Array(r),this._endRowArr=new Uint32Array(r),this._startColArr=new Uint32Array(r),this._endColArr=new Uint32Array(r),this._nodeArr=new Uint32Array(r),this._kindArr=new Uint8Array(r),this._activeArr=new Uint8Array(r),this._rangeSeenEpochArr=new Uint32Array(r)}addRange(e,t){let n=O(t),r=this._codec.encodeSheet(n.unitId,n.sheetId),i=k(n),a=A(n),o=a===this._codec.maxCols,s=i===this._codec.maxRows;if(o&&s){z(this._wholeSheet,r,e),N(this._nodeToWholeSheetKeys,e,r);return}if(s){for(let t=n.range.startColumn;t<=n.range.endColumn;t++){let n=this._codec.encodeColBySheetKey(r,t);z(this._wholeCol,n,e),N(this._nodeToWholeColKeys,e,n)}return}if(o){for(let t=n.range.startRow;t<=n.range.endRow;t++){let n=this._codec.encodeRowBySheetKey(r,t);z(this._wholeRow,n,e),N(this._nodeToWholeRowKeys,e,n)}return}let c=Math.min(i,a),l=this._allocRangeId();if(this._setRangeMeta(l,e,n),c>this._maxIndexedSpan)this._kindArr[l]=3,this._largeRangeIds.push(l);else if(i<=a){this._kindArr[l]=1;for(let e=n.range.startRow;e<=n.range.endRow;e++)N(this._rowBuckets,this._codec.encodeRowBySheetKey(r,e),l)}else{this._kindArr[l]=2;for(let e=n.range.startColumn;e<=n.range.endColumn;e++)N(this._colBuckets,this._codec.encodeColBySheetKey(r,e),l)}N(this._nodeToRangeIds,e,l)}removeNode(e){let t=this._nodeToWholeSheetKeys.get(e);if(t){for(let n=0;n<t.length;n++)B(this._wholeSheet,t[n],e);this._nodeToWholeSheetKeys.delete(e)}let n=this._nodeToWholeColKeys.get(e);if(n){for(let t=0;t<n.length;t++)B(this._wholeCol,n[t],e);this._nodeToWholeColKeys.delete(e)}let r=this._nodeToWholeRowKeys.get(e);if(r){for(let t=0;t<r.length;t++)B(this._wholeRow,r[t],e);this._nodeToWholeRowKeys.delete(e)}let i=this._nodeToRangeIds.get(e);if(i){for(let e=0;e<i.length;e++)this._removeRangeId(i[e]);this._nodeToRangeIds.delete(e)}}forEachPoint(e,t,n,r,i){let a=this._codec.encodeSheet(e,t);R(this._wholeSheet.get(a),i),R(this._wholeCol.get(this._codec.encodeColBySheetKey(a,r)),i),R(this._wholeRow.get(this._codec.encodeRowBySheetKey(a,n)),i);let o=this._rowBuckets.get(this._codec.encodeRowBySheetKey(a,n));if(o)for(let e=0;e<o.length;e++){let t=o[e];this._activeArr[t]&&this._rangeContainsPoint(t,a,n,r)&&i(this._nodeArr[t])}let s=this._colBuckets.get(this._codec.encodeColBySheetKey(a,r));if(s)for(let e=0;e<s.length;e++){let t=s[e];this._activeArr[t]&&this._rangeContainsPoint(t,a,n,r)&&i(this._nodeArr[t])}for(let e=0;e<this._largeRangeIds.length;e++){let t=this._largeRangeIds[e];this._activeArr[t]&&this._rangeContainsPoint(t,a,n,r)&&i(this._nodeArr[t])}}forEachRangeIntersecting(e,t){this.forEachRangesIntersecting([e],t)}forEachRangesIntersecting(e,t){if(e.length===0)return;let n=Array(e.length);for(let t=0;t<e.length;t++)n[t]=O(e[t]);this._nextRangeEpoch();for(let e=0;e<n.length;e++){let r=n[e],i=this._codec.encodeSheet(r.unitId,r.sheetId);R(this._wholeSheet.get(i),t),this._scanWholeCols(r,i,t),this._scanWholeRows(r,i,t),this._scanRowIndexedRanges(r,i,t),this._scanColIndexedRanges(r,i,t);for(let e=0;e<this._largeRangeIds.length;e++){let n=this._largeRangeIds[e];this._activeArr[n]&&(this._wasRangeSeen(n)||this._rangeIntersectsInput(n,r,i)&&(this._markRangeSeen(n),t(this._nodeArr[n])))}}}_allocRangeId(){let e=this._freeRangeIds.pop();if(e!==void 0)return e;let t=this._nextRangeId++;return this._ensureRangeCapacity(t+1),t}_ensureRangeCapacity(e){this._sheetArr=H(this._sheetArr,e),this._startRowArr=H(this._startRowArr,e),this._endRowArr=H(this._endRowArr,e),this._startColArr=H(this._startColArr,e),this._endColArr=H(this._endColArr,e),this._nodeArr=H(this._nodeArr,e),this._kindArr=V(this._kindArr,e),this._activeArr=V(this._activeArr,e),this._rangeSeenEpochArr=H(this._rangeSeenEpochArr,e)}_setRangeMeta(e,t,n){this._sheetArr[e]=this._codec.encodeSheet(n.unitId,n.sheetId),this._startRowArr[e]=n.range.startRow,this._endRowArr[e]=n.range.endRow,this._startColArr[e]=n.range.startColumn,this._endColArr[e]=n.range.endColumn,this._nodeArr[e]=t,this._activeArr[e]=1}_removeRangeId(e){if(!this._activeArr[e])return;let t=this._kindArr[e],n=this._sheetArr[e];if(t===1)for(let t=this._startRowArr[e];t<=this._endRowArr[e];t++)F(this._rowBuckets,this._codec.encodeRowBySheetKey(n,t),e);else if(t===2)for(let t=this._startColArr[e];t<=this._endColArr[e];t++)F(this._colBuckets,this._codec.encodeColBySheetKey(n,t),e);else t===3&&P(this._largeRangeIds,e);this._activeArr[e]=0,this._kindArr[e]=0,this._freeRangeIds.push(e)}_nextRangeEpoch(){this._rangeEpoch++,this._rangeEpoch>=4294967295&&(this._rangeSeenEpochArr.fill(0),this._rangeEpoch=1)}_wasRangeSeen(e){return this._rangeSeenEpochArr[e]===this._rangeEpoch}_markRangeSeen(e){this._rangeSeenEpochArr[e]=this._rangeEpoch}_scanWholeCols(e,t,n){if(A(e)<=this._wholeCol.size){for(let r=e.range.startColumn;r<=e.range.endColumn;r++)R(this._wholeCol.get(this._codec.encodeColBySheetKey(t,r)),n);return}let r=this._codec.encodeColBySheetKey(t,e.range.startColumn),i=this._codec.encodeColBySheetKey(t,e.range.endColumn);for(let[e,t]of this._wholeCol)r<=e&&e<=i&&R(t,n)}_scanWholeRows(e,t,n){if(k(e)<=this._wholeRow.size){for(let r=e.range.startRow;r<=e.range.endRow;r++)R(this._wholeRow.get(this._codec.encodeRowBySheetKey(t,r)),n);return}let r=this._codec.encodeRowBySheetKey(t,e.range.startRow),i=this._codec.encodeRowBySheetKey(t,e.range.endRow);for(let[e,t]of this._wholeRow)r<=e&&e<=i&&R(t,n)}_scanRowIndexedRanges(e,t,n){if(k(e)<=this._rowBuckets.size){for(let r=e.range.startRow;r<=e.range.endRow;r++)this._scanRangeIdBucket(this._rowBuckets.get(this._codec.encodeRowBySheetKey(t,r)),e,t,n);return}let r=this._codec.encodeRowBySheetKey(t,e.range.startRow),i=this._codec.encodeRowBySheetKey(t,e.range.endRow);for(let[a,o]of this._rowBuckets)r<=a&&a<=i&&this._scanRangeIdBucket(o,e,t,n)}_scanColIndexedRanges(e,t,n){if(A(e)<=this._colBuckets.size){for(let r=e.range.startColumn;r<=e.range.endColumn;r++)this._scanRangeIdBucket(this._colBuckets.get(this._codec.encodeColBySheetKey(t,r)),e,t,n);return}let r=this._codec.encodeColBySheetKey(t,e.range.startColumn),i=this._codec.encodeColBySheetKey(t,e.range.endColumn);for(let[a,o]of this._colBuckets)r<=a&&a<=i&&this._scanRangeIdBucket(o,e,t,n)}_scanRangeIdBucket(e,t,n,r){if(e)for(let i=0;i<e.length;i++){let a=e[i];this._activeArr[a]&&(this._wasRangeSeen(a)||this._rangeIntersectsInput(a,t,n)&&(this._markRangeSeen(a),r(this._nodeArr[a])))}}_rangeContainsPoint(e,t,n,r){return this._sheetArr[e]===t&&this._startRowArr[e]<=n&&n<=this._endRowArr[e]&&this._startColArr[e]<=r&&r<=this._endColArr[e]}_rangeIntersectsInput(e,t,n){return this._sheetArr[e]===n&&this._startRowArr[e]<=t.range.endRow&&this._endRowArr[e]>=t.range.startRow&&this._startColArr[e]<=t.range.endColumn&&this._endColArr[e]>=t.range.startColumn}},X=class{constructor(e){var t,n,r,i;C(this,`codec`,void 0),C(this,`_maxIndexedSpan`,void 0),C(this,`_pointScanCellLimit`,void 0),C(this,`_initialNodeCapacity`,void 0),C(this,`_initialRangeCapacity`,void 0),C(this,`directDeps`,void 0),C(this,`nodeDeps`,void 0),C(this,`rangeIndex`,void 0),C(this,`cellFormulaToIndex`,void 0),C(this,`otherFormulaToIndex`,void 0),C(this,`featureCalculationToIndex`,void 0),C(this,`indexToNodeId`,void 0),C(this,`dirty`,void 0),C(this,`inQueue`,void 0),C(this,`_indexToNodeType`,void 0),C(this,`_cellPrecedents`,void 0),C(this,`_rangePrecedents`,void 0),C(this,`_nodePrecedents`,void 0),C(this,`_dynamicDeps`,void 0),C(this,`_dynamicSignature`,void 0),C(this,`_runtimeDirectDeps`,void 0),C(this,`_runtimeNodeDeps`,void 0),C(this,`_runtimeRangeIndex`,void 0),C(this,`_runtimeCellPrecedents`,void 0),C(this,`_runtimeRangePrecedents`,void 0),C(this,`_runtimeNodePrecedents`,void 0),C(this,`_activeNode`,void 0),C(this,`_seenNodeEpoch`,void 0),C(this,`_visitNodeEpoch`,void 0),C(this,`_edgeSeenEpoch`,void 0),C(this,`_tarjanSeenEpoch`,void 0),C(this,`_tarjanIndexArr`,void 0),C(this,`_tarjanLowArr`,void 0),C(this,`_tarjanOnStack`,void 0),C(this,`_emitEpoch`,1),C(this,`_visitEpoch`,1),C(this,`_edgeEpoch`,1),C(this,`_tarjanEpoch`,1),C(this,`_propQueue`,[]),C(this,`_dirtyList`,[]),C(this,`_activeNodeCount`,0),C(this,`_dirtyNodeCount`,0),C(this,`_directPointIndex`,void 0),C(this,`_runtimeDirectPointIndex`,void 0),C(this,`_formulaCellIndex`,void 0),C(this,`_sharedFormulaGroups`,void 0),C(this,`_sharedFormulaGroupIndexById`,void 0),C(this,`_sharedFormulaMembershipByNode`,void 0),C(this,`_sharedFormulaSourceEntries`,void 0),C(this,`_sharedFormulaSourceRangeIndex`,void 0),this._maxIndexedSpan=(t=e.maxIndexedSpan)==null?4096:t,this._pointScanCellLimit=(n=e.pointScanCellLimit)==null?4096:n,this._initialNodeCapacity=Math.max(16,(r=e.initialNodeCapacity)==null?1024:r),this._initialRangeCapacity=Math.max(16,(i=e.initialRangeCapacity)==null?1024:i),this.codec=new E(e.maxRows,e.maxCols),this.reset()}reset(){this.codec.reset(),this.directDeps=new Map,this.nodeDeps=new Map,this.rangeIndex=new Y(this.codec,this._initialRangeCapacity,this._maxIndexedSpan),this._runtimeDirectDeps=new Map,this._runtimeNodeDeps=new Map,this._runtimeRangeIndex=new Y(this.codec,this._initialRangeCapacity,this._maxIndexedSpan),this.cellFormulaToIndex=new Map,this.otherFormulaToIndex=new Map,this.featureCalculationToIndex=new Map,this.indexToNodeId=[],this._indexToNodeType=new Uint8Array(this._initialNodeCapacity),this.dirty=new Uint8Array(this._initialNodeCapacity),this.inQueue=new Uint8Array(this._initialNodeCapacity),this._activeNode=new Uint8Array(this._initialNodeCapacity),this._cellPrecedents=[],this._rangePrecedents=[],this._nodePrecedents=[],this._dynamicDeps=[],this._dynamicSignature=[],this._runtimeCellPrecedents=[],this._runtimeRangePrecedents=[],this._runtimeNodePrecedents=[],this._seenNodeEpoch=new Uint32Array(this._initialNodeCapacity),this._visitNodeEpoch=new Uint32Array(this._initialNodeCapacity),this._edgeSeenEpoch=new Uint32Array(this._initialNodeCapacity),this._tarjanSeenEpoch=new Uint32Array(this._initialNodeCapacity),this._tarjanIndexArr=new Uint32Array(this._initialNodeCapacity),this._tarjanLowArr=new Uint32Array(this._initialNodeCapacity),this._tarjanOnStack=new Uint8Array(this._initialNodeCapacity),this._emitEpoch=1,this._visitEpoch=1,this._edgeEpoch=1,this._tarjanEpoch=1,this._propQueue.length=0,this._dirtyList.length=0,this._activeNodeCount=0,this._dirtyNodeCount=0,this._directPointIndex=new J(this.codec,this._pointScanCellLimit),this._runtimeDirectPointIndex=new J(this.codec,this._pointScanCellLimit),this._formulaCellIndex=new q(this.codec,this.indexToNodeId),this._sharedFormulaGroups=[],this._sharedFormulaGroupIndexById=new Map,this._sharedFormulaMembershipByNode=new Int32Array(this._initialNodeCapacity),this._sharedFormulaMembershipByNode.fill(-1),this._sharedFormulaSourceEntries=[],this._sharedFormulaSourceRangeIndex=new Y(this.codec,this._initialRangeCapacity,this._maxIndexedSpan)}encodeCell(e,t,n,r){return this.codec.encodeCell(e,t,n,r)}decodeCell(e){return this.codec.decodeCell(e)}encodeFeatureCalculationId(e,t,n){return`${e}${t}${n}`}decodeFeatureCalculationId(e){let t=this._tryDecodeFeatureCalculationId(e);if(t===void 0)throw Error(`Invalid feature calculation id: ${String(e)}`);return t}encodeOtherFormulaId(e,t,n,r,i){return`${e}${t}${n}${r}${i}`}decodeOtherFormulaId(e){let t=this._tryDecodeOtherFormulaId(e);if(t===void 0)throw Error(`Invalid other formula id: ${String(e)}`);return t}setCellFormulaDeps(e,t,n){var r,i;return this._setCalcNodeDepsByType(1,e,t,(r=n==null?void 0:n.checkCycle)==null?!0:r,(i=n==null?void 0:n.markDirty)==null?!0:i,(n==null?void 0:n.mode)===`merge`)}setOtherFormulaDeps(e,t,n){var r,i;return this._setCalcNodeDepsByType(2,e,t,(r=n==null?void 0:n.checkCycle)==null?!0:r,(i=n==null?void 0:n.markDirty)==null?!0:i,(n==null?void 0:n.mode)===`merge`)}setFeatureCalculationDeps(e,t,n){var r,i;return this._setCalcNodeDepsByType(3,e,t,(r=n==null?void 0:n.checkCycle)==null?!0:r,(i=n==null?void 0:n.markDirty)==null?!0:i,(n==null?void 0:n.mode)===`merge`)}setCalcNodeDeps(e,t,n){var r,i;return this._setCalcNodeDepsByType(e.type,e.id,t,(r=n==null?void 0:n.checkCycle)==null?!0:r,(i=n==null?void 0:n.markDirty)==null?!0:i,(n==null?void 0:n.mode)===`merge`)}registerCompressedSharedFormulaGroup(e){this.unregisterCompressedSharedFormulaGroup(e.groupId);let t=this._sharedFormulaGroups.length,n=O(e.fillRange),r={...n,range:{...n.range}},i={groupId:e.groupId,fillRange:r,patterns:e.patterns.slice(),sourceEntryIds:[]};this._sharedFormulaGroups.push(i),this._sharedFormulaGroupIndexById.set(i.groupId,t),this._markCompressedSharedFormulaMembership(t,r);for(let e=0;e<i.patterns.length;e++){let n=this._getCompressedSharedSourceCoverage(r,i.patterns[e]),a=this._sharedFormulaSourceEntries.length;this._sharedFormulaSourceEntries.push({groupIndex:t,patternIndex:e,sourceCoverage:n,active:!0}),i.sourceEntryIds.push(a),this._sharedFormulaSourceRangeIndex.addRange(a,n)}}unregisterCompressedSharedFormulaGroup(e){let t=this._sharedFormulaGroupIndexById.get(e);if(t===void 0)return;let n=this._sharedFormulaGroups[t];this._sharedFormulaGroupIndexById.delete(e);for(let e=0;e<n.sourceEntryIds.length;e++){let t=n.sourceEntryIds[e],r=this._sharedFormulaSourceEntries[t];r&&(r.active=!1),this._sharedFormulaSourceRangeIndex.removeNode(t)}this._clearCompressedSharedFormulaMembership(t,n.fillRange)}clearCompressedSharedFormulaGroups(e,t){let n=[];for(let r=0;r<this._sharedFormulaGroups.length;r++){let i=this._sharedFormulaGroups[r];this._sharedFormulaGroupIndexById.has(i.groupId)&&(e!==void 0&&i.fillRange.unitId!==e||t!==void 0&&i.fillRange.sheetId!==t||n.push(i.groupId))}for(let e=0;e<n.length;e++)this.unregisterCompressedSharedFormulaGroup(n[e])}_setCalcNodeDepsByType(e,t,n,r,i,a){var o,s,c,l,u,d,f;let p=this._getOrCreateNodeIndexByType(e,t),m=this._activeNode[p]===1,h=m&&e===1&&!this._isEmptyCalcNodeDeps(n)&&this._sharedFormulaMembershipByNode[p]>=0,g=m&&(r||a),_=g?(o=(s=this._cellPrecedents[p])==null?void 0:s.slice())==null?[]:o:[],v=g?(c=(l=this._rangePrecedents[p])==null?void 0:l.slice())==null?[]:c:[],y=g?(u=(d=this._nodePrecedents[p])==null?void 0:d.slice())==null?[]:u:[];m&&this._removeNodeDepsOnly(p);let b=this._normalizeCalcNodeDeps(n),x=b.cells,S=b.ranges,C=b.nodes,w=this._resolveExplicitNodeDeps(C),T=(f=this._dynamicDeps[p])==null?[]:f,E=a?this._mergeDynamicDeps(T,b.dynamics):b.dynamics,O=a?this._mergeSortedUniqueNumbers(_,x):x,k=a?this._mergeRangeDeps(v,S):S,A=a?this._mergeSortedUniqueNumbers(y,w):w;return r&&this._wouldCreateCycleForNewDeps(p,O,k,A)?(m&&this._addNodeDepsOnly(p,_,v,y),{nodeIndex:p,hasCycle:!0}):(h&&this._unregisterCompressedSharedFormulaGroupByNode(p),!m&&e===1&&(D(t),this._formulaCellIndex.addFormulaCell(t,p)),m||this._activeNodeCount++,this._activeNode[p]=1,this._addNodeDepsOnly(p,O,k,A),this._setNodeDynamicDeps(p,E),i&&(this._markNodeIndexDirty(p,!0),this._propagateDirtyQueue()),{nodeIndex:p,hasCycle:!1})}setManyCalcNodeDeps(e,t){var n,r;let i=(n=t==null?void 0:t.markDirty)==null?!0:n,a=(r=t==null?void 0:t.checkCycle)==null?!0:r,o=(t==null?void 0:t.mode)===`merge`,s=Array(e.length),c=[];for(let t=0;t<e.length;t++){let n=e[t],r=this._setCalcNodeDepsByType(n.node.type,n.node.id,n.deps,a,!1,o);s[t]=r,r.hasCycle||c.push(r.nodeIndex)}return i&&c.length>0&&this._markCalcNodeIndicesChanged(c),s}setManyCellFormulaDeps(e,t){var n,r;let i=(n=t==null?void 0:t.markDirty)==null?!0:n,a=(r=t==null?void 0:t.checkCycle)==null?!0:r,o=(t==null?void 0:t.mode)===`merge`,s=Array(e.length),c=[];for(let t=0;t<e.length;t++){let n=e[t],r=this._setCalcNodeDepsByType(1,n.cell,n.deps,a,!1,o);s[t]=r,r.hasCycle||c.push(r.nodeIndex)}return i&&c.length>0&&this._markCalcNodeIndicesChanged(c),s}setManyOtherFormulaDeps(e,t){var n,r;let i=(n=t==null?void 0:t.markDirty)==null?!0:n,a=(r=t==null?void 0:t.checkCycle)==null?!0:r,o=(t==null?void 0:t.mode)===`merge`,s=Array(e.length),c=[];for(let t=0;t<e.length;t++){let n=e[t],r=this._setCalcNodeDepsByType(2,n.id,n.deps,a,!1,o);s[t]=r,r.hasCycle||c.push(r.nodeIndex)}return i&&c.length>0&&this._markCalcNodeIndicesChanged(c),s}setManyFeatureCalculationDeps(e,t){var n,r;let i=(n=t==null?void 0:t.markDirty)==null?!0:n,a=(r=t==null?void 0:t.checkCycle)==null?!0:r,o=(t==null?void 0:t.mode)===`merge`,s=Array(e.length),c=[];for(let t=0;t<e.length;t++){let n=e[t],r=this._setCalcNodeDepsByType(3,n.id,n.deps,a,!1,o);s[t]=r,r.hasCycle||c.push(r.nodeIndex)}return i&&c.length>0&&this._markCalcNodeIndicesChanged(c),s}removeCellFormula(e,t){this._removeCalcNodeByType(1,e,t)}removeOtherFormula(e,t){this._removeCalcNodeByType(2,e,t)}removeFeatureCalculation(e,t){this._removeCalcNodeByType(3,e,t)}removeCellFormulas(e,t){this._removeCalcNodeIds(1,e,t)}removeOtherFormulas(e,t){this._removeCalcNodeIds(2,e,t)}removeFeatureCalculations(e,t){this._removeCalcNodeIds(3,e,t)}removeCalcNodes(e,t){if(e.length===0)return;let n=[];for(let t=0;t<e.length;t++){let r=e[t],i=this._getNodeIndexByType(r.type,r.id);i!==void 0&&this._activeNode[i]&&n.push(i)}this._removeCalcNodeIndices(n,t)}clearCellFormulas(e,t,n){let r=[];for(let[n,i]of this.cellFormulaToIndex){if(!this._activeNode[i])continue;let a=this.codec.decodeCell(n);a.unitId===e&&(t!==void 0&&a.sheetId!==t||r.push(i))}this._removeCalcNodeIndices(r,n)}clearOtherFormulas(e,t,n,r,i,a){if(n!==void 0&&n.length===0)return;let o=[];for(let[a,s]of this.otherFormulaToIndex){if(!this._activeNode[s])continue;let c=this._tryDecodeOtherFormulaId(a);c!==void 0&&c.unitId===e&&(t!==void 0&&c.sheetId!==t||n!==void 0&&!this._includesFormulaId(n,c.formulaId)||r!==void 0&&c.refOffsetX!==r||r!==void 0&&i!==void 0&&c.refOffsetY!==i||o.push(s))}this._removeCalcNodeIndices(o,a)}_includesFormulaId(e,t){for(let n=0;n<e.length;n++)if(e[n]===t)return!0;return!1}clearFeatureCalculations(e,t,n){let r=[];for(let[n,i]of this.featureCalculationToIndex){if(!this._activeNode[i])continue;let a=this._tryDecodeFeatureCalculationId(n);a!==void 0&&a.unitId===e&&(t!==void 0&&a.sheetId!==t||r.push(i))}this._removeCalcNodeIndices(r,n)}_tryDecodeFeatureCalculationId(e){if(typeof e!=`string`)return;let t=e.indexOf(`\0`);if(t<=0)return;let n=e.indexOf(`\0`,t+1);if(!(n<=t+1)&&n!==e.length-1&&e.indexOf(`\0`,n+1)===-1)return{unitId:e.slice(0,t),sheetId:e.slice(t+1,n),formulaId:e.slice(n+1)}}_tryDecodeOtherFormulaId(e){if(typeof e!=`string`)return;let t=e.indexOf(`\0`);if(t<=0)return;let n=e.indexOf(`\0`,t+1);if(n<=t+1)return;let r=e.indexOf(`\0`,n+1);if(r<=n+1)return;let i=e.indexOf(`\0`,r+1);if(i<=r+1||i===e.length-1||e.indexOf(`\0`,i+1)!==-1)return;let a=Number(e.slice(r+1,i)),o=Number(e.slice(i+1));if(!(!Number.isFinite(a)||!Number.isFinite(o)))return{unitId:e.slice(0,t),sheetId:e.slice(t+1,n),formulaId:e.slice(n+1,r),refOffsetX:a,refOffsetY:o}}_removeCalcNodeIds(e,t,n){if(t.length===0)return;let r=[];for(let n=0;n<t.length;n++){let i=this._getNodeIndexByType(e,t[n]);i!==void 0&&this._activeNode[i]&&r.push(i)}this._removeCalcNodeIndices(r,n)}_removeCalcNodeIndices(e,t){if(e.length!==0){if(t!=null&&t.markDependentsDirty&&this._markCalcNodeIndicesChanged(e),t!=null&&t.detachDependents)for(let t=0;t<e.length;t++)this._detachDependentsFromNode(e[t]);for(let t=0;t<e.length;t++)this._removeCalcNodeByIndex(e[t])}}removeCalcNode(e,t){this._removeCalcNodeByType(e.type,e.id,t)}_removeCalcNodeByType(e,t,n){let r=this._getNodeIndexByType(e,t);r!==void 0&&this._activeNode[r]&&(n!=null&&n.markDependentsDirty&&(this._markNodeIndexDirty(r,!0),this._propagateDirtyQueue()),n!=null&&n.detachDependents&&this._detachDependentsFromNode(r),this._removeCalcNodeByIndex(r))}_removeCalcNodeByIndex(e){if(this._activeNode[e]){if(this._unregisterCompressedSharedFormulaGroupByNode(e),this._removeNodeDepsOnly(e),this._removeRuntimeDepsOnly(e),this._dynamicDeps[e]=void 0,this._dynamicSignature[e]=void 0,this._indexToNodeType[e]===1){let t=this.indexToNodeId[e];this._formulaCellIndex.removeFormulaCell(t,e)}this._activeNode[e]=0,this._activeNodeCount--,this.dirty[e]&&(this.dirty[e]=0,this._dirtyNodeCount--,this._compactDirtyList()),this.inQueue[e]=0}}markCellChanged(e){this.markCellsChanged([e])}markCellsChanged(e){this._nextEmitEpoch();for(let t of e)this._forEachDependentIndexByCellRaw(t,e=>{this._emitNodeOnceAndMarkDirty(e)});this._propagateDirtyQueue()}markRangeChanged(e,t){this.markRangesChanged([e],t)}markRangesChanged(e,t){if(e.length===0)return;let n=(t==null?void 0:t.coalesce)===!1?this._normalizeRangeDeps(e):W(e);this._nextEmitEpoch();for(let e=0;e<n.length;e++){let r=n[e];t!=null&&t.includeFormulaCells&&this._formulaCellIndex.forEachFormulaInRange(r,e=>{this._emitNodeOnceAndMarkDirty(e,!0)}),this._directPointIndex.forEachCellInRange(r,e=>{R(this.directDeps.get(e),e=>{this._emitNodeOnceAndMarkDirty(e)})}),this._runtimeDirectPointIndex.forEachCellInRange(r,e=>{R(this._runtimeDirectDeps.get(e),e=>{this._emitNodeOnceAndMarkDirty(e)})})}this._isEveryActiveNodeDirty()||this.rangeIndex.forEachRangesIntersecting(n,e=>{this._emitNodeOnceAndMarkDirty(e)}),this._isEveryActiveNodeDirty()||this._runtimeRangeIndex.forEachRangesIntersecting(n,e=>{this._emitNodeOnceAndMarkDirty(e)});for(let e=0;e<n.length&&!this._isEveryActiveNodeDirty();e++)this._forEachCompressedSharedDependentByRange(n[e],e=>{this._emitNodeOnceAndMarkDirty(e)});this._propagateDirtyQueue()}markCellFormulaChanged(e){this._markCalcNodeChangedByType(1,e)}markOtherFormulaChanged(e){this._markCalcNodeChangedByType(2,e)}markOtherFormulasChanged(e,t,n){if(!(n!==void 0&&n.length===0)){this._nextEmitEpoch();for(let[r,i]of this.otherFormulaToIndex){if(!this._activeNode[i])continue;let a=this._tryDecodeOtherFormulaId(r);a!==void 0&&a.unitId===e&&(t!==void 0&&a.sheetId!==t||n!==void 0&&!this._includesFormulaId(n,a.formulaId)||this._emitNodeOnceAndMarkDirty(i,!0))}this._propagateDirtyQueue()}}markFeatureCalculationChanged(e){this._markCalcNodeChangedByType(3,e)}markCalcNodeChanged(e){this._markCalcNodeChangedByType(e.type,e.id)}_markCalcNodeChangedByType(e,t){let n=this._getNodeIndexByType(e,t);n!==void 0&&this._activeNode[n]&&(this._markNodeIndexDirty(n,!0),this._propagateDirtyQueue())}markCalcNodesChanged(e){if(e.length!==0){this._nextEmitEpoch();for(let t=0;t<e.length;t++){let n=e[t],r=this._getNodeIndexByType(n.type,n.id);r!==void 0&&this._activeNode[r]&&this._emitNodeOnceAndMarkDirty(r,!0)}this._propagateDirtyQueue()}}markAllDirty(){this._nextEmitEpoch();for(let e=0;e<this.indexToNodeId.length;e++)this._activeNode[e]&&this._emitNodeOnceAndMarkDirty(e,!0);this._propagateDirtyQueue()}hasDynamicDeps(e){let t=this.getNodeIndex(e);if(t===void 0)return!1;let n=this._dynamicDeps[t];return n!==void 0&&n.length>0}refreshDynamicDeps(e,t){let n=this.getNodeIndex(e);if(n===void 0||!this._activeNode[n])return!1;let r=this._dynamicDeps[n];if(!r||r.length===0)return!1;let i={cells:[],ranges:[],nodes:[]},a=[];for(let n=0;n<r.length;n++){var o;let s=r[n],c=t(e,s),l=(o=c.status)==null?`resolved`:o;a.push(`${String(s.id)}:${l}:${c.signature}`),this._collectDynamicResolveResult(i,c)}i.cells=M(i.cells),i.ranges=this._normalizeRangeDeps(i.ranges),i.nodes=this._mergeSortedUniqueNumbers([],i.nodes);let s=a.join(`|`),c=this._dynamicSignature[n];return this._removeRuntimeDepsOnly(n),this._addRuntimeDepsOnly(n,i.cells,i.ranges,i.nodes),this._dynamicSignature[n]=s,s===c?!1:(this._markNodeIndexDirty(n,!0),this._propagateDirtyQueue(),!0)}prepareDynamicDependencies(e){let t=this._getDirtyNodeIndicesSnapshot(),n=!1;for(let r=0;r<t.length;r++){let i=t[r],a=this._dynamicDeps[i];!a||a.length===0||this.refreshDynamicDeps(this.getNodeRefByIndex(i),e)&&(n=!0)}return n}getCalculationOrder(e){let t=this._getDirtyNodeIndicesSnapshot();if(t.length===0)return{hasCycle:!1,calculationForest:[]};let n=this._buildDirtyCalculationGraph(t);return{hasCycle:n.hasCycle,calculationForest:n.calculationForest}}clearCalculatedDirty(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];this.dirty[r]&&(this.dirty[r]=0,this._dirtyNodeCount--,t=!0)}t&&this._compactDirtyList()}_compactDirtyList(){let e=0;for(let t=0;t<this._dirtyList.length;t++){let n=this._dirtyList[t];this.dirty[n]&&this._activeNode[n]&&(this._dirtyList[e++]=n)}this._dirtyList.length=e}clearAllDirty(){for(let e=0;e<this._dirtyList.length;e++)this.dirty[this._dirtyList[e]]=0;this._dirtyList.length=0,this._dirtyNodeCount=0}getDirtyNodeIndices(){return this._getDirtyNodeIndicesSnapshot()}getDirtyNodes(){let e=this._getDirtyNodeIndicesSnapshot(),t=Array(e.length);for(let n=0;n<e.length;n++)t[n]=this.getNodeRefByIndex(e[n]);return t}forEachDependentByCell(e,t){this._nextEmitEpoch(),this._forEachDependentIndexByCellRaw(e,e=>{this._emitNodeOnce(e)&&t(this.getNodeRefByIndex(e),e)})}forEachDependentByRange(e,t){this._nextEmitEpoch(),this._directPointIndex.forEachCellInRange(e,e=>{R(this.directDeps.get(e),e=>{this._emitNodeOnce(e)&&t(this.getNodeRefByIndex(e),e)})}),this._runtimeDirectPointIndex.forEachCellInRange(e,e=>{R(this._runtimeDirectDeps.get(e),e=>{this._emitNodeOnce(e)&&t(this.getNodeRefByIndex(e),e)})}),this.rangeIndex.forEachRangeIntersecting(e,e=>{this._emitNodeOnce(e)&&t(this.getNodeRefByIndex(e),e)}),this._runtimeRangeIndex.forEachRangeIntersecting(e,e=>{this._emitNodeOnce(e)&&t(this.getNodeRefByIndex(e),e)}),this._forEachCompressedSharedDependentByRange(e,e=>{this._emitNodeOnce(e)&&t(this.getNodeRefByIndex(e),e)})}forEachDependentByNode(e,t){let n=this.getNodeIndex(e);n!==void 0&&(this._nextEmitEpoch(),this._forEachDependentOfNodeRaw(n,e=>{this._emitNodeOnce(e)&&t(this.getNodeRefByIndex(e),e)}))}forEachDependentByIndex(e,t){this._activeNode[e]&&(this._nextEmitEpoch(),this._forEachDependentOfNodeRaw(e,e=>{this._activeNode[e]&&this._emitNodeOnce(e)&&t(this.getNodeRefByIndex(e),e)}))}forEachPrecedentNode(e,t){let n=this.getNodeIndex(e);n!==void 0&&this._activeNode[n]&&(this._nextEmitEpoch(),this._forEachPrecedentNodeIndex(n,e=>{this._emitNodeOnce(e)&&t(this.getNodeRefByIndex(e),e)}))}forEachPrecedentNodeByIndex(e,t){this._activeNode[e]&&(this._nextEmitEpoch(),this._forEachPrecedentNodeIndex(e,e=>{this._emitNodeOnce(e)&&t(this.getNodeRefByIndex(e),e)}))}hasUncalculatedDirtyPrecedentByIndex(e,t){if(!this._activeNode[e])return!1;let n=!1;return this._nextEmitEpoch(),this._forEachPrecedentNodeIndex(e,e=>{if(!n&&this.dirty[e]&&!t.has(e))return n=!0,!1}),n}wouldCreateCycle(e,t){let n=this._getOrCreateNodeIndex(e),r=this._normalizeCalcNodeDeps(t),i=r.cells,a=r.ranges,o=r.nodes,s=this._resolveExplicitNodeDeps(o);return this._wouldCreateCycleForNewDeps(n,i,a,s)}_normalizeCalcNodeDeps(e){let t=[],n=[],r=[];return this._collectStaticDeps(e,t,n,r),{cells:M(t),ranges:this._normalizeRangeDeps(n),nodes:U(r),dynamics:e.dynamics?e.dynamics.slice():[]}}_collectStaticDeps(e,t,n,r){if(e&&(e.cells&&t.push(...e.cells),e.ranges&&n.push(...e.ranges),e.nodes&&r.push(...e.nodes),e.dynamics))for(let i=0;i<e.dynamics.length;i++)this._collectStaticDeps(e.dynamics[i].paramDeps,t,n,r)}_mergeDynamicDeps(e,t){if(e.length===0)return t;if(t.length===0)return e;let n=e.slice();for(let e=0;e<t.length;e++){let r=t[e],i=!1;for(let e=0;e<n.length;e++)if(n[e].id===r.id){i=!0;break}i||n.push(r)}return n}_setNodeDynamicDeps(e,t){let n=this._dynamicDeps[e];n===void 0&&t.length===0||this._isSameDynamicDeps(n,t)||(this._removeRuntimeDepsOnly(e),this._dynamicSignature[e]=void 0,this._dynamicDeps[e]=t.length>0?t:void 0)}_isSameDynamicDeps(e,t){var n;if(((n=e==null?void 0:e.length)==null?0:n)!==t.length)return!1;if(!e)return t.length===0;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}_normalizeRangeDeps(e){if(!e||e.length===0)return[];let t=Array(e.length);for(let n=0;n<e.length;n++)t[n]=O(e[n]);return t}_mergeSortedUniqueNumbers(e,t){if(e.length===0)return t;if(t.length===0)return e;let n=[],r=0,i=0;for(;r<e.length&&i<t.length;){let a=e[r],o=t[i];a===o?(n.push(a),r++,i++):a<o?(n.push(a),r++):(n.push(o),i++)}for(;r<e.length;)n.push(e[r++]);for(;i<t.length;)n.push(t[i++]);return n}_mergeRangeDeps(e,t){if(e.length===0)return t;if(t.length===0)return e;let n=e.slice();for(let e=0;e<t.length;e++){let r=t[e];this._containsRange(n,r)||n.push(r)}return n}_containsRange(e,t){for(let n=0;n<e.length;n++)if(this._isSameRange(e[n],t))return!0;return!1}_isSameRange(e,t){return e.unitId===t.unitId&&e.sheetId===t.sheetId&&e.range.startRow===t.range.startRow&&e.range.endRow===t.range.endRow&&e.range.startColumn===t.range.startColumn&&e.range.endColumn===t.range.endColumn}canReachNode(e,t){let n=this.getNodeIndex(e),r=this.getNodeIndex(t);return n===void 0||r===void 0?!1:this._canReachNodeIndex(n,r)}hasCellFormula(e){let t=this.cellFormulaToIndex.get(e);return t!==void 0&&this._activeNode[t]===1}hasOtherFormula(e){let t=this.otherFormulaToIndex.get(e);return t!==void 0&&this._activeNode[t]===1}hasFeatureCalculation(e){let t=this.featureCalculationToIndex.get(e);return t!==void 0&&this._activeNode[t]===1}getNodeIndex(e){return this._getNodeIndexByType(e.type,e.id)}_getNodeIndexByType(e,t){switch(e){case 1:return D(t),this.cellFormulaToIndex.get(t);case 2:return this.otherFormulaToIndex.get(t);case 3:return this.featureCalculationToIndex.get(t);default:return}}getNodeRefByIndex(e){return{type:this._indexToNodeType[e],id:this.indexToNodeId[e]}}markCalcNodeIndicesChanged(e,t){this._markCalcNodeIndicesChanged(e,t)}_markCalcNodeIndicesChanged(e,t){if(e.length===0)return;this._nextEmitEpoch();let n=(t==null?void 0:t.onlySelf)!==!0;for(let t=0;t<e.length;t++){let r=e[t];this._activeNode[r]&&this._emitNodeOnceAndMarkDirty(r,n,n)}n&&this._propagateDirtyQueue()}_getOrCreateNodeIndex(e){return this._getOrCreateNodeIndexByType(e.type,e.id)}_getOrCreateNodeIndexByType(e,t){let n=this._getNodeIndexByType(e,t);if(n!==void 0)return n;let r=this.indexToNodeId.length;switch(this.indexToNodeId.push(t),this._ensureNodeCapacity(r+1),this._indexToNodeType[r]=e,e){case 1:D(t),this.cellFormulaToIndex.set(t,r);break;case 2:this.otherFormulaToIndex.set(t,r);break;case 3:this.featureCalculationToIndex.set(t,r);break;default:throw Error(`Unknown CalcNodeType: ${e}`)}return r}_ensureNodeCapacity(e){let t=this._sharedFormulaMembershipByNode.length;this._indexToNodeType=V(this._indexToNodeType,e),this.dirty=V(this.dirty,e),this.inQueue=V(this.inQueue,e),this._activeNode=V(this._activeNode,e),this._seenNodeEpoch=H(this._seenNodeEpoch,e),this._visitNodeEpoch=H(this._visitNodeEpoch,e),this._edgeSeenEpoch=H(this._edgeSeenEpoch,e),this._tarjanSeenEpoch=H(this._tarjanSeenEpoch,e),this._tarjanIndexArr=H(this._tarjanIndexArr,e),this._tarjanLowArr=H(this._tarjanLowArr,e),this._tarjanOnStack=V(this._tarjanOnStack,e),this._sharedFormulaMembershipByNode=this._growIntThirtyTwoArray(this._sharedFormulaMembershipByNode,e,-1),this._sharedFormulaMembershipByNode.length>t&&this._sharedFormulaMembershipByNode.fill(-1,t)}_growIntThirtyTwoArray(e,t,n){if(e.length>=t)return e;let r=Math.max(16,e.length);for(;r<t;)r*=2;let i=new Int32Array(r);return i.fill(n),i.set(e),i}_resolveExplicitNodeDeps(e){if(e.length===0)return[];let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r.type===2)throw Error(`OtherFormula cannot be used as a dependency`);let i=this._getOrCreateNodeIndex(r);t.push(i)}if(t.length<=1)return t;t.sort((e,t)=>e-t);let n=1;for(let e=1;e<t.length;e++)t[e]!==t[n-1]&&(t[n++]=t[e]);return t.length=n,t}_isEmptyCalcNodeDeps(e){return(e.cells==null||e.cells.length===0)&&(e.ranges==null||e.ranges.length===0)&&(e.nodes==null||e.nodes.length===0)&&(e.dynamics==null||e.dynamics.length===0)}_unregisterCompressedSharedFormulaGroupByNode(e){let t=this._sharedFormulaMembershipByNode[e];if(t<0)return;let n=this._sharedFormulaGroups[t];if(n==null||!this._sharedFormulaGroupIndexById.has(n.groupId)){this._sharedFormulaMembershipByNode[e]=-1;return}this.unregisterCompressedSharedFormulaGroup(n.groupId)}_markCompressedSharedFormulaMembership(e,t){for(let n=t.range.startRow;n<=t.range.endRow;n++)for(let r=t.range.startColumn;r<=t.range.endColumn;r++){let i=this.codec.encodeCell(t.unitId,t.sheetId,n,r),a=this.cellFormulaToIndex.get(i);a!==void 0&&this._activeNode[a]&&(this._sharedFormulaMembershipByNode[a]=e)}}_clearCompressedSharedFormulaMembership(e,t){for(let n=t.range.startRow;n<=t.range.endRow;n++)for(let r=t.range.startColumn;r<=t.range.endColumn;r++){let i=this.codec.encodeCell(t.unitId,t.sheetId,n,r),a=this.cellFormulaToIndex.get(i);a!==void 0&&this._sharedFormulaMembershipByNode[a]===e&&(this._sharedFormulaMembershipByNode[a]=-1)}}_getCompressedSharedSourceCoverage(e,t){if(t.kind===`cell`)return O({unitId:t.unitId,sheetId:t.sheetId,range:{startRow:e.range.startRow+t.rowDelta,endRow:e.range.endRow+t.rowDelta,startColumn:e.range.startColumn+t.colDelta,endColumn:e.range.endColumn+t.colDelta}});let n=Math.min(t.startRowDelta,t.endRowDelta),r=Math.max(t.startRowDelta,t.endRowDelta),i=Math.min(t.startColDelta,t.endColDelta),a=Math.max(t.startColDelta,t.endColDelta);return O({unitId:t.unitId,sheetId:t.sheetId,range:{startRow:e.range.startRow+n,endRow:e.range.endRow+r,startColumn:e.range.startColumn+i,endColumn:e.range.endColumn+a}})}_forEachCompressedSharedDependentByRange(e,t){let n=O(e);this._sharedFormulaSourceRangeIndex.forEachRangeIntersecting(n,e=>{let r=this._sharedFormulaSourceEntries[e];if(!(r!=null&&r.active))return;let i=this._sharedFormulaGroups[r.groupIndex],a=this._reverseMapCompressedSharedPattern(n,i.fillRange,i.patterns[r.patternIndex]);a!=null&&this._forEachActiveCellFormulaInRange(a,t)})}_forEachActiveCellFormulaInRange(e,t){for(let n=e.range.startRow;n<=e.range.endRow;n++)for(let r=e.range.startColumn;r<=e.range.endColumn;r++){let i=this.codec.encodeCell(e.unitId,e.sheetId,n,r),a=this.cellFormulaToIndex.get(i);a!==void 0&&this._activeNode[a]&&t(a)}}_reverseMapCompressedSharedPattern(e,t,n){let r=n.kind===`cell`?[e.range.startRow-n.rowDelta,e.range.endRow-n.rowDelta]:[e.range.startRow-Math.max(n.startRowDelta,n.endRowDelta),e.range.endRow-Math.min(n.startRowDelta,n.endRowDelta)],i=n.kind===`cell`?[e.range.startColumn-n.colDelta,e.range.endColumn-n.colDelta]:[e.range.startColumn-Math.max(n.startColDelta,n.endColDelta),e.range.endColumn-Math.min(n.startColDelta,n.endColDelta)];return this._intersectRanges(t,{unitId:t.unitId,sheetId:t.sheetId,range:{startRow:r[0],endRow:r[1],startColumn:i[0],endColumn:i[1]}})}_intersectRanges(e,t){if(e.unitId!==t.unitId||e.sheetId!==t.sheetId)return;let n=Math.max(e.range.startRow,t.range.startRow),r=Math.min(e.range.endRow,t.range.endRow),i=Math.max(e.range.startColumn,t.range.startColumn),a=Math.min(e.range.endColumn,t.range.endColumn);if(!(n>r||i>a))return{unitId:e.unitId,sheetId:e.sheetId,range:{startRow:n,endRow:r,startColumn:i,endColumn:a}}}_forEachCompressedSharedPrecedent(e,t){let n=this._sharedFormulaMembershipByNode[e];if(n<0)return!0;let r=this._sharedFormulaGroups[n];for(let e=0;e<r.patterns.length;e++)if(t(r.patterns[e])===!1)return!1;return!0}_getCompressedSharedPrecedentCell(e,t){let n=this.indexToNodeId[e],r=this.codec.decodeCell(n);return this.codec.encodeCell(t.unitId,t.sheetId,r.row+t.rowDelta,r.col+t.colDelta)}_getCompressedSharedPrecedentRange(e,t){let n=this.indexToNodeId[e],r=this.codec.decodeCell(n);return O({unitId:t.unitId,sheetId:t.sheetId,range:{startRow:r.row+t.startRowDelta,startColumn:r.col+t.startColDelta,endRow:r.row+t.endRowDelta,endColumn:r.col+t.endColDelta}})}_addNodeDepsOnly(e,t,n,r){for(let n=0;n<t.length;n++)this._addDirectEdge(t[n],e);this._cellPrecedents[e]=t.length>0?t:void 0,this._rangePrecedents[e]=n.length>0?n:void 0;for(let t=0;t<n.length;t++)this.rangeIndex.addRange(e,n[t]);this._nodePrecedents[e]=r.length>0?r:void 0;for(let t=0;t<r.length;t++)this._addExplicitNodeEdge(r[t],e)}_removeNodeDepsOnly(e){let t=this._cellPrecedents[e];if(t){for(let n=0;n<t.length;n++)this._removeDirectEdge(t[n],e);this._cellPrecedents[e]=void 0}this.rangeIndex.removeNode(e),this._rangePrecedents[e]=void 0;let n=this._nodePrecedents[e];if(n){for(let t=0;t<n.length;t++)this._removeExplicitNodeEdge(n[t],e);this._nodePrecedents[e]=void 0}}_collectDynamicResolveResult(e,t){t.traceCells&&e.cells.push(...t.traceCells),t.cells&&e.cells.push(...t.cells),t.ranges&&e.ranges.push(...t.ranges),t.nodes&&e.nodes.push(...this._resolveExplicitNodeDeps(U(t.nodes)))}_addRuntimeDepsOnly(e,t,n,r){for(let n=0;n<t.length;n++)this._addRuntimeDirectEdge(t[n],e);this._runtimeCellPrecedents[e]=t.length>0?t:void 0,this._runtimeRangePrecedents[e]=n.length>0?n:void 0;for(let t=0;t<n.length;t++)this._runtimeRangeIndex.addRange(e,n[t]);this._runtimeNodePrecedents[e]=r.length>0?r:void 0;for(let t=0;t<r.length;t++)this._addRuntimeExplicitNodeEdge(r[t],e)}_removeRuntimeDepsOnly(e){let t=this._runtimeCellPrecedents[e];if(t){for(let n=0;n<t.length;n++)this._removeRuntimeDirectEdge(t[n],e);this._runtimeCellPrecedents[e]=void 0}this._runtimeRangeIndex.removeNode(e),this._runtimeRangePrecedents[e]=void 0;let n=this._runtimeNodePrecedents[e];if(n){for(let t=0;t<n.length;t++)this._removeRuntimeExplicitNodeEdge(n[t],e);this._runtimeNodePrecedents[e]=void 0}}_detachDependentsFromNode(e){let t=this.nodeDeps.get(e),n=[];R(t,e=>{n.push(e)}),this.nodeDeps.delete(e);for(let t=0;t<n.length;t++)this._detachPrecedentFromDependent(n[t],e);let r=this._runtimeNodeDeps.get(e);if(r===void 0)return;let i=[];R(r,e=>{i.push(e)}),this._runtimeNodeDeps.delete(e);for(let t=0;t<i.length;t++)this._detachRuntimePrecedentFromDependent(i[t],e)}_detachPrecedentFromDependent(e,t){let n=this._nodePrecedents[e];if(n===void 0)return;let r=0,i=!1;for(let e=0;e<n.length;e++){let a=n[e];if(a===t){i=!0;continue}n[r++]=a}i&&(r===0?this._nodePrecedents[e]=void 0:n.length=r)}_detachRuntimePrecedentFromDependent(e,t){let n=this._runtimeNodePrecedents[e];if(n===void 0)return;let r=0,i=!1;for(let e=0;e<n.length;e++){let a=n[e];if(a===t){i=!0;continue}n[r++]=a}i&&(r===0?this._runtimeNodePrecedents[e]=void 0:n.length=r)}_addDirectEdge(e,t){let n=this.directDeps.get(e);n===void 0&&this._directPointIndex.add(e),this.directDeps.set(e,I(n,t))}_removeDirectEdge(e,t){let n=this.directDeps.get(e);if(n===void 0)return;let r=L(n,t);r===void 0?(this.directDeps.delete(e),this._directPointIndex.remove(e)):this.directDeps.set(e,r)}_addRuntimeDirectEdge(e,t){let n=this._runtimeDirectDeps.get(e);n===void 0&&this._runtimeDirectPointIndex.add(e),this._runtimeDirectDeps.set(e,I(n,t))}_removeRuntimeDirectEdge(e,t){let n=this._runtimeDirectDeps.get(e);if(n===void 0)return;let r=L(n,t);r===void 0?(this._runtimeDirectDeps.delete(e),this._runtimeDirectPointIndex.remove(e)):this._runtimeDirectDeps.set(e,r)}_addExplicitNodeEdge(e,t){z(this.nodeDeps,e,t)}_removeExplicitNodeEdge(e,t){B(this.nodeDeps,e,t)}_addRuntimeExplicitNodeEdge(e,t){z(this._runtimeNodeDeps,e,t)}_removeRuntimeExplicitNodeEdge(e,t){B(this._runtimeNodeDeps,e,t)}_forEachDependentIndexByCellRaw(e,t){R(this.directDeps.get(e),t),R(this._runtimeDirectDeps.get(e),t);let n=this.codec.decodeCell(e);this.rangeIndex.forEachPoint(n.unitId,n.sheetId,n.row,n.col,t),this._runtimeRangeIndex.forEachPoint(n.unitId,n.sheetId,n.row,n.col,t),this._forEachCompressedSharedDependentByRange({unitId:n.unitId,sheetId:n.sheetId,range:{startRow:n.row,endRow:n.row,startColumn:n.col,endColumn:n.col}},t)}_forEachDependentOfNodeRaw(e,t){if(this._indexToNodeType[e]===1){let n=this.indexToNodeId[e];this._forEachDependentIndexByCellRaw(n,t)}R(this.nodeDeps.get(e),t),R(this._runtimeNodeDeps.get(e),t)}_markNodeIndexDirty(e,t=!1,n=!0){if(!this._activeNode[e])return;let r=this.dirty[e]===1;r||(this.dirty[e]=1,this._dirtyList.push(e),this._dirtyNodeCount++),n&&(!r||t)&&!this.inQueue[e]&&(this.inQueue[e]=1,this._propQueue.push(e))}_isEveryActiveNodeDirty(){return this._activeNodeCount>0&&this._dirtyNodeCount>=this._activeNodeCount}_propagateDirtyQueue(){if(this._isEveryActiveNodeDirty()){for(let e=0;e<this._propQueue.length;e++)this.inQueue[this._propQueue[e]]=0;this._propQueue.length=0;return}let e=0;for(;e<this._propQueue.length;){let t=this._propQueue[e++];this.inQueue[t]=0,this._activeNode[t]&&this._forEachDependentOfNodeRaw(t,e=>{this._markNodeIndexDirty(e,!1)})}this._propQueue.length=0}_getDirtyNodeIndicesSnapshot(){let e=[];for(let t=0;t<this._dirtyList.length;t++){let n=this._dirtyList[t];this.dirty[n]&&this._activeNode[n]&&e.push(n)}return e}_forEachDependentOfNodeDeduped(e,t){this._nextEdgeEpoch(),this._forEachDependentOfNodeRaw(e,e=>{this._edgeSeenEpoch[e]!==this._edgeEpoch&&(this._edgeSeenEpoch[e]=this._edgeEpoch,t(e))})}_forEachPrecedentNodeIndex(e,t){let n=this._cellPrecedents[e];if(n)for(let e=0;e<n.length;e++){let r=n[e],i=this.cellFormulaToIndex.get(r);if(i!==void 0&&this._activeNode[i]&&t(i)===!1)return!1}let r=this._rangePrecedents[e];if(r)for(let e=0;e<r.length;e++){let n=!0;if(this._formulaCellIndex.forEachFormulaInRange(r[e],e=>{if(n&&this._activeNode[e]&&t(e)===!1)return n=!1,!1}),!n)return!1}if(!this._forEachCompressedSharedPrecedent(e,n=>{if(n.kind===`cell`){let r=this._getCompressedSharedPrecedentCell(e,n),i=this.cellFormulaToIndex.get(r);return i!==void 0&&this._activeNode[i]&&t(i)===!1?!1:void 0}let r=!0;return this._formulaCellIndex.forEachFormulaInRange(this._getCompressedSharedPrecedentRange(e,n),e=>{if(r&&this._activeNode[e]&&t(e)===!1)return r=!1,!1}),r}))return!1;let i=this._nodePrecedents[e];if(i)for(let e=0;e<i.length;e++){let n=i[e];if(this._activeNode[n]&&t(n)===!1)return!1}let a=this._runtimeCellPrecedents[e];if(a)for(let e=0;e<a.length;e++){let n=a[e],r=this.cellFormulaToIndex.get(n);if(r!==void 0&&this._activeNode[r]&&t(r)===!1)return!1}let o=this._runtimeRangePrecedents[e];if(o)for(let e=0;e<o.length;e++){let n=!0;if(this._formulaCellIndex.forEachFormulaInRange(o[e],e=>{if(n&&this._activeNode[e]&&t(e)===!1)return n=!1,!1}),!n)return!1}let s=this._runtimeNodePrecedents[e];if(s)for(let e=0;e<s.length;e++){let n=s[e];if(this._activeNode[n]&&t(n)===!1)return!1}return!0}_wouldCreateCycleForNewDeps(e,t,n,r){for(let n=0;n<t.length;n++){let r=t[n],i=this.cellFormulaToIndex.get(r);if(i!==void 0&&this._activeNode[i]&&(i===e||this._canReachNodeIndex(e,i)))return!0}if(this._indexToNodeType[e]===1){let t=this.indexToNodeId[e],r=this.codec.decodeCell(t);for(let e=0;e<n.length;e++)if(j(n[e],r))return!0}for(let t=0;t<n.length;t++){let r=n[t],i=!1;if(this._formulaCellIndex.forEachFormulaInRange(r,t=>{if(!i&&this._activeNode[t]){if(t===e){i=!0;return}this._canReachNodeIndex(e,t)&&(i=!0)}}),i)return!0}for(let t=0;t<r.length;t++){let n=r[t];if(n===e||this._canReachNodeIndex(e,n))return!0}return!1}_canReachNodeIndex(e,t){if(e===t)return!0;this._nextVisitEpoch();let n=[e];for(;n.length>0;){let e=n.pop(),r=!1;if(this._forEachDependentOfNodeRaw(e,e=>{if(!r&&this._visitNodeEpoch[e]!==this._visitEpoch){if(this._visitNodeEpoch[e]=this._visitEpoch,e===t){r=!0;return}n.push(e)}}),r)return!0}return!1}_buildDirtyCalculationGraph(e){let t=this._tryBuildAcyclicDirtyCalculationGraph(e);return t===void 0?this._buildDirtyCalculationGraphWithScc(e):t}_tryBuildAcyclicDirtyCalculationGraph(e){let t=e.length;this._nextTarjanEpoch();for(let n=0;n<t;n++){let t=e[n];this._tarjanSeenEpoch[t]=this._tarjanEpoch,this._tarjanIndexArr[t]=n+1}let n=new Uint32Array(t),r=new Int32Array(t),i=new Int32Array(t),a=new Uint8Array(t),o=new Uint8Array(t),s=new Uint8Array(t),c=[],l=[],u=new Map,d=[],f=[],p=[],m=[],h=new Y(this.codec,this._initialRangeCapacity,this._maxIndexedSpan);for(let e=0;e<t;e++)i[e]=e,r[e]=-1;for(let g=0;g<t;g++){let t=e[g];this._nextEdgeEpoch(),this._addAcyclicExactPrecedentEdges(t,g,n,r,c,l,i,a,o,s),this._addAcyclicRangePrecedentGroups(t,g,n,u,d,f,p,m,h,i,a,o,s)}let g=new Int32Array(t),_=0,v=0;for(let e=0;e<t;e++)n[e]===0&&(g[v++]=e);let y=new Int32Array(t),b=[],x=-1,S=0,C=!1;for(;_<v;){let t=g[_++],a=e[t];S++,this._appendAcyclicCalculationNode(b,y,i,o,s,t,a,x),C=C||s[t]===1,o[t]===0&&x===-1&&(x=b.length-1);for(let e=r[t];e!==-1;e=l[e]){let t=c[e];n[t]--,n[t]===0&&(g[v++]=t)}if(this._indexToNodeType[a]===1){let e=this.indexToNodeId[a],t=this.codec.decodeCell(e);h.forEachPoint(t.unitId,t.sheetId,t.row,t.col,e=>{if(f[e]<=0||(f[e]--,f[e]!==0))return;let t=p[e];for(let e=0;e<t.length;e++){let r=t[e];n[r]--,n[r]===0&&(g[v++]=r)}})}}if(S===t)return{calculationForest:b,hasCycle:C}}_addAcyclicExactPrecedentEdges(e,t,n,r,i,a,o,s,c,l){let u=e=>{if(e===void 0||!this._activeNode[e]||!this.dirty[e]||this._edgeSeenEpoch[e]===this._edgeEpoch)return;this._edgeSeenEpoch[e]=this._edgeEpoch;let u=this._getCurrentDirtyOrdinal(e);if(!(u<0)){if(c[u]=1,c[t]=1,u===t){l[t]=1;return}a.push(r[u]),i.push(t),r[u]=i.length-1,n[t]++,this._unionCalculationForestComponents(o,s,u,t)}},d=this._cellPrecedents[e];if(d)for(let e=0;e<d.length;e++)u(this.cellFormulaToIndex.get(d[e]));let f=this._nodePrecedents[e];if(f)for(let e=0;e<f.length;e++)u(f[e]);let p=this._runtimeCellPrecedents[e];if(p)for(let e=0;e<p.length;e++)u(this.cellFormulaToIndex.get(p[e]));let m=this._runtimeNodePrecedents[e];if(m)for(let e=0;e<m.length;e++)u(m[e]);this._forEachCompressedSharedPrecedent(e,t=>{t.kind===`cell`&&u(this.cellFormulaToIndex.get(this._getCompressedSharedPrecedentCell(e,t)))})}_addAcyclicRangePrecedentGroups(e,t,n,r,i,a,o,s,c,l,u,d,f){let p=[],m=m=>{let h=this._getOrCreateAcyclicRangeGroup(m,r,i,a,o,s,c,l,u,d);if(a[h]===0)return;for(let e=0;e<p.length;e++)if(p[e]===h)return;p.push(h),o[h].push(t),n[t]++,d[t]=1;let g=s[h];g>=0&&this._unionCalculationForestComponents(l,u,g,t),this._indexToNodeType[e]===1&&j(m,this.codec.decodeCell(this.indexToNodeId[e]))&&(f[t]=1)},h=this._rangePrecedents[e];if(h)for(let e=0;e<h.length;e++)m(h[e]);let g=this._runtimeRangePrecedents[e];if(g)for(let e=0;e<g.length;e++)m(g[e]);this._forEachCompressedSharedPrecedent(e,t=>{t.kind===`range`&&m(this._getCompressedSharedPrecedentRange(e,t))})}_getOrCreateAcyclicRangeGroup(e,t,n,r,i,a,o,s,c,l){let u=O(e),d=[u.unitId,u.sheetId,u.range.startRow,u.range.endRow,u.range.startColumn,u.range.endColumn].join(`:`),f=t.get(d);if(f!==void 0)return f;let p=n.length,m=0,h=-1;return t.set(d,p),n.push(u),i.push([]),o.addRange(p,u),this._formulaCellIndex.forEachFormulaInRange(u,e=>{if(!this._activeNode[e]||!this.dirty[e])return;let t=this._getCurrentDirtyOrdinal(e);if(!(t<0)){if(m++,l[t]=1,h===-1){h=t;return}this._unionCalculationForestComponents(s,c,h,t)}}),r.push(m),a.push(h),p}_appendAcyclicCalculationNode(e,t,n,r,i,a,o,s){let c=r[a]===0,l=this._findCalculationForestRoot(n,a),u=(c?s+1:t[l])-1;if(u===-1&&(u=e.length,c||(t[l]=u+1),e.push({hasCycle:!1,plan:[]})),i[a]===1){e[u].plan.push({type:`cycle`,nodeIndices:[o]}),e[u].hasCycle=!0;return}this._appendCalculationNodePlanItem(e[u].plan,o)}_getCurrentDirtyOrdinal(e){return this._tarjanSeenEpoch[e]===this._tarjanEpoch?this._tarjanIndexArr[e]-1:-1}_buildDirtyCalculationGraphWithScc(e){let t=this._findDirtySccs(e),n=t.componentStarts.length,r=new Int32Array(this.indexToNodeId.length),i=new Int32Array(this.indexToNodeId.length);r.fill(-1),i.fill(-1);for(let t=0;t<e.length;t++)i[e[t]]=t;let a=new Int32Array(n);a.fill(2**53-1);for(let e=0;e<n;e++){let n=2**53-1,o=t.componentStarts[e],s=this._getDirtySccEnd(t,e);for(let a=o;a<s;a++){let o=t.componentNodes[a];r[o]=e;let s=i[o];s>=0&&s<n&&(n=s)}a[e]=n}let o=new Int32Array(n);o.fill(-1);let s=[],c=[],l=new Int32Array(n),u=new Uint8Array(n),d=new Uint8Array(n),f=new Uint32Array(n),p=1,m=new Uint32Array(n);for(let e=0;e<n;e++)l[e]=e;for(let e=0;e<n;e++){p===4294967295&&(f.fill(0),p=1);let n=t.componentStarts[e],i=this._getDirtySccEnd(t,e);for(let a=n;a<i;a++){let n=t.componentNodes[a];this._forEachDependentOfNodeDeduped(n,t=>{if(!this._activeNode[t]||!this.dirty[t])return;let n=r[t];n<0||n===e||f[n]!==p&&(f[n]=p,c.push(o[e]),s.push(n),o[e]=s.length-1,m[n]++,d[e]=1,d[n]=1,this._unionCalculationForestComponents(l,u,e,n))})}p++}let h=this._toposortComponents(o,s,c,m,a),g=this._buildCalculationForest(t,h,l,d);t.componentNodes.length=0,t.componentStarts.length=0,s.length=0,c.length=0,h.length=0;let _=!1;for(let e=0;e<g.length;e++)if(g[e].hasCycle){_=!0;break}return{calculationForest:g,hasCycle:_}}_toposortComponents(e,t,n,r,i){let a=new Uint32Array(r),o=[];for(let e=0;e<a.length;e++)a[e]===0&&this._insertComponentByRank(o,0,e,i);let s=[],c=0;for(;c<o.length;){let r=o[c++];s.push(r);for(let s=e[r];s!==-1;s=n[s]){let e=t[s];a[e]--,a[e]===0&&this._insertComponentByRank(o,c,e,i)}}return s}_insertComponentByRank(e,t,n,r){let i=e.length,a=r[n];for(;i>t&&r[e[i-1]]>a;)i--;e.splice(i,0,n)}_buildCalculationForest(e,t,n,r){let i=new Int32Array(e.componentStarts.length);i.fill(-1);let a=[],o=-1;for(let s=0;s<t.length;s++){let c=t[s],l=this._findCalculationForestRoot(n,c),u=r[c]===0,d=u?o:i[l];d===-1&&(d=a.length,u?o=d:i[l]=d,a.push({hasCycle:!1,plan:[]}));let f=a[d],p=this._createCalculationPlanItem(e,c);if(p.type===`node`){this._appendCalculationNodePlanItem(f.plan,p.nodeIndex);continue}f.plan.push(p),p.type===`cycle`&&(f.hasCycle=!0)}return a}_appendCalculationNodePlanItem(e,t){let n=e[e.length-1];if((n==null?void 0:n.type)===`nodes`&&n.nodeIndices.length<8192){n.nodeIndices.push(t);return}e.push({type:`nodes`,nodeIndices:[t]})}_findCalculationForestRoot(e,t){let n=t;for(;e[n]!==n;)n=e[n];for(;e[t]!==t;){let r=e[t];e[t]=n,t=r}return n}_unionCalculationForestComponents(e,t,n,r){let i=this._findCalculationForestRoot(e,n),a=this._findCalculationForestRoot(e,r);if(i!==a){if(t[i]<t[a]){let e=i;i=a,a=e}e[a]=i,t[i]===t[a]&&t[i]++}}_createCalculationPlanItem(e,t){let n=e.componentStarts[t],r=this._getDirtySccEnd(e,t);if(r-n===1&&!this._hasSelfLoop(e.componentNodes[n]))return{type:`node`,nodeIndex:e.componentNodes[n]};let i=e.componentNodes.slice(n,r);return i.sort((e,t)=>e-t),{type:`cycle`,nodeIndices:i}}_getDirtySccEnd(e,t){return t+1<e.componentStarts.length?e.componentStarts[t+1]:e.componentNodes.length}_findDirtySccs(e){this._nextTarjanEpoch();let t=1,n=[],r=[],i=[],a=e=>{if(this._tarjanSeenEpoch[e]=this._tarjanEpoch,this._tarjanIndexArr[e]=t,this._tarjanLowArr[e]=t,t++,n.push(e),this._tarjanOnStack[e]=1,this._forEachDependentOfNodeDeduped(e,t=>{this._activeNode[t]&&this.dirty[t]&&(this._tarjanSeenEpoch[t]===this._tarjanEpoch?this._tarjanOnStack[t]&&(this._tarjanLowArr[e]=Math.min(this._tarjanLowArr[e],this._tarjanIndexArr[t])):(a(t),this._tarjanLowArr[e]=Math.min(this._tarjanLowArr[e],this._tarjanLowArr[t])))}),this._tarjanLowArr[e]===this._tarjanIndexArr[e])for(i.push(r.length);;){let t=n.pop();if(this._tarjanOnStack[t]=0,r.push(t),t===e)break}};for(let t=0;t<e.length;t++){let n=e[t];this._activeNode[n]&&this.dirty[n]&&this._tarjanSeenEpoch[n]!==this._tarjanEpoch&&a(n)}return{componentNodes:r,componentStarts:i}}_hasSelfLoop(e){let t=!1;return this._forEachDependentOfNodeDeduped(e,n=>{n===e&&(t=!0)}),t}_nextEmitEpoch(){this._emitEpoch++,this._emitEpoch>=4294967295&&(this._seenNodeEpoch.fill(0),this._emitEpoch=1)}_emitNodeOnce(e){return this._seenNodeEpoch[e]===this._emitEpoch?!1:(this._seenNodeEpoch[e]=this._emitEpoch,!0)}_emitNodeOnceAndMarkDirty(e,t=!1,n=!0){this._emitNodeOnce(e)&&this._markNodeIndexDirty(e,t,n)}_nextVisitEpoch(){this._visitEpoch++,this._visitEpoch>=4294967295&&(this._visitNodeEpoch.fill(0),this._visitEpoch=1)}_nextEdgeEpoch(){this._edgeEpoch++,this._edgeEpoch>=4294967295&&(this._edgeSeenEpoch.fill(0),this._edgeEpoch=1)}_nextTarjanEpoch(){this._tarjanEpoch++,this._tarjanEpoch>=4294967295&&(this._tarjanSeenEpoch.fill(0),this._tarjanEpoch=1)}},Z=class extends n.DependencyManagerBaseService{constructor(...e){super(...e),C(this,`_dependencyEngineCache`,new X({maxRows:1048576,maxCols:16384}))}reset(){this._dependencyEngineCache.reset()}_getCellIdsAndRanges(e){let t=[],n=[];for(let r=0;r<e.rangeList.length;r++){let{unitId:i,sheetId:a,range:o}=e.rangeList[r];if(o.startRow===o.endRow&&o.startColumn===o.endColumn){let e=this._dependencyEngineCache.encodeCell(i,a,o.startRow,o.startColumn);t.push(e)}else n.push({unitId:i,sheetId:a,range:o})}return{cellIds:t,ranges:n}}_getDynamicDeps(e,t,n,r){if(!(!e.addressFunctionNodes||e.addressFunctionNodes.length===0))return[{id:`address-functions`,paramDeps:{cells:t,ranges:n,nodes:r}}]}addOtherFormulaDependencyPro(e,t,n,r,i,a=`replace`){let{cellIds:o,ranges:s}=this._getCellIdsAndRanges(r),c=this._getDynamicDeps(r,o,s,i),l=r.refOffsetX||0,u=r.refOffsetY||0,d=this._dependencyEngineCache.encodeOtherFormulaId(e,t,n,l,u);return this._dependencyEngineCache.setOtherFormulaDeps(d,{cells:o,ranges:s,nodes:i,dynamics:c},{checkCycle:!1,markDirty:!1,mode:a}).nodeIndex}removeOtherFormulaDependency(e,t,n){this._dependencyEngineCache.clearOtherFormulas(e,t,n,void 0,void 0,{markDependentsDirty:!0})}clearOtherFormulaDependency(e,t){t?this._dependencyEngineCache.clearOtherFormulas(e,t,void 0,void 0,void 0,{markDependentsDirty:!0}):this._dependencyEngineCache.clearOtherFormulas(e,void 0,void 0,void 0,void 0,{markDependentsDirty:!0})}getOtherFormulaDependencyPro(e,t,n,r,i){let a=this._dependencyEngineCache.encodeOtherFormulaId(e,t,n,r,i);if(this._dependencyEngineCache.hasOtherFormula(a))return this._dependencyEngineCache.getNodeIndex({type:2,id:a})}addFeatureFormulaDependencyPro(e,t,n,r){let{cellIds:i,ranges:a}=this._getCellIdsAndRanges(r),o=this._dependencyEngineCache.encodeFeatureCalculationId(e,t,n);return this._dependencyEngineCache.setFeatureCalculationDeps(o,{cells:i,ranges:a},{checkCycle:!1,markDirty:!1}).nodeIndex}removeFeatureFormulaDependency(e,t,n){let r=n.map(n=>this._dependencyEngineCache.encodeFeatureCalculationId(e,t,n));this._dependencyEngineCache.removeFeatureCalculations(r,{markDependentsDirty:!0,detachDependents:!0})}clearFeatureFormulaDependency(e,t){t?this._dependencyEngineCache.clearFeatureCalculations(e,t,{markDependentsDirty:!0,detachDependents:!0}):this._dependencyEngineCache.clearFeatureCalculations(e,void 0,{markDependentsDirty:!0,detachDependents:!0})}getFeatureFormulaDependencyPro(e,t,n){let r=this._dependencyEngineCache.encodeFeatureCalculationId(e,t,n);if(this._dependencyEngineCache.hasFeatureCalculation(r))return this._dependencyEngineCache.getNodeIndex({type:3,id:r})}getFeatureFormulaDependencyNodePro(e,t,n){return{type:3,id:this._dependencyEngineCache.encodeFeatureCalculationId(e,t,n)}}addFormulaDependencyPro(e,t,n,r,i,a,o=`replace`){let s=this._dependencyEngineCache.encodeCell(e,t,n,r),{cellIds:c,ranges:l}=this._getCellIdsAndRanges(i),u=this._getDynamicDeps(i,c,l,a);return this._dependencyEngineCache.setCellFormulaDeps(s,{cells:c,ranges:l,nodes:a,dynamics:u},{checkCycle:!1,markDirty:!1,mode:o}).nodeIndex}addFormulaDependencyNodeOnlyPro(e,t,n,r){let i=this._dependencyEngineCache.encodeCell(e,t,n,r);return this._dependencyEngineCache.setCellFormulaDeps(i,{},{checkCycle:!1,markDirty:!1}).nodeIndex}registerCompressedSharedFormulaGroup(e){this._dependencyEngineCache.registerCompressedSharedFormulaGroup(e)}clearCompressedSharedFormulaGroups(e,t){this._dependencyEngineCache.clearCompressedSharedFormulaGroups(e,t)}removeFormulaDependency(e,t,n,r){let i=this._dependencyEngineCache.encodeCell(e,t,n,r);this._dependencyEngineCache.removeCellFormula(i,{markDependentsDirty:!0})}clearFormulaDependency(e,t){this._dependencyEngineCache.clearCompressedSharedFormulaGroups(e,t),t?this._dependencyEngineCache.clearCellFormulas(e,t,{markDependentsDirty:!0}):this._dependencyEngineCache.clearCellFormulas(e,void 0,{markDependentsDirty:!0})}getFormulaDependencyPro(e,t,n,r){let i=this._dependencyEngineCache.encodeCell(e,t,n,r);if(this._dependencyEngineCache.hasCellFormula(i))return this._dependencyEngineCache.getNodeIndex({type:1,id:i})}markIndicesChanged(e,t){this._dependencyEngineCache.markCalcNodeIndicesChanged(e,t)}markRangesChanged(e,t){this._dependencyEngineCache.markRangesChanged(e,t)}markDirtyFeatureCalculations(e){let t=[];Object.keys(e).forEach(n=>{let r=e[n];r!=null&&Object.keys(r).forEach(e=>{let i=r[e];i!=null&&Object.keys(i).forEach(r=>{t.push(this.getFeatureFormulaDependencyNodePro(n,e,r))})})}),this._dependencyEngineCache.markCalcNodesChanged(t)}markDirtyOtherFormulas(e){Object.keys(e).forEach(t=>{let n=e[t];n!=null&&Object.keys(n).forEach(e=>{let r=n[e];r!=null&&this._dependencyEngineCache.markOtherFormulasChanged(t,e,Object.keys(r))})})}markDirtySheetNames(e){let t=[];Object.keys(e).forEach(n=>{let r=e[n];r!=null&&Object.keys(r).forEach(e=>{t.push({unitId:n,sheetId:e,range:{startRow:0,endRow:1048575,startColumn:0,endColumn:16383}})})}),this._dependencyEngineCache.markRangesChanged(t,{includeFormulaCells:!1})}markAllDirty(){this._dependencyEngineCache.markAllDirty()}clearCalculatedDirty(e){this._dependencyEngineCache.clearCalculatedDirty(e)}hasDynamicDeps(e){return this._dependencyEngineCache.hasDynamicDeps(e)}hasDynamicDepsByIndex(e){return this._dependencyEngineCache.hasDynamicDeps(this._dependencyEngineCache.getNodeRefByIndex(e))}refreshDynamicDeps(e,t){return this._dependencyEngineCache.refreshDynamicDeps(e,t)}refreshDynamicDepsByIndex(e,t){return this._dependencyEngineCache.refreshDynamicDeps(this._dependencyEngineCache.getNodeRefByIndex(e),t)}hasUncalculatedDirtyPrecedentByIndex(e,t){return this._dependencyEngineCache.hasUncalculatedDirtyPrecedentByIndex(e,t)}forEachPrecedentNodeByIndex(e,t){this._dependencyEngineCache.forEachPrecedentNodeByIndex(e,(e,n)=>{t(n)})}forEachDependentNodeByIndex(e,t){this._dependencyEngineCache.forEachDependentByIndex(e,(e,n)=>{t(n)})}prepareDynamicDependencies(e){return this._dependencyEngineCache.prepareDynamicDependencies(e)}getCalculationOrder(e){return this._dependencyEngineCache.getCalculationOrder(e)}};function Q(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let $=class extends n.UniverFormulaEnginePlugin{_initializeWithOverride(){var e;this._injector.add([n.LexerTreeBuilder,{useClass:n.LexerTreeBuilder}]),(e=this._config)!=null&&e.notExecuteFormula||[[n.ICalculateFormulaService,{useClass:T}],[n.IDependencyManagerService,{useClass:Z}],[n.IFormulaDependencyGenerator,{useClass:w}]].forEach(e=>this._injector.add(e))}};C($,`packageName`,r),C($,`version`,i),$=Q([(0,t.DependentOn)(e.UniverLicensePlugin)],$),Object.defineProperty(exports,`UniverProFormulaEnginePlugin`,{enumerable:!0,get:function(){return $}}),Object.keys(n).forEach(function(e){e!==`default`&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return n[e]}})});
|
package/lib/es/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x2c9df4,_0x14134d){var _0x7affa6=_0x5e13,_0x2c61ec=_0x2c9df4();while(!![]){try{var _0x25d0ef=-parseInt(_0x7affa6(0x14c))/0x1+parseInt(_0x7affa6(0x14e))/0x2+parseInt(_0x7affa6(0x14f))/0x3+-parseInt(_0x7affa6(0x151))/0x4+-parseInt(_0x7affa6(0x14b))/0x5*(parseInt(_0x7affa6(0x153))/0x6)+-parseInt(_0x7affa6(0x14d))/0x7*(parseInt(_0x7affa6(0x154))/0x8)+-parseInt(_0x7affa6(0x152))/0x9*(-parseInt(_0x7affa6(0x150))/0xa);if(_0x25d0ef===_0x14134d)break;else _0x2c61ec['push'](_0x2c61ec['shift']());}catch(_0x7eda92){_0x2c61ec['push'](_0x2c61ec['shift']());}}}(_0xc1dc,0x38bf7));function _0x5e13(_0x3e48a5,_0x4ab9e7){_0x3e48a5=_0x3e48a5-0x14b;var _0xc1dc4=_0xc1dc();var _0x5e13a6=_0xc1dc4[_0x3e48a5];return _0x5e13a6;}function _0xc1dc(){var _0x4def97=['10hnraAl','404022smHIPF','7KncEGA','263404UaXwrS','53235VifXJi','10WsaVfF','1254908QYcYoZ','8210880GqOGed','147990jvXswy','497992yFHuSn'];_0xc1dc=function(){return _0x4def97;};return _0xc1dc();}import{FFormula as _0x83c883}from'@univerjs/engine-formula/facade';export{_0x83c883 as FFormula};
|