@odoo/o-spreadsheet 16.0.59 → 16.0.62

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.
@@ -1098,9 +1098,16 @@ function deepEquals(o1, o2) {
1098
1098
  }
1099
1099
  return true;
1100
1100
  }
1101
- /** Check if the given array contains all the values of the other array. */
1101
+ /**
1102
+ * Check if the given array contains all the values of the other array.
1103
+ * It makes the assumption that both array do not contain duplicates.
1104
+ */
1102
1105
  function includesAll(arr, values) {
1103
- return values.every((value) => arr.includes(value));
1106
+ if (arr.length < values.length) {
1107
+ return false;
1108
+ }
1109
+ const set = new Set(arr);
1110
+ return values.every((value) => set.has(value));
1104
1111
  }
1105
1112
  /**
1106
1113
  * Return an object with all the keys in the object that have a falsy value removed.
@@ -2375,6 +2382,37 @@ class UuidGenerator {
2375
2382
  setIsFastStrategy(isFast) {
2376
2383
  this.isFastIdStrategy = isFast;
2377
2384
  }
2385
+ /**
2386
+ * Generates a custom UUID using a simple 26^8 method (8-character alphanumeric string with lowercase letters)
2387
+ * This has a higher chance of collision than a UUIDv4, but not only faster to generate than an UUIDV4,
2388
+ * it also has a smaller size, which is preferable to alleviate the overall data size.
2389
+ *
2390
+ * This method is preferable when generating uuids for the core data (sheetId, figureId, etc)
2391
+ * as they will appear several times in the revisions and local history.
2392
+ *
2393
+ */
2394
+ smallUuid() {
2395
+ if (this.isFastIdStrategy) {
2396
+ this.fastIdStart++;
2397
+ return String(this.fastIdStart);
2398
+ //@ts-ignore
2399
+ }
2400
+ else if (window.crypto && window.crypto.getRandomValues) {
2401
+ //@ts-ignore
2402
+ return ([1e7] + -1e3).replace(/[018]/g, (c) => (c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16));
2403
+ }
2404
+ else {
2405
+ // mainly for jest and other browsers that do not have the crypto functionality
2406
+ return "xxxxxxxx-xxxx".replace(/[xy]/g, function (c) {
2407
+ var r = (Math.random() * 16) | 0, v = c == "x" ? r : (r & 0x3) | 0x8;
2408
+ return v.toString(16);
2409
+ });
2410
+ }
2411
+ }
2412
+ /**
2413
+ * Generates an UUIDV4, has astronomically low chance of collision, but is larger in size than the smallUuid.
2414
+ * This method should be used when you need to avoid collisions at all costs, like the id of a revision.
2415
+ */
2378
2416
  uuidv4() {
2379
2417
  if (this.isFastIdStrategy) {
2380
2418
  this.fastIdStart++;
@@ -2488,17 +2526,20 @@ function toZoneWithoutBoundaryChanges(xc) {
2488
2526
  */
2489
2527
  function toUnboundedZone(xc) {
2490
2528
  const zone = toZoneWithoutBoundaryChanges(xc);
2529
+ reorderZone(zone);
2530
+ return zone;
2531
+ }
2532
+ function reorderZone(zone) {
2491
2533
  if (zone.right !== undefined && zone.right < zone.left) {
2492
- const tmp = zone.left;
2534
+ const right = zone.left;
2493
2535
  zone.left = zone.right;
2494
- zone.right = tmp;
2536
+ zone.right = right;
2495
2537
  }
2496
2538
  if (zone.bottom !== undefined && zone.bottom < zone.top) {
2497
- const tmp = zone.top;
2539
+ const bottom = zone.top;
2498
2540
  zone.top = zone.bottom;
2499
- zone.bottom = tmp;
2541
+ zone.bottom = bottom;
2500
2542
  }
2501
- return zone;
2502
2543
  }
2503
2544
  /**
2504
2545
  * Convert from a cartesian reference to a Zone.
@@ -3386,67 +3427,68 @@ var CommandResult;
3386
3427
  CommandResult[CommandResult["InvalidRange"] = 25] = "InvalidRange";
3387
3428
  CommandResult[CommandResult["InvalidZones"] = 26] = "InvalidZones";
3388
3429
  CommandResult[CommandResult["InvalidSheetId"] = 27] = "InvalidSheetId";
3389
- CommandResult[CommandResult["InputAlreadyFocused"] = 28] = "InputAlreadyFocused";
3390
- CommandResult[CommandResult["MaximumRangesReached"] = 29] = "MaximumRangesReached";
3391
- CommandResult[CommandResult["InvalidInputId"] = 30] = "InvalidInputId";
3392
- CommandResult[CommandResult["InvalidChartDefinition"] = 31] = "InvalidChartDefinition";
3393
- CommandResult[CommandResult["InvalidDataSet"] = 32] = "InvalidDataSet";
3394
- CommandResult[CommandResult["InvalidLabelRange"] = 33] = "InvalidLabelRange";
3395
- CommandResult[CommandResult["InvalidScorecardKeyValue"] = 34] = "InvalidScorecardKeyValue";
3396
- CommandResult[CommandResult["InvalidScorecardBaseline"] = 35] = "InvalidScorecardBaseline";
3397
- CommandResult[CommandResult["InvalidGaugeDataRange"] = 36] = "InvalidGaugeDataRange";
3398
- CommandResult[CommandResult["EmptyGaugeRangeMin"] = 37] = "EmptyGaugeRangeMin";
3399
- CommandResult[CommandResult["GaugeRangeMinNaN"] = 38] = "GaugeRangeMinNaN";
3400
- CommandResult[CommandResult["EmptyGaugeRangeMax"] = 39] = "EmptyGaugeRangeMax";
3401
- CommandResult[CommandResult["GaugeRangeMaxNaN"] = 40] = "GaugeRangeMaxNaN";
3402
- CommandResult[CommandResult["GaugeRangeMinBiggerThanRangeMax"] = 41] = "GaugeRangeMinBiggerThanRangeMax";
3403
- CommandResult[CommandResult["GaugeLowerInflectionPointNaN"] = 42] = "GaugeLowerInflectionPointNaN";
3404
- CommandResult[CommandResult["GaugeUpperInflectionPointNaN"] = 43] = "GaugeUpperInflectionPointNaN";
3405
- CommandResult[CommandResult["GaugeLowerBiggerThanUpper"] = 44] = "GaugeLowerBiggerThanUpper";
3406
- CommandResult[CommandResult["InvalidAutofillSelection"] = 45] = "InvalidAutofillSelection";
3407
- CommandResult[CommandResult["WrongComposerSelection"] = 46] = "WrongComposerSelection";
3408
- CommandResult[CommandResult["MinBiggerThanMax"] = 47] = "MinBiggerThanMax";
3409
- CommandResult[CommandResult["LowerBiggerThanUpper"] = 48] = "LowerBiggerThanUpper";
3410
- CommandResult[CommandResult["MidBiggerThanMax"] = 49] = "MidBiggerThanMax";
3411
- CommandResult[CommandResult["MinBiggerThanMid"] = 50] = "MinBiggerThanMid";
3412
- CommandResult[CommandResult["FirstArgMissing"] = 51] = "FirstArgMissing";
3413
- CommandResult[CommandResult["SecondArgMissing"] = 52] = "SecondArgMissing";
3414
- CommandResult[CommandResult["MinNaN"] = 53] = "MinNaN";
3415
- CommandResult[CommandResult["MidNaN"] = 54] = "MidNaN";
3416
- CommandResult[CommandResult["MaxNaN"] = 55] = "MaxNaN";
3417
- CommandResult[CommandResult["ValueUpperInflectionNaN"] = 56] = "ValueUpperInflectionNaN";
3418
- CommandResult[CommandResult["ValueLowerInflectionNaN"] = 57] = "ValueLowerInflectionNaN";
3419
- CommandResult[CommandResult["MinInvalidFormula"] = 58] = "MinInvalidFormula";
3420
- CommandResult[CommandResult["MidInvalidFormula"] = 59] = "MidInvalidFormula";
3421
- CommandResult[CommandResult["MaxInvalidFormula"] = 60] = "MaxInvalidFormula";
3422
- CommandResult[CommandResult["ValueUpperInvalidFormula"] = 61] = "ValueUpperInvalidFormula";
3423
- CommandResult[CommandResult["ValueLowerInvalidFormula"] = 62] = "ValueLowerInvalidFormula";
3424
- CommandResult[CommandResult["InvalidSortZone"] = 63] = "InvalidSortZone";
3425
- CommandResult[CommandResult["WaitingSessionConfirmation"] = 64] = "WaitingSessionConfirmation";
3426
- CommandResult[CommandResult["MergeOverlap"] = 65] = "MergeOverlap";
3427
- CommandResult[CommandResult["TooManyHiddenElements"] = 66] = "TooManyHiddenElements";
3428
- CommandResult[CommandResult["Readonly"] = 67] = "Readonly";
3429
- CommandResult[CommandResult["InvalidViewportSize"] = 68] = "InvalidViewportSize";
3430
- CommandResult[CommandResult["InvalidScrollingDirection"] = 69] = "InvalidScrollingDirection";
3431
- CommandResult[CommandResult["FigureDoesNotExist"] = 70] = "FigureDoesNotExist";
3432
- CommandResult[CommandResult["InvalidConditionalFormatId"] = 71] = "InvalidConditionalFormatId";
3433
- CommandResult[CommandResult["InvalidCellPopover"] = 72] = "InvalidCellPopover";
3434
- CommandResult[CommandResult["EmptyTarget"] = 73] = "EmptyTarget";
3435
- CommandResult[CommandResult["InvalidFreezeQuantity"] = 74] = "InvalidFreezeQuantity";
3436
- CommandResult[CommandResult["FrozenPaneOverlap"] = 75] = "FrozenPaneOverlap";
3437
- CommandResult[CommandResult["ValuesNotChanged"] = 76] = "ValuesNotChanged";
3438
- CommandResult[CommandResult["InvalidFilterZone"] = 77] = "InvalidFilterZone";
3439
- CommandResult[CommandResult["FilterOverlap"] = 78] = "FilterOverlap";
3440
- CommandResult[CommandResult["FilterNotFound"] = 79] = "FilterNotFound";
3441
- CommandResult[CommandResult["MergeInFilter"] = 80] = "MergeInFilter";
3442
- CommandResult[CommandResult["NonContinuousTargets"] = 81] = "NonContinuousTargets";
3443
- CommandResult[CommandResult["DuplicatedFigureId"] = 82] = "DuplicatedFigureId";
3444
- CommandResult[CommandResult["InvalidSelectionStep"] = 83] = "InvalidSelectionStep";
3445
- CommandResult[CommandResult["DuplicatedChartId"] = 84] = "DuplicatedChartId";
3446
- CommandResult[CommandResult["ChartDoesNotExist"] = 85] = "ChartDoesNotExist";
3447
- CommandResult[CommandResult["InvalidHeaderIndex"] = 86] = "InvalidHeaderIndex";
3448
- CommandResult[CommandResult["InvalidQuantity"] = 87] = "InvalidQuantity";
3449
- CommandResult[CommandResult["NoChanges"] = 88] = "NoChanges";
3430
+ CommandResult[CommandResult["InvalidCellId"] = 28] = "InvalidCellId";
3431
+ CommandResult[CommandResult["InputAlreadyFocused"] = 29] = "InputAlreadyFocused";
3432
+ CommandResult[CommandResult["MaximumRangesReached"] = 30] = "MaximumRangesReached";
3433
+ CommandResult[CommandResult["InvalidInputId"] = 31] = "InvalidInputId";
3434
+ CommandResult[CommandResult["InvalidChartDefinition"] = 32] = "InvalidChartDefinition";
3435
+ CommandResult[CommandResult["InvalidDataSet"] = 33] = "InvalidDataSet";
3436
+ CommandResult[CommandResult["InvalidLabelRange"] = 34] = "InvalidLabelRange";
3437
+ CommandResult[CommandResult["InvalidScorecardKeyValue"] = 35] = "InvalidScorecardKeyValue";
3438
+ CommandResult[CommandResult["InvalidScorecardBaseline"] = 36] = "InvalidScorecardBaseline";
3439
+ CommandResult[CommandResult["InvalidGaugeDataRange"] = 37] = "InvalidGaugeDataRange";
3440
+ CommandResult[CommandResult["EmptyGaugeRangeMin"] = 38] = "EmptyGaugeRangeMin";
3441
+ CommandResult[CommandResult["GaugeRangeMinNaN"] = 39] = "GaugeRangeMinNaN";
3442
+ CommandResult[CommandResult["EmptyGaugeRangeMax"] = 40] = "EmptyGaugeRangeMax";
3443
+ CommandResult[CommandResult["GaugeRangeMaxNaN"] = 41] = "GaugeRangeMaxNaN";
3444
+ CommandResult[CommandResult["GaugeRangeMinBiggerThanRangeMax"] = 42] = "GaugeRangeMinBiggerThanRangeMax";
3445
+ CommandResult[CommandResult["GaugeLowerInflectionPointNaN"] = 43] = "GaugeLowerInflectionPointNaN";
3446
+ CommandResult[CommandResult["GaugeUpperInflectionPointNaN"] = 44] = "GaugeUpperInflectionPointNaN";
3447
+ CommandResult[CommandResult["GaugeLowerBiggerThanUpper"] = 45] = "GaugeLowerBiggerThanUpper";
3448
+ CommandResult[CommandResult["InvalidAutofillSelection"] = 46] = "InvalidAutofillSelection";
3449
+ CommandResult[CommandResult["WrongComposerSelection"] = 47] = "WrongComposerSelection";
3450
+ CommandResult[CommandResult["MinBiggerThanMax"] = 48] = "MinBiggerThanMax";
3451
+ CommandResult[CommandResult["LowerBiggerThanUpper"] = 49] = "LowerBiggerThanUpper";
3452
+ CommandResult[CommandResult["MidBiggerThanMax"] = 50] = "MidBiggerThanMax";
3453
+ CommandResult[CommandResult["MinBiggerThanMid"] = 51] = "MinBiggerThanMid";
3454
+ CommandResult[CommandResult["FirstArgMissing"] = 52] = "FirstArgMissing";
3455
+ CommandResult[CommandResult["SecondArgMissing"] = 53] = "SecondArgMissing";
3456
+ CommandResult[CommandResult["MinNaN"] = 54] = "MinNaN";
3457
+ CommandResult[CommandResult["MidNaN"] = 55] = "MidNaN";
3458
+ CommandResult[CommandResult["MaxNaN"] = 56] = "MaxNaN";
3459
+ CommandResult[CommandResult["ValueUpperInflectionNaN"] = 57] = "ValueUpperInflectionNaN";
3460
+ CommandResult[CommandResult["ValueLowerInflectionNaN"] = 58] = "ValueLowerInflectionNaN";
3461
+ CommandResult[CommandResult["MinInvalidFormula"] = 59] = "MinInvalidFormula";
3462
+ CommandResult[CommandResult["MidInvalidFormula"] = 60] = "MidInvalidFormula";
3463
+ CommandResult[CommandResult["MaxInvalidFormula"] = 61] = "MaxInvalidFormula";
3464
+ CommandResult[CommandResult["ValueUpperInvalidFormula"] = 62] = "ValueUpperInvalidFormula";
3465
+ CommandResult[CommandResult["ValueLowerInvalidFormula"] = 63] = "ValueLowerInvalidFormula";
3466
+ CommandResult[CommandResult["InvalidSortZone"] = 64] = "InvalidSortZone";
3467
+ CommandResult[CommandResult["WaitingSessionConfirmation"] = 65] = "WaitingSessionConfirmation";
3468
+ CommandResult[CommandResult["MergeOverlap"] = 66] = "MergeOverlap";
3469
+ CommandResult[CommandResult["TooManyHiddenElements"] = 67] = "TooManyHiddenElements";
3470
+ CommandResult[CommandResult["Readonly"] = 68] = "Readonly";
3471
+ CommandResult[CommandResult["InvalidViewportSize"] = 69] = "InvalidViewportSize";
3472
+ CommandResult[CommandResult["InvalidScrollingDirection"] = 70] = "InvalidScrollingDirection";
3473
+ CommandResult[CommandResult["FigureDoesNotExist"] = 71] = "FigureDoesNotExist";
3474
+ CommandResult[CommandResult["InvalidConditionalFormatId"] = 72] = "InvalidConditionalFormatId";
3475
+ CommandResult[CommandResult["InvalidCellPopover"] = 73] = "InvalidCellPopover";
3476
+ CommandResult[CommandResult["EmptyTarget"] = 74] = "EmptyTarget";
3477
+ CommandResult[CommandResult["InvalidFreezeQuantity"] = 75] = "InvalidFreezeQuantity";
3478
+ CommandResult[CommandResult["FrozenPaneOverlap"] = 76] = "FrozenPaneOverlap";
3479
+ CommandResult[CommandResult["ValuesNotChanged"] = 77] = "ValuesNotChanged";
3480
+ CommandResult[CommandResult["InvalidFilterZone"] = 78] = "InvalidFilterZone";
3481
+ CommandResult[CommandResult["FilterOverlap"] = 79] = "FilterOverlap";
3482
+ CommandResult[CommandResult["FilterNotFound"] = 80] = "FilterNotFound";
3483
+ CommandResult[CommandResult["MergeInFilter"] = 81] = "MergeInFilter";
3484
+ CommandResult[CommandResult["NonContinuousTargets"] = 82] = "NonContinuousTargets";
3485
+ CommandResult[CommandResult["DuplicatedFigureId"] = 83] = "DuplicatedFigureId";
3486
+ CommandResult[CommandResult["InvalidSelectionStep"] = 84] = "InvalidSelectionStep";
3487
+ CommandResult[CommandResult["DuplicatedChartId"] = 85] = "DuplicatedChartId";
3488
+ CommandResult[CommandResult["ChartDoesNotExist"] = 86] = "ChartDoesNotExist";
3489
+ CommandResult[CommandResult["InvalidHeaderIndex"] = 87] = "InvalidHeaderIndex";
3490
+ CommandResult[CommandResult["InvalidQuantity"] = 88] = "InvalidQuantity";
3491
+ CommandResult[CommandResult["NoChanges"] = 89] = "NoChanges";
3450
3492
  })(CommandResult || (CommandResult = {}));
3451
3493
 
3452
3494
  function isMatrix(x) {
@@ -4976,7 +5018,7 @@ function interactiveSortSelection(env, sheetId, anchor, zone, sortDirection) {
4976
5018
  });
4977
5019
  }
4978
5020
  }
4979
- if (result.isCancelledBecause(63 /* CommandResult.InvalidSortZone */)) {
5021
+ if (result.isCancelledBecause(64 /* CommandResult.InvalidSortZone */)) {
4980
5022
  const { col, row } = anchor;
4981
5023
  env.model.selection.selectZone({ cell: { col, row }, zone });
4982
5024
  env.raiseError(_lt("Cannot sort. To sort, select only cells or only merges that have the same size."));
@@ -4999,13 +5041,13 @@ const AddFilterInteractiveContent = {
4999
5041
  };
5000
5042
  function interactiveAddFilter(env, sheetId, target) {
5001
5043
  const result = env.model.dispatch("CREATE_FILTER_TABLE", { target, sheetId });
5002
- if (result.isCancelledBecause(78 /* CommandResult.FilterOverlap */)) {
5044
+ if (result.isCancelledBecause(79 /* CommandResult.FilterOverlap */)) {
5003
5045
  env.raiseError(AddFilterInteractiveContent.filterOverlap);
5004
5046
  }
5005
- else if (result.isCancelledBecause(80 /* CommandResult.MergeInFilter */)) {
5047
+ else if (result.isCancelledBecause(81 /* CommandResult.MergeInFilter */)) {
5006
5048
  env.raiseError(AddFilterInteractiveContent.mergeInFilter);
5007
5049
  }
5008
- else if (result.isCancelledBecause(81 /* CommandResult.NonContinuousTargets */)) {
5050
+ else if (result.isCancelledBecause(82 /* CommandResult.NonContinuousTargets */)) {
5009
5051
  env.raiseError(AddFilterInteractiveContent.nonContinuousTargets);
5010
5052
  }
5011
5053
  }
@@ -5027,7 +5069,7 @@ function handlePasteResult(env, result) {
5027
5069
  else if (result.reasons.includes(22 /* CommandResult.WrongFigurePasteOption */)) {
5028
5070
  env.raiseError(PasteInteractiveContent.wrongFigurePasteOption);
5029
5071
  }
5030
- else if (result.reasons.includes(75 /* CommandResult.FrozenPaneOverlap */)) {
5072
+ else if (result.reasons.includes(76 /* CommandResult.FrozenPaneOverlap */)) {
5031
5073
  env.raiseError(PasteInteractiveContent.frozenPaneOverlap);
5032
5074
  }
5033
5075
  }
@@ -5532,7 +5574,7 @@ const UNHIDE_ROWS_ACTION = (env) => {
5532
5574
  const CREATE_SHEET_ACTION = (env) => {
5533
5575
  const activeSheetId = env.model.getters.getActiveSheetId();
5534
5576
  const position = env.model.getters.getSheetIds().indexOf(activeSheetId) + 1;
5535
- const sheetId = env.model.uuidGenerator.uuidv4();
5577
+ const sheetId = env.model.uuidGenerator.smallUuid();
5536
5578
  env.model.dispatch("CREATE_SHEET", { sheetId, position });
5537
5579
  env.model.dispatch("ACTIVATE_SHEET", { sheetIdFrom: activeSheetId, sheetIdTo: sheetId });
5538
5580
  };
@@ -5543,7 +5585,7 @@ const CREATE_CHART = (env) => {
5543
5585
  const getters = env.model.getters;
5544
5586
  const zone = getters.getSelectedZone();
5545
5587
  let dataSetZone = zone;
5546
- const id = env.model.uuidGenerator.uuidv4();
5588
+ const id = env.model.uuidGenerator.smallUuid();
5547
5589
  let labelRange;
5548
5590
  if (zone.left !== zone.right) {
5549
5591
  dataSetZone = { ...zone, left: zone.left + 1 };
@@ -6019,7 +6061,7 @@ sheetMenuRegistry
6019
6061
  name: _lt("Delete"),
6020
6062
  sequence: 10,
6021
6063
  isVisible: (env) => {
6022
- return env.model.getters.getSheetIds().length > 1;
6064
+ return env.model.getters.getVisibleSheetIds().length > 1;
6023
6065
  },
6024
6066
  action: (env) => env.askConfirmation(_lt("Are you sure you want to delete this sheet ?"), () => {
6025
6067
  env.model.dispatch("DELETE_SHEET", { sheetId: env.model.getters.getActiveSheetId() });
@@ -6030,7 +6072,7 @@ sheetMenuRegistry
6030
6072
  sequence: 20,
6031
6073
  action: (env) => {
6032
6074
  const sheetIdFrom = env.model.getters.getActiveSheetId();
6033
- const sheetIdTo = env.model.uuidGenerator.uuidv4();
6075
+ const sheetIdTo = env.model.uuidGenerator.smallUuid();
6034
6076
  env.model.dispatch("DUPLICATE_SHEET", {
6035
6077
  sheetId: sheetIdFrom,
6036
6078
  sheetIdTo,
@@ -6078,22 +6120,22 @@ sheetMenuRegistry
6078
6120
  const CfTerms = {
6079
6121
  Errors: {
6080
6122
  [25 /* CommandResult.InvalidRange */]: _lt("The range is invalid"),
6081
- [51 /* CommandResult.FirstArgMissing */]: _lt("The argument is missing. Please provide a value"),
6082
- [52 /* CommandResult.SecondArgMissing */]: _lt("The second argument is missing. Please provide a value"),
6083
- [53 /* CommandResult.MinNaN */]: _lt("The minpoint must be a number"),
6084
- [54 /* CommandResult.MidNaN */]: _lt("The midpoint must be a number"),
6085
- [55 /* CommandResult.MaxNaN */]: _lt("The maxpoint must be a number"),
6086
- [56 /* CommandResult.ValueUpperInflectionNaN */]: _lt("The first value must be a number"),
6087
- [57 /* CommandResult.ValueLowerInflectionNaN */]: _lt("The second value must be a number"),
6088
- [47 /* CommandResult.MinBiggerThanMax */]: _lt("Minimum must be smaller then Maximum"),
6089
- [50 /* CommandResult.MinBiggerThanMid */]: _lt("Minimum must be smaller then Midpoint"),
6090
- [49 /* CommandResult.MidBiggerThanMax */]: _lt("Midpoint must be smaller then Maximum"),
6091
- [48 /* CommandResult.LowerBiggerThanUpper */]: _lt("Lower inflection point must be smaller than upper inflection point"),
6092
- [58 /* CommandResult.MinInvalidFormula */]: _lt("Invalid Minpoint formula"),
6093
- [60 /* CommandResult.MaxInvalidFormula */]: _lt("Invalid Maxpoint formula"),
6094
- [59 /* CommandResult.MidInvalidFormula */]: _lt("Invalid Midpoint formula"),
6095
- [61 /* CommandResult.ValueUpperInvalidFormula */]: _lt("Invalid upper inflection point formula"),
6096
- [62 /* CommandResult.ValueLowerInvalidFormula */]: _lt("Invalid lower inflection point formula"),
6123
+ [52 /* CommandResult.FirstArgMissing */]: _lt("The argument is missing. Please provide a value"),
6124
+ [53 /* CommandResult.SecondArgMissing */]: _lt("The second argument is missing. Please provide a value"),
6125
+ [54 /* CommandResult.MinNaN */]: _lt("The minpoint must be a number"),
6126
+ [55 /* CommandResult.MidNaN */]: _lt("The midpoint must be a number"),
6127
+ [56 /* CommandResult.MaxNaN */]: _lt("The maxpoint must be a number"),
6128
+ [57 /* CommandResult.ValueUpperInflectionNaN */]: _lt("The first value must be a number"),
6129
+ [58 /* CommandResult.ValueLowerInflectionNaN */]: _lt("The second value must be a number"),
6130
+ [48 /* CommandResult.MinBiggerThanMax */]: _lt("Minimum must be smaller then Maximum"),
6131
+ [51 /* CommandResult.MinBiggerThanMid */]: _lt("Minimum must be smaller then Midpoint"),
6132
+ [50 /* CommandResult.MidBiggerThanMax */]: _lt("Midpoint must be smaller then Maximum"),
6133
+ [49 /* CommandResult.LowerBiggerThanUpper */]: _lt("Lower inflection point must be smaller than upper inflection point"),
6134
+ [59 /* CommandResult.MinInvalidFormula */]: _lt("Invalid Minpoint formula"),
6135
+ [61 /* CommandResult.MaxInvalidFormula */]: _lt("Invalid Maxpoint formula"),
6136
+ [60 /* CommandResult.MidInvalidFormula */]: _lt("Invalid Midpoint formula"),
6137
+ [62 /* CommandResult.ValueUpperInvalidFormula */]: _lt("Invalid upper inflection point formula"),
6138
+ [63 /* CommandResult.ValueLowerInvalidFormula */]: _lt("Invalid lower inflection point formula"),
6097
6139
  [24 /* CommandResult.EmptyRange */]: _lt("A range needs to be defined"),
6098
6140
  Unexpected: _lt("The rule is invalid for an unknown reason"),
6099
6141
  },
@@ -6121,20 +6163,20 @@ const ChartTerms = {
6121
6163
  Errors: {
6122
6164
  Unexpected: _lt("The chart definition is invalid for an unknown reason"),
6123
6165
  // BASIC CHART ERRORS (LINE | BAR | PIE)
6124
- [32 /* CommandResult.InvalidDataSet */]: _lt("The dataset is invalid"),
6125
- [33 /* CommandResult.InvalidLabelRange */]: _lt("Labels are invalid"),
6166
+ [33 /* CommandResult.InvalidDataSet */]: _lt("The dataset is invalid"),
6167
+ [34 /* CommandResult.InvalidLabelRange */]: _lt("Labels are invalid"),
6126
6168
  // SCORECARD CHART ERRORS
6127
- [34 /* CommandResult.InvalidScorecardKeyValue */]: _lt("The key value is invalid"),
6128
- [35 /* CommandResult.InvalidScorecardBaseline */]: _lt("The baseline value is invalid"),
6169
+ [35 /* CommandResult.InvalidScorecardKeyValue */]: _lt("The key value is invalid"),
6170
+ [36 /* CommandResult.InvalidScorecardBaseline */]: _lt("The baseline value is invalid"),
6129
6171
  // GAUGE CHART ERRORS
6130
- [36 /* CommandResult.InvalidGaugeDataRange */]: _lt("The data range is invalid"),
6131
- [37 /* CommandResult.EmptyGaugeRangeMin */]: _lt("A minimum range limit value is needed"),
6132
- [38 /* CommandResult.GaugeRangeMinNaN */]: _lt("The minimum range limit value must be a number"),
6133
- [39 /* CommandResult.EmptyGaugeRangeMax */]: _lt("A maximum range limit value is needed"),
6134
- [40 /* CommandResult.GaugeRangeMaxNaN */]: _lt("The maximum range limit value must be a number"),
6135
- [41 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */]: _lt("Minimum range limit must be smaller than maximum range limit"),
6136
- [42 /* CommandResult.GaugeLowerInflectionPointNaN */]: _lt("The lower inflection point value must be a number"),
6137
- [43 /* CommandResult.GaugeUpperInflectionPointNaN */]: _lt("The upper inflection point value must be a number"),
6172
+ [37 /* CommandResult.InvalidGaugeDataRange */]: _lt("The data range is invalid"),
6173
+ [38 /* CommandResult.EmptyGaugeRangeMin */]: _lt("A minimum range limit value is needed"),
6174
+ [39 /* CommandResult.GaugeRangeMinNaN */]: _lt("The minimum range limit value must be a number"),
6175
+ [40 /* CommandResult.EmptyGaugeRangeMax */]: _lt("A maximum range limit value is needed"),
6176
+ [41 /* CommandResult.GaugeRangeMaxNaN */]: _lt("The maximum range limit value must be a number"),
6177
+ [42 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */]: _lt("Minimum range limit must be smaller than maximum range limit"),
6178
+ [43 /* CommandResult.GaugeLowerInflectionPointNaN */]: _lt("The lower inflection point value must be a number"),
6179
+ [44 /* CommandResult.GaugeUpperInflectionPointNaN */]: _lt("The upper inflection point value must be a number"),
6138
6180
  },
6139
6181
  };
6140
6182
  const NumberFormatTerms = {
@@ -6158,7 +6200,7 @@ function interactiveFreezeColumnsRows(env, dimension, base) {
6158
6200
  const sheetId = env.model.getters.getActiveSheetId();
6159
6201
  const cmd = dimension === "COL" ? "FREEZE_COLUMNS" : "FREEZE_ROWS";
6160
6202
  const result = env.model.dispatch(cmd, { sheetId, quantity: base });
6161
- if (result.isCancelledBecause(65 /* CommandResult.MergeOverlap */)) {
6203
+ if (result.isCancelledBecause(66 /* CommandResult.MergeOverlap */)) {
6162
6204
  env.raiseError(MergeErrorMessage);
6163
6205
  }
6164
6206
  }
@@ -6669,7 +6711,7 @@ css /* scss */ `
6669
6711
  class SelectionInput extends Component {
6670
6712
  constructor() {
6671
6713
  super(...arguments);
6672
- this.id = uuidGenerator$1.uuidv4();
6714
+ this.id = uuidGenerator$1.smallUuid();
6673
6715
  this.previousRanges = this.props.ranges || [];
6674
6716
  this.originSheet = this.env.model.getters.getActiveSheetId();
6675
6717
  this.state = useState({
@@ -6804,11 +6846,11 @@ class LineBarPieConfigPanel extends Component {
6804
6846
  }
6805
6847
  get isDatasetInvalid() {
6806
6848
  var _a;
6807
- return !!((_a = this.state.datasetDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(32 /* CommandResult.InvalidDataSet */));
6849
+ return !!((_a = this.state.datasetDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(33 /* CommandResult.InvalidDataSet */));
6808
6850
  }
6809
6851
  get isLabelInvalid() {
6810
6852
  var _a;
6811
- return !!((_a = this.state.labelsDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(33 /* CommandResult.InvalidLabelRange */));
6853
+ return !!((_a = this.state.labelsDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(34 /* CommandResult.InvalidLabelRange */));
6812
6854
  }
6813
6855
  onUpdateDataSetsHaveTitle(ev) {
6814
6856
  this.props.updateChart(this.props.figureId, {
@@ -7152,11 +7194,11 @@ function checkDataset(definition) {
7152
7194
  if (definition.dataSets) {
7153
7195
  const invalidRanges = definition.dataSets.find((range) => !rangeReference.test(range)) !== undefined;
7154
7196
  if (invalidRanges) {
7155
- return 32 /* CommandResult.InvalidDataSet */;
7197
+ return 33 /* CommandResult.InvalidDataSet */;
7156
7198
  }
7157
7199
  const zones = definition.dataSets.map(toUnboundedZone);
7158
7200
  if (zones.some((zone) => zone.top !== zone.bottom && isFullRow(zone))) {
7159
- return 32 /* CommandResult.InvalidDataSet */;
7201
+ return 33 /* CommandResult.InvalidDataSet */;
7160
7202
  }
7161
7203
  }
7162
7204
  return 0 /* CommandResult.Success */;
@@ -7165,7 +7207,7 @@ function checkLabelRange(definition) {
7165
7207
  if (definition.labelRange) {
7166
7208
  const invalidLabels = !rangeReference.test(definition.labelRange || "");
7167
7209
  if (invalidLabels) {
7168
- return 33 /* CommandResult.InvalidLabelRange */;
7210
+ return 34 /* CommandResult.InvalidLabelRange */;
7169
7211
  }
7170
7212
  }
7171
7213
  return 0 /* CommandResult.Success */;
@@ -7626,7 +7668,7 @@ chartRegistry.add("gauge", {
7626
7668
  });
7627
7669
  function isDataRangeValid(definition) {
7628
7670
  return definition.dataRange && !rangeReference.test(definition.dataRange)
7629
- ? 36 /* CommandResult.InvalidGaugeDataRange */
7671
+ ? 37 /* CommandResult.InvalidGaugeDataRange */
7630
7672
  : 0 /* CommandResult.Success */;
7631
7673
  }
7632
7674
  function checkRangeLimits(check, batchValidations) {
@@ -7658,7 +7700,7 @@ function checkInflectionPointsValue(check, batchValidations) {
7658
7700
  function checkRangeMinBiggerThanRangeMax(definition) {
7659
7701
  if (definition.sectionRule) {
7660
7702
  if (Number(definition.sectionRule.rangeMin) >= Number(definition.sectionRule.rangeMax)) {
7661
- return 41 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */;
7703
+ return 42 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */;
7662
7704
  }
7663
7705
  }
7664
7706
  return 0 /* CommandResult.Success */;
@@ -7667,9 +7709,9 @@ function checkEmpty(value, valueName) {
7667
7709
  if (value === "") {
7668
7710
  switch (valueName) {
7669
7711
  case "rangeMin":
7670
- return 37 /* CommandResult.EmptyGaugeRangeMin */;
7712
+ return 38 /* CommandResult.EmptyGaugeRangeMin */;
7671
7713
  case "rangeMax":
7672
- return 39 /* CommandResult.EmptyGaugeRangeMax */;
7714
+ return 40 /* CommandResult.EmptyGaugeRangeMax */;
7673
7715
  }
7674
7716
  }
7675
7717
  return 0 /* CommandResult.Success */;
@@ -7678,13 +7720,13 @@ function checkNaN(value, valueName) {
7678
7720
  if (isNaN(value)) {
7679
7721
  switch (valueName) {
7680
7722
  case "rangeMin":
7681
- return 38 /* CommandResult.GaugeRangeMinNaN */;
7723
+ return 39 /* CommandResult.GaugeRangeMinNaN */;
7682
7724
  case "rangeMax":
7683
- return 40 /* CommandResult.GaugeRangeMaxNaN */;
7725
+ return 41 /* CommandResult.GaugeRangeMaxNaN */;
7684
7726
  case "lowerInflectionPointValue":
7685
- return 42 /* CommandResult.GaugeLowerInflectionPointNaN */;
7727
+ return 43 /* CommandResult.GaugeLowerInflectionPointNaN */;
7686
7728
  case "upperInflectionPointValue":
7687
- return 43 /* CommandResult.GaugeUpperInflectionPointNaN */;
7729
+ return 44 /* CommandResult.GaugeUpperInflectionPointNaN */;
7688
7730
  }
7689
7731
  }
7690
7732
  return 0 /* CommandResult.Success */;
@@ -8425,7 +8467,7 @@ function createPieChartRuntime(chart, getters) {
8425
8467
  const dataset = {
8426
8468
  label,
8427
8469
  data,
8428
- borderColor: "#FFFFFF",
8470
+ borderColor: chart.background || "#FFFFFF",
8429
8471
  backgroundColor,
8430
8472
  };
8431
8473
  config.data.datasets.push(dataset);
@@ -8444,12 +8486,12 @@ chartRegistry.add("scorecard", {
8444
8486
  });
8445
8487
  function checkKeyValue(definition) {
8446
8488
  return definition.keyValue && !rangeReference.test(definition.keyValue)
8447
- ? 34 /* CommandResult.InvalidScorecardKeyValue */
8489
+ ? 35 /* CommandResult.InvalidScorecardKeyValue */
8448
8490
  : 0 /* CommandResult.Success */;
8449
8491
  }
8450
8492
  function checkBaseline(definition) {
8451
8493
  return definition.baseline && !rangeReference.test(definition.baseline)
8452
- ? 35 /* CommandResult.InvalidScorecardBaseline */
8494
+ ? 36 /* CommandResult.InvalidScorecardBaseline */
8453
8495
  : 0 /* CommandResult.Success */;
8454
8496
  }
8455
8497
  class ScorecardChart$1 extends AbstractChart {
@@ -8878,7 +8920,7 @@ class GaugeChartConfigPanel extends Component {
8878
8920
  }
8879
8921
  get isDataRangeInvalid() {
8880
8922
  var _a;
8881
- return !!((_a = this.state.dataRangeDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(36 /* CommandResult.InvalidGaugeDataRange */));
8923
+ return !!((_a = this.state.dataRangeDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(37 /* CommandResult.InvalidGaugeDataRange */));
8882
8924
  }
8883
8925
  onDataRangeChanged(ranges) {
8884
8926
  this.dataRange = ranges[0];
@@ -8965,28 +9007,28 @@ class GaugeChartDesignPanel extends Component {
8965
9007
  }
8966
9008
  isRangeMinInvalid() {
8967
9009
  var _a, _b, _c;
8968
- return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(37 /* CommandResult.EmptyGaugeRangeMin */)) ||
8969
- ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(38 /* CommandResult.GaugeRangeMinNaN */)) ||
8970
- ((_c = this.state.sectionRuleDispatchResult) === null || _c === void 0 ? void 0 : _c.isCancelledBecause(41 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */)));
9010
+ return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(38 /* CommandResult.EmptyGaugeRangeMin */)) ||
9011
+ ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(39 /* CommandResult.GaugeRangeMinNaN */)) ||
9012
+ ((_c = this.state.sectionRuleDispatchResult) === null || _c === void 0 ? void 0 : _c.isCancelledBecause(42 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */)));
8971
9013
  }
8972
9014
  isRangeMaxInvalid() {
8973
9015
  var _a, _b, _c;
8974
- return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(39 /* CommandResult.EmptyGaugeRangeMax */)) ||
8975
- ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(40 /* CommandResult.GaugeRangeMaxNaN */)) ||
8976
- ((_c = this.state.sectionRuleDispatchResult) === null || _c === void 0 ? void 0 : _c.isCancelledBecause(41 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */)));
9016
+ return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(40 /* CommandResult.EmptyGaugeRangeMax */)) ||
9017
+ ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(41 /* CommandResult.GaugeRangeMaxNaN */)) ||
9018
+ ((_c = this.state.sectionRuleDispatchResult) === null || _c === void 0 ? void 0 : _c.isCancelledBecause(42 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */)));
8977
9019
  }
8978
9020
  // ---------------------------------------------------------------------------
8979
9021
  // COLOR_SECTION_TEMPLATE
8980
9022
  // ---------------------------------------------------------------------------
8981
9023
  get isLowerInflectionPointInvalid() {
8982
9024
  var _a, _b;
8983
- return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(42 /* CommandResult.GaugeLowerInflectionPointNaN */)) ||
8984
- ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(44 /* CommandResult.GaugeLowerBiggerThanUpper */)));
9025
+ return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(43 /* CommandResult.GaugeLowerInflectionPointNaN */)) ||
9026
+ ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(45 /* CommandResult.GaugeLowerBiggerThanUpper */)));
8985
9027
  }
8986
9028
  get isUpperInflectionPointInvalid() {
8987
9029
  var _a, _b;
8988
- return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(43 /* CommandResult.GaugeUpperInflectionPointNaN */)) ||
8989
- ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(44 /* CommandResult.GaugeLowerBiggerThanUpper */)));
9030
+ return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(44 /* CommandResult.GaugeUpperInflectionPointNaN */)) ||
9031
+ ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(45 /* CommandResult.GaugeLowerBiggerThanUpper */)));
8990
9032
  }
8991
9033
  updateInflectionPointValue(attr, ev) {
8992
9034
  const sectionRule = deepCopy(this.props.definition.sectionRule);
@@ -9089,11 +9131,11 @@ class ScorecardChartConfigPanel extends Component {
9089
9131
  }
9090
9132
  get isKeyValueInvalid() {
9091
9133
  var _a;
9092
- return !!((_a = this.state.keyValueDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(34 /* CommandResult.InvalidScorecardKeyValue */));
9134
+ return !!((_a = this.state.keyValueDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(35 /* CommandResult.InvalidScorecardKeyValue */));
9093
9135
  }
9094
9136
  get isBaselineInvalid() {
9095
9137
  var _a;
9096
- return !!((_a = this.state.keyValueDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(35 /* CommandResult.InvalidScorecardBaseline */));
9138
+ return !!((_a = this.state.keyValueDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(36 /* CommandResult.InvalidScorecardBaseline */));
9097
9139
  }
9098
9140
  onKeyValueRangeChanged(ranges) {
9099
9141
  this.keyValue = ranges[0];
@@ -9786,7 +9828,7 @@ class ConditionalFormattingPanel extends Component {
9786
9828
  rule: this.getEditorRule(),
9787
9829
  id: this.state.mode === "edit"
9788
9830
  ? this.state.currentCF.id
9789
- : this.env.model.uuidGenerator.uuidv4(),
9831
+ : this.env.model.uuidGenerator.smallUuid(),
9790
9832
  },
9791
9833
  ranges: this.state.currentCF.ranges.map((xc) => this.env.model.getters.getRangeDataFromXc(sheetId, xc)),
9792
9834
  sheetId,
@@ -9854,7 +9896,7 @@ class ConditionalFormattingPanel extends Component {
9854
9896
  this.state.mode = "add";
9855
9897
  this.state.currentCFType = "CellIsRule";
9856
9898
  this.state.currentCF = {
9857
- id: this.env.model.uuidGenerator.uuidv4(),
9899
+ id: this.env.model.uuidGenerator.smallUuid(),
9858
9900
  ranges: this.env.model.getters
9859
9901
  .getSelectedZones()
9860
9902
  .map((zone) => this.env.model.getters.zoneToXC(this.env.model.getters.getActiveSheetId(), zone)),
@@ -9933,11 +9975,11 @@ class ConditionalFormattingPanel extends Component {
9933
9975
  ****************************************************************************/
9934
9976
  get isValue1Invalid() {
9935
9977
  var _a;
9936
- return !!((_a = this.state.errors) === null || _a === void 0 ? void 0 : _a.includes(51 /* CommandResult.FirstArgMissing */));
9978
+ return !!((_a = this.state.errors) === null || _a === void 0 ? void 0 : _a.includes(52 /* CommandResult.FirstArgMissing */));
9937
9979
  }
9938
9980
  get isValue2Invalid() {
9939
9981
  var _a;
9940
- return !!((_a = this.state.errors) === null || _a === void 0 ? void 0 : _a.includes(52 /* CommandResult.SecondArgMissing */));
9982
+ return !!((_a = this.state.errors) === null || _a === void 0 ? void 0 : _a.includes(53 /* CommandResult.SecondArgMissing */));
9941
9983
  }
9942
9984
  toggleStyle(tool) {
9943
9985
  const style = this.state.rules.cellIs.style;
@@ -9954,17 +9996,17 @@ class ConditionalFormattingPanel extends Component {
9954
9996
  isValueInvalid(threshold) {
9955
9997
  switch (threshold) {
9956
9998
  case "minimum":
9957
- return (this.state.errors.includes(58 /* CommandResult.MinInvalidFormula */) ||
9958
- this.state.errors.includes(50 /* CommandResult.MinBiggerThanMid */) ||
9959
- this.state.errors.includes(47 /* CommandResult.MinBiggerThanMax */) ||
9960
- this.state.errors.includes(53 /* CommandResult.MinNaN */));
9999
+ return (this.state.errors.includes(59 /* CommandResult.MinInvalidFormula */) ||
10000
+ this.state.errors.includes(51 /* CommandResult.MinBiggerThanMid */) ||
10001
+ this.state.errors.includes(48 /* CommandResult.MinBiggerThanMax */) ||
10002
+ this.state.errors.includes(54 /* CommandResult.MinNaN */));
9961
10003
  case "midpoint":
9962
- return (this.state.errors.includes(59 /* CommandResult.MidInvalidFormula */) ||
9963
- this.state.errors.includes(54 /* CommandResult.MidNaN */) ||
9964
- this.state.errors.includes(49 /* CommandResult.MidBiggerThanMax */));
10004
+ return (this.state.errors.includes(60 /* CommandResult.MidInvalidFormula */) ||
10005
+ this.state.errors.includes(55 /* CommandResult.MidNaN */) ||
10006
+ this.state.errors.includes(50 /* CommandResult.MidBiggerThanMax */));
9965
10007
  case "maximum":
9966
- return (this.state.errors.includes(60 /* CommandResult.MaxInvalidFormula */) ||
9967
- this.state.errors.includes(55 /* CommandResult.MaxNaN */));
10008
+ return (this.state.errors.includes(61 /* CommandResult.MaxInvalidFormula */) ||
10009
+ this.state.errors.includes(56 /* CommandResult.MaxNaN */));
9968
10010
  default:
9969
10011
  return false;
9970
10012
  }
@@ -10016,13 +10058,13 @@ class ConditionalFormattingPanel extends Component {
10016
10058
  isInflectionPointInvalid(inflectionPoint) {
10017
10059
  switch (inflectionPoint) {
10018
10060
  case "lowerInflectionPoint":
10019
- return (this.state.errors.includes(57 /* CommandResult.ValueLowerInflectionNaN */) ||
10020
- this.state.errors.includes(62 /* CommandResult.ValueLowerInvalidFormula */) ||
10021
- this.state.errors.includes(48 /* CommandResult.LowerBiggerThanUpper */));
10061
+ return (this.state.errors.includes(58 /* CommandResult.ValueLowerInflectionNaN */) ||
10062
+ this.state.errors.includes(63 /* CommandResult.ValueLowerInvalidFormula */) ||
10063
+ this.state.errors.includes(49 /* CommandResult.LowerBiggerThanUpper */));
10022
10064
  case "upperInflectionPoint":
10023
- return (this.state.errors.includes(56 /* CommandResult.ValueUpperInflectionNaN */) ||
10024
- this.state.errors.includes(61 /* CommandResult.ValueUpperInvalidFormula */) ||
10025
- this.state.errors.includes(48 /* CommandResult.LowerBiggerThanUpper */));
10065
+ return (this.state.errors.includes(57 /* CommandResult.ValueUpperInflectionNaN */) ||
10066
+ this.state.errors.includes(62 /* CommandResult.ValueUpperInvalidFormula */) ||
10067
+ this.state.errors.includes(49 /* CommandResult.LowerBiggerThanUpper */));
10026
10068
  default:
10027
10069
  return true;
10028
10070
  }
@@ -10342,7 +10384,7 @@ class TopBarComponentRegistry extends Registry {
10342
10384
  this.uuidGenerator = new UuidGenerator();
10343
10385
  }
10344
10386
  add(name, value) {
10345
- const component = { ...value, id: this.uuidGenerator.uuidv4() };
10387
+ const component = { ...value, id: this.uuidGenerator.smallUuid() };
10346
10388
  return super.add(name, component);
10347
10389
  }
10348
10390
  }
@@ -12340,6 +12382,26 @@ const LN = {
12340
12382
  isExported: true,
12341
12383
  };
12342
12384
  // -----------------------------------------------------------------------------
12385
+ // LOG
12386
+ // -----------------------------------------------------------------------------
12387
+ const LOG = {
12388
+ description: _lt("The logarithm of a number, for a given base."),
12389
+ args: args(`
12390
+ value (number) ${_lt("The value for which to calculate the logarithm, base e.")}
12391
+ base (number, default=10) ${_lt("The base of the logarithm.")}
12392
+ `),
12393
+ returns: ["NUMBER"],
12394
+ compute: function (value, base = 10) {
12395
+ const _value = toNumber(value);
12396
+ const _base = toNumber(base);
12397
+ assert(() => _value > 0, _lt("The value (%s) must be strictly positive.", _value.toString()));
12398
+ assert(() => _base > 0, _lt("The base (%s) must be strictly positive.", _base.toString()));
12399
+ assert(() => _base !== 1, _lt("The base must be different from 1."));
12400
+ return Math.log10(_value) / Math.log10(_base);
12401
+ },
12402
+ isExported: true,
12403
+ };
12404
+ // -----------------------------------------------------------------------------
12343
12405
  // MOD
12344
12406
  // -----------------------------------------------------------------------------
12345
12407
  const MOD = {
@@ -12808,6 +12870,7 @@ var math = /*#__PURE__*/Object.freeze({
12808
12870
  ISO_CEILING: ISO_CEILING,
12809
12871
  ISODD: ISODD,
12810
12872
  LN: LN,
12873
+ LOG: LOG,
12811
12874
  MOD: MOD,
12812
12875
  ODD: ODD,
12813
12876
  PI: PI,
@@ -19684,7 +19747,7 @@ class EditionPlugin extends UIPlugin {
19684
19747
  validateSelection(length, start, end) {
19685
19748
  return start >= 0 && start <= length && end >= 0 && end <= length
19686
19749
  ? 0 /* CommandResult.Success */
19687
- : 46 /* CommandResult.WrongComposerSelection */;
19750
+ : 47 /* CommandResult.WrongComposerSelection */;
19688
19751
  }
19689
19752
  onColumnsRemoved(cmd) {
19690
19753
  if (cmd.elements.includes(this.col) && this.mode !== "inactive") {
@@ -22427,6 +22490,9 @@ function useGridDrawing(refName, model, canvasSize) {
22427
22490
  canvas.width = width * dpr;
22428
22491
  canvas.height = height * dpr;
22429
22492
  canvas.setAttribute("style", `width:${width}px;height:${height}px;`);
22493
+ if (width === 0 || height === 0) {
22494
+ return;
22495
+ }
22430
22496
  // Imagine each pixel as a large square. The whole-number coordinates (0, 1, 2…)
22431
22497
  // are the edges of the squares. If you draw a one-unit-wide line between whole-number
22432
22498
  // coordinates, it will overlap opposite sides of the pixel square, and the resulting
@@ -27241,7 +27307,7 @@ function forceUnicityOfFigure(data) {
27241
27307
  for (const sheet of data.sheets || []) {
27242
27308
  for (const figure of sheet.figures || []) {
27243
27309
  if (figureIds.has(figure.id)) {
27244
- figure.id += uuidGenerator.uuidv4();
27310
+ figure.id += uuidGenerator.smallUuid();
27245
27311
  }
27246
27312
  figureIds.add(figure.id);
27247
27313
  }
@@ -27926,7 +27992,7 @@ class BordersPlugin extends CorePlugin {
27926
27992
  const currentBorder = this.getCellBorder(cmd.sheetId, cmd.col, cmd.row);
27927
27993
  const areAllNewBordersUndefined = !((_a = cmd.border) === null || _a === void 0 ? void 0 : _a.bottom) && !((_b = cmd.border) === null || _b === void 0 ? void 0 : _b.left) && !((_c = cmd.border) === null || _c === void 0 ? void 0 : _c.right) && !((_d = cmd.border) === null || _d === void 0 ? void 0 : _d.top);
27928
27994
  if ((!currentBorder && areAllNewBordersUndefined) || deepEquals(currentBorder, cmd.border)) {
27929
- return 88 /* CommandResult.NoChanges */;
27995
+ return 89 /* CommandResult.NoChanges */;
27930
27996
  }
27931
27997
  return 0 /* CommandResult.Success */;
27932
27998
  }
@@ -28032,11 +28098,16 @@ class CellPlugin extends CorePlugin {
28032
28098
  // Command Handling
28033
28099
  // ---------------------------------------------------------------------------
28034
28100
  allowDispatch(cmd) {
28101
+ var _a;
28035
28102
  switch (cmd.type) {
28036
28103
  case "UPDATE_CELL":
28037
28104
  return this.checkValidations(cmd, this.checkCellOutOfSheet, this.checkUselessUpdateCell);
28038
28105
  case "CLEAR_CELL":
28039
28106
  return this.checkValidations(cmd, this.checkCellOutOfSheet, this.checkUselessClearCell);
28107
+ case "UPDATE_CELL_POSITION":
28108
+ return !cmd.cellId || ((_a = this.cells[cmd.sheetId]) === null || _a === void 0 ? void 0 : _a[cmd.cellId])
28109
+ ? 0 /* CommandResult.Success */
28110
+ : 28 /* CommandResult.InvalidCellId */;
28040
28111
  default:
28041
28112
  return 0 /* CommandResult.Success */;
28042
28113
  }
@@ -28075,6 +28146,9 @@ class CellPlugin extends CorePlugin {
28075
28146
  format: "",
28076
28147
  });
28077
28148
  break;
28149
+ case "DELETE_SHEET": {
28150
+ this.history.update("cells", cmd.sheetId, undefined);
28151
+ }
28078
28152
  }
28079
28153
  }
28080
28154
  /**
@@ -28390,9 +28464,9 @@ class CellPlugin extends CorePlugin {
28390
28464
  checkUselessClearCell(cmd) {
28391
28465
  const cell = this.getters.getCell(cmd.sheetId, cmd.col, cmd.row);
28392
28466
  if (!cell)
28393
- return 88 /* CommandResult.NoChanges */;
28467
+ return 89 /* CommandResult.NoChanges */;
28394
28468
  if (!cell.content && !cell.style && !cell.format) {
28395
- return 88 /* CommandResult.NoChanges */;
28469
+ return 89 /* CommandResult.NoChanges */;
28396
28470
  }
28397
28471
  return 0 /* CommandResult.Success */;
28398
28472
  }
@@ -28404,7 +28478,7 @@ class CellPlugin extends CorePlugin {
28404
28478
  if ((!hasContent || (cell === null || cell === void 0 ? void 0 : cell.content) === cmd.content) &&
28405
28479
  (!hasStyle || deepEquals(cell === null || cell === void 0 ? void 0 : cell.style, cmd.style)) &&
28406
28480
  (!hasFormat || (cell === null || cell === void 0 ? void 0 : cell.format) === cmd.format)) {
28407
- return 88 /* CommandResult.NoChanges */;
28481
+ return 89 /* CommandResult.NoChanges */;
28408
28482
  }
28409
28483
  return 0 /* CommandResult.Success */;
28410
28484
  }
@@ -28613,13 +28687,13 @@ class ChartPlugin extends CorePlugin {
28613
28687
  }
28614
28688
  checkChartDuplicate(cmd) {
28615
28689
  return this.getters.getFigureSheetId(cmd.id)
28616
- ? 84 /* CommandResult.DuplicatedChartId */
28690
+ ? 85 /* CommandResult.DuplicatedChartId */
28617
28691
  : 0 /* CommandResult.Success */;
28618
28692
  }
28619
28693
  checkChartExists(cmd) {
28620
28694
  return this.getters.getFigureSheetId(cmd.id)
28621
28695
  ? 0 /* CommandResult.Success */
28622
- : 85 /* CommandResult.ChartDoesNotExist */;
28696
+ : 86 /* CommandResult.ChartDoesNotExist */;
28623
28697
  }
28624
28698
  }
28625
28699
  ChartPlugin.getters = [
@@ -28827,10 +28901,10 @@ class ConditionalFormatPlugin extends CorePlugin {
28827
28901
  return 27 /* CommandResult.InvalidSheetId */;
28828
28902
  const ruleIndex = this.cfRules[sheetId].findIndex((cf) => cf.id === cfId);
28829
28903
  if (ruleIndex === -1)
28830
- return 71 /* CommandResult.InvalidConditionalFormatId */;
28904
+ return 72 /* CommandResult.InvalidConditionalFormatId */;
28831
28905
  const cfIndex2 = direction === "up" ? ruleIndex - 1 : ruleIndex + 1;
28832
28906
  if (cfIndex2 < 0 || cfIndex2 >= this.cfRules[sheetId].length) {
28833
- return 71 /* CommandResult.InvalidConditionalFormatId */;
28907
+ return 72 /* CommandResult.InvalidConditionalFormatId */;
28834
28908
  }
28835
28909
  return 0 /* CommandResult.Success */;
28836
28910
  }
@@ -28871,10 +28945,10 @@ class ConditionalFormatPlugin extends CorePlugin {
28871
28945
  const errors = [];
28872
28946
  const isEmpty = (value) => value === undefined || value === "";
28873
28947
  if (expectedNumber >= 1 && isEmpty(rule.values[0])) {
28874
- errors.push(51 /* CommandResult.FirstArgMissing */);
28948
+ errors.push(52 /* CommandResult.FirstArgMissing */);
28875
28949
  }
28876
28950
  if (expectedNumber >= 2 && isEmpty(rule.values[1])) {
28877
- errors.push(52 /* CommandResult.SecondArgMissing */);
28951
+ errors.push(53 /* CommandResult.SecondArgMissing */);
28878
28952
  }
28879
28953
  return errors.length ? errors : 0 /* CommandResult.Success */;
28880
28954
  }
@@ -28886,15 +28960,15 @@ class ConditionalFormatPlugin extends CorePlugin {
28886
28960
  (threshold.value === "" || isNaN(threshold.value))) {
28887
28961
  switch (thresholdName) {
28888
28962
  case "min":
28889
- return 53 /* CommandResult.MinNaN */;
28963
+ return 54 /* CommandResult.MinNaN */;
28890
28964
  case "max":
28891
- return 55 /* CommandResult.MaxNaN */;
28965
+ return 56 /* CommandResult.MaxNaN */;
28892
28966
  case "mid":
28893
- return 54 /* CommandResult.MidNaN */;
28967
+ return 55 /* CommandResult.MidNaN */;
28894
28968
  case "upperInflectionPoint":
28895
- return 56 /* CommandResult.ValueUpperInflectionNaN */;
28969
+ return 57 /* CommandResult.ValueUpperInflectionNaN */;
28896
28970
  case "lowerInflectionPoint":
28897
- return 57 /* CommandResult.ValueLowerInflectionNaN */;
28971
+ return 58 /* CommandResult.ValueLowerInflectionNaN */;
28898
28972
  }
28899
28973
  }
28900
28974
  return 0 /* CommandResult.Success */;
@@ -28908,15 +28982,15 @@ class ConditionalFormatPlugin extends CorePlugin {
28908
28982
  catch (error) {
28909
28983
  switch (thresholdName) {
28910
28984
  case "min":
28911
- return 58 /* CommandResult.MinInvalidFormula */;
28985
+ return 59 /* CommandResult.MinInvalidFormula */;
28912
28986
  case "max":
28913
- return 60 /* CommandResult.MaxInvalidFormula */;
28987
+ return 61 /* CommandResult.MaxInvalidFormula */;
28914
28988
  case "mid":
28915
- return 59 /* CommandResult.MidInvalidFormula */;
28989
+ return 60 /* CommandResult.MidInvalidFormula */;
28916
28990
  case "upperInflectionPoint":
28917
- return 61 /* CommandResult.ValueUpperInvalidFormula */;
28991
+ return 62 /* CommandResult.ValueUpperInvalidFormula */;
28918
28992
  case "lowerInflectionPoint":
28919
- return 62 /* CommandResult.ValueLowerInvalidFormula */;
28993
+ return 63 /* CommandResult.ValueLowerInvalidFormula */;
28920
28994
  }
28921
28995
  }
28922
28996
  return 0 /* CommandResult.Success */;
@@ -28933,7 +29007,7 @@ class ConditionalFormatPlugin extends CorePlugin {
28933
29007
  if (["number", "percentage", "percentile"].includes(rule.lowerInflectionPoint.type) &&
28934
29008
  rule.lowerInflectionPoint.type === rule.upperInflectionPoint.type &&
28935
29009
  Number(minValue) > Number(maxValue)) {
28936
- return 48 /* CommandResult.LowerBiggerThanUpper */;
29010
+ return 49 /* CommandResult.LowerBiggerThanUpper */;
28937
29011
  }
28938
29012
  return 0 /* CommandResult.Success */;
28939
29013
  }
@@ -28943,7 +29017,7 @@ class ConditionalFormatPlugin extends CorePlugin {
28943
29017
  if (["number", "percentage", "percentile"].includes(rule.minimum.type) &&
28944
29018
  rule.minimum.type === rule.maximum.type &&
28945
29019
  stringToNumber(minValue) >= stringToNumber(maxValue)) {
28946
- return 47 /* CommandResult.MinBiggerThanMax */;
29020
+ return 48 /* CommandResult.MinBiggerThanMax */;
28947
29021
  }
28948
29022
  return 0 /* CommandResult.Success */;
28949
29023
  }
@@ -28955,7 +29029,7 @@ class ConditionalFormatPlugin extends CorePlugin {
28955
29029
  ["number", "percentage", "percentile"].includes(rule.midpoint.type) &&
28956
29030
  rule.midpoint.type === rule.maximum.type &&
28957
29031
  stringToNumber(midValue) >= stringToNumber(maxValue)) {
28958
- return 49 /* CommandResult.MidBiggerThanMax */;
29032
+ return 50 /* CommandResult.MidBiggerThanMax */;
28959
29033
  }
28960
29034
  return 0 /* CommandResult.Success */;
28961
29035
  }
@@ -28967,7 +29041,7 @@ class ConditionalFormatPlugin extends CorePlugin {
28967
29041
  ["number", "percentage", "percentile"].includes(rule.midpoint.type) &&
28968
29042
  rule.minimum.type === rule.midpoint.type &&
28969
29043
  stringToNumber(minValue) >= stringToNumber(midValue)) {
28970
- return 50 /* CommandResult.MinBiggerThanMid */;
29044
+ return 51 /* CommandResult.MinBiggerThanMid */;
28971
29045
  }
28972
29046
  return 0 /* CommandResult.Success */;
28973
29047
  }
@@ -29077,13 +29151,13 @@ class FigurePlugin extends CorePlugin {
29077
29151
  checkFigureExists(sheetId, figureId) {
29078
29152
  var _a;
29079
29153
  if (((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) === undefined) {
29080
- return 70 /* CommandResult.FigureDoesNotExist */;
29154
+ return 71 /* CommandResult.FigureDoesNotExist */;
29081
29155
  }
29082
29156
  return 0 /* CommandResult.Success */;
29083
29157
  }
29084
29158
  checkFigureDuplicate(figureId) {
29085
29159
  if (Object.values(this.figures).find((sheet) => sheet === null || sheet === void 0 ? void 0 : sheet[figureId])) {
29086
- return 82 /* CommandResult.DuplicatedFigureId */;
29160
+ return 83 /* CommandResult.DuplicatedFigureId */;
29087
29161
  }
29088
29162
  return 0 /* CommandResult.Success */;
29089
29163
  }
@@ -29131,10 +29205,10 @@ class FilterTable {
29131
29205
  this.filters = [];
29132
29206
  this.zone = zone;
29133
29207
  const uuid = new UuidGenerator();
29134
- this.id = uuid.uuidv4();
29208
+ this.id = uuid.smallUuid();
29135
29209
  for (const i of range(zone.left, zone.right + 1)) {
29136
29210
  const filterZone = { ...this.zone, left: i, right: i };
29137
- this.filters.push(new Filter(uuid.uuidv4(), filterZone));
29211
+ this.filters.push(new Filter(uuid.smallUuid(), filterZone));
29138
29212
  }
29139
29213
  }
29140
29214
  /** Get zone of the table without the headers */
@@ -29185,12 +29259,12 @@ class FiltersPlugin extends CorePlugin {
29185
29259
  switch (cmd.type) {
29186
29260
  case "CREATE_FILTER_TABLE":
29187
29261
  if (!areZonesContinuous(...cmd.target)) {
29188
- return 81 /* CommandResult.NonContinuousTargets */;
29262
+ return 82 /* CommandResult.NonContinuousTargets */;
29189
29263
  }
29190
29264
  const zone = union(...cmd.target);
29191
29265
  const checkFilterOverlap = () => {
29192
29266
  if (this.getFilterTables(cmd.sheetId).some((filter) => overlap(filter.zone, zone))) {
29193
- return 78 /* CommandResult.FilterOverlap */;
29267
+ return 79 /* CommandResult.FilterOverlap */;
29194
29268
  }
29195
29269
  return 0 /* CommandResult.Success */;
29196
29270
  };
@@ -29198,7 +29272,7 @@ class FiltersPlugin extends CorePlugin {
29198
29272
  const mergesInTarget = this.getters.getMergesInZone(cmd.sheetId, zone);
29199
29273
  for (let merge of mergesInTarget) {
29200
29274
  if (overlap(zone, merge)) {
29201
- return 80 /* CommandResult.MergeInFilter */;
29275
+ return 81 /* CommandResult.MergeInFilter */;
29202
29276
  }
29203
29277
  }
29204
29278
  return 0 /* CommandResult.Success */;
@@ -29208,7 +29282,7 @@ class FiltersPlugin extends CorePlugin {
29208
29282
  for (let merge of cmd.target) {
29209
29283
  for (let filterTable of this.getFilterTables(cmd.sheetId)) {
29210
29284
  if (overlap(filterTable.zone, merge)) {
29211
- return 80 /* CommandResult.MergeInFilter */;
29285
+ return 81 /* CommandResult.MergeInFilter */;
29212
29286
  }
29213
29287
  }
29214
29288
  }
@@ -29314,7 +29388,7 @@ class FiltersPlugin extends CorePlugin {
29314
29388
  if (filters.length < zoneToDimension(zone).width) {
29315
29389
  for (let col = zone.left; col <= zone.right; col++) {
29316
29390
  if (!filters.find((filter) => filter.col === col)) {
29317
- filters.push(new Filter(this.uuidGenerator.uuidv4(), { ...zone, left: col, right: col }));
29391
+ filters.push(new Filter(this.uuidGenerator.smallUuid(), { ...zone, left: col, right: col }));
29318
29392
  }
29319
29393
  }
29320
29394
  filters.sort((f1, f2) => f1.col - f2.col);
@@ -29718,10 +29792,10 @@ class HeaderVisibilityPlugin extends CorePlugin {
29718
29792
  : this.getters.getNumberRows(cmd.sheetId);
29719
29793
  const hiddenElements = new Set((hiddenGroup || []).flat().concat(cmd.elements));
29720
29794
  if (hiddenElements.size >= elements) {
29721
- return 66 /* CommandResult.TooManyHiddenElements */;
29795
+ return 67 /* CommandResult.TooManyHiddenElements */;
29722
29796
  }
29723
29797
  else if (largeMin(cmd.elements) < 0 || largeMax(cmd.elements) > elements) {
29724
- return 86 /* CommandResult.InvalidHeaderIndex */;
29798
+ return 87 /* CommandResult.InvalidHeaderIndex */;
29725
29799
  }
29726
29800
  else {
29727
29801
  return 0 /* CommandResult.Success */;
@@ -30124,7 +30198,7 @@ class MergePlugin extends CorePlugin {
30124
30198
  for (const zone of target) {
30125
30199
  for (const zone2 of target) {
30126
30200
  if (zone !== zone2 && overlap(zone, zone2)) {
30127
- return 65 /* CommandResult.MergeOverlap */;
30201
+ return 66 /* CommandResult.MergeOverlap */;
30128
30202
  }
30129
30203
  }
30130
30204
  }
@@ -30138,7 +30212,7 @@ class MergePlugin extends CorePlugin {
30138
30212
  for (const zone of target) {
30139
30213
  if ((zone.left < xSplit && zone.right >= xSplit) ||
30140
30214
  (zone.top < ySplit && zone.bottom >= ySplit)) {
30141
- return 75 /* CommandResult.FrozenPaneOverlap */;
30215
+ return 76 /* CommandResult.FrozenPaneOverlap */;
30142
30216
  }
30143
30217
  }
30144
30218
  return 0 /* CommandResult.Success */;
@@ -30356,6 +30430,9 @@ class SheetPlugin extends CorePlugin {
30356
30430
  case "CREATE_SHEET": {
30357
30431
  return this.checkValidations(cmd, this.checkSheetName, this.checkSheetPosition);
30358
30432
  }
30433
+ case "DUPLICATE_SHEET": {
30434
+ return this.sheets[cmd.sheetIdTo] ? 12 /* CommandResult.DuplicatedSheetId */ : 0 /* CommandResult.Success */;
30435
+ }
30359
30436
  case "MOVE_SHEET":
30360
30437
  const currentIndex = this.orderedSheetIds.indexOf(cmd.sheetId);
30361
30438
  if (cmd.direction === "left") {
@@ -30377,7 +30454,7 @@ class SheetPlugin extends CorePlugin {
30377
30454
  case "RENAME_SHEET":
30378
30455
  return this.isRenameAllowed(cmd);
30379
30456
  case "DELETE_SHEET":
30380
- return this.orderedSheetIds.length > 1
30457
+ return this.getVisibleSheetIds().length > 1
30381
30458
  ? 0 /* CommandResult.Success */
30382
30459
  : 9 /* CommandResult.NotEnoughSheets */;
30383
30460
  case "ADD_COLUMNS_ROWS":
@@ -30385,10 +30462,10 @@ class SheetPlugin extends CorePlugin {
30385
30462
  ? this.getNumberCols(cmd.sheetId)
30386
30463
  : this.getNumberRows(cmd.sheetId);
30387
30464
  if (cmd.base < 0 || cmd.base >= elements) {
30388
- return 86 /* CommandResult.InvalidHeaderIndex */;
30465
+ return 87 /* CommandResult.InvalidHeaderIndex */;
30389
30466
  }
30390
30467
  else if (cmd.quantity <= 0) {
30391
- return 87 /* CommandResult.InvalidQuantity */;
30468
+ return 88 /* CommandResult.InvalidQuantity */;
30392
30469
  }
30393
30470
  return 0 /* CommandResult.Success */;
30394
30471
  case "REMOVE_COLUMNS_ROWS": {
@@ -30396,7 +30473,7 @@ class SheetPlugin extends CorePlugin {
30396
30473
  ? this.getNumberCols(cmd.sheetId)
30397
30474
  : this.getNumberRows(cmd.sheetId);
30398
30475
  if (largeMin(cmd.elements) < 0 || largeMax(cmd.elements) > elements) {
30399
- return 86 /* CommandResult.InvalidHeaderIndex */;
30476
+ return 87 /* CommandResult.InvalidHeaderIndex */;
30400
30477
  }
30401
30478
  else if (this.checkElementsIncludeAllNonFrozenHeaders(cmd.sheetId, cmd.dimension, cmd.elements)) {
30402
30479
  return 8 /* CommandResult.NotEnoughElements */;
@@ -30853,18 +30930,18 @@ class SheetPlugin extends CorePlugin {
30853
30930
  checkRowFreezeQuantity(cmd) {
30854
30931
  return cmd.quantity >= 1 && cmd.quantity < this.getNumberRows(cmd.sheetId)
30855
30932
  ? 0 /* CommandResult.Success */
30856
- : 74 /* CommandResult.InvalidFreezeQuantity */;
30933
+ : 75 /* CommandResult.InvalidFreezeQuantity */;
30857
30934
  }
30858
30935
  checkColFreezeQuantity(cmd) {
30859
30936
  return cmd.quantity >= 1 && cmd.quantity < this.getNumberCols(cmd.sheetId)
30860
30937
  ? 0 /* CommandResult.Success */
30861
- : 74 /* CommandResult.InvalidFreezeQuantity */;
30938
+ : 75 /* CommandResult.InvalidFreezeQuantity */;
30862
30939
  }
30863
30940
  checkRowFreezeOverlapMerge(cmd) {
30864
30941
  const merges = this.getters.getMerges(cmd.sheetId);
30865
30942
  for (let merge of merges) {
30866
30943
  if (merge.top < cmd.quantity && cmd.quantity <= merge.bottom) {
30867
- return 65 /* CommandResult.MergeOverlap */;
30944
+ return 66 /* CommandResult.MergeOverlap */;
30868
30945
  }
30869
30946
  }
30870
30947
  return 0 /* CommandResult.Success */;
@@ -30873,7 +30950,7 @@ class SheetPlugin extends CorePlugin {
30873
30950
  const merges = this.getters.getMerges(cmd.sheetId);
30874
30951
  for (let merge of merges) {
30875
30952
  if (merge.left < cmd.quantity && cmd.quantity <= merge.right) {
30876
- return 65 /* CommandResult.MergeOverlap */;
30953
+ return 66 /* CommandResult.MergeOverlap */;
30877
30954
  }
30878
30955
  }
30879
30956
  return 0 /* CommandResult.Success */;
@@ -31183,6 +31260,9 @@ class SheetPlugin extends CorePlugin {
31183
31260
  zones.push(...cmd.target);
31184
31261
  }
31185
31262
  if ("ranges" in cmd && Array.isArray(cmd.ranges)) {
31263
+ if (cmd.ranges.some((rangeData) => !this.getters.tryGetSheet(rangeData._sheetId))) {
31264
+ return 27 /* CommandResult.InvalidSheetId */;
31265
+ }
31186
31266
  zones.push(...cmd.ranges.map((rangeData) => this.getters.getRangeFromRangeData(rangeData).zone));
31187
31267
  }
31188
31268
  if (!zones.every(isZoneValid)) {
@@ -31304,7 +31384,7 @@ class AutofillPlugin extends UIPlugin {
31304
31384
  if (this.lastCellSelected.col !== undefined && this.lastCellSelected.row !== undefined) {
31305
31385
  return 0 /* CommandResult.Success */;
31306
31386
  }
31307
- return 45 /* CommandResult.InvalidAutofillSelection */;
31387
+ return 46 /* CommandResult.InvalidAutofillSelection */;
31308
31388
  case "AUTOFILL_AUTO":
31309
31389
  const zone = this.getters.getSelectedZone();
31310
31390
  return zone.top === zone.bottom
@@ -31904,7 +31984,7 @@ class CellPopoverPlugin extends UIPlugin {
31904
31984
  cellPopoverRegistry.get(cmd.popoverType);
31905
31985
  }
31906
31986
  catch (error) {
31907
- return 72 /* CommandResult.InvalidCellPopover */;
31987
+ return 73 /* CommandResult.InvalidCellPopover */;
31908
31988
  }
31909
31989
  return 0 /* CommandResult.Success */;
31910
31990
  default:
@@ -32128,7 +32208,7 @@ class ClipboardCellsState extends ClipboardCellsAbstractState {
32128
32208
  for (const zone of this.getPasteZones(target)) {
32129
32209
  if ((zone.left < xSplit && zone.right >= xSplit) ||
32130
32210
  (zone.top < ySplit && zone.bottom >= ySplit)) {
32131
- return 75 /* CommandResult.FrozenPaneOverlap */;
32211
+ return 76 /* CommandResult.FrozenPaneOverlap */;
32132
32212
  }
32133
32213
  }
32134
32214
  return 0 /* CommandResult.Success */;
@@ -32488,7 +32568,7 @@ class ClipboardFigureState {
32488
32568
  }
32489
32569
  isPasteAllowed(target, option) {
32490
32570
  if (target.length === 0) {
32491
- return 73 /* CommandResult.EmptyTarget */;
32571
+ return 74 /* CommandResult.EmptyTarget */;
32492
32572
  }
32493
32573
  if ((option === null || option === void 0 ? void 0 : option.pasteOption) !== undefined) {
32494
32574
  return 22 /* CommandResult.WrongFigurePasteOption */;
@@ -32505,7 +32585,7 @@ class ClipboardFigureState {
32505
32585
  y: this.getters.getRowDimensions(sheetId, target[0].top).start,
32506
32586
  };
32507
32587
  const newChart = this.copiedChart.copyInSheetId(sheetId);
32508
- const newId = new UuidGenerator().uuidv4();
32588
+ const newId = new UuidGenerator().smallUuid();
32509
32589
  this.dispatch("CREATE_CHART", {
32510
32590
  id: newId,
32511
32591
  sheetId,
@@ -33635,7 +33715,9 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
33635
33715
  const cfInTarget = this.getters
33636
33716
  .getConditionalFormats(targetSheetId)
33637
33717
  .find((cf) => cf.stopIfTrue === originCF.stopIfTrue && deepEquals(cf.rule, originCF.rule));
33638
- return cfInTarget ? cfInTarget : { ...originCF, id: this.uuidGenerator.uuidv4(), ranges: [] };
33718
+ return cfInTarget
33719
+ ? cfInTarget
33720
+ : { ...originCF, id: this.uuidGenerator.smallUuid(), ranges: [] };
33639
33721
  }
33640
33722
  }
33641
33723
  EvaluationConditionalFormatPlugin.getters = ["getConditionalIcon", "getCellComputedStyle"];
@@ -33651,7 +33733,7 @@ class FilterEvaluationPlugin extends UIPlugin {
33651
33733
  switch (cmd.type) {
33652
33734
  case "UPDATE_FILTER":
33653
33735
  if (!this.getters.getFilterId(cmd.sheetId, cmd.col, cmd.row)) {
33654
- return 79 /* CommandResult.FilterNotFound */;
33736
+ return 80 /* CommandResult.FilterNotFound */;
33655
33737
  }
33656
33738
  break;
33657
33739
  }
@@ -34630,10 +34712,8 @@ class RendererPlugin extends UIPlugin {
34630
34712
  const { ctx, thinLineWidth } = renderingContext;
34631
34713
  const visibleCols = this.getters.getSheetViewVisibleCols();
34632
34714
  const left = visibleCols[0];
34633
- const right = visibleCols[visibleCols.length - 1];
34634
34715
  const visibleRows = this.getters.getSheetViewVisibleRows();
34635
34716
  const top = visibleRows[0];
34636
- const bottom = visibleRows[visibleRows.length - 1];
34637
34717
  const { width, height } = this.getters.getSheetViewDimensionWithHeaders();
34638
34718
  const selection = this.getters.getSelectedZones();
34639
34719
  const selectedCols = getZonesCols(selection);
@@ -34649,7 +34729,7 @@ class RendererPlugin extends UIPlugin {
34649
34729
  ctx.lineWidth = thinLineWidth;
34650
34730
  ctx.strokeStyle = "#333";
34651
34731
  // Columns headers background
34652
- for (let col = left; col <= right; col++) {
34732
+ for (const col of visibleCols) {
34653
34733
  const colZone = { left: col, right: col, top: 0, bottom: numberOfRows - 1 };
34654
34734
  const { x, width } = this.getters.getVisibleRect(colZone);
34655
34735
  const colHasFilter = this.getters.doesZonesContainFilter(sheetId, [colZone]);
@@ -34669,7 +34749,7 @@ class RendererPlugin extends UIPlugin {
34669
34749
  ctx.fillRect(x, 0, width, HEADER_HEIGHT);
34670
34750
  }
34671
34751
  // Rows headers background
34672
- for (let row = top; row <= bottom; row++) {
34752
+ for (const row of visibleRows) {
34673
34753
  const rowZone = { top: row, bottom: row, left: 0, right: numberOfCols - 1 };
34674
34754
  const { y, height } = this.getters.getVisibleRect(rowZone);
34675
34755
  const rowHasFilter = this.getters.doesZonesContainFilter(sheetId, [rowZone]);
@@ -34698,21 +34778,21 @@ class RendererPlugin extends UIPlugin {
34698
34778
  ctx.stroke();
34699
34779
  ctx.beginPath();
34700
34780
  // column text + separator
34701
- for (const i of visibleCols) {
34702
- const colSize = this.getters.getColSize(sheetId, i);
34703
- const colName = numberToLetters(i);
34704
- ctx.fillStyle = activeCols.has(i) ? "#fff" : TEXT_HEADER_COLOR;
34705
- let colStart = this.getHeaderOffset("COL", left, i);
34781
+ for (const col of visibleCols) {
34782
+ const colSize = this.getters.getColSize(sheetId, col);
34783
+ const colName = numberToLetters(col);
34784
+ ctx.fillStyle = activeCols.has(col) ? "#fff" : TEXT_HEADER_COLOR;
34785
+ let colStart = this.getHeaderOffset("COL", left, col);
34706
34786
  ctx.fillText(colName, colStart + colSize / 2, HEADER_HEIGHT / 2);
34707
34787
  ctx.moveTo(colStart + colSize, 0);
34708
34788
  ctx.lineTo(colStart + colSize, HEADER_HEIGHT);
34709
34789
  }
34710
34790
  // row text + separator
34711
- for (const i of visibleRows) {
34712
- const rowSize = this.getters.getRowSize(sheetId, i);
34713
- ctx.fillStyle = activeRows.has(i) ? "#fff" : TEXT_HEADER_COLOR;
34714
- let rowStart = this.getHeaderOffset("ROW", top, i);
34715
- ctx.fillText(String(i + 1), HEADER_WIDTH / 2, rowStart + rowSize / 2);
34791
+ for (const row of visibleRows) {
34792
+ const rowSize = this.getters.getRowSize(sheetId, row);
34793
+ ctx.fillStyle = activeRows.has(row) ? "#fff" : TEXT_HEADER_COLOR;
34794
+ let rowStart = this.getHeaderOffset("ROW", top, row);
34795
+ ctx.fillText(String(row + 1), HEADER_WIDTH / 2, rowStart + rowSize / 2);
34716
34796
  ctx.moveTo(0, rowStart + rowSize);
34717
34797
  ctx.lineTo(HEADER_WIDTH, rowStart + rowSize);
34718
34798
  }
@@ -35159,23 +35239,7 @@ class GridSelectionPlugin extends UIPlugin {
35159
35239
  gridSelection: deepCopy(gridSelection),
35160
35240
  };
35161
35241
  }
35162
- if (!this.getters.tryGetSheet(this.getters.getActiveSheetId())) {
35163
- const currentSheetIds = this.getters.getVisibleSheetIds();
35164
- this.activeSheet = this.getters.getSheet(currentSheetIds[0]);
35165
- if (this.activeSheet.id in this.sheetsData) {
35166
- const { anchor } = this.clipSelection(this.activeSheet.id, this.sheetsData[this.activeSheet.id].gridSelection);
35167
- this.selectCell(anchor.cell.col, anchor.cell.row);
35168
- }
35169
- else {
35170
- this.selectCell(0, 0);
35171
- }
35172
- const { col, row } = this.gridSelection.anchor.cell;
35173
- this.moveClient({
35174
- sheetId: this.getters.getActiveSheetId(),
35175
- col,
35176
- row,
35177
- });
35178
- }
35242
+ this.fallbackToVisibleSheet();
35179
35243
  const sheetId = this.getters.getActiveSheetId();
35180
35244
  this.gridSelection.zones = this.gridSelection.zones.map((z) => this.getters.expandZone(sheetId, z));
35181
35245
  this.gridSelection.anchor.zone = this.getters.expandZone(sheetId, this.gridSelection.anchor.zone);
@@ -35185,6 +35249,7 @@ class GridSelectionPlugin extends UIPlugin {
35185
35249
  }
35186
35250
  }
35187
35251
  finalize() {
35252
+ this.fallbackToVisibleSheet();
35188
35253
  /** Any change to the selection has to be reflected in the selection processor. */
35189
35254
  this.selection.resetDefaultAnchor(this, deepCopy(this.gridSelection.anchor));
35190
35255
  }
@@ -35483,10 +35548,29 @@ class GridSelectionPlugin extends UIPlugin {
35483
35548
  const headers = [cmd.base, ...cmd.elements];
35484
35549
  const maxHeaderValue = isCol ? this.getters.getNumberCols(id) : this.getters.getNumberRows(id);
35485
35550
  if (headers.some((h) => h < 0 || h >= maxHeaderValue)) {
35486
- return 86 /* CommandResult.InvalidHeaderIndex */;
35551
+ return 87 /* CommandResult.InvalidHeaderIndex */;
35487
35552
  }
35488
35553
  return 0 /* CommandResult.Success */;
35489
35554
  }
35555
+ fallbackToVisibleSheet() {
35556
+ if (!this.getters.tryGetSheet(this.getters.getActiveSheetId())) {
35557
+ const currentSheetIds = this.getters.getVisibleSheetIds();
35558
+ this.activeSheet = this.getters.getSheet(currentSheetIds[0]);
35559
+ if (this.activeSheet.id in this.sheetsData) {
35560
+ const { anchor } = this.clipSelection(this.activeSheet.id, this.sheetsData[this.activeSheet.id].gridSelection);
35561
+ this.selectCell(anchor.cell.col, anchor.cell.row);
35562
+ }
35563
+ else {
35564
+ this.selectCell(0, 0);
35565
+ }
35566
+ const { col, row } = this.gridSelection.anchor.cell;
35567
+ this.moveClient({
35568
+ sheetId: this.getters.getActiveSheetId(),
35569
+ col,
35570
+ row,
35571
+ });
35572
+ }
35573
+ }
35490
35574
  //-------------------------------------------
35491
35575
  // Helpers for extensions
35492
35576
  // ------------------------------------------
@@ -35711,7 +35795,7 @@ class SelectionInputPlugin extends UIPlugin {
35711
35795
  setContent(index, xc) {
35712
35796
  this.ranges[index] = {
35713
35797
  ...this.ranges[index],
35714
- id: uuidGenerator.uuidv4(),
35798
+ id: uuidGenerator.smallUuid(),
35715
35799
  xc,
35716
35800
  };
35717
35801
  }
@@ -35826,26 +35910,26 @@ class SelectionInputsManagerPlugin extends UIPlugin {
35826
35910
  case "ADD_EMPTY_RANGE":
35827
35911
  case "REMOVE_RANGE":
35828
35912
  if (!this.inputs[cmd.id]) {
35829
- return 30 /* CommandResult.InvalidInputId */;
35913
+ return 31 /* CommandResult.InvalidInputId */;
35830
35914
  }
35831
35915
  }
35832
35916
  switch (cmd.type) {
35833
35917
  case "FOCUS_RANGE":
35834
35918
  const index = (_a = this.currentInput) === null || _a === void 0 ? void 0 : _a.getIndex(cmd.rangeId);
35835
35919
  if (this.focusedInputId === cmd.id && ((_b = this.currentInput) === null || _b === void 0 ? void 0 : _b.focusedRangeIndex) === index) {
35836
- return 28 /* CommandResult.InputAlreadyFocused */;
35920
+ return 29 /* CommandResult.InputAlreadyFocused */;
35837
35921
  }
35838
35922
  break;
35839
35923
  case "ADD_EMPTY_RANGE":
35840
35924
  const input = this.inputs[cmd.id];
35841
35925
  if (input.inputHasSingleRange && input.ranges.length === 1) {
35842
- return 29 /* CommandResult.MaximumRangesReached */;
35926
+ return 30 /* CommandResult.MaximumRangesReached */;
35843
35927
  }
35844
35928
  break;
35845
35929
  case "CHANGE_RANGE": {
35846
35930
  const input = this.inputs[cmd.id];
35847
35931
  if (input.inputHasSingleRange && cmd.value.split(",").length > 1) {
35848
- return 29 /* CommandResult.MaximumRangesReached */;
35932
+ return 30 /* CommandResult.MaximumRangesReached */;
35849
35933
  }
35850
35934
  break;
35851
35935
  }
@@ -36036,6 +36120,9 @@ function updateChartRangesTransformation(toTransform, executed) {
36036
36120
  }
36037
36121
  function createSheetTransformation(cmd, executed) {
36038
36122
  var _a;
36123
+ if (cmd.sheetId === executed.sheetId) {
36124
+ cmd = { ...cmd, sheetId: `${cmd.sheetId}~` };
36125
+ }
36039
36126
  if (cmd.name === executed.name) {
36040
36127
  return {
36041
36128
  ...cmd,
@@ -36611,21 +36698,14 @@ class Session extends EventBus {
36611
36698
  if (!message)
36612
36699
  return;
36613
36700
  if (message.type === "REMOTE_REVISION") {
36614
- const revision = this.revisions.get(message.nextRevisionId);
36701
+ let revision = this.revisions.get(message.nextRevisionId);
36615
36702
  if (revision.commands.length === 0) {
36616
36703
  /**
36617
- * The command is empty, we have to drop all the next local revisions
36704
+ * The command is empty, we have to rebase all the next local revisions
36618
36705
  * to avoid issues with undo/redo
36619
36706
  */
36620
- this.revisions.drop(revision.id);
36621
- const revisionIds = this.pendingMessages
36622
- .filter((message) => message.type === "REMOTE_REVISION")
36623
- .map((message) => message.nextRevisionId);
36624
- this.trigger("pending-revisions-dropped", { revisionIds });
36625
- this.waitingAck = false;
36626
- this.waitingUndoRedoAck = false;
36627
- this.pendingMessages = [];
36628
- return;
36707
+ this.revisions.rebase(revision.id);
36708
+ revision = this.revisions.get(message.nextRevisionId);
36629
36709
  }
36630
36710
  message = {
36631
36711
  ...message,
@@ -36649,7 +36729,6 @@ class Session extends EventBus {
36649
36729
  switch (message.type) {
36650
36730
  case "REMOTE_REVISION":
36651
36731
  case "REVISION_REDONE":
36652
- case "REVISION_UNDONE":
36653
36732
  case "SNAPSHOT_CREATED":
36654
36733
  this.waitingAck = false;
36655
36734
  this.pendingMessages = this.pendingMessages.filter((msg) => msg.nextRevisionId !== message.nextRevisionId);
@@ -36657,6 +36736,25 @@ class Session extends EventBus {
36657
36736
  this.processedRevisions.add(message.nextRevisionId);
36658
36737
  this.sendPendingMessage();
36659
36738
  break;
36739
+ case "REVISION_UNDONE": {
36740
+ this.waitingAck = false;
36741
+ this.pendingMessages = this.pendingMessages.filter((msg) => msg.nextRevisionId !== message.nextRevisionId);
36742
+ const firstPendingRevisionId = this.pendingMessages.findIndex((message) => message.type === "REMOTE_REVISION");
36743
+ if (firstPendingRevisionId !== -1) {
36744
+ /**
36745
+ * Some revisions undergo transformations that may cause issues with
36746
+ * undo/redo if the transformation is destructive (we don't get back
36747
+ * the original command by transforming it with the inverse).
36748
+ * To prevent these problems, we must rebase all subsequent local
36749
+ * revisions.
36750
+ */
36751
+ this.revisions.rebase(this.pendingMessages[firstPendingRevisionId].nextRevisionId);
36752
+ }
36753
+ this.serverRevisionId = message.nextRevisionId;
36754
+ this.processedRevisions.add(message.nextRevisionId);
36755
+ this.sendPendingMessage();
36756
+ break;
36757
+ }
36660
36758
  }
36661
36759
  }
36662
36760
  isAlreadyProcessed(message) {
@@ -36800,8 +36898,17 @@ class InternalViewport {
36800
36898
  this.getters = getters;
36801
36899
  this.sheetId = sheetId;
36802
36900
  this.boundaries = boundaries;
36803
- this.viewportWidth = sizeInGrid.width;
36804
- this.viewportHeight = sizeInGrid.height;
36901
+ if (sizeInGrid.width < 0 || sizeInGrid.height < 0) {
36902
+ throw new Error("Viewport size cannot be negative");
36903
+ }
36904
+ this.viewportWidth = sizeInGrid.height && sizeInGrid.width;
36905
+ this.viewportHeight = sizeInGrid.width && sizeInGrid.height;
36906
+ this.top = boundaries.top;
36907
+ this.bottom = boundaries.bottom;
36908
+ this.left = boundaries.left;
36909
+ this.right = boundaries.right;
36910
+ this.offsetX = offsets.x;
36911
+ this.offsetY = offsets.y;
36805
36912
  this.offsetScrollbarX = offsets.x;
36806
36913
  this.offsetScrollbarY = offsets.y;
36807
36914
  this.canScrollVertically = options.canScrollVertically;
@@ -36990,6 +37097,9 @@ class InternalViewport {
36990
37097
  }
36991
37098
  // PRIVATE
36992
37099
  searchHeaderIndex(dimension, position, startIndex = 0, absolute = false) {
37100
+ if (this.viewportWidth <= 0 || this.viewportHeight <= 0) {
37101
+ return -1;
37102
+ }
36993
37103
  let size = 0;
36994
37104
  const sheetId = this.sheetId;
36995
37105
  const headers = this.getters.getNumberHeaders(sheetId, dimension);
@@ -37028,7 +37138,7 @@ class InternalViewport {
37028
37138
  this.adjustViewportZoneY();
37029
37139
  }
37030
37140
  /** Corrects the viewport's horizontal offset based on the current structure
37031
- * To make sure that at least on column is visible inside the viewport.
37141
+ * To make sure that at least one column is visible inside the viewport.
37032
37142
  */
37033
37143
  adjustViewportOffsetX() {
37034
37144
  if (this.canScrollHorizontally) {
@@ -37045,7 +37155,7 @@ class InternalViewport {
37045
37155
  this.adjustViewportZoneX();
37046
37156
  }
37047
37157
  /** Corrects the viewport's vertical offset based on the current structure
37048
- * To make sure that at least on row is visible inside the viewport.
37158
+ * To make sure that at least one row is visible inside the viewport.
37049
37159
  */
37050
37160
  adjustViewportOffsetY() {
37051
37161
  if (this.canScrollVertically) {
@@ -37067,11 +37177,14 @@ class InternalViewport {
37067
37177
  const sheetId = this.sheetId;
37068
37178
  this.left = this.searchHeaderIndex("COL", this.offsetScrollbarX, this.boundaries.left);
37069
37179
  this.right = Math.min(this.boundaries.right, this.searchHeaderIndex("COL", this.viewportWidth, this.left));
37180
+ if (!this.viewportWidth) {
37181
+ return;
37182
+ }
37070
37183
  if (this.left === -1) {
37071
37184
  this.left = this.boundaries.left;
37072
37185
  }
37073
37186
  if (this.right === -1) {
37074
- this.right = this.getters.getNumberCols(sheetId) - 1;
37187
+ this.right = this.boundaries.right;
37075
37188
  }
37076
37189
  this.offsetX =
37077
37190
  this.getters.getColDimensions(sheetId, this.left).start -
@@ -37083,11 +37196,14 @@ class InternalViewport {
37083
37196
  const sheetId = this.sheetId;
37084
37197
  this.top = this.searchHeaderIndex("ROW", this.offsetScrollbarY, this.boundaries.top);
37085
37198
  this.bottom = Math.min(this.boundaries.bottom, this.searchHeaderIndex("ROW", this.viewportHeight, this.top));
37199
+ if (!this.viewportHeight) {
37200
+ return;
37201
+ }
37086
37202
  if (this.top === -1) {
37087
37203
  this.top = this.boundaries.top;
37088
37204
  }
37089
37205
  if (this.bottom === -1) {
37090
- this.bottom = this.getters.getNumberRows(sheetId) - 1;
37206
+ this.bottom = this.boundaries.bottom;
37091
37207
  }
37092
37208
  this.offsetY =
37093
37209
  this.getters.getRowDimensions(sheetId, this.top).start -
@@ -37339,12 +37455,12 @@ class SheetViewPlugin extends UIPlugin {
37339
37455
  getSheetViewVisibleCols() {
37340
37456
  const sheetId = this.getters.getActiveSheetId();
37341
37457
  const viewports = this.getSubViewports(sheetId);
37342
- return [...new Set(viewports.map((v) => range(v.left, v.right + 1)).flat())].filter((col) => !this.getters.isHeaderHidden(sheetId, "COL", col));
37458
+ return [...new Set(viewports.map((v) => range(v.left, v.right + 1)).flat())].filter((col) => col >= 0 && !this.getters.isHeaderHidden(sheetId, "COL", col));
37343
37459
  }
37344
37460
  getSheetViewVisibleRows() {
37345
37461
  const sheetId = this.getters.getActiveSheetId();
37346
37462
  const viewports = this.getSubViewports(sheetId);
37347
- return [...new Set(viewports.map((v) => range(v.top, v.bottom + 1)).flat())].filter((row) => !this.getters.isHeaderHidden(sheetId, "ROW", row));
37463
+ return [...new Set(viewports.map((v) => range(v.top, v.bottom + 1)).flat())].filter((row) => row >= 0 && !this.getters.isHeaderHidden(sheetId, "ROW", row));
37348
37464
  }
37349
37465
  /**
37350
37466
  * Return the main viewport maximum size relative to the client size.
@@ -37367,19 +37483,19 @@ class SheetViewPlugin extends UIPlugin {
37367
37483
  maxOffsetY: Math.max(0, height - viewport.viewportHeight + 1),
37368
37484
  };
37369
37485
  }
37370
- getColRowOffsetInViewport(dimension, referenceIndex, index) {
37371
- const sheetId = this.getters.getActiveSheetId();
37372
- const visibleCols = this.getters.getSheetViewVisibleCols();
37373
- const visibleRows = this.getters.getSheetViewVisibleRows();
37374
- if (index < referenceIndex) {
37375
- return -this.getColRowOffsetInViewport(dimension, index, referenceIndex);
37486
+ getColRowOffsetInViewport(dimension, referenceHeaderIndex, targetHeaderIndex) {
37487
+ if (targetHeaderIndex < referenceHeaderIndex) {
37488
+ return -this.getColRowOffsetInViewport(dimension, targetHeaderIndex, referenceHeaderIndex);
37376
37489
  }
37490
+ const sheetId = this.getters.getActiveSheetId();
37491
+ const visibleHeaders = dimension === "COL"
37492
+ ? this.getters.getSheetViewVisibleCols()
37493
+ : this.getters.getSheetViewVisibleRows();
37494
+ const startIndex = visibleHeaders.findIndex((header) => referenceHeaderIndex >= header);
37495
+ const endIndex = visibleHeaders.findIndex((header) => targetHeaderIndex <= header);
37496
+ const relevantIndexes = visibleHeaders.slice(startIndex, endIndex);
37377
37497
  let offset = 0;
37378
- const visibleIndexes = dimension === "COL" ? visibleCols : visibleRows;
37379
- for (let i = referenceIndex; i < index; i++) {
37380
- if (!visibleIndexes.includes(i)) {
37381
- continue;
37382
- }
37498
+ for (const i of relevantIndexes) {
37383
37499
  offset +=
37384
37500
  dimension === "COL"
37385
37501
  ? this.getters.getColSize(sheetId, i)
@@ -37429,7 +37545,7 @@ class SheetViewPlugin extends UIPlugin {
37429
37545
  }
37430
37546
  return { canEdgeScroll, direction, delay };
37431
37547
  }
37432
- getEdgeScrollRow(y, previousY, tartingY) {
37548
+ getEdgeScrollRow(y, previousY, startingY) {
37433
37549
  let canEdgeScroll = false;
37434
37550
  let direction = 0;
37435
37551
  let delay = 0;
@@ -37450,7 +37566,7 @@ class SheetViewPlugin extends UIPlugin {
37450
37566
  delay = scrollDelay(y - height);
37451
37567
  direction = 1;
37452
37568
  }
37453
- else if (y < offsetCorrectionY && tartingY >= offsetCorrectionY && currentOffsetY > 0) {
37569
+ else if (y < offsetCorrectionY && startingY >= offsetCorrectionY && currentOffsetY > 0) {
37454
37570
  // 2
37455
37571
  canEdgeScroll = true;
37456
37572
  delay = scrollDelay(offsetCorrectionY - y);
@@ -37469,13 +37585,7 @@ class SheetViewPlugin extends UIPlugin {
37469
37585
  */
37470
37586
  getVisibleRect(zone) {
37471
37587
  const sheetId = this.getters.getActiveSheetId();
37472
- const viewportRects = this.getSubViewports(sheetId)
37473
- .map((viewport) => viewport.getVisibleRect(zone))
37474
- .filter(isDefined$1);
37475
- if (viewportRects.length === 0) {
37476
- return { x: 0, y: 0, width: 0, height: 0 };
37477
- }
37478
- return this.recomposeRect(viewportRects);
37588
+ return this.mapViewportsToRect(sheetId, (viewport) => viewport.getVisibleRect(zone));
37479
37589
  }
37480
37590
  /**
37481
37591
  * Computes the actual size and position (:Rect) of the zone on the canvas
@@ -37483,13 +37593,7 @@ class SheetViewPlugin extends UIPlugin {
37483
37593
  */
37484
37594
  getRect(zone) {
37485
37595
  const sheetId = this.getters.getActiveSheetId();
37486
- const viewportRects = this.getSubViewports(sheetId)
37487
- .map((viewport) => viewport.getFullRect(zone))
37488
- .filter(isDefined$1);
37489
- if (viewportRects.length === 0) {
37490
- return { x: 0, y: 0, width: 0, height: 0 };
37491
- }
37492
- return this.recomposeRect(viewportRects);
37596
+ return this.mapViewportsToRect(sheetId, (viewport) => viewport.getFullRect(zone));
37493
37597
  }
37494
37598
  /**
37495
37599
  * Returns the position of the MainViewport relatively to the start of the grid (without headers)
@@ -37521,7 +37625,7 @@ class SheetViewPlugin extends UIPlugin {
37521
37625
  }
37522
37626
  checkPositiveDimension(cmd) {
37523
37627
  if (cmd.width < 0 || cmd.height < 0) {
37524
- return 68 /* CommandResult.InvalidViewportSize */;
37628
+ return 69 /* CommandResult.InvalidViewportSize */;
37525
37629
  }
37526
37630
  return 0 /* CommandResult.Success */;
37527
37631
  }
@@ -37531,7 +37635,7 @@ class SheetViewPlugin extends UIPlugin {
37531
37635
  cmd.gridOffsetY === this.gridOffsetY &&
37532
37636
  cmd.width === width &&
37533
37637
  cmd.height === height) {
37534
- return 76 /* CommandResult.ValuesNotChanged */;
37638
+ return 77 /* CommandResult.ValuesNotChanged */;
37535
37639
  }
37536
37640
  return 0 /* CommandResult.Success */;
37537
37641
  }
@@ -37539,7 +37643,7 @@ class SheetViewPlugin extends UIPlugin {
37539
37643
  const pane = this.getMainInternalViewport(this.getters.getActiveSheetId());
37540
37644
  if ((!pane.canScrollHorizontally && offsetX > 0) ||
37541
37645
  (!pane.canScrollVertically && offsetY > 0)) {
37542
- return 69 /* CommandResult.InvalidScrollingDirection */;
37646
+ return 70 /* CommandResult.InvalidScrollingDirection */;
37543
37647
  }
37544
37648
  return 0 /* CommandResult.Success */;
37545
37649
  }
@@ -37558,12 +37662,11 @@ class SheetViewPlugin extends UIPlugin {
37558
37662
  }
37559
37663
  /** gets rid of deprecated sheetIds */
37560
37664
  cleanViewports() {
37561
- const sheetIds = this.getters.getSheetIds();
37562
- for (let sheetId of Object.keys(this.viewports)) {
37563
- if (!sheetIds.includes(sheetId)) {
37564
- delete this.viewports[sheetId];
37565
- }
37665
+ const newViewport = {};
37666
+ for (const sheetId of this.getters.getSheetIds()) {
37667
+ newViewport[sheetId] = this.viewports[sheetId];
37566
37668
  }
37669
+ this.viewports = newViewport;
37567
37670
  }
37568
37671
  resetSheetViews() {
37569
37672
  this.cleanViewports();
@@ -37584,14 +37687,14 @@ class SheetViewPlugin extends UIPlugin {
37584
37687
  this.recomputeViewports();
37585
37688
  }
37586
37689
  recomputeViewports() {
37587
- for (let sheetId of Object.keys(this.viewports)) {
37690
+ for (const sheetId of this.getters.getSheetIds()) {
37588
37691
  this.resetViewports(sheetId);
37589
37692
  }
37590
37693
  }
37591
37694
  setSheetViewOffset(offsetX, offsetY) {
37592
37695
  const sheetId = this.getters.getActiveSheetId();
37593
37696
  const { maxOffsetX, maxOffsetY } = this.getMaximumSheetOffset();
37594
- Object.values(this.getSubViewports(sheetId)).forEach((viewport) => viewport.setViewportOffset(clip(offsetX, 0, maxOffsetX), clip(offsetY, 0, maxOffsetY)));
37697
+ this.getSubViewports(sheetId).forEach((viewport) => viewport.setViewportOffset(clip(offsetX, 0, maxOffsetX), clip(offsetY, 0, maxOffsetY)));
37595
37698
  }
37596
37699
  getViewportOffset(sheetId) {
37597
37700
  var _a, _b;
@@ -37607,8 +37710,10 @@ class SheetViewPlugin extends UIPlugin {
37607
37710
  const { xSplit, ySplit } = this.getters.getPaneDivisions(sheetId);
37608
37711
  const nCols = this.getters.getNumberCols(sheetId);
37609
37712
  const nRows = this.getters.getNumberRows(sheetId);
37610
- const colOffset = this.getters.getColRowOffset("COL", 0, xSplit, sheetId);
37611
- const rowOffset = this.getters.getColRowOffset("ROW", 0, ySplit, sheetId);
37713
+ const colOffset = Math.min(this.getters.getColRowOffset("COL", 0, xSplit, sheetId), this.sheetViewWidth);
37714
+ const rowOffset = Math.min(this.getters.getColRowOffset("ROW", 0, ySplit, sheetId), this.sheetViewHeight);
37715
+ const unfrozenWidth = Math.max(this.sheetViewWidth - colOffset, 0);
37716
+ const unfrozenHeight = Math.max(this.sheetViewHeight - rowOffset, 0);
37612
37717
  const { xRatio, yRatio } = this.getFrozenSheetViewRatio(sheetId);
37613
37718
  const canScrollHorizontally = xRatio < 1.0;
37614
37719
  const canScrollVertically = yRatio < 1.0;
@@ -37619,14 +37724,14 @@ class SheetViewPlugin extends UIPlugin {
37619
37724
  new InternalViewport(this.getters, sheetId, { left: 0, right: xSplit - 1, top: 0, bottom: ySplit - 1 }, { width: colOffset, height: rowOffset }, { canScrollHorizontally: false, canScrollVertically: false }, { x: 0, y: 0 })) ||
37620
37725
  undefined,
37621
37726
  topRight: (ySplit &&
37622
- new InternalViewport(this.getters, sheetId, { left: xSplit, right: nCols - 1, top: 0, bottom: ySplit - 1 }, { width: this.sheetViewWidth - colOffset, height: rowOffset }, { canScrollHorizontally, canScrollVertically: false }, { x: canScrollHorizontally ? previousOffset.x : 0, y: 0 })) ||
37727
+ new InternalViewport(this.getters, sheetId, { left: xSplit, right: nCols - 1, top: 0, bottom: ySplit - 1 }, { width: unfrozenWidth, height: rowOffset }, { canScrollHorizontally, canScrollVertically: false }, { x: canScrollHorizontally ? previousOffset.x : 0, y: 0 })) ||
37623
37728
  undefined,
37624
37729
  bottomLeft: (xSplit &&
37625
- new InternalViewport(this.getters, sheetId, { left: 0, right: xSplit - 1, top: ySplit, bottom: nRows - 1 }, { width: colOffset, height: this.sheetViewHeight - rowOffset }, { canScrollHorizontally: false, canScrollVertically }, { x: 0, y: canScrollVertically ? previousOffset.y : 0 })) ||
37730
+ new InternalViewport(this.getters, sheetId, { left: 0, right: xSplit - 1, top: ySplit, bottom: nRows - 1 }, { width: colOffset, height: unfrozenHeight }, { canScrollHorizontally: false, canScrollVertically }, { x: 0, y: canScrollVertically ? previousOffset.y : 0 })) ||
37626
37731
  undefined,
37627
37732
  bottomRight: new InternalViewport(this.getters, sheetId, { left: xSplit, right: nCols - 1, top: ySplit, bottom: nRows - 1 }, {
37628
- width: this.sheetViewWidth - colOffset,
37629
- height: this.sheetViewHeight - rowOffset,
37733
+ width: unfrozenWidth,
37734
+ height: unfrozenHeight,
37630
37735
  }, { canScrollHorizontally, canScrollVertically }, {
37631
37736
  x: canScrollHorizontally ? previousOffset.x : 0,
37632
37737
  y: canScrollVertically ? previousOffset.y : 0,
@@ -37638,7 +37743,7 @@ class SheetViewPlugin extends UIPlugin {
37638
37743
  * Adjust the viewport such that the anchor position is visible
37639
37744
  */
37640
37745
  refreshViewport(sheetId, anchorPosition) {
37641
- Object.values(this.getSubViewports(sheetId)).forEach((viewport) => {
37746
+ this.getSubViewports(sheetId).forEach((viewport) => {
37642
37747
  viewport.adjustViewportZone();
37643
37748
  viewport.adjustPosition(anchorPosition);
37644
37749
  });
@@ -37689,16 +37794,30 @@ class SheetViewPlugin extends UIPlugin {
37689
37794
  const height = this.sheetViewHeight + this.gridOffsetY;
37690
37795
  return { xRatio: offsetCorrectionX / width, yRatio: offsetCorrectionY / height };
37691
37796
  }
37692
- recomposeRect(viewportRects) {
37693
- const x = Math.min(...viewportRects.map((rect) => rect.x));
37694
- const y = Math.min(...viewportRects.map((rect) => rect.y));
37695
- const width = Math.max(...viewportRects.map((rect) => rect.x + rect.width)) - x;
37696
- const height = Math.max(...viewportRects.map((rect) => rect.y + rect.height)) - y;
37797
+ mapViewportsToRect(sheetId, rectCallBack) {
37798
+ let x = Infinity;
37799
+ let y = Infinity;
37800
+ let width = 0;
37801
+ let height = 0;
37802
+ let hasViewports = false;
37803
+ for (const viewport of this.getSubViewports(sheetId)) {
37804
+ const rect = rectCallBack(viewport);
37805
+ if (rect) {
37806
+ hasViewports = true;
37807
+ x = Math.min(x, rect.x);
37808
+ y = Math.min(y, rect.y);
37809
+ width = Math.max(width, rect.x + rect.width);
37810
+ height = Math.max(height, rect.y + rect.height);
37811
+ }
37812
+ }
37813
+ if (!hasViewports) {
37814
+ return { x: 0, y: 0, width: 0, height: 0 };
37815
+ }
37697
37816
  return {
37698
37817
  x: x + this.gridOffsetX,
37699
37818
  y: y + this.gridOffsetY,
37700
- width,
37701
- height,
37819
+ width: width - x,
37820
+ height: height - y,
37702
37821
  };
37703
37822
  }
37704
37823
  }
@@ -37751,7 +37870,7 @@ class SortPlugin extends UIPlugin {
37751
37870
  for (let row = zone.top; row <= zone.bottom; row++) {
37752
37871
  for (let col = zone.left; col <= zone.right; col++) {
37753
37872
  if (!this.getters.isInMerge(sheetId, col, row)) {
37754
- return 63 /* CommandResult.InvalidSortZone */;
37873
+ return 64 /* CommandResult.InvalidSortZone */;
37755
37874
  }
37756
37875
  }
37757
37876
  }
@@ -37772,7 +37891,7 @@ class SortPlugin extends UIPlugin {
37772
37891
  ];
37773
37892
  return widthCurrent === widthFirst && heightCurrent === heightFirst;
37774
37893
  })) {
37775
- return 63 /* CommandResult.InvalidSortZone */;
37894
+ return 64 /* CommandResult.InvalidSortZone */;
37776
37895
  }
37777
37896
  return 0 /* CommandResult.Success */;
37778
37897
  }
@@ -38438,7 +38557,7 @@ class BottomBar extends Component {
38438
38557
  addSheet() {
38439
38558
  const activeSheetId = this.env.model.getters.getActiveSheetId();
38440
38559
  const position = this.env.model.getters.getSheetIds().findIndex((sheetId) => sheetId === activeSheetId) + 1;
38441
- const sheetId = this.env.model.uuidGenerator.uuidv4();
38560
+ const sheetId = this.env.model.uuidGenerator.smallUuid();
38442
38561
  const name = this.env.model.getters.getNextSheetName(this.env._t("Sheet"));
38443
38562
  this.env.model.dispatch("CREATE_SHEET", { sheetId, position, name });
38444
38563
  this.env.model.dispatch("ACTIVATE_SHEET", { sheetIdFrom: activeSheetId, sheetIdTo: sheetId });
@@ -38927,7 +39046,7 @@ const AddMergeInteractiveContent = {
38927
39046
  };
38928
39047
  function interactiveAddMerge(env, sheetId, target) {
38929
39048
  const result = env.model.dispatch("ADD_MERGE", { sheetId, target });
38930
- if (result.isCancelledBecause(80 /* CommandResult.MergeInFilter */)) {
39049
+ if (result.isCancelledBecause(81 /* CommandResult.MergeInFilter */)) {
38931
39050
  env.raiseError(AddMergeInteractiveContent.MergeInFilter);
38932
39051
  }
38933
39052
  else if (result.isCancelledBecause(3 /* CommandResult.MergeIsDestructive */)) {
@@ -40060,7 +40179,7 @@ class Tree {
40060
40179
  }
40061
40180
  /**
40062
40181
  * Drop the operation and all following operations in every
40063
- * branch
40182
+ * branches
40064
40183
  */
40065
40184
  drop(operationId) {
40066
40185
  for (const branch of this.branches) {
@@ -40357,9 +40476,16 @@ class SelectiveHistory {
40357
40476
  this.fastForward();
40358
40477
  this.insert(redoId, this.buildEmpty(redoId), insertAfter);
40359
40478
  }
40360
- drop(operationId) {
40479
+ rebase(operationId) {
40480
+ const operation = this.get(operationId);
40481
+ const execution = [...this.tree.execution(this.HEAD_BRANCH).startAfter(operationId)];
40361
40482
  this.revertBefore(operationId);
40483
+ const baseId = this.HEAD_OPERATION.id;
40362
40484
  this.tree.drop(operationId);
40485
+ this.insert(operationId, operation, baseId);
40486
+ for (const { operation } of execution) {
40487
+ this.insert(operation.id, operation.data, this.HEAD_OPERATION.id);
40488
+ }
40363
40489
  }
40364
40490
  /**
40365
40491
  * Revert the state as it was *before* the given operation was executed.
@@ -40482,7 +40608,6 @@ class LocalHistory extends EventBus$1 {
40482
40608
  this.session.on("new-local-state-update", this, this.onNewLocalStateUpdate);
40483
40609
  this.session.on("revision-undone", this, ({ commands }) => this.selectiveUndo(commands));
40484
40610
  this.session.on("revision-redone", this, ({ commands }) => this.selectiveRedo(commands));
40485
- this.session.on("pending-revisions-dropped", this, ({ revisionIds }) => this.drop(revisionIds));
40486
40611
  this.session.on("snapshot", this, () => {
40487
40612
  this.undoStack = [];
40488
40613
  this.redoStack = [];
@@ -40535,10 +40660,6 @@ class LocalHistory extends EventBus$1 {
40535
40660
  canRedo() {
40536
40661
  return this.redoStack.length > 0;
40537
40662
  }
40538
- drop(revisionIds) {
40539
- this.undoStack = this.undoStack.filter((id) => !revisionIds.includes(id));
40540
- this.redoStack = [];
40541
- }
40542
40663
  onNewLocalStateUpdate({ id }) {
40543
40664
  this.undoStack.push(id);
40544
40665
  this.redoStack = [];
@@ -41119,7 +41240,7 @@ class SelectionStreamProcessor {
41119
41240
  */
41120
41241
  moveAnchorCell(direction, step = 1) {
41121
41242
  if (step !== "end" && step <= 0) {
41122
- return new DispatchResult(83 /* CommandResult.InvalidSelectionStep */);
41243
+ return new DispatchResult(84 /* CommandResult.InvalidSelectionStep */);
41123
41244
  }
41124
41245
  const { col, row } = this.getNextAvailablePosition(direction, step);
41125
41246
  return this.selectCell(col, row);
@@ -41165,7 +41286,7 @@ class SelectionStreamProcessor {
41165
41286
  */
41166
41287
  resizeAnchorZone(direction, step = 1) {
41167
41288
  if (step !== "end" && step <= 0) {
41168
- return new DispatchResult(83 /* CommandResult.InvalidSelectionStep */);
41289
+ return new DispatchResult(84 /* CommandResult.InvalidSelectionStep */);
41169
41290
  }
41170
41291
  const sheetId = this.getters.getActiveSheetId();
41171
41292
  const anchor = this.anchor;
@@ -43111,10 +43232,10 @@ class Model extends EventBus {
43111
43232
  const command = { type, ...payload };
43112
43233
  let status = this.status;
43113
43234
  if (this.getters.isReadonly() && !canExecuteInReadonly(command)) {
43114
- return new DispatchResult(67 /* CommandResult.Readonly */);
43235
+ return new DispatchResult(68 /* CommandResult.Readonly */);
43115
43236
  }
43116
43237
  if (!this.session.canApplyOptimisticUpdate()) {
43117
- return new DispatchResult(64 /* CommandResult.WaitingSessionConfirmation */);
43238
+ return new DispatchResult(65 /* CommandResult.WaitingSessionConfirmation */);
43118
43239
  }
43119
43240
  switch (status) {
43120
43241
  case 0 /* Status.Ready */:
@@ -43316,7 +43437,7 @@ class Model extends EventBus {
43316
43437
  }
43317
43438
  setupConfig(config) {
43318
43439
  const client = config.client || {
43319
- id: this.uuidGenerator.uuidv4(),
43440
+ id: this.uuidGenerator.smallUuid(),
43320
43441
  name: _lt("Anonymous").toString(),
43321
43442
  };
43322
43443
  const transportService = config.transportService || new LocalTransportService();
@@ -43536,6 +43657,6 @@ function addFunction(functionName, functionDescription) {
43536
43657
  export { AbstractChart, CommandResult, CorePlugin, DATETIME_FORMAT, DispatchResult, EvaluationError, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, __info__, addFunction, astToFormula, cellTypes, compile, components, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, invalidateEvaluationCommands, load, parse, readonlyAllowedCommands, registries, setTranslationMethod, tokenize };
43537
43658
 
43538
43659
 
43539
- __info__.version = '16.0.59';
43540
- __info__.date = '2025-01-29T06:24:17.486Z';
43541
- __info__.hash = '0897f45';
43660
+ __info__.version = '16.0.62';
43661
+ __info__.date = '2025-02-14T08:36:41.388Z';
43662
+ __info__.hash = '34f2802';