@odoo/o-spreadsheet 16.3.37 → 16.3.39

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.
@@ -5355,8 +5355,7 @@ function isCtrlKey(ev) {
5355
5355
  */
5356
5356
  function useSpreadsheetRect() {
5357
5357
  const position = owl.useState({ x: 0, y: 0, width: 0, height: 0 });
5358
- let spreadsheetElement = document.querySelector(".o-spreadsheet");
5359
- updatePosition();
5358
+ let spreadsheetElement = null;
5360
5359
  function updatePosition() {
5361
5360
  if (!spreadsheetElement) {
5362
5361
  spreadsheetElement = document.querySelector(".o-spreadsheet");
@@ -5494,7 +5493,7 @@ class Popover extends owl.Component {
5494
5493
  if (!anchor)
5495
5494
  return;
5496
5495
  const propsMaxSize = { width: this.props.maxWidth, height: this.props.maxHeight };
5497
- const elDims = {
5496
+ let elDims = {
5498
5497
  width: el.getBoundingClientRect().width,
5499
5498
  height: el.getBoundingClientRect().height,
5500
5499
  };
@@ -5502,7 +5501,14 @@ class Popover extends owl.Component {
5502
5501
  const popoverPositionHelper = this.props.positioning === "BottomLeft"
5503
5502
  ? new BottomLeftPopoverContext(anchor, this.containerRect, propsMaxSize, spreadsheetRect)
5504
5503
  : new TopRightPopoverContext(anchor, this.containerRect, propsMaxSize, spreadsheetRect);
5505
- const style = popoverPositionHelper.getCss(elDims, this.props.verticalOffset);
5504
+ el.style["max-height"] = popoverPositionHelper.getMaxHeight(elDims.height) + "px";
5505
+ el.style["max-width"] = popoverPositionHelper.getMaxWidth(elDims.width) + "px";
5506
+ // Re-compute the dimensions after setting the max-width and max-height
5507
+ elDims = {
5508
+ width: el.getBoundingClientRect().width,
5509
+ height: el.getBoundingClientRect().height,
5510
+ };
5511
+ let style = popoverPositionHelper.getCss(elDims, this.props.verticalOffset);
5506
5512
  for (const property of Object.keys(style)) {
5507
5513
  el.style[property] = style[property];
5508
5514
  }
@@ -5578,8 +5584,6 @@ class PopoverPositionContext {
5578
5584
  const shouldRenderAtRight = this.shouldRenderAtRight(elDims.width);
5579
5585
  verticalOffset = shouldRenderAtBottom ? verticalOffset : -verticalOffset;
5580
5586
  const cssProperties = {
5581
- "max-height": maxHeight + "px",
5582
- "max-width": maxWidth + "px",
5583
5587
  top: this.getTopCoordinate(actualHeight, shouldRenderAtBottom) -
5584
5588
  this.spreadsheetOffset.y -
5585
5589
  verticalOffset +
@@ -21284,8 +21288,15 @@ class Composer extends owl.Component {
21284
21288
  }
21285
21289
  onPaste(ev) {
21286
21290
  if (this.env.model.getters.getEditionMode() !== "inactive") {
21291
+ // let the browser clipboard work
21287
21292
  ev.stopPropagation();
21288
21293
  }
21294
+ else {
21295
+ // the user meant to paste in the sheet, not open the composer with the pasted content
21296
+ // While we're not editing, we still have the focus and should therefore prevent
21297
+ // the native "paste" to occur.
21298
+ ev.preventDefault();
21299
+ }
21289
21300
  }
21290
21301
  /*
21291
21302
  * Triggered automatically by the content-editable between the keydown and key up
@@ -21294,10 +21305,6 @@ class Composer extends owl.Component {
21294
21305
  if (!this.shouldProcessInputEvents) {
21295
21306
  return;
21296
21307
  }
21297
- if (ev.inputType === "insertFromPaste" &&
21298
- this.env.model.getters.getEditionMode() === "inactive") {
21299
- return;
21300
- }
21301
21308
  ev.stopPropagation();
21302
21309
  let content;
21303
21310
  if (this.env.model.getters.getEditionMode() === "inactive") {
@@ -21698,10 +21705,7 @@ class GridComposer extends owl.Component {
21698
21705
  }
21699
21706
  get containerStyle() {
21700
21707
  if (this.env.model.getters.getEditionMode() === "inactive" || !this.rect) {
21701
- return `
21702
- position: absolute;
21703
- z-index: -1000;
21704
- `;
21708
+ return `z-index: -1000;`;
21705
21709
  }
21706
21710
  const isFormula = this.env.model.getters.getCurrentContent().startsWith("=");
21707
21711
  const cell = this.env.model.getters.getActiveCell();
@@ -22284,7 +22288,7 @@ class FiguresContainer extends owl.Component {
22284
22288
  });
22285
22289
  }
22286
22290
  getContainerRect(container) {
22287
- const { width: viewWidth, height: viewHeight } = this.env.model.getters.getMainViewportRect();
22291
+ const { width: viewWidth, height: viewHeight } = this.env.model.getters.getSheetViewDimension();
22288
22292
  const { x: viewportX, y: viewportY } = this.env.model.getters.getMainViewportCoordinates();
22289
22293
  const x = ["bottomRight", "topRight"].includes(container) ? viewportX : 0;
22290
22294
  const width = viewWidth - x;
@@ -48102,6 +48106,7 @@ const helpers = {
48102
48106
  isDefined: isDefined$1,
48103
48107
  lazy,
48104
48108
  genericRepeat,
48109
+ deepEquals,
48105
48110
  };
48106
48111
  const links = {
48107
48112
  isMarkdownLink,
@@ -48162,6 +48167,6 @@ exports.setTranslationMethod = setTranslationMethod;
48162
48167
  exports.tokenize = tokenize;
48163
48168
 
48164
48169
 
48165
- __info__.version = '16.3.37';
48166
- __info__.date = '2024-06-03T14:49:37.305Z';
48167
- __info__.hash = 'e7bf8e1';
48170
+ __info__.version = '16.3.39';
48171
+ __info__.date = '2024-06-14T09:57:15.035Z';
48172
+ __info__.hash = '9701da6';
@@ -963,6 +963,10 @@ declare function isDefined<T>(argument: T | undefined): argument is T;
963
963
  * Lazy value computed by the provided function.
964
964
  */
965
965
  declare function lazy<T>(fn: (() => T) | T): Lazy<T>;
966
+ /**
967
+ * Compares two objects.
968
+ */
969
+ declare function deepEquals(o1: any, o2: any): boolean;
966
970
 
967
971
  interface ConstructorArgs {
968
972
  readonly zone: Readonly<Zone | UnboundedZone>;
@@ -7218,6 +7222,7 @@ declare const helpers: {
7218
7222
  isDefined: typeof isDefined;
7219
7223
  lazy: typeof lazy;
7220
7224
  genericRepeat: typeof genericRepeat;
7225
+ deepEquals: typeof deepEquals;
7221
7226
  };
7222
7227
  declare const links: {
7223
7228
  isMarkdownLink: typeof isMarkdownLink;
@@ -5351,8 +5351,7 @@ function isCtrlKey(ev) {
5351
5351
  */
5352
5352
  function useSpreadsheetRect() {
5353
5353
  const position = useState({ x: 0, y: 0, width: 0, height: 0 });
5354
- let spreadsheetElement = document.querySelector(".o-spreadsheet");
5355
- updatePosition();
5354
+ let spreadsheetElement = null;
5356
5355
  function updatePosition() {
5357
5356
  if (!spreadsheetElement) {
5358
5357
  spreadsheetElement = document.querySelector(".o-spreadsheet");
@@ -5490,7 +5489,7 @@ class Popover extends Component {
5490
5489
  if (!anchor)
5491
5490
  return;
5492
5491
  const propsMaxSize = { width: this.props.maxWidth, height: this.props.maxHeight };
5493
- const elDims = {
5492
+ let elDims = {
5494
5493
  width: el.getBoundingClientRect().width,
5495
5494
  height: el.getBoundingClientRect().height,
5496
5495
  };
@@ -5498,7 +5497,14 @@ class Popover extends Component {
5498
5497
  const popoverPositionHelper = this.props.positioning === "BottomLeft"
5499
5498
  ? new BottomLeftPopoverContext(anchor, this.containerRect, propsMaxSize, spreadsheetRect)
5500
5499
  : new TopRightPopoverContext(anchor, this.containerRect, propsMaxSize, spreadsheetRect);
5501
- const style = popoverPositionHelper.getCss(elDims, this.props.verticalOffset);
5500
+ el.style["max-height"] = popoverPositionHelper.getMaxHeight(elDims.height) + "px";
5501
+ el.style["max-width"] = popoverPositionHelper.getMaxWidth(elDims.width) + "px";
5502
+ // Re-compute the dimensions after setting the max-width and max-height
5503
+ elDims = {
5504
+ width: el.getBoundingClientRect().width,
5505
+ height: el.getBoundingClientRect().height,
5506
+ };
5507
+ let style = popoverPositionHelper.getCss(elDims, this.props.verticalOffset);
5502
5508
  for (const property of Object.keys(style)) {
5503
5509
  el.style[property] = style[property];
5504
5510
  }
@@ -5574,8 +5580,6 @@ class PopoverPositionContext {
5574
5580
  const shouldRenderAtRight = this.shouldRenderAtRight(elDims.width);
5575
5581
  verticalOffset = shouldRenderAtBottom ? verticalOffset : -verticalOffset;
5576
5582
  const cssProperties = {
5577
- "max-height": maxHeight + "px",
5578
- "max-width": maxWidth + "px",
5579
5583
  top: this.getTopCoordinate(actualHeight, shouldRenderAtBottom) -
5580
5584
  this.spreadsheetOffset.y -
5581
5585
  verticalOffset +
@@ -21280,8 +21284,15 @@ class Composer extends Component {
21280
21284
  }
21281
21285
  onPaste(ev) {
21282
21286
  if (this.env.model.getters.getEditionMode() !== "inactive") {
21287
+ // let the browser clipboard work
21283
21288
  ev.stopPropagation();
21284
21289
  }
21290
+ else {
21291
+ // the user meant to paste in the sheet, not open the composer with the pasted content
21292
+ // While we're not editing, we still have the focus and should therefore prevent
21293
+ // the native "paste" to occur.
21294
+ ev.preventDefault();
21295
+ }
21285
21296
  }
21286
21297
  /*
21287
21298
  * Triggered automatically by the content-editable between the keydown and key up
@@ -21290,10 +21301,6 @@ class Composer extends Component {
21290
21301
  if (!this.shouldProcessInputEvents) {
21291
21302
  return;
21292
21303
  }
21293
- if (ev.inputType === "insertFromPaste" &&
21294
- this.env.model.getters.getEditionMode() === "inactive") {
21295
- return;
21296
- }
21297
21304
  ev.stopPropagation();
21298
21305
  let content;
21299
21306
  if (this.env.model.getters.getEditionMode() === "inactive") {
@@ -21694,10 +21701,7 @@ class GridComposer extends Component {
21694
21701
  }
21695
21702
  get containerStyle() {
21696
21703
  if (this.env.model.getters.getEditionMode() === "inactive" || !this.rect) {
21697
- return `
21698
- position: absolute;
21699
- z-index: -1000;
21700
- `;
21704
+ return `z-index: -1000;`;
21701
21705
  }
21702
21706
  const isFormula = this.env.model.getters.getCurrentContent().startsWith("=");
21703
21707
  const cell = this.env.model.getters.getActiveCell();
@@ -22280,7 +22284,7 @@ class FiguresContainer extends Component {
22280
22284
  });
22281
22285
  }
22282
22286
  getContainerRect(container) {
22283
- const { width: viewWidth, height: viewHeight } = this.env.model.getters.getMainViewportRect();
22287
+ const { width: viewWidth, height: viewHeight } = this.env.model.getters.getSheetViewDimension();
22284
22288
  const { x: viewportX, y: viewportY } = this.env.model.getters.getMainViewportCoordinates();
22285
22289
  const x = ["bottomRight", "topRight"].includes(container) ? viewportX : 0;
22286
22290
  const width = viewWidth - x;
@@ -48098,6 +48102,7 @@ const helpers = {
48098
48102
  isDefined: isDefined$1,
48099
48103
  lazy,
48100
48104
  genericRepeat,
48105
+ deepEquals,
48101
48106
  };
48102
48107
  const links = {
48103
48108
  isMarkdownLink,
@@ -48130,6 +48135,6 @@ function addFunction(functionName, functionDescription) {
48130
48135
  export { AbstractChart, CommandResult, CorePlugin, 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, setDefaultSheetViewSize, setTranslationMethod, tokenize };
48131
48136
 
48132
48137
 
48133
- __info__.version = '16.3.37';
48134
- __info__.date = '2024-06-03T14:49:37.305Z';
48135
- __info__.hash = 'e7bf8e1';
48138
+ __info__.version = '16.3.39';
48139
+ __info__.date = '2024-06-14T09:57:15.035Z';
48140
+ __info__.hash = '9701da6';
@@ -5352,8 +5352,7 @@
5352
5352
  */
5353
5353
  function useSpreadsheetRect() {
5354
5354
  const position = owl.useState({ x: 0, y: 0, width: 0, height: 0 });
5355
- let spreadsheetElement = document.querySelector(".o-spreadsheet");
5356
- updatePosition();
5355
+ let spreadsheetElement = null;
5357
5356
  function updatePosition() {
5358
5357
  if (!spreadsheetElement) {
5359
5358
  spreadsheetElement = document.querySelector(".o-spreadsheet");
@@ -5491,7 +5490,7 @@
5491
5490
  if (!anchor)
5492
5491
  return;
5493
5492
  const propsMaxSize = { width: this.props.maxWidth, height: this.props.maxHeight };
5494
- const elDims = {
5493
+ let elDims = {
5495
5494
  width: el.getBoundingClientRect().width,
5496
5495
  height: el.getBoundingClientRect().height,
5497
5496
  };
@@ -5499,7 +5498,14 @@
5499
5498
  const popoverPositionHelper = this.props.positioning === "BottomLeft"
5500
5499
  ? new BottomLeftPopoverContext(anchor, this.containerRect, propsMaxSize, spreadsheetRect)
5501
5500
  : new TopRightPopoverContext(anchor, this.containerRect, propsMaxSize, spreadsheetRect);
5502
- const style = popoverPositionHelper.getCss(elDims, this.props.verticalOffset);
5501
+ el.style["max-height"] = popoverPositionHelper.getMaxHeight(elDims.height) + "px";
5502
+ el.style["max-width"] = popoverPositionHelper.getMaxWidth(elDims.width) + "px";
5503
+ // Re-compute the dimensions after setting the max-width and max-height
5504
+ elDims = {
5505
+ width: el.getBoundingClientRect().width,
5506
+ height: el.getBoundingClientRect().height,
5507
+ };
5508
+ let style = popoverPositionHelper.getCss(elDims, this.props.verticalOffset);
5503
5509
  for (const property of Object.keys(style)) {
5504
5510
  el.style[property] = style[property];
5505
5511
  }
@@ -5575,8 +5581,6 @@
5575
5581
  const shouldRenderAtRight = this.shouldRenderAtRight(elDims.width);
5576
5582
  verticalOffset = shouldRenderAtBottom ? verticalOffset : -verticalOffset;
5577
5583
  const cssProperties = {
5578
- "max-height": maxHeight + "px",
5579
- "max-width": maxWidth + "px",
5580
5584
  top: this.getTopCoordinate(actualHeight, shouldRenderAtBottom) -
5581
5585
  this.spreadsheetOffset.y -
5582
5586
  verticalOffset +
@@ -21281,8 +21285,15 @@
21281
21285
  }
21282
21286
  onPaste(ev) {
21283
21287
  if (this.env.model.getters.getEditionMode() !== "inactive") {
21288
+ // let the browser clipboard work
21284
21289
  ev.stopPropagation();
21285
21290
  }
21291
+ else {
21292
+ // the user meant to paste in the sheet, not open the composer with the pasted content
21293
+ // While we're not editing, we still have the focus and should therefore prevent
21294
+ // the native "paste" to occur.
21295
+ ev.preventDefault();
21296
+ }
21286
21297
  }
21287
21298
  /*
21288
21299
  * Triggered automatically by the content-editable between the keydown and key up
@@ -21291,10 +21302,6 @@
21291
21302
  if (!this.shouldProcessInputEvents) {
21292
21303
  return;
21293
21304
  }
21294
- if (ev.inputType === "insertFromPaste" &&
21295
- this.env.model.getters.getEditionMode() === "inactive") {
21296
- return;
21297
- }
21298
21305
  ev.stopPropagation();
21299
21306
  let content;
21300
21307
  if (this.env.model.getters.getEditionMode() === "inactive") {
@@ -21695,10 +21702,7 @@
21695
21702
  }
21696
21703
  get containerStyle() {
21697
21704
  if (this.env.model.getters.getEditionMode() === "inactive" || !this.rect) {
21698
- return `
21699
- position: absolute;
21700
- z-index: -1000;
21701
- `;
21705
+ return `z-index: -1000;`;
21702
21706
  }
21703
21707
  const isFormula = this.env.model.getters.getCurrentContent().startsWith("=");
21704
21708
  const cell = this.env.model.getters.getActiveCell();
@@ -22281,7 +22285,7 @@
22281
22285
  });
22282
22286
  }
22283
22287
  getContainerRect(container) {
22284
- const { width: viewWidth, height: viewHeight } = this.env.model.getters.getMainViewportRect();
22288
+ const { width: viewWidth, height: viewHeight } = this.env.model.getters.getSheetViewDimension();
22285
22289
  const { x: viewportX, y: viewportY } = this.env.model.getters.getMainViewportCoordinates();
22286
22290
  const x = ["bottomRight", "topRight"].includes(container) ? viewportX : 0;
22287
22291
  const width = viewWidth - x;
@@ -48099,6 +48103,7 @@
48099
48103
  isDefined: isDefined$1,
48100
48104
  lazy,
48101
48105
  genericRepeat,
48106
+ deepEquals,
48102
48107
  };
48103
48108
  const links = {
48104
48109
  isMarkdownLink,
@@ -48161,9 +48166,9 @@
48161
48166
  Object.defineProperty(exports, '__esModule', { value: true });
48162
48167
 
48163
48168
 
48164
- __info__.version = '16.3.37';
48165
- __info__.date = '2024-06-03T14:49:37.305Z';
48166
- __info__.hash = 'e7bf8e1';
48169
+ __info__.version = '16.3.39';
48170
+ __info__.date = '2024-06-14T09:57:15.035Z';
48171
+ __info__.hash = '9701da6';
48167
48172
 
48168
48173
 
48169
48174
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);
@@ -163,7 +163,7 @@
163
163
  }
164
164
  }
165
165
  }
166
- `;class tn extends t.Component{static size={width:G,height:295};static template="o-spreadsheet-FilterMenu";static style=en;static components={FilterMenuValueItem:Js};state=t.useState({values:[],textFilter:"",selectedValue:void 0});searchBar=t.useRef("filterMenuSearchBar");setup(){t.onWillUpdateProps((e=>{vt(e.filterPosition,this.props.filterPosition)||(this.state.values=this.getFilterValues(e.filterPosition))})),this.state.values=this.getFilterValues(this.props.filterPosition)}get isReadonly(){return this.env.model.getters.isReadonly()}getFilterValues(e){const t=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getFilter({sheetId:t,...e});if(!o)return[];const i=(o.filteredZone?Ci(o.filteredZone):[]).filter((({row:e})=>!this.env.model.getters.isRowHidden(t,e))).map((({col:e,row:o})=>this.env.model.getters.getEvaluatedCell({sheetId:t,col:e,row:o}).formattedValue)),s=this.env.model.getters.getFilterValues({sheetId:t,...e}),n=[...i,...s],r=s.map(Et);return[...new Set(n.map(Et))].sort(((e,t)=>e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"}))).map((e=>({checked:-1===r.findIndex((t=>t===e)),string:n.find((t=>Et(t)===e))||""})))}checkValue(e){this.state.selectedValue=e.string,e.checked=!e.checked,this.searchBar.el?.focus()}onMouseMove(e){this.state.selectedValue=e.string}selectAll(){this.state.values.forEach((e=>e.checked=!0))}clearAll(){this.state.values.forEach((e=>e.checked=!1))}get filterTable(){const e=this.env.model.getters.getActiveSheetId(),t=this.props.filterPosition;return this.env.model.getters.getFilterTable({sheetId:e,...t})}get displayedValues(){return this.state.textFilter?Jo(this.state.textFilter,this.state.values,(e=>e.string)):this.state.values}confirm(){const e=this.props.filterPosition;this.env.model.dispatch("UPDATE_FILTER",{...e,sheetId:this.env.model.getters.getActiveSheetId(),values:this.state.values.filter((e=>!e.checked)).map((e=>e.string))}),this.props.onClosed?.()}cancel(){this.props.onClosed?.()}onKeyDown(e){const t=this.displayedValues;if(0===t.length)return;let o;if(void 0!==this.state.selectedValue){const e=t.findIndex((e=>e.string===this.state.selectedValue));o=-1===e?void 0:e}switch(e.key){case"ArrowDown":o=void 0===o?0:Math.min(o+1,t.length-1),e.preventDefault(),e.stopPropagation();break;case"ArrowUp":o=void 0===o?t.length-1:Math.max(o-1,0),e.preventDefault(),e.stopPropagation();break;case"Enter":void 0!==o&&this.checkValue(t[o]),e.stopPropagation(),e.preventDefault()}this.state.selectedValue=void 0!==o?t[o].string:void 0,"ArrowUp"!==e.key&&"ArrowDown"!==e.key||this.scrollListToSelectedValue(e.key)}clearScrolledToValue(){this.state.values.forEach((e=>e.scrolledTo=void 0))}scrollListToSelectedValue(e){this.clearScrolledToValue();const t=this.state.values.find((e=>e.string===this.state.selectedValue));t&&(t.scrolledTo="ArrowUp"===e?"top":"bottom")}sortFilterZone(e){const t=this.props.filterPosition,o=this.filterTable;if(!t||!o||!o.contentZone)return;const i=this.env.model.getters.getActiveSheetId();this.env.model.dispatch("SORT_CELLS",{sheetId:i,col:t.col,row:o.contentZone.top,zone:o.contentZone,sortDirection:e,sortOptions:{emptyCellAsZero:!0,sortHeaders:!0}}),this.props.onClosed?.()}}tn.props={filterPosition:Object,onClosed:{type:Function,optional:!0}};const on={onOpen:(e,t)=>({isOpen:!0,props:{filterPosition:e},Component:tn,cellCorner:"BottomLeft"})},sn=/Mac/i,nn=["Shift","Control","Alt","Meta"];function rn(e,t){return!!t.target&&e.contains(t.target)}function an(){const e=document.querySelector(".o-grid-overlay");if(e){const{top:t,left:o}=e?.getBoundingClientRect();return{top:t,left:o}}throw new Error("Can't find spreadsheet position")}function ln(e){const t=e.getBoundingClientRect();return{x:t.x,y:t.y,width:t.width,height:t.height}}function*cn(e){if(yield e,e.hasChildNodes())for(let t of e.childNodes)yield*cn(t)}const hn=/^[a-zA-Z]$/;function dn(){return Boolean(sn.test(navigator.userAgent))}function un(e){return dn()?e.metaKey:e.ctrlKey}function gn(){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:s,height:n}=o.getBoundingClientRect();e.x=i,e.y=t,e.width=s,e.height=n}}return i(),t.onMounted(i),t.onPatched(i),e}function pn(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:s,width:n,height:r}=t.getBoundingClientRect();o.x=s,o.y=i,o.width=n,o.height=r}return t.onMounted(i),t.onPatched(i),o}function mn(e,t){return bn(di(fn(e),fn(t)))}function fn(e){return{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height}}function bn(e){if(e)return{x:e.left,y:e.top,width:e.right-e.left,height:e.bottom-e.top}}Ni`
166
+ `;class tn extends t.Component{static size={width:G,height:295};static template="o-spreadsheet-FilterMenu";static style=en;static components={FilterMenuValueItem:Js};state=t.useState({values:[],textFilter:"",selectedValue:void 0});searchBar=t.useRef("filterMenuSearchBar");setup(){t.onWillUpdateProps((e=>{vt(e.filterPosition,this.props.filterPosition)||(this.state.values=this.getFilterValues(e.filterPosition))})),this.state.values=this.getFilterValues(this.props.filterPosition)}get isReadonly(){return this.env.model.getters.isReadonly()}getFilterValues(e){const t=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getFilter({sheetId:t,...e});if(!o)return[];const i=(o.filteredZone?Ci(o.filteredZone):[]).filter((({row:e})=>!this.env.model.getters.isRowHidden(t,e))).map((({col:e,row:o})=>this.env.model.getters.getEvaluatedCell({sheetId:t,col:e,row:o}).formattedValue)),s=this.env.model.getters.getFilterValues({sheetId:t,...e}),n=[...i,...s],r=s.map(Et);return[...new Set(n.map(Et))].sort(((e,t)=>e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"}))).map((e=>({checked:-1===r.findIndex((t=>t===e)),string:n.find((t=>Et(t)===e))||""})))}checkValue(e){this.state.selectedValue=e.string,e.checked=!e.checked,this.searchBar.el?.focus()}onMouseMove(e){this.state.selectedValue=e.string}selectAll(){this.state.values.forEach((e=>e.checked=!0))}clearAll(){this.state.values.forEach((e=>e.checked=!1))}get filterTable(){const e=this.env.model.getters.getActiveSheetId(),t=this.props.filterPosition;return this.env.model.getters.getFilterTable({sheetId:e,...t})}get displayedValues(){return this.state.textFilter?Jo(this.state.textFilter,this.state.values,(e=>e.string)):this.state.values}confirm(){const e=this.props.filterPosition;this.env.model.dispatch("UPDATE_FILTER",{...e,sheetId:this.env.model.getters.getActiveSheetId(),values:this.state.values.filter((e=>!e.checked)).map((e=>e.string))}),this.props.onClosed?.()}cancel(){this.props.onClosed?.()}onKeyDown(e){const t=this.displayedValues;if(0===t.length)return;let o;if(void 0!==this.state.selectedValue){const e=t.findIndex((e=>e.string===this.state.selectedValue));o=-1===e?void 0:e}switch(e.key){case"ArrowDown":o=void 0===o?0:Math.min(o+1,t.length-1),e.preventDefault(),e.stopPropagation();break;case"ArrowUp":o=void 0===o?t.length-1:Math.max(o-1,0),e.preventDefault(),e.stopPropagation();break;case"Enter":void 0!==o&&this.checkValue(t[o]),e.stopPropagation(),e.preventDefault()}this.state.selectedValue=void 0!==o?t[o].string:void 0,"ArrowUp"!==e.key&&"ArrowDown"!==e.key||this.scrollListToSelectedValue(e.key)}clearScrolledToValue(){this.state.values.forEach((e=>e.scrolledTo=void 0))}scrollListToSelectedValue(e){this.clearScrolledToValue();const t=this.state.values.find((e=>e.string===this.state.selectedValue));t&&(t.scrolledTo="ArrowUp"===e?"top":"bottom")}sortFilterZone(e){const t=this.props.filterPosition,o=this.filterTable;if(!t||!o||!o.contentZone)return;const i=this.env.model.getters.getActiveSheetId();this.env.model.dispatch("SORT_CELLS",{sheetId:i,col:t.col,row:o.contentZone.top,zone:o.contentZone,sortDirection:e,sortOptions:{emptyCellAsZero:!0,sortHeaders:!0}}),this.props.onClosed?.()}}tn.props={filterPosition:Object,onClosed:{type:Function,optional:!0}};const on={onOpen:(e,t)=>({isOpen:!0,props:{filterPosition:e},Component:tn,cellCorner:"BottomLeft"})},sn=/Mac/i,nn=["Shift","Control","Alt","Meta"];function rn(e,t){return!!t.target&&e.contains(t.target)}function an(){const e=document.querySelector(".o-grid-overlay");if(e){const{top:t,left:o}=e?.getBoundingClientRect();return{top:t,left:o}}throw new Error("Can't find spreadsheet position")}function ln(e){const t=e.getBoundingClientRect();return{x:t.x,y:t.y,width:t.width,height:t.height}}function*cn(e){if(yield e,e.hasChildNodes())for(let t of e.childNodes)yield*cn(t)}const hn=/^[a-zA-Z]$/;function dn(){return Boolean(sn.test(navigator.userAgent))}function un(e){return dn()?e.metaKey:e.ctrlKey}function gn(){const e=t.useState({x:0,y:0,width:0,height:0});let o=null;function i(){if(o||(o=document.querySelector(".o-spreadsheet")),o){const{top:t,left:i,width:s,height:n}=o.getBoundingClientRect();e.x=i,e.y=t,e.width=s,e.height=n}}return t.onMounted(i),t.onPatched(i),e}function pn(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:s,width:n,height:r}=t.getBoundingClientRect();o.x=s,o.y=i,o.width=n,o.height=r}return t.onMounted(i),t.onPatched(i),o}function mn(e,t){return bn(di(fn(e),fn(t)))}function fn(e){return{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height}}function bn(e){if(e)return{x:e.left,y:e.top,width:e.right-e.left,height:e.bottom-e.top}}Ni`
167
167
  .o-popover {
168
168
  position: absolute;
169
169
  z-index: ${ue.Popover};
@@ -172,7 +172,7 @@
172
172
  width: fit-content;
173
173
  height: fit-content;
174
174
  }
175
- `;class vn extends t.Component{static template="o-spreadsheet-Popover";static defaultProps={positioning:"BottomLeft",verticalOffset:0,onMouseWheel:()=>{},onPopoverMoved:()=>{},onPopoverHidden:()=>{},zIndex:ue.Popover};popoverRef=t.useRef("popover");currentPosition=void 0;currentDisplayValue=void 0;spreadsheetRect=gn();containerRect;setup(){this.containerRect=function(){const e=t.useState({x:0,y:0,width:0,height:0}),o=t.useComponent(),i=gn();function s(){const t=o.env,s="getPopoverContainerRect"in t?t.getPopoverContainerRect():i;e.x=s.x,e.y=s.y,e.width=s.width,e.height=s.height}return s(),t.onMounted(s),t.onPatched(s),e}(),t.useEffect((()=>{if(!this.containerRect)throw new Error("Popover container is not defined");const e=this.popoverRef.el,t=mn(this.props.anchorRect,this.containerRect),o=t?"block":"none";if("none"!==this.currentDisplayValue&&"none"===o&&this.props.onPopoverHidden?.(),e.style.display=o,this.currentDisplayValue=o,!t)return;const i={width:this.props.maxWidth,height:this.props.maxHeight},s={width:e.getBoundingClientRect().width,height:e.getBoundingClientRect().height},n=this.spreadsheetRect,r="BottomLeft"===this.props.positioning?new Cn(t,this.containerRect,i,n):new En(t,this.containerRect,i,n),a=r.getCss(s,this.props.verticalOffset);for(const t of Object.keys(a))e.style[t]=a[t];const l=r.getCurrentPosition(s);this.currentPosition&&l!==this.currentPosition&&this.props.onPopoverMoved?.(),this.currentPosition=l}))}get popoverStyle(){return Li({"z-index":`${this.props.zIndex}`})}}vn.props={anchorRect:Object,containerRect:{type:Object,optional:!0},positioning:{type:String,optional:!0},maxWidth:{type:Number,optional:!0},maxHeight:{type:Number,optional:!0},verticalOffset:{type:Number,optional:!0},onMouseWheel:{type:Function,optional:!0},onPopoverHidden:{type:Function,optional:!0},onPopoverMoved:{type:Function,optional:!0},zIndex:{type:Number,optional:!0},slots:Object};class Sn{anchorRect;containerRect;propsMaxSize;spreadsheetOffset;constructor(e,t,o,i){this.anchorRect=e,this.containerRect=t,this.propsMaxSize=o,this.spreadsheetOffset=i}shouldRenderAtBottom(e){return e<=this.availableHeightDown||this.availableHeightDown>=this.availableHeightUp}shouldRenderAtRight(e){return e<=this.availableWidthRight||this.availableWidthRight>=this.availableWidthLeft}getMaxHeight(e){const t=this.shouldRenderAtBottom(e)?this.availableHeightDown:this.availableHeightUp;return this.propsMaxSize.height?Math.min(t,this.propsMaxSize.height):t}getMaxWidth(e){const t=this.shouldRenderAtRight(e)?this.availableWidthRight:this.availableWidthLeft;return this.propsMaxSize.width?Math.min(t,this.propsMaxSize.width):t}getCss(e,t){const o=this.getMaxHeight(e.height),i=this.getMaxWidth(e.width),s=Math.min(o,e.height),n=Math.min(i,e.width),r=this.shouldRenderAtBottom(e.height),a=this.shouldRenderAtRight(e.width);t=r?t:-t;return{"max-height":o+"px","max-width":i+"px",top:this.getTopCoordinate(s,r)-this.spreadsheetOffset.y-t+"px",left:this.getLeftCoordinate(n,a)-this.spreadsheetOffset.x+"px"}}getCurrentPosition(e){const t=this.shouldRenderAtBottom(e.height),o=this.shouldRenderAtRight(e.width);return t&&o?"BottomRight":t&&!o?"BottomLeft":!t&&o?"TopRight":"TopLeft"}}class Cn extends Sn{get availableHeightUp(){return this.anchorRect.y-this.containerRect.y}get availableHeightDown(){return this.containerRect.height-this.availableHeightUp-this.anchorRect.height}get availableWidthRight(){return this.containerRect.x+this.containerRect.width-this.anchorRect.x}get availableWidthLeft(){return this.anchorRect.x+this.anchorRect.width-this.containerRect.x}getTopCoordinate(e,t){return t?this.anchorRect.y+this.anchorRect.height:this.anchorRect.y-e}getLeftCoordinate(e,t){return t?this.anchorRect.x:this.anchorRect.x+this.anchorRect.width-e}}class En extends Sn{get availableHeightUp(){return this.anchorRect.y+this.anchorRect.height-this.containerRect.y}get availableHeightDown(){return this.containerRect.y+this.containerRect.height-this.anchorRect.y}get availableWidthRight(){return this.containerRect.width-this.anchorRect.width-this.availableWidthLeft}get availableWidthLeft(){return this.anchorRect.x-this.containerRect.x}getTopCoordinate(e,t){return t?this.anchorRect.y:this.anchorRect.y+this.anchorRect.height-e}getLeftCoordinate(e,t){return t?this.anchorRect.x+this.anchorRect.width:this.anchorRect.x-e}}Ni`
175
+ `;class vn extends t.Component{static template="o-spreadsheet-Popover";static defaultProps={positioning:"BottomLeft",verticalOffset:0,onMouseWheel:()=>{},onPopoverMoved:()=>{},onPopoverHidden:()=>{},zIndex:ue.Popover};popoverRef=t.useRef("popover");currentPosition=void 0;currentDisplayValue=void 0;spreadsheetRect=gn();containerRect;setup(){this.containerRect=function(){const e=t.useState({x:0,y:0,width:0,height:0}),o=t.useComponent(),i=gn();function s(){const t=o.env,s="getPopoverContainerRect"in t?t.getPopoverContainerRect():i;e.x=s.x,e.y=s.y,e.width=s.width,e.height=s.height}return s(),t.onMounted(s),t.onPatched(s),e}(),t.useEffect((()=>{if(!this.containerRect)throw new Error("Popover container is not defined");const e=this.popoverRef.el,t=mn(this.props.anchorRect,this.containerRect),o=t?"block":"none";if("none"!==this.currentDisplayValue&&"none"===o&&this.props.onPopoverHidden?.(),e.style.display=o,this.currentDisplayValue=o,!t)return;const i={width:this.props.maxWidth,height:this.props.maxHeight};let s={width:e.getBoundingClientRect().width,height:e.getBoundingClientRect().height};const n=this.spreadsheetRect,r="BottomLeft"===this.props.positioning?new Cn(t,this.containerRect,i,n):new En(t,this.containerRect,i,n);e.style["max-height"]=r.getMaxHeight(s.height)+"px",e.style["max-width"]=r.getMaxWidth(s.width)+"px",s={width:e.getBoundingClientRect().width,height:e.getBoundingClientRect().height};let a=r.getCss(s,this.props.verticalOffset);for(const t of Object.keys(a))e.style[t]=a[t];const l=r.getCurrentPosition(s);this.currentPosition&&l!==this.currentPosition&&this.props.onPopoverMoved?.(),this.currentPosition=l}))}get popoverStyle(){return Li({"z-index":`${this.props.zIndex}`})}}vn.props={anchorRect:Object,containerRect:{type:Object,optional:!0},positioning:{type:String,optional:!0},maxWidth:{type:Number,optional:!0},maxHeight:{type:Number,optional:!0},verticalOffset:{type:Number,optional:!0},onMouseWheel:{type:Function,optional:!0},onPopoverHidden:{type:Function,optional:!0},onPopoverMoved:{type:Function,optional:!0},zIndex:{type:Number,optional:!0},slots:Object};class Sn{anchorRect;containerRect;propsMaxSize;spreadsheetOffset;constructor(e,t,o,i){this.anchorRect=e,this.containerRect=t,this.propsMaxSize=o,this.spreadsheetOffset=i}shouldRenderAtBottom(e){return e<=this.availableHeightDown||this.availableHeightDown>=this.availableHeightUp}shouldRenderAtRight(e){return e<=this.availableWidthRight||this.availableWidthRight>=this.availableWidthLeft}getMaxHeight(e){const t=this.shouldRenderAtBottom(e)?this.availableHeightDown:this.availableHeightUp;return this.propsMaxSize.height?Math.min(t,this.propsMaxSize.height):t}getMaxWidth(e){const t=this.shouldRenderAtRight(e)?this.availableWidthRight:this.availableWidthLeft;return this.propsMaxSize.width?Math.min(t,this.propsMaxSize.width):t}getCss(e,t){const o=this.getMaxHeight(e.height),i=this.getMaxWidth(e.width),s=Math.min(o,e.height),n=Math.min(i,e.width),r=this.shouldRenderAtBottom(e.height),a=this.shouldRenderAtRight(e.width);t=r?t:-t;return{top:this.getTopCoordinate(s,r)-this.spreadsheetOffset.y-t+"px",left:this.getLeftCoordinate(n,a)-this.spreadsheetOffset.x+"px"}}getCurrentPosition(e){const t=this.shouldRenderAtBottom(e.height),o=this.shouldRenderAtRight(e.width);return t&&o?"BottomRight":t&&!o?"BottomLeft":!t&&o?"TopRight":"TopLeft"}}class Cn extends Sn{get availableHeightUp(){return this.anchorRect.y-this.containerRect.y}get availableHeightDown(){return this.containerRect.height-this.availableHeightUp-this.anchorRect.height}get availableWidthRight(){return this.containerRect.x+this.containerRect.width-this.anchorRect.x}get availableWidthLeft(){return this.anchorRect.x+this.anchorRect.width-this.containerRect.x}getTopCoordinate(e,t){return t?this.anchorRect.y+this.anchorRect.height:this.anchorRect.y-e}getLeftCoordinate(e,t){return t?this.anchorRect.x:this.anchorRect.x+this.anchorRect.width-e}}class En extends Sn{get availableHeightUp(){return this.anchorRect.y+this.anchorRect.height-this.containerRect.y}get availableHeightDown(){return this.containerRect.y+this.containerRect.height-this.anchorRect.y}get availableWidthRight(){return this.containerRect.width-this.anchorRect.width-this.availableWidthLeft}get availableWidthLeft(){return this.anchorRect.x-this.containerRect.x}getTopCoordinate(e,t){return t?this.anchorRect.y:this.anchorRect.y+this.anchorRect.height-e}getLeftCoordinate(e,t){return t?this.anchorRect.x+this.anchorRect.width:this.anchorRect.x-e}}Ni`
176
176
  .o-menu {
177
177
  background-color: white;
178
178
  padding: ${6}px 0px;
@@ -1159,7 +1159,7 @@
1159
1159
  pointer-events: none;
1160
1160
  }
1161
1161
  }
1162
- `;class Of extends t.Component{static template="o-spreadsheet-Composer";static components={TextValueProvider:Ef,FunctionDescriptionProvider:xf};static defaultProps={inputStyle:"",isDefaultFocus:!1};composerRef=t.useRef("o_composer");contentHelper=new wf(this.composerRef.el);composerState=t.useState({positionStart:0,positionEnd:0});autoCompleteState=t.useState({showProvider:!1,values:[],selectedIndex:0});functionDescriptionState=t.useState({showDescription:!1,functionName:"",functionDescription:{},argToFocus:0});isKeyStillDown=!1;compositionActive=!1;get assistantStyle(){if(this.props.delimitation&&this.props.rect){const{x:e,y:t,height:o}=this.props.rect;let i={};return t>this.props.delimitation.height-(t+o)&&(i.top="-3px",i.transform="translate(0, -100%)"),e+300>this.props.delimitation.width&&(i.right="0px"),i.width="300px",Li(i)}return Li({width:"300px"})}shouldProcessInputEvents=!1;tokens=[];keyMapping={ArrowUp:this.processArrowKeys,ArrowDown:this.processArrowKeys,ArrowLeft:this.processArrowKeys,ArrowRight:this.processArrowKeys,Enter:this.processEnterKey,Escape:this.processEscapeKey,F2:()=>console.warn("Not implemented"),F4:e=>this.processF4Key(e),Tab:e=>this.processTabKey(e)};setup(){t.onMounted((()=>{const e=this.composerRef.el;this.props.isDefaultFocus&&this.env.focusableElement.setFocusableElement(e),this.contentHelper.updateEl(e),this.processContent(),this.contentHelper.scrollSelectionIntoView()})),t.onPatched((()=>{this.isKeyStillDown||this.processContent(),"inactive"===this.env.model.getters.getEditionMode()&&this.processTokenAtCursor()}))}processArrowKeys(e){if(this.env.model.getters.isSelectingForComposer()||"inactive"===this.env.model.getters.getEditionMode())return this.functionDescriptionState.showDescription=!1,e.preventDefault(),e.stopPropagation(),void Um(e,this.env.model.selection);const t=this.env.model.getters.getCurrentContent();"cellFocus"!==this.props.focus||this.autoCompleteState.showProvider||t.startsWith("=")?(e.stopPropagation(),this.handleArrowKeysForAutocomplete(e)):this.env.model.dispatch("STOP_EDITION")}handleArrowKeysForAutocomplete(e){["ArrowUp","ArrowDown"].includes(e.key)&&this.autoCompleteState.showProvider&&(e.preventDefault(),"ArrowUp"===e.key?(this.autoCompleteState.selectedIndex--,this.autoCompleteState.selectedIndex<0&&(this.autoCompleteState.selectedIndex=this.autoCompleteState.values.length-1)):this.autoCompleteState.selectedIndex=(this.autoCompleteState.selectedIndex+1)%this.autoCompleteState.values.length),this.updateCursorIfNeeded()}processTabKey(e){if(e.preventDefault(),e.stopPropagation(),"inactive"!==this.env.model.getters.getEditionMode()){if(this.autoCompleteState.showProvider){const e=this.autoCompleteState.values[this.autoCompleteState.selectedIndex]?.text;if(e)return void this.autoComplete(e)}else this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");this.env.model.dispatch("STOP_EDITION")}const t=e.shiftKey?"left":"right";this.env.model.selection.moveAnchorCell(t,1)}processEnterKey(e){if(e.preventDefault(),e.stopPropagation(),e.altKey||e.ctrlKey){const e=this.contentHelper.getCurrentSelection(),t=this.env.model.getters.getCurrentContent(),o=t.slice(0,e.start)+me+t.slice(e.end);return this.env.model.dispatch("SET_CURRENT_CONTENT",{content:o,selection:{start:e.start+1,end:e.start+1}}),this.processContent(),void this.contentHelper.scrollSelectionIntoView()}if(this.isKeyStillDown=!1,this.autoCompleteState.showProvider){const e=this.autoCompleteState.values[this.autoCompleteState.selectedIndex]?.text;if(e)return void this.autoComplete(e)}this.env.model.dispatch("STOP_EDITION");const t=e.shiftKey?"up":"down";this.env.model.selection.moveAnchorCell(t,1)}processEscapeKey(){this.env.model.dispatch("STOP_EDITION",{cancel:!0})}processF4Key(e){this.env.model.dispatch("CYCLE_EDITION_REFERENCES"),this.processContent(),e.stopPropagation()}onCompositionStart(){this.compositionActive=!0}onCompositionEnd(){this.compositionActive=!1}onKeydown(e){if("inactive"===this.env.model.getters.getEditionMode())return;let t=this.keyMapping[e.key];t?t.call(this,e):(e.stopPropagation(),this.updateCursorIfNeeded())}updateCursorIfNeeded(){if(!(this.env.model.getters.isSelectingForComposer()||"inactive"===this.env.model.getters.getEditionMode())){const{start:e,end:t}=this.contentHelper.getCurrentSelection();this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:e,end:t}),this.isKeyStillDown=!0}}onPaste(e){"inactive"!==this.env.model.getters.getEditionMode()&&e.stopPropagation()}onInput(e){if(!this.shouldProcessInputEvents)return;if("insertFromPaste"===e.inputType&&"inactive"===this.env.model.getters.getEditionMode())return;let t;if(e.stopPropagation(),t="inactive"===this.env.model.getters.getEditionMode()?e.data||"":this.contentHelper.getText(),"inactive"===this.props.focus)return this.props.onComposerCellFocused?.(t);this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION"),this.env.model.dispatch("SET_CURRENT_CONTENT",{content:t,selection:this.contentHelper.getCurrentSelection()})}onKeyup(e){if(this.isKeyStillDown=!1,"inactive"===this.props.focus||["Control","Alt","Shift","Tab","Enter","F4"].includes(e.key))return;if(this.autoCompleteState.showProvider&&["ArrowUp","ArrowDown"].includes(e.key))return;if(this.env.model.getters.isSelectingForComposer()&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(e.key))return;if(e.preventDefault(),e.stopPropagation(),this.autoCompleteState.showProvider=!1,e.ctrlKey&&" "===e.key)return this.showAutocomplete(""),void this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");const{start:t,end:o}=this.env.model.getters.getComposerSelection(),{start:i,end:s}=this.contentHelper.getCurrentSelection();i===t&&s===o||this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",this.contentHelper.getCurrentSelection()),this.processTokenAtCursor(),this.processContent()}showAutocomplete(e){this.autoCompleteState.showProvider=!0;let t=Object.entries(Hg.content).filter((([e,{hidden:t}])=>!t)).map((([e,{description:t}])=>({text:e,description:t})));t=e?"true"===e.toLowerCase()||"false"===e.toLowerCase()?[]:Jo(e,t,(e=>e.text)):t.sort(((e,t)=>e.text.localeCompare(t.text))),this.autoCompleteState.values=t.slice(0,10),this.autoCompleteState.selectedIndex=0}onMousedown(e){e.button>0||this.contentHelper.removeSelection()}onClick(){if(this.env.model.getters.isReadonly())return;const e=this.contentHelper.getCurrentSelection();this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION"),this.props.onComposerContentFocused(),this.props.focus,this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",e),this.processTokenAtCursor()}onBlur(){this.isKeyStillDown=!1}onContextMenu(e){"inactive"===this.env.model.getters.getEditionMode()&&this.props.onInputContextMenu?.(e)}processContent(){if(this.compositionActive)return;const e=this.composerRef.el?.scrollTop||0;this.contentHelper.removeAll(),this.shouldProcessInputEvents=!1,"inactive"!==this.props.focus&&(this.contentHelper.el.focus(),this.contentHelper.selectRange(0,0));const t=this.getContentLines();if(0!==t.length&&0!==t.length[0]){this.contentHelper.setText(t);const{start:o,end:i}=this.env.model.getters.getComposerSelection();"inactive"!==this.props.focus&&this.contentHelper.selectRange(o,i),function(e,t){e&&(e.scrollTop=t)}(this.composerRef.el,e)}this.shouldProcessInputEvents=!0}getContentLines(){let e=this.env.model.getters.getCurrentContent();const t=e.startsWith("=")&&this.env.model.getters.getCurrentTokens().length>0;return""===e?[]:t&&"inactive"!==this.props.focus?this.splitHtmlContentIntoLines(this.getColoredTokens()):this.splitHtmlContentIntoLines([{value:e}])}getColoredTokens(){const e=this.env.model.getters.getCurrentTokens(),t=this.env.model.getters.getTokenAtCursor(),o=[],{end:i,start:s}=this.env.model.getters.getComposerSelection();for(const n of e){switch(n.type){case"OPERATOR":case"NUMBER":case"FUNCTION":case"COMMA":case"STRING":o.push({value:n.value,color:Af[n.type]||"#000"});break;case"REFERENCE":const{xc:e,sheetName:i}=Yo(n.value);o.push({value:n.value,color:this.rangeColor(e,i)||"#000"});break;case"SYMBOL":let s=n.value;["TRUE","FALSE"].includes(s.toUpperCase())?o.push({value:n.value,color:Af.NUMBER}):o.push({value:n.value,color:"#000"});break;case"LEFT_PAREN":case"RIGHT_PAREN":t&&["LEFT_PAREN","RIGHT_PAREN"].includes(t.type)&&t.parenIndex&&t.parenIndex===n.parenIndex?o.push({value:n.value,color:Af.MATCHING_PAREN}):o.push({value:n.value,color:Af[n.type]||"#000"});break;default:o.push({value:n.value,color:"#000"})}this.env.model.getters.showSelectionIndicator()&&i===s&&i===n.end&&(o[o.length-1].class=If)}return o}splitHtmlContentIntoLines(e){const t=[];let o=[];for(const i of e)if(i.value.includes(me)){const e=i.value.split(me),s=e.pop();for(const s of e)o.push({color:i.color,value:s}),t.push(o),o=[];o.push({...i,value:s})}else o.push(i);o.length&&t.push(o);const i=[];for(const e of t)e.every(this.isContentEmpty)?i.push([e[0]]):i.push(e.filter((e=>!this.isContentEmpty(e))));return i}isContentEmpty(e){return!(e.value||e.class)}rangeColor(e,t){if("inactive"===this.props.focus)return;const o=this.env.model.getters.getHighlights(),i=t?this.env.model.getters.getSheetIdByName(t):this.env.model.getters.getCurrentEditedCell()?.sheetId,s=o.find((t=>{if(t.sheetId!==i)return!1;let o=this.env.model.getters.getRangeFromSheetXC(i,e).zone;return o=1===Ri(o)?this.env.model.getters.expandZone(i,o):o,ui(o,t.zone)}));return s&&s.color?s.color:void 0}processTokenAtCursor(){let e=this.env.model.getters.getCurrentContent();if(this.autoCompleteState.showProvider=!1,this.functionDescriptionState.showDescription=!1,e.startsWith("=")){const e=this.env.model.getters.getTokenAtCursor();if(e){const{xc:t}=Yo(e.value);if("FUNCTION"===e.type||"SYMBOL"===e.type&&!$o.test(t))this.showAutocomplete(e.value);else if(e.functionContext&&"UNKNOWN"!==e.type){const t=e.functionContext,o=t.parent.toUpperCase(),i=yf[o],s=t.argPosition;this.functionDescriptionState.functionName=o,this.functionDescriptionState.functionDescription=i,this.functionDescriptionState.argToFocus=i.getArgToFocus(s+1)-1,this.functionDescriptionState.showDescription=!0}}}}autoComplete(e){if(e){const t=this.env.model.getters.getTokenAtCursor();if(t){let o=t.end,i=t.end;["SYMBOL","FUNCTION"].includes(t.type)&&(o=t.start);const s=this.env.model.getters.getCurrentTokens();if(s.length){e+="(";const o=s.map((e=>e.start)).indexOf(t.start);if(o+1<s.length){"LEFT_PAREN"===s[o+1].type&&i++}}this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:o,end:i})}this.env.model.dispatch("REPLACE_COMPOSER_CURSOR_SELECTION",{text:e})}this.processTokenAtCursor()}}Of.props={inputStyle:{type:String,optional:!0},rect:{type:Object,optional:!0},delimitation:{type:Object,optional:!0},focus:{validate:e=>["inactive","cellFocus","contentFocus"].includes(e)},onComposerCellFocused:{type:Function,optional:!0},onComposerContentFocused:Function,isDefaultFocus:{type:Boolean,optional:!0},onInputContextMenu:{type:Function,optional:!0}};const Mf=3*.4*window.devicePixelRatio||1;Ni`
1162
+ `;class Of extends t.Component{static template="o-spreadsheet-Composer";static components={TextValueProvider:Ef,FunctionDescriptionProvider:xf};static defaultProps={inputStyle:"",isDefaultFocus:!1};composerRef=t.useRef("o_composer");contentHelper=new wf(this.composerRef.el);composerState=t.useState({positionStart:0,positionEnd:0});autoCompleteState=t.useState({showProvider:!1,values:[],selectedIndex:0});functionDescriptionState=t.useState({showDescription:!1,functionName:"",functionDescription:{},argToFocus:0});isKeyStillDown=!1;compositionActive=!1;get assistantStyle(){if(this.props.delimitation&&this.props.rect){const{x:e,y:t,height:o}=this.props.rect;let i={};return t>this.props.delimitation.height-(t+o)&&(i.top="-3px",i.transform="translate(0, -100%)"),e+300>this.props.delimitation.width&&(i.right="0px"),i.width="300px",Li(i)}return Li({width:"300px"})}shouldProcessInputEvents=!1;tokens=[];keyMapping={ArrowUp:this.processArrowKeys,ArrowDown:this.processArrowKeys,ArrowLeft:this.processArrowKeys,ArrowRight:this.processArrowKeys,Enter:this.processEnterKey,Escape:this.processEscapeKey,F2:()=>console.warn("Not implemented"),F4:e=>this.processF4Key(e),Tab:e=>this.processTabKey(e)};setup(){t.onMounted((()=>{const e=this.composerRef.el;this.props.isDefaultFocus&&this.env.focusableElement.setFocusableElement(e),this.contentHelper.updateEl(e),this.processContent(),this.contentHelper.scrollSelectionIntoView()})),t.onPatched((()=>{this.isKeyStillDown||this.processContent(),"inactive"===this.env.model.getters.getEditionMode()&&this.processTokenAtCursor()}))}processArrowKeys(e){if(this.env.model.getters.isSelectingForComposer()||"inactive"===this.env.model.getters.getEditionMode())return this.functionDescriptionState.showDescription=!1,e.preventDefault(),e.stopPropagation(),void Um(e,this.env.model.selection);const t=this.env.model.getters.getCurrentContent();"cellFocus"!==this.props.focus||this.autoCompleteState.showProvider||t.startsWith("=")?(e.stopPropagation(),this.handleArrowKeysForAutocomplete(e)):this.env.model.dispatch("STOP_EDITION")}handleArrowKeysForAutocomplete(e){["ArrowUp","ArrowDown"].includes(e.key)&&this.autoCompleteState.showProvider&&(e.preventDefault(),"ArrowUp"===e.key?(this.autoCompleteState.selectedIndex--,this.autoCompleteState.selectedIndex<0&&(this.autoCompleteState.selectedIndex=this.autoCompleteState.values.length-1)):this.autoCompleteState.selectedIndex=(this.autoCompleteState.selectedIndex+1)%this.autoCompleteState.values.length),this.updateCursorIfNeeded()}processTabKey(e){if(e.preventDefault(),e.stopPropagation(),"inactive"!==this.env.model.getters.getEditionMode()){if(this.autoCompleteState.showProvider){const e=this.autoCompleteState.values[this.autoCompleteState.selectedIndex]?.text;if(e)return void this.autoComplete(e)}else this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");this.env.model.dispatch("STOP_EDITION")}const t=e.shiftKey?"left":"right";this.env.model.selection.moveAnchorCell(t,1)}processEnterKey(e){if(e.preventDefault(),e.stopPropagation(),e.altKey||e.ctrlKey){const e=this.contentHelper.getCurrentSelection(),t=this.env.model.getters.getCurrentContent(),o=t.slice(0,e.start)+me+t.slice(e.end);return this.env.model.dispatch("SET_CURRENT_CONTENT",{content:o,selection:{start:e.start+1,end:e.start+1}}),this.processContent(),void this.contentHelper.scrollSelectionIntoView()}if(this.isKeyStillDown=!1,this.autoCompleteState.showProvider){const e=this.autoCompleteState.values[this.autoCompleteState.selectedIndex]?.text;if(e)return void this.autoComplete(e)}this.env.model.dispatch("STOP_EDITION");const t=e.shiftKey?"up":"down";this.env.model.selection.moveAnchorCell(t,1)}processEscapeKey(){this.env.model.dispatch("STOP_EDITION",{cancel:!0})}processF4Key(e){this.env.model.dispatch("CYCLE_EDITION_REFERENCES"),this.processContent(),e.stopPropagation()}onCompositionStart(){this.compositionActive=!0}onCompositionEnd(){this.compositionActive=!1}onKeydown(e){if("inactive"===this.env.model.getters.getEditionMode())return;let t=this.keyMapping[e.key];t?t.call(this,e):(e.stopPropagation(),this.updateCursorIfNeeded())}updateCursorIfNeeded(){if(!(this.env.model.getters.isSelectingForComposer()||"inactive"===this.env.model.getters.getEditionMode())){const{start:e,end:t}=this.contentHelper.getCurrentSelection();this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:e,end:t}),this.isKeyStillDown=!0}}onPaste(e){"inactive"!==this.env.model.getters.getEditionMode()?e.stopPropagation():e.preventDefault()}onInput(e){if(!this.shouldProcessInputEvents)return;let t;if(e.stopPropagation(),t="inactive"===this.env.model.getters.getEditionMode()?e.data||"":this.contentHelper.getText(),"inactive"===this.props.focus)return this.props.onComposerCellFocused?.(t);this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION"),this.env.model.dispatch("SET_CURRENT_CONTENT",{content:t,selection:this.contentHelper.getCurrentSelection()})}onKeyup(e){if(this.isKeyStillDown=!1,"inactive"===this.props.focus||["Control","Alt","Shift","Tab","Enter","F4"].includes(e.key))return;if(this.autoCompleteState.showProvider&&["ArrowUp","ArrowDown"].includes(e.key))return;if(this.env.model.getters.isSelectingForComposer()&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(e.key))return;if(e.preventDefault(),e.stopPropagation(),this.autoCompleteState.showProvider=!1,e.ctrlKey&&" "===e.key)return this.showAutocomplete(""),void this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");const{start:t,end:o}=this.env.model.getters.getComposerSelection(),{start:i,end:s}=this.contentHelper.getCurrentSelection();i===t&&s===o||this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",this.contentHelper.getCurrentSelection()),this.processTokenAtCursor(),this.processContent()}showAutocomplete(e){this.autoCompleteState.showProvider=!0;let t=Object.entries(Hg.content).filter((([e,{hidden:t}])=>!t)).map((([e,{description:t}])=>({text:e,description:t})));t=e?"true"===e.toLowerCase()||"false"===e.toLowerCase()?[]:Jo(e,t,(e=>e.text)):t.sort(((e,t)=>e.text.localeCompare(t.text))),this.autoCompleteState.values=t.slice(0,10),this.autoCompleteState.selectedIndex=0}onMousedown(e){e.button>0||this.contentHelper.removeSelection()}onClick(){if(this.env.model.getters.isReadonly())return;const e=this.contentHelper.getCurrentSelection();this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION"),this.props.onComposerContentFocused(),this.props.focus,this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",e),this.processTokenAtCursor()}onBlur(){this.isKeyStillDown=!1}onContextMenu(e){"inactive"===this.env.model.getters.getEditionMode()&&this.props.onInputContextMenu?.(e)}processContent(){if(this.compositionActive)return;const e=this.composerRef.el?.scrollTop||0;this.contentHelper.removeAll(),this.shouldProcessInputEvents=!1,"inactive"!==this.props.focus&&(this.contentHelper.el.focus(),this.contentHelper.selectRange(0,0));const t=this.getContentLines();if(0!==t.length&&0!==t.length[0]){this.contentHelper.setText(t);const{start:o,end:i}=this.env.model.getters.getComposerSelection();"inactive"!==this.props.focus&&this.contentHelper.selectRange(o,i),function(e,t){e&&(e.scrollTop=t)}(this.composerRef.el,e)}this.shouldProcessInputEvents=!0}getContentLines(){let e=this.env.model.getters.getCurrentContent();const t=e.startsWith("=")&&this.env.model.getters.getCurrentTokens().length>0;return""===e?[]:t&&"inactive"!==this.props.focus?this.splitHtmlContentIntoLines(this.getColoredTokens()):this.splitHtmlContentIntoLines([{value:e}])}getColoredTokens(){const e=this.env.model.getters.getCurrentTokens(),t=this.env.model.getters.getTokenAtCursor(),o=[],{end:i,start:s}=this.env.model.getters.getComposerSelection();for(const n of e){switch(n.type){case"OPERATOR":case"NUMBER":case"FUNCTION":case"COMMA":case"STRING":o.push({value:n.value,color:Af[n.type]||"#000"});break;case"REFERENCE":const{xc:e,sheetName:i}=Yo(n.value);o.push({value:n.value,color:this.rangeColor(e,i)||"#000"});break;case"SYMBOL":let s=n.value;["TRUE","FALSE"].includes(s.toUpperCase())?o.push({value:n.value,color:Af.NUMBER}):o.push({value:n.value,color:"#000"});break;case"LEFT_PAREN":case"RIGHT_PAREN":t&&["LEFT_PAREN","RIGHT_PAREN"].includes(t.type)&&t.parenIndex&&t.parenIndex===n.parenIndex?o.push({value:n.value,color:Af.MATCHING_PAREN}):o.push({value:n.value,color:Af[n.type]||"#000"});break;default:o.push({value:n.value,color:"#000"})}this.env.model.getters.showSelectionIndicator()&&i===s&&i===n.end&&(o[o.length-1].class=If)}return o}splitHtmlContentIntoLines(e){const t=[];let o=[];for(const i of e)if(i.value.includes(me)){const e=i.value.split(me),s=e.pop();for(const s of e)o.push({color:i.color,value:s}),t.push(o),o=[];o.push({...i,value:s})}else o.push(i);o.length&&t.push(o);const i=[];for(const e of t)e.every(this.isContentEmpty)?i.push([e[0]]):i.push(e.filter((e=>!this.isContentEmpty(e))));return i}isContentEmpty(e){return!(e.value||e.class)}rangeColor(e,t){if("inactive"===this.props.focus)return;const o=this.env.model.getters.getHighlights(),i=t?this.env.model.getters.getSheetIdByName(t):this.env.model.getters.getCurrentEditedCell()?.sheetId,s=o.find((t=>{if(t.sheetId!==i)return!1;let o=this.env.model.getters.getRangeFromSheetXC(i,e).zone;return o=1===Ri(o)?this.env.model.getters.expandZone(i,o):o,ui(o,t.zone)}));return s&&s.color?s.color:void 0}processTokenAtCursor(){let e=this.env.model.getters.getCurrentContent();if(this.autoCompleteState.showProvider=!1,this.functionDescriptionState.showDescription=!1,e.startsWith("=")){const e=this.env.model.getters.getTokenAtCursor();if(e){const{xc:t}=Yo(e.value);if("FUNCTION"===e.type||"SYMBOL"===e.type&&!$o.test(t))this.showAutocomplete(e.value);else if(e.functionContext&&"UNKNOWN"!==e.type){const t=e.functionContext,o=t.parent.toUpperCase(),i=yf[o],s=t.argPosition;this.functionDescriptionState.functionName=o,this.functionDescriptionState.functionDescription=i,this.functionDescriptionState.argToFocus=i.getArgToFocus(s+1)-1,this.functionDescriptionState.showDescription=!0}}}}autoComplete(e){if(e){const t=this.env.model.getters.getTokenAtCursor();if(t){let o=t.end,i=t.end;["SYMBOL","FUNCTION"].includes(t.type)&&(o=t.start);const s=this.env.model.getters.getCurrentTokens();if(s.length){e+="(";const o=s.map((e=>e.start)).indexOf(t.start);if(o+1<s.length){"LEFT_PAREN"===s[o+1].type&&i++}}this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:o,end:i})}this.env.model.dispatch("REPLACE_COMPOSER_CURSOR_SELECTION",{text:e})}this.processTokenAtCursor()}}Of.props={inputStyle:{type:String,optional:!0},rect:{type:Object,optional:!0},delimitation:{type:Object,optional:!0},focus:{validate:e=>["inactive","cellFocus","contentFocus"].includes(e)},onComposerCellFocused:{type:Function,optional:!0},onComposerContentFocused:Function,isDefaultFocus:{type:Boolean,optional:!0},onInputContextMenu:{type:Function,optional:!0}};const Mf=3*.4*window.devicePixelRatio||1;Ni`
1163
1163
  div.o-grid-composer {
1164
1164
  z-index: ${ue.GridComposer};
1165
1165
  box-sizing: border-box;
@@ -1180,7 +1180,7 @@
1180
1180
  padding: 6px 7px;
1181
1181
  border-radius: 4px;
1182
1182
  }
1183
- `;class Nf extends t.Component{static template="o-spreadsheet-GridComposer";static components={Composer:Of};rect=this.defaultRect;isEditing=!1;isCellReferenceVisible;get defaultRect(){return{x:0,y:0,width:0,height:0}}setup(){t.onWillUpdateProps((()=>{this.updateComponentPosition(),this.updateCellReferenceVisibility()}))}get shouldDisplayCellReference(){return this.isCellReferenceVisible}get cellReference(){if(!this.env.model.getters.getCurrentEditedCell())return"";const{col:e,row:t,sheetId:o}=this.env.model.getters.getCurrentEditedCell();return`${o!==this.env.model.getters.getActiveSheetId()?$e(this.env.model.getters.getSheetName(o))+"!":""}${Zt(e,t)}`}get cellReferenceStyle(){const{x:e,y:t}=this.rect;return Li({left:e-Mf+"px",top:t-28+"px"})}get composerProps(){const{width:e,height:t}=this.env.model.getters.getSheetViewDimensionWithHeaders();return{rect:{...this.rect},delimitation:{width:e,height:t},focus:this.props.focus,isDefaultFocus:!0,onComposerContentFocused:this.props.onComposerContentFocused,onComposerCellFocused:this.props.onComposerCellFocused,onInputContextMenu:this.props.onInputContextMenu}}get containerStyle(){if("inactive"===this.env.model.getters.getEditionMode()||!this.rect)return"\n position: absolute;\n z-index: -1000;\n ";const e=this.env.model.getters.getCurrentContent().startsWith("="),t=this.env.model.getters.getActiveCell(),o=this.env.model.getters.getActivePosition(),i=this.env.model.getters.getCellComputedStyle(o),{x:s,y:n,width:r,height:a}=this.rect,l=!e&&i.fillColor||"#ffffff",c=!e&&i.textColor||"#000000",h=!e&&i.fontSize||10,d=!e&&i.bold?"bold":void 0,u=!e&&i.italic?"italic":"normal",g=e?"none":_i(i);let p="left";e||(p=i.align||t.defaultAlign);const m=this.props.gridDims.height-this.rect.y;return Li({left:s-1+"px",top:`${n}px`,"min-width":`${r+1}px`,"min-height":`${a+1}px`,"max-width":`${this.props.gridDims.width-this.rect.x}px`,"max-height":`${m}px`,background:l,color:c,"font-size":`${je(h)}px`,"font-weight":d,"font-style":u,"text-decoration":g,"text-align":p})}updateComponentPosition(){const e="inactive"!==this.env.model.getters.getEditionMode();if(this.isEditing!==e){if(this.isEditing=e,!e)return this.rect=this.defaultRect,void this.env.focusableElement.focus();const t=this.env.model.getters.getActivePosition(),o=this.env.model.getters.expandZone(t.sheetId,yi(t));this.rect=this.env.model.getters.getVisibleRect(o)}}updateCellReferenceVisibility(){if("inactive"===this.env.model.getters.getEditionMode())return void(this.isCellReferenceVisible=!1);if(this.isCellReferenceVisible)return;const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSelectedZone();vt(this.env.model.getters.getVisibleRect(t),this.rect)&&e===this.env.model.getters.getCurrentEditedCell().sheetId||(this.isCellReferenceVisible=!0)}}Nf.props={focus:{validate:e=>["inactive","cellFocus","contentFocus"].includes(e)},onComposerContentFocused:Function,gridDims:Object,onComposerCellFocused:Function,onInputContextMenu:Function};const _f=Ni`
1183
+ `;class Nf extends t.Component{static template="o-spreadsheet-GridComposer";static components={Composer:Of};rect=this.defaultRect;isEditing=!1;isCellReferenceVisible;get defaultRect(){return{x:0,y:0,width:0,height:0}}setup(){t.onWillUpdateProps((()=>{this.updateComponentPosition(),this.updateCellReferenceVisibility()}))}get shouldDisplayCellReference(){return this.isCellReferenceVisible}get cellReference(){if(!this.env.model.getters.getCurrentEditedCell())return"";const{col:e,row:t,sheetId:o}=this.env.model.getters.getCurrentEditedCell();return`${o!==this.env.model.getters.getActiveSheetId()?$e(this.env.model.getters.getSheetName(o))+"!":""}${Zt(e,t)}`}get cellReferenceStyle(){const{x:e,y:t}=this.rect;return Li({left:e-Mf+"px",top:t-28+"px"})}get composerProps(){const{width:e,height:t}=this.env.model.getters.getSheetViewDimensionWithHeaders();return{rect:{...this.rect},delimitation:{width:e,height:t},focus:this.props.focus,isDefaultFocus:!0,onComposerContentFocused:this.props.onComposerContentFocused,onComposerCellFocused:this.props.onComposerCellFocused,onInputContextMenu:this.props.onInputContextMenu}}get containerStyle(){if("inactive"===this.env.model.getters.getEditionMode()||!this.rect)return"z-index: -1000;";const e=this.env.model.getters.getCurrentContent().startsWith("="),t=this.env.model.getters.getActiveCell(),o=this.env.model.getters.getActivePosition(),i=this.env.model.getters.getCellComputedStyle(o),{x:s,y:n,width:r,height:a}=this.rect,l=!e&&i.fillColor||"#ffffff",c=!e&&i.textColor||"#000000",h=!e&&i.fontSize||10,d=!e&&i.bold?"bold":void 0,u=!e&&i.italic?"italic":"normal",g=e?"none":_i(i);let p="left";e||(p=i.align||t.defaultAlign);const m=this.props.gridDims.height-this.rect.y;return Li({left:s-1+"px",top:`${n}px`,"min-width":`${r+1}px`,"min-height":`${a+1}px`,"max-width":`${this.props.gridDims.width-this.rect.x}px`,"max-height":`${m}px`,background:l,color:c,"font-size":`${je(h)}px`,"font-weight":d,"font-style":u,"text-decoration":g,"text-align":p})}updateComponentPosition(){const e="inactive"!==this.env.model.getters.getEditionMode();if(this.isEditing!==e){if(this.isEditing=e,!e)return this.rect=this.defaultRect,void this.env.focusableElement.focus();const t=this.env.model.getters.getActivePosition(),o=this.env.model.getters.expandZone(t.sheetId,yi(t));this.rect=this.env.model.getters.getVisibleRect(o)}}updateCellReferenceVisibility(){if("inactive"===this.env.model.getters.getEditionMode())return void(this.isCellReferenceVisible=!1);if(this.isCellReferenceVisible)return;const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSelectedZone();vt(this.env.model.getters.getVisibleRect(t),this.rect)&&e===this.env.model.getters.getCurrentEditedCell().sheetId||(this.isCellReferenceVisible=!0)}}Nf.props={focus:{validate:e=>["inactive","cellFocus","contentFocus"].includes(e)},onComposerContentFocused:Function,gridDims:Object,onComposerCellFocused:Function,onInputContextMenu:Function};const _f=Ni`
1184
1184
  .o-filter-icon {
1185
1185
  color: ${T};
1186
1186
  position: absolute;
@@ -1207,7 +1207,7 @@
1207
1207
  height: 0px;
1208
1208
  }
1209
1209
  }
1210
- `;class Gf extends t.Component{static template="o-spreadsheet-FiguresContainer";static components={FigureComponent:mf};dnd=t.useState({draggedFigure:void 0,horizontalSnap:void 0,verticalSnap:void 0});setup(){t.onMounted((()=>{this.render()}))}getVisibleFigures(){const e=this.env.model.getters.getVisibleFigures();return this.dnd.draggedFigure&&!e.some((e=>e.id===this.dnd.draggedFigure?.id))&&e.push(this.env.model.getters.getFigure(this.env.model.getters.getActiveSheetId(),this.dnd.draggedFigure?.id)),e}get containers(){const e=this.getVisibleFigures(),t=[];for(const o of["topLeft","topRight","bottomLeft","bottomRight"]){const i=e.filter((e=>this.getFigureContainer(e)===o));i.length>0&&t.push({type:o,figures:i,style:this.getContainerStyle(o),inverseViewportStyle:this.getInverseViewportPositionStyle(o)})}return this.dnd.draggedFigure&&t.push({type:"dnd",figures:[this.getDndFigure()],style:this.getContainerStyle("dnd"),inverseViewportStyle:this.getInverseViewportPositionStyle("dnd")}),t}getContainerStyle(e){return this.rectToCss(this.getContainerRect(e))}rectToCss(e){return Li({left:`${e.x}px`,top:`${e.y}px`,width:`${e.width}px`,height:`${e.height}px`})}getContainerRect(e){const{width:t,height:o}=this.env.model.getters.getMainViewportRect(),{x:i,y:s}=this.env.model.getters.getMainViewportCoordinates(),n=["bottomRight","topRight"].includes(e)?i:0,r=t-n,a=["bottomRight","bottomLeft"].includes(e)?s:0;return{x:n,y:a,width:r,height:o-a}}getInverseViewportPositionStyle(e){const{scrollX:t,scrollY:o}=this.env.model.getters.getActiveSheetScrollInfo(),{x:i,y:s}=this.env.model.getters.getMainViewportCoordinates();return Li({left:`${["bottomRight","topRight"].includes(e)?-(i+t):0}px`,top:`${["bottomRight","bottomLeft"].includes(e)?-(s+o):0}px`})}getFigureContainer(e){const{x:t,y:o}=this.env.model.getters.getMainViewportCoordinates();return e.id===this.dnd.draggedFigure?.id?"dnd":e.x<t&&e.y<o?"topLeft":e.x<t?"bottomLeft":e.y<o?"topRight":"bottomRight"}startDraggingFigure(e,t){if(t.button>0||this.env.model.getters.isReadonly())return;if(!this.env.model.dispatch("SELECT_FIGURE",{id:e.id}).isSuccessful)return;const o=this.env.model.getters.getActiveSheetId(),i={x:t.clientX,y:t.clientY},s={maxX:this.env.model.getters.getColDimensions(o,this.env.model.getters.getNumberCols(o)-1).end,maxY:this.env.model.getters.getRowDimensions(o,this.env.model.getters.getNumberRows(o)-1).end},{x:n,y:r}=kf(this.env.model.getters,e),a={...e,x:n,y:r};ff((t=>{const o=this.env.model.getters,n=function({x:e,y:t},{x:o,y:i},s,{x:n,y:r},{maxX:a,maxY:l},{scrollX:c,scrollY:h}){const d=n?0:-c,u=r?0:-h,g=e-o,p=zf(s.x+g,d,a-s.width-c),m=t-i,f=zf(s.y+m,u,l-s.height-h);return{...s,x:p,y:f}}({x:t.clientX,y:t.clientY},i,a,this.env.model.getters.getMainViewportCoordinates(),s,o.getActiveSheetScrollInfo()),r=this.getOtherFigures(e.id),l=function(e,t,o){const i={...t},s=$f(e,i,["hCenter","right","left"],o,["hCenter","right","left"]),n=$f(e,i,["vCenter","bottom","top"],o,["vCenter","bottom","top"]),{y:r,x:a}=e.getMainViewportCoordinates(),{scrollY:l,scrollX:c}=e.getActiveSheetScrollInfo();if(n){i.y-=n.snapOffset;const e=t.y<r,o=i.y<r;e&&!o?i.y+=l:!e&&o&&(i.y-=l)}if(s){i.x-=s.snapOffset;const e=t.x<a,o=i.x<a;e&&!o?i.x+=c:!e&&o&&(i.x-=c)}return{snappedFigure:i,verticalSnapLine:s,horizontalSnapLine:n}}(o,Pf(o,n),r);this.dnd.draggedFigure=kf(o,l.snappedFigure),this.dnd.horizontalSnap=this.getSnap(l.horizontalSnapLine),this.dnd.verticalSnap=this.getSnap(l.verticalSnapLine)}),(t=>{if(!this.dnd.draggedFigure)return;let{x:i,y:s}=Pf(this.env.model.getters,this.dnd.draggedFigure);this.dnd.draggedFigure=void 0,this.dnd.horizontalSnap=void 0,this.dnd.verticalSnap=void 0,this.env.model.dispatch("UPDATE_FIGURE",{sheetId:o,id:e.id,x:i,y:s})}))}startResize(e,t,o,i){i.stopPropagation();const s={x:i.clientX,y:i.clientY},{x:n,y:r}=kf(this.env.model.getters,e),a={...e,x:n,y:r},l=Yr.get(e.tag).keepRatio||!1,c=Yr.get(e.tag).minFigSize||80;ff((i=>{const n={x:i.clientX,y:i.clientY},r=function(e,t,o,{x:i,y:s},{x:n,y:r},a,l,{scrollX:c,scrollY:h}){let{x:d,y:u,width:g,height:p}=e;if(a&&0!=t&&0!=o){const a=Math.min(t*(n-i),e.width-l),c=Math.min(o*(r-s),e.height-l),h=Math.min(a/e.width,c/e.height);g=e.width*(1-h),p=e.height*(1-h),t<0&&(d=e.x+e.width*h),o<0&&(u=e.y+e.height*h)}else{const a=Math.max(t*(i-n),l-e.width),c=Math.max(o*(s-r),l-e.height);g=e.width+a,p=e.height+c,t<0&&(d=e.x-a),o<0&&(u=e.y-c)}return d+c<=0&&(g=g+d+c,d=-c),u+h<=0&&(p=p+u+h,u=-h),{...e,x:d,y:u,width:g,height:p}}(a,t,o,n,s,l,c,this.env.model.getters.getActiveSheetScrollInfo()),h=this.getOtherFigures(e.id),d=function(e,t,o,i,s){const n={...i},r=$f(e,n,[-1===t?"left":"right"],s,["right","left"]);r&&(1===t?n.width-=r.snapOffset:-1===t&&(n.x-=r.snapOffset,n.width+=r.snapOffset));const a=$f(e,n,[-1===o?"top":"bottom"],s,["bottom","top"]);return a&&(1===o?n.height-=a.snapOffset:-1===o&&(n.y-=a.snapOffset,n.height+=a.snapOffset)),n.x=Math.round(n.x),n.y=Math.round(n.y),n.height=Math.round(n.height),n.width=Math.round(n.width),{snappedFigure:n,verticalSnapLine:r,horizontalSnapLine:a}}(this.env.model.getters,t,o,r,h);this.dnd.draggedFigure=d.snappedFigure,this.dnd.horizontalSnap=this.getSnap(d.horizontalSnapLine),this.dnd.verticalSnap=this.getSnap(d.verticalSnapLine)}),(i=>{if(!this.dnd.draggedFigure)return;let{x:s,y:n}=Pf(this.env.model.getters,this.dnd.draggedFigure);const r={x:s,y:n};t&&(r.width=this.dnd.draggedFigure.width),o&&(r.height=this.dnd.draggedFigure.height),this.env.model.dispatch("UPDATE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:e.id,...r}),this.dnd.draggedFigure=void 0,this.dnd.horizontalSnap=void 0,this.dnd.verticalSnap=void 0}))}getOtherFigures(e){return this.getVisibleFigures().filter((t=>t.id!==e))}getDndFigure(){const e=this.getVisibleFigures().find((e=>e.id===this.dnd.draggedFigure?.id));if(!e)throw new Error("Dnd figure not found");return{...e,...this.dnd.draggedFigure}}getFigureStyle(e){return e.id!==this.dnd.draggedFigure?.id?"":Li({opacity:"0.9",cursor:"grabbing"})}getSnap(e){if(!e||!this.dnd.draggedFigure)return;const t=e.matchedFigIds.map((e=>this.getVisibleFigures().find((t=>t.id===e)))).filter(dt).map((e=>{const t=kf(this.env.model.getters,e),o=this.getFigureContainer(e);return mn(t,this.getContainerRect(o))})).filter(dt),o=function(...e){return bn(hi(...e.map(fn)))}(this.dnd.draggedFigure,...t);return{line:e,containerStyle:this.rectToCss(o),lineStyle:this.getSnapLineStyle(e,o)}}getSnapLineStyle(e,t){return e?["top","vCenter","bottom"].includes(e.snappedAxisType)?Li({top:e.position-t.y+"px",left:"0px",width:"100%"}):Li({top:"0px",left:e.position-t.x+"px",height:"100%"}):""}}function qf(e,o,i){let s={col:void 0,row:void 0};const{Date:n}=window;let r=0,a=0,l=0;function c(){return{col:e.model.getters.getColIndex(r),row:e.model.getters.getRowIndex(a)}}const{pause:h,resume:d}=function(e,o){let i;const{setInterval:s,clearInterval:n}=window;return t.useEffect((()=>(i=s(e,o),()=>n(i))),(()=>[o])),{pause:()=>{n(i),i=void 0},resume:()=>{void 0===i&&(i=s(e,o))}}}((function(){const{col:e,row:t}=c(),o=n.now()-l;o>300&&(e!==s.col||t!==s.row)&&p(void 0,void 0);if(o>300){if(e<0||t<0)return;p(e,t)}}),200);function u(e){o.el===e.target&&(r=e.offsetX,a=e.offsetY,l=n.now())}function g(){const{col:e,row:t}=c();e===s.col&&t===s.row||p(void 0,void 0)}function p(e,t){e===s.col&&t===s.row||(s.col=e,s.row=t,i({col:e,row:t}))}return t.onMounted((()=>{const e=o.el;e.addEventListener("mousemove",u),e.addEventListener("mouseleave",h),e.addEventListener("mouseenter",d),e.addEventListener("mousedown",g)})),t.onWillUnmount((()=>{const e=o.el;e.removeEventListener("mousemove",u),e.removeEventListener("mouseleave",h),e.removeEventListener("mouseenter",d),e.removeEventListener("mousedown",g)})),s}Gf.props={onFigureDeleted:Function};class Zf extends t.Component{static template="o-spreadsheet-GridOverlay";static components={FiguresContainer:Gf};static defaultProps={onCellHovered:()=>{},onCellDoubleClicked:()=>{},onCellClicked:()=>{},onCellRightClicked:()=>{},onGridResized:()=>{},onFigureDeleted:()=>{}};gridOverlay;setup(){this.gridOverlay=t.useRef("gridOverlay"),qf(this.env,this.gridOverlay,this.props.onCellHovered);const e=new ResizeObserver((()=>{this.props.onGridResized({height:this.gridOverlayEl.clientHeight,width:this.gridOverlayEl.clientWidth})}));t.onMounted((()=>{e.observe(this.gridOverlayEl)})),t.onWillUnmount((()=>{e.disconnect()})),function(e,o,i){let s=null,n=null;function r(e){1===e.touches.length&&(s=e.touches[0].clientX,n=e.touches[0].clientY)}function a(){s=null,n=null}function l(e){if(1!==e.touches.length)return;i()&&(e.preventDefault(),e.stopPropagation());const t=e.touches[0].clientX,r=e.touches[0].clientY;o(s-t,n-r),s=t,n=r}t.onMounted((()=>{e.el.addEventListener("touchstart",r),e.el.addEventListener("touchend",a),e.el.addEventListener("touchmove",l)})),t.onWillUnmount((()=>{e.el.removeEventListener("touchstart",r),e.el.removeEventListener("touchend",a),e.el.removeEventListener("touchmove",l)}))}(this.gridOverlay,this.props.onGridMoved,(()=>{const{scrollY:e}=this.env.model.getters.getActiveSheetDOMScrollInfo();return e>0}))}get gridOverlayEl(){if(!this.gridOverlay.el)throw new Error("GridOverlay el is not defined.");return this.gridOverlay.el}onMouseDown(e){if(e.button>0)return;const[t,o]=this.getCartesianCoordinates(e);this.props.onCellClicked(t,o,{expandZone:e.shiftKey,addZone:un(e)})}onDoubleClick(e){const[t,o]=this.getCartesianCoordinates(e);this.props.onCellDoubleClicked(t,o)}onContextMenu(e){const[t,o]=this.getCartesianCoordinates(e);this.props.onCellRightClicked(t,o,{x:e.clientX,y:e.clientY})}getCartesianCoordinates(e){return[this.env.model.getters.getColIndex(e.offsetX),this.env.model.getters.getRowIndex(e.offsetY)]}}Zf.props={onCellHovered:{type:Function,optional:!0},onCellDoubleClicked:{type:Function,optional:!0},onCellClicked:{type:Function,optional:!0},onCellRightClicked:{type:Function,optional:!0},onGridResized:{type:Function,optional:!0},onFigureDeleted:{type:Function,optional:!0},onGridMoved:Function,gridOverlayDimensions:String};class jf extends t.Component{static template="o-spreadsheet-GridPopover";static components={Popover:vn};zIndex=ue.GridPopover;get cellPopover(){const e=this.env.model.getters.getCellPopover(this.props.hoveredCell);if(!e.isOpen)return{isOpen:!1};const t=e.anchorRect;return{...e,anchorRect:{...t,x:t.x+this.props.gridRect.x,y:t.y+this.props.gridRect.y}}}}jf.props={hoveredCell:Object,onClosePopover:Function,onMouseWheel:Function,gridRect:Object};class Yf extends t.Component{PADDING=0;MAX_SIZE_MARGIN=0;MIN_ELEMENT_SIZE=0;lastSelectedElementIndex=null;state=t.useState({resizerIsActive:!1,isResizing:!1,isMoving:!1,isSelecting:!1,waitingForMove:!1,activeElement:0,draggerLinePosition:0,draggerShadowPosition:0,draggerShadowThickness:0,delta:0,base:0,position:"before"});_computeHandleDisplay(e){const t=this._getEvOffset(e),o=this._getElementIndex(t);if(o<0)return;const i=this._getDimensionsInViewport(o);t-i.start<this.PADDING&&o!==this._getViewportOffset()?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=i.start,this.state.activeElement=this._getPreviousVisibleElement(o)):i.end-t<this.PADDING?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=i.end,this.state.activeElement=o):this.state.resizerIsActive=!1}_computeGrabDisplay(e){const t=this._getElementIndex(this._getEvOffset(e)),o=this._getActiveElements(),i=this._getSelectedZoneStart(),s=this._getSelectedZoneEnd();o.has(i)&&i<=t&&t<=s?this.state.waitingForMove=!0:this.state.waitingForMove=!1}onMouseMove(e){this.state.isResizing||this.state.isMoving||this.state.isSelecting||(this._computeHandleDisplay(e),this._computeGrabDisplay(e))}onMouseLeave(){this.state.resizerIsActive=this.state.isResizing,this.state.waitingForMove=!1}onDblClick(e){this._fitElementSize(this.state.activeElement),this.state.isResizing=!1,this._computeHandleDisplay(e),this._computeGrabDisplay(e)}onMouseDown(e){this.state.isResizing=!0,this.state.delta=0;const t=this._getClientPosition(e),o=this.state.draggerLinePosition,i=this._getElementSize(this.state.activeElement),s=o-i+this.MIN_ELEMENT_SIZE,n=this._getMaxSize();ff((e=>{this.state.delta=this._getClientPosition(e)-t,this.state.draggerLinePosition=o+this.state.delta,this.state.draggerLinePosition<s&&(this.state.draggerLinePosition=s,this.state.delta=this.MIN_ELEMENT_SIZE-i),this.state.draggerLinePosition>n&&(this.state.draggerLinePosition=n,this.state.delta=n-o)}),(e=>{this.state.isResizing=!1,0!==this.state.delta&&this._updateSize()}))}select(e){if(e.button>0)return;const t=this._getElementIndex(this._getEvOffset(e));t<0||(!0!==this.state.waitingForMove?("editing"===this.env.model.getters.getEditionMode()&&this.env.model.selection.getBackToDefault(),this.startSelection(e,t)):this.env.model.getters.isGridSelectionActive()?this.startMovement(e):this._selectElement(t,!1))}startMovement(e){this.state.waitingForMove=!1,this.state.isMoving=!0;const t=this._getDimensionsInViewport(this._getSelectedZoneStart()),o=this._getDimensionsInViewport(this._getSelectedZoneEnd()),i=t.start;this.state.draggerLinePosition=i,this.state.base=this._getSelectedZoneStart(),this.state.draggerShadowPosition=i,this.state.draggerShadowThickness=o.end-t.start;bf(this.env,((e,o)=>{let i="COL"===this._getType()?e:o;if(i>=0){const e=this._getDimensionsInViewport(i);i<=this._getSelectedZoneStart()?(this.state.draggerLinePosition=e.start,this.state.draggerShadowPosition=e.start,this.state.base=i,this.state.position="before"):this._getSelectedZoneEnd()<i?(this.state.draggerLinePosition=e.end,this.state.draggerShadowPosition=e.end-this.state.draggerShadowThickness,this.state.base=i,this.state.position="after"):(this.state.draggerLinePosition=t.start,this.state.draggerShadowPosition=t.start,this.state.base=this._getSelectedZoneStart())}}),(()=>{this.state.isMoving=!1,this.state.base!==this._getSelectedZoneStart()&&this._moveElements(),this._computeGrabDisplay(e)}))}startSelection(e,t){this.state.isSelecting=!0,e.shiftKey?this._increaseSelection(t):this._selectElement(t,un(e)),this.lastSelectedElementIndex=t;bf(this.env,((e,t)=>{let o="COL"===this._getType()?e:t;o!==this.lastSelectedElementIndex&&-1!==o&&(this._increaseSelection(o),this.lastSelectedElementIndex=o)}),(()=>{this.state.isSelecting=!1,this.lastSelectedElementIndex=null,this.env.model.dispatch(un(e)?"PREPARE_SELECTION_INPUT_EXPANSION":"STOP_SELECTION_INPUT"),this._computeGrabDisplay(e)}))}onMouseUp(e){this.lastSelectedElementIndex=null}onContextMenu(e){e.preventDefault();const t=this._getElementIndex(this._getEvOffset(e));if(t<0)return;this._getActiveElements().has(t)||this._selectElement(t,!1);const o=this._getType();this.props.onOpenContextMenu(o,e.clientX,e.clientY)}}Ni`
1210
+ `;class Gf extends t.Component{static template="o-spreadsheet-FiguresContainer";static components={FigureComponent:mf};dnd=t.useState({draggedFigure:void 0,horizontalSnap:void 0,verticalSnap:void 0});setup(){t.onMounted((()=>{this.render()}))}getVisibleFigures(){const e=this.env.model.getters.getVisibleFigures();return this.dnd.draggedFigure&&!e.some((e=>e.id===this.dnd.draggedFigure?.id))&&e.push(this.env.model.getters.getFigure(this.env.model.getters.getActiveSheetId(),this.dnd.draggedFigure?.id)),e}get containers(){const e=this.getVisibleFigures(),t=[];for(const o of["topLeft","topRight","bottomLeft","bottomRight"]){const i=e.filter((e=>this.getFigureContainer(e)===o));i.length>0&&t.push({type:o,figures:i,style:this.getContainerStyle(o),inverseViewportStyle:this.getInverseViewportPositionStyle(o)})}return this.dnd.draggedFigure&&t.push({type:"dnd",figures:[this.getDndFigure()],style:this.getContainerStyle("dnd"),inverseViewportStyle:this.getInverseViewportPositionStyle("dnd")}),t}getContainerStyle(e){return this.rectToCss(this.getContainerRect(e))}rectToCss(e){return Li({left:`${e.x}px`,top:`${e.y}px`,width:`${e.width}px`,height:`${e.height}px`})}getContainerRect(e){const{width:t,height:o}=this.env.model.getters.getSheetViewDimension(),{x:i,y:s}=this.env.model.getters.getMainViewportCoordinates(),n=["bottomRight","topRight"].includes(e)?i:0,r=t-n,a=["bottomRight","bottomLeft"].includes(e)?s:0;return{x:n,y:a,width:r,height:o-a}}getInverseViewportPositionStyle(e){const{scrollX:t,scrollY:o}=this.env.model.getters.getActiveSheetScrollInfo(),{x:i,y:s}=this.env.model.getters.getMainViewportCoordinates();return Li({left:`${["bottomRight","topRight"].includes(e)?-(i+t):0}px`,top:`${["bottomRight","bottomLeft"].includes(e)?-(s+o):0}px`})}getFigureContainer(e){const{x:t,y:o}=this.env.model.getters.getMainViewportCoordinates();return e.id===this.dnd.draggedFigure?.id?"dnd":e.x<t&&e.y<o?"topLeft":e.x<t?"bottomLeft":e.y<o?"topRight":"bottomRight"}startDraggingFigure(e,t){if(t.button>0||this.env.model.getters.isReadonly())return;if(!this.env.model.dispatch("SELECT_FIGURE",{id:e.id}).isSuccessful)return;const o=this.env.model.getters.getActiveSheetId(),i={x:t.clientX,y:t.clientY},s={maxX:this.env.model.getters.getColDimensions(o,this.env.model.getters.getNumberCols(o)-1).end,maxY:this.env.model.getters.getRowDimensions(o,this.env.model.getters.getNumberRows(o)-1).end},{x:n,y:r}=kf(this.env.model.getters,e),a={...e,x:n,y:r};ff((t=>{const o=this.env.model.getters,n=function({x:e,y:t},{x:o,y:i},s,{x:n,y:r},{maxX:a,maxY:l},{scrollX:c,scrollY:h}){const d=n?0:-c,u=r?0:-h,g=e-o,p=zf(s.x+g,d,a-s.width-c),m=t-i,f=zf(s.y+m,u,l-s.height-h);return{...s,x:p,y:f}}({x:t.clientX,y:t.clientY},i,a,this.env.model.getters.getMainViewportCoordinates(),s,o.getActiveSheetScrollInfo()),r=this.getOtherFigures(e.id),l=function(e,t,o){const i={...t},s=$f(e,i,["hCenter","right","left"],o,["hCenter","right","left"]),n=$f(e,i,["vCenter","bottom","top"],o,["vCenter","bottom","top"]),{y:r,x:a}=e.getMainViewportCoordinates(),{scrollY:l,scrollX:c}=e.getActiveSheetScrollInfo();if(n){i.y-=n.snapOffset;const e=t.y<r,o=i.y<r;e&&!o?i.y+=l:!e&&o&&(i.y-=l)}if(s){i.x-=s.snapOffset;const e=t.x<a,o=i.x<a;e&&!o?i.x+=c:!e&&o&&(i.x-=c)}return{snappedFigure:i,verticalSnapLine:s,horizontalSnapLine:n}}(o,Pf(o,n),r);this.dnd.draggedFigure=kf(o,l.snappedFigure),this.dnd.horizontalSnap=this.getSnap(l.horizontalSnapLine),this.dnd.verticalSnap=this.getSnap(l.verticalSnapLine)}),(t=>{if(!this.dnd.draggedFigure)return;let{x:i,y:s}=Pf(this.env.model.getters,this.dnd.draggedFigure);this.dnd.draggedFigure=void 0,this.dnd.horizontalSnap=void 0,this.dnd.verticalSnap=void 0,this.env.model.dispatch("UPDATE_FIGURE",{sheetId:o,id:e.id,x:i,y:s})}))}startResize(e,t,o,i){i.stopPropagation();const s={x:i.clientX,y:i.clientY},{x:n,y:r}=kf(this.env.model.getters,e),a={...e,x:n,y:r},l=Yr.get(e.tag).keepRatio||!1,c=Yr.get(e.tag).minFigSize||80;ff((i=>{const n={x:i.clientX,y:i.clientY},r=function(e,t,o,{x:i,y:s},{x:n,y:r},a,l,{scrollX:c,scrollY:h}){let{x:d,y:u,width:g,height:p}=e;if(a&&0!=t&&0!=o){const a=Math.min(t*(n-i),e.width-l),c=Math.min(o*(r-s),e.height-l),h=Math.min(a/e.width,c/e.height);g=e.width*(1-h),p=e.height*(1-h),t<0&&(d=e.x+e.width*h),o<0&&(u=e.y+e.height*h)}else{const a=Math.max(t*(i-n),l-e.width),c=Math.max(o*(s-r),l-e.height);g=e.width+a,p=e.height+c,t<0&&(d=e.x-a),o<0&&(u=e.y-c)}return d+c<=0&&(g=g+d+c,d=-c),u+h<=0&&(p=p+u+h,u=-h),{...e,x:d,y:u,width:g,height:p}}(a,t,o,n,s,l,c,this.env.model.getters.getActiveSheetScrollInfo()),h=this.getOtherFigures(e.id),d=function(e,t,o,i,s){const n={...i},r=$f(e,n,[-1===t?"left":"right"],s,["right","left"]);r&&(1===t?n.width-=r.snapOffset:-1===t&&(n.x-=r.snapOffset,n.width+=r.snapOffset));const a=$f(e,n,[-1===o?"top":"bottom"],s,["bottom","top"]);return a&&(1===o?n.height-=a.snapOffset:-1===o&&(n.y-=a.snapOffset,n.height+=a.snapOffset)),n.x=Math.round(n.x),n.y=Math.round(n.y),n.height=Math.round(n.height),n.width=Math.round(n.width),{snappedFigure:n,verticalSnapLine:r,horizontalSnapLine:a}}(this.env.model.getters,t,o,r,h);this.dnd.draggedFigure=d.snappedFigure,this.dnd.horizontalSnap=this.getSnap(d.horizontalSnapLine),this.dnd.verticalSnap=this.getSnap(d.verticalSnapLine)}),(i=>{if(!this.dnd.draggedFigure)return;let{x:s,y:n}=Pf(this.env.model.getters,this.dnd.draggedFigure);const r={x:s,y:n};t&&(r.width=this.dnd.draggedFigure.width),o&&(r.height=this.dnd.draggedFigure.height),this.env.model.dispatch("UPDATE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:e.id,...r}),this.dnd.draggedFigure=void 0,this.dnd.horizontalSnap=void 0,this.dnd.verticalSnap=void 0}))}getOtherFigures(e){return this.getVisibleFigures().filter((t=>t.id!==e))}getDndFigure(){const e=this.getVisibleFigures().find((e=>e.id===this.dnd.draggedFigure?.id));if(!e)throw new Error("Dnd figure not found");return{...e,...this.dnd.draggedFigure}}getFigureStyle(e){return e.id!==this.dnd.draggedFigure?.id?"":Li({opacity:"0.9",cursor:"grabbing"})}getSnap(e){if(!e||!this.dnd.draggedFigure)return;const t=e.matchedFigIds.map((e=>this.getVisibleFigures().find((t=>t.id===e)))).filter(dt).map((e=>{const t=kf(this.env.model.getters,e),o=this.getFigureContainer(e);return mn(t,this.getContainerRect(o))})).filter(dt),o=function(...e){return bn(hi(...e.map(fn)))}(this.dnd.draggedFigure,...t);return{line:e,containerStyle:this.rectToCss(o),lineStyle:this.getSnapLineStyle(e,o)}}getSnapLineStyle(e,t){return e?["top","vCenter","bottom"].includes(e.snappedAxisType)?Li({top:e.position-t.y+"px",left:"0px",width:"100%"}):Li({top:"0px",left:e.position-t.x+"px",height:"100%"}):""}}function qf(e,o,i){let s={col:void 0,row:void 0};const{Date:n}=window;let r=0,a=0,l=0;function c(){return{col:e.model.getters.getColIndex(r),row:e.model.getters.getRowIndex(a)}}const{pause:h,resume:d}=function(e,o){let i;const{setInterval:s,clearInterval:n}=window;return t.useEffect((()=>(i=s(e,o),()=>n(i))),(()=>[o])),{pause:()=>{n(i),i=void 0},resume:()=>{void 0===i&&(i=s(e,o))}}}((function(){const{col:e,row:t}=c(),o=n.now()-l;o>300&&(e!==s.col||t!==s.row)&&p(void 0,void 0);if(o>300){if(e<0||t<0)return;p(e,t)}}),200);function u(e){o.el===e.target&&(r=e.offsetX,a=e.offsetY,l=n.now())}function g(){const{col:e,row:t}=c();e===s.col&&t===s.row||p(void 0,void 0)}function p(e,t){e===s.col&&t===s.row||(s.col=e,s.row=t,i({col:e,row:t}))}return t.onMounted((()=>{const e=o.el;e.addEventListener("mousemove",u),e.addEventListener("mouseleave",h),e.addEventListener("mouseenter",d),e.addEventListener("mousedown",g)})),t.onWillUnmount((()=>{const e=o.el;e.removeEventListener("mousemove",u),e.removeEventListener("mouseleave",h),e.removeEventListener("mouseenter",d),e.removeEventListener("mousedown",g)})),s}Gf.props={onFigureDeleted:Function};class Zf extends t.Component{static template="o-spreadsheet-GridOverlay";static components={FiguresContainer:Gf};static defaultProps={onCellHovered:()=>{},onCellDoubleClicked:()=>{},onCellClicked:()=>{},onCellRightClicked:()=>{},onGridResized:()=>{},onFigureDeleted:()=>{}};gridOverlay;setup(){this.gridOverlay=t.useRef("gridOverlay"),qf(this.env,this.gridOverlay,this.props.onCellHovered);const e=new ResizeObserver((()=>{this.props.onGridResized({height:this.gridOverlayEl.clientHeight,width:this.gridOverlayEl.clientWidth})}));t.onMounted((()=>{e.observe(this.gridOverlayEl)})),t.onWillUnmount((()=>{e.disconnect()})),function(e,o,i){let s=null,n=null;function r(e){1===e.touches.length&&(s=e.touches[0].clientX,n=e.touches[0].clientY)}function a(){s=null,n=null}function l(e){if(1!==e.touches.length)return;i()&&(e.preventDefault(),e.stopPropagation());const t=e.touches[0].clientX,r=e.touches[0].clientY;o(s-t,n-r),s=t,n=r}t.onMounted((()=>{e.el.addEventListener("touchstart",r),e.el.addEventListener("touchend",a),e.el.addEventListener("touchmove",l)})),t.onWillUnmount((()=>{e.el.removeEventListener("touchstart",r),e.el.removeEventListener("touchend",a),e.el.removeEventListener("touchmove",l)}))}(this.gridOverlay,this.props.onGridMoved,(()=>{const{scrollY:e}=this.env.model.getters.getActiveSheetDOMScrollInfo();return e>0}))}get gridOverlayEl(){if(!this.gridOverlay.el)throw new Error("GridOverlay el is not defined.");return this.gridOverlay.el}onMouseDown(e){if(e.button>0)return;const[t,o]=this.getCartesianCoordinates(e);this.props.onCellClicked(t,o,{expandZone:e.shiftKey,addZone:un(e)})}onDoubleClick(e){const[t,o]=this.getCartesianCoordinates(e);this.props.onCellDoubleClicked(t,o)}onContextMenu(e){const[t,o]=this.getCartesianCoordinates(e);this.props.onCellRightClicked(t,o,{x:e.clientX,y:e.clientY})}getCartesianCoordinates(e){return[this.env.model.getters.getColIndex(e.offsetX),this.env.model.getters.getRowIndex(e.offsetY)]}}Zf.props={onCellHovered:{type:Function,optional:!0},onCellDoubleClicked:{type:Function,optional:!0},onCellClicked:{type:Function,optional:!0},onCellRightClicked:{type:Function,optional:!0},onGridResized:{type:Function,optional:!0},onFigureDeleted:{type:Function,optional:!0},onGridMoved:Function,gridOverlayDimensions:String};class jf extends t.Component{static template="o-spreadsheet-GridPopover";static components={Popover:vn};zIndex=ue.GridPopover;get cellPopover(){const e=this.env.model.getters.getCellPopover(this.props.hoveredCell);if(!e.isOpen)return{isOpen:!1};const t=e.anchorRect;return{...e,anchorRect:{...t,x:t.x+this.props.gridRect.x,y:t.y+this.props.gridRect.y}}}}jf.props={hoveredCell:Object,onClosePopover:Function,onMouseWheel:Function,gridRect:Object};class Yf extends t.Component{PADDING=0;MAX_SIZE_MARGIN=0;MIN_ELEMENT_SIZE=0;lastSelectedElementIndex=null;state=t.useState({resizerIsActive:!1,isResizing:!1,isMoving:!1,isSelecting:!1,waitingForMove:!1,activeElement:0,draggerLinePosition:0,draggerShadowPosition:0,draggerShadowThickness:0,delta:0,base:0,position:"before"});_computeHandleDisplay(e){const t=this._getEvOffset(e),o=this._getElementIndex(t);if(o<0)return;const i=this._getDimensionsInViewport(o);t-i.start<this.PADDING&&o!==this._getViewportOffset()?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=i.start,this.state.activeElement=this._getPreviousVisibleElement(o)):i.end-t<this.PADDING?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=i.end,this.state.activeElement=o):this.state.resizerIsActive=!1}_computeGrabDisplay(e){const t=this._getElementIndex(this._getEvOffset(e)),o=this._getActiveElements(),i=this._getSelectedZoneStart(),s=this._getSelectedZoneEnd();o.has(i)&&i<=t&&t<=s?this.state.waitingForMove=!0:this.state.waitingForMove=!1}onMouseMove(e){this.state.isResizing||this.state.isMoving||this.state.isSelecting||(this._computeHandleDisplay(e),this._computeGrabDisplay(e))}onMouseLeave(){this.state.resizerIsActive=this.state.isResizing,this.state.waitingForMove=!1}onDblClick(e){this._fitElementSize(this.state.activeElement),this.state.isResizing=!1,this._computeHandleDisplay(e),this._computeGrabDisplay(e)}onMouseDown(e){this.state.isResizing=!0,this.state.delta=0;const t=this._getClientPosition(e),o=this.state.draggerLinePosition,i=this._getElementSize(this.state.activeElement),s=o-i+this.MIN_ELEMENT_SIZE,n=this._getMaxSize();ff((e=>{this.state.delta=this._getClientPosition(e)-t,this.state.draggerLinePosition=o+this.state.delta,this.state.draggerLinePosition<s&&(this.state.draggerLinePosition=s,this.state.delta=this.MIN_ELEMENT_SIZE-i),this.state.draggerLinePosition>n&&(this.state.draggerLinePosition=n,this.state.delta=n-o)}),(e=>{this.state.isResizing=!1,0!==this.state.delta&&this._updateSize()}))}select(e){if(e.button>0)return;const t=this._getElementIndex(this._getEvOffset(e));t<0||(!0!==this.state.waitingForMove?("editing"===this.env.model.getters.getEditionMode()&&this.env.model.selection.getBackToDefault(),this.startSelection(e,t)):this.env.model.getters.isGridSelectionActive()?this.startMovement(e):this._selectElement(t,!1))}startMovement(e){this.state.waitingForMove=!1,this.state.isMoving=!0;const t=this._getDimensionsInViewport(this._getSelectedZoneStart()),o=this._getDimensionsInViewport(this._getSelectedZoneEnd()),i=t.start;this.state.draggerLinePosition=i,this.state.base=this._getSelectedZoneStart(),this.state.draggerShadowPosition=i,this.state.draggerShadowThickness=o.end-t.start;bf(this.env,((e,o)=>{let i="COL"===this._getType()?e:o;if(i>=0){const e=this._getDimensionsInViewport(i);i<=this._getSelectedZoneStart()?(this.state.draggerLinePosition=e.start,this.state.draggerShadowPosition=e.start,this.state.base=i,this.state.position="before"):this._getSelectedZoneEnd()<i?(this.state.draggerLinePosition=e.end,this.state.draggerShadowPosition=e.end-this.state.draggerShadowThickness,this.state.base=i,this.state.position="after"):(this.state.draggerLinePosition=t.start,this.state.draggerShadowPosition=t.start,this.state.base=this._getSelectedZoneStart())}}),(()=>{this.state.isMoving=!1,this.state.base!==this._getSelectedZoneStart()&&this._moveElements(),this._computeGrabDisplay(e)}))}startSelection(e,t){this.state.isSelecting=!0,e.shiftKey?this._increaseSelection(t):this._selectElement(t,un(e)),this.lastSelectedElementIndex=t;bf(this.env,((e,t)=>{let o="COL"===this._getType()?e:t;o!==this.lastSelectedElementIndex&&-1!==o&&(this._increaseSelection(o),this.lastSelectedElementIndex=o)}),(()=>{this.state.isSelecting=!1,this.lastSelectedElementIndex=null,this.env.model.dispatch(un(e)?"PREPARE_SELECTION_INPUT_EXPANSION":"STOP_SELECTION_INPUT"),this._computeGrabDisplay(e)}))}onMouseUp(e){this.lastSelectedElementIndex=null}onContextMenu(e){e.preventDefault();const t=this._getElementIndex(this._getEvOffset(e));if(t<0)return;this._getActiveElements().has(t)||this._selectElement(t,!1);const o=this._getType();this.props.onOpenContextMenu(o,e.clientX,e.clientY)}}Ni`
1211
1211
  .o-col-resizer {
1212
1212
  position: absolute;
1213
1213
  top: 0;
@@ -2492,4 +2492,4 @@
2492
2492
  <tableParts count="${e.filterTables.length}">
2493
2493
  ${XS(a)}
2494
2494
  </tableParts>
2495
- `}var Gw;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(Gw||(Gw={}));function qw(e,t={}){const o=Be(t);return o.type=e,o}const Zw={},jw={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:F,HEADER_WIDTH:D,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:L,DEFAULT_CELL_HEIGHT:k,SCROLLBAR_WIDTH:P},Yw={autofillModifiersRegistry:Ws,autofillRulesRegistry:Gs,cellMenuRegistry:fp,colMenuRegistry:Nm,linkMenuRegistry:kn,functionRegistry:Hg,featurePluginRegistry:vE,statefulUIPluginRegistry:SE,coreViewsPluginRegistry:CE,corePluginRegistry:bE,rowMenuRegistry:Dm,sidePanelRegistry:gf,figureRegistry:Yr,chartSidePanelComponentRegistry:ef,chartComponentRegistry:Wr,chartRegistry:$r,topbarMenuRegistry:Lm,topbarComponentRegistry:pf,clickableCellRegistry:EE,otRegistry:km,inverseCommandRegistry:Jr,urlRegistry:Hi,cellPopoverRegistry:Vn,numberFormatMenuRegistry:_m,repeatLocalCommandTransformRegistry:oE,repeatCommandTransformRegistry:tE},Xw={arg:el,toBoolean:rs,toJsDate:as,toNumber:Qi,toString:os,toXC:Zt,toZone:ii,toCartesian:qt,numberToLetters:Bt,UuidGenerator:ti,formatValue:bo,computeTextWidth:qe,createEmptyWorkbookData:wC,createEmptySheet:EC,createEmptyExcelSheet:xC,getDefaultChartJsRuntime:br,chartFontColor:er,ChartColors:Jn,EvaluationError:c,CellErrorLevel:l,getFillingMode:Er,rgbaToHex:Pt,colorToRGBA:Ut,positionToZone:yi,isDefined:dt,lazy:mt,genericRepeat:iE},Kw={isMarkdownLink:it,parseMarkdownLink:rt,markdownLink:nt,openLink:Zi,urlRepresentation:qi},Qw={ChartPanel:tf,ChartFigure:qr,ChartJsComponent:Ai,Grid:cb,GridOverlay:Zf,ScorecardChart:Pi,LineConfigPanel:Km,LineBarPieDesignPanel:jm,BarConfigPanel:Hm,LineBarPieConfigPanel:Bm,GaugeChartConfigPanel:Ym,GaugeChartDesignPanel:Xm,ScorecardChartConfigPanel:Qm,ScorecardChartDesignPanel:Jm,FigureComponent:mf};e.AbstractChart=Bn,e.CorePlugin=IC,e.DispatchResult=Ns,e.EvaluationError=c,e.Model=class extends kC{corePlugins=[];featurePlugins=[];statefulUIPlugins=[];coreViewsPlugins=[];range;session;isReplayingCommand=!1;renderers=[];status=0;config;corePluginConfig;uiPluginConfig;state;selection;getters;coreGetters;uuidGenerator;handlers=[];uiHandlers=[];coreHandlers=[];constructor(e={},o={},i=[],s=new ti,n=!0){super(),i=SC(e,i);const r=bC(e,n);this.state=new iw,this.uuidGenerator=s,this.config=this.setupConfig(o),this.session=this.setupSession(r.revisionId),this.coreGetters={},this.range=new NC(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},this.uuidGenerator.setIsFastStrategy(!0),this.selection=new ow(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range),this.corePluginConfig=this.setupCorePluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(let e of bE.getAll())this.setupCorePlugin(e,r);Object.assign(this.getters,this.coreGetters),this.session.loadInitialMessages(i);for(let e of SE.getAll()){const t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}for(let e of CE.getAll()){const t=this.setupUiPlugin(e);this.coreViewsPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t),this.coreHandlers.push(t)}for(let e of vE.getAll()){const t=this.setupUiPlugin(e);this.featurePlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}this.uuidGenerator.setIsFastStrategy(!1),this.dispatch("START"),this.selection.observe(this,{handleEvent:()=>this.trigger("update")}),this.setupSessionEvents(),this.joinSession(),o.snapshotRequested&&(this.session.snapshot(this.exportData()),this.garbageCollectExternalResources()),t.markRaw(this)}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),this.coreHandlers.push(o),this.handlers.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 GC(JE({initialRevisionId:e,recordChanges:this.state.recordChanges.bind(this.state),dispatch:e=>{this.checkDispatchAllowed(e).isSuccessful&&(this.isReplayingCommand=!0,this.dispatchToHandlers(this.coreHandlers,e),this.isReplayingCommand=!1)}}),this.config.transportService,e)}setupSessionEvents(){this.session.on("remote-revision-received",this,this.onRemoteRevisionReceived),this.session.on("revision-undone",this,(({commands:e})=>{this.dispatchFromCorePlugin("UNDO",{commands:e}),this.finalize()})),this.session.on("revision-redone",this,(({commands:e})=>{this.dispatchFromCorePlugin("REDO",{commands:e}),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:n("Anonymous").toString()},o=e.transportService||new WE;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,session:this.session}}checkDispatchAllowed(e){const t=Ms(e)?this.checkDispatchAllowedCoreCommand(e):this.checkDispatchAllowedLocalCommand(e);return t.some((e=>0!==e))?new Ns(t.flat()):Ns.Success}checkDispatchAllowedCoreCommand(e){const t=this.corePlugins.map((t=>t.allowDispatch(e)));return t.push(this.range.allowDispatch(e)),t}checkDispatchAllowedLocalCommand(e){return this.uiHandlers.map((t=>t.allowDispatch(e)))}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0}canDispatch=(e,t)=>this.checkDispatchAllowed(qw(e,t));dispatch=(e,t)=>{const o=qw(e,t);let i=this.status;if(this.getters.isReadonly()&&(s=o,!As.has(s.type)))return new Ns(68);var s;if(!this.session.canApplyOptimisticUpdate())return new Ns(65);switch(i){case 0:const t=this.checkDispatchAllowed(o);if(!t.isSuccessful)return t;this.status=1;const{changes:i,commands:s}=this.state.recordChanges((()=>{Ms(o)&&this.state.addCommand(o),this.dispatchToHandlers(this.handlers,o),this.finalize()}));this.session.save(o,s,i),this.status=0,this.trigger("update");break;case 1:if(Ms(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(Ms(o))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,o)}return Ns.Success};dispatchFromCorePlugin=(e,t)=>{const o=qw(e,t),i=this.status;this.status=2;const s=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(s,o),this.status=i,Ns.Success};dispatchToHandlers(e,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=wC();for(let t of this.handlers)t instanceof IC&&t.export(e);return e.revisionId=this.session.getRevisionId()||ee,e=Be(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={...wC(),sheets:[xC(fC,"Sheet1")]};for(let t of this.handlers)t instanceof yC&&t.exportForExcel(e);return e=Be(e),$w(e)}garbageCollectExternalResources(){for(const e of this.corePlugins)e.garbageCollectExternalResources()}},e.Registry=zi,e.Revision=$C,e.SPREADSHEET_DIMENSIONS=jw,e.Spreadsheet=$E,e.UIPlugin=_C,e.__info__=Zw,e.addFunction=function(e,t){Hg.add(e,t)},e.astToFormula=Zv,e.compile=rS,e.components=Qw,e.convertAstNodes=qv,e.coreTypes=Os,e.findCellInNewZone=wi,e.functionCache=nS,e.helpers=Xw,e.invalidateEvaluationCommands=Rs,e.links=Kw,e.load=bC,e.parse=Wv,e.readonlyAllowedCommands=As,e.registries=Yw,e.setDefaultSheetViewSize=function(e){ge=e},e.setTranslationMethod=function(e){o=e},e.tokenize=xv,Object.defineProperty(e,"__esModule",{value:!0}),Zw.version="16.3.37",Zw.date="2024-06-03T14:49:37.305Z",Zw.hash="e7bf8e1"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
2495
+ `}var Gw;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(Gw||(Gw={}));function qw(e,t={}){const o=Be(t);return o.type=e,o}const Zw={},jw={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:F,HEADER_WIDTH:D,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:L,DEFAULT_CELL_HEIGHT:k,SCROLLBAR_WIDTH:P},Yw={autofillModifiersRegistry:Ws,autofillRulesRegistry:Gs,cellMenuRegistry:fp,colMenuRegistry:Nm,linkMenuRegistry:kn,functionRegistry:Hg,featurePluginRegistry:vE,statefulUIPluginRegistry:SE,coreViewsPluginRegistry:CE,corePluginRegistry:bE,rowMenuRegistry:Dm,sidePanelRegistry:gf,figureRegistry:Yr,chartSidePanelComponentRegistry:ef,chartComponentRegistry:Wr,chartRegistry:$r,topbarMenuRegistry:Lm,topbarComponentRegistry:pf,clickableCellRegistry:EE,otRegistry:km,inverseCommandRegistry:Jr,urlRegistry:Hi,cellPopoverRegistry:Vn,numberFormatMenuRegistry:_m,repeatLocalCommandTransformRegistry:oE,repeatCommandTransformRegistry:tE},Xw={arg:el,toBoolean:rs,toJsDate:as,toNumber:Qi,toString:os,toXC:Zt,toZone:ii,toCartesian:qt,numberToLetters:Bt,UuidGenerator:ti,formatValue:bo,computeTextWidth:qe,createEmptyWorkbookData:wC,createEmptySheet:EC,createEmptyExcelSheet:xC,getDefaultChartJsRuntime:br,chartFontColor:er,ChartColors:Jn,EvaluationError:c,CellErrorLevel:l,getFillingMode:Er,rgbaToHex:Pt,colorToRGBA:Ut,positionToZone:yi,isDefined:dt,lazy:mt,genericRepeat:iE,deepEquals:vt},Kw={isMarkdownLink:it,parseMarkdownLink:rt,markdownLink:nt,openLink:Zi,urlRepresentation:qi},Qw={ChartPanel:tf,ChartFigure:qr,ChartJsComponent:Ai,Grid:cb,GridOverlay:Zf,ScorecardChart:Pi,LineConfigPanel:Km,LineBarPieDesignPanel:jm,BarConfigPanel:Hm,LineBarPieConfigPanel:Bm,GaugeChartConfigPanel:Ym,GaugeChartDesignPanel:Xm,ScorecardChartConfigPanel:Qm,ScorecardChartDesignPanel:Jm,FigureComponent:mf};e.AbstractChart=Bn,e.CorePlugin=IC,e.DispatchResult=Ns,e.EvaluationError=c,e.Model=class extends kC{corePlugins=[];featurePlugins=[];statefulUIPlugins=[];coreViewsPlugins=[];range;session;isReplayingCommand=!1;renderers=[];status=0;config;corePluginConfig;uiPluginConfig;state;selection;getters;coreGetters;uuidGenerator;handlers=[];uiHandlers=[];coreHandlers=[];constructor(e={},o={},i=[],s=new ti,n=!0){super(),i=SC(e,i);const r=bC(e,n);this.state=new iw,this.uuidGenerator=s,this.config=this.setupConfig(o),this.session=this.setupSession(r.revisionId),this.coreGetters={},this.range=new NC(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},this.uuidGenerator.setIsFastStrategy(!0),this.selection=new ow(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range),this.corePluginConfig=this.setupCorePluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(let e of bE.getAll())this.setupCorePlugin(e,r);Object.assign(this.getters,this.coreGetters),this.session.loadInitialMessages(i);for(let e of SE.getAll()){const t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}for(let e of CE.getAll()){const t=this.setupUiPlugin(e);this.coreViewsPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t),this.coreHandlers.push(t)}for(let e of vE.getAll()){const t=this.setupUiPlugin(e);this.featurePlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}this.uuidGenerator.setIsFastStrategy(!1),this.dispatch("START"),this.selection.observe(this,{handleEvent:()=>this.trigger("update")}),this.setupSessionEvents(),this.joinSession(),o.snapshotRequested&&(this.session.snapshot(this.exportData()),this.garbageCollectExternalResources()),t.markRaw(this)}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),this.coreHandlers.push(o),this.handlers.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 GC(JE({initialRevisionId:e,recordChanges:this.state.recordChanges.bind(this.state),dispatch:e=>{this.checkDispatchAllowed(e).isSuccessful&&(this.isReplayingCommand=!0,this.dispatchToHandlers(this.coreHandlers,e),this.isReplayingCommand=!1)}}),this.config.transportService,e)}setupSessionEvents(){this.session.on("remote-revision-received",this,this.onRemoteRevisionReceived),this.session.on("revision-undone",this,(({commands:e})=>{this.dispatchFromCorePlugin("UNDO",{commands:e}),this.finalize()})),this.session.on("revision-redone",this,(({commands:e})=>{this.dispatchFromCorePlugin("REDO",{commands:e}),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:n("Anonymous").toString()},o=e.transportService||new WE;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,session:this.session}}checkDispatchAllowed(e){const t=Ms(e)?this.checkDispatchAllowedCoreCommand(e):this.checkDispatchAllowedLocalCommand(e);return t.some((e=>0!==e))?new Ns(t.flat()):Ns.Success}checkDispatchAllowedCoreCommand(e){const t=this.corePlugins.map((t=>t.allowDispatch(e)));return t.push(this.range.allowDispatch(e)),t}checkDispatchAllowedLocalCommand(e){return this.uiHandlers.map((t=>t.allowDispatch(e)))}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0}canDispatch=(e,t)=>this.checkDispatchAllowed(qw(e,t));dispatch=(e,t)=>{const o=qw(e,t);let i=this.status;if(this.getters.isReadonly()&&(s=o,!As.has(s.type)))return new Ns(68);var s;if(!this.session.canApplyOptimisticUpdate())return new Ns(65);switch(i){case 0:const t=this.checkDispatchAllowed(o);if(!t.isSuccessful)return t;this.status=1;const{changes:i,commands:s}=this.state.recordChanges((()=>{Ms(o)&&this.state.addCommand(o),this.dispatchToHandlers(this.handlers,o),this.finalize()}));this.session.save(o,s,i),this.status=0,this.trigger("update");break;case 1:if(Ms(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(Ms(o))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,o)}return Ns.Success};dispatchFromCorePlugin=(e,t)=>{const o=qw(e,t),i=this.status;this.status=2;const s=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(s,o),this.status=i,Ns.Success};dispatchToHandlers(e,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=wC();for(let t of this.handlers)t instanceof IC&&t.export(e);return e.revisionId=this.session.getRevisionId()||ee,e=Be(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={...wC(),sheets:[xC(fC,"Sheet1")]};for(let t of this.handlers)t instanceof yC&&t.exportForExcel(e);return e=Be(e),$w(e)}garbageCollectExternalResources(){for(const e of this.corePlugins)e.garbageCollectExternalResources()}},e.Registry=zi,e.Revision=$C,e.SPREADSHEET_DIMENSIONS=jw,e.Spreadsheet=$E,e.UIPlugin=_C,e.__info__=Zw,e.addFunction=function(e,t){Hg.add(e,t)},e.astToFormula=Zv,e.compile=rS,e.components=Qw,e.convertAstNodes=qv,e.coreTypes=Os,e.findCellInNewZone=wi,e.functionCache=nS,e.helpers=Xw,e.invalidateEvaluationCommands=Rs,e.links=Kw,e.load=bC,e.parse=Wv,e.readonlyAllowedCommands=As,e.registries=Yw,e.setDefaultSheetViewSize=function(e){ge=e},e.setTranslationMethod=function(e){o=e},e.tokenize=xv,Object.defineProperty(e,"__esModule",{value:!0}),Zw.version="16.3.39",Zw.date="2024-06-14T09:57:15.035Z",Zw.hash="9701da6"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
@@ -3858,7 +3858,7 @@ https://fontawesome.com/license -->
3858
3858
  </t>
3859
3859
  </odoo>
3860
3860
  <!--
3861
- __info__.version = '16.3.37';
3862
- __info__.date = '2024-06-03T14:50:01.875Z';
3863
- __info__.hash = 'e7bf8e1';
3861
+ __info__.version = '16.3.39';
3862
+ __info__.date = '2024-06-14T09:57:39.164Z';
3863
+ __info__.hash = '9701da6';
3864
3864
  -->
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odoo/o-spreadsheet",
3
- "version": "16.3.37",
3
+ "version": "16.3.39",
4
4
  "description": "A spreadsheet component",
5
5
  "main": "dist/o-spreadsheet.cjs.js",
6
6
  "browser": "dist/o-spreadsheet.iife.js",