@odoo/o-spreadsheet 17.0.106 → 17.0.108
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.
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* This file is generated by o-spreadsheet build tools. Do not edit it.
|
|
4
4
|
* @see https://github.com/odoo/o-spreadsheet
|
|
5
|
-
* @version 17.0.
|
|
6
|
-
* @date 2026-
|
|
7
|
-
* @hash
|
|
5
|
+
* @version 17.0.108
|
|
6
|
+
* @date 2026-09-10T05:35:45.123Z
|
|
7
|
+
* @hash b2580c5
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { Component, markRaw, onMounted, onPatched, onWillPatch, onWillStart, onWillUnmount, onWillUpdateProps, useChildSubEnv, useComponent, useEffect, useExternalListener, useRef, useState, useSubEnv, xml } from "@odoo/owl";
|
|
@@ -7223,7 +7223,7 @@ function toXlsxHexColor(color) {
|
|
|
7223
7223
|
//#region src/helpers/ui/paste_interactive.ts
|
|
7224
7224
|
const PasteInteractiveContent = {
|
|
7225
7225
|
wrongPasteSelection: _t("This operation is not allowed with multiple selections."),
|
|
7226
|
-
willRemoveExistingMerge: _t("
|
|
7226
|
+
willRemoveExistingMerge: _t("Cannot perform this action on merged cells. Unmerge the cells and try again."),
|
|
7227
7227
|
wrongFigurePasteOption: _t("Cannot do a special paste of a figure."),
|
|
7228
7228
|
frozenPaneOverlap: _t("This operation is not allowed due to an overlapping frozen pane.")
|
|
7229
7229
|
};
|
|
@@ -43915,8 +43915,8 @@ var InternalViewport = class {
|
|
|
43915
43915
|
const { end: lastRowEnd, size: lastRowSize } = this.getters.getRowDimensions(this.sheetId, lastRow);
|
|
43916
43916
|
const leftColIndex = this.searchHeaderIndex("COL", lastColEnd - this.viewportWidth, 0);
|
|
43917
43917
|
const leftColSize = this.getters.getColSize(this.sheetId, leftColIndex);
|
|
43918
|
-
const
|
|
43919
|
-
const topRowSize = this.getters.getRowSize(this.sheetId,
|
|
43918
|
+
const topRowIndex = this.searchHeaderIndex("ROW", lastRowEnd - this.viewportHeight, 0);
|
|
43919
|
+
const topRowSize = this.getters.getRowSize(this.sheetId, topRowIndex);
|
|
43920
43920
|
let width = lastColEnd - this.offsetCorrectionX;
|
|
43921
43921
|
if (this.canScrollHorizontally) {
|
|
43922
43922
|
width += Math.max(96, Math.min(leftColSize, this.viewportWidth - lastColSize));
|
|
@@ -44109,7 +44109,11 @@ var InternalViewport = class {
|
|
|
44109
44109
|
this.left = this.searchHeaderIndex("COL", this.offsetScrollbarX, this.boundaries.left);
|
|
44110
44110
|
this.right = Math.min(this.boundaries.right, this.searchHeaderIndex("COL", this.viewportWidth, this.left));
|
|
44111
44111
|
if (!this.viewportWidth) return;
|
|
44112
|
-
if (this.left === -1)
|
|
44112
|
+
if (this.left === -1) {
|
|
44113
|
+
const colsHeight = this.getters.getColRowOffset("COL", this.boundaries.left, this.boundaries.right);
|
|
44114
|
+
if (0 < colsHeight && colsHeight <= this.offsetScrollbarX) this.left = this.boundaries.right;
|
|
44115
|
+
else this.left = this.boundaries.left;
|
|
44116
|
+
}
|
|
44113
44117
|
if (this.right === -1) this.right = this.boundaries.right;
|
|
44114
44118
|
this.offsetX = this.getters.getColDimensions(sheetId, this.left).start - this.getters.getColDimensions(sheetId, this.boundaries.left).start;
|
|
44115
44119
|
}
|
|
@@ -44120,7 +44124,11 @@ var InternalViewport = class {
|
|
|
44120
44124
|
this.top = this.searchHeaderIndex("ROW", this.offsetScrollbarY, this.boundaries.top);
|
|
44121
44125
|
this.bottom = Math.min(this.boundaries.bottom, this.searchHeaderIndex("ROW", this.viewportHeight, this.top));
|
|
44122
44126
|
if (!this.viewportHeight) return;
|
|
44123
|
-
if (this.top === -1)
|
|
44127
|
+
if (this.top === -1) {
|
|
44128
|
+
const rowsHeight = this.getters.getColRowOffset("ROW", this.boundaries.top, this.boundaries.bottom);
|
|
44129
|
+
if (0 < rowsHeight && rowsHeight <= this.offsetScrollbarY) this.top = this.boundaries.bottom;
|
|
44130
|
+
else this.top = this.boundaries.top;
|
|
44131
|
+
}
|
|
44124
44132
|
if (this.bottom === -1) this.bottom = this.boundaries.bottom;
|
|
44125
44133
|
this.offsetY = this.getters.getRowDimensions(sheetId, this.top).start - this.getters.getRowDimensions(sheetId, this.boundaries.top).start;
|
|
44126
44134
|
}
|
|
@@ -50872,6 +50880,6 @@ const constants = { DEFAULT_LOCALE };
|
|
|
50872
50880
|
//#endregion
|
|
50873
50881
|
export { AbstractChart, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, __info__, addFunction, astToFormula, compile, compileTokens, components, constants, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, hooks, invalidateCFEvaluationCommands, invalidateDependenciesCommands, invalidateEvaluationCommands, iterateAstNodes, links, load, parse, parseTokens, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, tokenize };
|
|
50874
50882
|
|
|
50875
|
-
__info__.version = "17.0.
|
|
50876
|
-
__info__.date = "2026-
|
|
50877
|
-
__info__.hash = "
|
|
50883
|
+
__info__.version = "17.0.108";
|
|
50884
|
+
__info__.date = "2026-09-10T05:35:45.123Z";
|
|
50885
|
+
__info__.hash = "b2580c5";
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* This file is generated by o-spreadsheet build tools. Do not edit it.
|
|
4
4
|
* @see https://github.com/odoo/o-spreadsheet
|
|
5
|
-
* @version 17.0.
|
|
6
|
-
* @date 2026-
|
|
7
|
-
* @hash
|
|
5
|
+
* @version 17.0.108
|
|
6
|
+
* @date 2026-09-10T05:35:45.123Z
|
|
7
|
+
* @hash b2580c5
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
(function(exports, _odoo_owl) {
|
|
@@ -7225,7 +7225,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
7225
7225
|
//#region src/helpers/ui/paste_interactive.ts
|
|
7226
7226
|
const PasteInteractiveContent = {
|
|
7227
7227
|
wrongPasteSelection: _t("This operation is not allowed with multiple selections."),
|
|
7228
|
-
willRemoveExistingMerge: _t("
|
|
7228
|
+
willRemoveExistingMerge: _t("Cannot perform this action on merged cells. Unmerge the cells and try again."),
|
|
7229
7229
|
wrongFigurePasteOption: _t("Cannot do a special paste of a figure."),
|
|
7230
7230
|
frozenPaneOverlap: _t("This operation is not allowed due to an overlapping frozen pane.")
|
|
7231
7231
|
};
|
|
@@ -43917,8 +43917,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
43917
43917
|
const { end: lastRowEnd, size: lastRowSize } = this.getters.getRowDimensions(this.sheetId, lastRow);
|
|
43918
43918
|
const leftColIndex = this.searchHeaderIndex("COL", lastColEnd - this.viewportWidth, 0);
|
|
43919
43919
|
const leftColSize = this.getters.getColSize(this.sheetId, leftColIndex);
|
|
43920
|
-
const
|
|
43921
|
-
const topRowSize = this.getters.getRowSize(this.sheetId,
|
|
43920
|
+
const topRowIndex = this.searchHeaderIndex("ROW", lastRowEnd - this.viewportHeight, 0);
|
|
43921
|
+
const topRowSize = this.getters.getRowSize(this.sheetId, topRowIndex);
|
|
43922
43922
|
let width = lastColEnd - this.offsetCorrectionX;
|
|
43923
43923
|
if (this.canScrollHorizontally) {
|
|
43924
43924
|
width += Math.max(96, Math.min(leftColSize, this.viewportWidth - lastColSize));
|
|
@@ -44111,7 +44111,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
44111
44111
|
this.left = this.searchHeaderIndex("COL", this.offsetScrollbarX, this.boundaries.left);
|
|
44112
44112
|
this.right = Math.min(this.boundaries.right, this.searchHeaderIndex("COL", this.viewportWidth, this.left));
|
|
44113
44113
|
if (!this.viewportWidth) return;
|
|
44114
|
-
if (this.left === -1)
|
|
44114
|
+
if (this.left === -1) {
|
|
44115
|
+
const colsHeight = this.getters.getColRowOffset("COL", this.boundaries.left, this.boundaries.right);
|
|
44116
|
+
if (0 < colsHeight && colsHeight <= this.offsetScrollbarX) this.left = this.boundaries.right;
|
|
44117
|
+
else this.left = this.boundaries.left;
|
|
44118
|
+
}
|
|
44115
44119
|
if (this.right === -1) this.right = this.boundaries.right;
|
|
44116
44120
|
this.offsetX = this.getters.getColDimensions(sheetId, this.left).start - this.getters.getColDimensions(sheetId, this.boundaries.left).start;
|
|
44117
44121
|
}
|
|
@@ -44122,7 +44126,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
44122
44126
|
this.top = this.searchHeaderIndex("ROW", this.offsetScrollbarY, this.boundaries.top);
|
|
44123
44127
|
this.bottom = Math.min(this.boundaries.bottom, this.searchHeaderIndex("ROW", this.viewportHeight, this.top));
|
|
44124
44128
|
if (!this.viewportHeight) return;
|
|
44125
|
-
if (this.top === -1)
|
|
44129
|
+
if (this.top === -1) {
|
|
44130
|
+
const rowsHeight = this.getters.getColRowOffset("ROW", this.boundaries.top, this.boundaries.bottom);
|
|
44131
|
+
if (0 < rowsHeight && rowsHeight <= this.offsetScrollbarY) this.top = this.boundaries.bottom;
|
|
44132
|
+
else this.top = this.boundaries.top;
|
|
44133
|
+
}
|
|
44126
44134
|
if (this.bottom === -1) this.bottom = this.boundaries.bottom;
|
|
44127
44135
|
this.offsetY = this.getters.getRowDimensions(sheetId, this.top).start - this.getters.getRowDimensions(sheetId, this.boundaries.top).start;
|
|
44128
44136
|
}
|
|
@@ -50910,8 +50918,8 @@ exports.setDefaultSheetViewSize = setDefaultSheetViewSize;
|
|
|
50910
50918
|
exports.setTranslationMethod = setTranslationMethod;
|
|
50911
50919
|
exports.tokenize = tokenize;
|
|
50912
50920
|
|
|
50913
|
-
__info__.version = "17.0.
|
|
50914
|
-
__info__.date = "2026-
|
|
50915
|
-
__info__.hash = "
|
|
50921
|
+
__info__.version = "17.0.108";
|
|
50922
|
+
__info__.date = "2026-09-10T05:35:45.123Z";
|
|
50923
|
+
__info__.hash = "b2580c5";
|
|
50916
50924
|
|
|
50917
50925
|
})(this.o_spreadsheet = this.o_spreadsheet || {}, owl);
|
|
@@ -288,7 +288,7 @@
|
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
290
|
}
|
|
291
|
-
`;var cl=class extends t.Component{static template=`o-spreadsheet-LinkEditor`;static components={Menu:pc};menuItems=sl.getMenuItems();link=(0,t.useState)(this.defaultState);menu=(0,t.useState)({isOpen:!1});linkEditorRef=(0,t.useRef)(`linkEditor`);position=rc(this.linkEditorRef);urlInput=(0,t.useRef)(`urlInput`);setup(){(0,t.onMounted)(()=>this.urlInput.el?.focus())}get defaultState(){let{col:e,row:t}=this.props.cellPosition,n=this.env.model.getters.getActiveSheetId(),r=this.env.model.getters.getEvaluatedCell({sheetId:n,col:e,row:t});return r.link?{url:r.link.url,label:r.formattedValue,isUrlEditable:r.link.isUrlEditable}:{label:r.formattedValue,url:``,isUrlEditable:!0}}get menuPosition(){return{x:this.position.x+320-12-2,y:this.position.y+100}}onSpecialLink(e){let{detail:t}=e,n=$a(t);n&&(this.link.url=n.url,this.link.label=n.label,this.link.isUrlEditable=n.isUrlEditable)}getUrlRepresentation(e){return Za(e,this.env.model.getters)}openMenu(){this.menu.isOpen=!0}removeLink(){this.link.url=``,this.link.isUrlEditable=!0}save(){let{col:e,row:t}=this.props.cellPosition,n=this.env.model.getters.getLocale(),r=this.link.label?Ic(this.link.label,n):this.link.url;this.env.model.dispatch(`UPDATE_CELL`,{col:e,row:t,sheetId:this.env.model.getters.getActiveSheetId(),content:st(r,this.link.url)}),this.props.onClosed?.()}cancel(){this.props.onClosed?.()}onKeyDown(e){switch(e.key){case`Enter`:this.link.url&&this.save(),e.stopPropagation(),e.preventDefault();break;case`Escape`:this.cancel(),e.stopPropagation();break}}};let ll={onOpen:(e,t)=>({isOpen:!0,props:{cellPosition:e},Component:cl,cellCorner:`BottomLeft`})};cl.props={cellPosition:Object,onClosed:{type:Function,optional:!0}};let ul=new H;ul.add(`ErrorToolTip`,Bs).add(`LinkCell`,hc).add(`LinkEditor`,ll).add(`FilterMenu`,Ws);function dl(e){return e=zt(e).replace(`#`,``),e.length===8?e.slice(6)+e.slice(0,6):e}let fl={wrongPasteSelection:y(`This operation is not allowed with multiple selections.`),willRemoveExistingMerge:y(`This operation is not possible due to a merge. Please remove the merges first than try again.`),wrongFigurePasteOption:y(`Cannot do a special paste of a figure.`),frozenPaneOverlap:y(`This operation is not allowed due to an overlapping frozen pane.`)};function pl(e,t){t.isSuccessful||(t.reasons.includes(`WrongPasteSelection`)?e.raiseError(fl.wrongPasteSelection):t.reasons.includes(`WillRemoveExistingMerge`)?e.raiseError(fl.willRemoveExistingMerge):t.reasons.includes(`WrongFigurePasteOption`)?e.raiseError(fl.wrongFigurePasteOption):t.reasons.includes(`FrozenPaneOverlap`)&&e.raiseError(fl.frozenPaneOverlap))}function ml(e,t,n){pl(e,e.model.dispatch(`PASTE`,{target:t,pasteOption:n}))}function hl(e,t,n,r){pl(e,e.model.dispatch(`PASTE_FROM_OS_CLIPBOARD`,{target:t,text:n,pasteOption:r}))}let gl={Errors:{InvalidRange:y(`The range is invalid`),FirstArgMissing:y(`The argument is missing. Please provide a value`),SecondArgMissing:y(`The second argument is missing. Please provide a value`),MinNaN:y(`The minpoint must be a number`),MidNaN:y(`The midpoint must be a number`),MaxNaN:y(`The maxpoint must be a number`),ValueUpperInflectionNaN:y(`The first value must be a number`),ValueLowerInflectionNaN:y(`The second value must be a number`),MinBiggerThanMax:y(`Minimum must be smaller then Maximum`),MinBiggerThanMid:y(`Minimum must be smaller then Midpoint`),MidBiggerThanMax:y(`Midpoint must be smaller then Maximum`),LowerBiggerThanUpper:y(`Lower inflection point must be smaller than upper inflection point`),MinInvalidFormula:y(`Invalid Minpoint formula`),MaxInvalidFormula:y(`Invalid Maxpoint formula`),MidInvalidFormula:y(`Invalid Midpoint formula`),ValueUpperInvalidFormula:y(`Invalid upper inflection point formula`),ValueLowerInvalidFormula:y(`Invalid lower inflection point formula`),EmptyRange:y(`A range needs to be defined`),Unexpected:y(`The rule is invalid for an unknown reason`)},ColorScale:y(`Color scale`),IconSet:y(`Icon set`)},_l={IsEmpty:y(`Is empty`),IsNotEmpty:y(`Is not empty`),ContainsText:y(`Contains`),NotContains:y(`Does not contain`),BeginsWith:y(`Starts with`),EndsWith:y(`Ends with`),Equal:y(`Is equal to`),NotEqual:y(`Is not equal to`),GreaterThan:y(`Is greater than`),GreaterThanOrEqual:y(`Is greater than or equal to`),LessThan:y(`Is less than`),LessThanOrEqual:y(`Is less than or equal to`),Between:y(`Is between`),NotBetween:y(`Is not between`)},vl={Series:y(`Series`),Errors:{Unexpected:y(`The chart definition is invalid for an unknown reason`),InvalidDataSet:y(`The dataset is invalid`),InvalidLabelRange:y(`Labels are invalid`),InvalidScorecardKeyValue:y(`The key value is invalid`),InvalidScorecardBaseline:y(`The baseline value is invalid`),InvalidGaugeDataRange:y(`The data range is invalid`),EmptyGaugeRangeMin:y(`A minimum range limit value is needed`),GaugeRangeMinNaN:y(`The minimum range limit value must be a number`),EmptyGaugeRangeMax:y(`A maximum range limit value is needed`),GaugeRangeMaxNaN:y(`The maximum range limit value must be a number`),GaugeRangeMinBiggerThanRangeMax:y(`Minimum range limit must be smaller than maximum range limit`),GaugeLowerInflectionPointNaN:y(`The lower inflection point value must be a number`),GaugeUpperInflectionPointNaN:y(`The upper inflection point value must be a number`)}},yl={Custom:y(`Custom`)},bl=y(`Merged cells are preventing this operation. Unmerge those cells and try again.`),xl={Errors:{Unexpected:y(`Cannot split the selection for an unknown reason`),NoSplitSeparatorInSelection:y(`There is no match for the selected separator in the selection`),MoreThanOneColumnSelected:y(`Only a selection from a single column can be split`),SplitWillOverwriteContent:y(`Splitting will overwrite existing content`)}},Sl={Errors:{Unexpected:y(`Cannot remove duplicates for an unknown reason`),MoreThanOneRangeSelected:y(`Please select only one range of cells`),EmptyTarget:y(`Please select a range of cells containing values.`),NoColumnsProvided:y(`Please select at latest one column to analyze.`),WillRemoveExistingMerge:fl.willRemoveExistingMerge}},G={DateIs:{today:y(`today`),yesterday:y(`yesterday`),tomorrow:y(`tomorrow`),lastWeek:y(`in the past week`),lastMonth:y(`in the past month`),lastYear:y(`in the past year`)},DateIsBefore:{today:y(`today`),yesterday:y(`yesterday`),tomorrow:y(`tomorrow`),lastWeek:y(`one week ago`),lastMonth:y(`one month ago`),lastYear:y(`one year ago`)},CriterionError:{notEmptyValue:y(`The value must not be empty`),numberValue:y(`The value must be a number`),dateValue:y(`The value must be a date`),validRange:y(`The value must be a valid range`)}};function Cl(e,t){if(t.dataRange){let n=t.labelCell?[B(t.labelCell.zone)]:[],r=pa([B(t.dataRange.zone)],n)[0];if(r===void 0)return[];let i=e.getRangeFromSheetXC(t.dataRange.sheetId,r);return e.getRangeValues(i).map(e=>e===``?void 0:e)}return[]}function wl(e,t){let n=w(0,Math.max(e.length,...t.map(e=>e.data?.length||0))).filter(n=>{let r=e[n],i=t.map(e=>e.data?.[n]);return r||i.some(e=>e===0||!!e)});return{labels:n.map(t=>e[t]||``),dataSetsValues:t.map(e=>({...e,data:n.map(t=>e.data[t])}))}}function Tl(e,t){let n=e=>typeof e==`number`?e:0,r=new Set(e),i={};r.forEach(e=>{i[e]=Array(t.length).fill(0)});for(let r of w(0,e.length)){let a=e[r];for(let e of w(0,t.length))i[a][e]+=n(t[e].data[r])}return{labels:Array.from(r),dataSetsValues:t.map((e,t)=>({...e,data:Array.from(r).map(e=>i[e][t])}))}}function El(e){return e?e.length>20?e.substring(0,20)+`…`:e:``}function Dl(e,t,n,{format:r,locale:i,truncateLabels:a=!0}){let o={responsive:!0,maintainAspectRatio:!1,layout:{padding:{left:20,right:20,top:e.title?10:25,bottom:10}},elements:{line:{fill:!1},point:{hitRadius:15}},animation:!1,plugins:{title:{display:!!e.title,text:y(e.title),color:n,font:{size:22,weight:`normal`}},legend:{onClick:()=>{}},tooltip:{callbacks:{label:function(e){let t=e.dataset?.label||e.label,n=e.parsed.y??e.parsed,a=z(n,{format:!r&&Math.abs(n)>=1e3?`#,##`:r,locale:i});return t?`${t}: ${a}`:a}}}}};return{type:e.type,options:o,data:{labels:a?t.map(El):t,datasets:[]},plugins:[]}}function Ol(e,t,n){if(!t)return;let{sheetId:r,zone:i}=t,a=ba(i).map(t=>e.getEvaluatedCell({sheetId:r,...t}).format);return n&&a.shift(),a.find(e=>e!==void 0)}function kl(e,t,n){let r={values:[],formattedValues:[]};if(n)!n.invalidXc&&!n.invalidSheetName&&(r={formattedValues:e.getRangeFormattedValues(n),values:e.getRangeValues(n).map(e=>String(e))});else if(t.length===1){let n=Cl(e,t[0]).length;for(let e=0;e<n;e++)r.formattedValues.push(``),r.values.push(``)}else t[0]&&(r={formattedValues:w(0,Cl(e,t[0]).length).map(e=>e.toString()),values:r.formattedValues});return r}function Al(e,t){for(let n of t){let t=e.getRangeFormats(n.dataRange).find(e=>e!==void 0&&!_i(e));if(t)return t}}function jl(e,t){let n=[];for(let[r,i]of Object.entries(t)){let t;if(i.labelCell){let n=i.labelCell,a=n?e.getEvaluatedCell({sheetId:n.sheetId,col:n.zone.left,row:n.zone.top}):void 0;t=a&&n?El(a.formattedValue):t=`${vl.Series} ${parseInt(r)+1}`}else t=t=`${vl.Series} ${parseInt(r)+1}`;let a=i.dataRange?Cl(e,i):[];n.push({data:a,label:t})}return n}function Ml(e){return e===0?`origin`:e-1}function Nl(e,t,n){let r=document.createElement(`div`);r.style.width=`${t.width}px`,r.style.height=`${t.height}px`;let i=document.createElement(`canvas`);if(r.append(i),i.setAttribute(`width`,t.width.toString()),i.setAttribute(`height`,t.height.toString()),document.body.append(r),`chartJsConfig`in e){e.chartJsConfig.plugins=[Pl];let t=new window.Chart(i,S(e.chartJsConfig)),n=t.toBase64Image();return t.destroy(),r.remove(),n}else if(n===`scorecard`){ss(gs(t,e),i);let n=i.toDataURL();return r.remove(),n}return``}let Pl={id:`customCanvasBackgroundColor`,beforeDraw:e=>{let{ctx:t}=e;t.save(),t.globalCompositeOperation=`destination-over`,t.fillStyle=`#ffffff`,t.fillRect(0,0,e.width,e.height),t.restore()}};var Fl=class e extends Io{dataSets;labelRange;background;verticalAxisPosition;legendPosition;stacked;aggregated;type=`bar`;dataSetsHaveTitle;constructor(e,t,n){super(e,t,n),this.dataSets=Vo(n,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Fa(n,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.stacked=e.stacked,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle}static transformDefinition(e,t){return Go(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,Yo,Xo)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,stacked:!1,aggregated:!1,legendPosition:`top`,title:e.title||``,type:`bar`,verticalAxisPosition:`left`,labelRange:e.auxiliaryRange||void 0}}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map(e=>this.getters.getRangeString(e.dataRange,this.sheetId)),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}copyForSheetId(t){let n=Ro(this.sheetId,t,this.dataSets),r=zo(this.sheetId,t,this.labelRange);return new e(this.getDefinitionWithSpecificDataSets(n,r,t),t,this.getters)}copyInSheetId(t){return new e(this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,t),t,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,n){return{type:`bar`,dataSetsHaveTitle:e.length?!!e[0].labelCell:!1,background:this.background,dataSets:e.map(e=>this.getters.getRangeString(e.dataRange,n||this.sheetId)),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,n||this.sheetId):void 0,title:this.title,stacked:this.stacked,aggregated:this.aggregated}}getDefinitionForExcel(){let e=this.dataSets.map(e=>Uo(this.getters,e)).filter(e=>e.range!==``&&e.range!==Ie),t=Wo(this.getters,this.labelRange,Zo(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle));return{...this.getDefinition(),backgroundColor:dl(this.background||`#FFFFFF`),fontColor:dl(Jo(this.background)),dataSets:e,labelRange:t}}updateRanges(t){let{dataSets:n,labelRange:r,isStale:i}=Lo(this.getters,t,this.dataSets,this.labelRange);return i?new e(this.getDefinitionWithSpecificDataSets(n,r),this.sheetId,this.getters):this}};function Il(e,t,n){let r=Jo(e.background),i=Dl(e,t,r,n),a={labels:{color:r}};return!e.labelRange&&e.dataSets.length===1||e.legendPosition===`none`?a.display=!1:a.position=e.legendPosition,i.options.plugins.legend={...i.options.plugins?.legend,...a},i.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},i.options.scales={x:{ticks:{padding:5,color:r}},y:{position:e.verticalAxisPosition,beginAtZero:!0,ticks:{color:r,callback:e=>{if(e=Number(e),isNaN(e))return e;let{locale:t,format:r}=n;return z(e,{locale:t,format:!r&&Math.abs(e)>=1e3?`#,##`:r})}}}},e.stacked&&(i.options.scales.x.stacked=!0,i.options.scales.y.stacked=!0),i}function Ll(e,t){let n=kl(t,e.dataSets,e.labelRange).formattedValues,r=jl(t,e.dataSets);Zo(e.labelRange,e.dataSets[0],e.dataSetsHaveTitle)&&n.shift(),{labels:n,dataSetsValues:r}=wl(n,r),e.aggregated&&({labels:n,dataSetsValues:r}=Tl(n,r));let i=Al(t,e.dataSets),a=t.getLocale(),o=Il(e,n,{format:i,locale:a}),s=new qo;for(let{label:e,data:t}of r){let n=s.next(),r={label:e,data:t,borderColor:n,backgroundColor:n};o.data.datasets.push(r)}return{chartJsConfig:o,background:e.background||`#FFFFFF`}}function Rl(e){return e.dataRange&&!Wi.test(e.dataRange)?`InvalidGaugeDataRange`:`Success`}function zl(e,t){return t(t=>t.sectionRule?e(t.sectionRule.rangeMin,`rangeMin`):`Success`,t=>t.sectionRule?e(t.sectionRule.rangeMax,`rangeMax`):`Success`)}function Bl(e,t){return t(t=>t.sectionRule?e(t.sectionRule.lowerInflectionPoint.value,`lowerInflectionPointValue`):`Success`,t=>t.sectionRule?e(t.sectionRule.upperInflectionPoint.value,`upperInflectionPointValue`):`Success`)}function Vl(e){return e.sectionRule&&Number(e.sectionRule.rangeMin)>=Number(e.sectionRule.rangeMax)?`GaugeRangeMinBiggerThanRangeMax`:`Success`}function Hl(e,t){if(e===``)switch(t){case`rangeMin`:return`EmptyGaugeRangeMin`;case`rangeMax`:return`EmptyGaugeRangeMax`}return`Success`}function Ul(e,t){if(isNaN(e))switch(t){case`rangeMin`:return`GaugeRangeMinNaN`;case`rangeMax`:return`GaugeRangeMaxNaN`;case`lowerInflectionPointValue`:return`GaugeLowerInflectionPointNaN`;case`upperInflectionPointValue`:return`GaugeUpperInflectionPointNaN`}return`Success`}var Wl=class e extends Io{dataRange;sectionRule;background;type=`gauge`;constructor(e,t,n){super(e,t,n),this.dataRange=Fa(this.getters,this.sheetId,e.dataRange),this.sectionRule=e.sectionRule,this.background=e.background}static validateChartDefinition(e,t){return e.checkValidations(t,Rl,e.chainValidations(zl(Hl,e.batchValidations),zl(Ul,e.batchValidations),Vl),e.chainValidations(Bl(Ul,e.batchValidations)))}static transformDefinition(e,t){let n;return e.dataRange&&(n=No(Qi(e.dataRange),t)),{...e,dataRange:n?B(n):void 0}}static getDefinitionFromContextCreation(e){return{background:e.background,title:e.title||``,type:`gauge`,dataRange:e.range?e.range[0]:void 0,sectionRule:{colors:{lowerColor:`#cc0000`,middleColor:`#f1c232`,upperColor:`#6aa84f`},rangeMin:`0`,rangeMax:`100`,lowerInflectionPoint:{type:`percentage`,value:`15`},upperInflectionPoint:{type:`percentage`,value:`40`}}}}copyForSheetId(t){let n=zo(this.sheetId,t,this.dataRange);return new e(this.getDefinitionWithSpecificRanges(n,t),t,this.getters)}copyInSheetId(t){return new e(this.getDefinitionWithSpecificRanges(this.dataRange,t),t,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.dataRange)}getDefinitionWithSpecificRanges(e,t){return{background:this.background,sectionRule:this.sectionRule,title:this.title,type:`gauge`,dataRange:e?this.getters.getRangeString(e,t||this.sheetId):void 0}}getDefinitionForExcel(){}getContextCreation(){return{background:this.background,title:this.title,range:this.dataRange?[this.getters.getRangeString(this.dataRange,this.sheetId)]:void 0}}updateRanges(t){let n=Bo(this.dataRange,t);return this.dataRange===n?this:new e(this.getDefinitionWithSpecificRanges(n),this.sheetId,this.getters)}};function Gl(e,t){let n=Dl(e,[],Jo(e.background),{locale:t});return n.options.hover=void 0,n.options.events=[],n.options.layout={padding:{left:30,right:30,top:e.title?10:25,bottom:25}},n.options.needle={width:10,borderColor:`#000000`,backgroundColor:`#000000`},n.options.valueLabel={display:!1,font:{size:30,color:`#FFFFFF`},backgroundColor:`#000000`,borderColor:`#000000`,borderRadius:5,padding:{top:5,right:5,bottom:5,left:5}},n}function Kl(e,t){let n=Gl(e,t.getLocale()),r=e.sectionRule.colors,i=e.sectionRule.lowerInflectionPoint,a=e.sectionRule.upperInflectionPoint,o=Number(i.value),s=Number(a.value),c=Number(e.sectionRule.rangeMin),l=Number(e.sectionRule.rangeMax),u=l-c,d=[];if(i.value!==``){let e=i.type===`number`?o:c+u*o/100;d.push({value:C(e,c,l),color:r.lowerColor})}if(a.value!==``){let e=a.type===`number`?s:c+u*s/100;d.push({value:C(e,c,l),color:r.middleColor})}let f=[],p=[];d.sort((e,t)=>e.value-t.value).map(e=>{f.push(e.value),p.push(e.color)}),f.push(l),p.push(r.upperColor);let m=e.dataRange,h=u/30,g=c-h,_,v=!1;if(m!==void 0){let e=t.getEvaluatedCell({sheetId:m.sheetId,col:m.zone.left,row:m.zone.top});e.type===`number`&&(g=C(e.value,c-h,l+h),_=()=>t.getRangeFormattedValues(m)[0],v=!0)}return n.options.valueLabel.display=v,n.options.valueLabel.formatter=_,n.data.datasets.push({data:f,minValue:Number(e.sectionRule.rangeMin),value:g,backgroundColor:p}),{chartJsConfig:n,background:t.getStyleOfSingleCellChart(e.background,m).background}}let ql={second:1e3,minute:1e3*60,hour:1e3*3600,day:1e3*3600*24,month:1e3*3600*24*30,year:1e3*3600*24*365},Jl={inSeconds:function(e){return Math.floor(e/ql.second)},inMinutes:function(e){return Math.floor(e/ql.minute)},inHours:function(e){return Math.floor(e/ql.hour)},inDays:function(e){return Math.floor(e/ql.day)},inMonths:function(e){return Math.floor(e/ql.month)},inYears:function(e){return Math.floor(e/ql.year)}},Yl=/^((d|dd|m|mm|yyyy|yy|hh|h|ss|a)(-|:|\s|\/))*(d|dd|m|mm|yyyy|yy|hh|h|ss|a)$/i;function Xl(e,t,n){let r=Zl(t),i=$l(e,r,n),a={};return i&&(a[i]=r),{parser:r,displayFormats:a,unit:i??!1,tooltipFormat:r}}function Zl(e){let t=e.indexOf(`h`);return e=t>=0?e.slice(0,t).replace(/m/g,`M`)+e.slice(t):e.replace(/m/g,`M`),e.includes(`a`)||(e=e.replace(/h/g,`H`)),e}function Ql(e){return e.includes(`s`)?`second`:e.includes(`m`)?`minute`:e.includes(`h`)||e.includes(`H`)?`hour`:e.includes(`d`)?`day`:e.includes(`M`)?`month`:`year`}function $l(e,t,n){let r=e.map(e=>yn(e,n)?.jsDate);if(r.some(e=>e===void 0)||e.length<2)return;let i=r.map(e=>e.getTime()),a=Nt(i)-Pt(i),o=Ql(t);return ql.second>=ql[o]&&Jl.inSeconds(a)<180?`second`:ql.minute>=ql[o]&&Jl.inMinutes(a)<180?`minute`:ql.hour>=ql[o]&&Jl.inHours(a)<96?`hour`:ql.day>=ql[o]&&Jl.inDays(a)<90?`day`:ql.month>=ql[o]&&Jl.inMonths(a)<36?`month`:`year`}var eu=class e extends Io{dataSets;labelRange;background;verticalAxisPosition;legendPosition;labelsAsText;stacked;aggregated;type=`line`;dataSetsHaveTitle;cumulative;constructor(e,t,n){super(e,t,n),this.dataSets=Vo(this.getters,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Fa(this.getters,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.labelsAsText=e.labelsAsText,this.stacked=e.stacked,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.cumulative=e.cumulative}static validateChartDefinition(e,t){return e.checkValidations(t,Yo,Xo)}static transformDefinition(e,t){return Go(e,t)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,labelsAsText:!1,legendPosition:`top`,title:e.title||``,type:`line`,verticalAxisPosition:`left`,labelRange:e.auxiliaryRange||void 0,stacked:!1,aggregated:!1,cumulative:!1}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,n){return{type:`line`,dataSetsHaveTitle:e.length?!!e[0].labelCell:!1,background:this.background,dataSets:e.map(e=>this.getters.getRangeString(e.dataRange,n||this.sheetId)),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,n||this.sheetId):void 0,title:this.title,labelsAsText:this.labelsAsText,stacked:this.stacked,aggregated:this.aggregated,cumulative:this.cumulative}}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map(e=>this.getters.getRangeString(e.dataRange,this.sheetId)),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}updateRanges(t){let{dataSets:n,labelRange:r,isStale:i}=Lo(this.getters,t,this.dataSets,this.labelRange);return i?new e(this.getDefinitionWithSpecificDataSets(n,r),this.sheetId,this.getters):this}getDefinitionForExcel(){let e=this.dataSets.map(e=>Uo(this.getters,e)).filter(e=>e.range!==``&&e.range!==Ie),t=Wo(this.getters,this.labelRange,Zo(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle));return{...this.getDefinition(),backgroundColor:dl(this.background||`#FFFFFF`),fontColor:dl(Jo(this.background)),dataSets:e,labelRange:t}}copyForSheetId(t){let n=Ro(this.sheetId,t,this.dataSets),r=zo(this.sheetId,t,this.labelRange);return new e(this.getDefinitionWithSpecificDataSets(n,r,t),t,this.getters)}copyInSheetId(t){return new e(this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,t),t,this.getters)}};function tu(e,t){if(e.length===0||e.every(e=>!e))return{labels:e,dataSetsValues:t};let n=[...e],r=S(t);for(let e=0;e<n.length;e++)if(!n[e]){n[e]=yt(n,e);for(let t of r)t.data[e]=void 0}return{labels:n,dataSetsValues:r}}function nu(e,t){return ou(e,t)||su(e,t)}function ru(e,t){return iu(e,t)&&du()?`time`:au(e,t)?`linear`:`category`}function iu(e,t){return!e.labelsAsText&&ou(e,t)}function au(e,t){return!e.labelsAsText&&su(e,t)}function ou(e,t){if(!e.labelRange||!su(e,t))return!1;let n=Ol(t,e.labelRange,Zo(e.labelRange,e.dataSets[0],e.dataSetsHaveTitle));return!!(n&&Yl.test(n))}function su(e,t){if(!e.labelRange)return!1;let n=t.getRangeValues(e.labelRange);return Zo(e.labelRange,e.dataSets[0],e.dataSetsHaveTitle)&&n.shift(),!(n.some(e=>isNaN(Number(e))&&e)||n.every(e=>!e))}function cu(e,t,n){let r=Jo(e.background),i=Dl(e,t,r,n),a={labels:{color:r,generateLabels(e){let{data:t}=e,n=window.Chart.defaults.plugins.legend.labels.generateLabels(e);for(let[e,r]of n.entries())r.fillStyle=t.datasets[e].borderColor;return n}}};return!e.labelRange&&e.dataSets.length===1||e.legendPosition===`none`?a.display=!1:a.position=e.legendPosition,Object.assign(i.options.plugins.legend||{},a),i.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},i.options.scales={x:{ticks:{padding:5,color:r}},y:{position:e.verticalAxisPosition,beginAtZero:!0,ticks:{color:r,callback:e=>{if(e=Number(e),isNaN(e))return e;let{locale:t,format:r}=n;return z(e,{locale:t,format:!r&&Math.abs(e)>=1e3?`#,##`:r})}}}},e.stacked&&i.options?.scales?.y&&(i.options.scales.y.stacked=!0),i}function lu(e,t){let n=ru(e,t),r=kl(t,e.dataSets,e.labelRange),i=n===`linear`?r.values:r.formattedValues,a=jl(t,e.dataSets),o=Zo(e.labelRange,e.dataSets[0],e.dataSetsHaveTitle);o&&i.shift(),{labels:i,dataSetsValues:a}=wl(i,a),n===`time`&&({labels:i,dataSetsValues:a}=tu(i,a)),e.aggregated&&({labels:i,dataSetsValues:a}=Tl(i,a));let s=t.getLocale(),c=n===`category`,l={format:Al(t,e.dataSets),locale:s,truncateLabels:c},u=cu(e,i,l),d=Ol(t,e.labelRange,o);if(n===`time`){let e={type:`time`,time:Xl(i,d,s)};Object.assign(u.options.scales.x,e),u.options.scales.x.ticks.maxTicksLimit=15}else n===`linear`&&(u.options.scales.x.type=`linear`,u.options.scales.x.ticks.callback=e=>z(e,{format:d,locale:s}),u.options.plugins.tooltip.callbacks.title=e=>z(e[0].parsed.x||e[0].label,{locale:s,format:d}));let f=new qo;for(let[t,{label:r,data:o}]of a.entries()){if(e.cumulative){let e=0;o=o.map(t=>isNaN(t)?t:(e+=parseFloat(t),e))}[`linear`,`time`].includes(n)&&(o=o.map((e,t)=>({x:i[t]||void 0,y:e})));let a=f.next(),s=qt(a);e.stacked&&(s.a=.4);let c=Kt(s),l={label:r,data:o,tension:0,borderColor:a,backgroundColor:c,pointBackgroundColor:a,fill:e.stacked?Ml(t):!1};u.data.datasets.push(l)}return{chartJsConfig:u,background:e.background||`#FFFFFF`}}let uu=!1;function du(){if(!window.Chart)return!1;let e=new window.Chart._adapters._date({})._id===`luxon`;return!e&&!uu&&(uu=!0,console.warn(`'chartjs-adapter-luxon' time adapter is not installed. Time scale axes are disabled.`)),e}var fu=class e extends Io{dataSets;labelRange;background;legendPosition;type=`pie`;aggregated;dataSetsHaveTitle;constructor(e,t,n){super(e,t,n),this.dataSets=Vo(n,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Fa(n,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle}static transformDefinition(e,t){return Go(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,Yo,Xo)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,legendPosition:`top`,title:e.title||``,type:`pie`,labelRange:e.auxiliaryRange||void 0,aggregated:!1}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map(e=>this.getters.getRangeString(e.dataRange,this.sheetId)),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}getDefinitionWithSpecificDataSets(e,t,n){return{type:`pie`,dataSetsHaveTitle:e.length?!!e[0].labelCell:!1,background:this.background,dataSets:e.map(e=>this.getters.getRangeString(e.dataRange,n||this.sheetId)),legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,n||this.sheetId):void 0,title:this.title,aggregated:this.aggregated}}copyForSheetId(t){let n=Ro(this.sheetId,t,this.dataSets),r=zo(this.sheetId,t,this.labelRange);return new e(this.getDefinitionWithSpecificDataSets(n,r,t),t,this.getters)}copyInSheetId(t){return new e(this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,t),t,this.getters)}getDefinitionForExcel(){let e=this.dataSets.map(e=>Uo(this.getters,e)).filter(e=>e.range!==``&&e.range!==Ie),t=Wo(this.getters,this.labelRange,Zo(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle));return{...this.getDefinition(),backgroundColor:dl(this.background||`#FFFFFF`),fontColor:dl(Jo(this.background)),verticalAxisPosition:`left`,dataSets:e,labelRange:t}}updateRanges(t){let{dataSets:n,labelRange:r,isStale:i}=Lo(this.getters,t,this.dataSets,this.labelRange);return i?new e(this.getDefinitionWithSpecificDataSets(n,r),this.sheetId,this.getters):this}};function pu(e,t,n){let r=Jo(e.background),i=Dl(e,t,r,n),a={labels:{color:r}};return!e.labelRange&&e.dataSets.length===1||e.legendPosition===`none`?a.display=!1:a.position=e.legendPosition,Object.assign(i.options.plugins.legend||{},a),i.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},i.options.plugins.tooltip.callbacks.title=function(e){return e[0].dataset.label},i.options.plugins.tooltip.callbacks.label=function(e){let{format:t,locale:r}=n,i=e.dataset.data,a=e.dataIndex,o=hu(i,a),s=e.label||e.dataset.label,c=e.parsed.y??e.parsed,l=z(c,{format:!t&&Math.abs(c)>=1e3?`#,##`:t,locale:r});return s?`${s}: ${l} (${o}%)`:`${l} (${o}%)`},i}function mu(e,t){let n=[],r=Nt(t.map(e=>e.data.length));for(let t=0;t<=r;t++)n.push(e.next());return n}function hu(e,t){let n=e.filter(e=>typeof e==`number`).reduce((e,t)=>e+t,0);return n?(e[t]/n*100).toFixed(2):``}function gu(e,t){let n=kl(t,e.dataSets,e.labelRange).formattedValues,r=jl(t,e.dataSets);Zo(e.labelRange,e.dataSets[0],e.dataSetsHaveTitle)&&n.shift(),{labels:n,dataSetsValues:r}=wl(n,r),e.aggregated&&({labels:n,dataSetsValues:r}=Tl(n,r));let i=Al(t,e.dataSets),a=t.getLocale(),o=pu(e,n,{format:i,locale:a}),s=new qo;for(let{label:t,data:n}of r){let i=mu(s,r),a={label:t,data:n,borderColor:e.background||`#FFFFFF`,backgroundColor:i};o.data.datasets.push(a)}return{chartJsConfig:o,background:e.background||`#FFFFFF`}}let _u=new H;_u.add(`bar`,{match:e=>e===`bar`,createChart:(e,t,n)=>new Fl(e,t,n),getChartRuntime:Ll,validateChartDefinition:(e,t)=>Fl.validateChartDefinition(e,t),transformDefinition:(e,t)=>Fl.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Fl.getDefinitionFromContextCreation(e),name:y(`Bar`),sequence:10}),_u.add(`line`,{match:e=>e===`line`,createChart:(e,t,n)=>new eu(e,t,n),getChartRuntime:lu,validateChartDefinition:(e,t)=>eu.validateChartDefinition(e,t),transformDefinition:(e,t)=>eu.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>eu.getDefinitionFromContextCreation(e),name:y(`Line`),sequence:20}),_u.add(`pie`,{match:e=>e===`pie`,createChart:(e,t,n)=>new fu(e,t,n),getChartRuntime:gu,validateChartDefinition:(e,t)=>fu.validateChartDefinition(e,t),transformDefinition:(e,t)=>fu.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>fu.getDefinitionFromContextCreation(e),name:y(`Pie`),sequence:30}),_u.add(`scorecard`,{match:e=>e===`scorecard`,createChart:(e,t,n)=>new os(e,t,n),getChartRuntime:cs,validateChartDefinition:(e,t)=>os.validateChartDefinition(e,t),transformDefinition:(e,t)=>os.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>os.getDefinitionFromContextCreation(e),name:y(`Scorecard`),sequence:40}),_u.add(`gauge`,{match:e=>e===`gauge`,createChart:(e,t,n)=>new Wl(e,t,n),getChartRuntime:Kl,validateChartDefinition:(e,t)=>Wl.validateChartDefinition(e,t),transformDefinition:(e,t)=>Wl.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Wl.getDefinitionFromContextCreation(e),name:y(`Gauge`),sequence:50});let vu=new H;vu.add(`line`,Fo),vu.add(`bar`,Fo),vu.add(`pie`,Fo),vu.add(`gauge`,Fo),vu.add(`scorecard`,xs);let yu=new H;U`
|
|
291
|
+
`;var cl=class extends t.Component{static template=`o-spreadsheet-LinkEditor`;static components={Menu:pc};menuItems=sl.getMenuItems();link=(0,t.useState)(this.defaultState);menu=(0,t.useState)({isOpen:!1});linkEditorRef=(0,t.useRef)(`linkEditor`);position=rc(this.linkEditorRef);urlInput=(0,t.useRef)(`urlInput`);setup(){(0,t.onMounted)(()=>this.urlInput.el?.focus())}get defaultState(){let{col:e,row:t}=this.props.cellPosition,n=this.env.model.getters.getActiveSheetId(),r=this.env.model.getters.getEvaluatedCell({sheetId:n,col:e,row:t});return r.link?{url:r.link.url,label:r.formattedValue,isUrlEditable:r.link.isUrlEditable}:{label:r.formattedValue,url:``,isUrlEditable:!0}}get menuPosition(){return{x:this.position.x+320-12-2,y:this.position.y+100}}onSpecialLink(e){let{detail:t}=e,n=$a(t);n&&(this.link.url=n.url,this.link.label=n.label,this.link.isUrlEditable=n.isUrlEditable)}getUrlRepresentation(e){return Za(e,this.env.model.getters)}openMenu(){this.menu.isOpen=!0}removeLink(){this.link.url=``,this.link.isUrlEditable=!0}save(){let{col:e,row:t}=this.props.cellPosition,n=this.env.model.getters.getLocale(),r=this.link.label?Ic(this.link.label,n):this.link.url;this.env.model.dispatch(`UPDATE_CELL`,{col:e,row:t,sheetId:this.env.model.getters.getActiveSheetId(),content:st(r,this.link.url)}),this.props.onClosed?.()}cancel(){this.props.onClosed?.()}onKeyDown(e){switch(e.key){case`Enter`:this.link.url&&this.save(),e.stopPropagation(),e.preventDefault();break;case`Escape`:this.cancel(),e.stopPropagation();break}}};let ll={onOpen:(e,t)=>({isOpen:!0,props:{cellPosition:e},Component:cl,cellCorner:`BottomLeft`})};cl.props={cellPosition:Object,onClosed:{type:Function,optional:!0}};let ul=new H;ul.add(`ErrorToolTip`,Bs).add(`LinkCell`,hc).add(`LinkEditor`,ll).add(`FilterMenu`,Ws);function dl(e){return e=zt(e).replace(`#`,``),e.length===8?e.slice(6)+e.slice(0,6):e}let fl={wrongPasteSelection:y(`This operation is not allowed with multiple selections.`),willRemoveExistingMerge:y(`Cannot perform this action on merged cells. Unmerge the cells and try again.`),wrongFigurePasteOption:y(`Cannot do a special paste of a figure.`),frozenPaneOverlap:y(`This operation is not allowed due to an overlapping frozen pane.`)};function pl(e,t){t.isSuccessful||(t.reasons.includes(`WrongPasteSelection`)?e.raiseError(fl.wrongPasteSelection):t.reasons.includes(`WillRemoveExistingMerge`)?e.raiseError(fl.willRemoveExistingMerge):t.reasons.includes(`WrongFigurePasteOption`)?e.raiseError(fl.wrongFigurePasteOption):t.reasons.includes(`FrozenPaneOverlap`)&&e.raiseError(fl.frozenPaneOverlap))}function ml(e,t,n){pl(e,e.model.dispatch(`PASTE`,{target:t,pasteOption:n}))}function hl(e,t,n,r){pl(e,e.model.dispatch(`PASTE_FROM_OS_CLIPBOARD`,{target:t,text:n,pasteOption:r}))}let gl={Errors:{InvalidRange:y(`The range is invalid`),FirstArgMissing:y(`The argument is missing. Please provide a value`),SecondArgMissing:y(`The second argument is missing. Please provide a value`),MinNaN:y(`The minpoint must be a number`),MidNaN:y(`The midpoint must be a number`),MaxNaN:y(`The maxpoint must be a number`),ValueUpperInflectionNaN:y(`The first value must be a number`),ValueLowerInflectionNaN:y(`The second value must be a number`),MinBiggerThanMax:y(`Minimum must be smaller then Maximum`),MinBiggerThanMid:y(`Minimum must be smaller then Midpoint`),MidBiggerThanMax:y(`Midpoint must be smaller then Maximum`),LowerBiggerThanUpper:y(`Lower inflection point must be smaller than upper inflection point`),MinInvalidFormula:y(`Invalid Minpoint formula`),MaxInvalidFormula:y(`Invalid Maxpoint formula`),MidInvalidFormula:y(`Invalid Midpoint formula`),ValueUpperInvalidFormula:y(`Invalid upper inflection point formula`),ValueLowerInvalidFormula:y(`Invalid lower inflection point formula`),EmptyRange:y(`A range needs to be defined`),Unexpected:y(`The rule is invalid for an unknown reason`)},ColorScale:y(`Color scale`),IconSet:y(`Icon set`)},_l={IsEmpty:y(`Is empty`),IsNotEmpty:y(`Is not empty`),ContainsText:y(`Contains`),NotContains:y(`Does not contain`),BeginsWith:y(`Starts with`),EndsWith:y(`Ends with`),Equal:y(`Is equal to`),NotEqual:y(`Is not equal to`),GreaterThan:y(`Is greater than`),GreaterThanOrEqual:y(`Is greater than or equal to`),LessThan:y(`Is less than`),LessThanOrEqual:y(`Is less than or equal to`),Between:y(`Is between`),NotBetween:y(`Is not between`)},vl={Series:y(`Series`),Errors:{Unexpected:y(`The chart definition is invalid for an unknown reason`),InvalidDataSet:y(`The dataset is invalid`),InvalidLabelRange:y(`Labels are invalid`),InvalidScorecardKeyValue:y(`The key value is invalid`),InvalidScorecardBaseline:y(`The baseline value is invalid`),InvalidGaugeDataRange:y(`The data range is invalid`),EmptyGaugeRangeMin:y(`A minimum range limit value is needed`),GaugeRangeMinNaN:y(`The minimum range limit value must be a number`),EmptyGaugeRangeMax:y(`A maximum range limit value is needed`),GaugeRangeMaxNaN:y(`The maximum range limit value must be a number`),GaugeRangeMinBiggerThanRangeMax:y(`Minimum range limit must be smaller than maximum range limit`),GaugeLowerInflectionPointNaN:y(`The lower inflection point value must be a number`),GaugeUpperInflectionPointNaN:y(`The upper inflection point value must be a number`)}},yl={Custom:y(`Custom`)},bl=y(`Merged cells are preventing this operation. Unmerge those cells and try again.`),xl={Errors:{Unexpected:y(`Cannot split the selection for an unknown reason`),NoSplitSeparatorInSelection:y(`There is no match for the selected separator in the selection`),MoreThanOneColumnSelected:y(`Only a selection from a single column can be split`),SplitWillOverwriteContent:y(`Splitting will overwrite existing content`)}},Sl={Errors:{Unexpected:y(`Cannot remove duplicates for an unknown reason`),MoreThanOneRangeSelected:y(`Please select only one range of cells`),EmptyTarget:y(`Please select a range of cells containing values.`),NoColumnsProvided:y(`Please select at latest one column to analyze.`),WillRemoveExistingMerge:fl.willRemoveExistingMerge}},G={DateIs:{today:y(`today`),yesterday:y(`yesterday`),tomorrow:y(`tomorrow`),lastWeek:y(`in the past week`),lastMonth:y(`in the past month`),lastYear:y(`in the past year`)},DateIsBefore:{today:y(`today`),yesterday:y(`yesterday`),tomorrow:y(`tomorrow`),lastWeek:y(`one week ago`),lastMonth:y(`one month ago`),lastYear:y(`one year ago`)},CriterionError:{notEmptyValue:y(`The value must not be empty`),numberValue:y(`The value must be a number`),dateValue:y(`The value must be a date`),validRange:y(`The value must be a valid range`)}};function Cl(e,t){if(t.dataRange){let n=t.labelCell?[B(t.labelCell.zone)]:[],r=pa([B(t.dataRange.zone)],n)[0];if(r===void 0)return[];let i=e.getRangeFromSheetXC(t.dataRange.sheetId,r);return e.getRangeValues(i).map(e=>e===``?void 0:e)}return[]}function wl(e,t){let n=w(0,Math.max(e.length,...t.map(e=>e.data?.length||0))).filter(n=>{let r=e[n],i=t.map(e=>e.data?.[n]);return r||i.some(e=>e===0||!!e)});return{labels:n.map(t=>e[t]||``),dataSetsValues:t.map(e=>({...e,data:n.map(t=>e.data[t])}))}}function Tl(e,t){let n=e=>typeof e==`number`?e:0,r=new Set(e),i={};r.forEach(e=>{i[e]=Array(t.length).fill(0)});for(let r of w(0,e.length)){let a=e[r];for(let e of w(0,t.length))i[a][e]+=n(t[e].data[r])}return{labels:Array.from(r),dataSetsValues:t.map((e,t)=>({...e,data:Array.from(r).map(e=>i[e][t])}))}}function El(e){return e?e.length>20?e.substring(0,20)+`…`:e:``}function Dl(e,t,n,{format:r,locale:i,truncateLabels:a=!0}){let o={responsive:!0,maintainAspectRatio:!1,layout:{padding:{left:20,right:20,top:e.title?10:25,bottom:10}},elements:{line:{fill:!1},point:{hitRadius:15}},animation:!1,plugins:{title:{display:!!e.title,text:y(e.title),color:n,font:{size:22,weight:`normal`}},legend:{onClick:()=>{}},tooltip:{callbacks:{label:function(e){let t=e.dataset?.label||e.label,n=e.parsed.y??e.parsed,a=z(n,{format:!r&&Math.abs(n)>=1e3?`#,##`:r,locale:i});return t?`${t}: ${a}`:a}}}}};return{type:e.type,options:o,data:{labels:a?t.map(El):t,datasets:[]},plugins:[]}}function Ol(e,t,n){if(!t)return;let{sheetId:r,zone:i}=t,a=ba(i).map(t=>e.getEvaluatedCell({sheetId:r,...t}).format);return n&&a.shift(),a.find(e=>e!==void 0)}function kl(e,t,n){let r={values:[],formattedValues:[]};if(n)!n.invalidXc&&!n.invalidSheetName&&(r={formattedValues:e.getRangeFormattedValues(n),values:e.getRangeValues(n).map(e=>String(e))});else if(t.length===1){let n=Cl(e,t[0]).length;for(let e=0;e<n;e++)r.formattedValues.push(``),r.values.push(``)}else t[0]&&(r={formattedValues:w(0,Cl(e,t[0]).length).map(e=>e.toString()),values:r.formattedValues});return r}function Al(e,t){for(let n of t){let t=e.getRangeFormats(n.dataRange).find(e=>e!==void 0&&!_i(e));if(t)return t}}function jl(e,t){let n=[];for(let[r,i]of Object.entries(t)){let t;if(i.labelCell){let n=i.labelCell,a=n?e.getEvaluatedCell({sheetId:n.sheetId,col:n.zone.left,row:n.zone.top}):void 0;t=a&&n?El(a.formattedValue):t=`${vl.Series} ${parseInt(r)+1}`}else t=t=`${vl.Series} ${parseInt(r)+1}`;let a=i.dataRange?Cl(e,i):[];n.push({data:a,label:t})}return n}function Ml(e){return e===0?`origin`:e-1}function Nl(e,t,n){let r=document.createElement(`div`);r.style.width=`${t.width}px`,r.style.height=`${t.height}px`;let i=document.createElement(`canvas`);if(r.append(i),i.setAttribute(`width`,t.width.toString()),i.setAttribute(`height`,t.height.toString()),document.body.append(r),`chartJsConfig`in e){e.chartJsConfig.plugins=[Pl];let t=new window.Chart(i,S(e.chartJsConfig)),n=t.toBase64Image();return t.destroy(),r.remove(),n}else if(n===`scorecard`){ss(gs(t,e),i);let n=i.toDataURL();return r.remove(),n}return``}let Pl={id:`customCanvasBackgroundColor`,beforeDraw:e=>{let{ctx:t}=e;t.save(),t.globalCompositeOperation=`destination-over`,t.fillStyle=`#ffffff`,t.fillRect(0,0,e.width,e.height),t.restore()}};var Fl=class e extends Io{dataSets;labelRange;background;verticalAxisPosition;legendPosition;stacked;aggregated;type=`bar`;dataSetsHaveTitle;constructor(e,t,n){super(e,t,n),this.dataSets=Vo(n,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Fa(n,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.stacked=e.stacked,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle}static transformDefinition(e,t){return Go(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,Yo,Xo)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,stacked:!1,aggregated:!1,legendPosition:`top`,title:e.title||``,type:`bar`,verticalAxisPosition:`left`,labelRange:e.auxiliaryRange||void 0}}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map(e=>this.getters.getRangeString(e.dataRange,this.sheetId)),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}copyForSheetId(t){let n=Ro(this.sheetId,t,this.dataSets),r=zo(this.sheetId,t,this.labelRange);return new e(this.getDefinitionWithSpecificDataSets(n,r,t),t,this.getters)}copyInSheetId(t){return new e(this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,t),t,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,n){return{type:`bar`,dataSetsHaveTitle:e.length?!!e[0].labelCell:!1,background:this.background,dataSets:e.map(e=>this.getters.getRangeString(e.dataRange,n||this.sheetId)),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,n||this.sheetId):void 0,title:this.title,stacked:this.stacked,aggregated:this.aggregated}}getDefinitionForExcel(){let e=this.dataSets.map(e=>Uo(this.getters,e)).filter(e=>e.range!==``&&e.range!==Ie),t=Wo(this.getters,this.labelRange,Zo(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle));return{...this.getDefinition(),backgroundColor:dl(this.background||`#FFFFFF`),fontColor:dl(Jo(this.background)),dataSets:e,labelRange:t}}updateRanges(t){let{dataSets:n,labelRange:r,isStale:i}=Lo(this.getters,t,this.dataSets,this.labelRange);return i?new e(this.getDefinitionWithSpecificDataSets(n,r),this.sheetId,this.getters):this}};function Il(e,t,n){let r=Jo(e.background),i=Dl(e,t,r,n),a={labels:{color:r}};return!e.labelRange&&e.dataSets.length===1||e.legendPosition===`none`?a.display=!1:a.position=e.legendPosition,i.options.plugins.legend={...i.options.plugins?.legend,...a},i.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},i.options.scales={x:{ticks:{padding:5,color:r}},y:{position:e.verticalAxisPosition,beginAtZero:!0,ticks:{color:r,callback:e=>{if(e=Number(e),isNaN(e))return e;let{locale:t,format:r}=n;return z(e,{locale:t,format:!r&&Math.abs(e)>=1e3?`#,##`:r})}}}},e.stacked&&(i.options.scales.x.stacked=!0,i.options.scales.y.stacked=!0),i}function Ll(e,t){let n=kl(t,e.dataSets,e.labelRange).formattedValues,r=jl(t,e.dataSets);Zo(e.labelRange,e.dataSets[0],e.dataSetsHaveTitle)&&n.shift(),{labels:n,dataSetsValues:r}=wl(n,r),e.aggregated&&({labels:n,dataSetsValues:r}=Tl(n,r));let i=Al(t,e.dataSets),a=t.getLocale(),o=Il(e,n,{format:i,locale:a}),s=new qo;for(let{label:e,data:t}of r){let n=s.next(),r={label:e,data:t,borderColor:n,backgroundColor:n};o.data.datasets.push(r)}return{chartJsConfig:o,background:e.background||`#FFFFFF`}}function Rl(e){return e.dataRange&&!Wi.test(e.dataRange)?`InvalidGaugeDataRange`:`Success`}function zl(e,t){return t(t=>t.sectionRule?e(t.sectionRule.rangeMin,`rangeMin`):`Success`,t=>t.sectionRule?e(t.sectionRule.rangeMax,`rangeMax`):`Success`)}function Bl(e,t){return t(t=>t.sectionRule?e(t.sectionRule.lowerInflectionPoint.value,`lowerInflectionPointValue`):`Success`,t=>t.sectionRule?e(t.sectionRule.upperInflectionPoint.value,`upperInflectionPointValue`):`Success`)}function Vl(e){return e.sectionRule&&Number(e.sectionRule.rangeMin)>=Number(e.sectionRule.rangeMax)?`GaugeRangeMinBiggerThanRangeMax`:`Success`}function Hl(e,t){if(e===``)switch(t){case`rangeMin`:return`EmptyGaugeRangeMin`;case`rangeMax`:return`EmptyGaugeRangeMax`}return`Success`}function Ul(e,t){if(isNaN(e))switch(t){case`rangeMin`:return`GaugeRangeMinNaN`;case`rangeMax`:return`GaugeRangeMaxNaN`;case`lowerInflectionPointValue`:return`GaugeLowerInflectionPointNaN`;case`upperInflectionPointValue`:return`GaugeUpperInflectionPointNaN`}return`Success`}var Wl=class e extends Io{dataRange;sectionRule;background;type=`gauge`;constructor(e,t,n){super(e,t,n),this.dataRange=Fa(this.getters,this.sheetId,e.dataRange),this.sectionRule=e.sectionRule,this.background=e.background}static validateChartDefinition(e,t){return e.checkValidations(t,Rl,e.chainValidations(zl(Hl,e.batchValidations),zl(Ul,e.batchValidations),Vl),e.chainValidations(Bl(Ul,e.batchValidations)))}static transformDefinition(e,t){let n;return e.dataRange&&(n=No(Qi(e.dataRange),t)),{...e,dataRange:n?B(n):void 0}}static getDefinitionFromContextCreation(e){return{background:e.background,title:e.title||``,type:`gauge`,dataRange:e.range?e.range[0]:void 0,sectionRule:{colors:{lowerColor:`#cc0000`,middleColor:`#f1c232`,upperColor:`#6aa84f`},rangeMin:`0`,rangeMax:`100`,lowerInflectionPoint:{type:`percentage`,value:`15`},upperInflectionPoint:{type:`percentage`,value:`40`}}}}copyForSheetId(t){let n=zo(this.sheetId,t,this.dataRange);return new e(this.getDefinitionWithSpecificRanges(n,t),t,this.getters)}copyInSheetId(t){return new e(this.getDefinitionWithSpecificRanges(this.dataRange,t),t,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.dataRange)}getDefinitionWithSpecificRanges(e,t){return{background:this.background,sectionRule:this.sectionRule,title:this.title,type:`gauge`,dataRange:e?this.getters.getRangeString(e,t||this.sheetId):void 0}}getDefinitionForExcel(){}getContextCreation(){return{background:this.background,title:this.title,range:this.dataRange?[this.getters.getRangeString(this.dataRange,this.sheetId)]:void 0}}updateRanges(t){let n=Bo(this.dataRange,t);return this.dataRange===n?this:new e(this.getDefinitionWithSpecificRanges(n),this.sheetId,this.getters)}};function Gl(e,t){let n=Dl(e,[],Jo(e.background),{locale:t});return n.options.hover=void 0,n.options.events=[],n.options.layout={padding:{left:30,right:30,top:e.title?10:25,bottom:25}},n.options.needle={width:10,borderColor:`#000000`,backgroundColor:`#000000`},n.options.valueLabel={display:!1,font:{size:30,color:`#FFFFFF`},backgroundColor:`#000000`,borderColor:`#000000`,borderRadius:5,padding:{top:5,right:5,bottom:5,left:5}},n}function Kl(e,t){let n=Gl(e,t.getLocale()),r=e.sectionRule.colors,i=e.sectionRule.lowerInflectionPoint,a=e.sectionRule.upperInflectionPoint,o=Number(i.value),s=Number(a.value),c=Number(e.sectionRule.rangeMin),l=Number(e.sectionRule.rangeMax),u=l-c,d=[];if(i.value!==``){let e=i.type===`number`?o:c+u*o/100;d.push({value:C(e,c,l),color:r.lowerColor})}if(a.value!==``){let e=a.type===`number`?s:c+u*s/100;d.push({value:C(e,c,l),color:r.middleColor})}let f=[],p=[];d.sort((e,t)=>e.value-t.value).map(e=>{f.push(e.value),p.push(e.color)}),f.push(l),p.push(r.upperColor);let m=e.dataRange,h=u/30,g=c-h,_,v=!1;if(m!==void 0){let e=t.getEvaluatedCell({sheetId:m.sheetId,col:m.zone.left,row:m.zone.top});e.type===`number`&&(g=C(e.value,c-h,l+h),_=()=>t.getRangeFormattedValues(m)[0],v=!0)}return n.options.valueLabel.display=v,n.options.valueLabel.formatter=_,n.data.datasets.push({data:f,minValue:Number(e.sectionRule.rangeMin),value:g,backgroundColor:p}),{chartJsConfig:n,background:t.getStyleOfSingleCellChart(e.background,m).background}}let ql={second:1e3,minute:1e3*60,hour:1e3*3600,day:1e3*3600*24,month:1e3*3600*24*30,year:1e3*3600*24*365},Jl={inSeconds:function(e){return Math.floor(e/ql.second)},inMinutes:function(e){return Math.floor(e/ql.minute)},inHours:function(e){return Math.floor(e/ql.hour)},inDays:function(e){return Math.floor(e/ql.day)},inMonths:function(e){return Math.floor(e/ql.month)},inYears:function(e){return Math.floor(e/ql.year)}},Yl=/^((d|dd|m|mm|yyyy|yy|hh|h|ss|a)(-|:|\s|\/))*(d|dd|m|mm|yyyy|yy|hh|h|ss|a)$/i;function Xl(e,t,n){let r=Zl(t),i=$l(e,r,n),a={};return i&&(a[i]=r),{parser:r,displayFormats:a,unit:i??!1,tooltipFormat:r}}function Zl(e){let t=e.indexOf(`h`);return e=t>=0?e.slice(0,t).replace(/m/g,`M`)+e.slice(t):e.replace(/m/g,`M`),e.includes(`a`)||(e=e.replace(/h/g,`H`)),e}function Ql(e){return e.includes(`s`)?`second`:e.includes(`m`)?`minute`:e.includes(`h`)||e.includes(`H`)?`hour`:e.includes(`d`)?`day`:e.includes(`M`)?`month`:`year`}function $l(e,t,n){let r=e.map(e=>yn(e,n)?.jsDate);if(r.some(e=>e===void 0)||e.length<2)return;let i=r.map(e=>e.getTime()),a=Nt(i)-Pt(i),o=Ql(t);return ql.second>=ql[o]&&Jl.inSeconds(a)<180?`second`:ql.minute>=ql[o]&&Jl.inMinutes(a)<180?`minute`:ql.hour>=ql[o]&&Jl.inHours(a)<96?`hour`:ql.day>=ql[o]&&Jl.inDays(a)<90?`day`:ql.month>=ql[o]&&Jl.inMonths(a)<36?`month`:`year`}var eu=class e extends Io{dataSets;labelRange;background;verticalAxisPosition;legendPosition;labelsAsText;stacked;aggregated;type=`line`;dataSetsHaveTitle;cumulative;constructor(e,t,n){super(e,t,n),this.dataSets=Vo(this.getters,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Fa(this.getters,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.labelsAsText=e.labelsAsText,this.stacked=e.stacked,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.cumulative=e.cumulative}static validateChartDefinition(e,t){return e.checkValidations(t,Yo,Xo)}static transformDefinition(e,t){return Go(e,t)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,labelsAsText:!1,legendPosition:`top`,title:e.title||``,type:`line`,verticalAxisPosition:`left`,labelRange:e.auxiliaryRange||void 0,stacked:!1,aggregated:!1,cumulative:!1}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,n){return{type:`line`,dataSetsHaveTitle:e.length?!!e[0].labelCell:!1,background:this.background,dataSets:e.map(e=>this.getters.getRangeString(e.dataRange,n||this.sheetId)),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,n||this.sheetId):void 0,title:this.title,labelsAsText:this.labelsAsText,stacked:this.stacked,aggregated:this.aggregated,cumulative:this.cumulative}}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map(e=>this.getters.getRangeString(e.dataRange,this.sheetId)),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}updateRanges(t){let{dataSets:n,labelRange:r,isStale:i}=Lo(this.getters,t,this.dataSets,this.labelRange);return i?new e(this.getDefinitionWithSpecificDataSets(n,r),this.sheetId,this.getters):this}getDefinitionForExcel(){let e=this.dataSets.map(e=>Uo(this.getters,e)).filter(e=>e.range!==``&&e.range!==Ie),t=Wo(this.getters,this.labelRange,Zo(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle));return{...this.getDefinition(),backgroundColor:dl(this.background||`#FFFFFF`),fontColor:dl(Jo(this.background)),dataSets:e,labelRange:t}}copyForSheetId(t){let n=Ro(this.sheetId,t,this.dataSets),r=zo(this.sheetId,t,this.labelRange);return new e(this.getDefinitionWithSpecificDataSets(n,r,t),t,this.getters)}copyInSheetId(t){return new e(this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,t),t,this.getters)}};function tu(e,t){if(e.length===0||e.every(e=>!e))return{labels:e,dataSetsValues:t};let n=[...e],r=S(t);for(let e=0;e<n.length;e++)if(!n[e]){n[e]=yt(n,e);for(let t of r)t.data[e]=void 0}return{labels:n,dataSetsValues:r}}function nu(e,t){return ou(e,t)||su(e,t)}function ru(e,t){return iu(e,t)&&du()?`time`:au(e,t)?`linear`:`category`}function iu(e,t){return!e.labelsAsText&&ou(e,t)}function au(e,t){return!e.labelsAsText&&su(e,t)}function ou(e,t){if(!e.labelRange||!su(e,t))return!1;let n=Ol(t,e.labelRange,Zo(e.labelRange,e.dataSets[0],e.dataSetsHaveTitle));return!!(n&&Yl.test(n))}function su(e,t){if(!e.labelRange)return!1;let n=t.getRangeValues(e.labelRange);return Zo(e.labelRange,e.dataSets[0],e.dataSetsHaveTitle)&&n.shift(),!(n.some(e=>isNaN(Number(e))&&e)||n.every(e=>!e))}function cu(e,t,n){let r=Jo(e.background),i=Dl(e,t,r,n),a={labels:{color:r,generateLabels(e){let{data:t}=e,n=window.Chart.defaults.plugins.legend.labels.generateLabels(e);for(let[e,r]of n.entries())r.fillStyle=t.datasets[e].borderColor;return n}}};return!e.labelRange&&e.dataSets.length===1||e.legendPosition===`none`?a.display=!1:a.position=e.legendPosition,Object.assign(i.options.plugins.legend||{},a),i.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},i.options.scales={x:{ticks:{padding:5,color:r}},y:{position:e.verticalAxisPosition,beginAtZero:!0,ticks:{color:r,callback:e=>{if(e=Number(e),isNaN(e))return e;let{locale:t,format:r}=n;return z(e,{locale:t,format:!r&&Math.abs(e)>=1e3?`#,##`:r})}}}},e.stacked&&i.options?.scales?.y&&(i.options.scales.y.stacked=!0),i}function lu(e,t){let n=ru(e,t),r=kl(t,e.dataSets,e.labelRange),i=n===`linear`?r.values:r.formattedValues,a=jl(t,e.dataSets),o=Zo(e.labelRange,e.dataSets[0],e.dataSetsHaveTitle);o&&i.shift(),{labels:i,dataSetsValues:a}=wl(i,a),n===`time`&&({labels:i,dataSetsValues:a}=tu(i,a)),e.aggregated&&({labels:i,dataSetsValues:a}=Tl(i,a));let s=t.getLocale(),c=n===`category`,l={format:Al(t,e.dataSets),locale:s,truncateLabels:c},u=cu(e,i,l),d=Ol(t,e.labelRange,o);if(n===`time`){let e={type:`time`,time:Xl(i,d,s)};Object.assign(u.options.scales.x,e),u.options.scales.x.ticks.maxTicksLimit=15}else n===`linear`&&(u.options.scales.x.type=`linear`,u.options.scales.x.ticks.callback=e=>z(e,{format:d,locale:s}),u.options.plugins.tooltip.callbacks.title=e=>z(e[0].parsed.x||e[0].label,{locale:s,format:d}));let f=new qo;for(let[t,{label:r,data:o}]of a.entries()){if(e.cumulative){let e=0;o=o.map(t=>isNaN(t)?t:(e+=parseFloat(t),e))}[`linear`,`time`].includes(n)&&(o=o.map((e,t)=>({x:i[t]||void 0,y:e})));let a=f.next(),s=qt(a);e.stacked&&(s.a=.4);let c=Kt(s),l={label:r,data:o,tension:0,borderColor:a,backgroundColor:c,pointBackgroundColor:a,fill:e.stacked?Ml(t):!1};u.data.datasets.push(l)}return{chartJsConfig:u,background:e.background||`#FFFFFF`}}let uu=!1;function du(){if(!window.Chart)return!1;let e=new window.Chart._adapters._date({})._id===`luxon`;return!e&&!uu&&(uu=!0,console.warn(`'chartjs-adapter-luxon' time adapter is not installed. Time scale axes are disabled.`)),e}var fu=class e extends Io{dataSets;labelRange;background;legendPosition;type=`pie`;aggregated;dataSetsHaveTitle;constructor(e,t,n){super(e,t,n),this.dataSets=Vo(n,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Fa(n,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle}static transformDefinition(e,t){return Go(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,Yo,Xo)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,legendPosition:`top`,title:e.title||``,type:`pie`,labelRange:e.auxiliaryRange||void 0,aggregated:!1}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map(e=>this.getters.getRangeString(e.dataRange,this.sheetId)),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}getDefinitionWithSpecificDataSets(e,t,n){return{type:`pie`,dataSetsHaveTitle:e.length?!!e[0].labelCell:!1,background:this.background,dataSets:e.map(e=>this.getters.getRangeString(e.dataRange,n||this.sheetId)),legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,n||this.sheetId):void 0,title:this.title,aggregated:this.aggregated}}copyForSheetId(t){let n=Ro(this.sheetId,t,this.dataSets),r=zo(this.sheetId,t,this.labelRange);return new e(this.getDefinitionWithSpecificDataSets(n,r,t),t,this.getters)}copyInSheetId(t){return new e(this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,t),t,this.getters)}getDefinitionForExcel(){let e=this.dataSets.map(e=>Uo(this.getters,e)).filter(e=>e.range!==``&&e.range!==Ie),t=Wo(this.getters,this.labelRange,Zo(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle));return{...this.getDefinition(),backgroundColor:dl(this.background||`#FFFFFF`),fontColor:dl(Jo(this.background)),verticalAxisPosition:`left`,dataSets:e,labelRange:t}}updateRanges(t){let{dataSets:n,labelRange:r,isStale:i}=Lo(this.getters,t,this.dataSets,this.labelRange);return i?new e(this.getDefinitionWithSpecificDataSets(n,r),this.sheetId,this.getters):this}};function pu(e,t,n){let r=Jo(e.background),i=Dl(e,t,r,n),a={labels:{color:r}};return!e.labelRange&&e.dataSets.length===1||e.legendPosition===`none`?a.display=!1:a.position=e.legendPosition,Object.assign(i.options.plugins.legend||{},a),i.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},i.options.plugins.tooltip.callbacks.title=function(e){return e[0].dataset.label},i.options.plugins.tooltip.callbacks.label=function(e){let{format:t,locale:r}=n,i=e.dataset.data,a=e.dataIndex,o=hu(i,a),s=e.label||e.dataset.label,c=e.parsed.y??e.parsed,l=z(c,{format:!t&&Math.abs(c)>=1e3?`#,##`:t,locale:r});return s?`${s}: ${l} (${o}%)`:`${l} (${o}%)`},i}function mu(e,t){let n=[],r=Nt(t.map(e=>e.data.length));for(let t=0;t<=r;t++)n.push(e.next());return n}function hu(e,t){let n=e.filter(e=>typeof e==`number`).reduce((e,t)=>e+t,0);return n?(e[t]/n*100).toFixed(2):``}function gu(e,t){let n=kl(t,e.dataSets,e.labelRange).formattedValues,r=jl(t,e.dataSets);Zo(e.labelRange,e.dataSets[0],e.dataSetsHaveTitle)&&n.shift(),{labels:n,dataSetsValues:r}=wl(n,r),e.aggregated&&({labels:n,dataSetsValues:r}=Tl(n,r));let i=Al(t,e.dataSets),a=t.getLocale(),o=pu(e,n,{format:i,locale:a}),s=new qo;for(let{label:t,data:n}of r){let i=mu(s,r),a={label:t,data:n,borderColor:e.background||`#FFFFFF`,backgroundColor:i};o.data.datasets.push(a)}return{chartJsConfig:o,background:e.background||`#FFFFFF`}}let _u=new H;_u.add(`bar`,{match:e=>e===`bar`,createChart:(e,t,n)=>new Fl(e,t,n),getChartRuntime:Ll,validateChartDefinition:(e,t)=>Fl.validateChartDefinition(e,t),transformDefinition:(e,t)=>Fl.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Fl.getDefinitionFromContextCreation(e),name:y(`Bar`),sequence:10}),_u.add(`line`,{match:e=>e===`line`,createChart:(e,t,n)=>new eu(e,t,n),getChartRuntime:lu,validateChartDefinition:(e,t)=>eu.validateChartDefinition(e,t),transformDefinition:(e,t)=>eu.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>eu.getDefinitionFromContextCreation(e),name:y(`Line`),sequence:20}),_u.add(`pie`,{match:e=>e===`pie`,createChart:(e,t,n)=>new fu(e,t,n),getChartRuntime:gu,validateChartDefinition:(e,t)=>fu.validateChartDefinition(e,t),transformDefinition:(e,t)=>fu.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>fu.getDefinitionFromContextCreation(e),name:y(`Pie`),sequence:30}),_u.add(`scorecard`,{match:e=>e===`scorecard`,createChart:(e,t,n)=>new os(e,t,n),getChartRuntime:cs,validateChartDefinition:(e,t)=>os.validateChartDefinition(e,t),transformDefinition:(e,t)=>os.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>os.getDefinitionFromContextCreation(e),name:y(`Scorecard`),sequence:40}),_u.add(`gauge`,{match:e=>e===`gauge`,createChart:(e,t,n)=>new Wl(e,t,n),getChartRuntime:Kl,validateChartDefinition:(e,t)=>Wl.validateChartDefinition(e,t),transformDefinition:(e,t)=>Wl.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Wl.getDefinitionFromContextCreation(e),name:y(`Gauge`),sequence:50});let vu=new H;vu.add(`line`,Fo),vu.add(`bar`,Fo),vu.add(`pie`,Fo),vu.add(`gauge`,Fo),vu.add(`scorecard`,xs);let yu=new H;U`
|
|
292
292
|
.o-chart-container {
|
|
293
293
|
width: 100%;
|
|
294
294
|
height: 100%;
|
|
@@ -1477,7 +1477,7 @@
|
|
|
1477
1477
|
%s unique rows remain.`,e.toString(),t.toString()),sticky:!1})}checkSingleRangeSelected(){return this.getters.getSelectedZones().length===1?`Success`:`MoreThanOneRangeSelected`}checkNoMergeInZone(){let e=this.getters.getActiveSheetId(),t=this.getters.getSelectedZone();return this.getters.getMergesInZone(e,t).length>0?`WillRemoveExistingMerge`:`Success`}checkRangeContainsValues(e){let t=this.getters.getActiveSheetId(),n=this.getters.getSelectedZone();return e.hasHeader&&(n.top+=1),this.getters.getEvaluatedCellsInZone(t,n).every(e=>e.type===`empty`)?`EmptyTarget`:`Success`}checkNoColumnProvided(e){return e.columns.length===0?`NoColumnsProvided`:`Success`}checkColumnsIncludedInZone(e){let t=this.getters.getSelectedZone();return e.columns.some(e=>e<t.left||e>t.right)?`ColumnsNotIncludedInZone`:`Success`}checkColumnsAreUnique(e){return e.columns.length===new Set(e.columns).size?`Success`:`DuplicatesColumnsSelected`}trimWhitespace(){let e=this.getters.getSelectedZones(),t=this.getters.getActiveSheetId(),n=0;for(let{col:r,row:i}of e.map(ba).flat()){let e=this.getters.getCell({col:r,row:i,sheetId:t});if(!e)continue;let a=jt(e.content);a!==e.content&&(n+=1,this.dispatch(`UPDATE_CELL`,{sheetId:t,col:r,row:i,content:a}))}let r=n?y(`Trimmed whitespace from %s cells.`,n):y(`No selected cells had whitespace trimmed.`);this.ui.notifyUI({type:`info`,text:r,sticky:!1})}},_A=class extends Q{static layers=[3];static getters=[`getSearchMatches`,`getCurrentSelectedMatchIndex`];searchMatches=[];selectedMatchIndex=null;currentSearchRegex=null;searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1};toSearch=``;isSearchDirty=!1;handle(e){switch(e.type){case`UPDATE_SEARCH`:this.updateSearch(e.toSearch,e.searchOptions);break;case`CLEAR_SEARCH`:this.clearSearch();break;case`SELECT_SEARCH_PREVIOUS_MATCH`:this.selectNextCell(-1);break;case`SELECT_SEARCH_NEXT_MATCH`:this.selectNextCell(1);break;case`REPLACE_SEARCH`:this.replace(e.replaceWith);break;case`REPLACE_ALL_SEARCH`:this.replaceAll(e.replaceWith);break;case`UNDO`:case`REDO`:case`REMOVE_FILTER_TABLE`:case`UPDATE_FILTER`:case`REMOVE_COLUMNS_ROWS`:case`HIDE_COLUMNS_ROWS`:case`UNHIDE_COLUMNS_ROWS`:case`ADD_COLUMNS_ROWS`:case`EVALUATE_CELLS`:case`UPDATE_CELL`:this.isSearchDirty=!0;break;case`ACTIVATE_SHEET`:this.refreshSearch();break}}finalize(){this.isSearchDirty&&=(this.refreshSearch(),!1)}getSearchMatches(){return this.searchMatches}getCurrentSelectedMatchIndex(){return this.selectedMatchIndex}updateSearch(e,t){this.searchOptions=t,e!==this.toSearch&&(this.selectedMatchIndex=null),this.toSearch=e,this.updateRegex(),this.refreshSearch()}refreshSearch(){let e=this.findMatches();this.searchMatches=e,this.selectNextCell(0)}updateRegex(){let e=Xe(this.toSearch),t=this.searchOptions.matchCase?``:`i`;this.searchOptions.exactMatch&&(e=`^${e}$`),this.currentSearchRegex=RegExp(e,t)}findMatches(){let e=this.getters.getActiveSheetId(),t=this.getters.getCells(e),n=[];if(this.toSearch&&this.currentSearchRegex)for(let r of Object.values(t)){let{col:t,row:i}=this.getters.getCellPosition(r.id),a={sheetId:e,col:t,row:i},o=this.getters.isColHidden(e,t),s=this.getters.isRowHidden(e,i);if(!(o||s)){if(this.currentSearchRegex.test(this.getSearchableString(a))){let e={col:t,row:i,selected:!1};n.push(e)}for(let e of this.getters.getSpreadPositionsOf(a))if(this.currentSearchRegex.test(this.getSearchableString(e))){let t={col:e.col,row:e.row,selected:!1};n.push(t)}}}return n.sort(this.sortByRowThenColumn)}sortByRowThenColumn(e,t){return e.row===t.row?e.col-t.col:e.row>t.row?1:-1}selectNextCell(e){let t=this.searchMatches;if(!t.length){this.selectedMatchIndex=null;return}let n;n=this.selectedMatchIndex===null?0:this.selectedMatchIndex+e,n=(n%t.length+t.length)%t.length,this.selectedMatchIndex=n,this.selection.selectCell(t[n].col,t[n].row);for(let e=0;e<this.searchMatches.length;e++)this.searchMatches[e].selected=e===this.selectedMatchIndex}clearSearch(){this.toSearch=``,this.searchMatches=[],this.selectedMatchIndex=null,this.currentSearchRegex=null,this.searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1}}replaceMatch(e,t){if(!this.currentSearchRegex)return;let n={sheetId:this.getters.getActiveSheetId(),...e},r=this.getters.getCell(n);if(!r?.content||r?.isFormula&&!this.searchOptions.searchFormulas)return;let i=new RegExp(this.currentSearchRegex.source,this.currentSearchRegex.flags+`g`),a=Ic(this.getSearchableString(n).replace(i,t),this.getters.getLocale());this.dispatch(`UPDATE_CELL`,{...n,content:a})}replace(e){if(this.selectedMatchIndex===null)return;let t=this.searchMatches[this.selectedMatchIndex];this.replaceMatch(t,e)}replaceAll(e){let t=this.searchMatches.length;for(let n=0;n<t;n++)this.replaceMatch(this.searchMatches[n],e)}getSearchableString(e){return this.getters.getCellText(e,this.searchOptions.searchFormulas)}drawGrid(e){let{ctx:t}=e,n=this.getters.getActiveSheetId();for(let e of this.searchMatches){let r=this.getters.getMerge({sheetId:n,col:e.col,row:e.row}),i=r?r.left:e.col,a=r?r.right:e.col,o=r?r.top:e.row,s=r?r.bottom:e.row,{x:c,y:l,width:u,height:d}=this.getters.getVisibleRect({top:o,left:i,right:a,bottom:s});u>0&&d>0&&(t.fillStyle=`#8B008B33`,t.fillRect(c,l,u,d),e.selected&&(t.strokeStyle=`#8B008B`,t.strokeRect(c,l,u,d)))}}},vA=class extends Q{handle(e){switch(e.type){case`SET_DECIMAL`:this.setDecimal(e.sheetId,e.target,e.step);break}}setDecimal(e,t,n){let r={};for(let i of t)for(let t of ba(i)){let i=this.getCellNumberFormat({sheetId:e,...t});if(i!==void 0){let e=Ai(i,n,this.getters.getLocale());r[e]=r[e]||[],r[e].push(t)}}for(let t in r){let n=HO(r[t].map(e=>V(e)));this.dispatch(`SET_FORMATTING`,{sheetId:e,format:t,target:n})}}getCellNumberFormat(e){for(let t of[e]){let e=this.getters.getEvaluatedCell(t);if(e.type===`number`&&!(e.format&&_i(e.format)))return e.format||Ci(e.value)}}},yA=class extends Q{static getters=[`getNextVisibleCellPosition`,`findVisibleHeader`,`findLastVisibleColRowIndex`,`findFirstVisibleColRowIndex`,`isRowHidden`,`isColHidden`,`isHeaderHidden`];isRowHidden(e,t){return this.getters.isRowHiddenByUser(e,t)||this.getters.isRowFiltered(e,t)}isColHidden(e,t){return this.getters.isColHiddenByUser(e,t)}isHeaderHidden(e,t,n){return t===`COL`?this.isColHidden(e,n):this.isRowHidden(e,n)}getNextVisibleCellPosition({sheetId:e,col:t,row:n}){return{sheetId:e,col:this.findVisibleHeader(e,`COL`,t,this.getters.getNumberCols(e)-1)||this.findVisibleHeader(e,`COL`,t,0)||0,row:this.findVisibleHeader(e,`ROW`,n,this.getters.getNumberRows(e)-1)||this.findVisibleHeader(e,`ROW`,n,0)||0}}findVisibleHeader(e,t,n,r){if(n<=r){for(let i=n;i<=r;i++)if(this.getters.doesHeaderExist(e,t,i)&&!this.isHeaderHidden(e,t,i))return i}if(n>r){for(let i=n;i>=r;i--)if(this.getters.doesHeaderExist(e,t,i)&&!this.isHeaderHidden(e,t,i))return i}}findLastVisibleColRowIndex(e,t,{last:n,first:r}){return w(n,r,-1).find(n=>!this.isHeaderHidden(e,t,n))||r}findFirstVisibleColRowIndex(e,t){let n=this.getters.getNumberHeaders(e,t);for(let r=0;r<n;r++)if(t===`COL`&&!this.isColHidden(e,r)||t===`ROW`&&!this.isRowHidden(e,r))return r}exportForExcel(e){for(let t of e.sheets)for(let[e,n]of Object.entries(t.rows))n.isHidden=this.isRowHidden(t.id,Number(e))}},bA=class extends Q{static layers=[1];static getters=[`getHighlights`];getHighlights(){return this.prepareHighlights(this.getters.getComposerHighlights().concat(this.getters.getSelectionInputHighlights()))}prepareHighlights(e){return e.filter(e=>e.zone.top>=0&&e.zone.left>=0&&e.zone.bottom<this.getters.getNumberRows(e.sheetId)&&e.zone.right<this.getters.getNumberCols(e.sheetId)).map(e=>{let{numberOfRows:t,numberOfCols:n}=va(e.zone),r=t*n===1?this.getters.expandZone(e.sheetId,e.zone):e.zone;return{...e,zone:r}})}drawGrid(e){let{ctx:t,thinLineWidth:n}=e,r=this.getters.getActiveSheetId(),i=3*n;t.lineWidth=i;let a=this.getHighlights();for(let e of a.filter((e,t)=>a.findIndex(t=>la(t.zone,e.zone)&&t.sheetId===r)===t)){let{x:n,y:r,width:a,height:o}=this.getters.getVisibleRect(e.zone);a>0&&o>0&&(t.strokeStyle=e.color,t.strokeRect(n+i/2,r+i/2,a-i,o-i),t.globalCompositeOperation=`source-over`,t.fillStyle=e.color+`20`,t.fillRect(n+i,r+i,a-2*i,o-2*i))}}},xA=class extends Q{static layers=[0,7];static getters=[`getColDimensionsInViewport`,`getRowDimensionsInViewport`];boxes=[];getColDimensionsInViewport(e,t){let n=Pt(this.getters.getSheetViewVisibleCols()),r=this.getters.getColRowOffsetInViewport(`COL`,n,t),i=this.getters.getColSize(e,t);return{start:r,size:i,end:r+(this.getters.isColHidden(e,t)?0:i)}}getRowDimensionsInViewport(e,t){let n=Pt(this.getters.getSheetViewVisibleRows()),r=this.getters.getColRowOffsetInViewport(`ROW`,n,t),i=this.getters.getRowSize(e,t);return{start:r,size:i,end:r+(this.getters.isRowHidden(e,t)?0:i)}}getHeaderOffset(e,t,n){let r=this.getters.getColRowOffsetInViewport(e,t,n);return this.getters.isDashboard()||(r+=e===`ROW`?26:48),r}drawGrid(e,t){switch(t){case 0:this.drawGlobalBackground(e);for(let{zone:t,rect:n}of this.getters.getAllActiveViewportsZonesAndRect()){let{ctx:r}=e;r.save(),r.beginPath(),r.rect(n.x,n.y,n.width,n.height),r.clip(),this.boxes=this.getGridBoxes(t),this.drawBackground(e),this.drawOverflowingCellBackground(e),this.drawCellBackground(e),this.drawBorders(e),this.drawTexts(e),this.drawIcon(e),r.restore()}this.drawFrozenPanes(e);break;case 7:this.getters.isDashboard()||(this.drawHeaders(e),this.drawFrozenPanesHeaders(e));break}}drawGlobalBackground(e){let{ctx:t}=e,{width:n,height:r}=this.getters.getSheetViewDimensionWithHeaders();t.fillStyle=`#ffffff`,t.fillRect(0,0,n+oe,r+oe)}drawBackground(e){let{ctx:t,thinLineWidth:n}=e,r=!this.getters.isDashboard()&&this.getters.getGridLinesVisibility(this.getters.getActiveSheetId()),i=r?.1*n:0;if(r)for(let e of this.boxes)t.strokeStyle=`#E2E3E3`,t.lineWidth=n,t.strokeRect(e.x+i,e.y+i,e.width-2*i,e.height-2*i)}drawCellBackground(e){let{ctx:t}=e;for(let e of this.boxes){let n=e.style;n.fillColor&&n.fillColor!==`#ffffff`&&(t.fillStyle=n.fillColor||`#ffffff`,t.fillRect(e.x,e.y,e.width,e.height)),e.isError&&(t.fillStyle=`red`,t.beginPath(),t.moveTo(e.x+e.width-5,e.y),t.lineTo(e.x+e.width,e.y),t.lineTo(e.x+e.width,e.y+5),t.fill())}}drawOverflowingCellBackground(e){let{ctx:t,thinLineWidth:n}=e;for(let e of this.boxes)if(e.content&&e.isOverflow){let r=e.content.align||`left`,i,a,o=e.y+n/2,s=e.height-n,c=Math.min(e.clipRect?.width||1/0,e.content.width);r===`left`?(i=e.x+n/2,a=c-2*n):r===`right`?(i=e.x+e.width-n/2,a=-c+2*n):(i=(e.clipRect?.x||e.x+e.width/2-e.content.width/2)+n/2,a=c-2*n),t.fillStyle=`#ffffff`,t.fillRect(i,o,a,s)}}drawBorders(e){let{ctx:t}=e;for(let e of this.boxes){let t=e.border;if(t){let{x:r,y:i,width:a,height:o}=e;t.left&&n(t.left,r,i,r,i+o),t.top&&n(t.top,r,i,r+a,i),t.right&&n(t.right,r+a,i,r+a,i+o),t.bottom&&n(t.bottom,r,i+o,r+a,i+o)}}function n({style:e,color:n},r,i,a,o){switch(t.strokeStyle=n,e){case`medium`:t.lineWidth=2,r+=i===o?-.5:.5,a+=i===o?1.5:.5,i+=r===a?-.5:.5,o+=r===a?1.5:.5;break;case`thick`:t.lineWidth=3,i===o&&(r--,a++),r===a&&(i--,o++);break;case`dashed`:t.lineWidth=1,t.setLineDash([1,3]);break;case`dotted`:t.lineWidth=1,i===o&&(r+=.5,a+=.5),r===a&&(i+=.5,o+=.5),t.setLineDash([1,1]);break;default:t.lineWidth=1;break}t.beginPath(),t.moveTo(r,i),t.lineTo(a,o),t.stroke(),t.lineWidth=1,t.setLineDash([])}}drawTexts(e){let{ctx:t}=e;t.textBaseline=`top`;let n;for(let e of this.boxes)if(e.content){let r=e.style||{},i=e.content.align||`left`,a=yo(r);a!==n&&(n=a,t.font=a),t.fillStyle=r.textColor||`#000`;let o=e.x;if(i===`left`?o+=4+(e.image?e.image.size+4:0):i===`right`?o+=e.width-4-(e.hasIcon?19:0):o+=e.width/2,t.textAlign=i,e.clipRect){t.save(),t.beginPath();let{x:n,y:r,width:i,height:a}=e.clipRect;t.rect(n,r,i,a),t.clip()}let s=bo(r),c=e.content.textLines.length,l=this.computeTextYCoordinate(e,s,c);for(let n of e.content.textLines)Oo(t,n,{x:Math.round(o),y:Math.round(l)},r.underline,r.strikethrough),l+=4+s;e.clipRect&&t.restore()}}drawIcon(e){let{ctx:t}=e;for(let e of this.boxes)if(e.image){let n=e.image.image;if(e.image.clipIcon){t.save(),t.beginPath();let{x:n,y:r,width:i,height:a}=e.image.clipIcon;t.rect(n,r,i,a),t.clip()}let r=e.image.size,i=this.computeTextYCoordinate(e,r);t.drawImage(n,e.x+4,i,r,r),e.image.clipIcon&&t.restore()}}computeTextYCoordinate(e,t,n=1){let r=e.y+1,i=po(t,n),a=e.height>i+8,o=e.verticalAlign||Ae;if(a){if(o===`middle`)return r+(e.height-i)/2;if(o===`bottom`)return r+e.height-i-4}return r+4}drawHeaders(e){let{ctx:t,thinLineWidth:n}=e,r=this.getters.getSheetViewVisibleCols(),i=r[0],a=this.getters.getSheetViewVisibleRows(),o=a[0],{width:s,height:c}=this.getters.getSheetViewDimensionWithHeaders(),l=this.getters.getSelectedZones(),u=ja(l),d=Ma(l),f=this.getters.getActiveSheetId(),p=this.getters.getNumberCols(f),m=this.getters.getNumberRows(f),h=this.getters.getActiveCols(),g=this.getters.getActiveRows();t.font=`400 11px ${Ne}`,t.textAlign=`center`,t.textBaseline=`middle`,t.lineWidth=n,t.strokeStyle=`#333`;for(let e of r){let n={left:e,right:e,top:0,bottom:m-1},{x:r,width:i}=this.getters.getVisibleRect(n),a=this.getters.doesZonesContainFilter(f,[n]),o=h.has(e),s=u.has(e);o?t.fillStyle=a?ve:ue:s?t.fillStyle=a?be:le:t.fillStyle=a?ye:ce,t.fillRect(r,0,i,26)}for(let e of a){let n={top:e,bottom:e,left:0,right:p-1},{y:r,height:i}=this.getters.getVisibleRect(n),a=this.getters.doesZonesContainFilter(f,[n]),o=g.has(e),s=d.has(e);o?t.fillStyle=a?ve:ue:s?t.fillStyle=a?be:le:t.fillStyle=a?ye:ce,t.fillRect(0,r,48,i)}t.beginPath(),t.moveTo(48,0),t.lineTo(48,c),t.moveTo(0,26),t.lineTo(s,26),t.strokeStyle=`#C0C0C0`,t.stroke(),t.beginPath();for(let e of r){let n=this.getters.getColSize(f,e),r=D(e);t.fillStyle=h.has(e)?`#fff`:de;let a=this.getHeaderOffset(`COL`,i,e);t.fillText(r,a+n/2,26/2),t.moveTo(a+n,0),t.lineTo(a+n,26)}for(let e of a){let n=this.getters.getRowSize(f,e);t.fillStyle=g.has(e)?`#fff`:de;let r=this.getHeaderOffset(`ROW`,o,e);t.fillText(String(e+1),48/2,r+n/2),t.moveTo(0,r+n),t.lineTo(48,r+n)}t.stroke()}drawFrozenPanesHeaders(e){let{ctx:t,thinLineWidth:n}=e,{x:r,y:i}=this.getters.getMainViewportCoordinates(),a=this.getters.isDashboard()?0:48,o=this.getters.isDashboard()?0:26;t.lineWidth=6*n,t.strokeStyle=Te,t.beginPath(),r&&(t.moveTo(a+r,0),t.lineTo(a+r,o)),i&&(t.moveTo(0,o+i),t.lineTo(a,o+i)),t.stroke()}drawFrozenPanes(e){let{ctx:t,thinLineWidth:n}=e,{x:r,y:i}=this.getters.getMainViewportCoordinates(),a=this.getters.getSheetViewVisibleCols(),o=a[0],s=a[a.length-1],c=this.getters.getSheetViewVisibleRows(),l={left:o,right:s,top:c[0],bottom:c[c.length-1]},u=this.getters.getVisibleRect(l),d=this.getters.isDashboard()?0:48,f=this.getters.isDashboard()?0:26;t.lineWidth=6*n,t.strokeStyle=`#DADFE8`,t.beginPath(),r&&(t.moveTo(d+r,f),t.lineTo(d+r,u.height+f)),i&&(t.moveTo(d,f+i),t.lineTo(u.width+d,f+i)),t.stroke()}findNextEmptyCol(e,t,n){let r=this.getters.getActiveSheetId(),i=e;for(;i<t;){let e={sheetId:r,col:i+1,row:n},t=this.getters.getEvaluatedCell(e),a=this.getters.getCellBorderWithFilterBorder(e),o=this.getters.doesCellHaveGridIcon(e),s=this.getters.isCellValidCheckbox(e);if(t.type!==`empty`||this.getters.isInMerge(e)||a?.left||o||s)return i;i++}return i}findPreviousEmptyCol(e,t,n){let r=this.getters.getActiveSheetId(),i=e;for(;i>t;){let e={sheetId:r,col:i-1,row:n},t=this.getters.getEvaluatedCell(e),a=this.getters.getCellBorderWithFilterBorder(e),o=this.getters.doesCellHaveGridIcon(e),s=this.getters.isCellValidCheckbox(e);if(t.type!==`empty`||this.getters.isInMerge(e)||a?.right||o||s)return i;i--}return i}computeCellAlignment(e,t){if(this.getters.getCell(e)?.isFormula&&this.getters.shouldShowFormulas())return`left`;let{align:n}=this.getters.getCellStyle(e),r=this.getters.getEvaluatedCell(e);return t&&r.type===`number`?n===`center`?n:`left`:n||r.defaultAlign}createZoneBox(e,t,n){let{left:r,right:i}=n,a=t.left,o=t.top,s={sheetId:e,col:a,row:o},c=this.getters.getEvaluatedCell(s),l=this.getters.shouldShowFormulas(),{x:u,y:d,width:f,height:p}=this.getters.getRect(t),{verticalAlign:m}=this.getters.getCellStyle(s),h={x:u,y:d,width:f,height:p,border:this.getters.getCellBorderWithFilterBorder(s)||void 0,style:this.getters.getCellComputedStyle(s),verticalAlign:m,isError:c.type===`error`&&c.error.isVerbose||this.getters.isDataValidationInvalid(s)};if(c.type===`empty`||this.getters.isCellValidCheckbox(s))return h;let g=this.getters.getConditionalIcon(s),_=bo(h.style),v=g?4+_:0;g&&(h.image={type:`icon`,size:_,clipIcon:{x:h.x,y:h.y,width:Math.min(v,f),height:p},image:MS[g].img}),h.hasIcon=this.getters.doesCellHaveGridIcon(s);let y=h.hasIcon?19:0,ee=this.getters.getCellComputedStyle(s),te=ee.wrapping||`overflow`,b=te===`wrap`&&!l?f-8:void 0,x=this.getters.getCellMultiLineText(s,b),ne=Math.max(...x.map(e=>this.getters.getTextWidth(e,ee)+4)),re=v+ne+y,ie=this.computeCellAlignment(s,re>f);h.content={textLines:x,width:te===`overflow`?ne:f,align:ie};let ae=re>f||_>p;if(g||h.hasIcon)h.clipRect={x:h.x+v,y:h.y,width:Math.max(0,f-v-y),height:p};else if(ae&&te===`overflow`){let e,n;switch(this.getters.isInMerge(s)?(e=this.getters.getMerge(s).right,n=a):(e=this.findNextEmptyCol(a,i,o),n=this.findPreviousEmptyCol(a,r,o),h.isOverflow=!0),ie){case`left`:{let n=V({col:e,row:o}),{x:r,y:i,width:a,height:s}=this.getters.getVisibleRect(sa(t,n));(a<re||_>s||x.length>1)&&(h.clipRect={x:r,y:i,width:a,height:s});break}case`right`:{let e=V({col:n,row:o}),{x:r,y:i,width:a,height:s}=this.getters.getVisibleRect(sa(t,e));(a<re||_>s||x.length>1)&&(h.clipRect={x:r,y:i,width:a,height:s});break}case`center`:{let r={...t,left:n,right:e},{x:i,y:a,height:o,width:s}=this.getters.getVisibleRect(r),c=re/2,l=h.x+h.width/2;if(i+s<l+c||i>l-c||_>o||x.length>1){let e=i>l-c?i:l-c;h.clipRect={x:e,y:a,width:i+s-e,height:o}}break}}}else(te===`clip`||te===`wrap`||x.length>1)&&(h.clipRect={x:h.x,y:h.y,width:f,height:p});return h}getGridBoxes(e){let t=[],n=this.getters.getSheetViewVisibleCols().filter(t=>t>=e.left&&t<=e.right),r=n[0],i=n[n.length-1],a=this.getters.getSheetViewVisibleRows().filter(t=>t>=e.top&&t<=e.bottom),o={left:r,right:i,top:a[0],bottom:a[a.length-1]},s=this.getters.getActiveSheetId();for(let e of a)for(let r of n){let n={sheetId:s,col:r,row:e};this.getters.isInMerge(n)||t.push(this.createZoneBox(s,V(n),o))}for(let e of this.getters.getMerges(s))if(!this.getters.isMergeHidden(s,e)&&ua(e,o)){let n=this.createZoneBox(s,e,o),r=this.getters.getCellBorder({sheetId:s,col:e.right,row:e.bottom});n.border={...n.border,bottom:r?r.bottom:void 0,right:r?r.right:void 0},n.isMerge=!0,t.push(n)}return t}},SA=class extends Q{inputHasSingleRange;static layers=[1];static getters=[];ranges=[];focusedRangeIndex=null;inputSheetId;constructor(e,t,n){if(n&&t.length>1)throw Error(`Input with a single range cannot be instantiated with several range references.`);super(e),this.inputHasSingleRange=n,this.insertNewRange(0,t),this.inputSheetId=this.getters.getActiveSheetId(),this.ranges.length===0&&(this.insertNewRange(this.ranges.length,[``]),this.focusLast())}handleEvent(e){if(this.focusedRangeIndex===null)return;let t=this.inputSheetId,n=this.getters.getActiveSheetId(),r=e.options.unbounded?this.getters.getUnboundedZone(n,e.anchor.zone):e.anchor.zone,i=this.getters.getRangeFromZone(n,r);if(e.mode===`newAnchor`&&!this.inputHasSingleRange&&this.ranges[this.focusedRangeIndex].xc.trim()!==``){let e=this.getters.getSelectionRangeString(i,t);this.insertNewRange(this.ranges.length,[e]),this.focusLast()}else{let e=i.parts,n=this.ranges[this.focusedRangeIndex].xc.trim();n&&(e=this.getters.getRangeFromSheetXC(t,n).parts);let r=i.clone({parts:e}),a=this.getters.getSelectionRangeString(r,t);this.setRange(this.focusedRangeIndex,[a])}}handle(e){switch(e.type){case`UNFOCUS_SELECTION_INPUT`:this.unfocus();break;case`FOCUS_RANGE`:this.focus(this.getIndex(e.rangeId));break;case`CHANGE_RANGE`:{let t=this.getIndex(e.rangeId);if(t!==null&&this.focusedRangeIndex!==t&&this.focus(t),t!==null){let n=e.value.replace(/^,+/,``).split(`,`).map(e=>e.trim());this.setRange(t,n)}break}case`ADD_EMPTY_RANGE`:this.insertNewRange(this.ranges.length,[``]),this.focusLast();break;case`ADD_RANGE`:this.insertNewRange(this.ranges.length,[e.value]),this.focusLast();break;case`REMOVE_RANGE`:let t=this.getIndex(e.rangeId);t!==null&&this.removeRange(t);break;case`ACTIVATE_SHEET`:if(e.sheetIdFrom!==e.sheetIdTo){let{col:t,row:n}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:0,row:0}),r=this.getters.expandZone(e.sheetIdTo,V({col:t,row:n}));this.selection.resetAnchor(this,{cell:{col:t,row:n},zone:r})}break;case`START_CHANGE_HIGHLIGHT`:let n=this.getters.getActiveSheetId(),r=this.getters.expandZone(n,e.zone),i=this.ranges.findIndex(e=>{let{xc:t,sheetName:i}=Xi(e.xc),a=i||this.getters.getSheetName(this.inputSheetId);if(this.getters.getSheetName(n)!==a)return!1;let o=this.getters.getRangeFromSheetXC(n,t);return la(this.getters.expandZone(n,o.zone),r)});if(i!==-1){this.focus(i);let{left:e,top:t}=r;this.selection.resetAnchor(this,{cell:{col:e,row:t},zone:r})}break}}getSelectionInputValue(){return this.cleanInputs(this.ranges.map(e=>e.xc?e.xc:``))}getSelectionInputHighlights(){return this.ranges.map(e=>this.inputToHighlights(e)).flat()}focus(e){this.focusedRangeIndex=e}focusLast(){this.focus(this.ranges.length-1)}unfocus(){this.focusedRangeIndex=null}setContent(e,t){this.ranges[e]={...this.ranges[e],xc:t}}insertNewRange(e,t){let n=Math.max(0,...this.ranges.map(e=>Number(e.id)));this.ranges.splice(e,0,...t.map((e,t)=>({xc:e,id:n+t+1,color:Lt[(n+t)%Lt.length]})))}setRange(e,t){let[,...n]=t;this.setContent(e,t[0]),this.insertNewRange(e+1,n),n.length&&this.focus(e+n.length)}removeRange(e){this.ranges.splice(e,1),this.focusedRangeIndex!==null&&this.focusLast()}inputToHighlights({xc:e,color:t}){return this.cleanInputs([e]).filter(e=>this.getters.isRangeValid(e)).filter(e=>this.shouldBeHighlighted(this.inputSheetId,e)).map(e=>{let{sheetName:n}=Xi(e);return{zone:this.getters.getRangeFromSheetXC(this.inputSheetId,e).zone,sheetId:n&&this.getters.getSheetIdByName(n)||this.inputSheetId,color:t}})}cleanInputs(e){return e.map(e=>e.split(`,`)).flat().map(e=>e.trim()).filter(e=>e!==``)}shouldBeHighlighted(e,t){let{sheetName:n}=Xi(t),r=this.getters.getSheetIdByName(n),i=this.getters.getActiveSheet().id;return this.getters.isRangeValid(t)&&(r===i||r===void 0&&i===e)}getIndex(e){let t=this.ranges.findIndex(t=>t.id===e);return t>=0?t:null}},CA=class extends Q{config;static layers=[1];static getters=[`getSelectionInput`,`getSelectionInputValue`,`isRangeValid`,`getSelectionInputHighlights`];inputs={};focusedInputId=null;get currentInput(){return this.focusedInputId?this.inputs[this.focusedInputId]:null}constructor(e){super(e),this.config=e}allowDispatch(e){switch(e.type){case`FOCUS_RANGE`:case`CHANGE_RANGE`:case`ADD_EMPTY_RANGE`:case`REMOVE_RANGE`:if(!this.inputs[e.id])return`InvalidInputId`}switch(e.type){case`FOCUS_RANGE`:let t=this.currentInput?.getIndex(e.rangeId);if(this.focusedInputId===e.id&&this.currentInput?.focusedRangeIndex===t)return`InputAlreadyFocused`;break;case`ADD_RANGE`:case`ADD_EMPTY_RANGE`:let n=this.inputs[e.id];if(n.inputHasSingleRange&&n.ranges.length===1)return`MaximumRangesReached`;break;case`REMOVE_RANGE`:if(this.inputs[e.id].ranges.length===1)return`MinimumRangesReached`;break;case`CHANGE_RANGE`:if(this.inputs[e.id].inputHasSingleRange&&e.value.split(`,`).length>1)return`MaximumRangesReached`;break}return`Success`}handle(e){switch(e.type){case`ENABLE_NEW_SELECTION_INPUT`:this.initInput(e.id,e.initialRanges||[],e.hasSingleRange);break;case`DISABLE_SELECTION_INPUT`:this.focusedInputId===e.id&&this.unfocus(),delete this.inputs[e.id];break;case`UNFOCUS_SELECTION_INPUT`:this.unfocus();break;case`ADD_RANGE`:case`ADD_EMPTY_RANGE`:case`REMOVE_RANGE`:if(e.id!==this.focusedInputId){let t=this.inputs[e.id];this.selection.capture(t,{cell:{col:0,row:0},zone:V({col:0,row:0})},{handleEvent:t.handleEvent.bind(t),release:()=>this.focusedInputId=null}),this.focusedInputId=e.id}break;case`FOCUS_RANGE`:case`CHANGE_RANGE`:let t=this.inputs[e.id],n=t.ranges.find(t=>t.id===e.rangeId);if(n){let e=this.getters.getActiveSheetId(),r=this.getters.getRangeFromSheetXC(e,n?.xc||`A1`).zone;this.selection.capture(t,{cell:{col:r.left,row:r.top},zone:r},{handleEvent:t.handleEvent.bind(t),release:()=>this.focusedInputId=null})}this.focusedInputId=e.id;break}this.currentInput?.handle(e)}getSelectionInput(e){return this.inputs[e]?this.inputs[e].ranges.map((t,n)=>Object.assign({},t,{color:this.focusedInputId===e&&this.inputs[e].focusedRangeIndex!==null&&this.isRangeValid(t.xc)?t.color:null,isFocused:this.focusedInputId===e&&this.inputs[e].focusedRangeIndex===n})):[]}isRangeValid(e){if(!e)return!1;let{xc:t,sheetName:n}=Xi(e);return t.match(Wi)!==null&&(!n||this.getters.getSheetIdByName(n)!==void 0)}getSelectionInputValue(e){return this.inputs[e].getSelectionInputValue()}getSelectionInputHighlights(){return this.focusedInputId?this.inputs[this.focusedInputId].getSelectionInputHighlights():[]}initInput(e,t,n=!1){if(this.inputs[e]&&this.unfocus(),this.inputs[e]=new SA(this.config,t,n),t.length===0){let t=this.inputs[e],n={zone:V({col:0,row:0}),cell:{col:0,row:0}};this.selection.capture(t,n,{handleEvent:t.handleEvent.bind(t),release:()=>this.focusedInputId=null}),this.focusedInputId=e}}unfocus(){this.selection.release(this.currentInput),this.focusedInputId=null}},wA=class extends Q{static getters=[`getContiguousZone`];allowDispatch(e){switch(e.type){case`SORT_CELLS`:if(!da(e.col,e.row,e.zone))throw Error(y(`The anchor must be part of the provided zone`));return this.checkValidations(e,this.checkMerge,this.checkMergeSizes)}return`Success`}handle(e){switch(e.type){case`SORT_CELLS`:this.sortZone(e.sheetId,e,e.zone,e.sortDirection,e.sortOptions||{});break}}checkMerge({sheetId:e,zone:t}){return this.getters.doesIntersectMerge(e,t)&&ba(t).some(({col:t,row:n})=>!this.getters.isInMerge({sheetId:e,col:t,row:n}))?`InvalidSortZone`:`Success`}checkMergeSizes({sheetId:e,zone:t}){if(!this.getters.doesIntersectMerge(e,t))return`Success`;let n=this.getters.getMerges(e).filter(e=>ua(e,t)),r=va(n[0]),[i,a]=[r.numberOfCols,r.numberOfRows];return n.every(e=>{let[t,n]=[e.right-e.left+1,e.bottom-e.top+1];return t===i&&n===a})?`Success`:`InvalidSortZone`}expand(e,t){let{left:n,right:r,top:i,bottom:a}=this.getters.expandZone(e,t);return{left:Math.max(0,n),right:Math.min(this.getters.getNumberCols(e)-1,r),top:Math.max(0,i),bottom:Math.min(this.getters.getNumberRows(e)-1,a)}}checkExpandedValues(e,t){let n=this.expand(e,t),r;if(this.getters.doesIntersectMerge(e,n)){let{left:t,right:i,top:a,bottom:o}=n;for(let n=t;n<=i;n++)for(let t=a;t<=o;t++){let{col:i,row:a}=this.getters.getMainCellPosition({sheetId:e,col:n,row:t});if(r=this.getters.getEvaluatedCell({sheetId:e,col:i,row:a}),r.formattedValue)return!0}}else for(let t of this.getters.getEvaluatedCellsInZone(e,n))if(t.formattedValue)return!0;return!1}getContiguousZone(e,t){let{top:n,bottom:r,left:i,right:a}=t,o,s=!1;for(;!s;)s=!0,n>0&&(o=this.checkExpandedValues(e,{left:i-1,right:a+1,top:n-1,bottom:n-1}),o&&(s=!1,n--)),i>0&&(o=this.checkExpandedValues(e,{left:i-1,right:i-1,top:n-1,bottom:r+1}),o&&(s=!1,i--)),a<this.getters.getNumberCols(e)-1&&(o=this.checkExpandedValues(e,{left:a+1,right:a+1,top:n-1,bottom:r+1}),o&&(s=!1,a++)),r<this.getters.getNumberRows(e)-1&&(o=this.checkExpandedValues(e,{left:i-1,right:a+1,top:r+1,bottom:r+1}),o&&(s=!1,r++));return{left:i,right:a,top:n,bottom:r}}hasHeader(e,t){if(t[0].length===1)return!1;let n=t.map(t=>t.map(({col:t,row:n})=>this.getters.getEvaluatedCell({sheetId:e,col:t,row:n}).type));return n[0][0]===`empty`&&(n=n.slice(1)),n.some(e=>e[0]===`empty`)?!1:!!n.some(e=>e[1]!==`empty`&&e[0]!==e[1])}sortZone(e,t,n,r,i){let[a,o]=this.mainCellsSteps(e,n),s=this.getters.getMainCellPosition({sheetId:e,col:t.col,row:t.row}).col,c=Object.assign({},n),l=this.mainCells(e,n);!i.sortHeaders&&this.hasHeader(e,l)&&(c.top+=o),l=this.mainCells(e,c);let u=l[s-c.left],d=_g(u.map(e=>this.getters.getEvaluatedCell(e)),r,!!i.emptyCellAsZero).map(e=>e.index),[f,p]=[l.length,l[0].length],m=[];for(let e=0;e<f;e++)for(let t=0;t<p;t++){let{col:n,row:r,sheetId:i}=l[e][d[t]],s=this.getters.getCell({sheetId:i,col:n,row:r}),u=c.left+e*a,f=c.top+t*o,p={sheetId:i,col:u,row:f,content:``};if(s){let e=s.content;if(s.isFormula){let t=this.getters.getCellPosition(s.id);e=this.getters.getTranslatedCellFormula(i,0,f-t.row,s.compiledFormula)}p.style=s.style,p.content=e,p.format=s.format}m.push(p)}m.forEach(e=>this.dispatch(`UPDATE_CELL`,e))}mainCellsSteps(e,t){let n=this.getters.getMerge({sheetId:e,col:t.left,row:t.top});return[n?n.right-n.left+1:1,n?n.bottom-n.top+1:1]}mainCells(e,t){let[n,r]=this.mainCellsSteps(e,t),i=[],a=w(t.left,t.right+1,n),o=w(t.top,t.bottom+1,r);for(let t of a){let n=[];i.push(n);for(let r of o)n.push({sheetId:e,col:t,row:r})}return i}},TA=class extends Q{static getters=[`shouldShowFormulas`];showFormulas=!1;handle(e){switch(e.type){case`SET_FORMULA_VISIBILITY`:this.showFormulas=e.show;break}}shouldShowFormulas(){return this.showFormulas}},EA=class extends Q{static getters=[`doesCellHaveGridIcon`,`getCellWidth`,`getTextWidth`,`getCellText`,`getCellMultiLineText`];ctx=document.createElement(`canvas`).getContext(`2d`);allowDispatch(e){return this.chainValidations(this.checkSheetExists,this.checkZonesAreInSheet)(e)}handle(e){switch(e.type){case`AUTORESIZE_COLUMNS`:for(let t of e.cols){let n=this.getColMaxWidth(e.sheetId,t);n!==0&&this.dispatch(`RESIZE_COLUMNS_ROWS`,{elements:[t],dimension:`COL`,size:n,sheetId:e.sheetId})}break;case`AUTORESIZE_ROWS`:this.autoResizeRows(e.sheetId,e.rows);break}}getCellWidth(e){let t=this.getters.getCellComputedStyle(e),n=0,r=this.getters.getEvaluatedCell(e).formattedValue;if(r){let e=So(this.ctx,r,t,void 0);n+=Math.max(...e.map(e=>_o(this.ctx,e,t)))}if(this.getters.getConditionalIcon(e)&&(n+=wo(t)),this.getters.doesCellHaveGridIcon(e)&&(n+=20),n===0)return 0;if(n+=8,t.wrapping===`wrap`){let t=this.getters.getColSize(e.sheetId,e.col);return Math.min(t,n)}return n}getTextWidth(e,t){return _o(this.ctx,e,t)}getCellText(e,t=!1){let n=this.getters.getCell(e);return t&&n?.isFormula?Vc(n.content,this.getters.getLocale()):t&&!n?.content?``:this.getters.getEvaluatedCell(e).formattedValue}getCellMultiLineText(e,t){let n=this.getters.getCellStyle(e),r=this.getters.getCellText(e,this.getters.shouldShowFormulas());return So(this.ctx,r,n,t)}doesCellHaveGridIcon(e){let t=this.getters.isFilterHeader(e),n=!this.getters.isReadonly()&&this.getters.cellHasListDataValidationIcon(e);return t||n}getColMaxWidth(e,t){let n=ba(this.getters.getColsZone(e,t,t)).map(t=>this.getCellWidth({sheetId:e,...t}));return Math.max(0,Nt(n))}checkSheetExists(e){return`sheetId`in e&&this.getters.tryGetSheet(e.sheetId)===void 0?`InvalidSheetId`:`Success`}checkZonesAreInSheet(e){let t=`sheetId`in e?e.sheetId:this.getters.tryGetActiveSheetId();if(`ranges`in e&&e.ranges.some(e=>!this.getters.tryGetSheet(e._sheetId)))return`InvalidSheetId`;let n=this.getters.getCommandZones(e);return!t&&n.length>0?`NoActiveSheet`:t&&n.length>0?this.getters.checkZonesExistInSheet(t,n):`Success`}autoResizeRows(e,t){let n=[];for(let r of t){let t=0;for(let n of this.getters.getRowCells(e,r)){let r=this.getters.getCellById(n);if(!r)continue;let i=this.getters.getCellPosition(r.id),a=this.getters.getColSize(e,i.col);if(r.isFormula||this.getters.getArrayFormulaSpreadingOn(i)){let e=this.getters.getEvaluatedCell(i).formattedValue,n=ho(this.ctx,e,r?.style,a);n>t&&n>23&&(t=n)}else{let e=r.content,n=ho(this.ctx,e,r?.style,a);n>=t&&n>23&&(t=0)}}n.push(t||null)}let r=new Map(n.map(e=>[e,[]]));for(let e=0;e<n.length;e++)r.get(n[e])?.push(t[e]);for(let[t,n]of r)this.dispatch(`RESIZE_COLUMNS_ROWS`,{elements:n,dimension:`ROW`,size:t,sheetId:e})}};let DA=[OA,kA,jA];function OA(e,t){return`sheetId`in t?{...S(t),sheetId:e.getActiveSheetId()}:t}function kA(e,t){return!(`target`in t)||!Array.isArray(t.target)?t:{...S(t),target:e.getSelectedZones()}}function AA(e,t){return`zone`in t?{...S(t),zone:e.getSelectedZone()}:t}function jA(e,t){if(!(`row`in t)||!(`col`in t))return t;let{col:n,row:r}=e.getActivePosition();return{...S(t),col:n,row:r}}let MA=new ko;function NA(e,t){return{...OA(e,t),id:MA.smallUuid()}}function PA(e,t){return{...OA(e,t),figureId:MA.smallUuid()}}function FA(e,t){let n=OA(e,t);return n.figure.id=MA.smallUuid(),n}function IA(e,t){let n=S(t);n.sheetId=MA.smallUuid();let r=t.name||e.getSheet(e.getActiveSheetId()).name,i=r.match(/(.+?)\d*$/)?.[1]||r;return n.name=e.getNextSheetName(i),n}function LA(e,t){let n=e.getActivePosition();return{...OA(e,t),base:t.dimension===`COL`?n.col:n.row}}function RA(e,t){let n=e.getSelectedZone();return{...OA(e,t),elements:t.dimension===`COL`?w(n.left,n.right+1):w(n.top,n.bottom+1)}}function zA(e,t){let n=e.getSelectedZone();return{...S(t),zone:n}}function BA(e,t){let n=S(t),{top:r,bottom:i,left:a,right:o}=e.getSelectedZone();return`cols`in n?n.cols=w(a,o+1):`rows`in n&&(n.rows=w(r,i+1)),n}function VA(e,t){let n=e.getSelectedZone();return{...OA(e,t),col:n.left,row:n.top,zone:n}}function HA(e,t){return{type:`REPEAT_PASTE`,pasteOption:S(t.pasteOption),target:e.getSelectedZones()}}function UA(e,t){let n=e.getSelectedZone();return{...OA(e,t),start:t.dimension===`COL`?n.left:n.top,end:t.dimension===`COL`?n.right:n.bottom}}let $=new H;$.add(`UPDATE_CELL`,GA),$.add(`CLEAR_CELL`,GA),$.add(`CLEAR_CELLS`,GA),$.add(`DELETE_CONTENT`,GA),$.add(`ADD_MERGE`,GA),$.add(`REMOVE_MERGE`,GA),$.add(`SET_FORMATTING`,GA),$.add(`CLEAR_FORMATTING`,GA),$.add(`SET_BORDER`,GA),$.add(`CREATE_FILTER_TABLE`,GA),$.add(`REMOVE_FILTER_TABLE`,GA),$.add(`HIDE_SHEET`,GA),$.add(`ADD_COLUMNS_ROWS`,LA),$.add(`REMOVE_COLUMNS_ROWS`,RA),$.add(`HIDE_COLUMNS_ROWS`,RA),$.add(`RESIZE_COLUMNS_ROWS`,RA),$.add(`CREATE_SHEET`,IA),$.add(`CREATE_FIGURE`,FA),$.add(`CREATE_CHART`,NA),$.add(`CREATE_IMAGE`,PA),$.add(`GROUP_HEADERS`,UA),$.add(`UNGROUP_HEADERS`,UA),$.add(`UNGROUP_HEADERS`,UA),$.add(`UNFOLD_HEADER_GROUPS_IN_ZONE`,AA),$.add(`FOLD_HEADER_GROUPS_IN_ZONE`,AA);let WA=new H;WA.add(`STOP_EDITION`,JA),WA.add(`PASTE`,HA),WA.add(`INSERT_CELL`,zA),WA.add(`DELETE_CELL`,zA),WA.add(`AUTORESIZE_COLUMNS`,BA),WA.add(`AUTORESIZE_ROWS`,BA),WA.add(`SORT_CELLS`,VA),WA.add(`SUM_SELECTION`,GA),WA.add(`SET_DECIMAL`,GA);function GA(e,t){let n=S(t);for(let t of DA)n=t(e,n);return n}function KA(e,t){if(t&&$.contains(t.type))return $.get(t.type)(e,t)}function qA(e,t,n){if(WA.contains(t.type))return WA.get(t.type)(e,t,n)}function JA(e,t,n){return n.map(t=>KA(e,t)).filter(T)}function YA(e){return!e||!e.rootCommand||typeof e.rootCommand!=`object`?!1:ur(e.rootCommand)?$.contains(e.rootCommand.type):WA.contains(e.rootCommand.type)}function XA(e,t){if(!(!e.rootCommand||typeof e.rootCommand!=`object`))return ur(e.rootCommand)?KA(t,e.rootCommand):qA(t,e.rootCommand,e.commands)}var ZA=class extends Q{static getters=[`canUndo`,`canRedo`];undoStack=[];redoStack=[];session;constructor(e){super(e),this.session=e.session,this.session.on(`new-local-state-update`,this,this.onNewLocalStateUpdate),this.session.on(`snapshot`,this,()=>{this.undoStack=[],this.redoStack=[]})}allowDispatch(e){switch(e.type){case`REQUEST_UNDO`:if(!this.canUndo())return`EmptyUndoStack`;break;case`REQUEST_REDO`:if(!this.canRedo())return`EmptyRedoStack`;break}return`Success`}handle(e){switch(e.type){case`REQUEST_UNDO`:case`REQUEST_REDO`:this.requestHistoryChange(e.type===`REQUEST_UNDO`?`UNDO`:`REDO`)}}finalize(){}requestHistoryChange(e){let t=e===`UNDO`?this.undoStack.pop():this.redoStack.pop();if(!t){let e=this.getPossibleRevisionToRepeat();if(!e)return;let t=XA(e,this.getters);if(!t)return;if(!Array.isArray(t)){this.dispatch(t.type,t);return}for(let e of t)this.dispatch(e.type,e);return}e===`UNDO`?(this.session.undo(t),this.redoStack.push(t)):(this.session.redo(t),this.undoStack.push(t))}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0?!0:YA(this.getPossibleRevisionToRepeat())}onNewLocalStateUpdate({id:e}){this.undoStack.push(e),this.redoStack=[],this.undoStack.length>99&&this.undoStack.shift()}getPossibleRevisionToRepeat(){return this.session.getLastLocalNonEmptyRevision()}},QA=class extends Q{static getters=[`getAutomaticSeparator`];allowDispatch(e){switch(e.type){case`SPLIT_TEXT_INTO_COLUMNS`:return this.chainValidations(this.batchValidations(this.checkSingleColSelected,this.checkNonEmptySelector),this.batchValidations(this.checkNotOverwritingContent,this.checkSeparatorInSelection))(e)}return`Success`}handle(e){switch(e.type){case`SPLIT_TEXT_INTO_COLUMNS`:this.splitIntoColumns(e);break}}getAutomaticSeparator(){let e=this.getters.getSelectedCells();for(let t of e)if(t.value&&t.type===`text`){let e=this.getAutoSeparatorForString(t.value);if(e)return e}return` `}getAutoSeparatorForString(e){for(let t of[`
|
|
1478
1478
|
`,`;`,`,`,` `,`.`])if(e.includes(t))return t}splitIntoColumns({separator:e,addNewColumns:t}){let n=this.getters.getSelectedZone(),r=this.getters.getActiveSheetId(),i=this.getSplittedCols(n,e);t&&this.addColsToAvoidCollisions(n,i),this.removeMergesInSplitZone(n,i),this.addColumnsToNotOverflowSheet(n,i);for(let e=0;e<i.length;e++){let t=n.top+e,a=i[e],o=n.left,s=this.getters.getCell({sheetId:r,col:o,row:t});if(!(a.length===1&&a[0]===s?.content))for(let[e,n]of a.entries())this.dispatch(`UPDATE_CELL`,{sheetId:r,col:o+e,row:t,content:Ic(n,this.getters.getLocale()),format:``,style:s?.style||null})}}getSplittedCols(e,t){if(!t)throw Error(`Separator cannot be empty`);let n=this.getters.getActiveSheetId(),r=[];for(let i of w(e.top,e.bottom+1)){let a=this.getters.getEvaluatedCell({sheetId:n,col:e.left,row:i}).formattedValue;r.push(this.splitAndRemoveTrailingEmpty(a,t))}return r}splitAndRemoveTrailingEmpty(e,t){let n=e.split(t);for(;n.length>1&&n[n.length-1]===``;)n.pop();return n}willSplittedColsOverwriteContent(e,t){let n=this.getters.getActiveSheetId();for(let r of w(e.top,e.bottom+1)){let i=t[r-e.top];for(let t=1;t<i.length;t++){let i=this.getters.getCell({sheetId:n,col:e.left+t,row:r});if(i&&i.content)return!0}}return!1}removeMergesInSplitZone(e,t){let n=this.getters.getActiveSheetId(),r=Math.max(...t.map(e=>e.length)),i={...e,right:e.left+r-1},a=this.getters.getMergesInZone(n,i);this.dispatch(`REMOVE_MERGE`,{sheetId:n,target:a})}addColsToAvoidCollisions(e,t){let n=this.getters.getActiveSheetId(),r=0;for(let i of w(e.top,e.bottom+1)){let a={sheetId:n,col:e.left,row:i},o=t[i-e.top],s=this.getColsToAddToAvoidCollision(a,o);r=Math.max(r,s)}r&&this.dispatch(`ADD_COLUMNS_ROWS`,{dimension:`COL`,base:e.left,sheetId:n,quantity:r,position:`after`})}getColsToAddToAvoidCollision(e,t){let n=t.length;for(let t=1;t<n;t++){let r=e.col+t,i=this.getters.getCell({...e,col:r});if(i&&i.content)return n-t}return 0}addColumnsToNotOverflowSheet(e,t){let n=this.getters.getActiveSheetId(),r=Math.max(...t.map(e=>e.length-1)),i=this.getters.getNumberCols(n)-1;e.left+r>i&&this.dispatch(`ADD_COLUMNS_ROWS`,{dimension:`COL`,base:i,sheetId:n,quantity:e.left+r-i,position:`after`})}checkSingleColSelected(){return this.getters.isSingleColSelected()?`Success`:`MoreThanOneColumnSelected`}checkNonEmptySelector(e){return e.separator===``?`EmptySplitSeparator`:`Success`}checkNotOverwritingContent(e){if(e.addNewColumns||e.force)return`Success`;let t=this.getters.getSelectedZones()[0],n=this.getSplittedCols(t,e.separator);return this.willSplittedColsOverwriteContent(t,n)?`SplitWillOverwriteContent`:`Success`}checkSeparatorInSelection({separator:e}){let t=this.getters.getSelectedCells();for(let n of t)if(n.formattedValue.includes(e))return`Success`;return`NoSplitSeparatorInSelection`}},$A=class{operation;getters;dispatch;sheetId;copiedFigure;copiedFigureContent;constructor(e,t,n){this.operation=e,this.getters=t,this.dispatch=n,this.sheetId=t.getActiveSheetId();let r=t.getSelectedFigureId();if(!r)throw Error(`No figure selected`);let i=t.getFigure(this.sheetId,r);if(!i)throw Error(`No figure for the given id: ${r}`);switch(this.copiedFigure={...i},i.tag){case`chart`:this.copiedFigureContent=new ej(n,t,this.sheetId,r);break;case`image`:this.copiedFigureContent=new tj(n,t,this.sheetId,r);break;default:throw Error(`Unknow tag '${i.tag}' for the given figure id: ${r}`)}}isCutAllowed(e){return`Success`}isPasteAllowed(e,t){return e.length===0?`EmptyTarget`:t?.pasteOption===void 0?`Success`:`WrongFigurePasteOption`}paste(e){let t=this.getters.getActiveSheetId(),{width:n,height:r}=this.copiedFigure,i=this.getters.getNumberCols(t),a=this.getters.getNumberRows(t),o=this.getters.getColDimensions(t,e[0].left).start,s=this.getters.getRowDimensions(t,e[0].top).start,c=this.getters.getColDimensions(t,i-1).end,l=this.getters.getRowDimensions(t,a-1).end,u={x:c<n?0:Math.min(o,c-n),y:l<r?0:Math.min(s,l-r)},d=new ko().smallUuid();this.copiedFigureContent.paste(t,d,u,{height:r,width:n}),this.operation===`CUT`&&this.dispatch(`DELETE_FIGURE`,{sheetId:this.copiedFigureContent.sheetId,id:this.copiedFigure.id}),this.dispatch(`SELECT_FIGURE`,{id:d})}getClipboardContent(){return{"text/plain":` `}}isColRowDirtyingClipboard(e,t){return!1}drawClipboard(e){}},ej=class{dispatch;sheetId;copiedChart;constructor(e,t,n,r){this.dispatch=e,this.sheetId=n;let i=t.getChart(r);if(!i)throw Error(`No chart for the given id: ${r}`);this.copiedChart=i.copyInSheetId(n)}paste(e,t,n,r){let i=this.copiedChart.copyInSheetId(e);this.dispatch(`CREATE_CHART`,{id:t,sheetId:e,position:n,size:r,definition:i.getDefinition()})}},tj=class{dispatch;sheetId;copiedImage;constructor(e,t,n,r){this.dispatch=e,this.sheetId=n;let i=t.getImage(r);this.copiedImage=S(i)}paste(e,t,n,r){let i=S(this.copiedImage);this.dispatch(`CREATE_IMAGE`,{figureId:t,sheetId:e,position:n,size:r,definition:i})}},nj=class extends mA{values;constructor(e,t,n,r){super(`COPY`,t,n,r),this.values=e.replace(/\r/g,``).split(`
|
|
1479
1479
|
`).map(e=>e.split(` `))}isPasteAllowed(e,t){let n=this.getters.getActiveSheetId(),r=this.getPasteZone(e);return this.getters.doesIntersectMerge(n,r)?`WillRemoveExistingMerge`:`Success`}paste(e,t){if(t?.pasteOption===`onlyFormat`)return;let n=this.values,r=this.getPasteZone(e),{left:i,top:a}=r,{numberOfCols:o,numberOfRows:s}=va(r),c=this.getters.getActiveSheetId(),l=this.getters.getLocale();this.addMissingDimensions(o,s,i,a);for(let e=0;e<n.length;e++)for(let t=0;t<n[e].length;t++)this.dispatch(`UPDATE_CELL`,{row:a+e,col:i+t,content:zc(n[e][t],l),sheetId:c});let u={left:i,top:a,right:i+o-1,bottom:a+s-1};this.selection.selectZone({cell:{col:i,row:a},zone:u},{scrollIntoView:!1})}getClipboardContent(){return{"text/plain":this.values.map(e=>e.join(` `)).join(`
|
|
1480
|
-
`)}}getPasteZone(e){let t=this.values.length,n=Nt(this.values.map(e=>e.length)),{left:r,top:i}=e[0];return{top:i,left:r,bottom:i+t-1,right:r+n-1}}},rj=class extends Q{static layers=[2];static getters=[`getClipboardContent`,`getClipboardTextContent`,`isCutOperation`,`isPaintingFormat`];status=`invisible`;state;lastPasteState;paintFormatStatus=`inactive`;originSheetId;allowDispatch(e){switch(e.type){case`CUT`:let t=this.getters.getSelectedZones();return this.getClipboardState(t,e.type).isCutAllowed(t);case`PASTE`:if(!this.state)return`EmptyClipboard`;let n=e.pasteOption||(this.paintFormatStatus===`inactive`?void 0:`onlyFormat`);return this.state.isPasteAllowed(e.target,{pasteOption:n});case`PASTE_FROM_OS_CLIPBOARD`:return new nj(e.text,this.getters,this.dispatch,this.selection).isPasteAllowed(e.target,{pasteOption:e.pasteOption});case`COPY_PASTE_CELLS_ABOVE`:{let e=this.getters.getSelectedZones();if(e.length>1||e[0].top===0&&e[0].bottom===0)return`InvalidCopyPasteSelection`;break}case`COPY_PASTE_CELLS_ON_LEFT`:{let e=this.getters.getSelectedZones();if(e.length>1||e[0].left===0&&e[0].right===0)return`InvalidCopyPasteSelection`;break}case`INSERT_CELL`:{let{cut:t,paste:n}=this.getInsertCellsTargets(e.zone,e.shiftDimension);return this.getClipboardStateForCopyCells(t,`CUT`,`shiftCells`).isPasteAllowed(n)}case`DELETE_CELL`:{let{cut:t,paste:n}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);return this.getClipboardStateForCopyCells(t,`CUT`,`shiftCells`).isPasteAllowed(n)}case`ACTIVATE_PAINT_FORMAT`:if(this.paintFormatStatus!==`inactive`)return`AlreadyInPaintingFormatMode`}return`Success`}handle(e){switch(e.type){case`COPY`:case`CUT`:let t=this.getters.getSelectedZones();this.state=this.getClipboardState(t,e.type),this.status=`visible`,this.originSheetId=this.getters.getActiveSheetId();break;case`PASTE`:if(!this.state)break;let n=e.pasteOption||(this.paintFormatStatus===`inactive`?void 0:`onlyFormat`);this.state.paste(e.target,{pasteOption:n,shouldPasteCF:!0,selectTarget:!0}),this.state.operation===`CUT`&&(this.state=void 0),this.lastPasteState=this.state,this.paintFormatStatus===`oneOff`&&(this.paintFormatStatus=`inactive`),this.status=`invisible`;break;case`COPY_PASTE_CELLS_ABOVE`:{let e=this.getters.getSelectedZone(),t=e.top!==e.bottom,n={...e,bottom:t?e.top:e.top-1,top:t?e.top:e.top-1};this.getClipboardStateForCopyCells([n],`COPY`).paste([e],{pasteOption:void 0,shouldPasteCF:!0,selectTarget:!0})}break;case`COPY_PASTE_CELLS_ON_LEFT`:{let e=this.getters.getSelectedZone(),t=e.left!==e.right,n={...e,right:t?e.left:e.left-1,left:t?e.left:e.left-1};this.getClipboardStateForCopyCells([n],`COPY`).paste([e],{pasteOption:void 0,shouldPasteCF:!0,selectTarget:!0})}break;case`CLEAN_CLIPBOARD_HIGHLIGHT`:this.status=`invisible`;break;case`DELETE_CELL`:{let{cut:t,paste:n}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);if(!ta(t[0])){this.dispatch(`CLEAR_CELLS`,{target:[e.zone],sheetId:this.getters.getActiveSheetId()});break}this.getClipboardStateForCopyCells(t,`CUT`,`shiftCells`).paste(n);break}case`INSERT_CELL`:{let{cut:t,paste:n}=this.getInsertCellsTargets(e.zone,e.shiftDimension);this.getClipboardStateForCopyCells(t,`CUT`,`shiftCells`).paste(n);break}case`ADD_COLUMNS_ROWS`:if(this.status=`invisible`,this.state?.operation!==`CUT`||e.sheetId!==this.state?.sheetId)return;this.state.isColRowDirtyingClipboard(e.position===`before`?e.base:e.base+1,e.dimension)&&(this.state=void 0);break;case`REMOVE_COLUMNS_ROWS`:if(this.status=`invisible`,this.state?.operation!==`CUT`||e.sheetId!==this.state?.sheetId)return;for(let t of e.elements)if(this.state.isColRowDirtyingClipboard(t,e.dimension)){this.state=void 0;break}this.status=`invisible`;break;case`PASTE_FROM_OS_CLIPBOARD`:this.state=new nj(e.text,this.getters,this.dispatch,this.selection),this.state.paste(e.target,{pasteOption:e.pasteOption}),this.lastPasteState=this.state,this.status=`invisible`;break;case`REPEAT_PASTE`:this.lastPasteState?.paste(e.target,{pasteOption:e.pasteOption,shouldPasteCF:!0,selectTarget:!0});break;case`ACTIVATE_PAINT_FORMAT`:{let t=this.getters.getSelectedZones();this.state=this.getClipboardStateForCopyCells(t,`COPY`),this.status=`visible`,e.persistent?this.paintFormatStatus=`persistent`:this.paintFormatStatus=`oneOff`;break}case`DELETE_SHEET`:if(this.state?.operation!==`CUT`)return;this.originSheetId===e.sheetId&&(this.state=void 0,this.status=`invisible`);break;case`CANCEL_PAINT_FORMAT`:this.paintFormatStatus=`inactive`,this.status=`invisible`;break;default:ur(e)&&(this.status=`invisible`)}}getClipboardContent(){return this.state?.getClipboardContent()||{"text/plain":` `}}getClipboardTextContent(){return this.state?.getClipboardContent()[`text/plain`]||` `}isCutOperation(){return this.state?this.state.operation===`CUT`:!1}isPaintingFormat(){return this.paintFormatStatus!==`inactive`}getDeleteCellsTargets(e,t){let n=this.getters.getActiveSheetId(),r;return r=t===`COL`?{...e,left:e.right+1,right:this.getters.getNumberCols(n)-1}:{...e,top:e.bottom+1,bottom:this.getters.getNumberRows(n)-1},{cut:[r],paste:[e]}}getInsertCellsTargets(e,t){let n=this.getters.getActiveSheetId(),r,i;return t===`COL`?(r={...e,right:this.getters.getNumberCols(n)-1},i={...e,left:e.right+1,right:e.right+1}):(r={...e,bottom:this.getters.getNumberRows(n)-1},i={...e,top:e.bottom+1,bottom:this.getters.getNumberRows(n)-1}),{cut:[r],paste:[i]}}getClipboardStateForCopyCells(e,t,n=`copyPaste`){return new hA(e,t,this.getters,this.dispatch,this.selection,n)}getClipboardState(e,t){return this.getters.getSelectedFigureId()?new $A(t,this.getters,this.dispatch):new hA(e,t,this.getters,this.dispatch,this.selection)}drawGrid(e){this.status!==`visible`||!this.state||this.state.drawClipboard(e)}};function ij(e){if(e.type!==`REFERENCE`)return e;let{xc:t,sheetName:n}=Xi(e.value),[r,i]=t.split(`:`),a=n?`${$e(n)}!`:``,o=aj(r),s=i?`:${aj(i)}`:``;return{...e,value:a+o+s}}function aj(e){switch(sj(e)){case`none`:e=oj(e,`colrow`);break;case`colrow`:e=oj(e,`row`);break;case`row`:e=oj(e,`col`);break;case`col`:e=oj(e,`none`);break}return e}function oj(e,t){e=e.replace(/\$/g,``);let n;switch(t){case`col`:return`$`+e;case`row`:return n=e.search(/[0-9]/),e.slice(0,n)+`$`+e.slice(n);case`colrow`:return n=e.search(/[0-9]/),n===-1||n===0||(e=e.slice(0,n)+`$`+e.slice(n)),`$`+e;case`none`:return e}}function sj(e){return uj(e)?`colrow`:cj(e)?`col`:lj(e)?`row`:`none`}function cj(e){return e.startsWith(`$`)}function lj(e){return e.includes(`$`,1)}function uj(e){return e.startsWith(`$`)&&e.length>1&&e.slice(1).includes(`$`)}let dj=y(`The cell you are trying to edit has been deleted.`);var fj=class extends Q{static getters=[`getEditionMode`,`isSelectingForComposer`,`showSelectionIndicator`,`getCurrentContent`,`getComposerSelection`,`getCurrentTokens`,`getTokenAtCursor`,`getComposerHighlights`,`getCurrentEditedCell`,`getCycledReference`,`getAutoCompleteDataValidationValues`];col=0;row=0;mode=`inactive`;sheetId=``;currentContent=``;currentTokens=[];selectionStart=0;selectionEnd=0;initialContent=``;colorIndexByRange={};allowDispatch(e){switch(e.type){case`CHANGE_COMPOSER_CURSOR_SELECTION`:return this.validateSelection(this.currentContent.length,e.start,e.end);case`SET_CURRENT_CONTENT`:if(e.selection)return this.validateSelection(e.content.length,e.selection.start,e.selection.end);break;case`START_EDITION`:if(e.selection){let t=e.text||this.getComposerContent(this.getters.getActivePosition());return this.validateSelection(t.length,e.selection.start,e.selection.end)}break;case`STOP_EDITION`:return this.mode===`inactive`?`Success`:this.checkDataValidation(e)}return`Success`}handleEvent(e){let t=this.getters.getActiveSheetId(),n;switch(n=e.options.unbounded?this.getters.getUnboundedZone(t,e.anchor.zone):e.anchor.zone,e.mode){case`newAnchor`:this.mode===`selecting`&&this.insertSelectedRange(n);break;default:this.mode===`selecting`?this.replaceSelectedRange(n):this.updateComposerRange(e.previousAnchor.zone,n);break}}handle(e){switch(e.type){case`CHANGE_COMPOSER_CURSOR_SELECTION`:this.selectionStart=e.start,this.selectionEnd=e.end,this.isSelectingForComposer()&&(this.mode=`editing`);break;case`STOP_COMPOSER_RANGE_SELECTION`:this.isSelectingForComposer()&&(this.mode=`editing`);break;case`START_EDITION`:this.mode!==`inactive`&&e.text?this.setContent(e.text,e.selection):this.startEdition(e.text,e.selection),this.updateRangeColor();break;case`STOP_EDITION`:this.stopEdition(),this.colorIndexByRange={};break;case`CANCEL_EDITION`:this.resetContent(),this.cancelEditionAndActivateSheet(),this.colorIndexByRange={};break;case`SET_CURRENT_CONTENT`:this.setContent(e.content,e.selection,!0),this.updateRangeColor();break;case`REPLACE_COMPOSER_CURSOR_SELECTION`:this.replaceSelection(e.text);break;case`SELECT_FIGURE`:this.resetContent(),this.cancelEditionAndActivateSheet();break;case`ADD_COLUMNS_ROWS`:this.onAddElements(e);break;case`REMOVE_COLUMNS_ROWS`:e.dimension===`COL`?this.onColumnsRemoved(e):this.onRowsRemoved(e);break;case`START_CHANGE_HIGHLIGHT`:let{left:t,top:n}=e.zone;this.isSelectingForComposer()&&(this.mode=`editing`),this.selection.resetAnchor(this,{cell:{col:t,row:n},zone:e.zone});break;case`ACTIVATE_SHEET`:if(this.currentContent.startsWith(`=`)||(this.cancelEdition(),this.resetContent()),this.selection.isListening(this)&&e.sheetIdFrom!==e.sheetIdTo){let t=this.getters.getActivePosition(),{col:n,row:r}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:t.col,row:t.row}),i=this.getters.expandZone(e.sheetIdTo,V({col:n,row:r}));this.selection.resetAnchor(this,{cell:{col:n,row:r},zone:i})}break;case`DELETE_SHEET`:case`UNDO`:case`REDO`:!this.getters.tryGetSheet(this.sheetId)&&this.mode!==`inactive`&&(this.sheetId=this.getters.getActiveSheetId(),this.resetContent(),this.cancelEditionAndActivateSheet(),this.ui.raiseBlockingErrorUI(dj));break;case`CYCLE_EDITION_REFERENCES`:this.cycleReferences();break}}getEditionMode(){return this.mode}getCurrentContent(){return this.mode===`inactive`?this.getComposerContent(this.getters.getActivePosition()):this.currentContent}getComposerSelection(){return{start:this.selectionStart,end:this.selectionEnd}}getCurrentEditedCell(){return{sheetId:this.sheetId,col:this.col,row:this.row}}isSelectingForComposer(){return this.mode===`selecting`}showSelectionIndicator(){return this.isSelectingForComposer()&&this.canStartComposerRangeSelection()}getCurrentTokens(){return this.currentTokens}getTokenAtCursor(){let e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);if(!(e===t&&t===0))return this.currentTokens.find(n=>n.start<=e&&n.end>=t)}getCycledReference(e,t){let n=this.getters.getLocale(),r=(t.startsWith(`=`)?UT(t,n):[]).filter(t=>t.start<=e.start&&t.end>=e.start||t.start>=e.start&&t.start<e.end),i=r.filter(e=>e.type===`REFERENCE`);if(i.length===0)return;let a=r.map(ij).map(e=>e.value).join(``),o=r[0].start,s=r[r.length-1].end,c=t.slice(0,o)+a+t.slice(s),l=c.length-t.length,u={start:i[0].start,end:i[i.length-1].end+l};return i.length===1&&e.start===e.end&&(u.start=u.end),{content:c,selection:u}}getInitialComposerContent(){return this.initialContent}cycleReferences(){let e=this.getCycledReference(this.getComposerSelection(),this.currentContent);e!==void 0&&this.dispatch(`SET_CURRENT_CONTENT`,{content:e.content,selection:e.selection})}validateSelection(e,t,n){return t>=0&&t<=e&&n>=0&&n<=e?`Success`:`WrongComposerSelection`}onColumnsRemoved(e){if(e.elements.includes(this.col)&&this.mode!==`inactive`){this.dispatch(`CANCEL_EDITION`),this.ui.raiseBlockingErrorUI(dj);return}let{top:t,left:n}=aa({left:this.col,right:this.col,top:this.row,bottom:this.row},`left`,[...e.elements]);this.col=n,this.row=t}onRowsRemoved(e){if(e.elements.includes(this.row)&&this.mode!==`inactive`){this.dispatch(`CANCEL_EDITION`),this.ui.raiseBlockingErrorUI(dj);return}let{top:t,left:n}=aa({left:this.col,right:this.col,top:this.row,bottom:this.row},`top`,[...e.elements]);this.col=n,this.row=t}onAddElements(e){let{top:t,left:n}=ia({left:this.col,right:this.col,top:this.row,bottom:this.row},e.dimension===`COL`?`left`:`top`,e.base,e.position,e.quantity);this.col=n,this.row=t}startComposerRangeSelection(){if(this.sheetId===this.getters.getActiveSheetId()){let e=V({col:this.col,row:this.row});this.selection.resetAnchor(this,{cell:{col:this.col,row:this.row},zone:e})}this.mode=`selecting`}startEdition(e,t){let n=this.getters.getActiveCell(),r=this.getters.getLocale();e&&n.format?.includes(`%`)&&Yn(e,r)&&(t||={start:e.length,end:e.length},e=`${e}%`);let{col:i,row:a,sheetId:o}=this.getters.getActivePosition();this.col=i,this.sheetId=o,this.row=a,this.initialContent=this.getComposerContent({sheetId:o,col:i,row:a}),this.mode=`editing`,this.setContent(e||this.initialContent,t),this.colorIndexByRange={};let s=V({col:this.col,row:this.row});this.selection.capture(this,{cell:{col:this.col,row:this.row},zone:s},{handleEvent:this.handleEvent.bind(this),release:()=>{this.stopEdition()}})}stopEdition(){if(this.mode!==`inactive`){this.cancelEditionAndActivateSheet();let e=this.col,t=this.row,n=this.getCurrentCanonicalContent();if(this.initialContent===n)return;if(n){let r=this.getters.getActiveSheetId(),i=this.getters.getEvaluatedCell({sheetId:r,col:this.col,row:this.row});if(n.startsWith(`=`)){let e=this.currentTokens.filter(e=>e.type===`LEFT_PAREN`).length-this.currentTokens.filter(e=>e.type===`RIGHT_PAREN`).length;e>0&&(n+=_t(Array(e).fill(`)`)))}else i.link&&(n=st(n,i.link.url));this.dispatch(`UPDATE_CELL`,{sheetId:this.sheetId,col:e,row:t,content:n})}else this.dispatch(`UPDATE_CELL`,{sheetId:this.sheetId,content:``,col:e,row:t});this.setContent(``)}}getCurrentCanonicalContent(){return Ic(this.currentContent,this.getters.getLocale())}cancelEditionAndActivateSheet(){this.mode!==`inactive`&&(this.cancelEdition(),this.getters.getActiveSheetId()!==this.sheetId&&this.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:this.getters.getActiveSheetId(),sheetIdTo:this.sheetId}))}getComposerContent(e){let t=this.getters.getLocale(),n=this.getters.getCell(e);if(n?.isFormula)return Vc(n.content,t);let{format:r,value:i,type:a,formattedValue:o}=this.getters.getEvaluatedCell(e);switch(a){case`text`:case`empty`:return i;case`boolean`:return o;case`error`:return n?.content||``;case`number`:return r&&_i(r)?yn(o,t)===null?z(i,{locale:t,format:Number.isInteger(i)?t.dateFormat:Qc(t)}):o:this.numberComposerContent(i,r,t)}}numberComposerContent(e,t,n){return t?.includes(`%`)?`${gi(e*100,n.decimalSeparator)}%`:gi(e,n.decimalSeparator)}cancelEdition(){this.mode!==`inactive`&&(this.mode=`inactive`,this.selection.release(this))}resetContent(){this.setContent(this.initialContent||``)}setContent(e,t,n){let r=this.currentContent!==e;if(this.currentContent=e,t?(this.selectionStart=t.start,this.selectionEnd=t.end):this.selectionStart=this.selectionEnd=e.length,r||this.mode!==`inactive`){let t=this.getters.getLocale();this.currentTokens=e.startsWith(`=`)?UT(e,t):[],this.currentTokens.length>100&&n&&this.ui.raiseBlockingErrorUI(y(`This formula has over 100 parts. It can't be processed properly, consider splitting it into multiple cells`))}this.canStartComposerRangeSelection()&&this.startComposerRangeSelection()}insertSelectedRange(e){let t=Math.min(this.selectionStart,this.selectionEnd),n=this.getZoneReference(e);this.canStartComposerRangeSelection()?this.insertText(n,t):this.insertText(`,`+n,t)}replaceSelectedRange(e){let t=this.getZoneReference(e),n=this.getTokenAtCursor(),r=n?.type===`REFERENCE`?n.start:this.selectionStart;this.replaceText(t,r,this.selectionEnd)}updateComposerRange(e,t){let n=this.getters.getActiveSheetId(),r=this.getTokenAtCursor(),i=(r?[r,...this.currentTokens]:this.currentTokens).filter(e=>e.type===`REFERENCE`).find(t=>{let{xc:r,sheetName:i}=Xi(t.value),a=i||this.getters.getSheetName(this.sheetId);if(!Ga(this.getters.getSheetName(n),a))return!1;let o=this.getters.getRangeFromSheetXC(n,r);return la(this.getters.expandZone(n,o.zone),e)});if(!i)return;let a=this.getters.getRangeFromSheetXC(n,i.value);this.selectionStart=i.start,this.selectionEnd=this.selectionStart+i.value.length;let o=this.getters.getRangeFromZone(n,t),s=this.getRangeReference(o,a.parts);this.replaceSelection(s)}getZoneReference(e){let t=this.getters.getCurrentEditedCell().sheetId,n=this.getters.getActiveSheetId(),r=this.getters.getRangeFromZone(n,e);return this.getters.getSelectionRangeString(r,t)}getRangeReference(e,t){let n=[...t],r=e.clone({parts:n});return this.getters.getSelectionRangeString(r,this.getters.getCurrentEditedCell().sheetId)}replaceSelection(e){let t=Math.min(this.selectionStart,this.selectionEnd),n=Math.max(this.selectionStart,this.selectionEnd);this.replaceText(e,t,n)}replaceText(e,t,n){this.currentContent=this.currentContent.slice(0,t)+this.currentContent.slice(n,this.currentContent.length),this.insertText(e,t)}insertText(e,t){let n=this.currentContent.slice(0,t)+e+this.currentContent.slice(t),r=t+e.length;this.dispatch(`SET_CURRENT_CONTENT`,{content:n,selection:{start:r,end:r}})}updateRangeColor(){if(!this.currentContent.startsWith(`=`)||this.mode===`inactive`)return;let e=this.getters.getCurrentEditedCell().sheetId,t=this.getReferencedRanges().map(t=>this.getters.getRangeString(t,e)),n={};for(let e of t)this.colorIndexByRange[e]!==void 0&&(n[e]=this.colorIndexByRange[e]);let r=new Set(Object.values(n)),i=0,a=()=>{for(;r.has(i);)i++;return r.add(i),i};for(let e of t)n[e]=e in n?n[e]:a();this.colorIndexByRange=n}getComposerHighlights(){if(!this.currentContent.startsWith(`=`)||this.mode===`inactive`)return[];let e=this.getters.getCurrentEditedCell().sheetId,t=e=>Lt[this.colorIndexByRange[e]%Lt.length];return this.getReferencedRanges().map(n=>{let r=this.getters.getRangeString(n,e);return{zone:n.zone,color:t(r),sheetId:n.sheetId}})}getReferencedRanges(){let e=this.getters.getCurrentEditedCell().sheetId;return this.currentTokens.filter(e=>e.type===`REFERENCE`).map(t=>this.getters.getRangeFromSheetXC(e,t.value)).filter(e=>!e.invalidSheetName&&!e.invalidXc)}getAutoCompleteDataValidationValues(){if(this.mode===`inactive`)return[];let e=this.getters.getValidationRuleForCell(this.getCurrentEditedCell());if(!e||e.criterion.type!==`isValueInList`&&e.criterion.type!==`isValueInRange`)return[];let t;if(e.criterion.type===`isValueInList`)t=e.criterion.values;else{let n=this.getters.getRangeFromSheetXC(this.sheetId,e.criterion.values[0]);t=Array.from(new Set(this.getters.getRangeValues(n).filter(pt).map(e=>e.toString()).filter(e=>e!==``)))}let n=this.getCurrentContent();if(n&&n!==this.getInitialComposerContent()){let e=za(n,t,e=>e);t=e.length?e:t}return t}canStartComposerRangeSelection(){if(this.currentContent.startsWith(`=`)){let e=this.getTokenAtCursor();if(!e)return!1;let t=this.currentTokens.map(e=>e.start).indexOf(e.start),n=t,r=e;for(;![`ARG_SEPARATOR`,`LEFT_PAREN`,`OPERATOR`].includes(r.type)||gc.includes(r.value);){if(r.type!==`SPACE`||n<1)return!1;n--,r=this.currentTokens[n]}for(n=t+1,r=this.currentTokens[n];r&&![`ARG_SEPARATOR`,`RIGHT_PAREN`,`OPERATOR`].includes(r.type);){if(r.type!==`SPACE`)return!1;n++,r=this.currentTokens[n]}return!0}return!1}checkDataValidation(e){let t={sheetId:this.sheetId,col:this.col,row:this.row};try{let e=this.getCurrentCanonicalContent(),n=e.startsWith(`=`)?this.getters.evaluateFormula(this.sheetId,e):to(e,this.getters.getLocale());if(j(n))return`Success`;let r=this.getters.getValidationResultForCellValue(n,t);return!r.isValid&&r.rule.isBlocking?`BlockingValidationRule`:`Success`}catch{return this.getters.getValidationRuleForCell(t)?.isBlocking?`BlockingValidationRule`:`Success`}}},pj=class extends Q{static getters=[`getCellBorderWithFilterBorder`,`getFilterValues`,`isRowFiltered`,`isFilterActive`];filterValues={};hiddenRows={};isEvaluationDirty=!1;allowDispatch(e){switch(e.type){case`UPDATE_FILTER`:if(!this.getters.getFilterId(e))return`FilterNotFound`;break}return`Success`}handle(e){switch(e.type){case`UNDO`:case`REDO`:case`UPDATE_CELL`:case`EVALUATE_CELLS`:case`ACTIVATE_SHEET`:case`REMOVE_FILTER_TABLE`:case`ADD_COLUMNS_ROWS`:case`REMOVE_COLUMNS_ROWS`:this.isEvaluationDirty=!0;break;case`START`:for(let e of this.getters.getSheetIds()){this.filterValues[e]={};for(let t of this.getters.getFilters(e))this.filterValues[e][t.id]=[]}break;case`CREATE_SHEET`:this.filterValues[e.sheetId]={};break;case`HIDE_COLUMNS_ROWS`:case`UNHIDE_COLUMNS_ROWS`:case`GROUP_HEADERS`:case`UNGROUP_HEADERS`:case`FOLD_HEADER_GROUP`:case`UNFOLD_HEADER_GROUP`:case`FOLD_ALL_HEADER_GROUPS`:case`UNFOLD_ALL_HEADER_GROUPS`:this.updateHiddenRows(e.sheetId);break;case`UPDATE_FILTER`:this.updateFilter(e),this.updateHiddenRows(e.sheetId);break;case`DUPLICATE_SHEET`:let t={};for(let n of this.getters.getFilters(e.sheetIdTo)){let r=n.zoneWithHeaders;t[n.id]=this.getFilterValues({sheetId:e.sheetId,col:r.left,row:r.top})}this.filterValues[e.sheetIdTo]=t;break}}finalize(){if(this.isEvaluationDirty){for(let e of this.getters.getSheetIds())this.updateHiddenRows(e);this.isEvaluationDirty=!1}}isRowFiltered(e,t){return!!this.hiddenRows[e]?.has(t)}getCellBorderWithFilterBorder(e){let{sheetId:t,col:n,row:r}=e,i;for(let e of this.getters.getFilterTables(t)){let a=e.zone;if(da(n,r,a)){let e=this.intersectZoneWithViewport(t,a);i={top:r===e.top?Fe:void 0,bottom:r===e.bottom?Fe:void 0,left:n===e.left?Fe:void 0,right:n===e.right?Fe:void 0}}}let a=this.getters.getCellBorder(e),o={...i,...St(a||{})};return mt(o)?null:o}getFilterValues(e){let t=this.getters.getFilterId(e),n=e.sheetId;return!t||!this.filterValues[n]?[]:this.filterValues[n][t]||[]}isFilterActive(e){let t=this.getters.getFilterId(e),n=e.sheetId;return!!(t&&this.filterValues[n]?.[t]?.length)}intersectZoneWithViewport(e,t){return{left:this.getters.findVisibleHeader(e,`COL`,t.left,t.right),right:this.getters.findVisibleHeader(e,`COL`,t.right,t.left),top:this.getters.findVisibleHeader(e,`ROW`,t.top,t.bottom),bottom:this.getters.findVisibleHeader(e,`ROW`,t.bottom,t.top)}}updateFilter({col:e,row:t,hiddenValues:n,sheetId:r}){let i=this.getters.getFilterId({sheetId:r,col:e,row:t});i&&(this.filterValues[r]||(this.filterValues[r]={}),this.filterValues[r][i]=n)}updateHiddenRows(e){let t=this.getters.getFilters(e).sort((e,t)=>e.zoneWithHeaders.top-t.zoneWithHeaders.top),n=new Set;for(let r of t){if(n.has(r.zoneWithHeaders.top)||this.getters.isRowHiddenByUser(e,r.zoneWithHeaders.top))continue;let t=this.filterValues[e]?.[r.id]?.map(To);if(!t||!r.filteredZone)continue;let i=new Set(t);for(let t=r.filteredZone.top;t<=r.filteredZone.bottom;t++){let a=this.getCellValueAsString(e,r.col,t);i.has(a)&&n.add(t)}}this.hiddenRows[e]=n}getCellValueAsString(e,t,n){return this.getters.getEvaluatedCell({sheetId:e,col:t,row:n}).formattedValue.toLowerCase()}exportForExcel(e){for(let t of e.sheets){let e=t.id;for(let n of t.filterTables){let r=ea(n.range),i=[],a=[];for(let n of w(0,va(r).numberOfCols)){let o={sheetId:t.id,col:r.left+n,row:r.top},s=this.getFilterValues(o),c=this.getters.getFilter(o);if(!c)continue;let l=c.filteredZone?ba(c.filteredZone).map(t=>this.getters.getEvaluatedCell({sheetId:e,...t}).formattedValue):[];if(s.length){let e=l.filter(e=>e).filter(e=>!s.includes(e));i.push({colId:n,displayedValues:[...new Set(e)],displayBlanks:!s.includes(``)&&l.some(e=>!e)})}let u={col:c.col,row:c.zoneWithHeaders.top,sheetId:e},d=this.getters.getEvaluatedCell(u).formattedValue,f=this.getUniqueColNameForExcel(n,d,a);a.push(f),t.cells[O(u.col,u.row)]={...t.cells[O(u.col,u.row)],content:f,value:f,isFormula:!1}}n.filters=i}}}getUniqueColNameForExcel(e,t,n){t||=`Column${e}`;let r=t,i=2;for(;n.includes(r);)r=t+String(i),i++;return r}};let mj=[{name:y(`Sum`),types:[`number`],compute:(e,t)=>Kp.compute.bind({locale:t})([e])},{name:y(`Avg`),types:[`number`],compute:(e,t)=>gm.compute.bind({locale:t})([e])},{name:y(`Min`),types:[`number`],compute:(e,t)=>zm.compute.bind({locale:t})([e])},{name:y(`Max`),types:[`number`],compute:(e,t)=>Fm.compute.bind({locale:t})([e])},{name:y(`Count`),types:[`number`,`text`,`boolean`,`error`],compute:(e,t)=>wm.compute.bind({locale:t})([e])},{name:y(`Count Numbers`),types:[`number`,`text`,`boolean`,`error`],compute:(e,t)=>Cm.compute.bind({locale:t})([e])}];var hj=class extends Q{static layers=[6];static getters=[`getActiveSheet`,`getActiveSheetId`,`getActiveCell`,`getActiveCols`,`getActiveRows`,`getCurrentStyle`,`getSelectedZones`,`getSelectedZone`,`getSelectedCells`,`getStatisticFnResults`,`getAggregate`,`getSelectedFigureId`,`getSelection`,`getActivePosition`,`getSheetPosition`,`isSelected`,`isSingleColSelected`,`getElementsFromSelection`,`tryGetActiveSheetId`,`isGridSelectionActive`];gridSelection={anchor:{cell:{col:0,row:0},zone:{top:0,left:0,bottom:0,right:0}},zones:[{top:0,left:0,bottom:0,right:0}]};selectedFigureId=null;sheetsData={};moveClient;activeSheet=null;constructor(e){super(e),this.moveClient=e.moveClient}allowDispatch(e){switch(e.type){case`ACTIVATE_SHEET`:try{this.getters.getSheet(e.sheetIdTo);break}catch{return`InvalidSheetId`}case`MOVE_COLUMNS_ROWS`:return this.isMoveElementAllowed(e)}return`Success`}handleEvent(e){let t=e.anchor,n=[];switch(e.mode){case`overrideSelection`:n=[t.zone];break;case`updateAnchor`:n=[...this.gridSelection.zones];let r=n.findIndex(t=>la(t,e.previousAnchor.zone));r>=0&&(n[r]=t.zone);break;case`newAnchor`:n=[...this.gridSelection.zones,t.zone];break}this.setSelectionMixin(e.anchor,n),this.selection.resetDefaultAnchor(this,S(this.gridSelection.anchor));let{col:r,row:i}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:r,row:i}),this.selectedFigureId=null}handle(e){switch(e.type){case`START_EDITION`:case`ACTIVATE_SHEET`:this.selectedFigureId=null;break;case`DELETE_FIGURE`:this.selectedFigureId===e.id&&(this.selectedFigureId=null);break;case`DELETE_SHEET`:this.selectedFigureId&&this.getters.getFigure(e.sheetId,this.selectedFigureId)&&(this.selectedFigureId=null);break}switch(e.type){case`START`:let t=this.getters.getVisibleSheetIds()[0];this.activateSheet(t,t);let{col:n,row:r}=this.getters.getNextVisibleCellPosition({sheetId:t,col:0,row:0});this.selectCell(n,r),this.selection.registerAsDefault(this,this.gridSelection.anchor,{handleEvent:this.handleEvent.bind(this)}),this.moveClient({sheetId:t,col:0,row:0});break;case`ACTIVATE_SHEET`:this.activateSheet(e.sheetIdFrom,e.sheetIdTo);break;case`REMOVE_COLUMNS_ROWS`:{let t=this.getters.getActiveSheetId();if(e.sheetId===t){e.dimension===`COL`?this.onColumnsRemoved(e):this.onRowsRemoved(e);let{col:n,row:r}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:n,row:r})}break}case`ADD_COLUMNS_ROWS`:{let t=this.getters.getActiveSheetId();if(e.sheetId===t){this.onAddElements(e);let{col:n,row:r}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:n,row:r})}break}case`MOVE_COLUMNS_ROWS`:e.sheetId===this.getActiveSheetId()&&this.onMoveElements(e);break;case`SELECT_FIGURE`:this.selectedFigureId=e.id;break;case`ACTIVATE_NEXT_SHEET`:this.activateNextSheet(`right`);break;case`ACTIVATE_PREVIOUS_SHEET`:this.activateNextSheet(`left`);break;case`HIDE_SHEET`:e.sheetId===this.getActiveSheetId()&&this.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:e.sheetId,sheetIdTo:this.getters.getVisibleSheetIds()[0]});break;case`UNDO`:case`REDO`:case`DELETE_SHEET`:let i=Object.keys(this.sheetsData).filter(e=>!this.getters.tryGetSheet(e));for(let e of i)delete this.sheetsData[e];for(let e in this.sheetsData){let t=this.clipSelection(e,this.sheetsData[e].gridSelection);this.sheetsData[e]={gridSelection:S(t)}}this.fallbackToVisibleSheet();let a=this.getters.getActiveSheetId();this.gridSelection.zones=this.gridSelection.zones.map(e=>this.getters.expandZone(a,e)),this.gridSelection.anchor.zone=this.getters.expandZone(a,this.gridSelection.anchor.zone),this.setSelectionMixin(this.gridSelection.anchor,this.gridSelection.zones),this.selectedFigureId=null;break}}finalize(){this.fallbackToVisibleSheet(),this.selection.resetDefaultAnchor(this,S(this.gridSelection.anchor))}isGridSelectionActive(){return this.selection.isListening(this)}getActiveSheet(){return this.activeSheet}getActiveSheetId(){return this.activeSheet.id}tryGetActiveSheetId(){return this.activeSheet?.id}getActiveCell(){return this.getters.getEvaluatedCell(this.getActivePosition())}getActiveCols(){let e=new Set;for(let t of this.gridSelection.zones)if(t.top===0&&t.bottom===this.getters.getNumberRows(this.getters.getActiveSheetId())-1)for(let n=t.left;n<=t.right;n++)e.add(n);return e}getActiveRows(){let e=new Set,t=this.getters.getActiveSheetId();for(let n of this.gridSelection.zones)if(n.left===0&&n.right===this.getters.getNumberCols(t)-1)for(let t=n.top;t<=n.bottom;t++)e.add(t);return e}getCurrentStyle(){let e=this.getters.getSelectedZone(),t=this.getters.getActiveSheetId();return this.getters.getCellStyle({sheetId:t,col:e.left,row:e.top})}getSelectedZones(){return S(this.gridSelection.zones)}getSelectedZone(){return S(this.gridSelection.anchor.zone)}getSelection(){return S(this.gridSelection)}getSelectedCells(){let e=this.getters.getActiveSheetId(),t=[];for(let n of this.gridSelection.zones)t.push(...this.getters.getEvaluatedCellsInZone(e,n));return t}getSelectedFigureId(){return this.selectedFigureId}getActivePosition(){return this.getters.getMainCellPosition({sheetId:this.getActiveSheetId(),col:this.gridSelection.anchor.cell.col,row:this.gridSelection.anchor.cell.row})}getSheetPosition(e){if(e===this.getters.getActiveSheetId())return this.getActivePosition();{let t=this.sheetsData[e];return t?{sheetId:e,col:t.gridSelection.anchor.cell.col,row:t.gridSelection.anchor.cell.row}:this.getters.getNextVisibleCellPosition({sheetId:e,col:0,row:0})}}getStatisticFnResults(){let e=this.getters.getActiveSheetId(),t=new Set;for(let n of this.gridSelection.zones)for(let{col:r,row:i}of ba(n)){if(this.getters.isRowHidden(e,i)||this.getters.isColHidden(e,r))continue;let n=this.getters.getEvaluatedCell({sheetId:e,col:r,row:i});n.type!==`empty`&&t.add(n)}let n=new Set,r=[];for(let e of t)n.add(e.type),r.push(e.value);let i=this.getters.getLocale(),a={};for(let e of mj){let t;e.types.some(e=>n.has(e))&&(t=e.compute(r,i)),a[e.name]=t}return a}getAggregate(){let e=0,t=0,n=this.getters.getActiveSheetId(),r=this.gridSelection.zones.map(ba).flat();for(let{col:i,row:a}of r){let r=this.getters.getEvaluatedCell({sheetId:n,col:i,row:a});r.type===`number`&&(t++,e+=r.value)}let i=this.getters.getLocale();return t<2?null:z(e,{locale:i})}isSelected(e){return!!this.getters.getSelectedZones().find(t=>la(t,e))}isSingleColSelected(){let e=this.getters.getSelectedZones();return!(e.length!==1||e[0].left!==e[0].right)}getElementsFromSelection(e){if(e===`COL`&&this.getters.getActiveCols().size===0||e===`ROW`&&this.getters.getActiveRows().size===0)return[];let t=this.getters.getSelectedZones(),n=[],r=e===`COL`?`left`:`top`,i=e===`COL`?`right`:`bottom`;for(let e of t){let t=Array.from({length:e[i]-e[r]+1},(t,n)=>e[r]+n);n=n.concat(t)}return[...new Set(n)].sort()}activateSheet(e,t){if(this.getters.isSheetVisible(t)||this.dispatch(`SHOW_SHEET`,{sheetId:t}),this.setActiveSheet(t),this.sheetsData[e]={gridSelection:S(this.gridSelection)},t in this.sheetsData)Object.assign(this,this.sheetsData[t]),this.selection.resetDefaultAnchor(this,S(this.gridSelection.anchor));else{let{col:e,row:n}=this.getters.getNextVisibleCellPosition({sheetId:t,col:0,row:0});this.selectCell(e,n)}let{col:n,row:r}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.activeSheet.id,col:n,row:r})}setSelectionMixin(e,t){let{anchor:n,zones:r}=this.clipSelection(this.getters.getActiveSheetId(),{anchor:e,zones:t});this.gridSelection.anchor=n,this.gridSelection.zones=Ca(r)}selectCell(e,t){let n=this.getters.getActiveSheetId(),r=this.getters.expandZone(n,{left:e,right:e,top:t,bottom:t});this.setSelectionMixin({zone:r,cell:{col:e,row:t}},[r])}setActiveSheet(e){let t=this.getters.getSheet(e);this.activeSheet=t}activateNextSheet(e){let t=this.getters.getSheetIds(),n=(t.findIndex(e=>e===this.activeSheet.id)+(e===`left`?t.length-1:1))%t.length;this.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:this.getActiveSheetId(),sheetIdTo:t[n]})}onColumnsRemoved(e){let{cell:t,zone:n}=this.gridSelection.anchor,r=aa(n,`left`,[...e.elements]),i={left:t.col,right:t.col,top:t.row,bottom:t.row};i=aa(i,`left`,[...e.elements]);let a={cell:{col:i.left,row:i.top},zone:r},o=this.gridSelection.zones.map(t=>aa(t,`left`,[...e.elements]));this.setSelectionMixin(a,o)}onRowsRemoved(e){let{cell:t,zone:n}=this.gridSelection.anchor,r=aa(n,`top`,[...e.elements]),i={left:t.col,right:t.col,top:t.row,bottom:t.row};i=aa(i,`top`,[...e.elements]);let a={cell:{col:i.left,row:i.top},zone:r},o=this.gridSelection.zones.map(t=>aa(t,`top`,[...e.elements]));this.setSelectionMixin(a,o)}onAddElements(e){let t=e.dimension===`COL`?`left`:`top`,n=ia(this.gridSelection.anchor.zone,t,e.base,e.position,e.quantity),r=this.gridSelection.zones.map(n=>ia(n,t,e.base,e.position,e.quantity)),i={cell:{col:n.left,row:n.top},zone:n};this.setSelectionMixin(i,r)}onMoveElements(e){let t=e.elements.length;this.dispatch(`ADD_COLUMNS_ROWS`,{dimension:e.dimension,sheetId:e.sheetId,base:e.base,quantity:t,position:e.position});let n=e.dimension===`COL`,r=e.elements[0],i=e.elements[t-1],a=e.base<r,o=a&&n?t:0,s=a&&!n?t:0,c=a?e.elements.map(e=>e+t):e.elements,l=Object.fromEntries(c.map(t=>{let r=n?this.getters.getColSize(e.sheetId,t):this.getters.getUserRowSize(e.sheetId,t);return[t,n&&r===96||r===void 0?null:r]})),u=new hA([{left:n?r+o:0,right:n?i+o:this.getters.getNumberCols(e.sheetId)-1,top:n?0:r+s,bottom:n?this.getters.getNumberRows(e.sheetId)-1:i+s}],`CUT`,this.getters,this.dispatch,this.selection,`shiftCells`),d=a?e.base:e.base+1,f=[{left:n?d:0,right:n?d+t-1:this.getters.getNumberCols(e.sheetId)-1,top:n?0:d,bottom:n?this.getters.getNumberRows(e.sheetId)-1:d+t-1}];u.paste(f,{selectTarget:!0});let p=a?e.base:e.base+1;for(let t of c)this.dispatch(`RESIZE_COLUMNS_ROWS`,{dimension:e.dimension,sheetId:e.sheetId,size:l[t],elements:[p]}),p+=1;this.dispatch(`REMOVE_COLUMNS_ROWS`,{dimension:e.dimension,sheetId:e.sheetId,elements:c})}isMoveElementAllowed(e){let t=e.dimension===`COL`,n=e.elements[0],r=e.elements[e.elements.length-1],i=e.sheetId,a=t?this.getters.doesColumnsHaveCommonMerges:this.getters.doesRowsHaveCommonMerges;if(a(i,n-1,n)||a(i,r,r+1)||a(i,e.base-1,e.base))return`WillRemoveExistingMerge`;let o=[e.base,...e.elements],s=t?this.getters.getNumberCols(i):this.getters.getNumberRows(i);return o.some(e=>e<0||e>=s)?`InvalidHeaderIndex`:`Success`}fallbackToVisibleSheet(){if(!this.getters.tryGetSheet(this.getters.getActiveSheetId())){let e=this.getters.getVisibleSheetIds();if(this.activeSheet=this.getters.getSheet(e[0]),this.activeSheet.id in this.sheetsData){let{anchor:e}=this.clipSelection(this.activeSheet.id,this.sheetsData[this.activeSheet.id].gridSelection);this.selectCell(e.cell.col,e.cell.row)}else this.selectCell(0,0);let{col:t,row:n}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:t,row:n})}}clipSelection(e,t){let n=this.getters.getNumberCols(e)-1,r=this.getters.getNumberRows(e)-1,i=t.zones.map(e=>({left:C(e.left,0,n),right:C(e.right,0,n),top:C(e.top,0,r),bottom:C(e.bottom,0,r)})),a=C(t.anchor.cell.col,0,n),o=C(t.anchor.cell.row,0,r),s={left:C(t.anchor.zone.left,0,n),right:C(t.anchor.zone.right,0,n),top:C(t.anchor.zone.top,0,r),bottom:C(t.anchor.zone.bottom,0,r)};return{zones:i,anchor:{cell:{col:a,row:o},zone:s}}}drawGrid(e){if(this.getters.isDashboard())return;let{ctx:t,thinLineWidth:n}=e,r=this.getSelectedZones();t.fillStyle=`#f3f7fe`,t.fillStyle=r.length===1&&r[0].left===r[0].right&&r[0].top===r[0].bottom?`#f3f7fe`:`#e9f0ff`,t.strokeStyle=pe,t.lineWidth=1.5*n;for(let e of r){let{x:n,y:r,width:i,height:a}=this.getters.getVisibleRect(e);t.globalCompositeOperation=`multiply`,t.fillRect(n,r,i,a),t.globalCompositeOperation=`source-over`,t.strokeRect(n,r,i,a)}t.globalCompositeOperation=`source-over`;let i=this.getActivePosition();t.strokeStyle=pe,t.lineWidth=3*n;let a;a=this.getters.isInMerge(i)?this.getters.getMerge(i):V(i);let{x:o,y:s,width:c,height:l}=this.getters.getVisibleRect(a);c>0&&l>0&&t.strokeRect(o,s,c,l)}},gj=class{getters;sheetId;boundaries;top;bottom;left;right;offsetX;offsetY;offsetScrollbarX;offsetScrollbarY;canScrollVertically;canScrollHorizontally;viewportWidth;viewportHeight;offsetCorrectionX;offsetCorrectionY;constructor(e,t,n,r,i,a){if(this.getters=e,this.sheetId=t,this.boundaries=n,r.width<0||r.height<0)throw Error(`Viewport size cannot be negative`);this.viewportWidth=r.height&&r.width,this.viewportHeight=r.width&&r.height,this.top=n.top,this.bottom=n.bottom,this.left=n.left,this.right=n.right,this.offsetX=a.x,this.offsetY=a.y,this.offsetScrollbarX=a.x,this.offsetScrollbarY=a.y,this.canScrollVertically=i.canScrollVertically,this.canScrollHorizontally=i.canScrollHorizontally,this.offsetCorrectionX=this.getters.getColDimensions(this.sheetId,this.boundaries.left).start,this.offsetCorrectionY=this.getters.getRowDimensions(this.sheetId,this.boundaries.top).start,this.adjustViewportOffsetX(),this.adjustViewportOffsetY()}getMaxSize(){let e=this.getters.findLastVisibleColRowIndex(this.sheetId,`COL`,{first:this.boundaries.left,last:this.boundaries.right}),t=this.getters.findLastVisibleColRowIndex(this.sheetId,`ROW`,{first:this.boundaries.top,last:this.boundaries.bottom}),{end:n,size:r}=this.getters.getColDimensions(this.sheetId,e),{end:i,size:a}=this.getters.getRowDimensions(this.sheetId,t),o=this.searchHeaderIndex(`COL`,n-this.viewportWidth,0),s=this.getters.getColSize(this.sheetId,o),c=this.searchHeaderIndex(`ROW`,i-this.viewportHeight,0),l=this.getters.getRowSize(this.sheetId,c),u=n-this.offsetCorrectionX;this.canScrollHorizontally&&(u+=Math.max(96,Math.min(s,this.viewportWidth-r)),u=Math.max(u,this.viewportWidth));let d=i-this.offsetCorrectionY;return this.canScrollVertically&&(d+=Math.max(28,Math.min(l,this.viewportHeight-a)),d=Math.max(d,this.viewportHeight),i+46>d&&!this.getters.isReadonly()&&(d+=46)),{width:u,height:d}}getColIndex(e){return e<this.offsetCorrectionX||e>this.offsetCorrectionX+this.viewportWidth?-1:this.searchHeaderIndex(`COL`,e-this.offsetCorrectionX,this.left)}getRowIndex(e){return e<this.offsetCorrectionY||e>this.offsetCorrectionY+this.viewportHeight?-1:this.searchHeaderIndex(`ROW`,e-this.offsetCorrectionY,this.top)}adjustPosition(e){let t=this.sheetId;e||=this.getters.getSheetPosition(t);let n=this.getters.getMainCellPosition({sheetId:t,...e}),{col:r,row:i}=this.getters.getNextVisibleCellPosition(n);da(r,this.boundaries.top,this.boundaries)&&this.adjustPositionX(r),da(this.boundaries.left,i,this.boundaries)&&this.adjustPositionY(i)}adjustPositionX(e){let t=this.sheetId,{end:n}=this.getters.getColDimensions(t,e),r=this.getters.getNumberCols(t);if(this.offsetX+this.offsetCorrectionX+this.viewportWidth<n){let n=e;for(;this.getters.isColHidden(t,n)&&e<r;)n++;let i=this.getters.getColDimensions(t,n).end,a=this.searchHeaderIndex(`COL`,i-this.viewportWidth-this.offsetCorrectionX,this.boundaries.left);this.offsetX=this.getters.getColDimensions(t,a).end-this.offsetCorrectionX,this.offsetScrollbarX=this.offsetX,this.adjustViewportZoneX()}else if(this.left>e){let n=e;for(;this.getters.isColHidden(t,n)&&e>0;)n--;this.offsetX=this.getters.getColDimensions(t,n).start-this.offsetCorrectionX,this.offsetScrollbarX=this.offsetX,this.adjustViewportZoneX()}}adjustPositionY(e){let t=this.sheetId,{end:n}=this.getters.getRowDimensions(t,e),r=this.getters.getNumberRows(t);if(this.offsetY+this.viewportHeight+this.offsetCorrectionY<n){let n=e;for(;this.getters.isRowHidden(t,n)&&e<r;)n++;let i=this.getters.getRowDimensions(t,n).end,a=this.searchHeaderIndex(`ROW`,i-this.viewportHeight-this.offsetCorrectionY,this.boundaries.top);this.offsetY=this.getters.getRowDimensions(t,a).end-this.offsetCorrectionY,this.offsetScrollbarY=this.offsetY,this.adjustViewportZoneY()}else if(this.top>e){let n=e;for(;this.getters.isRowHidden(t,n)&&e>0;)n--;this.offsetY=this.getters.getRowDimensions(t,n).start-this.offsetCorrectionY,this.offsetScrollbarY=this.offsetY,this.adjustViewportZoneY()}}setViewportOffset(e,t){this.setViewportOffsetX(e),this.setViewportOffsetY(t)}adjustViewportZone(){this.adjustViewportZoneX(),this.adjustViewportZoneY()}getVisibleRect(e){let t=ca(e,this.zone);if(t)return{x:this.getters.getColRowOffset(`COL`,this.zone.left,t.left)+this.offsetCorrectionX,y:this.getters.getColRowOffset(`ROW`,this.zone.top,t.top)+this.offsetCorrectionY,width:Math.min(this.getters.getColRowOffset(`COL`,t.left,t.right+1),this.viewportWidth),height:Math.min(this.getters.getColRowOffset(`ROW`,t.top,t.bottom+1),this.viewportHeight)}}getFullRect(e){if(ca(e,this.zone))return{x:this.getters.getColRowOffset(`COL`,this.zone.left,e.left)+this.offsetCorrectionX,y:this.getters.getColRowOffset(`ROW`,this.zone.top,e.top)+this.offsetCorrectionY,width:this.getters.getColRowOffset(`COL`,e.left,e.right+1),height:this.getters.getColRowOffset(`ROW`,e.top,e.bottom+1)}}isVisible(e,t){return t<=this.bottom&&t>=this.top&&e>=this.left&&e<=this.right&&!this.getters.isColHidden(this.sheetId,e)&&!this.getters.isRowHidden(this.sheetId,t)}searchHeaderIndex(e,t,n=0){if(this.viewportWidth<=0||this.viewportHeight<=0)return-1;let r=this.sheetId,i=this.getters.getNumberHeaders(r,e),a=n,o=i;for(;a<=o&&a!==i&&o!==-1;){let i=Math.floor((a+o)/2),s=this.getters.getColRowOffset(e,n,i),c=this.getters.getHeaderSize(r,e,i);if(t>=s&&t<s+c)return i;t>=s+c?a=i+1:o=i-1}return-1}get zone(){return{left:this.left,right:this.right,top:this.top,bottom:this.bottom}}setViewportOffsetX(e){this.canScrollHorizontally&&(this.offsetScrollbarX=e,this.adjustViewportZoneX())}setViewportOffsetY(e){this.canScrollVertically&&(this.offsetScrollbarY=e,this.adjustViewportZoneY())}adjustViewportOffsetX(){if(this.canScrollHorizontally){let{width:e}=this.getMaxSize();this.viewportWidth+this.offsetScrollbarX>e&&(this.offsetScrollbarX=Math.max(0,e-this.viewportWidth))}this.left=this.getColIndex(this.offsetScrollbarX),this.right=this.getColIndex(this.offsetScrollbarX+this.viewportWidth),this.right===-1&&(this.right=this.boundaries.right),this.adjustViewportZoneX()}adjustViewportOffsetY(){if(this.canScrollVertically){let{height:e}=this.getMaxSize();this.viewportHeight+this.offsetScrollbarY>e&&(this.offsetScrollbarY=Math.max(0,e-this.viewportHeight))}this.top=this.getRowIndex(this.offsetScrollbarY),this.bottom=this.getRowIndex(this.offsetScrollbarY+this.viewportHeight),this.bottom===-1&&(this.bottom=this.boundaries.bottom),this.adjustViewportZoneY()}adjustViewportZoneX(){let e=this.sheetId;this.left=this.searchHeaderIndex(`COL`,this.offsetScrollbarX,this.boundaries.left),this.right=Math.min(this.boundaries.right,this.searchHeaderIndex(`COL`,this.viewportWidth,this.left)),this.viewportWidth&&(this.left===-1&&(this.left=this.boundaries.left),this.right===-1&&(this.right=this.boundaries.right),this.offsetX=this.getters.getColDimensions(e,this.left).start-this.getters.getColDimensions(e,this.boundaries.left).start)}adjustViewportZoneY(){let e=this.sheetId;this.top=this.searchHeaderIndex(`ROW`,this.offsetScrollbarY,this.boundaries.top),this.bottom=Math.min(this.boundaries.bottom,this.searchHeaderIndex(`ROW`,this.viewportHeight,this.top)),this.viewportHeight&&(this.top===-1&&(this.top=this.boundaries.top),this.bottom===-1&&(this.bottom=this.boundaries.bottom),this.offsetY=this.getters.getRowDimensions(e,this.top).start-this.getters.getRowDimensions(e,this.boundaries.top).start)}},_j=class extends Q{static getters=[`getColIndex`,`getRowIndex`,`getActiveMainViewport`,`getSheetViewDimension`,`getSheetViewDimensionWithHeaders`,`getMainViewportRect`,`isVisibleInViewport`,`getEdgeScrollCol`,`getEdgeScrollRow`,`getVisibleFigures`,`getVisibleRect`,`getVisibleRectWithoutHeaders`,`getVisibleCellPositions`,`getColRowOffsetInViewport`,`getMainViewportCoordinates`,`getActiveSheetScrollInfo`,`getActiveSheetDOMScrollInfo`,`getSheetViewVisibleCols`,`getSheetViewVisibleRows`,`getFrozenSheetViewRatio`,`isPositionVisible`,`getAllActiveViewportsZonesAndRect`,`getRect`];viewports={};sheetViewWidth=Ge();sheetViewHeight=Ge();gridOffsetX=0;gridOffsetY=0;sheetsWithDirtyViewports=new Set;shouldAdjustViewports=!1;allowDispatch(e){switch(e.type){case`SET_VIEWPORT_OFFSET`:return this.checkScrollingDirection(e);case`RESIZE_SHEETVIEW`:return this.chainValidations(this.checkValuesAreDifferent,this.checkPositiveDimension)(e);default:return`Success`}}handleEvent(e){let t=this.getters.getActiveSheetId();if(e.options.scrollIntoView){let{col:n,row:r}=Ta(e.previousAnchor.zone,e.anchor.zone);if(e.mode===`updateAnchor`){let i=e.previousAnchor.zone,a=e.anchor.zone,{top:o,bottom:s,left:c,right:l}=this.getMainInternalViewport(t);i.left===a.left&&i.right===a.right&&(n=c>n||n>l?c:n),i.top===a.top&&i.bottom===a.bottom&&(r=o>r||r>s?o:r)}n=Math.min(n,this.getters.getNumberCols(t)-1),r=Math.min(r,this.getters.getNumberRows(t)-1),this.sheetsWithDirtyViewports.has(t)||this.refreshViewport(this.getters.getActiveSheetId(),{col:n,row:r})}}handle(e){if(ar.has(e.type))for(let e of this.getters.getSheetIds())this.sheetsWithDirtyViewports.add(e);switch(e.type){case`START`:this.selection.observe(this,{handleEvent:this.handleEvent.bind(this)}),this.resetViewports(this.getters.getActiveSheetId());break;case`UNDO`:case`REDO`:this.cleanViewports();for(let e of this.getters.getSheetIds())this.sheetsWithDirtyViewports.add(e);this.shouldAdjustViewports=!0;break;case`RESIZE_SHEETVIEW`:this.resizeSheetView(e.height,e.width,e.gridOffsetX,e.gridOffsetY);break;case`SET_VIEWPORT_OFFSET`:this.setSheetViewOffset(e.offsetX,e.offsetY);break;case`SHIFT_VIEWPORT_DOWN`:let t=this.getters.getActiveSheetId(),{top:n,viewportHeight:r,offsetCorrectionY:i}=this.getMainInternalViewport(t),a=this.getters.getRowDimensions(t,n);this.shiftVertically(a.start+r-i);break;case`SHIFT_VIEWPORT_UP`:{let e=this.getters.getActiveSheetId(),{top:t,viewportHeight:n,offsetCorrectionY:r}=this.getMainInternalViewport(e),i=this.getters.getRowDimensions(e,t);this.shiftVertically(i.end-r-n);break}case`REMOVE_FILTER_TABLE`:case`UPDATE_FILTER`:case`UNFREEZE_ROWS`:case`UNFREEZE_COLUMNS`:case`FREEZE_COLUMNS`:case`FREEZE_ROWS`:case`UNFREEZE_COLUMNS_ROWS`:case`REMOVE_COLUMNS_ROWS`:case`RESIZE_COLUMNS_ROWS`:case`HIDE_COLUMNS_ROWS`:case`ADD_COLUMNS_ROWS`:case`UNHIDE_COLUMNS_ROWS`:case`UNGROUP_HEADERS`:case`GROUP_HEADERS`:case`FOLD_HEADER_GROUP`:case`UNFOLD_HEADER_GROUP`:case`FOLD_HEADER_GROUPS_IN_ZONE`:case`UNFOLD_HEADER_GROUPS_IN_ZONE`:case`UNFOLD_ALL_HEADER_GROUPS`:case`FOLD_ALL_HEADER_GROUPS`:this.sheetsWithDirtyViewports.add(e.sheetId);break;case`UPDATE_CELL`:for(let e of this.getters.getSheetIds())this.sheetsWithDirtyViewports.add(e);break;case`DELETE_SHEET`:this.cleanViewports(),this.sheetsWithDirtyViewports.delete(e.sheetId);break;case`ACTIVATE_SHEET`:this.sheetsWithDirtyViewports.add(e.sheetIdTo);break;case`DELETE_SHEET`:this.sheetsWithDirtyViewports.delete(e.sheetId);break;case`START_EDITION`:let{col:o,row:s}=this.getters.getActivePosition();this.refreshViewport(this.getters.getActiveSheetId(),{col:o,row:s});break}}finalize(){for(let e of this.sheetsWithDirtyViewports)if(this.resetViewports(e),this.shouldAdjustViewports){let t=this.getters.getSheetPosition(e),n=this.getSubViewports(e);Object.values(n).forEach(e=>{e.adjustPosition(t)})}this.sheetsWithDirtyViewports=new Set,this.shouldAdjustViewports=!1,this.setViewports()}setViewports(){let e=this.getters.getSheetIds();for(let t of e)this.viewports[t]?.bottomRight||this.resetViewports(t)}getColIndex(e){let t=this.getters.getActiveSheetId();return Math.max(...this.getSubViewports(t).map(t=>t.getColIndex(e)))}getRowIndex(e){let t=this.getters.getActiveSheetId();return Math.max(...this.getSubViewports(t).map(t=>t.getRowIndex(e)))}getSheetViewDimensionWithHeaders(){return{width:this.sheetViewWidth+this.gridOffsetX,height:this.sheetViewHeight+this.gridOffsetY}}getSheetViewDimension(){return{width:this.sheetViewWidth,height:this.sheetViewHeight}}getActiveMainViewport(){let e=this.getters.getActiveSheetId();return this.getMainViewport(e)}getActiveSheetScrollInfo(){let e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e);return{scrollX:t.offsetX,scrollY:t.offsetY}}getActiveSheetDOMScrollInfo(){let e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e);return{scrollX:t.offsetScrollbarX,scrollY:t.offsetScrollbarY}}getSheetViewVisibleCols(){let e=this.getters.getActiveSheetId(),t=this.getSubViewports(e);return[...new Set(t.map(e=>w(e.left,e.right+1)).flat())].filter(t=>t>=0&&!this.getters.isHeaderHidden(e,`COL`,t))}getSheetViewVisibleRows(){let e=this.getters.getActiveSheetId(),t=this.getSubViewports(e);return[...new Set(t.map(e=>w(e.top,e.bottom+1)).flat())].filter(t=>t>=0&&!this.getters.isHeaderHidden(e,`ROW`,t))}getVisibleCellPositions(){let e=this.getSheetViewVisibleCols(),t=this.getSheetViewVisibleRows(),n=this.getters.getActiveSheetId(),r=[];for(let i of e)for(let e of t){let t={sheetId:n,col:i,row:e},a=this.getters.getMainCellPosition(t);a.row!==e||a.col!==i||r.push(t)}return r}getMainViewportRect(){let e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e),{xSplit:n,ySplit:r}=this.getters.getPaneDivisions(e),{width:i,height:a}=t.getMaxSize();return{x:this.getters.getColDimensions(e,n).start,y:this.getters.getRowDimensions(e,r).start,width:i,height:a}}getMaximumSheetOffset(){let e=this.getters.getActiveSheetId(),{width:t,height:n}=this.getMainViewportRect(),r=this.getMainInternalViewport(e);return{maxOffsetX:Math.max(0,t-r.viewportWidth+1),maxOffsetY:Math.max(0,n-r.viewportHeight+1)}}getColRowOffsetInViewport(e,t,n){if(n<t)return-this.getColRowOffsetInViewport(e,n,t);let r=this.getters.getActiveSheetId(),i=e===`COL`?this.getters.getSheetViewVisibleCols():this.getters.getSheetViewVisibleRows(),a=i.findIndex(e=>t>=e),o=i.findIndex(e=>n<=e);o=o===-1?i.length:o;let s=i.slice(a,o),c=0;for(let t of s)c+=this.getters.getHeaderSize(r,e,t);return c}isVisibleInViewport({sheetId:e,col:t,row:n}){return this.getSubViewports(e).some(e=>e.isVisible(t,n))}getEdgeScrollCol(e,t,n){let r=!1,i=0,a=0,{xSplit:o}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{width:s}=this.getSheetViewDimension(),{x:c}=this.getMainViewportCoordinates(),l=this.getActiveSheetScrollInfo().scrollX;return e>s?(r=!0,a=$r(e-s),i=1):e<c&&n>=c&&l>0?(r=!0,a=$r(c-e),i=-1):o&&t<c&&e>c&&(r=!0,a=$r(e),i=`reset`),{canEdgeScroll:r,direction:i,delay:a}}getEdgeScrollRow(e,t,n){let r=!1,i=0,a=0,{ySplit:o}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{height:s}=this.getSheetViewDimension(),{y:c}=this.getMainViewportCoordinates(),l=this.getActiveSheetScrollInfo().scrollY;return e>s?(r=!0,a=$r(e-s),i=1):e<c&&n>=c&&l>0?(r=!0,a=$r(c-e),i=-1):o&&t<c&&e>c&&(r=!0,a=$r(e),i=`reset`),{canEdgeScroll:r,direction:i,delay:a}}getVisibleRect(e){let t=this.getVisibleRectWithoutHeaders(e);return{...t,x:t.x+this.gridOffsetX,y:t.y+this.gridOffsetY}}getVisibleRectWithoutHeaders(e){let t=this.getters.getActiveSheetId();return this.mapViewportsToRect(t,t=>t.getVisibleRect(e))}getRect(e){let t=this.getters.getActiveSheetId(),n=this.mapViewportsToRect(t,t=>t.getFullRect(e));return{...n,x:n.x+this.gridOffsetX,y:n.y+this.gridOffsetY}}getMainViewportCoordinates(){let e=this.getters.getActiveSheetId(),{xSplit:t,ySplit:n}=this.getters.getPaneDivisions(e);return{x:this.getters.getColDimensions(e,t).start,y:this.getters.getRowDimensions(e,n).start}}getAllActiveViewportsZonesAndRect(){let e=this.getters.getActiveSheetId();return this.getSubViewports(e).map(e=>({zone:e,rect:{x:e.offsetCorrectionX+this.gridOffsetX,y:e.offsetCorrectionY+this.gridOffsetY,...e.getMaxSize()}}))}ensureMainViewportExist(e){this.viewports[e]||this.resetViewports(e)}getSubViewports(e){return this.ensureMainViewportExist(e),Object.values(this.viewports[e]).filter(T)}checkPositiveDimension(e){return e.width<0||e.height<0?`InvalidViewportSize`:`Success`}checkValuesAreDifferent(e){let{height:t,width:n}=this.getSheetViewDimension();return e.gridOffsetX===this.gridOffsetX&&e.gridOffsetY===this.gridOffsetY&&e.width===n&&e.height===t?`ValuesNotChanged`:`Success`}checkScrollingDirection({offsetX:e,offsetY:t}){let n=this.getMainInternalViewport(this.getters.getActiveSheetId());return!n.canScrollHorizontally&&e>0||!n.canScrollVertically&&t>0?`InvalidScrollingDirection`:`Success`}getMainViewport(e){let t=this.getMainInternalViewport(e);return{top:t.top,left:t.left,bottom:t.bottom,right:t.right}}getMainInternalViewport(e){return this.ensureMainViewportExist(e),this.viewports[e].bottomRight}cleanViewports(){let e={};for(let t of this.getters.getSheetIds())e[t]=this.viewports[t];this.viewports=e}resizeSheetView(e,t,n=0,r=0){this.sheetViewHeight=e,this.sheetViewWidth=t,this.gridOffsetX=n,this.gridOffsetY=r,this.recomputeViewports()}recomputeViewports(){for(let e of this.getters.getSheetIds())this.resetViewports(e)}setSheetViewOffset(e,t){let n=this.getters.getActiveSheetId(),{maxOffsetX:r,maxOffsetY:i}=this.getMaximumSheetOffset();this.getSubViewports(n).forEach(n=>n.setViewportOffset(C(e,0,r),C(t,0,i)))}getViewportOffset(e){return{x:this.viewports[e]?.bottomRight.offsetScrollbarX||0,y:this.viewports[e]?.bottomRight.offsetScrollbarY||0}}resetViewports(e){if(!this.getters.tryGetSheet(e))return;let{xSplit:t,ySplit:n}=this.getters.getPaneDivisions(e),r=this.getters.getNumberCols(e),i=this.getters.getNumberRows(e),a=Math.min(this.getters.getColRowOffset(`COL`,0,t,e),this.sheetViewWidth),o=Math.min(this.getters.getColRowOffset(`ROW`,0,n,e),this.sheetViewHeight),s=Math.max(this.sheetViewWidth-a,0),c=Math.max(this.sheetViewHeight-o,0),{xRatio:l,yRatio:u}=this.getFrozenSheetViewRatio(e),d=l<1,f=u<1,p=this.getViewportOffset(e),m={topLeft:n&&t&&new gj(this.getters,e,{left:0,right:t-1,top:0,bottom:n-1},{width:a,height:o},{canScrollHorizontally:!1,canScrollVertically:!1},{x:0,y:0})||void 0,topRight:n&&new gj(this.getters,e,{left:t,right:r-1,top:0,bottom:n-1},{width:s,height:o},{canScrollHorizontally:d,canScrollVertically:!1},{x:d?p.x:0,y:0})||void 0,bottomLeft:t&&new gj(this.getters,e,{left:0,right:t-1,top:n,bottom:i-1},{width:a,height:c},{canScrollHorizontally:!1,canScrollVertically:f},{x:0,y:f?p.y:0})||void 0,bottomRight:new gj(this.getters,e,{left:t,right:r-1,top:n,bottom:i-1},{width:s,height:c},{canScrollHorizontally:d,canScrollVertically:f},{x:d?p.x:0,y:f?p.y:0})};this.viewports[e]=m}refreshViewport(e,t){this.getSubViewports(e).forEach(e=>{e.adjustViewportZone(),e.adjustPosition(t)})}shiftVertically(e){let t=this.getters.getActiveSheetId(),{top:n}=this.getMainInternalViewport(t),{scrollX:r}=this.getActiveSheetScrollInfo();this.setSheetViewOffset(r,e);let{anchor:i}=this.getters.getSelection();if(i.cell.row>=this.getters.getPaneDivisions(t).ySplit){let e=this.getMainInternalViewport(t).top-n;this.selection.selectCell(i.cell.col,i.cell.row+e)}}getVisibleFigures(){let e=this.getters.getActiveSheetId(),t=[],n=this.getters.getFigures(e),{scrollX:r,scrollY:i}=this.getActiveSheetScrollInfo(),{x:a,y:o}=this.getters.getMainViewportCoordinates(),{width:s,height:c}=this.getters.getSheetViewDimensionWithHeaders();for(let e of n)e.x>=a&&(e.x+e.width<=a+r||e.x>=s+r+a)||e.y>=o&&(e.y+e.height<=o+i||e.y>=c+i+o)||t.push(e);return t}isPositionVisible(e){let{scrollX:t,scrollY:n}=this.getters.getActiveSheetScrollInfo(),{x:r,y:i}=this.getters.getMainViewportCoordinates(),{width:a,height:o}=this.getters.getSheetViewDimension();return!(e.x>=r&&(e.x<r+t||e.x>a+t+r)||e.y>=i&&(e.y<i+n||e.y>o+n+i))}getFrozenSheetViewRatio(e){let{xSplit:t,ySplit:n}=this.getters.getPaneDivisions(e),r=this.getters.getColDimensions(e,t).start,i=this.getters.getRowDimensions(e,n).start,a=this.sheetViewWidth+this.gridOffsetX,o=this.sheetViewHeight+this.gridOffsetY;return{xRatio:r/a,yRatio:i/o}}mapViewportsToRect(e,t){let n=1/0,r=1/0,i=0,a=0,o=!1;for(let s of this.getSubViewports(e)){let e=t(s);e&&(o=!0,n=Math.min(n,e.x),r=Math.min(r,e.y),i=Math.max(i,e.x+e.width),a=Math.max(a,e.y+e.height))}return o?{x:n,y:r,width:i-n,height:a-r}:{x:0,y:0,width:0,height:0}}},vj=class extends Q{static getters=[`getColDimensions`,`getRowDimensions`,`getColRowOffset`];headerPositions={};isDirty=!0;handle(e){switch(ar.has(e.type)&&(this.headerPositions={},this.isDirty=!0),e.type){case`START`:for(let e of this.getters.getSheetIds())this.headerPositions[e]=this.computeHeaderPositionsOfSheet(e);break;case`UPDATE_CELL`:this.headerPositions={},this.isDirty=!0;break;case`UPDATE_FILTER`:case`REMOVE_FILTER_TABLE`:this.headerPositions={},this.isDirty=!0;break;case`REMOVE_COLUMNS_ROWS`:case`RESIZE_COLUMNS_ROWS`:case`HIDE_COLUMNS_ROWS`:case`ADD_COLUMNS_ROWS`:case`UNHIDE_COLUMNS_ROWS`:case`FOLD_HEADER_GROUP`:case`UNFOLD_HEADER_GROUP`:case`FOLD_HEADER_GROUPS_IN_ZONE`:case`UNFOLD_HEADER_GROUPS_IN_ZONE`:case`UNFOLD_ALL_HEADER_GROUPS`:case`FOLD_ALL_HEADER_GROUPS`:case`UNGROUP_HEADERS`:case`GROUP_HEADERS`:case`CREATE_SHEET`:this.getters.tryGetSheet(e.sheetId)&&(this.headerPositions[e.sheetId]=this.computeHeaderPositionsOfSheet(e.sheetId));break;case`DUPLICATE_SHEET`:this.headerPositions[e.sheetIdTo]=S(this.headerPositions[e.sheetId]);break}}finalize(){for(let e of this.getters.getSheetIds())(this.isDirty||!this.headerPositions[e])&&(this.headerPositions[e]=this.computeHeaderPositionsOfSheet(e));this.isDirty=!1}getColDimensions(e,t){let n=this.headerPositions[e].COL[t],r=this.getters.getColSize(e,t);return{start:n,size:r,end:n+(this.getters.isColHidden(e,t)?0:r)}}getRowDimensions(e,t){let n=this.headerPositions[e].ROW[t],r=this.getters.getRowSize(e,t);return{start:n,size:r,end:n+(this.getters.isRowHidden(e,t)?0:r)}}getColRowOffset(e,t,n,r=this.getters.getActiveSheetId()){let i=this.headerPositions[r][e][t];return this.headerPositions[r][e][n]-i}computeHeaderPositionsOfSheet(e){return{COL:this.computePositions(e,`COL`),ROW:this.computePositions(e,`ROW`)}}computePositions(e,t){let n={},r=0;for(let i=0;i<this.getters.getNumberHeaders(e,t)+1;i++)n[i]=r,!this.getters.isHeaderHidden(e,t,i)&&(r+=this.getters.getHeaderSize(e,t,i));return n}};let yj=new H().add(`settings`,pk).add(`sheet`,dk).add(`header grouping`,fk).add(`header visibility`,ak).add(`filters`,rk).add(`cell`,RO).add(`merge`,sk).add(`headerSize`,ik).add(`borders`,LO).add(`conditional formatting`,QO).add(`figures`,ek).add(`chart`,VO).add(`image`,ok).add(`dataValidation`,$O),bj=new H().add(`ui_sheet`,EA).add(`ui_options`,TA).add(`selectionInputManager`,CA).add(`highlight`,bA).add(`grid renderer`,xA).add(`autofill`,Lk).add(`find_and_replace`,_A).add(`sort`,wA).add(`automatic_sum`,Rk).add(`format`,vA).add(`split_to_columns`,QA).add(`cell_popovers`,zk).add(`collaborative`,pA).add(`history`,ZA).add(`data_cleanup`,gA),xj=new H().add(`selection`,hj).add(`evaluation_filter`,pj).add(`header_visibility_ui`,yA).add(`header_positions`,vj).add(`viewport`,_j).add(`clipboard`,rj).add(`edition`,fj),Sj=new H().add(`evaluation`,Ek).add(`evaluation_chart`,jk).add(`evaluation_cf`,Mk).add(`row_size`,Fk).add(`custom_colors`,Ak).add(`data_validation_ui`,Pk),Cj=new H;Cj.add(`link`,{condition:(e,t)=>!!t.model.getters.getEvaluatedCell(e).link,execute:(e,t)=>Qa(t.model.getters.getEvaluatedCell(e).link,t),sequence:5});var wj=class{fileStore;constructor(e){this.fileStore=e}async requestImage(){let e=await this.getImageFromUser(),t=await this.fileStore.upload(e);return{path:t,size:await this.getImageOriginalSize(t),mimetype:e.type}}getImageFromUser(){return new Promise((e,t)=>{let n=document.createElement(`input`);n.setAttribute(`type`,`file`),n.setAttribute(`accept`,`image/*`),n.addEventListener(`change`,async()=>{n.files===null||n.files.length!==1?t():e(n.files[0])}),n.click()})}getImageOriginalSize(e){return new Promise((t,n)=>{let r=new Image;r.src=e,r.addEventListener(`load`,()=>{t({width:r.width,height:r.height})}),r.addEventListener(`error`,n)})}},Tj=class{focusableElement=void 0;setFocusableElement(e){this.focusableElement=e}focus(){this.focusableElement?.focus()}};let Ej=[{transform:`scale(0)`},{transform:`scale(0.8)`,offset:.33},{opacity:`0`,transform:`scale(1)`,offset:1}];U`
|
|
1480
|
+
`)}}getPasteZone(e){let t=this.values.length,n=Nt(this.values.map(e=>e.length)),{left:r,top:i}=e[0];return{top:i,left:r,bottom:i+t-1,right:r+n-1}}},rj=class extends Q{static layers=[2];static getters=[`getClipboardContent`,`getClipboardTextContent`,`isCutOperation`,`isPaintingFormat`];status=`invisible`;state;lastPasteState;paintFormatStatus=`inactive`;originSheetId;allowDispatch(e){switch(e.type){case`CUT`:let t=this.getters.getSelectedZones();return this.getClipboardState(t,e.type).isCutAllowed(t);case`PASTE`:if(!this.state)return`EmptyClipboard`;let n=e.pasteOption||(this.paintFormatStatus===`inactive`?void 0:`onlyFormat`);return this.state.isPasteAllowed(e.target,{pasteOption:n});case`PASTE_FROM_OS_CLIPBOARD`:return new nj(e.text,this.getters,this.dispatch,this.selection).isPasteAllowed(e.target,{pasteOption:e.pasteOption});case`COPY_PASTE_CELLS_ABOVE`:{let e=this.getters.getSelectedZones();if(e.length>1||e[0].top===0&&e[0].bottom===0)return`InvalidCopyPasteSelection`;break}case`COPY_PASTE_CELLS_ON_LEFT`:{let e=this.getters.getSelectedZones();if(e.length>1||e[0].left===0&&e[0].right===0)return`InvalidCopyPasteSelection`;break}case`INSERT_CELL`:{let{cut:t,paste:n}=this.getInsertCellsTargets(e.zone,e.shiftDimension);return this.getClipboardStateForCopyCells(t,`CUT`,`shiftCells`).isPasteAllowed(n)}case`DELETE_CELL`:{let{cut:t,paste:n}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);return this.getClipboardStateForCopyCells(t,`CUT`,`shiftCells`).isPasteAllowed(n)}case`ACTIVATE_PAINT_FORMAT`:if(this.paintFormatStatus!==`inactive`)return`AlreadyInPaintingFormatMode`}return`Success`}handle(e){switch(e.type){case`COPY`:case`CUT`:let t=this.getters.getSelectedZones();this.state=this.getClipboardState(t,e.type),this.status=`visible`,this.originSheetId=this.getters.getActiveSheetId();break;case`PASTE`:if(!this.state)break;let n=e.pasteOption||(this.paintFormatStatus===`inactive`?void 0:`onlyFormat`);this.state.paste(e.target,{pasteOption:n,shouldPasteCF:!0,selectTarget:!0}),this.state.operation===`CUT`&&(this.state=void 0),this.lastPasteState=this.state,this.paintFormatStatus===`oneOff`&&(this.paintFormatStatus=`inactive`),this.status=`invisible`;break;case`COPY_PASTE_CELLS_ABOVE`:{let e=this.getters.getSelectedZone(),t=e.top!==e.bottom,n={...e,bottom:t?e.top:e.top-1,top:t?e.top:e.top-1};this.getClipboardStateForCopyCells([n],`COPY`).paste([e],{pasteOption:void 0,shouldPasteCF:!0,selectTarget:!0})}break;case`COPY_PASTE_CELLS_ON_LEFT`:{let e=this.getters.getSelectedZone(),t=e.left!==e.right,n={...e,right:t?e.left:e.left-1,left:t?e.left:e.left-1};this.getClipboardStateForCopyCells([n],`COPY`).paste([e],{pasteOption:void 0,shouldPasteCF:!0,selectTarget:!0})}break;case`CLEAN_CLIPBOARD_HIGHLIGHT`:this.status=`invisible`;break;case`DELETE_CELL`:{let{cut:t,paste:n}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);if(!ta(t[0])){this.dispatch(`CLEAR_CELLS`,{target:[e.zone],sheetId:this.getters.getActiveSheetId()});break}this.getClipboardStateForCopyCells(t,`CUT`,`shiftCells`).paste(n);break}case`INSERT_CELL`:{let{cut:t,paste:n}=this.getInsertCellsTargets(e.zone,e.shiftDimension);this.getClipboardStateForCopyCells(t,`CUT`,`shiftCells`).paste(n);break}case`ADD_COLUMNS_ROWS`:if(this.status=`invisible`,this.state?.operation!==`CUT`||e.sheetId!==this.state?.sheetId)return;this.state.isColRowDirtyingClipboard(e.position===`before`?e.base:e.base+1,e.dimension)&&(this.state=void 0);break;case`REMOVE_COLUMNS_ROWS`:if(this.status=`invisible`,this.state?.operation!==`CUT`||e.sheetId!==this.state?.sheetId)return;for(let t of e.elements)if(this.state.isColRowDirtyingClipboard(t,e.dimension)){this.state=void 0;break}this.status=`invisible`;break;case`PASTE_FROM_OS_CLIPBOARD`:this.state=new nj(e.text,this.getters,this.dispatch,this.selection),this.state.paste(e.target,{pasteOption:e.pasteOption}),this.lastPasteState=this.state,this.status=`invisible`;break;case`REPEAT_PASTE`:this.lastPasteState?.paste(e.target,{pasteOption:e.pasteOption,shouldPasteCF:!0,selectTarget:!0});break;case`ACTIVATE_PAINT_FORMAT`:{let t=this.getters.getSelectedZones();this.state=this.getClipboardStateForCopyCells(t,`COPY`),this.status=`visible`,e.persistent?this.paintFormatStatus=`persistent`:this.paintFormatStatus=`oneOff`;break}case`DELETE_SHEET`:if(this.state?.operation!==`CUT`)return;this.originSheetId===e.sheetId&&(this.state=void 0,this.status=`invisible`);break;case`CANCEL_PAINT_FORMAT`:this.paintFormatStatus=`inactive`,this.status=`invisible`;break;default:ur(e)&&(this.status=`invisible`)}}getClipboardContent(){return this.state?.getClipboardContent()||{"text/plain":` `}}getClipboardTextContent(){return this.state?.getClipboardContent()[`text/plain`]||` `}isCutOperation(){return this.state?this.state.operation===`CUT`:!1}isPaintingFormat(){return this.paintFormatStatus!==`inactive`}getDeleteCellsTargets(e,t){let n=this.getters.getActiveSheetId(),r;return r=t===`COL`?{...e,left:e.right+1,right:this.getters.getNumberCols(n)-1}:{...e,top:e.bottom+1,bottom:this.getters.getNumberRows(n)-1},{cut:[r],paste:[e]}}getInsertCellsTargets(e,t){let n=this.getters.getActiveSheetId(),r,i;return t===`COL`?(r={...e,right:this.getters.getNumberCols(n)-1},i={...e,left:e.right+1,right:e.right+1}):(r={...e,bottom:this.getters.getNumberRows(n)-1},i={...e,top:e.bottom+1,bottom:this.getters.getNumberRows(n)-1}),{cut:[r],paste:[i]}}getClipboardStateForCopyCells(e,t,n=`copyPaste`){return new hA(e,t,this.getters,this.dispatch,this.selection,n)}getClipboardState(e,t){return this.getters.getSelectedFigureId()?new $A(t,this.getters,this.dispatch):new hA(e,t,this.getters,this.dispatch,this.selection)}drawGrid(e){this.status!==`visible`||!this.state||this.state.drawClipboard(e)}};function ij(e){if(e.type!==`REFERENCE`)return e;let{xc:t,sheetName:n}=Xi(e.value),[r,i]=t.split(`:`),a=n?`${$e(n)}!`:``,o=aj(r),s=i?`:${aj(i)}`:``;return{...e,value:a+o+s}}function aj(e){switch(sj(e)){case`none`:e=oj(e,`colrow`);break;case`colrow`:e=oj(e,`row`);break;case`row`:e=oj(e,`col`);break;case`col`:e=oj(e,`none`);break}return e}function oj(e,t){e=e.replace(/\$/g,``);let n;switch(t){case`col`:return`$`+e;case`row`:return n=e.search(/[0-9]/),e.slice(0,n)+`$`+e.slice(n);case`colrow`:return n=e.search(/[0-9]/),n===-1||n===0||(e=e.slice(0,n)+`$`+e.slice(n)),`$`+e;case`none`:return e}}function sj(e){return uj(e)?`colrow`:cj(e)?`col`:lj(e)?`row`:`none`}function cj(e){return e.startsWith(`$`)}function lj(e){return e.includes(`$`,1)}function uj(e){return e.startsWith(`$`)&&e.length>1&&e.slice(1).includes(`$`)}let dj=y(`The cell you are trying to edit has been deleted.`);var fj=class extends Q{static getters=[`getEditionMode`,`isSelectingForComposer`,`showSelectionIndicator`,`getCurrentContent`,`getComposerSelection`,`getCurrentTokens`,`getTokenAtCursor`,`getComposerHighlights`,`getCurrentEditedCell`,`getCycledReference`,`getAutoCompleteDataValidationValues`];col=0;row=0;mode=`inactive`;sheetId=``;currentContent=``;currentTokens=[];selectionStart=0;selectionEnd=0;initialContent=``;colorIndexByRange={};allowDispatch(e){switch(e.type){case`CHANGE_COMPOSER_CURSOR_SELECTION`:return this.validateSelection(this.currentContent.length,e.start,e.end);case`SET_CURRENT_CONTENT`:if(e.selection)return this.validateSelection(e.content.length,e.selection.start,e.selection.end);break;case`START_EDITION`:if(e.selection){let t=e.text||this.getComposerContent(this.getters.getActivePosition());return this.validateSelection(t.length,e.selection.start,e.selection.end)}break;case`STOP_EDITION`:return this.mode===`inactive`?`Success`:this.checkDataValidation(e)}return`Success`}handleEvent(e){let t=this.getters.getActiveSheetId(),n;switch(n=e.options.unbounded?this.getters.getUnboundedZone(t,e.anchor.zone):e.anchor.zone,e.mode){case`newAnchor`:this.mode===`selecting`&&this.insertSelectedRange(n);break;default:this.mode===`selecting`?this.replaceSelectedRange(n):this.updateComposerRange(e.previousAnchor.zone,n);break}}handle(e){switch(e.type){case`CHANGE_COMPOSER_CURSOR_SELECTION`:this.selectionStart=e.start,this.selectionEnd=e.end,this.isSelectingForComposer()&&(this.mode=`editing`);break;case`STOP_COMPOSER_RANGE_SELECTION`:this.isSelectingForComposer()&&(this.mode=`editing`);break;case`START_EDITION`:this.mode!==`inactive`&&e.text?this.setContent(e.text,e.selection):this.startEdition(e.text,e.selection),this.updateRangeColor();break;case`STOP_EDITION`:this.stopEdition(),this.colorIndexByRange={};break;case`CANCEL_EDITION`:this.resetContent(),this.cancelEditionAndActivateSheet(),this.colorIndexByRange={};break;case`SET_CURRENT_CONTENT`:this.setContent(e.content,e.selection,!0),this.updateRangeColor();break;case`REPLACE_COMPOSER_CURSOR_SELECTION`:this.replaceSelection(e.text);break;case`SELECT_FIGURE`:this.resetContent(),this.cancelEditionAndActivateSheet();break;case`ADD_COLUMNS_ROWS`:this.onAddElements(e);break;case`REMOVE_COLUMNS_ROWS`:e.dimension===`COL`?this.onColumnsRemoved(e):this.onRowsRemoved(e);break;case`START_CHANGE_HIGHLIGHT`:let{left:t,top:n}=e.zone;this.isSelectingForComposer()&&(this.mode=`editing`),this.selection.resetAnchor(this,{cell:{col:t,row:n},zone:e.zone});break;case`ACTIVATE_SHEET`:if(this.currentContent.startsWith(`=`)||(this.cancelEdition(),this.resetContent()),this.selection.isListening(this)&&e.sheetIdFrom!==e.sheetIdTo){let t=this.getters.getActivePosition(),{col:n,row:r}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:t.col,row:t.row}),i=this.getters.expandZone(e.sheetIdTo,V({col:n,row:r}));this.selection.resetAnchor(this,{cell:{col:n,row:r},zone:i})}break;case`DELETE_SHEET`:case`UNDO`:case`REDO`:!this.getters.tryGetSheet(this.sheetId)&&this.mode!==`inactive`&&(this.sheetId=this.getters.getActiveSheetId(),this.resetContent(),this.cancelEditionAndActivateSheet(),this.ui.raiseBlockingErrorUI(dj));break;case`CYCLE_EDITION_REFERENCES`:this.cycleReferences();break}}getEditionMode(){return this.mode}getCurrentContent(){return this.mode===`inactive`?this.getComposerContent(this.getters.getActivePosition()):this.currentContent}getComposerSelection(){return{start:this.selectionStart,end:this.selectionEnd}}getCurrentEditedCell(){return{sheetId:this.sheetId,col:this.col,row:this.row}}isSelectingForComposer(){return this.mode===`selecting`}showSelectionIndicator(){return this.isSelectingForComposer()&&this.canStartComposerRangeSelection()}getCurrentTokens(){return this.currentTokens}getTokenAtCursor(){let e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);if(!(e===t&&t===0))return this.currentTokens.find(n=>n.start<=e&&n.end>=t)}getCycledReference(e,t){let n=this.getters.getLocale(),r=(t.startsWith(`=`)?UT(t,n):[]).filter(t=>t.start<=e.start&&t.end>=e.start||t.start>=e.start&&t.start<e.end),i=r.filter(e=>e.type===`REFERENCE`);if(i.length===0)return;let a=r.map(ij).map(e=>e.value).join(``),o=r[0].start,s=r[r.length-1].end,c=t.slice(0,o)+a+t.slice(s),l=c.length-t.length,u={start:i[0].start,end:i[i.length-1].end+l};return i.length===1&&e.start===e.end&&(u.start=u.end),{content:c,selection:u}}getInitialComposerContent(){return this.initialContent}cycleReferences(){let e=this.getCycledReference(this.getComposerSelection(),this.currentContent);e!==void 0&&this.dispatch(`SET_CURRENT_CONTENT`,{content:e.content,selection:e.selection})}validateSelection(e,t,n){return t>=0&&t<=e&&n>=0&&n<=e?`Success`:`WrongComposerSelection`}onColumnsRemoved(e){if(e.elements.includes(this.col)&&this.mode!==`inactive`){this.dispatch(`CANCEL_EDITION`),this.ui.raiseBlockingErrorUI(dj);return}let{top:t,left:n}=aa({left:this.col,right:this.col,top:this.row,bottom:this.row},`left`,[...e.elements]);this.col=n,this.row=t}onRowsRemoved(e){if(e.elements.includes(this.row)&&this.mode!==`inactive`){this.dispatch(`CANCEL_EDITION`),this.ui.raiseBlockingErrorUI(dj);return}let{top:t,left:n}=aa({left:this.col,right:this.col,top:this.row,bottom:this.row},`top`,[...e.elements]);this.col=n,this.row=t}onAddElements(e){let{top:t,left:n}=ia({left:this.col,right:this.col,top:this.row,bottom:this.row},e.dimension===`COL`?`left`:`top`,e.base,e.position,e.quantity);this.col=n,this.row=t}startComposerRangeSelection(){if(this.sheetId===this.getters.getActiveSheetId()){let e=V({col:this.col,row:this.row});this.selection.resetAnchor(this,{cell:{col:this.col,row:this.row},zone:e})}this.mode=`selecting`}startEdition(e,t){let n=this.getters.getActiveCell(),r=this.getters.getLocale();e&&n.format?.includes(`%`)&&Yn(e,r)&&(t||={start:e.length,end:e.length},e=`${e}%`);let{col:i,row:a,sheetId:o}=this.getters.getActivePosition();this.col=i,this.sheetId=o,this.row=a,this.initialContent=this.getComposerContent({sheetId:o,col:i,row:a}),this.mode=`editing`,this.setContent(e||this.initialContent,t),this.colorIndexByRange={};let s=V({col:this.col,row:this.row});this.selection.capture(this,{cell:{col:this.col,row:this.row},zone:s},{handleEvent:this.handleEvent.bind(this),release:()=>{this.stopEdition()}})}stopEdition(){if(this.mode!==`inactive`){this.cancelEditionAndActivateSheet();let e=this.col,t=this.row,n=this.getCurrentCanonicalContent();if(this.initialContent===n)return;if(n){let r=this.getters.getActiveSheetId(),i=this.getters.getEvaluatedCell({sheetId:r,col:this.col,row:this.row});if(n.startsWith(`=`)){let e=this.currentTokens.filter(e=>e.type===`LEFT_PAREN`).length-this.currentTokens.filter(e=>e.type===`RIGHT_PAREN`).length;e>0&&(n+=_t(Array(e).fill(`)`)))}else i.link&&(n=st(n,i.link.url));this.dispatch(`UPDATE_CELL`,{sheetId:this.sheetId,col:e,row:t,content:n})}else this.dispatch(`UPDATE_CELL`,{sheetId:this.sheetId,content:``,col:e,row:t});this.setContent(``)}}getCurrentCanonicalContent(){return Ic(this.currentContent,this.getters.getLocale())}cancelEditionAndActivateSheet(){this.mode!==`inactive`&&(this.cancelEdition(),this.getters.getActiveSheetId()!==this.sheetId&&this.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:this.getters.getActiveSheetId(),sheetIdTo:this.sheetId}))}getComposerContent(e){let t=this.getters.getLocale(),n=this.getters.getCell(e);if(n?.isFormula)return Vc(n.content,t);let{format:r,value:i,type:a,formattedValue:o}=this.getters.getEvaluatedCell(e);switch(a){case`text`:case`empty`:return i;case`boolean`:return o;case`error`:return n?.content||``;case`number`:return r&&_i(r)?yn(o,t)===null?z(i,{locale:t,format:Number.isInteger(i)?t.dateFormat:Qc(t)}):o:this.numberComposerContent(i,r,t)}}numberComposerContent(e,t,n){return t?.includes(`%`)?`${gi(e*100,n.decimalSeparator)}%`:gi(e,n.decimalSeparator)}cancelEdition(){this.mode!==`inactive`&&(this.mode=`inactive`,this.selection.release(this))}resetContent(){this.setContent(this.initialContent||``)}setContent(e,t,n){let r=this.currentContent!==e;if(this.currentContent=e,t?(this.selectionStart=t.start,this.selectionEnd=t.end):this.selectionStart=this.selectionEnd=e.length,r||this.mode!==`inactive`){let t=this.getters.getLocale();this.currentTokens=e.startsWith(`=`)?UT(e,t):[],this.currentTokens.length>100&&n&&this.ui.raiseBlockingErrorUI(y(`This formula has over 100 parts. It can't be processed properly, consider splitting it into multiple cells`))}this.canStartComposerRangeSelection()&&this.startComposerRangeSelection()}insertSelectedRange(e){let t=Math.min(this.selectionStart,this.selectionEnd),n=this.getZoneReference(e);this.canStartComposerRangeSelection()?this.insertText(n,t):this.insertText(`,`+n,t)}replaceSelectedRange(e){let t=this.getZoneReference(e),n=this.getTokenAtCursor(),r=n?.type===`REFERENCE`?n.start:this.selectionStart;this.replaceText(t,r,this.selectionEnd)}updateComposerRange(e,t){let n=this.getters.getActiveSheetId(),r=this.getTokenAtCursor(),i=(r?[r,...this.currentTokens]:this.currentTokens).filter(e=>e.type===`REFERENCE`).find(t=>{let{xc:r,sheetName:i}=Xi(t.value),a=i||this.getters.getSheetName(this.sheetId);if(!Ga(this.getters.getSheetName(n),a))return!1;let o=this.getters.getRangeFromSheetXC(n,r);return la(this.getters.expandZone(n,o.zone),e)});if(!i)return;let a=this.getters.getRangeFromSheetXC(n,i.value);this.selectionStart=i.start,this.selectionEnd=this.selectionStart+i.value.length;let o=this.getters.getRangeFromZone(n,t),s=this.getRangeReference(o,a.parts);this.replaceSelection(s)}getZoneReference(e){let t=this.getters.getCurrentEditedCell().sheetId,n=this.getters.getActiveSheetId(),r=this.getters.getRangeFromZone(n,e);return this.getters.getSelectionRangeString(r,t)}getRangeReference(e,t){let n=[...t],r=e.clone({parts:n});return this.getters.getSelectionRangeString(r,this.getters.getCurrentEditedCell().sheetId)}replaceSelection(e){let t=Math.min(this.selectionStart,this.selectionEnd),n=Math.max(this.selectionStart,this.selectionEnd);this.replaceText(e,t,n)}replaceText(e,t,n){this.currentContent=this.currentContent.slice(0,t)+this.currentContent.slice(n,this.currentContent.length),this.insertText(e,t)}insertText(e,t){let n=this.currentContent.slice(0,t)+e+this.currentContent.slice(t),r=t+e.length;this.dispatch(`SET_CURRENT_CONTENT`,{content:n,selection:{start:r,end:r}})}updateRangeColor(){if(!this.currentContent.startsWith(`=`)||this.mode===`inactive`)return;let e=this.getters.getCurrentEditedCell().sheetId,t=this.getReferencedRanges().map(t=>this.getters.getRangeString(t,e)),n={};for(let e of t)this.colorIndexByRange[e]!==void 0&&(n[e]=this.colorIndexByRange[e]);let r=new Set(Object.values(n)),i=0,a=()=>{for(;r.has(i);)i++;return r.add(i),i};for(let e of t)n[e]=e in n?n[e]:a();this.colorIndexByRange=n}getComposerHighlights(){if(!this.currentContent.startsWith(`=`)||this.mode===`inactive`)return[];let e=this.getters.getCurrentEditedCell().sheetId,t=e=>Lt[this.colorIndexByRange[e]%Lt.length];return this.getReferencedRanges().map(n=>{let r=this.getters.getRangeString(n,e);return{zone:n.zone,color:t(r),sheetId:n.sheetId}})}getReferencedRanges(){let e=this.getters.getCurrentEditedCell().sheetId;return this.currentTokens.filter(e=>e.type===`REFERENCE`).map(t=>this.getters.getRangeFromSheetXC(e,t.value)).filter(e=>!e.invalidSheetName&&!e.invalidXc)}getAutoCompleteDataValidationValues(){if(this.mode===`inactive`)return[];let e=this.getters.getValidationRuleForCell(this.getCurrentEditedCell());if(!e||e.criterion.type!==`isValueInList`&&e.criterion.type!==`isValueInRange`)return[];let t;if(e.criterion.type===`isValueInList`)t=e.criterion.values;else{let n=this.getters.getRangeFromSheetXC(this.sheetId,e.criterion.values[0]);t=Array.from(new Set(this.getters.getRangeValues(n).filter(pt).map(e=>e.toString()).filter(e=>e!==``)))}let n=this.getCurrentContent();if(n&&n!==this.getInitialComposerContent()){let e=za(n,t,e=>e);t=e.length?e:t}return t}canStartComposerRangeSelection(){if(this.currentContent.startsWith(`=`)){let e=this.getTokenAtCursor();if(!e)return!1;let t=this.currentTokens.map(e=>e.start).indexOf(e.start),n=t,r=e;for(;![`ARG_SEPARATOR`,`LEFT_PAREN`,`OPERATOR`].includes(r.type)||gc.includes(r.value);){if(r.type!==`SPACE`||n<1)return!1;n--,r=this.currentTokens[n]}for(n=t+1,r=this.currentTokens[n];r&&![`ARG_SEPARATOR`,`RIGHT_PAREN`,`OPERATOR`].includes(r.type);){if(r.type!==`SPACE`)return!1;n++,r=this.currentTokens[n]}return!0}return!1}checkDataValidation(e){let t={sheetId:this.sheetId,col:this.col,row:this.row};try{let e=this.getCurrentCanonicalContent(),n=e.startsWith(`=`)?this.getters.evaluateFormula(this.sheetId,e):to(e,this.getters.getLocale());if(j(n))return`Success`;let r=this.getters.getValidationResultForCellValue(n,t);return!r.isValid&&r.rule.isBlocking?`BlockingValidationRule`:`Success`}catch{return this.getters.getValidationRuleForCell(t)?.isBlocking?`BlockingValidationRule`:`Success`}}},pj=class extends Q{static getters=[`getCellBorderWithFilterBorder`,`getFilterValues`,`isRowFiltered`,`isFilterActive`];filterValues={};hiddenRows={};isEvaluationDirty=!1;allowDispatch(e){switch(e.type){case`UPDATE_FILTER`:if(!this.getters.getFilterId(e))return`FilterNotFound`;break}return`Success`}handle(e){switch(e.type){case`UNDO`:case`REDO`:case`UPDATE_CELL`:case`EVALUATE_CELLS`:case`ACTIVATE_SHEET`:case`REMOVE_FILTER_TABLE`:case`ADD_COLUMNS_ROWS`:case`REMOVE_COLUMNS_ROWS`:this.isEvaluationDirty=!0;break;case`START`:for(let e of this.getters.getSheetIds()){this.filterValues[e]={};for(let t of this.getters.getFilters(e))this.filterValues[e][t.id]=[]}break;case`CREATE_SHEET`:this.filterValues[e.sheetId]={};break;case`HIDE_COLUMNS_ROWS`:case`UNHIDE_COLUMNS_ROWS`:case`GROUP_HEADERS`:case`UNGROUP_HEADERS`:case`FOLD_HEADER_GROUP`:case`UNFOLD_HEADER_GROUP`:case`FOLD_ALL_HEADER_GROUPS`:case`UNFOLD_ALL_HEADER_GROUPS`:this.updateHiddenRows(e.sheetId);break;case`UPDATE_FILTER`:this.updateFilter(e),this.updateHiddenRows(e.sheetId);break;case`DUPLICATE_SHEET`:let t={};for(let n of this.getters.getFilters(e.sheetIdTo)){let r=n.zoneWithHeaders;t[n.id]=this.getFilterValues({sheetId:e.sheetId,col:r.left,row:r.top})}this.filterValues[e.sheetIdTo]=t;break}}finalize(){if(this.isEvaluationDirty){for(let e of this.getters.getSheetIds())this.updateHiddenRows(e);this.isEvaluationDirty=!1}}isRowFiltered(e,t){return!!this.hiddenRows[e]?.has(t)}getCellBorderWithFilterBorder(e){let{sheetId:t,col:n,row:r}=e,i;for(let e of this.getters.getFilterTables(t)){let a=e.zone;if(da(n,r,a)){let e=this.intersectZoneWithViewport(t,a);i={top:r===e.top?Fe:void 0,bottom:r===e.bottom?Fe:void 0,left:n===e.left?Fe:void 0,right:n===e.right?Fe:void 0}}}let a=this.getters.getCellBorder(e),o={...i,...St(a||{})};return mt(o)?null:o}getFilterValues(e){let t=this.getters.getFilterId(e),n=e.sheetId;return!t||!this.filterValues[n]?[]:this.filterValues[n][t]||[]}isFilterActive(e){let t=this.getters.getFilterId(e),n=e.sheetId;return!!(t&&this.filterValues[n]?.[t]?.length)}intersectZoneWithViewport(e,t){return{left:this.getters.findVisibleHeader(e,`COL`,t.left,t.right),right:this.getters.findVisibleHeader(e,`COL`,t.right,t.left),top:this.getters.findVisibleHeader(e,`ROW`,t.top,t.bottom),bottom:this.getters.findVisibleHeader(e,`ROW`,t.bottom,t.top)}}updateFilter({col:e,row:t,hiddenValues:n,sheetId:r}){let i=this.getters.getFilterId({sheetId:r,col:e,row:t});i&&(this.filterValues[r]||(this.filterValues[r]={}),this.filterValues[r][i]=n)}updateHiddenRows(e){let t=this.getters.getFilters(e).sort((e,t)=>e.zoneWithHeaders.top-t.zoneWithHeaders.top),n=new Set;for(let r of t){if(n.has(r.zoneWithHeaders.top)||this.getters.isRowHiddenByUser(e,r.zoneWithHeaders.top))continue;let t=this.filterValues[e]?.[r.id]?.map(To);if(!t||!r.filteredZone)continue;let i=new Set(t);for(let t=r.filteredZone.top;t<=r.filteredZone.bottom;t++){let a=this.getCellValueAsString(e,r.col,t);i.has(a)&&n.add(t)}}this.hiddenRows[e]=n}getCellValueAsString(e,t,n){return this.getters.getEvaluatedCell({sheetId:e,col:t,row:n}).formattedValue.toLowerCase()}exportForExcel(e){for(let t of e.sheets){let e=t.id;for(let n of t.filterTables){let r=ea(n.range),i=[],a=[];for(let n of w(0,va(r).numberOfCols)){let o={sheetId:t.id,col:r.left+n,row:r.top},s=this.getFilterValues(o),c=this.getters.getFilter(o);if(!c)continue;let l=c.filteredZone?ba(c.filteredZone).map(t=>this.getters.getEvaluatedCell({sheetId:e,...t}).formattedValue):[];if(s.length){let e=l.filter(e=>e).filter(e=>!s.includes(e));i.push({colId:n,displayedValues:[...new Set(e)],displayBlanks:!s.includes(``)&&l.some(e=>!e)})}let u={col:c.col,row:c.zoneWithHeaders.top,sheetId:e},d=this.getters.getEvaluatedCell(u).formattedValue,f=this.getUniqueColNameForExcel(n,d,a);a.push(f),t.cells[O(u.col,u.row)]={...t.cells[O(u.col,u.row)],content:f,value:f,isFormula:!1}}n.filters=i}}}getUniqueColNameForExcel(e,t,n){t||=`Column${e}`;let r=t,i=2;for(;n.includes(r);)r=t+String(i),i++;return r}};let mj=[{name:y(`Sum`),types:[`number`],compute:(e,t)=>Kp.compute.bind({locale:t})([e])},{name:y(`Avg`),types:[`number`],compute:(e,t)=>gm.compute.bind({locale:t})([e])},{name:y(`Min`),types:[`number`],compute:(e,t)=>zm.compute.bind({locale:t})([e])},{name:y(`Max`),types:[`number`],compute:(e,t)=>Fm.compute.bind({locale:t})([e])},{name:y(`Count`),types:[`number`,`text`,`boolean`,`error`],compute:(e,t)=>wm.compute.bind({locale:t})([e])},{name:y(`Count Numbers`),types:[`number`,`text`,`boolean`,`error`],compute:(e,t)=>Cm.compute.bind({locale:t})([e])}];var hj=class extends Q{static layers=[6];static getters=[`getActiveSheet`,`getActiveSheetId`,`getActiveCell`,`getActiveCols`,`getActiveRows`,`getCurrentStyle`,`getSelectedZones`,`getSelectedZone`,`getSelectedCells`,`getStatisticFnResults`,`getAggregate`,`getSelectedFigureId`,`getSelection`,`getActivePosition`,`getSheetPosition`,`isSelected`,`isSingleColSelected`,`getElementsFromSelection`,`tryGetActiveSheetId`,`isGridSelectionActive`];gridSelection={anchor:{cell:{col:0,row:0},zone:{top:0,left:0,bottom:0,right:0}},zones:[{top:0,left:0,bottom:0,right:0}]};selectedFigureId=null;sheetsData={};moveClient;activeSheet=null;constructor(e){super(e),this.moveClient=e.moveClient}allowDispatch(e){switch(e.type){case`ACTIVATE_SHEET`:try{this.getters.getSheet(e.sheetIdTo);break}catch{return`InvalidSheetId`}case`MOVE_COLUMNS_ROWS`:return this.isMoveElementAllowed(e)}return`Success`}handleEvent(e){let t=e.anchor,n=[];switch(e.mode){case`overrideSelection`:n=[t.zone];break;case`updateAnchor`:n=[...this.gridSelection.zones];let r=n.findIndex(t=>la(t,e.previousAnchor.zone));r>=0&&(n[r]=t.zone);break;case`newAnchor`:n=[...this.gridSelection.zones,t.zone];break}this.setSelectionMixin(e.anchor,n),this.selection.resetDefaultAnchor(this,S(this.gridSelection.anchor));let{col:r,row:i}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:r,row:i}),this.selectedFigureId=null}handle(e){switch(e.type){case`START_EDITION`:case`ACTIVATE_SHEET`:this.selectedFigureId=null;break;case`DELETE_FIGURE`:this.selectedFigureId===e.id&&(this.selectedFigureId=null);break;case`DELETE_SHEET`:this.selectedFigureId&&this.getters.getFigure(e.sheetId,this.selectedFigureId)&&(this.selectedFigureId=null);break}switch(e.type){case`START`:let t=this.getters.getVisibleSheetIds()[0];this.activateSheet(t,t);let{col:n,row:r}=this.getters.getNextVisibleCellPosition({sheetId:t,col:0,row:0});this.selectCell(n,r),this.selection.registerAsDefault(this,this.gridSelection.anchor,{handleEvent:this.handleEvent.bind(this)}),this.moveClient({sheetId:t,col:0,row:0});break;case`ACTIVATE_SHEET`:this.activateSheet(e.sheetIdFrom,e.sheetIdTo);break;case`REMOVE_COLUMNS_ROWS`:{let t=this.getters.getActiveSheetId();if(e.sheetId===t){e.dimension===`COL`?this.onColumnsRemoved(e):this.onRowsRemoved(e);let{col:n,row:r}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:n,row:r})}break}case`ADD_COLUMNS_ROWS`:{let t=this.getters.getActiveSheetId();if(e.sheetId===t){this.onAddElements(e);let{col:n,row:r}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:n,row:r})}break}case`MOVE_COLUMNS_ROWS`:e.sheetId===this.getActiveSheetId()&&this.onMoveElements(e);break;case`SELECT_FIGURE`:this.selectedFigureId=e.id;break;case`ACTIVATE_NEXT_SHEET`:this.activateNextSheet(`right`);break;case`ACTIVATE_PREVIOUS_SHEET`:this.activateNextSheet(`left`);break;case`HIDE_SHEET`:e.sheetId===this.getActiveSheetId()&&this.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:e.sheetId,sheetIdTo:this.getters.getVisibleSheetIds()[0]});break;case`UNDO`:case`REDO`:case`DELETE_SHEET`:let i=Object.keys(this.sheetsData).filter(e=>!this.getters.tryGetSheet(e));for(let e of i)delete this.sheetsData[e];for(let e in this.sheetsData){let t=this.clipSelection(e,this.sheetsData[e].gridSelection);this.sheetsData[e]={gridSelection:S(t)}}this.fallbackToVisibleSheet();let a=this.getters.getActiveSheetId();this.gridSelection.zones=this.gridSelection.zones.map(e=>this.getters.expandZone(a,e)),this.gridSelection.anchor.zone=this.getters.expandZone(a,this.gridSelection.anchor.zone),this.setSelectionMixin(this.gridSelection.anchor,this.gridSelection.zones),this.selectedFigureId=null;break}}finalize(){this.fallbackToVisibleSheet(),this.selection.resetDefaultAnchor(this,S(this.gridSelection.anchor))}isGridSelectionActive(){return this.selection.isListening(this)}getActiveSheet(){return this.activeSheet}getActiveSheetId(){return this.activeSheet.id}tryGetActiveSheetId(){return this.activeSheet?.id}getActiveCell(){return this.getters.getEvaluatedCell(this.getActivePosition())}getActiveCols(){let e=new Set;for(let t of this.gridSelection.zones)if(t.top===0&&t.bottom===this.getters.getNumberRows(this.getters.getActiveSheetId())-1)for(let n=t.left;n<=t.right;n++)e.add(n);return e}getActiveRows(){let e=new Set,t=this.getters.getActiveSheetId();for(let n of this.gridSelection.zones)if(n.left===0&&n.right===this.getters.getNumberCols(t)-1)for(let t=n.top;t<=n.bottom;t++)e.add(t);return e}getCurrentStyle(){let e=this.getters.getSelectedZone(),t=this.getters.getActiveSheetId();return this.getters.getCellStyle({sheetId:t,col:e.left,row:e.top})}getSelectedZones(){return S(this.gridSelection.zones)}getSelectedZone(){return S(this.gridSelection.anchor.zone)}getSelection(){return S(this.gridSelection)}getSelectedCells(){let e=this.getters.getActiveSheetId(),t=[];for(let n of this.gridSelection.zones)t.push(...this.getters.getEvaluatedCellsInZone(e,n));return t}getSelectedFigureId(){return this.selectedFigureId}getActivePosition(){return this.getters.getMainCellPosition({sheetId:this.getActiveSheetId(),col:this.gridSelection.anchor.cell.col,row:this.gridSelection.anchor.cell.row})}getSheetPosition(e){if(e===this.getters.getActiveSheetId())return this.getActivePosition();{let t=this.sheetsData[e];return t?{sheetId:e,col:t.gridSelection.anchor.cell.col,row:t.gridSelection.anchor.cell.row}:this.getters.getNextVisibleCellPosition({sheetId:e,col:0,row:0})}}getStatisticFnResults(){let e=this.getters.getActiveSheetId(),t=new Set;for(let n of this.gridSelection.zones)for(let{col:r,row:i}of ba(n)){if(this.getters.isRowHidden(e,i)||this.getters.isColHidden(e,r))continue;let n=this.getters.getEvaluatedCell({sheetId:e,col:r,row:i});n.type!==`empty`&&t.add(n)}let n=new Set,r=[];for(let e of t)n.add(e.type),r.push(e.value);let i=this.getters.getLocale(),a={};for(let e of mj){let t;e.types.some(e=>n.has(e))&&(t=e.compute(r,i)),a[e.name]=t}return a}getAggregate(){let e=0,t=0,n=this.getters.getActiveSheetId(),r=this.gridSelection.zones.map(ba).flat();for(let{col:i,row:a}of r){let r=this.getters.getEvaluatedCell({sheetId:n,col:i,row:a});r.type===`number`&&(t++,e+=r.value)}let i=this.getters.getLocale();return t<2?null:z(e,{locale:i})}isSelected(e){return!!this.getters.getSelectedZones().find(t=>la(t,e))}isSingleColSelected(){let e=this.getters.getSelectedZones();return!(e.length!==1||e[0].left!==e[0].right)}getElementsFromSelection(e){if(e===`COL`&&this.getters.getActiveCols().size===0||e===`ROW`&&this.getters.getActiveRows().size===0)return[];let t=this.getters.getSelectedZones(),n=[],r=e===`COL`?`left`:`top`,i=e===`COL`?`right`:`bottom`;for(let e of t){let t=Array.from({length:e[i]-e[r]+1},(t,n)=>e[r]+n);n=n.concat(t)}return[...new Set(n)].sort()}activateSheet(e,t){if(this.getters.isSheetVisible(t)||this.dispatch(`SHOW_SHEET`,{sheetId:t}),this.setActiveSheet(t),this.sheetsData[e]={gridSelection:S(this.gridSelection)},t in this.sheetsData)Object.assign(this,this.sheetsData[t]),this.selection.resetDefaultAnchor(this,S(this.gridSelection.anchor));else{let{col:e,row:n}=this.getters.getNextVisibleCellPosition({sheetId:t,col:0,row:0});this.selectCell(e,n)}let{col:n,row:r}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.activeSheet.id,col:n,row:r})}setSelectionMixin(e,t){let{anchor:n,zones:r}=this.clipSelection(this.getters.getActiveSheetId(),{anchor:e,zones:t});this.gridSelection.anchor=n,this.gridSelection.zones=Ca(r)}selectCell(e,t){let n=this.getters.getActiveSheetId(),r=this.getters.expandZone(n,{left:e,right:e,top:t,bottom:t});this.setSelectionMixin({zone:r,cell:{col:e,row:t}},[r])}setActiveSheet(e){let t=this.getters.getSheet(e);this.activeSheet=t}activateNextSheet(e){let t=this.getters.getSheetIds(),n=(t.findIndex(e=>e===this.activeSheet.id)+(e===`left`?t.length-1:1))%t.length;this.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:this.getActiveSheetId(),sheetIdTo:t[n]})}onColumnsRemoved(e){let{cell:t,zone:n}=this.gridSelection.anchor,r=aa(n,`left`,[...e.elements]),i={left:t.col,right:t.col,top:t.row,bottom:t.row};i=aa(i,`left`,[...e.elements]);let a={cell:{col:i.left,row:i.top},zone:r},o=this.gridSelection.zones.map(t=>aa(t,`left`,[...e.elements]));this.setSelectionMixin(a,o)}onRowsRemoved(e){let{cell:t,zone:n}=this.gridSelection.anchor,r=aa(n,`top`,[...e.elements]),i={left:t.col,right:t.col,top:t.row,bottom:t.row};i=aa(i,`top`,[...e.elements]);let a={cell:{col:i.left,row:i.top},zone:r},o=this.gridSelection.zones.map(t=>aa(t,`top`,[...e.elements]));this.setSelectionMixin(a,o)}onAddElements(e){let t=e.dimension===`COL`?`left`:`top`,n=ia(this.gridSelection.anchor.zone,t,e.base,e.position,e.quantity),r=this.gridSelection.zones.map(n=>ia(n,t,e.base,e.position,e.quantity)),i={cell:{col:n.left,row:n.top},zone:n};this.setSelectionMixin(i,r)}onMoveElements(e){let t=e.elements.length;this.dispatch(`ADD_COLUMNS_ROWS`,{dimension:e.dimension,sheetId:e.sheetId,base:e.base,quantity:t,position:e.position});let n=e.dimension===`COL`,r=e.elements[0],i=e.elements[t-1],a=e.base<r,o=a&&n?t:0,s=a&&!n?t:0,c=a?e.elements.map(e=>e+t):e.elements,l=Object.fromEntries(c.map(t=>{let r=n?this.getters.getColSize(e.sheetId,t):this.getters.getUserRowSize(e.sheetId,t);return[t,n&&r===96||r===void 0?null:r]})),u=new hA([{left:n?r+o:0,right:n?i+o:this.getters.getNumberCols(e.sheetId)-1,top:n?0:r+s,bottom:n?this.getters.getNumberRows(e.sheetId)-1:i+s}],`CUT`,this.getters,this.dispatch,this.selection,`shiftCells`),d=a?e.base:e.base+1,f=[{left:n?d:0,right:n?d+t-1:this.getters.getNumberCols(e.sheetId)-1,top:n?0:d,bottom:n?this.getters.getNumberRows(e.sheetId)-1:d+t-1}];u.paste(f,{selectTarget:!0});let p=a?e.base:e.base+1;for(let t of c)this.dispatch(`RESIZE_COLUMNS_ROWS`,{dimension:e.dimension,sheetId:e.sheetId,size:l[t],elements:[p]}),p+=1;this.dispatch(`REMOVE_COLUMNS_ROWS`,{dimension:e.dimension,sheetId:e.sheetId,elements:c})}isMoveElementAllowed(e){let t=e.dimension===`COL`,n=e.elements[0],r=e.elements[e.elements.length-1],i=e.sheetId,a=t?this.getters.doesColumnsHaveCommonMerges:this.getters.doesRowsHaveCommonMerges;if(a(i,n-1,n)||a(i,r,r+1)||a(i,e.base-1,e.base))return`WillRemoveExistingMerge`;let o=[e.base,...e.elements],s=t?this.getters.getNumberCols(i):this.getters.getNumberRows(i);return o.some(e=>e<0||e>=s)?`InvalidHeaderIndex`:`Success`}fallbackToVisibleSheet(){if(!this.getters.tryGetSheet(this.getters.getActiveSheetId())){let e=this.getters.getVisibleSheetIds();if(this.activeSheet=this.getters.getSheet(e[0]),this.activeSheet.id in this.sheetsData){let{anchor:e}=this.clipSelection(this.activeSheet.id,this.sheetsData[this.activeSheet.id].gridSelection);this.selectCell(e.cell.col,e.cell.row)}else this.selectCell(0,0);let{col:t,row:n}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:t,row:n})}}clipSelection(e,t){let n=this.getters.getNumberCols(e)-1,r=this.getters.getNumberRows(e)-1,i=t.zones.map(e=>({left:C(e.left,0,n),right:C(e.right,0,n),top:C(e.top,0,r),bottom:C(e.bottom,0,r)})),a=C(t.anchor.cell.col,0,n),o=C(t.anchor.cell.row,0,r),s={left:C(t.anchor.zone.left,0,n),right:C(t.anchor.zone.right,0,n),top:C(t.anchor.zone.top,0,r),bottom:C(t.anchor.zone.bottom,0,r)};return{zones:i,anchor:{cell:{col:a,row:o},zone:s}}}drawGrid(e){if(this.getters.isDashboard())return;let{ctx:t,thinLineWidth:n}=e,r=this.getSelectedZones();t.fillStyle=`#f3f7fe`,t.fillStyle=r.length===1&&r[0].left===r[0].right&&r[0].top===r[0].bottom?`#f3f7fe`:`#e9f0ff`,t.strokeStyle=pe,t.lineWidth=1.5*n;for(let e of r){let{x:n,y:r,width:i,height:a}=this.getters.getVisibleRect(e);t.globalCompositeOperation=`multiply`,t.fillRect(n,r,i,a),t.globalCompositeOperation=`source-over`,t.strokeRect(n,r,i,a)}t.globalCompositeOperation=`source-over`;let i=this.getActivePosition();t.strokeStyle=pe,t.lineWidth=3*n;let a;a=this.getters.isInMerge(i)?this.getters.getMerge(i):V(i);let{x:o,y:s,width:c,height:l}=this.getters.getVisibleRect(a);c>0&&l>0&&t.strokeRect(o,s,c,l)}},gj=class{getters;sheetId;boundaries;top;bottom;left;right;offsetX;offsetY;offsetScrollbarX;offsetScrollbarY;canScrollVertically;canScrollHorizontally;viewportWidth;viewportHeight;offsetCorrectionX;offsetCorrectionY;constructor(e,t,n,r,i,a){if(this.getters=e,this.sheetId=t,this.boundaries=n,r.width<0||r.height<0)throw Error(`Viewport size cannot be negative`);this.viewportWidth=r.height&&r.width,this.viewportHeight=r.width&&r.height,this.top=n.top,this.bottom=n.bottom,this.left=n.left,this.right=n.right,this.offsetX=a.x,this.offsetY=a.y,this.offsetScrollbarX=a.x,this.offsetScrollbarY=a.y,this.canScrollVertically=i.canScrollVertically,this.canScrollHorizontally=i.canScrollHorizontally,this.offsetCorrectionX=this.getters.getColDimensions(this.sheetId,this.boundaries.left).start,this.offsetCorrectionY=this.getters.getRowDimensions(this.sheetId,this.boundaries.top).start,this.adjustViewportOffsetX(),this.adjustViewportOffsetY()}getMaxSize(){let e=this.getters.findLastVisibleColRowIndex(this.sheetId,`COL`,{first:this.boundaries.left,last:this.boundaries.right}),t=this.getters.findLastVisibleColRowIndex(this.sheetId,`ROW`,{first:this.boundaries.top,last:this.boundaries.bottom}),{end:n,size:r}=this.getters.getColDimensions(this.sheetId,e),{end:i,size:a}=this.getters.getRowDimensions(this.sheetId,t),o=this.searchHeaderIndex(`COL`,n-this.viewportWidth,0),s=this.getters.getColSize(this.sheetId,o),c=this.searchHeaderIndex(`ROW`,i-this.viewportHeight,0),l=this.getters.getRowSize(this.sheetId,c),u=n-this.offsetCorrectionX;this.canScrollHorizontally&&(u+=Math.max(96,Math.min(s,this.viewportWidth-r)),u=Math.max(u,this.viewportWidth));let d=i-this.offsetCorrectionY;return this.canScrollVertically&&(d+=Math.max(28,Math.min(l,this.viewportHeight-a)),d=Math.max(d,this.viewportHeight),i+46>d&&!this.getters.isReadonly()&&(d+=46)),{width:u,height:d}}getColIndex(e){return e<this.offsetCorrectionX||e>this.offsetCorrectionX+this.viewportWidth?-1:this.searchHeaderIndex(`COL`,e-this.offsetCorrectionX,this.left)}getRowIndex(e){return e<this.offsetCorrectionY||e>this.offsetCorrectionY+this.viewportHeight?-1:this.searchHeaderIndex(`ROW`,e-this.offsetCorrectionY,this.top)}adjustPosition(e){let t=this.sheetId;e||=this.getters.getSheetPosition(t);let n=this.getters.getMainCellPosition({sheetId:t,...e}),{col:r,row:i}=this.getters.getNextVisibleCellPosition(n);da(r,this.boundaries.top,this.boundaries)&&this.adjustPositionX(r),da(this.boundaries.left,i,this.boundaries)&&this.adjustPositionY(i)}adjustPositionX(e){let t=this.sheetId,{end:n}=this.getters.getColDimensions(t,e),r=this.getters.getNumberCols(t);if(this.offsetX+this.offsetCorrectionX+this.viewportWidth<n){let n=e;for(;this.getters.isColHidden(t,n)&&e<r;)n++;let i=this.getters.getColDimensions(t,n).end,a=this.searchHeaderIndex(`COL`,i-this.viewportWidth-this.offsetCorrectionX,this.boundaries.left);this.offsetX=this.getters.getColDimensions(t,a).end-this.offsetCorrectionX,this.offsetScrollbarX=this.offsetX,this.adjustViewportZoneX()}else if(this.left>e){let n=e;for(;this.getters.isColHidden(t,n)&&e>0;)n--;this.offsetX=this.getters.getColDimensions(t,n).start-this.offsetCorrectionX,this.offsetScrollbarX=this.offsetX,this.adjustViewportZoneX()}}adjustPositionY(e){let t=this.sheetId,{end:n}=this.getters.getRowDimensions(t,e),r=this.getters.getNumberRows(t);if(this.offsetY+this.viewportHeight+this.offsetCorrectionY<n){let n=e;for(;this.getters.isRowHidden(t,n)&&e<r;)n++;let i=this.getters.getRowDimensions(t,n).end,a=this.searchHeaderIndex(`ROW`,i-this.viewportHeight-this.offsetCorrectionY,this.boundaries.top);this.offsetY=this.getters.getRowDimensions(t,a).end-this.offsetCorrectionY,this.offsetScrollbarY=this.offsetY,this.adjustViewportZoneY()}else if(this.top>e){let n=e;for(;this.getters.isRowHidden(t,n)&&e>0;)n--;this.offsetY=this.getters.getRowDimensions(t,n).start-this.offsetCorrectionY,this.offsetScrollbarY=this.offsetY,this.adjustViewportZoneY()}}setViewportOffset(e,t){this.setViewportOffsetX(e),this.setViewportOffsetY(t)}adjustViewportZone(){this.adjustViewportZoneX(),this.adjustViewportZoneY()}getVisibleRect(e){let t=ca(e,this.zone);if(t)return{x:this.getters.getColRowOffset(`COL`,this.zone.left,t.left)+this.offsetCorrectionX,y:this.getters.getColRowOffset(`ROW`,this.zone.top,t.top)+this.offsetCorrectionY,width:Math.min(this.getters.getColRowOffset(`COL`,t.left,t.right+1),this.viewportWidth),height:Math.min(this.getters.getColRowOffset(`ROW`,t.top,t.bottom+1),this.viewportHeight)}}getFullRect(e){if(ca(e,this.zone))return{x:this.getters.getColRowOffset(`COL`,this.zone.left,e.left)+this.offsetCorrectionX,y:this.getters.getColRowOffset(`ROW`,this.zone.top,e.top)+this.offsetCorrectionY,width:this.getters.getColRowOffset(`COL`,e.left,e.right+1),height:this.getters.getColRowOffset(`ROW`,e.top,e.bottom+1)}}isVisible(e,t){return t<=this.bottom&&t>=this.top&&e>=this.left&&e<=this.right&&!this.getters.isColHidden(this.sheetId,e)&&!this.getters.isRowHidden(this.sheetId,t)}searchHeaderIndex(e,t,n=0){if(this.viewportWidth<=0||this.viewportHeight<=0)return-1;let r=this.sheetId,i=this.getters.getNumberHeaders(r,e),a=n,o=i;for(;a<=o&&a!==i&&o!==-1;){let i=Math.floor((a+o)/2),s=this.getters.getColRowOffset(e,n,i),c=this.getters.getHeaderSize(r,e,i);if(t>=s&&t<s+c)return i;t>=s+c?a=i+1:o=i-1}return-1}get zone(){return{left:this.left,right:this.right,top:this.top,bottom:this.bottom}}setViewportOffsetX(e){this.canScrollHorizontally&&(this.offsetScrollbarX=e,this.adjustViewportZoneX())}setViewportOffsetY(e){this.canScrollVertically&&(this.offsetScrollbarY=e,this.adjustViewportZoneY())}adjustViewportOffsetX(){if(this.canScrollHorizontally){let{width:e}=this.getMaxSize();this.viewportWidth+this.offsetScrollbarX>e&&(this.offsetScrollbarX=Math.max(0,e-this.viewportWidth))}this.left=this.getColIndex(this.offsetScrollbarX),this.right=this.getColIndex(this.offsetScrollbarX+this.viewportWidth),this.right===-1&&(this.right=this.boundaries.right),this.adjustViewportZoneX()}adjustViewportOffsetY(){if(this.canScrollVertically){let{height:e}=this.getMaxSize();this.viewportHeight+this.offsetScrollbarY>e&&(this.offsetScrollbarY=Math.max(0,e-this.viewportHeight))}this.top=this.getRowIndex(this.offsetScrollbarY),this.bottom=this.getRowIndex(this.offsetScrollbarY+this.viewportHeight),this.bottom===-1&&(this.bottom=this.boundaries.bottom),this.adjustViewportZoneY()}adjustViewportZoneX(){let e=this.sheetId;if(this.left=this.searchHeaderIndex(`COL`,this.offsetScrollbarX,this.boundaries.left),this.right=Math.min(this.boundaries.right,this.searchHeaderIndex(`COL`,this.viewportWidth,this.left)),this.viewportWidth){if(this.left===-1){let e=this.getters.getColRowOffset(`COL`,this.boundaries.left,this.boundaries.right);0<e&&e<=this.offsetScrollbarX?this.left=this.boundaries.right:this.left=this.boundaries.left}this.right===-1&&(this.right=this.boundaries.right),this.offsetX=this.getters.getColDimensions(e,this.left).start-this.getters.getColDimensions(e,this.boundaries.left).start}}adjustViewportZoneY(){let e=this.sheetId;if(this.top=this.searchHeaderIndex(`ROW`,this.offsetScrollbarY,this.boundaries.top),this.bottom=Math.min(this.boundaries.bottom,this.searchHeaderIndex(`ROW`,this.viewportHeight,this.top)),this.viewportHeight){if(this.top===-1){let e=this.getters.getColRowOffset(`ROW`,this.boundaries.top,this.boundaries.bottom);0<e&&e<=this.offsetScrollbarY?this.top=this.boundaries.bottom:this.top=this.boundaries.top}this.bottom===-1&&(this.bottom=this.boundaries.bottom),this.offsetY=this.getters.getRowDimensions(e,this.top).start-this.getters.getRowDimensions(e,this.boundaries.top).start}}},_j=class extends Q{static getters=[`getColIndex`,`getRowIndex`,`getActiveMainViewport`,`getSheetViewDimension`,`getSheetViewDimensionWithHeaders`,`getMainViewportRect`,`isVisibleInViewport`,`getEdgeScrollCol`,`getEdgeScrollRow`,`getVisibleFigures`,`getVisibleRect`,`getVisibleRectWithoutHeaders`,`getVisibleCellPositions`,`getColRowOffsetInViewport`,`getMainViewportCoordinates`,`getActiveSheetScrollInfo`,`getActiveSheetDOMScrollInfo`,`getSheetViewVisibleCols`,`getSheetViewVisibleRows`,`getFrozenSheetViewRatio`,`isPositionVisible`,`getAllActiveViewportsZonesAndRect`,`getRect`];viewports={};sheetViewWidth=Ge();sheetViewHeight=Ge();gridOffsetX=0;gridOffsetY=0;sheetsWithDirtyViewports=new Set;shouldAdjustViewports=!1;allowDispatch(e){switch(e.type){case`SET_VIEWPORT_OFFSET`:return this.checkScrollingDirection(e);case`RESIZE_SHEETVIEW`:return this.chainValidations(this.checkValuesAreDifferent,this.checkPositiveDimension)(e);default:return`Success`}}handleEvent(e){let t=this.getters.getActiveSheetId();if(e.options.scrollIntoView){let{col:n,row:r}=Ta(e.previousAnchor.zone,e.anchor.zone);if(e.mode===`updateAnchor`){let i=e.previousAnchor.zone,a=e.anchor.zone,{top:o,bottom:s,left:c,right:l}=this.getMainInternalViewport(t);i.left===a.left&&i.right===a.right&&(n=c>n||n>l?c:n),i.top===a.top&&i.bottom===a.bottom&&(r=o>r||r>s?o:r)}n=Math.min(n,this.getters.getNumberCols(t)-1),r=Math.min(r,this.getters.getNumberRows(t)-1),this.sheetsWithDirtyViewports.has(t)||this.refreshViewport(this.getters.getActiveSheetId(),{col:n,row:r})}}handle(e){if(ar.has(e.type))for(let e of this.getters.getSheetIds())this.sheetsWithDirtyViewports.add(e);switch(e.type){case`START`:this.selection.observe(this,{handleEvent:this.handleEvent.bind(this)}),this.resetViewports(this.getters.getActiveSheetId());break;case`UNDO`:case`REDO`:this.cleanViewports();for(let e of this.getters.getSheetIds())this.sheetsWithDirtyViewports.add(e);this.shouldAdjustViewports=!0;break;case`RESIZE_SHEETVIEW`:this.resizeSheetView(e.height,e.width,e.gridOffsetX,e.gridOffsetY);break;case`SET_VIEWPORT_OFFSET`:this.setSheetViewOffset(e.offsetX,e.offsetY);break;case`SHIFT_VIEWPORT_DOWN`:let t=this.getters.getActiveSheetId(),{top:n,viewportHeight:r,offsetCorrectionY:i}=this.getMainInternalViewport(t),a=this.getters.getRowDimensions(t,n);this.shiftVertically(a.start+r-i);break;case`SHIFT_VIEWPORT_UP`:{let e=this.getters.getActiveSheetId(),{top:t,viewportHeight:n,offsetCorrectionY:r}=this.getMainInternalViewport(e),i=this.getters.getRowDimensions(e,t);this.shiftVertically(i.end-r-n);break}case`REMOVE_FILTER_TABLE`:case`UPDATE_FILTER`:case`UNFREEZE_ROWS`:case`UNFREEZE_COLUMNS`:case`FREEZE_COLUMNS`:case`FREEZE_ROWS`:case`UNFREEZE_COLUMNS_ROWS`:case`REMOVE_COLUMNS_ROWS`:case`RESIZE_COLUMNS_ROWS`:case`HIDE_COLUMNS_ROWS`:case`ADD_COLUMNS_ROWS`:case`UNHIDE_COLUMNS_ROWS`:case`UNGROUP_HEADERS`:case`GROUP_HEADERS`:case`FOLD_HEADER_GROUP`:case`UNFOLD_HEADER_GROUP`:case`FOLD_HEADER_GROUPS_IN_ZONE`:case`UNFOLD_HEADER_GROUPS_IN_ZONE`:case`UNFOLD_ALL_HEADER_GROUPS`:case`FOLD_ALL_HEADER_GROUPS`:this.sheetsWithDirtyViewports.add(e.sheetId);break;case`UPDATE_CELL`:for(let e of this.getters.getSheetIds())this.sheetsWithDirtyViewports.add(e);break;case`DELETE_SHEET`:this.cleanViewports(),this.sheetsWithDirtyViewports.delete(e.sheetId);break;case`ACTIVATE_SHEET`:this.sheetsWithDirtyViewports.add(e.sheetIdTo);break;case`DELETE_SHEET`:this.sheetsWithDirtyViewports.delete(e.sheetId);break;case`START_EDITION`:let{col:o,row:s}=this.getters.getActivePosition();this.refreshViewport(this.getters.getActiveSheetId(),{col:o,row:s});break}}finalize(){for(let e of this.sheetsWithDirtyViewports)if(this.resetViewports(e),this.shouldAdjustViewports){let t=this.getters.getSheetPosition(e),n=this.getSubViewports(e);Object.values(n).forEach(e=>{e.adjustPosition(t)})}this.sheetsWithDirtyViewports=new Set,this.shouldAdjustViewports=!1,this.setViewports()}setViewports(){let e=this.getters.getSheetIds();for(let t of e)this.viewports[t]?.bottomRight||this.resetViewports(t)}getColIndex(e){let t=this.getters.getActiveSheetId();return Math.max(...this.getSubViewports(t).map(t=>t.getColIndex(e)))}getRowIndex(e){let t=this.getters.getActiveSheetId();return Math.max(...this.getSubViewports(t).map(t=>t.getRowIndex(e)))}getSheetViewDimensionWithHeaders(){return{width:this.sheetViewWidth+this.gridOffsetX,height:this.sheetViewHeight+this.gridOffsetY}}getSheetViewDimension(){return{width:this.sheetViewWidth,height:this.sheetViewHeight}}getActiveMainViewport(){let e=this.getters.getActiveSheetId();return this.getMainViewport(e)}getActiveSheetScrollInfo(){let e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e);return{scrollX:t.offsetX,scrollY:t.offsetY}}getActiveSheetDOMScrollInfo(){let e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e);return{scrollX:t.offsetScrollbarX,scrollY:t.offsetScrollbarY}}getSheetViewVisibleCols(){let e=this.getters.getActiveSheetId(),t=this.getSubViewports(e);return[...new Set(t.map(e=>w(e.left,e.right+1)).flat())].filter(t=>t>=0&&!this.getters.isHeaderHidden(e,`COL`,t))}getSheetViewVisibleRows(){let e=this.getters.getActiveSheetId(),t=this.getSubViewports(e);return[...new Set(t.map(e=>w(e.top,e.bottom+1)).flat())].filter(t=>t>=0&&!this.getters.isHeaderHidden(e,`ROW`,t))}getVisibleCellPositions(){let e=this.getSheetViewVisibleCols(),t=this.getSheetViewVisibleRows(),n=this.getters.getActiveSheetId(),r=[];for(let i of e)for(let e of t){let t={sheetId:n,col:i,row:e},a=this.getters.getMainCellPosition(t);a.row!==e||a.col!==i||r.push(t)}return r}getMainViewportRect(){let e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e),{xSplit:n,ySplit:r}=this.getters.getPaneDivisions(e),{width:i,height:a}=t.getMaxSize();return{x:this.getters.getColDimensions(e,n).start,y:this.getters.getRowDimensions(e,r).start,width:i,height:a}}getMaximumSheetOffset(){let e=this.getters.getActiveSheetId(),{width:t,height:n}=this.getMainViewportRect(),r=this.getMainInternalViewport(e);return{maxOffsetX:Math.max(0,t-r.viewportWidth+1),maxOffsetY:Math.max(0,n-r.viewportHeight+1)}}getColRowOffsetInViewport(e,t,n){if(n<t)return-this.getColRowOffsetInViewport(e,n,t);let r=this.getters.getActiveSheetId(),i=e===`COL`?this.getters.getSheetViewVisibleCols():this.getters.getSheetViewVisibleRows(),a=i.findIndex(e=>t>=e),o=i.findIndex(e=>n<=e);o=o===-1?i.length:o;let s=i.slice(a,o),c=0;for(let t of s)c+=this.getters.getHeaderSize(r,e,t);return c}isVisibleInViewport({sheetId:e,col:t,row:n}){return this.getSubViewports(e).some(e=>e.isVisible(t,n))}getEdgeScrollCol(e,t,n){let r=!1,i=0,a=0,{xSplit:o}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{width:s}=this.getSheetViewDimension(),{x:c}=this.getMainViewportCoordinates(),l=this.getActiveSheetScrollInfo().scrollX;return e>s?(r=!0,a=$r(e-s),i=1):e<c&&n>=c&&l>0?(r=!0,a=$r(c-e),i=-1):o&&t<c&&e>c&&(r=!0,a=$r(e),i=`reset`),{canEdgeScroll:r,direction:i,delay:a}}getEdgeScrollRow(e,t,n){let r=!1,i=0,a=0,{ySplit:o}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{height:s}=this.getSheetViewDimension(),{y:c}=this.getMainViewportCoordinates(),l=this.getActiveSheetScrollInfo().scrollY;return e>s?(r=!0,a=$r(e-s),i=1):e<c&&n>=c&&l>0?(r=!0,a=$r(c-e),i=-1):o&&t<c&&e>c&&(r=!0,a=$r(e),i=`reset`),{canEdgeScroll:r,direction:i,delay:a}}getVisibleRect(e){let t=this.getVisibleRectWithoutHeaders(e);return{...t,x:t.x+this.gridOffsetX,y:t.y+this.gridOffsetY}}getVisibleRectWithoutHeaders(e){let t=this.getters.getActiveSheetId();return this.mapViewportsToRect(t,t=>t.getVisibleRect(e))}getRect(e){let t=this.getters.getActiveSheetId(),n=this.mapViewportsToRect(t,t=>t.getFullRect(e));return{...n,x:n.x+this.gridOffsetX,y:n.y+this.gridOffsetY}}getMainViewportCoordinates(){let e=this.getters.getActiveSheetId(),{xSplit:t,ySplit:n}=this.getters.getPaneDivisions(e);return{x:this.getters.getColDimensions(e,t).start,y:this.getters.getRowDimensions(e,n).start}}getAllActiveViewportsZonesAndRect(){let e=this.getters.getActiveSheetId();return this.getSubViewports(e).map(e=>({zone:e,rect:{x:e.offsetCorrectionX+this.gridOffsetX,y:e.offsetCorrectionY+this.gridOffsetY,...e.getMaxSize()}}))}ensureMainViewportExist(e){this.viewports[e]||this.resetViewports(e)}getSubViewports(e){return this.ensureMainViewportExist(e),Object.values(this.viewports[e]).filter(T)}checkPositiveDimension(e){return e.width<0||e.height<0?`InvalidViewportSize`:`Success`}checkValuesAreDifferent(e){let{height:t,width:n}=this.getSheetViewDimension();return e.gridOffsetX===this.gridOffsetX&&e.gridOffsetY===this.gridOffsetY&&e.width===n&&e.height===t?`ValuesNotChanged`:`Success`}checkScrollingDirection({offsetX:e,offsetY:t}){let n=this.getMainInternalViewport(this.getters.getActiveSheetId());return!n.canScrollHorizontally&&e>0||!n.canScrollVertically&&t>0?`InvalidScrollingDirection`:`Success`}getMainViewport(e){let t=this.getMainInternalViewport(e);return{top:t.top,left:t.left,bottom:t.bottom,right:t.right}}getMainInternalViewport(e){return this.ensureMainViewportExist(e),this.viewports[e].bottomRight}cleanViewports(){let e={};for(let t of this.getters.getSheetIds())e[t]=this.viewports[t];this.viewports=e}resizeSheetView(e,t,n=0,r=0){this.sheetViewHeight=e,this.sheetViewWidth=t,this.gridOffsetX=n,this.gridOffsetY=r,this.recomputeViewports()}recomputeViewports(){for(let e of this.getters.getSheetIds())this.resetViewports(e)}setSheetViewOffset(e,t){let n=this.getters.getActiveSheetId(),{maxOffsetX:r,maxOffsetY:i}=this.getMaximumSheetOffset();this.getSubViewports(n).forEach(n=>n.setViewportOffset(C(e,0,r),C(t,0,i)))}getViewportOffset(e){return{x:this.viewports[e]?.bottomRight.offsetScrollbarX||0,y:this.viewports[e]?.bottomRight.offsetScrollbarY||0}}resetViewports(e){if(!this.getters.tryGetSheet(e))return;let{xSplit:t,ySplit:n}=this.getters.getPaneDivisions(e),r=this.getters.getNumberCols(e),i=this.getters.getNumberRows(e),a=Math.min(this.getters.getColRowOffset(`COL`,0,t,e),this.sheetViewWidth),o=Math.min(this.getters.getColRowOffset(`ROW`,0,n,e),this.sheetViewHeight),s=Math.max(this.sheetViewWidth-a,0),c=Math.max(this.sheetViewHeight-o,0),{xRatio:l,yRatio:u}=this.getFrozenSheetViewRatio(e),d=l<1,f=u<1,p=this.getViewportOffset(e),m={topLeft:n&&t&&new gj(this.getters,e,{left:0,right:t-1,top:0,bottom:n-1},{width:a,height:o},{canScrollHorizontally:!1,canScrollVertically:!1},{x:0,y:0})||void 0,topRight:n&&new gj(this.getters,e,{left:t,right:r-1,top:0,bottom:n-1},{width:s,height:o},{canScrollHorizontally:d,canScrollVertically:!1},{x:d?p.x:0,y:0})||void 0,bottomLeft:t&&new gj(this.getters,e,{left:0,right:t-1,top:n,bottom:i-1},{width:a,height:c},{canScrollHorizontally:!1,canScrollVertically:f},{x:0,y:f?p.y:0})||void 0,bottomRight:new gj(this.getters,e,{left:t,right:r-1,top:n,bottom:i-1},{width:s,height:c},{canScrollHorizontally:d,canScrollVertically:f},{x:d?p.x:0,y:f?p.y:0})};this.viewports[e]=m}refreshViewport(e,t){this.getSubViewports(e).forEach(e=>{e.adjustViewportZone(),e.adjustPosition(t)})}shiftVertically(e){let t=this.getters.getActiveSheetId(),{top:n}=this.getMainInternalViewport(t),{scrollX:r}=this.getActiveSheetScrollInfo();this.setSheetViewOffset(r,e);let{anchor:i}=this.getters.getSelection();if(i.cell.row>=this.getters.getPaneDivisions(t).ySplit){let e=this.getMainInternalViewport(t).top-n;this.selection.selectCell(i.cell.col,i.cell.row+e)}}getVisibleFigures(){let e=this.getters.getActiveSheetId(),t=[],n=this.getters.getFigures(e),{scrollX:r,scrollY:i}=this.getActiveSheetScrollInfo(),{x:a,y:o}=this.getters.getMainViewportCoordinates(),{width:s,height:c}=this.getters.getSheetViewDimensionWithHeaders();for(let e of n)e.x>=a&&(e.x+e.width<=a+r||e.x>=s+r+a)||e.y>=o&&(e.y+e.height<=o+i||e.y>=c+i+o)||t.push(e);return t}isPositionVisible(e){let{scrollX:t,scrollY:n}=this.getters.getActiveSheetScrollInfo(),{x:r,y:i}=this.getters.getMainViewportCoordinates(),{width:a,height:o}=this.getters.getSheetViewDimension();return!(e.x>=r&&(e.x<r+t||e.x>a+t+r)||e.y>=i&&(e.y<i+n||e.y>o+n+i))}getFrozenSheetViewRatio(e){let{xSplit:t,ySplit:n}=this.getters.getPaneDivisions(e),r=this.getters.getColDimensions(e,t).start,i=this.getters.getRowDimensions(e,n).start,a=this.sheetViewWidth+this.gridOffsetX,o=this.sheetViewHeight+this.gridOffsetY;return{xRatio:r/a,yRatio:i/o}}mapViewportsToRect(e,t){let n=1/0,r=1/0,i=0,a=0,o=!1;for(let s of this.getSubViewports(e)){let e=t(s);e&&(o=!0,n=Math.min(n,e.x),r=Math.min(r,e.y),i=Math.max(i,e.x+e.width),a=Math.max(a,e.y+e.height))}return o?{x:n,y:r,width:i-n,height:a-r}:{x:0,y:0,width:0,height:0}}},vj=class extends Q{static getters=[`getColDimensions`,`getRowDimensions`,`getColRowOffset`];headerPositions={};isDirty=!0;handle(e){switch(ar.has(e.type)&&(this.headerPositions={},this.isDirty=!0),e.type){case`START`:for(let e of this.getters.getSheetIds())this.headerPositions[e]=this.computeHeaderPositionsOfSheet(e);break;case`UPDATE_CELL`:this.headerPositions={},this.isDirty=!0;break;case`UPDATE_FILTER`:case`REMOVE_FILTER_TABLE`:this.headerPositions={},this.isDirty=!0;break;case`REMOVE_COLUMNS_ROWS`:case`RESIZE_COLUMNS_ROWS`:case`HIDE_COLUMNS_ROWS`:case`ADD_COLUMNS_ROWS`:case`UNHIDE_COLUMNS_ROWS`:case`FOLD_HEADER_GROUP`:case`UNFOLD_HEADER_GROUP`:case`FOLD_HEADER_GROUPS_IN_ZONE`:case`UNFOLD_HEADER_GROUPS_IN_ZONE`:case`UNFOLD_ALL_HEADER_GROUPS`:case`FOLD_ALL_HEADER_GROUPS`:case`UNGROUP_HEADERS`:case`GROUP_HEADERS`:case`CREATE_SHEET`:this.getters.tryGetSheet(e.sheetId)&&(this.headerPositions[e.sheetId]=this.computeHeaderPositionsOfSheet(e.sheetId));break;case`DUPLICATE_SHEET`:this.headerPositions[e.sheetIdTo]=S(this.headerPositions[e.sheetId]);break}}finalize(){for(let e of this.getters.getSheetIds())(this.isDirty||!this.headerPositions[e])&&(this.headerPositions[e]=this.computeHeaderPositionsOfSheet(e));this.isDirty=!1}getColDimensions(e,t){let n=this.headerPositions[e].COL[t],r=this.getters.getColSize(e,t);return{start:n,size:r,end:n+(this.getters.isColHidden(e,t)?0:r)}}getRowDimensions(e,t){let n=this.headerPositions[e].ROW[t],r=this.getters.getRowSize(e,t);return{start:n,size:r,end:n+(this.getters.isRowHidden(e,t)?0:r)}}getColRowOffset(e,t,n,r=this.getters.getActiveSheetId()){let i=this.headerPositions[r][e][t];return this.headerPositions[r][e][n]-i}computeHeaderPositionsOfSheet(e){return{COL:this.computePositions(e,`COL`),ROW:this.computePositions(e,`ROW`)}}computePositions(e,t){let n={},r=0;for(let i=0;i<this.getters.getNumberHeaders(e,t)+1;i++)n[i]=r,!this.getters.isHeaderHidden(e,t,i)&&(r+=this.getters.getHeaderSize(e,t,i));return n}};let yj=new H().add(`settings`,pk).add(`sheet`,dk).add(`header grouping`,fk).add(`header visibility`,ak).add(`filters`,rk).add(`cell`,RO).add(`merge`,sk).add(`headerSize`,ik).add(`borders`,LO).add(`conditional formatting`,QO).add(`figures`,ek).add(`chart`,VO).add(`image`,ok).add(`dataValidation`,$O),bj=new H().add(`ui_sheet`,EA).add(`ui_options`,TA).add(`selectionInputManager`,CA).add(`highlight`,bA).add(`grid renderer`,xA).add(`autofill`,Lk).add(`find_and_replace`,_A).add(`sort`,wA).add(`automatic_sum`,Rk).add(`format`,vA).add(`split_to_columns`,QA).add(`cell_popovers`,zk).add(`collaborative`,pA).add(`history`,ZA).add(`data_cleanup`,gA),xj=new H().add(`selection`,hj).add(`evaluation_filter`,pj).add(`header_visibility_ui`,yA).add(`header_positions`,vj).add(`viewport`,_j).add(`clipboard`,rj).add(`edition`,fj),Sj=new H().add(`evaluation`,Ek).add(`evaluation_chart`,jk).add(`evaluation_cf`,Mk).add(`row_size`,Fk).add(`custom_colors`,Ak).add(`data_validation_ui`,Pk),Cj=new H;Cj.add(`link`,{condition:(e,t)=>!!t.model.getters.getEvaluatedCell(e).link,execute:(e,t)=>Qa(t.model.getters.getEvaluatedCell(e).link,t),sequence:5});var wj=class{fileStore;constructor(e){this.fileStore=e}async requestImage(){let e=await this.getImageFromUser(),t=await this.fileStore.upload(e);return{path:t,size:await this.getImageOriginalSize(t),mimetype:e.type}}getImageFromUser(){return new Promise((e,t)=>{let n=document.createElement(`input`);n.setAttribute(`type`,`file`),n.setAttribute(`accept`,`image/*`),n.addEventListener(`change`,async()=>{n.files===null||n.files.length!==1?t():e(n.files[0])}),n.click()})}getImageOriginalSize(e){return new Promise((t,n)=>{let r=new Image;r.src=e,r.addEventListener(`load`,()=>{t({width:r.width,height:r.height})}),r.addEventListener(`error`,n)})}},Tj=class{focusableElement=void 0;setFocusableElement(e){this.focusableElement=e}focus(){this.focusableElement?.focus()}};let Ej=[{transform:`scale(0)`},{transform:`scale(0.8)`,offset:.33},{opacity:`0`,transform:`scale(1)`,offset:1}];U`
|
|
1481
1481
|
.o-ripple {
|
|
1482
1482
|
z-index: 1;
|
|
1483
1483
|
}
|
|
@@ -2677,4 +2677,4 @@
|
|
|
2677
2677
|
<Relationships xmlns="${Hw.Relationships}">
|
|
2678
2678
|
<Relationship ${Y(e)} />
|
|
2679
2679
|
</Relationships>
|
|
2680
|
-
`),`_rels/.rels`)}var AN=class extends Bk{corePlugins=[];featurePlugins=[];statefulUIPlugins=[];coreViewsPlugins=[];range;session;isReplayingCommand=!1;renderers=[];status=0;config;corePluginConfig;uiPluginConfig;state;selection;getters;coreGetters;uuidGenerator;handlers=[];uiHandlers=[];coreHandlers=[];constructor(e={},n={},r=[],i=new ko,a=!0){super(),v(),r=TO(e,r);let o=yO(e,a);this.state=new fM,this.uuidGenerator=i,this.config=this.setupConfig(n),this.session=this.setupSession(o.revisionId),this.coreGetters={},this.range=new uk(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.getRangeFromZone=this.range.getRangeFromZone.bind(this.range),this.getters={isReadonly:()=>this.config.mode===`readonly`||this.config.mode===`dashboard`,isDashboard:()=>this.config.mode===`dashboard`},this.uuidGenerator.setIsFastStrategy(!0),this.selection=new dM(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range),this.corePluginConfig=this.setupCorePluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(let e of yj.getAll())this.setupCorePlugin(e,o);Object.assign(this.getters,this.coreGetters),this.session.loadInitialMessages(r);for(let e of Sj.getAll()){let t=this.setupUiPlugin(e);this.coreViewsPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t),this.coreHandlers.push(t)}for(let e of xj.getAll()){let t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}for(let e of bj.getAll()){let 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(),n.snapshotRequested&&(this.session.snapshot(this.exportData()),this.garbageCollectExternalResources()),(0,t.markRaw)(this)}joinSession(){this.session.join(this.config.client)}async leaveSession(){let e=this.getters.isReadonly()?void 0:vt(()=>this.exportData());await this.session.leave(e)}setupUiPlugin(e){let t=new e(this.uiPluginConfig);for(let n of e.getters){if(!(n in t))throw Error(`Invalid getter name: ${n} for plugin ${t.constructor}`);if(n in this.getters)throw Error(`Getter "${n}" is already defined.`);this.getters[n]=t[n].bind(t)}let n=e.layers.map(e=>[t,e]);return this.renderers.push(...n),this.renderers.sort((e,t)=>e[1]-t[1]),t}setupCorePlugin(e,t){let n=new e(this.corePluginConfig);for(let t of e.getters){if(!(t in n))throw Error(`Invalid getter name: ${t} for plugin ${n.constructor}`);if(t in this.coreGetters)throw Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=n[t].bind(n)}n.import(t),this.corePlugins.push(n),this.coreHandlers.push(n),this.handlers.push(n)}onRemoteRevisionReceived({commands:e}){for(let t of e){let e=this.status;this.status=2,this.dispatchToHandlers(this.statefulUIPlugins,t),this.status=e}this.finalize()}setupSession(e){return new uA(sM({initialRevisionId:e,recordChanges:this.state.recordChanges.bind(this.state),dispatch:e=>{if(!this.checkDispatchAllowed(e).isSuccessful){this.dispatchToHandlers(this.coreHandlers,{type:`UNDO`,commands:[e]});return}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){let t=e.client||{id:this.uuidGenerator.smallUuid(),name:y(`Anonymous`).toString()},n=e.transportService||new Qj;return{...e,mode:e.mode||`normal`,custom:e.custom||{},external:this.setupExternalConfig(e.external||{}),transportService:n,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger(`notify-ui`,e),raiseBlockingErrorUI:e=>this.trigger(`raise-error-ui`,{text:e})}}setupExternalConfig(e){let t=e.loadLocales||(()=>Promise.resolve(hr));return{...e,loadLocales:t}}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,session:this.session,defaultCurrencyFormat:this.config.defaultCurrencyFormat}}checkDispatchAllowed(e){let t=ur(e)?this.checkDispatchAllowedCoreCommand(e):this.checkDispatchAllowedLocalCommand(e);return t.some(e=>e!==`Success`)?new fr(t.flat()):fr.Success}checkDispatchAllowedCoreCommand(e){let 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(let e of this.handlers)e.finalize();this.status=0}canDispatch=(e,t)=>this.checkDispatchAllowed(jN(e,t));dispatch=(e,t)=>{let n=jN(e,t),r=this.status;if(this.getters.isReadonly()&&!dr(n))return new fr(`Readonly`);if(!this.session.canApplyOptimisticUpdate())return new fr(`WaitingSessionConfirmation`);switch(r){case 0:let t=this.checkDispatchAllowed(n);if(!t.isSuccessful)return t;this.status=1;let{changes:r,commands:i}=this.state.recordChanges(()=>{ur(n)&&this.state.addCommand(n),this.dispatchToHandlers(this.handlers,n),this.finalize()});this.session.save(n,i,r),this.status=0,this.trigger(`update`);break;case 1:if(ur(n)){let e=this.checkDispatchAllowed(n);if(!e.isSuccessful)return e;this.state.addCommand(n)}this.dispatchToHandlers(this.handlers,n);break;case 3:throw Error(`Cannot dispatch commands in the finalize state`);case 2:if(ur(n))throw Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,n)}return fr.Success};dispatchFromCorePlugin=(e,t)=>{let n=jN(e,t),r=this.status;this.status=2;let i=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(i,n),this.status=r,fr.Success};dispatchToHandlers(e,t){let n=ur(t);for(let r of e)!n&&r instanceof IO||r.beforeHandle(t);for(let r of e)!n&&r instanceof IO||r.handle(t)}drawGrid(e){for(let[t,n]of this.renderers)e.ctx.save(),t.drawGrid(e,n),e.ctx.restore()}exportData(){let e=MO();for(let t of this.handlers)t instanceof IO&&t.export(e);return e.revisionId=this.session.getRevisionId()||`START_REVISION`,e=S(e),e}updateMode(e){e!==`normal`&&this.dispatch(`CANCEL_EDITION`),this.config.mode=e,this.trigger(`update`)}exportXLSX(){this.dispatch(`EVALUATE_CELLS`);let e=PO();for(let t of this.handlers)t instanceof FO&&t.exportForExcel(e);return e=S(e),xN(e)}garbageCollectExternalResources(){for(let e of this.corePlugins)e.garbageCollectExternalResources()}};function jN(e,t={}){let n=S(t);return n.type=e,n}let MN={},NN={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:26,HEADER_WIDTH:48,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:96,DEFAULT_CELL_HEIGHT:23,SCROLLBAR_WIDTH:15},PN={autofillModifiersRegistry:Ss,autofillRulesRegistry:Cs,cellMenuRegistry:db,colMenuRegistry:rS,linkMenuRegistry:sl,functionRegistry:Ny,featurePluginRegistry:bj,statefulUIPluginRegistry:xj,coreViewsPluginRegistry:Sj,corePluginRegistry:yj,rowMenuRegistry:oS,sidePanelRegistry:bC,figureRegistry:wu,chartSidePanelComponentRegistry:kS,chartComponentRegistry:vu,chartRegistry:_u,topbarMenuRegistry:cS,topbarComponentRegistry:xC,clickableCellRegistry:Cj,otRegistry:lS,inverseCommandRegistry:Au,urlRegistry:qa,cellPopoverRegistry:ul,numberFormatMenuRegistry:iS,repeatLocalCommandTransformRegistry:WA,repeatCommandTransformRegistry:$},FN={arg:K,toBoolean:F,toJsDate:I,toNumber:N,toString:P,toXC:O,toZone:ea,toUnboundedZone:Qi,toCartesian:rn,numberToLetters:D,lettersToNumber:en,UuidGenerator:ko,formatValue:z,createCurrencyFormat:Ei,computeTextWidth:_o,createEmptyWorkbookData:MO,createEmptySheet:jO,createEmptyExcelSheet:NO,getDefaultChartJsRuntime:Dl,chartFontColor:Jo,ChartColors:qo,EvaluationError:b,CellErrorLevel:te,getFillingMode:Ml,rgbaToHex:Kt,colorToRGBA:qt,positionToZone:V,isDefined:T,isMatrix:j,lazy:vt,genericRepeat:GA,createAction:Mo,createActions:Ao,transformRangeData:Po,deepEquals:E,isNumber:Yn,isDateTime:_n},IN={isMarkdownLink:at,parseMarkdownLink:ct,markdownLink:st,openLink:Qa,urlRepresentation:Za},LN={ChartPanel:AS,ChartFigure:bu,ChartJsComponent:Fo,Grid:Lw,GridOverlay:bw,ScorecardChart:xs,LineConfigPanel:TS,LineBarPieDesignPanel:xS,BarConfigPanel:gS,LineBarPieConfigPanel:hS,GaugeChartConfigPanel:CS,GaugeChartDesignPanel:wS,ScorecardChartConfigPanel:DS,ScorecardChartDesignPanel:OS,FigureComponent:SC,Menu:pc,SelectionInput:pS},RN={useDragAndDropListItems:FS};function zN(e,t){return Ny.add(e,t),{addFunction:(e,t)=>zN(e,t)}}let BN={DEFAULT_LOCALE:A};e.AbstractChart=Io,e.CommandResult=mr,e.CorePlugin=IO,e.DispatchResult=fr,e.EvaluationError=b,e.Model=AN,e.Registry=H,e.Revision=cA,e.SPREADSHEET_DIMENSIONS=NN,e.Spreadsheet=Zj,e.UIPlugin=Q,e.__info__=MN,e.addFunction=zN,e.astToFormula=ET,e.compile=NT,e.compileTokens=PT,e.components=LN,e.constants=BN,e.convertAstNodes=ST,e.coreTypes=lr,e.findCellInNewZone=Ta,e.functionCache=MT,e.helpers=FN,e.hooks=RN,e.invalidateCFEvaluationCommands=sr,e.invalidateDependenciesCommands=or,e.invalidateEvaluationCommands=ar,e.iterateAstNodes=CT,e.links=IN,e.load=yO,e.parse=bT,e.parseTokens=xT,e.readonlyAllowedCommands=cr,e.registries=PN,e.setDefaultSheetViewSize=Ke,e.setTranslationMethod=_,e.tokenize=vc,MN.version=`17.0.106`,MN.date=`2026-08-29T09:12:26.343Z`,MN.hash=`c877406`})(this.o_spreadsheet=this.o_spreadsheet||{},owl);
|
|
2680
|
+
`),`_rels/.rels`)}var AN=class extends Bk{corePlugins=[];featurePlugins=[];statefulUIPlugins=[];coreViewsPlugins=[];range;session;isReplayingCommand=!1;renderers=[];status=0;config;corePluginConfig;uiPluginConfig;state;selection;getters;coreGetters;uuidGenerator;handlers=[];uiHandlers=[];coreHandlers=[];constructor(e={},n={},r=[],i=new ko,a=!0){super(),v(),r=TO(e,r);let o=yO(e,a);this.state=new fM,this.uuidGenerator=i,this.config=this.setupConfig(n),this.session=this.setupSession(o.revisionId),this.coreGetters={},this.range=new uk(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.getRangeFromZone=this.range.getRangeFromZone.bind(this.range),this.getters={isReadonly:()=>this.config.mode===`readonly`||this.config.mode===`dashboard`,isDashboard:()=>this.config.mode===`dashboard`},this.uuidGenerator.setIsFastStrategy(!0),this.selection=new dM(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range),this.corePluginConfig=this.setupCorePluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(let e of yj.getAll())this.setupCorePlugin(e,o);Object.assign(this.getters,this.coreGetters),this.session.loadInitialMessages(r);for(let e of Sj.getAll()){let t=this.setupUiPlugin(e);this.coreViewsPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t),this.coreHandlers.push(t)}for(let e of xj.getAll()){let t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}for(let e of bj.getAll()){let 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(),n.snapshotRequested&&(this.session.snapshot(this.exportData()),this.garbageCollectExternalResources()),(0,t.markRaw)(this)}joinSession(){this.session.join(this.config.client)}async leaveSession(){let e=this.getters.isReadonly()?void 0:vt(()=>this.exportData());await this.session.leave(e)}setupUiPlugin(e){let t=new e(this.uiPluginConfig);for(let n of e.getters){if(!(n in t))throw Error(`Invalid getter name: ${n} for plugin ${t.constructor}`);if(n in this.getters)throw Error(`Getter "${n}" is already defined.`);this.getters[n]=t[n].bind(t)}let n=e.layers.map(e=>[t,e]);return this.renderers.push(...n),this.renderers.sort((e,t)=>e[1]-t[1]),t}setupCorePlugin(e,t){let n=new e(this.corePluginConfig);for(let t of e.getters){if(!(t in n))throw Error(`Invalid getter name: ${t} for plugin ${n.constructor}`);if(t in this.coreGetters)throw Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=n[t].bind(n)}n.import(t),this.corePlugins.push(n),this.coreHandlers.push(n),this.handlers.push(n)}onRemoteRevisionReceived({commands:e}){for(let t of e){let e=this.status;this.status=2,this.dispatchToHandlers(this.statefulUIPlugins,t),this.status=e}this.finalize()}setupSession(e){return new uA(sM({initialRevisionId:e,recordChanges:this.state.recordChanges.bind(this.state),dispatch:e=>{if(!this.checkDispatchAllowed(e).isSuccessful){this.dispatchToHandlers(this.coreHandlers,{type:`UNDO`,commands:[e]});return}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){let t=e.client||{id:this.uuidGenerator.smallUuid(),name:y(`Anonymous`).toString()},n=e.transportService||new Qj;return{...e,mode:e.mode||`normal`,custom:e.custom||{},external:this.setupExternalConfig(e.external||{}),transportService:n,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger(`notify-ui`,e),raiseBlockingErrorUI:e=>this.trigger(`raise-error-ui`,{text:e})}}setupExternalConfig(e){let t=e.loadLocales||(()=>Promise.resolve(hr));return{...e,loadLocales:t}}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,session:this.session,defaultCurrencyFormat:this.config.defaultCurrencyFormat}}checkDispatchAllowed(e){let t=ur(e)?this.checkDispatchAllowedCoreCommand(e):this.checkDispatchAllowedLocalCommand(e);return t.some(e=>e!==`Success`)?new fr(t.flat()):fr.Success}checkDispatchAllowedCoreCommand(e){let 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(let e of this.handlers)e.finalize();this.status=0}canDispatch=(e,t)=>this.checkDispatchAllowed(jN(e,t));dispatch=(e,t)=>{let n=jN(e,t),r=this.status;if(this.getters.isReadonly()&&!dr(n))return new fr(`Readonly`);if(!this.session.canApplyOptimisticUpdate())return new fr(`WaitingSessionConfirmation`);switch(r){case 0:let t=this.checkDispatchAllowed(n);if(!t.isSuccessful)return t;this.status=1;let{changes:r,commands:i}=this.state.recordChanges(()=>{ur(n)&&this.state.addCommand(n),this.dispatchToHandlers(this.handlers,n),this.finalize()});this.session.save(n,i,r),this.status=0,this.trigger(`update`);break;case 1:if(ur(n)){let e=this.checkDispatchAllowed(n);if(!e.isSuccessful)return e;this.state.addCommand(n)}this.dispatchToHandlers(this.handlers,n);break;case 3:throw Error(`Cannot dispatch commands in the finalize state`);case 2:if(ur(n))throw Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,n)}return fr.Success};dispatchFromCorePlugin=(e,t)=>{let n=jN(e,t),r=this.status;this.status=2;let i=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(i,n),this.status=r,fr.Success};dispatchToHandlers(e,t){let n=ur(t);for(let r of e)!n&&r instanceof IO||r.beforeHandle(t);for(let r of e)!n&&r instanceof IO||r.handle(t)}drawGrid(e){for(let[t,n]of this.renderers)e.ctx.save(),t.drawGrid(e,n),e.ctx.restore()}exportData(){let e=MO();for(let t of this.handlers)t instanceof IO&&t.export(e);return e.revisionId=this.session.getRevisionId()||`START_REVISION`,e=S(e),e}updateMode(e){e!==`normal`&&this.dispatch(`CANCEL_EDITION`),this.config.mode=e,this.trigger(`update`)}exportXLSX(){this.dispatch(`EVALUATE_CELLS`);let e=PO();for(let t of this.handlers)t instanceof FO&&t.exportForExcel(e);return e=S(e),xN(e)}garbageCollectExternalResources(){for(let e of this.corePlugins)e.garbageCollectExternalResources()}};function jN(e,t={}){let n=S(t);return n.type=e,n}let MN={},NN={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:26,HEADER_WIDTH:48,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:96,DEFAULT_CELL_HEIGHT:23,SCROLLBAR_WIDTH:15},PN={autofillModifiersRegistry:Ss,autofillRulesRegistry:Cs,cellMenuRegistry:db,colMenuRegistry:rS,linkMenuRegistry:sl,functionRegistry:Ny,featurePluginRegistry:bj,statefulUIPluginRegistry:xj,coreViewsPluginRegistry:Sj,corePluginRegistry:yj,rowMenuRegistry:oS,sidePanelRegistry:bC,figureRegistry:wu,chartSidePanelComponentRegistry:kS,chartComponentRegistry:vu,chartRegistry:_u,topbarMenuRegistry:cS,topbarComponentRegistry:xC,clickableCellRegistry:Cj,otRegistry:lS,inverseCommandRegistry:Au,urlRegistry:qa,cellPopoverRegistry:ul,numberFormatMenuRegistry:iS,repeatLocalCommandTransformRegistry:WA,repeatCommandTransformRegistry:$},FN={arg:K,toBoolean:F,toJsDate:I,toNumber:N,toString:P,toXC:O,toZone:ea,toUnboundedZone:Qi,toCartesian:rn,numberToLetters:D,lettersToNumber:en,UuidGenerator:ko,formatValue:z,createCurrencyFormat:Ei,computeTextWidth:_o,createEmptyWorkbookData:MO,createEmptySheet:jO,createEmptyExcelSheet:NO,getDefaultChartJsRuntime:Dl,chartFontColor:Jo,ChartColors:qo,EvaluationError:b,CellErrorLevel:te,getFillingMode:Ml,rgbaToHex:Kt,colorToRGBA:qt,positionToZone:V,isDefined:T,isMatrix:j,lazy:vt,genericRepeat:GA,createAction:Mo,createActions:Ao,transformRangeData:Po,deepEquals:E,isNumber:Yn,isDateTime:_n},IN={isMarkdownLink:at,parseMarkdownLink:ct,markdownLink:st,openLink:Qa,urlRepresentation:Za},LN={ChartPanel:AS,ChartFigure:bu,ChartJsComponent:Fo,Grid:Lw,GridOverlay:bw,ScorecardChart:xs,LineConfigPanel:TS,LineBarPieDesignPanel:xS,BarConfigPanel:gS,LineBarPieConfigPanel:hS,GaugeChartConfigPanel:CS,GaugeChartDesignPanel:wS,ScorecardChartConfigPanel:DS,ScorecardChartDesignPanel:OS,FigureComponent:SC,Menu:pc,SelectionInput:pS},RN={useDragAndDropListItems:FS};function zN(e,t){return Ny.add(e,t),{addFunction:(e,t)=>zN(e,t)}}let BN={DEFAULT_LOCALE:A};e.AbstractChart=Io,e.CommandResult=mr,e.CorePlugin=IO,e.DispatchResult=fr,e.EvaluationError=b,e.Model=AN,e.Registry=H,e.Revision=cA,e.SPREADSHEET_DIMENSIONS=NN,e.Spreadsheet=Zj,e.UIPlugin=Q,e.__info__=MN,e.addFunction=zN,e.astToFormula=ET,e.compile=NT,e.compileTokens=PT,e.components=LN,e.constants=BN,e.convertAstNodes=ST,e.coreTypes=lr,e.findCellInNewZone=Ta,e.functionCache=MT,e.helpers=FN,e.hooks=RN,e.invalidateCFEvaluationCommands=sr,e.invalidateDependenciesCommands=or,e.invalidateEvaluationCommands=ar,e.iterateAstNodes=CT,e.links=IN,e.load=yO,e.parse=bT,e.parseTokens=xT,e.readonlyAllowedCommands=cr,e.registries=PN,e.setDefaultSheetViewSize=Ke,e.setTranslationMethod=_,e.tokenize=vc,MN.version=`17.0.108`,MN.date=`2026-09-10T05:35:45.123Z`,MN.hash=`b2580c5`})(this.o_spreadsheet=this.o_spreadsheet||{},owl);
|
package/dist/o_spreadsheet.xml
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
This file is generated by o-spreadsheet build tools. Do not edit it.
|
|
3
3
|
@see https://github.com/odoo/o-spreadsheet
|
|
4
|
-
@version 17.0.
|
|
5
|
-
@date 2026-
|
|
6
|
-
@hash
|
|
4
|
+
@version 17.0.108
|
|
5
|
+
@date 2026-09-10T05:35:45.552Z
|
|
6
|
+
@hash b2580c5
|
|
7
7
|
-->
|
|
8
8
|
<odoo>
|
|
9
9
|
<t t-name="o-spreadsheet-ActionButton">
|