@odoo/o-spreadsheet 15.2.14 → 15.2.15

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.
@@ -18786,13 +18786,18 @@ class EvaluationPlugin extends UIPlugin {
18786
18786
  // Getters
18787
18787
  // ---------------------------------------------------------------------------
18788
18788
  evaluateFormula(formulaString, sheetId = this.getters.getActiveSheetId()) {
18789
- const compiledFormula = compile(formulaString);
18790
- const params = this.getFormulaParameters(() => { });
18791
- const ranges = [];
18792
- for (let xc of compiledFormula.dependencies) {
18793
- ranges.push(this.getters.getRangeFromSheetXC(sheetId, xc));
18789
+ try {
18790
+ const compiledFormula = compile(formulaString);
18791
+ const params = this.getFormulaParameters(() => { });
18792
+ const ranges = [];
18793
+ for (let xc of compiledFormula.dependencies) {
18794
+ ranges.push(this.getters.getRangeFromSheetXC(sheetId, xc));
18795
+ }
18796
+ return compiledFormula.execute(ranges, sheetId, ...params);
18797
+ }
18798
+ catch {
18799
+ return "#ERROR";
18794
18800
  }
18795
- return compiledFormula.execute(ranges, sheetId, ...params);
18796
18801
  }
18797
18802
  /**
18798
18803
  * Return the value of each cell in the range as they are displayed in the grid.
@@ -19285,25 +19290,26 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
19285
19290
  */
19286
19291
  this.rulePredicate = {
19287
19292
  CellIsRule: (cell, rule) => {
19293
+ var _a, _b, _c, _d, _e, _f;
19288
19294
  if (cell && cell.evaluated.type === CellValueType.error) {
19289
19295
  return false;
19290
19296
  }
19291
19297
  const values = rule.values.map(parsePrimitiveContent);
19292
19298
  switch (rule.operator) {
19293
19299
  case "IsEmpty":
19294
- return !isDefined(cell) || cell.evaluated.value.toString().trim() === "";
19300
+ return !isDefined(cell) || ((_a = cell.evaluated.value) === null || _a === void 0 ? void 0 : _a.toString().trim()) === "";
19295
19301
  case "IsNotEmpty":
19296
- return isDefined(cell) && cell.evaluated.value.toString().trim() !== "";
19302
+ return isDefined(cell) && ((_b = cell.evaluated.value) === null || _b === void 0 ? void 0 : _b.toString().trim()) !== "";
19297
19303
  case "BeginsWith":
19298
19304
  if (!cell && values[0] === "") {
19299
19305
  return false;
19300
19306
  }
19301
- return (isDefined(cell) && (cell === null || cell === void 0 ? void 0 : cell.evaluated.value.toString().startsWith(values[0].toString())));
19307
+ return (isDefined(cell) && ((_c = cell.evaluated.value) === null || _c === void 0 ? void 0 : _c.toString().startsWith(values[0].toString())));
19302
19308
  case "EndsWith":
19303
19309
  if (!cell && values[0] === "") {
19304
19310
  return false;
19305
19311
  }
19306
- return isDefined(cell) && cell.evaluated.value.toString().endsWith(values[0].toString());
19312
+ return isDefined(cell) && ((_d = cell.evaluated.value) === null || _d === void 0 ? void 0 : _d.toString().endsWith(values[0].toString()));
19307
19313
  case "Between":
19308
19314
  return (isDefined(cell) &&
19309
19315
  cell.evaluated.value >= values[0] &&
@@ -19313,11 +19319,11 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
19313
19319
  cell.evaluated.value >= values[0] &&
19314
19320
  cell.evaluated.value <= values[1]);
19315
19321
  case "ContainsText":
19316
- return (isDefined(cell) && cell.evaluated.value.toString().indexOf(values[0].toString()) > -1);
19322
+ return (isDefined(cell) && ((_e = cell.evaluated.value) === null || _e === void 0 ? void 0 : _e.toString().indexOf(values[0].toString())) > -1);
19317
19323
  case "NotContains":
19318
19324
  return (!isDefined(cell) ||
19319
19325
  !cell.evaluated.value ||
19320
- cell.evaluated.value.toString().indexOf(values[0].toString()) == -1);
19326
+ ((_f = cell.evaluated.value) === null || _f === void 0 ? void 0 : _f.toString().indexOf(values[0].toString())) == -1);
19321
19327
  case "GreaterThan":
19322
19328
  return isDefined(cell) && cell.evaluated.value > values[0];
19323
19329
  case "GreaterThanOrEqual":
@@ -19426,39 +19432,34 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
19426
19432
  this.computedIcons[activeSheetId] = {};
19427
19433
  const computedStyle = this.computedStyles[activeSheetId];
19428
19434
  for (let cf of this.getters.getConditionalFormats(activeSheetId)) {
19429
- try {
19430
- switch (cf.rule.type) {
19431
- case "ColorScaleRule":
19432
- for (let range of cf.ranges) {
19433
- this.applyColorScale(range, cf.rule);
19434
- }
19435
- break;
19436
- case "IconSetRule":
19437
- for (let range of cf.ranges) {
19438
- this.applyIcon(range, cf.rule);
19439
- }
19440
- break;
19441
- default:
19442
- for (let ref of cf.ranges) {
19443
- const zone = toZone(ref);
19444
- for (let row = zone.top; row <= zone.bottom; row++) {
19445
- for (let col = zone.left; col <= zone.right; col++) {
19446
- const pr = this.rulePredicate[cf.rule.type];
19447
- let cell = this.getters.getCell(activeSheetId, col, row);
19448
- if (pr && pr(cell, cf.rule)) {
19449
- if (!computedStyle[col])
19450
- computedStyle[col] = [];
19451
- // we must combine all the properties of all the CF rules applied to the given cell
19452
- computedStyle[col][row] = Object.assign(((_a = computedStyle[col]) === null || _a === void 0 ? void 0 : _a[row]) || {}, cf.rule.style);
19453
- }
19435
+ switch (cf.rule.type) {
19436
+ case "ColorScaleRule":
19437
+ for (let range of cf.ranges) {
19438
+ this.applyColorScale(range, cf.rule);
19439
+ }
19440
+ break;
19441
+ case "IconSetRule":
19442
+ for (let range of cf.ranges) {
19443
+ this.applyIcon(range, cf.rule);
19444
+ }
19445
+ break;
19446
+ default:
19447
+ for (let ref of cf.ranges) {
19448
+ const zone = toZone(ref);
19449
+ for (let row = zone.top; row <= zone.bottom; row++) {
19450
+ for (let col = zone.left; col <= zone.right; col++) {
19451
+ const pr = this.rulePredicate[cf.rule.type];
19452
+ let cell = this.getters.getCell(activeSheetId, col, row);
19453
+ if (pr && pr(cell, cf.rule)) {
19454
+ if (!computedStyle[col])
19455
+ computedStyle[col] = [];
19456
+ // we must combine all the properties of all the CF rules applied to the given cell
19457
+ computedStyle[col][row] = Object.assign(((_a = computedStyle[col]) === null || _a === void 0 ? void 0 : _a[row]) || {}, cf.rule.style);
19454
19458
  }
19455
19459
  }
19456
19460
  }
19457
- break;
19458
- }
19459
- }
19460
- catch (_) {
19461
- // we don't care about the errors within the evaluation of a rule
19461
+ }
19462
+ break;
19462
19463
  }
19463
19464
  }
19464
19465
  }
@@ -19477,7 +19478,7 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
19477
19478
  return this.getters.evaluateFormula(`=PERCENTILE(${range},${Number(threshold.value) / 100})`);
19478
19479
  case "formula":
19479
19480
  const value = threshold.value && this.getters.evaluateFormula(threshold.value);
19480
- return !(value instanceof Promise) ? value : null;
19481
+ return typeof value === "number" ? value : null;
19481
19482
  default:
19482
19483
  return null;
19483
19484
  }
@@ -31440,6 +31441,6 @@ exports.registries = registries;
31440
31441
  exports.setTranslationMethod = setTranslationMethod;
31441
31442
 
31442
31443
 
31443
- __info__.version = '15.2.14';
31444
- __info__.date = '2024-01-12T13:37:05.872Z';
31445
- __info__.hash = '6515f7c';
31444
+ __info__.version = '15.2.15';
31445
+ __info__.date = '2024-01-17T10:22:20.395Z';
31446
+ __info__.hash = 'c78b15d';
@@ -18763,13 +18763,18 @@ class EvaluationPlugin extends UIPlugin {
18763
18763
  // Getters
18764
18764
  // ---------------------------------------------------------------------------
18765
18765
  evaluateFormula(formulaString, sheetId = this.getters.getActiveSheetId()) {
18766
- const compiledFormula = compile(formulaString);
18767
- const params = this.getFormulaParameters(() => { });
18768
- const ranges = [];
18769
- for (let xc of compiledFormula.dependencies) {
18770
- ranges.push(this.getters.getRangeFromSheetXC(sheetId, xc));
18766
+ try {
18767
+ const compiledFormula = compile(formulaString);
18768
+ const params = this.getFormulaParameters(() => { });
18769
+ const ranges = [];
18770
+ for (let xc of compiledFormula.dependencies) {
18771
+ ranges.push(this.getters.getRangeFromSheetXC(sheetId, xc));
18772
+ }
18773
+ return compiledFormula.execute(ranges, sheetId, ...params);
18774
+ }
18775
+ catch {
18776
+ return "#ERROR";
18771
18777
  }
18772
- return compiledFormula.execute(ranges, sheetId, ...params);
18773
18778
  }
18774
18779
  /**
18775
18780
  * Return the value of each cell in the range as they are displayed in the grid.
@@ -19262,25 +19267,26 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
19262
19267
  */
19263
19268
  this.rulePredicate = {
19264
19269
  CellIsRule: (cell, rule) => {
19270
+ var _a, _b, _c, _d, _e, _f;
19265
19271
  if (cell && cell.evaluated.type === CellValueType.error) {
19266
19272
  return false;
19267
19273
  }
19268
19274
  const values = rule.values.map(parsePrimitiveContent);
19269
19275
  switch (rule.operator) {
19270
19276
  case "IsEmpty":
19271
- return !isDefined(cell) || cell.evaluated.value.toString().trim() === "";
19277
+ return !isDefined(cell) || ((_a = cell.evaluated.value) === null || _a === void 0 ? void 0 : _a.toString().trim()) === "";
19272
19278
  case "IsNotEmpty":
19273
- return isDefined(cell) && cell.evaluated.value.toString().trim() !== "";
19279
+ return isDefined(cell) && ((_b = cell.evaluated.value) === null || _b === void 0 ? void 0 : _b.toString().trim()) !== "";
19274
19280
  case "BeginsWith":
19275
19281
  if (!cell && values[0] === "") {
19276
19282
  return false;
19277
19283
  }
19278
- return (isDefined(cell) && (cell === null || cell === void 0 ? void 0 : cell.evaluated.value.toString().startsWith(values[0].toString())));
19284
+ return (isDefined(cell) && ((_c = cell.evaluated.value) === null || _c === void 0 ? void 0 : _c.toString().startsWith(values[0].toString())));
19279
19285
  case "EndsWith":
19280
19286
  if (!cell && values[0] === "") {
19281
19287
  return false;
19282
19288
  }
19283
- return isDefined(cell) && cell.evaluated.value.toString().endsWith(values[0].toString());
19289
+ return isDefined(cell) && ((_d = cell.evaluated.value) === null || _d === void 0 ? void 0 : _d.toString().endsWith(values[0].toString()));
19284
19290
  case "Between":
19285
19291
  return (isDefined(cell) &&
19286
19292
  cell.evaluated.value >= values[0] &&
@@ -19290,11 +19296,11 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
19290
19296
  cell.evaluated.value >= values[0] &&
19291
19297
  cell.evaluated.value <= values[1]);
19292
19298
  case "ContainsText":
19293
- return (isDefined(cell) && cell.evaluated.value.toString().indexOf(values[0].toString()) > -1);
19299
+ return (isDefined(cell) && ((_e = cell.evaluated.value) === null || _e === void 0 ? void 0 : _e.toString().indexOf(values[0].toString())) > -1);
19294
19300
  case "NotContains":
19295
19301
  return (!isDefined(cell) ||
19296
19302
  !cell.evaluated.value ||
19297
- cell.evaluated.value.toString().indexOf(values[0].toString()) == -1);
19303
+ ((_f = cell.evaluated.value) === null || _f === void 0 ? void 0 : _f.toString().indexOf(values[0].toString())) == -1);
19298
19304
  case "GreaterThan":
19299
19305
  return isDefined(cell) && cell.evaluated.value > values[0];
19300
19306
  case "GreaterThanOrEqual":
@@ -19403,39 +19409,34 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
19403
19409
  this.computedIcons[activeSheetId] = {};
19404
19410
  const computedStyle = this.computedStyles[activeSheetId];
19405
19411
  for (let cf of this.getters.getConditionalFormats(activeSheetId)) {
19406
- try {
19407
- switch (cf.rule.type) {
19408
- case "ColorScaleRule":
19409
- for (let range of cf.ranges) {
19410
- this.applyColorScale(range, cf.rule);
19411
- }
19412
- break;
19413
- case "IconSetRule":
19414
- for (let range of cf.ranges) {
19415
- this.applyIcon(range, cf.rule);
19416
- }
19417
- break;
19418
- default:
19419
- for (let ref of cf.ranges) {
19420
- const zone = toZone(ref);
19421
- for (let row = zone.top; row <= zone.bottom; row++) {
19422
- for (let col = zone.left; col <= zone.right; col++) {
19423
- const pr = this.rulePredicate[cf.rule.type];
19424
- let cell = this.getters.getCell(activeSheetId, col, row);
19425
- if (pr && pr(cell, cf.rule)) {
19426
- if (!computedStyle[col])
19427
- computedStyle[col] = [];
19428
- // we must combine all the properties of all the CF rules applied to the given cell
19429
- computedStyle[col][row] = Object.assign(((_a = computedStyle[col]) === null || _a === void 0 ? void 0 : _a[row]) || {}, cf.rule.style);
19430
- }
19412
+ switch (cf.rule.type) {
19413
+ case "ColorScaleRule":
19414
+ for (let range of cf.ranges) {
19415
+ this.applyColorScale(range, cf.rule);
19416
+ }
19417
+ break;
19418
+ case "IconSetRule":
19419
+ for (let range of cf.ranges) {
19420
+ this.applyIcon(range, cf.rule);
19421
+ }
19422
+ break;
19423
+ default:
19424
+ for (let ref of cf.ranges) {
19425
+ const zone = toZone(ref);
19426
+ for (let row = zone.top; row <= zone.bottom; row++) {
19427
+ for (let col = zone.left; col <= zone.right; col++) {
19428
+ const pr = this.rulePredicate[cf.rule.type];
19429
+ let cell = this.getters.getCell(activeSheetId, col, row);
19430
+ if (pr && pr(cell, cf.rule)) {
19431
+ if (!computedStyle[col])
19432
+ computedStyle[col] = [];
19433
+ // we must combine all the properties of all the CF rules applied to the given cell
19434
+ computedStyle[col][row] = Object.assign(((_a = computedStyle[col]) === null || _a === void 0 ? void 0 : _a[row]) || {}, cf.rule.style);
19431
19435
  }
19432
19436
  }
19433
19437
  }
19434
- break;
19435
- }
19436
- }
19437
- catch (_) {
19438
- // we don't care about the errors within the evaluation of a rule
19438
+ }
19439
+ break;
19439
19440
  }
19440
19441
  }
19441
19442
  }
@@ -19454,7 +19455,7 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
19454
19455
  return this.getters.evaluateFormula(`=PERCENTILE(${range},${Number(threshold.value) / 100})`);
19455
19456
  case "formula":
19456
19457
  const value = threshold.value && this.getters.evaluateFormula(threshold.value);
19457
- return !(value instanceof Promise) ? value : null;
19458
+ return typeof value === "number" ? value : null;
19458
19459
  default:
19459
19460
  return null;
19460
19461
  }
@@ -31394,6 +31395,6 @@ const helpers = {
31394
31395
  export { CommandResult, CorePlugin, DATETIME_FORMAT, DataSource, DispatchResult, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, DEBUG as __DEBUG__, __info__, astToFormula, cellTypes, compile, convertAstNodes, coreTypes, functionCache, helpers, invalidateEvaluationCommands, parse, readonlyAllowedCommands, registries, setTranslationMethod };
31395
31396
 
31396
31397
 
31397
- __info__.version = '15.2.14';
31398
- __info__.date = '2024-01-12T13:37:05.872Z';
31399
- __info__.hash = '6515f7c';
31398
+ __info__.version = '15.2.15';
31399
+ __info__.date = '2024-01-17T10:22:20.395Z';
31400
+ __info__.hash = 'c78b15d';
@@ -18783,13 +18783,18 @@
18783
18783
  // Getters
18784
18784
  // ---------------------------------------------------------------------------
18785
18785
  evaluateFormula(formulaString, sheetId = this.getters.getActiveSheetId()) {
18786
- const compiledFormula = compile(formulaString);
18787
- const params = this.getFormulaParameters(() => { });
18788
- const ranges = [];
18789
- for (let xc of compiledFormula.dependencies) {
18790
- ranges.push(this.getters.getRangeFromSheetXC(sheetId, xc));
18786
+ try {
18787
+ const compiledFormula = compile(formulaString);
18788
+ const params = this.getFormulaParameters(() => { });
18789
+ const ranges = [];
18790
+ for (let xc of compiledFormula.dependencies) {
18791
+ ranges.push(this.getters.getRangeFromSheetXC(sheetId, xc));
18792
+ }
18793
+ return compiledFormula.execute(ranges, sheetId, ...params);
18794
+ }
18795
+ catch {
18796
+ return "#ERROR";
18791
18797
  }
18792
- return compiledFormula.execute(ranges, sheetId, ...params);
18793
18798
  }
18794
18799
  /**
18795
18800
  * Return the value of each cell in the range as they are displayed in the grid.
@@ -19282,25 +19287,26 @@
19282
19287
  */
19283
19288
  this.rulePredicate = {
19284
19289
  CellIsRule: (cell, rule) => {
19290
+ var _a, _b, _c, _d, _e, _f;
19285
19291
  if (cell && cell.evaluated.type === CellValueType.error) {
19286
19292
  return false;
19287
19293
  }
19288
19294
  const values = rule.values.map(parsePrimitiveContent);
19289
19295
  switch (rule.operator) {
19290
19296
  case "IsEmpty":
19291
- return !isDefined(cell) || cell.evaluated.value.toString().trim() === "";
19297
+ return !isDefined(cell) || ((_a = cell.evaluated.value) === null || _a === void 0 ? void 0 : _a.toString().trim()) === "";
19292
19298
  case "IsNotEmpty":
19293
- return isDefined(cell) && cell.evaluated.value.toString().trim() !== "";
19299
+ return isDefined(cell) && ((_b = cell.evaluated.value) === null || _b === void 0 ? void 0 : _b.toString().trim()) !== "";
19294
19300
  case "BeginsWith":
19295
19301
  if (!cell && values[0] === "") {
19296
19302
  return false;
19297
19303
  }
19298
- return (isDefined(cell) && (cell === null || cell === void 0 ? void 0 : cell.evaluated.value.toString().startsWith(values[0].toString())));
19304
+ return (isDefined(cell) && ((_c = cell.evaluated.value) === null || _c === void 0 ? void 0 : _c.toString().startsWith(values[0].toString())));
19299
19305
  case "EndsWith":
19300
19306
  if (!cell && values[0] === "") {
19301
19307
  return false;
19302
19308
  }
19303
- return isDefined(cell) && cell.evaluated.value.toString().endsWith(values[0].toString());
19309
+ return isDefined(cell) && ((_d = cell.evaluated.value) === null || _d === void 0 ? void 0 : _d.toString().endsWith(values[0].toString()));
19304
19310
  case "Between":
19305
19311
  return (isDefined(cell) &&
19306
19312
  cell.evaluated.value >= values[0] &&
@@ -19310,11 +19316,11 @@
19310
19316
  cell.evaluated.value >= values[0] &&
19311
19317
  cell.evaluated.value <= values[1]);
19312
19318
  case "ContainsText":
19313
- return (isDefined(cell) && cell.evaluated.value.toString().indexOf(values[0].toString()) > -1);
19319
+ return (isDefined(cell) && ((_e = cell.evaluated.value) === null || _e === void 0 ? void 0 : _e.toString().indexOf(values[0].toString())) > -1);
19314
19320
  case "NotContains":
19315
19321
  return (!isDefined(cell) ||
19316
19322
  !cell.evaluated.value ||
19317
- cell.evaluated.value.toString().indexOf(values[0].toString()) == -1);
19323
+ ((_f = cell.evaluated.value) === null || _f === void 0 ? void 0 : _f.toString().indexOf(values[0].toString())) == -1);
19318
19324
  case "GreaterThan":
19319
19325
  return isDefined(cell) && cell.evaluated.value > values[0];
19320
19326
  case "GreaterThanOrEqual":
@@ -19423,39 +19429,34 @@
19423
19429
  this.computedIcons[activeSheetId] = {};
19424
19430
  const computedStyle = this.computedStyles[activeSheetId];
19425
19431
  for (let cf of this.getters.getConditionalFormats(activeSheetId)) {
19426
- try {
19427
- switch (cf.rule.type) {
19428
- case "ColorScaleRule":
19429
- for (let range of cf.ranges) {
19430
- this.applyColorScale(range, cf.rule);
19431
- }
19432
- break;
19433
- case "IconSetRule":
19434
- for (let range of cf.ranges) {
19435
- this.applyIcon(range, cf.rule);
19436
- }
19437
- break;
19438
- default:
19439
- for (let ref of cf.ranges) {
19440
- const zone = toZone(ref);
19441
- for (let row = zone.top; row <= zone.bottom; row++) {
19442
- for (let col = zone.left; col <= zone.right; col++) {
19443
- const pr = this.rulePredicate[cf.rule.type];
19444
- let cell = this.getters.getCell(activeSheetId, col, row);
19445
- if (pr && pr(cell, cf.rule)) {
19446
- if (!computedStyle[col])
19447
- computedStyle[col] = [];
19448
- // we must combine all the properties of all the CF rules applied to the given cell
19449
- computedStyle[col][row] = Object.assign(((_a = computedStyle[col]) === null || _a === void 0 ? void 0 : _a[row]) || {}, cf.rule.style);
19450
- }
19432
+ switch (cf.rule.type) {
19433
+ case "ColorScaleRule":
19434
+ for (let range of cf.ranges) {
19435
+ this.applyColorScale(range, cf.rule);
19436
+ }
19437
+ break;
19438
+ case "IconSetRule":
19439
+ for (let range of cf.ranges) {
19440
+ this.applyIcon(range, cf.rule);
19441
+ }
19442
+ break;
19443
+ default:
19444
+ for (let ref of cf.ranges) {
19445
+ const zone = toZone(ref);
19446
+ for (let row = zone.top; row <= zone.bottom; row++) {
19447
+ for (let col = zone.left; col <= zone.right; col++) {
19448
+ const pr = this.rulePredicate[cf.rule.type];
19449
+ let cell = this.getters.getCell(activeSheetId, col, row);
19450
+ if (pr && pr(cell, cf.rule)) {
19451
+ if (!computedStyle[col])
19452
+ computedStyle[col] = [];
19453
+ // we must combine all the properties of all the CF rules applied to the given cell
19454
+ computedStyle[col][row] = Object.assign(((_a = computedStyle[col]) === null || _a === void 0 ? void 0 : _a[row]) || {}, cf.rule.style);
19451
19455
  }
19452
19456
  }
19453
19457
  }
19454
- break;
19455
- }
19456
- }
19457
- catch (_) {
19458
- // we don't care about the errors within the evaluation of a rule
19458
+ }
19459
+ break;
19459
19460
  }
19460
19461
  }
19461
19462
  }
@@ -19474,7 +19475,7 @@
19474
19475
  return this.getters.evaluateFormula(`=PERCENTILE(${range},${Number(threshold.value) / 100})`);
19475
19476
  case "formula":
19476
19477
  const value = threshold.value && this.getters.evaluateFormula(threshold.value);
19477
- return !(value instanceof Promise) ? value : null;
19478
+ return typeof value === "number" ? value : null;
19478
19479
  default:
19479
19480
  return null;
19480
19481
  }
@@ -31439,9 +31440,9 @@
31439
31440
  Object.defineProperty(exports, '__esModule', { value: true });
31440
31441
 
31441
31442
 
31442
- __info__.version = '15.2.14';
31443
- __info__.date = '2024-01-12T13:37:05.872Z';
31444
- __info__.hash = '6515f7c';
31443
+ __info__.version = '15.2.15';
31444
+ __info__.date = '2024-01-17T10:22:20.395Z';
31445
+ __info__.hash = 'c78b15d';
31445
31446
 
31446
31447
 
31447
31448
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);
@@ -1045,7 +1045,7 @@
1045
1045
  }
1046
1046
  }
1047
1047
  }
1048
- `;class bh extends t.Component{constructor(){super(...arguments),this.getters=this.env.getters,this.state=t.useState(this.initialState())}get hasSearchResult(){return null!==this.env.getters.getCurrentSelectedMatchIndex()}setup(){ph((()=>this.focusInput())),gh((()=>this.env.dispatch("CLEAR_SEARCH")))}onInput(e){this.state.toSearch=e.target.value,this.debouncedUpdateSearch()}onKeydownSearch(e){"Enter"===e.key&&(e.preventDefault(),this.onSelectNextCell())}onKeydownReplace(e){"Enter"===e.key&&(e.preventDefault(),this.replace())}onFocusSidePanel(){this.state.searchOptions.searchFormulas=this.getters.shouldShowFormulas(),this.state.replaceOptions.modifyFormulas=this.state.searchOptions.searchFormulas?this.state.searchOptions.searchFormulas:this.state.replaceOptions.modifyFormulas,this.env.dispatch("REFRESH_SEARCH")}searchFormulas(){this.env.dispatch("SET_FORMULA_VISIBILITY",{show:this.state.searchOptions.searchFormulas}),this.state.replaceOptions.modifyFormulas=this.state.searchOptions.searchFormulas,this.updateSearch()}onSelectPreviousCell(){this.env.dispatch("SELECT_SEARCH_PREVIOUS_MATCH")}onSelectNextCell(){this.env.dispatch("SELECT_SEARCH_NEXT_MATCH")}updateSearch(){this.env.dispatch("UPDATE_SEARCH",{toSearch:this.state.toSearch,searchOptions:this.state.searchOptions})}debouncedUpdateSearch(){clearTimeout(this.inDebounce),this.inDebounce=setTimeout((()=>this.updateSearch.call(this)),400)}replace(){this.env.dispatch("REPLACE_SEARCH",{replaceWith:this.state.replaceWith,replaceOptions:this.state.replaceOptions})}replaceAll(){this.env.dispatch("REPLACE_ALL_SEARCH",{replaceWith:this.state.replaceWith,replaceOptions:this.state.replaceOptions})}focusInput(){const e=this.el.querySelector("input");e&&e.focus()}initialState(){return{toSearch:"",replaceWith:"",searchOptions:{matchCase:!1,exactMatch:!1,searchFormulas:!1},replaceOptions:{modifyFormulas:!1}}}}bh.template=vh,bh.style=Eh;const Sh=new Ae;Sh.add("ConditionalFormatting",{title:a("Conditional formatting"),Body:uh}),Sh.add("ChartPanel",{title:a("Chart"),Body:zc}),Sh.add("FindAndReplace",{title:a("Find and Replace"),Body:bh});const Ch=new Ae;class yh extends ma{constructor(e,t,s,o){super(t,s,o),this.getters=e,this.ui=o}drawGrid(e,t){}}yh.layers=[];class wh{constructor(e,t,s){this.index=0,this.cells=e,this.getters=t,this.direction=s}next(){const e=this.cells[this.index++%this.cells.length],t=e.rule,{cellData:s,tooltip:o}=Ma.get(t.type).apply(t,e.data,this.getters,this.direction);return{cellData:s,tooltip:o,origin:{col:e.data.col,row:e.data.row}}}}class Ih extends yh{constructor(){super(...arguments),this.lastCellSelected={}}allowDispatch(e){switch(e.type){case"AUTOFILL_SELECT":const t=this.getters.getActiveSheetId();return this.lastCellSelected.col=-1===e.col?this.lastCellSelected.col:ms(e.col,0,this.getters.getSheet(t).cols.length),this.lastCellSelected.row=-1===e.row?this.lastCellSelected.row:ms(e.row,0,this.getters.getSheet(t).rows.length),void 0!==this.lastCellSelected.col&&void 0!==this.lastCellSelected.row?0:30;case"AUTOFILL_AUTO":const s=this.getters.getSelectedZone();return s.top===s.bottom?0:1}return 0}handle(e){switch(e.type){case"AUTOFILL":this.autofill(!0);break;case"AUTOFILL_SELECT":this.select(e.col,e.row);break;case"AUTOFILL_AUTO":this.autofillAuto();break;case"AUTOFILL_CELL":this.autoFillMerge(e.originCol,e.originRow,e.col,e.row);const t=this.getters.getActiveSheetId();this.dispatch("UPDATE_CELL",{sheetId:t,col:e.col,row:e.row,style:e.style||null,content:e.content||"",format:e.format||""}),this.dispatch("SET_BORDER",{sheetId:t,col:e.col,row:e.row,border:e.border})}}getAutofillTooltip(){return this.tooltip}autofill(e){if(!this.autofillZone||void 0===this.direction)return void(this.tooltip=void 0);const t=this.getters.getSelectedZone(),s=this.autofillZone;switch(this.direction){case 1:for(let o=t.left;o<=t.right;o++){const i=[];for(let e=t.top;e<=t.bottom;e++)i.push(ns(o,e));const n=this.createGenerator(i);for(let t=s.top;t<=s.bottom;t++)this.computeNewCell(n,o,t,e)}break;case 0:for(let o=t.left;o<=t.right;o++){const i=[];for(let e=t.bottom;e>=t.top;e--)i.push(ns(o,e));const n=this.createGenerator(i);for(let t=s.bottom;t>=s.top;t--)this.computeNewCell(n,o,t,e)}break;case 2:for(let o=t.top;o<=t.bottom;o++){const i=[];for(let e=t.right;e>=t.left;e--)i.push(ns(e,o));const n=this.createGenerator(i);for(let t=s.right;t>=s.left;t--)this.computeNewCell(n,t,o,e)}break;case 3:for(let o=t.top;o<=t.bottom;o++){const i=[];for(let e=t.left;e<=t.right;e++)i.push(ns(e,o));const n=this.createGenerator(i);for(let t=s.left;t<=s.right;t++)this.computeNewCell(n,t,o,e)}}if(e){const e=Qs(this.getters.getSelectedZone(),this.autofillZone);this.autofillZone=void 0,this.lastCellSelected={},this.direction=void 0,this.tooltip=void 0,this.dispatch("SET_SELECTION",{zones:[e],anchor:[e.left,e.top],anchorZone:e})}}select(e,t){const s=this.getters.getSelectedZone();if(to(e,t,s))this.autofillZone=void 0;else{switch(this.direction=this.getDirection(e,t),this.direction){case 0:this.saveZone(t,s.top-1,s.left,s.right);break;case 1:this.saveZone(s.bottom+1,t,s.left,s.right);break;case 2:this.saveZone(s.top,s.bottom,e,s.left-1);break;case 3:this.saveZone(s.top,s.bottom,s.right+1,e)}this.autofill(!1)}}autofillAuto(){const e=this.getters.getSelectedZone(),t=this.getters.getActiveSheetId();let s=e.left,o=e.bottom;if(s>0){let e=this.getters.getCell(t,s-1,o);for(;e&&!e.isEmpty();)o+=1,e=this.getters.getCell(t,s-1,o)}if(o===e.bottom&&(s=e.right,s<=this.getters.getActiveSheet().cols.length)){let e=this.getters.getCell(t,s+1,o);for(;e&&!e.isEmpty();)o+=1,e=this.getters.getCell(t,s+1,o)}o!==e.bottom&&(this.select(e.left,o-1),this.autofill(!0))}computeNewCell(e,t,s,o){const{cellData:i,tooltip:n,origin:r}=e.next(),{content:a,style:l,border:c,format:h}=i;this.tooltip=n,o&&this.dispatch("AUTOFILL_CELL",{originCol:r.col,originRow:r.row,col:t,row:s,content:a,style:l,border:c,format:h})}getRule(e,t){const s=Aa.getAll().sort(((e,t)=>e.sequence-t.sequence)).find((s=>s.condition(e,t)));return s&&s.generateRule(e,t)}createGenerator(e){const t=[],s=[],o=this.getters.getActiveSheetId();for(let t of e){const[e,i]=is(t),n=this.getters.getCell(o,e,i);s.push({col:e,row:i,cell:n,sheetId:o})}const i=s.map((e=>e.cell));for(let e of s){let s={type:"COPY_MODIFIER"};if(e&&e.cell){s=this.getRule(e.cell,i)||s}const{sheetId:o,col:n,row:r}=e,a=this.getters.getCellBorder(o,n,r)||void 0;t.push({data:{...e,border:a},rule:s})}return new wh(t,this.getters,this.direction)}saveZone(e,t,s,o){this.autofillZone={top:e,bottom:t,left:s,right:o}}getDirection(e,t){const s=this.getters.getSelectedZone(),o={up:{number:s.top-t,value:0},down:{number:t-s.bottom,value:1},left:{number:s.left-e,value:2},right:{number:e-s.right,value:3}};if(1===Object.values(o).map((e=>e.number>0?1:0)).reduce(((e,t)=>e+t)))return Object.values(o).find((e=>e.number>0?1:0)).value;const i=o.up.number>0?"up":"down",n=o.left.number>0?"left":"right";return Math.abs(o[i].number)>=Math.abs(o[n].number)?o[i].value:o[n].value}autoFillMerge(e,t,s,o){const i=this.getters.getActiveSheet();if(this.getters.isInMerge(i.id,s,o)&&!this.getters.isInMerge(i.id,e,t)){const e=this.getters.getMerge(i.id,s,o);e&&this.dispatch("REMOVE_MERGE",{sheetId:i.id,target:[e]})}const n=this.getters.getMerge(i.id,e,t);(null==n?void 0:n.topLeft.col)===e&&(null==n?void 0:n.topLeft.row)===t&&this.dispatch("ADD_MERGE",{sheetId:i.id,target:[{top:o,bottom:o+n.bottom-n.top,left:s,right:s+n.right-n.left}]})}drawGrid(e){if(!this.autofillZone)return;const{viewport:t,ctx:s,thinLineWidth:o}=e,[i,n,r,a]=this.getters.getRect(this.autofillZone,t);r>0&&a>0&&(s.strokeStyle="black",s.lineWidth=o,s.setLineDash([3]),s.strokeRect(i,n,r,a),s.setLineDash([]))}}Ih.layers=[6],Ih.getters=["getAutofillTooltip"],Ih.modes=["normal"];class xh extends yh{handle(e){if("SUM_SELECTION"===e.type){const e=this.getters.getActiveSheetId(),{zones:t,anchor:s}=this.getters.getSelection();for(const o of t){const t=this.getAutomaticSums(e,o,s);this.dispatchCellUpdates(e,t)}}}getAutomaticSums(e,t,s){return this.shouldFindData(e,t)?this.sumAdjacentData(e,t,s):this.sumData(e,t)}sumData(e,t){const s=this.dimensionsToSum(e,t),o=this.sumDimensions(e,t,s).filter((({zone:t})=>!this.getters.isEmpty(e,t)));return s.has("ROW")&&s.has("COL")&&o.push(this.sumTotal(t)),o}sumAdjacentData(e,t,s){const[o,i]=to(s[0],s[1],t)?s:[t.left,t.top],n=this.findAdjacentData(e,o,i);return n?this.getters.isSingleCellOrMerge(e,t)||no(Qs(n,t))?[{position:[o,i],zone:n}]:this.sumDimensions(e,Qs(n,t),this.transpose(this.dimensionsToSum(e,t))):[]}findAdjacentData(e,t,s){const o=this.getters.getSheet(e),i=this.findSuitableZoneToSum(o,...this.getters.getMainCell(e,t,s));if(i)return this.getters.expandZone(e,i)}findSuitableZoneToSum(e,t,s){const o=this.getters.getCell(e.id,t,s-1),i=this.getters.getCell(e.id,t-1,s);if(this.isNumber(i)&&!this.isNumber(o))return this.findHorizontalZone(e,t,s);const n=this.findVerticalZone(e,t,s);if(this.isZoneValid(n))return n;const r=this.findHorizontalZone(e,t,s);return this.isZoneValid(r)?r:void 0}findVerticalZone(e,t,s){const o={top:0,bottom:s-1,left:t,right:t},i=this.reduceZoneStart(e,o,o.bottom);return{...o,top:i}}findHorizontalZone(e,t,s){const o={top:s,bottom:s,left:0,right:t-1},i=this.reduceZoneStart(e,o,o.right);return{...o,left:i}}reduceZoneStart(e,t,s){const o=this.getters.getCellsInZone(e.id,t),i=Es(s,-1,-1),n=i.filter((e=>{var t;return o[e]&&!(null===(t=o[e])||void 0===t?void 0:t.isAutoSummable)})),r=Math.max(...n),a=bs(i.filter((e=>this.isNumber(o[e]))))[0]||[];return Math.max(...a)<r?1/0:Math.min(...a)}shouldFindData(e,t){return this.getters.isEmpty(e,t)||this.getters.isSingleCellOrMerge(e,t)}isNumber(e){var t;return(null==e?void 0:e.evaluated.type)===$e.number&&!(null===(t=e.format)||void 0===t?void 0:t.match(_))}isZoneValid(e){return e.bottom>=e.top&&e.right>=e.left}lastColIsEmpty(e,t){return this.getters.isEmpty(e,{...t,left:t.right})}lastRowIsEmpty(e,t){return this.getters.isEmpty(e,{...t,top:t.bottom})}dimensionsToSum(e,t){const s=new Set;return no(t)?(s.add(1===io(t).width?"COL":"ROW"),s):(this.lastColIsEmpty(e,t)&&s.add("ROW"),this.lastRowIsEmpty(e,t)&&s.add("COL"),0===s.size&&s.add("COL"),s)}sumDimensions(e,t,s){return[...s.has("COL")?this.sumColumns(t,e):[],...s.has("ROW")?this.sumRows(t,e):[]]}sumTotal(e){const{bottom:t,right:s}=e;return{position:[s,t],zone:{...e,top:t,right:s-1}}}sumColumns(e,t){const s=this.nextEmptyRow(t,{...e,bottom:e.bottom-1});return e={...e,bottom:Math.min(e.bottom,s.bottom-1)},ro(s).map((t=>({position:t,zone:{...e,right:t[0],left:t[0]}})))}sumRows(e,t){const s=this.nextEmptyCol(t,{...e,right:e.right-1});return e={...e,right:Math.min(e.right,s.right-1)},ro(s).map((t=>({position:t,zone:{...e,top:t[1],bottom:t[1]}})))}dispatchCellUpdates(e,t){for(const s of t){const[t,o]=s.position;this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:o,content:`=SUM(${this.getters.zoneToXC(e,s.zone)})`})}}nextEmptyRow(e,t){let s=t.bottom+1;const{left:o,right:i}=t;for(;!this.getters.isEmpty(e,{bottom:s,top:s,left:o,right:i});)s++;return{...t,top:s,bottom:s}}nextEmptyCol(e,t){let s=t.right+1;const{top:o,bottom:i}=t;for(;!this.getters.isEmpty(e,{left:s,right:s,top:o,bottom:i});)s++;return{...t,left:s,right:s}}transpose(e){return new Set([...e.values()].map((e=>"COL"===e?"ROW":"COL")))}}xh.getters=["getAutomaticSums"],xh.modes=["normal","headless"];class Th extends yh{constructor(){super(...arguments),this.status="invisible",this._isPaintingFormat=!1}allowDispatch(e){switch(e.type){case"PASTE":return this.isPasteAllowed(this.state,e.target,!!e.force);case"INSERT_CELL":{const{cut:t,paste:s}=this.getInsertCellsTargets(e.zone,e.shiftDimension),o=this.getClipboardState(t,"CUT");return this.isPasteAllowed(o,s,!1)}case"DELETE_CELL":{const{cut:t,paste:s}=this.getDeleteCellsTargets(e.zone,e.shiftDimension),o=this.getClipboardState(t,"CUT");return this.isPasteAllowed(o,s,!1)}}return 0}handle(e){var t,s;switch(e.type){case"COPY":case"CUT":this.state=this.getClipboardState(e.target,e.type),this.status="visible";break;case"PASTE":if(!this.state)break;const o=e.pasteOption||(this._isPaintingFormat?"onlyFormat":void 0);this._isPaintingFormat=!1;const i=this.state.cells.length,n=this.state.cells[0].length;this.paste(this.state,e.target,o),this.selectPastedZone(n,i,e.target),this.status="invisible";break;case"DELETE_CELL":{const{cut:t,paste:s}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);if(!js(t[0])){for(const[t,s]of ro(e.zone))this.dispatch("CLEAR_CELL",{col:t,row:s,sheetId:this.getters.getActiveSheetId()});break}const o=this.getClipboardState(t,"CUT");this.paste(o,s);break}case"INSERT_CELL":{const{cut:t,paste:s}=this.getInsertCellsTargets(e.zone,e.shiftDimension),o=this.getClipboardState(t,"CUT");this.paste(o,s);break}case"ADD_COLUMNS_ROWS":if(this.status="invisible","CUT"!==(null===(t=this.state)||void 0===t?void 0:t.operation))return;this.isColRowDirtyingClipboard("before"===e.position?e.base:e.base+1,e.dimension)&&(this.state=void 0);break;case"REMOVE_COLUMNS_ROWS":if(this.status="invisible","CUT"!==(null===(s=this.state)||void 0===s?void 0:s.operation))return;for(let t of e.elements){if(this.isColRowDirtyingClipboard(t,e.dimension)){this.state=void 0;break}}this.status="invisible";break;case"PASTE_FROM_OS_CLIPBOARD":this.pasteFromClipboard(e.target,e.text);break;case"ACTIVATE_PAINT_FORMAT":this.state=this.getClipboardState(e.target,"COPY"),this._isPaintingFormat=!0,this.status="visible";break;default:Ve(e)&&(this.status="invisible")}}getClipboardContent(){return this.state&&this.state.cells.length&&this.state.cells.map((e=>e.map((e=>e.cell?this.getters.getCellText(e.cell,this.getters.shouldShowFormulas()):"")).join("\t"))).join("\n")||"\t"}isPaintingFormat(){return this._isPaintingFormat}getDeleteCellsTargets(e,t){const s=this.getters.getActiveSheet();let o;return o="COL"===t?{...e,left:e.right+1,right:s.cols.length-1}:{...e,top:e.bottom+1,bottom:s.rows.length-1},{cut:[o],paste:[e]}}getInsertCellsTargets(e,t){const s=this.getters.getActiveSheet();let o,i;return"COL"===t?(o={...e,right:s.cols.length-1},i={...e,left:e.right+1,right:e.right+1}):(o={...e,bottom:s.rows.length-1},i={...e,top:e.bottom+1,bottom:s.rows.length-1}),{cut:[o],paste:[i]}}removeMergeIfTopLeft(e){const{sheetId:t,col:s,row:o}=e,[i,n]=this.getters.getMainCell(t,s,o);if(n===o&&i===s){const e=this.getters.getMerge(t,s,o);e&&this.dispatch("REMOVE_MERGE",{sheetId:t,target:[e]})}}pasteMergeIfExist(e,t){let{sheetId:s,col:o,row:i}=e;const[n,r]=this.getters.getMainCell(s,o,i);if(n===o&&r===i){const e=this.getters.getMerge(s,o,i);if(!e)return;({sheetId:s,col:o,row:i}=t),this.dispatch("ADD_MERGE",{sheetId:s,force:!0,target:[{left:o,top:i,right:o+e.right-e.left,bottom:i+e.bottom-e.top}]})}}getPasteZones(e,t){if(!t.length||!t[0].length)return e;const s=[],o=t.length,i=t[0].length,n=e[e.length-1],r=n.left,a=n.top,l=Math.max(1,Math.floor((n.right+1-r)/i)),c=Math.max(1,Math.floor((n.bottom+1-a)/o));for(let e=1;e<=l;e++)for(let t=1;t<=c;t++)s.push({left:r,top:a,right:r-1+e*i,bottom:a-1+t*o});return s}getClipboardState(e,t){const s=new Set(e.map((e=>e.left))),o=new Set(e.map((e=>e.right))),i=new Set(e.map((e=>e.top))),n=new Set(e.map((e=>e.bottom))),r=1===i.size&&1===n.size||1===s.size&&1===o.size?function(e){return e.reduce(((e,t)=>{const s=e.length;for(let o=0;o<s;o++)if(eo(e[o],t))return e[o]=Qs(e[o],t),e;return e[s]=t,e}),[])}(e):[e[e.length-1]],a=r.map((e=>ro(e))).flat(),l=[...new Set(a.map((e=>e[0])))].sort(((e,t)=>e-t)),c=[...new Set(a.map((e=>e[1])))].sort(((e,t)=>e-t)),h=[],d=[],u=this.getters.getActiveSheetId();for(let e of c){let t=[];for(let s of l){t.push({cell:this.getters.getCell(u,s,e),border:this.getters.getCellBorder(u,s,e)||void 0,position:{col:s,row:e,sheetId:u}});const o=this.getters.getMerge(u,s,e);o&&o.top===e&&o.left===s&&d.push(o)}h.push(t)}return{cells:h,operation:t,sheetId:u,zones:r,merges:d}}pasteFromClipboard(e,t){this.status="invisible";const s=t.replace(/\r/g,"").split("\n").map((e=>e.split("\t"))),{left:o,top:i}=e[0],n=Math.max.apply(Math,s.map((e=>e.length))),r=s.length,a=this.getters.getActiveSheet();this.addMissingDimensions(a,n,r,o,i);for(let e=0;e<s.length;e++)for(let t=0;t<s[e].length;t++)this.dispatch("UPDATE_CELL",{row:i+e,col:o+t,content:s[e][t],sheetId:a.id});const l={left:o,top:i,right:o+n-1,bottom:i+r-1};this.dispatch("SET_SELECTION",{anchor:[o,i],zones:[l],anchorZone:l})}isPasteAllowed(e,t,s){const o=this.getters.getActiveSheetId();if(!e)return 20;if(t.length>1&&(e.cells.length>1||e.cells[0].length>1))return 19;if(!s)for(let s of this.getPasteZones(t,e.cells))if(this.getters.doesIntersectMerge(o,s))return 2;return 0}paste(e,t,s){if("CUT"===e.operation&&this.clearClippedZones(e),t.length>1)for(const o of t)for(let t=o.left;t<=o.right;t++)for(let i=o.top;i<=o.bottom;i++)this.pasteZone(e,t,i,s);else{const o=e.cells.length,i=e.cells[0].length,n=t[0],r=Math.max(1,Math.floor((n.right+1-n.left)/i)),a=Math.max(1,Math.floor((n.bottom+1-n.top)/o));for(let t=0;t<r;t++)for(let r=0;r<a;r++)this.pasteZone(e,n.left+t*i,n.top+r*o,s)}"CUT"===e.operation&&(this.dispatch("REMOVE_MERGE",{sheetId:e.sheetId,target:e.merges}),this.state=void 0)}selectPastedZone(e,t,s){const o=s[0],i=o.left,n=o.top,r=Math.max(1,Math.floor((o.right+1-o.left)/e)),a=Math.max(1,Math.floor((o.bottom+1-o.top)/t));if(t>1||e>1){const s={left:i,top:n,right:i+r*e-1,bottom:n+a*t-1},[o,l]=this.getters.getSelection().anchor,c=ms(o,i,i+r*e-1),h=ms(l,n,n+a*t-1);this.dispatch("SET_SELECTION",{anchor:[c,h],zones:[s],anchorZone:s})}}clearClippedZones(e){for(const t of e.cells)for(const e of t)e.cell&&this.dispatch("CLEAR_CELL",e.position);this.dispatch("CLEAR_FORMATTING",{sheetId:e.sheetId,target:e.zones})}pasteZone(e,t,s,o){const i=e.cells.length,n=e.cells[0].length,r="onlyValue"!==o&&this.state&&this.state===e,a=this.getters.getActiveSheet();this.addMissingDimensions(a,n,i,t,s);for(let l=0;l<i;l++){const i=e.cells[l];for(let c=0;c<n;c++){const n=i[c],h={col:t+c,row:s+l,sheetId:a.id};this.removeMergeIfTopLeft(h),this.pasteMergeIfExist(n.position,h),this.pasteCell(n,h,e.operation,e.zones,o),r&&this.dispatch("PASTE_CONDITIONAL_FORMAT",{origin:n.position,target:h,operation:e.operation})}}}addMissingDimensions(e,t,s,o,i){const{cols:n,rows:r,id:a}=e,l=s+i-r.length;l>0&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"ROW",base:r.length-1,sheetId:a,quantity:l,position:"after"});const c=t+o-n.length;c>0&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"COL",base:n.length-1,sheetId:a,quantity:c,position:"after"})}pasteCell(e,t,s,o,i){const{sheetId:n,col:r,row:a}=t,l=this.getters.getCell(n,r,a);if("onlyValue"!==i&&this.dispatch("SET_BORDER",{sheetId:n,col:r,row:a,border:e.border}),e.cell){if("onlyFormat"===i)return void this.dispatch("UPDATE_CELL",{...t,style:e.cell.style,format:e.cell.format});if("onlyValue"===i){const s=jr(e.cell.evaluated.value);return void this.dispatch("UPDATE_CELL",{...t,content:s})}let l=e.cell.content;if(e.cell.isFormula()){const t=r-e.position.col,i=a-e.position.row;l=this.getUpdatedContent(n,e.cell,t,i,o,s)}this.dispatch("UPDATE_CELL",{...t,content:l,style:e.cell.style||null,format:e.cell.format})}else l&&("onlyValue"===i?this.dispatch("UPDATE_CELL",{...t,content:""}):"onlyFormat"===i?this.dispatch("UPDATE_CELL",{...t,style:null,format:""}):this.dispatch("CLEAR_CELL",t))}getUpdatedContent(e,t,s,o,i,n){if("CUT"===n){const n=[];for(const r of t.dependencies)this.isZoneOverlapClippedZone(i,r.zone)?n.push(...this.getters.createAdaptedRanges([r],s,o,e)):n.push(r);return this.getters.buildFormulaContent(e,t,n)}const r=this.getters.createAdaptedRanges(t.dependencies,s,o,e);return this.getters.buildFormulaContent(e,t,r)}isZoneOverlapClippedZone(e,t){return e.some((e=>eo(t,e)))}isColRowDirtyingClipboard(e,t){if(!this.state||!this.state.zones)return!1;for(let s of this.state.zones){if("COL"===t&&e<=s.right)return!0;if("ROW"===t&&e<=s.bottom)return!0}return!1}drawGrid(e){const{viewport:t,ctx:s,thinLineWidth:o}=e;if("visible"===this.status&&this.state&&this.state.zones&&this.state.zones.length&&this.state.sheetId===this.getters.getActiveSheetId()){s.setLineDash([8,5]),s.strokeStyle=p,s.lineWidth=3.3*o;for(const e of this.state.zones){const[o,i,n,r]=this.getters.getRect(e,t);n>0&&r>0&&s.strokeRect(o,i,n,r)}}}}Th.layers=[2],Th.getters=["getClipboardContent","isPaintingFormat"],Th.modes=["normal"];const Rh=[{name:a("Sum"),types:[$e.number],compute:e=>Ht.compute([e])},{name:a("Avg"),types:[$e.number],compute:e=>fo.compute([e])},{name:a("Min"),types:[$e.number],compute:e=>Oo.compute([e])},{name:a("Max"),types:[$e.number],compute:e=>Lo.compute([e])},{name:a("Count"),types:[$e.number,$e.text,$e.boolean,$e.error],compute:e=>wo.compute([e])},{name:a("Count Numbers"),types:[$e.number,$e.text,$e.boolean,$e.error],compute:e=>yo.compute([e])}];var Lh;!function(e){e[e.idle=0]="idle",e[e.selecting=1]="selecting",e[e.readyToExpand=2]="readyToExpand",e[e.expanding=3]="expanding"}(Lh||(Lh={}));class Mh extends yh{constructor(e,t,s,o){super(e,t,s,o),this.selection={zones:[{top:0,left:0,bottom:0,right:0}],anchor:[0,0],anchorZone:{top:0,left:0,bottom:0,right:0}},this.selectedFigureId=null,this.activeCol=0,this.activeRow=0,this.mode=Lh.idle,this.sheetsData={},this.activeSheet=null,this.moveClient=o.moveClient}allowDispatch(e){switch(e.type){case"SET_SELECTION":if(-1===e.zones.findIndex((t=>Js(t,e.anchorZone))))return 16;break;case"ALTER_SELECTION":if(e.delta){const{left:t,right:s,top:o,bottom:i}=this.getSelectedZone(),n=this.getters.getActiveSheet(),r=Zs(n,"cols",Es(t,s+1)),a=Zs(n,"rows",Es(o,i+1));if(0!==e.delta[0]&&void 0===a||0!==e.delta[1]&&void 0===r)return 17}break;case"MOVE_POSITION":{const{cols:t,rows:s}=this.getters.getActiveSheet();if(0!==e.deltaX&&s[this.activeRow].isHidden||0!==e.deltaY&&t[this.activeCol].isHidden)return 17;const{col:o,row:i}=this.getNextAvailablePosition(e.deltaX,e.deltaY);if(i<0||i>s.length-1||o<0||o>t.length-1)return 17;break}case"SELECT_COLUMN":{const{index:t}=e;if(t<0||t>=this.getters.getActiveSheet().cols.length)return 17;break}case"SELECT_ROW":{const{index:t}=e;if(t<0||t>=this.getters.getActiveSheet().rows.length)return 17;break}case"ACTIVATE_SHEET":try{this.getters.getSheet(e.sheetIdTo);break}catch(e){return 23}case"MOVE_COLUMNS_ROWS":return this.isMoveElementAllowed(e)}return 0}handle(e){switch(e.type){case"CREATE_SHEET":case"DELETE_SHEET":case"CREATE_FIGURE":case"CREATE_CHART":case"UPDATE_FIGURE":case"EVALUATE_CELLS":case"DISABLE_SELECTION_INPUT":case"ENABLE_NEW_SELECTION_INPUT":case"RESIZE_VIEWPORT":break;case"DELETE_FIGURE":this.selectedFigureId===e.id&&(this.selectedFigureId=null);break;default:this.selectedFigureId=null}switch(e.type){case"START":const t=zs(this.getters.getSheets()[0],0,0);this.activeCol=t[0],this.activeRow=t[1],this.dispatch("ACTIVATE_SHEET",{sheetIdTo:this.getters.getSheets()[0].id,sheetIdFrom:this.getters.getSheets()[0].id}),this.selectCell(...t);break;case"ACTIVATE_SHEET":this.setActiveSheet(e.sheetIdTo),this.sheetsData[e.sheetIdFrom]={selection:JSON.parse(JSON.stringify(this.selection)),activeCol:this.activeCol,activeRow:this.activeRow},e.sheetIdTo in this.sheetsData?Object.assign(this,this.sheetsData[e.sheetIdTo]):this.selectCell(...zs(this.getters.getSheet(e.sheetIdTo),0,0));break;case"SET_SELECTION":this.setSelection(e.anchor,e.zones,e.anchorZone,e.strict);break;case"START_SELECTION":this.mode=Lh.selecting;break;case"PREPARE_SELECTION_EXPANSION":this.mode=Lh.readyToExpand;break;case"START_SELECTION_EXPANSION":this.mode=Lh.expanding;break;case"STOP_SELECTION":this.mode=Lh.idle;break;case"MOVE_POSITION":this.movePosition(e.deltaX,e.deltaY);break;case"SELECT_CELL":this.selectCell(e.col,e.row);break;case"SELECT_COLUMN":this.selectColumn(e.index,e.createRange||!1,e.updateRange||!1);break;case"SELECT_ROW":this.selectRow(e.index,e.createRange||!1,e.updateRange||!1);break;case"SELECT_ALL":this.selectAll();break;case"ALTER_SELECTION":e.delta&&this.moveSelection(e.delta[0],e.delta[1]),e.cell&&this.addCellToSelection(...e.cell);break;case"UNDO":case"REDO":case"DELETE_SHEET":if(!this.getters.tryGetSheet(this.getActiveSheetId())){const e=this.getters.getVisibleSheets();this.activeSheet=this.getters.getSheet(e[0]),this.selectCell(0,0)}this.ensureSelectionValidity();break;case"REMOVE_COLUMNS_ROWS":e.sheetId===this.getActiveSheetId()&&("COL"===e.dimension?this.onColumnsRemoved(e):this.onRowsRemoved(e));break;case"ADD_COLUMNS_ROWS":e.sheetId===this.getActiveSheetId()&&this.onAddElements(e);break;case"MOVE_COLUMNS_ROWS":e.sheetId===this.getActiveSheetId()&&this.onMoveElements(e);break;case"UPDATE_CHART":case"SELECT_FIGURE":this.selectedFigureId=e.id;break;case"ACTIVATE_NEXT_SHEET":this.activateNextSheet("right");break;case"ACTIVATE_PREVIOUS_SHEET":this.activateNextSheet("left")}}getActiveSheet(){return this.activeSheet}getActiveSheetId(){return this.activeSheet.id}getActiveCell(){const e=this.getters.getActiveSheetId(),[t,s]=this.getters.getMainCell(e,this.activeCol,this.activeRow);return this.getters.getCell(e,t,s)}getActiveCols(){const e=new Set;for(let t of this.selection.zones)if(0===t.top&&t.bottom===this.getters.getActiveSheet().rows.length-1)for(let s=t.left;s<=t.right;s++)e.add(s);return e}getActiveRows(){const e=new Set;for(let t of this.selection.zones)if(0===t.left&&t.right===this.getters.getActiveSheet().cols.length-1)for(let s=t.top;s<=t.bottom;s++)e.add(s);return e}getCurrentStyle(){const e=this.getters.getActiveCell();return e?this.getters.getCellStyle(e):{}}getSelectedZones(){return this.selection.zones}getSelectedZone(){return this.selection.anchorZone}getSelection(){return this.selection}getSelectedFigureId(){return this.selectedFigureId}getPosition(){return[this.activeCol,this.activeRow]}getSheetPosition(e){if(e===this.getters.getActiveSheetId())return this.getPosition();{const t=this.sheetsData[e];return t?[t.activeCol,t.activeRow]:zs(this.getters.getSheet(e),0,0)}}getStatisticFnResults(){const e=new Set(this.selection.zones.map((e=>this.getters.getCellsInZone(this.getters.getActiveSheetId(),e))).flat().filter((e=>void 0!==e)));let t=new Set,s=[];for(let o of e)t.add(o.evaluated.type),s.push(o.evaluated.value);let o={};for(let e of Rh){let i;e.types.some((e=>t.has(e)))&&(i=e.compute(s)),o[e.name]=i}return o}getSelectionMode(){return this.mode}isSelected(e){return!!this.getters.getSelectedZones().find((t=>Js(t,e)))}getVisibleFigures(){const e=this.getters.getActiveSheetId(),t=[],s=this.getters.getFigures(e),{offsetX:o,offsetY:i}=this.getters.getActiveSnappedViewport(),{width:n,height:r}=this.getters.getViewportDimensionWithHeaders();for(let e of s)e.x>=o+n||e.x+e.width<=o||e.y>=i+r||e.y+e.height<=i||t.push(e);return t}getElementsFromSelection(e){if("COL"===e&&0===this.getters.getActiveCols().size)return[];if("ROW"===e&&0===this.getters.getActiveRows().size)return[];const t=this.getters.getSelectedZones();let s=[];const o="COL"===e?"left":"top",i="COL"===e?"right":"bottom";for(const e of t){const t=Array.from({length:e[i]-e[o]+1},((t,s)=>e[o]+s));s=s.concat(t)}return[...new Set(s)].sort()}selectColumn(e,t,s){const o=this.getters.getActiveSheet().rows.length-1;let i={left:e,right:e,top:0,bottom:o};const n=this.selection.zones;let r,a;const l=this.getters.getActiveSheet().rows.findIndex((e=>!e.isHidden));if(s){const[e,t]=this.selection.anchor;i=Qs(i,{left:e,right:e,top:l,bottom:o}),r=this.updateSelectionZones(i),a=[e,t]}else r=t?n.concat(i):[i],a=[e,l];this.dispatch("SET_SELECTION",{zones:r,anchor:a,strict:!0,anchorZone:i})}selectRow(e,t,s){const o=this.getters.getActiveSheet().cols.length-1;let i={top:e,bottom:e,left:0,right:o};const n=this.selection.zones;let r,a;const l=this.getters.getActiveSheet().cols.findIndex((e=>!e.isHidden));if(s){const[e,t]=this.selection.anchor;i=Qs(i,{left:l,right:o,top:t,bottom:t}),r=this.updateSelectionZones(i),a=[e,t]}else r=t?n.concat(i):[i],a=[l,e];this.dispatch("SET_SELECTION",{zones:r,anchor:a,strict:!0,anchorZone:i})}selectAll(){const e={left:0,top:0,bottom:this.getters.getActiveSheet().rows.length-1,right:this.getters.getActiveSheet().cols.length-1};this.dispatch("SET_SELECTION",{zones:[e],anchor:[0,0],anchorZone:e})}selectCell(e,t){const s=this.getters.getActiveSheet();this.moveClient({sheetId:s.id,col:e,row:t});const o=this.getters.expandZone(s.id,{left:e,right:e,top:t,bottom:t});let i;i=this.mode===Lh.expanding?lo([...this.selection.zones,o]):[o],this.selection=this.clipSelection(s.id,{anchor:[e,t],zones:i,anchorZone:o}),this.activeCol=this.selection.anchor[0],this.activeRow=this.selection.anchor[1]}setActiveSheet(e){const t=this.getters.getSheet(e);this.activeSheet=t}getNextAvailablePosition(e,t){return{col:this.getNextAvailableCol(e,this.activeCol,this.activeRow),row:this.getNextAvailableRow(t,this.activeCol,this.activeRow)}}getNextAvailableCol(e,t,s){const{cols:o,id:i}=this.getActiveSheet(),n={col:t,row:s};return this.getNextAvailableHeader(e,o,t,n,(e=>this.getters.isInSameMerge(i,t,s,e,s)))}getNextAvailableRow(e,t,s){const{rows:o,id:i}=this.getActiveSheet(),n={col:t,row:s};return this.getNextAvailableHeader(e,o,s,n,(e=>this.getters.isInSameMerge(i,t,s,t,e)))}getNextAvailableHeader(e,t,s,o,i){var n,r,a;const l=this.getters.getActiveSheetId(),{col:c,row:h}=o;if(0===e)return s;let d=s+e;if(this.getters.isInMerge(l,c,h)){for(;i(d);)d+=e;for(;null===(n=t[d])||void 0===n?void 0:n.isHidden;)d+=e}else if(null===(r=t[d])||void 0===r?void 0:r.isHidden)for(;null===(a=t[d])||void 0===a?void 0:a.isHidden;)d+=e;return d<0||d>t.length-1?t[s].isHidden?this.getNextAvailableHeader(-e,t,s,o,i):s:d}movePosition(e,t){const{col:s,row:o}=this.getNextAvailablePosition(e,t);this.selectCell(s,o)}setSelection(e,t,s,o=!1){this.selectCell(...e);const i=this.getters.getActiveSheetId();let n;t=lo(t),n=o?{zones:t,anchorZone:s,anchor:e}:{anchor:e,zones:t.map((e=>this.getters.expandZone(i,e))),anchorZone:this.getters.expandZone(i,s)},this.selection=this.clipSelection(i,n)}getReferencePosition(){const e=this.getters.getActiveSheet(),t=this.selection,{left:s,right:o,top:i,bottom:n}=t.anchorZone,[r,a]=t.anchor;return{col:e.cols[r].isHidden&&Zs(e,"cols",Es(s,o+1))||r,row:e.rows[a].isHidden&&Zs(e,"rows",Es(i,n+1))||a}}moveSelection(e,t){const s=this.selection;let o=[];const[i,n]=s.anchor,{left:r,right:a,top:l,bottom:c}=s.anchorZone;let h=s.anchorZone;const d=this.getters.getActiveSheet(),u=e=>{const{left:t,right:s,top:o,bottom:i}=this.getters.expandZone(d.id,e);return{left:Math.max(0,t),right:Math.min(d.cols.length-1,s),top:Math.max(0,o),bottom:Math.min(d.rows.length-1,i)}},{col:p,row:g}=this.getReferencePosition();let f=0;for(;null!==h;){if(f++,e<0){const t=this.getNextAvailableCol(e,a-(f-1),g);h=p<=a-f?u({top:l,left:r,bottom:c,right:t}):null}if(e>0){const t=this.getNextAvailableCol(e,r+(f-1),g);h=r+f<=p?u({top:l,left:t,bottom:c,right:a}):null}if(t<0){const e=this.getNextAvailableRow(t,p,c-(f-1));h=g<=c-f?u({top:l,left:r,bottom:e,right:a}):null}if(t>0){const e=this.getNextAvailableRow(t,p,l+(f-1));h=l+f<=g?u({top:e,left:r,bottom:c,right:a}):null}if(h=h?co(h):h,h&&!Js(h,s.anchorZone))return o=this.updateSelectionZones(h),void this.dispatch("SET_SELECTION",{zones:o,anchor:[i,n],anchorZone:h})}h=u(Qs({top:n,bottom:n,left:i,right:i},co({top:this.getNextAvailableRow(t,p,l),left:this.getNextAvailableCol(e,r,g),bottom:this.getNextAvailableRow(t,p,c),right:this.getNextAvailableCol(e,a,g)}))),Js(h,s.anchorZone)||(o=this.updateSelectionZones(h),this.dispatch("SET_SELECTION",{zones:o,anchor:[i,n],anchorZone:h}))}addCellToSelection(e,t){const s=this.selection,[o,i]=s.anchor,n={left:Math.min(o,e),top:Math.min(i,t),right:Math.max(o,e),bottom:Math.max(i,t)},r=this.updateSelectionZones(n);this.dispatch("SET_SELECTION",{zones:r,anchor:[o,i],anchorZone:n})}ensureSelectionValidity(){const{anchor:e,zones:t,anchorZone:s}=this.clipSelection(this.getActiveSheetId(),this.selection);this.setSelection(e,t,s);const o=Object.keys(this.sheetsData).filter((e=>!this.getters.tryGetSheet(e)));for(const e of o)delete this.sheetsData[e];for(const e in this.sheetsData){const{anchor:t,zones:s,anchorZone:o}=this.clipSelection(e,this.sheetsData[e].selection);this.sheetsData[e]={selection:{anchor:t,zones:s,anchorZone:o},activeCol:t[0],activeRow:t[1]}}}clipSelection(e,t){const s=this.getters.getSheet(e),o=s.cols.length-1,i=s.rows.length-1,n=t.zones.map((e=>({left:ms(e.left,0,o),right:ms(e.right,0,o),top:ms(e.top,0,i),bottom:ms(e.bottom,0,i)})));return{anchor:[ms(t.anchor[0],0,o),ms(t.anchor[1],0,i)],zones:n,anchorZone:{left:ms(t.anchorZone.left,0,o),right:ms(t.anchorZone.right,0,o),top:ms(t.anchorZone.top,0,i),bottom:ms(t.anchorZone.bottom,0,i)}}}onColumnsRemoved(e){const t=Ks(this.getSelectedZone(),"left",e.elements);this.setSelection([t.left,t.top],[t],t,!0),this.ensureSelectionValidity()}onRowsRemoved(e){const t=Ks(this.getSelectedZone(),"top",e.elements);this.setSelection([t.left,t.top],[t],t,!0),this.ensureSelectionValidity()}onAddElements(e){const t=Ys(this.getSelectedZone(),"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);this.setSelection([t.left,t.top],[t],t,!0)}updateSelectionZones(e){let t=[...this.selection.zones];const s=this.selection.anchorZone,o=t.findIndex((e=>Js(e,s)));return o>=0&&(t[o]=e),t}activateNextSheet(e){const t=this.getters.getSheets().map((e=>e.id)),s=(t.findIndex((e=>e===this.activeSheet.id))+("left"===e?t.length-1:1))%t.length;this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getActiveSheetId(),sheetIdTo:t[s]})}onMoveElements(e){const t=e.elements.length;this.dispatch("ADD_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,base:e.base,quantity:t,position:"before"});const s="COL"===e.dimension,o=e.elements[0],i=e.elements[t-1],n=e.base<o,r=n&&s?t:0,a=n&&!s?t:0,l=this.getters.getSheet(e.sheetId);this.dispatch("CUT",{target:[{left:s?o+r:0,right:s?i+r:l.cols.length-1,top:s?0:o+a,bottom:s?l.rows.length-1:i+a}]}),this.dispatch("PASTE",{target:[{left:s?e.base:0,right:s?e.base+t-1:l.cols.length-1,top:s?0:e.base,bottom:s?l.rows.length-1:e.base+t-1}]});const c=n?e.elements.map((e=>e+t)):e.elements;let h=e.base;for(const t of c){const s="COL"===e.dimension?this.getters.getCol(e.sheetId,t).size:this.getters.getRow(e.sheetId,t).size;this.dispatch("RESIZE_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,size:s,elements:[h]}),h+=1}this.dispatch("REMOVE_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,elements:c})}isMoveElementAllowed(e){const t="COL"===e.dimension,s=e.elements[0],o=e.elements[e.elements.length-1],i=e.sheetId,n=t?this.getters.doesColumnsHaveCommonMerges:this.getters.doesRowsHaveCommonMerges;return n(i,s-1,s)||n(i,o,o+1)||n(i,e.base-1,e.base)?2:0}drawGrid(e){if("inactive"!==this.getters.getEditionMode())return;const{viewport:t,ctx:s,thinLineWidth:o}=e,i=this.getSelectedZones();s.fillStyle="#f3f7fe";const n=1===i.length&&i[0].left===i[0].right&&i[0].top===i[0].bottom;s.fillStyle=n?"#f3f7fe":"#e9f0ff",s.strokeStyle=p,s.lineWidth=1.5*o,s.globalCompositeOperation="multiply";for(const e of i){const[o,i,n,r]=this.getters.getRect(e,t);s.fillRect(o,i,n,r),s.strokeRect(o,i,n,r)}s.globalCompositeOperation="source-over";const r=this.getters.getActiveSheetId(),[a,l]=this.getPosition();let c;s.strokeStyle=p,s.lineWidth=3*o,c=this.getters.isInMerge(r,a,l)?this.getters.getMerge(r,a,l):{top:l,bottom:l,left:a,right:a};const[h,d,u,g]=this.getters.getRect(c,t);u>0&&g>0&&s.strokeRect(h,d,u,g)}}Mh.layers=[5],Mh.modes=["normal"],Mh.getters=["getActiveSheet","getActiveSheetId","getActiveCell","getActiveCols","getActiveRows","getCurrentStyle","getSelectedZones","getSelectedZone","getStatisticFnResults","getSelectedFigureId","getVisibleFigures","getSelection","getPosition","getSheetPosition","getSelectionMode","isSelected","getElementsFromSelection"];const Ah=a("The cell you are trying to edit has been deleted.");class _h extends yh{constructor(){super(...arguments),this.col=0,this.row=0,this.mode="inactive",this.sheet="",this.currentContent="",this.currentTokens=[],this.selectionStart=0,this.selectionEnd=0,this.selectionInitialStart=0,this.multiSelectionInitialStart=0,this.initialContent="",this.previousRef="",this.previousRange=void 0,this.colorIndexByRange={}}allowDispatch(e){switch(e.type){case"CHANGE_COMPOSER_CURSOR_SELECTION":return this.validateSelection(this.currentContent.length,e.start,e.end);case"SET_CURRENT_CONTENT":return e.selection?this.validateSelection(e.content.length,e.selection.start,e.selection.end):0;case"START_EDITION":if(e.selection){const t=this.getters.getActiveCell(),s=e.text||(null==t?void 0:t.composerContent)||"";return this.validateSelection(s.length,e.selection.start,e.selection.end)}return 0;default:return 0}}handle(e){switch(e.type){case"CHANGE_COMPOSER_CURSOR_SELECTION":this.selectionStart=e.start,this.selectionEnd=e.end;break;case"STOP_COMPOSER_RANGE_SELECTION":this.isSelectingForComposer()&&(this.mode="editing");break;case"START_EDITION":this.startEdition(e.text,e.selection);break;case"STOP_EDITION":e.cancel?(this.cancelEdition(),this.resetContent()):this.stopEdition();break;case"SET_CURRENT_CONTENT":this.setContent(e.content,e.selection,!0);break;case"REPLACE_COMPOSER_CURSOR_SELECTION":this.replaceSelection(e.text);break;case"SELECT_FIGURE":this.cancelEdition(),this.resetContent();break;case"SELECT_CELL":case"SET_SELECTION":case"MOVE_POSITION":switch(this.mode){case"editing":this.dispatch("STOP_EDITION");break;case"waitingForRangeSelection":this.insertSelectedRange();break;case"rangeSelected":switch(e.type){case"MOVE_POSITION":this.replaceAllSelectedRanges();break;case"SELECT_CELL":this.getters.getSelectionMode()===Lh.expanding?this.insertSelectedRange():this.replaceAllSelectedRanges();break;case"SET_SELECTION":e.strict?this.getters.getSelectionMode()===Lh.expanding?this.insertSelectedRange():this.replaceAllSelectedRanges():this.replaceSelectedRange()}}break;case"ADD_COLUMNS_ROWS":this.onAddElements(e);break;case"REMOVE_COLUMNS_ROWS":"COL"===e.dimension?this.onColumnsRemoved(e):this.onRowsRemoved(e);break;case"START_CHANGE_HIGHLIGHT":this.dispatch("STOP_COMPOSER_RANGE_SELECTION");const t=this.currentTokens.filter((e=>"REFERENCE"===e.type)).find((t=>{let s=t.value;const{xc:o,sheetName:i}=ss(s),n=i||this.getters.getSheetName(this.sheet),r=this.getters.getActiveSheetId();return Js(this.getters.expandZone(r,qs(o)),e.zone)&&this.getters.getSheetName(r)===n}));this.previousRef=t.value,this.previousRange=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),this.previousRef),this.selectionInitialStart=t.start;break;case"CHANGE_HIGHLIGHT":const s=this.getZoneReference(e.zone,this.previousRange.parts);this.selectionStart=this.selectionInitialStart,this.selectionEnd=this.selectionInitialStart+this.previousRef.length,this.replaceSelection(s),this.previousRef=s,this.selectionStart=this.currentContent.length,this.selectionEnd=this.currentContent.length;break;case"DELETE_SHEET":case"UNDO":case"REDO":!!this.getters.tryGetSheet(this.sheet)||"inactive"===this.mode||(this.cancelEdition(),this.resetContent(),this.ui.notifyUI({type:"NOTIFICATION",text:Ah}))}}getEditionMode(){return this.mode}getCurrentContent(){if("inactive"===this.mode){const e=this.getters.getActiveCell();return(null==e?void 0:e.composerContent)||""}return this.currentContent}getEditionSheet(){return this.sheet}getComposerSelection(){return{start:this.selectionStart,end:this.selectionEnd}}isSelectingForComposer(){return"waitingForRangeSelection"===this.mode||"rangeSelected"===this.mode||"resettingPosition"===this.mode}getCurrentTokens(){return this.currentTokens}getTokenAtCursor(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return e===t&&0===t?void 0:this.currentTokens.find((s=>s.start<=e&&s.end>=t))}validateSelection(e,t,s){return t>=0&&t<=e&&s>=0&&s<=e?0:31}onColumnsRemoved(e){if(e.elements.includes(this.col)&&"inactive"!==this.mode)return this.dispatch("STOP_EDITION",{cancel:!0}),void this.ui.notifyUI({type:"NOTIFICATION",text:Ah});const{top:t,left:s}=Ks({left:this.col,right:this.col,top:this.row,bottom:this.row},"left",e.elements);this.col=s,this.row=t}onRowsRemoved(e){if(e.elements.includes(this.row)&&"inactive"!==this.mode)return this.dispatch("STOP_EDITION",{cancel:!0}),void this.ui.notifyUI({type:"NOTIFICATION",text:Ah});const{top:t,left:s}=Ks({left:this.col,right:this.col,top:this.row,bottom:this.row},"top",e.elements);this.col=s,this.row=t}onAddElements(e){const{top:t,left:s}=Ys({left:this.col,right:this.col,top:this.row,bottom:this.row},"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);this.col=s,this.row=t}startComposerRangeSelection(){this.mode="resettingPosition",this.sheet===this.getters.getActiveSheetId()&&this.dispatch("SELECT_CELL",{col:this.col,row:this.row}),this.mode="waitingForRangeSelection",this.multiSelectionInitialStart=this.selectionStart}startEdition(e,t){const s=this.getters.getActiveCell();this.initialContent=(null==s?void 0:s.composerContent)||"",this.mode="editing";const[o,i]=this.getters.getPosition();this.col=o,this.row=i,this.sheet=this.getters.getActiveSheetId(),this.setContent(e||this.initialContent,t),this.colorIndexByRange={}}stopEdition(){if("inactive"!==this.mode){this.cancelEdition();const e=this.getters.getActiveSheetId(),t=this.getters.getSheets().find((e=>e.id===this.sheet)).id,[s,o]=this.getters.getMainCell(t,this.col,this.row);let i=this.currentContent;if(!(this.initialContent!==i))return;if(i){const t=this.getters.getCell(e,s,o);if(i.startsWith("=")){const e=this.currentTokens.filter((e=>"LEFT_PAREN"===e.type)).length,t=this.currentTokens.filter((e=>"RIGHT_PAREN"===e.type)).length,s=e-t;s>0&&(i+=new Array(s).fill(")").join(""))}else(null==t?void 0:t.isLink())&&(i=Ts(i,t.link.url));this.dispatch("UPDATE_CELL",{sheetId:this.sheet,col:s,row:o,content:i})}else this.dispatch("UPDATE_CELL",{sheetId:this.sheet,content:"",col:s,row:o});e!==this.sheet&&this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getters.getActiveSheetId(),sheetIdTo:this.sheet}),this.setContent("")}}cancelEdition(){this.mode="inactive"}resetContent(){this.setContent(this.initialContent||"")}setContent(e,t,s){e=e.replace(/[\r\n]/g,"");const o=this.currentContent!==e;this.currentContent=e,t?(this.selectionStart=t.start,this.selectionEnd=t.end):this.selectionStart=this.selectionEnd=e.length,(o||"inactive"!==this.mode)&&(this.currentTokens=e.startsWith("=")?Wr(e):[],this.currentTokens.length>100&&s&&this.ui.notifyUI({type:"NOTIFICATION",text:a("This formula has over 100 parts. It can't be processed properly, consider splitting it into multiple cells")})),this.canStartComposerRangeSelection()&&this.startComposerRangeSelection()}insertSelectedRange(){const e=Math.min(this.selectionStart,this.selectionEnd),t=this.getZoneReference(this.getters.getSelectedZone());if("waitingForRangeSelection"===this.mode)return this.insertText(t,e),this.selectionInitialStart=e,void(this.mode="rangeSelected");this.insertText(","+t,e),this.selectionInitialStart=e+1}replaceSelectedRange(){const{end:e}=this.getters.getComposerSelection();this.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:this.selectionInitialStart,end:e}),this.replaceSelection(this.getZoneReference(this.getters.getSelectedZone()))}replaceAllSelectedRanges(){const{end:e}=this.getters.getComposerSelection();this.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:this.multiSelectionInitialStart,end:e}),this.replaceSelection(this.getZoneReference(this.getters.getSelectedZone())),this.selectionInitialStart=this.multiSelectionInitialStart}getZoneReference(e,t=[{colFixed:!1,rowFixed:!1}]){const s=this.getters.getActiveSheetId();let o=this.getters.zoneToXC(s,e,t);if(this.getters.getEditionSheet()!==this.getters.getActiveSheetId()){o=`${fs(this.getters.getSheetName(this.getters.getActiveSheetId()))}!${o}`}return o}replaceSelection(e){const t=Math.min(this.selectionStart,this.selectionEnd),s=Math.max(this.selectionStart,this.selectionEnd);this.replaceText(e,t,s)}replaceText(e,t,s){this.currentContent=this.currentContent.slice(0,t)+this.currentContent.slice(s,this.currentContent.length),this.insertText(e,t)}insertText(e,t){const s=this.currentContent.slice(0,t)+e+this.currentContent.slice(t),o=t+e.length;this.dispatch("SET_CURRENT_CONTENT",{content:s,selection:{start:o,end:o}})}getComposerHighlights(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return[];const e=[],t={};for(let s of this.currentTokens.filter((e=>"REFERENCE"===e.type))){let o=s.value;const{xc:i,sheetName:n}=ss(o);if(ts.test(i)){const s=(n?`${n}!`:`${this.getters.getSheetName(this.getters.getEditionSheet())}!`)+i.replace(/\$/g,"");e.push(s);const o=this.colorIndexByRange[s];void 0!==o&&(t[s]=o)}}this.colorIndexByRange=t;let s=Object.values(t),o=0;return e.map((e=>{if(void 0===this.colorIndexByRange[e]){for(;s.includes(o);)o++;s.push(o),this.colorIndexByRange[e]=o}return[e,Xt[this.colorIndexByRange[e]%Xt.length]]}))}canStartComposerRangeSelection(){if("editing"!==this.mode&&this.selectionStart===this.selectionEnd)return!1;if(this.currentContent.startsWith("=")){const e=this.getTokenAtCursor();if(e){const t=this.currentTokens.map((e=>e.start)).indexOf(e.start);let s=t,o=e;for(;!["COMMA","LEFT_PAREN","OPERATOR"].includes(o.type);){if("SPACE"!==o.type||s<1)return!1;s--,o=this.currentTokens[s]}for(s=t+1,o=this.currentTokens[s];o&&!["COMMA","RIGHT_PAREN","OPERATOR"].includes(o.type);){if("SPACE"!==o.type)return!1;s++,o=this.currentTokens[s]}s++,o=this.currentTokens[s]}return!0}return!1}}_h.getters=["getEditionMode","isSelectingForComposer","getCurrentContent","getEditionSheet","getComposerSelection","getCurrentTokens","getTokenAtCursor","getComposerHighlights"],_h.modes=["normal"];const Oh=hr.mapping;class Nh extends yh{constructor(e,t,s,o){super(e,t,s,o),this.isUpToDate=new Set,this.evalContext=o.evalContext,o.dataSources.on("data-loaded",this,(()=>{this.dispatch("EVALUATE_CELLS",{sheetId:this.getters.getActiveSheetId()})}))}handle(e){switch(De.has(e.type)&&this.isUpToDate.clear(),e.type){case"UPDATE_CELL":"content"in e&&this.isUpToDate.clear();break;case"ACTIVATE_SHEET":this.evaluate(e.sheetIdTo),this.isUpToDate.add(e.sheetIdTo);break;case"EVALUATE_CELLS":this.evaluate(e.sheetId),this.isUpToDate.add(e.sheetId);break;case"EVALUATE_ALL_SHEETS":this.evaluateAllSheets()}}finalize(){const e=this.getters.getActiveSheetId();this.isUpToDate.has(e)||(this.evaluate(e),this.isUpToDate.add(e))}evaluateFormula(e,t=this.getters.getActiveSheetId()){const s=Gr(e),o=this.getFormulaParameters((()=>{})),i=[];for(let e of s.dependencies)i.push(this.getters.getRangeFromSheetXC(t,e));return s.execute(i,t,...o)}getRangeFormattedValues(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getCellsInZone(t.id,e.zone).map((e=>(null==e?void 0:e.formattedValue)||""))}getRangeValues(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getCellsInZone(t.id,e.zone).map((e=>null==e?void 0:e.evaluated.value))}evaluate(e){const t=this.getters.getCells(e),s=this.getFormulaParameters(i),o={};for(let s of Object.values(t))i(s,e);function i(e,t){if(!e.isFormula())return;const i=e.id;if(i in o)null===o[i]&&e.assignError("#CYCLE",a("Circular reference"));else{o[i]=null;try{if(s[2].__originCellXC=()=>{const e=s[2].getters.getCellPosition(i);return ns(e.col,e.row)},e.assignValue(e.compiledFormula.execute(e.dependencies,t,...s)),Array.isArray(e.evaluated.value))throw new Error(a("This formula depends on invalid values"))}catch(t){!function(e,t){if(e instanceof Error||(e=new Error(e)),"#CYCLE"!==t.evaluated.value){t.assignValue("#ERROR");const o=s[2].__lastFnCalled||"";t.assignError("#ERROR",e.message.replace("[[FUNCTION_NAME]]",o))}}(t,e)}o[i]=!0}}}getFormulaParameters(e){const t=Object.assign(Object.create(Oh),this.evalContext,{getters:this.getters}),s=this.getters;function o(t,s){if(e(t,s),t.evaluated.type===$e.error)throw new Error(a("This formula depends on invalid values"));return t.evaluated.value}function i(e){const i=e.sheetId;if(!js(e.zone))throw new Error(a("Invalid reference"));const n={top:0,bottom:s.getNumberRows(i)-1,left:0,right:s.getNumberCols(i)-1},r=[],l=function(e,t){if(eo(e,t))return{top:Math.max(e.top,t.top),left:Math.max(e.left,t.left),bottom:Math.min(e.bottom,t.bottom),right:Math.min(e.right,t.right)}}(e.zone,n);if(!l)return r.push([]),r;for(let s=l.left;s<=l.right;s++){const i=[];for(let n=l.top;n<=l.bottom;n++){const r=t.getters.getCell(e.sheetId,s,n);i.push(r?o(r,e.sheetId):void 0)}r.push(i)}return r}return[function(e,i,n,r,l,c){const h=i[e];if(r)return t.getters.getRangeString(h,n);if(!js(h.zone))throw new Error(a("Invalid reference"));if(h.zone.bottom!==h.zone.top||h.zone.left!==h.zone.right)throw new Error(c?a("Function %s expects the parameter %s to be a single value or a single cell reference, not a range.",l.toString(),c.toString()):a("Function %s expects its parameters to be single values or single cell references, not ranges.",l.toString()));if(h.invalidSheetName)throw new Error(a("Invalid sheet name: %s",h.invalidSheetName));return function(e){let t;if(!s.tryGetSheet(e.sheetId))throw new Error(a("Invalid sheet name"));return t=s.getCell(e.sheetId,e.zone.left,e.zone.top),!t||t.isEmpty()?null:o(t,e.sheetId)}(h)},function(e,t,s){return i(t[e])},t]}evaluateAllSheets(){for(const e of this.getters.getVisibleSheets())this.evaluate(e),this.isUpToDate.add(e)}}Nh.getters=["evaluateFormula","getRangeFormattedValues","getRangeValues"],Nh.modes=["normal"];const kh=["rgb(31,119,180)","rgb(255,127,14)","rgb(174,199,232)","rgb(255,187,120)","rgb(44,160,44)","rgb(152,223,138)","rgb(214,39,40)","rgb(255,152,150)","rgb(148,103,189)","rgb(197,176,213)","rgb(140,86,75)","rgb(196,156,148)","rgb(227,119,194)","rgb(247,182,210)","rgb(127,127,127)","rgb(199,199,199)","rgb(188,189,34)","rgb(219,219,141)","rgb(23,190,207)","rgb(158,218,229)"];class Fh{constructor(){this.graphColorIndex=0}next(){return kh[this.graphColorIndex++%kh.length]}}class $h extends yh{constructor(){super(...arguments),this.chartRuntime={},this.outOfDate=new Set}handle(e){if(De.has(e.type)||"EVALUATE_CELLS"===e.type||"UPDATE_CELL"===e.type&&"content"in e)for(let e of Object.keys(this.chartRuntime))this.outOfDate.add(e);switch(e.type){case"UPDATE_CHART":case"CREATE_CHART":const t=this.getters.getChartDefinition(e.id);this.chartRuntime[e.id]=this.mapDefinitionToRuntime(t);break;case"DELETE_FIGURE":delete this.chartRuntime[e.id];break;case"REFRESH_CHART":this.evaluateUsedSheets([e.id]),this.outOfDate.add(e.id);break;case"ACTIVATE_SHEET":const s=this.getters.getChartsIdBySheet(e.sheetIdTo);this.evaluateUsedSheets(s);break;case"DELETE_SHEET":for(let e of Object.keys(this.chartRuntime))this.getters.getChartDefinition(e)||delete this.chartRuntime[e]}}getChartRuntime(e){if(this.outOfDate.has(e)||!(e in this.chartRuntime)){const t=this.getters.getChartDefinition(e);if(void 0===t)return;this.chartRuntime[e]=this.mapDefinitionToRuntime(t),this.outOfDate.delete(e)}return this.chartRuntime[e]}truncateLabel(e){return e?e.length>20?e.substring(0,20)+"…":e:""}getDefaultConfiguration(e,t){const s={};e.labelRange||1!==e.dataSets.length?s.position=e.legendPosition:s.display=!1;const o={type:e.type,options:{legend:s,responsive:!0,maintainAspectRatio:!1,layout:{padding:{left:20,right:20,top:e.title?10:25,bottom:10}},elements:{line:{fill:!1},point:{hitRadius:15}},animation:{duration:0},hover:{animationDuration:10},responsiveAnimationDuration:0,title:{display:!!e.title,fontSize:22,fontStyle:"normal",text:e.title}},data:{labels:t.map(this.truncateLabel),datasets:[]}};return"pie"!==e.type?(o.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2}}],yAxes:[{position:e.verticalAxisPosition,ticks:{beginAtZero:!0}}]},"bar"===e.type&&e.stackedBar&&(o.options.scales.xAxes[0].stacked=!0,o.options.scales.yAxes[0].stacked=!0)):o.options.tooltips={callbacks:{title:function(e,t){return t.datasets[e[0].datasetIndex].label}}},o}getSheetIdsUsedInChart(e){const t=new Set;for(let s of e.dataSets)t.add(s.dataRange.sheetId);return e.labelRange&&t.add(e.labelRange.sheetId),t}evaluateUsedSheets(e){const t=new Set;for(let s of e){const e=this.getters.getChartDefinition(s);(void 0!==e?this.getSheetIdsUsedInChart(e):[]).forEach((e=>{e!==this.getters.getActiveSheetId()&&t.add(e)}))}for(let e of t)this.dispatch("EVALUATE_CELLS",{sheetId:e})}mapDefinitionToRuntime(e){let t=[];if(e.labelRange)e.labelRange.invalidXc||e.labelRange.invalidSheetName||(t=this.getters.getRangeFormattedValues(e.labelRange));else if(1===e.dataSets.length)for(let s=0;s<this.getData(e.dataSets[0],e.sheetId).length;s++)t.push("");else if(e.dataSets[0]){t=Es(0,this.getData(e.dataSets[0],e.sheetId).length).map((e=>e.toString()))}const s=this.getDefaultConfiguration(e,t),o=new Fh,i=[];if("pie"===e.type){const t=Math.max(...e.dataSets.map((t=>this.getData(t,e.sheetId).length)));for(let e=0;e<=t;e++)i.push(o.next())}for(const[t,n]of Object.entries(e.dataSets)){let r;if(n.labelCell){const e=n.labelCell,s=e?this.getters.getCell(e.sheetId,e.zone.left,e.zone.top):void 0;r=s&&e?this.truncateLabel(s.formattedValue):r=`${Cc.Series} ${parseInt(t)+1}`}else r=r=`${Cc.Series} ${parseInt(t)+1}`;const a="pie"!==e.type?o.next():"#FFFFFF",l={label:r,data:n.dataRange?this.getData(n,e.sheetId):[],lineTension:0,borderColor:a,backgroundColor:a};"pie"===e.type&&(l.backgroundColor=i),s.data.datasets.push(l)}return s}getData(e,t){if(e.dataRange){const t=e.labelCell?[Xs(e.labelCell.zone)]:[],s=so([Xs(e.dataRange.zone)],t)[0];if(void 0===s)return[];const o=this.getters.getRangeFromSheetXC(e.dataRange.sheetId,s);return this.getters.getRangeValues(o)}return[]}}$h.getters=["getChartRuntime"],$h.modes=["normal"];class Dh extends yh{constructor(){super(...arguments),this.isStale=!0,this.computedStyles={},this.computedIcons={},this.uuidGenerator=new Hs,this.rulePredicate={CellIsRule:(e,t)=>{if(e&&e.evaluated.type===$e.error)return!1;const s=t.values.map(Xr);switch(t.operator){case"IsEmpty":return!_s(e)||""===e.evaluated.value.toString().trim();case"IsNotEmpty":return _s(e)&&""!==e.evaluated.value.toString().trim();case"BeginsWith":return!(!e&&""===s[0])&&(_s(e)&&(null==e?void 0:e.evaluated.value.toString().startsWith(s[0].toString())));case"EndsWith":return!(!e&&""===s[0])&&(_s(e)&&e.evaluated.value.toString().endsWith(s[0].toString()));case"Between":return _s(e)&&e.evaluated.value>=s[0]&&e.evaluated.value<=s[1];case"NotBetween":return!(_s(e)&&e.evaluated.value>=s[0]&&e.evaluated.value<=s[1]);case"ContainsText":return _s(e)&&e.evaluated.value.toString().indexOf(s[0].toString())>-1;case"NotContains":return!_s(e)||!e.evaluated.value||-1==e.evaluated.value.toString().indexOf(s[0].toString());case"GreaterThan":return _s(e)&&e.evaluated.value>s[0];case"GreaterThanOrEqual":return _s(e)&&e.evaluated.value>=s[0];case"LessThan":return _s(e)&&e.evaluated.value<s[0];case"LessThanOrEqual":return _s(e)&&e.evaluated.value<=s[0];case"NotEqual":return!(!_s(e)&&""===s[0])&&(_s(e)&&e.evaluated.value!==s[0]);case"Equal":return!e&&""===s[0]||_s(e)&&e.evaluated.value===s[0];default:console.warn(a("Not implemented operator %s for kind of conditional formatting: %s",t.operator,t.type))}return!1}}}handle(e){switch(e.type){case"ACTIVATE_SHEET":const t=e.sheetIdTo;this.computedStyles[t]=this.computedStyles[t]||{},this.computedIcons[t]=this.computedIcons[t]||{},this.isStale=!0;break;case"AUTOFILL_CELL":const s=this.getters.getActiveSheetId(),o=this.getters.getRulesByCell(s,e.originCol,e.originRow);for(const t of o)this.adaptRules(s,t,[ns(e.col,e.row)],[]);break;case"PASTE_CONDITIONAL_FORMAT":this.pasteCf(e.origin,e.target,e.operation);break;case"DUPLICATE_SHEET":case"CREATE_SHEET":case"DELETE_SHEET":case"ADD_CONDITIONAL_FORMAT":case"REMOVE_CONDITIONAL_FORMAT":case"REMOVE_COLUMNS_ROWS":case"ADD_COLUMNS_ROWS":case"EVALUATE_CELLS":case"UPDATE_CELL":case"UNDO":case"REDO":case"DELETE_CELL":case"INSERT_CELL":this.isStale=!0}}finalize(){this.isStale&&(this.computeStyles(),this.isStale=!1)}getConditionalStyle(e,t){var s;const o=this.getters.getActiveSheetId(),i=this.computedStyles[o];return i&&(null===(s=i[e])||void 0===s?void 0:s[t])}getConditionalIcon(e,t){var s;const o=this.getters.getActiveSheetId(),i=this.computedIcons[o];return i&&(null===(s=i[e])||void 0===s?void 0:s[t])}computeStyles(){var e;const t=this.getters.getActiveSheetId();this.computedStyles[t]={},this.computedIcons[t]={};const s=this.computedStyles[t];for(let o of this.getters.getConditionalFormats(t))try{switch(o.rule.type){case"ColorScaleRule":for(let e of o.ranges)this.applyColorScale(e,o.rule);break;case"IconSetRule":for(let e of o.ranges)this.applyIcon(e,o.rule);break;default:for(let i of o.ranges){const n=qs(i);for(let i=n.top;i<=n.bottom;i++)for(let r=n.left;r<=n.right;r++){const n=this.rulePredicate[o.rule.type];let a=this.getters.getCell(t,r,i);n&&n(a,o.rule)&&(s[r]||(s[r]=[]),s[r][i]=Object.assign((null===(e=s[r])||void 0===e?void 0:e[i])||{},o.rule.style))}}}}catch(e){}}parsePoint(e,t,s){switch(t.type){case"value":return this.getters.evaluateFormula(`=${s}(${e})`);case"number":return Number(t.value);case"percentage":const o=this.getters.evaluateFormula(`=min(${e})`);return o+(this.getters.evaluateFormula(`=max(${e})`)-o)*Number(t.value)/100;case"percentile":return this.getters.evaluateFormula(`=PERCENTILE(${e},${Number(t.value)/100})`);case"formula":const i=t.value&&this.getters.evaluateFormula(t.value);return i instanceof Promise?null:i;default:return null}}applyIcon(e,t){const s=this.parsePoint(e,t.lowerInflectionPoint),o=this.parsePoint(e,t.upperInflectionPoint);if(null===s||null===o||s>o)return;const i=qs(e),n=this.getters.getActiveSheetId(),r=this.computedIcons[n],a=[t.icons.upper,t.icons.middle,t.icons.lower];for(let e=i.top;e<=i.bottom;e++)for(let l=i.left;l<=i.right;l++){const i=this.getters.getCell(n,l,e);if((null==i?void 0:i.evaluated.type)!==$e.number)continue;const c=this.computeIcon(i.evaluated.value,o,t.upperInflectionPoint.operator,s,t.lowerInflectionPoint.operator,a);r[l]||(r[l]=[]),r[l][e]=c}}computeIcon(e,t,s,o,i,n){return"ge"===s&&e>=t||"gt"===s&&e>t?n[0]:"ge"===i&&e>=o||"gt"===i&&e>o?n[1]:n[2]}applyColorScale(e,t){var s;const o=this.parsePoint(e,t.minimum,"min"),i=t.midpoint?this.parsePoint(e,t.midpoint):null,n=this.parsePoint(e,t.maximum,"max");if(null===o||null===n||o>=n||i&&(o>=i||i>=n))return;const r=qs(e),a=this.getters.getActiveSheetId(),l=this.computedStyles[a],c=[];t.midpoint&&i?(c.push({minValue:o,minColor:t.minimum.color,colorDiffUnit:this.computeColorDiffUnits(o,i,t.minimum.color,t.midpoint.color)}),c.push({minValue:i,minColor:t.midpoint.color,colorDiffUnit:this.computeColorDiffUnits(i,n,t.midpoint.color,t.maximum.color)})):c.push({minValue:o,minColor:t.minimum.color,colorDiffUnit:this.computeColorDiffUnits(o,n,t.minimum.color,t.maximum.color)});for(let e=r.top;e<=r.bottom;e++)for(let t=r.left;t<=r.right;t++){const r=this.getters.getCell(a,t,e);if((null==r?void 0:r.evaluated.type)===$e.number){const a=ms(r.evaluated.value,o,n);let h;h=2===c.length&&i?a<=i?this.colorCell(a,c[0].minValue,c[0].minColor,c[0].colorDiffUnit):this.colorCell(a,c[1].minValue,c[1].minColor,c[1].colorDiffUnit):this.colorCell(a,c[0].minValue,c[0].minColor,c[0].colorDiffUnit),l[t]||(l[t]=[]),l[t][e]=(null===(s=l[t])||void 0===s?void 0:s[e])||{},l[t][e].fillColor="#"+Yt(h)}}}computeColorDiffUnits(e,t,s,o){const i=t-e;return[((s>>16)%256-(o>>16)%256)/i,((s>>8)%256-(o>>8)%256)/i,(s%256-o%256)/i]}colorCell(e,t,s,o){const[i,n,r]=o;return Math.round((s>>16)%256-i*(e-t))<<16|Math.round((s>>8)%256-n*(e-t))<<8|Math.round(s%256-r*(e-t))}adaptRules(e,t,s,o){if(0===s.length&&0===o.length)return;const i=this.getters.getConditionalFormats(e),n=i.findIndex((e=>e.id===t.id));let r=[];n>-1&&(r=i[n].ranges),r=r.concat(s);const a=so(r,o);0!==a.length?this.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{id:t.id,rule:t.rule,stopIfTrue:t.stopIfTrue},target:a.map(qs),sheetId:e}):this.dispatch("REMOVE_CONDITIONAL_FORMAT",{id:t.id,sheetId:e})}pasteCf(e,t,s){const o=ns(t.col,t.row);for(let i of this.getters.getConditionalFormats(e.sheetId))for(let n of i.ranges)if(to(e.col,e.row,qs(n))){const n=i,r=[];if("CUT"===s&&r.push(ns(e.col,e.row)),e.sheetId===t.sheetId)this.adaptRules(e.sheetId,n,[o],r);else{this.adaptRules(e.sheetId,n,[],r);const s=this.getCFToCopyTo(t.sheetId,n);this.adaptRules(t.sheetId,s,[o],[])}}}getCFToCopyTo(e,t){const s=this.getters.getConditionalFormats(e).find((e=>e.stopIfTrue===t.stopIfTrue&&Fs(e.rule,t.rule)));return s||{...t,id:this.uuidGenerator.uuidv4(),ranges:[]}}}Dh.getters=["getConditionalStyle","getConditionalIcon"],Dh.modes=["normal"];var Ph;!function(e){e[e.previous=-1]="previous",e[e.current=0]="current",e[e.next=1]="next"}(Ph||(Ph={}));class Uh extends yh{constructor(){super(...arguments),this.searchMatches=[],this.selectedMatchIndex=null,this.currentSearchRegex=null,this.searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1},this.replaceOptions={modifyFormulas:!1},this.toSearch=""}handle(e){switch(e.type){case"UPDATE_SEARCH":this.updateSearch(e.toSearch,e.searchOptions);break;case"CLEAR_SEARCH":case"UNDO":case"REDO":case"REMOVE_COLUMNS_ROWS":case"ADD_COLUMNS_ROWS":this.clearSearch();break;case"SELECT_SEARCH_PREVIOUS_MATCH":this.selectNextCell(Ph.previous);break;case"SELECT_SEARCH_NEXT_MATCH":this.selectNextCell(Ph.next);break;case"REPLACE_SEARCH":this.replace(e.replaceWith,e.replaceOptions);break;case"REPLACE_ALL_SEARCH":this.replaceAll(e.replaceWith,e.replaceOptions);break;case"ACTIVATE_SHEET":case"REFRESH_SEARCH":this.refreshSearch()}}getSearchMatches(){return this.searchMatches}getCurrentSelectedMatchIndex(){return this.selectedMatchIndex}updateSearch(e,t){this.searchOptions=t,e!==this.toSearch&&(this.selectedMatchIndex=null),this.toSearch=e,this.updateRegex(),this.refreshSearch()}refreshSearch(){const e=this.findMatches();this.searchMatches=e,this.selectNextCell(Ph.current)}updateRegex(){let e=ps(this.toSearch);const t=this.searchOptions.matchCase?"":"i";this.searchOptions.exactMatch&&(e=`^${e}$`),this.currentSearchRegex=RegExp(e,t)}findMatches(){const e=this.getters.getActiveSheetId(),t=this.getters.getCells(e),s=[];if(this.toSearch)for(const e of Object.values(t))if(e&&this.currentSearchRegex&&this.currentSearchRegex.test(this.searchOptions.searchFormulas&&e.isFormula()?e.content:String(e.evaluated.value))){const t=this.getters.getCellPosition(e.id),o={col:t.col,row:t.row,selected:!1};s.push(o)}return s.sort(this.sortByRowThenColumn)}sortByRowThenColumn(e,t){return e.row===t.row?e.col-t.col:e.row>t.row?1:-1}selectNextCell(e){const t=this.searchMatches;if(!t.length)return void(this.selectedMatchIndex=null);let s;s=null===this.selectedMatchIndex?0:this.selectedMatchIndex+e,s=(s%t.length+t.length)%t.length,null!==this.selectedMatchIndex&&this.selectedMatchIndex===s||(this.selectedMatchIndex=s,this.dispatch("SELECT_CELL",{col:t[s].col,row:t[s].row}));for(let e=0;e<this.searchMatches.length;e++)this.searchMatches[e].selected=e===this.selectedMatchIndex}clearSearch(){this.toSearch="",this.searchMatches=[],this.selectedMatchIndex=null,this.currentSearchRegex=null,this.searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1},this.replaceOptions={modifyFormulas:!1}}replace(e,t){if(this.replaceOptions=t,null===this.selectedMatchIndex||!this.currentSearchRegex)return;const s=this.searchMatches[this.selectedMatchIndex],o=this.getters.getActiveSheetId(),i=this.getters.getCell(o,s.col,s.row),n=this.toReplace(i,o);if(i&&n){const t=new RegExp(this.currentSearchRegex.source,this.currentSearchRegex.flags+"g"),o=n.toString().replace(t,e);this.dispatch("UPDATE_CELL",{sheetId:this.getters.getActiveSheetId(),col:s.col,row:s.row,content:o}),this.searchMatches.splice(this.selectedMatchIndex,1),this.selectNextCell(Ph.current)}else this.selectNextCell(Ph.next)}replaceAll(e,t){const s=this.searchMatches.length;for(let o=0;o<s;o++)this.replace(e,t)}toReplace(e,t){if(e){if(this.searchOptions.searchFormulas&&e.isFormula())return e.content;if(this.replaceOptions.modifyFormulas||!e.isFormula())return e.evaluated.value.toString()}return null}drawGrid(e){const{ctx:t,viewport:s}=e,o=this.getters.getActiveSheetId();for(const e of this.searchMatches){const i=this.getters.getMerge(o,e.col,e.row),n=i?i.left:e.col,r=i?i.right:e.col,a=i?i.top:e.row,l=i?i.bottom:e.row,[c,h,d,u]=this.getters.getRect({top:a,left:n,right:r,bottom:l},s);d>0&&u>0&&(t.fillStyle="#8B008B33",t.fillRect(c,h,d,u),e.selected&&(t.strokeStyle="#8B008B",t.strokeRect(c,h,d,u)))}}}Uh.layers=[3],Uh.getters=["getSearchMatches","getCurrentSelectedMatchIndex"];class Vh extends yh{handle(e){if("SET_DECIMAL"===e.type)this.setDecimal(e.sheetId,e.target,e.step)}setDecimal(e,t,s){const o=this.searchNumberFormat(e,t);if(void 0!==o){const i=this.changeDecimalFormat(o,s);this.dispatch("SET_FORMATTING",{sheetId:e,target:t,format:i})}}searchNumberFormat(e,t){var s;for(let o of t)for(let t=o.top;t<=o.bottom;t++)for(let i=o.left;i<=o.right;i++){const o=this.getters.getCell(e,i,t);if((null==o?void 0:o.evaluated.type)===$e.number&&!(null===(s=o.format)||void 0===s?void 0:s.match(_)))return o.format||this.setDefaultNumberFormat(o.evaluated.value)}}setDefaultNumberFormat(e){const t=e.toString().split(".");return 1===t.length?"0":"0."+Array(t[1].length+1).join("0")}changeDecimalFormat(e,t){const s=Math.sign(t),o=e.split(";");let i=[];for(let e of o){const t=e.indexOf("."),o=e.toUpperCase().indexOf("E");let n;const r=o>-1?e.slice(0,o):e,a=t>-1?r.slice(t).match(/0/g).length:0,l=r.lastIndexOf("0");l>-1?s>0?n=a<ae?e.slice(0,l+1)+(0===a?".0":"0")+e.slice(l+1):e:a>0?(n=e.slice(0,l)+e.slice(l+1),1===a&&(n=n.slice(0,t)+n.slice(t+1))):n=e:n=e,i.push(n)}return i.join(";")}}Vh.modes=["normal"];class Bh extends yh{getHighlights(){return this.prepareHighlights(this.getters.getComposerHighlights().concat(this.getters.getSelectionInputHighlights()))}prepareHighlights(e){if(0===e.length)return[];const t=this.getters.getActiveSheetId(),s=[];for(let[o,i]of e){const{xc:e,sheetName:n}=ss(o),r=n?this.getters.getSheetIdByName(n):t;if(r){let o=qs(e);const{height:n,width:a}=io(o);o=n*a==1?this.getters.expandZone(t,qs(e)):o,s.push({zone:o,color:i,sheet:r})}}return s.filter((e=>e.zone.top>=0&&e.zone.left>=0&&e.zone.bottom<this.getters.getSheet(e.sheet).rows.length&&e.zone.right<this.getters.getSheet(e.sheet).cols.length))}drawGrid(e){const{ctx:t,viewport:s,thinLineWidth:o}=e,i=this.getters.getActiveSheetId(),n=3*o;t.lineWidth=n;for(let e of this.getHighlights().filter(((e,t)=>this.getHighlights().findIndex((t=>Js(t.zone,e.zone)&&t.sheet===i))===t))){const[o,i,r,a]=this.getters.getRect(e.zone,s);r>0&&a>0&&(t.strokeStyle=e.color,t.strokeRect(o+n/2,i+n/2,r-n,a-n),t.globalCompositeOperation="source-over",t.fillStyle=e.color+"20",t.fillRect(o+n,i+n,r-2*n,a-2*n))}}}function Hh(e,t){let s=0,o=e.length-1;for(;s<=o;){const i=Math.floor((s+o)/2),n=e[i];if(t<n.start)o=i-1;else if(t>n.end)s=i+1;else{if(!n.isHidden)return i;s+=1}}return-1}Bh.modes=["normal"],Bh.layers=[1],Bh.getters=["getHighlights"];class zh extends yh{constructor(){super(...arguments),this.boxes=[]}getColIndex(e,t,s){if(e<v)return-1;const o=(s||this.getters.getActiveSheet()).cols;return Hh(o,e-v+o[t].start+1)}getRowIndex(e,t,s){if(e<m)return-1;const o=(s||this.getters.getActiveSheet()).rows;return Hh(o,e-m+o[t].start+1)}getRect(e,t){const{left:s,top:o,right:i,bottom:n}=e,{offsetX:r,offsetY:a}=this.getShiftedViewport(t),{cols:l,rows:c}=this.getters.getActiveSheet(),h=Math.max(l[s].start-r,v),d=l[i].end-r-h,u=Math.max(c[o].start-a,m);return[h,u,d,c[n].end-a-u]}isVisibleInViewport(e,t,s){const{right:o,left:i,top:n,bottom:r}=s;return t<=r&&t>=n&&e>=i&&e<=o}getEdgeScrollCol(e){let t=!1,s=0,o=0;const{width:i}=this.getters.getViewportDimensionWithHeaders(),{width:n}=this.getters.getMaxViewportSize(this.getters.getActiveSheet()),{left:r,offsetX:a}=this.getters.getActiveSnappedViewport();return e<v&&r>0?(t=!0,s=-1,o=cs(v-e)):e>i&&a<n-i&&(t=!0,s=1,o=cs(e-i)),{canEdgeScroll:t,direction:s,delay:o}}getEdgeScrollRow(e){let t=!1,s=0,o=0;const{height:i}=this.getters.getViewportDimensionWithHeaders(),{height:n}=this.getters.getMaxViewportSize(this.getters.getActiveSheet()),{top:r,offsetY:a}=this.getters.getActiveSnappedViewport();return e<m&&r>0?(t=!0,s=-1,o=cs(m-e)):e>i&&a<n-i&&(t=!0,s=1,o=cs(e-i)),{canEdgeScroll:t,direction:s,delay:o}}drawGrid(e,t){switch(t){case 0:this.boxes=this.getGridBoxes(e),this.drawBackground(e),this.drawCellBackground(e),this.drawBorders(e),this.drawTexts(e),this.drawIcon(e);break;case 7:this.drawHeaders(e)}}drawBackground(e){const{ctx:t,thinLineWidth:s,viewport:o}=e,{width:i,height:n}=this.getters.getViewportDimensionWithHeaders(),{cols:r,rows:a,id:l}=this.getters.getActiveSheet();t.fillStyle="white",t.fillRect(0,0,i,n);const{right:c,left:h,top:d,bottom:u,offsetX:p,offsetY:g}=this.getShiftedViewport(o);if(!this.getters.getGridLinesVisibility(l))return;t.lineWidth=2*s,t.strokeStyle="#E2E3E3",t.beginPath();const f=Math.min(n,a[u].end-g);for(let e=h;e<=c;e++){if(r[e].isHidden)continue;const s=r[e].end-p;t.moveTo(s,0),t.lineTo(s,f)}const m=Math.min(i,r[c].end-p);for(let e=d;e<=u;e++){if(a[e].isHidden)continue;const s=a[e].end-g;t.moveTo(0,s),t.lineTo(m,s)}t.stroke()}drawCellBackground(e){const{ctx:t,thinLineWidth:s}=e;t.lineWidth=.3*s;const o=.1*s;t.strokeStyle="#111";const i=this.getters.getGridLinesVisibility(this.getters.getActiveSheetId());for(let e of this.boxes){let s=e.style;(s.fillColor&&"#ffffff"!==s.fillColor||e.isMerge)&&(t.fillStyle=s.fillColor||"#ffffff",t.fillRect(e.x,e.y,e.width,e.height),i&&t.strokeRect(e.x+o,e.y+o,e.width-2*o,e.height-2*o)),e.error&&(t.fillStyle="red",t.beginPath(),t.moveTo(e.x+e.width-5,e.y),t.lineTo(e.x+e.width,e.y),t.lineTo(e.x+e.width,e.y+5),t.fill())}}drawBorders(e){const{ctx:t,thinLineWidth:s}=e;for(let e of this.boxes){let t=e.border;if(t){const{x:s,y:i,width:n,height:r}=e;t.left&&o(t.left,s,i,s,i+r),t.top&&o(t.top,s,i,s+n,i),t.right&&o(t.right,s+n,i,s+n,i+r),t.bottom&&o(t.bottom,s,i+r,s+n,i+r)}}function o([e,o],i,n,r,a){t.strokeStyle=o,t.lineWidth=("thin"===e?2:3)*s,t.beginPath(),t.moveTo(i,n),t.lineTo(r,a),t.stroke()}}drawTexts(e){const{ctx:t,thinLineWidth:s}=e;let o;t.textBaseline="middle";for(let e of this.boxes)if(e.content){const i=e.style||{},n=e.content.align||"left",r=i.italic?"italic ":"",a=i.bold?"bold":T,l=i.fontSize||R,c=ds[l],h=`${r}${a} ${c}px ${L}`;let d;h!==o&&(o=h,t.font=h),t.fillStyle=i.textColor||"#000";let u=e.y+e.height/2+1;d="left"===n?e.x+(e.image?e.image.size+2*w:4):"right"===n?e.x+e.width-4:e.x+e.width/2,t.textAlign=n,e.clipRect&&(t.save(),t.beginPath(),t.rect(...e.clipRect),t.clip()),t.fillText(e.content.text,Math.round(d),Math.round(u)),(i.strikethrough||i.underline)&&("right"===n?d-=e.content.width:"center"===n&&(d-=e.content.width/2),i.strikethrough&&t.fillRect(d,u,e.content.width,2.6*s),i.underline&&(u=e.y+e.height/2+1+c/2,t.fillRect(d,u,e.content.width,1.3*s))),e.clipRect&&t.restore()}}drawIcon(e){const{ctx:t}=e;for(const e of this.boxes)if(e.image){const s=e.image.image,o=e.image.size,i=(e.height-o)/2;e.image.clipIcon&&(t.save(),t.beginPath(),t.rect(...e.image.clipIcon),t.clip()),t.drawImage(s,e.x+w,e.y+i,o,o),e.image.clipIcon&&t.restore()}}drawHeaders(e){const{ctx:t,thinLineWidth:s,viewport:o}=e,{right:i,left:n,top:r,bottom:a,offsetX:l,offsetY:p}=this.getShiftedViewport(o),{width:g,height:f}=this.getters.getViewportDimensionWithHeaders(),E=this.getters.getSelectedZones(),{cols:b,rows:S}=this.getters.getActiveSheet(),C=this.getters.getActiveCols(),y=this.getters.getActiveRows();t.fillStyle=c,t.font=`400 11px ${L}`,t.textAlign="center",t.textBaseline="middle",t.lineWidth=s,t.strokeStyle="#333",t.fillRect(0,0,g,m),t.fillRect(0,0,v,f),t.fillStyle=h;for(let e of E){const s=Math.max(v,b[e.left].start-l),o=Math.max(v,b[e.right].end-l),i=Math.max(m,S[e.top].start-p),n=Math.max(m,S[e.bottom].end-p);t.fillStyle=C.has(e.left)?d:h,t.fillRect(s,0,o-s,m),t.fillStyle=y.has(e.top)?d:h,t.fillRect(0,i,v,n-i)}t.beginPath(),t.moveTo(v,0),t.lineTo(v,f),t.moveTo(0,m),t.lineTo(g,m),t.strokeStyle="#C0C0C0",t.stroke(),t.beginPath();for(let e=n;e<=i;e++){const s=b[e];s.isHidden||(t.fillStyle=C.has(e)?"#fff":u,t.fillText(s.name,(s.start+s.end)/2-l,13),t.moveTo(s.end-l,0),t.lineTo(s.end-l,m))}for(let e=r;e<=a;e++){const s=S[e];s.isHidden||(t.fillStyle=y.has(e)?"#fff":u,t.fillText(s.name,24,(s.start+s.end)/2-p),t.moveTo(0,s.end-p),t.lineTo(v,s.end-p))}t.stroke()}hasContent(e,t){const s=this.getters.getActiveSheetId(),o=this.getters.getCell(s,e,t);return o&&!o.isEmpty()||this.getters.isInMerge(s,e,t)}getShiftedViewport(e){return{...e,offsetX:e.offsetX-v,offsetY:e.offsetY-m}}findNextEmptyCol(e,t,s){let o=e;for(;o<t&&!this.hasContent(o+1,s);)o++;return o}findPreviousEmptyCol(e,t,s){let o=e;for(;o>t&&!this.hasContent(o-1,s);)o--;return o}computeCellAlignment(e,t){if(e.isFormula()&&this.getters.shouldShowFormulas())return"left";const{align:s}=this.getters.getCellStyle(e);return t&&e.evaluated.type===$e.number?"center"!==s?"left":s:s||e.defaultAlign}createBoxFromPosition(e,t,s,o,i,n){const{right:r,left:a,offsetX:l,offsetY:c}=this.getShiftedViewport(o),h=this.getters.getCol(e,t),d=this.getters.getRow(e,s),u=this.getters.getCell(e,t,s),p=this.getters.shouldShowFormulas(),g={x:h.start-l,y:d.start-c,width:i,height:n,border:this.getters.getCellBorder(e,t,s)||void 0,style:{...this.getters.getCellStyle(u),...this.getters.getConditionalStyle(t,s)}};if(!u)return g;const f=this.getters.getConditionalIcon(t,s),m=g.style.fontSize||R,v=ds[m],E=f?2*w+v:0;f&&(g.image={type:"icon",size:v,clipIcon:[g.x,g.y,Math.min(E,i),n],image:Yl[f].img});const b=this.getters.getCellText(u,p),S=this.getters.getTextWidth(u),C=E+S,y=this.computeCellAlignment(u,C>i);g.content={text:b,width:S,align:y},u.evaluated.type===$e.error&&(g.error=u.evaluated.error);const I=C>i||ds[m]>n;if(f)g.clipRect=[g.x+E,g.y,Math.max(0,i-E),n];else if(I){let o,u;switch(this.getters.isInMerge(e,t,s)?(o=this.getters.getMerge(e,t,s).right,u=t):(o=this.findNextEmptyCol(t,r,s),u=this.findPreviousEmptyCol(t,a,s)),y){case"left":{const t=this.getters.getCol(e,o).end-h.start;(t<S||v>d.size)&&(g.clipRect=[h.start-l,d.start-c,t,n]);break}case"right":{const t=this.getters.getCol(e,u),s=h.end+i-h.size-t.start;(s<S||v>d.size)&&(g.clipRect=[t.start-l,d.start-c,s,n]);break}case"center":{const s=this.getters.getCol(e,u),i=this.getters.getCol(e,o).end-s.start;(i<S||u===t||o===t||v>d.size)&&(g.clipRect=[s.start-l,d.start-c,i,n]);break}}}return g}getGridBoxes(e){const t=[],{viewport:s}=e,{right:o,left:i,top:n,bottom:r}=this.getShiftedViewport(s),a=this.getters.getActiveSheetId();for(let e=n;e<=r;e++){const n=this.getters.getRow(a,e);if(!n.isHidden)for(let r=i;r<=o;r++){const o=this.getters.getCol(a,r);o.isHidden||(this.getters.isInMerge(a,r,e)||t.push(this.createBoxFromPosition(a,r,e,s,o.size,n.size)))}}for(const e of this.getters.getMerges(a))if(!this.getters.isMergeHidden(a,e)&&eo(e,s)){const o=this.getters.getCol(a,e.right).end-this.getters.getCol(a,e.left).start,i=this.getters.getRow(a,e.bottom).end-this.getters.getRow(a,e.top).start,n=this.createBoxFromPosition(a,e.left,e.top,s,o,i),r=this.getters.getCellBorder(a,e.right,e.bottom);n.border={...n.border,bottom:r?r.bottom:void 0,right:r?r.right:void 0},n.isMerge=!0,t.push(n)}return t}}zh.layers=[0,7],zh.getters=["getColIndex","getRowIndex","getRect","isVisibleInViewport","getEdgeScrollCol","getEdgeScrollRow"],zh.modes=["normal"];const Zh=new Hs;class Gh extends yh{constructor(){super(...arguments),this.inputs={},this.activeSheets={},this.inputHasSingleRange={},this.focusedInputId=null,this.focusedRange=null,this.willAddNewRange=!1}allowDispatch(e){switch(e.type){case"FOCUS_RANGE":const t=this.getIndex(e.id,e.rangeId);if(this.focusedInputId===e.id&&this.focusedRange===t)return 24;break;case"ADD_EMPTY_RANGE":if(this.inputHasSingleRange[e.id]&&1===this.inputs[e.id].length)return 25}return 0}handle(e){switch(e.type){case"ENABLE_NEW_SELECTION_INPUT":this.initInput(e.id,e.initialRanges||[],e.hasSingleRange);break;case"DISABLE_SELECTION_INPUT":this.focusedInputId===e.id&&this.unfocus(),delete this.inputs[e.id],delete this.activeSheets[e.id],delete this.inputHasSingleRange[e.id];break;case"UNFOCUS_SELECTION_INPUT":this.unfocus();break;case"FOCUS_RANGE":this.focus(e.id,this.getIndex(e.id,e.rangeId));break;case"CHANGE_RANGE":{const t=this.getIndex(e.id,e.rangeId);if(null!==t){const s=e.id;this.focusedInputId===s&&this.focusedRange===t||this.dispatch("FOCUS_RANGE",{id:s,rangeId:this.inputs[s][t].id});const o=e.value.split(",").map((e=>e.trim()));this.setRange(s,t,o)}break}case"ADD_EMPTY_RANGE":this.insertNewRange(e.id,this.inputs[e.id].length,[""]),this.focusLast(e.id);break;case"REMOVE_RANGE":const t=this.getIndex(e.id,e.rangeId);null!==t&&this.removeRange(e.id,t);break;case"SELECT_CELL":case"SET_SELECTION":if(!this.focusedInputId)break;const s=this.getSelectionInputValue(this.focusedInputId),o=(this.inputHasSingleRange[this.focusedInputId]?[this.getters.getSelectedZone()]:this.getters.getSelectedZones()).map(Xs).filter((e=>!s.includes(e))),i=this.activeSheets[this.focusedInputId],n=this.getters.getActiveSheetId(),r=this.getters.getSheetName(n);this.add(o.map((e=>n===i?e:`${fs(r)}!${e}`)));break;case"PREPARE_SELECTION_EXPANSION":{const[e,t]=[this.focusedInputId,this.focusedRange];null===e||null===t||this.inputHasSingleRange[e]||(this.willAddNewRange=""!==this.inputs[e][t].xc.trim());break}}}getSelectionInput(e){return this.inputs[e]?this.inputs[e].map(((t,s)=>Object.assign({},t,{color:this.focusedInputId===e&&null!==this.focusedRange&&this.isRangeValid(t.xc)?t.color:null,isFocused:this.focusedInputId===e&&this.focusedRange===s}))):[]}isRangeValid(e){if(!e)return!1;const{xc:t,sheetName:s}=ss(e);return null!==t.match(ts)&&(!s||void 0!==this.getters.getSheetIdByName(s))}getSelectionInputValue(e){return this.cleanInputs(this.inputs[e].map((e=>e.xc?e.xc:"")))}getSelectionInputHighlights(){return this.focusedInputId?this.inputs[this.focusedInputId].map((e=>this.inputToHighlights(this.focusedInputId,e))).flat():[]}initInput(e,t,s=!1){this.inputs[e]=[],this.insertNewRange(e,0,t),this.activeSheets[e]=this.getters.getActiveSheetId(),this.inputHasSingleRange[e]=s,0===this.inputs[e].length&&this.dispatch("ADD_EMPTY_RANGE",{id:e})}focus(e,t){this.focusedInputId=e,this.focusedRange=t}focusLast(e){this.focus(e,this.inputs[e].length-1)}unfocus(){this.focusedInputId=null,this.focusedRange=null}add(e){if(null===this.focusedInputId||null===this.focusedRange||this.getters.isSelectingForComposer()||0===e.length)return;if(this.getters.getSelectionMode()===Lh.expanding&&this.willAddNewRange){const t=this.focusedInputId;this.insertNewRange(t,this.inputs[t].length,e),this.focusLast(this.focusedInputId),this.willAddNewRange=!1}else this.setRange(this.focusedInputId,this.focusedRange,e)}setContent(e,t,s){this.inputs[e][t]={...this.inputs[e][t],id:Zh.uuidv4(),xc:s}}insertNewRange(e,t,s){this.inputs[e].splice(t,0,...s.map(((t,s)=>({xc:t,id:(this.inputs[e].length+s+1).toString(),color:Qt()}))))}setRange(e,t,s){const[,...o]=s;this.setContent(e,t,s[0]),this.insertNewRange(e,t+1,o),o.length&&this.focus(e,t+o.length)}removeRange(e,t){this.inputs[e].splice(t,1),this.focusedInputId===e&&null!==this.focusedRange&&this.focusLast(e)}inputToHighlights(e,{xc:t,color:s}){const o=this.cleanInputs([t]).filter((e=>this.isRangeValid(e))).filter((t=>this.shouldBeHighlighted(this.activeSheets[e],t)));if(0===o.length)return[];const[i,...n]=o,r=[[i,s||Qt()]];for(const e of n)r.push([e,Qt()]);return r}cleanInputs(e){return e.map((e=>e.split(","))).flat().map((e=>e.trim())).filter((e=>""!==e))}shouldBeHighlighted(e,t){const{sheetName:s}=ss(t),o=this.getters.getSheetIdByName(s),i=this.getters.getActiveSheet().id;return this.isRangeValid(t)&&(o===i||void 0===o&&i===e)}getIndex(e,t){const s=this.inputs[e].findIndex((e=>e.id===t));return s>=0?s:null}}Gh.modes=["normal"],Gh.layers=[1],Gh.getters=["getSelectionInput","getSelectionInputValue","isRangeValid","getSelectionInputHighlights"];class Wh{constructor(){this.bus=new o.core.EventBus}on(e,t,s){this.bus.on(e,t,s)}trigger(e,t){this.bus.trigger(e,t)}off(e,t){this.bus.off(e,t)}clear(){this.bus.clear()}}function qh(e,t){return"REMOVE_COLUMNS_ROWS"===t.type?function(e,t,s){const o="left"===t?"right":"bottom";let i=e[t],n=e[o];for(let r of s.sort(((e,t)=>t-e)))e[t]>r&&(i--,n--),e[t]<=r&&e[o]>=r&&n--;if(!(i>n))return{...e,[t]:i,[o]:n}}(e,"COL"===t.dimension?"left":"top",t.elements):"ADD_COLUMNS_ROWS"===t.type?function(e,t,s,o,i){const n="left"===t?"columns":"rows",r="before"===o?s-1:s,a="left"===t?"right":"bottom",l="before"===o?e[a]>r:e[a]>=r;return e[t]<=r&&l?ao(e,n,"RESIZE",i):r<e[t]?ao(e,n,"MOVE",i):{...e}}(e,"COL"===t.dimension?"left":"top",t.base,t.position,t.quantity):{...e}}function jh(e,t){const s=e.definition;let o,i;return s.labelRange&&(o=qh(qs(s.labelRange),t)),s.dataSets&&(i=s.dataSets.map(qs).map((e=>qh(e,t))).filter(_s).map(Xs)),{...e,definition:{...s,dataSets:i,labelRange:o?Xs(o):void 0}}}yl.addTransformation("ADD_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],jh),yl.addTransformation("REMOVE_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],jh),yl.addTransformation("DELETE_FIGURE",["UPDATE_FIGURE","UPDATE_CHART"],(function(e,t){if(e.id===t.id)return;return e})),yl.addTransformation("CREATE_SHEET",["CREATE_SHEET"],(function(e,t){var s;if(e.name===t.name)return{...e,name:(null===(s=e.name)||void 0===s?void 0:s.match(/\d+/))?e.name.replace(/\d+/,(e=>(parseInt(e)+1).toString())):`${e.name}~`,position:e.position+1};return e})),yl.addTransformation("ADD_MERGE",["ADD_MERGE","REMOVE_MERGE"],(function(e,t){if(e.sheetId!==t.sheetId)return e;const s=[];for(const o of e.target)for(const e of t.target)eo(o,e)||s.push({...o});if(s.length)return{...e,target:s};return}));const Xh=[{match:function(e){return"sheetId"in e},fn:function(e,t){const s="DELETE_SHEET"===t.type&&t.sheetId;if(e.sheetId===s)return"IGNORE_COMMAND";if("CREATE_SHEET"===e.type||"CREATE_SHEET"===t.type||e.sheetId!==t.sheetId)return e;return"SKIP_TRANSFORMATION"}},{match:function(e){return"target"in e},fn:function(e,t){const s=[];for(const o of e.target){const e=qh(o,t);e&&s.push(e)}if(!s.length)return"IGNORE_COMMAND";return{...e,target:s}}},{match:function(e){return"col"in e&&"row"in e},fn:function(e,t){if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type)return function(e,t){const s="COL"===t.dimension?"col":"row";let o=e[s];if("REMOVE_COLUMNS_ROWS"===t.type){const e=[...t.elements].sort(((e,t)=>t-e));if(e.includes(o))return"IGNORE_COMMAND";for(let t of e)o>=t&&o--}"ADD_COLUMNS_ROWS"===t.type&&(o>t.base||o===t.base&&"before"===t.position)&&(o+=t.quantity);return{...e,[s]:o}}(e,t);if("ADD_MERGE"===t.type)return function(e,t){for(const s of t.target){if(!(e.col===s.left&&e.row===s.top)&&to(e.col,e.row,s))return"IGNORE_COMMAND"}return e}(e,t);return"SKIP_TRANSFORMATION"}},{match:function(e){return"dimension"in e},fn:function(e,t){if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type){if(t.dimension!==e.dimension)return e;const s="ADD_COLUMNS_ROWS"===e.type,o=s?"base":"elements";let i=s?[e[o]]:e[o];if("REMOVE_COLUMNS_ROWS"===t.type&&(i=i.map((e=>{if(t.elements.includes(e))return;const s=t.elements.sort(((e,t)=>t-e));for(let t of s)e>t&&e--;return e})).filter(_s)),"ADD_COLUMNS_ROWS"===t.type){const e="before"===t.position?t.base-1:t.base;i=i.map((s=>s>e?s+t.quantity:s))}if(i.length){let t=i;return s&&(t=i[0]),{...e,[o]:t}}return"IGNORE_COMMAND"}return"SKIP_TRANSFORMATION"}}];function Yh(e,t){const s=yl.getTransformation(e.type,t.type);return s?s(e,t):function(e,t){for(const{match:s,fn:o}of Xh)if(s(e)){const s=o(e,t);if("SKIP_TRANSFORMATION"===s)continue;if("IGNORE_COMMAND"===s)return;return s}return e}(e,t)}function Kh(e,t){let s=[...e];for(const e of t)s=s.map((t=>Yh(t,e))).filter(_s);return s}class Qh{constructor(e,t,s,o){this._commands=[],this._changes=[],this.id=e,this.clientId=t,this._commands=[...s],this._changes=o?[...o]:[]}setChanges(e){this._changes=e}get commands(){return this._commands}get changes(){return this._changes}}class Jh extends Error{}class ed extends Wh{constructor(e,t,s=N){super(),this.revisions=e,this.transportService=t,this.serverRevisionId=s,this.clients={},this.clientId="local",this.pendingMessages=[],this.waitingAck=!1,this.waitingUndoRedoAck=!1,this.isReplayingInitialRevisions=!1,this.processedRevisions=new Set,this.uuidGenerator=new Hs,this.debouncedMove=o.utils.debounce(this._move.bind(this),200)}canApplyOptimisticUpdate(){return!this.waitingUndoRedoAck}save(e,t){if(!e.length||!t.length||!this.canApplyOptimisticUpdate())return;const s=new Qh(this.uuidGenerator.uuidv4(),this.clientId,e,t);this.revisions.append(s.id,s),this.trigger("new-local-state-update",{id:s.id}),this.sendUpdateMessage({type:"REMOTE_REVISION",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:s.id,clientId:s.clientId,commands:s.commands})}undo(e){this.waitingUndoRedoAck=!0,this.sendUpdateMessage({type:"REVISION_UNDONE",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:this.uuidGenerator.uuidv4(),undoneRevisionId:e})}redo(e){this.waitingUndoRedoAck=!0,this.sendUpdateMessage({type:"REVISION_REDONE",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:this.uuidGenerator.uuidv4(),redoneRevisionId:e})}move(e){this.debouncedMove(e)}join(e){e?(this.clients[e.id]=e,this.clientId=e.id):(this.clients.local={id:"local",name:"local"},this.clientId="local"),this.transportService.onNewMessage(this.clientId,this.onMessageReceived.bind(this))}loadInitialMessages(e){this.isReplayingInitialRevisions=!0;for(const t of e)this.onMessageReceived(t);this.isReplayingInitialRevisions=!1}leave(){delete this.clients[this.clientId],this.transportService.leave(this.clientId),this.transportService.sendMessage({type:"CLIENT_LEFT",clientId:this.clientId,version:1})}snapshot(e){const t=this.uuidGenerator.uuidv4();this.transportService.sendMessage({type:"SNAPSHOT",nextRevisionId:t,serverRevisionId:this.serverRevisionId,data:{...e,revisionId:t},version:1})}getClient(){const e=this.clients[this.clientId];if(!e)throw new Jh("The client left the session");return e}getConnectedClients(){return new Set(Object.values(this.clients).filter(_s))}getRevisionId(){return this.serverRevisionId}isFullySynchronized(){return 0===this.pendingMessages.length}_move(e){var t;if(!this.clients[this.clientId])return;const s=null===(t=this.clients[this.clientId])||void 0===t?void 0:t.position;if((null==s?void 0:s.col)===e.col&&s.row===e.row&&s.sheetId===e.sheetId)return;const o=s?"CLIENT_MOVED":"CLIENT_JOINED",i=this.getClient();this.clients[this.clientId]={...i,position:e},this.transportService.sendMessage({type:o,version:1,client:{...i,position:e}})}onMessageReceived(e){if(!this.isAlreadyProcessed(e))if(this.isWrongServerRevisionId(e))this.trigger("unexpected-revision-id");else{switch(e.type){case"CLIENT_MOVED":this.onClientMoved(e);break;case"CLIENT_JOINED":this.onClientJoined(e);break;case"CLIENT_LEFT":this.onClientLeft(e);break;case"REVISION_REDONE":this.revisions.redo(e.redoneRevisionId,e.nextRevisionId,e.serverRevisionId),this.trigger("revision-redone",{revisionId:e.redoneRevisionId,commands:this.revisions.get(e.redoneRevisionId).commands});break;case"REVISION_UNDONE":this.revisions.undo(e.undoneRevisionId,e.nextRevisionId,e.serverRevisionId),this.trigger("revision-undone",{revisionId:e.undoneRevisionId,commands:this.revisions.get(e.undoneRevisionId).commands});break;case"REMOTE_REVISION":const{clientId:t,commands:s}=e,o=new Qh(e.nextRevisionId,t,s);if(o.clientId!==this.clientId){this.revisions.insert(o.id,o,e.serverRevisionId);const t=this.pendingMessages.filter((e=>"REMOTE_REVISION"===e.type)).map((e=>e.commands)).flat();this.trigger("remote-revision-received",{commands:Kh(s,t)})}break;case"SNAPSHOT_CREATED":{const t=new Qh(e.nextRevisionId,"server",[]);this.revisions.insert(t.id,t,e.serverRevisionId),this.dropPendingHistoryMessages(),this.trigger("snapshot");break}}this.acknowledge(e),this.trigger("collaborative-event-received")}}onClientMoved(e){e.client.id!==this.clientId&&(this.clients[e.client.id]=e.client)}onClientJoined(e){if(e.client.id!==this.clientId){this.clients[e.client.id]=e.client;const t=this.clients[this.clientId];if(t){const{position:e}=t;e&&this.transportService.sendMessage({type:"CLIENT_MOVED",version:1,client:{...t,position:e}})}}}onClientLeft(e){e.clientId!==this.clientId&&delete this.clients[e.clientId]}sendUpdateMessage(e){this.pendingMessages.push(e),this.waitingAck||(this.waitingAck=!0,this.sendPendingMessage())}sendPendingMessage(){let e=this.pendingMessages[0];if(e){if("REMOTE_REVISION"===e.type){const t=this.revisions.get(e.nextRevisionId);if(0===t.commands.length){this.revisions.drop(t.id);const e=this.pendingMessages.filter((e=>"REMOTE_REVISION"===e.type)).map((e=>e.nextRevisionId));return this.trigger("pending-revisions-dropped",{revisionIds:e}),this.waitingAck=!1,this.waitingUndoRedoAck=!1,void(this.pendingMessages=[])}e={...e,clientId:t.clientId,commands:t.commands}}if(this.isReplayingInitialRevisions)throw new Error(`Trying to send a new revision while replaying initial revision. This can lead to endless dispatches every time the spreadsheet is open.\n ${JSON.stringify(e)}`);this.transportService.sendMessage({...e,serverRevisionId:this.serverRevisionId})}}acknowledge(e){switch("REVISION_UNDONE"!==e.type&&"REVISION_REDONE"!==e.type||(this.waitingUndoRedoAck=!1),e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":case"SNAPSHOT_CREATED":this.waitingAck=!1,this.pendingMessages=this.pendingMessages.filter((t=>t.nextRevisionId!==e.nextRevisionId)),this.serverRevisionId=e.nextRevisionId,this.processedRevisions.add(e.nextRevisionId),this.sendPendingMessage()}}isAlreadyProcessed(e){switch(e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":return this.processedRevisions.has(e.nextRevisionId);default:return!1}}isWrongServerRevisionId(e){switch(e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":case"SNAPSHOT_CREATED":return e.serverRevisionId!==this.serverRevisionId;default:return!1}}dropPendingHistoryMessages(){this.waitingUndoRedoAck=!1,this.pendingMessages=this.pendingMessages.filter((({type:e})=>"REVISION_REDONE"!==e&&"REVISION_UNDONE"!==e))}}const td=["#ff851b","#0074d9","#7fdbff","#b10dc9","#39cccc","#f012be","#3d9970","#111111","#ff4136","#aaaaaa","#85144b","#001f3f"];class sd extends yh{constructor(){super(...arguments),this.availableColors=new Set(td),this.colors={}}isPositionValid(e){const t=this.getters.getSheet(e.sheetId);return e.row<t.rows.length&&e.col<t.cols.length}chooseNewColor(){0===this.availableColors.size&&(this.availableColors=new Set(td));const e=(t=[...this.availableColors.values()])[Math.floor(Math.random()*t.length)];var t;return this.availableColors.delete(e),e}getClientsToDisplay(){try{this.getters.getClient()}catch(e){if(e instanceof Jh)return[];throw e}const e=this.getters.getActiveSheetId(),t=[];for(const s of this.getters.getConnectedClients())if(s.id!==this.getters.getClient().id&&s.position&&s.position.sheetId===e&&this.isPositionValid(s.position)){const e=s.position;this.colors[s.id]||(this.colors[s.id]=this.chooseNewColor());const o=this.colors[s.id];t.push({...s,position:e,color:o})}return t}drawGrid(e){const{viewport:t,ctx:s,thinLineWidth:o}=e,i=this.getters.getActiveSheetId();for(const e of this.getClientsToDisplay()){const{row:n,col:r}=e.position,a=this.getters.expandZone(i,{top:n,bottom:n,left:r,right:r}),[l,c,h,d]=this.getters.getRect(a,t);if(h<=0||d<=0)continue;const u=e.color,p=`${u}10`;s.fillStyle=p,s.lineWidth=4*o,s.strokeStyle=u,s.globalCompositeOperation="multiply",s.fillRect(l,c,h,d),s.globalCompositeOperation="source-over",s.strokeRect(l,c,h,d),s.font=`bold ${R+1}px ${L}`}}}sd.getters=["getClientsToDisplay"],sd.layers=[5],sd.modes=["normal"];class od extends yh{allowDispatch(e){if("SORT_CELLS"===e.type){if(!to(e.col,e.row,e.zone))throw new Error(a("The anchor must be part of the provided zone"));return this.checkValidations(e,this.checkMerge,this.checkMergeSizes)}return 0}handle(e){if("SORT_CELLS"===e.type)this.sortZone(e.sheetId,e,e.zone,e.sortDirection)}checkMerge({sheetId:e,zone:t}){if(!this.getters.doesIntersectMerge(e,t))return 0;for(let s=t.top;s<=t.bottom;s++)for(let o=t.left;o<=t.right;o++)if(!this.getters.isInMerge(e,o,s))return 48;return 0}checkMergeSizes({sheetId:e,zone:t}){if(!this.getters.doesIntersectMerge(e,t))return 0;const s=this.getters.getMerges(e).filter((e=>eo(e,t))),o=io(s[0]);let[i,n]=[o.width,o.height];return s.every((e=>{let[t,s]=[e.right-e.left+1,e.bottom-e.top+1];return t===i&&s===n}))?0:48}expand(e,t){const{left:s,right:o,top:i,bottom:n}=this.getters.expandZone(e.id,t);return{left:Math.max(0,s),right:Math.min(e.cols.length-1,o),top:Math.max(0,i),bottom:Math.min(e.rows.length-1,n)}}checkExpandedValues(e,t){const s=this.expand(e,t),o=e.id;let i,n=[];if(this.getters.doesIntersectMerge(o,s)){const{left:e,right:t,top:r,bottom:a}=s;for(let s=e;s<=t;s++)for(let e=r;e<=a;e++){const[t,r]=this.getters.getMainCell(o,s,e);i=this.getters.getCell(o,t,r),n.push((null==i?void 0:i.formattedValue)||"")}}else n=this.getters.getCellsInZone(o,s).map((e=>(null==e?void 0:e.formattedValue)||""));return n.some((e=>""!==e))}getContiguousZone(e,t){let s,{top:o,bottom:i,left:n,right:r}=t;const a=this.getters.getSheet(e);let l=!1;for(;!l;)l=!0,o>0&&(s=this.checkExpandedValues(a,{left:n-1,right:r+1,top:o-1,bottom:o-1}),s&&(l=!1,o--)),n>0&&(s=this.checkExpandedValues(a,{left:n-1,right:n-1,top:o-1,bottom:i+1}),s&&(l=!1,n--)),r<a.cols.length-1&&(s=this.checkExpandedValues(a,{left:r+1,right:r+1,top:o-1,bottom:i+1}),s&&(l=!1,r++)),i<a.rows.length-1&&(s=this.checkExpandedValues(a,{left:n-1,right:r+1,top:i+1,bottom:i+1}),s&&(l=!1,i++));return{left:n,right:r,top:o,bottom:i}}hasHeader(e){if(1===e[0].length)return!1;let t=e.map((e=>e.map((e=>(null==e?void 0:e.evaluated.type)||$e.empty))));return t[0][0]===$e.empty&&(t=t.slice(1)),!t.some((e=>e[0]===$e.empty))&&!!t.some((e=>e[1]!==$e.empty&&e[0]!==e[1]))}sortZone(e,t,s,o){const[i,n]=this.mainCellsSteps(e,s);let r=this.getters.getMainCell(e,t.col,t.row)[0],a=Object.assign({},s),l=this.mainCells(e,s);this.hasHeader(l)&&(a.top+=n),l=this.mainCells(e,a);const c=function(e,t){const s=e.map(Pa),o=s.filter((e=>e.type===$e.empty)),i=s.filter((e=>e.type!==$e.empty)),n="descending"===t?-1:1;return i.sort(((e,t)=>{let s=Da.indexOf(e.type)-Da.indexOf(t.type);return 0===s&&(s=e.type===$e.text||e.type===$e.error?e.value.localeCompare(t.value):e.value-t.value),n*s})).concat(o)}(l[r-a.left],o),h=c.map((e=>e.index)),[d,u]=[l.length,l[0].length];for(let t=0;t<d;t++)for(let s=0;s<u;s++){let o=l[t][h[s]],r=a.left+t*i,c=a.top+s*n,d={sheetId:e,col:r,row:c,content:"",value:""};if(o){let t=o.content;if(o.isFormula()){const s=c-this.getters.getCellPosition(o.id).row,i=this.getters.createAdaptedRanges(o.dependencies,0,s,e);t=this.getters.buildFormulaContent(e,o,i)}d.style=o.style,d.content=t,d.format=o.format,d.value=o.evaluated.value}this.dispatch("UPDATE_CELL",d)}}mainCellsSteps(e,t){const s=this.getters.getMerge(e,t.left,t.top);return[s?s.right-s.left+1:1,s?s.bottom-s.top+1:1]}mainCells(e,t){const[s,o]=this.mainCellsSteps(e,t),i=[],n=Es(t.left,t.right+1,s),r=Es(t.top,t.bottom+1,o);for(const t of n){const s=[];i.push(s);for(const o of r)s.push(this.getters.getCell(e,t,o))}return i}}od.getters=["getContiguousZone"];class id extends yh{constructor(){super(...arguments),this.showFormulas=!1}handle(e){if("SET_FORMULA_VISIBILITY"===e.type)this.showFormulas=e.show}shouldShowFormulas(){return this.showFormulas}}id.modes=["normal"],id.getters=["shouldShowFormulas"];class nd extends yh{constructor(){super(...arguments),this.ctx=document.createElement("canvas").getContext("2d")}allowDispatch(e){switch(e.type){case"AUTORESIZE_ROWS":case"AUTORESIZE_COLUMNS":try{this.getters.getSheet(e.sheetId);break}catch(e){return 23}}return 0}handle(e){switch(e.type){case"AUTORESIZE_COLUMNS":for(let t of e.cols){const s=this.getColMaxWidth(e.sheetId,t);0!==s&&this.dispatch("RESIZE_COLUMNS_ROWS",{elements:[t],dimension:"COL",size:s+6,sheetId:e.sheetId})}break;case"AUTORESIZE_ROWS":for(let t of e.rows){const s=this.getRowMaxHeight(e.sheetId,t);0!==s&&this.dispatch("RESIZE_COLUMNS_ROWS",{elements:[t],dimension:"ROW",size:s+6,sheetId:e.sheetId})}}}getCellWidth(e){let t=this.getTextWidth(e);const s=this.getters.getCellPosition(e.id);return this.getters.getConditionalIcon(s.col,s.row)&&(t+=function(e,t){const s=t.fontSize||R;return ds[s]+2*w}(this.ctx,this.getters.getCellStyle(e))),t}getTextWidth(e){const t=this.getters.getCellText(e,this.getters.shouldShowFormulas());return vs(this.ctx,t,this.getters.getCellStyle(e))}getCellHeight(e){const t=this.getters.getCellStyle(e).fontSize||R;return ds[t]}getCellText(e,t=!1){return t&&(e.isFormula()||e.evaluated.type===$e.error)?e.content:e.formattedValue}getColMaxWidth(e,t){const s=this.getters.getColCells(e,t).map((e=>this.getCellWidth(e)));return Math.max(0,...s)}getRowMaxHeight(e,t){const s=this.getters.getSheet(e),o=Object.values(s.rows[t].cells).filter(_s).map((e=>this.getters.getCellById(e))).map((e=>this.getCellHeight(e)));return Math.max(0,...o)}}nd.getters=["getCellWidth","getCellHeight","getTextWidth","getCellText"];class rd extends yh{constructor(){super(...arguments),this.viewports={},this.snappedViewports={},this.updateSnap=!1,this.viewportWidth=1e3,this.viewportHeight=1e3}allowDispatch(e){switch(e.type){case"SET_VIEWPORT_OFFSET":return this.checkOffsetValidity(e.offsetX,e.offsetY);case"RESIZE_VIEWPORT":return e.width<0||e.height<0?54:0;default:return 0}}handle(e){switch(e.type){case"UNDO":case"REDO":this.cleanViewports(),this.resetViewports();break;case"RESIZE_VIEWPORT":this.cleanViewports(),this.resizeViewport(e.height,e.width);break;case"SET_VIEWPORT_OFFSET":this.setViewportOffset(e.offsetX,e.offsetY);break;case"SHIFT_VIEWPORT_DOWN":const t=this.getActiveTopRow(),s=this.clipOffsetY(t.start+this.viewportHeight);this.shiftVertically(s);break;case"SHIFT_VIEWPORT_UP":{const e=this.getActiveTopRow(),t=this.clipOffsetY(e.end-this.viewportHeight);this.shiftVertically(t);break}case"REMOVE_COLUMNS_ROWS":case"RESIZE_COLUMNS_ROWS":case"HIDE_COLUMNS_ROWS":"COL"===e.dimension?this.adjustViewportOffsetX(e.sheetId,this.getViewport(e.sheetId)):this.adjustViewportOffsetY(e.sheetId,this.getViewport(e.sheetId));break;case"ADD_COLUMNS_ROWS":case"UNHIDE_COLUMNS_ROWS":"COL"===e.dimension?this.adjustViewportZoneX(e.sheetId,this.getViewport(e.sheetId)):this.adjustViewportZoneY(e.sheetId,this.getViewport(e.sheetId));break;case"ACTIVATE_SHEET":this.refreshViewport(e.sheetIdTo);break;case"SELECT_CELL":case"MOVE_POSITION":this.refreshViewport(this.getters.getActiveSheetId())}}finalize(){this.updateSnap&&(this.snapViewportToCell(this.getters.getActiveSheetId()),this.updateSnap=!1)}getViewportDimensionWithHeaders(){return{width:this.viewportWidth+v,height:this.viewportHeight+m}}getActiveViewport(){const e=this.getters.getActiveSheetId();return this.getViewport(e)}getActiveSnappedViewport(){const e=this.getters.getActiveSheetId();return this.getSnappedViewport(e)}getMaxViewportSize(e){const t=Gs(e,"cols"),s=Gs(e,"rows"),o=e.cols.find((e=>e.end>t.end-this.viewportWidth))||e.cols[e.cols.length-1],i=e.rows.find((e=>e.end>s.end-this.viewportHeight))||e.rows[e.rows.length-1];return{width:t.end+Math.max(b,Math.min(o.size,this.viewportWidth-t.size)),height:s.end+Math.max(S+5,Math.min(i.size,this.viewportHeight-s.size))}}getMaximumViewportOffset(e){const{width:t,height:s}=this.getters.getMaxViewportSize(e);return{maxOffsetX:Math.max(0,t-this.viewportWidth+1),maxOffsetY:Math.max(0,s-this.viewportHeight+1)}}checkOffsetValidity(e,t){const s=this.getters.getActiveSheet(),{maxOffsetX:o,maxOffsetY:i}=this.getMaximumViewportOffset(s);return e<0||t<0||t>i||e>o?53:0}getSnappedViewport(e){return this.snapViewportToCell(e),this.snappedViewports[e]}getViewport(e){return this.viewports[e]?this.viewports[e]:this.generateViewportState(e)}cleanViewports(){const e=this.getters.getVisibleSheets();for(let t of Object.keys(this.viewports))e.includes(t)||delete this.viewports[t]}resetViewports(){for(let[e,t]of Object.entries(this.viewports))this.adjustViewportOffsetX(e,t),this.adjustViewportOffsetY(e,t),this.adjustViewportsPosition(e)}adjustViewportOffsetX(e,t){const{offsetX:s}=t,{width:o}=this.getMaxViewportSize(this.getters.getSheet(e));if(this.viewportWidth+s>o){const e=this.viewportWidth+s-o;t.offsetX=Math.max(0,s-e)}this.adjustViewportZoneX(e,t)}adjustViewportOffsetY(e,t){const{offsetY:s}=t,{height:o}=this.getMaxViewportSize(this.getters.getSheet(e));if(this.viewportHeight+s>o){const e=this.viewportHeight+s-o;t.offsetY=Math.max(0,s-e)}this.adjustViewportZoneY(e,t)}resizeViewport(e,t){this.viewportHeight=e,this.viewportWidth=t,this.recomputeViewports()}recomputeViewports(){for(let e of Object.keys(this.viewports))this.adjustViewportOffsetX(e,this.viewports[e]),this.adjustViewportOffsetY(e,this.viewports[e])}setViewportOffset(e,t){const s=this.getters.getActiveSheetId();this.getActiveViewport(),this.viewports[s].offsetX=e,this.viewports[s].offsetY=t,this.adjustViewportZone(s,this.viewports[s])}clipOffsetY(e){const{height:t}=this.getters.getMaxViewportSize(this.getters.getActiveSheet()),s=t-this.viewportHeight;return e=Math.min(e,s),e=Math.max(e,0)}generateViewportState(e){return this.viewports[e]={left:0,right:0,top:0,bottom:0,offsetX:0,offsetY:0},this.viewports[e]}refreshViewport(e){const t=this.getViewport(e);this.adjustViewportZone(e,t),this.adjustViewportsPosition(e)}adjustViewportZone(e,t){this.adjustViewportZoneX(e,t),this.adjustViewportZoneY(e,t)}adjustViewportZoneX(e,t){const s=this.getters.getSheet(e),o=s.cols;t.left=this.getters.getColIndex(t.offsetX+v,0,s);const i=this.viewportWidth+t.offsetX;t.right=o.length-1;for(let e=t.left;e<o.length;e++)if(i<o[e].end){t.right=e;break}this.updateSnap=!0}adjustViewportZoneY(e,t){const s=this.getters.getSheet(e),o=s.rows;t.top=this.getters.getRowIndex(t.offsetY+m,0,s);const i=this.viewportHeight+t.offsetY;t.bottom=o.length-1;for(let e=t.top;e<o.length;e++)if(i<o[e].end){t.bottom=e;break}this.updateSnap=!0}adjustViewportsPosition(e,t){const s=this.getters.getSheet(e),{cols:o,rows:i}=s,n=this.getSnappedViewport(e);t=t||this.getters.getSheetPosition(e);const[r,a]=zs(s,...this.getters.getMainCell(e,t[0],t[1]));for(;o[r].end>n.offsetX+this.viewportWidth&&n.offsetX<o[r].start;)n.offsetX=o[n.left].end,this.adjustViewportZoneX(e,n);for(;r<n.left;){const t=o.slice(0,n.left).reverse().findIndex((e=>!e.isHidden));n.offsetX=o[n.left-1-t].start,this.adjustViewportZoneX(e,n)}for(;i[a].end>n.offsetY+this.viewportHeight&&n.offsetY<i[a].start;)n.offsetY=i[n.top].end,this.adjustViewportZoneY(e,n);for(;a<n.top;){const t=i.slice(0,n.top).reverse().findIndex((e=>!e.isHidden));n.offsetY=i[n.top-1-t].start,this.adjustViewportZoneY(e,n)}const{top:l,left:c}=this.viewports[e];l===n.top&&c===n.left||(this.viewports[e]=n),this.updateSnap=!1}snapViewportToCell(e){const{cols:t,rows:s}=this.getters.getSheet(e),o=this.getViewport(e),i=Object.assign({},o);this.adjustViewportOffsetX(e,i),this.adjustViewportOffsetY(e,i),i.offsetX=t[i.left].start,i.offsetY=s[i.top].start,this.adjustViewportZone(e,i),this.snappedViewports[e]=i}shiftVertically(e){const{top:t,offsetX:s}=this.getActiveSnappedViewport();this.setViewportOffset(s,e);const{anchor:o}=this.getters.getSelection(),i=this.getActiveSnappedViewport().top-t;this.dispatch("SELECT_CELL",{col:o[0],row:o[1]+i})}getActiveTopRow(){const{top:e}=this.getActiveSnappedViewport(),t=this.getters.getActiveSheet();return this.getters.getRow(t.id,e)}}rd.getters=["getActiveViewport","getActiveSnappedViewport","getViewportDimensionWithHeaders","getMaxViewportSize","getMaximumViewportOffset"],rd.modes=["normal"];const ad=(new Ae).add("sheet",La).add("cell",Sa).add("merge",xa).add("borders",Ea).add("conditional formatting",wa).add("figures",Ia).add("chart",Ca),ld=(new Ae).add("selection",Mh).add("ui_sheet",nd).add("ui_options",id).add("evaluation",Nh).add("evaluation_cf",Dh).add("evaluation_chart",$h).add("clipboard",Th).add("edition",_h).add("highlight",Bh).add("selectionInput",Gh).add("viewport",rd).add("grid renderer",zh).add("autofill",Ih).add("find_and_replace",Uh).add("sort",od).add("automatic_sum",xh).add("format",Vh).add("selection_multiuser",sd);class cd{constructor(){this.listeners=[]}sendMessage(e){for(const{callback:t}of this.listeners)t(e)}onNewMessage(e,t){this.listeners.push({id:e,callback:t})}leave(e){this.listeners=this.listeners.filter((t=>t.id!==e))}}class hd extends o.core.EventBus{constructor(){super(...arguments),this.registry=new Ae}add(e,t){this.registry.add(e,t);const s=o.utils.debounce((()=>this.trigger("data-loaded",{id:e})),0);return t.on("data-loaded",this,(()=>s())),t.loadMetadata(),this}get(e){return this.registry.get(e)}getAll(){return this.registry.getAll()}remove(e){this.get(e).off("data-loaded",this),this.registry.remove(e)}async waitForReady(){const e=[];for(const t of this.getAll())e.push(t.get());return Promise.all(e)}}class dd extends o.core.EventBus{async loadMetadata(){this.metadataPromise||(this.metadataPromise=this._fetchMetadata().then((e=>(this.metadata=e,e)))),await this.metadataPromise}async get(e){return e&&e.forceFetch&&(this.data=void 0,this.dataPromise=void 0),await this.loadMetadata(),this.dataPromise||(this.dataPromise=this._fetch(e).then((e=>(this.data=e,this.lastUpdate=Date.now(),this.trigger("data-loaded"),e)))),this.dataPromise}getSync(){return this.data}getMetadataSync(){return this.metadata}getLastUpdate(){return this.lastUpdate}}function ud(e){return Oa.get(e.type)(e)}function pd(e){if("string"==typeof e)return{};if("number"==typeof e)return[];throw new Error("Cannot create new node")}class gd{constructor(e,t=[]){this.buildTransformation=e,this.operations=t}getOperations(){return this.operations}getOperation(e){const t=this.operations.find((t=>t.id===e));if(!t)throw new Error(`Operation ${e} not found`);return t}getLastOperationId(){var e;return null===(e=this.operations[this.operations.length-1])||void 0===e?void 0:e.id}getFirstOperationAmong(e,t){for(const s of this.operations){if(s.id===e)return e;if(s.id===t)return t}throw new Error(`Operation ${e} and ${t} not found`)}contains(e){return!!this.operations.find((t=>t.id===e))}prepend(e){const t=this.buildTransformation.with(e.data);this.operations=[e,...this.operations.map((e=>e.transformed(t)))]}insert(e,t){const s=this.buildTransformation.with(e.data),{before:o,operation:i,after:n}=this.locateOperation(t);this.operations=[...o,i,e,...n.map((e=>e.transformed(s)))]}append(e){this.operations.push(e)}appendBranch(e){this.operations=this.operations.concat(e.operations)}fork(e){const{after:t}=this.locateOperation(e);return new gd(this.buildTransformation,t)}transform(e){this.operations=this.operations.map((t=>t.transformed(e)))}cutBefore(e){this.operations=this.locateOperation(e).before}cutAfter(e){const{before:t,operation:s}=this.locateOperation(e);this.operations=t.concat([s])}locateOperation(e){const t=this.operations.findIndex((t=>t.id===e));if(-1===t)throw new Error(`Operation ${e} not found`);return{before:this.operations.slice(0,t),operation:this.operations[t],after:this.operations.slice(t+1)}}}class fd{constructor(e,t){this.id=e,this.data=t}transformed(e){return new md(this.id,ks((()=>e(this.data))))}}class md{constructor(e,t){this.id=e,this.lazyData=t}get data(){return this.lazyData()}transformed(e){return new md(this.id,this.lazyData.map(e))}}class vd{constructor(e){this.operations=e}[Symbol.iterator](){return this.operations[Symbol.iterator]()}stopWith(e){return new vd(function*(e,t){for(const s of e)if(yield s,s.operation.id===t)return}(this.operations,e))}stopBefore(e){return new vd(function*(e,t){for(const s of e){if(s.operation.id===t)return;yield s}}(this.operations,e))}startAfter(e){return new vd(function*(e,t){let s=!0;for(const o of e)s||(yield o),o.operation.id===t&&(s=!1)}(this.operations,e))}}class Ed{constructor(e,t){this.buildTransformation=e,this.branchingOperationIds=new Map,this.branches=[t]}getLastBranch(){return this.branches[this.branches.length-1]}execution(e){return new vd(Ss(this._execution(e),this._execution(e)))}revertedExecution(e){return new vd(Ss(this._revertedExecution(e),this._revertedExecution(e)))}insertOperationLast(e,t){var s;const o=e.getLastOperationId()||(null===(s=this.previousBranch(e))||void 0===s?void 0:s.getLastOperationId());e.append(t),o&&this.insertPrevious(e,t,o)}insertOperationAfter(e,t,s){e.insert(t,s),this.updateNextWith(e,t,s),this.insertPrevious(e,t,s)}undo(e,t){const s=this.buildTransformation.without(t.data),o=this.branchingOperationIds.get(e);this.branchingOperationIds.set(e,t.id);const i=e.fork(t.id);o&&this.branchingOperationIds.set(i,o),this.insertBranchAfter(e,i),this.transform(i,s)}redo(e){const t=this.nextBranch(e);if(!t)return;const s=this.nextBranch(t);this.removeBranchFromTree(t);const o=this.branchingOperationIds.get(t);o?this.branchingOperationIds.set(e,o):this.branchingOperationIds.delete(e),s&&this.rebaseUp(s)}drop(e){for(const t of this.branches)t.contains(e)&&t.cutBefore(e)}findOperation(e,t){for(const s of this.revertedExecution(e))if(s.operation.id===t)return s;throw new Error(`Operation ${t} not found`)}rebaseUp(e){const{previousBranch:t,branchingOperation:s}=this.findPreviousBranchingOperation(e);if(!t||!s)return;const o=this.buildTransformation.without(s.data),i=t.fork(s.id);this.branchingOperationIds.set(i,this.branchingOperationIds.get(e)),this.removeBranchFromTree(e),this.insertBranchAfter(t,i),i.transform(o);const n=this.nextBranch(i);n&&this.rebaseUp(n)}removeBranchFromTree(e){const t=this.branches.findIndex((t=>t===e));this.branches.splice(t,1)}insertBranchAfter(e,t){const s=this.branches.findIndex((t=>t===e));this.branches.splice(s+1,0,t)}updateNextWith(e,t,s){const o=this.branchingOperationIds.get(e),i=this.nextBranch(e);if(o&&i)if(e.getFirstOperationAmong(s,o)===o){const n=this.addToNextBranch(e,i,o,t,s);this.updateNextWith(i,n,s)}else{const e=this.buildTransformation.with(t.data);this.transform(i,e)}}addToNextBranch(e,t,s,o,i){let n=o;return i===s?(n=this.getTransformedOperation(e,s,o),t.prepend(n)):t.contains(i)?(n=this.getTransformedOperation(e,s,o),t.insert(n,i)):t.append(o),n}getTransformedOperation(e,t,s){const o=e.getOperation(t),i=this.buildTransformation.without(o.data);return s.transformed(i)}shouldExecute(e,t){return t.id!==this.branchingOperationIds.get(e)}transform(e,t){e.transform(t);const s=this.nextBranch(e);s&&this.transform(s,t)}insertPrevious(e,t,s){const{previousBranch:o,branchingOperation:i}=this.findPreviousBranchingOperation(e);if(!o||!i)return;const n=this.buildTransformation.with(i.data),r=e.fork(s);r.transform(n),o.cutAfter(s),o.appendBranch(r);const a=t.transformed(n);this.insertPrevious(o,a,s)}findPreviousBranchingOperation(e){const t=this.previousBranch(e);if(!t)return{previousBranch:void 0,branchingOperation:void 0};const s=this.branchingOperationIds.get(t);return s?{previousBranch:t,branchingOperation:t.getOperation(s)}:{previousBranch:void 0,branchingOperation:void 0}}nextBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t+1]}previousBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t-1]}*_revertedExecution(e){const t=this.branchingOperationIds.get(e);let s=!!t;const o=e.getOperations();for(let i=o.length-1;i>=0;i--){const n=o[i];n.id===t&&(s=!1),s||(yield{operation:n,branch:e,isCancelled:!this.shouldExecute(e,n)})}const i=this.previousBranch(e);yield*i?this._revertedExecution(i):[]}*_execution(e){for(const t of e.getOperations())if(yield{operation:t,branch:e,isCancelled:!this.shouldExecute(e,t)},t.id===this.branchingOperationIds.get(e)){const t=this.nextBranch(e);return void(yield*t?this._execution(t):[])}if(!this.branchingOperationIds.get(e)){const t=this.nextBranch(e);yield*t?this._execution(t):[]}}}class bd{constructor(e,t,s,o,i){this.applyOperation=t,this.revertOperation=s,this.buildEmpty=o,this.buildTransformation=i,this.HEAD_BRANCH=new gd(this.buildTransformation),this.tree=new Ed(i,this.HEAD_BRANCH);const n=new fd(e,o(e));this.tree.insertOperationLast(this.HEAD_BRANCH,n),this.HEAD_OPERATION=n}get(e){return this.tree.findOperation(this.HEAD_BRANCH,e).operation.data}append(e,t){const s=new fd(e,t),o=this.tree.getLastBranch();this.tree.insertOperationLast(o,s),this.HEAD_BRANCH=o,this.HEAD_OPERATION=s}insert(e,t,s){const o=new fd(e,t);this.revertTo(s),this.tree.insertOperationAfter(this.HEAD_BRANCH,o,s),this.fastForward()}undo(e,t,s){const{branch:o,operation:i}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.undo(o,i),this.fastForward(),this.insert(t,this.buildEmpty(t),s)}redo(e,t,s){const{branch:o}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.redo(o),this.fastForward(),this.insert(t,this.buildEmpty(t),s)}drop(e){this.revertBefore(e),this.tree.drop(e)}revertBefore(e){const t=this.tree.revertedExecution(this.HEAD_BRANCH).stopWith(e);this.revert(t)}revertTo(e){const t=e?this.tree.revertedExecution(this.HEAD_BRANCH).stopBefore(e):this.tree.revertedExecution(this.HEAD_BRANCH);this.revert(t)}revert(e){for(const{next:t,operation:s,isCancelled:o}of e)o||this.revertOperation(s.data),t&&(this.HEAD_BRANCH=t.branch,this.HEAD_OPERATION=t.operation)}fastForward(){const e=this.HEAD_OPERATION?this.tree.execution(this.HEAD_BRANCH).startAfter(this.HEAD_OPERATION.id):this.tree.execution(this.HEAD_BRANCH);for(const{operation:t,branch:s,isCancelled:o}of e)o||this.applyOperation(t.data),this.HEAD_OPERATION=t,this.HEAD_BRANCH=s}}function Sd(e,t,s){return new bd(e,(e=>{const o=e.commands.slice(),{changes:i}=t((()=>{for(const e of o)s(e)}));e.setChanges(i)}),(e=>function(e){for(const t of e.slice().reverse())for(let e=t.changes.length-1;e>=0;e--){Cd(t.changes[e],"before")}}([e])),(e=>new Qh(e,"empty",[],[])),{with:e=>t=>new Qh(t.id,t.clientId,Kh(t.commands,e.commands)),without:e=>t=>new Qh(t.id,t.clientId,Kh(t.commands,e.commands.map(ud).flat()))})}function Cd(e,t){let s=e.path[0];const o=e.path[e.path.length-1];for(let t=1;t<e.path.slice(0,-1).length;t++){const o=e.path[t];if(void 0===s[o]){const i=e.path[t+1];s[o]=pd(i)}s=s[o]}void 0===e[t]?delete s[o]:s[o]=e[t]}class yd extends o.core.EventBus{constructor(e,t){super(),this.dispatch=e,this.session=t,this.undoStack=[],this.redoStack=[],this.session.on("new-local-state-update",this,this.onNewLocalStateUpdate),this.session.on("revision-undone",this,(({commands:e})=>this.selectiveUndo(e))),this.session.on("revision-redone",this,(({commands:e})=>this.selectiveRedo(e))),this.session.on("pending-revisions-dropped",this,(({revisionIds:e})=>this.drop(e))),this.session.on("snapshot",this,(()=>{this.undoStack=[],this.redoStack=[]}))}allowDispatch(e){switch(e.type){case"REQUEST_UNDO":if(!this.canUndo())return 6;break;case"REQUEST_REDO":if(!this.canRedo())return 7}return 0}beforeHandle(e){}handle(e){switch(e.type){case"REQUEST_UNDO":case"REQUEST_REDO":this.requestHistoryChange("REQUEST_UNDO"===e.type?"UNDO":"REDO")}}finalize(){}requestHistoryChange(e){const t="UNDO"===e?this.undoStack.pop():this.redoStack.pop();t&&("UNDO"===e?(this.session.undo(t),this.redoStack.push(t)):(this.session.redo(t),this.undoStack.push(t)))}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}drop(e){this.undoStack=this.undoStack.filter((t=>!e.includes(t))),this.redoStack=[]}onNewLocalStateUpdate({id:e}){this.undoStack.push(e),this.redoStack=[],this.undoStack.length>99&&this.undoStack.shift()}selectiveUndo(e){this.dispatch("UNDO",{commands:e})}selectiveRedo(e){this.dispatch("REDO",{commands:e})}}class wd{constructor(e){this.providers=[],this.getters=e}allowDispatch(e){return 0}beforeHandle(e){}handle(e){switch(e.type){case"REMOVE_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",s="COL"===e.dimension?"right":"bottom",o="COL"===e.dimension?"columns":"rows";e.elements.sort(((e,t)=>t-e));const i=bs(e.elements);this.executeOnAllRanges((n=>{if(n.sheetId!==e.sheetId)return{changeType:"NONE"};let r=n,a="NONE";for(let e of i){const i=Math.min(...e),l=Math.max(...e);if(n.zone[t]<=i&&i<=n.zone[s]){const e=Math.min(n.zone[s],l)-i+1;a="RESIZE",r=this.createAdaptedRange(r,o,a,-e)}else if(n.zone[t]>=i&&n.zone[s]<=l)a="REMOVE",r=this.buildInvalidRange(O);else if(n.zone[t]<=l&&n.zone[s]>=l){const e=l-n.zone[t]+1;a="RESIZE",r=this.createAdaptedRange(r,o,a,-e),r=this.createAdaptedRange(r,o,"MOVE",-(n.zone[t]-i))}else i<n.zone[t]&&(a="MOVE",r=this.createAdaptedRange(r,o,a,-(l-i+1)))}return"NONE"!==a?{changeType:a,range:r}:{changeType:"NONE"}}),e.sheetId);break}case"ADD_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",s="COL"===e.dimension?"right":"bottom",o="COL"===e.dimension?"columns":"rows";this.executeOnAllRanges((i=>{if(i.sheetId!==e.sheetId)return{changeType:"NONE"};if("after"===e.position){if(i.zone[t]<=e.base&&e.base<i.zone[s])return{changeType:"RESIZE",range:this.createAdaptedRange(i,o,"RESIZE",e.quantity)};if(e.base<i.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(i,o,"MOVE",e.quantity)}}else{if(i.zone[t]<e.base&&e.base<=i.zone[s])return{changeType:"RESIZE",range:this.createAdaptedRange(i,o,"RESIZE",e.quantity)};if(e.base<=i.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(i,o,"MOVE",e.quantity)}}return{changeType:"NONE"}}),e.sheetId);break}case"DELETE_SHEET":this.executeOnAllRanges((t=>t.sheetId!==e.sheetId?{changeType:"NONE"}:{changeType:"REMOVE",range:t={...this.buildInvalidRange(O),invalidSheetName:this.getters.getSheetName(e.sheetId)}}),e.sheetId);break;case"RENAME_SHEET":this.executeOnAllRanges((t=>{if(t.sheetId===e.sheetId)return{changeType:"CHANGE",range:t};if(e.name&&t.invalidSheetName===e.name){const s={...t,zone:{...t.zone}};return s.invalidSheetName=void 0,s.sheetId=e.sheetId,{changeType:"CHANGE",range:s}}return{changeType:"NONE"}}))}}finalize(){}verifyRangeRemoved(e){return t=>{const s=e(t);return"NONE"===s.changeType||js(s.range.zone)?s:{range:s.range,changeType:"REMOVE"}}}createAdaptedRange(e,t,s,o){return{...e,zone:ao(e.zone,t,s,o)}}executeOnAllRanges(e,t){const s=this.verifyRangeRemoved(e);for(const e of this.providers)e(s,t)}addRangeProvider(e){this.providers.push(e)}orderZone(e,t){if(e.right<e.left){let s=e.right;e.right=e.left,e.left=s;let o=t[1].colFixed;t[1].colFixed=t[0].colFixed,t[0].colFixed=o}if(e.bottom<e.top){let s=e.bottom;e.bottom=e.top,e.top=s;let o=t[1].rowFixed;t[1].rowFixed=t[0].rowFixed,t[0].rowFixed=o}}createAdaptedRanges(e,t,s,o){return e.map((e=>js(e.zone)?(e={...e,sheetId:e.prefixSheet?e.sheetId:o,zone:{left:e.zone.left+(e.parts[0].colFixed?0:t),right:e.zone.right+((e.parts[1]||e.parts[0]).colFixed?0:t),top:e.zone.top+(e.parts[0].rowFixed?0:s),bottom:e.zone.bottom+((e.parts[1]||e.parts[0]).rowFixed?0:s)}},this.orderZone(e.zone,e.parts),e):e))}getRangeFromSheetXC(e,t){let s,o,i,n=t,r=!1;if(!ts.test(t))return this.buildInvalidRange(t);t.includes("!")&&(({xc:n,sheetName:s}=ss(t)),s?(o=this.getters.getSheetIdByName(s),r=!0,o||(i=s)):i=s);const a=Ws(n);let l=n.split(":").map((e=>({colFixed:e.startsWith("$"),rowFixed:e.includes("$",1)})));return this.orderZone(a,l),{sheetId:o||e,zone:a,parts:l,invalidSheetName:i,prefixSheet:r}}getRangeString(e,t){if(!e)return O;if(e.invalidXc)return e.invalidXc;if(e.zone.bottom-e.zone.top<0||e.zone.right-e.zone.left<0)return O;if(e.zone.left<0||e.zone.top<0)return O;let s=e.sheetId!==t||e.invalidSheetName||e.prefixSheet,o="";if(s&&(o=e.invalidSheetName?e.invalidSheetName:fs(this.getters.getSheetName(e.sheetId))),s&&!o)return O;let i=Array(9);return i[0]=e.parts&&e.parts[0].colFixed?"$":"",i[1]=os(e.zone.left),i[2]=e.parts&&e.parts[0].rowFixed?"$":"",i[3]=String(e.zone.top+1),e.parts&&2===e.parts.length&&(e.zone.top!==e.zone.bottom||e.zone.left!==e.zone.right||e.parts[0].rowFixed||e.parts[0].colFixed||e.parts[1].rowFixed||e.parts[1].colFixed)&&(i[4]=":",i[5]=e.parts[1].colFixed?"$":"",i[6]=os(e.zone.right),i[7]=e.parts[1].rowFixed?"$":"",i[8]=String(e.zone.bottom+1)),`${s?o+"!":""}${i.join("")}`}buildInvalidRange(e){return{parts:[],prefixSheet:!1,zone:{left:-1,top:-1,right:-1,bottom:-1},sheetId:"",invalidXc:e}}}wd.getters=["getRangeString","getRangeFromSheetXC","createAdaptedRanges"];class Id{constructor(){this.changes=[],this.commands=[]}recordChanges(e){return this.changes=[],this.commands=[],e(),{changes:this.changes,commands:this.commands}}addCommand(e){this.commands.push(e)}addChange(...e){const t=e.pop();let s=e[0],o=e[e.length-1];const i=e.length-2;for(let t=1;t<=i;t++){const o=e[t];if(void 0===s[o]){const i=e[t+1];s[o]=pd(i)}s=s[o]}s[o]!==t&&(this.changes.push({path:e,before:s[o],after:t}),void 0===t?delete s[o]:s[o]=t)}}const xd={General:0,0:1,"0.00":2,"#,#00":3,"#,##0.00":4,"0%":9,"0.00%":10,"0.00E+00":11,"# ?/?":12,"# ??/??":13,"mm-dd-yy":14,"d-mm-yy":15,"mm-yy":16,"mmm-yy":17,"h:mm AM/PM":18,"h:mm:ss AM/PM":19,"h:mm":20,"h:mm:ss":21,"m/d/yy h:mm":22,"#,##0 ;(#,##0)":37,"#,##0 ;[Red](#,##0)":38,"#,##0.00;(#,##0.00)":39,"#,##0.00;[Red](#,##0.00)":40,"mm:ss":45,"[h]:mm:ss":46,"mmss.0":47,"##0.0E+0":48,"@":49,"hh:mm:ss a":19},Td={arrow:"3Arrows",smiley:"3Symbols",dot:"3TrafficLights1"},Rd={styleSheet:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",sst:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",Relationships:"http://schemas.openxmlformats.org/package/2006/relationships",Types:"http://schemas.openxmlformats.org/package/2006/content-types",worksheet:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",workbook:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",drawing:"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"},Ld="http://schemas.openxmlformats.org/drawingml/2006/main",Md="http://schemas.openxmlformats.org/drawingml/2006/chart",Ad={workbook:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml",sheet:"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml",sharedStrings:"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml",styles:"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml",drawing:"application/vnd.openxmlformats-officedocument.drawing+xml",chart:"application/vnd.openxmlformats-officedocument.drawingml.chart+xml"},_d="http://schemas.openxmlformats.org/officeDocument/2006/relationships",Od=.75,Nd=.1425,kd=164,Fd={FLOOR:[{type:"NUMBER",value:1}],CEILING:[{type:"NUMBER",value:1}],ROUND:[{type:"NUMBER",value:0}],ROUNDUP:[{type:"NUMBER",value:0}],ROUNDDOWN:[{type:"NUMBER",value:0}]},$d=["ACOT","ACOTH","AGGREGATE","ARABIC","BASE","BETA.DIST","BETA.INV","BINOM.DIST","BINOM.DIST.RANGE","BINOM.INV","BITAND","BITLSHIFT","BITOR","BITRSHIFT","BITXOR","CEILING.MATH","CEILING.PRECISE","CHISQ.DIST","CHISQ.DIST.RT","CHISQ.INV","CHISQ.INV.RT","CHISQ.TEST","COMBINA","CONCAT","CONFIDENCE.NORM","CONFIDENCE.T","COT","COTH","COVARIANCE.P","COVARIANCE.S","CSC","CSCH","DAYS","DECIMAL","ERF.PRECISE","ERFC.PRECISE","EXPON.DIST","F.DIST","F.DIST.RT","F.INV","F.INV.RT","F.TEST","FILTERXML","FLOOR.MATH","FLOOR.PRECISE","FORECAST.ETS","FORECAST.ETS.CONFINT","FORECAST.ETS.SEASONALITY","FORECAST.ETS.STAT","FORECAST.LINEAR","FORMULATEXT","GAMMA","GAMMA.DIST","GAMMA.INV","GAMMALN.PRECISE","GAUSS","HYPGEOM.DIST","IFNA","IFS","IMCOSH","IMCOT","IMCSC","IMCSCH","IMSEC","IMSECH","IMSINH","IMTAN","ISFORMULA","ISOWEEKNUM","LOGNORM.DIST","LOGNORM.INV","MAXIFS","MINIFS","MODE.MULT","MODE.SNGL","MUNIT","NEGBINOM.DIST","NORM.DIST","NORM.INV","NORM.S.DIST","NORM.S.INV","NUMBERVALUE","PDURATION","PERCENTILE.EXC","PERCENTILE.INC","PERCENTRANK.EXC","PERCENTRANK.INC","PERMUTATIONA","PHI","POISSON.DIST","QUARTILE.EXC","QUARTILE.INC","QUERYSTRING","RANK.AVG","RANK.EQ","RRI","SEC","SECH","SHEET","SHEETS","SKEW.P","STDEV.P","STDEV.S","SWITCH","T.DIST","T.DIST.2T","T.DIST.RT","T.INV","T.INV.2T","T.TEST","TEXTJOIN","UNICHAR","UNICODE","VAR.P","VAR.S","WEBSERVICE","WEIBULL.DIST","XOR","Z.TEST"];function Dd(e){switch(e){case"IsNotEmpty":case"NotContains":return"notContainsBlanks";case"IsEmpty":return"containsBlanks";default:return e.charAt(0).toLowerCase()+e.slice(1)}}function Pd(e){return Math.round(Od*e*window.devicePixelRatio*100)/100}function Ud(e){return Math.round(Nd*e*100)/100}function Vd(e,t){let s={};e.style&&(s=t.styles[e.style]);const o=e.format?t.formats[e.format]:void 0;let i={};e.border&&(i=t.borders[e.border]);const n={font:{size:(null==s?void 0:s.fontSize)||R,color:(null==s?void 0:s.textColor)?s.textColor:"000000",family:2,name:"Arial"},fill:(null==s?void 0:s.fillColor)?{fgColor:s.fillColor}:{reservedAttribute:"none"},numFmt:o,border:i||{},verticalAlignment:"center",horizontalAlignment:null==s?void 0:s.align};return n.font.strike=!!(null==s?void 0:s.strikethrough)||void 0,n.font.underline=!!(null==s?void 0:s.underline)||void 0,n.font.bold=!!(null==s?void 0:s.bold)||void 0,n.font.italic=!!(null==s?void 0:s.italic)||void 0,n}function Bd(e,t){const{id:s}=zd(t.font,e.fonts),{id:o}=zd(t.fill,e.fills),{id:i}=zd(t.border,e.borders),n=function(e,t){if(!e)return 0;let s=xd[e];if(!s){const{id:o}=zd(e,t);s=o+kd}return s}(t.numFmt,e.numFmts),r={fontId:s,fillId:o,borderId:i,numFmtId:n,verticalAlignment:t.verticalAlignment,horizontalAlignment:t.horizontalAlignment},{id:a}=zd(r,e.styles);return a}function Hd(e,t,s){let o,i=e.find((e=>e.path===t));return i?(o=`rId${(i.rels.length+1).toString()}`,i.rels.push({...s,id:o})):(o="rId1",e.push({path:t,rels:[{...s,id:o}]})),o}function zd(e,t){for(let[s,o]of Object.entries(t))if(JSON.stringify(o)===JSON.stringify(e))return{id:parseInt(s,10),list:t};let s=t.findIndex((t=>JSON.stringify(t)===JSON.stringify(e)));return-1===s&&(t.push(e),s=t.length-1),{id:s,list:t}}const Zd=[];function Gd(e){const t=Zd.findIndex((t=>t===e));return-1===t?(Zd.push(e),Zd.length):t+1}function Wd(e){return Math.round(914400*e/96)}class qd{constructor(e){this.xmlString=e}toString(){return this.xmlString}}function jd(e,t,s){return{content:(new XMLSerializer).serializeToString(e),path:t,contentType:s}}function Xd(e){return String(e).replace(/\&/g,"&amp;").replace(/\</g,"&lt;").replace(/\>/g,"&gt;").replace(/\"/g,"&quot;").replace(/\'/g,"&apos;").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"")}function Yd(e){return new qd(e.map((([e,t])=>`${e}="${Xd(t)}"`)).join(" "))}function Kd(e){const t=(new DOMParser).parseFromString(e.toString(),"text/xml"),s=t.querySelector("parsererror");if(s){const t=s.innerHTML,o=parseInt(t.split(":")[0],10),i=e.toString().trim().split("\n"),n=i.slice(Math.max(o-3,0),Math.min(o+2,i.length)).join("\n");throw new Error(`XML string could not be parsed: ${t}\n${n}`)}return t}function Qd(e,t){return eu`
1048
+ `;class bh extends t.Component{constructor(){super(...arguments),this.getters=this.env.getters,this.state=t.useState(this.initialState())}get hasSearchResult(){return null!==this.env.getters.getCurrentSelectedMatchIndex()}setup(){ph((()=>this.focusInput())),gh((()=>this.env.dispatch("CLEAR_SEARCH")))}onInput(e){this.state.toSearch=e.target.value,this.debouncedUpdateSearch()}onKeydownSearch(e){"Enter"===e.key&&(e.preventDefault(),this.onSelectNextCell())}onKeydownReplace(e){"Enter"===e.key&&(e.preventDefault(),this.replace())}onFocusSidePanel(){this.state.searchOptions.searchFormulas=this.getters.shouldShowFormulas(),this.state.replaceOptions.modifyFormulas=this.state.searchOptions.searchFormulas?this.state.searchOptions.searchFormulas:this.state.replaceOptions.modifyFormulas,this.env.dispatch("REFRESH_SEARCH")}searchFormulas(){this.env.dispatch("SET_FORMULA_VISIBILITY",{show:this.state.searchOptions.searchFormulas}),this.state.replaceOptions.modifyFormulas=this.state.searchOptions.searchFormulas,this.updateSearch()}onSelectPreviousCell(){this.env.dispatch("SELECT_SEARCH_PREVIOUS_MATCH")}onSelectNextCell(){this.env.dispatch("SELECT_SEARCH_NEXT_MATCH")}updateSearch(){this.env.dispatch("UPDATE_SEARCH",{toSearch:this.state.toSearch,searchOptions:this.state.searchOptions})}debouncedUpdateSearch(){clearTimeout(this.inDebounce),this.inDebounce=setTimeout((()=>this.updateSearch.call(this)),400)}replace(){this.env.dispatch("REPLACE_SEARCH",{replaceWith:this.state.replaceWith,replaceOptions:this.state.replaceOptions})}replaceAll(){this.env.dispatch("REPLACE_ALL_SEARCH",{replaceWith:this.state.replaceWith,replaceOptions:this.state.replaceOptions})}focusInput(){const e=this.el.querySelector("input");e&&e.focus()}initialState(){return{toSearch:"",replaceWith:"",searchOptions:{matchCase:!1,exactMatch:!1,searchFormulas:!1},replaceOptions:{modifyFormulas:!1}}}}bh.template=vh,bh.style=Eh;const Sh=new Ae;Sh.add("ConditionalFormatting",{title:a("Conditional formatting"),Body:uh}),Sh.add("ChartPanel",{title:a("Chart"),Body:zc}),Sh.add("FindAndReplace",{title:a("Find and Replace"),Body:bh});const Ch=new Ae;class yh extends ma{constructor(e,t,s,o){super(t,s,o),this.getters=e,this.ui=o}drawGrid(e,t){}}yh.layers=[];class wh{constructor(e,t,s){this.index=0,this.cells=e,this.getters=t,this.direction=s}next(){const e=this.cells[this.index++%this.cells.length],t=e.rule,{cellData:s,tooltip:o}=Ma.get(t.type).apply(t,e.data,this.getters,this.direction);return{cellData:s,tooltip:o,origin:{col:e.data.col,row:e.data.row}}}}class Ih extends yh{constructor(){super(...arguments),this.lastCellSelected={}}allowDispatch(e){switch(e.type){case"AUTOFILL_SELECT":const t=this.getters.getActiveSheetId();return this.lastCellSelected.col=-1===e.col?this.lastCellSelected.col:ms(e.col,0,this.getters.getSheet(t).cols.length),this.lastCellSelected.row=-1===e.row?this.lastCellSelected.row:ms(e.row,0,this.getters.getSheet(t).rows.length),void 0!==this.lastCellSelected.col&&void 0!==this.lastCellSelected.row?0:30;case"AUTOFILL_AUTO":const s=this.getters.getSelectedZone();return s.top===s.bottom?0:1}return 0}handle(e){switch(e.type){case"AUTOFILL":this.autofill(!0);break;case"AUTOFILL_SELECT":this.select(e.col,e.row);break;case"AUTOFILL_AUTO":this.autofillAuto();break;case"AUTOFILL_CELL":this.autoFillMerge(e.originCol,e.originRow,e.col,e.row);const t=this.getters.getActiveSheetId();this.dispatch("UPDATE_CELL",{sheetId:t,col:e.col,row:e.row,style:e.style||null,content:e.content||"",format:e.format||""}),this.dispatch("SET_BORDER",{sheetId:t,col:e.col,row:e.row,border:e.border})}}getAutofillTooltip(){return this.tooltip}autofill(e){if(!this.autofillZone||void 0===this.direction)return void(this.tooltip=void 0);const t=this.getters.getSelectedZone(),s=this.autofillZone;switch(this.direction){case 1:for(let o=t.left;o<=t.right;o++){const i=[];for(let e=t.top;e<=t.bottom;e++)i.push(ns(o,e));const n=this.createGenerator(i);for(let t=s.top;t<=s.bottom;t++)this.computeNewCell(n,o,t,e)}break;case 0:for(let o=t.left;o<=t.right;o++){const i=[];for(let e=t.bottom;e>=t.top;e--)i.push(ns(o,e));const n=this.createGenerator(i);for(let t=s.bottom;t>=s.top;t--)this.computeNewCell(n,o,t,e)}break;case 2:for(let o=t.top;o<=t.bottom;o++){const i=[];for(let e=t.right;e>=t.left;e--)i.push(ns(e,o));const n=this.createGenerator(i);for(let t=s.right;t>=s.left;t--)this.computeNewCell(n,t,o,e)}break;case 3:for(let o=t.top;o<=t.bottom;o++){const i=[];for(let e=t.left;e<=t.right;e++)i.push(ns(e,o));const n=this.createGenerator(i);for(let t=s.left;t<=s.right;t++)this.computeNewCell(n,t,o,e)}}if(e){const e=Qs(this.getters.getSelectedZone(),this.autofillZone);this.autofillZone=void 0,this.lastCellSelected={},this.direction=void 0,this.tooltip=void 0,this.dispatch("SET_SELECTION",{zones:[e],anchor:[e.left,e.top],anchorZone:e})}}select(e,t){const s=this.getters.getSelectedZone();if(to(e,t,s))this.autofillZone=void 0;else{switch(this.direction=this.getDirection(e,t),this.direction){case 0:this.saveZone(t,s.top-1,s.left,s.right);break;case 1:this.saveZone(s.bottom+1,t,s.left,s.right);break;case 2:this.saveZone(s.top,s.bottom,e,s.left-1);break;case 3:this.saveZone(s.top,s.bottom,s.right+1,e)}this.autofill(!1)}}autofillAuto(){const e=this.getters.getSelectedZone(),t=this.getters.getActiveSheetId();let s=e.left,o=e.bottom;if(s>0){let e=this.getters.getCell(t,s-1,o);for(;e&&!e.isEmpty();)o+=1,e=this.getters.getCell(t,s-1,o)}if(o===e.bottom&&(s=e.right,s<=this.getters.getActiveSheet().cols.length)){let e=this.getters.getCell(t,s+1,o);for(;e&&!e.isEmpty();)o+=1,e=this.getters.getCell(t,s+1,o)}o!==e.bottom&&(this.select(e.left,o-1),this.autofill(!0))}computeNewCell(e,t,s,o){const{cellData:i,tooltip:n,origin:r}=e.next(),{content:a,style:l,border:c,format:h}=i;this.tooltip=n,o&&this.dispatch("AUTOFILL_CELL",{originCol:r.col,originRow:r.row,col:t,row:s,content:a,style:l,border:c,format:h})}getRule(e,t){const s=Aa.getAll().sort(((e,t)=>e.sequence-t.sequence)).find((s=>s.condition(e,t)));return s&&s.generateRule(e,t)}createGenerator(e){const t=[],s=[],o=this.getters.getActiveSheetId();for(let t of e){const[e,i]=is(t),n=this.getters.getCell(o,e,i);s.push({col:e,row:i,cell:n,sheetId:o})}const i=s.map((e=>e.cell));for(let e of s){let s={type:"COPY_MODIFIER"};if(e&&e.cell){s=this.getRule(e.cell,i)||s}const{sheetId:o,col:n,row:r}=e,a=this.getters.getCellBorder(o,n,r)||void 0;t.push({data:{...e,border:a},rule:s})}return new wh(t,this.getters,this.direction)}saveZone(e,t,s,o){this.autofillZone={top:e,bottom:t,left:s,right:o}}getDirection(e,t){const s=this.getters.getSelectedZone(),o={up:{number:s.top-t,value:0},down:{number:t-s.bottom,value:1},left:{number:s.left-e,value:2},right:{number:e-s.right,value:3}};if(1===Object.values(o).map((e=>e.number>0?1:0)).reduce(((e,t)=>e+t)))return Object.values(o).find((e=>e.number>0?1:0)).value;const i=o.up.number>0?"up":"down",n=o.left.number>0?"left":"right";return Math.abs(o[i].number)>=Math.abs(o[n].number)?o[i].value:o[n].value}autoFillMerge(e,t,s,o){const i=this.getters.getActiveSheet();if(this.getters.isInMerge(i.id,s,o)&&!this.getters.isInMerge(i.id,e,t)){const e=this.getters.getMerge(i.id,s,o);e&&this.dispatch("REMOVE_MERGE",{sheetId:i.id,target:[e]})}const n=this.getters.getMerge(i.id,e,t);(null==n?void 0:n.topLeft.col)===e&&(null==n?void 0:n.topLeft.row)===t&&this.dispatch("ADD_MERGE",{sheetId:i.id,target:[{top:o,bottom:o+n.bottom-n.top,left:s,right:s+n.right-n.left}]})}drawGrid(e){if(!this.autofillZone)return;const{viewport:t,ctx:s,thinLineWidth:o}=e,[i,n,r,a]=this.getters.getRect(this.autofillZone,t);r>0&&a>0&&(s.strokeStyle="black",s.lineWidth=o,s.setLineDash([3]),s.strokeRect(i,n,r,a),s.setLineDash([]))}}Ih.layers=[6],Ih.getters=["getAutofillTooltip"],Ih.modes=["normal"];class xh extends yh{handle(e){if("SUM_SELECTION"===e.type){const e=this.getters.getActiveSheetId(),{zones:t,anchor:s}=this.getters.getSelection();for(const o of t){const t=this.getAutomaticSums(e,o,s);this.dispatchCellUpdates(e,t)}}}getAutomaticSums(e,t,s){return this.shouldFindData(e,t)?this.sumAdjacentData(e,t,s):this.sumData(e,t)}sumData(e,t){const s=this.dimensionsToSum(e,t),o=this.sumDimensions(e,t,s).filter((({zone:t})=>!this.getters.isEmpty(e,t)));return s.has("ROW")&&s.has("COL")&&o.push(this.sumTotal(t)),o}sumAdjacentData(e,t,s){const[o,i]=to(s[0],s[1],t)?s:[t.left,t.top],n=this.findAdjacentData(e,o,i);return n?this.getters.isSingleCellOrMerge(e,t)||no(Qs(n,t))?[{position:[o,i],zone:n}]:this.sumDimensions(e,Qs(n,t),this.transpose(this.dimensionsToSum(e,t))):[]}findAdjacentData(e,t,s){const o=this.getters.getSheet(e),i=this.findSuitableZoneToSum(o,...this.getters.getMainCell(e,t,s));if(i)return this.getters.expandZone(e,i)}findSuitableZoneToSum(e,t,s){const o=this.getters.getCell(e.id,t,s-1),i=this.getters.getCell(e.id,t-1,s);if(this.isNumber(i)&&!this.isNumber(o))return this.findHorizontalZone(e,t,s);const n=this.findVerticalZone(e,t,s);if(this.isZoneValid(n))return n;const r=this.findHorizontalZone(e,t,s);return this.isZoneValid(r)?r:void 0}findVerticalZone(e,t,s){const o={top:0,bottom:s-1,left:t,right:t},i=this.reduceZoneStart(e,o,o.bottom);return{...o,top:i}}findHorizontalZone(e,t,s){const o={top:s,bottom:s,left:0,right:t-1},i=this.reduceZoneStart(e,o,o.right);return{...o,left:i}}reduceZoneStart(e,t,s){const o=this.getters.getCellsInZone(e.id,t),i=Es(s,-1,-1),n=i.filter((e=>{var t;return o[e]&&!(null===(t=o[e])||void 0===t?void 0:t.isAutoSummable)})),r=Math.max(...n),a=bs(i.filter((e=>this.isNumber(o[e]))))[0]||[];return Math.max(...a)<r?1/0:Math.min(...a)}shouldFindData(e,t){return this.getters.isEmpty(e,t)||this.getters.isSingleCellOrMerge(e,t)}isNumber(e){var t;return(null==e?void 0:e.evaluated.type)===$e.number&&!(null===(t=e.format)||void 0===t?void 0:t.match(_))}isZoneValid(e){return e.bottom>=e.top&&e.right>=e.left}lastColIsEmpty(e,t){return this.getters.isEmpty(e,{...t,left:t.right})}lastRowIsEmpty(e,t){return this.getters.isEmpty(e,{...t,top:t.bottom})}dimensionsToSum(e,t){const s=new Set;return no(t)?(s.add(1===io(t).width?"COL":"ROW"),s):(this.lastColIsEmpty(e,t)&&s.add("ROW"),this.lastRowIsEmpty(e,t)&&s.add("COL"),0===s.size&&s.add("COL"),s)}sumDimensions(e,t,s){return[...s.has("COL")?this.sumColumns(t,e):[],...s.has("ROW")?this.sumRows(t,e):[]]}sumTotal(e){const{bottom:t,right:s}=e;return{position:[s,t],zone:{...e,top:t,right:s-1}}}sumColumns(e,t){const s=this.nextEmptyRow(t,{...e,bottom:e.bottom-1});return e={...e,bottom:Math.min(e.bottom,s.bottom-1)},ro(s).map((t=>({position:t,zone:{...e,right:t[0],left:t[0]}})))}sumRows(e,t){const s=this.nextEmptyCol(t,{...e,right:e.right-1});return e={...e,right:Math.min(e.right,s.right-1)},ro(s).map((t=>({position:t,zone:{...e,top:t[1],bottom:t[1]}})))}dispatchCellUpdates(e,t){for(const s of t){const[t,o]=s.position;this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:o,content:`=SUM(${this.getters.zoneToXC(e,s.zone)})`})}}nextEmptyRow(e,t){let s=t.bottom+1;const{left:o,right:i}=t;for(;!this.getters.isEmpty(e,{bottom:s,top:s,left:o,right:i});)s++;return{...t,top:s,bottom:s}}nextEmptyCol(e,t){let s=t.right+1;const{top:o,bottom:i}=t;for(;!this.getters.isEmpty(e,{left:s,right:s,top:o,bottom:i});)s++;return{...t,left:s,right:s}}transpose(e){return new Set([...e.values()].map((e=>"COL"===e?"ROW":"COL")))}}xh.getters=["getAutomaticSums"],xh.modes=["normal","headless"];class Th extends yh{constructor(){super(...arguments),this.status="invisible",this._isPaintingFormat=!1}allowDispatch(e){switch(e.type){case"PASTE":return this.isPasteAllowed(this.state,e.target,!!e.force);case"INSERT_CELL":{const{cut:t,paste:s}=this.getInsertCellsTargets(e.zone,e.shiftDimension),o=this.getClipboardState(t,"CUT");return this.isPasteAllowed(o,s,!1)}case"DELETE_CELL":{const{cut:t,paste:s}=this.getDeleteCellsTargets(e.zone,e.shiftDimension),o=this.getClipboardState(t,"CUT");return this.isPasteAllowed(o,s,!1)}}return 0}handle(e){var t,s;switch(e.type){case"COPY":case"CUT":this.state=this.getClipboardState(e.target,e.type),this.status="visible";break;case"PASTE":if(!this.state)break;const o=e.pasteOption||(this._isPaintingFormat?"onlyFormat":void 0);this._isPaintingFormat=!1;const i=this.state.cells.length,n=this.state.cells[0].length;this.paste(this.state,e.target,o),this.selectPastedZone(n,i,e.target),this.status="invisible";break;case"DELETE_CELL":{const{cut:t,paste:s}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);if(!js(t[0])){for(const[t,s]of ro(e.zone))this.dispatch("CLEAR_CELL",{col:t,row:s,sheetId:this.getters.getActiveSheetId()});break}const o=this.getClipboardState(t,"CUT");this.paste(o,s);break}case"INSERT_CELL":{const{cut:t,paste:s}=this.getInsertCellsTargets(e.zone,e.shiftDimension),o=this.getClipboardState(t,"CUT");this.paste(o,s);break}case"ADD_COLUMNS_ROWS":if(this.status="invisible","CUT"!==(null===(t=this.state)||void 0===t?void 0:t.operation))return;this.isColRowDirtyingClipboard("before"===e.position?e.base:e.base+1,e.dimension)&&(this.state=void 0);break;case"REMOVE_COLUMNS_ROWS":if(this.status="invisible","CUT"!==(null===(s=this.state)||void 0===s?void 0:s.operation))return;for(let t of e.elements){if(this.isColRowDirtyingClipboard(t,e.dimension)){this.state=void 0;break}}this.status="invisible";break;case"PASTE_FROM_OS_CLIPBOARD":this.pasteFromClipboard(e.target,e.text);break;case"ACTIVATE_PAINT_FORMAT":this.state=this.getClipboardState(e.target,"COPY"),this._isPaintingFormat=!0,this.status="visible";break;default:Ve(e)&&(this.status="invisible")}}getClipboardContent(){return this.state&&this.state.cells.length&&this.state.cells.map((e=>e.map((e=>e.cell?this.getters.getCellText(e.cell,this.getters.shouldShowFormulas()):"")).join("\t"))).join("\n")||"\t"}isPaintingFormat(){return this._isPaintingFormat}getDeleteCellsTargets(e,t){const s=this.getters.getActiveSheet();let o;return o="COL"===t?{...e,left:e.right+1,right:s.cols.length-1}:{...e,top:e.bottom+1,bottom:s.rows.length-1},{cut:[o],paste:[e]}}getInsertCellsTargets(e,t){const s=this.getters.getActiveSheet();let o,i;return"COL"===t?(o={...e,right:s.cols.length-1},i={...e,left:e.right+1,right:e.right+1}):(o={...e,bottom:s.rows.length-1},i={...e,top:e.bottom+1,bottom:s.rows.length-1}),{cut:[o],paste:[i]}}removeMergeIfTopLeft(e){const{sheetId:t,col:s,row:o}=e,[i,n]=this.getters.getMainCell(t,s,o);if(n===o&&i===s){const e=this.getters.getMerge(t,s,o);e&&this.dispatch("REMOVE_MERGE",{sheetId:t,target:[e]})}}pasteMergeIfExist(e,t){let{sheetId:s,col:o,row:i}=e;const[n,r]=this.getters.getMainCell(s,o,i);if(n===o&&r===i){const e=this.getters.getMerge(s,o,i);if(!e)return;({sheetId:s,col:o,row:i}=t),this.dispatch("ADD_MERGE",{sheetId:s,force:!0,target:[{left:o,top:i,right:o+e.right-e.left,bottom:i+e.bottom-e.top}]})}}getPasteZones(e,t){if(!t.length||!t[0].length)return e;const s=[],o=t.length,i=t[0].length,n=e[e.length-1],r=n.left,a=n.top,l=Math.max(1,Math.floor((n.right+1-r)/i)),c=Math.max(1,Math.floor((n.bottom+1-a)/o));for(let e=1;e<=l;e++)for(let t=1;t<=c;t++)s.push({left:r,top:a,right:r-1+e*i,bottom:a-1+t*o});return s}getClipboardState(e,t){const s=new Set(e.map((e=>e.left))),o=new Set(e.map((e=>e.right))),i=new Set(e.map((e=>e.top))),n=new Set(e.map((e=>e.bottom))),r=1===i.size&&1===n.size||1===s.size&&1===o.size?function(e){return e.reduce(((e,t)=>{const s=e.length;for(let o=0;o<s;o++)if(eo(e[o],t))return e[o]=Qs(e[o],t),e;return e[s]=t,e}),[])}(e):[e[e.length-1]],a=r.map((e=>ro(e))).flat(),l=[...new Set(a.map((e=>e[0])))].sort(((e,t)=>e-t)),c=[...new Set(a.map((e=>e[1])))].sort(((e,t)=>e-t)),h=[],d=[],u=this.getters.getActiveSheetId();for(let e of c){let t=[];for(let s of l){t.push({cell:this.getters.getCell(u,s,e),border:this.getters.getCellBorder(u,s,e)||void 0,position:{col:s,row:e,sheetId:u}});const o=this.getters.getMerge(u,s,e);o&&o.top===e&&o.left===s&&d.push(o)}h.push(t)}return{cells:h,operation:t,sheetId:u,zones:r,merges:d}}pasteFromClipboard(e,t){this.status="invisible";const s=t.replace(/\r/g,"").split("\n").map((e=>e.split("\t"))),{left:o,top:i}=e[0],n=Math.max.apply(Math,s.map((e=>e.length))),r=s.length,a=this.getters.getActiveSheet();this.addMissingDimensions(a,n,r,o,i);for(let e=0;e<s.length;e++)for(let t=0;t<s[e].length;t++)this.dispatch("UPDATE_CELL",{row:i+e,col:o+t,content:s[e][t],sheetId:a.id});const l={left:o,top:i,right:o+n-1,bottom:i+r-1};this.dispatch("SET_SELECTION",{anchor:[o,i],zones:[l],anchorZone:l})}isPasteAllowed(e,t,s){const o=this.getters.getActiveSheetId();if(!e)return 20;if(t.length>1&&(e.cells.length>1||e.cells[0].length>1))return 19;if(!s)for(let s of this.getPasteZones(t,e.cells))if(this.getters.doesIntersectMerge(o,s))return 2;return 0}paste(e,t,s){if("CUT"===e.operation&&this.clearClippedZones(e),t.length>1)for(const o of t)for(let t=o.left;t<=o.right;t++)for(let i=o.top;i<=o.bottom;i++)this.pasteZone(e,t,i,s);else{const o=e.cells.length,i=e.cells[0].length,n=t[0],r=Math.max(1,Math.floor((n.right+1-n.left)/i)),a=Math.max(1,Math.floor((n.bottom+1-n.top)/o));for(let t=0;t<r;t++)for(let r=0;r<a;r++)this.pasteZone(e,n.left+t*i,n.top+r*o,s)}"CUT"===e.operation&&(this.dispatch("REMOVE_MERGE",{sheetId:e.sheetId,target:e.merges}),this.state=void 0)}selectPastedZone(e,t,s){const o=s[0],i=o.left,n=o.top,r=Math.max(1,Math.floor((o.right+1-o.left)/e)),a=Math.max(1,Math.floor((o.bottom+1-o.top)/t));if(t>1||e>1){const s={left:i,top:n,right:i+r*e-1,bottom:n+a*t-1},[o,l]=this.getters.getSelection().anchor,c=ms(o,i,i+r*e-1),h=ms(l,n,n+a*t-1);this.dispatch("SET_SELECTION",{anchor:[c,h],zones:[s],anchorZone:s})}}clearClippedZones(e){for(const t of e.cells)for(const e of t)e.cell&&this.dispatch("CLEAR_CELL",e.position);this.dispatch("CLEAR_FORMATTING",{sheetId:e.sheetId,target:e.zones})}pasteZone(e,t,s,o){const i=e.cells.length,n=e.cells[0].length,r="onlyValue"!==o&&this.state&&this.state===e,a=this.getters.getActiveSheet();this.addMissingDimensions(a,n,i,t,s);for(let l=0;l<i;l++){const i=e.cells[l];for(let c=0;c<n;c++){const n=i[c],h={col:t+c,row:s+l,sheetId:a.id};this.removeMergeIfTopLeft(h),this.pasteMergeIfExist(n.position,h),this.pasteCell(n,h,e.operation,e.zones,o),r&&this.dispatch("PASTE_CONDITIONAL_FORMAT",{origin:n.position,target:h,operation:e.operation})}}}addMissingDimensions(e,t,s,o,i){const{cols:n,rows:r,id:a}=e,l=s+i-r.length;l>0&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"ROW",base:r.length-1,sheetId:a,quantity:l,position:"after"});const c=t+o-n.length;c>0&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"COL",base:n.length-1,sheetId:a,quantity:c,position:"after"})}pasteCell(e,t,s,o,i){const{sheetId:n,col:r,row:a}=t,l=this.getters.getCell(n,r,a);if("onlyValue"!==i&&this.dispatch("SET_BORDER",{sheetId:n,col:r,row:a,border:e.border}),e.cell){if("onlyFormat"===i)return void this.dispatch("UPDATE_CELL",{...t,style:e.cell.style,format:e.cell.format});if("onlyValue"===i){const s=jr(e.cell.evaluated.value);return void this.dispatch("UPDATE_CELL",{...t,content:s})}let l=e.cell.content;if(e.cell.isFormula()){const t=r-e.position.col,i=a-e.position.row;l=this.getUpdatedContent(n,e.cell,t,i,o,s)}this.dispatch("UPDATE_CELL",{...t,content:l,style:e.cell.style||null,format:e.cell.format})}else l&&("onlyValue"===i?this.dispatch("UPDATE_CELL",{...t,content:""}):"onlyFormat"===i?this.dispatch("UPDATE_CELL",{...t,style:null,format:""}):this.dispatch("CLEAR_CELL",t))}getUpdatedContent(e,t,s,o,i,n){if("CUT"===n){const n=[];for(const r of t.dependencies)this.isZoneOverlapClippedZone(i,r.zone)?n.push(...this.getters.createAdaptedRanges([r],s,o,e)):n.push(r);return this.getters.buildFormulaContent(e,t,n)}const r=this.getters.createAdaptedRanges(t.dependencies,s,o,e);return this.getters.buildFormulaContent(e,t,r)}isZoneOverlapClippedZone(e,t){return e.some((e=>eo(t,e)))}isColRowDirtyingClipboard(e,t){if(!this.state||!this.state.zones)return!1;for(let s of this.state.zones){if("COL"===t&&e<=s.right)return!0;if("ROW"===t&&e<=s.bottom)return!0}return!1}drawGrid(e){const{viewport:t,ctx:s,thinLineWidth:o}=e;if("visible"===this.status&&this.state&&this.state.zones&&this.state.zones.length&&this.state.sheetId===this.getters.getActiveSheetId()){s.setLineDash([8,5]),s.strokeStyle=p,s.lineWidth=3.3*o;for(const e of this.state.zones){const[o,i,n,r]=this.getters.getRect(e,t);n>0&&r>0&&s.strokeRect(o,i,n,r)}}}}Th.layers=[2],Th.getters=["getClipboardContent","isPaintingFormat"],Th.modes=["normal"];const Rh=[{name:a("Sum"),types:[$e.number],compute:e=>Ht.compute([e])},{name:a("Avg"),types:[$e.number],compute:e=>fo.compute([e])},{name:a("Min"),types:[$e.number],compute:e=>Oo.compute([e])},{name:a("Max"),types:[$e.number],compute:e=>Lo.compute([e])},{name:a("Count"),types:[$e.number,$e.text,$e.boolean,$e.error],compute:e=>wo.compute([e])},{name:a("Count Numbers"),types:[$e.number,$e.text,$e.boolean,$e.error],compute:e=>yo.compute([e])}];var Lh;!function(e){e[e.idle=0]="idle",e[e.selecting=1]="selecting",e[e.readyToExpand=2]="readyToExpand",e[e.expanding=3]="expanding"}(Lh||(Lh={}));class Mh extends yh{constructor(e,t,s,o){super(e,t,s,o),this.selection={zones:[{top:0,left:0,bottom:0,right:0}],anchor:[0,0],anchorZone:{top:0,left:0,bottom:0,right:0}},this.selectedFigureId=null,this.activeCol=0,this.activeRow=0,this.mode=Lh.idle,this.sheetsData={},this.activeSheet=null,this.moveClient=o.moveClient}allowDispatch(e){switch(e.type){case"SET_SELECTION":if(-1===e.zones.findIndex((t=>Js(t,e.anchorZone))))return 16;break;case"ALTER_SELECTION":if(e.delta){const{left:t,right:s,top:o,bottom:i}=this.getSelectedZone(),n=this.getters.getActiveSheet(),r=Zs(n,"cols",Es(t,s+1)),a=Zs(n,"rows",Es(o,i+1));if(0!==e.delta[0]&&void 0===a||0!==e.delta[1]&&void 0===r)return 17}break;case"MOVE_POSITION":{const{cols:t,rows:s}=this.getters.getActiveSheet();if(0!==e.deltaX&&s[this.activeRow].isHidden||0!==e.deltaY&&t[this.activeCol].isHidden)return 17;const{col:o,row:i}=this.getNextAvailablePosition(e.deltaX,e.deltaY);if(i<0||i>s.length-1||o<0||o>t.length-1)return 17;break}case"SELECT_COLUMN":{const{index:t}=e;if(t<0||t>=this.getters.getActiveSheet().cols.length)return 17;break}case"SELECT_ROW":{const{index:t}=e;if(t<0||t>=this.getters.getActiveSheet().rows.length)return 17;break}case"ACTIVATE_SHEET":try{this.getters.getSheet(e.sheetIdTo);break}catch(e){return 23}case"MOVE_COLUMNS_ROWS":return this.isMoveElementAllowed(e)}return 0}handle(e){switch(e.type){case"CREATE_SHEET":case"DELETE_SHEET":case"CREATE_FIGURE":case"CREATE_CHART":case"UPDATE_FIGURE":case"EVALUATE_CELLS":case"DISABLE_SELECTION_INPUT":case"ENABLE_NEW_SELECTION_INPUT":case"RESIZE_VIEWPORT":break;case"DELETE_FIGURE":this.selectedFigureId===e.id&&(this.selectedFigureId=null);break;default:this.selectedFigureId=null}switch(e.type){case"START":const t=zs(this.getters.getSheets()[0],0,0);this.activeCol=t[0],this.activeRow=t[1],this.dispatch("ACTIVATE_SHEET",{sheetIdTo:this.getters.getSheets()[0].id,sheetIdFrom:this.getters.getSheets()[0].id}),this.selectCell(...t);break;case"ACTIVATE_SHEET":this.setActiveSheet(e.sheetIdTo),this.sheetsData[e.sheetIdFrom]={selection:JSON.parse(JSON.stringify(this.selection)),activeCol:this.activeCol,activeRow:this.activeRow},e.sheetIdTo in this.sheetsData?Object.assign(this,this.sheetsData[e.sheetIdTo]):this.selectCell(...zs(this.getters.getSheet(e.sheetIdTo),0,0));break;case"SET_SELECTION":this.setSelection(e.anchor,e.zones,e.anchorZone,e.strict);break;case"START_SELECTION":this.mode=Lh.selecting;break;case"PREPARE_SELECTION_EXPANSION":this.mode=Lh.readyToExpand;break;case"START_SELECTION_EXPANSION":this.mode=Lh.expanding;break;case"STOP_SELECTION":this.mode=Lh.idle;break;case"MOVE_POSITION":this.movePosition(e.deltaX,e.deltaY);break;case"SELECT_CELL":this.selectCell(e.col,e.row);break;case"SELECT_COLUMN":this.selectColumn(e.index,e.createRange||!1,e.updateRange||!1);break;case"SELECT_ROW":this.selectRow(e.index,e.createRange||!1,e.updateRange||!1);break;case"SELECT_ALL":this.selectAll();break;case"ALTER_SELECTION":e.delta&&this.moveSelection(e.delta[0],e.delta[1]),e.cell&&this.addCellToSelection(...e.cell);break;case"UNDO":case"REDO":case"DELETE_SHEET":if(!this.getters.tryGetSheet(this.getActiveSheetId())){const e=this.getters.getVisibleSheets();this.activeSheet=this.getters.getSheet(e[0]),this.selectCell(0,0)}this.ensureSelectionValidity();break;case"REMOVE_COLUMNS_ROWS":e.sheetId===this.getActiveSheetId()&&("COL"===e.dimension?this.onColumnsRemoved(e):this.onRowsRemoved(e));break;case"ADD_COLUMNS_ROWS":e.sheetId===this.getActiveSheetId()&&this.onAddElements(e);break;case"MOVE_COLUMNS_ROWS":e.sheetId===this.getActiveSheetId()&&this.onMoveElements(e);break;case"UPDATE_CHART":case"SELECT_FIGURE":this.selectedFigureId=e.id;break;case"ACTIVATE_NEXT_SHEET":this.activateNextSheet("right");break;case"ACTIVATE_PREVIOUS_SHEET":this.activateNextSheet("left")}}getActiveSheet(){return this.activeSheet}getActiveSheetId(){return this.activeSheet.id}getActiveCell(){const e=this.getters.getActiveSheetId(),[t,s]=this.getters.getMainCell(e,this.activeCol,this.activeRow);return this.getters.getCell(e,t,s)}getActiveCols(){const e=new Set;for(let t of this.selection.zones)if(0===t.top&&t.bottom===this.getters.getActiveSheet().rows.length-1)for(let s=t.left;s<=t.right;s++)e.add(s);return e}getActiveRows(){const e=new Set;for(let t of this.selection.zones)if(0===t.left&&t.right===this.getters.getActiveSheet().cols.length-1)for(let s=t.top;s<=t.bottom;s++)e.add(s);return e}getCurrentStyle(){const e=this.getters.getActiveCell();return e?this.getters.getCellStyle(e):{}}getSelectedZones(){return this.selection.zones}getSelectedZone(){return this.selection.anchorZone}getSelection(){return this.selection}getSelectedFigureId(){return this.selectedFigureId}getPosition(){return[this.activeCol,this.activeRow]}getSheetPosition(e){if(e===this.getters.getActiveSheetId())return this.getPosition();{const t=this.sheetsData[e];return t?[t.activeCol,t.activeRow]:zs(this.getters.getSheet(e),0,0)}}getStatisticFnResults(){const e=new Set(this.selection.zones.map((e=>this.getters.getCellsInZone(this.getters.getActiveSheetId(),e))).flat().filter((e=>void 0!==e)));let t=new Set,s=[];for(let o of e)t.add(o.evaluated.type),s.push(o.evaluated.value);let o={};for(let e of Rh){let i;e.types.some((e=>t.has(e)))&&(i=e.compute(s)),o[e.name]=i}return o}getSelectionMode(){return this.mode}isSelected(e){return!!this.getters.getSelectedZones().find((t=>Js(t,e)))}getVisibleFigures(){const e=this.getters.getActiveSheetId(),t=[],s=this.getters.getFigures(e),{offsetX:o,offsetY:i}=this.getters.getActiveSnappedViewport(),{width:n,height:r}=this.getters.getViewportDimensionWithHeaders();for(let e of s)e.x>=o+n||e.x+e.width<=o||e.y>=i+r||e.y+e.height<=i||t.push(e);return t}getElementsFromSelection(e){if("COL"===e&&0===this.getters.getActiveCols().size)return[];if("ROW"===e&&0===this.getters.getActiveRows().size)return[];const t=this.getters.getSelectedZones();let s=[];const o="COL"===e?"left":"top",i="COL"===e?"right":"bottom";for(const e of t){const t=Array.from({length:e[i]-e[o]+1},((t,s)=>e[o]+s));s=s.concat(t)}return[...new Set(s)].sort()}selectColumn(e,t,s){const o=this.getters.getActiveSheet().rows.length-1;let i={left:e,right:e,top:0,bottom:o};const n=this.selection.zones;let r,a;const l=this.getters.getActiveSheet().rows.findIndex((e=>!e.isHidden));if(s){const[e,t]=this.selection.anchor;i=Qs(i,{left:e,right:e,top:l,bottom:o}),r=this.updateSelectionZones(i),a=[e,t]}else r=t?n.concat(i):[i],a=[e,l];this.dispatch("SET_SELECTION",{zones:r,anchor:a,strict:!0,anchorZone:i})}selectRow(e,t,s){const o=this.getters.getActiveSheet().cols.length-1;let i={top:e,bottom:e,left:0,right:o};const n=this.selection.zones;let r,a;const l=this.getters.getActiveSheet().cols.findIndex((e=>!e.isHidden));if(s){const[e,t]=this.selection.anchor;i=Qs(i,{left:l,right:o,top:t,bottom:t}),r=this.updateSelectionZones(i),a=[e,t]}else r=t?n.concat(i):[i],a=[l,e];this.dispatch("SET_SELECTION",{zones:r,anchor:a,strict:!0,anchorZone:i})}selectAll(){const e={left:0,top:0,bottom:this.getters.getActiveSheet().rows.length-1,right:this.getters.getActiveSheet().cols.length-1};this.dispatch("SET_SELECTION",{zones:[e],anchor:[0,0],anchorZone:e})}selectCell(e,t){const s=this.getters.getActiveSheet();this.moveClient({sheetId:s.id,col:e,row:t});const o=this.getters.expandZone(s.id,{left:e,right:e,top:t,bottom:t});let i;i=this.mode===Lh.expanding?lo([...this.selection.zones,o]):[o],this.selection=this.clipSelection(s.id,{anchor:[e,t],zones:i,anchorZone:o}),this.activeCol=this.selection.anchor[0],this.activeRow=this.selection.anchor[1]}setActiveSheet(e){const t=this.getters.getSheet(e);this.activeSheet=t}getNextAvailablePosition(e,t){return{col:this.getNextAvailableCol(e,this.activeCol,this.activeRow),row:this.getNextAvailableRow(t,this.activeCol,this.activeRow)}}getNextAvailableCol(e,t,s){const{cols:o,id:i}=this.getActiveSheet(),n={col:t,row:s};return this.getNextAvailableHeader(e,o,t,n,(e=>this.getters.isInSameMerge(i,t,s,e,s)))}getNextAvailableRow(e,t,s){const{rows:o,id:i}=this.getActiveSheet(),n={col:t,row:s};return this.getNextAvailableHeader(e,o,s,n,(e=>this.getters.isInSameMerge(i,t,s,t,e)))}getNextAvailableHeader(e,t,s,o,i){var n,r,a;const l=this.getters.getActiveSheetId(),{col:c,row:h}=o;if(0===e)return s;let d=s+e;if(this.getters.isInMerge(l,c,h)){for(;i(d);)d+=e;for(;null===(n=t[d])||void 0===n?void 0:n.isHidden;)d+=e}else if(null===(r=t[d])||void 0===r?void 0:r.isHidden)for(;null===(a=t[d])||void 0===a?void 0:a.isHidden;)d+=e;return d<0||d>t.length-1?t[s].isHidden?this.getNextAvailableHeader(-e,t,s,o,i):s:d}movePosition(e,t){const{col:s,row:o}=this.getNextAvailablePosition(e,t);this.selectCell(s,o)}setSelection(e,t,s,o=!1){this.selectCell(...e);const i=this.getters.getActiveSheetId();let n;t=lo(t),n=o?{zones:t,anchorZone:s,anchor:e}:{anchor:e,zones:t.map((e=>this.getters.expandZone(i,e))),anchorZone:this.getters.expandZone(i,s)},this.selection=this.clipSelection(i,n)}getReferencePosition(){const e=this.getters.getActiveSheet(),t=this.selection,{left:s,right:o,top:i,bottom:n}=t.anchorZone,[r,a]=t.anchor;return{col:e.cols[r].isHidden&&Zs(e,"cols",Es(s,o+1))||r,row:e.rows[a].isHidden&&Zs(e,"rows",Es(i,n+1))||a}}moveSelection(e,t){const s=this.selection;let o=[];const[i,n]=s.anchor,{left:r,right:a,top:l,bottom:c}=s.anchorZone;let h=s.anchorZone;const d=this.getters.getActiveSheet(),u=e=>{const{left:t,right:s,top:o,bottom:i}=this.getters.expandZone(d.id,e);return{left:Math.max(0,t),right:Math.min(d.cols.length-1,s),top:Math.max(0,o),bottom:Math.min(d.rows.length-1,i)}},{col:p,row:g}=this.getReferencePosition();let f=0;for(;null!==h;){if(f++,e<0){const t=this.getNextAvailableCol(e,a-(f-1),g);h=p<=a-f?u({top:l,left:r,bottom:c,right:t}):null}if(e>0){const t=this.getNextAvailableCol(e,r+(f-1),g);h=r+f<=p?u({top:l,left:t,bottom:c,right:a}):null}if(t<0){const e=this.getNextAvailableRow(t,p,c-(f-1));h=g<=c-f?u({top:l,left:r,bottom:e,right:a}):null}if(t>0){const e=this.getNextAvailableRow(t,p,l+(f-1));h=l+f<=g?u({top:e,left:r,bottom:c,right:a}):null}if(h=h?co(h):h,h&&!Js(h,s.anchorZone))return o=this.updateSelectionZones(h),void this.dispatch("SET_SELECTION",{zones:o,anchor:[i,n],anchorZone:h})}h=u(Qs({top:n,bottom:n,left:i,right:i},co({top:this.getNextAvailableRow(t,p,l),left:this.getNextAvailableCol(e,r,g),bottom:this.getNextAvailableRow(t,p,c),right:this.getNextAvailableCol(e,a,g)}))),Js(h,s.anchorZone)||(o=this.updateSelectionZones(h),this.dispatch("SET_SELECTION",{zones:o,anchor:[i,n],anchorZone:h}))}addCellToSelection(e,t){const s=this.selection,[o,i]=s.anchor,n={left:Math.min(o,e),top:Math.min(i,t),right:Math.max(o,e),bottom:Math.max(i,t)},r=this.updateSelectionZones(n);this.dispatch("SET_SELECTION",{zones:r,anchor:[o,i],anchorZone:n})}ensureSelectionValidity(){const{anchor:e,zones:t,anchorZone:s}=this.clipSelection(this.getActiveSheetId(),this.selection);this.setSelection(e,t,s);const o=Object.keys(this.sheetsData).filter((e=>!this.getters.tryGetSheet(e)));for(const e of o)delete this.sheetsData[e];for(const e in this.sheetsData){const{anchor:t,zones:s,anchorZone:o}=this.clipSelection(e,this.sheetsData[e].selection);this.sheetsData[e]={selection:{anchor:t,zones:s,anchorZone:o},activeCol:t[0],activeRow:t[1]}}}clipSelection(e,t){const s=this.getters.getSheet(e),o=s.cols.length-1,i=s.rows.length-1,n=t.zones.map((e=>({left:ms(e.left,0,o),right:ms(e.right,0,o),top:ms(e.top,0,i),bottom:ms(e.bottom,0,i)})));return{anchor:[ms(t.anchor[0],0,o),ms(t.anchor[1],0,i)],zones:n,anchorZone:{left:ms(t.anchorZone.left,0,o),right:ms(t.anchorZone.right,0,o),top:ms(t.anchorZone.top,0,i),bottom:ms(t.anchorZone.bottom,0,i)}}}onColumnsRemoved(e){const t=Ks(this.getSelectedZone(),"left",e.elements);this.setSelection([t.left,t.top],[t],t,!0),this.ensureSelectionValidity()}onRowsRemoved(e){const t=Ks(this.getSelectedZone(),"top",e.elements);this.setSelection([t.left,t.top],[t],t,!0),this.ensureSelectionValidity()}onAddElements(e){const t=Ys(this.getSelectedZone(),"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);this.setSelection([t.left,t.top],[t],t,!0)}updateSelectionZones(e){let t=[...this.selection.zones];const s=this.selection.anchorZone,o=t.findIndex((e=>Js(e,s)));return o>=0&&(t[o]=e),t}activateNextSheet(e){const t=this.getters.getSheets().map((e=>e.id)),s=(t.findIndex((e=>e===this.activeSheet.id))+("left"===e?t.length-1:1))%t.length;this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getActiveSheetId(),sheetIdTo:t[s]})}onMoveElements(e){const t=e.elements.length;this.dispatch("ADD_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,base:e.base,quantity:t,position:"before"});const s="COL"===e.dimension,o=e.elements[0],i=e.elements[t-1],n=e.base<o,r=n&&s?t:0,a=n&&!s?t:0,l=this.getters.getSheet(e.sheetId);this.dispatch("CUT",{target:[{left:s?o+r:0,right:s?i+r:l.cols.length-1,top:s?0:o+a,bottom:s?l.rows.length-1:i+a}]}),this.dispatch("PASTE",{target:[{left:s?e.base:0,right:s?e.base+t-1:l.cols.length-1,top:s?0:e.base,bottom:s?l.rows.length-1:e.base+t-1}]});const c=n?e.elements.map((e=>e+t)):e.elements;let h=e.base;for(const t of c){const s="COL"===e.dimension?this.getters.getCol(e.sheetId,t).size:this.getters.getRow(e.sheetId,t).size;this.dispatch("RESIZE_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,size:s,elements:[h]}),h+=1}this.dispatch("REMOVE_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,elements:c})}isMoveElementAllowed(e){const t="COL"===e.dimension,s=e.elements[0],o=e.elements[e.elements.length-1],i=e.sheetId,n=t?this.getters.doesColumnsHaveCommonMerges:this.getters.doesRowsHaveCommonMerges;return n(i,s-1,s)||n(i,o,o+1)||n(i,e.base-1,e.base)?2:0}drawGrid(e){if("inactive"!==this.getters.getEditionMode())return;const{viewport:t,ctx:s,thinLineWidth:o}=e,i=this.getSelectedZones();s.fillStyle="#f3f7fe";const n=1===i.length&&i[0].left===i[0].right&&i[0].top===i[0].bottom;s.fillStyle=n?"#f3f7fe":"#e9f0ff",s.strokeStyle=p,s.lineWidth=1.5*o,s.globalCompositeOperation="multiply";for(const e of i){const[o,i,n,r]=this.getters.getRect(e,t);s.fillRect(o,i,n,r),s.strokeRect(o,i,n,r)}s.globalCompositeOperation="source-over";const r=this.getters.getActiveSheetId(),[a,l]=this.getPosition();let c;s.strokeStyle=p,s.lineWidth=3*o,c=this.getters.isInMerge(r,a,l)?this.getters.getMerge(r,a,l):{top:l,bottom:l,left:a,right:a};const[h,d,u,g]=this.getters.getRect(c,t);u>0&&g>0&&s.strokeRect(h,d,u,g)}}Mh.layers=[5],Mh.modes=["normal"],Mh.getters=["getActiveSheet","getActiveSheetId","getActiveCell","getActiveCols","getActiveRows","getCurrentStyle","getSelectedZones","getSelectedZone","getStatisticFnResults","getSelectedFigureId","getVisibleFigures","getSelection","getPosition","getSheetPosition","getSelectionMode","isSelected","getElementsFromSelection"];const Ah=a("The cell you are trying to edit has been deleted.");class _h extends yh{constructor(){super(...arguments),this.col=0,this.row=0,this.mode="inactive",this.sheet="",this.currentContent="",this.currentTokens=[],this.selectionStart=0,this.selectionEnd=0,this.selectionInitialStart=0,this.multiSelectionInitialStart=0,this.initialContent="",this.previousRef="",this.previousRange=void 0,this.colorIndexByRange={}}allowDispatch(e){switch(e.type){case"CHANGE_COMPOSER_CURSOR_SELECTION":return this.validateSelection(this.currentContent.length,e.start,e.end);case"SET_CURRENT_CONTENT":return e.selection?this.validateSelection(e.content.length,e.selection.start,e.selection.end):0;case"START_EDITION":if(e.selection){const t=this.getters.getActiveCell(),s=e.text||(null==t?void 0:t.composerContent)||"";return this.validateSelection(s.length,e.selection.start,e.selection.end)}return 0;default:return 0}}handle(e){switch(e.type){case"CHANGE_COMPOSER_CURSOR_SELECTION":this.selectionStart=e.start,this.selectionEnd=e.end;break;case"STOP_COMPOSER_RANGE_SELECTION":this.isSelectingForComposer()&&(this.mode="editing");break;case"START_EDITION":this.startEdition(e.text,e.selection);break;case"STOP_EDITION":e.cancel?(this.cancelEdition(),this.resetContent()):this.stopEdition();break;case"SET_CURRENT_CONTENT":this.setContent(e.content,e.selection,!0);break;case"REPLACE_COMPOSER_CURSOR_SELECTION":this.replaceSelection(e.text);break;case"SELECT_FIGURE":this.cancelEdition(),this.resetContent();break;case"SELECT_CELL":case"SET_SELECTION":case"MOVE_POSITION":switch(this.mode){case"editing":this.dispatch("STOP_EDITION");break;case"waitingForRangeSelection":this.insertSelectedRange();break;case"rangeSelected":switch(e.type){case"MOVE_POSITION":this.replaceAllSelectedRanges();break;case"SELECT_CELL":this.getters.getSelectionMode()===Lh.expanding?this.insertSelectedRange():this.replaceAllSelectedRanges();break;case"SET_SELECTION":e.strict?this.getters.getSelectionMode()===Lh.expanding?this.insertSelectedRange():this.replaceAllSelectedRanges():this.replaceSelectedRange()}}break;case"ADD_COLUMNS_ROWS":this.onAddElements(e);break;case"REMOVE_COLUMNS_ROWS":"COL"===e.dimension?this.onColumnsRemoved(e):this.onRowsRemoved(e);break;case"START_CHANGE_HIGHLIGHT":this.dispatch("STOP_COMPOSER_RANGE_SELECTION");const t=this.currentTokens.filter((e=>"REFERENCE"===e.type)).find((t=>{let s=t.value;const{xc:o,sheetName:i}=ss(s),n=i||this.getters.getSheetName(this.sheet),r=this.getters.getActiveSheetId();return Js(this.getters.expandZone(r,qs(o)),e.zone)&&this.getters.getSheetName(r)===n}));this.previousRef=t.value,this.previousRange=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),this.previousRef),this.selectionInitialStart=t.start;break;case"CHANGE_HIGHLIGHT":const s=this.getZoneReference(e.zone,this.previousRange.parts);this.selectionStart=this.selectionInitialStart,this.selectionEnd=this.selectionInitialStart+this.previousRef.length,this.replaceSelection(s),this.previousRef=s,this.selectionStart=this.currentContent.length,this.selectionEnd=this.currentContent.length;break;case"DELETE_SHEET":case"UNDO":case"REDO":!!this.getters.tryGetSheet(this.sheet)||"inactive"===this.mode||(this.cancelEdition(),this.resetContent(),this.ui.notifyUI({type:"NOTIFICATION",text:Ah}))}}getEditionMode(){return this.mode}getCurrentContent(){if("inactive"===this.mode){const e=this.getters.getActiveCell();return(null==e?void 0:e.composerContent)||""}return this.currentContent}getEditionSheet(){return this.sheet}getComposerSelection(){return{start:this.selectionStart,end:this.selectionEnd}}isSelectingForComposer(){return"waitingForRangeSelection"===this.mode||"rangeSelected"===this.mode||"resettingPosition"===this.mode}getCurrentTokens(){return this.currentTokens}getTokenAtCursor(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return e===t&&0===t?void 0:this.currentTokens.find((s=>s.start<=e&&s.end>=t))}validateSelection(e,t,s){return t>=0&&t<=e&&s>=0&&s<=e?0:31}onColumnsRemoved(e){if(e.elements.includes(this.col)&&"inactive"!==this.mode)return this.dispatch("STOP_EDITION",{cancel:!0}),void this.ui.notifyUI({type:"NOTIFICATION",text:Ah});const{top:t,left:s}=Ks({left:this.col,right:this.col,top:this.row,bottom:this.row},"left",e.elements);this.col=s,this.row=t}onRowsRemoved(e){if(e.elements.includes(this.row)&&"inactive"!==this.mode)return this.dispatch("STOP_EDITION",{cancel:!0}),void this.ui.notifyUI({type:"NOTIFICATION",text:Ah});const{top:t,left:s}=Ks({left:this.col,right:this.col,top:this.row,bottom:this.row},"top",e.elements);this.col=s,this.row=t}onAddElements(e){const{top:t,left:s}=Ys({left:this.col,right:this.col,top:this.row,bottom:this.row},"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);this.col=s,this.row=t}startComposerRangeSelection(){this.mode="resettingPosition",this.sheet===this.getters.getActiveSheetId()&&this.dispatch("SELECT_CELL",{col:this.col,row:this.row}),this.mode="waitingForRangeSelection",this.multiSelectionInitialStart=this.selectionStart}startEdition(e,t){const s=this.getters.getActiveCell();this.initialContent=(null==s?void 0:s.composerContent)||"",this.mode="editing";const[o,i]=this.getters.getPosition();this.col=o,this.row=i,this.sheet=this.getters.getActiveSheetId(),this.setContent(e||this.initialContent,t),this.colorIndexByRange={}}stopEdition(){if("inactive"!==this.mode){this.cancelEdition();const e=this.getters.getActiveSheetId(),t=this.getters.getSheets().find((e=>e.id===this.sheet)).id,[s,o]=this.getters.getMainCell(t,this.col,this.row);let i=this.currentContent;if(!(this.initialContent!==i))return;if(i){const t=this.getters.getCell(e,s,o);if(i.startsWith("=")){const e=this.currentTokens.filter((e=>"LEFT_PAREN"===e.type)).length,t=this.currentTokens.filter((e=>"RIGHT_PAREN"===e.type)).length,s=e-t;s>0&&(i+=new Array(s).fill(")").join(""))}else(null==t?void 0:t.isLink())&&(i=Ts(i,t.link.url));this.dispatch("UPDATE_CELL",{sheetId:this.sheet,col:s,row:o,content:i})}else this.dispatch("UPDATE_CELL",{sheetId:this.sheet,content:"",col:s,row:o});e!==this.sheet&&this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getters.getActiveSheetId(),sheetIdTo:this.sheet}),this.setContent("")}}cancelEdition(){this.mode="inactive"}resetContent(){this.setContent(this.initialContent||"")}setContent(e,t,s){e=e.replace(/[\r\n]/g,"");const o=this.currentContent!==e;this.currentContent=e,t?(this.selectionStart=t.start,this.selectionEnd=t.end):this.selectionStart=this.selectionEnd=e.length,(o||"inactive"!==this.mode)&&(this.currentTokens=e.startsWith("=")?Wr(e):[],this.currentTokens.length>100&&s&&this.ui.notifyUI({type:"NOTIFICATION",text:a("This formula has over 100 parts. It can't be processed properly, consider splitting it into multiple cells")})),this.canStartComposerRangeSelection()&&this.startComposerRangeSelection()}insertSelectedRange(){const e=Math.min(this.selectionStart,this.selectionEnd),t=this.getZoneReference(this.getters.getSelectedZone());if("waitingForRangeSelection"===this.mode)return this.insertText(t,e),this.selectionInitialStart=e,void(this.mode="rangeSelected");this.insertText(","+t,e),this.selectionInitialStart=e+1}replaceSelectedRange(){const{end:e}=this.getters.getComposerSelection();this.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:this.selectionInitialStart,end:e}),this.replaceSelection(this.getZoneReference(this.getters.getSelectedZone()))}replaceAllSelectedRanges(){const{end:e}=this.getters.getComposerSelection();this.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:this.multiSelectionInitialStart,end:e}),this.replaceSelection(this.getZoneReference(this.getters.getSelectedZone())),this.selectionInitialStart=this.multiSelectionInitialStart}getZoneReference(e,t=[{colFixed:!1,rowFixed:!1}]){const s=this.getters.getActiveSheetId();let o=this.getters.zoneToXC(s,e,t);if(this.getters.getEditionSheet()!==this.getters.getActiveSheetId()){o=`${fs(this.getters.getSheetName(this.getters.getActiveSheetId()))}!${o}`}return o}replaceSelection(e){const t=Math.min(this.selectionStart,this.selectionEnd),s=Math.max(this.selectionStart,this.selectionEnd);this.replaceText(e,t,s)}replaceText(e,t,s){this.currentContent=this.currentContent.slice(0,t)+this.currentContent.slice(s,this.currentContent.length),this.insertText(e,t)}insertText(e,t){const s=this.currentContent.slice(0,t)+e+this.currentContent.slice(t),o=t+e.length;this.dispatch("SET_CURRENT_CONTENT",{content:s,selection:{start:o,end:o}})}getComposerHighlights(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return[];const e=[],t={};for(let s of this.currentTokens.filter((e=>"REFERENCE"===e.type))){let o=s.value;const{xc:i,sheetName:n}=ss(o);if(ts.test(i)){const s=(n?`${n}!`:`${this.getters.getSheetName(this.getters.getEditionSheet())}!`)+i.replace(/\$/g,"");e.push(s);const o=this.colorIndexByRange[s];void 0!==o&&(t[s]=o)}}this.colorIndexByRange=t;let s=Object.values(t),o=0;return e.map((e=>{if(void 0===this.colorIndexByRange[e]){for(;s.includes(o);)o++;s.push(o),this.colorIndexByRange[e]=o}return[e,Xt[this.colorIndexByRange[e]%Xt.length]]}))}canStartComposerRangeSelection(){if("editing"!==this.mode&&this.selectionStart===this.selectionEnd)return!1;if(this.currentContent.startsWith("=")){const e=this.getTokenAtCursor();if(e){const t=this.currentTokens.map((e=>e.start)).indexOf(e.start);let s=t,o=e;for(;!["COMMA","LEFT_PAREN","OPERATOR"].includes(o.type);){if("SPACE"!==o.type||s<1)return!1;s--,o=this.currentTokens[s]}for(s=t+1,o=this.currentTokens[s];o&&!["COMMA","RIGHT_PAREN","OPERATOR"].includes(o.type);){if("SPACE"!==o.type)return!1;s++,o=this.currentTokens[s]}s++,o=this.currentTokens[s]}return!0}return!1}}_h.getters=["getEditionMode","isSelectingForComposer","getCurrentContent","getEditionSheet","getComposerSelection","getCurrentTokens","getTokenAtCursor","getComposerHighlights"],_h.modes=["normal"];const Oh=hr.mapping;class Nh extends yh{constructor(e,t,s,o){super(e,t,s,o),this.isUpToDate=new Set,this.evalContext=o.evalContext,o.dataSources.on("data-loaded",this,(()=>{this.dispatch("EVALUATE_CELLS",{sheetId:this.getters.getActiveSheetId()})}))}handle(e){switch(De.has(e.type)&&this.isUpToDate.clear(),e.type){case"UPDATE_CELL":"content"in e&&this.isUpToDate.clear();break;case"ACTIVATE_SHEET":this.evaluate(e.sheetIdTo),this.isUpToDate.add(e.sheetIdTo);break;case"EVALUATE_CELLS":this.evaluate(e.sheetId),this.isUpToDate.add(e.sheetId);break;case"EVALUATE_ALL_SHEETS":this.evaluateAllSheets()}}finalize(){const e=this.getters.getActiveSheetId();this.isUpToDate.has(e)||(this.evaluate(e),this.isUpToDate.add(e))}evaluateFormula(e,t=this.getters.getActiveSheetId()){try{const s=Gr(e),o=this.getFormulaParameters((()=>{})),i=[];for(let e of s.dependencies)i.push(this.getters.getRangeFromSheetXC(t,e));return s.execute(i,t,...o)}catch{return"#ERROR"}}getRangeFormattedValues(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getCellsInZone(t.id,e.zone).map((e=>(null==e?void 0:e.formattedValue)||""))}getRangeValues(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getCellsInZone(t.id,e.zone).map((e=>null==e?void 0:e.evaluated.value))}evaluate(e){const t=this.getters.getCells(e),s=this.getFormulaParameters(i),o={};for(let s of Object.values(t))i(s,e);function i(e,t){if(!e.isFormula())return;const i=e.id;if(i in o)null===o[i]&&e.assignError("#CYCLE",a("Circular reference"));else{o[i]=null;try{if(s[2].__originCellXC=()=>{const e=s[2].getters.getCellPosition(i);return ns(e.col,e.row)},e.assignValue(e.compiledFormula.execute(e.dependencies,t,...s)),Array.isArray(e.evaluated.value))throw new Error(a("This formula depends on invalid values"))}catch(t){!function(e,t){if(e instanceof Error||(e=new Error(e)),"#CYCLE"!==t.evaluated.value){t.assignValue("#ERROR");const o=s[2].__lastFnCalled||"";t.assignError("#ERROR",e.message.replace("[[FUNCTION_NAME]]",o))}}(t,e)}o[i]=!0}}}getFormulaParameters(e){const t=Object.assign(Object.create(Oh),this.evalContext,{getters:this.getters}),s=this.getters;function o(t,s){if(e(t,s),t.evaluated.type===$e.error)throw new Error(a("This formula depends on invalid values"));return t.evaluated.value}function i(e){const i=e.sheetId;if(!js(e.zone))throw new Error(a("Invalid reference"));const n={top:0,bottom:s.getNumberRows(i)-1,left:0,right:s.getNumberCols(i)-1},r=[],l=function(e,t){if(eo(e,t))return{top:Math.max(e.top,t.top),left:Math.max(e.left,t.left),bottom:Math.min(e.bottom,t.bottom),right:Math.min(e.right,t.right)}}(e.zone,n);if(!l)return r.push([]),r;for(let s=l.left;s<=l.right;s++){const i=[];for(let n=l.top;n<=l.bottom;n++){const r=t.getters.getCell(e.sheetId,s,n);i.push(r?o(r,e.sheetId):void 0)}r.push(i)}return r}return[function(e,i,n,r,l,c){const h=i[e];if(r)return t.getters.getRangeString(h,n);if(!js(h.zone))throw new Error(a("Invalid reference"));if(h.zone.bottom!==h.zone.top||h.zone.left!==h.zone.right)throw new Error(c?a("Function %s expects the parameter %s to be a single value or a single cell reference, not a range.",l.toString(),c.toString()):a("Function %s expects its parameters to be single values or single cell references, not ranges.",l.toString()));if(h.invalidSheetName)throw new Error(a("Invalid sheet name: %s",h.invalidSheetName));return function(e){let t;if(!s.tryGetSheet(e.sheetId))throw new Error(a("Invalid sheet name"));return t=s.getCell(e.sheetId,e.zone.left,e.zone.top),!t||t.isEmpty()?null:o(t,e.sheetId)}(h)},function(e,t,s){return i(t[e])},t]}evaluateAllSheets(){for(const e of this.getters.getVisibleSheets())this.evaluate(e),this.isUpToDate.add(e)}}Nh.getters=["evaluateFormula","getRangeFormattedValues","getRangeValues"],Nh.modes=["normal"];const kh=["rgb(31,119,180)","rgb(255,127,14)","rgb(174,199,232)","rgb(255,187,120)","rgb(44,160,44)","rgb(152,223,138)","rgb(214,39,40)","rgb(255,152,150)","rgb(148,103,189)","rgb(197,176,213)","rgb(140,86,75)","rgb(196,156,148)","rgb(227,119,194)","rgb(247,182,210)","rgb(127,127,127)","rgb(199,199,199)","rgb(188,189,34)","rgb(219,219,141)","rgb(23,190,207)","rgb(158,218,229)"];class Fh{constructor(){this.graphColorIndex=0}next(){return kh[this.graphColorIndex++%kh.length]}}class $h extends yh{constructor(){super(...arguments),this.chartRuntime={},this.outOfDate=new Set}handle(e){if(De.has(e.type)||"EVALUATE_CELLS"===e.type||"UPDATE_CELL"===e.type&&"content"in e)for(let e of Object.keys(this.chartRuntime))this.outOfDate.add(e);switch(e.type){case"UPDATE_CHART":case"CREATE_CHART":const t=this.getters.getChartDefinition(e.id);this.chartRuntime[e.id]=this.mapDefinitionToRuntime(t);break;case"DELETE_FIGURE":delete this.chartRuntime[e.id];break;case"REFRESH_CHART":this.evaluateUsedSheets([e.id]),this.outOfDate.add(e.id);break;case"ACTIVATE_SHEET":const s=this.getters.getChartsIdBySheet(e.sheetIdTo);this.evaluateUsedSheets(s);break;case"DELETE_SHEET":for(let e of Object.keys(this.chartRuntime))this.getters.getChartDefinition(e)||delete this.chartRuntime[e]}}getChartRuntime(e){if(this.outOfDate.has(e)||!(e in this.chartRuntime)){const t=this.getters.getChartDefinition(e);if(void 0===t)return;this.chartRuntime[e]=this.mapDefinitionToRuntime(t),this.outOfDate.delete(e)}return this.chartRuntime[e]}truncateLabel(e){return e?e.length>20?e.substring(0,20)+"…":e:""}getDefaultConfiguration(e,t){const s={};e.labelRange||1!==e.dataSets.length?s.position=e.legendPosition:s.display=!1;const o={type:e.type,options:{legend:s,responsive:!0,maintainAspectRatio:!1,layout:{padding:{left:20,right:20,top:e.title?10:25,bottom:10}},elements:{line:{fill:!1},point:{hitRadius:15}},animation:{duration:0},hover:{animationDuration:10},responsiveAnimationDuration:0,title:{display:!!e.title,fontSize:22,fontStyle:"normal",text:e.title}},data:{labels:t.map(this.truncateLabel),datasets:[]}};return"pie"!==e.type?(o.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2}}],yAxes:[{position:e.verticalAxisPosition,ticks:{beginAtZero:!0}}]},"bar"===e.type&&e.stackedBar&&(o.options.scales.xAxes[0].stacked=!0,o.options.scales.yAxes[0].stacked=!0)):o.options.tooltips={callbacks:{title:function(e,t){return t.datasets[e[0].datasetIndex].label}}},o}getSheetIdsUsedInChart(e){const t=new Set;for(let s of e.dataSets)t.add(s.dataRange.sheetId);return e.labelRange&&t.add(e.labelRange.sheetId),t}evaluateUsedSheets(e){const t=new Set;for(let s of e){const e=this.getters.getChartDefinition(s);(void 0!==e?this.getSheetIdsUsedInChart(e):[]).forEach((e=>{e!==this.getters.getActiveSheetId()&&t.add(e)}))}for(let e of t)this.dispatch("EVALUATE_CELLS",{sheetId:e})}mapDefinitionToRuntime(e){let t=[];if(e.labelRange)e.labelRange.invalidXc||e.labelRange.invalidSheetName||(t=this.getters.getRangeFormattedValues(e.labelRange));else if(1===e.dataSets.length)for(let s=0;s<this.getData(e.dataSets[0],e.sheetId).length;s++)t.push("");else if(e.dataSets[0]){t=Es(0,this.getData(e.dataSets[0],e.sheetId).length).map((e=>e.toString()))}const s=this.getDefaultConfiguration(e,t),o=new Fh,i=[];if("pie"===e.type){const t=Math.max(...e.dataSets.map((t=>this.getData(t,e.sheetId).length)));for(let e=0;e<=t;e++)i.push(o.next())}for(const[t,n]of Object.entries(e.dataSets)){let r;if(n.labelCell){const e=n.labelCell,s=e?this.getters.getCell(e.sheetId,e.zone.left,e.zone.top):void 0;r=s&&e?this.truncateLabel(s.formattedValue):r=`${Cc.Series} ${parseInt(t)+1}`}else r=r=`${Cc.Series} ${parseInt(t)+1}`;const a="pie"!==e.type?o.next():"#FFFFFF",l={label:r,data:n.dataRange?this.getData(n,e.sheetId):[],lineTension:0,borderColor:a,backgroundColor:a};"pie"===e.type&&(l.backgroundColor=i),s.data.datasets.push(l)}return s}getData(e,t){if(e.dataRange){const t=e.labelCell?[Xs(e.labelCell.zone)]:[],s=so([Xs(e.dataRange.zone)],t)[0];if(void 0===s)return[];const o=this.getters.getRangeFromSheetXC(e.dataRange.sheetId,s);return this.getters.getRangeValues(o)}return[]}}$h.getters=["getChartRuntime"],$h.modes=["normal"];class Dh extends yh{constructor(){super(...arguments),this.isStale=!0,this.computedStyles={},this.computedIcons={},this.uuidGenerator=new Hs,this.rulePredicate={CellIsRule:(e,t)=>{var s,o,i,n,r,l;if(e&&e.evaluated.type===$e.error)return!1;const c=t.values.map(Xr);switch(t.operator){case"IsEmpty":return!_s(e)||""===(null===(s=e.evaluated.value)||void 0===s?void 0:s.toString().trim());case"IsNotEmpty":return _s(e)&&""!==(null===(o=e.evaluated.value)||void 0===o?void 0:o.toString().trim());case"BeginsWith":return!(!e&&""===c[0])&&(_s(e)&&(null===(i=e.evaluated.value)||void 0===i?void 0:i.toString().startsWith(c[0].toString())));case"EndsWith":return!(!e&&""===c[0])&&(_s(e)&&(null===(n=e.evaluated.value)||void 0===n?void 0:n.toString().endsWith(c[0].toString())));case"Between":return _s(e)&&e.evaluated.value>=c[0]&&e.evaluated.value<=c[1];case"NotBetween":return!(_s(e)&&e.evaluated.value>=c[0]&&e.evaluated.value<=c[1]);case"ContainsText":return _s(e)&&(null===(r=e.evaluated.value)||void 0===r?void 0:r.toString().indexOf(c[0].toString()))>-1;case"NotContains":return!_s(e)||!e.evaluated.value||-1==(null===(l=e.evaluated.value)||void 0===l?void 0:l.toString().indexOf(c[0].toString()));case"GreaterThan":return _s(e)&&e.evaluated.value>c[0];case"GreaterThanOrEqual":return _s(e)&&e.evaluated.value>=c[0];case"LessThan":return _s(e)&&e.evaluated.value<c[0];case"LessThanOrEqual":return _s(e)&&e.evaluated.value<=c[0];case"NotEqual":return!(!_s(e)&&""===c[0])&&(_s(e)&&e.evaluated.value!==c[0]);case"Equal":return!e&&""===c[0]||_s(e)&&e.evaluated.value===c[0];default:console.warn(a("Not implemented operator %s for kind of conditional formatting: %s",t.operator,t.type))}return!1}}}handle(e){switch(e.type){case"ACTIVATE_SHEET":const t=e.sheetIdTo;this.computedStyles[t]=this.computedStyles[t]||{},this.computedIcons[t]=this.computedIcons[t]||{},this.isStale=!0;break;case"AUTOFILL_CELL":const s=this.getters.getActiveSheetId(),o=this.getters.getRulesByCell(s,e.originCol,e.originRow);for(const t of o)this.adaptRules(s,t,[ns(e.col,e.row)],[]);break;case"PASTE_CONDITIONAL_FORMAT":this.pasteCf(e.origin,e.target,e.operation);break;case"DUPLICATE_SHEET":case"CREATE_SHEET":case"DELETE_SHEET":case"ADD_CONDITIONAL_FORMAT":case"REMOVE_CONDITIONAL_FORMAT":case"REMOVE_COLUMNS_ROWS":case"ADD_COLUMNS_ROWS":case"EVALUATE_CELLS":case"UPDATE_CELL":case"UNDO":case"REDO":case"DELETE_CELL":case"INSERT_CELL":this.isStale=!0}}finalize(){this.isStale&&(this.computeStyles(),this.isStale=!1)}getConditionalStyle(e,t){var s;const o=this.getters.getActiveSheetId(),i=this.computedStyles[o];return i&&(null===(s=i[e])||void 0===s?void 0:s[t])}getConditionalIcon(e,t){var s;const o=this.getters.getActiveSheetId(),i=this.computedIcons[o];return i&&(null===(s=i[e])||void 0===s?void 0:s[t])}computeStyles(){var e;const t=this.getters.getActiveSheetId();this.computedStyles[t]={},this.computedIcons[t]={};const s=this.computedStyles[t];for(let o of this.getters.getConditionalFormats(t))switch(o.rule.type){case"ColorScaleRule":for(let e of o.ranges)this.applyColorScale(e,o.rule);break;case"IconSetRule":for(let e of o.ranges)this.applyIcon(e,o.rule);break;default:for(let i of o.ranges){const n=qs(i);for(let i=n.top;i<=n.bottom;i++)for(let r=n.left;r<=n.right;r++){const n=this.rulePredicate[o.rule.type];let a=this.getters.getCell(t,r,i);n&&n(a,o.rule)&&(s[r]||(s[r]=[]),s[r][i]=Object.assign((null===(e=s[r])||void 0===e?void 0:e[i])||{},o.rule.style))}}}}parsePoint(e,t,s){switch(t.type){case"value":return this.getters.evaluateFormula(`=${s}(${e})`);case"number":return Number(t.value);case"percentage":const o=this.getters.evaluateFormula(`=min(${e})`);return o+(this.getters.evaluateFormula(`=max(${e})`)-o)*Number(t.value)/100;case"percentile":return this.getters.evaluateFormula(`=PERCENTILE(${e},${Number(t.value)/100})`);case"formula":const i=t.value&&this.getters.evaluateFormula(t.value);return"number"==typeof i?i:null;default:return null}}applyIcon(e,t){const s=this.parsePoint(e,t.lowerInflectionPoint),o=this.parsePoint(e,t.upperInflectionPoint);if(null===s||null===o||s>o)return;const i=qs(e),n=this.getters.getActiveSheetId(),r=this.computedIcons[n],a=[t.icons.upper,t.icons.middle,t.icons.lower];for(let e=i.top;e<=i.bottom;e++)for(let l=i.left;l<=i.right;l++){const i=this.getters.getCell(n,l,e);if((null==i?void 0:i.evaluated.type)!==$e.number)continue;const c=this.computeIcon(i.evaluated.value,o,t.upperInflectionPoint.operator,s,t.lowerInflectionPoint.operator,a);r[l]||(r[l]=[]),r[l][e]=c}}computeIcon(e,t,s,o,i,n){return"ge"===s&&e>=t||"gt"===s&&e>t?n[0]:"ge"===i&&e>=o||"gt"===i&&e>o?n[1]:n[2]}applyColorScale(e,t){var s;const o=this.parsePoint(e,t.minimum,"min"),i=t.midpoint?this.parsePoint(e,t.midpoint):null,n=this.parsePoint(e,t.maximum,"max");if(null===o||null===n||o>=n||i&&(o>=i||i>=n))return;const r=qs(e),a=this.getters.getActiveSheetId(),l=this.computedStyles[a],c=[];t.midpoint&&i?(c.push({minValue:o,minColor:t.minimum.color,colorDiffUnit:this.computeColorDiffUnits(o,i,t.minimum.color,t.midpoint.color)}),c.push({minValue:i,minColor:t.midpoint.color,colorDiffUnit:this.computeColorDiffUnits(i,n,t.midpoint.color,t.maximum.color)})):c.push({minValue:o,minColor:t.minimum.color,colorDiffUnit:this.computeColorDiffUnits(o,n,t.minimum.color,t.maximum.color)});for(let e=r.top;e<=r.bottom;e++)for(let t=r.left;t<=r.right;t++){const r=this.getters.getCell(a,t,e);if((null==r?void 0:r.evaluated.type)===$e.number){const a=ms(r.evaluated.value,o,n);let h;h=2===c.length&&i?a<=i?this.colorCell(a,c[0].minValue,c[0].minColor,c[0].colorDiffUnit):this.colorCell(a,c[1].minValue,c[1].minColor,c[1].colorDiffUnit):this.colorCell(a,c[0].minValue,c[0].minColor,c[0].colorDiffUnit),l[t]||(l[t]=[]),l[t][e]=(null===(s=l[t])||void 0===s?void 0:s[e])||{},l[t][e].fillColor="#"+Yt(h)}}}computeColorDiffUnits(e,t,s,o){const i=t-e;return[((s>>16)%256-(o>>16)%256)/i,((s>>8)%256-(o>>8)%256)/i,(s%256-o%256)/i]}colorCell(e,t,s,o){const[i,n,r]=o;return Math.round((s>>16)%256-i*(e-t))<<16|Math.round((s>>8)%256-n*(e-t))<<8|Math.round(s%256-r*(e-t))}adaptRules(e,t,s,o){if(0===s.length&&0===o.length)return;const i=this.getters.getConditionalFormats(e),n=i.findIndex((e=>e.id===t.id));let r=[];n>-1&&(r=i[n].ranges),r=r.concat(s);const a=so(r,o);0!==a.length?this.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{id:t.id,rule:t.rule,stopIfTrue:t.stopIfTrue},target:a.map(qs),sheetId:e}):this.dispatch("REMOVE_CONDITIONAL_FORMAT",{id:t.id,sheetId:e})}pasteCf(e,t,s){const o=ns(t.col,t.row);for(let i of this.getters.getConditionalFormats(e.sheetId))for(let n of i.ranges)if(to(e.col,e.row,qs(n))){const n=i,r=[];if("CUT"===s&&r.push(ns(e.col,e.row)),e.sheetId===t.sheetId)this.adaptRules(e.sheetId,n,[o],r);else{this.adaptRules(e.sheetId,n,[],r);const s=this.getCFToCopyTo(t.sheetId,n);this.adaptRules(t.sheetId,s,[o],[])}}}getCFToCopyTo(e,t){const s=this.getters.getConditionalFormats(e).find((e=>e.stopIfTrue===t.stopIfTrue&&Fs(e.rule,t.rule)));return s||{...t,id:this.uuidGenerator.uuidv4(),ranges:[]}}}Dh.getters=["getConditionalStyle","getConditionalIcon"],Dh.modes=["normal"];var Ph;!function(e){e[e.previous=-1]="previous",e[e.current=0]="current",e[e.next=1]="next"}(Ph||(Ph={}));class Uh extends yh{constructor(){super(...arguments),this.searchMatches=[],this.selectedMatchIndex=null,this.currentSearchRegex=null,this.searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1},this.replaceOptions={modifyFormulas:!1},this.toSearch=""}handle(e){switch(e.type){case"UPDATE_SEARCH":this.updateSearch(e.toSearch,e.searchOptions);break;case"CLEAR_SEARCH":case"UNDO":case"REDO":case"REMOVE_COLUMNS_ROWS":case"ADD_COLUMNS_ROWS":this.clearSearch();break;case"SELECT_SEARCH_PREVIOUS_MATCH":this.selectNextCell(Ph.previous);break;case"SELECT_SEARCH_NEXT_MATCH":this.selectNextCell(Ph.next);break;case"REPLACE_SEARCH":this.replace(e.replaceWith,e.replaceOptions);break;case"REPLACE_ALL_SEARCH":this.replaceAll(e.replaceWith,e.replaceOptions);break;case"ACTIVATE_SHEET":case"REFRESH_SEARCH":this.refreshSearch()}}getSearchMatches(){return this.searchMatches}getCurrentSelectedMatchIndex(){return this.selectedMatchIndex}updateSearch(e,t){this.searchOptions=t,e!==this.toSearch&&(this.selectedMatchIndex=null),this.toSearch=e,this.updateRegex(),this.refreshSearch()}refreshSearch(){const e=this.findMatches();this.searchMatches=e,this.selectNextCell(Ph.current)}updateRegex(){let e=ps(this.toSearch);const t=this.searchOptions.matchCase?"":"i";this.searchOptions.exactMatch&&(e=`^${e}$`),this.currentSearchRegex=RegExp(e,t)}findMatches(){const e=this.getters.getActiveSheetId(),t=this.getters.getCells(e),s=[];if(this.toSearch)for(const e of Object.values(t))if(e&&this.currentSearchRegex&&this.currentSearchRegex.test(this.searchOptions.searchFormulas&&e.isFormula()?e.content:String(e.evaluated.value))){const t=this.getters.getCellPosition(e.id),o={col:t.col,row:t.row,selected:!1};s.push(o)}return s.sort(this.sortByRowThenColumn)}sortByRowThenColumn(e,t){return e.row===t.row?e.col-t.col:e.row>t.row?1:-1}selectNextCell(e){const t=this.searchMatches;if(!t.length)return void(this.selectedMatchIndex=null);let s;s=null===this.selectedMatchIndex?0:this.selectedMatchIndex+e,s=(s%t.length+t.length)%t.length,null!==this.selectedMatchIndex&&this.selectedMatchIndex===s||(this.selectedMatchIndex=s,this.dispatch("SELECT_CELL",{col:t[s].col,row:t[s].row}));for(let e=0;e<this.searchMatches.length;e++)this.searchMatches[e].selected=e===this.selectedMatchIndex}clearSearch(){this.toSearch="",this.searchMatches=[],this.selectedMatchIndex=null,this.currentSearchRegex=null,this.searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1},this.replaceOptions={modifyFormulas:!1}}replace(e,t){if(this.replaceOptions=t,null===this.selectedMatchIndex||!this.currentSearchRegex)return;const s=this.searchMatches[this.selectedMatchIndex],o=this.getters.getActiveSheetId(),i=this.getters.getCell(o,s.col,s.row),n=this.toReplace(i,o);if(i&&n){const t=new RegExp(this.currentSearchRegex.source,this.currentSearchRegex.flags+"g"),o=n.toString().replace(t,e);this.dispatch("UPDATE_CELL",{sheetId:this.getters.getActiveSheetId(),col:s.col,row:s.row,content:o}),this.searchMatches.splice(this.selectedMatchIndex,1),this.selectNextCell(Ph.current)}else this.selectNextCell(Ph.next)}replaceAll(e,t){const s=this.searchMatches.length;for(let o=0;o<s;o++)this.replace(e,t)}toReplace(e,t){if(e){if(this.searchOptions.searchFormulas&&e.isFormula())return e.content;if(this.replaceOptions.modifyFormulas||!e.isFormula())return e.evaluated.value.toString()}return null}drawGrid(e){const{ctx:t,viewport:s}=e,o=this.getters.getActiveSheetId();for(const e of this.searchMatches){const i=this.getters.getMerge(o,e.col,e.row),n=i?i.left:e.col,r=i?i.right:e.col,a=i?i.top:e.row,l=i?i.bottom:e.row,[c,h,d,u]=this.getters.getRect({top:a,left:n,right:r,bottom:l},s);d>0&&u>0&&(t.fillStyle="#8B008B33",t.fillRect(c,h,d,u),e.selected&&(t.strokeStyle="#8B008B",t.strokeRect(c,h,d,u)))}}}Uh.layers=[3],Uh.getters=["getSearchMatches","getCurrentSelectedMatchIndex"];class Vh extends yh{handle(e){if("SET_DECIMAL"===e.type)this.setDecimal(e.sheetId,e.target,e.step)}setDecimal(e,t,s){const o=this.searchNumberFormat(e,t);if(void 0!==o){const i=this.changeDecimalFormat(o,s);this.dispatch("SET_FORMATTING",{sheetId:e,target:t,format:i})}}searchNumberFormat(e,t){var s;for(let o of t)for(let t=o.top;t<=o.bottom;t++)for(let i=o.left;i<=o.right;i++){const o=this.getters.getCell(e,i,t);if((null==o?void 0:o.evaluated.type)===$e.number&&!(null===(s=o.format)||void 0===s?void 0:s.match(_)))return o.format||this.setDefaultNumberFormat(o.evaluated.value)}}setDefaultNumberFormat(e){const t=e.toString().split(".");return 1===t.length?"0":"0."+Array(t[1].length+1).join("0")}changeDecimalFormat(e,t){const s=Math.sign(t),o=e.split(";");let i=[];for(let e of o){const t=e.indexOf("."),o=e.toUpperCase().indexOf("E");let n;const r=o>-1?e.slice(0,o):e,a=t>-1?r.slice(t).match(/0/g).length:0,l=r.lastIndexOf("0");l>-1?s>0?n=a<ae?e.slice(0,l+1)+(0===a?".0":"0")+e.slice(l+1):e:a>0?(n=e.slice(0,l)+e.slice(l+1),1===a&&(n=n.slice(0,t)+n.slice(t+1))):n=e:n=e,i.push(n)}return i.join(";")}}Vh.modes=["normal"];class Bh extends yh{getHighlights(){return this.prepareHighlights(this.getters.getComposerHighlights().concat(this.getters.getSelectionInputHighlights()))}prepareHighlights(e){if(0===e.length)return[];const t=this.getters.getActiveSheetId(),s=[];for(let[o,i]of e){const{xc:e,sheetName:n}=ss(o),r=n?this.getters.getSheetIdByName(n):t;if(r){let o=qs(e);const{height:n,width:a}=io(o);o=n*a==1?this.getters.expandZone(t,qs(e)):o,s.push({zone:o,color:i,sheet:r})}}return s.filter((e=>e.zone.top>=0&&e.zone.left>=0&&e.zone.bottom<this.getters.getSheet(e.sheet).rows.length&&e.zone.right<this.getters.getSheet(e.sheet).cols.length))}drawGrid(e){const{ctx:t,viewport:s,thinLineWidth:o}=e,i=this.getters.getActiveSheetId(),n=3*o;t.lineWidth=n;for(let e of this.getHighlights().filter(((e,t)=>this.getHighlights().findIndex((t=>Js(t.zone,e.zone)&&t.sheet===i))===t))){const[o,i,r,a]=this.getters.getRect(e.zone,s);r>0&&a>0&&(t.strokeStyle=e.color,t.strokeRect(o+n/2,i+n/2,r-n,a-n),t.globalCompositeOperation="source-over",t.fillStyle=e.color+"20",t.fillRect(o+n,i+n,r-2*n,a-2*n))}}}function Hh(e,t){let s=0,o=e.length-1;for(;s<=o;){const i=Math.floor((s+o)/2),n=e[i];if(t<n.start)o=i-1;else if(t>n.end)s=i+1;else{if(!n.isHidden)return i;s+=1}}return-1}Bh.modes=["normal"],Bh.layers=[1],Bh.getters=["getHighlights"];class zh extends yh{constructor(){super(...arguments),this.boxes=[]}getColIndex(e,t,s){if(e<v)return-1;const o=(s||this.getters.getActiveSheet()).cols;return Hh(o,e-v+o[t].start+1)}getRowIndex(e,t,s){if(e<m)return-1;const o=(s||this.getters.getActiveSheet()).rows;return Hh(o,e-m+o[t].start+1)}getRect(e,t){const{left:s,top:o,right:i,bottom:n}=e,{offsetX:r,offsetY:a}=this.getShiftedViewport(t),{cols:l,rows:c}=this.getters.getActiveSheet(),h=Math.max(l[s].start-r,v),d=l[i].end-r-h,u=Math.max(c[o].start-a,m);return[h,u,d,c[n].end-a-u]}isVisibleInViewport(e,t,s){const{right:o,left:i,top:n,bottom:r}=s;return t<=r&&t>=n&&e>=i&&e<=o}getEdgeScrollCol(e){let t=!1,s=0,o=0;const{width:i}=this.getters.getViewportDimensionWithHeaders(),{width:n}=this.getters.getMaxViewportSize(this.getters.getActiveSheet()),{left:r,offsetX:a}=this.getters.getActiveSnappedViewport();return e<v&&r>0?(t=!0,s=-1,o=cs(v-e)):e>i&&a<n-i&&(t=!0,s=1,o=cs(e-i)),{canEdgeScroll:t,direction:s,delay:o}}getEdgeScrollRow(e){let t=!1,s=0,o=0;const{height:i}=this.getters.getViewportDimensionWithHeaders(),{height:n}=this.getters.getMaxViewportSize(this.getters.getActiveSheet()),{top:r,offsetY:a}=this.getters.getActiveSnappedViewport();return e<m&&r>0?(t=!0,s=-1,o=cs(m-e)):e>i&&a<n-i&&(t=!0,s=1,o=cs(e-i)),{canEdgeScroll:t,direction:s,delay:o}}drawGrid(e,t){switch(t){case 0:this.boxes=this.getGridBoxes(e),this.drawBackground(e),this.drawCellBackground(e),this.drawBorders(e),this.drawTexts(e),this.drawIcon(e);break;case 7:this.drawHeaders(e)}}drawBackground(e){const{ctx:t,thinLineWidth:s,viewport:o}=e,{width:i,height:n}=this.getters.getViewportDimensionWithHeaders(),{cols:r,rows:a,id:l}=this.getters.getActiveSheet();t.fillStyle="white",t.fillRect(0,0,i,n);const{right:c,left:h,top:d,bottom:u,offsetX:p,offsetY:g}=this.getShiftedViewport(o);if(!this.getters.getGridLinesVisibility(l))return;t.lineWidth=2*s,t.strokeStyle="#E2E3E3",t.beginPath();const f=Math.min(n,a[u].end-g);for(let e=h;e<=c;e++){if(r[e].isHidden)continue;const s=r[e].end-p;t.moveTo(s,0),t.lineTo(s,f)}const m=Math.min(i,r[c].end-p);for(let e=d;e<=u;e++){if(a[e].isHidden)continue;const s=a[e].end-g;t.moveTo(0,s),t.lineTo(m,s)}t.stroke()}drawCellBackground(e){const{ctx:t,thinLineWidth:s}=e;t.lineWidth=.3*s;const o=.1*s;t.strokeStyle="#111";const i=this.getters.getGridLinesVisibility(this.getters.getActiveSheetId());for(let e of this.boxes){let s=e.style;(s.fillColor&&"#ffffff"!==s.fillColor||e.isMerge)&&(t.fillStyle=s.fillColor||"#ffffff",t.fillRect(e.x,e.y,e.width,e.height),i&&t.strokeRect(e.x+o,e.y+o,e.width-2*o,e.height-2*o)),e.error&&(t.fillStyle="red",t.beginPath(),t.moveTo(e.x+e.width-5,e.y),t.lineTo(e.x+e.width,e.y),t.lineTo(e.x+e.width,e.y+5),t.fill())}}drawBorders(e){const{ctx:t,thinLineWidth:s}=e;for(let e of this.boxes){let t=e.border;if(t){const{x:s,y:i,width:n,height:r}=e;t.left&&o(t.left,s,i,s,i+r),t.top&&o(t.top,s,i,s+n,i),t.right&&o(t.right,s+n,i,s+n,i+r),t.bottom&&o(t.bottom,s,i+r,s+n,i+r)}}function o([e,o],i,n,r,a){t.strokeStyle=o,t.lineWidth=("thin"===e?2:3)*s,t.beginPath(),t.moveTo(i,n),t.lineTo(r,a),t.stroke()}}drawTexts(e){const{ctx:t,thinLineWidth:s}=e;let o;t.textBaseline="middle";for(let e of this.boxes)if(e.content){const i=e.style||{},n=e.content.align||"left",r=i.italic?"italic ":"",a=i.bold?"bold":T,l=i.fontSize||R,c=ds[l],h=`${r}${a} ${c}px ${L}`;let d;h!==o&&(o=h,t.font=h),t.fillStyle=i.textColor||"#000";let u=e.y+e.height/2+1;d="left"===n?e.x+(e.image?e.image.size+2*w:4):"right"===n?e.x+e.width-4:e.x+e.width/2,t.textAlign=n,e.clipRect&&(t.save(),t.beginPath(),t.rect(...e.clipRect),t.clip()),t.fillText(e.content.text,Math.round(d),Math.round(u)),(i.strikethrough||i.underline)&&("right"===n?d-=e.content.width:"center"===n&&(d-=e.content.width/2),i.strikethrough&&t.fillRect(d,u,e.content.width,2.6*s),i.underline&&(u=e.y+e.height/2+1+c/2,t.fillRect(d,u,e.content.width,1.3*s))),e.clipRect&&t.restore()}}drawIcon(e){const{ctx:t}=e;for(const e of this.boxes)if(e.image){const s=e.image.image,o=e.image.size,i=(e.height-o)/2;e.image.clipIcon&&(t.save(),t.beginPath(),t.rect(...e.image.clipIcon),t.clip()),t.drawImage(s,e.x+w,e.y+i,o,o),e.image.clipIcon&&t.restore()}}drawHeaders(e){const{ctx:t,thinLineWidth:s,viewport:o}=e,{right:i,left:n,top:r,bottom:a,offsetX:l,offsetY:p}=this.getShiftedViewport(o),{width:g,height:f}=this.getters.getViewportDimensionWithHeaders(),E=this.getters.getSelectedZones(),{cols:b,rows:S}=this.getters.getActiveSheet(),C=this.getters.getActiveCols(),y=this.getters.getActiveRows();t.fillStyle=c,t.font=`400 11px ${L}`,t.textAlign="center",t.textBaseline="middle",t.lineWidth=s,t.strokeStyle="#333",t.fillRect(0,0,g,m),t.fillRect(0,0,v,f),t.fillStyle=h;for(let e of E){const s=Math.max(v,b[e.left].start-l),o=Math.max(v,b[e.right].end-l),i=Math.max(m,S[e.top].start-p),n=Math.max(m,S[e.bottom].end-p);t.fillStyle=C.has(e.left)?d:h,t.fillRect(s,0,o-s,m),t.fillStyle=y.has(e.top)?d:h,t.fillRect(0,i,v,n-i)}t.beginPath(),t.moveTo(v,0),t.lineTo(v,f),t.moveTo(0,m),t.lineTo(g,m),t.strokeStyle="#C0C0C0",t.stroke(),t.beginPath();for(let e=n;e<=i;e++){const s=b[e];s.isHidden||(t.fillStyle=C.has(e)?"#fff":u,t.fillText(s.name,(s.start+s.end)/2-l,13),t.moveTo(s.end-l,0),t.lineTo(s.end-l,m))}for(let e=r;e<=a;e++){const s=S[e];s.isHidden||(t.fillStyle=y.has(e)?"#fff":u,t.fillText(s.name,24,(s.start+s.end)/2-p),t.moveTo(0,s.end-p),t.lineTo(v,s.end-p))}t.stroke()}hasContent(e,t){const s=this.getters.getActiveSheetId(),o=this.getters.getCell(s,e,t);return o&&!o.isEmpty()||this.getters.isInMerge(s,e,t)}getShiftedViewport(e){return{...e,offsetX:e.offsetX-v,offsetY:e.offsetY-m}}findNextEmptyCol(e,t,s){let o=e;for(;o<t&&!this.hasContent(o+1,s);)o++;return o}findPreviousEmptyCol(e,t,s){let o=e;for(;o>t&&!this.hasContent(o-1,s);)o--;return o}computeCellAlignment(e,t){if(e.isFormula()&&this.getters.shouldShowFormulas())return"left";const{align:s}=this.getters.getCellStyle(e);return t&&e.evaluated.type===$e.number?"center"!==s?"left":s:s||e.defaultAlign}createBoxFromPosition(e,t,s,o,i,n){const{right:r,left:a,offsetX:l,offsetY:c}=this.getShiftedViewport(o),h=this.getters.getCol(e,t),d=this.getters.getRow(e,s),u=this.getters.getCell(e,t,s),p=this.getters.shouldShowFormulas(),g={x:h.start-l,y:d.start-c,width:i,height:n,border:this.getters.getCellBorder(e,t,s)||void 0,style:{...this.getters.getCellStyle(u),...this.getters.getConditionalStyle(t,s)}};if(!u)return g;const f=this.getters.getConditionalIcon(t,s),m=g.style.fontSize||R,v=ds[m],E=f?2*w+v:0;f&&(g.image={type:"icon",size:v,clipIcon:[g.x,g.y,Math.min(E,i),n],image:Yl[f].img});const b=this.getters.getCellText(u,p),S=this.getters.getTextWidth(u),C=E+S,y=this.computeCellAlignment(u,C>i);g.content={text:b,width:S,align:y},u.evaluated.type===$e.error&&(g.error=u.evaluated.error);const I=C>i||ds[m]>n;if(f)g.clipRect=[g.x+E,g.y,Math.max(0,i-E),n];else if(I){let o,u;switch(this.getters.isInMerge(e,t,s)?(o=this.getters.getMerge(e,t,s).right,u=t):(o=this.findNextEmptyCol(t,r,s),u=this.findPreviousEmptyCol(t,a,s)),y){case"left":{const t=this.getters.getCol(e,o).end-h.start;(t<S||v>d.size)&&(g.clipRect=[h.start-l,d.start-c,t,n]);break}case"right":{const t=this.getters.getCol(e,u),s=h.end+i-h.size-t.start;(s<S||v>d.size)&&(g.clipRect=[t.start-l,d.start-c,s,n]);break}case"center":{const s=this.getters.getCol(e,u),i=this.getters.getCol(e,o).end-s.start;(i<S||u===t||o===t||v>d.size)&&(g.clipRect=[s.start-l,d.start-c,i,n]);break}}}return g}getGridBoxes(e){const t=[],{viewport:s}=e,{right:o,left:i,top:n,bottom:r}=this.getShiftedViewport(s),a=this.getters.getActiveSheetId();for(let e=n;e<=r;e++){const n=this.getters.getRow(a,e);if(!n.isHidden)for(let r=i;r<=o;r++){const o=this.getters.getCol(a,r);o.isHidden||(this.getters.isInMerge(a,r,e)||t.push(this.createBoxFromPosition(a,r,e,s,o.size,n.size)))}}for(const e of this.getters.getMerges(a))if(!this.getters.isMergeHidden(a,e)&&eo(e,s)){const o=this.getters.getCol(a,e.right).end-this.getters.getCol(a,e.left).start,i=this.getters.getRow(a,e.bottom).end-this.getters.getRow(a,e.top).start,n=this.createBoxFromPosition(a,e.left,e.top,s,o,i),r=this.getters.getCellBorder(a,e.right,e.bottom);n.border={...n.border,bottom:r?r.bottom:void 0,right:r?r.right:void 0},n.isMerge=!0,t.push(n)}return t}}zh.layers=[0,7],zh.getters=["getColIndex","getRowIndex","getRect","isVisibleInViewport","getEdgeScrollCol","getEdgeScrollRow"],zh.modes=["normal"];const Zh=new Hs;class Gh extends yh{constructor(){super(...arguments),this.inputs={},this.activeSheets={},this.inputHasSingleRange={},this.focusedInputId=null,this.focusedRange=null,this.willAddNewRange=!1}allowDispatch(e){switch(e.type){case"FOCUS_RANGE":const t=this.getIndex(e.id,e.rangeId);if(this.focusedInputId===e.id&&this.focusedRange===t)return 24;break;case"ADD_EMPTY_RANGE":if(this.inputHasSingleRange[e.id]&&1===this.inputs[e.id].length)return 25}return 0}handle(e){switch(e.type){case"ENABLE_NEW_SELECTION_INPUT":this.initInput(e.id,e.initialRanges||[],e.hasSingleRange);break;case"DISABLE_SELECTION_INPUT":this.focusedInputId===e.id&&this.unfocus(),delete this.inputs[e.id],delete this.activeSheets[e.id],delete this.inputHasSingleRange[e.id];break;case"UNFOCUS_SELECTION_INPUT":this.unfocus();break;case"FOCUS_RANGE":this.focus(e.id,this.getIndex(e.id,e.rangeId));break;case"CHANGE_RANGE":{const t=this.getIndex(e.id,e.rangeId);if(null!==t){const s=e.id;this.focusedInputId===s&&this.focusedRange===t||this.dispatch("FOCUS_RANGE",{id:s,rangeId:this.inputs[s][t].id});const o=e.value.split(",").map((e=>e.trim()));this.setRange(s,t,o)}break}case"ADD_EMPTY_RANGE":this.insertNewRange(e.id,this.inputs[e.id].length,[""]),this.focusLast(e.id);break;case"REMOVE_RANGE":const t=this.getIndex(e.id,e.rangeId);null!==t&&this.removeRange(e.id,t);break;case"SELECT_CELL":case"SET_SELECTION":if(!this.focusedInputId)break;const s=this.getSelectionInputValue(this.focusedInputId),o=(this.inputHasSingleRange[this.focusedInputId]?[this.getters.getSelectedZone()]:this.getters.getSelectedZones()).map(Xs).filter((e=>!s.includes(e))),i=this.activeSheets[this.focusedInputId],n=this.getters.getActiveSheetId(),r=this.getters.getSheetName(n);this.add(o.map((e=>n===i?e:`${fs(r)}!${e}`)));break;case"PREPARE_SELECTION_EXPANSION":{const[e,t]=[this.focusedInputId,this.focusedRange];null===e||null===t||this.inputHasSingleRange[e]||(this.willAddNewRange=""!==this.inputs[e][t].xc.trim());break}}}getSelectionInput(e){return this.inputs[e]?this.inputs[e].map(((t,s)=>Object.assign({},t,{color:this.focusedInputId===e&&null!==this.focusedRange&&this.isRangeValid(t.xc)?t.color:null,isFocused:this.focusedInputId===e&&this.focusedRange===s}))):[]}isRangeValid(e){if(!e)return!1;const{xc:t,sheetName:s}=ss(e);return null!==t.match(ts)&&(!s||void 0!==this.getters.getSheetIdByName(s))}getSelectionInputValue(e){return this.cleanInputs(this.inputs[e].map((e=>e.xc?e.xc:"")))}getSelectionInputHighlights(){return this.focusedInputId?this.inputs[this.focusedInputId].map((e=>this.inputToHighlights(this.focusedInputId,e))).flat():[]}initInput(e,t,s=!1){this.inputs[e]=[],this.insertNewRange(e,0,t),this.activeSheets[e]=this.getters.getActiveSheetId(),this.inputHasSingleRange[e]=s,0===this.inputs[e].length&&this.dispatch("ADD_EMPTY_RANGE",{id:e})}focus(e,t){this.focusedInputId=e,this.focusedRange=t}focusLast(e){this.focus(e,this.inputs[e].length-1)}unfocus(){this.focusedInputId=null,this.focusedRange=null}add(e){if(null===this.focusedInputId||null===this.focusedRange||this.getters.isSelectingForComposer()||0===e.length)return;if(this.getters.getSelectionMode()===Lh.expanding&&this.willAddNewRange){const t=this.focusedInputId;this.insertNewRange(t,this.inputs[t].length,e),this.focusLast(this.focusedInputId),this.willAddNewRange=!1}else this.setRange(this.focusedInputId,this.focusedRange,e)}setContent(e,t,s){this.inputs[e][t]={...this.inputs[e][t],id:Zh.uuidv4(),xc:s}}insertNewRange(e,t,s){this.inputs[e].splice(t,0,...s.map(((t,s)=>({xc:t,id:(this.inputs[e].length+s+1).toString(),color:Qt()}))))}setRange(e,t,s){const[,...o]=s;this.setContent(e,t,s[0]),this.insertNewRange(e,t+1,o),o.length&&this.focus(e,t+o.length)}removeRange(e,t){this.inputs[e].splice(t,1),this.focusedInputId===e&&null!==this.focusedRange&&this.focusLast(e)}inputToHighlights(e,{xc:t,color:s}){const o=this.cleanInputs([t]).filter((e=>this.isRangeValid(e))).filter((t=>this.shouldBeHighlighted(this.activeSheets[e],t)));if(0===o.length)return[];const[i,...n]=o,r=[[i,s||Qt()]];for(const e of n)r.push([e,Qt()]);return r}cleanInputs(e){return e.map((e=>e.split(","))).flat().map((e=>e.trim())).filter((e=>""!==e))}shouldBeHighlighted(e,t){const{sheetName:s}=ss(t),o=this.getters.getSheetIdByName(s),i=this.getters.getActiveSheet().id;return this.isRangeValid(t)&&(o===i||void 0===o&&i===e)}getIndex(e,t){const s=this.inputs[e].findIndex((e=>e.id===t));return s>=0?s:null}}Gh.modes=["normal"],Gh.layers=[1],Gh.getters=["getSelectionInput","getSelectionInputValue","isRangeValid","getSelectionInputHighlights"];class Wh{constructor(){this.bus=new o.core.EventBus}on(e,t,s){this.bus.on(e,t,s)}trigger(e,t){this.bus.trigger(e,t)}off(e,t){this.bus.off(e,t)}clear(){this.bus.clear()}}function qh(e,t){return"REMOVE_COLUMNS_ROWS"===t.type?function(e,t,s){const o="left"===t?"right":"bottom";let i=e[t],n=e[o];for(let r of s.sort(((e,t)=>t-e)))e[t]>r&&(i--,n--),e[t]<=r&&e[o]>=r&&n--;if(!(i>n))return{...e,[t]:i,[o]:n}}(e,"COL"===t.dimension?"left":"top",t.elements):"ADD_COLUMNS_ROWS"===t.type?function(e,t,s,o,i){const n="left"===t?"columns":"rows",r="before"===o?s-1:s,a="left"===t?"right":"bottom",l="before"===o?e[a]>r:e[a]>=r;return e[t]<=r&&l?ao(e,n,"RESIZE",i):r<e[t]?ao(e,n,"MOVE",i):{...e}}(e,"COL"===t.dimension?"left":"top",t.base,t.position,t.quantity):{...e}}function jh(e,t){const s=e.definition;let o,i;return s.labelRange&&(o=qh(qs(s.labelRange),t)),s.dataSets&&(i=s.dataSets.map(qs).map((e=>qh(e,t))).filter(_s).map(Xs)),{...e,definition:{...s,dataSets:i,labelRange:o?Xs(o):void 0}}}yl.addTransformation("ADD_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],jh),yl.addTransformation("REMOVE_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],jh),yl.addTransformation("DELETE_FIGURE",["UPDATE_FIGURE","UPDATE_CHART"],(function(e,t){if(e.id===t.id)return;return e})),yl.addTransformation("CREATE_SHEET",["CREATE_SHEET"],(function(e,t){var s;if(e.name===t.name)return{...e,name:(null===(s=e.name)||void 0===s?void 0:s.match(/\d+/))?e.name.replace(/\d+/,(e=>(parseInt(e)+1).toString())):`${e.name}~`,position:e.position+1};return e})),yl.addTransformation("ADD_MERGE",["ADD_MERGE","REMOVE_MERGE"],(function(e,t){if(e.sheetId!==t.sheetId)return e;const s=[];for(const o of e.target)for(const e of t.target)eo(o,e)||s.push({...o});if(s.length)return{...e,target:s};return}));const Xh=[{match:function(e){return"sheetId"in e},fn:function(e,t){const s="DELETE_SHEET"===t.type&&t.sheetId;if(e.sheetId===s)return"IGNORE_COMMAND";if("CREATE_SHEET"===e.type||"CREATE_SHEET"===t.type||e.sheetId!==t.sheetId)return e;return"SKIP_TRANSFORMATION"}},{match:function(e){return"target"in e},fn:function(e,t){const s=[];for(const o of e.target){const e=qh(o,t);e&&s.push(e)}if(!s.length)return"IGNORE_COMMAND";return{...e,target:s}}},{match:function(e){return"col"in e&&"row"in e},fn:function(e,t){if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type)return function(e,t){const s="COL"===t.dimension?"col":"row";let o=e[s];if("REMOVE_COLUMNS_ROWS"===t.type){const e=[...t.elements].sort(((e,t)=>t-e));if(e.includes(o))return"IGNORE_COMMAND";for(let t of e)o>=t&&o--}"ADD_COLUMNS_ROWS"===t.type&&(o>t.base||o===t.base&&"before"===t.position)&&(o+=t.quantity);return{...e,[s]:o}}(e,t);if("ADD_MERGE"===t.type)return function(e,t){for(const s of t.target){if(!(e.col===s.left&&e.row===s.top)&&to(e.col,e.row,s))return"IGNORE_COMMAND"}return e}(e,t);return"SKIP_TRANSFORMATION"}},{match:function(e){return"dimension"in e},fn:function(e,t){if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type){if(t.dimension!==e.dimension)return e;const s="ADD_COLUMNS_ROWS"===e.type,o=s?"base":"elements";let i=s?[e[o]]:e[o];if("REMOVE_COLUMNS_ROWS"===t.type&&(i=i.map((e=>{if(t.elements.includes(e))return;const s=t.elements.sort(((e,t)=>t-e));for(let t of s)e>t&&e--;return e})).filter(_s)),"ADD_COLUMNS_ROWS"===t.type){const e="before"===t.position?t.base-1:t.base;i=i.map((s=>s>e?s+t.quantity:s))}if(i.length){let t=i;return s&&(t=i[0]),{...e,[o]:t}}return"IGNORE_COMMAND"}return"SKIP_TRANSFORMATION"}}];function Yh(e,t){const s=yl.getTransformation(e.type,t.type);return s?s(e,t):function(e,t){for(const{match:s,fn:o}of Xh)if(s(e)){const s=o(e,t);if("SKIP_TRANSFORMATION"===s)continue;if("IGNORE_COMMAND"===s)return;return s}return e}(e,t)}function Kh(e,t){let s=[...e];for(const e of t)s=s.map((t=>Yh(t,e))).filter(_s);return s}class Qh{constructor(e,t,s,o){this._commands=[],this._changes=[],this.id=e,this.clientId=t,this._commands=[...s],this._changes=o?[...o]:[]}setChanges(e){this._changes=e}get commands(){return this._commands}get changes(){return this._changes}}class Jh extends Error{}class ed extends Wh{constructor(e,t,s=N){super(),this.revisions=e,this.transportService=t,this.serverRevisionId=s,this.clients={},this.clientId="local",this.pendingMessages=[],this.waitingAck=!1,this.waitingUndoRedoAck=!1,this.isReplayingInitialRevisions=!1,this.processedRevisions=new Set,this.uuidGenerator=new Hs,this.debouncedMove=o.utils.debounce(this._move.bind(this),200)}canApplyOptimisticUpdate(){return!this.waitingUndoRedoAck}save(e,t){if(!e.length||!t.length||!this.canApplyOptimisticUpdate())return;const s=new Qh(this.uuidGenerator.uuidv4(),this.clientId,e,t);this.revisions.append(s.id,s),this.trigger("new-local-state-update",{id:s.id}),this.sendUpdateMessage({type:"REMOTE_REVISION",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:s.id,clientId:s.clientId,commands:s.commands})}undo(e){this.waitingUndoRedoAck=!0,this.sendUpdateMessage({type:"REVISION_UNDONE",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:this.uuidGenerator.uuidv4(),undoneRevisionId:e})}redo(e){this.waitingUndoRedoAck=!0,this.sendUpdateMessage({type:"REVISION_REDONE",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:this.uuidGenerator.uuidv4(),redoneRevisionId:e})}move(e){this.debouncedMove(e)}join(e){e?(this.clients[e.id]=e,this.clientId=e.id):(this.clients.local={id:"local",name:"local"},this.clientId="local"),this.transportService.onNewMessage(this.clientId,this.onMessageReceived.bind(this))}loadInitialMessages(e){this.isReplayingInitialRevisions=!0;for(const t of e)this.onMessageReceived(t);this.isReplayingInitialRevisions=!1}leave(){delete this.clients[this.clientId],this.transportService.leave(this.clientId),this.transportService.sendMessage({type:"CLIENT_LEFT",clientId:this.clientId,version:1})}snapshot(e){const t=this.uuidGenerator.uuidv4();this.transportService.sendMessage({type:"SNAPSHOT",nextRevisionId:t,serverRevisionId:this.serverRevisionId,data:{...e,revisionId:t},version:1})}getClient(){const e=this.clients[this.clientId];if(!e)throw new Jh("The client left the session");return e}getConnectedClients(){return new Set(Object.values(this.clients).filter(_s))}getRevisionId(){return this.serverRevisionId}isFullySynchronized(){return 0===this.pendingMessages.length}_move(e){var t;if(!this.clients[this.clientId])return;const s=null===(t=this.clients[this.clientId])||void 0===t?void 0:t.position;if((null==s?void 0:s.col)===e.col&&s.row===e.row&&s.sheetId===e.sheetId)return;const o=s?"CLIENT_MOVED":"CLIENT_JOINED",i=this.getClient();this.clients[this.clientId]={...i,position:e},this.transportService.sendMessage({type:o,version:1,client:{...i,position:e}})}onMessageReceived(e){if(!this.isAlreadyProcessed(e))if(this.isWrongServerRevisionId(e))this.trigger("unexpected-revision-id");else{switch(e.type){case"CLIENT_MOVED":this.onClientMoved(e);break;case"CLIENT_JOINED":this.onClientJoined(e);break;case"CLIENT_LEFT":this.onClientLeft(e);break;case"REVISION_REDONE":this.revisions.redo(e.redoneRevisionId,e.nextRevisionId,e.serverRevisionId),this.trigger("revision-redone",{revisionId:e.redoneRevisionId,commands:this.revisions.get(e.redoneRevisionId).commands});break;case"REVISION_UNDONE":this.revisions.undo(e.undoneRevisionId,e.nextRevisionId,e.serverRevisionId),this.trigger("revision-undone",{revisionId:e.undoneRevisionId,commands:this.revisions.get(e.undoneRevisionId).commands});break;case"REMOTE_REVISION":const{clientId:t,commands:s}=e,o=new Qh(e.nextRevisionId,t,s);if(o.clientId!==this.clientId){this.revisions.insert(o.id,o,e.serverRevisionId);const t=this.pendingMessages.filter((e=>"REMOTE_REVISION"===e.type)).map((e=>e.commands)).flat();this.trigger("remote-revision-received",{commands:Kh(s,t)})}break;case"SNAPSHOT_CREATED":{const t=new Qh(e.nextRevisionId,"server",[]);this.revisions.insert(t.id,t,e.serverRevisionId),this.dropPendingHistoryMessages(),this.trigger("snapshot");break}}this.acknowledge(e),this.trigger("collaborative-event-received")}}onClientMoved(e){e.client.id!==this.clientId&&(this.clients[e.client.id]=e.client)}onClientJoined(e){if(e.client.id!==this.clientId){this.clients[e.client.id]=e.client;const t=this.clients[this.clientId];if(t){const{position:e}=t;e&&this.transportService.sendMessage({type:"CLIENT_MOVED",version:1,client:{...t,position:e}})}}}onClientLeft(e){e.clientId!==this.clientId&&delete this.clients[e.clientId]}sendUpdateMessage(e){this.pendingMessages.push(e),this.waitingAck||(this.waitingAck=!0,this.sendPendingMessage())}sendPendingMessage(){let e=this.pendingMessages[0];if(e){if("REMOTE_REVISION"===e.type){const t=this.revisions.get(e.nextRevisionId);if(0===t.commands.length){this.revisions.drop(t.id);const e=this.pendingMessages.filter((e=>"REMOTE_REVISION"===e.type)).map((e=>e.nextRevisionId));return this.trigger("pending-revisions-dropped",{revisionIds:e}),this.waitingAck=!1,this.waitingUndoRedoAck=!1,void(this.pendingMessages=[])}e={...e,clientId:t.clientId,commands:t.commands}}if(this.isReplayingInitialRevisions)throw new Error(`Trying to send a new revision while replaying initial revision. This can lead to endless dispatches every time the spreadsheet is open.\n ${JSON.stringify(e)}`);this.transportService.sendMessage({...e,serverRevisionId:this.serverRevisionId})}}acknowledge(e){switch("REVISION_UNDONE"!==e.type&&"REVISION_REDONE"!==e.type||(this.waitingUndoRedoAck=!1),e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":case"SNAPSHOT_CREATED":this.waitingAck=!1,this.pendingMessages=this.pendingMessages.filter((t=>t.nextRevisionId!==e.nextRevisionId)),this.serverRevisionId=e.nextRevisionId,this.processedRevisions.add(e.nextRevisionId),this.sendPendingMessage()}}isAlreadyProcessed(e){switch(e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":return this.processedRevisions.has(e.nextRevisionId);default:return!1}}isWrongServerRevisionId(e){switch(e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":case"SNAPSHOT_CREATED":return e.serverRevisionId!==this.serverRevisionId;default:return!1}}dropPendingHistoryMessages(){this.waitingUndoRedoAck=!1,this.pendingMessages=this.pendingMessages.filter((({type:e})=>"REVISION_REDONE"!==e&&"REVISION_UNDONE"!==e))}}const td=["#ff851b","#0074d9","#7fdbff","#b10dc9","#39cccc","#f012be","#3d9970","#111111","#ff4136","#aaaaaa","#85144b","#001f3f"];class sd extends yh{constructor(){super(...arguments),this.availableColors=new Set(td),this.colors={}}isPositionValid(e){const t=this.getters.getSheet(e.sheetId);return e.row<t.rows.length&&e.col<t.cols.length}chooseNewColor(){0===this.availableColors.size&&(this.availableColors=new Set(td));const e=(t=[...this.availableColors.values()])[Math.floor(Math.random()*t.length)];var t;return this.availableColors.delete(e),e}getClientsToDisplay(){try{this.getters.getClient()}catch(e){if(e instanceof Jh)return[];throw e}const e=this.getters.getActiveSheetId(),t=[];for(const s of this.getters.getConnectedClients())if(s.id!==this.getters.getClient().id&&s.position&&s.position.sheetId===e&&this.isPositionValid(s.position)){const e=s.position;this.colors[s.id]||(this.colors[s.id]=this.chooseNewColor());const o=this.colors[s.id];t.push({...s,position:e,color:o})}return t}drawGrid(e){const{viewport:t,ctx:s,thinLineWidth:o}=e,i=this.getters.getActiveSheetId();for(const e of this.getClientsToDisplay()){const{row:n,col:r}=e.position,a=this.getters.expandZone(i,{top:n,bottom:n,left:r,right:r}),[l,c,h,d]=this.getters.getRect(a,t);if(h<=0||d<=0)continue;const u=e.color,p=`${u}10`;s.fillStyle=p,s.lineWidth=4*o,s.strokeStyle=u,s.globalCompositeOperation="multiply",s.fillRect(l,c,h,d),s.globalCompositeOperation="source-over",s.strokeRect(l,c,h,d),s.font=`bold ${R+1}px ${L}`}}}sd.getters=["getClientsToDisplay"],sd.layers=[5],sd.modes=["normal"];class od extends yh{allowDispatch(e){if("SORT_CELLS"===e.type){if(!to(e.col,e.row,e.zone))throw new Error(a("The anchor must be part of the provided zone"));return this.checkValidations(e,this.checkMerge,this.checkMergeSizes)}return 0}handle(e){if("SORT_CELLS"===e.type)this.sortZone(e.sheetId,e,e.zone,e.sortDirection)}checkMerge({sheetId:e,zone:t}){if(!this.getters.doesIntersectMerge(e,t))return 0;for(let s=t.top;s<=t.bottom;s++)for(let o=t.left;o<=t.right;o++)if(!this.getters.isInMerge(e,o,s))return 48;return 0}checkMergeSizes({sheetId:e,zone:t}){if(!this.getters.doesIntersectMerge(e,t))return 0;const s=this.getters.getMerges(e).filter((e=>eo(e,t))),o=io(s[0]);let[i,n]=[o.width,o.height];return s.every((e=>{let[t,s]=[e.right-e.left+1,e.bottom-e.top+1];return t===i&&s===n}))?0:48}expand(e,t){const{left:s,right:o,top:i,bottom:n}=this.getters.expandZone(e.id,t);return{left:Math.max(0,s),right:Math.min(e.cols.length-1,o),top:Math.max(0,i),bottom:Math.min(e.rows.length-1,n)}}checkExpandedValues(e,t){const s=this.expand(e,t),o=e.id;let i,n=[];if(this.getters.doesIntersectMerge(o,s)){const{left:e,right:t,top:r,bottom:a}=s;for(let s=e;s<=t;s++)for(let e=r;e<=a;e++){const[t,r]=this.getters.getMainCell(o,s,e);i=this.getters.getCell(o,t,r),n.push((null==i?void 0:i.formattedValue)||"")}}else n=this.getters.getCellsInZone(o,s).map((e=>(null==e?void 0:e.formattedValue)||""));return n.some((e=>""!==e))}getContiguousZone(e,t){let s,{top:o,bottom:i,left:n,right:r}=t;const a=this.getters.getSheet(e);let l=!1;for(;!l;)l=!0,o>0&&(s=this.checkExpandedValues(a,{left:n-1,right:r+1,top:o-1,bottom:o-1}),s&&(l=!1,o--)),n>0&&(s=this.checkExpandedValues(a,{left:n-1,right:n-1,top:o-1,bottom:i+1}),s&&(l=!1,n--)),r<a.cols.length-1&&(s=this.checkExpandedValues(a,{left:r+1,right:r+1,top:o-1,bottom:i+1}),s&&(l=!1,r++)),i<a.rows.length-1&&(s=this.checkExpandedValues(a,{left:n-1,right:r+1,top:i+1,bottom:i+1}),s&&(l=!1,i++));return{left:n,right:r,top:o,bottom:i}}hasHeader(e){if(1===e[0].length)return!1;let t=e.map((e=>e.map((e=>(null==e?void 0:e.evaluated.type)||$e.empty))));return t[0][0]===$e.empty&&(t=t.slice(1)),!t.some((e=>e[0]===$e.empty))&&!!t.some((e=>e[1]!==$e.empty&&e[0]!==e[1]))}sortZone(e,t,s,o){const[i,n]=this.mainCellsSteps(e,s);let r=this.getters.getMainCell(e,t.col,t.row)[0],a=Object.assign({},s),l=this.mainCells(e,s);this.hasHeader(l)&&(a.top+=n),l=this.mainCells(e,a);const c=function(e,t){const s=e.map(Pa),o=s.filter((e=>e.type===$e.empty)),i=s.filter((e=>e.type!==$e.empty)),n="descending"===t?-1:1;return i.sort(((e,t)=>{let s=Da.indexOf(e.type)-Da.indexOf(t.type);return 0===s&&(s=e.type===$e.text||e.type===$e.error?e.value.localeCompare(t.value):e.value-t.value),n*s})).concat(o)}(l[r-a.left],o),h=c.map((e=>e.index)),[d,u]=[l.length,l[0].length];for(let t=0;t<d;t++)for(let s=0;s<u;s++){let o=l[t][h[s]],r=a.left+t*i,c=a.top+s*n,d={sheetId:e,col:r,row:c,content:"",value:""};if(o){let t=o.content;if(o.isFormula()){const s=c-this.getters.getCellPosition(o.id).row,i=this.getters.createAdaptedRanges(o.dependencies,0,s,e);t=this.getters.buildFormulaContent(e,o,i)}d.style=o.style,d.content=t,d.format=o.format,d.value=o.evaluated.value}this.dispatch("UPDATE_CELL",d)}}mainCellsSteps(e,t){const s=this.getters.getMerge(e,t.left,t.top);return[s?s.right-s.left+1:1,s?s.bottom-s.top+1:1]}mainCells(e,t){const[s,o]=this.mainCellsSteps(e,t),i=[],n=Es(t.left,t.right+1,s),r=Es(t.top,t.bottom+1,o);for(const t of n){const s=[];i.push(s);for(const o of r)s.push(this.getters.getCell(e,t,o))}return i}}od.getters=["getContiguousZone"];class id extends yh{constructor(){super(...arguments),this.showFormulas=!1}handle(e){if("SET_FORMULA_VISIBILITY"===e.type)this.showFormulas=e.show}shouldShowFormulas(){return this.showFormulas}}id.modes=["normal"],id.getters=["shouldShowFormulas"];class nd extends yh{constructor(){super(...arguments),this.ctx=document.createElement("canvas").getContext("2d")}allowDispatch(e){switch(e.type){case"AUTORESIZE_ROWS":case"AUTORESIZE_COLUMNS":try{this.getters.getSheet(e.sheetId);break}catch(e){return 23}}return 0}handle(e){switch(e.type){case"AUTORESIZE_COLUMNS":for(let t of e.cols){const s=this.getColMaxWidth(e.sheetId,t);0!==s&&this.dispatch("RESIZE_COLUMNS_ROWS",{elements:[t],dimension:"COL",size:s+6,sheetId:e.sheetId})}break;case"AUTORESIZE_ROWS":for(let t of e.rows){const s=this.getRowMaxHeight(e.sheetId,t);0!==s&&this.dispatch("RESIZE_COLUMNS_ROWS",{elements:[t],dimension:"ROW",size:s+6,sheetId:e.sheetId})}}}getCellWidth(e){let t=this.getTextWidth(e);const s=this.getters.getCellPosition(e.id);return this.getters.getConditionalIcon(s.col,s.row)&&(t+=function(e,t){const s=t.fontSize||R;return ds[s]+2*w}(this.ctx,this.getters.getCellStyle(e))),t}getTextWidth(e){const t=this.getters.getCellText(e,this.getters.shouldShowFormulas());return vs(this.ctx,t,this.getters.getCellStyle(e))}getCellHeight(e){const t=this.getters.getCellStyle(e).fontSize||R;return ds[t]}getCellText(e,t=!1){return t&&(e.isFormula()||e.evaluated.type===$e.error)?e.content:e.formattedValue}getColMaxWidth(e,t){const s=this.getters.getColCells(e,t).map((e=>this.getCellWidth(e)));return Math.max(0,...s)}getRowMaxHeight(e,t){const s=this.getters.getSheet(e),o=Object.values(s.rows[t].cells).filter(_s).map((e=>this.getters.getCellById(e))).map((e=>this.getCellHeight(e)));return Math.max(0,...o)}}nd.getters=["getCellWidth","getCellHeight","getTextWidth","getCellText"];class rd extends yh{constructor(){super(...arguments),this.viewports={},this.snappedViewports={},this.updateSnap=!1,this.viewportWidth=1e3,this.viewportHeight=1e3}allowDispatch(e){switch(e.type){case"SET_VIEWPORT_OFFSET":return this.checkOffsetValidity(e.offsetX,e.offsetY);case"RESIZE_VIEWPORT":return e.width<0||e.height<0?54:0;default:return 0}}handle(e){switch(e.type){case"UNDO":case"REDO":this.cleanViewports(),this.resetViewports();break;case"RESIZE_VIEWPORT":this.cleanViewports(),this.resizeViewport(e.height,e.width);break;case"SET_VIEWPORT_OFFSET":this.setViewportOffset(e.offsetX,e.offsetY);break;case"SHIFT_VIEWPORT_DOWN":const t=this.getActiveTopRow(),s=this.clipOffsetY(t.start+this.viewportHeight);this.shiftVertically(s);break;case"SHIFT_VIEWPORT_UP":{const e=this.getActiveTopRow(),t=this.clipOffsetY(e.end-this.viewportHeight);this.shiftVertically(t);break}case"REMOVE_COLUMNS_ROWS":case"RESIZE_COLUMNS_ROWS":case"HIDE_COLUMNS_ROWS":"COL"===e.dimension?this.adjustViewportOffsetX(e.sheetId,this.getViewport(e.sheetId)):this.adjustViewportOffsetY(e.sheetId,this.getViewport(e.sheetId));break;case"ADD_COLUMNS_ROWS":case"UNHIDE_COLUMNS_ROWS":"COL"===e.dimension?this.adjustViewportZoneX(e.sheetId,this.getViewport(e.sheetId)):this.adjustViewportZoneY(e.sheetId,this.getViewport(e.sheetId));break;case"ACTIVATE_SHEET":this.refreshViewport(e.sheetIdTo);break;case"SELECT_CELL":case"MOVE_POSITION":this.refreshViewport(this.getters.getActiveSheetId())}}finalize(){this.updateSnap&&(this.snapViewportToCell(this.getters.getActiveSheetId()),this.updateSnap=!1)}getViewportDimensionWithHeaders(){return{width:this.viewportWidth+v,height:this.viewportHeight+m}}getActiveViewport(){const e=this.getters.getActiveSheetId();return this.getViewport(e)}getActiveSnappedViewport(){const e=this.getters.getActiveSheetId();return this.getSnappedViewport(e)}getMaxViewportSize(e){const t=Gs(e,"cols"),s=Gs(e,"rows"),o=e.cols.find((e=>e.end>t.end-this.viewportWidth))||e.cols[e.cols.length-1],i=e.rows.find((e=>e.end>s.end-this.viewportHeight))||e.rows[e.rows.length-1];return{width:t.end+Math.max(b,Math.min(o.size,this.viewportWidth-t.size)),height:s.end+Math.max(S+5,Math.min(i.size,this.viewportHeight-s.size))}}getMaximumViewportOffset(e){const{width:t,height:s}=this.getters.getMaxViewportSize(e);return{maxOffsetX:Math.max(0,t-this.viewportWidth+1),maxOffsetY:Math.max(0,s-this.viewportHeight+1)}}checkOffsetValidity(e,t){const s=this.getters.getActiveSheet(),{maxOffsetX:o,maxOffsetY:i}=this.getMaximumViewportOffset(s);return e<0||t<0||t>i||e>o?53:0}getSnappedViewport(e){return this.snapViewportToCell(e),this.snappedViewports[e]}getViewport(e){return this.viewports[e]?this.viewports[e]:this.generateViewportState(e)}cleanViewports(){const e=this.getters.getVisibleSheets();for(let t of Object.keys(this.viewports))e.includes(t)||delete this.viewports[t]}resetViewports(){for(let[e,t]of Object.entries(this.viewports))this.adjustViewportOffsetX(e,t),this.adjustViewportOffsetY(e,t),this.adjustViewportsPosition(e)}adjustViewportOffsetX(e,t){const{offsetX:s}=t,{width:o}=this.getMaxViewportSize(this.getters.getSheet(e));if(this.viewportWidth+s>o){const e=this.viewportWidth+s-o;t.offsetX=Math.max(0,s-e)}this.adjustViewportZoneX(e,t)}adjustViewportOffsetY(e,t){const{offsetY:s}=t,{height:o}=this.getMaxViewportSize(this.getters.getSheet(e));if(this.viewportHeight+s>o){const e=this.viewportHeight+s-o;t.offsetY=Math.max(0,s-e)}this.adjustViewportZoneY(e,t)}resizeViewport(e,t){this.viewportHeight=e,this.viewportWidth=t,this.recomputeViewports()}recomputeViewports(){for(let e of Object.keys(this.viewports))this.adjustViewportOffsetX(e,this.viewports[e]),this.adjustViewportOffsetY(e,this.viewports[e])}setViewportOffset(e,t){const s=this.getters.getActiveSheetId();this.getActiveViewport(),this.viewports[s].offsetX=e,this.viewports[s].offsetY=t,this.adjustViewportZone(s,this.viewports[s])}clipOffsetY(e){const{height:t}=this.getters.getMaxViewportSize(this.getters.getActiveSheet()),s=t-this.viewportHeight;return e=Math.min(e,s),e=Math.max(e,0)}generateViewportState(e){return this.viewports[e]={left:0,right:0,top:0,bottom:0,offsetX:0,offsetY:0},this.viewports[e]}refreshViewport(e){const t=this.getViewport(e);this.adjustViewportZone(e,t),this.adjustViewportsPosition(e)}adjustViewportZone(e,t){this.adjustViewportZoneX(e,t),this.adjustViewportZoneY(e,t)}adjustViewportZoneX(e,t){const s=this.getters.getSheet(e),o=s.cols;t.left=this.getters.getColIndex(t.offsetX+v,0,s);const i=this.viewportWidth+t.offsetX;t.right=o.length-1;for(let e=t.left;e<o.length;e++)if(i<o[e].end){t.right=e;break}this.updateSnap=!0}adjustViewportZoneY(e,t){const s=this.getters.getSheet(e),o=s.rows;t.top=this.getters.getRowIndex(t.offsetY+m,0,s);const i=this.viewportHeight+t.offsetY;t.bottom=o.length-1;for(let e=t.top;e<o.length;e++)if(i<o[e].end){t.bottom=e;break}this.updateSnap=!0}adjustViewportsPosition(e,t){const s=this.getters.getSheet(e),{cols:o,rows:i}=s,n=this.getSnappedViewport(e);t=t||this.getters.getSheetPosition(e);const[r,a]=zs(s,...this.getters.getMainCell(e,t[0],t[1]));for(;o[r].end>n.offsetX+this.viewportWidth&&n.offsetX<o[r].start;)n.offsetX=o[n.left].end,this.adjustViewportZoneX(e,n);for(;r<n.left;){const t=o.slice(0,n.left).reverse().findIndex((e=>!e.isHidden));n.offsetX=o[n.left-1-t].start,this.adjustViewportZoneX(e,n)}for(;i[a].end>n.offsetY+this.viewportHeight&&n.offsetY<i[a].start;)n.offsetY=i[n.top].end,this.adjustViewportZoneY(e,n);for(;a<n.top;){const t=i.slice(0,n.top).reverse().findIndex((e=>!e.isHidden));n.offsetY=i[n.top-1-t].start,this.adjustViewportZoneY(e,n)}const{top:l,left:c}=this.viewports[e];l===n.top&&c===n.left||(this.viewports[e]=n),this.updateSnap=!1}snapViewportToCell(e){const{cols:t,rows:s}=this.getters.getSheet(e),o=this.getViewport(e),i=Object.assign({},o);this.adjustViewportOffsetX(e,i),this.adjustViewportOffsetY(e,i),i.offsetX=t[i.left].start,i.offsetY=s[i.top].start,this.adjustViewportZone(e,i),this.snappedViewports[e]=i}shiftVertically(e){const{top:t,offsetX:s}=this.getActiveSnappedViewport();this.setViewportOffset(s,e);const{anchor:o}=this.getters.getSelection(),i=this.getActiveSnappedViewport().top-t;this.dispatch("SELECT_CELL",{col:o[0],row:o[1]+i})}getActiveTopRow(){const{top:e}=this.getActiveSnappedViewport(),t=this.getters.getActiveSheet();return this.getters.getRow(t.id,e)}}rd.getters=["getActiveViewport","getActiveSnappedViewport","getViewportDimensionWithHeaders","getMaxViewportSize","getMaximumViewportOffset"],rd.modes=["normal"];const ad=(new Ae).add("sheet",La).add("cell",Sa).add("merge",xa).add("borders",Ea).add("conditional formatting",wa).add("figures",Ia).add("chart",Ca),ld=(new Ae).add("selection",Mh).add("ui_sheet",nd).add("ui_options",id).add("evaluation",Nh).add("evaluation_cf",Dh).add("evaluation_chart",$h).add("clipboard",Th).add("edition",_h).add("highlight",Bh).add("selectionInput",Gh).add("viewport",rd).add("grid renderer",zh).add("autofill",Ih).add("find_and_replace",Uh).add("sort",od).add("automatic_sum",xh).add("format",Vh).add("selection_multiuser",sd);class cd{constructor(){this.listeners=[]}sendMessage(e){for(const{callback:t}of this.listeners)t(e)}onNewMessage(e,t){this.listeners.push({id:e,callback:t})}leave(e){this.listeners=this.listeners.filter((t=>t.id!==e))}}class hd extends o.core.EventBus{constructor(){super(...arguments),this.registry=new Ae}add(e,t){this.registry.add(e,t);const s=o.utils.debounce((()=>this.trigger("data-loaded",{id:e})),0);return t.on("data-loaded",this,(()=>s())),t.loadMetadata(),this}get(e){return this.registry.get(e)}getAll(){return this.registry.getAll()}remove(e){this.get(e).off("data-loaded",this),this.registry.remove(e)}async waitForReady(){const e=[];for(const t of this.getAll())e.push(t.get());return Promise.all(e)}}class dd extends o.core.EventBus{async loadMetadata(){this.metadataPromise||(this.metadataPromise=this._fetchMetadata().then((e=>(this.metadata=e,e)))),await this.metadataPromise}async get(e){return e&&e.forceFetch&&(this.data=void 0,this.dataPromise=void 0),await this.loadMetadata(),this.dataPromise||(this.dataPromise=this._fetch(e).then((e=>(this.data=e,this.lastUpdate=Date.now(),this.trigger("data-loaded"),e)))),this.dataPromise}getSync(){return this.data}getMetadataSync(){return this.metadata}getLastUpdate(){return this.lastUpdate}}function ud(e){return Oa.get(e.type)(e)}function pd(e){if("string"==typeof e)return{};if("number"==typeof e)return[];throw new Error("Cannot create new node")}class gd{constructor(e,t=[]){this.buildTransformation=e,this.operations=t}getOperations(){return this.operations}getOperation(e){const t=this.operations.find((t=>t.id===e));if(!t)throw new Error(`Operation ${e} not found`);return t}getLastOperationId(){var e;return null===(e=this.operations[this.operations.length-1])||void 0===e?void 0:e.id}getFirstOperationAmong(e,t){for(const s of this.operations){if(s.id===e)return e;if(s.id===t)return t}throw new Error(`Operation ${e} and ${t} not found`)}contains(e){return!!this.operations.find((t=>t.id===e))}prepend(e){const t=this.buildTransformation.with(e.data);this.operations=[e,...this.operations.map((e=>e.transformed(t)))]}insert(e,t){const s=this.buildTransformation.with(e.data),{before:o,operation:i,after:n}=this.locateOperation(t);this.operations=[...o,i,e,...n.map((e=>e.transformed(s)))]}append(e){this.operations.push(e)}appendBranch(e){this.operations=this.operations.concat(e.operations)}fork(e){const{after:t}=this.locateOperation(e);return new gd(this.buildTransformation,t)}transform(e){this.operations=this.operations.map((t=>t.transformed(e)))}cutBefore(e){this.operations=this.locateOperation(e).before}cutAfter(e){const{before:t,operation:s}=this.locateOperation(e);this.operations=t.concat([s])}locateOperation(e){const t=this.operations.findIndex((t=>t.id===e));if(-1===t)throw new Error(`Operation ${e} not found`);return{before:this.operations.slice(0,t),operation:this.operations[t],after:this.operations.slice(t+1)}}}class fd{constructor(e,t){this.id=e,this.data=t}transformed(e){return new md(this.id,ks((()=>e(this.data))))}}class md{constructor(e,t){this.id=e,this.lazyData=t}get data(){return this.lazyData()}transformed(e){return new md(this.id,this.lazyData.map(e))}}class vd{constructor(e){this.operations=e}[Symbol.iterator](){return this.operations[Symbol.iterator]()}stopWith(e){return new vd(function*(e,t){for(const s of e)if(yield s,s.operation.id===t)return}(this.operations,e))}stopBefore(e){return new vd(function*(e,t){for(const s of e){if(s.operation.id===t)return;yield s}}(this.operations,e))}startAfter(e){return new vd(function*(e,t){let s=!0;for(const o of e)s||(yield o),o.operation.id===t&&(s=!1)}(this.operations,e))}}class Ed{constructor(e,t){this.buildTransformation=e,this.branchingOperationIds=new Map,this.branches=[t]}getLastBranch(){return this.branches[this.branches.length-1]}execution(e){return new vd(Ss(this._execution(e),this._execution(e)))}revertedExecution(e){return new vd(Ss(this._revertedExecution(e),this._revertedExecution(e)))}insertOperationLast(e,t){var s;const o=e.getLastOperationId()||(null===(s=this.previousBranch(e))||void 0===s?void 0:s.getLastOperationId());e.append(t),o&&this.insertPrevious(e,t,o)}insertOperationAfter(e,t,s){e.insert(t,s),this.updateNextWith(e,t,s),this.insertPrevious(e,t,s)}undo(e,t){const s=this.buildTransformation.without(t.data),o=this.branchingOperationIds.get(e);this.branchingOperationIds.set(e,t.id);const i=e.fork(t.id);o&&this.branchingOperationIds.set(i,o),this.insertBranchAfter(e,i),this.transform(i,s)}redo(e){const t=this.nextBranch(e);if(!t)return;const s=this.nextBranch(t);this.removeBranchFromTree(t);const o=this.branchingOperationIds.get(t);o?this.branchingOperationIds.set(e,o):this.branchingOperationIds.delete(e),s&&this.rebaseUp(s)}drop(e){for(const t of this.branches)t.contains(e)&&t.cutBefore(e)}findOperation(e,t){for(const s of this.revertedExecution(e))if(s.operation.id===t)return s;throw new Error(`Operation ${t} not found`)}rebaseUp(e){const{previousBranch:t,branchingOperation:s}=this.findPreviousBranchingOperation(e);if(!t||!s)return;const o=this.buildTransformation.without(s.data),i=t.fork(s.id);this.branchingOperationIds.set(i,this.branchingOperationIds.get(e)),this.removeBranchFromTree(e),this.insertBranchAfter(t,i),i.transform(o);const n=this.nextBranch(i);n&&this.rebaseUp(n)}removeBranchFromTree(e){const t=this.branches.findIndex((t=>t===e));this.branches.splice(t,1)}insertBranchAfter(e,t){const s=this.branches.findIndex((t=>t===e));this.branches.splice(s+1,0,t)}updateNextWith(e,t,s){const o=this.branchingOperationIds.get(e),i=this.nextBranch(e);if(o&&i)if(e.getFirstOperationAmong(s,o)===o){const n=this.addToNextBranch(e,i,o,t,s);this.updateNextWith(i,n,s)}else{const e=this.buildTransformation.with(t.data);this.transform(i,e)}}addToNextBranch(e,t,s,o,i){let n=o;return i===s?(n=this.getTransformedOperation(e,s,o),t.prepend(n)):t.contains(i)?(n=this.getTransformedOperation(e,s,o),t.insert(n,i)):t.append(o),n}getTransformedOperation(e,t,s){const o=e.getOperation(t),i=this.buildTransformation.without(o.data);return s.transformed(i)}shouldExecute(e,t){return t.id!==this.branchingOperationIds.get(e)}transform(e,t){e.transform(t);const s=this.nextBranch(e);s&&this.transform(s,t)}insertPrevious(e,t,s){const{previousBranch:o,branchingOperation:i}=this.findPreviousBranchingOperation(e);if(!o||!i)return;const n=this.buildTransformation.with(i.data),r=e.fork(s);r.transform(n),o.cutAfter(s),o.appendBranch(r);const a=t.transformed(n);this.insertPrevious(o,a,s)}findPreviousBranchingOperation(e){const t=this.previousBranch(e);if(!t)return{previousBranch:void 0,branchingOperation:void 0};const s=this.branchingOperationIds.get(t);return s?{previousBranch:t,branchingOperation:t.getOperation(s)}:{previousBranch:void 0,branchingOperation:void 0}}nextBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t+1]}previousBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t-1]}*_revertedExecution(e){const t=this.branchingOperationIds.get(e);let s=!!t;const o=e.getOperations();for(let i=o.length-1;i>=0;i--){const n=o[i];n.id===t&&(s=!1),s||(yield{operation:n,branch:e,isCancelled:!this.shouldExecute(e,n)})}const i=this.previousBranch(e);yield*i?this._revertedExecution(i):[]}*_execution(e){for(const t of e.getOperations())if(yield{operation:t,branch:e,isCancelled:!this.shouldExecute(e,t)},t.id===this.branchingOperationIds.get(e)){const t=this.nextBranch(e);return void(yield*t?this._execution(t):[])}if(!this.branchingOperationIds.get(e)){const t=this.nextBranch(e);yield*t?this._execution(t):[]}}}class bd{constructor(e,t,s,o,i){this.applyOperation=t,this.revertOperation=s,this.buildEmpty=o,this.buildTransformation=i,this.HEAD_BRANCH=new gd(this.buildTransformation),this.tree=new Ed(i,this.HEAD_BRANCH);const n=new fd(e,o(e));this.tree.insertOperationLast(this.HEAD_BRANCH,n),this.HEAD_OPERATION=n}get(e){return this.tree.findOperation(this.HEAD_BRANCH,e).operation.data}append(e,t){const s=new fd(e,t),o=this.tree.getLastBranch();this.tree.insertOperationLast(o,s),this.HEAD_BRANCH=o,this.HEAD_OPERATION=s}insert(e,t,s){const o=new fd(e,t);this.revertTo(s),this.tree.insertOperationAfter(this.HEAD_BRANCH,o,s),this.fastForward()}undo(e,t,s){const{branch:o,operation:i}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.undo(o,i),this.fastForward(),this.insert(t,this.buildEmpty(t),s)}redo(e,t,s){const{branch:o}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.redo(o),this.fastForward(),this.insert(t,this.buildEmpty(t),s)}drop(e){this.revertBefore(e),this.tree.drop(e)}revertBefore(e){const t=this.tree.revertedExecution(this.HEAD_BRANCH).stopWith(e);this.revert(t)}revertTo(e){const t=e?this.tree.revertedExecution(this.HEAD_BRANCH).stopBefore(e):this.tree.revertedExecution(this.HEAD_BRANCH);this.revert(t)}revert(e){for(const{next:t,operation:s,isCancelled:o}of e)o||this.revertOperation(s.data),t&&(this.HEAD_BRANCH=t.branch,this.HEAD_OPERATION=t.operation)}fastForward(){const e=this.HEAD_OPERATION?this.tree.execution(this.HEAD_BRANCH).startAfter(this.HEAD_OPERATION.id):this.tree.execution(this.HEAD_BRANCH);for(const{operation:t,branch:s,isCancelled:o}of e)o||this.applyOperation(t.data),this.HEAD_OPERATION=t,this.HEAD_BRANCH=s}}function Sd(e,t,s){return new bd(e,(e=>{const o=e.commands.slice(),{changes:i}=t((()=>{for(const e of o)s(e)}));e.setChanges(i)}),(e=>function(e){for(const t of e.slice().reverse())for(let e=t.changes.length-1;e>=0;e--){Cd(t.changes[e],"before")}}([e])),(e=>new Qh(e,"empty",[],[])),{with:e=>t=>new Qh(t.id,t.clientId,Kh(t.commands,e.commands)),without:e=>t=>new Qh(t.id,t.clientId,Kh(t.commands,e.commands.map(ud).flat()))})}function Cd(e,t){let s=e.path[0];const o=e.path[e.path.length-1];for(let t=1;t<e.path.slice(0,-1).length;t++){const o=e.path[t];if(void 0===s[o]){const i=e.path[t+1];s[o]=pd(i)}s=s[o]}void 0===e[t]?delete s[o]:s[o]=e[t]}class yd extends o.core.EventBus{constructor(e,t){super(),this.dispatch=e,this.session=t,this.undoStack=[],this.redoStack=[],this.session.on("new-local-state-update",this,this.onNewLocalStateUpdate),this.session.on("revision-undone",this,(({commands:e})=>this.selectiveUndo(e))),this.session.on("revision-redone",this,(({commands:e})=>this.selectiveRedo(e))),this.session.on("pending-revisions-dropped",this,(({revisionIds:e})=>this.drop(e))),this.session.on("snapshot",this,(()=>{this.undoStack=[],this.redoStack=[]}))}allowDispatch(e){switch(e.type){case"REQUEST_UNDO":if(!this.canUndo())return 6;break;case"REQUEST_REDO":if(!this.canRedo())return 7}return 0}beforeHandle(e){}handle(e){switch(e.type){case"REQUEST_UNDO":case"REQUEST_REDO":this.requestHistoryChange("REQUEST_UNDO"===e.type?"UNDO":"REDO")}}finalize(){}requestHistoryChange(e){const t="UNDO"===e?this.undoStack.pop():this.redoStack.pop();t&&("UNDO"===e?(this.session.undo(t),this.redoStack.push(t)):(this.session.redo(t),this.undoStack.push(t)))}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}drop(e){this.undoStack=this.undoStack.filter((t=>!e.includes(t))),this.redoStack=[]}onNewLocalStateUpdate({id:e}){this.undoStack.push(e),this.redoStack=[],this.undoStack.length>99&&this.undoStack.shift()}selectiveUndo(e){this.dispatch("UNDO",{commands:e})}selectiveRedo(e){this.dispatch("REDO",{commands:e})}}class wd{constructor(e){this.providers=[],this.getters=e}allowDispatch(e){return 0}beforeHandle(e){}handle(e){switch(e.type){case"REMOVE_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",s="COL"===e.dimension?"right":"bottom",o="COL"===e.dimension?"columns":"rows";e.elements.sort(((e,t)=>t-e));const i=bs(e.elements);this.executeOnAllRanges((n=>{if(n.sheetId!==e.sheetId)return{changeType:"NONE"};let r=n,a="NONE";for(let e of i){const i=Math.min(...e),l=Math.max(...e);if(n.zone[t]<=i&&i<=n.zone[s]){const e=Math.min(n.zone[s],l)-i+1;a="RESIZE",r=this.createAdaptedRange(r,o,a,-e)}else if(n.zone[t]>=i&&n.zone[s]<=l)a="REMOVE",r=this.buildInvalidRange(O);else if(n.zone[t]<=l&&n.zone[s]>=l){const e=l-n.zone[t]+1;a="RESIZE",r=this.createAdaptedRange(r,o,a,-e),r=this.createAdaptedRange(r,o,"MOVE",-(n.zone[t]-i))}else i<n.zone[t]&&(a="MOVE",r=this.createAdaptedRange(r,o,a,-(l-i+1)))}return"NONE"!==a?{changeType:a,range:r}:{changeType:"NONE"}}),e.sheetId);break}case"ADD_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",s="COL"===e.dimension?"right":"bottom",o="COL"===e.dimension?"columns":"rows";this.executeOnAllRanges((i=>{if(i.sheetId!==e.sheetId)return{changeType:"NONE"};if("after"===e.position){if(i.zone[t]<=e.base&&e.base<i.zone[s])return{changeType:"RESIZE",range:this.createAdaptedRange(i,o,"RESIZE",e.quantity)};if(e.base<i.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(i,o,"MOVE",e.quantity)}}else{if(i.zone[t]<e.base&&e.base<=i.zone[s])return{changeType:"RESIZE",range:this.createAdaptedRange(i,o,"RESIZE",e.quantity)};if(e.base<=i.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(i,o,"MOVE",e.quantity)}}return{changeType:"NONE"}}),e.sheetId);break}case"DELETE_SHEET":this.executeOnAllRanges((t=>t.sheetId!==e.sheetId?{changeType:"NONE"}:{changeType:"REMOVE",range:t={...this.buildInvalidRange(O),invalidSheetName:this.getters.getSheetName(e.sheetId)}}),e.sheetId);break;case"RENAME_SHEET":this.executeOnAllRanges((t=>{if(t.sheetId===e.sheetId)return{changeType:"CHANGE",range:t};if(e.name&&t.invalidSheetName===e.name){const s={...t,zone:{...t.zone}};return s.invalidSheetName=void 0,s.sheetId=e.sheetId,{changeType:"CHANGE",range:s}}return{changeType:"NONE"}}))}}finalize(){}verifyRangeRemoved(e){return t=>{const s=e(t);return"NONE"===s.changeType||js(s.range.zone)?s:{range:s.range,changeType:"REMOVE"}}}createAdaptedRange(e,t,s,o){return{...e,zone:ao(e.zone,t,s,o)}}executeOnAllRanges(e,t){const s=this.verifyRangeRemoved(e);for(const e of this.providers)e(s,t)}addRangeProvider(e){this.providers.push(e)}orderZone(e,t){if(e.right<e.left){let s=e.right;e.right=e.left,e.left=s;let o=t[1].colFixed;t[1].colFixed=t[0].colFixed,t[0].colFixed=o}if(e.bottom<e.top){let s=e.bottom;e.bottom=e.top,e.top=s;let o=t[1].rowFixed;t[1].rowFixed=t[0].rowFixed,t[0].rowFixed=o}}createAdaptedRanges(e,t,s,o){return e.map((e=>js(e.zone)?(e={...e,sheetId:e.prefixSheet?e.sheetId:o,zone:{left:e.zone.left+(e.parts[0].colFixed?0:t),right:e.zone.right+((e.parts[1]||e.parts[0]).colFixed?0:t),top:e.zone.top+(e.parts[0].rowFixed?0:s),bottom:e.zone.bottom+((e.parts[1]||e.parts[0]).rowFixed?0:s)}},this.orderZone(e.zone,e.parts),e):e))}getRangeFromSheetXC(e,t){let s,o,i,n=t,r=!1;if(!ts.test(t))return this.buildInvalidRange(t);t.includes("!")&&(({xc:n,sheetName:s}=ss(t)),s?(o=this.getters.getSheetIdByName(s),r=!0,o||(i=s)):i=s);const a=Ws(n);let l=n.split(":").map((e=>({colFixed:e.startsWith("$"),rowFixed:e.includes("$",1)})));return this.orderZone(a,l),{sheetId:o||e,zone:a,parts:l,invalidSheetName:i,prefixSheet:r}}getRangeString(e,t){if(!e)return O;if(e.invalidXc)return e.invalidXc;if(e.zone.bottom-e.zone.top<0||e.zone.right-e.zone.left<0)return O;if(e.zone.left<0||e.zone.top<0)return O;let s=e.sheetId!==t||e.invalidSheetName||e.prefixSheet,o="";if(s&&(o=e.invalidSheetName?e.invalidSheetName:fs(this.getters.getSheetName(e.sheetId))),s&&!o)return O;let i=Array(9);return i[0]=e.parts&&e.parts[0].colFixed?"$":"",i[1]=os(e.zone.left),i[2]=e.parts&&e.parts[0].rowFixed?"$":"",i[3]=String(e.zone.top+1),e.parts&&2===e.parts.length&&(e.zone.top!==e.zone.bottom||e.zone.left!==e.zone.right||e.parts[0].rowFixed||e.parts[0].colFixed||e.parts[1].rowFixed||e.parts[1].colFixed)&&(i[4]=":",i[5]=e.parts[1].colFixed?"$":"",i[6]=os(e.zone.right),i[7]=e.parts[1].rowFixed?"$":"",i[8]=String(e.zone.bottom+1)),`${s?o+"!":""}${i.join("")}`}buildInvalidRange(e){return{parts:[],prefixSheet:!1,zone:{left:-1,top:-1,right:-1,bottom:-1},sheetId:"",invalidXc:e}}}wd.getters=["getRangeString","getRangeFromSheetXC","createAdaptedRanges"];class Id{constructor(){this.changes=[],this.commands=[]}recordChanges(e){return this.changes=[],this.commands=[],e(),{changes:this.changes,commands:this.commands}}addCommand(e){this.commands.push(e)}addChange(...e){const t=e.pop();let s=e[0],o=e[e.length-1];const i=e.length-2;for(let t=1;t<=i;t++){const o=e[t];if(void 0===s[o]){const i=e[t+1];s[o]=pd(i)}s=s[o]}s[o]!==t&&(this.changes.push({path:e,before:s[o],after:t}),void 0===t?delete s[o]:s[o]=t)}}const xd={General:0,0:1,"0.00":2,"#,#00":3,"#,##0.00":4,"0%":9,"0.00%":10,"0.00E+00":11,"# ?/?":12,"# ??/??":13,"mm-dd-yy":14,"d-mm-yy":15,"mm-yy":16,"mmm-yy":17,"h:mm AM/PM":18,"h:mm:ss AM/PM":19,"h:mm":20,"h:mm:ss":21,"m/d/yy h:mm":22,"#,##0 ;(#,##0)":37,"#,##0 ;[Red](#,##0)":38,"#,##0.00;(#,##0.00)":39,"#,##0.00;[Red](#,##0.00)":40,"mm:ss":45,"[h]:mm:ss":46,"mmss.0":47,"##0.0E+0":48,"@":49,"hh:mm:ss a":19},Td={arrow:"3Arrows",smiley:"3Symbols",dot:"3TrafficLights1"},Rd={styleSheet:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",sst:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",Relationships:"http://schemas.openxmlformats.org/package/2006/relationships",Types:"http://schemas.openxmlformats.org/package/2006/content-types",worksheet:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",workbook:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",drawing:"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"},Ld="http://schemas.openxmlformats.org/drawingml/2006/main",Md="http://schemas.openxmlformats.org/drawingml/2006/chart",Ad={workbook:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml",sheet:"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml",sharedStrings:"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml",styles:"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml",drawing:"application/vnd.openxmlformats-officedocument.drawing+xml",chart:"application/vnd.openxmlformats-officedocument.drawingml.chart+xml"},_d="http://schemas.openxmlformats.org/officeDocument/2006/relationships",Od=.75,Nd=.1425,kd=164,Fd={FLOOR:[{type:"NUMBER",value:1}],CEILING:[{type:"NUMBER",value:1}],ROUND:[{type:"NUMBER",value:0}],ROUNDUP:[{type:"NUMBER",value:0}],ROUNDDOWN:[{type:"NUMBER",value:0}]},$d=["ACOT","ACOTH","AGGREGATE","ARABIC","BASE","BETA.DIST","BETA.INV","BINOM.DIST","BINOM.DIST.RANGE","BINOM.INV","BITAND","BITLSHIFT","BITOR","BITRSHIFT","BITXOR","CEILING.MATH","CEILING.PRECISE","CHISQ.DIST","CHISQ.DIST.RT","CHISQ.INV","CHISQ.INV.RT","CHISQ.TEST","COMBINA","CONCAT","CONFIDENCE.NORM","CONFIDENCE.T","COT","COTH","COVARIANCE.P","COVARIANCE.S","CSC","CSCH","DAYS","DECIMAL","ERF.PRECISE","ERFC.PRECISE","EXPON.DIST","F.DIST","F.DIST.RT","F.INV","F.INV.RT","F.TEST","FILTERXML","FLOOR.MATH","FLOOR.PRECISE","FORECAST.ETS","FORECAST.ETS.CONFINT","FORECAST.ETS.SEASONALITY","FORECAST.ETS.STAT","FORECAST.LINEAR","FORMULATEXT","GAMMA","GAMMA.DIST","GAMMA.INV","GAMMALN.PRECISE","GAUSS","HYPGEOM.DIST","IFNA","IFS","IMCOSH","IMCOT","IMCSC","IMCSCH","IMSEC","IMSECH","IMSINH","IMTAN","ISFORMULA","ISOWEEKNUM","LOGNORM.DIST","LOGNORM.INV","MAXIFS","MINIFS","MODE.MULT","MODE.SNGL","MUNIT","NEGBINOM.DIST","NORM.DIST","NORM.INV","NORM.S.DIST","NORM.S.INV","NUMBERVALUE","PDURATION","PERCENTILE.EXC","PERCENTILE.INC","PERCENTRANK.EXC","PERCENTRANK.INC","PERMUTATIONA","PHI","POISSON.DIST","QUARTILE.EXC","QUARTILE.INC","QUERYSTRING","RANK.AVG","RANK.EQ","RRI","SEC","SECH","SHEET","SHEETS","SKEW.P","STDEV.P","STDEV.S","SWITCH","T.DIST","T.DIST.2T","T.DIST.RT","T.INV","T.INV.2T","T.TEST","TEXTJOIN","UNICHAR","UNICODE","VAR.P","VAR.S","WEBSERVICE","WEIBULL.DIST","XOR","Z.TEST"];function Dd(e){switch(e){case"IsNotEmpty":case"NotContains":return"notContainsBlanks";case"IsEmpty":return"containsBlanks";default:return e.charAt(0).toLowerCase()+e.slice(1)}}function Pd(e){return Math.round(Od*e*window.devicePixelRatio*100)/100}function Ud(e){return Math.round(Nd*e*100)/100}function Vd(e,t){let s={};e.style&&(s=t.styles[e.style]);const o=e.format?t.formats[e.format]:void 0;let i={};e.border&&(i=t.borders[e.border]);const n={font:{size:(null==s?void 0:s.fontSize)||R,color:(null==s?void 0:s.textColor)?s.textColor:"000000",family:2,name:"Arial"},fill:(null==s?void 0:s.fillColor)?{fgColor:s.fillColor}:{reservedAttribute:"none"},numFmt:o,border:i||{},verticalAlignment:"center",horizontalAlignment:null==s?void 0:s.align};return n.font.strike=!!(null==s?void 0:s.strikethrough)||void 0,n.font.underline=!!(null==s?void 0:s.underline)||void 0,n.font.bold=!!(null==s?void 0:s.bold)||void 0,n.font.italic=!!(null==s?void 0:s.italic)||void 0,n}function Bd(e,t){const{id:s}=zd(t.font,e.fonts),{id:o}=zd(t.fill,e.fills),{id:i}=zd(t.border,e.borders),n=function(e,t){if(!e)return 0;let s=xd[e];if(!s){const{id:o}=zd(e,t);s=o+kd}return s}(t.numFmt,e.numFmts),r={fontId:s,fillId:o,borderId:i,numFmtId:n,verticalAlignment:t.verticalAlignment,horizontalAlignment:t.horizontalAlignment},{id:a}=zd(r,e.styles);return a}function Hd(e,t,s){let o,i=e.find((e=>e.path===t));return i?(o=`rId${(i.rels.length+1).toString()}`,i.rels.push({...s,id:o})):(o="rId1",e.push({path:t,rels:[{...s,id:o}]})),o}function zd(e,t){for(let[s,o]of Object.entries(t))if(JSON.stringify(o)===JSON.stringify(e))return{id:parseInt(s,10),list:t};let s=t.findIndex((t=>JSON.stringify(t)===JSON.stringify(e)));return-1===s&&(t.push(e),s=t.length-1),{id:s,list:t}}const Zd=[];function Gd(e){const t=Zd.findIndex((t=>t===e));return-1===t?(Zd.push(e),Zd.length):t+1}function Wd(e){return Math.round(914400*e/96)}class qd{constructor(e){this.xmlString=e}toString(){return this.xmlString}}function jd(e,t,s){return{content:(new XMLSerializer).serializeToString(e),path:t,contentType:s}}function Xd(e){return String(e).replace(/\&/g,"&amp;").replace(/\</g,"&lt;").replace(/\>/g,"&gt;").replace(/\"/g,"&quot;").replace(/\'/g,"&apos;").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"")}function Yd(e){return new qd(e.map((([e,t])=>`${e}="${Xd(t)}"`)).join(" "))}function Kd(e){const t=(new DOMParser).parseFromString(e.toString(),"text/xml"),s=t.querySelector("parsererror");if(s){const t=s.innerHTML,o=parseInt(t.split(":")[0],10),i=e.toString().trim().split("\n"),n=i.slice(Math.max(o-3,0),Math.min(o+2,i.length)).join("\n");throw new Error(`XML string could not be parsed: ${t}\n${n}`)}return t}function Qd(e,t){return eu`
1049
1049
  <Override ContentType="${t}" PartName="${e}" />
1050
1050
  `}function Jd(e){return new qd(e.join("\n"))}function eu(e,...t){let s=[e[0]];for(let o=0;o<t.length;o++){const i=t[o]instanceof qd?t[o]:Xd(t[o]);s.push(i+e[o+1])}return new qd(s.join(""))}const tu=17781237,su=88853993;function ou(e){const t=[["xmlns:r",_d],["xmlns:a",Ld],["xmlns:c",Md]],s=iu({backgroundColor:Jt(e.data.backgroundColor),line:{color:"000000"}});let o=eu``;e.data.title&&(o=eu`
1051
1051
  <c:title>
@@ -3087,4 +3087,4 @@
3087
3087
  height: ${15}px;
3088
3088
  vertical-align: sub;
3089
3089
  }
3090
- `;class qf extends t.Component{constructor(e,s={}){super(e,s),this.model=new ku(this.props.data,{evalContext:{env:this.env},transportService:this.props.transportService,client:this.props.client,isReadonly:this.props.isReadonly,snapshotRequested:this.props.snapshotRequested},this.props.stateUpdateMessages),this.sidePanel=t.useState({isOpen:!1,panelProps:{}}),this.linkEditor=t.useState({isOpen:!1}),this.composer=t.useState({topBarFocus:"inactive",gridFocusMode:"inactive"}),this.keyDownMapping={"CTRL+H":()=>this.toggleSidePanel("FindAndReplace",{}),"CTRL+F":()=>this.toggleSidePanel("FindAndReplace",{})},Uf({openSidePanel:(e,t={})=>this.openSidePanel(e,t),toggleSidePanel:(e,t={})=>this.toggleSidePanel(e,t),dispatch:this.model.dispatch,getters:this.model.getters,uuidGenerator:this.model.uuidGenerator,_t:qf._t,clipboard:navigator.clipboard,export:this.model.exportData.bind(this.model),waitForIdle:this.model.waitForIdle.bind(this.model),exportXLSX:this.model.exportXLSX.bind(this.model),openLinkEditor:()=>this.openLinkEditor()}),this.activateFirstSheet()}setup(){Pf(window,"resize",this.render),Pf(document.body,"keyup",this.onKeyup.bind(this)),Pf(window,"beforeunload",this.leaveCollaborativeSession.bind(this)),Vf((()=>this.initiateModelEvents())),Bf((()=>this.leaveCollaborativeSession())),Hf((e=>this.checkReadonly(e)))}get focusTopBarComposer(){return"inactive"===this.model.getters.getEditionMode()?"inactive":this.composer.topBarFocus}get focusGridComposer(){return"inactive"===this.model.getters.getEditionMode()?"inactive":this.composer.gridFocusMode}initiateModelEvents(){this.model.on("update",this,this.render),this.model.on("notify-ui",this,this.onNotifyUI),this.model.on("unexpected-revision-id",this,(()=>this.trigger("unexpected-revision-id"))),this.props.client&&this.model.joinSession(this.props.client)}onNotifyUI(e){if("NOTIFICATION"===e.type)this.env.notifyUser(e.text)}checkReadonly(e){this.props.isReadonly!==e.isReadonly&&this.model.updateReadOnly(e.isReadonly)}leaveCollaborativeSession(){this.model.off("update",this),this.model.leaveSession()}activateFirstSheet(){const e=this.model.getters.getActiveSheetId(),[t]=this.model.getters.getSheets();t.id!==e&&this.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:e,sheetIdTo:t.id})}destroy(){this.model.destroy(),super.destroy()}openSidePanel(e,t){this.sidePanel.component=e,this.sidePanel.panelProps=t,this.sidePanel.isOpen=!0}closeSidePanel(){this.sidePanel.isOpen=!1,this.focusGrid()}openLinkEditor(){this.linkEditor.isOpen=!0}closeLinkEditor(){this.linkEditor.isOpen=!1,this.focusGrid()}toggleSidePanel(e,t){this.sidePanel.isOpen&&e===this.sidePanel.component?(this.sidePanel.isOpen=!1,this.focusGrid()):this.openSidePanel(e,t)}focusGrid(){if(!this._focusGrid)throw new Error("_focusGrid should be exposed by the grid component");this._focusGrid()}save(){this.trigger("save-content",{data:this.model.exportData()})}onKeyup(e){"Control"===e.key&&this.model.getters.getSelectionMode()!==Lh.expanding&&this.model.dispatch("STOP_SELECTION")}onKeydown(e){"Control"!==e.key||e.repeat||this.model.dispatch(this.model.getters.getSelectionMode()===Lh.idle?"PREPARE_SELECTION_EXPANSION":"START_SELECTION_EXPANSION");let t="";(e.ctrlKey||e.metaKey)&&(t+="CTRL+"),t+=e.key.toUpperCase();let s=this.keyDownMapping[t];if(s)return e.preventDefault(),e.stopPropagation(),void s()}onTopBarComposerFocused(e){this.model.getters.isReadonly()||(this.composer.topBarFocus="contentFocus",this.composer.gridFocusMode="inactive",this.setComposerContent({selection:e}||{}),this.env.dispatch("UNFOCUS_SELECTION_INPUT"))}onGridComposerContentFocused(){this.model.getters.isReadonly()||(this.composer.topBarFocus="inactive",this.composer.gridFocusMode="contentFocus",this.setComposerContent({}),this.env.dispatch("UNFOCUS_SELECTION_INPUT"))}onGridComposerCellFocused(e,t){this.model.getters.isReadonly()||(this.composer.topBarFocus="inactive",this.composer.gridFocusMode="cellFocus",this.setComposerContent({content:e,selection:t}||{}),this.env.dispatch("UNFOCUS_SELECTION_INPUT"))}setComposerContent({content:e,selection:t}){"inactive"===this.model.getters.getEditionMode()?this.model.dispatch("START_EDITION",{text:e,selection:t}):e&&this.model.dispatch("SET_CURRENT_CONTENT",{content:e,selection:t})}}qf.template=Gf,qf.style=Wf,qf.components={TopBar:Df,Grid:wf,BottomBar:np,SidePanel:Af,LinkEditor:tf},qf._t=e=>e;const jf={},Xf={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:m,HEADER_WIDTH:v,TOPBAR_HEIGHT:E,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:b,DEFAULT_CELL_HEIGHT:S,SCROLLBAR_WIDTH:C},Yf={autofillModifiersRegistry:Ma,autofillRulesRegistry:Aa,cellMenuRegistry:fl,colMenuRegistry:ml,linkMenuRegistry:vl,functionRegistry:hr,uiPluginRegistry:ld,corePluginRegistry:ad,rowMenuRegistry:El,sidePanelRegistry:Sh,sheetMenuRegistry:Sl,topbarMenuRegistry:Cl,topbarComponentRegistry:Ch,otRegistry:yl,inverseCommandRegistry:Oa,cellRegistry:qr},Kf={LinkCell:sa},Qf={args:Ne,toBoolean:me,toNumber:ue,toString:ge,toXC:ns,toZone:qs,toCartesian:is,numberToLetters:os,createFullMenuItem:Fa,UuidGenerator:Hs,formatDecimal:le,computeTextWidth:vs,isMarkdownLink:xs,parseMarkdownLink:Rs,markdownLink:Ts,createEmptyWorkbookData:fa};e.CorePlugin=va,e.DATETIME_FORMAT=_,e.DataSource=dd,e.DispatchResult=Be,e.Model=ku,e.Registry=Ae,e.Revision=Qh,e.SPREADSHEET_DIMENSIONS=Xf,e.Spreadsheet=qf,e.UIPlugin=yh,e.__DEBUG__=Os,e.__info__=jf,e.astToFormula=$r,e.cellTypes=Kf,e.compile=Gr,e.convertAstNodes=Fr,e.coreTypes=Ue,e.functionCache=Zr,e.helpers=Qf,e.invalidateEvaluationCommands=De,e.parse=Nr,e.readonlyAllowedCommands=Pe,e.registries=Yf,e.setTranslationMethod=function(e){i=e},Object.defineProperty(e,"__esModule",{value:!0}),jf.version="15.2.14",jf.date="2024-01-12T13:37:05.872Z",jf.hash="6515f7c"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
3090
+ `;class qf extends t.Component{constructor(e,s={}){super(e,s),this.model=new ku(this.props.data,{evalContext:{env:this.env},transportService:this.props.transportService,client:this.props.client,isReadonly:this.props.isReadonly,snapshotRequested:this.props.snapshotRequested},this.props.stateUpdateMessages),this.sidePanel=t.useState({isOpen:!1,panelProps:{}}),this.linkEditor=t.useState({isOpen:!1}),this.composer=t.useState({topBarFocus:"inactive",gridFocusMode:"inactive"}),this.keyDownMapping={"CTRL+H":()=>this.toggleSidePanel("FindAndReplace",{}),"CTRL+F":()=>this.toggleSidePanel("FindAndReplace",{})},Uf({openSidePanel:(e,t={})=>this.openSidePanel(e,t),toggleSidePanel:(e,t={})=>this.toggleSidePanel(e,t),dispatch:this.model.dispatch,getters:this.model.getters,uuidGenerator:this.model.uuidGenerator,_t:qf._t,clipboard:navigator.clipboard,export:this.model.exportData.bind(this.model),waitForIdle:this.model.waitForIdle.bind(this.model),exportXLSX:this.model.exportXLSX.bind(this.model),openLinkEditor:()=>this.openLinkEditor()}),this.activateFirstSheet()}setup(){Pf(window,"resize",this.render),Pf(document.body,"keyup",this.onKeyup.bind(this)),Pf(window,"beforeunload",this.leaveCollaborativeSession.bind(this)),Vf((()=>this.initiateModelEvents())),Bf((()=>this.leaveCollaborativeSession())),Hf((e=>this.checkReadonly(e)))}get focusTopBarComposer(){return"inactive"===this.model.getters.getEditionMode()?"inactive":this.composer.topBarFocus}get focusGridComposer(){return"inactive"===this.model.getters.getEditionMode()?"inactive":this.composer.gridFocusMode}initiateModelEvents(){this.model.on("update",this,this.render),this.model.on("notify-ui",this,this.onNotifyUI),this.model.on("unexpected-revision-id",this,(()=>this.trigger("unexpected-revision-id"))),this.props.client&&this.model.joinSession(this.props.client)}onNotifyUI(e){if("NOTIFICATION"===e.type)this.env.notifyUser(e.text)}checkReadonly(e){this.props.isReadonly!==e.isReadonly&&this.model.updateReadOnly(e.isReadonly)}leaveCollaborativeSession(){this.model.off("update",this),this.model.leaveSession()}activateFirstSheet(){const e=this.model.getters.getActiveSheetId(),[t]=this.model.getters.getSheets();t.id!==e&&this.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:e,sheetIdTo:t.id})}destroy(){this.model.destroy(),super.destroy()}openSidePanel(e,t){this.sidePanel.component=e,this.sidePanel.panelProps=t,this.sidePanel.isOpen=!0}closeSidePanel(){this.sidePanel.isOpen=!1,this.focusGrid()}openLinkEditor(){this.linkEditor.isOpen=!0}closeLinkEditor(){this.linkEditor.isOpen=!1,this.focusGrid()}toggleSidePanel(e,t){this.sidePanel.isOpen&&e===this.sidePanel.component?(this.sidePanel.isOpen=!1,this.focusGrid()):this.openSidePanel(e,t)}focusGrid(){if(!this._focusGrid)throw new Error("_focusGrid should be exposed by the grid component");this._focusGrid()}save(){this.trigger("save-content",{data:this.model.exportData()})}onKeyup(e){"Control"===e.key&&this.model.getters.getSelectionMode()!==Lh.expanding&&this.model.dispatch("STOP_SELECTION")}onKeydown(e){"Control"!==e.key||e.repeat||this.model.dispatch(this.model.getters.getSelectionMode()===Lh.idle?"PREPARE_SELECTION_EXPANSION":"START_SELECTION_EXPANSION");let t="";(e.ctrlKey||e.metaKey)&&(t+="CTRL+"),t+=e.key.toUpperCase();let s=this.keyDownMapping[t];if(s)return e.preventDefault(),e.stopPropagation(),void s()}onTopBarComposerFocused(e){this.model.getters.isReadonly()||(this.composer.topBarFocus="contentFocus",this.composer.gridFocusMode="inactive",this.setComposerContent({selection:e}||{}),this.env.dispatch("UNFOCUS_SELECTION_INPUT"))}onGridComposerContentFocused(){this.model.getters.isReadonly()||(this.composer.topBarFocus="inactive",this.composer.gridFocusMode="contentFocus",this.setComposerContent({}),this.env.dispatch("UNFOCUS_SELECTION_INPUT"))}onGridComposerCellFocused(e,t){this.model.getters.isReadonly()||(this.composer.topBarFocus="inactive",this.composer.gridFocusMode="cellFocus",this.setComposerContent({content:e,selection:t}||{}),this.env.dispatch("UNFOCUS_SELECTION_INPUT"))}setComposerContent({content:e,selection:t}){"inactive"===this.model.getters.getEditionMode()?this.model.dispatch("START_EDITION",{text:e,selection:t}):e&&this.model.dispatch("SET_CURRENT_CONTENT",{content:e,selection:t})}}qf.template=Gf,qf.style=Wf,qf.components={TopBar:Df,Grid:wf,BottomBar:np,SidePanel:Af,LinkEditor:tf},qf._t=e=>e;const jf={},Xf={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:m,HEADER_WIDTH:v,TOPBAR_HEIGHT:E,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:b,DEFAULT_CELL_HEIGHT:S,SCROLLBAR_WIDTH:C},Yf={autofillModifiersRegistry:Ma,autofillRulesRegistry:Aa,cellMenuRegistry:fl,colMenuRegistry:ml,linkMenuRegistry:vl,functionRegistry:hr,uiPluginRegistry:ld,corePluginRegistry:ad,rowMenuRegistry:El,sidePanelRegistry:Sh,sheetMenuRegistry:Sl,topbarMenuRegistry:Cl,topbarComponentRegistry:Ch,otRegistry:yl,inverseCommandRegistry:Oa,cellRegistry:qr},Kf={LinkCell:sa},Qf={args:Ne,toBoolean:me,toNumber:ue,toString:ge,toXC:ns,toZone:qs,toCartesian:is,numberToLetters:os,createFullMenuItem:Fa,UuidGenerator:Hs,formatDecimal:le,computeTextWidth:vs,isMarkdownLink:xs,parseMarkdownLink:Rs,markdownLink:Ts,createEmptyWorkbookData:fa};e.CorePlugin=va,e.DATETIME_FORMAT=_,e.DataSource=dd,e.DispatchResult=Be,e.Model=ku,e.Registry=Ae,e.Revision=Qh,e.SPREADSHEET_DIMENSIONS=Xf,e.Spreadsheet=qf,e.UIPlugin=yh,e.__DEBUG__=Os,e.__info__=jf,e.astToFormula=$r,e.cellTypes=Kf,e.compile=Gr,e.convertAstNodes=Fr,e.coreTypes=Ue,e.functionCache=Zr,e.helpers=Qf,e.invalidateEvaluationCommands=De,e.parse=Nr,e.readonlyAllowedCommands=Pe,e.registries=Yf,e.setTranslationMethod=function(e){i=e},Object.defineProperty(e,"__esModule",{value:!0}),jf.version="15.2.15",jf.date="2024-01-17T10:22:20.395Z",jf.hash="c78b15d"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odoo/o-spreadsheet",
3
- "version": "15.2.14",
3
+ "version": "15.2.15",
4
4
  "description": "A spreadsheet component",
5
5
  "main": "dist/o-spreadsheet.cjs.js",
6
6
  "browser": "dist/o-spreadsheet.iife.js",