@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.
@@ -1102,9 +1102,16 @@ function deepEquals(o1, o2) {
1102
1102
  }
1103
1103
  return true;
1104
1104
  }
1105
- /** Check if the given array contains all the values of the other array. */
1105
+ /**
1106
+ * Check if the given array contains all the values of the other array.
1107
+ * It makes the assumption that both array do not contain duplicates.
1108
+ */
1106
1109
  function includesAll(arr, values) {
1107
- return values.every((value) => arr.includes(value));
1110
+ if (arr.length < values.length) {
1111
+ return false;
1112
+ }
1113
+ const set = new Set(arr);
1114
+ return values.every((value) => set.has(value));
1108
1115
  }
1109
1116
  /**
1110
1117
  * Return an object with all the keys in the object that have a falsy value removed.
@@ -2379,6 +2386,37 @@ class UuidGenerator {
2379
2386
  setIsFastStrategy(isFast) {
2380
2387
  this.isFastIdStrategy = isFast;
2381
2388
  }
2389
+ /**
2390
+ * Generates a custom UUID using a simple 26^8 method (8-character alphanumeric string with lowercase letters)
2391
+ * This has a higher chance of collision than a UUIDv4, but not only faster to generate than an UUIDV4,
2392
+ * it also has a smaller size, which is preferable to alleviate the overall data size.
2393
+ *
2394
+ * This method is preferable when generating uuids for the core data (sheetId, figureId, etc)
2395
+ * as they will appear several times in the revisions and local history.
2396
+ *
2397
+ */
2398
+ smallUuid() {
2399
+ if (this.isFastIdStrategy) {
2400
+ this.fastIdStart++;
2401
+ return String(this.fastIdStart);
2402
+ //@ts-ignore
2403
+ }
2404
+ else if (window.crypto && window.crypto.getRandomValues) {
2405
+ //@ts-ignore
2406
+ return ([1e7] + -1e3).replace(/[018]/g, (c) => (c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16));
2407
+ }
2408
+ else {
2409
+ // mainly for jest and other browsers that do not have the crypto functionality
2410
+ return "xxxxxxxx-xxxx".replace(/[xy]/g, function (c) {
2411
+ var r = (Math.random() * 16) | 0, v = c == "x" ? r : (r & 0x3) | 0x8;
2412
+ return v.toString(16);
2413
+ });
2414
+ }
2415
+ }
2416
+ /**
2417
+ * Generates an UUIDV4, has astronomically low chance of collision, but is larger in size than the smallUuid.
2418
+ * This method should be used when you need to avoid collisions at all costs, like the id of a revision.
2419
+ */
2382
2420
  uuidv4() {
2383
2421
  if (this.isFastIdStrategy) {
2384
2422
  this.fastIdStart++;
@@ -2492,17 +2530,20 @@ function toZoneWithoutBoundaryChanges(xc) {
2492
2530
  */
2493
2531
  function toUnboundedZone(xc) {
2494
2532
  const zone = toZoneWithoutBoundaryChanges(xc);
2533
+ reorderZone(zone);
2534
+ return zone;
2535
+ }
2536
+ function reorderZone(zone) {
2495
2537
  if (zone.right !== undefined && zone.right < zone.left) {
2496
- const tmp = zone.left;
2538
+ const right = zone.left;
2497
2539
  zone.left = zone.right;
2498
- zone.right = tmp;
2540
+ zone.right = right;
2499
2541
  }
2500
2542
  if (zone.bottom !== undefined && zone.bottom < zone.top) {
2501
- const tmp = zone.top;
2543
+ const bottom = zone.top;
2502
2544
  zone.top = zone.bottom;
2503
- zone.bottom = tmp;
2545
+ zone.bottom = bottom;
2504
2546
  }
2505
- return zone;
2506
2547
  }
2507
2548
  /**
2508
2549
  * Convert from a cartesian reference to a Zone.
@@ -3390,67 +3431,68 @@ exports.CommandResult = void 0;
3390
3431
  CommandResult[CommandResult["InvalidRange"] = 25] = "InvalidRange";
3391
3432
  CommandResult[CommandResult["InvalidZones"] = 26] = "InvalidZones";
3392
3433
  CommandResult[CommandResult["InvalidSheetId"] = 27] = "InvalidSheetId";
3393
- CommandResult[CommandResult["InputAlreadyFocused"] = 28] = "InputAlreadyFocused";
3394
- CommandResult[CommandResult["MaximumRangesReached"] = 29] = "MaximumRangesReached";
3395
- CommandResult[CommandResult["InvalidInputId"] = 30] = "InvalidInputId";
3396
- CommandResult[CommandResult["InvalidChartDefinition"] = 31] = "InvalidChartDefinition";
3397
- CommandResult[CommandResult["InvalidDataSet"] = 32] = "InvalidDataSet";
3398
- CommandResult[CommandResult["InvalidLabelRange"] = 33] = "InvalidLabelRange";
3399
- CommandResult[CommandResult["InvalidScorecardKeyValue"] = 34] = "InvalidScorecardKeyValue";
3400
- CommandResult[CommandResult["InvalidScorecardBaseline"] = 35] = "InvalidScorecardBaseline";
3401
- CommandResult[CommandResult["InvalidGaugeDataRange"] = 36] = "InvalidGaugeDataRange";
3402
- CommandResult[CommandResult["EmptyGaugeRangeMin"] = 37] = "EmptyGaugeRangeMin";
3403
- CommandResult[CommandResult["GaugeRangeMinNaN"] = 38] = "GaugeRangeMinNaN";
3404
- CommandResult[CommandResult["EmptyGaugeRangeMax"] = 39] = "EmptyGaugeRangeMax";
3405
- CommandResult[CommandResult["GaugeRangeMaxNaN"] = 40] = "GaugeRangeMaxNaN";
3406
- CommandResult[CommandResult["GaugeRangeMinBiggerThanRangeMax"] = 41] = "GaugeRangeMinBiggerThanRangeMax";
3407
- CommandResult[CommandResult["GaugeLowerInflectionPointNaN"] = 42] = "GaugeLowerInflectionPointNaN";
3408
- CommandResult[CommandResult["GaugeUpperInflectionPointNaN"] = 43] = "GaugeUpperInflectionPointNaN";
3409
- CommandResult[CommandResult["GaugeLowerBiggerThanUpper"] = 44] = "GaugeLowerBiggerThanUpper";
3410
- CommandResult[CommandResult["InvalidAutofillSelection"] = 45] = "InvalidAutofillSelection";
3411
- CommandResult[CommandResult["WrongComposerSelection"] = 46] = "WrongComposerSelection";
3412
- CommandResult[CommandResult["MinBiggerThanMax"] = 47] = "MinBiggerThanMax";
3413
- CommandResult[CommandResult["LowerBiggerThanUpper"] = 48] = "LowerBiggerThanUpper";
3414
- CommandResult[CommandResult["MidBiggerThanMax"] = 49] = "MidBiggerThanMax";
3415
- CommandResult[CommandResult["MinBiggerThanMid"] = 50] = "MinBiggerThanMid";
3416
- CommandResult[CommandResult["FirstArgMissing"] = 51] = "FirstArgMissing";
3417
- CommandResult[CommandResult["SecondArgMissing"] = 52] = "SecondArgMissing";
3418
- CommandResult[CommandResult["MinNaN"] = 53] = "MinNaN";
3419
- CommandResult[CommandResult["MidNaN"] = 54] = "MidNaN";
3420
- CommandResult[CommandResult["MaxNaN"] = 55] = "MaxNaN";
3421
- CommandResult[CommandResult["ValueUpperInflectionNaN"] = 56] = "ValueUpperInflectionNaN";
3422
- CommandResult[CommandResult["ValueLowerInflectionNaN"] = 57] = "ValueLowerInflectionNaN";
3423
- CommandResult[CommandResult["MinInvalidFormula"] = 58] = "MinInvalidFormula";
3424
- CommandResult[CommandResult["MidInvalidFormula"] = 59] = "MidInvalidFormula";
3425
- CommandResult[CommandResult["MaxInvalidFormula"] = 60] = "MaxInvalidFormula";
3426
- CommandResult[CommandResult["ValueUpperInvalidFormula"] = 61] = "ValueUpperInvalidFormula";
3427
- CommandResult[CommandResult["ValueLowerInvalidFormula"] = 62] = "ValueLowerInvalidFormula";
3428
- CommandResult[CommandResult["InvalidSortZone"] = 63] = "InvalidSortZone";
3429
- CommandResult[CommandResult["WaitingSessionConfirmation"] = 64] = "WaitingSessionConfirmation";
3430
- CommandResult[CommandResult["MergeOverlap"] = 65] = "MergeOverlap";
3431
- CommandResult[CommandResult["TooManyHiddenElements"] = 66] = "TooManyHiddenElements";
3432
- CommandResult[CommandResult["Readonly"] = 67] = "Readonly";
3433
- CommandResult[CommandResult["InvalidViewportSize"] = 68] = "InvalidViewportSize";
3434
- CommandResult[CommandResult["InvalidScrollingDirection"] = 69] = "InvalidScrollingDirection";
3435
- CommandResult[CommandResult["FigureDoesNotExist"] = 70] = "FigureDoesNotExist";
3436
- CommandResult[CommandResult["InvalidConditionalFormatId"] = 71] = "InvalidConditionalFormatId";
3437
- CommandResult[CommandResult["InvalidCellPopover"] = 72] = "InvalidCellPopover";
3438
- CommandResult[CommandResult["EmptyTarget"] = 73] = "EmptyTarget";
3439
- CommandResult[CommandResult["InvalidFreezeQuantity"] = 74] = "InvalidFreezeQuantity";
3440
- CommandResult[CommandResult["FrozenPaneOverlap"] = 75] = "FrozenPaneOverlap";
3441
- CommandResult[CommandResult["ValuesNotChanged"] = 76] = "ValuesNotChanged";
3442
- CommandResult[CommandResult["InvalidFilterZone"] = 77] = "InvalidFilterZone";
3443
- CommandResult[CommandResult["FilterOverlap"] = 78] = "FilterOverlap";
3444
- CommandResult[CommandResult["FilterNotFound"] = 79] = "FilterNotFound";
3445
- CommandResult[CommandResult["MergeInFilter"] = 80] = "MergeInFilter";
3446
- CommandResult[CommandResult["NonContinuousTargets"] = 81] = "NonContinuousTargets";
3447
- CommandResult[CommandResult["DuplicatedFigureId"] = 82] = "DuplicatedFigureId";
3448
- CommandResult[CommandResult["InvalidSelectionStep"] = 83] = "InvalidSelectionStep";
3449
- CommandResult[CommandResult["DuplicatedChartId"] = 84] = "DuplicatedChartId";
3450
- CommandResult[CommandResult["ChartDoesNotExist"] = 85] = "ChartDoesNotExist";
3451
- CommandResult[CommandResult["InvalidHeaderIndex"] = 86] = "InvalidHeaderIndex";
3452
- CommandResult[CommandResult["InvalidQuantity"] = 87] = "InvalidQuantity";
3453
- CommandResult[CommandResult["NoChanges"] = 88] = "NoChanges";
3434
+ CommandResult[CommandResult["InvalidCellId"] = 28] = "InvalidCellId";
3435
+ CommandResult[CommandResult["InputAlreadyFocused"] = 29] = "InputAlreadyFocused";
3436
+ CommandResult[CommandResult["MaximumRangesReached"] = 30] = "MaximumRangesReached";
3437
+ CommandResult[CommandResult["InvalidInputId"] = 31] = "InvalidInputId";
3438
+ CommandResult[CommandResult["InvalidChartDefinition"] = 32] = "InvalidChartDefinition";
3439
+ CommandResult[CommandResult["InvalidDataSet"] = 33] = "InvalidDataSet";
3440
+ CommandResult[CommandResult["InvalidLabelRange"] = 34] = "InvalidLabelRange";
3441
+ CommandResult[CommandResult["InvalidScorecardKeyValue"] = 35] = "InvalidScorecardKeyValue";
3442
+ CommandResult[CommandResult["InvalidScorecardBaseline"] = 36] = "InvalidScorecardBaseline";
3443
+ CommandResult[CommandResult["InvalidGaugeDataRange"] = 37] = "InvalidGaugeDataRange";
3444
+ CommandResult[CommandResult["EmptyGaugeRangeMin"] = 38] = "EmptyGaugeRangeMin";
3445
+ CommandResult[CommandResult["GaugeRangeMinNaN"] = 39] = "GaugeRangeMinNaN";
3446
+ CommandResult[CommandResult["EmptyGaugeRangeMax"] = 40] = "EmptyGaugeRangeMax";
3447
+ CommandResult[CommandResult["GaugeRangeMaxNaN"] = 41] = "GaugeRangeMaxNaN";
3448
+ CommandResult[CommandResult["GaugeRangeMinBiggerThanRangeMax"] = 42] = "GaugeRangeMinBiggerThanRangeMax";
3449
+ CommandResult[CommandResult["GaugeLowerInflectionPointNaN"] = 43] = "GaugeLowerInflectionPointNaN";
3450
+ CommandResult[CommandResult["GaugeUpperInflectionPointNaN"] = 44] = "GaugeUpperInflectionPointNaN";
3451
+ CommandResult[CommandResult["GaugeLowerBiggerThanUpper"] = 45] = "GaugeLowerBiggerThanUpper";
3452
+ CommandResult[CommandResult["InvalidAutofillSelection"] = 46] = "InvalidAutofillSelection";
3453
+ CommandResult[CommandResult["WrongComposerSelection"] = 47] = "WrongComposerSelection";
3454
+ CommandResult[CommandResult["MinBiggerThanMax"] = 48] = "MinBiggerThanMax";
3455
+ CommandResult[CommandResult["LowerBiggerThanUpper"] = 49] = "LowerBiggerThanUpper";
3456
+ CommandResult[CommandResult["MidBiggerThanMax"] = 50] = "MidBiggerThanMax";
3457
+ CommandResult[CommandResult["MinBiggerThanMid"] = 51] = "MinBiggerThanMid";
3458
+ CommandResult[CommandResult["FirstArgMissing"] = 52] = "FirstArgMissing";
3459
+ CommandResult[CommandResult["SecondArgMissing"] = 53] = "SecondArgMissing";
3460
+ CommandResult[CommandResult["MinNaN"] = 54] = "MinNaN";
3461
+ CommandResult[CommandResult["MidNaN"] = 55] = "MidNaN";
3462
+ CommandResult[CommandResult["MaxNaN"] = 56] = "MaxNaN";
3463
+ CommandResult[CommandResult["ValueUpperInflectionNaN"] = 57] = "ValueUpperInflectionNaN";
3464
+ CommandResult[CommandResult["ValueLowerInflectionNaN"] = 58] = "ValueLowerInflectionNaN";
3465
+ CommandResult[CommandResult["MinInvalidFormula"] = 59] = "MinInvalidFormula";
3466
+ CommandResult[CommandResult["MidInvalidFormula"] = 60] = "MidInvalidFormula";
3467
+ CommandResult[CommandResult["MaxInvalidFormula"] = 61] = "MaxInvalidFormula";
3468
+ CommandResult[CommandResult["ValueUpperInvalidFormula"] = 62] = "ValueUpperInvalidFormula";
3469
+ CommandResult[CommandResult["ValueLowerInvalidFormula"] = 63] = "ValueLowerInvalidFormula";
3470
+ CommandResult[CommandResult["InvalidSortZone"] = 64] = "InvalidSortZone";
3471
+ CommandResult[CommandResult["WaitingSessionConfirmation"] = 65] = "WaitingSessionConfirmation";
3472
+ CommandResult[CommandResult["MergeOverlap"] = 66] = "MergeOverlap";
3473
+ CommandResult[CommandResult["TooManyHiddenElements"] = 67] = "TooManyHiddenElements";
3474
+ CommandResult[CommandResult["Readonly"] = 68] = "Readonly";
3475
+ CommandResult[CommandResult["InvalidViewportSize"] = 69] = "InvalidViewportSize";
3476
+ CommandResult[CommandResult["InvalidScrollingDirection"] = 70] = "InvalidScrollingDirection";
3477
+ CommandResult[CommandResult["FigureDoesNotExist"] = 71] = "FigureDoesNotExist";
3478
+ CommandResult[CommandResult["InvalidConditionalFormatId"] = 72] = "InvalidConditionalFormatId";
3479
+ CommandResult[CommandResult["InvalidCellPopover"] = 73] = "InvalidCellPopover";
3480
+ CommandResult[CommandResult["EmptyTarget"] = 74] = "EmptyTarget";
3481
+ CommandResult[CommandResult["InvalidFreezeQuantity"] = 75] = "InvalidFreezeQuantity";
3482
+ CommandResult[CommandResult["FrozenPaneOverlap"] = 76] = "FrozenPaneOverlap";
3483
+ CommandResult[CommandResult["ValuesNotChanged"] = 77] = "ValuesNotChanged";
3484
+ CommandResult[CommandResult["InvalidFilterZone"] = 78] = "InvalidFilterZone";
3485
+ CommandResult[CommandResult["FilterOverlap"] = 79] = "FilterOverlap";
3486
+ CommandResult[CommandResult["FilterNotFound"] = 80] = "FilterNotFound";
3487
+ CommandResult[CommandResult["MergeInFilter"] = 81] = "MergeInFilter";
3488
+ CommandResult[CommandResult["NonContinuousTargets"] = 82] = "NonContinuousTargets";
3489
+ CommandResult[CommandResult["DuplicatedFigureId"] = 83] = "DuplicatedFigureId";
3490
+ CommandResult[CommandResult["InvalidSelectionStep"] = 84] = "InvalidSelectionStep";
3491
+ CommandResult[CommandResult["DuplicatedChartId"] = 85] = "DuplicatedChartId";
3492
+ CommandResult[CommandResult["ChartDoesNotExist"] = 86] = "ChartDoesNotExist";
3493
+ CommandResult[CommandResult["InvalidHeaderIndex"] = 87] = "InvalidHeaderIndex";
3494
+ CommandResult[CommandResult["InvalidQuantity"] = 88] = "InvalidQuantity";
3495
+ CommandResult[CommandResult["NoChanges"] = 89] = "NoChanges";
3454
3496
  })(exports.CommandResult || (exports.CommandResult = {}));
3455
3497
 
3456
3498
  function isMatrix(x) {
@@ -4980,7 +5022,7 @@ function interactiveSortSelection(env, sheetId, anchor, zone, sortDirection) {
4980
5022
  });
4981
5023
  }
4982
5024
  }
4983
- if (result.isCancelledBecause(63 /* CommandResult.InvalidSortZone */)) {
5025
+ if (result.isCancelledBecause(64 /* CommandResult.InvalidSortZone */)) {
4984
5026
  const { col, row } = anchor;
4985
5027
  env.model.selection.selectZone({ cell: { col, row }, zone });
4986
5028
  env.raiseError(_lt("Cannot sort. To sort, select only cells or only merges that have the same size."));
@@ -5003,13 +5045,13 @@ const AddFilterInteractiveContent = {
5003
5045
  };
5004
5046
  function interactiveAddFilter(env, sheetId, target) {
5005
5047
  const result = env.model.dispatch("CREATE_FILTER_TABLE", { target, sheetId });
5006
- if (result.isCancelledBecause(78 /* CommandResult.FilterOverlap */)) {
5048
+ if (result.isCancelledBecause(79 /* CommandResult.FilterOverlap */)) {
5007
5049
  env.raiseError(AddFilterInteractiveContent.filterOverlap);
5008
5050
  }
5009
- else if (result.isCancelledBecause(80 /* CommandResult.MergeInFilter */)) {
5051
+ else if (result.isCancelledBecause(81 /* CommandResult.MergeInFilter */)) {
5010
5052
  env.raiseError(AddFilterInteractiveContent.mergeInFilter);
5011
5053
  }
5012
- else if (result.isCancelledBecause(81 /* CommandResult.NonContinuousTargets */)) {
5054
+ else if (result.isCancelledBecause(82 /* CommandResult.NonContinuousTargets */)) {
5013
5055
  env.raiseError(AddFilterInteractiveContent.nonContinuousTargets);
5014
5056
  }
5015
5057
  }
@@ -5031,7 +5073,7 @@ function handlePasteResult(env, result) {
5031
5073
  else if (result.reasons.includes(22 /* CommandResult.WrongFigurePasteOption */)) {
5032
5074
  env.raiseError(PasteInteractiveContent.wrongFigurePasteOption);
5033
5075
  }
5034
- else if (result.reasons.includes(75 /* CommandResult.FrozenPaneOverlap */)) {
5076
+ else if (result.reasons.includes(76 /* CommandResult.FrozenPaneOverlap */)) {
5035
5077
  env.raiseError(PasteInteractiveContent.frozenPaneOverlap);
5036
5078
  }
5037
5079
  }
@@ -5536,7 +5578,7 @@ const UNHIDE_ROWS_ACTION = (env) => {
5536
5578
  const CREATE_SHEET_ACTION = (env) => {
5537
5579
  const activeSheetId = env.model.getters.getActiveSheetId();
5538
5580
  const position = env.model.getters.getSheetIds().indexOf(activeSheetId) + 1;
5539
- const sheetId = env.model.uuidGenerator.uuidv4();
5581
+ const sheetId = env.model.uuidGenerator.smallUuid();
5540
5582
  env.model.dispatch("CREATE_SHEET", { sheetId, position });
5541
5583
  env.model.dispatch("ACTIVATE_SHEET", { sheetIdFrom: activeSheetId, sheetIdTo: sheetId });
5542
5584
  };
@@ -5547,7 +5589,7 @@ const CREATE_CHART = (env) => {
5547
5589
  const getters = env.model.getters;
5548
5590
  const zone = getters.getSelectedZone();
5549
5591
  let dataSetZone = zone;
5550
- const id = env.model.uuidGenerator.uuidv4();
5592
+ const id = env.model.uuidGenerator.smallUuid();
5551
5593
  let labelRange;
5552
5594
  if (zone.left !== zone.right) {
5553
5595
  dataSetZone = { ...zone, left: zone.left + 1 };
@@ -6023,7 +6065,7 @@ sheetMenuRegistry
6023
6065
  name: _lt("Delete"),
6024
6066
  sequence: 10,
6025
6067
  isVisible: (env) => {
6026
- return env.model.getters.getSheetIds().length > 1;
6068
+ return env.model.getters.getVisibleSheetIds().length > 1;
6027
6069
  },
6028
6070
  action: (env) => env.askConfirmation(_lt("Are you sure you want to delete this sheet ?"), () => {
6029
6071
  env.model.dispatch("DELETE_SHEET", { sheetId: env.model.getters.getActiveSheetId() });
@@ -6034,7 +6076,7 @@ sheetMenuRegistry
6034
6076
  sequence: 20,
6035
6077
  action: (env) => {
6036
6078
  const sheetIdFrom = env.model.getters.getActiveSheetId();
6037
- const sheetIdTo = env.model.uuidGenerator.uuidv4();
6079
+ const sheetIdTo = env.model.uuidGenerator.smallUuid();
6038
6080
  env.model.dispatch("DUPLICATE_SHEET", {
6039
6081
  sheetId: sheetIdFrom,
6040
6082
  sheetIdTo,
@@ -6082,22 +6124,22 @@ sheetMenuRegistry
6082
6124
  const CfTerms = {
6083
6125
  Errors: {
6084
6126
  [25 /* CommandResult.InvalidRange */]: _lt("The range is invalid"),
6085
- [51 /* CommandResult.FirstArgMissing */]: _lt("The argument is missing. Please provide a value"),
6086
- [52 /* CommandResult.SecondArgMissing */]: _lt("The second argument is missing. Please provide a value"),
6087
- [53 /* CommandResult.MinNaN */]: _lt("The minpoint must be a number"),
6088
- [54 /* CommandResult.MidNaN */]: _lt("The midpoint must be a number"),
6089
- [55 /* CommandResult.MaxNaN */]: _lt("The maxpoint must be a number"),
6090
- [56 /* CommandResult.ValueUpperInflectionNaN */]: _lt("The first value must be a number"),
6091
- [57 /* CommandResult.ValueLowerInflectionNaN */]: _lt("The second value must be a number"),
6092
- [47 /* CommandResult.MinBiggerThanMax */]: _lt("Minimum must be smaller then Maximum"),
6093
- [50 /* CommandResult.MinBiggerThanMid */]: _lt("Minimum must be smaller then Midpoint"),
6094
- [49 /* CommandResult.MidBiggerThanMax */]: _lt("Midpoint must be smaller then Maximum"),
6095
- [48 /* CommandResult.LowerBiggerThanUpper */]: _lt("Lower inflection point must be smaller than upper inflection point"),
6096
- [58 /* CommandResult.MinInvalidFormula */]: _lt("Invalid Minpoint formula"),
6097
- [60 /* CommandResult.MaxInvalidFormula */]: _lt("Invalid Maxpoint formula"),
6098
- [59 /* CommandResult.MidInvalidFormula */]: _lt("Invalid Midpoint formula"),
6099
- [61 /* CommandResult.ValueUpperInvalidFormula */]: _lt("Invalid upper inflection point formula"),
6100
- [62 /* CommandResult.ValueLowerInvalidFormula */]: _lt("Invalid lower inflection point formula"),
6127
+ [52 /* CommandResult.FirstArgMissing */]: _lt("The argument is missing. Please provide a value"),
6128
+ [53 /* CommandResult.SecondArgMissing */]: _lt("The second argument is missing. Please provide a value"),
6129
+ [54 /* CommandResult.MinNaN */]: _lt("The minpoint must be a number"),
6130
+ [55 /* CommandResult.MidNaN */]: _lt("The midpoint must be a number"),
6131
+ [56 /* CommandResult.MaxNaN */]: _lt("The maxpoint must be a number"),
6132
+ [57 /* CommandResult.ValueUpperInflectionNaN */]: _lt("The first value must be a number"),
6133
+ [58 /* CommandResult.ValueLowerInflectionNaN */]: _lt("The second value must be a number"),
6134
+ [48 /* CommandResult.MinBiggerThanMax */]: _lt("Minimum must be smaller then Maximum"),
6135
+ [51 /* CommandResult.MinBiggerThanMid */]: _lt("Minimum must be smaller then Midpoint"),
6136
+ [50 /* CommandResult.MidBiggerThanMax */]: _lt("Midpoint must be smaller then Maximum"),
6137
+ [49 /* CommandResult.LowerBiggerThanUpper */]: _lt("Lower inflection point must be smaller than upper inflection point"),
6138
+ [59 /* CommandResult.MinInvalidFormula */]: _lt("Invalid Minpoint formula"),
6139
+ [61 /* CommandResult.MaxInvalidFormula */]: _lt("Invalid Maxpoint formula"),
6140
+ [60 /* CommandResult.MidInvalidFormula */]: _lt("Invalid Midpoint formula"),
6141
+ [62 /* CommandResult.ValueUpperInvalidFormula */]: _lt("Invalid upper inflection point formula"),
6142
+ [63 /* CommandResult.ValueLowerInvalidFormula */]: _lt("Invalid lower inflection point formula"),
6101
6143
  [24 /* CommandResult.EmptyRange */]: _lt("A range needs to be defined"),
6102
6144
  Unexpected: _lt("The rule is invalid for an unknown reason"),
6103
6145
  },
@@ -6125,20 +6167,20 @@ const ChartTerms = {
6125
6167
  Errors: {
6126
6168
  Unexpected: _lt("The chart definition is invalid for an unknown reason"),
6127
6169
  // BASIC CHART ERRORS (LINE | BAR | PIE)
6128
- [32 /* CommandResult.InvalidDataSet */]: _lt("The dataset is invalid"),
6129
- [33 /* CommandResult.InvalidLabelRange */]: _lt("Labels are invalid"),
6170
+ [33 /* CommandResult.InvalidDataSet */]: _lt("The dataset is invalid"),
6171
+ [34 /* CommandResult.InvalidLabelRange */]: _lt("Labels are invalid"),
6130
6172
  // SCORECARD CHART ERRORS
6131
- [34 /* CommandResult.InvalidScorecardKeyValue */]: _lt("The key value is invalid"),
6132
- [35 /* CommandResult.InvalidScorecardBaseline */]: _lt("The baseline value is invalid"),
6173
+ [35 /* CommandResult.InvalidScorecardKeyValue */]: _lt("The key value is invalid"),
6174
+ [36 /* CommandResult.InvalidScorecardBaseline */]: _lt("The baseline value is invalid"),
6133
6175
  // GAUGE CHART ERRORS
6134
- [36 /* CommandResult.InvalidGaugeDataRange */]: _lt("The data range is invalid"),
6135
- [37 /* CommandResult.EmptyGaugeRangeMin */]: _lt("A minimum range limit value is needed"),
6136
- [38 /* CommandResult.GaugeRangeMinNaN */]: _lt("The minimum range limit value must be a number"),
6137
- [39 /* CommandResult.EmptyGaugeRangeMax */]: _lt("A maximum range limit value is needed"),
6138
- [40 /* CommandResult.GaugeRangeMaxNaN */]: _lt("The maximum range limit value must be a number"),
6139
- [41 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */]: _lt("Minimum range limit must be smaller than maximum range limit"),
6140
- [42 /* CommandResult.GaugeLowerInflectionPointNaN */]: _lt("The lower inflection point value must be a number"),
6141
- [43 /* CommandResult.GaugeUpperInflectionPointNaN */]: _lt("The upper inflection point value must be a number"),
6176
+ [37 /* CommandResult.InvalidGaugeDataRange */]: _lt("The data range is invalid"),
6177
+ [38 /* CommandResult.EmptyGaugeRangeMin */]: _lt("A minimum range limit value is needed"),
6178
+ [39 /* CommandResult.GaugeRangeMinNaN */]: _lt("The minimum range limit value must be a number"),
6179
+ [40 /* CommandResult.EmptyGaugeRangeMax */]: _lt("A maximum range limit value is needed"),
6180
+ [41 /* CommandResult.GaugeRangeMaxNaN */]: _lt("The maximum range limit value must be a number"),
6181
+ [42 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */]: _lt("Minimum range limit must be smaller than maximum range limit"),
6182
+ [43 /* CommandResult.GaugeLowerInflectionPointNaN */]: _lt("The lower inflection point value must be a number"),
6183
+ [44 /* CommandResult.GaugeUpperInflectionPointNaN */]: _lt("The upper inflection point value must be a number"),
6142
6184
  },
6143
6185
  };
6144
6186
  const NumberFormatTerms = {
@@ -6162,7 +6204,7 @@ function interactiveFreezeColumnsRows(env, dimension, base) {
6162
6204
  const sheetId = env.model.getters.getActiveSheetId();
6163
6205
  const cmd = dimension === "COL" ? "FREEZE_COLUMNS" : "FREEZE_ROWS";
6164
6206
  const result = env.model.dispatch(cmd, { sheetId, quantity: base });
6165
- if (result.isCancelledBecause(65 /* CommandResult.MergeOverlap */)) {
6207
+ if (result.isCancelledBecause(66 /* CommandResult.MergeOverlap */)) {
6166
6208
  env.raiseError(MergeErrorMessage);
6167
6209
  }
6168
6210
  }
@@ -6673,7 +6715,7 @@ css /* scss */ `
6673
6715
  class SelectionInput extends owl.Component {
6674
6716
  constructor() {
6675
6717
  super(...arguments);
6676
- this.id = uuidGenerator$1.uuidv4();
6718
+ this.id = uuidGenerator$1.smallUuid();
6677
6719
  this.previousRanges = this.props.ranges || [];
6678
6720
  this.originSheet = this.env.model.getters.getActiveSheetId();
6679
6721
  this.state = owl.useState({
@@ -6808,11 +6850,11 @@ class LineBarPieConfigPanel extends owl.Component {
6808
6850
  }
6809
6851
  get isDatasetInvalid() {
6810
6852
  var _a;
6811
- return !!((_a = this.state.datasetDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(32 /* CommandResult.InvalidDataSet */));
6853
+ return !!((_a = this.state.datasetDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(33 /* CommandResult.InvalidDataSet */));
6812
6854
  }
6813
6855
  get isLabelInvalid() {
6814
6856
  var _a;
6815
- return !!((_a = this.state.labelsDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(33 /* CommandResult.InvalidLabelRange */));
6857
+ return !!((_a = this.state.labelsDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(34 /* CommandResult.InvalidLabelRange */));
6816
6858
  }
6817
6859
  onUpdateDataSetsHaveTitle(ev) {
6818
6860
  this.props.updateChart(this.props.figureId, {
@@ -7156,11 +7198,11 @@ function checkDataset(definition) {
7156
7198
  if (definition.dataSets) {
7157
7199
  const invalidRanges = definition.dataSets.find((range) => !rangeReference.test(range)) !== undefined;
7158
7200
  if (invalidRanges) {
7159
- return 32 /* CommandResult.InvalidDataSet */;
7201
+ return 33 /* CommandResult.InvalidDataSet */;
7160
7202
  }
7161
7203
  const zones = definition.dataSets.map(toUnboundedZone);
7162
7204
  if (zones.some((zone) => zone.top !== zone.bottom && isFullRow(zone))) {
7163
- return 32 /* CommandResult.InvalidDataSet */;
7205
+ return 33 /* CommandResult.InvalidDataSet */;
7164
7206
  }
7165
7207
  }
7166
7208
  return 0 /* CommandResult.Success */;
@@ -7169,7 +7211,7 @@ function checkLabelRange(definition) {
7169
7211
  if (definition.labelRange) {
7170
7212
  const invalidLabels = !rangeReference.test(definition.labelRange || "");
7171
7213
  if (invalidLabels) {
7172
- return 33 /* CommandResult.InvalidLabelRange */;
7214
+ return 34 /* CommandResult.InvalidLabelRange */;
7173
7215
  }
7174
7216
  }
7175
7217
  return 0 /* CommandResult.Success */;
@@ -7630,7 +7672,7 @@ chartRegistry.add("gauge", {
7630
7672
  });
7631
7673
  function isDataRangeValid(definition) {
7632
7674
  return definition.dataRange && !rangeReference.test(definition.dataRange)
7633
- ? 36 /* CommandResult.InvalidGaugeDataRange */
7675
+ ? 37 /* CommandResult.InvalidGaugeDataRange */
7634
7676
  : 0 /* CommandResult.Success */;
7635
7677
  }
7636
7678
  function checkRangeLimits(check, batchValidations) {
@@ -7662,7 +7704,7 @@ function checkInflectionPointsValue(check, batchValidations) {
7662
7704
  function checkRangeMinBiggerThanRangeMax(definition) {
7663
7705
  if (definition.sectionRule) {
7664
7706
  if (Number(definition.sectionRule.rangeMin) >= Number(definition.sectionRule.rangeMax)) {
7665
- return 41 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */;
7707
+ return 42 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */;
7666
7708
  }
7667
7709
  }
7668
7710
  return 0 /* CommandResult.Success */;
@@ -7671,9 +7713,9 @@ function checkEmpty(value, valueName) {
7671
7713
  if (value === "") {
7672
7714
  switch (valueName) {
7673
7715
  case "rangeMin":
7674
- return 37 /* CommandResult.EmptyGaugeRangeMin */;
7716
+ return 38 /* CommandResult.EmptyGaugeRangeMin */;
7675
7717
  case "rangeMax":
7676
- return 39 /* CommandResult.EmptyGaugeRangeMax */;
7718
+ return 40 /* CommandResult.EmptyGaugeRangeMax */;
7677
7719
  }
7678
7720
  }
7679
7721
  return 0 /* CommandResult.Success */;
@@ -7682,13 +7724,13 @@ function checkNaN(value, valueName) {
7682
7724
  if (isNaN(value)) {
7683
7725
  switch (valueName) {
7684
7726
  case "rangeMin":
7685
- return 38 /* CommandResult.GaugeRangeMinNaN */;
7727
+ return 39 /* CommandResult.GaugeRangeMinNaN */;
7686
7728
  case "rangeMax":
7687
- return 40 /* CommandResult.GaugeRangeMaxNaN */;
7729
+ return 41 /* CommandResult.GaugeRangeMaxNaN */;
7688
7730
  case "lowerInflectionPointValue":
7689
- return 42 /* CommandResult.GaugeLowerInflectionPointNaN */;
7731
+ return 43 /* CommandResult.GaugeLowerInflectionPointNaN */;
7690
7732
  case "upperInflectionPointValue":
7691
- return 43 /* CommandResult.GaugeUpperInflectionPointNaN */;
7733
+ return 44 /* CommandResult.GaugeUpperInflectionPointNaN */;
7692
7734
  }
7693
7735
  }
7694
7736
  return 0 /* CommandResult.Success */;
@@ -8429,7 +8471,7 @@ function createPieChartRuntime(chart, getters) {
8429
8471
  const dataset = {
8430
8472
  label,
8431
8473
  data,
8432
- borderColor: "#FFFFFF",
8474
+ borderColor: chart.background || "#FFFFFF",
8433
8475
  backgroundColor,
8434
8476
  };
8435
8477
  config.data.datasets.push(dataset);
@@ -8448,12 +8490,12 @@ chartRegistry.add("scorecard", {
8448
8490
  });
8449
8491
  function checkKeyValue(definition) {
8450
8492
  return definition.keyValue && !rangeReference.test(definition.keyValue)
8451
- ? 34 /* CommandResult.InvalidScorecardKeyValue */
8493
+ ? 35 /* CommandResult.InvalidScorecardKeyValue */
8452
8494
  : 0 /* CommandResult.Success */;
8453
8495
  }
8454
8496
  function checkBaseline(definition) {
8455
8497
  return definition.baseline && !rangeReference.test(definition.baseline)
8456
- ? 35 /* CommandResult.InvalidScorecardBaseline */
8498
+ ? 36 /* CommandResult.InvalidScorecardBaseline */
8457
8499
  : 0 /* CommandResult.Success */;
8458
8500
  }
8459
8501
  class ScorecardChart$1 extends AbstractChart {
@@ -8882,7 +8924,7 @@ class GaugeChartConfigPanel extends owl.Component {
8882
8924
  }
8883
8925
  get isDataRangeInvalid() {
8884
8926
  var _a;
8885
- return !!((_a = this.state.dataRangeDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(36 /* CommandResult.InvalidGaugeDataRange */));
8927
+ return !!((_a = this.state.dataRangeDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(37 /* CommandResult.InvalidGaugeDataRange */));
8886
8928
  }
8887
8929
  onDataRangeChanged(ranges) {
8888
8930
  this.dataRange = ranges[0];
@@ -8969,28 +9011,28 @@ class GaugeChartDesignPanel extends owl.Component {
8969
9011
  }
8970
9012
  isRangeMinInvalid() {
8971
9013
  var _a, _b, _c;
8972
- return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(37 /* CommandResult.EmptyGaugeRangeMin */)) ||
8973
- ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(38 /* CommandResult.GaugeRangeMinNaN */)) ||
8974
- ((_c = this.state.sectionRuleDispatchResult) === null || _c === void 0 ? void 0 : _c.isCancelledBecause(41 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */)));
9014
+ return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(38 /* CommandResult.EmptyGaugeRangeMin */)) ||
9015
+ ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(39 /* CommandResult.GaugeRangeMinNaN */)) ||
9016
+ ((_c = this.state.sectionRuleDispatchResult) === null || _c === void 0 ? void 0 : _c.isCancelledBecause(42 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */)));
8975
9017
  }
8976
9018
  isRangeMaxInvalid() {
8977
9019
  var _a, _b, _c;
8978
- return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(39 /* CommandResult.EmptyGaugeRangeMax */)) ||
8979
- ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(40 /* CommandResult.GaugeRangeMaxNaN */)) ||
8980
- ((_c = this.state.sectionRuleDispatchResult) === null || _c === void 0 ? void 0 : _c.isCancelledBecause(41 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */)));
9020
+ return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(40 /* CommandResult.EmptyGaugeRangeMax */)) ||
9021
+ ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(41 /* CommandResult.GaugeRangeMaxNaN */)) ||
9022
+ ((_c = this.state.sectionRuleDispatchResult) === null || _c === void 0 ? void 0 : _c.isCancelledBecause(42 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */)));
8981
9023
  }
8982
9024
  // ---------------------------------------------------------------------------
8983
9025
  // COLOR_SECTION_TEMPLATE
8984
9026
  // ---------------------------------------------------------------------------
8985
9027
  get isLowerInflectionPointInvalid() {
8986
9028
  var _a, _b;
8987
- return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(42 /* CommandResult.GaugeLowerInflectionPointNaN */)) ||
8988
- ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(44 /* CommandResult.GaugeLowerBiggerThanUpper */)));
9029
+ return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(43 /* CommandResult.GaugeLowerInflectionPointNaN */)) ||
9030
+ ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(45 /* CommandResult.GaugeLowerBiggerThanUpper */)));
8989
9031
  }
8990
9032
  get isUpperInflectionPointInvalid() {
8991
9033
  var _a, _b;
8992
- return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(43 /* CommandResult.GaugeUpperInflectionPointNaN */)) ||
8993
- ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(44 /* CommandResult.GaugeLowerBiggerThanUpper */)));
9034
+ return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(44 /* CommandResult.GaugeUpperInflectionPointNaN */)) ||
9035
+ ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(45 /* CommandResult.GaugeLowerBiggerThanUpper */)));
8994
9036
  }
8995
9037
  updateInflectionPointValue(attr, ev) {
8996
9038
  const sectionRule = deepCopy(this.props.definition.sectionRule);
@@ -9093,11 +9135,11 @@ class ScorecardChartConfigPanel extends owl.Component {
9093
9135
  }
9094
9136
  get isKeyValueInvalid() {
9095
9137
  var _a;
9096
- return !!((_a = this.state.keyValueDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(34 /* CommandResult.InvalidScorecardKeyValue */));
9138
+ return !!((_a = this.state.keyValueDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(35 /* CommandResult.InvalidScorecardKeyValue */));
9097
9139
  }
9098
9140
  get isBaselineInvalid() {
9099
9141
  var _a;
9100
- return !!((_a = this.state.keyValueDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(35 /* CommandResult.InvalidScorecardBaseline */));
9142
+ return !!((_a = this.state.keyValueDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(36 /* CommandResult.InvalidScorecardBaseline */));
9101
9143
  }
9102
9144
  onKeyValueRangeChanged(ranges) {
9103
9145
  this.keyValue = ranges[0];
@@ -9790,7 +9832,7 @@ class ConditionalFormattingPanel extends owl.Component {
9790
9832
  rule: this.getEditorRule(),
9791
9833
  id: this.state.mode === "edit"
9792
9834
  ? this.state.currentCF.id
9793
- : this.env.model.uuidGenerator.uuidv4(),
9835
+ : this.env.model.uuidGenerator.smallUuid(),
9794
9836
  },
9795
9837
  ranges: this.state.currentCF.ranges.map((xc) => this.env.model.getters.getRangeDataFromXc(sheetId, xc)),
9796
9838
  sheetId,
@@ -9858,7 +9900,7 @@ class ConditionalFormattingPanel extends owl.Component {
9858
9900
  this.state.mode = "add";
9859
9901
  this.state.currentCFType = "CellIsRule";
9860
9902
  this.state.currentCF = {
9861
- id: this.env.model.uuidGenerator.uuidv4(),
9903
+ id: this.env.model.uuidGenerator.smallUuid(),
9862
9904
  ranges: this.env.model.getters
9863
9905
  .getSelectedZones()
9864
9906
  .map((zone) => this.env.model.getters.zoneToXC(this.env.model.getters.getActiveSheetId(), zone)),
@@ -9937,11 +9979,11 @@ class ConditionalFormattingPanel extends owl.Component {
9937
9979
  ****************************************************************************/
9938
9980
  get isValue1Invalid() {
9939
9981
  var _a;
9940
- return !!((_a = this.state.errors) === null || _a === void 0 ? void 0 : _a.includes(51 /* CommandResult.FirstArgMissing */));
9982
+ return !!((_a = this.state.errors) === null || _a === void 0 ? void 0 : _a.includes(52 /* CommandResult.FirstArgMissing */));
9941
9983
  }
9942
9984
  get isValue2Invalid() {
9943
9985
  var _a;
9944
- return !!((_a = this.state.errors) === null || _a === void 0 ? void 0 : _a.includes(52 /* CommandResult.SecondArgMissing */));
9986
+ return !!((_a = this.state.errors) === null || _a === void 0 ? void 0 : _a.includes(53 /* CommandResult.SecondArgMissing */));
9945
9987
  }
9946
9988
  toggleStyle(tool) {
9947
9989
  const style = this.state.rules.cellIs.style;
@@ -9958,17 +10000,17 @@ class ConditionalFormattingPanel extends owl.Component {
9958
10000
  isValueInvalid(threshold) {
9959
10001
  switch (threshold) {
9960
10002
  case "minimum":
9961
- return (this.state.errors.includes(58 /* CommandResult.MinInvalidFormula */) ||
9962
- this.state.errors.includes(50 /* CommandResult.MinBiggerThanMid */) ||
9963
- this.state.errors.includes(47 /* CommandResult.MinBiggerThanMax */) ||
9964
- this.state.errors.includes(53 /* CommandResult.MinNaN */));
10003
+ return (this.state.errors.includes(59 /* CommandResult.MinInvalidFormula */) ||
10004
+ this.state.errors.includes(51 /* CommandResult.MinBiggerThanMid */) ||
10005
+ this.state.errors.includes(48 /* CommandResult.MinBiggerThanMax */) ||
10006
+ this.state.errors.includes(54 /* CommandResult.MinNaN */));
9965
10007
  case "midpoint":
9966
- return (this.state.errors.includes(59 /* CommandResult.MidInvalidFormula */) ||
9967
- this.state.errors.includes(54 /* CommandResult.MidNaN */) ||
9968
- this.state.errors.includes(49 /* CommandResult.MidBiggerThanMax */));
10008
+ return (this.state.errors.includes(60 /* CommandResult.MidInvalidFormula */) ||
10009
+ this.state.errors.includes(55 /* CommandResult.MidNaN */) ||
10010
+ this.state.errors.includes(50 /* CommandResult.MidBiggerThanMax */));
9969
10011
  case "maximum":
9970
- return (this.state.errors.includes(60 /* CommandResult.MaxInvalidFormula */) ||
9971
- this.state.errors.includes(55 /* CommandResult.MaxNaN */));
10012
+ return (this.state.errors.includes(61 /* CommandResult.MaxInvalidFormula */) ||
10013
+ this.state.errors.includes(56 /* CommandResult.MaxNaN */));
9972
10014
  default:
9973
10015
  return false;
9974
10016
  }
@@ -10020,13 +10062,13 @@ class ConditionalFormattingPanel extends owl.Component {
10020
10062
  isInflectionPointInvalid(inflectionPoint) {
10021
10063
  switch (inflectionPoint) {
10022
10064
  case "lowerInflectionPoint":
10023
- return (this.state.errors.includes(57 /* CommandResult.ValueLowerInflectionNaN */) ||
10024
- this.state.errors.includes(62 /* CommandResult.ValueLowerInvalidFormula */) ||
10025
- this.state.errors.includes(48 /* CommandResult.LowerBiggerThanUpper */));
10065
+ return (this.state.errors.includes(58 /* CommandResult.ValueLowerInflectionNaN */) ||
10066
+ this.state.errors.includes(63 /* CommandResult.ValueLowerInvalidFormula */) ||
10067
+ this.state.errors.includes(49 /* CommandResult.LowerBiggerThanUpper */));
10026
10068
  case "upperInflectionPoint":
10027
- return (this.state.errors.includes(56 /* CommandResult.ValueUpperInflectionNaN */) ||
10028
- this.state.errors.includes(61 /* CommandResult.ValueUpperInvalidFormula */) ||
10029
- this.state.errors.includes(48 /* CommandResult.LowerBiggerThanUpper */));
10069
+ return (this.state.errors.includes(57 /* CommandResult.ValueUpperInflectionNaN */) ||
10070
+ this.state.errors.includes(62 /* CommandResult.ValueUpperInvalidFormula */) ||
10071
+ this.state.errors.includes(49 /* CommandResult.LowerBiggerThanUpper */));
10030
10072
  default:
10031
10073
  return true;
10032
10074
  }
@@ -10346,7 +10388,7 @@ class TopBarComponentRegistry extends Registry {
10346
10388
  this.uuidGenerator = new UuidGenerator();
10347
10389
  }
10348
10390
  add(name, value) {
10349
- const component = { ...value, id: this.uuidGenerator.uuidv4() };
10391
+ const component = { ...value, id: this.uuidGenerator.smallUuid() };
10350
10392
  return super.add(name, component);
10351
10393
  }
10352
10394
  }
@@ -12344,6 +12386,26 @@ const LN = {
12344
12386
  isExported: true,
12345
12387
  };
12346
12388
  // -----------------------------------------------------------------------------
12389
+ // LOG
12390
+ // -----------------------------------------------------------------------------
12391
+ const LOG = {
12392
+ description: _lt("The logarithm of a number, for a given base."),
12393
+ args: args(`
12394
+ value (number) ${_lt("The value for which to calculate the logarithm, base e.")}
12395
+ base (number, default=10) ${_lt("The base of the logarithm.")}
12396
+ `),
12397
+ returns: ["NUMBER"],
12398
+ compute: function (value, base = 10) {
12399
+ const _value = toNumber(value);
12400
+ const _base = toNumber(base);
12401
+ assert(() => _value > 0, _lt("The value (%s) must be strictly positive.", _value.toString()));
12402
+ assert(() => _base > 0, _lt("The base (%s) must be strictly positive.", _base.toString()));
12403
+ assert(() => _base !== 1, _lt("The base must be different from 1."));
12404
+ return Math.log10(_value) / Math.log10(_base);
12405
+ },
12406
+ isExported: true,
12407
+ };
12408
+ // -----------------------------------------------------------------------------
12347
12409
  // MOD
12348
12410
  // -----------------------------------------------------------------------------
12349
12411
  const MOD = {
@@ -12812,6 +12874,7 @@ var math = /*#__PURE__*/Object.freeze({
12812
12874
  ISO_CEILING: ISO_CEILING,
12813
12875
  ISODD: ISODD,
12814
12876
  LN: LN,
12877
+ LOG: LOG,
12815
12878
  MOD: MOD,
12816
12879
  ODD: ODD,
12817
12880
  PI: PI,
@@ -19688,7 +19751,7 @@ class EditionPlugin extends UIPlugin {
19688
19751
  validateSelection(length, start, end) {
19689
19752
  return start >= 0 && start <= length && end >= 0 && end <= length
19690
19753
  ? 0 /* CommandResult.Success */
19691
- : 46 /* CommandResult.WrongComposerSelection */;
19754
+ : 47 /* CommandResult.WrongComposerSelection */;
19692
19755
  }
19693
19756
  onColumnsRemoved(cmd) {
19694
19757
  if (cmd.elements.includes(this.col) && this.mode !== "inactive") {
@@ -22431,6 +22494,9 @@ function useGridDrawing(refName, model, canvasSize) {
22431
22494
  canvas.width = width * dpr;
22432
22495
  canvas.height = height * dpr;
22433
22496
  canvas.setAttribute("style", `width:${width}px;height:${height}px;`);
22497
+ if (width === 0 || height === 0) {
22498
+ return;
22499
+ }
22434
22500
  // Imagine each pixel as a large square. The whole-number coordinates (0, 1, 2…)
22435
22501
  // are the edges of the squares. If you draw a one-unit-wide line between whole-number
22436
22502
  // coordinates, it will overlap opposite sides of the pixel square, and the resulting
@@ -27245,7 +27311,7 @@ function forceUnicityOfFigure(data) {
27245
27311
  for (const sheet of data.sheets || []) {
27246
27312
  for (const figure of sheet.figures || []) {
27247
27313
  if (figureIds.has(figure.id)) {
27248
- figure.id += uuidGenerator.uuidv4();
27314
+ figure.id += uuidGenerator.smallUuid();
27249
27315
  }
27250
27316
  figureIds.add(figure.id);
27251
27317
  }
@@ -27930,7 +27996,7 @@ class BordersPlugin extends CorePlugin {
27930
27996
  const currentBorder = this.getCellBorder(cmd.sheetId, cmd.col, cmd.row);
27931
27997
  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);
27932
27998
  if ((!currentBorder && areAllNewBordersUndefined) || deepEquals(currentBorder, cmd.border)) {
27933
- return 88 /* CommandResult.NoChanges */;
27999
+ return 89 /* CommandResult.NoChanges */;
27934
28000
  }
27935
28001
  return 0 /* CommandResult.Success */;
27936
28002
  }
@@ -28036,11 +28102,16 @@ class CellPlugin extends CorePlugin {
28036
28102
  // Command Handling
28037
28103
  // ---------------------------------------------------------------------------
28038
28104
  allowDispatch(cmd) {
28105
+ var _a;
28039
28106
  switch (cmd.type) {
28040
28107
  case "UPDATE_CELL":
28041
28108
  return this.checkValidations(cmd, this.checkCellOutOfSheet, this.checkUselessUpdateCell);
28042
28109
  case "CLEAR_CELL":
28043
28110
  return this.checkValidations(cmd, this.checkCellOutOfSheet, this.checkUselessClearCell);
28111
+ case "UPDATE_CELL_POSITION":
28112
+ return !cmd.cellId || ((_a = this.cells[cmd.sheetId]) === null || _a === void 0 ? void 0 : _a[cmd.cellId])
28113
+ ? 0 /* CommandResult.Success */
28114
+ : 28 /* CommandResult.InvalidCellId */;
28044
28115
  default:
28045
28116
  return 0 /* CommandResult.Success */;
28046
28117
  }
@@ -28079,6 +28150,9 @@ class CellPlugin extends CorePlugin {
28079
28150
  format: "",
28080
28151
  });
28081
28152
  break;
28153
+ case "DELETE_SHEET": {
28154
+ this.history.update("cells", cmd.sheetId, undefined);
28155
+ }
28082
28156
  }
28083
28157
  }
28084
28158
  /**
@@ -28394,9 +28468,9 @@ class CellPlugin extends CorePlugin {
28394
28468
  checkUselessClearCell(cmd) {
28395
28469
  const cell = this.getters.getCell(cmd.sheetId, cmd.col, cmd.row);
28396
28470
  if (!cell)
28397
- return 88 /* CommandResult.NoChanges */;
28471
+ return 89 /* CommandResult.NoChanges */;
28398
28472
  if (!cell.content && !cell.style && !cell.format) {
28399
- return 88 /* CommandResult.NoChanges */;
28473
+ return 89 /* CommandResult.NoChanges */;
28400
28474
  }
28401
28475
  return 0 /* CommandResult.Success */;
28402
28476
  }
@@ -28408,7 +28482,7 @@ class CellPlugin extends CorePlugin {
28408
28482
  if ((!hasContent || (cell === null || cell === void 0 ? void 0 : cell.content) === cmd.content) &&
28409
28483
  (!hasStyle || deepEquals(cell === null || cell === void 0 ? void 0 : cell.style, cmd.style)) &&
28410
28484
  (!hasFormat || (cell === null || cell === void 0 ? void 0 : cell.format) === cmd.format)) {
28411
- return 88 /* CommandResult.NoChanges */;
28485
+ return 89 /* CommandResult.NoChanges */;
28412
28486
  }
28413
28487
  return 0 /* CommandResult.Success */;
28414
28488
  }
@@ -28617,13 +28691,13 @@ class ChartPlugin extends CorePlugin {
28617
28691
  }
28618
28692
  checkChartDuplicate(cmd) {
28619
28693
  return this.getters.getFigureSheetId(cmd.id)
28620
- ? 84 /* CommandResult.DuplicatedChartId */
28694
+ ? 85 /* CommandResult.DuplicatedChartId */
28621
28695
  : 0 /* CommandResult.Success */;
28622
28696
  }
28623
28697
  checkChartExists(cmd) {
28624
28698
  return this.getters.getFigureSheetId(cmd.id)
28625
28699
  ? 0 /* CommandResult.Success */
28626
- : 85 /* CommandResult.ChartDoesNotExist */;
28700
+ : 86 /* CommandResult.ChartDoesNotExist */;
28627
28701
  }
28628
28702
  }
28629
28703
  ChartPlugin.getters = [
@@ -28831,10 +28905,10 @@ class ConditionalFormatPlugin extends CorePlugin {
28831
28905
  return 27 /* CommandResult.InvalidSheetId */;
28832
28906
  const ruleIndex = this.cfRules[sheetId].findIndex((cf) => cf.id === cfId);
28833
28907
  if (ruleIndex === -1)
28834
- return 71 /* CommandResult.InvalidConditionalFormatId */;
28908
+ return 72 /* CommandResult.InvalidConditionalFormatId */;
28835
28909
  const cfIndex2 = direction === "up" ? ruleIndex - 1 : ruleIndex + 1;
28836
28910
  if (cfIndex2 < 0 || cfIndex2 >= this.cfRules[sheetId].length) {
28837
- return 71 /* CommandResult.InvalidConditionalFormatId */;
28911
+ return 72 /* CommandResult.InvalidConditionalFormatId */;
28838
28912
  }
28839
28913
  return 0 /* CommandResult.Success */;
28840
28914
  }
@@ -28875,10 +28949,10 @@ class ConditionalFormatPlugin extends CorePlugin {
28875
28949
  const errors = [];
28876
28950
  const isEmpty = (value) => value === undefined || value === "";
28877
28951
  if (expectedNumber >= 1 && isEmpty(rule.values[0])) {
28878
- errors.push(51 /* CommandResult.FirstArgMissing */);
28952
+ errors.push(52 /* CommandResult.FirstArgMissing */);
28879
28953
  }
28880
28954
  if (expectedNumber >= 2 && isEmpty(rule.values[1])) {
28881
- errors.push(52 /* CommandResult.SecondArgMissing */);
28955
+ errors.push(53 /* CommandResult.SecondArgMissing */);
28882
28956
  }
28883
28957
  return errors.length ? errors : 0 /* CommandResult.Success */;
28884
28958
  }
@@ -28890,15 +28964,15 @@ class ConditionalFormatPlugin extends CorePlugin {
28890
28964
  (threshold.value === "" || isNaN(threshold.value))) {
28891
28965
  switch (thresholdName) {
28892
28966
  case "min":
28893
- return 53 /* CommandResult.MinNaN */;
28967
+ return 54 /* CommandResult.MinNaN */;
28894
28968
  case "max":
28895
- return 55 /* CommandResult.MaxNaN */;
28969
+ return 56 /* CommandResult.MaxNaN */;
28896
28970
  case "mid":
28897
- return 54 /* CommandResult.MidNaN */;
28971
+ return 55 /* CommandResult.MidNaN */;
28898
28972
  case "upperInflectionPoint":
28899
- return 56 /* CommandResult.ValueUpperInflectionNaN */;
28973
+ return 57 /* CommandResult.ValueUpperInflectionNaN */;
28900
28974
  case "lowerInflectionPoint":
28901
- return 57 /* CommandResult.ValueLowerInflectionNaN */;
28975
+ return 58 /* CommandResult.ValueLowerInflectionNaN */;
28902
28976
  }
28903
28977
  }
28904
28978
  return 0 /* CommandResult.Success */;
@@ -28912,15 +28986,15 @@ class ConditionalFormatPlugin extends CorePlugin {
28912
28986
  catch (error) {
28913
28987
  switch (thresholdName) {
28914
28988
  case "min":
28915
- return 58 /* CommandResult.MinInvalidFormula */;
28989
+ return 59 /* CommandResult.MinInvalidFormula */;
28916
28990
  case "max":
28917
- return 60 /* CommandResult.MaxInvalidFormula */;
28991
+ return 61 /* CommandResult.MaxInvalidFormula */;
28918
28992
  case "mid":
28919
- return 59 /* CommandResult.MidInvalidFormula */;
28993
+ return 60 /* CommandResult.MidInvalidFormula */;
28920
28994
  case "upperInflectionPoint":
28921
- return 61 /* CommandResult.ValueUpperInvalidFormula */;
28995
+ return 62 /* CommandResult.ValueUpperInvalidFormula */;
28922
28996
  case "lowerInflectionPoint":
28923
- return 62 /* CommandResult.ValueLowerInvalidFormula */;
28997
+ return 63 /* CommandResult.ValueLowerInvalidFormula */;
28924
28998
  }
28925
28999
  }
28926
29000
  return 0 /* CommandResult.Success */;
@@ -28937,7 +29011,7 @@ class ConditionalFormatPlugin extends CorePlugin {
28937
29011
  if (["number", "percentage", "percentile"].includes(rule.lowerInflectionPoint.type) &&
28938
29012
  rule.lowerInflectionPoint.type === rule.upperInflectionPoint.type &&
28939
29013
  Number(minValue) > Number(maxValue)) {
28940
- return 48 /* CommandResult.LowerBiggerThanUpper */;
29014
+ return 49 /* CommandResult.LowerBiggerThanUpper */;
28941
29015
  }
28942
29016
  return 0 /* CommandResult.Success */;
28943
29017
  }
@@ -28947,7 +29021,7 @@ class ConditionalFormatPlugin extends CorePlugin {
28947
29021
  if (["number", "percentage", "percentile"].includes(rule.minimum.type) &&
28948
29022
  rule.minimum.type === rule.maximum.type &&
28949
29023
  stringToNumber(minValue) >= stringToNumber(maxValue)) {
28950
- return 47 /* CommandResult.MinBiggerThanMax */;
29024
+ return 48 /* CommandResult.MinBiggerThanMax */;
28951
29025
  }
28952
29026
  return 0 /* CommandResult.Success */;
28953
29027
  }
@@ -28959,7 +29033,7 @@ class ConditionalFormatPlugin extends CorePlugin {
28959
29033
  ["number", "percentage", "percentile"].includes(rule.midpoint.type) &&
28960
29034
  rule.midpoint.type === rule.maximum.type &&
28961
29035
  stringToNumber(midValue) >= stringToNumber(maxValue)) {
28962
- return 49 /* CommandResult.MidBiggerThanMax */;
29036
+ return 50 /* CommandResult.MidBiggerThanMax */;
28963
29037
  }
28964
29038
  return 0 /* CommandResult.Success */;
28965
29039
  }
@@ -28971,7 +29045,7 @@ class ConditionalFormatPlugin extends CorePlugin {
28971
29045
  ["number", "percentage", "percentile"].includes(rule.midpoint.type) &&
28972
29046
  rule.minimum.type === rule.midpoint.type &&
28973
29047
  stringToNumber(minValue) >= stringToNumber(midValue)) {
28974
- return 50 /* CommandResult.MinBiggerThanMid */;
29048
+ return 51 /* CommandResult.MinBiggerThanMid */;
28975
29049
  }
28976
29050
  return 0 /* CommandResult.Success */;
28977
29051
  }
@@ -29081,13 +29155,13 @@ class FigurePlugin extends CorePlugin {
29081
29155
  checkFigureExists(sheetId, figureId) {
29082
29156
  var _a;
29083
29157
  if (((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) === undefined) {
29084
- return 70 /* CommandResult.FigureDoesNotExist */;
29158
+ return 71 /* CommandResult.FigureDoesNotExist */;
29085
29159
  }
29086
29160
  return 0 /* CommandResult.Success */;
29087
29161
  }
29088
29162
  checkFigureDuplicate(figureId) {
29089
29163
  if (Object.values(this.figures).find((sheet) => sheet === null || sheet === void 0 ? void 0 : sheet[figureId])) {
29090
- return 82 /* CommandResult.DuplicatedFigureId */;
29164
+ return 83 /* CommandResult.DuplicatedFigureId */;
29091
29165
  }
29092
29166
  return 0 /* CommandResult.Success */;
29093
29167
  }
@@ -29135,10 +29209,10 @@ class FilterTable {
29135
29209
  this.filters = [];
29136
29210
  this.zone = zone;
29137
29211
  const uuid = new UuidGenerator();
29138
- this.id = uuid.uuidv4();
29212
+ this.id = uuid.smallUuid();
29139
29213
  for (const i of range(zone.left, zone.right + 1)) {
29140
29214
  const filterZone = { ...this.zone, left: i, right: i };
29141
- this.filters.push(new Filter(uuid.uuidv4(), filterZone));
29215
+ this.filters.push(new Filter(uuid.smallUuid(), filterZone));
29142
29216
  }
29143
29217
  }
29144
29218
  /** Get zone of the table without the headers */
@@ -29189,12 +29263,12 @@ class FiltersPlugin extends CorePlugin {
29189
29263
  switch (cmd.type) {
29190
29264
  case "CREATE_FILTER_TABLE":
29191
29265
  if (!areZonesContinuous(...cmd.target)) {
29192
- return 81 /* CommandResult.NonContinuousTargets */;
29266
+ return 82 /* CommandResult.NonContinuousTargets */;
29193
29267
  }
29194
29268
  const zone = union(...cmd.target);
29195
29269
  const checkFilterOverlap = () => {
29196
29270
  if (this.getFilterTables(cmd.sheetId).some((filter) => overlap(filter.zone, zone))) {
29197
- return 78 /* CommandResult.FilterOverlap */;
29271
+ return 79 /* CommandResult.FilterOverlap */;
29198
29272
  }
29199
29273
  return 0 /* CommandResult.Success */;
29200
29274
  };
@@ -29202,7 +29276,7 @@ class FiltersPlugin extends CorePlugin {
29202
29276
  const mergesInTarget = this.getters.getMergesInZone(cmd.sheetId, zone);
29203
29277
  for (let merge of mergesInTarget) {
29204
29278
  if (overlap(zone, merge)) {
29205
- return 80 /* CommandResult.MergeInFilter */;
29279
+ return 81 /* CommandResult.MergeInFilter */;
29206
29280
  }
29207
29281
  }
29208
29282
  return 0 /* CommandResult.Success */;
@@ -29212,7 +29286,7 @@ class FiltersPlugin extends CorePlugin {
29212
29286
  for (let merge of cmd.target) {
29213
29287
  for (let filterTable of this.getFilterTables(cmd.sheetId)) {
29214
29288
  if (overlap(filterTable.zone, merge)) {
29215
- return 80 /* CommandResult.MergeInFilter */;
29289
+ return 81 /* CommandResult.MergeInFilter */;
29216
29290
  }
29217
29291
  }
29218
29292
  }
@@ -29318,7 +29392,7 @@ class FiltersPlugin extends CorePlugin {
29318
29392
  if (filters.length < zoneToDimension(zone).width) {
29319
29393
  for (let col = zone.left; col <= zone.right; col++) {
29320
29394
  if (!filters.find((filter) => filter.col === col)) {
29321
- filters.push(new Filter(this.uuidGenerator.uuidv4(), { ...zone, left: col, right: col }));
29395
+ filters.push(new Filter(this.uuidGenerator.smallUuid(), { ...zone, left: col, right: col }));
29322
29396
  }
29323
29397
  }
29324
29398
  filters.sort((f1, f2) => f1.col - f2.col);
@@ -29722,10 +29796,10 @@ class HeaderVisibilityPlugin extends CorePlugin {
29722
29796
  : this.getters.getNumberRows(cmd.sheetId);
29723
29797
  const hiddenElements = new Set((hiddenGroup || []).flat().concat(cmd.elements));
29724
29798
  if (hiddenElements.size >= elements) {
29725
- return 66 /* CommandResult.TooManyHiddenElements */;
29799
+ return 67 /* CommandResult.TooManyHiddenElements */;
29726
29800
  }
29727
29801
  else if (largeMin(cmd.elements) < 0 || largeMax(cmd.elements) > elements) {
29728
- return 86 /* CommandResult.InvalidHeaderIndex */;
29802
+ return 87 /* CommandResult.InvalidHeaderIndex */;
29729
29803
  }
29730
29804
  else {
29731
29805
  return 0 /* CommandResult.Success */;
@@ -30128,7 +30202,7 @@ class MergePlugin extends CorePlugin {
30128
30202
  for (const zone of target) {
30129
30203
  for (const zone2 of target) {
30130
30204
  if (zone !== zone2 && overlap(zone, zone2)) {
30131
- return 65 /* CommandResult.MergeOverlap */;
30205
+ return 66 /* CommandResult.MergeOverlap */;
30132
30206
  }
30133
30207
  }
30134
30208
  }
@@ -30142,7 +30216,7 @@ class MergePlugin extends CorePlugin {
30142
30216
  for (const zone of target) {
30143
30217
  if ((zone.left < xSplit && zone.right >= xSplit) ||
30144
30218
  (zone.top < ySplit && zone.bottom >= ySplit)) {
30145
- return 75 /* CommandResult.FrozenPaneOverlap */;
30219
+ return 76 /* CommandResult.FrozenPaneOverlap */;
30146
30220
  }
30147
30221
  }
30148
30222
  return 0 /* CommandResult.Success */;
@@ -30360,6 +30434,9 @@ class SheetPlugin extends CorePlugin {
30360
30434
  case "CREATE_SHEET": {
30361
30435
  return this.checkValidations(cmd, this.checkSheetName, this.checkSheetPosition);
30362
30436
  }
30437
+ case "DUPLICATE_SHEET": {
30438
+ return this.sheets[cmd.sheetIdTo] ? 12 /* CommandResult.DuplicatedSheetId */ : 0 /* CommandResult.Success */;
30439
+ }
30363
30440
  case "MOVE_SHEET":
30364
30441
  const currentIndex = this.orderedSheetIds.indexOf(cmd.sheetId);
30365
30442
  if (cmd.direction === "left") {
@@ -30381,7 +30458,7 @@ class SheetPlugin extends CorePlugin {
30381
30458
  case "RENAME_SHEET":
30382
30459
  return this.isRenameAllowed(cmd);
30383
30460
  case "DELETE_SHEET":
30384
- return this.orderedSheetIds.length > 1
30461
+ return this.getVisibleSheetIds().length > 1
30385
30462
  ? 0 /* CommandResult.Success */
30386
30463
  : 9 /* CommandResult.NotEnoughSheets */;
30387
30464
  case "ADD_COLUMNS_ROWS":
@@ -30389,10 +30466,10 @@ class SheetPlugin extends CorePlugin {
30389
30466
  ? this.getNumberCols(cmd.sheetId)
30390
30467
  : this.getNumberRows(cmd.sheetId);
30391
30468
  if (cmd.base < 0 || cmd.base >= elements) {
30392
- return 86 /* CommandResult.InvalidHeaderIndex */;
30469
+ return 87 /* CommandResult.InvalidHeaderIndex */;
30393
30470
  }
30394
30471
  else if (cmd.quantity <= 0) {
30395
- return 87 /* CommandResult.InvalidQuantity */;
30472
+ return 88 /* CommandResult.InvalidQuantity */;
30396
30473
  }
30397
30474
  return 0 /* CommandResult.Success */;
30398
30475
  case "REMOVE_COLUMNS_ROWS": {
@@ -30400,7 +30477,7 @@ class SheetPlugin extends CorePlugin {
30400
30477
  ? this.getNumberCols(cmd.sheetId)
30401
30478
  : this.getNumberRows(cmd.sheetId);
30402
30479
  if (largeMin(cmd.elements) < 0 || largeMax(cmd.elements) > elements) {
30403
- return 86 /* CommandResult.InvalidHeaderIndex */;
30480
+ return 87 /* CommandResult.InvalidHeaderIndex */;
30404
30481
  }
30405
30482
  else if (this.checkElementsIncludeAllNonFrozenHeaders(cmd.sheetId, cmd.dimension, cmd.elements)) {
30406
30483
  return 8 /* CommandResult.NotEnoughElements */;
@@ -30857,18 +30934,18 @@ class SheetPlugin extends CorePlugin {
30857
30934
  checkRowFreezeQuantity(cmd) {
30858
30935
  return cmd.quantity >= 1 && cmd.quantity < this.getNumberRows(cmd.sheetId)
30859
30936
  ? 0 /* CommandResult.Success */
30860
- : 74 /* CommandResult.InvalidFreezeQuantity */;
30937
+ : 75 /* CommandResult.InvalidFreezeQuantity */;
30861
30938
  }
30862
30939
  checkColFreezeQuantity(cmd) {
30863
30940
  return cmd.quantity >= 1 && cmd.quantity < this.getNumberCols(cmd.sheetId)
30864
30941
  ? 0 /* CommandResult.Success */
30865
- : 74 /* CommandResult.InvalidFreezeQuantity */;
30942
+ : 75 /* CommandResult.InvalidFreezeQuantity */;
30866
30943
  }
30867
30944
  checkRowFreezeOverlapMerge(cmd) {
30868
30945
  const merges = this.getters.getMerges(cmd.sheetId);
30869
30946
  for (let merge of merges) {
30870
30947
  if (merge.top < cmd.quantity && cmd.quantity <= merge.bottom) {
30871
- return 65 /* CommandResult.MergeOverlap */;
30948
+ return 66 /* CommandResult.MergeOverlap */;
30872
30949
  }
30873
30950
  }
30874
30951
  return 0 /* CommandResult.Success */;
@@ -30877,7 +30954,7 @@ class SheetPlugin extends CorePlugin {
30877
30954
  const merges = this.getters.getMerges(cmd.sheetId);
30878
30955
  for (let merge of merges) {
30879
30956
  if (merge.left < cmd.quantity && cmd.quantity <= merge.right) {
30880
- return 65 /* CommandResult.MergeOverlap */;
30957
+ return 66 /* CommandResult.MergeOverlap */;
30881
30958
  }
30882
30959
  }
30883
30960
  return 0 /* CommandResult.Success */;
@@ -31187,6 +31264,9 @@ class SheetPlugin extends CorePlugin {
31187
31264
  zones.push(...cmd.target);
31188
31265
  }
31189
31266
  if ("ranges" in cmd && Array.isArray(cmd.ranges)) {
31267
+ if (cmd.ranges.some((rangeData) => !this.getters.tryGetSheet(rangeData._sheetId))) {
31268
+ return 27 /* CommandResult.InvalidSheetId */;
31269
+ }
31190
31270
  zones.push(...cmd.ranges.map((rangeData) => this.getters.getRangeFromRangeData(rangeData).zone));
31191
31271
  }
31192
31272
  if (!zones.every(isZoneValid)) {
@@ -31308,7 +31388,7 @@ class AutofillPlugin extends UIPlugin {
31308
31388
  if (this.lastCellSelected.col !== undefined && this.lastCellSelected.row !== undefined) {
31309
31389
  return 0 /* CommandResult.Success */;
31310
31390
  }
31311
- return 45 /* CommandResult.InvalidAutofillSelection */;
31391
+ return 46 /* CommandResult.InvalidAutofillSelection */;
31312
31392
  case "AUTOFILL_AUTO":
31313
31393
  const zone = this.getters.getSelectedZone();
31314
31394
  return zone.top === zone.bottom
@@ -31908,7 +31988,7 @@ class CellPopoverPlugin extends UIPlugin {
31908
31988
  cellPopoverRegistry.get(cmd.popoverType);
31909
31989
  }
31910
31990
  catch (error) {
31911
- return 72 /* CommandResult.InvalidCellPopover */;
31991
+ return 73 /* CommandResult.InvalidCellPopover */;
31912
31992
  }
31913
31993
  return 0 /* CommandResult.Success */;
31914
31994
  default:
@@ -32132,7 +32212,7 @@ class ClipboardCellsState extends ClipboardCellsAbstractState {
32132
32212
  for (const zone of this.getPasteZones(target)) {
32133
32213
  if ((zone.left < xSplit && zone.right >= xSplit) ||
32134
32214
  (zone.top < ySplit && zone.bottom >= ySplit)) {
32135
- return 75 /* CommandResult.FrozenPaneOverlap */;
32215
+ return 76 /* CommandResult.FrozenPaneOverlap */;
32136
32216
  }
32137
32217
  }
32138
32218
  return 0 /* CommandResult.Success */;
@@ -32492,7 +32572,7 @@ class ClipboardFigureState {
32492
32572
  }
32493
32573
  isPasteAllowed(target, option) {
32494
32574
  if (target.length === 0) {
32495
- return 73 /* CommandResult.EmptyTarget */;
32575
+ return 74 /* CommandResult.EmptyTarget */;
32496
32576
  }
32497
32577
  if ((option === null || option === void 0 ? void 0 : option.pasteOption) !== undefined) {
32498
32578
  return 22 /* CommandResult.WrongFigurePasteOption */;
@@ -32509,7 +32589,7 @@ class ClipboardFigureState {
32509
32589
  y: this.getters.getRowDimensions(sheetId, target[0].top).start,
32510
32590
  };
32511
32591
  const newChart = this.copiedChart.copyInSheetId(sheetId);
32512
- const newId = new UuidGenerator().uuidv4();
32592
+ const newId = new UuidGenerator().smallUuid();
32513
32593
  this.dispatch("CREATE_CHART", {
32514
32594
  id: newId,
32515
32595
  sheetId,
@@ -33639,7 +33719,9 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
33639
33719
  const cfInTarget = this.getters
33640
33720
  .getConditionalFormats(targetSheetId)
33641
33721
  .find((cf) => cf.stopIfTrue === originCF.stopIfTrue && deepEquals(cf.rule, originCF.rule));
33642
- return cfInTarget ? cfInTarget : { ...originCF, id: this.uuidGenerator.uuidv4(), ranges: [] };
33722
+ return cfInTarget
33723
+ ? cfInTarget
33724
+ : { ...originCF, id: this.uuidGenerator.smallUuid(), ranges: [] };
33643
33725
  }
33644
33726
  }
33645
33727
  EvaluationConditionalFormatPlugin.getters = ["getConditionalIcon", "getCellComputedStyle"];
@@ -33655,7 +33737,7 @@ class FilterEvaluationPlugin extends UIPlugin {
33655
33737
  switch (cmd.type) {
33656
33738
  case "UPDATE_FILTER":
33657
33739
  if (!this.getters.getFilterId(cmd.sheetId, cmd.col, cmd.row)) {
33658
- return 79 /* CommandResult.FilterNotFound */;
33740
+ return 80 /* CommandResult.FilterNotFound */;
33659
33741
  }
33660
33742
  break;
33661
33743
  }
@@ -34634,10 +34716,8 @@ class RendererPlugin extends UIPlugin {
34634
34716
  const { ctx, thinLineWidth } = renderingContext;
34635
34717
  const visibleCols = this.getters.getSheetViewVisibleCols();
34636
34718
  const left = visibleCols[0];
34637
- const right = visibleCols[visibleCols.length - 1];
34638
34719
  const visibleRows = this.getters.getSheetViewVisibleRows();
34639
34720
  const top = visibleRows[0];
34640
- const bottom = visibleRows[visibleRows.length - 1];
34641
34721
  const { width, height } = this.getters.getSheetViewDimensionWithHeaders();
34642
34722
  const selection = this.getters.getSelectedZones();
34643
34723
  const selectedCols = getZonesCols(selection);
@@ -34653,7 +34733,7 @@ class RendererPlugin extends UIPlugin {
34653
34733
  ctx.lineWidth = thinLineWidth;
34654
34734
  ctx.strokeStyle = "#333";
34655
34735
  // Columns headers background
34656
- for (let col = left; col <= right; col++) {
34736
+ for (const col of visibleCols) {
34657
34737
  const colZone = { left: col, right: col, top: 0, bottom: numberOfRows - 1 };
34658
34738
  const { x, width } = this.getters.getVisibleRect(colZone);
34659
34739
  const colHasFilter = this.getters.doesZonesContainFilter(sheetId, [colZone]);
@@ -34673,7 +34753,7 @@ class RendererPlugin extends UIPlugin {
34673
34753
  ctx.fillRect(x, 0, width, HEADER_HEIGHT);
34674
34754
  }
34675
34755
  // Rows headers background
34676
- for (let row = top; row <= bottom; row++) {
34756
+ for (const row of visibleRows) {
34677
34757
  const rowZone = { top: row, bottom: row, left: 0, right: numberOfCols - 1 };
34678
34758
  const { y, height } = this.getters.getVisibleRect(rowZone);
34679
34759
  const rowHasFilter = this.getters.doesZonesContainFilter(sheetId, [rowZone]);
@@ -34702,21 +34782,21 @@ class RendererPlugin extends UIPlugin {
34702
34782
  ctx.stroke();
34703
34783
  ctx.beginPath();
34704
34784
  // column text + separator
34705
- for (const i of visibleCols) {
34706
- const colSize = this.getters.getColSize(sheetId, i);
34707
- const colName = numberToLetters(i);
34708
- ctx.fillStyle = activeCols.has(i) ? "#fff" : TEXT_HEADER_COLOR;
34709
- let colStart = this.getHeaderOffset("COL", left, i);
34785
+ for (const col of visibleCols) {
34786
+ const colSize = this.getters.getColSize(sheetId, col);
34787
+ const colName = numberToLetters(col);
34788
+ ctx.fillStyle = activeCols.has(col) ? "#fff" : TEXT_HEADER_COLOR;
34789
+ let colStart = this.getHeaderOffset("COL", left, col);
34710
34790
  ctx.fillText(colName, colStart + colSize / 2, HEADER_HEIGHT / 2);
34711
34791
  ctx.moveTo(colStart + colSize, 0);
34712
34792
  ctx.lineTo(colStart + colSize, HEADER_HEIGHT);
34713
34793
  }
34714
34794
  // row text + separator
34715
- for (const i of visibleRows) {
34716
- const rowSize = this.getters.getRowSize(sheetId, i);
34717
- ctx.fillStyle = activeRows.has(i) ? "#fff" : TEXT_HEADER_COLOR;
34718
- let rowStart = this.getHeaderOffset("ROW", top, i);
34719
- ctx.fillText(String(i + 1), HEADER_WIDTH / 2, rowStart + rowSize / 2);
34795
+ for (const row of visibleRows) {
34796
+ const rowSize = this.getters.getRowSize(sheetId, row);
34797
+ ctx.fillStyle = activeRows.has(row) ? "#fff" : TEXT_HEADER_COLOR;
34798
+ let rowStart = this.getHeaderOffset("ROW", top, row);
34799
+ ctx.fillText(String(row + 1), HEADER_WIDTH / 2, rowStart + rowSize / 2);
34720
34800
  ctx.moveTo(0, rowStart + rowSize);
34721
34801
  ctx.lineTo(HEADER_WIDTH, rowStart + rowSize);
34722
34802
  }
@@ -35163,23 +35243,7 @@ class GridSelectionPlugin extends UIPlugin {
35163
35243
  gridSelection: deepCopy(gridSelection),
35164
35244
  };
35165
35245
  }
35166
- if (!this.getters.tryGetSheet(this.getters.getActiveSheetId())) {
35167
- const currentSheetIds = this.getters.getVisibleSheetIds();
35168
- this.activeSheet = this.getters.getSheet(currentSheetIds[0]);
35169
- if (this.activeSheet.id in this.sheetsData) {
35170
- const { anchor } = this.clipSelection(this.activeSheet.id, this.sheetsData[this.activeSheet.id].gridSelection);
35171
- this.selectCell(anchor.cell.col, anchor.cell.row);
35172
- }
35173
- else {
35174
- this.selectCell(0, 0);
35175
- }
35176
- const { col, row } = this.gridSelection.anchor.cell;
35177
- this.moveClient({
35178
- sheetId: this.getters.getActiveSheetId(),
35179
- col,
35180
- row,
35181
- });
35182
- }
35246
+ this.fallbackToVisibleSheet();
35183
35247
  const sheetId = this.getters.getActiveSheetId();
35184
35248
  this.gridSelection.zones = this.gridSelection.zones.map((z) => this.getters.expandZone(sheetId, z));
35185
35249
  this.gridSelection.anchor.zone = this.getters.expandZone(sheetId, this.gridSelection.anchor.zone);
@@ -35189,6 +35253,7 @@ class GridSelectionPlugin extends UIPlugin {
35189
35253
  }
35190
35254
  }
35191
35255
  finalize() {
35256
+ this.fallbackToVisibleSheet();
35192
35257
  /** Any change to the selection has to be reflected in the selection processor. */
35193
35258
  this.selection.resetDefaultAnchor(this, deepCopy(this.gridSelection.anchor));
35194
35259
  }
@@ -35487,10 +35552,29 @@ class GridSelectionPlugin extends UIPlugin {
35487
35552
  const headers = [cmd.base, ...cmd.elements];
35488
35553
  const maxHeaderValue = isCol ? this.getters.getNumberCols(id) : this.getters.getNumberRows(id);
35489
35554
  if (headers.some((h) => h < 0 || h >= maxHeaderValue)) {
35490
- return 86 /* CommandResult.InvalidHeaderIndex */;
35555
+ return 87 /* CommandResult.InvalidHeaderIndex */;
35491
35556
  }
35492
35557
  return 0 /* CommandResult.Success */;
35493
35558
  }
35559
+ fallbackToVisibleSheet() {
35560
+ if (!this.getters.tryGetSheet(this.getters.getActiveSheetId())) {
35561
+ const currentSheetIds = this.getters.getVisibleSheetIds();
35562
+ this.activeSheet = this.getters.getSheet(currentSheetIds[0]);
35563
+ if (this.activeSheet.id in this.sheetsData) {
35564
+ const { anchor } = this.clipSelection(this.activeSheet.id, this.sheetsData[this.activeSheet.id].gridSelection);
35565
+ this.selectCell(anchor.cell.col, anchor.cell.row);
35566
+ }
35567
+ else {
35568
+ this.selectCell(0, 0);
35569
+ }
35570
+ const { col, row } = this.gridSelection.anchor.cell;
35571
+ this.moveClient({
35572
+ sheetId: this.getters.getActiveSheetId(),
35573
+ col,
35574
+ row,
35575
+ });
35576
+ }
35577
+ }
35494
35578
  //-------------------------------------------
35495
35579
  // Helpers for extensions
35496
35580
  // ------------------------------------------
@@ -35715,7 +35799,7 @@ class SelectionInputPlugin extends UIPlugin {
35715
35799
  setContent(index, xc) {
35716
35800
  this.ranges[index] = {
35717
35801
  ...this.ranges[index],
35718
- id: uuidGenerator.uuidv4(),
35802
+ id: uuidGenerator.smallUuid(),
35719
35803
  xc,
35720
35804
  };
35721
35805
  }
@@ -35830,26 +35914,26 @@ class SelectionInputsManagerPlugin extends UIPlugin {
35830
35914
  case "ADD_EMPTY_RANGE":
35831
35915
  case "REMOVE_RANGE":
35832
35916
  if (!this.inputs[cmd.id]) {
35833
- return 30 /* CommandResult.InvalidInputId */;
35917
+ return 31 /* CommandResult.InvalidInputId */;
35834
35918
  }
35835
35919
  }
35836
35920
  switch (cmd.type) {
35837
35921
  case "FOCUS_RANGE":
35838
35922
  const index = (_a = this.currentInput) === null || _a === void 0 ? void 0 : _a.getIndex(cmd.rangeId);
35839
35923
  if (this.focusedInputId === cmd.id && ((_b = this.currentInput) === null || _b === void 0 ? void 0 : _b.focusedRangeIndex) === index) {
35840
- return 28 /* CommandResult.InputAlreadyFocused */;
35924
+ return 29 /* CommandResult.InputAlreadyFocused */;
35841
35925
  }
35842
35926
  break;
35843
35927
  case "ADD_EMPTY_RANGE":
35844
35928
  const input = this.inputs[cmd.id];
35845
35929
  if (input.inputHasSingleRange && input.ranges.length === 1) {
35846
- return 29 /* CommandResult.MaximumRangesReached */;
35930
+ return 30 /* CommandResult.MaximumRangesReached */;
35847
35931
  }
35848
35932
  break;
35849
35933
  case "CHANGE_RANGE": {
35850
35934
  const input = this.inputs[cmd.id];
35851
35935
  if (input.inputHasSingleRange && cmd.value.split(",").length > 1) {
35852
- return 29 /* CommandResult.MaximumRangesReached */;
35936
+ return 30 /* CommandResult.MaximumRangesReached */;
35853
35937
  }
35854
35938
  break;
35855
35939
  }
@@ -36040,6 +36124,9 @@ function updateChartRangesTransformation(toTransform, executed) {
36040
36124
  }
36041
36125
  function createSheetTransformation(cmd, executed) {
36042
36126
  var _a;
36127
+ if (cmd.sheetId === executed.sheetId) {
36128
+ cmd = { ...cmd, sheetId: `${cmd.sheetId}~` };
36129
+ }
36043
36130
  if (cmd.name === executed.name) {
36044
36131
  return {
36045
36132
  ...cmd,
@@ -36615,21 +36702,14 @@ class Session extends EventBus {
36615
36702
  if (!message)
36616
36703
  return;
36617
36704
  if (message.type === "REMOTE_REVISION") {
36618
- const revision = this.revisions.get(message.nextRevisionId);
36705
+ let revision = this.revisions.get(message.nextRevisionId);
36619
36706
  if (revision.commands.length === 0) {
36620
36707
  /**
36621
- * The command is empty, we have to drop all the next local revisions
36708
+ * The command is empty, we have to rebase all the next local revisions
36622
36709
  * to avoid issues with undo/redo
36623
36710
  */
36624
- this.revisions.drop(revision.id);
36625
- const revisionIds = this.pendingMessages
36626
- .filter((message) => message.type === "REMOTE_REVISION")
36627
- .map((message) => message.nextRevisionId);
36628
- this.trigger("pending-revisions-dropped", { revisionIds });
36629
- this.waitingAck = false;
36630
- this.waitingUndoRedoAck = false;
36631
- this.pendingMessages = [];
36632
- return;
36711
+ this.revisions.rebase(revision.id);
36712
+ revision = this.revisions.get(message.nextRevisionId);
36633
36713
  }
36634
36714
  message = {
36635
36715
  ...message,
@@ -36653,7 +36733,6 @@ class Session extends EventBus {
36653
36733
  switch (message.type) {
36654
36734
  case "REMOTE_REVISION":
36655
36735
  case "REVISION_REDONE":
36656
- case "REVISION_UNDONE":
36657
36736
  case "SNAPSHOT_CREATED":
36658
36737
  this.waitingAck = false;
36659
36738
  this.pendingMessages = this.pendingMessages.filter((msg) => msg.nextRevisionId !== message.nextRevisionId);
@@ -36661,6 +36740,25 @@ class Session extends EventBus {
36661
36740
  this.processedRevisions.add(message.nextRevisionId);
36662
36741
  this.sendPendingMessage();
36663
36742
  break;
36743
+ case "REVISION_UNDONE": {
36744
+ this.waitingAck = false;
36745
+ this.pendingMessages = this.pendingMessages.filter((msg) => msg.nextRevisionId !== message.nextRevisionId);
36746
+ const firstPendingRevisionId = this.pendingMessages.findIndex((message) => message.type === "REMOTE_REVISION");
36747
+ if (firstPendingRevisionId !== -1) {
36748
+ /**
36749
+ * Some revisions undergo transformations that may cause issues with
36750
+ * undo/redo if the transformation is destructive (we don't get back
36751
+ * the original command by transforming it with the inverse).
36752
+ * To prevent these problems, we must rebase all subsequent local
36753
+ * revisions.
36754
+ */
36755
+ this.revisions.rebase(this.pendingMessages[firstPendingRevisionId].nextRevisionId);
36756
+ }
36757
+ this.serverRevisionId = message.nextRevisionId;
36758
+ this.processedRevisions.add(message.nextRevisionId);
36759
+ this.sendPendingMessage();
36760
+ break;
36761
+ }
36664
36762
  }
36665
36763
  }
36666
36764
  isAlreadyProcessed(message) {
@@ -36804,8 +36902,17 @@ class InternalViewport {
36804
36902
  this.getters = getters;
36805
36903
  this.sheetId = sheetId;
36806
36904
  this.boundaries = boundaries;
36807
- this.viewportWidth = sizeInGrid.width;
36808
- this.viewportHeight = sizeInGrid.height;
36905
+ if (sizeInGrid.width < 0 || sizeInGrid.height < 0) {
36906
+ throw new Error("Viewport size cannot be negative");
36907
+ }
36908
+ this.viewportWidth = sizeInGrid.height && sizeInGrid.width;
36909
+ this.viewportHeight = sizeInGrid.width && sizeInGrid.height;
36910
+ this.top = boundaries.top;
36911
+ this.bottom = boundaries.bottom;
36912
+ this.left = boundaries.left;
36913
+ this.right = boundaries.right;
36914
+ this.offsetX = offsets.x;
36915
+ this.offsetY = offsets.y;
36809
36916
  this.offsetScrollbarX = offsets.x;
36810
36917
  this.offsetScrollbarY = offsets.y;
36811
36918
  this.canScrollVertically = options.canScrollVertically;
@@ -36994,6 +37101,9 @@ class InternalViewport {
36994
37101
  }
36995
37102
  // PRIVATE
36996
37103
  searchHeaderIndex(dimension, position, startIndex = 0, absolute = false) {
37104
+ if (this.viewportWidth <= 0 || this.viewportHeight <= 0) {
37105
+ return -1;
37106
+ }
36997
37107
  let size = 0;
36998
37108
  const sheetId = this.sheetId;
36999
37109
  const headers = this.getters.getNumberHeaders(sheetId, dimension);
@@ -37032,7 +37142,7 @@ class InternalViewport {
37032
37142
  this.adjustViewportZoneY();
37033
37143
  }
37034
37144
  /** Corrects the viewport's horizontal offset based on the current structure
37035
- * To make sure that at least on column is visible inside the viewport.
37145
+ * To make sure that at least one column is visible inside the viewport.
37036
37146
  */
37037
37147
  adjustViewportOffsetX() {
37038
37148
  if (this.canScrollHorizontally) {
@@ -37049,7 +37159,7 @@ class InternalViewport {
37049
37159
  this.adjustViewportZoneX();
37050
37160
  }
37051
37161
  /** Corrects the viewport's vertical offset based on the current structure
37052
- * To make sure that at least on row is visible inside the viewport.
37162
+ * To make sure that at least one row is visible inside the viewport.
37053
37163
  */
37054
37164
  adjustViewportOffsetY() {
37055
37165
  if (this.canScrollVertically) {
@@ -37071,11 +37181,14 @@ class InternalViewport {
37071
37181
  const sheetId = this.sheetId;
37072
37182
  this.left = this.searchHeaderIndex("COL", this.offsetScrollbarX, this.boundaries.left);
37073
37183
  this.right = Math.min(this.boundaries.right, this.searchHeaderIndex("COL", this.viewportWidth, this.left));
37184
+ if (!this.viewportWidth) {
37185
+ return;
37186
+ }
37074
37187
  if (this.left === -1) {
37075
37188
  this.left = this.boundaries.left;
37076
37189
  }
37077
37190
  if (this.right === -1) {
37078
- this.right = this.getters.getNumberCols(sheetId) - 1;
37191
+ this.right = this.boundaries.right;
37079
37192
  }
37080
37193
  this.offsetX =
37081
37194
  this.getters.getColDimensions(sheetId, this.left).start -
@@ -37087,11 +37200,14 @@ class InternalViewport {
37087
37200
  const sheetId = this.sheetId;
37088
37201
  this.top = this.searchHeaderIndex("ROW", this.offsetScrollbarY, this.boundaries.top);
37089
37202
  this.bottom = Math.min(this.boundaries.bottom, this.searchHeaderIndex("ROW", this.viewportHeight, this.top));
37203
+ if (!this.viewportHeight) {
37204
+ return;
37205
+ }
37090
37206
  if (this.top === -1) {
37091
37207
  this.top = this.boundaries.top;
37092
37208
  }
37093
37209
  if (this.bottom === -1) {
37094
- this.bottom = this.getters.getNumberRows(sheetId) - 1;
37210
+ this.bottom = this.boundaries.bottom;
37095
37211
  }
37096
37212
  this.offsetY =
37097
37213
  this.getters.getRowDimensions(sheetId, this.top).start -
@@ -37343,12 +37459,12 @@ class SheetViewPlugin extends UIPlugin {
37343
37459
  getSheetViewVisibleCols() {
37344
37460
  const sheetId = this.getters.getActiveSheetId();
37345
37461
  const viewports = this.getSubViewports(sheetId);
37346
- return [...new Set(viewports.map((v) => range(v.left, v.right + 1)).flat())].filter((col) => !this.getters.isHeaderHidden(sheetId, "COL", col));
37462
+ return [...new Set(viewports.map((v) => range(v.left, v.right + 1)).flat())].filter((col) => col >= 0 && !this.getters.isHeaderHidden(sheetId, "COL", col));
37347
37463
  }
37348
37464
  getSheetViewVisibleRows() {
37349
37465
  const sheetId = this.getters.getActiveSheetId();
37350
37466
  const viewports = this.getSubViewports(sheetId);
37351
- return [...new Set(viewports.map((v) => range(v.top, v.bottom + 1)).flat())].filter((row) => !this.getters.isHeaderHidden(sheetId, "ROW", row));
37467
+ return [...new Set(viewports.map((v) => range(v.top, v.bottom + 1)).flat())].filter((row) => row >= 0 && !this.getters.isHeaderHidden(sheetId, "ROW", row));
37352
37468
  }
37353
37469
  /**
37354
37470
  * Return the main viewport maximum size relative to the client size.
@@ -37371,19 +37487,19 @@ class SheetViewPlugin extends UIPlugin {
37371
37487
  maxOffsetY: Math.max(0, height - viewport.viewportHeight + 1),
37372
37488
  };
37373
37489
  }
37374
- getColRowOffsetInViewport(dimension, referenceIndex, index) {
37375
- const sheetId = this.getters.getActiveSheetId();
37376
- const visibleCols = this.getters.getSheetViewVisibleCols();
37377
- const visibleRows = this.getters.getSheetViewVisibleRows();
37378
- if (index < referenceIndex) {
37379
- return -this.getColRowOffsetInViewport(dimension, index, referenceIndex);
37490
+ getColRowOffsetInViewport(dimension, referenceHeaderIndex, targetHeaderIndex) {
37491
+ if (targetHeaderIndex < referenceHeaderIndex) {
37492
+ return -this.getColRowOffsetInViewport(dimension, targetHeaderIndex, referenceHeaderIndex);
37380
37493
  }
37494
+ const sheetId = this.getters.getActiveSheetId();
37495
+ const visibleHeaders = dimension === "COL"
37496
+ ? this.getters.getSheetViewVisibleCols()
37497
+ : this.getters.getSheetViewVisibleRows();
37498
+ const startIndex = visibleHeaders.findIndex((header) => referenceHeaderIndex >= header);
37499
+ const endIndex = visibleHeaders.findIndex((header) => targetHeaderIndex <= header);
37500
+ const relevantIndexes = visibleHeaders.slice(startIndex, endIndex);
37381
37501
  let offset = 0;
37382
- const visibleIndexes = dimension === "COL" ? visibleCols : visibleRows;
37383
- for (let i = referenceIndex; i < index; i++) {
37384
- if (!visibleIndexes.includes(i)) {
37385
- continue;
37386
- }
37502
+ for (const i of relevantIndexes) {
37387
37503
  offset +=
37388
37504
  dimension === "COL"
37389
37505
  ? this.getters.getColSize(sheetId, i)
@@ -37433,7 +37549,7 @@ class SheetViewPlugin extends UIPlugin {
37433
37549
  }
37434
37550
  return { canEdgeScroll, direction, delay };
37435
37551
  }
37436
- getEdgeScrollRow(y, previousY, tartingY) {
37552
+ getEdgeScrollRow(y, previousY, startingY) {
37437
37553
  let canEdgeScroll = false;
37438
37554
  let direction = 0;
37439
37555
  let delay = 0;
@@ -37454,7 +37570,7 @@ class SheetViewPlugin extends UIPlugin {
37454
37570
  delay = scrollDelay(y - height);
37455
37571
  direction = 1;
37456
37572
  }
37457
- else if (y < offsetCorrectionY && tartingY >= offsetCorrectionY && currentOffsetY > 0) {
37573
+ else if (y < offsetCorrectionY && startingY >= offsetCorrectionY && currentOffsetY > 0) {
37458
37574
  // 2
37459
37575
  canEdgeScroll = true;
37460
37576
  delay = scrollDelay(offsetCorrectionY - y);
@@ -37473,13 +37589,7 @@ class SheetViewPlugin extends UIPlugin {
37473
37589
  */
37474
37590
  getVisibleRect(zone) {
37475
37591
  const sheetId = this.getters.getActiveSheetId();
37476
- const viewportRects = this.getSubViewports(sheetId)
37477
- .map((viewport) => viewport.getVisibleRect(zone))
37478
- .filter(isDefined$1);
37479
- if (viewportRects.length === 0) {
37480
- return { x: 0, y: 0, width: 0, height: 0 };
37481
- }
37482
- return this.recomposeRect(viewportRects);
37592
+ return this.mapViewportsToRect(sheetId, (viewport) => viewport.getVisibleRect(zone));
37483
37593
  }
37484
37594
  /**
37485
37595
  * Computes the actual size and position (:Rect) of the zone on the canvas
@@ -37487,13 +37597,7 @@ class SheetViewPlugin extends UIPlugin {
37487
37597
  */
37488
37598
  getRect(zone) {
37489
37599
  const sheetId = this.getters.getActiveSheetId();
37490
- const viewportRects = this.getSubViewports(sheetId)
37491
- .map((viewport) => viewport.getFullRect(zone))
37492
- .filter(isDefined$1);
37493
- if (viewportRects.length === 0) {
37494
- return { x: 0, y: 0, width: 0, height: 0 };
37495
- }
37496
- return this.recomposeRect(viewportRects);
37600
+ return this.mapViewportsToRect(sheetId, (viewport) => viewport.getFullRect(zone));
37497
37601
  }
37498
37602
  /**
37499
37603
  * Returns the position of the MainViewport relatively to the start of the grid (without headers)
@@ -37525,7 +37629,7 @@ class SheetViewPlugin extends UIPlugin {
37525
37629
  }
37526
37630
  checkPositiveDimension(cmd) {
37527
37631
  if (cmd.width < 0 || cmd.height < 0) {
37528
- return 68 /* CommandResult.InvalidViewportSize */;
37632
+ return 69 /* CommandResult.InvalidViewportSize */;
37529
37633
  }
37530
37634
  return 0 /* CommandResult.Success */;
37531
37635
  }
@@ -37535,7 +37639,7 @@ class SheetViewPlugin extends UIPlugin {
37535
37639
  cmd.gridOffsetY === this.gridOffsetY &&
37536
37640
  cmd.width === width &&
37537
37641
  cmd.height === height) {
37538
- return 76 /* CommandResult.ValuesNotChanged */;
37642
+ return 77 /* CommandResult.ValuesNotChanged */;
37539
37643
  }
37540
37644
  return 0 /* CommandResult.Success */;
37541
37645
  }
@@ -37543,7 +37647,7 @@ class SheetViewPlugin extends UIPlugin {
37543
37647
  const pane = this.getMainInternalViewport(this.getters.getActiveSheetId());
37544
37648
  if ((!pane.canScrollHorizontally && offsetX > 0) ||
37545
37649
  (!pane.canScrollVertically && offsetY > 0)) {
37546
- return 69 /* CommandResult.InvalidScrollingDirection */;
37650
+ return 70 /* CommandResult.InvalidScrollingDirection */;
37547
37651
  }
37548
37652
  return 0 /* CommandResult.Success */;
37549
37653
  }
@@ -37562,12 +37666,11 @@ class SheetViewPlugin extends UIPlugin {
37562
37666
  }
37563
37667
  /** gets rid of deprecated sheetIds */
37564
37668
  cleanViewports() {
37565
- const sheetIds = this.getters.getSheetIds();
37566
- for (let sheetId of Object.keys(this.viewports)) {
37567
- if (!sheetIds.includes(sheetId)) {
37568
- delete this.viewports[sheetId];
37569
- }
37669
+ const newViewport = {};
37670
+ for (const sheetId of this.getters.getSheetIds()) {
37671
+ newViewport[sheetId] = this.viewports[sheetId];
37570
37672
  }
37673
+ this.viewports = newViewport;
37571
37674
  }
37572
37675
  resetSheetViews() {
37573
37676
  this.cleanViewports();
@@ -37588,14 +37691,14 @@ class SheetViewPlugin extends UIPlugin {
37588
37691
  this.recomputeViewports();
37589
37692
  }
37590
37693
  recomputeViewports() {
37591
- for (let sheetId of Object.keys(this.viewports)) {
37694
+ for (const sheetId of this.getters.getSheetIds()) {
37592
37695
  this.resetViewports(sheetId);
37593
37696
  }
37594
37697
  }
37595
37698
  setSheetViewOffset(offsetX, offsetY) {
37596
37699
  const sheetId = this.getters.getActiveSheetId();
37597
37700
  const { maxOffsetX, maxOffsetY } = this.getMaximumSheetOffset();
37598
- Object.values(this.getSubViewports(sheetId)).forEach((viewport) => viewport.setViewportOffset(clip(offsetX, 0, maxOffsetX), clip(offsetY, 0, maxOffsetY)));
37701
+ this.getSubViewports(sheetId).forEach((viewport) => viewport.setViewportOffset(clip(offsetX, 0, maxOffsetX), clip(offsetY, 0, maxOffsetY)));
37599
37702
  }
37600
37703
  getViewportOffset(sheetId) {
37601
37704
  var _a, _b;
@@ -37611,8 +37714,10 @@ class SheetViewPlugin extends UIPlugin {
37611
37714
  const { xSplit, ySplit } = this.getters.getPaneDivisions(sheetId);
37612
37715
  const nCols = this.getters.getNumberCols(sheetId);
37613
37716
  const nRows = this.getters.getNumberRows(sheetId);
37614
- const colOffset = this.getters.getColRowOffset("COL", 0, xSplit, sheetId);
37615
- const rowOffset = this.getters.getColRowOffset("ROW", 0, ySplit, sheetId);
37717
+ const colOffset = Math.min(this.getters.getColRowOffset("COL", 0, xSplit, sheetId), this.sheetViewWidth);
37718
+ const rowOffset = Math.min(this.getters.getColRowOffset("ROW", 0, ySplit, sheetId), this.sheetViewHeight);
37719
+ const unfrozenWidth = Math.max(this.sheetViewWidth - colOffset, 0);
37720
+ const unfrozenHeight = Math.max(this.sheetViewHeight - rowOffset, 0);
37616
37721
  const { xRatio, yRatio } = this.getFrozenSheetViewRatio(sheetId);
37617
37722
  const canScrollHorizontally = xRatio < 1.0;
37618
37723
  const canScrollVertically = yRatio < 1.0;
@@ -37623,14 +37728,14 @@ class SheetViewPlugin extends UIPlugin {
37623
37728
  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 })) ||
37624
37729
  undefined,
37625
37730
  topRight: (ySplit &&
37626
- 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 })) ||
37731
+ 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 })) ||
37627
37732
  undefined,
37628
37733
  bottomLeft: (xSplit &&
37629
- 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 })) ||
37734
+ 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 })) ||
37630
37735
  undefined,
37631
37736
  bottomRight: new InternalViewport(this.getters, sheetId, { left: xSplit, right: nCols - 1, top: ySplit, bottom: nRows - 1 }, {
37632
- width: this.sheetViewWidth - colOffset,
37633
- height: this.sheetViewHeight - rowOffset,
37737
+ width: unfrozenWidth,
37738
+ height: unfrozenHeight,
37634
37739
  }, { canScrollHorizontally, canScrollVertically }, {
37635
37740
  x: canScrollHorizontally ? previousOffset.x : 0,
37636
37741
  y: canScrollVertically ? previousOffset.y : 0,
@@ -37642,7 +37747,7 @@ class SheetViewPlugin extends UIPlugin {
37642
37747
  * Adjust the viewport such that the anchor position is visible
37643
37748
  */
37644
37749
  refreshViewport(sheetId, anchorPosition) {
37645
- Object.values(this.getSubViewports(sheetId)).forEach((viewport) => {
37750
+ this.getSubViewports(sheetId).forEach((viewport) => {
37646
37751
  viewport.adjustViewportZone();
37647
37752
  viewport.adjustPosition(anchorPosition);
37648
37753
  });
@@ -37693,16 +37798,30 @@ class SheetViewPlugin extends UIPlugin {
37693
37798
  const height = this.sheetViewHeight + this.gridOffsetY;
37694
37799
  return { xRatio: offsetCorrectionX / width, yRatio: offsetCorrectionY / height };
37695
37800
  }
37696
- recomposeRect(viewportRects) {
37697
- const x = Math.min(...viewportRects.map((rect) => rect.x));
37698
- const y = Math.min(...viewportRects.map((rect) => rect.y));
37699
- const width = Math.max(...viewportRects.map((rect) => rect.x + rect.width)) - x;
37700
- const height = Math.max(...viewportRects.map((rect) => rect.y + rect.height)) - y;
37801
+ mapViewportsToRect(sheetId, rectCallBack) {
37802
+ let x = Infinity;
37803
+ let y = Infinity;
37804
+ let width = 0;
37805
+ let height = 0;
37806
+ let hasViewports = false;
37807
+ for (const viewport of this.getSubViewports(sheetId)) {
37808
+ const rect = rectCallBack(viewport);
37809
+ if (rect) {
37810
+ hasViewports = true;
37811
+ x = Math.min(x, rect.x);
37812
+ y = Math.min(y, rect.y);
37813
+ width = Math.max(width, rect.x + rect.width);
37814
+ height = Math.max(height, rect.y + rect.height);
37815
+ }
37816
+ }
37817
+ if (!hasViewports) {
37818
+ return { x: 0, y: 0, width: 0, height: 0 };
37819
+ }
37701
37820
  return {
37702
37821
  x: x + this.gridOffsetX,
37703
37822
  y: y + this.gridOffsetY,
37704
- width,
37705
- height,
37823
+ width: width - x,
37824
+ height: height - y,
37706
37825
  };
37707
37826
  }
37708
37827
  }
@@ -37755,7 +37874,7 @@ class SortPlugin extends UIPlugin {
37755
37874
  for (let row = zone.top; row <= zone.bottom; row++) {
37756
37875
  for (let col = zone.left; col <= zone.right; col++) {
37757
37876
  if (!this.getters.isInMerge(sheetId, col, row)) {
37758
- return 63 /* CommandResult.InvalidSortZone */;
37877
+ return 64 /* CommandResult.InvalidSortZone */;
37759
37878
  }
37760
37879
  }
37761
37880
  }
@@ -37776,7 +37895,7 @@ class SortPlugin extends UIPlugin {
37776
37895
  ];
37777
37896
  return widthCurrent === widthFirst && heightCurrent === heightFirst;
37778
37897
  })) {
37779
- return 63 /* CommandResult.InvalidSortZone */;
37898
+ return 64 /* CommandResult.InvalidSortZone */;
37780
37899
  }
37781
37900
  return 0 /* CommandResult.Success */;
37782
37901
  }
@@ -38442,7 +38561,7 @@ class BottomBar extends owl.Component {
38442
38561
  addSheet() {
38443
38562
  const activeSheetId = this.env.model.getters.getActiveSheetId();
38444
38563
  const position = this.env.model.getters.getSheetIds().findIndex((sheetId) => sheetId === activeSheetId) + 1;
38445
- const sheetId = this.env.model.uuidGenerator.uuidv4();
38564
+ const sheetId = this.env.model.uuidGenerator.smallUuid();
38446
38565
  const name = this.env.model.getters.getNextSheetName(this.env._t("Sheet"));
38447
38566
  this.env.model.dispatch("CREATE_SHEET", { sheetId, position, name });
38448
38567
  this.env.model.dispatch("ACTIVATE_SHEET", { sheetIdFrom: activeSheetId, sheetIdTo: sheetId });
@@ -38931,7 +39050,7 @@ const AddMergeInteractiveContent = {
38931
39050
  };
38932
39051
  function interactiveAddMerge(env, sheetId, target) {
38933
39052
  const result = env.model.dispatch("ADD_MERGE", { sheetId, target });
38934
- if (result.isCancelledBecause(80 /* CommandResult.MergeInFilter */)) {
39053
+ if (result.isCancelledBecause(81 /* CommandResult.MergeInFilter */)) {
38935
39054
  env.raiseError(AddMergeInteractiveContent.MergeInFilter);
38936
39055
  }
38937
39056
  else if (result.isCancelledBecause(3 /* CommandResult.MergeIsDestructive */)) {
@@ -40064,7 +40183,7 @@ class Tree {
40064
40183
  }
40065
40184
  /**
40066
40185
  * Drop the operation and all following operations in every
40067
- * branch
40186
+ * branches
40068
40187
  */
40069
40188
  drop(operationId) {
40070
40189
  for (const branch of this.branches) {
@@ -40361,9 +40480,16 @@ class SelectiveHistory {
40361
40480
  this.fastForward();
40362
40481
  this.insert(redoId, this.buildEmpty(redoId), insertAfter);
40363
40482
  }
40364
- drop(operationId) {
40483
+ rebase(operationId) {
40484
+ const operation = this.get(operationId);
40485
+ const execution = [...this.tree.execution(this.HEAD_BRANCH).startAfter(operationId)];
40365
40486
  this.revertBefore(operationId);
40487
+ const baseId = this.HEAD_OPERATION.id;
40366
40488
  this.tree.drop(operationId);
40489
+ this.insert(operationId, operation, baseId);
40490
+ for (const { operation } of execution) {
40491
+ this.insert(operation.id, operation.data, this.HEAD_OPERATION.id);
40492
+ }
40367
40493
  }
40368
40494
  /**
40369
40495
  * Revert the state as it was *before* the given operation was executed.
@@ -40486,7 +40612,6 @@ class LocalHistory extends owl.EventBus {
40486
40612
  this.session.on("new-local-state-update", this, this.onNewLocalStateUpdate);
40487
40613
  this.session.on("revision-undone", this, ({ commands }) => this.selectiveUndo(commands));
40488
40614
  this.session.on("revision-redone", this, ({ commands }) => this.selectiveRedo(commands));
40489
- this.session.on("pending-revisions-dropped", this, ({ revisionIds }) => this.drop(revisionIds));
40490
40615
  this.session.on("snapshot", this, () => {
40491
40616
  this.undoStack = [];
40492
40617
  this.redoStack = [];
@@ -40539,10 +40664,6 @@ class LocalHistory extends owl.EventBus {
40539
40664
  canRedo() {
40540
40665
  return this.redoStack.length > 0;
40541
40666
  }
40542
- drop(revisionIds) {
40543
- this.undoStack = this.undoStack.filter((id) => !revisionIds.includes(id));
40544
- this.redoStack = [];
40545
- }
40546
40667
  onNewLocalStateUpdate({ id }) {
40547
40668
  this.undoStack.push(id);
40548
40669
  this.redoStack = [];
@@ -41123,7 +41244,7 @@ class SelectionStreamProcessor {
41123
41244
  */
41124
41245
  moveAnchorCell(direction, step = 1) {
41125
41246
  if (step !== "end" && step <= 0) {
41126
- return new DispatchResult(83 /* CommandResult.InvalidSelectionStep */);
41247
+ return new DispatchResult(84 /* CommandResult.InvalidSelectionStep */);
41127
41248
  }
41128
41249
  const { col, row } = this.getNextAvailablePosition(direction, step);
41129
41250
  return this.selectCell(col, row);
@@ -41169,7 +41290,7 @@ class SelectionStreamProcessor {
41169
41290
  */
41170
41291
  resizeAnchorZone(direction, step = 1) {
41171
41292
  if (step !== "end" && step <= 0) {
41172
- return new DispatchResult(83 /* CommandResult.InvalidSelectionStep */);
41293
+ return new DispatchResult(84 /* CommandResult.InvalidSelectionStep */);
41173
41294
  }
41174
41295
  const sheetId = this.getters.getActiveSheetId();
41175
41296
  const anchor = this.anchor;
@@ -43115,10 +43236,10 @@ class Model extends EventBus {
43115
43236
  const command = { type, ...payload };
43116
43237
  let status = this.status;
43117
43238
  if (this.getters.isReadonly() && !canExecuteInReadonly(command)) {
43118
- return new DispatchResult(67 /* CommandResult.Readonly */);
43239
+ return new DispatchResult(68 /* CommandResult.Readonly */);
43119
43240
  }
43120
43241
  if (!this.session.canApplyOptimisticUpdate()) {
43121
- return new DispatchResult(64 /* CommandResult.WaitingSessionConfirmation */);
43242
+ return new DispatchResult(65 /* CommandResult.WaitingSessionConfirmation */);
43122
43243
  }
43123
43244
  switch (status) {
43124
43245
  case 0 /* Status.Ready */:
@@ -43320,7 +43441,7 @@ class Model extends EventBus {
43320
43441
  }
43321
43442
  setupConfig(config) {
43322
43443
  const client = config.client || {
43323
- id: this.uuidGenerator.uuidv4(),
43444
+ id: this.uuidGenerator.smallUuid(),
43324
43445
  name: _lt("Anonymous").toString(),
43325
43446
  };
43326
43447
  const transportService = config.transportService || new LocalTransportService();
@@ -43568,6 +43689,6 @@ exports.setTranslationMethod = setTranslationMethod;
43568
43689
  exports.tokenize = tokenize;
43569
43690
 
43570
43691
 
43571
- __info__.version = '16.0.59';
43572
- __info__.date = '2025-01-29T06:24:17.486Z';
43573
- __info__.hash = '0897f45';
43692
+ __info__.version = '16.0.62';
43693
+ __info__.date = '2025-02-14T08:36:41.388Z';
43694
+ __info__.hash = '34f2802';