@odoo/o-spreadsheet 16.1.0 → 16.1.2

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.
@@ -5478,28 +5478,28 @@ function useSpreadsheetRect() {
5478
5478
  return position;
5479
5479
  }
5480
5480
  /**
5481
- * Return the component (or ref's component) top left position (in pixels) relative
5481
+ * Return the component (or ref's component) BoundingRect, relative
5482
5482
  * to the upper left corner of the screen (<body> element).
5483
5483
  *
5484
5484
  * Note: when used with a <Portal/> component, it will
5485
5485
  * return the portal position, not the teleported position.
5486
5486
  */
5487
- function useAbsolutePosition(ref) {
5488
- const position = owl.useState({ x: 0, y: 0 });
5489
- function updateElPosition() {
5487
+ function useAbsoluteBoundingRect(ref) {
5488
+ const rect = owl.useState({ x: 0, y: 0, width: 0, height: 0 });
5489
+ function updateElRect() {
5490
5490
  const el = ref.el;
5491
5491
  if (el === null) {
5492
5492
  return;
5493
5493
  }
5494
- const { top, left } = el.getBoundingClientRect();
5495
- if (left !== position.x || top !== position.y) {
5496
- position.x = left;
5497
- position.y = top;
5498
- }
5494
+ const { top, left, width, height } = el.getBoundingClientRect();
5495
+ rect.x = left;
5496
+ rect.y = top;
5497
+ rect.width = width;
5498
+ rect.height = height;
5499
5499
  }
5500
- owl.onMounted(updateElPosition);
5501
- owl.onPatched(updateElPosition);
5502
- return position;
5500
+ owl.onMounted(updateElRect);
5501
+ owl.onPatched(updateElRect);
5502
+ return rect;
5503
5503
  }
5504
5504
  /**
5505
5505
  * Get the rectangle inside which a popover should stay when being displayed.
@@ -5858,7 +5858,7 @@ class Menu extends owl.Component {
5858
5858
  menuItems: [],
5859
5859
  });
5860
5860
  this.menuRef = owl.useRef("menu");
5861
- this.position = useAbsolutePosition(this.menuRef);
5861
+ this.position = useAbsoluteBoundingRect(this.menuRef);
5862
5862
  }
5863
5863
  setup() {
5864
5864
  owl.useExternalListener(window, "click", this.onExternalClick, { capture: true });
@@ -6024,8 +6024,8 @@ class ChartFigure extends owl.Component {
6024
6024
  this.menuState = owl.useState({ isOpen: false, position: null, menuItems: [] });
6025
6025
  this.chartContainerRef = owl.useRef("chartContainer");
6026
6026
  this.menuButtonRef = owl.useRef("menuButton");
6027
- this.menuButtonPosition = useAbsolutePosition(this.menuButtonRef);
6028
- this.position = useAbsolutePosition(this.chartContainerRef);
6027
+ this.menuButtonRect = useAbsoluteBoundingRect(this.menuButtonRef);
6028
+ this.position = useAbsoluteBoundingRect(this.chartContainerRef);
6029
6029
  }
6030
6030
  getMenuItemRegistry() {
6031
6031
  const registry = new MenuItemRegistry();
@@ -6079,11 +6079,12 @@ class ChartFigure extends owl.Component {
6079
6079
  this.openContextMenu(position);
6080
6080
  }
6081
6081
  showMenu() {
6082
- const position = {
6083
- x: this.menuButtonPosition.x - MENU_WIDTH,
6084
- y: this.menuButtonPosition.y,
6082
+ const { x, y, width } = this.menuButtonRect;
6083
+ const menuPosition = {
6084
+ x: x >= MENU_WIDTH ? x - MENU_WIDTH : x + width,
6085
+ y: y,
6085
6086
  };
6086
- this.openContextMenu(position);
6087
+ this.openContextMenu(menuPosition);
6087
6088
  }
6088
6089
  openContextMenu(position) {
6089
6090
  const registry = this.getMenuItemRegistry();
@@ -18658,7 +18659,7 @@ class LinkEditor extends owl.Component {
18658
18659
  isOpen: false,
18659
18660
  });
18660
18661
  this.linkEditorRef = owl.useRef("linkEditor");
18661
- this.position = useAbsolutePosition(this.linkEditorRef);
18662
+ this.position = useAbsoluteBoundingRect(this.linkEditorRef);
18662
18663
  this.urlInput = owl.useRef("urlInput");
18663
18664
  }
18664
18665
  setup() {
@@ -18774,8 +18775,8 @@ class ImageFigure extends owl.Component {
18774
18775
  this.menuState = owl.useState({ isOpen: false, position: null, menuItems: [] });
18775
18776
  this.imageContainerRef = owl.useRef("o-image");
18776
18777
  this.menuButtonRef = owl.useRef("menuButton");
18777
- this.menuButtonPosition = useAbsolutePosition(this.menuButtonRef);
18778
- this.position = useAbsolutePosition(this.imageContainerRef);
18778
+ this.menuButtonRect = useAbsoluteBoundingRect(this.menuButtonRef);
18779
+ this.position = useAbsoluteBoundingRect(this.imageContainerRef);
18779
18780
  }
18780
18781
  getMenuItemRegistry() {
18781
18782
  const registry = new MenuItemRegistry();
@@ -18834,11 +18835,12 @@ class ImageFigure extends owl.Component {
18834
18835
  this.openContextMenu(position);
18835
18836
  }
18836
18837
  showMenu() {
18837
- const position = {
18838
- x: this.menuButtonPosition.x - MENU_WIDTH,
18839
- y: this.menuButtonPosition.y,
18838
+ const { x, y, width } = this.menuButtonRect;
18839
+ const menuPosition = {
18840
+ x: x >= MENU_WIDTH ? x - MENU_WIDTH : x + width,
18841
+ y: y,
18840
18842
  };
18841
- this.openContextMenu(position);
18843
+ this.openContextMenu(menuPosition);
18842
18844
  }
18843
18845
  openContextMenu(position) {
18844
18846
  const registry = this.getMenuItemRegistry();
@@ -20516,7 +20518,6 @@ class ChartPanel extends owl.Component {
20516
20518
  ...this.getChartDefinition(),
20517
20519
  ...updateDefinition,
20518
20520
  };
20519
- // TODORAR add a putain de test - c'est faux de nouveau ...
20520
20521
  return this.env.model.dispatch("UPDATE_CHART", {
20521
20522
  definition,
20522
20523
  id: this.figureId,
@@ -20529,7 +20530,6 @@ class ChartPanel extends owl.Component {
20529
20530
  throw new Error("Chart not defined.");
20530
20531
  }
20531
20532
  const definition = getChartDefinitionFromContextCreation(context, type);
20532
- // TODORAR add a putain de test - c'est faux de nouveau ...
20533
20533
  this.env.model.dispatch("UPDATE_CHART", {
20534
20534
  definition,
20535
20535
  id: this.figureId,
@@ -23524,7 +23524,7 @@ class Grid extends owl.Component {
23524
23524
  });
23525
23525
  this.gridRef = owl.useRef("grid");
23526
23526
  this.hiddenInput = owl.useRef("hiddenInput");
23527
- this.canvasPosition = useAbsolutePosition(this.gridRef);
23527
+ this.canvasPosition = useAbsoluteBoundingRect(this.gridRef);
23528
23528
  this.hoveredCell = owl.useState({ col: undefined, row: undefined });
23529
23529
  owl.useChildSubEnv({ getPopoverContainerRect: () => this.getGridRect() });
23530
23530
  owl.useExternalListener(document.body, "cut", this.copy.bind(this, true));
@@ -28567,9 +28567,6 @@ class ChartPlugin extends CorePlugin {
28567
28567
  return figureId in (this.charts[sheetId] || {});
28568
28568
  }
28569
28569
  getChartIds(sheetId) {
28570
- // TODORAR refaire ce shit truc
28571
- // on veut un truc du genre Object.keys(this.charts[sheetId] || {} a mon avis
28572
- // return (Object.values(this.charts[sheetId] || {}).filter(isDefined) as AbstractChart[]).map((chart) => chart.id);
28573
28570
  return Object.keys(this.charts[sheetId] || {});
28574
28571
  }
28575
28572
  getChartDefinition(sheetId, figureId) {
@@ -39098,7 +39095,7 @@ let tKey = 1;
39098
39095
  class SpreadsheetDashboard extends owl.Component {
39099
39096
  setup() {
39100
39097
  const gridRef = owl.useRef("grid");
39101
- this.canvasPosition = useAbsolutePosition(gridRef);
39098
+ this.canvasPosition = useAbsoluteBoundingRect(gridRef);
39102
39099
  this.hoveredCell = owl.useState({ col: undefined, row: undefined });
39103
39100
  owl.useChildSubEnv({ getPopoverContainerRect: () => this.getGridRect() });
39104
39101
  useGridDrawing("canvas", this.env.model, () => this.env.model.getters.getSheetViewDimension());
@@ -43851,6 +43848,6 @@ exports.setTranslationMethod = setTranslationMethod;
43851
43848
  exports.tokenize = tokenize;
43852
43849
 
43853
43850
 
43854
- __info__.version = '16.1.0';
43855
- __info__.date = '2023-02-27T14:56:39.727Z';
43856
- __info__.hash = '5ecccad';
43851
+ __info__.version = '16.1.2';
43852
+ __info__.date = '2023-03-01T14:43:45.667Z';
43853
+ __info__.hash = '59bec2d';
@@ -5431,7 +5431,7 @@ declare class ChartFigure extends Component<Props$n, SpreadsheetChildEnv> {
5431
5431
  private menuState;
5432
5432
  private chartContainerRef;
5433
5433
  private menuButtonRef;
5434
- private menuButtonPosition;
5434
+ private menuButtonRect;
5435
5435
  private position;
5436
5436
  private getMenuItemRegistry;
5437
5437
  get chartType(): ChartType;
@@ -5474,28 +5474,28 @@ function useSpreadsheetRect() {
5474
5474
  return position;
5475
5475
  }
5476
5476
  /**
5477
- * Return the component (or ref's component) top left position (in pixels) relative
5477
+ * Return the component (or ref's component) BoundingRect, relative
5478
5478
  * to the upper left corner of the screen (<body> element).
5479
5479
  *
5480
5480
  * Note: when used with a <Portal/> component, it will
5481
5481
  * return the portal position, not the teleported position.
5482
5482
  */
5483
- function useAbsolutePosition(ref) {
5484
- const position = useState({ x: 0, y: 0 });
5485
- function updateElPosition() {
5483
+ function useAbsoluteBoundingRect(ref) {
5484
+ const rect = useState({ x: 0, y: 0, width: 0, height: 0 });
5485
+ function updateElRect() {
5486
5486
  const el = ref.el;
5487
5487
  if (el === null) {
5488
5488
  return;
5489
5489
  }
5490
- const { top, left } = el.getBoundingClientRect();
5491
- if (left !== position.x || top !== position.y) {
5492
- position.x = left;
5493
- position.y = top;
5494
- }
5490
+ const { top, left, width, height } = el.getBoundingClientRect();
5491
+ rect.x = left;
5492
+ rect.y = top;
5493
+ rect.width = width;
5494
+ rect.height = height;
5495
5495
  }
5496
- onMounted(updateElPosition);
5497
- onPatched(updateElPosition);
5498
- return position;
5496
+ onMounted(updateElRect);
5497
+ onPatched(updateElRect);
5498
+ return rect;
5499
5499
  }
5500
5500
  /**
5501
5501
  * Get the rectangle inside which a popover should stay when being displayed.
@@ -5854,7 +5854,7 @@ class Menu extends Component {
5854
5854
  menuItems: [],
5855
5855
  });
5856
5856
  this.menuRef = useRef("menu");
5857
- this.position = useAbsolutePosition(this.menuRef);
5857
+ this.position = useAbsoluteBoundingRect(this.menuRef);
5858
5858
  }
5859
5859
  setup() {
5860
5860
  useExternalListener(window, "click", this.onExternalClick, { capture: true });
@@ -6020,8 +6020,8 @@ class ChartFigure extends Component {
6020
6020
  this.menuState = useState({ isOpen: false, position: null, menuItems: [] });
6021
6021
  this.chartContainerRef = useRef("chartContainer");
6022
6022
  this.menuButtonRef = useRef("menuButton");
6023
- this.menuButtonPosition = useAbsolutePosition(this.menuButtonRef);
6024
- this.position = useAbsolutePosition(this.chartContainerRef);
6023
+ this.menuButtonRect = useAbsoluteBoundingRect(this.menuButtonRef);
6024
+ this.position = useAbsoluteBoundingRect(this.chartContainerRef);
6025
6025
  }
6026
6026
  getMenuItemRegistry() {
6027
6027
  const registry = new MenuItemRegistry();
@@ -6075,11 +6075,12 @@ class ChartFigure extends Component {
6075
6075
  this.openContextMenu(position);
6076
6076
  }
6077
6077
  showMenu() {
6078
- const position = {
6079
- x: this.menuButtonPosition.x - MENU_WIDTH,
6080
- y: this.menuButtonPosition.y,
6078
+ const { x, y, width } = this.menuButtonRect;
6079
+ const menuPosition = {
6080
+ x: x >= MENU_WIDTH ? x - MENU_WIDTH : x + width,
6081
+ y: y,
6081
6082
  };
6082
- this.openContextMenu(position);
6083
+ this.openContextMenu(menuPosition);
6083
6084
  }
6084
6085
  openContextMenu(position) {
6085
6086
  const registry = this.getMenuItemRegistry();
@@ -18654,7 +18655,7 @@ class LinkEditor extends Component {
18654
18655
  isOpen: false,
18655
18656
  });
18656
18657
  this.linkEditorRef = useRef("linkEditor");
18657
- this.position = useAbsolutePosition(this.linkEditorRef);
18658
+ this.position = useAbsoluteBoundingRect(this.linkEditorRef);
18658
18659
  this.urlInput = useRef("urlInput");
18659
18660
  }
18660
18661
  setup() {
@@ -18770,8 +18771,8 @@ class ImageFigure extends Component {
18770
18771
  this.menuState = useState({ isOpen: false, position: null, menuItems: [] });
18771
18772
  this.imageContainerRef = useRef("o-image");
18772
18773
  this.menuButtonRef = useRef("menuButton");
18773
- this.menuButtonPosition = useAbsolutePosition(this.menuButtonRef);
18774
- this.position = useAbsolutePosition(this.imageContainerRef);
18774
+ this.menuButtonRect = useAbsoluteBoundingRect(this.menuButtonRef);
18775
+ this.position = useAbsoluteBoundingRect(this.imageContainerRef);
18775
18776
  }
18776
18777
  getMenuItemRegistry() {
18777
18778
  const registry = new MenuItemRegistry();
@@ -18830,11 +18831,12 @@ class ImageFigure extends Component {
18830
18831
  this.openContextMenu(position);
18831
18832
  }
18832
18833
  showMenu() {
18833
- const position = {
18834
- x: this.menuButtonPosition.x - MENU_WIDTH,
18835
- y: this.menuButtonPosition.y,
18834
+ const { x, y, width } = this.menuButtonRect;
18835
+ const menuPosition = {
18836
+ x: x >= MENU_WIDTH ? x - MENU_WIDTH : x + width,
18837
+ y: y,
18836
18838
  };
18837
- this.openContextMenu(position);
18839
+ this.openContextMenu(menuPosition);
18838
18840
  }
18839
18841
  openContextMenu(position) {
18840
18842
  const registry = this.getMenuItemRegistry();
@@ -20512,7 +20514,6 @@ class ChartPanel extends Component {
20512
20514
  ...this.getChartDefinition(),
20513
20515
  ...updateDefinition,
20514
20516
  };
20515
- // TODORAR add a putain de test - c'est faux de nouveau ...
20516
20517
  return this.env.model.dispatch("UPDATE_CHART", {
20517
20518
  definition,
20518
20519
  id: this.figureId,
@@ -20525,7 +20526,6 @@ class ChartPanel extends Component {
20525
20526
  throw new Error("Chart not defined.");
20526
20527
  }
20527
20528
  const definition = getChartDefinitionFromContextCreation(context, type);
20528
- // TODORAR add a putain de test - c'est faux de nouveau ...
20529
20529
  this.env.model.dispatch("UPDATE_CHART", {
20530
20530
  definition,
20531
20531
  id: this.figureId,
@@ -23520,7 +23520,7 @@ class Grid extends Component {
23520
23520
  });
23521
23521
  this.gridRef = useRef("grid");
23522
23522
  this.hiddenInput = useRef("hiddenInput");
23523
- this.canvasPosition = useAbsolutePosition(this.gridRef);
23523
+ this.canvasPosition = useAbsoluteBoundingRect(this.gridRef);
23524
23524
  this.hoveredCell = useState({ col: undefined, row: undefined });
23525
23525
  useChildSubEnv({ getPopoverContainerRect: () => this.getGridRect() });
23526
23526
  useExternalListener(document.body, "cut", this.copy.bind(this, true));
@@ -28563,9 +28563,6 @@ class ChartPlugin extends CorePlugin {
28563
28563
  return figureId in (this.charts[sheetId] || {});
28564
28564
  }
28565
28565
  getChartIds(sheetId) {
28566
- // TODORAR refaire ce shit truc
28567
- // on veut un truc du genre Object.keys(this.charts[sheetId] || {} a mon avis
28568
- // return (Object.values(this.charts[sheetId] || {}).filter(isDefined) as AbstractChart[]).map((chart) => chart.id);
28569
28566
  return Object.keys(this.charts[sheetId] || {});
28570
28567
  }
28571
28568
  getChartDefinition(sheetId, figureId) {
@@ -39094,7 +39091,7 @@ let tKey = 1;
39094
39091
  class SpreadsheetDashboard extends Component {
39095
39092
  setup() {
39096
39093
  const gridRef = useRef("grid");
39097
- this.canvasPosition = useAbsolutePosition(gridRef);
39094
+ this.canvasPosition = useAbsoluteBoundingRect(gridRef);
39098
39095
  this.hoveredCell = useState({ col: undefined, row: undefined });
39099
39096
  useChildSubEnv({ getPopoverContainerRect: () => this.getGridRect() });
39100
39097
  useGridDrawing("canvas", this.env.model, () => this.env.model.getters.getSheetViewDimension());
@@ -43819,6 +43816,6 @@ function addFunction(functionName, functionDescription) {
43819
43816
  export { AbstractChart, CommandResult, CorePlugin, DATETIME_FORMAT, DispatchResult, EvaluationError, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, __info__, addFunction, astToFormula, compile, components, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, invalidateEvaluationCommands, links, load, parse, readonlyAllowedCommands, registries, setTranslationMethod, tokenize };
43820
43817
 
43821
43818
 
43822
- __info__.version = '16.1.0';
43823
- __info__.date = '2023-02-27T14:56:39.727Z';
43824
- __info__.hash = '5ecccad';
43819
+ __info__.version = '16.1.2';
43820
+ __info__.date = '2023-03-01T14:43:45.667Z';
43821
+ __info__.hash = '59bec2d';
@@ -5475,28 +5475,28 @@
5475
5475
  return position;
5476
5476
  }
5477
5477
  /**
5478
- * Return the component (or ref's component) top left position (in pixels) relative
5478
+ * Return the component (or ref's component) BoundingRect, relative
5479
5479
  * to the upper left corner of the screen (<body> element).
5480
5480
  *
5481
5481
  * Note: when used with a <Portal/> component, it will
5482
5482
  * return the portal position, not the teleported position.
5483
5483
  */
5484
- function useAbsolutePosition(ref) {
5485
- const position = owl.useState({ x: 0, y: 0 });
5486
- function updateElPosition() {
5484
+ function useAbsoluteBoundingRect(ref) {
5485
+ const rect = owl.useState({ x: 0, y: 0, width: 0, height: 0 });
5486
+ function updateElRect() {
5487
5487
  const el = ref.el;
5488
5488
  if (el === null) {
5489
5489
  return;
5490
5490
  }
5491
- const { top, left } = el.getBoundingClientRect();
5492
- if (left !== position.x || top !== position.y) {
5493
- position.x = left;
5494
- position.y = top;
5495
- }
5491
+ const { top, left, width, height } = el.getBoundingClientRect();
5492
+ rect.x = left;
5493
+ rect.y = top;
5494
+ rect.width = width;
5495
+ rect.height = height;
5496
5496
  }
5497
- owl.onMounted(updateElPosition);
5498
- owl.onPatched(updateElPosition);
5499
- return position;
5497
+ owl.onMounted(updateElRect);
5498
+ owl.onPatched(updateElRect);
5499
+ return rect;
5500
5500
  }
5501
5501
  /**
5502
5502
  * Get the rectangle inside which a popover should stay when being displayed.
@@ -5855,7 +5855,7 @@
5855
5855
  menuItems: [],
5856
5856
  });
5857
5857
  this.menuRef = owl.useRef("menu");
5858
- this.position = useAbsolutePosition(this.menuRef);
5858
+ this.position = useAbsoluteBoundingRect(this.menuRef);
5859
5859
  }
5860
5860
  setup() {
5861
5861
  owl.useExternalListener(window, "click", this.onExternalClick, { capture: true });
@@ -6021,8 +6021,8 @@
6021
6021
  this.menuState = owl.useState({ isOpen: false, position: null, menuItems: [] });
6022
6022
  this.chartContainerRef = owl.useRef("chartContainer");
6023
6023
  this.menuButtonRef = owl.useRef("menuButton");
6024
- this.menuButtonPosition = useAbsolutePosition(this.menuButtonRef);
6025
- this.position = useAbsolutePosition(this.chartContainerRef);
6024
+ this.menuButtonRect = useAbsoluteBoundingRect(this.menuButtonRef);
6025
+ this.position = useAbsoluteBoundingRect(this.chartContainerRef);
6026
6026
  }
6027
6027
  getMenuItemRegistry() {
6028
6028
  const registry = new MenuItemRegistry();
@@ -6076,11 +6076,12 @@
6076
6076
  this.openContextMenu(position);
6077
6077
  }
6078
6078
  showMenu() {
6079
- const position = {
6080
- x: this.menuButtonPosition.x - MENU_WIDTH,
6081
- y: this.menuButtonPosition.y,
6079
+ const { x, y, width } = this.menuButtonRect;
6080
+ const menuPosition = {
6081
+ x: x >= MENU_WIDTH ? x - MENU_WIDTH : x + width,
6082
+ y: y,
6082
6083
  };
6083
- this.openContextMenu(position);
6084
+ this.openContextMenu(menuPosition);
6084
6085
  }
6085
6086
  openContextMenu(position) {
6086
6087
  const registry = this.getMenuItemRegistry();
@@ -18655,7 +18656,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
18655
18656
  isOpen: false,
18656
18657
  });
18657
18658
  this.linkEditorRef = owl.useRef("linkEditor");
18658
- this.position = useAbsolutePosition(this.linkEditorRef);
18659
+ this.position = useAbsoluteBoundingRect(this.linkEditorRef);
18659
18660
  this.urlInput = owl.useRef("urlInput");
18660
18661
  }
18661
18662
  setup() {
@@ -18771,8 +18772,8 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
18771
18772
  this.menuState = owl.useState({ isOpen: false, position: null, menuItems: [] });
18772
18773
  this.imageContainerRef = owl.useRef("o-image");
18773
18774
  this.menuButtonRef = owl.useRef("menuButton");
18774
- this.menuButtonPosition = useAbsolutePosition(this.menuButtonRef);
18775
- this.position = useAbsolutePosition(this.imageContainerRef);
18775
+ this.menuButtonRect = useAbsoluteBoundingRect(this.menuButtonRef);
18776
+ this.position = useAbsoluteBoundingRect(this.imageContainerRef);
18776
18777
  }
18777
18778
  getMenuItemRegistry() {
18778
18779
  const registry = new MenuItemRegistry();
@@ -18831,11 +18832,12 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
18831
18832
  this.openContextMenu(position);
18832
18833
  }
18833
18834
  showMenu() {
18834
- const position = {
18835
- x: this.menuButtonPosition.x - MENU_WIDTH,
18836
- y: this.menuButtonPosition.y,
18835
+ const { x, y, width } = this.menuButtonRect;
18836
+ const menuPosition = {
18837
+ x: x >= MENU_WIDTH ? x - MENU_WIDTH : x + width,
18838
+ y: y,
18837
18839
  };
18838
- this.openContextMenu(position);
18840
+ this.openContextMenu(menuPosition);
18839
18841
  }
18840
18842
  openContextMenu(position) {
18841
18843
  const registry = this.getMenuItemRegistry();
@@ -20513,7 +20515,6 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
20513
20515
  ...this.getChartDefinition(),
20514
20516
  ...updateDefinition,
20515
20517
  };
20516
- // TODORAR add a putain de test - c'est faux de nouveau ...
20517
20518
  return this.env.model.dispatch("UPDATE_CHART", {
20518
20519
  definition,
20519
20520
  id: this.figureId,
@@ -20526,7 +20527,6 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
20526
20527
  throw new Error("Chart not defined.");
20527
20528
  }
20528
20529
  const definition = getChartDefinitionFromContextCreation(context, type);
20529
- // TODORAR add a putain de test - c'est faux de nouveau ...
20530
20530
  this.env.model.dispatch("UPDATE_CHART", {
20531
20531
  definition,
20532
20532
  id: this.figureId,
@@ -23521,7 +23521,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
23521
23521
  });
23522
23522
  this.gridRef = owl.useRef("grid");
23523
23523
  this.hiddenInput = owl.useRef("hiddenInput");
23524
- this.canvasPosition = useAbsolutePosition(this.gridRef);
23524
+ this.canvasPosition = useAbsoluteBoundingRect(this.gridRef);
23525
23525
  this.hoveredCell = owl.useState({ col: undefined, row: undefined });
23526
23526
  owl.useChildSubEnv({ getPopoverContainerRect: () => this.getGridRect() });
23527
23527
  owl.useExternalListener(document.body, "cut", this.copy.bind(this, true));
@@ -28564,9 +28564,6 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
28564
28564
  return figureId in (this.charts[sheetId] || {});
28565
28565
  }
28566
28566
  getChartIds(sheetId) {
28567
- // TODORAR refaire ce shit truc
28568
- // on veut un truc du genre Object.keys(this.charts[sheetId] || {} a mon avis
28569
- // return (Object.values(this.charts[sheetId] || {}).filter(isDefined) as AbstractChart[]).map((chart) => chart.id);
28570
28567
  return Object.keys(this.charts[sheetId] || {});
28571
28568
  }
28572
28569
  getChartDefinition(sheetId, figureId) {
@@ -39095,7 +39092,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
39095
39092
  class SpreadsheetDashboard extends owl.Component {
39096
39093
  setup() {
39097
39094
  const gridRef = owl.useRef("grid");
39098
- this.canvasPosition = useAbsolutePosition(gridRef);
39095
+ this.canvasPosition = useAbsoluteBoundingRect(gridRef);
39099
39096
  this.hoveredCell = owl.useState({ col: undefined, row: undefined });
39100
39097
  owl.useChildSubEnv({ getPopoverContainerRect: () => this.getGridRect() });
39101
39098
  useGridDrawing("canvas", this.env.model, () => this.env.model.getters.getSheetViewDimension());
@@ -43850,9 +43847,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
43850
43847
  Object.defineProperty(exports, '__esModule', { value: true });
43851
43848
 
43852
43849
 
43853
- __info__.version = '16.1.0';
43854
- __info__.date = '2023-02-27T14:56:39.727Z';
43855
- __info__.hash = '5ecccad';
43850
+ __info__.version = '16.1.2';
43851
+ __info__.date = '2023-03-01T14:43:45.667Z';
43852
+ __info__.hash = '59bec2d';
43856
43853
 
43857
43854
 
43858
43855
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);
@@ -49,7 +49,7 @@
49
49
  }
50
50
  }
51
51
  }
52
- `;class ri extends t.Component{constructor(){super(...arguments),this.ctx=document.createElement("canvas").getContext("2d")}get runtime(){return this.env.model.getters.getChartRuntime(this.env.model.getters.getActiveSheetId(),this.props.figure.id)}get title(){return this.runtime.title}get keyValue(){return this.runtime.keyValue}get baseline(){return this.runtime.baselineDisplay}get baselineDescr(){const e=this.runtime.baselineDescr||"";return this.baseline&&e?" "+e:e}get baselineArrowDirection(){return this.runtime.baselineArrow}get backgroundColor(){return this.runtime.background}get primaryFontColor(){return this.runtime.fontColor}get secondaryFontColor(){return pt(this.primaryFontColor)<=.3?"#757575":"#bbbbbb"}get figure(){return this.props.figure}get chartStyle(){return`\n padding:${this.chartPadding}px;\n background:${this.backgroundColor};\n `}get chartContentStyle(){return`\n height:${this.getDrawableHeight()}px;\n `}get chartPadding(){return.02*this.props.figure.width}getTextStyles(){const e=.96*this.props.figure.width,t=this.getWidestElement(),o=t.getElementMaxFontSize(this.getDrawableHeight(),this);let i=function(e,t,o,i=.25){let n=1;if(o(n)>e)return n;if(o(t)<e)return t;let r=(n+t)/2,s=o(r),a=0;for(;Math.abs(s-e)>i&&a<20;)s>=e?t=(n+t)/2:n=(n+t)/2,r=(n+t)/2,s=o(r),a++;return r}(e,o,(e=>t.getElementWidth(e,this.ctx,this)))/o;const n=(new ai).getElementMaxFontSize(this.getDrawableHeight(),this)*i,r=(new si).getElementMaxFontSize(this.getDrawableHeight(),this)*i;return{titleStyle:this.getTextStyle({fontSize:18,color:this.secondaryFontColor}),keyStyle:this.getTextStyle({fontSize:n,cellStyle:this.runtime.keyValueStyle,color:this.primaryFontColor}),baselineStyle:this.getTextStyle({fontSize:r}),baselineValueStyle:this.getTextStyle({fontSize:r,cellStyle:this.runtime.baselineStyle,color:this.runtime.baselineColor||this.secondaryFontColor}),baselineDescrStyle:this.getTextStyle({fontSize:.9*r,color:this.secondaryFontColor})}}getTextStyle(e){const t=oi(e.cellStyle);return t["font-size"]=`${e.fontSize}px`,t.display="inline-block",!t.color&&e.color&&(t.color=e.color),ii(t)}getDrawableHeight(){const e=2*this.chartPadding;let t=this.props.figure.height-e;return t-=this.title?18*ni:0,t}getWidestElement(){const e=new si,t=new ai;return e.getElementWidth(.35,this.ctx,this)>t.getElementWidth(.65,this.ctx,this)?e:t}}ri.template="o-spreadsheet-ScorecardChart";class si{getElementWidth(e,t,o){if(!o.runtime)return 0;const i=o.baseline,n="neutral"!==o.baselineArrowDirection?"A "+i:i;t.font=`${e}px ${G}`;let r=t.measureText(n).width;return t.font=`${.9*e}px ${G}`,r+=t.measureText(o.baselineDescr).width,r}getElementMaxFontSize(e,t){if(!t.runtime)return 0;return(""!==t.baseline||t.baselineDescr?.35*e:0)/ni}}class ai{getElementWidth(e,t,o){if(!o.runtime)return 0;const i=o.keyValue||"";return t.font=`${e}px ${G}`,t.measureText(i).width}getElementMaxFontSize(e,t){if(!t.runtime)return 0;return(""!==t.baseline||t.baselineDescr?.65*e:e)/ni}}function li(e){return 8===(e=ht(e).replace("#","")).length?e.slice(6)+e.slice(0,6):e}ri.props={figure:Object};class ci{constructor(e,t,o){this.title=e.title,this.sheetId=t,this.getters=o}static validateChartDefinition(e,t){throw new Error("This method should be implemented by sub class")}static transformDefinition(e,t){throw new Error("This method should be implemented by sub class")}static getDefinitionFromContextCreation(e){throw new Error("This method should be implemented by sub class")}}function hi(e,t){return"REMOVE_COLUMNS_ROWS"===t.type?No(e,"COL"===t.dimension?"left":"top",t.elements):"ADD_COLUMNS_ROWS"===t.type?Ao(e,"COL"===t.dimension?"left":"top",t.base,t.position,t.quantity):{...e}}var di,ui;!function(e){e.boolean="boolean",e.number="number",e.text="text",e.empty="empty",e.error="error"}(di||(di={})),function(e){e.PlainText="text/plain",e.Html="text/html"}(ui||(ui={}));const gi=new Set(["RENAME_SHEET","DELETE_SHEET","CREATE_SHEET","ADD_COLUMNS_ROWS","REMOVE_COLUMNS_ROWS","DELETE_CELL","INSERT_CELL","UNDO","REDO"]),pi=new Set([...gi,"DUPLICATE_SHEET","EVALUATE_CELLS","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","MOVE_CONDITIONAL_FORMAT"]),mi=new Set(["START","ACTIVATE_SHEET","COPY","PREPARE_SELECTION_INPUT_EXPANSION","STOP_SELECTION_INPUT","RESIZE_SHEETVIEW","SET_VIEWPORT_OFFSET","SELECT_SEARCH_NEXT_MATCH","SELECT_SEARCH_PREVIOUS_MATCH","REFRESH_SEARCH","UPDATE_SEARCH","CLEAR_SEARCH","EVALUATE_CELLS","SET_CURRENT_CONTENT","SET_FORMULA_VISIBILITY","OPEN_CELL_POPOVER","CLOSE_CELL_POPOVER","UPDATE_FILTER"]),fi=new Set(["UPDATE_CELL","UPDATE_CELL_POSITION","CLEAR_CELL","DELETE_CONTENT","ADD_COLUMNS_ROWS","REMOVE_COLUMNS_ROWS","RESIZE_COLUMNS_ROWS","HIDE_COLUMNS_ROWS","UNHIDE_COLUMNS_ROWS","SET_GRID_LINES_VISIBILITY","UNFREEZE_COLUMNS","UNFREEZE_ROWS","FREEZE_COLUMNS","FREEZE_ROWS","UNFREEZE_COLUMNS_ROWS","ADD_MERGE","REMOVE_MERGE","CREATE_SHEET","DELETE_SHEET","DUPLICATE_SHEET","MOVE_SHEET","RENAME_SHEET","HIDE_SHEET","SHOW_SHEET","MOVE_RANGES","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","MOVE_CONDITIONAL_FORMAT","CREATE_FIGURE","DELETE_FIGURE","UPDATE_FIGURE","SET_FORMATTING","CLEAR_FORMATTING","SET_BORDER","CREATE_CHART","UPDATE_CHART","CREATE_FILTER_TABLE","REMOVE_FILTER_TABLE","CREATE_IMAGE"]);function vi(e){return fi.has(e.type)}class bi{constructor(e=[]){Array.isArray(e)||(e=[e]),e=[...new Set(e)],this.reasons=e.filter((e=>0!==e))}static get Success(){return new bi}get isSuccessful(){return 0===this.reasons.length}isCancelledBecause(e){return this.reasons.includes(e)}}var Si,Ci,Ei;function wi(e,t,o,i){let n=!1;const r=[];for(let i in o){let s=o[i];if(s.labelCell){const e=Ii(s.labelCell,t);s.labelCell!==e&&(n=!0,s={...s,labelCell:e})}const a=Ii(s.dataRange,t);void 0===a||e.getRangeString(a,a.sheetId)===X?(n=!0,s=void 0):a!==s.dataRange&&(n=!0,s={...s,dataRange:a}),r[i]=s}let s=i;const a=Ii(s,t);a!==s&&(n=!0,s=a);return{isStale:n,dataSets:r.filter(Qe),labelRange:s}}function yi(e,t,o){return o.map((o=>({dataRange:Co(e,t,o.dataRange),labelCell:o.labelCell?Co(e,t,o.labelCell):void 0})))}function xi(e,t,o){return o?Co(e,t,o):void 0}function Ii(e,t){if(!e)return;const o=t(e);switch(o.changeType){case"NONE":return e;case"REMOVE":return;default:return o.range}}function Ri(e,t,o,i){const n=[];for(const r of t){const t=e.getRangeFromSheetXC(o,r),{unboundedZone:s,sheetId:a,invalidSheetName:l}=t;if(!l)if(s.left!==s.right&&s.top!==s.bottom){if(void 0===s.right)continue;for(let t=s.left;t<=s.right;t++){const o={...s,left:t,right:t};n.push(Ti(e,a,o,i?{top:o.top,bottom:o.top,left:o.left,right:o.left}:void 0))}}else s.left===s.right&&s.top===s.bottom?i||n.push(Ti(e,a,s,void 0)):n.push(Ti(e,a,s,i?{top:s.top,bottom:s.top,left:s.left,right:s.left}:void 0))}return n}function Ti(e,t,o,i){if(o.left!==o.right&&o.top!==o.bottom)throw new Error(`Zone should be a single column or row: ${To(o)}`);if(i){const n=To(o),r=To(i);return{labelCell:e.getRangeFromSheetXC(t,r),dataRange:e.getRangeFromSheetXC(t,n)}}return{labelCell:void 0,dataRange:e.getRangeFromSheetXC(t,To(o))}}function Ai(e,t){var o;const i=null===(o=t.labelCell)||void 0===o?void 0:o.zone;let n=t.dataRange.zone;if(i){const{height:e,width:t}=Vo(n);1===e?n={...n,left:n.left+1}:1===t&&(n={...n,top:n.top+1})}const r=t.dataRange.clone({zone:n});return{label:t.labelCell?e.getRangeString(t.labelCell,"forceSheetReference"):void 0,range:e.getRangeString(r,"forceSheetReference")}}function Oi(e,t){let o;if(e.labelRange){const i=hi(xo(e.labelRange),t);o=i?To(i):void 0}const i=e.dataSets.map(xo).map((e=>hi(e,t))).filter(Qe).map(To);return{...e,labelRange:o,dataSets:i}}e.CommandResult=void 0,(Si=e.CommandResult||(e.CommandResult={}))[Si.Success=0]="Success",Si[Si.CancelledForUnknownReason=1]="CancelledForUnknownReason",Si[Si.WillRemoveExistingMerge=2]="WillRemoveExistingMerge",Si[Si.MergeIsDestructive=3]="MergeIsDestructive",Si[Si.CellIsMerged=4]="CellIsMerged",Si[Si.InvalidTarget=5]="InvalidTarget",Si[Si.EmptyUndoStack=6]="EmptyUndoStack",Si[Si.EmptyRedoStack=7]="EmptyRedoStack",Si[Si.NotEnoughElements=8]="NotEnoughElements",Si[Si.NotEnoughSheets=9]="NotEnoughSheets",Si[Si.MissingSheetName=10]="MissingSheetName",Si[Si.DuplicatedSheetName=11]="DuplicatedSheetName",Si[Si.DuplicatedSheetId=12]="DuplicatedSheetId",Si[Si.ForbiddenCharactersInSheetName=13]="ForbiddenCharactersInSheetName",Si[Si.WrongSheetMove=14]="WrongSheetMove",Si[Si.WrongSheetPosition=15]="WrongSheetPosition",Si[Si.InvalidAnchorZone=16]="InvalidAnchorZone",Si[Si.SelectionOutOfBound=17]="SelectionOutOfBound",Si[Si.TargetOutOfSheet=18]="TargetOutOfSheet",Si[Si.WrongCutSelection=19]="WrongCutSelection",Si[Si.WrongPasteSelection=20]="WrongPasteSelection",Si[Si.WrongPasteOption=21]="WrongPasteOption",Si[Si.WrongFigurePasteOption=22]="WrongFigurePasteOption",Si[Si.EmptyClipboard=23]="EmptyClipboard",Si[Si.EmptyRange=24]="EmptyRange",Si[Si.InvalidRange=25]="InvalidRange",Si[Si.InvalidZones=26]="InvalidZones",Si[Si.InvalidSheetId=27]="InvalidSheetId",Si[Si.DuplicatedImageId=28]="DuplicatedImageId",Si[Si.InputAlreadyFocused=29]="InputAlreadyFocused",Si[Si.MaximumRangesReached=30]="MaximumRangesReached",Si[Si.InvalidChartDefinition=31]="InvalidChartDefinition",Si[Si.InvalidDataSet=32]="InvalidDataSet",Si[Si.InvalidLabelRange=33]="InvalidLabelRange",Si[Si.InvalidScorecardKeyValue=34]="InvalidScorecardKeyValue",Si[Si.InvalidScorecardBaseline=35]="InvalidScorecardBaseline",Si[Si.InvalidGaugeDataRange=36]="InvalidGaugeDataRange",Si[Si.EmptyGaugeRangeMin=37]="EmptyGaugeRangeMin",Si[Si.GaugeRangeMinNaN=38]="GaugeRangeMinNaN",Si[Si.EmptyGaugeRangeMax=39]="EmptyGaugeRangeMax",Si[Si.GaugeRangeMaxNaN=40]="GaugeRangeMaxNaN",Si[Si.GaugeRangeMinBiggerThanRangeMax=41]="GaugeRangeMinBiggerThanRangeMax",Si[Si.GaugeLowerInflectionPointNaN=42]="GaugeLowerInflectionPointNaN",Si[Si.GaugeUpperInflectionPointNaN=43]="GaugeUpperInflectionPointNaN",Si[Si.GaugeLowerBiggerThanUpper=44]="GaugeLowerBiggerThanUpper",Si[Si.InvalidAutofillSelection=45]="InvalidAutofillSelection",Si[Si.WrongComposerSelection=46]="WrongComposerSelection",Si[Si.MinBiggerThanMax=47]="MinBiggerThanMax",Si[Si.LowerBiggerThanUpper=48]="LowerBiggerThanUpper",Si[Si.MidBiggerThanMax=49]="MidBiggerThanMax",Si[Si.MinBiggerThanMid=50]="MinBiggerThanMid",Si[Si.FirstArgMissing=51]="FirstArgMissing",Si[Si.SecondArgMissing=52]="SecondArgMissing",Si[Si.MinNaN=53]="MinNaN",Si[Si.MidNaN=54]="MidNaN",Si[Si.MaxNaN=55]="MaxNaN",Si[Si.ValueUpperInflectionNaN=56]="ValueUpperInflectionNaN",Si[Si.ValueLowerInflectionNaN=57]="ValueLowerInflectionNaN",Si[Si.MinInvalidFormula=58]="MinInvalidFormula",Si[Si.MidInvalidFormula=59]="MidInvalidFormula",Si[Si.MaxInvalidFormula=60]="MaxInvalidFormula",Si[Si.ValueUpperInvalidFormula=61]="ValueUpperInvalidFormula",Si[Si.ValueLowerInvalidFormula=62]="ValueLowerInvalidFormula",Si[Si.InvalidSortZone=63]="InvalidSortZone",Si[Si.WaitingSessionConfirmation=64]="WaitingSessionConfirmation",Si[Si.MergeOverlap=65]="MergeOverlap",Si[Si.TooManyHiddenElements=66]="TooManyHiddenElements",Si[Si.Readonly=67]="Readonly",Si[Si.InvalidViewportSize=68]="InvalidViewportSize",Si[Si.InvalidScrollingDirection=69]="InvalidScrollingDirection",Si[Si.FigureDoesNotExist=70]="FigureDoesNotExist",Si[Si.InvalidConditionalFormatId=71]="InvalidConditionalFormatId",Si[Si.InvalidCellPopover=72]="InvalidCellPopover",Si[Si.EmptyTarget=73]="EmptyTarget",Si[Si.InvalidFreezeQuantity=74]="InvalidFreezeQuantity",Si[Si.FrozenPaneOverlap=75]="FrozenPaneOverlap",Si[Si.ValuesNotChanged=76]="ValuesNotChanged",Si[Si.InvalidFilterZone=77]="InvalidFilterZone",Si[Si.FilterOverlap=78]="FilterOverlap",Si[Si.FilterNotFound=79]="FilterNotFound",Si[Si.MergeInFilter=80]="MergeInFilter",Si[Si.NonContinuousTargets=81]="NonContinuousTargets",Si[Si.DuplicatedFigureId=82]="DuplicatedFigureId",Si[Si.InvalidSelectionStep=83]="InvalidSelectionStep",Si[Si.DuplicatedChartId=84]="DuplicatedChartId",function(e){e.UP="up",e.DOWN="down",e.LEFT="left",e.RIGHT="right"}(Ci||(Ci={})),function(e){e[e.Background=0]="Background",e[e.Highlights=1]="Highlights",e[e.Clipboard=2]="Clipboard",e[e.Search=3]="Search",e[e.Chart=4]="Chart",e[e.Autofill=5]="Autofill",e[e.Selection=6]="Selection",e[e.Headers=7]="Headers"}(Ei||(Ei={}));const Mi=["rgb(31,119,180)","rgb(255,127,14)","rgb(174,199,232)","rgb(255,187,120)","rgb(44,160,44)","rgb(152,223,138)","rgb(214,39,40)","rgb(255,152,150)","rgb(148,103,189)","rgb(197,176,213)","rgb(140,86,75)","rgb(196,156,148)","rgb(227,119,194)","rgb(247,182,210)","rgb(127,127,127)","rgb(199,199,199)","rgb(188,189,34)","rgb(219,219,141)","rgb(23,190,207)","rgb(158,218,229)"];class Ni{constructor(){this.graphColorIndex=0}next(){return Mi[this.graphColorIndex++%Mi.length]}}function _i(e){return e&&pt(e)<.3?"#FFFFFF":"#000000"}function Fi(e){if(e.dataSets){const t=void 0!==e.dataSets.find((e=>!xt.test(e)));if(t)return 32;if(e.dataSets.map(xo).some((e=>e.top!==e.bottom&&Zo(e))))return 32}return 0}function Di(e){if(e.labelRange){if(!xt.test(e.labelRange||""))return 33}return 0}function ki(e,t,o){if(e){if("text"===o||(null==t?void 0:t.type)!==di.number||e.type!==di.number)return e.formattedValue;{let i=t.value-e.value;if("percentage"===o&&0!==i&&(i=i/e.value*100),"percentage"!==o&&e.format)return oo(i,e.format);const n=Math.abs(parseFloat(i.toFixed(2))).toLocaleString();return"percentage"===o?n+"%":n}}return""}function $i(e,t,o,i,n){if("text"===t||(null==e?void 0:e.type)!==di.number||(null==o?void 0:o.type)!==di.number)return;const r=o.value-e.value;return r>0?i:r<0?n:void 0}function Pi(e,t,o){if("text"===o||(null==e?void 0:e.type)!==di.number||(null==t?void 0:t.type)!==di.number)return"neutral";const i=t.value-e.value;return i>0?"up":i<0?"down":"neutral"}const Li={Errors:{25:r("The range is invalid"),51:r("The argument is missing. Please provide a value"),52:r("The second argument is missing. Please provide a value"),53:r("The minpoint must be a number"),54:r("The midpoint must be a number"),55:r("The maxpoint must be a number"),56:r("The first value must be a number"),57:r("The second value must be a number"),47:r("Minimum must be smaller then Maximum"),50:r("Minimum must be smaller then Midpoint"),49:r("Midpoint must be smaller then Maximum"),48:r("Lower inflection point must be smaller than upper inflection point"),58:r("Invalid Minpoint formula"),60:r("Invalid Maxpoint formula"),59:r("Invalid Midpoint formula"),61:r("Invalid upper inflection point formula"),62:r("Invalid lower inflection point formula"),24:r("A range needs to be defined"),Unexpected:r("The rule is invalid for an unknown reason")},ColorScale:r("Color scale"),IconSet:r("Icon set")},Ui={IsEmpty:r("Is empty"),IsNotEmpty:r("Is not empty"),ContainsText:r("Contains"),NotContains:r("Does not contain"),BeginsWith:r("Starts with"),EndsWith:r("Ends with"),Equal:r("Is equal to"),NotEqual:r("Is not equal to"),GreaterThan:r("Is greater than"),GreaterThanOrEqual:r("Is greater than or equal to"),LessThan:r("Is less than"),LessThanOrEqual:r("Is less than or equal to"),Between:r("Is between"),NotBetween:r("Is not between")},Vi={Series:r("Series"),Errors:{Unexpected:r("The chart definition is invalid for an unknown reason"),32:r("The dataset is invalid"),33:r("Labels are invalid"),34:r("The key value is invalid"),35:r("The baseline value is invalid"),36:r("The data range is invalid"),37:r("A minimum range limit value is needed"),38:r("The minimum range limit value must be a number"),39:r("A maximum range limit value is needed"),40:r("The maximum range limit value must be a number"),41:r("Minimum range limit must be smaller than maximum range limit"),42:r("The lower inflection point value must be a number"),43:r("The upper inflection point value must be a number")}},zi={Automatic:r("Automatic"),Number:r("Number"),Percent:r("Percent"),Currency:r("Currency"),CurrencyRounded:r("Currency rounded"),Date:r("Date"),Time:r("Time"),DateTime:r("Date time"),Duration:r("Duration"),CustomCurrency:r("Custom currency")},Bi={Custom:r("Custom")},Hi=r("Merged cells are preventing this operation. Unmerge those cells and try again.");function Wi(e,t){if(t.dataRange){const o=t.labelCell?[To(t.labelCell.zone)]:[],i=Lo([To(t.dataRange.zone)],o)[0];if(void 0===i)return[];const n=e.getRangeFromSheetXC(t.dataRange.sheetId,i);return e.getRangeValues(n).map((e=>""===e?void 0:e))}return[]}function Gi(e,t){const o=Le(0,Math.max(e.length,...t.map((e=>{var t;return(null===(t=e.data)||void 0===t?void 0:t.length)||0})))).filter((o=>{const i=e[o],n=t.map((e=>{var t;return null===(t=e.data)||void 0===t?void 0:t[o]}));return i||n.some((e=>0===e||Boolean(e)))}));return{labels:o.map((t=>e[t]||"")),dataSetsValues:t.map((e=>({...e,data:o.map((t=>e.data[t]))})))}}function qi(e,t){const o=new Set(e),i={};o.forEach((e=>{i[e]=new Array(t.length).fill(0)}));for(const o of Le(0,e.length)){const r=e[o];for(const e of Le(0,t.length))i[r][e]+="number"==typeof(n=t[e].data[o])?n:0}var n;return{labels:Object.keys(i),dataSetsValues:t.map(((e,t)=>({...e,data:Object.values(i).map((e=>e[t]))})))}}function Zi(e){return e?e.length>K?e.substring(0,K)+"…":e:""}function ji(e,t,o){return{type:e.type,options:{responsive:!0,maintainAspectRatio:!1,layout:{padding:{left:20,right:20,top:e.title?10:25,bottom:10}},elements:{line:{fill:!1},point:{hitRadius:15}},animation:{duration:0},hover:{animationDuration:10},responsiveAnimationDuration:0,title:{display:!!e.title,fontSize:22,fontStyle:"normal",text:n(e.title),fontColor:o},legend:{onClick:void 0}},data:{labels:t.map(Zi),datasets:[]}}}function Xi(e,t,o){let i={values:[],formattedValues:[]};if(o)o.invalidXc||o.invalidSheetName||(i={formattedValues:e.getRangeFormattedValues(o),values:e.getRangeValues(o).map((e=>String(e)))});else if(1===t.length)for(let o=0;o<Wi(e,t[0]).length;o++)i.formattedValues.push(""),i.values.push("");else if(t[0]){i={formattedValues:Le(0,Wi(e,t[0]).length).map((e=>e.toString())),values:i.formattedValues}}return i}function Yi(e,t){const o=[];for(const[i,n]of Object.entries(t)){let t;if(n.labelCell){const o=n.labelCell,r=o?e.getEvaluatedCell({sheetId:o.sheetId,col:o.zone.left,row:o.zone.top}):void 0;t=r&&o?Zi(r.formattedValue):t=`${Vi.Series} ${parseInt(i)+1}`}else t=t=`${Vi.Series} ${parseInt(i)+1}`;let r=n.dataRange?Wi(e,n):[];o.push({data:r,label:t})}return o}function Ki(e){return 0===e?"origin":e-1}class Qi extends ci{constructor(e,t,o){super(e,t,o),this.type="bar",this.dataSets=Ri(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Eo(o,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.stacked=e.stacked,this.aggregated=e.aggregated}static transformDefinition(e,t){return Oi(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,Fi,Di)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,stacked:!1,aggregated:!1,legendPosition:"top",title:e.title||"",type:"bar",verticalAxisPosition:"left",labelRange:e.auxiliaryRange||void 0}}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}copyForSheetId(e){const t=yi(this.sheetId,e,this.dataSets),o=xi(this.sheetId,e,this.labelRange),i=this.getDefinitionWithSpecificDataSets(t,o,e);return new Qi(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new Qi(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){return{type:"bar",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,o||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,stacked:this.stacked,aggregated:this.aggregated}}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>Ai(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:li(this.background||w),fontColor:li(_i(this.background)),dataSets:e}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:i}=wi(this.getters,e,this.dataSets,this.labelRange);if(!i)return this;const n=this.getDefinitionWithSpecificDataSets(t,o);return new Qi(n,this.sheetId,this.getters)}}function Ji(e){return e.dataRange&&!xt.test(e.dataRange)?36:0}function en(e,t){return t((t=>t.sectionRule?e(t.sectionRule.rangeMin,"rangeMin"):0),(t=>t.sectionRule?e(t.sectionRule.rangeMax,"rangeMax"):0))}function tn(e){return e.sectionRule&&Number(e.sectionRule.rangeMin)>=Number(e.sectionRule.rangeMax)?41:0}function on(e,t){if(""===e)switch(t){case"rangeMin":return 37;case"rangeMax":return 39}return 0}function nn(e,t){if(isNaN(e))switch(t){case"rangeMin":return 38;case"rangeMax":return 40;case"lowerInflectionPointValue":return 42;case"upperInflectionPointValue":return 43}return 0}class rn extends ci{constructor(e,t,o){super(e,t,o),this.type="gauge",this.dataRange=Eo(this.getters,this.sheetId,e.dataRange),this.sectionRule=e.sectionRule,this.background=e.background}static validateChartDefinition(e,t){return e.checkValidations(t,Ji,e.chainValidations(en(on,e.batchValidations),en(nn,e.batchValidations),tn),e.chainValidations((o=nn,(0,e.batchValidations)((e=>e.sectionRule?o(e.sectionRule.lowerInflectionPoint.value,"lowerInflectionPointValue"):0),(e=>e.sectionRule?o(e.sectionRule.upperInflectionPoint.value,"upperInflectionPointValue"):0)))));var o}static transformDefinition(e,t){let o;return e.dataRange&&(o=hi(xo(e.dataRange),t)),{...e,dataRange:o?To(o):void 0}}static getDefinitionFromContextCreation(e){return{background:e.background,title:e.title||"",type:"gauge",dataRange:e.range?e.range[0]:void 0,sectionRule:{colors:{lowerColor:"#cc0000",middleColor:"#f1c232",upperColor:"#6aa84f"},rangeMin:"0",rangeMax:"100",lowerInflectionPoint:{type:"percentage",value:"15"},upperInflectionPoint:{type:"percentage",value:"40"}}}}copyForSheetId(e){const t=xi(this.sheetId,e,this.dataRange),o=this.getDefinitionWithSpecificRanges(t,e);return new rn(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.dataRange,e);return new rn(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.dataRange)}getDefinitionWithSpecificRanges(e,t){return{background:this.background,sectionRule:this.sectionRule,title:this.title,type:"gauge",dataRange:e?this.getters.getRangeString(e,t||this.sheetId):void 0}}getDefinitionForExcel(){}getContextCreation(){return{background:this.background,title:this.title,range:this.dataRange?[this.getters.getRangeString(this.dataRange,this.sheetId)]:void 0}}updateRanges(e){const t=Ii(this.dataRange,e);if(this.dataRange===t)return this;const o=this.getDefinitionWithSpecificRanges(t);return new rn(o,this.sheetId,this.getters)}}const sn={second:1e3,minute:6e4,hour:36e5,day:864e5,month:2592e6,year:31536e6},an={inSeconds:function(e){return Math.floor(e/sn.second)},inMinutes:function(e){return Math.floor(e/sn.minute)},inHours:function(e){return Math.floor(e/sn.hour)},inDays:function(e){return Math.floor(e/sn.day)},inMonths:function(e){return Math.floor(e/sn.month)},inYears:function(e){return Math.floor(e/sn.year)}},ln=/^((d|dd|m|mm|yyyy|yy|hh|h|ss|a)(-|:|\s|\/))*(d|dd|m|mm|yyyy|yy|hh|h|ss|a)$/i;function cn(e,t){const o=function(e){const t=(e=(e=e.replace(/y/g,"Y")).replace(/d/g,"D")).indexOf("h");e=t>=0?e.slice(0,t).replace(/m/g,"M")+e.slice(t):e.replace(/m/g,"M");e.includes("a")||(e=e.replace(/h/g,"H"));return e}(t),i=function(e,t){const o=e.map((e=>{var t;return null===(t=be(e))||void 0===t?void 0:t.jsDate}));if(o.some((e=>void 0===e))||e.length<2)return;const i=o.map((e=>e.getTime())),n=Math.max(...i)-Math.min(...i),r=function(e){if(e.includes("s"))return"second";if(e.includes("m"))return"minute";if(e.includes("h")||e.includes("H"))return"hour";if(e.includes("D"))return"day";if(e.includes("M"))return"month";return"year"}(t);if(sn.second>=sn[r]&&an.inSeconds(n)<180)return"second";if(sn.minute>=sn[r]&&an.inMinutes(n)<180)return"minute";if(sn.hour>=sn[r]&&an.inHours(n)<96)return"hour";if(sn.day>=sn[r]&&an.inDays(n)<90)return"day";if(sn.month>=sn[r]&&an.inMonths(n)<36)return"month";return"year"}(e,o),n={};return i&&(n[i]=o),{parser:o,displayFormats:n,unit:i}}class hn extends ci{constructor(e,t,o){super(e,t,o),this.type="line",this.dataSets=Ri(this.getters,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Eo(this.getters,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.labelsAsText=e.labelsAsText,this.stacked=e.stacked,this.aggregated=e.aggregated}static validateChartDefinition(e,t){return e.checkValidations(t,Fi,Di)}static transformDefinition(e,t){return Oi(e,t)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,labelsAsText:!1,legendPosition:"top",title:e.title||"",type:"line",verticalAxisPosition:"left",labelRange:e.auxiliaryRange||void 0,stacked:!1,aggregated:!1}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){return{type:"line",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,o||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,labelsAsText:this.labelsAsText,stacked:this.stacked,aggregated:this.aggregated}}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:i}=wi(this.getters,e,this.dataSets,this.labelRange);if(!i)return this;const n=this.getDefinitionWithSpecificDataSets(t,o);return new hn(n,this.sheetId,this.getters)}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>Ai(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:li(this.background||w),fontColor:li(_i(this.background)),dataSets:e}}copyForSheetId(e){const t=yi(this.sheetId,e,this.dataSets),o=xi(this.sheetId,e,this.labelRange),i=this.getDefinitionWithSpecificDataSets(t,o,e);return new hn(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new hn(t,e,this.getters)}}function dn(e,t){return gn(e,t)||pn(e,t)}function un(e,t){return function(e,t){return!e.labelsAsText&&gn(e.labelRange,t)}(e,t)?"time":function(e,t){return!e.labelsAsText&&pn(e.labelRange,t)}(e,t)?"linear":"category"}function gn(e,t){if(!e||!pn(e,t))return!1;const o=t.getEvaluatedCell({sheetId:e.sheetId,col:e.zone.left,row:e.zone.top}).format;return Boolean(o&&ln.test(o))}function pn(e,t){if(!e)return!1;const o=t.getRangeValues(e);return!o.some((e=>isNaN(Number(e))&&e))&&!o.every((e=>!e))}class mn extends ci{constructor(e,t,o){super(e,t,o),this.type="pie",this.dataSets=Ri(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Eo(o,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.aggregated=e.aggregated}static transformDefinition(e,t){return Oi(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,Fi,Di)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,legendPosition:"top",title:e.title||"",type:"pie",labelRange:e.auxiliaryRange||void 0,aggregated:!1}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}getDefinitionWithSpecificDataSets(e,t,o){return{type:"pie",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,o||this.sheetId))),legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,aggregated:this.aggregated}}copyForSheetId(e){const t=yi(this.sheetId,e,this.dataSets),o=xi(this.sheetId,e,this.labelRange),i=this.getDefinitionWithSpecificDataSets(t,o,e);return new mn(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new mn(t,e,this.getters)}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>Ai(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:li(this.background||w),fontColor:li(_i(this.background)),verticalAxisPosition:"left",dataSets:e}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:i}=wi(this.getters,e,this.dataSets,this.labelRange);if(!i)return this;const n=this.getDefinitionWithSpecificDataSets(t,o);return new mn(n,this.sheetId,this.getters)}}function fn(e,t){const o=[],i=Math.max(...t.map((e=>e.data.length)));for(let t=0;t<=i;t++)o.push(e.next());return o}function vn(e){return e.keyValue&&!xt.test(e.keyValue)?34:0}function bn(e){return e.baseline&&!xt.test(e.baseline)?35:0}class Sn extends ci{constructor(e,t,o){super(e,t,o),this.type="scorecard",this.keyValue=Eo(o,t,e.keyValue),this.baseline=Eo(o,t,e.baseline),this.baselineMode=e.baselineMode,this.baselineDescr=e.baselineDescr,this.background=e.background,this.baselineColorUp=e.baselineColorUp,this.baselineColorDown=e.baselineColorDown}static validateChartDefinition(e,t){return e.checkValidations(t,vn,bn)}static getDefinitionFromContextCreation(e){return{background:e.background,type:"scorecard",keyValue:e.range?e.range[0]:void 0,title:e.title||"",baselineMode:J,baselineColorUp:ee,baselineColorDown:te,baseline:e.auxiliaryRange||""}}static transformDefinition(e,t){let o,i;return e.baseline&&(o=hi(xo(e.baseline),t)),e.keyValue&&(i=hi(xo(e.keyValue),t)),{...e,baseline:o?To(o):void 0,keyValue:i?To(i):void 0}}copyForSheetId(e){const t=xi(this.sheetId,e,this.baseline),o=xi(this.sheetId,e,this.keyValue),i=this.getDefinitionWithSpecificRanges(t,o,e);return new Sn(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue,e);return new Sn(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue)}getContextCreation(){return{background:this.background,title:this.title,range:this.keyValue?[this.getters.getRangeString(this.keyValue,this.sheetId)]:void 0,auxiliaryRange:this.baseline?this.getters.getRangeString(this.baseline,this.sheetId):void 0}}getDefinitionWithSpecificRanges(e,t,o){return{baselineColorDown:this.baselineColorDown,baselineColorUp:this.baselineColorUp,baselineMode:this.baselineMode,title:this.title,type:"scorecard",background:this.background,baseline:e?this.getters.getRangeString(e,o||this.sheetId):void 0,baselineDescr:this.baselineDescr,keyValue:t?this.getters.getRangeString(t,o||this.sheetId):void 0}}getDefinitionForExcel(){}updateRanges(e){const t=Ii(this.baseline,e),o=Ii(this.keyValue,e);if(this.baseline===t&&this.keyValue===o)return this;const i=this.getDefinitionWithSpecificRanges(t,o);return new Sn(i,this.sheetId,this.getters)}}class Cn{constructor(){this.content={}}add(e,t){return this.content[e]=t,this}get(e){const t=this.content[e];if(!t&&!(e in this.content))throw new Error(`Cannot find ${e} in this registry!`);return t}contains(e){return e in this.content}getAll(){return Object.values(this.content)}getKeys(){return Object.keys(this.content)}remove(e){delete this.content[e]}}const En=new Cn;En.add("bar",{match:e=>"bar"===e,createChart:(e,t,o)=>new Qi(e,t,o),getChartRuntime:function(e,t){let o=Xi(t,e.dataSets,e.labelRange).formattedValues,i=Yi(t,e.dataSets);({labels:o,dataSetsValues:i}=Gi(o,i)),e.aggregated&&({labels:o,dataSetsValues:i}=qi(o,i));const n=function(e,t){var o;const i=_i(e.background),n=ji(e,t,i),r={labels:{fontColor:i}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,n.options.legend={...null===(o=n.options)||void 0===o?void 0:o.legend,...r},n.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},n.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2,fontColor:i}}],yAxes:[{position:e.verticalAxisPosition,ticks:{fontColor:i,beginAtZero:!0}}]},e.stacked&&(n.options.scales.xAxes[0].stacked=!0,n.options.scales.yAxes[0].stacked=!0),n}(e,o),r=new Ni;for(let{label:e,data:t}of i){const o=r.next(),i={label:e,data:t,borderColor:o,backgroundColor:o};n.data.datasets.push(i)}return{chartJsConfig:n,background:e.background||w}},validateChartDefinition:(e,t)=>Qi.validateChartDefinition(e,t),transformDefinition:(e,t)=>Qi.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Qi.getDefinitionFromContextCreation(e),name:r("Bar")}),En.add("line",{match:e=>"line"===e,createChart:(e,t,o)=>new hn(e,t,o),getChartRuntime:function(e,t){const o=un(e,t),i=Xi(t,e.dataSets,e.labelRange);let n="linear"===o?i.values:i.formattedValues,r=Yi(t,e.dataSets);({labels:n,dataSetsValues:r}=Gi(n,r)),"time"===o&&({labels:n,dataSetsValues:r}=function(e,t){if(0===e.length||e.every((e=>!e)))return{labels:e,dataSetsValues:t};const o=[...e],i=Me(t);for(let e=0;e<o.length;e++)if(!o[e]){o[e]=it(o,e);for(let t of i)t.data[e]=void 0}return{labels:o,dataSetsValues:i}}(n,r)),e.aggregated&&({labels:n,dataSetsValues:r}=qi(n,r));const s=function(e,t){var o;const i=_i(e.background),n=ji(e,t,i),r={labels:{fontColor:i,generateLabels(e){const{data:t}=e,o=window.Chart.defaults.global.legend.labels.generateLabels(e);for(const[e,i]of o.entries())i.fillStyle=t.datasets[e].borderColor;return o}}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,n.options.legend={...null===(o=n.options)||void 0===o?void 0:o.legend,...r},n.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},n.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2,fontColor:i}}],yAxes:[{position:e.verticalAxisPosition,ticks:{fontColor:i,beginAtZero:!0}}]},e.stacked&&(n.options.scales.yAxes[0].stacked=!0),n}(e,n),a=function(e,t){if(t)return e.getEvaluatedCell({sheetId:t.sheetId,col:t.zone.left,row:t.zone.top}).format}(t,e.labelRange);"time"===o?(s.options.scales.xAxes[0].type="time",s.options.scales.xAxes[0].time=cn(n,a),s.options.scales.xAxes[0].ticks.maxTicksLimit=15):"linear"===o&&(s.options.scales.xAxes[0].type="linear",s.options.scales.xAxes[0].ticks.callback=e=>oo(e,a));const l=new Ni;for(let[t,{label:i,data:a}]of r.entries()){["linear","time"].includes(o)&&(a=a.map(((e,t)=>({x:n[t]||void 0,y:e}))));const r=l.next();let c=ft(r);e.stacked&&(c.a=oe);const h={label:i,data:a,lineTension:0,borderColor:r,backgroundColor:mt(c),pointBackgroundColor:r,fill:!!e.stacked&&Ki(t)};s.data.datasets.push(h)}return{chartJsConfig:s,background:e.background||w}},validateChartDefinition:(e,t)=>hn.validateChartDefinition(e,t),transformDefinition:(e,t)=>hn.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>hn.getDefinitionFromContextCreation(e),name:r("Line")}),En.add("pie",{match:e=>"pie"===e,createChart:(e,t,o)=>new mn(e,t,o),getChartRuntime:function(e,t){let o=Xi(t,e.dataSets,e.labelRange).formattedValues,i=Yi(t,e.dataSets);({labels:o,dataSetsValues:i}=Gi(o,i)),e.aggregated&&({labels:o,dataSetsValues:i}=qi(o,i));const n=function(e,t){var o;const i=_i(e.background),n=ji(e,t,i),r={labels:{fontColor:i}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,n.options.legend={...null===(o=n.options)||void 0===o?void 0:o.legend,...r},n.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},n.options.tooltips={callbacks:{title:function(e,t){return t.datasets[e[0].datasetIndex].label}}},n}(e,o),r=new Ni;for(let{label:e,data:t}of i){const o={label:e,data:t,borderColor:"#FFFFFF",backgroundColor:fn(r,i)};n.data.datasets.push(o)}return{chartJsConfig:n,background:e.background||w}},validateChartDefinition:(e,t)=>mn.validateChartDefinition(e,t),transformDefinition:(e,t)=>mn.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>mn.getDefinitionFromContextCreation(e),name:r("Pie")}),En.add("scorecard",{match:e=>"scorecard"===e,createChart:(e,t,o)=>new Sn(e,t,o),getChartRuntime:function(e,t){let o,i,r="",s="";if(e.keyValue){const i={sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top};o=t.getEvaluatedCell(i),r=String(o.value),s=o.formattedValue}const a=e.baseline;if(a){const o={sheetId:e.baseline.sheetId,col:e.baseline.zone.left,row:e.baseline.zone.top};i=t.getEvaluatedCell(o)}const l=t.getBackgroundOfSingleCellChart(e.background,e.keyValue);return{title:n(e.title),keyValue:s||r,baselineDisplay:ki(i,o,e.baselineMode),baselineArrow:Pi(i,o,e.baselineMode),baselineColor:$i(i,e.baselineMode,o,e.baselineColorUp,e.baselineColorDown),baselineDescr:e.baselineDescr?n(e.baselineDescr):"",fontColor:_i(l),background:l,baselineStyle:"percentage"!==e.baselineMode&&a?t.getCellStyle({sheetId:a.sheetId,col:a.zone.left,row:a.zone.top}):void 0,keyValueStyle:e.keyValue?t.getCellStyle({sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top}):void 0}},validateChartDefinition:(e,t)=>Sn.validateChartDefinition(e,t),transformDefinition:(e,t)=>Sn.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Sn.getDefinitionFromContextCreation(e),name:r("Scorecard")}),En.add("gauge",{match:e=>"gauge"===e,createChart:(e,t,o)=>new rn(e,t,o),getChartRuntime:function(e,t){const o=function(e){const t=ji(e,[],_i(e.background));return t.options.hover=void 0,t.options.events=[],t.options.layout={padding:{left:30,right:30,top:e.title?10:25,bottom:25}},t.options.needle={radiusPercentage:2,widthPercentage:3.2,lengthPercentage:80,color:"#000000"},t.options.valueLabel={display:!1,formatter:null,color:"#FFFFFF",backgroundColor:"#000000",fontSize:30,borderRadius:5,padding:{top:5,right:5,bottom:5,left:5},bottomMarginPercentage:5},t}(e),i=e.sectionRule.colors,n=e.sectionRule.lowerInflectionPoint,r=e.sectionRule.upperInflectionPoint,s=Number(n.value),a=Number(r.value),l=Number(e.sectionRule.rangeMin),c=Number(e.sectionRule.rangeMax),h=c-l,d=[];if(""!==n.value){const e="number"===n.type?s:l+h*s/100;d.push({value:Fe(e,l,c),color:i.lowerColor})}if(""!==r.value){const e="number"===r.type?a:l+h*a/100;d.push({value:Fe(e,l,c),color:i.middleColor})}const u=[],g=[];d.sort(((e,t)=>e.value-t.value)).map((e=>{u.push(e.value),g.push(e.color)})),u.push(c),g.push(i.upperColor);const p=e.dataRange,m=h/30;let f=l-m,v=null,b=!1;if(void 0!==p){const e=t.getEvaluatedCell({sheetId:p.sheetId,col:p.zone.left,row:p.zone.top});e.type===di.number&&(f=Fe(e.value,l-m,c+m),v=()=>t.getRangeFormattedValues(p)[0],b=!0)}return o.options.valueLabel.display=b,o.options.valueLabel.formatter=v,o.data.datasets.push({data:u,minValue:Number(e.sectionRule.rangeMin),value:f,backgroundColor:g}),{chartJsConfig:o,background:t.getBackgroundOfSingleCellChart(e.background,p)}},validateChartDefinition:(e,t)=>rn.validateChartDefinition(e,t),transformDefinition:(e,t)=>rn.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>rn.getDefinitionFromContextCreation(e),name:r("Gauge")});const wn=new Cn;wn.add("line",Yo),wn.add("bar",Yo),wn.add("pie",Yo),wn.add("gauge",Yo),wn.add("scorecard",ri);const yn=e=>({isVisible:()=>!0,isEnabled:()=>!0,isReadonlyAllowed:!1,description:"",action:!1,children:[],separator:!1,icon:!1,id:e});function xn(e,t){return Object.assign({},yn(e),t)}function In(e){return"function"!=typeof e}class Rn extends Cn{add(e,t){return this.content[e]=xn(e,t),this}addChild(e,t,o){const i=t.splice(0,1)[0];let n=this.content[i];if(!n)throw new Error(`Path ${i+":"+t.join(":")} not found`);for(let e of t)if(n=n.children.filter(In).find((t=>t.id===e)),!n)throw new Error(`Path ${i+":"+t.join(":")} not found`);return"function"!=typeof o?n.children.push(xn(e,o)):n.children.push(o),this}getAll(){return super.getAll().sort(((e,t)=>e.sequence-t.sequence))}}function Tn(){const e=t.useState({x:0,y:0,width:0,height:0});let o=document.querySelector(".o-spreadsheet");function i(){if(o||(o=document.querySelector(".o-spreadsheet")),o){const{top:t,left:i,width:n,height:r}=o.getBoundingClientRect();e.x=i,e.y=t,e.width=n,e.height=r}}return i(),t.onMounted(i),t.onPatched(i),e}function An(e){const o=t.useState({x:0,y:0});function i(){const t=e.el;if(null===t)return;const{top:i,left:n}=t.getBoundingClientRect();n===o.x&&i===o.y||(o.x=n,o.y=i)}return t.onMounted(i),t.onPatched(i),o}function On(e,t){const o=[];for(const i of e.children)"function"==typeof i?o.push(...i(t)):o.push(i);return o.sort(((e,t)=>e.sequence-t.sequence))}function Mn(e,t){return"function"==typeof e.name?e.name(t):e.name}function Nn(){const e=document.querySelector(".o-grid-overlay");if(e){const{top:t,left:o}=null==e?void 0:e.getBoundingClientRect();return{top:t,left:o}}throw new Error("Can't find spreadsheet position")}function _n(e,t){return(o=Fo(Fn(e),Fn(t)))?{x:o.left,y:o.top,width:o.right-o.left,height:o.bottom-o.top}:void 0;var o}function Fn(e){return{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height}}Jo`
52
+ `;class ri extends t.Component{constructor(){super(...arguments),this.ctx=document.createElement("canvas").getContext("2d")}get runtime(){return this.env.model.getters.getChartRuntime(this.env.model.getters.getActiveSheetId(),this.props.figure.id)}get title(){return this.runtime.title}get keyValue(){return this.runtime.keyValue}get baseline(){return this.runtime.baselineDisplay}get baselineDescr(){const e=this.runtime.baselineDescr||"";return this.baseline&&e?" "+e:e}get baselineArrowDirection(){return this.runtime.baselineArrow}get backgroundColor(){return this.runtime.background}get primaryFontColor(){return this.runtime.fontColor}get secondaryFontColor(){return pt(this.primaryFontColor)<=.3?"#757575":"#bbbbbb"}get figure(){return this.props.figure}get chartStyle(){return`\n padding:${this.chartPadding}px;\n background:${this.backgroundColor};\n `}get chartContentStyle(){return`\n height:${this.getDrawableHeight()}px;\n `}get chartPadding(){return.02*this.props.figure.width}getTextStyles(){const e=.96*this.props.figure.width,t=this.getWidestElement(),o=t.getElementMaxFontSize(this.getDrawableHeight(),this);let i=function(e,t,o,i=.25){let n=1;if(o(n)>e)return n;if(o(t)<e)return t;let r=(n+t)/2,s=o(r),a=0;for(;Math.abs(s-e)>i&&a<20;)s>=e?t=(n+t)/2:n=(n+t)/2,r=(n+t)/2,s=o(r),a++;return r}(e,o,(e=>t.getElementWidth(e,this.ctx,this)))/o;const n=(new ai).getElementMaxFontSize(this.getDrawableHeight(),this)*i,r=(new si).getElementMaxFontSize(this.getDrawableHeight(),this)*i;return{titleStyle:this.getTextStyle({fontSize:18,color:this.secondaryFontColor}),keyStyle:this.getTextStyle({fontSize:n,cellStyle:this.runtime.keyValueStyle,color:this.primaryFontColor}),baselineStyle:this.getTextStyle({fontSize:r}),baselineValueStyle:this.getTextStyle({fontSize:r,cellStyle:this.runtime.baselineStyle,color:this.runtime.baselineColor||this.secondaryFontColor}),baselineDescrStyle:this.getTextStyle({fontSize:.9*r,color:this.secondaryFontColor})}}getTextStyle(e){const t=oi(e.cellStyle);return t["font-size"]=`${e.fontSize}px`,t.display="inline-block",!t.color&&e.color&&(t.color=e.color),ii(t)}getDrawableHeight(){const e=2*this.chartPadding;let t=this.props.figure.height-e;return t-=this.title?18*ni:0,t}getWidestElement(){const e=new si,t=new ai;return e.getElementWidth(.35,this.ctx,this)>t.getElementWidth(.65,this.ctx,this)?e:t}}ri.template="o-spreadsheet-ScorecardChart";class si{getElementWidth(e,t,o){if(!o.runtime)return 0;const i=o.baseline,n="neutral"!==o.baselineArrowDirection?"A "+i:i;t.font=`${e}px ${G}`;let r=t.measureText(n).width;return t.font=`${.9*e}px ${G}`,r+=t.measureText(o.baselineDescr).width,r}getElementMaxFontSize(e,t){if(!t.runtime)return 0;return(""!==t.baseline||t.baselineDescr?.35*e:0)/ni}}class ai{getElementWidth(e,t,o){if(!o.runtime)return 0;const i=o.keyValue||"";return t.font=`${e}px ${G}`,t.measureText(i).width}getElementMaxFontSize(e,t){if(!t.runtime)return 0;return(""!==t.baseline||t.baselineDescr?.65*e:e)/ni}}function li(e){return 8===(e=ht(e).replace("#","")).length?e.slice(6)+e.slice(0,6):e}ri.props={figure:Object};class ci{constructor(e,t,o){this.title=e.title,this.sheetId=t,this.getters=o}static validateChartDefinition(e,t){throw new Error("This method should be implemented by sub class")}static transformDefinition(e,t){throw new Error("This method should be implemented by sub class")}static getDefinitionFromContextCreation(e){throw new Error("This method should be implemented by sub class")}}function hi(e,t){return"REMOVE_COLUMNS_ROWS"===t.type?No(e,"COL"===t.dimension?"left":"top",t.elements):"ADD_COLUMNS_ROWS"===t.type?Ao(e,"COL"===t.dimension?"left":"top",t.base,t.position,t.quantity):{...e}}var di,ui;!function(e){e.boolean="boolean",e.number="number",e.text="text",e.empty="empty",e.error="error"}(di||(di={})),function(e){e.PlainText="text/plain",e.Html="text/html"}(ui||(ui={}));const gi=new Set(["RENAME_SHEET","DELETE_SHEET","CREATE_SHEET","ADD_COLUMNS_ROWS","REMOVE_COLUMNS_ROWS","DELETE_CELL","INSERT_CELL","UNDO","REDO"]),pi=new Set([...gi,"DUPLICATE_SHEET","EVALUATE_CELLS","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","MOVE_CONDITIONAL_FORMAT"]),mi=new Set(["START","ACTIVATE_SHEET","COPY","PREPARE_SELECTION_INPUT_EXPANSION","STOP_SELECTION_INPUT","RESIZE_SHEETVIEW","SET_VIEWPORT_OFFSET","SELECT_SEARCH_NEXT_MATCH","SELECT_SEARCH_PREVIOUS_MATCH","REFRESH_SEARCH","UPDATE_SEARCH","CLEAR_SEARCH","EVALUATE_CELLS","SET_CURRENT_CONTENT","SET_FORMULA_VISIBILITY","OPEN_CELL_POPOVER","CLOSE_CELL_POPOVER","UPDATE_FILTER"]),fi=new Set(["UPDATE_CELL","UPDATE_CELL_POSITION","CLEAR_CELL","DELETE_CONTENT","ADD_COLUMNS_ROWS","REMOVE_COLUMNS_ROWS","RESIZE_COLUMNS_ROWS","HIDE_COLUMNS_ROWS","UNHIDE_COLUMNS_ROWS","SET_GRID_LINES_VISIBILITY","UNFREEZE_COLUMNS","UNFREEZE_ROWS","FREEZE_COLUMNS","FREEZE_ROWS","UNFREEZE_COLUMNS_ROWS","ADD_MERGE","REMOVE_MERGE","CREATE_SHEET","DELETE_SHEET","DUPLICATE_SHEET","MOVE_SHEET","RENAME_SHEET","HIDE_SHEET","SHOW_SHEET","MOVE_RANGES","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","MOVE_CONDITIONAL_FORMAT","CREATE_FIGURE","DELETE_FIGURE","UPDATE_FIGURE","SET_FORMATTING","CLEAR_FORMATTING","SET_BORDER","CREATE_CHART","UPDATE_CHART","CREATE_FILTER_TABLE","REMOVE_FILTER_TABLE","CREATE_IMAGE"]);function vi(e){return fi.has(e.type)}class bi{constructor(e=[]){Array.isArray(e)||(e=[e]),e=[...new Set(e)],this.reasons=e.filter((e=>0!==e))}static get Success(){return new bi}get isSuccessful(){return 0===this.reasons.length}isCancelledBecause(e){return this.reasons.includes(e)}}var Si,Ci,Ei;function wi(e,t,o,i){let n=!1;const r=[];for(let i in o){let s=o[i];if(s.labelCell){const e=Ii(s.labelCell,t);s.labelCell!==e&&(n=!0,s={...s,labelCell:e})}const a=Ii(s.dataRange,t);void 0===a||e.getRangeString(a,a.sheetId)===X?(n=!0,s=void 0):a!==s.dataRange&&(n=!0,s={...s,dataRange:a}),r[i]=s}let s=i;const a=Ii(s,t);a!==s&&(n=!0,s=a);return{isStale:n,dataSets:r.filter(Qe),labelRange:s}}function yi(e,t,o){return o.map((o=>({dataRange:Co(e,t,o.dataRange),labelCell:o.labelCell?Co(e,t,o.labelCell):void 0})))}function xi(e,t,o){return o?Co(e,t,o):void 0}function Ii(e,t){if(!e)return;const o=t(e);switch(o.changeType){case"NONE":return e;case"REMOVE":return;default:return o.range}}function Ri(e,t,o,i){const n=[];for(const r of t){const t=e.getRangeFromSheetXC(o,r),{unboundedZone:s,sheetId:a,invalidSheetName:l}=t;if(!l)if(s.left!==s.right&&s.top!==s.bottom){if(void 0===s.right)continue;for(let t=s.left;t<=s.right;t++){const o={...s,left:t,right:t};n.push(Ti(e,a,o,i?{top:o.top,bottom:o.top,left:o.left,right:o.left}:void 0))}}else s.left===s.right&&s.top===s.bottom?i||n.push(Ti(e,a,s,void 0)):n.push(Ti(e,a,s,i?{top:s.top,bottom:s.top,left:s.left,right:s.left}:void 0))}return n}function Ti(e,t,o,i){if(o.left!==o.right&&o.top!==o.bottom)throw new Error(`Zone should be a single column or row: ${To(o)}`);if(i){const n=To(o),r=To(i);return{labelCell:e.getRangeFromSheetXC(t,r),dataRange:e.getRangeFromSheetXC(t,n)}}return{labelCell:void 0,dataRange:e.getRangeFromSheetXC(t,To(o))}}function Ai(e,t){var o;const i=null===(o=t.labelCell)||void 0===o?void 0:o.zone;let n=t.dataRange.zone;if(i){const{height:e,width:t}=Vo(n);1===e?n={...n,left:n.left+1}:1===t&&(n={...n,top:n.top+1})}const r=t.dataRange.clone({zone:n});return{label:t.labelCell?e.getRangeString(t.labelCell,"forceSheetReference"):void 0,range:e.getRangeString(r,"forceSheetReference")}}function Oi(e,t){let o;if(e.labelRange){const i=hi(xo(e.labelRange),t);o=i?To(i):void 0}const i=e.dataSets.map(xo).map((e=>hi(e,t))).filter(Qe).map(To);return{...e,labelRange:o,dataSets:i}}e.CommandResult=void 0,(Si=e.CommandResult||(e.CommandResult={}))[Si.Success=0]="Success",Si[Si.CancelledForUnknownReason=1]="CancelledForUnknownReason",Si[Si.WillRemoveExistingMerge=2]="WillRemoveExistingMerge",Si[Si.MergeIsDestructive=3]="MergeIsDestructive",Si[Si.CellIsMerged=4]="CellIsMerged",Si[Si.InvalidTarget=5]="InvalidTarget",Si[Si.EmptyUndoStack=6]="EmptyUndoStack",Si[Si.EmptyRedoStack=7]="EmptyRedoStack",Si[Si.NotEnoughElements=8]="NotEnoughElements",Si[Si.NotEnoughSheets=9]="NotEnoughSheets",Si[Si.MissingSheetName=10]="MissingSheetName",Si[Si.DuplicatedSheetName=11]="DuplicatedSheetName",Si[Si.DuplicatedSheetId=12]="DuplicatedSheetId",Si[Si.ForbiddenCharactersInSheetName=13]="ForbiddenCharactersInSheetName",Si[Si.WrongSheetMove=14]="WrongSheetMove",Si[Si.WrongSheetPosition=15]="WrongSheetPosition",Si[Si.InvalidAnchorZone=16]="InvalidAnchorZone",Si[Si.SelectionOutOfBound=17]="SelectionOutOfBound",Si[Si.TargetOutOfSheet=18]="TargetOutOfSheet",Si[Si.WrongCutSelection=19]="WrongCutSelection",Si[Si.WrongPasteSelection=20]="WrongPasteSelection",Si[Si.WrongPasteOption=21]="WrongPasteOption",Si[Si.WrongFigurePasteOption=22]="WrongFigurePasteOption",Si[Si.EmptyClipboard=23]="EmptyClipboard",Si[Si.EmptyRange=24]="EmptyRange",Si[Si.InvalidRange=25]="InvalidRange",Si[Si.InvalidZones=26]="InvalidZones",Si[Si.InvalidSheetId=27]="InvalidSheetId",Si[Si.DuplicatedImageId=28]="DuplicatedImageId",Si[Si.InputAlreadyFocused=29]="InputAlreadyFocused",Si[Si.MaximumRangesReached=30]="MaximumRangesReached",Si[Si.InvalidChartDefinition=31]="InvalidChartDefinition",Si[Si.InvalidDataSet=32]="InvalidDataSet",Si[Si.InvalidLabelRange=33]="InvalidLabelRange",Si[Si.InvalidScorecardKeyValue=34]="InvalidScorecardKeyValue",Si[Si.InvalidScorecardBaseline=35]="InvalidScorecardBaseline",Si[Si.InvalidGaugeDataRange=36]="InvalidGaugeDataRange",Si[Si.EmptyGaugeRangeMin=37]="EmptyGaugeRangeMin",Si[Si.GaugeRangeMinNaN=38]="GaugeRangeMinNaN",Si[Si.EmptyGaugeRangeMax=39]="EmptyGaugeRangeMax",Si[Si.GaugeRangeMaxNaN=40]="GaugeRangeMaxNaN",Si[Si.GaugeRangeMinBiggerThanRangeMax=41]="GaugeRangeMinBiggerThanRangeMax",Si[Si.GaugeLowerInflectionPointNaN=42]="GaugeLowerInflectionPointNaN",Si[Si.GaugeUpperInflectionPointNaN=43]="GaugeUpperInflectionPointNaN",Si[Si.GaugeLowerBiggerThanUpper=44]="GaugeLowerBiggerThanUpper",Si[Si.InvalidAutofillSelection=45]="InvalidAutofillSelection",Si[Si.WrongComposerSelection=46]="WrongComposerSelection",Si[Si.MinBiggerThanMax=47]="MinBiggerThanMax",Si[Si.LowerBiggerThanUpper=48]="LowerBiggerThanUpper",Si[Si.MidBiggerThanMax=49]="MidBiggerThanMax",Si[Si.MinBiggerThanMid=50]="MinBiggerThanMid",Si[Si.FirstArgMissing=51]="FirstArgMissing",Si[Si.SecondArgMissing=52]="SecondArgMissing",Si[Si.MinNaN=53]="MinNaN",Si[Si.MidNaN=54]="MidNaN",Si[Si.MaxNaN=55]="MaxNaN",Si[Si.ValueUpperInflectionNaN=56]="ValueUpperInflectionNaN",Si[Si.ValueLowerInflectionNaN=57]="ValueLowerInflectionNaN",Si[Si.MinInvalidFormula=58]="MinInvalidFormula",Si[Si.MidInvalidFormula=59]="MidInvalidFormula",Si[Si.MaxInvalidFormula=60]="MaxInvalidFormula",Si[Si.ValueUpperInvalidFormula=61]="ValueUpperInvalidFormula",Si[Si.ValueLowerInvalidFormula=62]="ValueLowerInvalidFormula",Si[Si.InvalidSortZone=63]="InvalidSortZone",Si[Si.WaitingSessionConfirmation=64]="WaitingSessionConfirmation",Si[Si.MergeOverlap=65]="MergeOverlap",Si[Si.TooManyHiddenElements=66]="TooManyHiddenElements",Si[Si.Readonly=67]="Readonly",Si[Si.InvalidViewportSize=68]="InvalidViewportSize",Si[Si.InvalidScrollingDirection=69]="InvalidScrollingDirection",Si[Si.FigureDoesNotExist=70]="FigureDoesNotExist",Si[Si.InvalidConditionalFormatId=71]="InvalidConditionalFormatId",Si[Si.InvalidCellPopover=72]="InvalidCellPopover",Si[Si.EmptyTarget=73]="EmptyTarget",Si[Si.InvalidFreezeQuantity=74]="InvalidFreezeQuantity",Si[Si.FrozenPaneOverlap=75]="FrozenPaneOverlap",Si[Si.ValuesNotChanged=76]="ValuesNotChanged",Si[Si.InvalidFilterZone=77]="InvalidFilterZone",Si[Si.FilterOverlap=78]="FilterOverlap",Si[Si.FilterNotFound=79]="FilterNotFound",Si[Si.MergeInFilter=80]="MergeInFilter",Si[Si.NonContinuousTargets=81]="NonContinuousTargets",Si[Si.DuplicatedFigureId=82]="DuplicatedFigureId",Si[Si.InvalidSelectionStep=83]="InvalidSelectionStep",Si[Si.DuplicatedChartId=84]="DuplicatedChartId",function(e){e.UP="up",e.DOWN="down",e.LEFT="left",e.RIGHT="right"}(Ci||(Ci={})),function(e){e[e.Background=0]="Background",e[e.Highlights=1]="Highlights",e[e.Clipboard=2]="Clipboard",e[e.Search=3]="Search",e[e.Chart=4]="Chart",e[e.Autofill=5]="Autofill",e[e.Selection=6]="Selection",e[e.Headers=7]="Headers"}(Ei||(Ei={}));const Mi=["rgb(31,119,180)","rgb(255,127,14)","rgb(174,199,232)","rgb(255,187,120)","rgb(44,160,44)","rgb(152,223,138)","rgb(214,39,40)","rgb(255,152,150)","rgb(148,103,189)","rgb(197,176,213)","rgb(140,86,75)","rgb(196,156,148)","rgb(227,119,194)","rgb(247,182,210)","rgb(127,127,127)","rgb(199,199,199)","rgb(188,189,34)","rgb(219,219,141)","rgb(23,190,207)","rgb(158,218,229)"];class Ni{constructor(){this.graphColorIndex=0}next(){return Mi[this.graphColorIndex++%Mi.length]}}function _i(e){return e&&pt(e)<.3?"#FFFFFF":"#000000"}function Fi(e){if(e.dataSets){const t=void 0!==e.dataSets.find((e=>!xt.test(e)));if(t)return 32;if(e.dataSets.map(xo).some((e=>e.top!==e.bottom&&Zo(e))))return 32}return 0}function Di(e){if(e.labelRange){if(!xt.test(e.labelRange||""))return 33}return 0}function ki(e,t,o){if(e){if("text"===o||(null==t?void 0:t.type)!==di.number||e.type!==di.number)return e.formattedValue;{let i=t.value-e.value;if("percentage"===o&&0!==i&&(i=i/e.value*100),"percentage"!==o&&e.format)return oo(i,e.format);const n=Math.abs(parseFloat(i.toFixed(2))).toLocaleString();return"percentage"===o?n+"%":n}}return""}function $i(e,t,o,i,n){if("text"===t||(null==e?void 0:e.type)!==di.number||(null==o?void 0:o.type)!==di.number)return;const r=o.value-e.value;return r>0?i:r<0?n:void 0}function Pi(e,t,o){if("text"===o||(null==e?void 0:e.type)!==di.number||(null==t?void 0:t.type)!==di.number)return"neutral";const i=t.value-e.value;return i>0?"up":i<0?"down":"neutral"}const Li={Errors:{25:r("The range is invalid"),51:r("The argument is missing. Please provide a value"),52:r("The second argument is missing. Please provide a value"),53:r("The minpoint must be a number"),54:r("The midpoint must be a number"),55:r("The maxpoint must be a number"),56:r("The first value must be a number"),57:r("The second value must be a number"),47:r("Minimum must be smaller then Maximum"),50:r("Minimum must be smaller then Midpoint"),49:r("Midpoint must be smaller then Maximum"),48:r("Lower inflection point must be smaller than upper inflection point"),58:r("Invalid Minpoint formula"),60:r("Invalid Maxpoint formula"),59:r("Invalid Midpoint formula"),61:r("Invalid upper inflection point formula"),62:r("Invalid lower inflection point formula"),24:r("A range needs to be defined"),Unexpected:r("The rule is invalid for an unknown reason")},ColorScale:r("Color scale"),IconSet:r("Icon set")},Ui={IsEmpty:r("Is empty"),IsNotEmpty:r("Is not empty"),ContainsText:r("Contains"),NotContains:r("Does not contain"),BeginsWith:r("Starts with"),EndsWith:r("Ends with"),Equal:r("Is equal to"),NotEqual:r("Is not equal to"),GreaterThan:r("Is greater than"),GreaterThanOrEqual:r("Is greater than or equal to"),LessThan:r("Is less than"),LessThanOrEqual:r("Is less than or equal to"),Between:r("Is between"),NotBetween:r("Is not between")},Vi={Series:r("Series"),Errors:{Unexpected:r("The chart definition is invalid for an unknown reason"),32:r("The dataset is invalid"),33:r("Labels are invalid"),34:r("The key value is invalid"),35:r("The baseline value is invalid"),36:r("The data range is invalid"),37:r("A minimum range limit value is needed"),38:r("The minimum range limit value must be a number"),39:r("A maximum range limit value is needed"),40:r("The maximum range limit value must be a number"),41:r("Minimum range limit must be smaller than maximum range limit"),42:r("The lower inflection point value must be a number"),43:r("The upper inflection point value must be a number")}},zi={Automatic:r("Automatic"),Number:r("Number"),Percent:r("Percent"),Currency:r("Currency"),CurrencyRounded:r("Currency rounded"),Date:r("Date"),Time:r("Time"),DateTime:r("Date time"),Duration:r("Duration"),CustomCurrency:r("Custom currency")},Bi={Custom:r("Custom")},Hi=r("Merged cells are preventing this operation. Unmerge those cells and try again.");function Wi(e,t){if(t.dataRange){const o=t.labelCell?[To(t.labelCell.zone)]:[],i=Lo([To(t.dataRange.zone)],o)[0];if(void 0===i)return[];const n=e.getRangeFromSheetXC(t.dataRange.sheetId,i);return e.getRangeValues(n).map((e=>""===e?void 0:e))}return[]}function Gi(e,t){const o=Le(0,Math.max(e.length,...t.map((e=>{var t;return(null===(t=e.data)||void 0===t?void 0:t.length)||0})))).filter((o=>{const i=e[o],n=t.map((e=>{var t;return null===(t=e.data)||void 0===t?void 0:t[o]}));return i||n.some((e=>0===e||Boolean(e)))}));return{labels:o.map((t=>e[t]||"")),dataSetsValues:t.map((e=>({...e,data:o.map((t=>e.data[t]))})))}}function qi(e,t){const o=new Set(e),i={};o.forEach((e=>{i[e]=new Array(t.length).fill(0)}));for(const o of Le(0,e.length)){const r=e[o];for(const e of Le(0,t.length))i[r][e]+="number"==typeof(n=t[e].data[o])?n:0}var n;return{labels:Object.keys(i),dataSetsValues:t.map(((e,t)=>({...e,data:Object.values(i).map((e=>e[t]))})))}}function Zi(e){return e?e.length>K?e.substring(0,K)+"…":e:""}function ji(e,t,o){return{type:e.type,options:{responsive:!0,maintainAspectRatio:!1,layout:{padding:{left:20,right:20,top:e.title?10:25,bottom:10}},elements:{line:{fill:!1},point:{hitRadius:15}},animation:{duration:0},hover:{animationDuration:10},responsiveAnimationDuration:0,title:{display:!!e.title,fontSize:22,fontStyle:"normal",text:n(e.title),fontColor:o},legend:{onClick:void 0}},data:{labels:t.map(Zi),datasets:[]}}}function Xi(e,t,o){let i={values:[],formattedValues:[]};if(o)o.invalidXc||o.invalidSheetName||(i={formattedValues:e.getRangeFormattedValues(o),values:e.getRangeValues(o).map((e=>String(e)))});else if(1===t.length)for(let o=0;o<Wi(e,t[0]).length;o++)i.formattedValues.push(""),i.values.push("");else if(t[0]){i={formattedValues:Le(0,Wi(e,t[0]).length).map((e=>e.toString())),values:i.formattedValues}}return i}function Yi(e,t){const o=[];for(const[i,n]of Object.entries(t)){let t;if(n.labelCell){const o=n.labelCell,r=o?e.getEvaluatedCell({sheetId:o.sheetId,col:o.zone.left,row:o.zone.top}):void 0;t=r&&o?Zi(r.formattedValue):t=`${Vi.Series} ${parseInt(i)+1}`}else t=t=`${Vi.Series} ${parseInt(i)+1}`;let r=n.dataRange?Wi(e,n):[];o.push({data:r,label:t})}return o}function Ki(e){return 0===e?"origin":e-1}class Qi extends ci{constructor(e,t,o){super(e,t,o),this.type="bar",this.dataSets=Ri(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Eo(o,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.stacked=e.stacked,this.aggregated=e.aggregated}static transformDefinition(e,t){return Oi(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,Fi,Di)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,stacked:!1,aggregated:!1,legendPosition:"top",title:e.title||"",type:"bar",verticalAxisPosition:"left",labelRange:e.auxiliaryRange||void 0}}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}copyForSheetId(e){const t=yi(this.sheetId,e,this.dataSets),o=xi(this.sheetId,e,this.labelRange),i=this.getDefinitionWithSpecificDataSets(t,o,e);return new Qi(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new Qi(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){return{type:"bar",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,o||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,stacked:this.stacked,aggregated:this.aggregated}}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>Ai(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:li(this.background||w),fontColor:li(_i(this.background)),dataSets:e}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:i}=wi(this.getters,e,this.dataSets,this.labelRange);if(!i)return this;const n=this.getDefinitionWithSpecificDataSets(t,o);return new Qi(n,this.sheetId,this.getters)}}function Ji(e){return e.dataRange&&!xt.test(e.dataRange)?36:0}function en(e,t){return t((t=>t.sectionRule?e(t.sectionRule.rangeMin,"rangeMin"):0),(t=>t.sectionRule?e(t.sectionRule.rangeMax,"rangeMax"):0))}function tn(e){return e.sectionRule&&Number(e.sectionRule.rangeMin)>=Number(e.sectionRule.rangeMax)?41:0}function on(e,t){if(""===e)switch(t){case"rangeMin":return 37;case"rangeMax":return 39}return 0}function nn(e,t){if(isNaN(e))switch(t){case"rangeMin":return 38;case"rangeMax":return 40;case"lowerInflectionPointValue":return 42;case"upperInflectionPointValue":return 43}return 0}class rn extends ci{constructor(e,t,o){super(e,t,o),this.type="gauge",this.dataRange=Eo(this.getters,this.sheetId,e.dataRange),this.sectionRule=e.sectionRule,this.background=e.background}static validateChartDefinition(e,t){return e.checkValidations(t,Ji,e.chainValidations(en(on,e.batchValidations),en(nn,e.batchValidations),tn),e.chainValidations((o=nn,(0,e.batchValidations)((e=>e.sectionRule?o(e.sectionRule.lowerInflectionPoint.value,"lowerInflectionPointValue"):0),(e=>e.sectionRule?o(e.sectionRule.upperInflectionPoint.value,"upperInflectionPointValue"):0)))));var o}static transformDefinition(e,t){let o;return e.dataRange&&(o=hi(xo(e.dataRange),t)),{...e,dataRange:o?To(o):void 0}}static getDefinitionFromContextCreation(e){return{background:e.background,title:e.title||"",type:"gauge",dataRange:e.range?e.range[0]:void 0,sectionRule:{colors:{lowerColor:"#cc0000",middleColor:"#f1c232",upperColor:"#6aa84f"},rangeMin:"0",rangeMax:"100",lowerInflectionPoint:{type:"percentage",value:"15"},upperInflectionPoint:{type:"percentage",value:"40"}}}}copyForSheetId(e){const t=xi(this.sheetId,e,this.dataRange),o=this.getDefinitionWithSpecificRanges(t,e);return new rn(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.dataRange,e);return new rn(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.dataRange)}getDefinitionWithSpecificRanges(e,t){return{background:this.background,sectionRule:this.sectionRule,title:this.title,type:"gauge",dataRange:e?this.getters.getRangeString(e,t||this.sheetId):void 0}}getDefinitionForExcel(){}getContextCreation(){return{background:this.background,title:this.title,range:this.dataRange?[this.getters.getRangeString(this.dataRange,this.sheetId)]:void 0}}updateRanges(e){const t=Ii(this.dataRange,e);if(this.dataRange===t)return this;const o=this.getDefinitionWithSpecificRanges(t);return new rn(o,this.sheetId,this.getters)}}const sn={second:1e3,minute:6e4,hour:36e5,day:864e5,month:2592e6,year:31536e6},an={inSeconds:function(e){return Math.floor(e/sn.second)},inMinutes:function(e){return Math.floor(e/sn.minute)},inHours:function(e){return Math.floor(e/sn.hour)},inDays:function(e){return Math.floor(e/sn.day)},inMonths:function(e){return Math.floor(e/sn.month)},inYears:function(e){return Math.floor(e/sn.year)}},ln=/^((d|dd|m|mm|yyyy|yy|hh|h|ss|a)(-|:|\s|\/))*(d|dd|m|mm|yyyy|yy|hh|h|ss|a)$/i;function cn(e,t){const o=function(e){const t=(e=(e=e.replace(/y/g,"Y")).replace(/d/g,"D")).indexOf("h");e=t>=0?e.slice(0,t).replace(/m/g,"M")+e.slice(t):e.replace(/m/g,"M");e.includes("a")||(e=e.replace(/h/g,"H"));return e}(t),i=function(e,t){const o=e.map((e=>{var t;return null===(t=be(e))||void 0===t?void 0:t.jsDate}));if(o.some((e=>void 0===e))||e.length<2)return;const i=o.map((e=>e.getTime())),n=Math.max(...i)-Math.min(...i),r=function(e){if(e.includes("s"))return"second";if(e.includes("m"))return"minute";if(e.includes("h")||e.includes("H"))return"hour";if(e.includes("D"))return"day";if(e.includes("M"))return"month";return"year"}(t);if(sn.second>=sn[r]&&an.inSeconds(n)<180)return"second";if(sn.minute>=sn[r]&&an.inMinutes(n)<180)return"minute";if(sn.hour>=sn[r]&&an.inHours(n)<96)return"hour";if(sn.day>=sn[r]&&an.inDays(n)<90)return"day";if(sn.month>=sn[r]&&an.inMonths(n)<36)return"month";return"year"}(e,o),n={};return i&&(n[i]=o),{parser:o,displayFormats:n,unit:i}}class hn extends ci{constructor(e,t,o){super(e,t,o),this.type="line",this.dataSets=Ri(this.getters,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Eo(this.getters,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.labelsAsText=e.labelsAsText,this.stacked=e.stacked,this.aggregated=e.aggregated}static validateChartDefinition(e,t){return e.checkValidations(t,Fi,Di)}static transformDefinition(e,t){return Oi(e,t)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,labelsAsText:!1,legendPosition:"top",title:e.title||"",type:"line",verticalAxisPosition:"left",labelRange:e.auxiliaryRange||void 0,stacked:!1,aggregated:!1}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){return{type:"line",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,o||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,labelsAsText:this.labelsAsText,stacked:this.stacked,aggregated:this.aggregated}}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:i}=wi(this.getters,e,this.dataSets,this.labelRange);if(!i)return this;const n=this.getDefinitionWithSpecificDataSets(t,o);return new hn(n,this.sheetId,this.getters)}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>Ai(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:li(this.background||w),fontColor:li(_i(this.background)),dataSets:e}}copyForSheetId(e){const t=yi(this.sheetId,e,this.dataSets),o=xi(this.sheetId,e,this.labelRange),i=this.getDefinitionWithSpecificDataSets(t,o,e);return new hn(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new hn(t,e,this.getters)}}function dn(e,t){return gn(e,t)||pn(e,t)}function un(e,t){return function(e,t){return!e.labelsAsText&&gn(e.labelRange,t)}(e,t)?"time":function(e,t){return!e.labelsAsText&&pn(e.labelRange,t)}(e,t)?"linear":"category"}function gn(e,t){if(!e||!pn(e,t))return!1;const o=t.getEvaluatedCell({sheetId:e.sheetId,col:e.zone.left,row:e.zone.top}).format;return Boolean(o&&ln.test(o))}function pn(e,t){if(!e)return!1;const o=t.getRangeValues(e);return!o.some((e=>isNaN(Number(e))&&e))&&!o.every((e=>!e))}class mn extends ci{constructor(e,t,o){super(e,t,o),this.type="pie",this.dataSets=Ri(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Eo(o,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.aggregated=e.aggregated}static transformDefinition(e,t){return Oi(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,Fi,Di)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,legendPosition:"top",title:e.title||"",type:"pie",labelRange:e.auxiliaryRange||void 0,aggregated:!1}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}getDefinitionWithSpecificDataSets(e,t,o){return{type:"pie",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,o||this.sheetId))),legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,aggregated:this.aggregated}}copyForSheetId(e){const t=yi(this.sheetId,e,this.dataSets),o=xi(this.sheetId,e,this.labelRange),i=this.getDefinitionWithSpecificDataSets(t,o,e);return new mn(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new mn(t,e,this.getters)}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>Ai(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:li(this.background||w),fontColor:li(_i(this.background)),verticalAxisPosition:"left",dataSets:e}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:i}=wi(this.getters,e,this.dataSets,this.labelRange);if(!i)return this;const n=this.getDefinitionWithSpecificDataSets(t,o);return new mn(n,this.sheetId,this.getters)}}function fn(e,t){const o=[],i=Math.max(...t.map((e=>e.data.length)));for(let t=0;t<=i;t++)o.push(e.next());return o}function vn(e){return e.keyValue&&!xt.test(e.keyValue)?34:0}function bn(e){return e.baseline&&!xt.test(e.baseline)?35:0}class Sn extends ci{constructor(e,t,o){super(e,t,o),this.type="scorecard",this.keyValue=Eo(o,t,e.keyValue),this.baseline=Eo(o,t,e.baseline),this.baselineMode=e.baselineMode,this.baselineDescr=e.baselineDescr,this.background=e.background,this.baselineColorUp=e.baselineColorUp,this.baselineColorDown=e.baselineColorDown}static validateChartDefinition(e,t){return e.checkValidations(t,vn,bn)}static getDefinitionFromContextCreation(e){return{background:e.background,type:"scorecard",keyValue:e.range?e.range[0]:void 0,title:e.title||"",baselineMode:J,baselineColorUp:ee,baselineColorDown:te,baseline:e.auxiliaryRange||""}}static transformDefinition(e,t){let o,i;return e.baseline&&(o=hi(xo(e.baseline),t)),e.keyValue&&(i=hi(xo(e.keyValue),t)),{...e,baseline:o?To(o):void 0,keyValue:i?To(i):void 0}}copyForSheetId(e){const t=xi(this.sheetId,e,this.baseline),o=xi(this.sheetId,e,this.keyValue),i=this.getDefinitionWithSpecificRanges(t,o,e);return new Sn(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue,e);return new Sn(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue)}getContextCreation(){return{background:this.background,title:this.title,range:this.keyValue?[this.getters.getRangeString(this.keyValue,this.sheetId)]:void 0,auxiliaryRange:this.baseline?this.getters.getRangeString(this.baseline,this.sheetId):void 0}}getDefinitionWithSpecificRanges(e,t,o){return{baselineColorDown:this.baselineColorDown,baselineColorUp:this.baselineColorUp,baselineMode:this.baselineMode,title:this.title,type:"scorecard",background:this.background,baseline:e?this.getters.getRangeString(e,o||this.sheetId):void 0,baselineDescr:this.baselineDescr,keyValue:t?this.getters.getRangeString(t,o||this.sheetId):void 0}}getDefinitionForExcel(){}updateRanges(e){const t=Ii(this.baseline,e),o=Ii(this.keyValue,e);if(this.baseline===t&&this.keyValue===o)return this;const i=this.getDefinitionWithSpecificRanges(t,o);return new Sn(i,this.sheetId,this.getters)}}class Cn{constructor(){this.content={}}add(e,t){return this.content[e]=t,this}get(e){const t=this.content[e];if(!t&&!(e in this.content))throw new Error(`Cannot find ${e} in this registry!`);return t}contains(e){return e in this.content}getAll(){return Object.values(this.content)}getKeys(){return Object.keys(this.content)}remove(e){delete this.content[e]}}const En=new Cn;En.add("bar",{match:e=>"bar"===e,createChart:(e,t,o)=>new Qi(e,t,o),getChartRuntime:function(e,t){let o=Xi(t,e.dataSets,e.labelRange).formattedValues,i=Yi(t,e.dataSets);({labels:o,dataSetsValues:i}=Gi(o,i)),e.aggregated&&({labels:o,dataSetsValues:i}=qi(o,i));const n=function(e,t){var o;const i=_i(e.background),n=ji(e,t,i),r={labels:{fontColor:i}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,n.options.legend={...null===(o=n.options)||void 0===o?void 0:o.legend,...r},n.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},n.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2,fontColor:i}}],yAxes:[{position:e.verticalAxisPosition,ticks:{fontColor:i,beginAtZero:!0}}]},e.stacked&&(n.options.scales.xAxes[0].stacked=!0,n.options.scales.yAxes[0].stacked=!0),n}(e,o),r=new Ni;for(let{label:e,data:t}of i){const o=r.next(),i={label:e,data:t,borderColor:o,backgroundColor:o};n.data.datasets.push(i)}return{chartJsConfig:n,background:e.background||w}},validateChartDefinition:(e,t)=>Qi.validateChartDefinition(e,t),transformDefinition:(e,t)=>Qi.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Qi.getDefinitionFromContextCreation(e),name:r("Bar")}),En.add("line",{match:e=>"line"===e,createChart:(e,t,o)=>new hn(e,t,o),getChartRuntime:function(e,t){const o=un(e,t),i=Xi(t,e.dataSets,e.labelRange);let n="linear"===o?i.values:i.formattedValues,r=Yi(t,e.dataSets);({labels:n,dataSetsValues:r}=Gi(n,r)),"time"===o&&({labels:n,dataSetsValues:r}=function(e,t){if(0===e.length||e.every((e=>!e)))return{labels:e,dataSetsValues:t};const o=[...e],i=Me(t);for(let e=0;e<o.length;e++)if(!o[e]){o[e]=it(o,e);for(let t of i)t.data[e]=void 0}return{labels:o,dataSetsValues:i}}(n,r)),e.aggregated&&({labels:n,dataSetsValues:r}=qi(n,r));const s=function(e,t){var o;const i=_i(e.background),n=ji(e,t,i),r={labels:{fontColor:i,generateLabels(e){const{data:t}=e,o=window.Chart.defaults.global.legend.labels.generateLabels(e);for(const[e,i]of o.entries())i.fillStyle=t.datasets[e].borderColor;return o}}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,n.options.legend={...null===(o=n.options)||void 0===o?void 0:o.legend,...r},n.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},n.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2,fontColor:i}}],yAxes:[{position:e.verticalAxisPosition,ticks:{fontColor:i,beginAtZero:!0}}]},e.stacked&&(n.options.scales.yAxes[0].stacked=!0),n}(e,n),a=function(e,t){if(t)return e.getEvaluatedCell({sheetId:t.sheetId,col:t.zone.left,row:t.zone.top}).format}(t,e.labelRange);"time"===o?(s.options.scales.xAxes[0].type="time",s.options.scales.xAxes[0].time=cn(n,a),s.options.scales.xAxes[0].ticks.maxTicksLimit=15):"linear"===o&&(s.options.scales.xAxes[0].type="linear",s.options.scales.xAxes[0].ticks.callback=e=>oo(e,a));const l=new Ni;for(let[t,{label:i,data:a}]of r.entries()){["linear","time"].includes(o)&&(a=a.map(((e,t)=>({x:n[t]||void 0,y:e}))));const r=l.next();let c=ft(r);e.stacked&&(c.a=oe);const h={label:i,data:a,lineTension:0,borderColor:r,backgroundColor:mt(c),pointBackgroundColor:r,fill:!!e.stacked&&Ki(t)};s.data.datasets.push(h)}return{chartJsConfig:s,background:e.background||w}},validateChartDefinition:(e,t)=>hn.validateChartDefinition(e,t),transformDefinition:(e,t)=>hn.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>hn.getDefinitionFromContextCreation(e),name:r("Line")}),En.add("pie",{match:e=>"pie"===e,createChart:(e,t,o)=>new mn(e,t,o),getChartRuntime:function(e,t){let o=Xi(t,e.dataSets,e.labelRange).formattedValues,i=Yi(t,e.dataSets);({labels:o,dataSetsValues:i}=Gi(o,i)),e.aggregated&&({labels:o,dataSetsValues:i}=qi(o,i));const n=function(e,t){var o;const i=_i(e.background),n=ji(e,t,i),r={labels:{fontColor:i}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,n.options.legend={...null===(o=n.options)||void 0===o?void 0:o.legend,...r},n.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},n.options.tooltips={callbacks:{title:function(e,t){return t.datasets[e[0].datasetIndex].label}}},n}(e,o),r=new Ni;for(let{label:e,data:t}of i){const o={label:e,data:t,borderColor:"#FFFFFF",backgroundColor:fn(r,i)};n.data.datasets.push(o)}return{chartJsConfig:n,background:e.background||w}},validateChartDefinition:(e,t)=>mn.validateChartDefinition(e,t),transformDefinition:(e,t)=>mn.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>mn.getDefinitionFromContextCreation(e),name:r("Pie")}),En.add("scorecard",{match:e=>"scorecard"===e,createChart:(e,t,o)=>new Sn(e,t,o),getChartRuntime:function(e,t){let o,i,r="",s="";if(e.keyValue){const i={sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top};o=t.getEvaluatedCell(i),r=String(o.value),s=o.formattedValue}const a=e.baseline;if(a){const o={sheetId:e.baseline.sheetId,col:e.baseline.zone.left,row:e.baseline.zone.top};i=t.getEvaluatedCell(o)}const l=t.getBackgroundOfSingleCellChart(e.background,e.keyValue);return{title:n(e.title),keyValue:s||r,baselineDisplay:ki(i,o,e.baselineMode),baselineArrow:Pi(i,o,e.baselineMode),baselineColor:$i(i,e.baselineMode,o,e.baselineColorUp,e.baselineColorDown),baselineDescr:e.baselineDescr?n(e.baselineDescr):"",fontColor:_i(l),background:l,baselineStyle:"percentage"!==e.baselineMode&&a?t.getCellStyle({sheetId:a.sheetId,col:a.zone.left,row:a.zone.top}):void 0,keyValueStyle:e.keyValue?t.getCellStyle({sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top}):void 0}},validateChartDefinition:(e,t)=>Sn.validateChartDefinition(e,t),transformDefinition:(e,t)=>Sn.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Sn.getDefinitionFromContextCreation(e),name:r("Scorecard")}),En.add("gauge",{match:e=>"gauge"===e,createChart:(e,t,o)=>new rn(e,t,o),getChartRuntime:function(e,t){const o=function(e){const t=ji(e,[],_i(e.background));return t.options.hover=void 0,t.options.events=[],t.options.layout={padding:{left:30,right:30,top:e.title?10:25,bottom:25}},t.options.needle={radiusPercentage:2,widthPercentage:3.2,lengthPercentage:80,color:"#000000"},t.options.valueLabel={display:!1,formatter:null,color:"#FFFFFF",backgroundColor:"#000000",fontSize:30,borderRadius:5,padding:{top:5,right:5,bottom:5,left:5},bottomMarginPercentage:5},t}(e),i=e.sectionRule.colors,n=e.sectionRule.lowerInflectionPoint,r=e.sectionRule.upperInflectionPoint,s=Number(n.value),a=Number(r.value),l=Number(e.sectionRule.rangeMin),c=Number(e.sectionRule.rangeMax),h=c-l,d=[];if(""!==n.value){const e="number"===n.type?s:l+h*s/100;d.push({value:Fe(e,l,c),color:i.lowerColor})}if(""!==r.value){const e="number"===r.type?a:l+h*a/100;d.push({value:Fe(e,l,c),color:i.middleColor})}const u=[],g=[];d.sort(((e,t)=>e.value-t.value)).map((e=>{u.push(e.value),g.push(e.color)})),u.push(c),g.push(i.upperColor);const p=e.dataRange,m=h/30;let f=l-m,v=null,b=!1;if(void 0!==p){const e=t.getEvaluatedCell({sheetId:p.sheetId,col:p.zone.left,row:p.zone.top});e.type===di.number&&(f=Fe(e.value,l-m,c+m),v=()=>t.getRangeFormattedValues(p)[0],b=!0)}return o.options.valueLabel.display=b,o.options.valueLabel.formatter=v,o.data.datasets.push({data:u,minValue:Number(e.sectionRule.rangeMin),value:f,backgroundColor:g}),{chartJsConfig:o,background:t.getBackgroundOfSingleCellChart(e.background,p)}},validateChartDefinition:(e,t)=>rn.validateChartDefinition(e,t),transformDefinition:(e,t)=>rn.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>rn.getDefinitionFromContextCreation(e),name:r("Gauge")});const wn=new Cn;wn.add("line",Yo),wn.add("bar",Yo),wn.add("pie",Yo),wn.add("gauge",Yo),wn.add("scorecard",ri);const yn=e=>({isVisible:()=>!0,isEnabled:()=>!0,isReadonlyAllowed:!1,description:"",action:!1,children:[],separator:!1,icon:!1,id:e});function xn(e,t){return Object.assign({},yn(e),t)}function In(e){return"function"!=typeof e}class Rn extends Cn{add(e,t){return this.content[e]=xn(e,t),this}addChild(e,t,o){const i=t.splice(0,1)[0];let n=this.content[i];if(!n)throw new Error(`Path ${i+":"+t.join(":")} not found`);for(let e of t)if(n=n.children.filter(In).find((t=>t.id===e)),!n)throw new Error(`Path ${i+":"+t.join(":")} not found`);return"function"!=typeof o?n.children.push(xn(e,o)):n.children.push(o),this}getAll(){return super.getAll().sort(((e,t)=>e.sequence-t.sequence))}}function Tn(){const e=t.useState({x:0,y:0,width:0,height:0});let o=document.querySelector(".o-spreadsheet");function i(){if(o||(o=document.querySelector(".o-spreadsheet")),o){const{top:t,left:i,width:n,height:r}=o.getBoundingClientRect();e.x=i,e.y=t,e.width=n,e.height=r}}return i(),t.onMounted(i),t.onPatched(i),e}function An(e){const o=t.useState({x:0,y:0,width:0,height:0});function i(){const t=e.el;if(null===t)return;const{top:i,left:n,width:r,height:s}=t.getBoundingClientRect();o.x=n,o.y=i,o.width=r,o.height=s}return t.onMounted(i),t.onPatched(i),o}function On(e,t){const o=[];for(const i of e.children)"function"==typeof i?o.push(...i(t)):o.push(i);return o.sort(((e,t)=>e.sequence-t.sequence))}function Mn(e,t){return"function"==typeof e.name?e.name(t):e.name}function Nn(){const e=document.querySelector(".o-grid-overlay");if(e){const{top:t,left:o}=null==e?void 0:e.getBoundingClientRect();return{top:t,left:o}}throw new Error("Can't find spreadsheet position")}function _n(e,t){return(o=Fo(Fn(e),Fn(t)))?{x:o.left,y:o.top,width:o.right-o.left,height:o.bottom-o.top}:void 0;var o}function Fn(e){return{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height}}Jo`
53
53
  .o-popover {
54
54
  position: absolute;
55
55
  z-index: ${ae.Popover};
@@ -114,7 +114,7 @@
114
114
  height: 100%;
115
115
  position: relative;
116
116
  }
117
- `;class Un extends t.Component{constructor(){super(...arguments),this.menuState=t.useState({isOpen:!1,position:null,menuItems:[]}),this.chartContainerRef=t.useRef("chartContainer"),this.menuButtonRef=t.useRef("menuButton"),this.menuButtonPosition=An(this.menuButtonRef),this.position=An(this.chartContainerRef)}getMenuItemRegistry(){const e=new Rn;return e.add("edit",{name:r("Edit"),sequence:1,action:()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.props.figure.id}),this.env.openSidePanel("ChartPanel")}}),e.add("copy",{name:r("Copy"),sequence:2,action:async()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.props.figure.id}),this.env.model.dispatch("COPY"),await this.env.clipboard.write(this.env.model.getters.getClipboardContent())}}),e.add("cut",{name:r("Cut"),sequence:3,action:async()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.props.figure.id}),this.env.model.dispatch("CUT"),await this.env.clipboard.write(this.env.model.getters.getClipboardContent())}}),e.add("delete",{name:r("Delete"),sequence:10,action:()=>{this.env.model.dispatch("DELETE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:this.props.figure.id}),this.props.onFigureDeleted()}}),e}get chartType(){return this.env.model.getters.getChartType(this.env.model.getters.getActiveSheetId(),this.props.figure.id)}onContextMenu(e){const t={x:this.position.x+e.offsetX,y:this.position.y+e.offsetY};this.openContextMenu(t)}showMenu(){const e={x:this.menuButtonPosition.x-z,y:this.menuButtonPosition.y};this.openContextMenu(e)}openContextMenu(e){const t=this.getMenuItemRegistry();this.menuState.isOpen=!0,this.menuState.menuItems=t.getAll().filter((e=>e.isVisible(this.env))),this.menuState.position=e}get chartComponent(){const e=this.chartType,t=wn.get(e);if(!t)throw new Error(`Component is not defined for type ${e}`);return t}}function Vn(e){const t=e.model.dispatch("CUT");t.isSuccessful||t.isCancelledBecause(19)&&e.raiseError(r("This operation is not allowed with multiple selections."))}Un.template="o-spreadsheet-ChartFigure",Un.components={Menu:Ln},Un.props={figure:Object,onFigureDeleted:Function};const zn={wrongPasteSelection:r("This operation is not allowed with multiple selections."),willRemoveExistingMerge:r("This operation is not possible due to a merge. Please remove the merges first than try again."),wrongFigurePasteOption:r("Cannot do a special paste of a figure."),frozenPaneOverlap:r("Cannot paste merged cells over a frozen pane.")};function Bn(e,t){t.isSuccessful||(t.reasons.includes(20)?e.raiseError(zn.wrongPasteSelection):t.reasons.includes(2)?e.raiseError(zn.willRemoveExistingMerge):t.reasons.includes(22)?e.raiseError(zn.wrongFigurePasteOption):t.reasons.includes(75)&&e.raiseError(zn.frozenPaneOverlap))}function Hn(e,t,o){const i=e.model.dispatch("PASTE",{target:t,pasteOption:o});Bn(e,i)}function Wn(e,t,o){const i=e.model.dispatch("PASTE_FROM_OS_CLIPBOARD",{target:t,text:o});Bn(e,i)}function Gn(e,t){const o=En.getAll().find((t=>t.match(e.type)));if(!o)throw new Error("Unknown chart type.");return o.transformDefinition(e,t)}function qn(e,t){var o;let i=e;e.left!==e.right&&(i={...e,left:e.left+1});const r=[To(i)],s=t.getActiveSheetId(),a=t.getCell({sheetId:s,col:e.left,row:e.top});if(1===jo(e)&&(null==a?void 0:a.content))return{type:"scorecard",title:"",background:(null===(o=a.style)||void 0===o?void 0:o.fillColor)||void 0,keyValue:To(e),baselineMode:J,baselineColorUp:ee,baselineColorDown:te};let l="";const c=t.getEvaluatedCellsInZone(s,{...i,bottom:i.top}),h=!!c.find((e=>e.type!==di.empty&&e.type!==di.number));if(h){const e=c.filter((e=>e.type!==di.error&&e.type!==di.empty)).map((e=>e.formattedValue)),t=e.splice(-1)[0];l=e.join(", "),t&&(l+=(l?" "+n("and")+" ":"")+t)}let d;e.left!==e.right&&(d=To({...e,right:e.left,top:h?e.top+1:e.top}));const u=i.right===i.left?"none":"top";return dn(d?t.getRangeFromSheetXC(s,d):void 0,t)?{title:l,dataSets:r,labelsAsText:!1,stacked:!1,aggregated:!1,labelRange:d,type:"line",dataSetsHaveTitle:h,verticalAxisPosition:"left",legendPosition:u}:{title:l,dataSets:r,labelRange:d,type:"bar",stacked:!1,aggregated:!1,dataSetsHaveTitle:h,verticalAxisPosition:"left",legendPosition:u}}function Zn(e,t){const o=Me(t),i=e.getSheetViewDimension(),n=i.width,r=i.height;if(o.width>n){const e=n/o.width;o.width=n,o.height=o.height*e}if(o.height>r){const e=r/o.height;o.height=r,o.width=o.width*e}return o}const jn=[di.number,di.error,di.text,di.boolean];function Xn(e,t,o,i,n){let s=bi.Success,a=i.right>i.left;if(e.model.getters.doesIntersectMerge(t,i)){let o;a=!1;for(let n=i.top;n<=i.bottom;n++){o=[];for(let r=i.left;r<=i.right;r++){let i=e.model.getters.getMerge({sheetId:t,col:r,row:n});i&&!o.includes(i.id.toString())&&o.push(i.id.toString())}if(o.length>=2){a=!0;break}}}const{col:l,row:c}=o;if(a)s=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:i,sortDirection:n});else{const o=e.model.getters.getContiguousZone(t,i);Do(o,i)?s=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:i,sortDirection:n}):e.askConfirmation(r("We found data next to your selection. Since this data was not selected, it will not be sorted. Do you want to extend your selection?"),(()=>{i=o,s=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:i,sortDirection:n})}),(()=>{s=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:i,sortDirection:n})}))}if(s.isCancelledBecause(63)){const{col:t,row:n}=o;e.model.selection.selectZone({cell:{col:t,row:n},zone:i}),e.raiseError(r("Cannot sort. To sort, select only cells or only merges that have the same size."))}}const Yn={filterOverlap:r("You cannot create overlapping filters."),nonContinuousTargets:r("A filter can only be created on a continuous selection."),mergeInFilter:r("You can't create a filter over a range that contains a merge.")};function Kn(e,t,o){const i=e.model.dispatch("CREATE_FILTER_TABLE",{target:o,sheetId:t});i.isCancelledBecause(78)?e.raiseError(Yn.filterOverlap):i.isCancelledBecause(80)?e.raiseError(Yn.mergeInFilter):i.isCancelledBecause(81)&&e.raiseError(Yn.nonContinuousTargets)}function Qn(e){const t=e.model.getters.getActiveCols();if(t.size)return t.size;{const t=e.model.getters.getSelectedZones()[0];return t.right-t.left+1}}function Jn(e){const t=e.model.getters.getActiveRows();if(t.size)return t.size;{const t=e.model.getters.getSelectedZones()[0];return t.bottom-t.top+1}}function er(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),format:t})}function tr(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),style:t})}const or=async e=>{e.model.dispatch("COPY"),await e.clipboard.write(e.model.getters.getClipboardContent())},ir=async e=>{Vn(e),await e.clipboard.write(e.model.getters.getClipboardContent())},nr=async e=>sr(e),rr=async e=>sr(e,"onlyValue");async function sr(e,t){const o=e.model.getters.getClipboardTextContent(),i=await e.clipboard.readText();switch(i.status){case"ok":const n=e.model.getters.getSelectedZones();i&&i.content!==o?Wn(e,n,i.content):Hn(e,n,t);break;case"notImplemented":e.raiseError(r("Pasting from the context menu is not supported in this browser. Use keyboard shortcuts ctrl+c / ctrl+v instead."));break;case"permissionDenied":e.raiseError(r("Access to the clipboard denied by the browser. Please enable clipboard permission for this page in your browser settings."))}}const ar=e=>Hn(e,e.model.getters.getSelectedZones(),"onlyFormat"),lr=e=>!e.model.getters.isCutOperation(),cr=e=>{if(e.model.getters.getSelectedZones().length>1)return r("Delete rows");let t,o;const i=e.model.getters.getActiveRows();if(0!==i.size)t=Math.min(...i),o=Math.max(...i);else{const i=e.model.getters.getSelectedZones()[0];t=i.top,o=i.bottom}return t===o?r("Delete row %s",(t+1).toString()):r("Delete rows %s - %s",(t+1).toString(),(o+1).toString())},hr=e=>{let t=[...e.model.getters.getActiveRows()];if(!t.length){const o=e.model.getters.getSelectedZones()[0];for(let e=o.top;e<=o.bottom;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},dr=e=>{if(e.model.getters.getSelectedZones().length>1)return r("Delete columns");let t,o;const i=e.model.getters.getActiveCols();if(0!==i.size)t=Math.min(...i),o=Math.max(...i);else{const i=e.model.getters.getSelectedZones()[0];t=i.left,o=i.right}return t===o?r("Delete column %s",Mt(t)):r("Delete columns %s - %s",Mt(t),Mt(o))},ur=e=>{let t=[...e.model.getters.getActiveCols()];if(!t.length){const o=e.model.getters.getSelectedZones()[0];for(let e=o.left;e<=o.right;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},gr=e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"ROW"});Bn(e,o)},pr=e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"COL"});Bn(e,o)},mr=e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"ROW"});Bn(e,o)},fr=e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"COL"});Bn(e,o)},vr=e=>{const t=e.model.getters.getActiveRows();let o,i;if(t.size)o=Math.min(...t),i=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.top,i=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",base:o,quantity:i,dimension:"ROW"})},br=e=>{const t=e.model.getters.getActiveRows();let o,i;if(t.size)o=Math.max(...t),i=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.bottom,i=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",base:o,quantity:i,dimension:"ROW"})},Sr=e=>{const t=e.model.getters.getActiveCols();let o,i;if(t.size)o=Math.min(...t),i=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.left,i=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",dimension:"COL",base:o,quantity:i})},Cr=e=>{const t=e.model.getters.getActiveCols();let o,i;if(t.size)o=Math.max(...t),i=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.right,i=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",dimension:"COL",base:o,quantity:i})};const Er=e=>{e.openSidePanel("ConditionalFormatting",{selection:e.model.getters.getSelectedZones()})},wr=e=>{let{col:t,row:o}=e.model.getters.getActivePosition();e.model.dispatch("OPEN_CELL_POPOVER",{col:t,row:o,popoverType:"LinkEditor"})},yr=e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelectedZones();return e.model.getters.doesZonesContainFilter(t,o)},xr=e=>{const{anchor:t,zones:o}=e.model.getters.getSelection(),i=e.model.getters.getActiveSheetId();Xn(e,i,t.cell,o[0],"ascending")},Ir=e=>{const{anchor:t,zones:o}=e.model.getters.getSelection(),i=e.model.getters.getActiveSheetId();Xn(e,i,t.cell,o[0],"descending")},Rr=e=>1===e.model.getters.getSelectedZones().length,Tr=new Rn;Tr.add("cut",{name:r("Cut"),description:"Ctrl+X",sequence:10,action:ir}).add("copy",{name:r("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:or}).add("paste",{name:r("Paste"),description:"Ctrl+V",sequence:30,action:nr}).add("paste_special",{name:r("Paste special"),sequence:40,separator:!0,isVisible:lr}).addChild("paste_value_only",["paste_special"],{name:r("Paste values only"),sequence:10,action:rr}).addChild("paste_format_only",["paste_special"],{name:r("Paste format only"),sequence:20,action:ar}).add("add_row_before",{name:e=>{const t=Jn(e);return 1===t?r("Insert row"):r("Insert %s rows",t.toString())},sequence:70,action:vr,isVisible:Rr}).add("add_column_before",{name:e=>{const t=Qn(e);return 1===t?r("Insert column"):r("Insert %s columns",t.toString())},sequence:90,action:Sr,isVisible:Rr}).add("insert_cell",{name:r("Insert cells"),sequence:100,isVisible:Rr,separator:!0}).addChild("insert_cell_down",["insert_cell"],{name:r("Shift down"),sequence:10,action:gr}).addChild("insert_cell_right",["insert_cell"],{name:r("Shift right"),sequence:20,action:pr}).add("delete_row",{name:cr,sequence:110,action:hr,isVisible:Rr}).add("delete_column",{name:dr,sequence:120,action:ur,isVisible:Rr}).add("delete_cell",{name:r("Delete cells"),sequence:130,isVisible:Rr}).addChild("delete_cell_up",["delete_cell"],{name:r("Shift up"),sequence:10,action:mr}).addChild("delete_cell_down",["delete_cell"],{name:r("Shift left"),sequence:20,action:fr}).add("insert_link",{name:r("Insert link"),separator:!0,sequence:150,action:wr});const Ar=new Rn;Ar.add("cut",{name:r("Cut"),description:"Ctrl+X",sequence:10,action:ir}).add("copy",{name:r("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:or}).add("paste",{name:r("Paste"),description:"Ctrl+V",sequence:30,action:nr}).add("paste_special",{name:r("Paste special"),sequence:40,separator:!0,isVisible:lr}).addChild("paste_value_only",["paste_special"],{name:r("Paste value only"),sequence:10,action:rr}).addChild("paste_format_only",["paste_special"],{name:r("Paste format only"),sequence:20,action:ar}).add("sort_columns",{name:e=>e.model.getters.getActiveCols().size>1?r("Sort columns"):r("Sort column"),sequence:50,isVisible:Rr,separator:!0}).addChild("sort_ascending",["sort_columns"],{name:r("Ascending (A ⟶ Z)"),sequence:10,action:xr}).addChild("sort_descending",["sort_columns"],{name:r("Descending (Z ⟶ A)"),sequence:20,action:Ir}).add("add_column_before",{name:e=>{const t=Qn(e);return 1===t?r("Insert column left"):r("Insert %s columns left",t.toString())},sequence:70,action:Sr}).add("add_column_after",{name:e=>{const t=Qn(e);return 1===t?r("Insert column right"):r("Insert %s columns right",t.toString())},sequence:80,action:Cr}).add("delete_column",{name:dr,sequence:90,action:ur}).add("clear_column",{name:e=>{if(e.model.getters.getSelectedZones().length>1)return r("Clear columns");let t,o;const i=e.model.getters.getActiveCols();if(0!==i.size)t=Math.min(...i),o=Math.max(...i);else{const i=e.model.getters.getSelectedZones()[0];t=i.left,o=i.right}return t===o?r("Clear column %s",Mt(t)):r("Clear columns %s - %s",Mt(t),Mt(o))},sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId(),o=[...e.model.getters.getActiveCols()].map((o=>e.model.getters.getColsZone(t,o,o)));e.model.dispatch("DELETE_CONTENT",{target:o,sheetId:e.model.getters.getActiveSheetId()})}}).add("hide_columns",{name:e=>{const t=e.model.getters.getElementsFromSelection("COL");let o=t[0],i=t[t.length-1];return 1===t.length?r("Hide column %s",Mt(o).toString()):i-o+1===t.length?r("Hide columns %s - %s",Mt(o).toString(),Mt(i).toString()):r("Hide columns")},sequence:85,action:e=>{const t=e.model.getters.getElementsFromSelection("COL");e.model.dispatch("HIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getHiddenColsGroups(t).flat();return e.model.getters.getNumberCols(t)>o.length+e.model.getters.getElementsFromSelection("COL").length},separator:!0}).add("unhide_columns",{name:r("Unhide columns"),sequence:86,action:e=>{const t=e.model.getters.getElementsFromSelection("COL");e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>{const t=e.model.getters.getHiddenColsGroups(e.model.getters.getActiveSheetId()).flat();return e.model.getters.getElementsFromSelection("COL").some((e=>t.includes(e)))},separator:!0}).add("conditional_formatting",{name:r("Conditional formatting"),sequence:110,action:Er});const Or=new Rn;function Mr(e,t,o=(()=>{})){const i=e=>{e.preventDefault(),o(e)},n=t=>{t.preventDefault(),e(t)},r=e=>{e.preventDefault(),t(e),window.removeEventListener("mousedown",i),window.removeEventListener("mouseup",r),window.removeEventListener("dragstart",s),window.removeEventListener("mousemove",n),window.removeEventListener("wheel",n)};function s(e){e.preventDefault()}window.addEventListener("mousedown",i),window.addEventListener("mouseup",r),window.addEventListener("dragstart",s),window.addEventListener("mousemove",n),window.addEventListener("wheel",n,{passive:!1})}function Nr(e,t,o,i=!1){let n,r,s,a,l,c=null;const h=e.model.getters,d=h.getActiveSheetId(),u=Nn();let g,p;const m=o=>{if(n=o,c)return;const{x:s,y:f}=h.getMainViewportCoordinates();let{top:v,left:b,bottom:S,right:C}=h.getActiveMainViewport(),{scrollX:E,scrollY:w}=h.getActiveSheetDOMScrollInfo();const{xSplit:y,ySplit:x}=h.getPaneDivisions(d);let I=!1,R=Dt;const T=n.clientX-u.left;if(g=h.getColIndex(T),"vertical"!==i){const t=r.clientX-u.left,o=h.getEdgeScrollCol(T,t,a);if(o.canEdgeScroll){let t;switch(I=!0,R=Math.min(R,o.delay),o.direction){case"reset":g=y,t=y;break;case 1:g=C,t=b+1;break;case-1:for(g=b-1;e.model.getters.isColHidden(d,g);)g--;t=g}E=h.getColDimensions(d,t).start-s}}const A=n.clientY-u.top;if(p=h.getRowIndex(A),"horizontal"!==i){const t=r.clientY-u.top,o=h.getEdgeScrollRow(A,t,l);if(o.canEdgeScroll){let t;switch(I=!0,R=Math.min(R,o.delay),o.direction){case"reset":p=x,t=x;break;case 1:p=S,t=v+o.direction;break;case-1:for(p=v-1;e.model.getters.isRowHidden(d,p);)p--;t=p}w=e.model.getters.getRowDimensions(d,t).start-f}}I||(-1===p&&(p=A<0?0:h.getNumberRows(d)-1),-1===g&&T<0&&(g=T<0?0:h.getNumberCols(d)-1)),t(g,p,n),I&&(e.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:E,offsetY:w}),c=setTimeout((()=>{c=null,m(n)}),Math.round(R))),r=n};Mr(m,(()=>{clearTimeout(c),o()}),(e=>{r=e,s=e,a=s.clientX-u.left,l=s.clientY-u.top}))}Or.add("cut",{name:r("Cut"),sequence:10,description:"Ctrl+X",action:ir}).add("copy",{name:r("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:or}).add("paste",{name:r("Paste"),description:"Ctrl+V",sequence:30,action:nr}).add("paste_special",{name:r("Paste special"),sequence:40,separator:!0,isVisible:lr}).addChild("paste_value_only",["paste_special"],{name:r("Paste value only"),sequence:10,action:rr}).addChild("paste_format_only",["paste_special"],{name:r("Paste format only"),sequence:20,action:ar}).add("add_row_before",{name:e=>{const t=Jn(e);return 1===t?r("Insert row above"):r("Insert %s rows above",t.toString())},sequence:50,action:vr}).add("add_row_after",{name:e=>{const t=Jn(e);return 1===t?r("Insert row below"):r("Insert %s rows below",t.toString())},sequence:60,action:br}).add("delete_row",{name:cr,sequence:70,action:hr}).add("clear_row",{name:e=>{if(e.model.getters.getSelectedZones().length>1)return r("Clear rows");let t,o;const i=e.model.getters.getActiveRows();if(0!==i.size)t=Math.min(...i),o=Math.max(...i);else{const i=e.model.getters.getSelectedZones()[0];t=i.top,o=i.bottom}return t===o?r("Clear row %s",(t+1).toString()):r("Clear rows %s - %s",(t+1).toString(),(o+1).toString())},sequence:80,action:e=>{const t=e.model.getters.getActiveSheetId(),o=[...e.model.getters.getActiveRows()].map((o=>e.model.getters.getRowsZone(t,o,o)));e.model.dispatch("DELETE_CONTENT",{target:o,sheetId:e.model.getters.getActiveSheetId()})}}).add("hide_rows",{name:e=>{const t=e.model.getters.getElementsFromSelection("ROW");let o=t[0],i=t[t.length-1];return 1===t.length?r("Hide row %s",(o+1).toString()):i-o+1===t.length?r("Hide rows %s - %s",(o+1).toString(),(i+1).toString()):r("Hide rows")},sequence:85,action:e=>{const t=e.model.getters.getElementsFromSelection("ROW");e.model.dispatch("HIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getHiddenRowsGroups(t).flat();return e.model.getters.getNumberRows(t)>o.length+e.model.getters.getElementsFromSelection("ROW").length},separator:!0}).add("unhide_rows",{name:r("Unhide rows"),sequence:86,action:e=>{const t=e.model.getters.getElementsFromSelection("ROW");e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>{const t=e.model.getters.getHiddenRowsGroups(e.model.getters.getActiveSheetId()).flat();return e.model.getters.getElementsFromSelection("ROW").some((e=>t.includes(e)))},separator:!0}).add("conditional_formatting",{name:r("Conditional formatting"),sequence:90,action:Er}),Jo`
117
+ `;class Un extends t.Component{constructor(){super(...arguments),this.menuState=t.useState({isOpen:!1,position:null,menuItems:[]}),this.chartContainerRef=t.useRef("chartContainer"),this.menuButtonRef=t.useRef("menuButton"),this.menuButtonRect=An(this.menuButtonRef),this.position=An(this.chartContainerRef)}getMenuItemRegistry(){const e=new Rn;return e.add("edit",{name:r("Edit"),sequence:1,action:()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.props.figure.id}),this.env.openSidePanel("ChartPanel")}}),e.add("copy",{name:r("Copy"),sequence:2,action:async()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.props.figure.id}),this.env.model.dispatch("COPY"),await this.env.clipboard.write(this.env.model.getters.getClipboardContent())}}),e.add("cut",{name:r("Cut"),sequence:3,action:async()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.props.figure.id}),this.env.model.dispatch("CUT"),await this.env.clipboard.write(this.env.model.getters.getClipboardContent())}}),e.add("delete",{name:r("Delete"),sequence:10,action:()=>{this.env.model.dispatch("DELETE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:this.props.figure.id}),this.props.onFigureDeleted()}}),e}get chartType(){return this.env.model.getters.getChartType(this.env.model.getters.getActiveSheetId(),this.props.figure.id)}onContextMenu(e){const t={x:this.position.x+e.offsetX,y:this.position.y+e.offsetY};this.openContextMenu(t)}showMenu(){const{x:e,y:t,width:o}=this.menuButtonRect,i={x:e>=z?e-z:e+o,y:t};this.openContextMenu(i)}openContextMenu(e){const t=this.getMenuItemRegistry();this.menuState.isOpen=!0,this.menuState.menuItems=t.getAll().filter((e=>e.isVisible(this.env))),this.menuState.position=e}get chartComponent(){const e=this.chartType,t=wn.get(e);if(!t)throw new Error(`Component is not defined for type ${e}`);return t}}function Vn(e){const t=e.model.dispatch("CUT");t.isSuccessful||t.isCancelledBecause(19)&&e.raiseError(r("This operation is not allowed with multiple selections."))}Un.template="o-spreadsheet-ChartFigure",Un.components={Menu:Ln},Un.props={figure:Object,onFigureDeleted:Function};const zn={wrongPasteSelection:r("This operation is not allowed with multiple selections."),willRemoveExistingMerge:r("This operation is not possible due to a merge. Please remove the merges first than try again."),wrongFigurePasteOption:r("Cannot do a special paste of a figure."),frozenPaneOverlap:r("Cannot paste merged cells over a frozen pane.")};function Bn(e,t){t.isSuccessful||(t.reasons.includes(20)?e.raiseError(zn.wrongPasteSelection):t.reasons.includes(2)?e.raiseError(zn.willRemoveExistingMerge):t.reasons.includes(22)?e.raiseError(zn.wrongFigurePasteOption):t.reasons.includes(75)&&e.raiseError(zn.frozenPaneOverlap))}function Hn(e,t,o){const i=e.model.dispatch("PASTE",{target:t,pasteOption:o});Bn(e,i)}function Wn(e,t,o){const i=e.model.dispatch("PASTE_FROM_OS_CLIPBOARD",{target:t,text:o});Bn(e,i)}function Gn(e,t){const o=En.getAll().find((t=>t.match(e.type)));if(!o)throw new Error("Unknown chart type.");return o.transformDefinition(e,t)}function qn(e,t){var o;let i=e;e.left!==e.right&&(i={...e,left:e.left+1});const r=[To(i)],s=t.getActiveSheetId(),a=t.getCell({sheetId:s,col:e.left,row:e.top});if(1===jo(e)&&(null==a?void 0:a.content))return{type:"scorecard",title:"",background:(null===(o=a.style)||void 0===o?void 0:o.fillColor)||void 0,keyValue:To(e),baselineMode:J,baselineColorUp:ee,baselineColorDown:te};let l="";const c=t.getEvaluatedCellsInZone(s,{...i,bottom:i.top}),h=!!c.find((e=>e.type!==di.empty&&e.type!==di.number));if(h){const e=c.filter((e=>e.type!==di.error&&e.type!==di.empty)).map((e=>e.formattedValue)),t=e.splice(-1)[0];l=e.join(", "),t&&(l+=(l?" "+n("and")+" ":"")+t)}let d;e.left!==e.right&&(d=To({...e,right:e.left,top:h?e.top+1:e.top}));const u=i.right===i.left?"none":"top";return dn(d?t.getRangeFromSheetXC(s,d):void 0,t)?{title:l,dataSets:r,labelsAsText:!1,stacked:!1,aggregated:!1,labelRange:d,type:"line",dataSetsHaveTitle:h,verticalAxisPosition:"left",legendPosition:u}:{title:l,dataSets:r,labelRange:d,type:"bar",stacked:!1,aggregated:!1,dataSetsHaveTitle:h,verticalAxisPosition:"left",legendPosition:u}}function Zn(e,t){const o=Me(t),i=e.getSheetViewDimension(),n=i.width,r=i.height;if(o.width>n){const e=n/o.width;o.width=n,o.height=o.height*e}if(o.height>r){const e=r/o.height;o.height=r,o.width=o.width*e}return o}const jn=[di.number,di.error,di.text,di.boolean];function Xn(e,t,o,i,n){let s=bi.Success,a=i.right>i.left;if(e.model.getters.doesIntersectMerge(t,i)){let o;a=!1;for(let n=i.top;n<=i.bottom;n++){o=[];for(let r=i.left;r<=i.right;r++){let i=e.model.getters.getMerge({sheetId:t,col:r,row:n});i&&!o.includes(i.id.toString())&&o.push(i.id.toString())}if(o.length>=2){a=!0;break}}}const{col:l,row:c}=o;if(a)s=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:i,sortDirection:n});else{const o=e.model.getters.getContiguousZone(t,i);Do(o,i)?s=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:i,sortDirection:n}):e.askConfirmation(r("We found data next to your selection. Since this data was not selected, it will not be sorted. Do you want to extend your selection?"),(()=>{i=o,s=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:i,sortDirection:n})}),(()=>{s=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:i,sortDirection:n})}))}if(s.isCancelledBecause(63)){const{col:t,row:n}=o;e.model.selection.selectZone({cell:{col:t,row:n},zone:i}),e.raiseError(r("Cannot sort. To sort, select only cells or only merges that have the same size."))}}const Yn={filterOverlap:r("You cannot create overlapping filters."),nonContinuousTargets:r("A filter can only be created on a continuous selection."),mergeInFilter:r("You can't create a filter over a range that contains a merge.")};function Kn(e,t,o){const i=e.model.dispatch("CREATE_FILTER_TABLE",{target:o,sheetId:t});i.isCancelledBecause(78)?e.raiseError(Yn.filterOverlap):i.isCancelledBecause(80)?e.raiseError(Yn.mergeInFilter):i.isCancelledBecause(81)&&e.raiseError(Yn.nonContinuousTargets)}function Qn(e){const t=e.model.getters.getActiveCols();if(t.size)return t.size;{const t=e.model.getters.getSelectedZones()[0];return t.right-t.left+1}}function Jn(e){const t=e.model.getters.getActiveRows();if(t.size)return t.size;{const t=e.model.getters.getSelectedZones()[0];return t.bottom-t.top+1}}function er(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),format:t})}function tr(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),style:t})}const or=async e=>{e.model.dispatch("COPY"),await e.clipboard.write(e.model.getters.getClipboardContent())},ir=async e=>{Vn(e),await e.clipboard.write(e.model.getters.getClipboardContent())},nr=async e=>sr(e),rr=async e=>sr(e,"onlyValue");async function sr(e,t){const o=e.model.getters.getClipboardTextContent(),i=await e.clipboard.readText();switch(i.status){case"ok":const n=e.model.getters.getSelectedZones();i&&i.content!==o?Wn(e,n,i.content):Hn(e,n,t);break;case"notImplemented":e.raiseError(r("Pasting from the context menu is not supported in this browser. Use keyboard shortcuts ctrl+c / ctrl+v instead."));break;case"permissionDenied":e.raiseError(r("Access to the clipboard denied by the browser. Please enable clipboard permission for this page in your browser settings."))}}const ar=e=>Hn(e,e.model.getters.getSelectedZones(),"onlyFormat"),lr=e=>!e.model.getters.isCutOperation(),cr=e=>{if(e.model.getters.getSelectedZones().length>1)return r("Delete rows");let t,o;const i=e.model.getters.getActiveRows();if(0!==i.size)t=Math.min(...i),o=Math.max(...i);else{const i=e.model.getters.getSelectedZones()[0];t=i.top,o=i.bottom}return t===o?r("Delete row %s",(t+1).toString()):r("Delete rows %s - %s",(t+1).toString(),(o+1).toString())},hr=e=>{let t=[...e.model.getters.getActiveRows()];if(!t.length){const o=e.model.getters.getSelectedZones()[0];for(let e=o.top;e<=o.bottom;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},dr=e=>{if(e.model.getters.getSelectedZones().length>1)return r("Delete columns");let t,o;const i=e.model.getters.getActiveCols();if(0!==i.size)t=Math.min(...i),o=Math.max(...i);else{const i=e.model.getters.getSelectedZones()[0];t=i.left,o=i.right}return t===o?r("Delete column %s",Mt(t)):r("Delete columns %s - %s",Mt(t),Mt(o))},ur=e=>{let t=[...e.model.getters.getActiveCols()];if(!t.length){const o=e.model.getters.getSelectedZones()[0];for(let e=o.left;e<=o.right;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},gr=e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"ROW"});Bn(e,o)},pr=e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"COL"});Bn(e,o)},mr=e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"ROW"});Bn(e,o)},fr=e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"COL"});Bn(e,o)},vr=e=>{const t=e.model.getters.getActiveRows();let o,i;if(t.size)o=Math.min(...t),i=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.top,i=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",base:o,quantity:i,dimension:"ROW"})},br=e=>{const t=e.model.getters.getActiveRows();let o,i;if(t.size)o=Math.max(...t),i=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.bottom,i=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",base:o,quantity:i,dimension:"ROW"})},Sr=e=>{const t=e.model.getters.getActiveCols();let o,i;if(t.size)o=Math.min(...t),i=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.left,i=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",dimension:"COL",base:o,quantity:i})},Cr=e=>{const t=e.model.getters.getActiveCols();let o,i;if(t.size)o=Math.max(...t),i=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.right,i=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",dimension:"COL",base:o,quantity:i})};const Er=e=>{e.openSidePanel("ConditionalFormatting",{selection:e.model.getters.getSelectedZones()})},wr=e=>{let{col:t,row:o}=e.model.getters.getActivePosition();e.model.dispatch("OPEN_CELL_POPOVER",{col:t,row:o,popoverType:"LinkEditor"})},yr=e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelectedZones();return e.model.getters.doesZonesContainFilter(t,o)},xr=e=>{const{anchor:t,zones:o}=e.model.getters.getSelection(),i=e.model.getters.getActiveSheetId();Xn(e,i,t.cell,o[0],"ascending")},Ir=e=>{const{anchor:t,zones:o}=e.model.getters.getSelection(),i=e.model.getters.getActiveSheetId();Xn(e,i,t.cell,o[0],"descending")},Rr=e=>1===e.model.getters.getSelectedZones().length,Tr=new Rn;Tr.add("cut",{name:r("Cut"),description:"Ctrl+X",sequence:10,action:ir}).add("copy",{name:r("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:or}).add("paste",{name:r("Paste"),description:"Ctrl+V",sequence:30,action:nr}).add("paste_special",{name:r("Paste special"),sequence:40,separator:!0,isVisible:lr}).addChild("paste_value_only",["paste_special"],{name:r("Paste values only"),sequence:10,action:rr}).addChild("paste_format_only",["paste_special"],{name:r("Paste format only"),sequence:20,action:ar}).add("add_row_before",{name:e=>{const t=Jn(e);return 1===t?r("Insert row"):r("Insert %s rows",t.toString())},sequence:70,action:vr,isVisible:Rr}).add("add_column_before",{name:e=>{const t=Qn(e);return 1===t?r("Insert column"):r("Insert %s columns",t.toString())},sequence:90,action:Sr,isVisible:Rr}).add("insert_cell",{name:r("Insert cells"),sequence:100,isVisible:Rr,separator:!0}).addChild("insert_cell_down",["insert_cell"],{name:r("Shift down"),sequence:10,action:gr}).addChild("insert_cell_right",["insert_cell"],{name:r("Shift right"),sequence:20,action:pr}).add("delete_row",{name:cr,sequence:110,action:hr,isVisible:Rr}).add("delete_column",{name:dr,sequence:120,action:ur,isVisible:Rr}).add("delete_cell",{name:r("Delete cells"),sequence:130,isVisible:Rr}).addChild("delete_cell_up",["delete_cell"],{name:r("Shift up"),sequence:10,action:mr}).addChild("delete_cell_down",["delete_cell"],{name:r("Shift left"),sequence:20,action:fr}).add("insert_link",{name:r("Insert link"),separator:!0,sequence:150,action:wr});const Ar=new Rn;Ar.add("cut",{name:r("Cut"),description:"Ctrl+X",sequence:10,action:ir}).add("copy",{name:r("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:or}).add("paste",{name:r("Paste"),description:"Ctrl+V",sequence:30,action:nr}).add("paste_special",{name:r("Paste special"),sequence:40,separator:!0,isVisible:lr}).addChild("paste_value_only",["paste_special"],{name:r("Paste value only"),sequence:10,action:rr}).addChild("paste_format_only",["paste_special"],{name:r("Paste format only"),sequence:20,action:ar}).add("sort_columns",{name:e=>e.model.getters.getActiveCols().size>1?r("Sort columns"):r("Sort column"),sequence:50,isVisible:Rr,separator:!0}).addChild("sort_ascending",["sort_columns"],{name:r("Ascending (A ⟶ Z)"),sequence:10,action:xr}).addChild("sort_descending",["sort_columns"],{name:r("Descending (Z ⟶ A)"),sequence:20,action:Ir}).add("add_column_before",{name:e=>{const t=Qn(e);return 1===t?r("Insert column left"):r("Insert %s columns left",t.toString())},sequence:70,action:Sr}).add("add_column_after",{name:e=>{const t=Qn(e);return 1===t?r("Insert column right"):r("Insert %s columns right",t.toString())},sequence:80,action:Cr}).add("delete_column",{name:dr,sequence:90,action:ur}).add("clear_column",{name:e=>{if(e.model.getters.getSelectedZones().length>1)return r("Clear columns");let t,o;const i=e.model.getters.getActiveCols();if(0!==i.size)t=Math.min(...i),o=Math.max(...i);else{const i=e.model.getters.getSelectedZones()[0];t=i.left,o=i.right}return t===o?r("Clear column %s",Mt(t)):r("Clear columns %s - %s",Mt(t),Mt(o))},sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId(),o=[...e.model.getters.getActiveCols()].map((o=>e.model.getters.getColsZone(t,o,o)));e.model.dispatch("DELETE_CONTENT",{target:o,sheetId:e.model.getters.getActiveSheetId()})}}).add("hide_columns",{name:e=>{const t=e.model.getters.getElementsFromSelection("COL");let o=t[0],i=t[t.length-1];return 1===t.length?r("Hide column %s",Mt(o).toString()):i-o+1===t.length?r("Hide columns %s - %s",Mt(o).toString(),Mt(i).toString()):r("Hide columns")},sequence:85,action:e=>{const t=e.model.getters.getElementsFromSelection("COL");e.model.dispatch("HIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getHiddenColsGroups(t).flat();return e.model.getters.getNumberCols(t)>o.length+e.model.getters.getElementsFromSelection("COL").length},separator:!0}).add("unhide_columns",{name:r("Unhide columns"),sequence:86,action:e=>{const t=e.model.getters.getElementsFromSelection("COL");e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>{const t=e.model.getters.getHiddenColsGroups(e.model.getters.getActiveSheetId()).flat();return e.model.getters.getElementsFromSelection("COL").some((e=>t.includes(e)))},separator:!0}).add("conditional_formatting",{name:r("Conditional formatting"),sequence:110,action:Er});const Or=new Rn;function Mr(e,t,o=(()=>{})){const i=e=>{e.preventDefault(),o(e)},n=t=>{t.preventDefault(),e(t)},r=e=>{e.preventDefault(),t(e),window.removeEventListener("mousedown",i),window.removeEventListener("mouseup",r),window.removeEventListener("dragstart",s),window.removeEventListener("mousemove",n),window.removeEventListener("wheel",n)};function s(e){e.preventDefault()}window.addEventListener("mousedown",i),window.addEventListener("mouseup",r),window.addEventListener("dragstart",s),window.addEventListener("mousemove",n),window.addEventListener("wheel",n,{passive:!1})}function Nr(e,t,o,i=!1){let n,r,s,a,l,c=null;const h=e.model.getters,d=h.getActiveSheetId(),u=Nn();let g,p;const m=o=>{if(n=o,c)return;const{x:s,y:f}=h.getMainViewportCoordinates();let{top:v,left:b,bottom:S,right:C}=h.getActiveMainViewport(),{scrollX:E,scrollY:w}=h.getActiveSheetDOMScrollInfo();const{xSplit:y,ySplit:x}=h.getPaneDivisions(d);let I=!1,R=Dt;const T=n.clientX-u.left;if(g=h.getColIndex(T),"vertical"!==i){const t=r.clientX-u.left,o=h.getEdgeScrollCol(T,t,a);if(o.canEdgeScroll){let t;switch(I=!0,R=Math.min(R,o.delay),o.direction){case"reset":g=y,t=y;break;case 1:g=C,t=b+1;break;case-1:for(g=b-1;e.model.getters.isColHidden(d,g);)g--;t=g}E=h.getColDimensions(d,t).start-s}}const A=n.clientY-u.top;if(p=h.getRowIndex(A),"horizontal"!==i){const t=r.clientY-u.top,o=h.getEdgeScrollRow(A,t,l);if(o.canEdgeScroll){let t;switch(I=!0,R=Math.min(R,o.delay),o.direction){case"reset":p=x,t=x;break;case 1:p=S,t=v+o.direction;break;case-1:for(p=v-1;e.model.getters.isRowHidden(d,p);)p--;t=p}w=e.model.getters.getRowDimensions(d,t).start-f}}I||(-1===p&&(p=A<0?0:h.getNumberRows(d)-1),-1===g&&T<0&&(g=T<0?0:h.getNumberCols(d)-1)),t(g,p,n),I&&(e.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:E,offsetY:w}),c=setTimeout((()=>{c=null,m(n)}),Math.round(R))),r=n};Mr(m,(()=>{clearTimeout(c),o()}),(e=>{r=e,s=e,a=s.clientX-u.left,l=s.clientY-u.top}))}Or.add("cut",{name:r("Cut"),sequence:10,description:"Ctrl+X",action:ir}).add("copy",{name:r("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:or}).add("paste",{name:r("Paste"),description:"Ctrl+V",sequence:30,action:nr}).add("paste_special",{name:r("Paste special"),sequence:40,separator:!0,isVisible:lr}).addChild("paste_value_only",["paste_special"],{name:r("Paste value only"),sequence:10,action:rr}).addChild("paste_format_only",["paste_special"],{name:r("Paste format only"),sequence:20,action:ar}).add("add_row_before",{name:e=>{const t=Jn(e);return 1===t?r("Insert row above"):r("Insert %s rows above",t.toString())},sequence:50,action:vr}).add("add_row_after",{name:e=>{const t=Jn(e);return 1===t?r("Insert row below"):r("Insert %s rows below",t.toString())},sequence:60,action:br}).add("delete_row",{name:cr,sequence:70,action:hr}).add("clear_row",{name:e=>{if(e.model.getters.getSelectedZones().length>1)return r("Clear rows");let t,o;const i=e.model.getters.getActiveRows();if(0!==i.size)t=Math.min(...i),o=Math.max(...i);else{const i=e.model.getters.getSelectedZones()[0];t=i.top,o=i.bottom}return t===o?r("Clear row %s",(t+1).toString()):r("Clear rows %s - %s",(t+1).toString(),(o+1).toString())},sequence:80,action:e=>{const t=e.model.getters.getActiveSheetId(),o=[...e.model.getters.getActiveRows()].map((o=>e.model.getters.getRowsZone(t,o,o)));e.model.dispatch("DELETE_CONTENT",{target:o,sheetId:e.model.getters.getActiveSheetId()})}}).add("hide_rows",{name:e=>{const t=e.model.getters.getElementsFromSelection("ROW");let o=t[0],i=t[t.length-1];return 1===t.length?r("Hide row %s",(o+1).toString()):i-o+1===t.length?r("Hide rows %s - %s",(o+1).toString(),(i+1).toString()):r("Hide rows")},sequence:85,action:e=>{const t=e.model.getters.getElementsFromSelection("ROW");e.model.dispatch("HIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getHiddenRowsGroups(t).flat();return e.model.getters.getNumberRows(t)>o.length+e.model.getters.getElementsFromSelection("ROW").length},separator:!0}).add("unhide_rows",{name:r("Unhide rows"),sequence:86,action:e=>{const t=e.model.getters.getElementsFromSelection("ROW");e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>{const t=e.model.getters.getHiddenRowsGroups(e.model.getters.getActiveSheetId()).flat();return e.model.getters.getElementsFromSelection("ROW").some((e=>t.includes(e)))},separator:!0}).add("conditional_formatting",{name:r("Conditional formatting"),sequence:90,action:Er}),Jo`
118
118
  .o-autofill {
119
119
  height: 6px;
120
120
  width: 6px;
@@ -530,7 +530,7 @@
530
530
  }
531
531
  }
532
532
  }
533
- `;class kg extends t.Component{constructor(){super(...arguments),this.menuItems=Dg.getAll(),this.link=t.useState(this.defaultState),this.menu=t.useState({isOpen:!1}),this.linkEditorRef=t.useRef("linkEditor"),this.position=An(this.linkEditorRef),this.urlInput=t.useRef("urlInput")}setup(){t.onMounted((()=>{var e;return null===(e=this.urlInput.el)||void 0===e?void 0:e.focus()}))}get defaultState(){const{col:e,row:t}=this.props.cellPosition,o=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getEvaluatedCell({sheetId:o,col:e,row:t});return i.link?{url:i.link.url,label:i.formattedValue,isUrlEditable:i.link.isUrlEditable}:{label:i.formattedValue,url:"",isUrlEditable:!0}}get menuPosition(){return{x:this.position.x+320-12-2,y:this.position.y+100}}onSpecialLink(e){const{detail:t}=e,o=mg(t);o&&(this.link.url=o.url,this.link.label=o.label,this.link.isUrlEditable=o.isUrlEditable)}getUrlRepresentation(e){return gg(e,this.env.model.getters)}openMenu(){this.menu.isOpen=!0}removeLink(){this.link.url="",this.link.isUrlEditable=!0}save(){var e,t;const{col:o,row:i}=this.props.cellPosition,n=this.link.label||this.link.url;this.env.model.dispatch("UPDATE_CELL",{col:o,row:i,sheetId:this.env.model.getters.getActiveSheetId(),content:qe(n,this.link.url)}),null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}cancel(){var e,t;null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}onKeyDown(e){switch(e.key){case"Enter":this.link.url&&this.save(),e.stopPropagation();break;case"Escape":this.cancel(),e.stopPropagation()}}}kg.template="o-spreadsheet-LinkEditor",kg.components={Menu:Ln};const $g={onOpen:(e,t)=>({isOpen:!0,props:{cellPosition:e},Component:kg,cellCorner:"BottomLeft"})};kg.props={cellPosition:Object,onClosed:{type:Function,optional:!0}};const Pg=new Cn;Pg.add("ErrorToolTip",Tg).add("LinkCell",Fg).add("LinkEditor",$g).add("FilterMenu",Ng);const Lg=new Cn;class Ug extends t.Component{constructor(){super(...arguments),this.menuState=t.useState({isOpen:!1,position:null,menuItems:[]}),this.imageContainerRef=t.useRef("o-image"),this.menuButtonRef=t.useRef("menuButton"),this.menuButtonPosition=An(this.menuButtonRef),this.position=An(this.imageContainerRef)}getMenuItemRegistry(){const e=new Rn;return e.add("copy",{name:r("Copy"),description:"Ctrl+C",sequence:1,action:async()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.figureId}),this.env.model.dispatch("COPY"),await this.env.clipboard.write(this.env.model.getters.getClipboardContent())}}),e.add("cut",{name:r("Cut"),description:"Ctrl+X",sequence:2,action:async()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.figureId}),this.env.model.dispatch("CUT"),await this.env.clipboard.write(this.env.model.getters.getClipboardContent())}}),e.add("reset_size",{name:r("Reset size"),sequence:3,action:()=>{const e=this.env.model.getters.getImage(this.env.model.getters.getActiveSheetId(),this.figureId).size,{height:t,width:o}=Zn(this.env.model.getters,e);this.env.model.dispatch("UPDATE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:this.figureId,height:t,width:o})}}),e.add("delete",{name:r("Delete image"),description:"delete",sequence:5,action:()=>{this.env.model.dispatch("DELETE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:this.figureId})}}),e}onContextMenu(e){const t={x:this.position.x+e.offsetX,y:this.position.y+e.offsetY};this.openContextMenu(t)}showMenu(){const e={x:this.menuButtonPosition.x-z,y:this.menuButtonPosition.y};this.openContextMenu(e)}openContextMenu(e){const t=this.getMenuItemRegistry();this.menuState.isOpen=!0,this.menuState.menuItems=t.getAll().filter((e=>e.isVisible(this.env))),this.menuState.position=e}get figureId(){return this.props.figure.id}get getImagePath(){return this.env.model.getters.getImage(this.env.model.getters.getActiveSheetId(),this.figureId).path}}Ug.template="o-spreadsheet-ImageFigure",Ug.components={Menu:Ln},Ug.props={figure:Object,onFigureDeleted:Function};const Vg=new Cn;Vg.add("chart",{Component:Un,SidePanelComponent:"ChartPanel"}),Vg.add("image",{Component:Ug,keepRatio:!0,minFigSize:20,borderWidth:0});const zg=(new Cn).add("ADD_COLUMNS_ROWS",(function(e){const t=[];let o=e.base;"after"===e.position&&o++;for(let i=0;i<e.quantity;i++)t.push(i+o);return[{type:"REMOVE_COLUMNS_ROWS",dimension:e.dimension,elements:t,sheetId:e.sheetId}]})).add("REMOVE_COLUMNS_ROWS",(function(e){const t=[],o=[...e.elements].sort(((e,t)=>e-t));for(let i of Ue(o)){const o=0===i[0]?0:i[0]-1,n=0===i[0]?"before":"after";t.push({type:"ADD_COLUMNS_ROWS",dimension:e.dimension,quantity:i.length,base:o,sheetId:e.sheetId,position:n})}return t})).add("ADD_MERGE",(function(e){return[{type:"REMOVE_MERGE",sheetId:e.sheetId,target:e.target}]})).add("REMOVE_MERGE",(function(e){return[{type:"ADD_MERGE",sheetId:e.sheetId,target:e.target}]})).add("CREATE_SHEET",(function(e){return[{type:"DELETE_SHEET",sheetId:e.sheetId}]})).add("DELETE_SHEET",(function(e){return[{type:"CREATE_SHEET",sheetId:e.sheetId,position:1}]})).add("DUPLICATE_SHEET",(function(e){return[{type:"DELETE_SHEET",sheetId:e.sheetIdTo}]})).add("CREATE_FIGURE",(function(e){return[{type:"DELETE_FIGURE",id:e.figure.id,sheetId:e.sheetId}]})).add("CREATE_CHART",(function(e){return[{type:"DELETE_FIGURE",id:e.id,sheetId:e.sheetId}]})).add("HIDE_COLUMNS_ROWS",(function(e){return[{type:"UNHIDE_COLUMNS_ROWS",sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]})).add("UNHIDE_COLUMNS_ROWS",(function(e){return[{type:"HIDE_COLUMNS_ROWS",sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]}));for(const e of fi.values())zg.contains(e)||zg.add(e,Bg);function Bg(e){return[e]}function Hg(e,t,o){const i=e.model.getters.getSheetName(t),n=r("Rename Sheet");e.editText(n,(o=>{if(null===o||o===i)return;""===o&&Hg(e,t,r("The sheet name cannot be empty."));const n=e.model.dispatch("RENAME_SHEET",{sheetId:t,name:o});n.isSuccessful||(n.reasons.includes(11)&&Hg(e,t,r("A sheet with the name %s already exists. Please select another name.",o)),n.reasons.includes(13)&&Hg(e,t,r("Some used characters are not allowed in a sheet name (Forbidden characters are %s).",ie.join(" "))))}),{placeholder:i,error:o})}const Wg=new Rn;function Gg(e,t,o){const i=e.model.getters.getActiveSheetId(),n="COL"===t?"FREEZE_COLUMNS":"FREEZE_ROWS";e.model.dispatch(n,{sheetId:i,quantity:o}).isCancelledBecause(65)&&e.raiseError(Hi)}Wg.add("delete",{name:r("Delete"),sequence:10,isVisible:e=>e.model.getters.getSheetIds().length>1,action:e=>e.askConfirmation(r("Are you sure you want to delete this sheet ?"),(()=>{e.model.dispatch("DELETE_SHEET",{sheetId:e.model.getters.getActiveSheetId()})}))}).add("duplicate",{name:r("Duplicate"),sequence:20,action:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.uuidGenerator.uuidv4();e.model.dispatch("DUPLICATE_SHEET",{sheetId:t,sheetIdTo:o}),e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:o})}}).add("rename",{name:r("Rename"),sequence:30,action:e=>Hg(e,e.model.getters.getActiveSheetId())}).add("move_right",{name:r("Move right"),sequence:40,isVisible:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getVisibleSheetIds();return o.indexOf(t)!==o.length-1},action:e=>e.model.dispatch("MOVE_SHEET",{sheetId:e.model.getters.getActiveSheetId(),direction:"right"})}).add("move_left",{name:r("Move left"),sequence:50,isVisible:e=>{const t=e.model.getters.getActiveSheetId();return e.model.getters.getVisibleSheetIds()[0]!==t},action:e=>e.model.dispatch("MOVE_SHEET",{sheetId:e.model.getters.getActiveSheetId(),direction:"left"})}).add("hide_sheet",{name:r("Hide sheet"),sequence:60,isVisible:e=>1!==e.model.getters.getVisibleSheetIds().length,action:e=>e.model.dispatch("HIDE_SHEET",{sheetId:e.model.getters.getActiveSheetId()})});const qg=new Rn;qg.add("file",{name:r("File"),sequence:10}).add("edit",{name:r("Edit"),sequence:20}).add("view",{name:r("View"),sequence:30}).add("insert",{name:r("Insert"),sequence:40}).add("format",{name:r("Format"),sequence:50}).add("data",{name:r("Data"),sequence:60}).addChild("save",["file"],{name:r("Save"),description:"Ctrl+S",sequence:10,action:()=>console.log("Not implemented")}).addChild("undo",["edit"],{name:r("Undo"),description:"Ctrl+Z",sequence:10,action:e=>e.model.dispatch("REQUEST_UNDO")}).addChild("redo",["edit"],{name:r("Redo"),description:"Ctrl+Y",sequence:20,action:e=>e.model.dispatch("REQUEST_REDO"),separator:!0}).addChild("copy",["edit"],{name:r("Copy"),description:"Ctrl+C",sequence:30,isReadonlyAllowed:!0,action:or}).addChild("cut",["edit"],{name:r("Cut"),description:"Ctrl+X",sequence:40,action:ir}).addChild("paste",["edit"],{name:r("Paste"),description:"Ctrl+V",sequence:50,action:nr}).addChild("paste_special",["edit"],{name:r("Paste special"),sequence:60,separator:!0,isVisible:lr}).addChild("paste_special_value",["edit","paste_special"],{name:r("Paste value only"),sequence:10,action:rr}).addChild("paste_special_format",["edit","paste_special"],{name:r("Paste format only"),sequence:20,action:ar}).addChild("sort_range",["data"],{name:r("Sort range"),sequence:20,isVisible:Rr,separator:!0}).addChild("sort_ascending",["data","sort_range"],{name:r("Ascending (A ⟶ Z)"),sequence:10,action:xr}).addChild("sort_descending",["data","sort_range"],{name:r("Descending (Z ⟶ A)"),sequence:20,action:Ir}).addChild("find_and_replace",["edit"],{name:r("Find and replace"),description:"Ctrl+H",sequence:65,isReadonlyAllowed:!0,action:e=>{e.openSidePanel("FindAndReplace",{})},separator:!0}).addChild("edit_delete_cell_values",["edit"],{name:r("Delete values"),sequence:70,action:e=>e.model.dispatch("DELETE_CONTENT",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()})}).addChild("edit_delete_row",["edit"],{name:cr,sequence:80,action:hr}).addChild("edit_delete_column",["edit"],{name:dr,sequence:90,action:ur}).addChild("edit_delete_cell_shift_up",["edit"],{name:r("Delete cell and shift up"),sequence:93,action:mr}).addChild("edit_delete_cell_shift_left",["edit"],{name:r("Delete cell and shift left"),sequence:97,action:fr}).addChild("edit_unhide_columns",["edit"],{name:r("Unhide all columns"),sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:t,dimension:"COL",elements:Array.from(Array(e.model.getters.getNumberCols(t)).keys())})},isVisible:e=>e.model.getters.getHiddenColsGroups(e.model.getters.getActiveSheetId()).length>0}).addChild("edit_unhide_rows",["edit"],{name:r("Unhide all rows"),sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:t,dimension:"ROW",elements:Array.from(Array(e.model.getters.getNumberRows(t)).keys())})},isVisible:e=>e.model.getters.getHiddenRowsGroups(e.model.getters.getActiveSheetId()).length>0}).addChild("insert_row_before",["insert"],{name:e=>{const t=Jn(e);return 1===t?r("Row above"):r("%s Rows above",t.toString())},sequence:10,action:vr,isVisible:e=>0===e.model.getters.getActiveCols().size}).addChild("insert_row_after",["insert"],{name:e=>{const t=Jn(e);return 1===t?r("Row below"):r("%s Rows below",t.toString())},sequence:20,action:br,isVisible:e=>0===e.model.getters.getActiveCols().size,separator:!0}).addChild("insert_column_before",["insert"],{name:e=>{const t=Qn(e);return 1===t?r("Column left"):r("%s Columns left",t.toString())},sequence:30,action:Sr,isVisible:e=>0===e.model.getters.getActiveRows().size}).addChild("insert_column_after",["insert"],{name:e=>{const t=Qn(e);return 1===t?r("Column right"):r("%s Columns right",t.toString())},sequence:40,action:Cr,isVisible:e=>0===e.model.getters.getActiveRows().size,separator:!0}).addChild("insert_insert_cell_shift_down",["insert"],{name:r("Insert cells and shift down"),sequence:43,action:gr}).addChild("insert_insert_cell_shift_right",["insert"],{name:r("Insert cells and shift right"),sequence:47,action:pr,separator:!0}).addChild("insert_chart",["insert"],{name:r("Chart"),sequence:50,action:e=>{const t=e.model.getters,o=e.model.uuidGenerator.uuidv4(),i=t.getActiveSheetId();1===jo(e.model.getters.getSelectedZone())&&e.model.selection.selectTableAroundSelection();const n={width:536,height:335},r=function(e,t){const{x:o,y:i}=e.getMainViewportCoordinates(),{scrollX:n,scrollY:r}=e.getActiveSheetScrollInfo(),{width:s,height:a}=e.getVisibleRect(e.getActiveMainViewport());return{x:o+n+Math.max(0,(s-t.width)/2),y:i+r+Math.max(0,(a-t.height)/2)}}(t,n);e.model.dispatch("CREATE_CHART",{sheetId:i,id:o,position:r,size:n,definition:qn(e.model.getters.getSelectedZone(),e.model.getters)}).isSuccessful&&(e.model.dispatch("SELECT_FIGURE",{id:o}),e.openSidePanel("ChartPanel"))}}).addChild("insert_image",["insert"],{name:r("Image"),sequence:55,action:async e=>{if(e.imageProvider){const t=e.model.getters.getActiveSheetId(),o=e.model.uuidGenerator.uuidv4(),i=await async function(e){try{return await e.imageProvider.requestImage()}catch{return void e.raiseError(r("An unexpected error occurred during the image transfer"))}}(e);if(!i)throw new Error("No image provider was given to the environment");const n=Zn(e.model.getters,i.size),s=function(e,t){const{x:o,y:i}=e.getMainViewportCoordinates(),{scrollX:n,scrollY:r}=e.getActiveSheetScrollInfo(),s=e.getSheetViewDimension(),a=e.getVisibleRect(e.getActiveMainViewport()),l=Math.min(a.width,s.width-o),c=Math.min(a.height,s.height-i);return{x:o+n+Math.max(0,(l-t.width)/2),y:i+r+Math.max(0,(c-t.height)/2)}}(e.model.getters,n);e.model.dispatch("CREATE_IMAGE",{sheetId:t,figureId:o,position:s,size:n,definition:i})}},isVisible:e=>void 0!==e.imageProvider}).addChild("insert_link",["insert"],{name:r("Link"),separator:!0,sequence:60,action:wr}).addChild("insert_sheet",["insert"],{name:r("New sheet"),sequence:70,action:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSheetIds().indexOf(t)+1,i=e.model.uuidGenerator.uuidv4();e.model.dispatch("CREATE_SHEET",{sheetId:i,position:o}),e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:i})},separator:!0}).addChild("unfreeze_panes",["view"],{name:r("Unfreeze"),sequence:4,isVisible:e=>{const{xSplit:t,ySplit:o}=e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId());return t+o>0},action:e=>e.model.dispatch("UNFREEZE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId()})}).addChild("freeze_panes",["view"],{name:r("Freeze"),sequence:5,separator:!0}).addChild("unfreeze_rows",["view","freeze_panes"],{name:r("No rows"),action:e=>e.model.dispatch("UNFREEZE_ROWS",{sheetId:e.model.getters.getActiveSheetId()}),isReadonlyAllowed:!0,sequence:5,isVisible:e=>!!e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId()).ySplit}).addChild("freeze_first_row",["view","freeze_panes"],{name:r("1 row"),action:e=>Gg(e,"ROW",1),isReadonlyAllowed:!0,sequence:10}).addChild("freeze_second_row",["view","freeze_panes"],{name:r("2 rows"),action:e=>Gg(e,"ROW",2),isReadonlyAllowed:!0,sequence:15}).addChild("freeze_current_row",["view","freeze_panes"],{name:r("Up to current row"),action:e=>{const{bottom:t}=e.model.getters.getSelectedZone();Gg(e,"ROW",t+1)},isReadonlyAllowed:!0,sequence:20,separator:!0}).addChild("unfreeze_columns",["view","freeze_panes"],{name:r("No columns"),action:e=>e.model.dispatch("UNFREEZE_COLUMNS",{sheetId:e.model.getters.getActiveSheetId()}),isReadonlyAllowed:!0,sequence:25,isVisible:e=>!!e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId()).xSplit}).addChild("freeze_first_col",["view","freeze_panes"],{name:r("1 column"),action:e=>Gg(e,"COL",1),isReadonlyAllowed:!0,sequence:30}).addChild("freeze_second_col",["view","freeze_panes"],{name:r("2 columns"),action:e=>Gg(e,"COL",2),isReadonlyAllowed:!0,sequence:35}).addChild("freeze_current_col",["view","freeze_panes"],{name:r("Up to current column"),action:e=>{const{right:t}=e.model.getters.getSelectedZone();Gg(e,"COL",t+1)},isReadonlyAllowed:!0,sequence:40}).addChild("view_gridlines",["view"],{name:e=>e.model.getters.getGridLinesVisibility(e.model.getters.getActiveSheetId())?r("Hide gridlines"):r("Show gridlines"),action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("SET_GRID_LINES_VISIBILITY",{sheetId:t,areGridLinesVisible:!e.model.getters.getGridLinesVisibility(t)})},sequence:10}).addChild("view_formulas",["view"],{name:e=>e.model.getters.shouldShowFormulas()?r("Hide formulas"):r("Show formulas"),action:e=>e.model.dispatch("SET_FORMULA_VISIBILITY",{show:!e.model.getters.shouldShowFormulas()}),isReadonlyAllowed:!0,sequence:15}).addChild("format_number",["format"],{name:r("Numbers"),sequence:10,separator:!0}).addChild("format_number_automatic",["format","format_number"],{name:zi.Automatic,sequence:10,separator:!0,action:e=>er(e,"")}).addChild("format_number_number",["format","format_number"],{name:zi.Number,description:"1,000.12",sequence:20,action:e=>er(e,"#,##0.00")}).addChild("format_number_percent",["format","format_number"],{name:zi.Percent,description:"10.12%",sequence:30,separator:!0,action:e=>er(e,"0.00%")}).addChild("format_number_currency",["format","format_number"],{name:zi.Currency,description:"$1,000.12",sequence:37,action:e=>er(e,"[$$]#,##0.00")}).addChild("format_number_currency_rounded",["format","format_number"],{name:zi.CurrencyRounded,description:"$1,000",sequence:38,action:e=>er(e,"[$$]#,##0")}).addChild("format_custom_currency",["format","format_number"],{name:zi.CustomCurrency,sequence:39,separator:!0,isVisible:e=>void 0!==e.loadCurrencies,action:e=>{e.openSidePanel("CustomCurrency",{})}}).addChild("format_number_date",["format","format_number"],{name:zi.Date,description:"9/26/2008",sequence:40,action:e=>er(e,"m/d/yyyy")}).addChild("format_number_time",["format","format_number"],{name:zi.Time,description:"10:43:00 PM",sequence:50,action:e=>er(e,"hh:mm:ss a")}).addChild("format_number_date_time",["format","format_number"],{name:zi.DateTime,description:"9/26/2008 22:43:00",sequence:60,action:e=>er(e,"m/d/yyyy hh:mm:ss")}).addChild("format_number_duration",["format","format_number"],{name:zi.Duration,description:"27:51:38",sequence:70,separator:!0,action:e=>er(e,"hhhh:mm:ss")}).addChild("format_bold",["format"],{name:r("Bold"),sequence:20,description:"Ctrl+B",action:e=>tr(e,{bold:!e.model.getters.getCurrentStyle().bold})}).addChild("format_italic",["format"],{name:r("Italic"),sequence:30,description:"Ctrl+I",action:e=>tr(e,{italic:!e.model.getters.getCurrentStyle().italic})}).addChild("format_underline",["format"],{name:r("Underline"),description:"Ctrl+U",sequence:40,action:e=>tr(e,{underline:!e.model.getters.getCurrentStyle().underline})}).addChild("format_strikethrough",["format"],{name:r("Strikethrough"),sequence:50,action:e=>tr(e,{strikethrough:!e.model.getters.getCurrentStyle().strikethrough}),separator:!0}).addChild("format_font_size",["format"],{name:r("Font size"),sequence:60,separator:!0}).addChild("format_alignment",["format"],{name:r("Alignment"),sequence:70}).addChild("format_alignment_left",["format","format_alignment"],{name:"Left",sequence:10,action:e=>tr(e,{align:"left"})}).addChild("format_alignment_center",["format","format_alignment"],{name:"Center",sequence:20,action:e=>tr(e,{align:"center"})}).addChild("format_alignment_right",["format","format_alignment"],{name:"Right",sequence:30,action:e=>tr(e,{align:"right"}),separator:!0}).addChild("format_alignment_top",["format","format_alignment"],{name:"Top",sequence:40,action:e=>tr(e,{verticalAlign:"top"})}).addChild("format_alignment_middle",["format","format_alignment"],{name:"Middle",sequence:50,action:e=>tr(e,{verticalAlign:"middle"})}).addChild("format_alignment_bottom",["format","format_alignment"],{name:"Bottom",sequence:60,action:e=>tr(e,{verticalAlign:"bottom"}),separator:!0}).addChild("format_wrapping",["format"],{name:r("Wrapping"),sequence:80,separator:!0}).addChild("format_wrapping_overflow",["format","format_wrapping"],{name:r("Overflow"),sequence:10,action:e=>tr(e,{wrapping:"overflow"})}).addChild("format_wrapping_wrap",["format","format_wrapping"],{name:r("Wrap"),sequence:20,action:e=>tr(e,{wrapping:"wrap"})}).addChild("format_wrapping_clip",["format","format_wrapping"],{name:r("Clip"),sequence:30,action:e=>tr(e,{wrapping:"clip"})}).addChild("format_cf",["format"],{name:r("Conditional formatting"),sequence:90,action:Er,separator:!0}).addChild("format_clearFormat",["format"],{name:r("Clear formatting"),sequence:100,action:e=>{e.model.dispatch("CLEAR_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()})},separator:!0}).addChild("add_data_filter",["data"],{name:r("Create filter"),sequence:10,action:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelection().zones;Kn(e,t,o)},isVisible:e=>!yr(e),isEnabled:e=>(e=>Xo(...e.model.getters.getSelectedZones()))(e)}).addChild("remove_data_filter",["data"],{name:r("Remove filter"),sequence:10,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("REMOVE_FILTER_TABLE",{sheetId:t,target:e.model.getters.getSelectedZones()})},isVisible:yr});for(let e of le)qg.addChild(`format_font_size_${e.pt}`,["format","format_font_size"],{name:e.pt.toString(),sequence:e.pt,action:t=>tr(t,{fontSize:e.pt})});const Zg=new class extends Cn{addTransformation(e,t,o){for(let i of t)this.content[i]||(this.content[i]=new Map),this.content[i].set(e,o);return this}getTransformation(e,t){return this.content[e]&&this.content[e].get(t)}},jg=new yo;Jo`
533
+ `;class kg extends t.Component{constructor(){super(...arguments),this.menuItems=Dg.getAll(),this.link=t.useState(this.defaultState),this.menu=t.useState({isOpen:!1}),this.linkEditorRef=t.useRef("linkEditor"),this.position=An(this.linkEditorRef),this.urlInput=t.useRef("urlInput")}setup(){t.onMounted((()=>{var e;return null===(e=this.urlInput.el)||void 0===e?void 0:e.focus()}))}get defaultState(){const{col:e,row:t}=this.props.cellPosition,o=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getEvaluatedCell({sheetId:o,col:e,row:t});return i.link?{url:i.link.url,label:i.formattedValue,isUrlEditable:i.link.isUrlEditable}:{label:i.formattedValue,url:"",isUrlEditable:!0}}get menuPosition(){return{x:this.position.x+320-12-2,y:this.position.y+100}}onSpecialLink(e){const{detail:t}=e,o=mg(t);o&&(this.link.url=o.url,this.link.label=o.label,this.link.isUrlEditable=o.isUrlEditable)}getUrlRepresentation(e){return gg(e,this.env.model.getters)}openMenu(){this.menu.isOpen=!0}removeLink(){this.link.url="",this.link.isUrlEditable=!0}save(){var e,t;const{col:o,row:i}=this.props.cellPosition,n=this.link.label||this.link.url;this.env.model.dispatch("UPDATE_CELL",{col:o,row:i,sheetId:this.env.model.getters.getActiveSheetId(),content:qe(n,this.link.url)}),null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}cancel(){var e,t;null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}onKeyDown(e){switch(e.key){case"Enter":this.link.url&&this.save(),e.stopPropagation();break;case"Escape":this.cancel(),e.stopPropagation()}}}kg.template="o-spreadsheet-LinkEditor",kg.components={Menu:Ln};const $g={onOpen:(e,t)=>({isOpen:!0,props:{cellPosition:e},Component:kg,cellCorner:"BottomLeft"})};kg.props={cellPosition:Object,onClosed:{type:Function,optional:!0}};const Pg=new Cn;Pg.add("ErrorToolTip",Tg).add("LinkCell",Fg).add("LinkEditor",$g).add("FilterMenu",Ng);const Lg=new Cn;class Ug extends t.Component{constructor(){super(...arguments),this.menuState=t.useState({isOpen:!1,position:null,menuItems:[]}),this.imageContainerRef=t.useRef("o-image"),this.menuButtonRef=t.useRef("menuButton"),this.menuButtonRect=An(this.menuButtonRef),this.position=An(this.imageContainerRef)}getMenuItemRegistry(){const e=new Rn;return e.add("copy",{name:r("Copy"),description:"Ctrl+C",sequence:1,action:async()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.figureId}),this.env.model.dispatch("COPY"),await this.env.clipboard.write(this.env.model.getters.getClipboardContent())}}),e.add("cut",{name:r("Cut"),description:"Ctrl+X",sequence:2,action:async()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.figureId}),this.env.model.dispatch("CUT"),await this.env.clipboard.write(this.env.model.getters.getClipboardContent())}}),e.add("reset_size",{name:r("Reset size"),sequence:3,action:()=>{const e=this.env.model.getters.getImage(this.env.model.getters.getActiveSheetId(),this.figureId).size,{height:t,width:o}=Zn(this.env.model.getters,e);this.env.model.dispatch("UPDATE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:this.figureId,height:t,width:o})}}),e.add("delete",{name:r("Delete image"),description:"delete",sequence:5,action:()=>{this.env.model.dispatch("DELETE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:this.figureId})}}),e}onContextMenu(e){const t={x:this.position.x+e.offsetX,y:this.position.y+e.offsetY};this.openContextMenu(t)}showMenu(){const{x:e,y:t,width:o}=this.menuButtonRect,i={x:e>=z?e-z:e+o,y:t};this.openContextMenu(i)}openContextMenu(e){const t=this.getMenuItemRegistry();this.menuState.isOpen=!0,this.menuState.menuItems=t.getAll().filter((e=>e.isVisible(this.env))),this.menuState.position=e}get figureId(){return this.props.figure.id}get getImagePath(){return this.env.model.getters.getImage(this.env.model.getters.getActiveSheetId(),this.figureId).path}}Ug.template="o-spreadsheet-ImageFigure",Ug.components={Menu:Ln},Ug.props={figure:Object,onFigureDeleted:Function};const Vg=new Cn;Vg.add("chart",{Component:Un,SidePanelComponent:"ChartPanel"}),Vg.add("image",{Component:Ug,keepRatio:!0,minFigSize:20,borderWidth:0});const zg=(new Cn).add("ADD_COLUMNS_ROWS",(function(e){const t=[];let o=e.base;"after"===e.position&&o++;for(let i=0;i<e.quantity;i++)t.push(i+o);return[{type:"REMOVE_COLUMNS_ROWS",dimension:e.dimension,elements:t,sheetId:e.sheetId}]})).add("REMOVE_COLUMNS_ROWS",(function(e){const t=[],o=[...e.elements].sort(((e,t)=>e-t));for(let i of Ue(o)){const o=0===i[0]?0:i[0]-1,n=0===i[0]?"before":"after";t.push({type:"ADD_COLUMNS_ROWS",dimension:e.dimension,quantity:i.length,base:o,sheetId:e.sheetId,position:n})}return t})).add("ADD_MERGE",(function(e){return[{type:"REMOVE_MERGE",sheetId:e.sheetId,target:e.target}]})).add("REMOVE_MERGE",(function(e){return[{type:"ADD_MERGE",sheetId:e.sheetId,target:e.target}]})).add("CREATE_SHEET",(function(e){return[{type:"DELETE_SHEET",sheetId:e.sheetId}]})).add("DELETE_SHEET",(function(e){return[{type:"CREATE_SHEET",sheetId:e.sheetId,position:1}]})).add("DUPLICATE_SHEET",(function(e){return[{type:"DELETE_SHEET",sheetId:e.sheetIdTo}]})).add("CREATE_FIGURE",(function(e){return[{type:"DELETE_FIGURE",id:e.figure.id,sheetId:e.sheetId}]})).add("CREATE_CHART",(function(e){return[{type:"DELETE_FIGURE",id:e.id,sheetId:e.sheetId}]})).add("HIDE_COLUMNS_ROWS",(function(e){return[{type:"UNHIDE_COLUMNS_ROWS",sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]})).add("UNHIDE_COLUMNS_ROWS",(function(e){return[{type:"HIDE_COLUMNS_ROWS",sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]}));for(const e of fi.values())zg.contains(e)||zg.add(e,Bg);function Bg(e){return[e]}function Hg(e,t,o){const i=e.model.getters.getSheetName(t),n=r("Rename Sheet");e.editText(n,(o=>{if(null===o||o===i)return;""===o&&Hg(e,t,r("The sheet name cannot be empty."));const n=e.model.dispatch("RENAME_SHEET",{sheetId:t,name:o});n.isSuccessful||(n.reasons.includes(11)&&Hg(e,t,r("A sheet with the name %s already exists. Please select another name.",o)),n.reasons.includes(13)&&Hg(e,t,r("Some used characters are not allowed in a sheet name (Forbidden characters are %s).",ie.join(" "))))}),{placeholder:i,error:o})}const Wg=new Rn;function Gg(e,t,o){const i=e.model.getters.getActiveSheetId(),n="COL"===t?"FREEZE_COLUMNS":"FREEZE_ROWS";e.model.dispatch(n,{sheetId:i,quantity:o}).isCancelledBecause(65)&&e.raiseError(Hi)}Wg.add("delete",{name:r("Delete"),sequence:10,isVisible:e=>e.model.getters.getSheetIds().length>1,action:e=>e.askConfirmation(r("Are you sure you want to delete this sheet ?"),(()=>{e.model.dispatch("DELETE_SHEET",{sheetId:e.model.getters.getActiveSheetId()})}))}).add("duplicate",{name:r("Duplicate"),sequence:20,action:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.uuidGenerator.uuidv4();e.model.dispatch("DUPLICATE_SHEET",{sheetId:t,sheetIdTo:o}),e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:o})}}).add("rename",{name:r("Rename"),sequence:30,action:e=>Hg(e,e.model.getters.getActiveSheetId())}).add("move_right",{name:r("Move right"),sequence:40,isVisible:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getVisibleSheetIds();return o.indexOf(t)!==o.length-1},action:e=>e.model.dispatch("MOVE_SHEET",{sheetId:e.model.getters.getActiveSheetId(),direction:"right"})}).add("move_left",{name:r("Move left"),sequence:50,isVisible:e=>{const t=e.model.getters.getActiveSheetId();return e.model.getters.getVisibleSheetIds()[0]!==t},action:e=>e.model.dispatch("MOVE_SHEET",{sheetId:e.model.getters.getActiveSheetId(),direction:"left"})}).add("hide_sheet",{name:r("Hide sheet"),sequence:60,isVisible:e=>1!==e.model.getters.getVisibleSheetIds().length,action:e=>e.model.dispatch("HIDE_SHEET",{sheetId:e.model.getters.getActiveSheetId()})});const qg=new Rn;qg.add("file",{name:r("File"),sequence:10}).add("edit",{name:r("Edit"),sequence:20}).add("view",{name:r("View"),sequence:30}).add("insert",{name:r("Insert"),sequence:40}).add("format",{name:r("Format"),sequence:50}).add("data",{name:r("Data"),sequence:60}).addChild("save",["file"],{name:r("Save"),description:"Ctrl+S",sequence:10,action:()=>console.log("Not implemented")}).addChild("undo",["edit"],{name:r("Undo"),description:"Ctrl+Z",sequence:10,action:e=>e.model.dispatch("REQUEST_UNDO")}).addChild("redo",["edit"],{name:r("Redo"),description:"Ctrl+Y",sequence:20,action:e=>e.model.dispatch("REQUEST_REDO"),separator:!0}).addChild("copy",["edit"],{name:r("Copy"),description:"Ctrl+C",sequence:30,isReadonlyAllowed:!0,action:or}).addChild("cut",["edit"],{name:r("Cut"),description:"Ctrl+X",sequence:40,action:ir}).addChild("paste",["edit"],{name:r("Paste"),description:"Ctrl+V",sequence:50,action:nr}).addChild("paste_special",["edit"],{name:r("Paste special"),sequence:60,separator:!0,isVisible:lr}).addChild("paste_special_value",["edit","paste_special"],{name:r("Paste value only"),sequence:10,action:rr}).addChild("paste_special_format",["edit","paste_special"],{name:r("Paste format only"),sequence:20,action:ar}).addChild("sort_range",["data"],{name:r("Sort range"),sequence:20,isVisible:Rr,separator:!0}).addChild("sort_ascending",["data","sort_range"],{name:r("Ascending (A ⟶ Z)"),sequence:10,action:xr}).addChild("sort_descending",["data","sort_range"],{name:r("Descending (Z ⟶ A)"),sequence:20,action:Ir}).addChild("find_and_replace",["edit"],{name:r("Find and replace"),description:"Ctrl+H",sequence:65,isReadonlyAllowed:!0,action:e=>{e.openSidePanel("FindAndReplace",{})},separator:!0}).addChild("edit_delete_cell_values",["edit"],{name:r("Delete values"),sequence:70,action:e=>e.model.dispatch("DELETE_CONTENT",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()})}).addChild("edit_delete_row",["edit"],{name:cr,sequence:80,action:hr}).addChild("edit_delete_column",["edit"],{name:dr,sequence:90,action:ur}).addChild("edit_delete_cell_shift_up",["edit"],{name:r("Delete cell and shift up"),sequence:93,action:mr}).addChild("edit_delete_cell_shift_left",["edit"],{name:r("Delete cell and shift left"),sequence:97,action:fr}).addChild("edit_unhide_columns",["edit"],{name:r("Unhide all columns"),sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:t,dimension:"COL",elements:Array.from(Array(e.model.getters.getNumberCols(t)).keys())})},isVisible:e=>e.model.getters.getHiddenColsGroups(e.model.getters.getActiveSheetId()).length>0}).addChild("edit_unhide_rows",["edit"],{name:r("Unhide all rows"),sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:t,dimension:"ROW",elements:Array.from(Array(e.model.getters.getNumberRows(t)).keys())})},isVisible:e=>e.model.getters.getHiddenRowsGroups(e.model.getters.getActiveSheetId()).length>0}).addChild("insert_row_before",["insert"],{name:e=>{const t=Jn(e);return 1===t?r("Row above"):r("%s Rows above",t.toString())},sequence:10,action:vr,isVisible:e=>0===e.model.getters.getActiveCols().size}).addChild("insert_row_after",["insert"],{name:e=>{const t=Jn(e);return 1===t?r("Row below"):r("%s Rows below",t.toString())},sequence:20,action:br,isVisible:e=>0===e.model.getters.getActiveCols().size,separator:!0}).addChild("insert_column_before",["insert"],{name:e=>{const t=Qn(e);return 1===t?r("Column left"):r("%s Columns left",t.toString())},sequence:30,action:Sr,isVisible:e=>0===e.model.getters.getActiveRows().size}).addChild("insert_column_after",["insert"],{name:e=>{const t=Qn(e);return 1===t?r("Column right"):r("%s Columns right",t.toString())},sequence:40,action:Cr,isVisible:e=>0===e.model.getters.getActiveRows().size,separator:!0}).addChild("insert_insert_cell_shift_down",["insert"],{name:r("Insert cells and shift down"),sequence:43,action:gr}).addChild("insert_insert_cell_shift_right",["insert"],{name:r("Insert cells and shift right"),sequence:47,action:pr,separator:!0}).addChild("insert_chart",["insert"],{name:r("Chart"),sequence:50,action:e=>{const t=e.model.getters,o=e.model.uuidGenerator.uuidv4(),i=t.getActiveSheetId();1===jo(e.model.getters.getSelectedZone())&&e.model.selection.selectTableAroundSelection();const n={width:536,height:335},r=function(e,t){const{x:o,y:i}=e.getMainViewportCoordinates(),{scrollX:n,scrollY:r}=e.getActiveSheetScrollInfo(),{width:s,height:a}=e.getVisibleRect(e.getActiveMainViewport());return{x:o+n+Math.max(0,(s-t.width)/2),y:i+r+Math.max(0,(a-t.height)/2)}}(t,n);e.model.dispatch("CREATE_CHART",{sheetId:i,id:o,position:r,size:n,definition:qn(e.model.getters.getSelectedZone(),e.model.getters)}).isSuccessful&&(e.model.dispatch("SELECT_FIGURE",{id:o}),e.openSidePanel("ChartPanel"))}}).addChild("insert_image",["insert"],{name:r("Image"),sequence:55,action:async e=>{if(e.imageProvider){const t=e.model.getters.getActiveSheetId(),o=e.model.uuidGenerator.uuidv4(),i=await async function(e){try{return await e.imageProvider.requestImage()}catch{return void e.raiseError(r("An unexpected error occurred during the image transfer"))}}(e);if(!i)throw new Error("No image provider was given to the environment");const n=Zn(e.model.getters,i.size),s=function(e,t){const{x:o,y:i}=e.getMainViewportCoordinates(),{scrollX:n,scrollY:r}=e.getActiveSheetScrollInfo(),s=e.getSheetViewDimension(),a=e.getVisibleRect(e.getActiveMainViewport()),l=Math.min(a.width,s.width-o),c=Math.min(a.height,s.height-i);return{x:o+n+Math.max(0,(l-t.width)/2),y:i+r+Math.max(0,(c-t.height)/2)}}(e.model.getters,n);e.model.dispatch("CREATE_IMAGE",{sheetId:t,figureId:o,position:s,size:n,definition:i})}},isVisible:e=>void 0!==e.imageProvider}).addChild("insert_link",["insert"],{name:r("Link"),separator:!0,sequence:60,action:wr}).addChild("insert_sheet",["insert"],{name:r("New sheet"),sequence:70,action:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSheetIds().indexOf(t)+1,i=e.model.uuidGenerator.uuidv4();e.model.dispatch("CREATE_SHEET",{sheetId:i,position:o}),e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:i})},separator:!0}).addChild("unfreeze_panes",["view"],{name:r("Unfreeze"),sequence:4,isVisible:e=>{const{xSplit:t,ySplit:o}=e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId());return t+o>0},action:e=>e.model.dispatch("UNFREEZE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId()})}).addChild("freeze_panes",["view"],{name:r("Freeze"),sequence:5,separator:!0}).addChild("unfreeze_rows",["view","freeze_panes"],{name:r("No rows"),action:e=>e.model.dispatch("UNFREEZE_ROWS",{sheetId:e.model.getters.getActiveSheetId()}),isReadonlyAllowed:!0,sequence:5,isVisible:e=>!!e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId()).ySplit}).addChild("freeze_first_row",["view","freeze_panes"],{name:r("1 row"),action:e=>Gg(e,"ROW",1),isReadonlyAllowed:!0,sequence:10}).addChild("freeze_second_row",["view","freeze_panes"],{name:r("2 rows"),action:e=>Gg(e,"ROW",2),isReadonlyAllowed:!0,sequence:15}).addChild("freeze_current_row",["view","freeze_panes"],{name:r("Up to current row"),action:e=>{const{bottom:t}=e.model.getters.getSelectedZone();Gg(e,"ROW",t+1)},isReadonlyAllowed:!0,sequence:20,separator:!0}).addChild("unfreeze_columns",["view","freeze_panes"],{name:r("No columns"),action:e=>e.model.dispatch("UNFREEZE_COLUMNS",{sheetId:e.model.getters.getActiveSheetId()}),isReadonlyAllowed:!0,sequence:25,isVisible:e=>!!e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId()).xSplit}).addChild("freeze_first_col",["view","freeze_panes"],{name:r("1 column"),action:e=>Gg(e,"COL",1),isReadonlyAllowed:!0,sequence:30}).addChild("freeze_second_col",["view","freeze_panes"],{name:r("2 columns"),action:e=>Gg(e,"COL",2),isReadonlyAllowed:!0,sequence:35}).addChild("freeze_current_col",["view","freeze_panes"],{name:r("Up to current column"),action:e=>{const{right:t}=e.model.getters.getSelectedZone();Gg(e,"COL",t+1)},isReadonlyAllowed:!0,sequence:40}).addChild("view_gridlines",["view"],{name:e=>e.model.getters.getGridLinesVisibility(e.model.getters.getActiveSheetId())?r("Hide gridlines"):r("Show gridlines"),action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("SET_GRID_LINES_VISIBILITY",{sheetId:t,areGridLinesVisible:!e.model.getters.getGridLinesVisibility(t)})},sequence:10}).addChild("view_formulas",["view"],{name:e=>e.model.getters.shouldShowFormulas()?r("Hide formulas"):r("Show formulas"),action:e=>e.model.dispatch("SET_FORMULA_VISIBILITY",{show:!e.model.getters.shouldShowFormulas()}),isReadonlyAllowed:!0,sequence:15}).addChild("format_number",["format"],{name:r("Numbers"),sequence:10,separator:!0}).addChild("format_number_automatic",["format","format_number"],{name:zi.Automatic,sequence:10,separator:!0,action:e=>er(e,"")}).addChild("format_number_number",["format","format_number"],{name:zi.Number,description:"1,000.12",sequence:20,action:e=>er(e,"#,##0.00")}).addChild("format_number_percent",["format","format_number"],{name:zi.Percent,description:"10.12%",sequence:30,separator:!0,action:e=>er(e,"0.00%")}).addChild("format_number_currency",["format","format_number"],{name:zi.Currency,description:"$1,000.12",sequence:37,action:e=>er(e,"[$$]#,##0.00")}).addChild("format_number_currency_rounded",["format","format_number"],{name:zi.CurrencyRounded,description:"$1,000",sequence:38,action:e=>er(e,"[$$]#,##0")}).addChild("format_custom_currency",["format","format_number"],{name:zi.CustomCurrency,sequence:39,separator:!0,isVisible:e=>void 0!==e.loadCurrencies,action:e=>{e.openSidePanel("CustomCurrency",{})}}).addChild("format_number_date",["format","format_number"],{name:zi.Date,description:"9/26/2008",sequence:40,action:e=>er(e,"m/d/yyyy")}).addChild("format_number_time",["format","format_number"],{name:zi.Time,description:"10:43:00 PM",sequence:50,action:e=>er(e,"hh:mm:ss a")}).addChild("format_number_date_time",["format","format_number"],{name:zi.DateTime,description:"9/26/2008 22:43:00",sequence:60,action:e=>er(e,"m/d/yyyy hh:mm:ss")}).addChild("format_number_duration",["format","format_number"],{name:zi.Duration,description:"27:51:38",sequence:70,separator:!0,action:e=>er(e,"hhhh:mm:ss")}).addChild("format_bold",["format"],{name:r("Bold"),sequence:20,description:"Ctrl+B",action:e=>tr(e,{bold:!e.model.getters.getCurrentStyle().bold})}).addChild("format_italic",["format"],{name:r("Italic"),sequence:30,description:"Ctrl+I",action:e=>tr(e,{italic:!e.model.getters.getCurrentStyle().italic})}).addChild("format_underline",["format"],{name:r("Underline"),description:"Ctrl+U",sequence:40,action:e=>tr(e,{underline:!e.model.getters.getCurrentStyle().underline})}).addChild("format_strikethrough",["format"],{name:r("Strikethrough"),sequence:50,action:e=>tr(e,{strikethrough:!e.model.getters.getCurrentStyle().strikethrough}),separator:!0}).addChild("format_font_size",["format"],{name:r("Font size"),sequence:60,separator:!0}).addChild("format_alignment",["format"],{name:r("Alignment"),sequence:70}).addChild("format_alignment_left",["format","format_alignment"],{name:"Left",sequence:10,action:e=>tr(e,{align:"left"})}).addChild("format_alignment_center",["format","format_alignment"],{name:"Center",sequence:20,action:e=>tr(e,{align:"center"})}).addChild("format_alignment_right",["format","format_alignment"],{name:"Right",sequence:30,action:e=>tr(e,{align:"right"}),separator:!0}).addChild("format_alignment_top",["format","format_alignment"],{name:"Top",sequence:40,action:e=>tr(e,{verticalAlign:"top"})}).addChild("format_alignment_middle",["format","format_alignment"],{name:"Middle",sequence:50,action:e=>tr(e,{verticalAlign:"middle"})}).addChild("format_alignment_bottom",["format","format_alignment"],{name:"Bottom",sequence:60,action:e=>tr(e,{verticalAlign:"bottom"}),separator:!0}).addChild("format_wrapping",["format"],{name:r("Wrapping"),sequence:80,separator:!0}).addChild("format_wrapping_overflow",["format","format_wrapping"],{name:r("Overflow"),sequence:10,action:e=>tr(e,{wrapping:"overflow"})}).addChild("format_wrapping_wrap",["format","format_wrapping"],{name:r("Wrap"),sequence:20,action:e=>tr(e,{wrapping:"wrap"})}).addChild("format_wrapping_clip",["format","format_wrapping"],{name:r("Clip"),sequence:30,action:e=>tr(e,{wrapping:"clip"})}).addChild("format_cf",["format"],{name:r("Conditional formatting"),sequence:90,action:Er,separator:!0}).addChild("format_clearFormat",["format"],{name:r("Clear formatting"),sequence:100,action:e=>{e.model.dispatch("CLEAR_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()})},separator:!0}).addChild("add_data_filter",["data"],{name:r("Create filter"),sequence:10,action:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelection().zones;Kn(e,t,o)},isVisible:e=>!yr(e),isEnabled:e=>(e=>Xo(...e.model.getters.getSelectedZones()))(e)}).addChild("remove_data_filter",["data"],{name:r("Remove filter"),sequence:10,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("REMOVE_FILTER_TABLE",{sheetId:t,target:e.model.getters.getSelectedZones()})},isVisible:yr});for(let e of le)qg.addChild(`format_font_size_${e.pt}`,["format","format_font_size"],{name:e.pt.toString(),sequence:e.pt,action:t=>tr(t,{fontSize:e.pt})});const Zg=new class extends Cn{addTransformation(e,t,o){for(let i of t)this.content[i]||(this.content[i]=new Map),this.content[i].set(e,o);return this}getTransformation(e,t){return this.content[e]&&this.content[e].get(t)}},jg=new yo;Jo`
534
534
  .o-selection {
535
535
  .o-selection-input {
536
536
  display: flex;
@@ -2451,4 +2451,4 @@
2451
2451
  <tableParts count="${e.filterTables.length}">
2452
2452
  ${Of(a)}
2453
2453
  </tableParts>
2454
- `}var RS;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(RS||(RS={}));const TS={},AS={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:O,HEADER_WIDTH:M,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:N,DEFAULT_CELL_HEIGHT:_,SCROLLBAR_WIDTH:F},OS={autofillModifiersRegistry:xg,autofillRulesRegistry:Ig,cellMenuRegistry:Tr,colMenuRegistry:Ar,linkMenuRegistry:Dg,functionRegistry:qd,featurePluginRegistry:ub,statefulUIPluginRegistry:gb,coreViewsPluginRegistry:pb,corePluginRegistry:db,rowMenuRegistry:Or,sidePanelRegistry:Sp,figureRegistry:Vg,sheetMenuRegistry:Wg,chartSidePanelComponentRegistry:hp,chartComponentRegistry:wn,chartRegistry:En,topbarMenuRegistry:qg,topbarComponentRegistry:Cp,clickableCellRegistry:mb,otRegistry:Zg,inverseCommandRegistry:zg,urlRegistry:cg,cellPopoverRegistry:Pg},MS={args:Pr,toBoolean:jr,toJsDate:Xr,toNumber:Hr,toString:Gr,toXC:Ft,toZone:Io,toCartesian:_t,numberToLetters:Mt,createFullMenuItem:xn,UuidGenerator:yo,formatValue:oo,computeTextWidth:ke,createEmptyWorkbookData:tv,createEmptySheet:ev,createEmptyExcelSheet:ov,getDefaultChartJsRuntime:ji,chartFontColor:_i,getMenuChildren:On,ChartColors:Ni,EvaluationError:c,CellErrorLevel:l,getFillingMode:Ki,rgbaToHex:mt,colorToRGBA:ft,positionToZone:qo,isDefined:Qe},NS={isMarkdownLink:We,parseMarkdownLink:Ze,markdownLink:qe,openLink:pg,urlRepresentation:gg},_S={ChartPanel:dp,ChartFigure:Un,ChartJsComponent:Yo,Grid:Vp,GridOverlay:xp,ScorecardChart:ri,LineConfigPanel:sp,LineBarPieDesignPanel:op,BarConfigPanel:Kg,LineBarPieConfigPanel:Yg,GaugeChartConfigPanel:np,GaugeChartDesignPanel:rp,ScorecardChartConfigPanel:lp,ScorecardChartDesignPanel:cp};e.AbstractChart=ci,e.CorePlugin=iv,e.DATETIME_FORMAT=j,e.DispatchResult=bi,e.EvaluationError=c,e.Model=class extends zv{constructor(e={},o={},i=[],n=new yo,r=!0){super(),this.corePlugins=[],this.featurePlugins=[],this.statefulUIPlugins=[],this.coreViewsPlugins=[],this.isReplayingCommand=!1,this.renderers=[],this.status=0,this.dispatch=(e,t)=>{const o={...t,type:e};let i=this.status;if(this.getters.isReadonly()&&(n=o,!mi.has(n.type)))return new bi(67);var n;if(!this.session.canApplyOptimisticUpdate())return new bi(64);switch(i){case 0:const t=this.checkDispatchAllowed(o);if(!t.isSuccessful)return t;this.status=1;const{changes:i,commands:n}=this.state.recordChanges((()=>{vi(o)&&this.state.addCommand(o),this.dispatchToHandlers(this.handlers,o),this.finalize()}));this.session.save(n,i),this.status=0,this.trigger("update");break;case 1:if(vi(o)){const e=this.checkDispatchAllowed(o);if(!e.isSuccessful)return e;this.state.addCommand(o)}this.dispatchToHandlers(this.handlers,o);break;case 3:throw new Error("Cannot dispatch commands in the finalize state");case 2:if(vi(o))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,o)}return bi.Success},this.dispatchFromCorePlugin=(e,t)=>{const o={...t,type:e},i=this.status;this.status=2;const n=this.isReplayingCommand?[this.range,...this.corePlugins,...this.coreViewsPlugins]:this.handlers;return this.dispatchToHandlers(n,o),this.status=i,bi.Success},i=Qf(e,i);const s=Yf(e,r);this.state=new zb,this.uuidGenerator=n,this.config=this.setupConfig(o),this.session=this.setupSession(s.revisionId),this.history=new Lb(this.dispatchFromCorePlugin,this.session),this.coreGetters={},this.range=new Cv(this.coreGetters),this.coreGetters.getRangeString=this.range.getRangeString.bind(this.range),this.coreGetters.getRangeFromSheetXC=this.range.getRangeFromSheetXC.bind(this.range),this.coreGetters.createAdaptedRanges=this.range.createAdaptedRanges.bind(this.range),this.coreGetters.getRangeDataFromXc=this.range.getRangeDataFromXc.bind(this.range),this.coreGetters.getRangeDataFromZone=this.range.getRangeDataFromZone.bind(this.range),this.coreGetters.getRangeFromRangeData=this.range.getRangeFromRangeData.bind(this.range),this.coreGetters.getSelectionRangeString=this.range.getSelectionRangeString.bind(this.range),this.getters={isReadonly:()=>"readonly"===this.config.mode||"dashboard"===this.config.mode,isDashboard:()=>"dashboard"===this.config.mode,canUndo:this.history.canUndo.bind(this.history),canRedo:this.history.canRedo.bind(this.history),getClient:this.session.getClient.bind(this.session),getConnectedClients:this.session.getConnectedClients.bind(this.session),isFullySynchronized:this.session.isFullySynchronized.bind(this.session)},this.uuidGenerator.setIsFastStrategy(!0),this.selection=new Vb(this.getters),this.corePluginConfig=this.setupCorePluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(let e of db.getAll())this.setupCorePlugin(e,s);Object.assign(this.getters,this.coreGetters);for(let e of gb.getAll())this.statefulUIPlugins.push(this.setupUiPlugin(e));for(let e of pb.getAll())this.coreViewsPlugins.push(this.setupUiPlugin(e));for(let e of ub.getAll())this.featurePlugins.push(this.setupUiPlugin(e));this.uuidGenerator.setIsFastStrategy(!1),this.dispatch("START"),this.selection.observe(this,{handleEvent:()=>this.trigger("update")}),this.setupSessionEvents(),this.session.loadInitialMessages(i),this.joinSession(),o.snapshotRequested&&(this.session.snapshot(this.exportData()),this.garbageCollectExternalResources()),t.markRaw(this)}get handlers(){return[this.range,...this.corePlugins,...this.allUIPlugins,this.history]}get allUIPlugins(){return[...this.statefulUIPlugins,...this.coreViewsPlugins,...this.featurePlugins]}joinSession(){this.session.join(this.config.client)}leaveSession(){this.session.leave()}setupUiPlugin(e){const t=new e(this.uiPluginConfig);for(let o of e.getters){if(!(o in t))throw new Error(`Invalid getter name: ${o} for plugin ${t.constructor}`);if(o in this.getters)throw new Error(`Getter "${o}" is already defined.`);this.getters[o]=t[o].bind(t)}const o=e.layers.map((e=>[t,e]));return this.renderers.push(...o),this.renderers.sort(((e,t)=>e[1]-t[1])),t}setupCorePlugin(e,t){const o=new e(this.corePluginConfig);for(let t of e.getters){if(!(t in o))throw new Error(`Invalid getter name: ${t} for plugin ${o.constructor}`);if(t in this.coreGetters)throw new Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=o[t].bind(o)}o.import(t),this.corePlugins.push(o)}onRemoteRevisionReceived({commands:e}){for(let t of e){const e=this.status;this.status=2,this.dispatchToHandlers(this.statefulUIPlugins,t),this.status=e}this.finalize()}setupSession(e){return new Yv($b(e,this.state.recordChanges.bind(this.state),(e=>{this.checkDispatchAllowed(e).isSuccessful&&(this.isReplayingCommand=!0,this.dispatchToHandlers([this.range,...this.corePlugins,...this.coreViewsPlugins],e),this.isReplayingCommand=!1)})),this.config.transportService,e)}setupSessionEvents(){this.session.on("remote-revision-received",this,this.onRemoteRevisionReceived),this.session.on("revision-redone",this,this.finalize),this.session.on("revision-undone",this,this.finalize),this.session.on("unexpected-revision-id",this,(()=>this.trigger("unexpected-revision-id"))),this.session.on("collaborative-event-received",this,(()=>{this.trigger("update")}))}setupConfig(e){const t=e.client||{id:this.uuidGenerator.uuidv4(),name:r("Anonymous").toString()},o=e.transportService||new Tb;return{...e,mode:e.mode||"normal",custom:e.custom||{},external:e.external||{},transportService:o,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger("notify-ui",e),lazyEvaluation:!("lazyEvaluation"in e)||e.lazyEvaluation}}setupCorePluginConfig(){return{getters:this.coreGetters,stateObserver:this.state,range:this.range,dispatch:this.dispatchFromCorePlugin,uuidGenerator:this.uuidGenerator,custom:this.config.custom,external:this.config.external}}setupUiPluginConfig(){return{getters:this.getters,stateObserver:this.state,dispatch:this.dispatch,selection:this.selection,moveClient:this.session.move.bind(this.session),custom:this.config.custom,uiActions:this.config,lazyEvaluation:this.config.lazyEvaluation}}checkDispatchAllowed(e){const t=this.handlers.map((t=>t.allowDispatch(e)));return new bi(t.flat())}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0}dispatchToHandlers(e,t){t=Me(t);for(const o of e)o.beforeHandle(t);for(const o of e)o.handle(t)}drawGrid(e){for(let[t,o]of this.renderers)e.ctx.save(),t.drawGrid(e,o),e.ctx.restore()}exportData(){let e=tv();for(let t of this.handlers)t instanceof iv&&t.export(e);return e.revisionId=this.session.getRevisionId()||Y,e=JSON.parse(JSON.stringify(e)),e}updateMode(e){"normal"!==e&&this.dispatch("STOP_EDITION",{cancel:!0}),this.config.mode=e,this.trigger("update")}exportXLSX(){this.dispatch("EVALUATE_CELLS");let e={...tv(),sheets:[ov(Xf,"Sheet1")]};for(let t of this.handlers)t instanceof Vu&&t.exportForExcel(e);return e=JSON.parse(JSON.stringify(e)),xS(e)}garbageCollectExternalResources(){for(const e of this.corePlugins)e.garbageCollectExternalResources()}},e.Registry=Cn,e.Revision=jv,e.SPREADSHEET_DIMENSIONS=AS,e.Spreadsheet=Rb,e.UIPlugin=zu,e.__info__=TS,e.addFunction=function(e,t){qd.add(e,t)},e.astToFormula=Eu,e.compile=ku,e.components=_S,e.convertAstNodes=Cu,e.coreTypes=fi,e.findCellInNewZone=Wo,e.functionCache=Du,e.helpers=MS,e.invalidateEvaluationCommands=gi,e.links=NS,e.load=Yf,e.parse=bu,e.readonlyAllowedCommands=mi,e.registries=OS,e.setTranslationMethod=function(e){o=e},e.tokenize=Yd,Object.defineProperty(e,"__esModule",{value:!0}),TS.version="16.1.0",TS.date="2023-02-27T14:56:39.727Z",TS.hash="5ecccad"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
2454
+ `}var RS;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(RS||(RS={}));const TS={},AS={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:O,HEADER_WIDTH:M,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:N,DEFAULT_CELL_HEIGHT:_,SCROLLBAR_WIDTH:F},OS={autofillModifiersRegistry:xg,autofillRulesRegistry:Ig,cellMenuRegistry:Tr,colMenuRegistry:Ar,linkMenuRegistry:Dg,functionRegistry:qd,featurePluginRegistry:ub,statefulUIPluginRegistry:gb,coreViewsPluginRegistry:pb,corePluginRegistry:db,rowMenuRegistry:Or,sidePanelRegistry:Sp,figureRegistry:Vg,sheetMenuRegistry:Wg,chartSidePanelComponentRegistry:hp,chartComponentRegistry:wn,chartRegistry:En,topbarMenuRegistry:qg,topbarComponentRegistry:Cp,clickableCellRegistry:mb,otRegistry:Zg,inverseCommandRegistry:zg,urlRegistry:cg,cellPopoverRegistry:Pg},MS={args:Pr,toBoolean:jr,toJsDate:Xr,toNumber:Hr,toString:Gr,toXC:Ft,toZone:Io,toCartesian:_t,numberToLetters:Mt,createFullMenuItem:xn,UuidGenerator:yo,formatValue:oo,computeTextWidth:ke,createEmptyWorkbookData:tv,createEmptySheet:ev,createEmptyExcelSheet:ov,getDefaultChartJsRuntime:ji,chartFontColor:_i,getMenuChildren:On,ChartColors:Ni,EvaluationError:c,CellErrorLevel:l,getFillingMode:Ki,rgbaToHex:mt,colorToRGBA:ft,positionToZone:qo,isDefined:Qe},NS={isMarkdownLink:We,parseMarkdownLink:Ze,markdownLink:qe,openLink:pg,urlRepresentation:gg},_S={ChartPanel:dp,ChartFigure:Un,ChartJsComponent:Yo,Grid:Vp,GridOverlay:xp,ScorecardChart:ri,LineConfigPanel:sp,LineBarPieDesignPanel:op,BarConfigPanel:Kg,LineBarPieConfigPanel:Yg,GaugeChartConfigPanel:np,GaugeChartDesignPanel:rp,ScorecardChartConfigPanel:lp,ScorecardChartDesignPanel:cp};e.AbstractChart=ci,e.CorePlugin=iv,e.DATETIME_FORMAT=j,e.DispatchResult=bi,e.EvaluationError=c,e.Model=class extends zv{constructor(e={},o={},i=[],n=new yo,r=!0){super(),this.corePlugins=[],this.featurePlugins=[],this.statefulUIPlugins=[],this.coreViewsPlugins=[],this.isReplayingCommand=!1,this.renderers=[],this.status=0,this.dispatch=(e,t)=>{const o={...t,type:e};let i=this.status;if(this.getters.isReadonly()&&(n=o,!mi.has(n.type)))return new bi(67);var n;if(!this.session.canApplyOptimisticUpdate())return new bi(64);switch(i){case 0:const t=this.checkDispatchAllowed(o);if(!t.isSuccessful)return t;this.status=1;const{changes:i,commands:n}=this.state.recordChanges((()=>{vi(o)&&this.state.addCommand(o),this.dispatchToHandlers(this.handlers,o),this.finalize()}));this.session.save(n,i),this.status=0,this.trigger("update");break;case 1:if(vi(o)){const e=this.checkDispatchAllowed(o);if(!e.isSuccessful)return e;this.state.addCommand(o)}this.dispatchToHandlers(this.handlers,o);break;case 3:throw new Error("Cannot dispatch commands in the finalize state");case 2:if(vi(o))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,o)}return bi.Success},this.dispatchFromCorePlugin=(e,t)=>{const o={...t,type:e},i=this.status;this.status=2;const n=this.isReplayingCommand?[this.range,...this.corePlugins,...this.coreViewsPlugins]:this.handlers;return this.dispatchToHandlers(n,o),this.status=i,bi.Success},i=Qf(e,i);const s=Yf(e,r);this.state=new zb,this.uuidGenerator=n,this.config=this.setupConfig(o),this.session=this.setupSession(s.revisionId),this.history=new Lb(this.dispatchFromCorePlugin,this.session),this.coreGetters={},this.range=new Cv(this.coreGetters),this.coreGetters.getRangeString=this.range.getRangeString.bind(this.range),this.coreGetters.getRangeFromSheetXC=this.range.getRangeFromSheetXC.bind(this.range),this.coreGetters.createAdaptedRanges=this.range.createAdaptedRanges.bind(this.range),this.coreGetters.getRangeDataFromXc=this.range.getRangeDataFromXc.bind(this.range),this.coreGetters.getRangeDataFromZone=this.range.getRangeDataFromZone.bind(this.range),this.coreGetters.getRangeFromRangeData=this.range.getRangeFromRangeData.bind(this.range),this.coreGetters.getSelectionRangeString=this.range.getSelectionRangeString.bind(this.range),this.getters={isReadonly:()=>"readonly"===this.config.mode||"dashboard"===this.config.mode,isDashboard:()=>"dashboard"===this.config.mode,canUndo:this.history.canUndo.bind(this.history),canRedo:this.history.canRedo.bind(this.history),getClient:this.session.getClient.bind(this.session),getConnectedClients:this.session.getConnectedClients.bind(this.session),isFullySynchronized:this.session.isFullySynchronized.bind(this.session)},this.uuidGenerator.setIsFastStrategy(!0),this.selection=new Vb(this.getters),this.corePluginConfig=this.setupCorePluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(let e of db.getAll())this.setupCorePlugin(e,s);Object.assign(this.getters,this.coreGetters);for(let e of gb.getAll())this.statefulUIPlugins.push(this.setupUiPlugin(e));for(let e of pb.getAll())this.coreViewsPlugins.push(this.setupUiPlugin(e));for(let e of ub.getAll())this.featurePlugins.push(this.setupUiPlugin(e));this.uuidGenerator.setIsFastStrategy(!1),this.dispatch("START"),this.selection.observe(this,{handleEvent:()=>this.trigger("update")}),this.setupSessionEvents(),this.session.loadInitialMessages(i),this.joinSession(),o.snapshotRequested&&(this.session.snapshot(this.exportData()),this.garbageCollectExternalResources()),t.markRaw(this)}get handlers(){return[this.range,...this.corePlugins,...this.allUIPlugins,this.history]}get allUIPlugins(){return[...this.statefulUIPlugins,...this.coreViewsPlugins,...this.featurePlugins]}joinSession(){this.session.join(this.config.client)}leaveSession(){this.session.leave()}setupUiPlugin(e){const t=new e(this.uiPluginConfig);for(let o of e.getters){if(!(o in t))throw new Error(`Invalid getter name: ${o} for plugin ${t.constructor}`);if(o in this.getters)throw new Error(`Getter "${o}" is already defined.`);this.getters[o]=t[o].bind(t)}const o=e.layers.map((e=>[t,e]));return this.renderers.push(...o),this.renderers.sort(((e,t)=>e[1]-t[1])),t}setupCorePlugin(e,t){const o=new e(this.corePluginConfig);for(let t of e.getters){if(!(t in o))throw new Error(`Invalid getter name: ${t} for plugin ${o.constructor}`);if(t in this.coreGetters)throw new Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=o[t].bind(o)}o.import(t),this.corePlugins.push(o)}onRemoteRevisionReceived({commands:e}){for(let t of e){const e=this.status;this.status=2,this.dispatchToHandlers(this.statefulUIPlugins,t),this.status=e}this.finalize()}setupSession(e){return new Yv($b(e,this.state.recordChanges.bind(this.state),(e=>{this.checkDispatchAllowed(e).isSuccessful&&(this.isReplayingCommand=!0,this.dispatchToHandlers([this.range,...this.corePlugins,...this.coreViewsPlugins],e),this.isReplayingCommand=!1)})),this.config.transportService,e)}setupSessionEvents(){this.session.on("remote-revision-received",this,this.onRemoteRevisionReceived),this.session.on("revision-redone",this,this.finalize),this.session.on("revision-undone",this,this.finalize),this.session.on("unexpected-revision-id",this,(()=>this.trigger("unexpected-revision-id"))),this.session.on("collaborative-event-received",this,(()=>{this.trigger("update")}))}setupConfig(e){const t=e.client||{id:this.uuidGenerator.uuidv4(),name:r("Anonymous").toString()},o=e.transportService||new Tb;return{...e,mode:e.mode||"normal",custom:e.custom||{},external:e.external||{},transportService:o,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger("notify-ui",e),lazyEvaluation:!("lazyEvaluation"in e)||e.lazyEvaluation}}setupCorePluginConfig(){return{getters:this.coreGetters,stateObserver:this.state,range:this.range,dispatch:this.dispatchFromCorePlugin,uuidGenerator:this.uuidGenerator,custom:this.config.custom,external:this.config.external}}setupUiPluginConfig(){return{getters:this.getters,stateObserver:this.state,dispatch:this.dispatch,selection:this.selection,moveClient:this.session.move.bind(this.session),custom:this.config.custom,uiActions:this.config,lazyEvaluation:this.config.lazyEvaluation}}checkDispatchAllowed(e){const t=this.handlers.map((t=>t.allowDispatch(e)));return new bi(t.flat())}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0}dispatchToHandlers(e,t){t=Me(t);for(const o of e)o.beforeHandle(t);for(const o of e)o.handle(t)}drawGrid(e){for(let[t,o]of this.renderers)e.ctx.save(),t.drawGrid(e,o),e.ctx.restore()}exportData(){let e=tv();for(let t of this.handlers)t instanceof iv&&t.export(e);return e.revisionId=this.session.getRevisionId()||Y,e=JSON.parse(JSON.stringify(e)),e}updateMode(e){"normal"!==e&&this.dispatch("STOP_EDITION",{cancel:!0}),this.config.mode=e,this.trigger("update")}exportXLSX(){this.dispatch("EVALUATE_CELLS");let e={...tv(),sheets:[ov(Xf,"Sheet1")]};for(let t of this.handlers)t instanceof Vu&&t.exportForExcel(e);return e=JSON.parse(JSON.stringify(e)),xS(e)}garbageCollectExternalResources(){for(const e of this.corePlugins)e.garbageCollectExternalResources()}},e.Registry=Cn,e.Revision=jv,e.SPREADSHEET_DIMENSIONS=AS,e.Spreadsheet=Rb,e.UIPlugin=zu,e.__info__=TS,e.addFunction=function(e,t){qd.add(e,t)},e.astToFormula=Eu,e.compile=ku,e.components=_S,e.convertAstNodes=Cu,e.coreTypes=fi,e.findCellInNewZone=Wo,e.functionCache=Du,e.helpers=MS,e.invalidateEvaluationCommands=gi,e.links=NS,e.load=Yf,e.parse=bu,e.readonlyAllowedCommands=mi,e.registries=OS,e.setTranslationMethod=function(e){o=e},e.tokenize=Yd,Object.defineProperty(e,"__esModule",{value:!0}),TS.version="16.1.2",TS.date="2023-03-01T14:43:45.667Z",TS.hash="59bec2d"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odoo/o-spreadsheet",
3
- "version": "16.1.0",
3
+ "version": "16.1.2",
4
4
  "description": "A spreadsheet component",
5
5
  "main": "dist/o-spreadsheet.cjs.js",
6
6
  "browser": "dist/o-spreadsheet.iife.js",
@@ -11,20 +11,20 @@
11
11
  "dist/*.d.ts"
12
12
  ],
13
13
  "scripts": {
14
- "serve-static": "live-server --open=demo --watch=dist/o_spreadsheet.js,dist/o_spreadsheet.xml,demo",
14
+ "serve-static": "live-server --open=demo --watch=build/o_spreadsheet.js,build/o_spreadsheet.xml,demo",
15
15
  "dev": "npm-run-all build --parallel server serve-static watch:*",
16
16
  "server": "node tools/server/main.js",
17
17
  "build:js": "tsc --module es6 --incremental",
18
18
  "bundle:js": "rollup -c -m dev",
19
19
  "bundle:xml": "node tools/bundle_xml/main.js",
20
- "build": "npm-run-all build:js bundle:*",
20
+ "build": "npm-run-all build:js bundle:js 'bundle:xml -- --outDir build'",
21
21
  "doc": "typedoc",
22
22
  "precommit": "npm run prettier && npm run doc",
23
23
  "test": "jest",
24
24
  "test:watch": "jest --watch",
25
25
  "prettier": "prettier . --write",
26
26
  "check-formatting": "prettier . --check",
27
- "dist": "tsc --module es6 --declaration --declarationDir dist/types && rollup -c && npm run bundle:xml",
27
+ "dist": "tsc --module es6 --declaration --declarationDir dist/types && rollup -c && npm run bundle:xml -- --outDir dist",
28
28
  "prepare": "husky install",
29
29
  "watch:bundle": "npm run bundle:js -- --watch",
30
30
  "watch:ts": "npm run build:js -- --watch",
@@ -130,5 +130,8 @@
130
130
  },
131
131
  "lint-staged": {
132
132
  "*": "prettier --write"
133
+ },
134
+ "publishConfig": {
135
+ "tag": "latest"
133
136
  }
134
137
  }